Skip to content

fix(continuation): never-supersede a RUNNING continuation work (#988-P2-1, Pillar-3 fold-side write-guard)#993

Merged
scribe-dandelion-cult merged 1 commit into
frond-scribe/20260609/assembly-token-wiringfrom
codeagent/988-p2-1-write-guard
Jun 11, 2026
Merged

fix(continuation): never-supersede a RUNNING continuation work (#988-P2-1, Pillar-3 fold-side write-guard)#993
scribe-dandelion-cult merged 1 commit into
frond-scribe/20260609/assembly-token-wiringfrom
codeagent/988-p2-1-write-guard

Conversation

@scribe-dandelion-cult

Copy link
Copy Markdown

#988-P2-1 — Pillar-3 fold-side write-guard (the last open codex-P2)

Closes the "recovered-running mis-superseded" P2. Stacks on assembly a437ca7 (complete doom-lock cure).

The bug

The running-work recovery path (dispatchPendingContinuationWork with includeRunning: true) can pass running flows to partitionSupersededWork, which folds any non-newest stale member into supersededmarkPendingWorkSuperseded → terminal. A recovered running work (actively observing requests-in-flight) could thus be finished-as-superseded out from under an in-flight turn.

The fix (two-part, surgical)

  1. carry status onto PendingContinuationWork (sourced from flow.status in workToRuntime).
  2. never-supersede-running in partitionSupersededWork: a running member always drives; only queued members are supersede-eligible. The continuation: add maxPendingWork + drain-superseded guard for multi-continue_work flood (fast-follow to #982/#985) #986 Guard-2 fold for queued members (newest-elected-drives, close-burst-drives, hop/electedAt tie-break) is preserved exactly.

Invariant: only-coalesce-queued · carry-status · never-supersede-running. Distinct from the requeue READ-guard (requeuePendingWork:259) — this is the FOLD-side WRITE-guard. Scheduled-depth count untouched. No #990 give-up-fork coupling.

Verification

  • work-dispatch.test.ts 28/28 green; RED-verified the 3 new fix(continuation): maxPendingWork cap + drain-superseded guard (#986) #988-P2-1 cases fail without the guard (running-not-superseded · queued-still-folds · mixed-batch).
  • Full suite: 88 shards / 6 failed — all known-baseline-env (agents-core model-selection, extension-memory, secrets channel-contract, imessage, telegram, tooling pnpm-path); continuation shard green.
  • tsgo:core + core-test clean, type-aware oxlint 0 new, oxfmt clean.

Owner-reviewer 🌊 (Pillar-3 spec). Lane: codeagent/988-p2-1-write-guard @ 744a18e.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

…P2-1)

Fold-side write-guard (Pillar-3). The running-work recovery path consumes
flows whose PRE-claim durable status is `running` (recovered active turns),
so the batch handed to partitionSupersededWork could include live, in-flight
turns. partitionSupersededWork folded any stale non-newest member into the
superseded bucket without a status check, so a recovered `running` turn that
is actively driving (observing requests-in-flight) could be marked terminal
out from under itself.

Two-part guard (only-coalesce-queued / carry-status / never-supersede-running):
1. Carry the PRE-claim flow status onto PendingContinuationWork via
   workToRuntime; consumePendingWork captures it before the claim flips every
   consumed flow to `running`.
2. partitionSupersededWork always routes `status === "running"` members to
   drive, never superseded, regardless of staleness or election order. The
   existing #986 queued-backlog coalesce (newest-elected drives, close-burst
   drives, tie-break by hop) is unchanged.

Tests extend the existing partitionSupersededWork unit suite (running-not-
superseded, queued-still-folds, mixed batch) plus an end-to-end dispatch test
proving the carried status survives consumePendingWork. RED-verified the new
cases fail without the guard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@scribe-dandelion-cult scribe-dandelion-cult merged commit 0ea26ac into frond-scribe/20260609/assembly-token-wiring Jun 11, 2026
130 of 143 checks passed
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.

1 participant