Skip to content

audit anchor recovery: new-epoch, epoch-aware verify-anchor, startup detection, off-host copy (from #3549) #3772

Done

Description

@hsinatfootprintai

Follow-up to #3549. Surfacing a refused audit anchor (health, doctor, metrics, log line) shipped in #3649. This issue is the recovery path that #3549 left open.

Problem

When the audit database is recreated or restored from an older point, the chain starts again near checkpoint 1 while the anchor file on the host still records a later checkpoint. Anchoring refuses forever. Today the only fix is moving files by hand.

Scope (items 2–6 of #3549)

  1. A first-class recovery command, for example containarium audit anchor new-epoch (name tentative).
  2. audit verify-anchor understands epochs: a documented, recorded break verifies as a break, not as tampering. An unexplained drop still fails as it does today.
  3. Detect a reset chain at startup (chain length or base behind the last anchored checkpoint) and report it once, clearly, instead of a silent per-tick loop.
  4. Keep a second copy of the anchor file off the host by default, or have doctor warn when only a local file is configured.
  5. Runbook section: "the audit database was recreated or restored".

Constraints (from #3549, binding)

The refusal exists to defeat rollback, so the recovery path must not become the way to launder one. new-epoch must:

  • never delete the old file (archive it, with its sha256 recorded);
  • write a break record that verify-anchor and the proof pack show;
  • record the actor in the audit chain;
  • require an explicit flag, so it cannot run by accident.

An unexplained jump keeps failing verification.

Acceptance

  • new-epoch archives the old file (sha256 recorded), writes the break record, and the next tick publishes successfully.
  • verify-anchor reports a recorded break as a break and an unexplained drop as a failure.
  • A reset chain is detected once at startup with a clear message.
  • Runbook section exists and matches the commands.

Part of #3725's sprint track. Phase 2: the recovery is needed, but the flow works with surfacing alone.

Activity

  1. added
    security
    phase-2-optimize
    on Nov 17, 2026
  2. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet is starting processing it. This issue is too large for one reviewable PR, so I am cutting it into slices; this claim covers slice 1 only and the issue stays open after it:

    1. Format + library core (this PR): a break record in the anchor file; FileSink.NewEpoch (archives the old file with its sha256, never deletes it, writes the break record, atomic replace); every reader of the file made safe against break lines; rollback protection unchanged inside an epoch. No CLI, no daemon wiring.
    2. containarium audit anchor new-epoch (explicit confirmation flag, root-level caller) and the actor recorded in the audit chain.
    3. verify-anchor reports a recorded break as a break (local file, bucket, TSA) while an unexplained drop still fails.
    4. Startup detection of a reset chain (once, clearly), doctor warning when only a local file is configured, off-host copy.
    5. Runbook section.

    Open choices, defaults I am taking unless told otherwise: command name new-epoch as in the issue; the break record is a JSON line with "kind":"epoch_break" in the same file.

  3. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 1 PR opened at f610ecbd — CI pending. The issue stays open for slices 2–5 (listed in the claim above).

  4. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet is starting processing it. Slice 1 merged (0f22bf0). This claim covers slice 2 only: containarium audit anchor new-epoch (explicit confirmation flag, root caller) and recording the actor in the audit chain. Slices 3–5 stay open.

  5. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 2 PR #3885 opened — CI pending. Issue stays open for slices 3–5.

  6. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 2 merged (c5df8b3). Slice 3a PR opened (local-file break reporting + archive check); 3b (bucket/TSA across a break) is next. CI pending.

  7. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 3b (bucket and timestamp tokens across a break) is not started: it needs a design decision, so I am flagging it here instead of improvising.

    Finding. The bucket sink names each object by checkpoint alone (%020d.json), writes with --if-generation-match=0, and LastPublished is the highest object name. The TSA token directory does the same (<anchor-path>.tsa/<checkpoint>.tsr). After new-epoch the chain restarts at low checkpoints, so with a bucket configured:

    • the daemon's bucket LastPublished is still the old epoch's high checkpoint, so it refuses to anchor again (the original problem, now in the bucket);
    • a new epoch's checkpoint that already exists in the bucket with a different root fails as ErrAnchorConflict;
    • verify-anchor --anchor-bucket reports the old epoch's checkpoints as above the chain tip.

    No change on the verify side alone fixes this; the object naming has to change.

    Proposed default (needs a yes): an epoch number. The break record gains epoch (n+1), epoch 1 keeps today's names so existing buckets and token dirs stay valid, and epoch n>1 publishes under <prefix>epoch-<n>/ and <path>.tsa/epoch-<n>/. Verification then treats each earlier epoch as sealed history that must equal what its verified archive holds, and checks only the current epoch against the database. An unexplained checkpoint in any prefix still fails. The break record change is additive, so slices 1–3a need no rework.

    Alternative: the operator points the daemon at a new bucket prefix at new-epoch time and the break records the old one. Simpler code, but it moves a safety property onto a manual step.

    Slices 4 (startup detection, doctor warning, off-host copy) and 5 (runbook) do not depend on this and can proceed. Slice 3a is in #3891 (local file only).

  8. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: decision received from the maintainer: epoch numbering for slice 3b (design as proposed above). 3b is unblocked but not started; I am taking slice 4 now (startup detection of a reset chain, doctor warning when only a local anchor file is configured, off-host copy).

  9. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 4a PR #3892 opened (startup detection). Slice 4b (doctor warning for a local-only anchor, off-host copy) needs a decision: a readiness entry would show OK: false on every default install in the cloud probe. Default I would take: a doctor-only advisory line that reads the daemon's anchor configuration, not a readiness entry. Not started. 3b (epoch numbering, approved) is also not started. CI pending on #3891 and #3892.

  10. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 3b PR #3893 (epoch numbering, stacked on #3891) and slice 5 PR #3894 (runbook, stacked on #3893) opened; slice 4a is #3892. All CI pending. Remaining open item on this issue: 4b (doctor warning for a local-only anchor / off-host copy), waiting on a decision.

  11. hsinatfootprintai commented on Dec 2, 2026

    @hsinatfootprintai
    ContributorAuthor

    agent-2bc6610c-sonnet: slice 4b PR #3896 opened at 6e8af21f — CI pending. Doctor-only advisory; closes this issue on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

phase-2-optimizesecurity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions