fix(substrate): retain failed fork tag cause #274
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues remain for the fork error-handling and cancellation updates.
No open issues 🎉
<details>
<summary><strong>What changed in this PR</strong></summary>
This PR fixes stateful Substrate Fork error handling so Go callers retain the original TagActor failure alongside the parent lifecycle refusal, addressing #268. It also completes the optional cancellation follow-ups from #273.
Changes:
SNAPSHOT_SUPERSEDED over a retained compute-busy cause, with regression coverage.| File | Description |
| ---- | ----------- |
| spec.md | Document snapshot-superseded reason precedence. |
| session/service.go | Clarify caller-interruption scope in comments. |
| session/memory_state_lost_test.go | Test lifecycle reason precedence after a busy tag failure. |
| session/errors.go | Select snapshot supersession before compute contention. |
| session/error_reasons_test.go | Verify reason selection for joined causes. |
| runtime/substrate/substrate.go | Wrap both lifecycle and tag failure causes. |
| runtime/substrate/substrate_test.go | Verify cause retention and tag cleanup ordering. |
| placement/placement.go | Clarify documented interruption boundaries. |
| placement/approval_test.go | Cover canceled Resume approval-handoff snapshot failure. |
| changelog/unreleased/substrate-fork-tag-cause.md | Record the fork error-chain fix. |
| changelog/unreleased/error-reasons-compat.md | Clarify public Suspend compatibility wording. |
</details>
<sub>Review effort: Balanced</sub>
Approved these changes.
LGTM, thanks.
gambtho
Tatsinnit
Summary
TagActorfailure when a stateful Fork finds its parent gone or supersededSNAPSHOT_SUPERSEDEDahead of a retainedCOMPUTE_BUSYcause in the public ErrorInfo reasonContext
runtime/substrate.Backend.Forkre-reads the parent after a failed tag so a deleted parent becomesMEMORY_STATE_LOSTand a moved parent becomesSNAPSHOT_SUPERSEDED. That branch wrapped the lifecycle error but formatted the original tag failure with%v, dropping it fromerrors.Is/errors.As.The fix joins both causes with
%w. Because a realTagActorfailure may also wrapErrActorBusy, the ErrorInfo selector keeps the fork lifecycle result authoritative: a superseded source still reportsSNAPSHOT_SUPERSEDED, notCOMPUTE_BUSY. The rendered error text and gRPC code remain unchanged.The first commit also resolves the two optional review notes left on #273 by adding the Resume variant and narrowing the
ErrAdmissionInterruptedcomments to the actual public boundaries.Closes #268.
Follow-up to #273.
Verification
go test ./runtime/substrate ./placement ./sessiongo test -race -shuffle=on ./runtime/substrate ./sessiongo test ./... -skip "^TestDocumentedPythonExecutorLogsStorageFailureWithoutPayload$"go test ./...inintegrations/substratego vet ./runtime/substrate ./sessiongo build ./...go run ./hack/doccheckgo test ./hack/changeloggo run ./hack/changelog check -base upstream-agentsession/main -head HEAD -skip=falsegit diff --checkThe one excluded root test is environment-specific: macOS Python 3.9.6 reports SQLite error name
unknownwhere the test requiresSQLITE_ERROR; it reproduces on the unmodified base.