ci(bruno): check the collection against the OpenAPI contracts
Summary
Guardrail 15 asks that a change to an operation in api/openapi comes with the same change in api/bruno, but nothing checked it. docs/dev/bruno.md said so directly: "Nothing checks the collection against the contracts."
This adds scripts/bruno-openapi-sync, a small Go checker. It matches each Bruno request to an OpenAPI operation by method and path, and fails when:
- an operation has no request and is not listed in
scripts/bruno-openapi-sync/uncovered.txt, - a request matches no operation (the API was renamed or removed under it), or
- an
uncovered.txtentry gained a request or left the contracts, so the list only shrinks.
It runs as a pre-commit hook and as the lint:bruno-openapi-sync CI job, scoped to changes under api/openapi, api/bruno, and the tool itself. Its unit tests run in go_unittests. uncovered.txt starts with the 14 operations that have no request today, matching the gap docs/dev/bruno.md already describes (mostly the artifact reads).
Guardrail 15 now points at the check rather than restating the rule. It keeps its number, because guardrails 16 to 26 are cited by number across the repo.
The check covers which operations exist, not request bodies, headers, or whether a request works.
Size
690 added lines, over the 500 in guardrail 18. Splitting would not help: the tool, its tests, and the wiring only work together, and a tool without its CI job enforces nothing.
| Group | Lines |
|---|---|
Checker (main.go) |
424 |
Tests (main_test.go) |
198 |
Baseline list (uncovered.txt) |
24 |
| CI job and pre-commit hook | 27 |
Docs (docs/dev/bruno.md, AGENTS.md) |
17 added, 8 removed |
Governing ADRs
ADR 009 (API design) makes the OpenAPI specifications the record of request and response payloads. The checker only reads them, so it conforms. No other mirrored ADR covers developer tooling. The two internal ADRs were not checked.
Testing
go test ./scripts/bruno-openapi-sync/covers: an operation with no request, a request matching no operation, a method mismatch, a stale or unknownuncovered.txtentry,/npm/tagspreferring the specific operation over/{format}/tags, a renamed path parameter, and malformed input.go run ./scripts/bruno-openapi-syncon this branch exits 0: all 60 requests match an operation.- Negative check: deleting
get-repository.brufrom a copy of the collection makes the check reportgetRepository has no request in the collection. golangci-lint, comment caps, markdownlint, vale, and yamllint are clean.