You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+25-92Lines changed: 25 additions & 92 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,16 @@
1
-
# CLAUDE.md
1
+
# HyperFleet Sentinel
2
2
3
-
## Project Identity
3
+
Kubernetes resource watcher — polls HyperFleet API for cluster/nodepool updates, makes orchestration decisions via CEL-based decision logic, publishes CloudEvents to message brokers. Stateless, horizontally scalable via label-based sharding, delegates all state persistence to API.
4
4
5
-
HyperFleet Sentinel is a **Kubernetes resource watcher** that polls the HyperFleet API for cluster/nodepool updates, makes orchestration decisions via CEL-based decision logic, and publishes CloudEvents to message brokers. Stateless, horizontally scalable via label-based sharding, delegates all state persistence to the API.
5
+
Go 1.25 · Broker abstraction (RabbitMQ, GCP Pub/Sub, Stub) · Helm chart in `charts/`
-**API Client**: Generated from [hyperfleet-api-spec](https://github.com/openshift-hyperfleet/hyperfleet-api-spec) — see [openapi/README.md](openapi/README.md)
10
-
-**Deployment**: Helm chart in `charts/`
11
-
12
-
Sentinel is one component in the HyperFleet control plane:
13
-
-**API** — persists cluster/nodepool state (source of truth)
14
-
-**Sentinel** — watches API, decides when resources need reconciliation, publishes events
15
-
-**Adapters** — consume events, execute provisioning/deprovisioning, report back to API
16
-
-**Broker** (RabbitMQ or Pub/Sub) — decouples Sentinel from adapters
17
-
18
-
## Critical First Steps
19
-
20
-
**Generated OpenAPI client is NOT committed to git.** Before any build, test, or development task:
21
-
22
-
```bash
23
-
make generate # Extracts OpenAPI spec from hyperfleet-api-spec module and generates Go client
24
-
```
25
-
26
-
Setup sequence for a fresh clone:
27
-
1.`make generate` — generate OpenAPI client in `pkg/api/openapi/`
28
-
2.`make download` — fetch Go dependencies
29
-
3.`make build` — build `bin/sentinel` binary
30
-
4.`make test` — verify unit tests pass
7
+
**Generated OpenAPI client is NOT committed to git.** Run `make generate` before any build, test, or development task.
31
8
32
9
## Verification
33
10
34
11
| Command | What it does |
35
12
|---|---|
13
+
|`make generate`| Extract OpenAPI spec from hyperfleet-api-spec module, generate Go client |
36
14
|`make verify`| go vet + format check (fast) |
37
15
|`make lint`| golangci-lint (comprehensive) |
38
16
|`make test`| all tests (`./...`), writes `coverage.out` profile |
@@ -44,14 +22,18 @@ Setup sequence for a fresh clone:
44
22
45
23
Quick feedback: `make verify && make test-unit`. Full pre-push: `make test-all`.
46
24
47
-
**PR pre-flight order:**
48
-
1.`make generate`
49
-
2.`make fmt`
50
-
3.`make lint`
51
-
4.`make test-unit`
52
-
5.`make test-integration` — if broker/API changes
53
-
6.`make test-helm` — if chart changes
54
-
7. Update CHANGELOG.md if the change is user-visible
25
+
Setup sequence for a fresh clone:
26
+
1.`make generate` — generate OpenAPI client in `pkg/api/openapi/`
27
+
2.`make download` — fetch Go dependencies
28
+
3.`make install-hooks` — install pre-commit hooks
29
+
4.`make build` — build `bin/sentinel` binary
30
+
5.`make test` — verify unit tests pass
31
+
32
+
## CLI
33
+
34
+
Subcommands: `sentinel serve`, `sentinel config-dump`, `sentinel version`. Config path via `--config`. All flags have env var equivalents (`HYPERFLEET_*` prefix) — run `sentinel serve --help`.
@@ -72,7 +54,7 @@ Quick feedback: `make verify && make test-unit`. Full pre-push: `make test-all`.
72
54
73
55
## Architecture Context
74
56
75
-
Sentinel's job: **decide when**, not **execute how**. It can be killed and restarted at any time without data loss — this is what makes label-based sharding safe. The `message_decision` config uses CEL expressions to decide when to publish — see `DefaultMessageDecision()` in `internal/config/config.go` for default expressions.
57
+
Sentinel's job: **decide when**, not **execute how**. Can be killed and restarted at any time without data loss — this is what makes label-based sharding safe. `message_decision` config uses CEL expressions to decide when to publish — see `DefaultMessageDecision()` in `internal/config/config.go`.
76
58
77
59
### Key Internal Patterns
78
60
-**Config validation fails fast** — `Validate()` returns error at startup, `LoadConfig()` propagates to main which exits non-zero
@@ -81,79 +63,30 @@ Sentinel's job: **decide when**, not **execute how**. It can be killed and resta
81
63
82
64
## Code Conventions
83
65
84
-
### Commit Messages
85
-
Format: `HYPERFLEET-### - type: description`
86
-
87
-
Example:
88
-
```
89
-
HYPERFLEET-427 - feat: add standard metrics labels
90
-
91
-
Adds resource_type and resource_selector labels to all
92
-
Prometheus metrics for consistent querying.
93
-
94
-
Co-Authored-By: Claude <noreply@anthropic.com>
95
-
```
96
-
Co-Authored-By trailer required on all Claude-assisted commits.
97
-
98
-
### Configuration
99
-
- Config struct in `internal/config/config.go` — YAML struct tags, validation via `Validate()`
100
-
- All durations use `time.Duration` with YAML `duration` format (e.g., `5s`, `30m`)
- Pre-commit hooks: run `make install-hooks` to install — enforces commit message format (`hyperfleet-commitlint`), Go formatting, linting, and vet
80
+
## Boundaries
148
81
149
-
## Project Boundaries
82
+
### DON'T
150
83
151
-
**DO NOT**:
152
84
- Add business logic to Sentinel — orchestration decisions only, execution belongs in adapters
153
85
- Store state in Sentinel — it is stateless, API is source of truth
154
86
- Hardcode the resource polling interval — always use `poll_interval` from config for the main sentinel loop; adding a second resource polling loop bypasses the single-ticker backpressure model
155
87
156
-
**DO**:
88
+
### DO
89
+
157
90
- Update `hyperfleet-api-spec` version in `go.mod` and run `make generate` when API spec changes
158
91
- New exported functions require unit tests; new broker/API interactions require integration tests
159
92
- Add metrics when adding observable behavior — see [docs/metrics.md](docs/metrics.md) for conventions
0 commit comments