fix(placement): refuse unsafe memory checkpoints #296
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #296"
general
weight: 0.35
aramase
Summary
CHECKPOINT_INCOMPLETE_TURN, strengthen the Runtime checkpoint contract, and update conformance/docsFixes #98.
Problem
A
REQUIRES_MEMORY_SNAPSHOTharness can mutate RAM before its next durable sink record. Previously, a stateful Fork could fence and close that turn, then snapshot the mutated RAM while its journal still lackedEND. Suspend could also snapshot an abandoned incomplete execution. A later Resume restored that RAM and re-drove the incomplete turn, applying the mutation twice.The same mismatch could occur when another host advanced the journal while public Suspend was capturing RAM: Suspend used to append at the post-snapshot current head rather than the head it validated before capture.
Design
Controller-owned checkpoint classifier
controller.ValidateCheckpointStateverifies the supplied hash chain and reuses the controller's execution and approval projections. A memory checkpoint is accepted only when recovery cannot re-run captured mutations:Harness.RunIt refuses ordinary modern or legacy incomplete turns, modern
ERRORtails, markerless pending turns, decided approval gates without a receipt, receipted executions withoutEND, and malformed evidence.A decided gate is deliberately refused: an earlier recovery may have changed RAM before failing without a receipt.
Stateful Fork admission
A memory-tier Fork temporarily takes the existing session operation guard through journal validation and checkpoint-mark installation. Therefore:
SESSION_BUSYCHECKPOINT_INCOMPLETE_TURNAfter the checkpoint mark is installed, the transient operation hold is released so calls during snapshot/fan-out retain
CHECKPOINT_IN_PROGRESSbehavior.Stateless forks are unchanged.
Memory Suspend publication
On a memory-capable backend, Suspend admits the harness to determine whether it is memory-tier. A memory-tier Suspend:
1. verifies and classifies the current records
2. mints a fence before capture
3. rereads and revalidates the same exact head
4. calls
Snapshot(EXTERNAL)5. appends
SUSPENDwith CAS at that validated head and fenceA peer writer can therefore invalidate publication, but cannot widen the accepted checkpoint boundary over its incomplete turn. If the physical capture landed before the CAS failed, the Runtime contract now requires a memory backend to quarantine it by refusing a mismatched
RecordedCheckpoint; Substrate already enforces that rule.Stateless Suspend keeps its existing replay-safe behavior.
Public errors
Abandoned incomplete memory checkpoints map to:
FAILED_PRECONDITIONgoogle.rpc.ErrorInfo{domain: "agentsessions", reason: "CHECKPOINT_INCOMPLETE_TURN"}Active local contention remains
ABORTED / SESSION_BUSY. Tampered Suspend journals areDATA_LOSS. Memory-capable Suspend admission maps unavailable harnesses toUNAVAILABLE / HARNESS_UNAVAILABLE, and descriptor/class refusals toFAILED_PRECONDITION.Tests
Added or updated coverage for:
Verification
go test -race -shuffle=on ./controllergo test -race -shuffle=on ./placementgo test -race -shuffle=on ./sessiongo test -race -shuffle=on ./...inintegrations/substratego test -race -shuffle=on ./...inintegrations/claudecodego build ./...go vet ./...buf lintbuf breaking --against ".git#tag=v0.4.0,subdir=api"go run ./hack/doccheckpython3 hack/verify_chain.py --golden./hack/verify_chain.shgofmt -l .git diff --checkThe repository-wide root race run still reaches the pre-existing Python 3.9 portability failure in
internal/agentsessionsd.TestDocumentedPythonExecutorLogsStorageFailureWithoutPayload: Python reports the documented fallbacksqlite_errorname=unknownwhile the test expectsSQLITE_ERROR. The same targeted failure reproduces on cleanmain; all changed packages pass under the race detector.