Skip to content

chore(contracts): CHAOS-5732 Mirror the cut-kind-census coverage detail code - #77

Merged
chrisgeo merged 4 commits into
mainfrom
chore/5732-kind-census-mirror
Sep 14, 2026
Merged

chrisgeo merged 4 commits into
mainfrom
chore/5732-kind-census-mirror

Conversation

@chrisgeo

@chrisgeo chrisgeo commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Ticket: CHAOS-5732

TEST-EVIDENCE

What this change accomplishes, and for whom. Mirrors acr's kind_census_truncated coverage-detail code (a discovered cohort's kind-scoped census was cut at its own row bound) into this workbench: the pinned contract types, the CoveragePanel rendering, and the wire-shape validation tests — so a caller of this workbench can see which kind's census was cut, the declared floor, and how many members were served, the moment acr starts emitting the code.

EXECUTE-THE-CLAIM.

  1. Regeneration is CI-checked by exact diff (sync-acr-contracts.mjs's own doc comment: "Regeneration is CI-checked by EXACT DIFF"). Ran pnpm run acr:contracts:generate against a real checkout of the acr merge commit (final pin, acr sha a57b599b88a28c170444e786d701af980911db9d — acr main's own squash of the kind-census coverage detail work, closing kind to the same closed vocabulary Go enforces; clean and parked exactly on that commit — the script's readPinnedSourceFiles verifies both), then pnpm run acr:contracts:check with no --source (reads the committed copies back and verifies each against the manifest digest, and regenerates the derived TypeScript types from THOSE copies) — ACR contracts are current., zero drift. The only wire-shape change this pin carries for this repo is kind closing from an unenumerated string to the 15-member subject-kind union (verified in the generated type, tsc --noEmit clean, no test needed a fixture update). Every re-pin since the first (7ae3719f72c9e3eaa57b599b, the last being the squash merge) is a pointer move only: contracts/ and internal/mcp/schemas/ stayed byte-identical across all three acr shas, so only generated-file banners and the manifest source_commit moved each time.
  2. pnpm exec tsc --noEmit — clean.
  3. pnpm run build (next build, Turbopack) — compiles, typechecks, prerenders all four routes, zero errors.
  4. pnpm run lint (eslint .) — clean.
  5. pnpm run format:check (prettier --check .) — clean (ran prettier --write once on the two touched test files + the component, to match this repo's own style; verified no test broke as a result).
  6. Real pnpm install (not a symlinked/inherited node_modules) before any of the above, per this repo's own pre-TELL rule.

ENUMERATE-THE-SURFACE.

Surface File Change
Pin scripts/sync-acr-contracts.mjs SOURCE_COMMIT bump note + final value, the acr squash-merge sha
Vendored schema src/contracts/schemas/context_fabric_common.v1.schema.json enum member + 3 properties, byte-identical to acr's own file at the pin (generator copies verbatim; not hand-edited)
Generated types src/contracts/generated/investigation-result.ts (+ banner-only sha bumps in error.ts/investigation-request.ts) CoverageDetail.code union gains "kind_census_truncated"; 3 new optional fields (kind?: string, declared?: number, served?: number)
Manifest src/contracts/manifest.json source_commit + the one changed file's sha256
Rendering src/components/CoveragePanel.tsx new "Kind census" section (own heading, between "Per-kind read states" and "Degraded reasons"); excluded from the generic degrading-details list to avoid double-render; still counted as degrading everywhere else (degradingDetailsOf, degradedReasonCount untouched)
Component tests src/components/CoveragePanel.test.tsx pinned-vocabulary totality test (17→18 members); "exactly one code renders its own" → "exactly two"; new describe block, 8 tests, covering the shape's own input domain (present/absent kind, absent declared/served together, boundary served===declared, served===0, phrasing-over-label precedence, no double-render, coexistence with a generic degraded reason)
Contract-validation tests src/lib/acr/validate.test.ts new describe block mirroring the existing fact_read_origin_state consumer-pin pattern: GREEN (all fields present), GREEN (each field independently optional at the schema level — acr's own write path enforces the require-together rule, this schema does not duplicate it), RED CONTROL ×2 (served/declared wrong type or negative), the-already-live-codes-still-validate, vocabulary-stays-closed, and an EXECUTED repro that the PRIOR pin's own schema (enum member stripped) rejects the new code while still accepting a live one

INPUT-DOMAIN TABLE, executed through the real component render (pnpm exec vitest run):

CoveragePanel — kind_census_truncated (D47)
  ✓ shows the kind, the declared/served numbers, and the engine label under its own 'Kind census' heading
  ✓ prefers the synthesis phrasing over the label when both are present, keeping the numbers line separate
  ✓ omits the kind label and the numbers line when kind/declared/served are absent (legacy-shaped detail)
  ✓ renders the boundary shape served === declared (an uncut census reported some other way) without dividing by anything odd
  ✓ renders served === 0 (no cohort of this kind was assembled) as a real number, not a fallback
  ✓ does not double-render the row in the generic 'Degraded reasons' list
  ✓ still shows a generic degraded reason alongside a kind_census_truncated row, without merging the two

and through the real JSON-Schema validator (ajv, src/lib/acr/validate.ts):

coverage detail contract — the kind_census_truncated code (consumer pin, D47)
  ✓ GREEN: a degrading detail carrying the new code and all three fields validates at this pin
  ✓ GREEN: the fields are each independently optional at the SCHEMA level (acr's own write path enforces they ride together)
  ✓ RED CONTROL: served must be a non-negative integer, not a string or a fraction
  ✓ RED CONTROL: declared must be a non-negative integer
  ✓ the already-live codes still validate
  ✓ the vocabulary stays CLOSED: a code outside it is still rejected
  ✓ EXECUTED repro: the prior pin's own schema rejects the new code

RED-FIRST, verified against origin/main directly (detached worktree at dbf936d06a953788688c285d108e6e32e4b257a7, only the two modified test files copied in, component/lib left untouched): pnpm exec vitest run src/components/CoveragePanel.test.tsx9 of 96 tests fail (the pinned-vocabulary count, the exactly-two-codes-render check, and the 6 new "Kind census" behavior tests that need detail.kind/.declared/.served to exist as recognized fields and the dedicated section to exist at all). src/lib/acr/validate.test.ts's new block was not separately red-checked this way since it is entirely new (no prior assertion to regress) — its own EXECUTED-repro test is the red-on-the-prior-pin proof, in miniature, run against a reproduction of the old schema rather than the old component.

FULL SUITE, re-run at the final pin:

$ pnpm exec vitest run   # 60 test files, 991 tests, all passed
$ pnpm run build          # next build, Turbopack — compiled, typechecked, 4 routes generated
$ pnpm run lint           # eslint . — clean
$ pnpm run format:check   # prettier --check . — clean
$ pnpm exec tsc --noEmit  # clean

This is a contract-sync-only change (0 production TypeScript lines beyond the earlier CoveragePanel mirror already covered above) stacked on the acr PR, which has already merged to main — CI and PR-ref CodeQL on this PR's own pushed tip are the remaining gate.

RISK-NOTES

  • Pin is FINAL. SOURCE_COMMIT points at a57b599b, the acr PR's own squash-merge sha on main — no further re-pin is needed for this ticket.
  • Additive-only on the wire, and additive-only in the renderer: no existing code's rendering path changed except the one-line degradingDetailsgenericDegradingDetails rename at its map call site (the underlying array itself, and every OTHER consumer of degradingDetails, are untouched).
  • No consumer-side phrasing table introduced. The new "declared N (floor) · served M" line renders the contract's own declared/served INTEGER fields verbatim (string interpolation of numbers, not a derived sentence) — the same discipline countPhrase/structured-field rendering already follows elsewhere in this panel; the engine's own label/phrasing text is what's shown for the prose half of the row, exactly like every other coverage detail.
  • Scope note, same as the acr body's: this renders whenever acr emits the code on ANY terminal its own Coverage.Details reaches, not specifically tied to a structure_needs.kind_options co-occurrence (that field is a different, unrelated acr mechanism — see the acr PR body for the full trace).

Regenerates the pinned acr contract surface (provisional pin, a lane
tip not yet on acr main -- re-pin to the merge sha before this PR
merges): a new coverage-detail code, kind_census_truncated, with three
additive fields (kind, declared, served).

Renders it in CoveragePanel under its own "Kind census" section
(kind, "declared N (floor) · served M"), and covers the shape with
component tests (present/absent/boundary/no-double-render) and a
contract-validation test for the pin.
@linear-code

linear-code Bot commented Sep 13, 2026

Copy link
Copy Markdown

CHAOS-5732

Re-pins the provisional acr contract to the tip that derives a cut
kind census's served count last, at every serving surface (stage-3
retry and reuse), and closes the kind property to the same closed
subject-kind vocabulary Go already enforces.
Re-pins the provisional acr contract to its next tip; contracts/ and
internal/mcp/schemas/ are byte-identical to the prior pin (acr's
change there was comment-only), so only the source-commit pointer and
generated-file banners move.
Re-pins to acr main's squash of the kind-census coverage detail work;
every vendored file stays byte-identical to the pre-merge pin, only
the source-commit pointer and generated-file banners move.
@chrisgeo
chrisgeo merged commit daed63d into main Sep 14, 2026
13 checks passed
@chrisgeo
chrisgeo deleted the chore/5732-kind-census-mirror branch September 14, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant