feat(agent-interface): unify exact candidate outcomes and receipts#46
Conversation
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — 1146e073
This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: drewstone_author · 2026-07-13T07:26:24Z
tangletools
left a comment
There was a problem hiding this comment.
🟢 Value Audit — sound
| Verdict | sound |
| Concerns | 0 (none) |
| Heuristic | 0.0s |
| Duplication | 0.0s |
| Interrogation | 464.3s (2 bridge agents) |
| Total | 464.3s |
💰 Value — sound
Unifies the pre-release candidate receipt around one discriminated task-outcome union (workspace or bounded media output) and collapses the V1/V2 receipt and model-settlement duplication into a single canonical shape; built in the grain of the existing codebase with all 105 tests passing.
- What it does: Three coupled changes to the @tangle-network/agent-interface (v0.24.0, explicitly pre-release) candidate evidence contract. (1) Introduces AgentCandidateTaskOutcomeSpec as a kind-discriminated union (workspace | output) and threads it through the execution plan and the task-outcome material, replacing the workspace-only
task.repositoryfield and adding a new bounded-output variant where a candid - Goals it achieves: (a) Let the same receipt/grading pipeline carry either code-workspace results OR bounded non-code outputs (data extraction, JSON, etc.) through one discriminated contract, so products stop forking parallel outcome shapes. (b) Kill the V1/V2 dual-parser machinery before the contract stabilizes — the version split existed only because V2 added fields on top of V1 instead of folding back, and carryin
- Assessment: Coherent and in-grain. The new
kind-tagged outcome union mirrors how the rest of the candidate contract already models choices (AgentCandidateCode, AgentCandidateMemoryReceipt, AgentCandidateTermination are all kind-discriminated unions), so this extends the existing pattern rather than introducing a new one. The refactor is genuinely subtractive: net -270 lines across 10 files, with the V1/V2 r - Better / existing approach: none — this is the right approach. I checked: (1) agentCandidateMediaTypeSchema is defined once in agent-candidate-schema-common.ts:43 and reused, not duplicated. (2) The discriminated-union shape matches the existing AgentCandidateCode pattern (agent-candidate.ts:200-203), so this folds into the codebase's grain rather than fighting it. (3) The pre-PR state on main was strictly worse — parallel V
- Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 2
- Bridge warning: opencode/kimi-for-coding/k2p7: bridge stream ended without value-audit content
🎯 Usefulness — sound
Clean unification of the candidate-outcome contract: extends the plan/result shapes with a bounded typed-output branch and collapses the redundant V1/V2 receipt and settlement schemas into one canonical V1 each — built in the grain of a pre-release contract package ahead of its first external consum
- Integration: Reachable via the public export chain index.ts:809 → agent-candidate-schema.ts:171,173 → agent-candidate-outcome-schema.ts / agent-candidate-receipt-schema.ts. README:80 already tells producers to attach AgentCandidateRunReceipt to benchmark runs. No sibling workspace package consumes any candidate schema yet, but the candidate contract is brand-new (#41/#43/#45 landed days ago) and the package is
- Fit with existing patterns: Idiomatic. Every neighbor contract uses z.discriminatedUnion + .strict() + .superRefine + isCanonicalJsonValue (e.g. agent-candidate-outcome-schema.ts:214-300, agent-candidate-execution-plan-schema.ts:84-101). The new output branch reuses agentCandidateMediaTypeSchema and agentCandidateArtifactRefSchema rather than forking primitives. The V1/V2 collapse removes a real duplication (prior receipt ca
- Real-world viability: 105 tests pass and tsc --noEmit is clean. New refinements are correct: maxBytes ≤ 64 MiB and positive (agent-candidate-execution-plan-schema.ts:232), output artifact byteLength > 0 (agent-candidate-outcome-schema.ts:284-293), and the empty-task-workspace check is correctly gated on outcome.kind === "workspace" so bounded-output tasks aren't falsely rejected (agent-candidate-execution-plan-schema.t
- Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 1
No concerns — sound change, no better or existing approach found. ✅
What this audit checks
It judges the change on its merits — not whether it was tasked out in an issue. Unticketed, fast-moving work is fine; the question is whether the change is good and whether a better or existing approach should be used instead.
| Pass | What it asks |
|---|---|
| Heuristic | Vague title? Whitespace-only or cruft-bearing diff? (content signals only) |
| Duplication | Do added function/class names already exist elsewhere in the repo? |
| Value Audit | What does it do? What goal does it achieve? Is it good? Better architecture or already-exists? |
| Usefulness Audit | Does it integrate and fit? Will it hold up in real use and actually get used? |
Findings are concerns, not blocks — the human reviewer decides what to do with them.
✅ No Blockers —
|
tangletools
left a comment
There was a problem hiding this comment.
✅ Approved — 4 non-blocking findings — 1146e073
Full multi-shot audit completed 3/3 planned shots over 10 changed files. Global verifier still owns final merge decision.
Full immutable report for this review: trace
Summary comment for this run: full summary
tangletools · 2026-07-13T07:47:22Z · immutable trace
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — fdbe7d34
This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: drewstone_author · 2026-07-13T15:15:05Z
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — 451f6518
This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: drewstone_author · 2026-07-13T15:44:39Z
tangletools
left a comment
There was a problem hiding this comment.
🟢 Value Audit — sound
| Verdict | sound |
| Concerns | 0 (none) |
| Heuristic | 0.0s |
| Duplication | 0.0s |
| Interrogation | 216.5s (2 bridge agents) |
| Total | 216.5s |
💰 Value — sound
Collapses parallel V1/V2 candidate contracts into one canonical schema set, adds a workspace|output discriminated task outcome, folds the full promotion pipeline (propose→review→execute) into agent-interface, and replaces duplicated float-dollar usage tracking with one integer-nanos per-call settlem
- What it does: (1) Removes the parallel V1/V2 split across bundle, run/materialization receipts, profile-plan, execution-plan, workspace-manifest, model-settlement, task-outcome and benchmark-result materials — every
*V1/*V2type alias and*V1Schema/*V2Schemazod parser is collapsed to a single canonical form, keeping the richer V2 shape (e.g.generationIdon settlement calls) as the only form. (2) Int - Goals it achieves: Read from the change itself: (a) one canonical task-outcome contract so workspace and non-workspace (bounded-media) tasks share the same execution-plan, receipt, and benchmark-result shapes; (b) kill the duplicated/transitional usage tracking — the old
usage+modelUsagepair and the V1/V2 settlement split are gone, replaced by one router-authored ledger with full per-call detail and exact int - Assessment: Good change on its merits, in the grain of the codebase. agent-interface already owned the bundle/receipt contracts; extending it to own the promotion contract and collapse the V1/V2 split is the natural end state of the transitional versioning added in #33 (executable outcome receipts) and #43 (benchmark graders). The discriminated
workspace|outputoutcome is the right factorization — previousl - Better / existing approach: none — this is the right approach. Searched:
git grepforAgentImprovementProposal|AgentImprovementReview|CandidateExecutionEvidence|agent-candidate-promotion-schema(only matches are inside this package — nothing else in the repo defines a promotion contract, so no duplication);git grepfor every removed*V1/*V2symbol (zero hits — no internal consumer breaks); checkedls packages/( - Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 2
- Bridge warning: opencode/kimi-for-coding/k2p7: bridge stream ended without value-audit content
🎯 Usefulness — sound
Clean consolidation: collapses an internal V1/V2 receipt split, adds a unified workspace-vs-output task outcome discriminated contract, and lands the proposal→review→execution-evidence promotion chain — all in-grain with the existing schema pattern and exported from a contracts package whose callers
- Integration: All new schemas are exported via packages/agent-interface/src/index.ts:810 (export * from "./agent-candidate-promotion-schema.js") and via the existing re-exports in agent-candidate-schema.ts:171-173. The package is a published contracts library (@tangle-network/agent-interface@0.24.0); no package inside this monorepo consumes the candidate surface today (grepped: agent-core, agent-provider-{tan
- Fit with existing patterns: Follows the established pattern exactly: z.object({...}).strict().superRefine(...) satisfies z.ZodType; MutuallyAssignable<A,B> compile-time type/schema parity assertions; discriminated unions on
kind; reuse of shared helpers (agentCandidateMediaTypeSchema, sha256Utf8, isWellFormedUnicode, isSafeRelativePath, isCanonicalJsonValue) from agent-candidate-schema-common.ts. Collapses a V1/V2 split - Real-world viability: Discriminated outcome contract is robust: workspace outcomes require task.repository provenance (agent-candidate-execution-plan-schema.ts:392-401) and enforce matching base/result repo identity and Git-object-format consistency (agent-candidate-outcome-schema.ts:251-290); output outcomes reject empty artifacts and artifacts exceeding the signed maxBytes (agent-candidate-outcome-schema.ts:291-310).
- Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 1
No concerns — sound change, no better or existing approach found. ✅
What this audit checks
It judges the change on its merits — not whether it was tasked out in an issue. Unticketed, fast-moving work is fine; the question is whether the change is good and whether a better or existing approach should be used instead.
| Pass | What it asks |
|---|---|
| Heuristic | Vague title? Whitespace-only or cruft-bearing diff? (content signals only) |
| Duplication | Do added function/class names already exist elsewhere in the repo? |
| Value Audit | What does it do? What goal does it achieve? Is it good? Better architecture or already-exists? |
| Usefulness Audit | Does it integrate and fit? Will it hold up in real use and actually get used? |
Findings are concerns, not blocks — the human reviewer decides what to do with them.
✅ No Blockers —
|
tangletools
left a comment
There was a problem hiding this comment.
✅ Approved — 6 non-blocking findings — 451f6518
Full multi-shot audit completed 5/5 planned shots over 18 changed files. Global verifier still owns final merge decision.
Full immutable report for this review: trace
Summary comment for this run: full summary
tangletools · 2026-07-13T16:22:19Z · immutable trace
Problem
Candidate execution had parallel task-output shapes and duplicated receipt/usage records, making exact workspace and non-workspace outcomes hard to share across products.
Solution
Verification