adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Decision ledger: persist the authority, refusal, and approval behind each tool call

Open ainaomotayo opened this issue 5 months ago • 106 comments

Is your feature request related to a specific problem?

Yes. ADK's observability answers what happened: OpenTelemetry spans for agent invocation, model calls, and tool execution; persisted session Events for function calls, responses, and confirmation actions; the BigQuery Agent Analytics plugin streaming structured events at the runner level.

Incident response and compliance for production agents need a different artifact, what was decided:

  • why this tool was selected for this step
  • under which authority the call ran (agent-auth vs user-auth, and which principal)
  • what a guardrail or plugin refused, and on what rule
  • what confirmation was required, and what approval made the action permissible

Each of those decisions passes through an ADK surface (plugin callbacks, tool confirmation, per-tool auth config), but no component writes a unified record of them. A team with all five security layers configured still cannot reconstruct, from framework output alone, the moment an agent crossed from suggestion into action. Credit to Alex Shev for naming this in a community discussion of indirect prompt injection defenses: the layer most often missing is the decision ledger between policy and action.

Describe the Solution You'd Like

An opt-in, runner-level decision ledger plugin (so every agent on a runner inherits it) that emits one structured, persistable entry per decision point: tool call, refusal, confirmation request, confirmation resolution. Deterministic fields (authority, policy outcome, confirmation payload) are attested by the framework; the model's stated rationale is recorded but typed as untrusted, since a hijacked agent will narrate a plausible justification. Schema and pseudo-code below.

To my knowledge, no framework persists this unified record today. In ADK all four decision surfaces already exist, so this is integration work, not new machinery.

Impact on your work

I am a Google Developer Expert for AI producing developer education on ADK agent security. The recurring question from production teams in those discussions is not "how do I block the attack" but "how do I reconstruct what my agent decided when something gets through." Today my honest answer is that every team must build its own ledger from plugin callbacks, and none of those one-off schemas interoperate. A first-class answer would close the most common gap I see between teams configuring ADK's security layers and teams being able to audit them. No hard timeline; this is an ecosystem maturity request, not a personal blocker.

Willingness to contribute

Yes. I am willing to contribute the plugin implementation and a schema RFC if maintainers are open to the direction.


Describe Alternatives You've Considered

  • Persisted session Events: capture function calls, responses, and confirmation actions with timestamps, but not the authority a tool ran under, the rule behind a refusal, or selection rationale. The ledger is the decision-semantics layer above the event log.
  • BigQuery Agent Analytics plugin: the closest existing component, registered once at the app level and structured, with dedicated HITL confirmation event types. It does not capture tool-selection rationale, logs tool_origin rather than the agent-auth/user-auth principal, and records generic TOOL_ERROR rather than policy refusals with rules.
  • Model Armor logging to Cloud Logging / SCC: records which policy a blocked request triggered, but only for Model Armor's own screenings, in a sink disconnected from the agent trace.
  • Cloud Audit Logs: capture the principal for GCP API calls only; nothing for arbitrary tools, and no framework semantics.
  • Third-party attestation tools (signed receipts, hash-chained audit trails, policy evaluators): a real ecosystem exists, with several incompatible schemas, and all of them attest records the framework never emits. They can sign what happened; only the framework sees why. This request is for the emission point; the existing ecosystem can consume it.
  • Per-team custom plugins: possible today via before/after tool callbacks, confirmation payloads, and declared per-tool auth, which is the argument for making it first-class: every production team re-derives the same schema and none of them interoperate.
  • Prior art in other frameworks, none complete: AWS Bedrock Agents record per-step rationale and guardrail assessments in an ephemeral trace with identity held elsewhere; the Claude Agent SDK computes structured allow/deny/ask permission decisions without persisting them; LangGraph persists human-interrupt approvals in checkpoint history.

Proposed API / Implementation

Registration, following the existing runner-level plugin pattern:

from google.adk.plugins import DecisionLedgerPlugin  # proposed

runner = InMemoryRunner(
    agent=root_agent,
    app_name="my_app",
    plugins=[
        DecisionLedgerPlugin(
            sink=...,                      # BigQuery, Cloud Logging, file
            record_model_rationale=True,   # always typed untrusted
        ),
    ],
)

One ledger entry per decision point:

{
  "invocation_id": "...",
  "step": 3,
  "decision": "tool_call | tool_refused | confirmation_required | confirmation_resolved",
  "tool": "...",
  "authority": {"mode": "agent-auth | user-auth", "principal": "..."},
  "policy": {"source": "plugin | tool_context | confirmation", "rule": "...", "outcome": "allow | deny | escalate"},
  "confirmation": {"required": true, "response_payload": "..."},
  "model_rationale": {"text": "...", "trust": "untrusted_generated"},
  "timestamp": "..."
}

Implementation sketch: the plugin populates entries from surfaces that already exist: before/after tool callbacks (tool, args, step), the declared per-tool auth config (authority), plugin/callback block decisions (policy source, rule, outcome), tool confirmation responses (confirmation payload), and the model's stated reasoning from the model response that produced the tool call (rationale, typed untrusted).

Additional Context

Related prior items, scoped against deliberately: #5202, #5201, #5164 (audit trails and signed receipts of what was called, all closed) and open Discussion #5090 (execution provenance exporter, which covers principal and approval references but not selection rationale, refusal rules, or a unified schema). This request is for the decision-semantics layer those items stop short of.

ainaomotayo avatar Jun 13 '26 00:06 ainaomotayo

This is a strong distinction. I would keep the ledger boundary very explicit: traces and session events describe execution, while the decision ledger should describe authority.

One useful split is:

  • framework-attested fields: tool name, invocation or step id, principal, auth mode, policy source, policy version, confirmation id, decision state, timestamp;
  • derived commitments: canonical args digest, result digest when available, and the policy or guardrail version that was evaluated;
  • untrusted context: model-stated rationale, useful for review but never treated as the authority record.

That separation matters because the most important question after an incident is not only "what tool ran?", but "what made this exact action permissible at that moment?"

I would also make the decision state shape terminal and machine-readable:

  • allowed;
  • refused;
  • confirmation_required;
  • confirmation_resolved;
  • stale_or_mismatched;
  • policy_error.

Then the runner can fail closed when a confirmation is missing, expired, or bound to a different tool, principal, policy version, or args digest. The ledger becomes more than audit text: it becomes the object downstream verifiers can use to prove that the action that executed was the same action that was authorized.

rpelevin avatar Jun 15 '26 15:06 rpelevin

Hello @ainaomotayo ,

Thank you for your request. It is currently being reviewed and we appreciate your patience in the meantime.

llalitkumarrr avatar Jun 16 '26 06:06 llalitkumarrr

This is the right gap to close, and @rpelevin's split — traces/events describe execution, the ledger describes authority — is the load-bearing distinction. One thing worth nailing down early, because it decides whether the ledger is auditable or just more telemetry: bind each decision to the call it authorized, so a verifier can prove executed == authorized without trusting the agent's narration.

Grounding it in ADK's current surfaces:

  • The four decision points already exist, but the deny path is lossy. A BasePlugin.before_tool_callback that returns a dict short-circuits execution and that dict becomes the function response (flows/llm_flows/functions.py, the before-tool step). So a policy refusal is indistinguishable in the event log from a tool that simply returned that dict. The ledger's first job is to make refusal a first-class, attributable record ({source, rule, outcome=deny}), not a substituted result.
  • EventActions persists only requested_auth_configs and requested_tool_confirmations — there's no authority / principal / policy / outcome slot. And the agent-auth vs user-auth principal physically exists (auth/auth_tool.py::AuthConfig, tools/base_authenticated_tool.py) but is never joined onto the event, so "which principal did this call run under" is unrecoverable after the fact. That's exactly the attribution the ledger needs, and it's reachable at the before_tool/after_tool hook via tool_context._invocation_context.
  • ToolConfirmation is {hint, confirmed, payload} — no binding. That's the piece I'd add first: when a confirmation is issued, compute and store a tag over (fully-qualified tool name ‖ canonical-args digest ‖ principal ‖ policy version ‖ expiry). On resume, recompute and compare; if the resolved confirmation doesn't match the call about to execute — different tool, mutated args, wrong principal, stale policy, expired — the runner fails closed (stale_or_mismatched) instead of re-executing. Today resolution is reconstructed by event-scanning in request_confirmation.py, which can match an approval to a call whose args changed after it was approved.

@rpelevin's trust-typing matters here too: the digest/principal/policy fields are framework-attested; the model's stated rationale goes in an explicitly untrusted slot that the enforcement path never reads. A hijacked agent can write a convincing rationale but cannot forge the tag.

I've been working through this same bind-the-capability-to-the-exact-call problem on a couple of other MCP/agent projects, and the invariant that's carried across all of them is: the approval must commit to the canonical args digest, and the executor must re-verify it at dispatch — otherwise "approved" quietly degrades to "approved something, once." Happy to write up the confirmation-binding piece as a concrete schema proposal (the tag construction + the fail-closed states) against ADK's ToolConfirmation / EventActions if that's useful for the RFC.

Whatsonyourmind avatar Jun 17 '26 13:06 Whatsonyourmind

The ledger should join authority to execution. A minimal event can carry session id, step id, tool call id, principal, auth mode, policy source/version, decision state, confirmation id, args digest, and result digest when available. Then a verifier can ask whether a tool call was authorized without trusting the agent's narration after the fact.


Generated with ax.

Necmttn avatar Jun 21 '26 12:06 Necmttn

the execution vs authority distinction @rpelevin drew is the right split — and it maps to a concrete join key problem.

the ledger entry needs to be joinable back to the trace span without trusting the runtime's local IDs. if the only join key is the span's tool_call_id (runtime-local), an auditor checking the ledger against an external trace cannot verify the join without trusting the operator's infrastructure.

a content-derived join key closes this: action_ref = SHA-256(JCS({agent_id, action_type, scope, timestamp_ms})) is recomputable from the intent tuple alone — any verifier can derive it from the four fields and check it against both the ledger entry and the trace span attribute. two independent systems can verify they're talking about the same action without a shared runtime state.

for the ADK decision ledger specifically: the event shape @Necmttn described (principal, auth mode, policy source, decision state, args digest) is exactly right — the action_ref sits alongside those as the portable correlation handle. the args digest proves the action wasn't substituted; the action_ref proves the event is joinable across audit consumers.

the spec counterpart for external execution evidence (what happens after the gate passes) just landed in agentrust-io/trace-spec §3.3.1 this week. worth aligning the ADK ledger schema with that so audit consumers get a consistent join key across frameworks.

arian-gogani avatar Jun 23 '26 16:06 arian-gogani

I tried a small implementation of the case this issue describes for verifiers and exporters. Mainly, after a tool call finishes, can code outside ADK tell which ADK decision allowed it, refused it, or required confirmation first?

I tested that in this ADK Python proof.

https://github.com/creatornader/atrib/tree/main/packages/integration/examples/google-adk-python

To reproduce it locally, run pnpm --filter @atrib/integration google-adk-python-decision-ledger-proof.

The proof uses google-adk==2.3.0 with InMemoryRunner, BasePlugin, and FunctionTool. It records allow, refuse, and policy-error decisions from before_tool_callback, keeps the model's stated rationale from after_model_callback as review context, and records the allowed tool outcome with a pointer back to the decision. The rationale helps a human read the run, but it is not the authority check.

It also exercises FunctionTool(require_confirmation=True). ADK can request confirmation today. The proof uses local fixtures for the later approved and stale/mismatched cases because ADK does not currently expose a stable tag tying an approval to the exact tool, args, principal, policy version, and expiry.

The proof worked locally, but it exposed the schema question. A verifier should not have to reverse-engineer authority from callback behavior. The fields I ended up needing were tool call id, portable join handle, canonical args digest, auth mode, principal reference, policy source/version, refusal rule, confirmation id/expiry, result digest when available, and trace/span/session/invocation ids.

The hosted visual is here.

https://atrib-google.vercel.app

That demo is a local proof with hosted replay. It shows AP2 evidence feeding an A2A handoff, then an ADK allow decision that cites the handoff before the callback runs. I included it to show the decision-to-outcome join, not to propose atrib as an upstream ADK dependency or claim a BigQuery or Agent Platform Runtime deployment.

My concrete suggestion from the proof is to include enough stable IDs and digests for someone outside the runner to join the decision to the later tool outcome. If that stays adapter-specific, every plugin can emit a ledger, but the resulting records will not be interoperable.

creatornader avatar Jun 23 '26 18:06 creatornader

the 'decision ledger between policy and action' framing is the right architectural cut, and the five decision categories you've identified (tool selection / authority / refusal / confirmation request / confirmation resolution) cover the full surface for compliance-grade reconstruction.

one property worth pinning at the design stage, because it's load-bearing for the use case the issue is solving (incident response and compliance): the decision ledger should be independently verifiable — meaning a third party with no access to ADK's runtime infrastructure can recompute the ledger entries from their canonical bytes and verify the signature against a published key.

if the ledger is just structured logging (operator-controlled, mutable post-write), it solves the operator question ('what did our agent do?') but not the adversarial audit question ('can we prove our agent did what we said?'). these are different artifacts. for EU AI Act Article 12 enforcement (August 2, 2026), the operator-only version doesn't satisfy the post-hoc verifiability requirement.

the shape that works for both is a bilateral signed record per decision: a pre-execution admission record (decision_id, authority, refusal_reason, confirmation_required) and a post-execution outcome record (resolution, executed_action, result_digest), joined by a content-derived identifier over the canonical preimage:

decision_ref = SHA-256(JCS({decision_id, agent_id, action_type, scope, policy_version, timestamp_ms}))

this gives you (a) the operator-side searchable ledger you described, plus (b) cryptographic verifiability when a compliance team or regulator asks 'show your work.' canonical-bytes equality is what makes the two halves recomputable independently — RFC 8785 JCS specifically, not stdlib json.dumps(sort_keys=True) (those coincide for ASCII text + integers + booleans but diverge on Unicode or non-integer fields).

the spec landscape on this is converging. four independent receipt formats (vaara, x402 settlement-receipt extension, agent-guard, nobulex) recently demonstrated byte-identical cross-implementation hashes against the same canonical-preimage discipline — see x402 PR #2666 §5 for the conformance evidence. ADK doesn't need to invent a new format; it needs to choose a canonical preimage shape and emit signed bytes at the five decision points. the rest composes.

happy to sketch an ADK-specific integration of the existing pattern against the plugin callback + tool confirmation surface if useful — the wire format would slot into the BigQuery Agent Analytics plugin's existing event stream without disturbing the schema.

arian-gogani avatar Jun 24 '26 21:06 arian-gogani

The ADK-specific integration I would start with is a small signed decision-ledger event emitted at the same boundary where the runtime already decides whether a proposed tool call may proceed.

I would keep the first contract narrow:

  1. Pre-execution decision event: emitted from the policy/confirmation path before the tool handler runs. It carries decision_id, action_ref, agent/session/turn identity, tool identity, normalized args digest, policy/version refs, authority result, confirmation state, reason code, and validity window.
  2. Post-execution outcome event: emitted after the tool returns or fails. It carries the same action_ref plus outcome state, result digest or refusal/error class, side-effect boundary, and evidence refs.
  3. Confirmation events: request and resolution stay separate ledger rows, not just UI state, so the verifier can see which human decision authorized which action.

The verifier should be able to recompute action_ref from the decision-side intent fields and compare it with the outcome-side action_ref without trusting local span IDs. Runtime-local tool_call_id can still be useful for tracing, but it should not be the only authority/execution join key.

Two negative cases are worth pinning early:

  1. an outcome row with no matching pre-execution decision row is not authorized, even if the trace span exists;
  2. a confirmation resolution that changes tool, args digest, target scope, actor, policy version, or continuation identity must create a new decision rather than mutate the prior one.

That keeps the ledger useful for operator search while making it strong enough for external audit: searchable events for operations, signed canonical bytes for verification.

Boundary: architecture and test feedback only; no claim about using this project or running its code.

rpelevin avatar Jun 24 '26 21:06 rpelevin

@rpelevin's two-event split (pre-execution decision + post-execution outcome) is the right shape — but the moment there are two events you inherit a second obligation beyond the join. The content-derived action_ref @arian-gogani described proves the two events are about the same action; it doesn't prove the pair is intact. Two failure modes a verifier still can't catch with the join alone:

  1. Orphaned authority. A decision emits state=allowed, the tool handler then raises / times out, and no outcome event is written. In the log that's indistinguishable from "allowed and silently succeeded" — the lossy-deny problem from earlier, generalized: any allowed decision with no terminal outcome is a hole.
  2. Swapped outcome. If nothing binds the outcome to the specific decision that authorized it, an outcome can be reattributed to a different decision.

Both close with one move: make the outcome event commit to the decision event — carry decision_digest = SHA-256(JCS(decision_event)) on the outcome — so the chain is intent → decision → outcome, each hash-linking the prior. Then the ledger stops being a bag of events you join after the fact and becomes an append-only chain with a checkable invariant:

every allowed decision has exactly one terminal outcome; every refused / confirmation_required(denied) has zero.

That invariant is the compliance property the issue is after — it's what lets a verifier assert nothing executed unauthorized, and nothing authorized vanished without trusting the runtime's narration.

Grounding it in ADK: this has to be enforced at the tool-execution step in flows/llm_flows/functions.py. The allowed path must emit its terminal outcome in a finally, so a raising/cancelled handler still produces {errored | timed_out} instead of a gap. @creatornader's proof already records the allow/refuse/policy-error decisions from before_tool_callback; the missing half is guaranteeing the outcome side can't be dropped when the handler itself fails — that's the difference between "we logged decisions" and "a verifier can prove the decision/outcome set is complete."

Whatsonyourmind avatar Jun 25 '26 09:06 Whatsonyourmind

The decision_digest point is the missing invariant I would add to the first contract, but I would keep action_ref and decision_digest separate because they answer different verifier questions.

action_ref answers: are these events about the same intended action? decision_digest answers: did this outcome commit to the exact decision that authorized it?

That gives the ADK ledger a small conformance surface:

  1. An allowed decision must have exactly one terminal outcome with the same action_ref and decision_digest = SHA-256(JCS(decision_event)).
  2. A refused decision must have zero executed outcomes and should have a terminal non-execution state.
  3. A confirmation_required decision should not authorize execution until a later resolution creates a fresh allowed decision or a terminal denied state.
  4. Any outcome with the right action_ref but a wrong decision_digest is nonconformant.
  5. Any allowed decision still missing a terminal outcome at turn/session close is incomplete, not silently successful.
  6. A timeout, cancellation, or raised tool handler is still a terminal outcome, emitted from finally on the allowed execution path.

The tests I would pin first:

  • accept: allowed decision -> tool returns -> exactly one executed outcome hash-links to the decision;
  • accept: allowed decision -> tool handler raises -> exactly one errored outcome hash-links to the decision;
  • reject: outcome matches action_ref but points at a different decision_digest;
  • reject: allowed decision has no terminal outcome by close;
  • reject: refused or denied-confirmation decision is followed by an executed outcome;
  • reject: confirmation resolution changes tool, args digest, actor, policy version, target scope, or continuation identity without a new decision.

In ADK terms, this belongs at the same tool-execution boundary named above: the before-tool decision can be recorded by callback/plugin code, but the runtime path that invokes the handler has to guarantee the outcome side. Otherwise the ledger is only decision logging, not a verifier-complete decision/outcome chain.

Boundary: architecture and test feedback only; no claim about ADK adoption, implementation, or running code.

rpelevin avatar Jun 25 '26 10:06 rpelevin

Agreed on keeping them separate — action_ref ("same intended action?") and decision_digest ("did this outcome commit to the exact authorizing decision?") are orthogonal, and collapsing them loses the swapped-outcome detection. Your five points are the right per-entry conformance surface.

The one property they can't give you — by construction, because they only reason about entries that exist — is completeness: a decision+outcome pair that was never written at all. That's the highest-stakes failure for the incident-response use case, because a tool call that bypassed the policy path (or a crash between authority-grant and ledger-write) looks like silence, not a nonconformant entry, and a per-entry rule can't fire on an absent entry.

Two mechanisms close it, and both lean on surfaces ADK already has:

  1. Log-level chaining, one level up from decision_digest: each entry commits to the prior log head (prev_digest), making the ledger an append-only chain. A dropped entry breaks the chain — detectable without trusting the writer. (decision_digest binds outcome→decision; prev_digest binds entry→log, which is what catches omission.)
  2. A ledger⇄trace bijection against the OTel tool-execution spans the issue contrasts the ledger against: every span that executed a tool maps to exactly one allowed ledger decision, and every allowed decision to exactly one span. That's the "no tool executes off-ledger" invariant — the trace proves execution happened, the ledger proves it was authorized, and the bijection between them is the omission detector the conformance surface can't express internally.

So the full stack is: per-entry conformance (your 1–5) + log-chaining + the ledger⇄trace bijection. The first proves each entry is well-formed and bound; the second two prove the set is complete — which is the property compliance actually needs: nothing executed unauthorized, and nothing authorized vanished.

Whatsonyourmind avatar Jun 25 '26 10:06 Whatsonyourmind

Agreed. I would make the first spec name those as three separate verifier layers, because they catch different failures.

Layer 1: entry conformance. Each decision and outcome is well-formed, canonicalized, hash-bound, and has the right terminal state.

Layer 2: log completeness. Each ledger entry carries prev_digest, and each turn/session close records the current ledger_head_digest. That makes omission detectable as a broken chain rather than an absent row a per-entry verifier cannot see.

Layer 3: execution completeness. The tool-execution trace and the ledger form a bijection at the action boundary:

  • every executed tool span maps to exactly one allowed decision and one terminal outcome;
  • every allowed decision maps to exactly one terminal outcome;
  • every terminal executed outcome maps to exactly one tool span;
  • refused, denied-confirmation, policy-error, pre-dispatch cancelled, and pre-dispatch timed_out outcomes map to zero executed spans;
  • post-dispatch error, cancellation, or timeout still maps to the attempted execution span and a terminal outcome.

The negative fixtures I would add after the per-entry cases:

  1. missing ledger entry between two valid entries breaks prev_digest;
  2. turn close ledger_head_digest does not match replayed entries;
  3. executed span has no allowed decision;
  4. allowed decision has no terminal outcome;
  5. terminal executed outcome has no span;
  6. one allowed decision maps to two terminal outcomes;
  7. one executed span maps to two decisions;
  8. trace action_ref matches but decision_digest points at a different decision.

That gives the verifier a clean escalation path: entry validity proves each row is sound; log chaining proves the ledger was not edited by omission; ledger/trace bijection proves the runtime did not execute off-ledger.

Boundary: architecture and test feedback only; no claim about ADK adoption, implementation, or running code.

rpelevin avatar Jun 25 '26 10:06 rpelevin

That three-layer split is exactly it. One implementation hazard worth pinning in the spec for Layer 2, because ADK specifically allows it: parallel tool calls fork a naive prev_digest chain. If two tool executions in the same turn both read ledger_head = H and each appends chaining to H, you get two children of H — an ambiguous head, and the "broken chain ⇒ omission" check can no longer distinguish a fork from a drop.

Two ways to keep Layer 2 sound under concurrency:

  • Serialize the append — single-writer per session (monotonic sequence number + a lock/queue on the ledger head), so the chain stays linear even when the tool calls themselves run in parallel; or
  • Model the ledger as an explicit DAG — each entry records its parent set, and the ledger_head_digest at a turn/session close is a Merkle root over all entries since the last close, not a single linear tip. Then concurrent appends are expected multiple-parents, and only a genuinely missing entry breaks the root.

The linear chain is simpler and probably right for most agents; the DAG is the honest model once you have true parallel function calls. Either way it's Layer 3 — the span ⇄ allowed-decision ⇄ outcome bijection — that actually catches the omission; the chain/DAG just lets Layer 2 localize where it happened. Good shape for the spec.

Whatsonyourmind avatar Jun 25 '26 11:06 Whatsonyourmind

Agreed. I would make that concurrency choice explicit in the spec instead of leaving prev_digest underspecified.

There are two valid Layer 2 shapes:

  1. Linear ledger: one append authority per session or turn. Tool executions may run in parallel, but ledger append is serialized through a lock, queue, or monotonic sequence. Each entry has exactly one prev_digest, and turn close records the single ledger_head_digest.

  2. DAG ledger: concurrent entries may share a parent. Each entry records its parent digest set, and turn close records a deterministic Merkle root over the closed frontier for that turn/session.

The important thing is not which shape ADK chooses first; it is that the verifier knows which shape it is checking. A linear verifier should reject forks. A DAG verifier should accept declared concurrency but reject missing parents, duplicate entries, nondeterministic root construction, and any executed span that is absent from the root.

I would add two negative fixtures to Layer 2:

  1. two entries claim the same prev_digest in a linear-ledger mode;
  2. a DAG turn close omits one executed entry from the Merkle root.

Layer 3 then remains the independent execution-completeness check: every executed span must appear in the ledger/trace bijection, whether Layer 2 is linear or DAG-shaped.

Boundary: architecture and test-shape feedback only; no claim about ADK adoption, implementation, or running code.

rpelevin avatar Jun 25 '26 11:06 rpelevin

Completing the negative-fixture matrix — the two you listed both live in Layer 2, but Layers 1 and 3 each need a row only they can fail, otherwise the three-layer split isn't provably non-redundant.

Layer 3 (the span ⇄ decision ⇄ outcome bijection):

  1. Off-ledger execution — an executed tool span with no allowed decision and no ledger entry at all. Layer 1 sees nothing malformed; a linear/DAG chain stays intact (nothing was appended wrong). Only the bijection catches it. This is the direct test of the "no tool executes off-ledger" invariant.
  2. Orphaned authority — an allowed decision with a valid, well-chained entry but no terminal outcome and no executed span. The mirror image: the ledger says yes, nothing ran. Chain/root verify clean; only the "exactly one terminal outcome per allowed" side of the bijection flags it.

Layer 1 (the one that's easy to drop):

  1. Swapped outcome — a well-formed outcome that chains correctly but whose decision_digest commits to a different decision than the one it's adjacent to in the log. This is the fixture that justifies keeping decision_digest and action_ref as separate fields: collapse them into one and this case passes silently (positional adjacency and a single shared id both agree — it's only the independent decision_digest = SHA256(JCS(decision_event)) binding that disagrees).

With those three plus your two Layer-2 fixtures, every layer has at least one negative that only it can catch — which is exactly the property that makes the layering load-bearing rather than three views of the same check.

(Same boundary as you: architecture and test-shape only, no claim about ADK adoption or running code.)

Whatsonyourmind avatar Jun 25 '26 14:06 Whatsonyourmind

Yes. I would make that matrix prove independence rather than just coverage.

The minimum fixture set I would want is:

  1. Layer 1 only: swapped outcome chains correctly but commits to a different decision_digest;
  2. Layer 2 only: two entries claim the same prev_digest in linear-ledger mode;
  3. Layer 2 only: a DAG close omits one executed entry from the Merkle root;
  4. Layer 3 only: an executed span has no allowed decision and no ledger entry;
  5. Layer 3 only: an allowed decision has no terminal outcome and no executed span;
  6. cross-layer guard: an executed span is accepted only when entry conformance, log completeness, and execution bijection all pass.

The acceptance rule should be that each negative fixture has exactly one primary failing layer. If every verifier reports every failure from every layer, the split is probably not precise enough yet.

rpelevin avatar Jun 25 '26 15:06 rpelevin

That leave-one-out framing is the right acceptance test — and I'd make it operational as a mutation test rather than an observation: for each negative fixture i, assert that with layer Lᵢ's check disabled the breach passes undetected, and with it enabled the breach is caught while the other two layers stay silent on it. That's strictly stronger than "exactly one layer reports it" — it proves Lᵢ is necessary, not just first-to-fire, so no other layer is quietly redundant-covering the case.

Two guards to keep the matrix honest:

  • Pair fixture 6 (all-pass) with the negatives as the false-positive anchor. A verifier that rejects everything trivially "catches" all five negatives, so the legitimate trace must pass cleanly through all three layers. Independence (sensitivity) + the all-pass anchor (specificity) together are what make the claim falsifiable instead of aesthetic.

  • Fixture 3 (DAG omission) is actually two rows. The "Layers 1 and 3 stay silent" expectation only holds if the omitted entry's span is also absent from the trace. If the span exists but the ledger entry is missing, Layer 3 should also fire (off-ledger execution) — that's the bijection doing its job, not a precision leak. So specify whether the omission is entry-only (Layer 2 sole) or entry+span (Layer 2 primary, Layer 3 corroborating); they're different acceptance rows.

Good matrix — this is the part that makes the three-layer claim testable rather than rhetorical.

Whatsonyourmind avatar Jun 25 '26 21:06 Whatsonyourmind

Nice — the U/D/A/H split is cleaner than the 3-layer cut I'd sketched, and deriving the nonce from (tool_call_id + agent_id + round_number) signed by the verifier is the right way to kill cross-call approval replay.

One gap that sits next to the nonce rather than inside it: the per-entry signature proves every entry that's present is authentic, but it doesn't prove no entry is missing or reordered. An adversary who can't forge a U/D/A/H signature can still drop the entry for a disallowed action so the ledger reads clean, or reorder so an approval appears to precede a call it never covered. The replay-nonce protects a single approval; it says nothing about the set of entries.

The structural sibling is to chain the entries — each record commits to the hash of the previous (append-only hash chain, or a Merkle accumulator if you want O(log n) inclusion proofs). A dropped or reordered entry then breaks verification, and "the ledger is complete" becomes checkable rather than assumed. It composes cleanly with what you have: nonce = per-entry authenticity + anti-replay; chain = sequence integrity + completeness.

That also gives the mutation matrix a row beyond U/D/A/H — a completeness fixture: log a run, delete the entry for the action that should have been recorded, and assert (a) chain verification fails and (b) none of U/D/A/H individually would have caught a silently-omitted action. That row is what proves the four content-layers can't substitute for structural integrity.

One genuine question on H, since it's the hardest of the four: where does the verifier get ground truth for "description matches what actually happens"? Diffing the declared call against the observed tool-call args is tractable, but matching against actual effects seems to need the verifier to model each tool's semantics. Do you diff at the args layer, or capture post-conditions some other way?

Whatsonyourmind avatar Jun 27 '26 01:06 Whatsonyourmind

I would split H into two checks, because one verifier source cannot safely answer both.

The first check is representational honesty: did the action description match the call the runner was actually about to dispatch? That can be checked at the args layer. Canonicalize the tool name, args, principal, target scope, policy version, continuation identity, and expiry into the decision record, then recompute that digest at dispatch. If the visible description says one thing but the canonical dispatch tuple says another, the verifier can fail closed before the tool runs.

The second check is effect honesty: did the executed tool stay inside the effect boundary that was authorized? I would not make the verifier infer that from free text, and I would not require a general semantic model of every tool. The tool adapter should emit a typed outcome receipt with a small effect schema: effect class, target resource class, target identity digest when safe, result digest when available, side-effect class, and terminal state. The verifier compares that receipt against the authorized effect boundary, not against prose.

So the ground truth is layered:

  1. pre-dispatch canonical tuple for description versus intended call;
  2. runtime dispatch record for intended call versus actual invocation;
  3. adapter-emitted outcome receipt for actual invocation versus authorized effect boundary;
  4. optional domain-specific postcondition checks only for tools that can provide them.

The negative fixtures then become clear:

  1. description says read but canonical tuple is write: fail before dispatch;
  2. args digest changes after approval: stale or mismatched decision;
  3. tool returns an outcome receipt with a broader effect class than authorized: terminal policy violation;
  4. tool lacks a receipt for an effectful operation: incomplete outcome, not successful;
  5. receipt passes the generic boundary but a domain postcondition fails: domain violation.

That keeps H enforceable without pretending the verifier understands every tool's real-world semantics. The base contract is not "the verifier knows what happened in the world"; it is "the runtime and tool adapter must produce typed evidence precise enough that the authorized boundary can be checked."

Boundary: architecture and test-shape feedback only; no claim about ADK adoption, implementation, running code, verifier completeness, security review, production readiness, partnership, customer interest, official alignment, Google usage, ADK usage, conformance certification, or Neura usage.

rpelevin avatar Jun 27 '26 01:06 rpelevin

That layered split is the right resolution — it separates the trust sources (args-layer for representational honesty, adapter receipt for effect honesty) instead of asking one verifier to answer both. Three things I'd add:

The adapter receipt is itself a trust boundary. Layer 3 moves trust onto the tool adapter, but a compromised adapter is exactly the threat model that motivated putting the ledger outside the agent in the first place — it can emit a receipt claiming effect_class=read, within_boundary=true while doing more. For low-severity effect classes that's an acceptable assumption; for the high-severity ones (exfiltration, destructive write) I'd corroborate the receipt at an independent observation point — the sandbox's own fs/egress accounting — rather than the adapter's self-report. So layer 3 itself splits by severity: adapter receipt where the blast radius is small, boundary-observed evidence where it isn't.

Fixture 4 is a completeness check in disguise, and it needs the chain. "Tool lacks a receipt for an effectful operation → incomplete, not success" is only sound if the runtime guarantees a record per effectful dispatch — otherwise a silently-omitted dispatch is indistinguishable from "no effect happened." That's the sequence-integrity property from upthread: the per-entry digests prove what's present, the chain proves nothing effectful was dropped. So the chain isn't only for ordering — it's what makes fixture 4 enforceable rather than best-effort.

Canonicalization needs a fixed encoding. The pre-dispatch tuple → digest only survives "recompute at dispatch" if the serialization is deterministic across runs and languages (JCS / RFC 8785 or equivalent). Otherwise key ordering or number formatting yields false mismatches that present as fixture 2 (args digest changed after approval) when nothing actually changed — a flaky verifier is worse than a missing one because it trains people to ignore it.

Same boundary on my end — architecture and test-shape only, no implementation or adoption claim.

Whatsonyourmind avatar Jun 27 '26 02:06 Whatsonyourmind