Skip to content

feat: expose auditable agent decision traces (ENG-16854) — boon port of #80 - #92

Merged
william-antoline-boon merged 4 commits into
boonfrom
eng16854-audit-trace-boon
Aug 3, 2026
Merged

william-antoline-boon merged 4 commits into
boonfrom
eng16854-audit-trace-boon

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Ports #80 ("auditable agent decision traces", ENG-16854) onto the boon release branch.

#80 was merged to main (the upstream mirror) by mistake — it can't reach the customer fleet from there, since every v*-boon.N release is cut from boon. boon and main are diverged ~20k commits and boon's run/ layer is structured differently, so a cherry-pick is impossible (12 conflicts, 6 missing files). This is a manual re-implementation against boon's actual structure, using #80's diff as the spec.

Adds auditTrace to the final assistant reply

Bounded, 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) on visibleTools/toolInvocations (evidence inherits 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 in run-attempt-result.ts (absent on boon); on boon it already lives in run.ts. Extended in place: added visibleToolNames, visibleTools, invocations[{name,status}]; maps boon's errored→error.
  • Terminal call site: run.ts runEmbeddedAgentInternal (boon's equivalent of terminal-preparation.ts).
  • visibleToolNames source: run/attempt.ts inline result build (effectiveTools.map(t=>t.name)).

⚠️ Reviewer attention — Slack delivery deviation

#80 uses a "segments" reply model that does not exist on boon. Boon sends one flat SlackBlock[] alongside text, and Slack demotes top-level text to 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

    • Adds auditTrace to the terminal reply: schemaVersion:1, visibleTools, per-call toolInvocations with ok/error/blocked, evidence, confidence, disposition, reason (no prompts, reasoning, args, or results).
    • Caps visibleTools, toolInvocations, and evidence at 128 to prevent boon-core 400s and dropped replies.
    • Builds trace from runtime facts in run.ts using visibleToolNames; attaches only to the final assistant payload.
    • Slack delivery: sends a trailing “How this was verified” context block as a separate message to keep the main reply text visible.
  • Bug Fixes

    • Carries status:"blocked" through normalizeToolMetas so approval-unavailable or never-started calls render as blocked (not ok).
    • Preserves reply payload metadata when attaching the trace, and derives disposition from the full invocation set before the 128-item cap.
    • Slack delivery follows the actually delivered thread (not a rejected anchor) and truncates the context text to Slack’s 3000‑char limit to avoid 400s and dropped replies.

Written for commit a7295e6. Summary will update on new commits.

Review in cubic

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

claude Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/auto-reply/reply/agent-runner.ts Resolved
Comment thread extensions/slack/src/reply-blocks.ts Resolved
Comment thread extensions/slack/src/monitor/replies.ts Resolved
Comment thread extensions/slack/src/monitor/replies.ts Resolved
Comment thread src/auto-reply/reply/agent-runner.ts Resolved

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ✅

  • buildTraceToolSummary moved to boon's run.ts (vs #80's run-attempt-result.ts, absent here) and exported for test. boon's per-call errored flag is mapped to the error status (#80 used isError); hadFailure param rename handled.
  • visibleToolNames sourced from effectiveTools.map(t=>t.name) in run/attempt.ts (boon's equivalent of #80's settle site).
  • blocked-status plumbing (approvalUnavailable || !executionStarted) ported verbatim into boon's handlers.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.

william-antoline-boon and others added 2 commits July 31, 2026 15:43
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]>
…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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread extensions/slack/src/reply-blocks.ts Resolved
@william-antoline-boon

Copy link
Copy Markdown
Collaborator Author

/cr

@claude

claude Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@william-antoline-boon
william-antoline-boon merged commit 9d77653 into boon Aug 3, 2026
150 of 156 checks passed
@william-antoline-boon
william-antoline-boon deleted the eng16854-audit-trace-boon branch August 3, 2026 07:35
convyusboy added a commit that referenced this pull request Aug 3, 2026
Version-bump release carrying the 5 commits merged onto boon since boon.12:
#90 (ENG-16868), #92 (ENG-16854), #93, #94 (ENG-15788), #95 (ENG-17134).

Bumps gateway + slack + msteams + diagnostics-prometheus to
2026.6.11-boon.13 in lockstep (9 files). CI: 108 pass / 0 fail / 7 skip.
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