Skip to content

fix(placement): keep fork failure when deadline lapses in teardown - #283

Merged
Anish Ramasekar (aramase) merged 1 commit into
agent-primitives:mainfrom
aramase:aramase/i/fork_deadline_primary_error_269
Nov 17, 2026
Merged

Anish Ramasekar (aramase) merged 1 commit into
agent-primitives:mainfrom
aramase:aramase/i/fork_deadline_primary_error_269

Conversation

@aramase

Copy link
Copy Markdown
Collaborator

When a substrate Fork fails 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, allocationStartError saw an ended context and reported DEADLINE_EXCEEDED or CANCELED instead of the real failure (for example UNAVAILABLE with COMPUTE_UNAVAILABLE). Fixes #269.

  • runtime/substrate: the first Fork teardown step records whether the caller's context was still live, and Fork marks the returned error accordingly. The error text and errors.Is/As chain are unchanged.
  • internal/callerctx (new, module-internal): the mark and its check. No public API, proto or journal change.
  • placement: allocationStartError returns a marked error unchanged. Unmarked errors, including a caller context that ended before or during the failing call, are classified as before.
  • Changelog fragment added.

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 ErrComputeUnavailable and teardown outlasts a 250ms caller deadline: the status stays UNAVAILABLE with reason COMPUTE_UNAVAILABLE. A deadline that lapses inside the resume itself still returns DEADLINE_EXCEEDED. The session test fails on the base commit. go test -race on placement, runtime/substrate, session and internal, go vet ./..., gofmt and the changelog check all pass.

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
@aramase
Anish Ramasekar (aramase) marked this pull request as ready for review November 17, 2026 06:39
@aramase
Anish Ramasekar (aramase) requested a review from a team as a code owner November 17, 2026 06:39
Copilot AI balanced review requested due to automatic review settings November 17, 2026 06:39

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.

🟢 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

@aramase
Anish Ramasekar (aramase) merged commit bf2c1f0 into agent-primitives:main Nov 17, 2026
19 checks passed
@aramase
Anish Ramasekar (aramase) deleted the aramase/i/fork_deadline_primary_error_269 branch November 17, 2026 16:34
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.

Preserve the primary fork failure when the caller's deadline expires during detached cleanup

3 participants