Repository navigation
feat: expose auditable agent decision traces (ENG-16854) — boon port of #80 - #92
Conversation
Port of #80 onto the `boon` release branch. #80 merged to `main` (the upstream mirror) by mistake and can't reach the fleet from there; `boon`'s run/ layer is structured differently so this is a manual re-port, not a cherry-pick. Wire contract (enums/keys/schemaVersion/decision ladder) is byte-identical to #80 and matches boon-core's validator (getboon/boon#13591). Also folds in the >128 array count-cap follow-up (MAX_TRACE_ITEMS=128) that #80 lacked, so an oversized trace can't trigger a boon-core 400 that drops the whole reply. Slack: delivered as a trailing standalone "How this was verified" context message (boon has no segment reply model; appending blocks would demote the answer text to fallback-only). Flagged for review. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 17 files
Linked issue analysis
Linked issue: ENG-16854: Auditable Agent Trace
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Add a portable auditTrace on the final assistant reply with schemaVersion:1 and the advertised keys (visibleTools, toolInvocations, evidence, confidence, disposition, reason) | Types and payload plumbing were added and the trace is attached to replies. reply-payload.ts defines the AgentDecisionTrace type and ReplyPayload.auditTrace; agent-runner attaches a built trace; tests assert presence. |
| ✅ | Trace contents exclude model reasoning, prompts, tool arguments, results, secrets, and raw exceptions (only bounded runtime facts) | Projection code builds compact invocations and evidence entries that only include name/status; Slack test asserts the serialized block does not contain 'arguments' or 'result'. |
| ✅ | Cap visibleTools, toolInvocations, and evidence at 128 items to avoid boon-core HTTP 400 / dropped replies | MAX_TRACE_ITEMS = 128 is enforced in normalization and build; tests verify 200-item input yields 128-item outputs. |
| ✅ | Build trace from runtime facts: include visible tool names, per-call status (ok/error/blocked), and mark blocked calls when approval/execution unavailable | Visible tool names are propagated into attempt results; buildTraceToolSummary now returns visibleTools and invocations; subscribe handler sets status 'blocked' when appropriate; tests exercise blocked mapping. |
| ✅ | Slack delivery preserves assistant text: send the audit trace as a trailing standalone context message rather than appending blocks that would demote text | Slack delivery layer adds deliverAuditTrace to send a separate message containing the audit block; helper resolves the context block and tests ensure the audit trace is not injected into primary reply blocks. |
| ✅ | Attach the audit trace only to the terminal assistant reply and not to status/diagnostic payloads | attachAgentDecisionTrace finds the last terminal assistant payload excluding status notices and reasoning, and tests verify the trace is attached only to that payload. |
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
There was a problem hiding this comment.
Reviewed as a port of #80 onto boon. Verdict: faithful port + one correct improvement. Approving.
Wire contract — byte-identical to #80 ✅
AgentDecisionTrace (reply-payload.ts) and AgentRuntimeDecisionTrace (runtime-plan/types.ts) match #80 exactly: same enum values, key names, schemaVersion:1, and the full disposition/reason ladder. buildAgentDecisionTrace's branch order is identical. Verified against boon-core's validator (getboon/boon#13591, merged): statuses ok/error/blocked, confidences high/medium/low, and the reason set all line up.
boon structural adaptation — correct ✅
buildTraceToolSummarymoved to boon'srun.ts(vs #80'srun-attempt-result.ts, absent here) and exported for test. boon's per-callerroredflag is mapped to theerrorstatus (#80 usedisError);hadFailureparam rename handled.visibleToolNamessourced fromeffectiveTools.map(t=>t.name)inrun/attempt.ts(boon's equivalent of #80's settle site).- blocked-status plumbing (
approvalUnavailable || !executionStarted) ported verbatim into boon'shandlers.tools.ts.
Improvement over #80 — the >128 cap ✅
MAX_TRACE_ITEMS=128 with .slice(0,128) on visibleTools + toolInvocations (evidence inherits via .map). This matters: boon-core rejects >128-item arrays with HTTP 400 (AUDIT_TRACE_MAX_ITEMS=128, confirmed in callback_controller.rb), and a 400 drops the whole reply. #80 lacked this. Test covers all three arrays capping at 128.
Slack delivery deviation — sound ✅
boon has no segments model; appending the block into resolveSlackReplyBlocks would demote the answer text to fallback. Delivering the trace as a trailing standalone context message preserves the answer. deliverAuditTrace runs AFTER the primary send and swallows its own errors — a trace-send failure can never suppress the answer. This is a faithful behavioral port. UX (separate message vs appended block) confirmed acceptable given the flat-block constraint.
Tests — new suites for run.trace-tool-summary, reply-blocks, agent-decision-trace, plus the runreplyagent terminal-payload assertion; the private_input negative assertion confirms no args/results leak. No secrets in the diff or the single commit.
One note (not blocking, and NOT a regression): the payload is camelCase (auditTrace.visibleTools) while boon-core's callback hard-requires snake_case (audit_trace.visible_tools, "Snake_case everywhere"). No camel→snake serializer appears in this diff — but that boundary is inherited from #80's design (which merged with the same shape), so it's out of scope for the port. Worth a quick confirm that the boon-core transport deep-snake-cases the reply payload before this reaches the fleet; if it doesn't, the trace would 400 (and the 128 cap is what saves the reply from being dropped). Doesn't block the port.
Fidelity-audit finding vs #80: boon's normalizeToolMetas sits between the blocked-status producer (subscribe handler) and the trace consumer (buildTraceToolSummary), and dropped the `status:"blocked"` marker #80 preserved in its own normalizer. Effect: a permission-denied/approval-unavailable tool call (errored:false, status:blocked) reached the trace as status:undefined -> classified "ok" -> reported disposition:completed/tool_execution_succeeded/high. A blocked run was reported to the user as a verified success — defeating the feature's core auditability guarantee, and untested (the plumbing test hand-built blocked metas, bypassing the normalizer). Adds `status?:"blocked"` to Raw/Normalized types + copies it forward, mirroring #80's attempt-result.ts normalizer, plus a regression test through the normalizer. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…NG-16854)
Addresses two cubic review findings on the boon port:
P1 (agent-runner metadata loss): attachAgentDecisionTrace cloned the terminal
payload with a bare `{...payload, auditTrace}` spread, orphaning boon's
WeakMap-backed ReplyPayloadMetadata (reply/threading, transcript, block-stream
identity) on every traced reply. Now copies it via copyReplyPayloadMetadata.
P2 (cap-before-disposition): the >128 cap sliced toolInvocations before the
decision ladder counted outcomes, so a failure/blocked call beyond item 128 was
discarded and the trace could report high-confidence success for a run that
failed a tool. Now the disposition is derived from the FULL normalized
invocation set; only the emitted toolInvocations/evidence arrays are bounded.
Adds regression tests for both.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1706ad5 to
eb9f65d
Compare
…ext (ENG-16854) Address PR review feedback on the audit-trace port: - deliverAuditTrace now follows the ACTUAL delivered thread (result?.threadTs), not the request threadTs. When a primary send degrades to the channel on a rejected anchor, send.ts returns threadTs: undefined; the old ?? threadTs fallback re-posted the trace against the dead thread and triggered a second invalid-thread retry. - resolveSlackAuditTraceBlock truncates the assembled context mrkdwn to Slack's 3000-char text-object limit. The 12-item list cap alone can still exceed it with long tool names, which Slack rejects with a 400 and boon-core then drops the reply. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
|
/cr |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Re-review of the post-approval commits (eb9f65d, a7295e6) — all clear, approving.
P1 (agent-runner metadata loss): attachAgentDecisionTrace now copies boon's WeakMap-backed ReplyPayloadMetadata onto the traced clone via copyReplyPayloadMetadata, so threading/transcript/block-stream identity survives. Regression test asserts replyToIdExplicit persists.
P2 (cap-before-disposition): disposition is now derived from the FULL normalized invocation set; only the emitted toolInvocations/evidence arrays are sliced to MAX_TRACE_ITEMS=128. Test confirms a failure at index >128 drives tool_execution_partial rather than reading as clean success.
Slack (a7295e6): deliverAuditTrace follows the actually-delivered thread (result?.threadTs / lastResult?.threadTs, dropping the ?? threadTs fallback) on both the text+blocks and chunked/media paths, so a channel-fallback trace no longer retries the rejected anchor. resolveSlackAuditTraceBlock truncates the assembled context mrkdwn to the 3000-char text-object limit on top of the 12-item cap. Both covered by new tests.
Remaining cubic threads (P2 pending-reply, P2 aggregate-only toolSummary, P3 surrogate-pair): verified as not-reachable-on-boon with cited producer paths — pending-reply text is a resume marker, buildTraceToolSummary always co-populates invocations, and tool names are ASCII-validated so no non-BMP char can reach the truncation boundary. Correct dispositions.
Verified locally at HEAD a7295e6: 199/199 tests pass across all six changed suites (agent-decision-trace, run.trace-tool-summary, normalize-tool-metas, reply-blocks, replies, subscribe.handlers.tools). CI fully green incl. cubic. Every fix carries a regression test; secrets/CoT excluded by design and asserted absent. Ship it.
What & why
Ports #80 ("auditable agent decision traces", ENG-16854) onto the
boonrelease branch.#80 was merged to
main(the upstream mirror) by mistake — it can't reach the customer fleet from there, since everyv*-boon.Nrelease is cut fromboon.boonandmainare diverged ~20k commits andboon'srun/layer is structured differently, so a cherry-pick is impossible (12 conflicts, 6 missing files). This is a manual re-implementation againstboon's actual structure, using #80's diff as the spec.Adds
auditTraceto the final assistant replyBounded, projected purely from runtime facts: visible tool names, tool invocation order + terminal status (ok/error/blocked), confidence, disposition, and a deterministic reason. Excludes prompts, reasoning, tool args/results, secrets, raw exceptions. Replies without a trace are unchanged.
Wire contract is byte-identical to #80 and matches boon-core's validator (getboon/boon#13591, already merged): no enum value, key name,
schemaVersion:1, decision-ladder branch, or the 120-char tool-name cap was altered.Also folds in the >128 count-cap follow-up
MAX_TRACE_ITEMS = 128+.slice(0,128)onvisibleTools/toolInvocations(evidenceinherits via.map). boon-core rejects >128-entry arrays with HTTP 400, and the anychat transport drops the entire reply on a 400 — so without this, a run with >128 tool calls loses the user's answer. #80 lacked this cap.Where the plumbing landed on boon (differs from #80's file layout)
buildTraceToolSummary— feat: expose auditable agent decision traces ENG-16854 #80 puts it inrun-attempt-result.ts(absent on boon); on boon it already lives inrun.ts. Extended in place: addedvisibleToolNames,visibleTools,invocations[{name,status}]; maps boon'serrored→error.run.tsrunEmbeddedAgentInternal(boon's equivalent ofterminal-preparation.ts).visibleToolNamessource:run/attempt.tsinline result build (effectiveTools.map(t=>t.name)).#80 uses a "segments" reply model that does not exist on boon. Boon sends one flat
SlackBlock[]alongsidetext, and Slack demotes top-leveltextto fallback when blocks are present — so appending the trace block the naive way would suppress the assistant's actual answer on plain-text replies. Instead the trace is delivered as a trailing standalone "How this was verified" context message (same thread, best-effort). This is a faithful behavioral port, not a literal diff port — please confirm this UX (separate message vs. appended block) is acceptable.Tests
Independently verified: agent-decision-trace (6), run.trace-tool-summary (3, new), reply-blocks (3, new), subscribe-handlers.tools, agent-runner.misc (+2 new), plus 200 across touched suites — all green. oxlint clean on changed files. Full monorepo typecheck deferred to CI (Node 24).
🤖 Generated with Claude Code
Summary by cubic
Adds auditable agent decision traces so users can verify what ran and why, and delivers a compact Slack “How this was verified” message. Implements ENG-16854 and hardens classification, outcome derivation, and Slack delivery so blocked or late-failing runs aren’t misreported and Slack never drops the reply.
New Features
auditTraceto the terminal reply:schemaVersion:1,visibleTools, per-calltoolInvocationswithok/error/blocked,evidence,confidence,disposition,reason(no prompts, reasoning, args, or results).visibleTools,toolInvocations, andevidenceat 128 to preventboon-core400s and dropped replies.run.tsusingvisibleToolNames; attaches only to the final assistant payload.Bug Fixes
status:"blocked"throughnormalizeToolMetasso approval-unavailable or never-started calls render asblocked(notok).Written for commit a7295e6. Summary will update on new commits.