Repository navigation
fix(reconstruction)!: summarize obligation ledgers by cited Evidence authority - #5875
Merged
Merged
Conversation
…authority summary.by_evidence_authority bucketed each obligation's source_state, so a shipped-artifact and a controlled-replay ledger returned the same summary and the promised authority breakdown was unanswerable. Derive the buckets from authority_references[].authority using the Evidence authority vocabulary owned by the Evidence schema. An obligation counts once under each distinct authority it cites, so counts can exceed total. Keep the source-state histogram under its own name, by_source_state. The readiness example now derives its summary from the same owner function instead of hand-writing buckets. BREAKING CHANGE: summary.by_evidence_authority keys are now Evidence authorities (shipped-artifact, controlled-replay, historical-reference, external-service, analyst-inference) instead of source states. The previous state counts move to the new required summary.by_source_state. Ledger closure digests change accordingly. Fixes #5838 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge with the explicitly accepted breaking output change. SummaryThe PR counts obligations by the Evidence authorities they cite and preserves source-state counts in
Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
2 tasks done
…-authority-summary
…-authority-summary
3 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What broke:
summary.by_evidence_authorityin the obligation ledger counted each obligation'ssource_state. A shipped-artifact ledger and a controlled-replay ledger got the same summary.Fix: The summary now counts obligations by their
authority_references[].authority, using the Evidence-owned authority enum. The state histogram moves to a new field,by_source_state.Risk: Breaking output change. The keys of
by_evidence_authoritychange,by_source_stateis now a required field, and ledger closure digests change. No other code in the repo reads the old keys.Summary
Fixes #5838. Issue #405 asked for a summary "grouped by application layer and evidence authority". The field had the right name, but its keys were the four source states. Clients could not get an authority breakdown from it.
Problem and expected behavior
Smallest trigger: one reviewed obligation that cites a
shipped-artifactrecord, and another that cites acontrolled-replayrecord. Both returnedreviewed: 1underby_evidence_authority. The broken rule: a summary dimension should be derived from the fact it names. Here it was derived from a different field.Change and scope
summarizeReconstructionObligationsis the single shared implementation for CLI and MCP. It now countsby_evidence_authorityfromauthority_references[].authority.by_*buckets. An obligation counts once under each distinct authority it cites, so the sum can exceedtotal. The referencestateand the obligationsource_statedo not affect the authority bucket. This rule is documented in the schema.describe()and indocs/reconstruction-obligation-ledgers.md.authorityis required, andauthority_referencesmust have at least one entry. So there is nounknownauthority bucket.evidenceAuthoritySchemais now exported fromsrc/domain/evidence.ts. The authority-reference schema and the summary both use it, replacing a copy of the enum in the ledger schema. The ledger's local state enum now also has one definition.by_source_state.reconstructionReadinessExample.tswrote its summary buckets by hand. It now builds them with the owner function. Its old hand-written values encoded the bug.countBynow makes a single pass and counts distinct keys per item.source_stateitself is derived (reviewed obligations are alwaysreviewed). That is existing behavior and outside this issue.Contract and boundary impact
src/domain/reconstructionObligationLedgerIntegrity.ts(summary derivation) andreconstructionObligationLedgerSchemas.ts(summary schema and its consistency check).build_reconstruction_obligation_ledgerchanges.by_evidence_authoritykeys are now the Evidence authority enum, andby_source_stateis added as required. The readiness input embeds the ledger, so it gets the same change.closure_digestandledger_idvalues change for the same inputs, because the digest covers the summary.metadata:checkanddocs:checkpass.None of the listed effects apply: the change is a pure derivation over caller-supplied Evidence, with no target interaction.
Evidence and regression coverage
tests/boundary/cli/reconstructionObligationLedgerCli.test.tsruns the real CLI subprocess.tests/boundary/mcp/reconstructionObligationLedgerMcp.test.tsruns through an in-memory MCP client.mixedAuthorityRequest()fixture: one obligation citing only shipped-artifact, plus one multi-reference obligation citing two shipped-artifact records and one controlled-replay record. Expected:shipped-artifact: 2,controlled-replay: 1,by_source_state.reviewed: 2. The CLI test also checks that shipped-artifact references keepcandidatestate.AssertionError: expected { total: 2, required: 2, …(5) } to match object { total: 2, …(2) }. MCP: the same mismatch. With the fix, both pass.node scripts/rea.mjs build-reconstruction-obligation-ledger <json> --jsonwith authenticated synthetic Evidence.Before (main
f801b2fbf):{"case":"shipped-artifact","by_evidence_authority":[{"key":"candidate","count":0},{"key":"observed","count":0},{"key":"reviewed","count":1},{"key":"unknown","count":0}]} {"case":"controlled-replay","by_evidence_authority":[{"key":"candidate","count":0},{"key":"observed","count":0},{"key":"reviewed","count":1},{"key":"unknown","count":0}]} {"case":"multi-reference","refs":[["shipped-artifact/candidate","controlled-replay/reviewed","shipped-artifact/candidate"],["shipped-artifact/candidate"]],"by_evidence_authority":[{"key":"candidate","count":0},{"key":"observed","count":0},{"key":"reviewed","count":2},{"key":"unknown","count":0}]}After:
{"case":"shipped-artifact","by_evidence_authority":[{"key":"shipped-artifact","count":1},{"key":"controlled-replay","count":0},{"key":"historical-reference","count":0},{"key":"external-service","count":0},{"key":"analyst-inference","count":0}],"by_source_state":[{"key":"candidate","count":0},{"key":"observed","count":0},{"key":"reviewed","count":1},{"key":"unknown","count":0}]} {"case":"controlled-replay","by_evidence_authority":[{"key":"shipped-artifact","count":0},{"key":"controlled-replay","count":1},…],"by_source_state":[…,{"key":"reviewed","count":1},…]} {"case":"multi-reference","by_evidence_authority":[{"key":"shipped-artifact","count":2},{"key":"controlled-replay","count":1},…],"by_source_state":[…,{"key":"reviewed","count":2},…]}Cost: the output grows by two summary buckets, about 190 bytes per ledger. CLI wall time per call was about 360 ms both before and after (single runs, not a benchmark).
Remaining proof gaps: not run:
npm run verify:readiness, which needs native fixture builds.src/domain/reconstructionReadiness.test.ts, which parses the readiness example, passed. Coverage for generated (Application Graph and process-capture) obligations comes from the shared summarizer and the existing source tests; no new generated-obligation fixture was added.Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
VITEST_MAX_WORKERS=2 npm run test:focused -- tests/boundary/cli/reconstructionObligationLedgerCli.test.ts tests/boundary/mcp/reconstructionObligationLedgerMcp.test.ts, with base sources: 2 failed, 5 passed (the new tests failed). With the fix: 7 passed.VITEST_MAX_WORKERS=2 npm run test:focused --on 13 files (ReconstructionObligationCandidates,ReconstructionObligationLedger.authority/.closure,reconstructionObligationLedgerSchemas,reconstructionReadiness, both ledger boundary tests,outputSchemaProfile,outputSchemaSemanticConstraints,toolSchemaValidity,compactInputSchemaMcp,mcpResponseBudget,cliStartupImports): 13 files, 83 tests passed.npm run check:fast: passed.npm run format:check: passed.npm run metadata:check: passed.npm run docs:check: passed.Compatibility, safety, and release
summary.by_evidence_authoritywith keyscandidate | observed | reviewed | unknown. Those counts are now atsummary.by_source_state.by_evidence_authoritynow has the keysshipped-artifact | controlled-replay | historical-reference | external-service | analyst-inference.Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code