-
Notifications
You must be signed in to change notification settings - Fork 9
HYPERFLEET-930 - docs: add CLAUDE.md and AGENTS.md #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kuudori
wants to merge
4
commits into
main
Choose a base branch
from
HYPERFLEET-930
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f2e373b
HYPERFLEET-930 - docs: add CLAUDE.md and AGENTS.md
kuudori d748207
HYPERFLEET-930 - chore: add pre-commit hooks and golangci-lint config
kuudori 869f067
HYPERFLEET-930 - fix: resolve all golangci-lint issues
kuudori 3fe50fc
HYPERFLEET-930 - fix: skip parallelism > 1 for Google Pub/Sub tests
kuudori File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # HyperFleet Broker - golangci-lint configuration | ||
| # Aligned with: https://github.com/openshift-hyperfleet/architecture/blob/main/hyperfleet/standards/golangci.yml | ||
|
|
||
| version: "2" | ||
|
|
||
| run: | ||
| timeout: 5m | ||
| tests: true | ||
| modules-download-mode: readonly | ||
|
|
||
| linters: | ||
| enable: | ||
| # Code Quality | ||
| - errcheck | ||
| - govet | ||
| - staticcheck | ||
| - ineffassign | ||
| - unused | ||
| - unconvert | ||
| - unparam | ||
| - goconst | ||
| - exhaustive | ||
|
|
||
| # Code Style | ||
| - misspell | ||
| - lll | ||
| - revive | ||
| - gocritic | ||
|
|
||
| # Security | ||
| - gosec | ||
| settings: | ||
| errcheck: | ||
| check-type-assertions: true | ||
| check-blank: true | ||
| govet: | ||
| enable-all: true | ||
| goconst: | ||
| min-len: 3 | ||
| min-occurrences: 3 | ||
| misspell: | ||
| locale: US | ||
| lll: | ||
| line-length: 120 | ||
| revive: | ||
| rules: | ||
| - name: exported | ||
| severity: warning | ||
| disabled: true | ||
| - name: unexported-return | ||
| severity: warning | ||
| disabled: false | ||
| - name: var-naming | ||
| severity: warning | ||
| disabled: false | ||
| unparam: | ||
| check-exported: false | ||
| exhaustive: | ||
| default-signifies-exhaustive: true | ||
| exclusions: | ||
| generated: lax | ||
| rules: | ||
| # Relaxed rules for test files | ||
| - linters: | ||
| - gosec | ||
| - errcheck | ||
| - unparam | ||
| path: _test\.go | ||
| paths: | ||
| - third_party(/|$) | ||
| - builtin(/|$) | ||
| - example(/|$) | ||
|
|
||
| issues: | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| new: false | ||
|
|
||
| formatters: | ||
| enable: | ||
| - gofmt | ||
| - goimports | ||
| - gci | ||
| - golines | ||
| settings: | ||
| gofmt: | ||
| simplify: true | ||
| golines: | ||
| max-len: 120 | ||
| # Local addition on top of org standard: repo-specific import grouping | ||
| gci: | ||
| custom-order: true | ||
| sections: | ||
| - standard | ||
| - default | ||
| - prefix(github.com/openshift-hyperfleet) | ||
| - prefix(github.com/openshift-hyperfleet/hyperfleet-broker) | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party(/|$) | ||
| - builtin(/|$) | ||
| - example(/|$) | ||
|
|
||
| output: | ||
| formats: | ||
| text: | ||
| path: stdout | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| default_install_hook_types: [pre-commit, commit-msg] | ||
|
|
||
| repos: | ||
| - repo: https://github.com/openshift-hyperfleet/hyperfleet-hooks | ||
| rev: v0.2.1 | ||
| hooks: | ||
| - id: hyperfleet-commitlint | ||
| stages: [commit-msg] | ||
| - id: hyperfleet-gofmt | ||
| - id: hyperfleet-golangci-lint | ||
| - id: hyperfleet-go-vet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # AGENTS.md — hyperfleet-broker | ||
|
|
||
| Go library: unified pub/sub API over RabbitMQ and Google Pub/Sub with CloudEvents. Not a binary — consumed as a dependency by other HyperFleet services. Wraps [Watermill](https://github.com/ThreeDotsLabs/watermill) internally; public API never exposes Watermill types. | ||
|
|
||
| ## Verification | ||
|
|
||
| | Target | What it runs | | ||
| |--------|-------------| | ||
| | `make lint` | golangci-lint v2.7.0 (bingo-managed, config in `.golangci.yml`) | | ||
| | `make fmt` | `golangci-lint fmt` — gofmt + goimports + gci (4-group imports) + golines (120 char wrap) | | ||
| | `make test` | Unit tests: `./broker/... ./pkg/...` (timeout 10m) | | ||
| | `make test-integration` | Integration tests: `./test/integration/...` (sequential `-p 1`, timeout 10m) | | ||
| | `make test-all` | Both unit + integration | | ||
| | `make install-hooks` | Install pre-commit hooks (`pre-commit install --install-hooks`) | | ||
|
|
||
| ### Pre-push order | ||
|
|
||
| 1. `make fmt` → 2. `make lint` → 3. `make test` → 4. `make test-integration` (if touching broker/ or test/) | ||
|
|
||
| ## Source of truth | ||
|
|
||
| | Topic | Location | | ||
| |-------|----------| | ||
| | Public API | `broker/broker.go`, `broker/publisher.go`, `broker/subscriber.go`, `broker/metrics.go`, `broker/errors.go` | | ||
| | Logger interface | `pkg/logger/logger.go` | | ||
| | Config structure + validation | `broker/config.go`, `broker/rabbitmq.go`, `broker/googlepubsub.go` | | ||
| | Config fields reference | `example/broker.example.yaml` | | ||
| | Linter config | `.golangci.yml` | | ||
| | Integration test helpers | `test/integration/common/common.go` | | ||
| | Mock logger (unit tests) | `pkg/logger/mock.go` — use `NewMockLogger()` | | ||
| | Container setup helpers | `test/integration/rabbitmq/setup.go`, `test/integration/googlepubsub/setup.go` | | ||
| | Leak & perf integration tests | `test/integration/broker_leak_test.go`, `test/integration/broker_perf_test.go` | | ||
| | Examples (separate go.mod) | `example/go.mod`, `example/cmd/publisher/main.go`, `example/cmd/subscriber/main.go` | | ||
| | Docker Compose examples | `example/rabbitmq/`, `example/googlepubsub/` | | ||
| | Comprehensive user docs | `README.md` | | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## Architecture context | ||
|
|
||
| Only patterns an agent cannot infer from reading the code: | ||
|
|
||
| - **Subscription ID** controls messaging pattern: same ID = shared/load-balanced queue, different IDs = fanout. RabbitMQ queue name = `{topic}-{subscriptionID}` (default) or `{queue}-{subscriptionID}` when `broker.rabbitmq.queue` is set. Google Pub/Sub subscription name = `{subscriptionID}`. | ||
| - **Config precedence**: programmatic map > env vars > broker.yaml file > defaults. `BROKER_CONFIG_FILE` env var overrides file path. Env vars use underscore for dots (e.g., `BROKER_RABBITMQ_URL`). | ||
| - **Health check asymmetry**: RabbitMQ = in-memory connection state check (no network call). Google Pub/Sub = `GetTopic` API probe with 3s timeout on a non-existent topic; `NotFound` = healthy. | ||
| - **Config debugging**: `log_config: true` in broker.yaml (or `LOG_CONFIG=true`) logs full config as JSON at creation time. Passwords masked. | ||
| - **DLQ topic naming**: DLQ topic is always `{subscriptionID}-dlq` (hardcoded at `googlepubsub.go`). Not configurable. | ||
|
|
||
| ## Boundaries | ||
|
|
||
| ### DO | ||
|
|
||
| - Keep Watermill as internal implementation detail — never expose Watermill types in public API | ||
| - Write integration tests for new broker-level behavior using `test/integration/common/` helpers | ||
|
|
||
| ### DON'T | ||
|
|
||
| - Don't add a third broker backend without updating `validateConfig`, both constructors, health checks, and integration test infrastructure | ||
|
|
||
| ## Gotchas | ||
|
|
||
| - **Google Pub/Sub health check requires `pubsub.topics.get`** — NOT included in `roles/pubsub.publisher`. Grant `roles/pubsub.viewer` or custom role. | ||
| - **`subscriber.parallelism` > 1 only needed for RabbitMQ**. Google Pub/Sub handles parallelism internally via `num_goroutines` and `max_outstanding_messages`. | ||
| - **Integration tests run sequentially** (`-p 1`) because CI has 1 CPU. Parallel execution causes timeouts. | ||
| - **`example/` has its own `go.mod`** — `make test` from root does not test examples. Update `example/go.mod` when changing public API. | ||
| - **`error_test.go` "missing rabbitmq url" test is false-passing**: sets `expectError: false` but `validateRabbitMQConfig` rejects empty URLs. Test passes because else branch only asserts when `err == nil`. Do not rely on it as documenting intentional behavior. | ||
| - **Google Pub/Sub subscriber auto-creates DLQ topic** (`{subscriptionID}-dlq`) when `create_topic_if_missing` is true — see `googlepubsub.go:188`. | ||
| - **Integration tests**: call `common.SetupTestEnvironment()` first in `TestMain`, share one container per package. Topic/subscription name uniqueness is handled internally by `Run*` helper functions in `common/common.go`. Pattern at `test/integration/rabbitmq/rabbitmq_test.go:28`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @AGENTS.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.