refactor(agent-candidate): give captured-artifact evidence one schema owner - #242
Merged
Merged
Conversation
tangletools
approved these changes
Aug 21, 2026
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — 19aa5341
This PR was opened by the trusted drewstone account.
This approval is provisional and was applied by the local stand-in because the pr-reviewer webhook host is unreachable (2026-08-21). CI on this head is fully green. The full PR reviewer audit re-runs via the resweep when the service returns and will publish findings if it detects issues.
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.
Plan
Problem -
agent-candidate-execution-plan-schema.tsandagent-candidate-outcome-schema.tseach built the same evidence schema by hand: same object shape, same.strict(), and the same two integrity refusals - the captured artifact's hash must equal the digest its material canonicalizes to, and the artifact must carry bytes. The outcome copy already took alabel; the plan copy hardcoded"plan"into both messages, soplanEvidenceSchema(kind, material)was exactlyevidenceSchema(kind, material, "plan").Change - one
agentCandidateEvidenceSchemain a new internal module; both call it.Why long-term right - this is a digest-identity rule. Evidence whose artifact hash names something other than its material is evidence for a different value, and nothing cross-checks two hand-written copies of that check - the
satisfies z.ZodType<T>annotations cover the shape, not thesuperRefinebodies. One owner is the only thing that keeps 11 evidence schemas refusing on the same grounds.Cost - 4 files, all inside
agent-interface. No public API change: the owner lives in a module the package index does not re-export, sodist/index.d.tsis byte-identical toorigin/main. Rollback is a revert.Proof
Every evidence schema behaves identically - measured, not asserted. Built
origin/mainand this branch, enumerated every exported*EvidenceSchema, and ran each against four inputs (empty, artifact-hash mismatch, zero-length artifact, an extra field a strict object must reject), capturing every issue path and message:The only line that differed on my first attempt was the schema count - 12 against 11 - because the owner had landed in a module that is re-exported transitively through
agent-candidate-schema.jsand had silently become public API. Nothing outside the package needs it, so I moved it to an internal module and re-ran: 11 against 11, anddist/index.d.tsbyte-identical.pnpm buildpnpm check-typespnpm testorigin/mainpnpm check:package-artifactspnpm check:control-artifactsSimplification
Simplification: the captured-artifact evidence schema, including both integrity refusals, was 2 hand-written copies and is now 1 owner; the plan module's wrapper is 3 lines that name its label.
Net: +57 / -58 lines, 4 files, 2 copies of one digest-identity rule collapsed to 1 owner.
Not done here:
agent-candidate-code-schema.tsandagent-candidate-lineage-schema.tsalso importagentCandidateCapturedArtifactSchemaand check artifact integrity, but they check different things about it - they are not third and fourth copies of this rule, and folding them in would extract shape rather than intent.Tests: +0, -0. The claim is "these 11 schemas accept and refuse exactly what they did before", and the 44-outcome before/after comparison above proves that better than a unit test could; the existing schema tests in
agent-candidate-execution-plan-schema.test.tsandagent-candidate-outcome-schema.test.tsalready exercise both refusals and pass unchanged.