Skip to content

fix(substrate): report and enforce observed snapshot fidelity - #181

Merged
Anish Ramasekar (aramase) merged 7 commits into
agent-primitives:mainfrom
gambtho:fix/substrate-snapshot-fidelity
Oct 19, 2026
Merged

Anish Ramasekar (aramase) merged 7 commits into
agent-primitives:mainfrom
gambtho:fix/substrate-snapshot-fidelity

Conversation

@gambtho

@gambtho Tom Gamble (gambtho) commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Refs #170

Reports observed Substrate snapshot fidelity and enforces memory/VOLUMES-only checkpoint requirements while preserving legacy stateless recovery.

Compatibility: custom clients must report fidelity; invalid checkpoints return FAILED_PRECONDITION. Paused actors may resume local rather than validated durable checkpoints; this remains a known limit.

Verification: root/nested race suites, vet, lint/staticcheck, generation, docs and integrity checks passed; no new local live-cluster run.

@gambtho
Tom Gamble (gambtho) requested a review from a team as a code owner October 17, 2026 20:27

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tom. The reporting half looks right: URI and fidelity come from the same selected entry, Memory is true only for observed MEMORY, and the #153 lost/replaced-actor checks still run first. Two things on the enforcement half before this goes in (inline):

  1. The fidelity check runs after SuspendActor and records nothing, so the next Create/Restore resumes the snapshot that was just refused. With WithVolumesOnly that brings back process memory; on a memory-tier session it resumes a VOLUMES snapshot under the same UID, which passes the instance check and runs the turn without its RAM state.
  2. The new refusals are untyped errors, so a stateful Fork refusal that used to be FAILED_PRECONDITION is now INTERNAL, and the test that pinned the code was loosened.

Smaller: the record-before-validate comment at placement/placement.go:1488-1491 is stale now that substrate validates inside Snapshot. Also, does a fork child's borrowed snapshot entry carry fidelity?

Comment thread runtime/substrate/substrate.go Resolved
Comment thread runtime/substrate/substrate.go Resolved
Comment thread placement/placement_test.go Resolved
Comment thread CHANGELOG.md Resolved
Comment thread runtime/substrate/substrate_test.go Resolved
Comment thread integrations/substrate/adapter.go Resolved
@gambtho

Copy link
Copy Markdown
Member Author

Updated the stale Placer comment. On borrowed fidelity: at the pinned Substrate the tag copies fidelity and the child's borrowed generation keeps it, so fork children get no exemption.

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fence fixes the earlier comments. One regression inline for sessions that main already suspended, plus two doc nits.

Comment thread runtime/substrate/substrate.go Resolved
Comment thread docs/substrate-conformance.md Resolved
Comment thread docs/substrate-conformance.md Resolved
Copilot AI balanced review requested due to automatic review settings October 19, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Recovery validation checks durable metadata rather than the effective resume source, requiring correction and human review of stateful recovery behavior.

1 open issue
What changed in this PR

Reports observed Substrate snapshot fidelity and enforces checkpoint requirements for memory-dependent and files-only sessions.

Changes:

  • Carries snapshot URI and fidelity from the same completed generation.
  • Adds VOLUMES-only admission and checkpoint validation.
  • Updates error mapping, regression tests, and compatibility documentation.
File Description
spec.md Documents fidelity and recovery requirements.
session/​service.go Maps invalid checkpoints to failed preconditions.
session/​memory_state_lost_test.go Generalizes the control-client helper.
session/​fork_wake_test.go Supplies snapshot evidence in test controls.
session/​checkpoint_fidelity_test.go Tests refusal without journal changes or revival.
runtime/​substrate/​substrate.go Adds fidelity reporting and checkpoint enforcement.
runtime/​substrate/​substrate_test.go Covers fidelity validation and compatibility.
placement/​suspend_test.go Tests legacy stateless checkpoint recovery.
placement/​placement.go Classifies refused fork checkpoints.
placement/​placement_test.go Tests checkpoint refusal before journaling or cloning.
placement/​harness_identity_test.go Supplies held-snapshot evidence.
integrations/​substrate/​fork_test.go Updates incomplete-checkpoint expectations.
integrations/​substrate/​adapter.go Extracts fidelity and snapshot-history evidence.
integrations/​substrate/​adapter_test.go Tests selection and evidence mapping.
docs/​substrate-conformance.md Explains files-only configuration and limitations.
CHANGELOG.md Records behavior and compatibility changes.
api/​runtime.go Defines the invalid-checkpoint sentinel.

Review effort: Balanced

Comment thread runtime/substrate/substrate.go Resolved

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 70d048b. All of my earlier threads check out. I confirmed the refuse-after-capture fence holds across a host restart (a fresh host on the same control plane and journal refuses Exec, Resume, Fork and Suspend), and that a stateless journal written by main resumes again with VOLUMES and UNKNOWN actors. LGTM from my side; two doc nits below, fine as a follow-up.

On the effective-resume-source question I answered in the thread: follow-up.

Comment thread docs/substrate-conformance.md Resolved
Comment thread CHANGELOG.md Resolved
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.

3 participants