Skip to content

fix(agent): settle finalized SWM after catch-up - #2035

Open
branarakic wants to merge 2 commits into
codex/rfc64-m1-cold-join-swm-retirementfrom
codex/rfc64-m1-post-sync-finalization
Open

fix(agent): settle finalized SWM after catch-up#2035
branarakic wants to merge 2 commits into
codex/rfc64-m1-cold-join-swm-retirementfrom
codex/rfc64-m1-post-sync-finalization

Conversation

@branarakic

Copy link
Copy Markdown
Contributor

User impact

A cold Edge receiver that explicitly subscribes to a public Context Graph now converges to one user-visible finalized state after foreground catch-up:

  • finalized content remains visible in Verifiable Memory;
  • the publisher's physically retained SWM recovery copy is hidden from the user-facing SWM view;
  • a newer or unmatched SWM draft remains visible;
  • no global subscription or all-CG synchronization is introduced.

This closes the testnet-canary seam where durable VM catch-up succeeded first, then public SWM snapshot materialization re-exposed the same finalized assertion as live SWM.

Before

sequenceDiagram
    participant E as Cold Edge
    participant C as Core provider
    participant S as Local store
    participant Q as User query

    E->>C: Foreground durable VM catch-up
    C-->>E: Finalized assertion and confirmed metadata
    E->>S: Store exact VM
    E->>C: Public SWM snapshot catch-up
    C-->>E: Retained recovery snapshot and verified head
    E->>S: Materialize SWM and advance checkpoint
    Q->>S: Query VM and SWM
    S-->>Q: Finalized assertion appears in both views
Loading

After

sequenceDiagram
    participant E as Cold Edge
    participant C as Core provider
    participant B as Chain
    participant S as Local store
    participant Q as User query

    E->>C: Foreground durable VM catch-up
    C-->>E: Finalized assertion and confirmed metadata
    E->>S: Store exact VM
    E->>C: Public SWM snapshot catch-up
    C-->>E: Retained recovery snapshot and verified head
    E->>S: Materialize SWM and verified metadata
    E->>S: Reverify exact confirmed VM
    E->>B: Read latest root, version, and CG binding
    B-->>E: Current canonical state
    E->>S: Recheck exact SWM under per-KA writer lock
    E->>S: Stamp local retirement marker
    E->>E: Advance sync checkpoint
    Q->>S: Query VM and SWM
    S-->>Q: Finalized assertion only in VM; newer SWM drafts remain
Loading

Safety properties

  • Peer metadata alone cannot retire SWM. The receiver requires surviving confirmed VM metadata and exact local VM content.
  • Root, assertion version, KA-to-CG binding, and local CG identity are re-read from chain while the shared per-KA writer lock is held.
  • The exact current SWM head is re-read and verified under that lock before the marker is written.
  • The physical SWM snapshot is retained for recovery or reorg handling.
  • If chain verification or the retirement handoff fails, meta/data checkpoints do not advance and the sync remains retryable/incomplete.
  • Unfinalized drafts and superseded snapshots are not retired.

Validation

  • Focused finalization and SWM materialization lane: 62 passed.
  • Full Agent unit lane: 165 files, 2,241 passed, 5 skipped, 0 failed.
  • Agent build: TypeScript, type-contract tests, and package-root test passed.
  • git diff --check passed.

Stack

Stacked on #2034. The fresh two-node testnet-canary validation runs against this exact head after review CI starts; no production Core deployment and no merge are part of this PR.

Comment thread packages/agent/src/finalization-handler.ts Outdated
Comment thread packages/agent/src/sync/requester/shared-memory-sync.ts Outdated
Comment thread packages/agent/src/finalization-handler.ts
Comment thread packages/agent/test/ka-graph-finalization-handler.test.ts Outdated
Comment thread packages/agent/src/sync/requester/shared-memory-sync.ts
Comment thread packages/agent/src/sync/requester/swm-snapshot-materializer.ts
Comment thread packages/agent/src/sync/requester/swm-snapshot-materializer.ts
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.

2 participants