Repository navigation
fix(placement): keep fork failure when deadline lapses in teardown - #283
Merged
Anish Ramasekar (aramase) merged 1 commit intoNov 17, 2026
Conversation
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preserving primary fork failures when caller cancellation or deadlines occur during teardown.
No open issues 🎉
What changed in this PR
Fixes #269 by preserving a Substrate fork’s primary failure when the caller’s deadline or cancellation occurs during backend teardown. Caller interruptions before or during the failing operation retain their existing classification.
Changes:
- Record caller context state before fork teardown using an internal error marker.
- Preserve marked failures in placement without changing error text or cause chains.
- Add regression coverage and a changelog entry; no public API, proto, or journal changes.
| File | Description |
|---|---|
session/error_fork_test.go |
Tests public status and reason preservation through the Substrate backend. |
runtime/substrate/substrate.go |
Captures caller state at teardown start and marks returned failures. |
runtime/substrate/substrate_test.go |
Tests marking across cancellation and cleanup boundaries. |
placement/cleanup.go |
Preserves marked failures instead of reclassifying them as caller interruptions. |
placement/cleanup_context_test.go |
Covers cancellation during runtime teardown. |
internal/callerctx/callerctx.go |
Adds the internal error marker and detection helper. |
changelog/unreleased/fork-primary-failure-after-deadline.md |
Documents the corrected fork failure classification. |
Review effort: Balanced
Tom Gamble (gambtho)
approved these changes
Nov 17, 2026
Anish Ramasekar (aramase)
merged commit Nov 17, 2026
bf2c1f0
into
agent-primitives:main
19 checks passed
Anish Ramasekar (aramase)
deleted the
aramase/i/fork_deadline_primary_error_269
branch
November 17, 2026 16:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a substrate
Forkfails while the caller is still waiting, the backend tears down the half-made child before it returns. If the caller's deadline or cancellation lapsed during that teardown,allocationStartErrorsaw an ended context and reported DEADLINE_EXCEEDED or CANCELED instead of the real failure (for example UNAVAILABLE withCOMPUTE_UNAVAILABLE). Fixes #269.runtime/substrate: the first Fork teardown step records whether the caller's context was still live, andForkmarks the returned error accordingly. The error text anderrors.Is/Aschain are unchanged.internal/callerctx(new, module-internal): the mark and its check. No public API, proto or journal change.placement:allocationStartErrorreturns a marked error unchanged. Unmarked errors, including a caller context that ended before or during the failing call, are classified as before.Tested with new rows in the placement and substrate tests, plus a session-level test through the real substrate backend over a fake control client. In it the child's resume fails with
ErrComputeUnavailableand teardown outlasts a 250ms caller deadline: the status stays UNAVAILABLE with reasonCOMPUTE_UNAVAILABLE. A deadline that lapses inside the resume itself still returns DEADLINE_EXCEEDED. The session test fails on the base commit.go test -raceon placement, runtime/substrate, session and internal,go vet ./..., gofmt and the changelog check all pass.