{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-its-audit-trail-the-moment-a-tool-call-is-retried-sequence-number-collapse-in-per-turn-audit-ledgers-and-the-idempotency-key",
  "title": "Why does an instance lose its audit trail the moment a tool call is retried: sequence-number collapse in per-turn audit ledgers and the idempotency-key reuse that hides it",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agent runtimes that emit tool-call audit records keyed on a per-turn monotonic sequence number and that retry tool invocations under a stable idempotency key. Does not apply to runtimes that emit one audit record per transport attempt with a globally unique attempt ID and no key reuse.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-audit-trail-the-moment-a-tool-call-is-retried-sequence-number-collapse-in-per-turn-audit-ledgers-and-the-idempotency-key.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-audit-trail-the-moment-a-tool-call-is-retried-sequence-number-collapse-in-per-turn-audit-ledgers-and-the-idempotency-key.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-audit-trail-the-moment-a-tool-call-is-retried-sequence-number-collapse-in-per-turn-audit-ledgers-and-the-idempotency-key.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2197,
    "python_slice_tokens": 257,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **attempt identity** and **call identity**. A tool call is a logical request (\"charge card X for $40\"). An attempt is a physical execution of that request (the first try, the retry after a 503, the retry after a sandbox timeout). Audit ledgers are almost always written at the *attempt* layer because that is where the r...",
    "what_was_observed": "A research agent was given a task requiring it to fetch a document from an allowlisted host and then POST a summary to a second allowlisted host. The egress policy was enforced at the tool-call layer: each outbound HTTP call was checked against an allowlist and an audit record was appended to a per-turn ledger with fields `{turn_id, seq, tool, args_hash, idempotency_key, verdict, ts}`. During execution, the first POS...",
    "condition_of_validity": "The invariant that must hold for the ledger to be trustworthy is: > For every logical tool call, the number of audit records with distinct `(idempotency_key, attempt_ordinal)` pairs equals the number of physical attempts made, and the set of `attempt_ordinal` values is exactly `{0..n-1}` with no gaps and no reuse. The collapse occurs exactly when three condi...",
    "decision_boundary": "The runtime must decide, at the moment it invokes a tool, whether the invocation is a *new call* or a *retry of an existing call*. This is the decision boundary, and it must be made by consulting the retry wrapper's state, not by consulting the turn counter. - If the invocation carries a `(idempotency_key, attempt_ordinal)` pair that has not been seen, it is...",
    "operational_effect": "The operational consequence is that audit-trail completeness cannot be asserted from the ledger alone. Any claim of the form \"the agent made N outbound calls\" derived from a `seq`-keyed ledger is a lower bound, and the gap between the bound and the truth is exactly the number of retries that occurred under key reuse. For an agent operating near an egress rat..."
  },
  "matched_failure_symptoms": [
    "DUPLICATE_MUTATION_OR_BILLING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "64537e6c8948f1a352ae96f4a80f66da01a885e903d2e62455a5baff495122e6",
    "verified_classes": [
      "AuditLedgerCollapseError",
      "AttemptLedger"
    ],
    "verified_functions": [
      "record_tool_attempt",
      "__init__",
      "note_wrapper_attempt",
      "write",
      "reconcile"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "AuditLedgerCollapseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
