feat(tools): add contractaudit for standing contract-conformance reporting
Reachability (tools/reachaudit, epic archie-core-06ag) answers "is this code in a shipped binary?". It cannot answer the complementary question: "does every declared contract surface have a consumer, or a declaration that it has none?". ratelimit was in the binary closure and called by nothing, which reachability could not see. tools/contractaudit classifies each subject of each declared surface as CONSUMED, DECLARED-UNCONSUMED, UNDECLARED-UNCONSUMED, or STALE-DECLARATION, and only the last two are findings. The declaration allowlist must match reality exactly: a missing entry fails and so does an entry that outlived its subject, because a stale allowlist is how a gate quietly stops checking anything. Surfaces: the two gRPC services, whose consumption is derived by scanning adapter bodies for calls through the generated client, and the dashboard HTTP API, matched between the registerXRoutes call sites and the path literals the bundled client calls. Findings on the current tree, all deliberate and now declared: ListCaptures and ListUndispatchedCaptures are superseded by their streaming variants -- staterpc's client calls StreamCaptures -- so no production client reaches the unary RPCs. Three bugs this tool found in itself, each recorded because each is the class of error that makes a conformance check worse than none: - Joining RPCs to adapter methods by name silently reported live RPCs as unconsumed, because adapters do not map one-to-one: StoreClient.Get calls GetSession, List calls ListSessions. - Reflecting over the client value rather than the pointer reported zero methods, hence the whole surface unconsumed. - Treating the asset mount and the health probes as dashboard API routes reported four healthy routes as undeclared; they have different consumers and are out of scope for this surface. The consumer extractor fails loudly on a call shape it cannot parse rather than under-reporting, and every check is negative-tested: a route, an RPC, and a removed consumer are each injected, confirmed to fail for the right reason, and reverted. The declaration staleness rule is tested too. Advisory when run directly; task check runs it -strict. See docs/prds/contract-conformance-audit.md.
This commit is contained in:
11 files changed
+1288
-1
No files matched your search
+23
-1
@@ -221,7 +221,7 @@ tasks:
|
||||
- go -C tools test -mod=readonly ./... -count=1
|
||||
|
||||
check:
|
||||
desc: "Full quality gate: fmt, go fix, proto, vet, lint, build, test, tools tests, ui tests"
|
||||
desc: "Full quality gate: fmt, go fix, proto, vet, lint, build, test, tools tests, ui tests, contract"
|
||||
cmds:
|
||||
- task: fmt
|
||||
- go fix ./...
|
||||
@@ -238,6 +238,28 @@ tasks:
|
||||
# The dashboard's suite runs here too. Left out of the gate it rots
|
||||
# silently: nothing else executes it, so a broken DOM primitive ships.
|
||||
- task: test:ui
|
||||
# Contract conformance. Static and dependency-light, so it belongs with
|
||||
# the per-edit checks rather than next to the end-to-end suite. It runs
|
||||
# -strict here: every unconsumed surface must be declared in
|
||||
# docs/contract-declarations.json with a reason and a tracker, and a
|
||||
# stale declaration fails the same way an undeclared one does.
|
||||
- task: contract
|
||||
|
||||
contract:
|
||||
desc: "Report contract conformance: declared surfaces, their consumers, and the drift between them"
|
||||
summary: |
|
||||
Walks every declared contract surface -- the two gRPC services, the
|
||||
dashboard HTTP API -- and classifies each subject as consumed,
|
||||
declared-unconsumed, undeclared, or a stale declaration.
|
||||
|
||||
Advisory when run directly; `task check` runs it with -strict so an
|
||||
undeclared or stale entry fails the gate. Declare an intentionally
|
||||
unconsumed surface in docs/contract-declarations.json with a reason
|
||||
that states the consequence and the tracker that owns the work.
|
||||
|
||||
See docs/prds/contract-conformance-audit.md.
|
||||
cmds:
|
||||
- go -C tools run ./contractaudit --repo-root .. --strict
|
||||
|
||||
release:preview:
|
||||
desc: "Show the release notes that would be generated (VERSION=1.2.0, or GATEWAY=/RUNTIME= to version the two components separately)"
|
||||
|
||||
Reference in new issue
Block a user