feat(#2886): ToolAuditLedger — tamper-evident, Merkle-chained tool-action log#120
Merged
Conversation
…tion log Epic #2882 (Pillar 2), TDD. New ToolAuditLedger in agents-kt-observability (sibling to JsonlAuditExporter). - Append-only, Merkle-chained, PII-safe: each row's entryHash = SHA-256(prevHash | sequence | callId | toolName | decision | denialReason | resultHash | timestamp), chained to the previous (genesis = 64 zeros). verify(path) recomputes the chain and pinpoints the first edited/inserted/deleted/reordered row. The tool result is stored only as a hash, never raw. read(path) parses rows (flat-JSON, zero-dep). - Auto-wire: agent.events.ledger(file) records PipelineEvent.ToolCalled -> APPROVED, ToolDenied -> DENIED (reason), ToolHallucinated -> HALLUCINATED; returns the ledger for later verify(). Tests (9, TDD RED->GREEN): chain links to genesis + prev; verify ok on untampered + empty; tamper detection (edit at sequence / delete / reorder); PII-safety (raw result absent, hash present); callId + decision recorded + read-back; end-to-end auto-record via the observe hook. Remaining for #2886: callId-keying of denied/hallucinated rows needs PipelineEvent to carry the callId (the ledger core already accepts it) — a scoped follow-up. CHANGELOG. Full ./gradlew build green.
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.
Slice 3 of epic #2882 — Pillar 2 (tamper-evident audit). New
ToolAuditLedgerinagents-kt-observability, sibling toJsonlAuditExporter. TDD.What
An append-only, Merkle-chained, PII-safe record of every tool action. Each row's
entryHash = SHA-256(prevHash ‖ sequence ‖ callId ‖ toolName ‖ decision ‖ denialReason ‖ resultHash ‖ timestamp)chains to the previous (genesis = 64 zeros), soToolAuditLedger.verify(path)recomputes the chain and pinpoints the first edited / inserted / deleted / reordered row. The tool result is stored only as a hash — never raw.agent.events.ledger(file)auto-wires it:ToolCalled→APPROVED,ToolDenied→DENIED(with reason),ToolHallucinated→HALLUCINATED; returns the ledger for laterverify(...).read(path)parses rows (flat-JSON, zero-dep).Tests (9, TDD RED→GREEN)
chain links to genesis + prev · verify ok (untampered + empty) · tamper detection (edit-at-sequence / delete / reorder) · PII-safety (raw result absent, hash present) · callId+decision recorded + read-back · end-to-end auto-record via the observe hook.
Remaining for #2886 (kept open)
callId-keying of the denied/hallucinated rows needs
PipelineEventto carry the callId (the ledger core already accepts callId) — a scoped follow-up. Everything else of the acceptance is in: append-only, Merkle-chained, tamper-detecting, child-unreachable writer, PII-safe, covers approved/denied/hallucinated.Verified: full
./gradlew buildgreen (suite + detekt).🤖 Generated with Claude Code