Skip to content

fix(automation): a branch whose subflow or map child parks, where the run cannot park, fails the run instead of dropping work - #39030

Merged
objectstack-fleet[bot] merged 18 commits into
mainfrom
claude/issue-38876-subflow-branch-pause-lost
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 18 commits into
mainfrom
claude/issue-38876-subflow-branch-pause-lost

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Part of #38876

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:流程运行时,一个节点同时分出多条分支、或先走一条条件分支,而某条分支里的子流程停在审批或等待处时,运行不再悄悄完成并漏掉另一条分支,而是失败并写明哪一步、为什么、怎么改;若另一条分支先停下,运行先显示"已暂停",随后改为失败。
  • 为什么做:属于"流程暂停不能丢分支"这一组修复,替审批流的作者解决分支后续丢失、审批单决定后流程不动的问题;保存时的检查看不到子流程会不会暂停,只能在运行到那里时拦下。
  • 出错会怎样:只影响这两种本来就会丢分支的流程形状,它们改为报错而不是假装成功,其余流程照旧,暂停的时机和记录也与原来一致;改动可直接撤回。
  • 要你做什么:裁决"启用触发器前就拒绝这类流程"的另一半是否做(需要改公开契约),选项在派发席转来的决策里。

What changes

The run-time door of the limit #3267 ruled 禁, for the two shapes the parse rules of #38871 and #38970 cannot see because a subflow / map pauses only when the child flow it names does (ruling D: not judged by type).

  • New service-automation/src/branch-suspension-refusal.ts: FlowBranchSuspensionRefusalError (an Error, recognised by a registered symbol, branded a guard refusal via markGuardRefusal, carrying shape, forkNodeId, suspendedEdge, suspended[] with each child flow, untakenEdges[]), the two traversal helpers and the late feed:
    • runConcurrentBranches: the unconditional bucket. The node answers at its FIRST rejection, at the moment it arrives, as Promise.all did, so a pause is never delayed and nothing ever waits on a sibling. First a suspension with nothing else collected yet: it is thrown, the run parks and its pause is stored exactly as before (same moment, step log ending at the node it parked on), and the branches still running are recorded on the signal. First a suspension with a second suspension or a pause refusal (branch or region) already collected when the frame resumes: the refusal is thrown at once, nothing is stored, every parked child cancelled. First anything else: thrown as before, and a branch that suspends after it has its child run cancelled.
    • the late feed: runConcurrentBranches records, on the signal it throws, a feed of the fan-out's later rejections that hands each one over the moment its branch rejects (never once every branch has settled).
    • runSequentialBranch: a conditioned or isDefault branch that suspends while the traversal still has an edge to take after it (a later conditioned edge whose condition holds at the pause, on any node but an exclusive decision; a later isDefault edge; any unconditional edge) is the sequential refusal, thrown at once (sequential edges are awaited anyway, so nothing waits that did not before). Nothing left to take: the suspension is re-thrown untouched.
  • New service-automation/src/late-branch-watch.ts: watchLateBranches, armed by the three places that store a pause (execute, a retry attempt in executeWithoutRetry, a resume that parks again in resumeInternal) right after they stored it, never awaited, and never rejecting (a fault inside is said at error). It acts on the FIRST late suspension or branch/region refusal, bound to the pause it watched: it enters the engine's in-process resume gate (ResumeGate, the resuming set resume takes, now able to be waited on) UNDECIDED, reads the run strictly, leaves it alone unless it is still parked at the watched node with the watched correlation, claims that pause through claimAdvance (which compares the same node and correlation), marks the gate decided, writes the failed record from the stored pause (the write guarded as settleUnresumableSuspension guards it), fails the ancestors, and cancels every child run the suspensions parked. A run a decision has moved on (finished, or parked again elsewhere) keeps its new pause and that pause's child; the late child is cancelled and one error line says the run had already left that pause. While the gate is undecided, a resume that meets it (a child's bubble to its parent, an approval decision) waits for the watch's read and claim instead of being refused: it goes on when the watch leaves the run alone, and is answered RESUME_IN_PROGRESS as before once the watch has claimed the pause. It never waits on a node's release hook, so a hook that resumes the run is answered, never deadlocked. A throw while failing an ancestor is said at error and no longer skips the late child's cancellation. A store that cannot be read or claimed gets its own error line (the run may still read paused, cancel it with cancelRun), never the moved-on one. The ancestor walk leaves a pending failure under each parent's id BEFORE reading it; a parent the read finds is failed by the walk, one whose pause is not stored yet takes the entry from its own store step (the same watchLateBranches call) and fails itself, so no parent stays parked on a child the watch failed. The watch lives in process memory: an engine restarted between the store write and the late settle keeps base's behaviour.
  • New parked-child-cancel.ts: runRegion's child-run cancellation (the strict chain read, deepest first, the two error lines), moved out unedited apart from the location phrase, so the region refusal and the branch refusal call one copy. The region's log text is byte-identical.
  • dag-traversal.ts: traverseNext calls the two helpers; runRegion re-raises a branch refusal met inside a region body as the region refusal (the containers know that type, and a region cannot pause on any branch), calls the shared cancel, and cancels what a converted suspension's late branches park; executeWithoutRetry arms the late watch after storing its pause.
  • engine-run-facet.ts, run-resume.ts: execute and resumeInternal arm the late watch after storing a pause; resumeInternal waits, before its synchronous gate check, while the watch holds the gate undecided. engine.ts: watchLateBranches (a host of forwarders and one forwarding call; check:facade-delegation-only green), resuming is a ResumeGate (same has / add / delete, plus the watch's undecided hold), pendingAncestorFailures is a bounded map (1000, oldest first), the traverseNext host carries resolveSuspensionChainForCancel and cancelRun, and three hosts carry watchLateBranches. dry-run.ts: its traversal host carries the two cancel members, which a dry run never reaches (it starts no child run).
  • Docs (content/docs/automation/flows.mdx): the two "not judged here" sentences point to a paragraph teaching the run-time refusal, its two messages, WHEN it fires (at once, or after the run answered paused), what is cancelled and what is left. Changeset @objectstack/service-automation patch.

Not built: the arming half. Two reasons, both outside this claim's file surface and both contract changes: a declined flow reports an unboundCause from the sealed list FLOW_UNBOUND_CAUSES in packages/spec/src/contracts/automation-service.ts (no member fits; reusing suspending_subflow_in_region would make /_status lie), and the traversal model the arming reader needs (which out-edges run together, which before which) is private to packages/spec/src/automation/flow-concurrent-pause.ts. Reported to the seat as a decision with options; this PR leaves the card open.

Read first

  1. packages/services/service-automation/src/late-branch-watch.ts, ResumeGate, failParkedRun and failAncestorsAfterLateFailure: the risk is the late failure of a run already answered paused: the gate and its undecided hold (where decide is called, before the release hook), the watched-pause check before the claim, and the set-before-read hand-over to a parent not yet stored.
  2. packages/services/service-automation/src/branch-suspension-refusal.ts, runConcurrentBranches: the first rejection answers at once; the feed hands later ones over as they arrive.
  3. packages/services/service-automation/src/dag-traversal.ts, traverseNext: takenAfterwards and wouldHold judge the later edges only after a suspension, so a traversal that does not pause evaluates exactly what it did.

Tests

Measured first, through registerFlow + execute on the real engine and approval service (a scratch file on this rig, deleted), against the base dist:

  • CONCURRENT (a_review beside sub, child parks on c_review): paused, two pending requests, two suspensions. Child decided first: child [finalized, resumed] = [true, true], the parent run completed with steps start, a_review, and a_review's decision threw RESUME_TARGET_LOST, the request still pending. Parent decided first: both decisions [true, true], the work after sub never ran.
  • SEQUENTIAL (x1 -c1-> sub, x1 -c2-> s_sync, both true): paused, c_review decided [true, true], the run completed with steps start, x1, sub; s_sync never ran.
  • After: both end failed with the named refusal, the child run cancelled, nothing parked.

Pinned:

  • plugin-approvals/src/flow-route.integration.test.ts, top-level describe [#38876] (one ObjectQL in beforeAll(() => boot(), 30_000), afterAll destroy), 14 cases: 5 refusals (concurrent with a subflow, with a map, two subflows with an approval child and a timer child; sequential conditioned; sequential isDefault beside an unconditional sibling), the contract review's M1 in both arrival orders (an approval beside x1, whose true edge enters the subflow before a later true edge: approval parks first, the refusal arrives after and fails the parked run; a delay before the approval, the refusal arrives first and fails the run at execute), the race arms on a gate node the case opens (RE-PARK: a_review approved parks the run at b_review, then a late timer-child branch suspends, or is refused as sequential: the run is left at b_review, one moved-on line, b_review's decision completes it, nothing parked; RESUME WINS: a_review approved completes the run, then the late branch suspends: still completed, the late child cancelled; DECIDED IN THE WINDOW: a_review approved parks the run at b_review, the late branch suspends, and b_review is decided while the watch's store read of the run is held in flight: the decision answers [finalized, resumed] = [true, true], the run is left alone and completed, nothing parked), and 3 controls (one pausing branch beside a synchronous one parks and completes with s_after run; the call branch taken last; a later sibling whose condition is false at the pause). The refusal helper reads a late failure through getRun and waits for every run to leave the store.
  • service-automation/src/branch-suspension-refusal.test.ts, 29 cases on timer children: concurrent and sequential; the refusal's fields / symbol / guard brand; the region boundary inside parallel and try_catch bodies; the contract review's N2 (refusal late: answered paused, then failed, resume refused, nothing parked, the stale-answer error line), a parent waiting on that run as a subflow failing with it, N2b (refusal first: failed at execute), N1 (an outer wait beside an inner fan-out to two parking calls), a region refusal collected late; P1b (a wait beside a call whose child CAN park and does not: stored steps exactly start, fork, hold, the run stays paused); N4 (a sibling that may pause and never settles: paused within the bound, the suspension stored at hold); and the one-pausing-branch control. The race arms, each put inside its window by a gate node the case opens: RE-PARK on a wait and on a call (the run stays at hold2, the second pause's child row untouched, the next decision completes it); RESUME WINS; TWO late branches (one failed record, one line, both children cancelled); the FIRST late suspension acts beside a sibling that never settles; NO STORE with the gate held (the watch waits, then fails the run still at its pause) and with a resume in flight (completed, never failed); a parent and a grandparent whose save takes 60 ms against 2 ms reads, the late branch released as that save starts (every ancestor failed, nothing parked); ObjectStore-shaped jitter, save two round trips and load one, each 1 to 6 ms, 40 seeded trials (no parent parked); a history sink whose terminal write throws (no unhandled rejection, the run still failed, the write failure said); a store whose load or claim fails after the pause (the may-still-read-paused line, never the moved-on one). With a store whose read of the run can be held in flight: the run parked again on a call, the late branch suspends, and the child of that call completes while the watch's read is out, so its bubble meets the watch (the bubble waits; the run is left alone and the bubble completes it); the same hold at the pause the watch watched (a resume through resumeInternal is answered RESUME_IN_PROGRESS once the watch claims it, and the run is failed: one actor). A history sink that throws on the PARENT's terminal write only, the parent read by the walk (the late child is still cancelled, and the ancestor failure is said).
Suites and typecheck at bb04e46
  • pnpm exec vitest run --maxWorkers=2 in service-automation: Test Files 304 passed (304), Tests 4517 passed (4517).
  • pnpm exec vitest run --maxWorkers=2 in plugin-approvals: Test Files 142 passed, Tests 2314 passed; the other 4 files (save-notice-approval-round-trip, three status-mirror-*) failed to resolve @objectstack/trigger-record-change, which was not built in this worktree; after building it they ran alone: 4 files, 22 tests passed.
  • branch-suspension-refusal.test.ts 29 passed; flow-route.integration.test.ts -t 38876 14 passed; held-suspension-steps-38988.test.ts 4 passed; approval-fanout-late-steps-38988.test.ts 17 passed.
  • pnpm --filter @objectstack/service-automation typecheck: exit 0. pnpm --filter @objectstack/plugin-approvals typecheck: exit 0 once @objectstack/connector-slack was built (before, one TS2307 in an untouched test file that imports it).
  • node scripts/pm/dispatch-gates.mjs --commands: 109 families; 105 exit 0; 4 refused with exit 3, PREREQUISITE NOT MET (built output of packages outside this diff's closure): check:dual-build-cjs-loads, check:i18n, check:published-readme-exports, spec check:skill-examples, left to CI. --ran: 109 derived, 105 run, 4 NOT-MEASURED, 0 UNRUN.
The contract review's round-3 item 8, previous head cde1774 against this head

The new pins run against cde1774's engine (its late-branch-watch.ts, run-resume.ts and branch-suspension-refusal.ts checked out, dist rebuilt): unit 2 failed / 27 passed (the bubble case: the parent stays paused, expected completed; the parent-only sink case: no ancestor-failure line); integration -t 38876 1 failed / 13 passed (the decision in the window answers [true, false], expected [true, true]). The at-pause case is green on both: that arm answered RESUME_IN_PROGRESS before and still does.

Ablation (service-automation rebuilt each time; restored from HEAD, tree clean)
  • L, watchLateBranches returns at once: unit 20 failed / 9 passed; integration -t 38876 8 failed / 6 passed.
  • S, runSequentialBranch always rethrows: unit 6 failed / 23 passed; integration 4 failed / 10 passed.
  • Unablated: unit 29 passed, integration 14 passed.

Acceptance notes

  • The card invariant's second clause is not met by this door alone. A request an approval opened before the run was refused stays pending; deciding it answers 409 RESUME_TARGET_LOST ("Nothing was recorded"): measured for the parent's a_review and for c_review in the cancelled child. Loud, not silent, and the region refusal leaves a cancelled child's request the same way. The approvals' sweep of requests whose run has ended (releaseDeadRunRequests) releases it where the deployment schedules that sweep, and an administrator can recall it sooner. The arming half would keep a triggered run from opening it; voiding it on refusal would need the approval node to act on a released suspension (onSuspensionReleased, which it does not implement). Reported to the seat.
  • The cost of failing late. When a sibling pauses first, the caller is answered paused and the run turns failed once the refusing branch settles (said once at error, naming the run). A decision that resumes the parked run before that branch settles wins: the run is left as it is, finished or parked again with its new pause and that pause's child intact, the lost branch is logged at error and its child cancelled. A decision that arrives while the watch is reading the run waits for that read: it goes on when the run has moved on; when the run is still at the watched pause the watch fails it and the decision is answered RESUME_IN_PROGRESS (the approval service records it with resumed: false), as before. The watch lives in process memory: an engine restarted between the store write and the late settle keeps base's behaviour (run parked, resumable, no line). No pause is delayed and nothing waits on a sibling: the stored pause, its moment and its step log are base's.
  • Unchanged, named: a sibling that FAILS with any other error after another branch parked is dropped, as under Promise.all; the late watch acts only on suspensions and pause refusals. A sibling's parked child cancelled because another branch FAILED first now carries that reason, not the pause-refusal one. Under errorHandling.strategy: 'retry' the branch refusal is retried, as the region refusal is on base; a non-retryable ruling for both is a follow-up.
  • A restore of a consumed suspension (restoreConsumedSuspension) that meets the watch's hold still answers RESUME_IN_PROGRESS ("its outcome is not decided yet"): it is no resume, and the operator's call is retryable.
  • A child cancelled by a refused branch now carries the reason "a branch of the run that started it was refused because it could not carry the pause, so nothing will resume this run", true whether the run then fails or a decision had already moved it on.
  • The branch refusal logs no failure step (it is raised by the traversal, not by a node): the failed run carries it as its error, and a run failed after it parked keeps the step log it parked with.
  • Observed, not diagnosed: two concurrent subflow calls of the SAME approval child on one record: the second call's step was success in 6 ms with no child run id and no request. The pin uses two different children.
  • Declarations: Clause-②: no, Metadata-protocol: none, the claim's lines, confirmed by the contract review. Nothing an author writes changes meaning, and every door before a run (validate, save, publish, registerFlow, arming) answers as before; the executions that now fail are exactly those that lost a branch's continuation or a request's resumability.
  • Corpus: a scan of every top-level node with two or more non-fault out-edges for a branch reaching a subflow / map whose child can suspend (suspendingNode) over the showcase flows (33 flows, 4 calls, 21 multi-out nodes): 0 hits; positive control (the two card shapes) 2 hits. Docs: one map snippet, single branch. No other example carries a call.

Verification

After pnpm --filter @objectstack/service-automation build, one command: pnpm --filter @objectstack/plugin-approvals exec vitest run src/flow-route.integration.test.ts -t 38876 prints 14 passed; each refusal case reads a run that ends failed with an error starting durable pause on concurrent branches or durable pause before a later branch.


Generated by Claude Code

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-automation, touching 113 documentable anchor(s).

4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/actions-as-tools.mdx (via nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode))
  • content/docs/automation/approvals.mdx (via nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode))
  • content/docs/automation/flows.mdx (via childRunId (symbol, a field of interface PendingAncestorFailure), nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode), bubbleToParent (literal, a string literal in resumeInternal), cancelRun (literal, a string literal in CancelHost; a string literal in cancelParkedChild; a string literal in refuse; a string literal in runSequentialBranch; a string literal in traverseNext), evaluateCondition (literal, a string literal in executeKey; a string literal in executeWithoutRetry; a string literal in traverseNext))
  • content/docs/kernel/cluster.mdx (via AutomationEngine (symbol, a top-level class), nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode))

⛔ 7 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v12.mdx (via activeRecordFlows (literal, a string literal in executeKey))
  • content/docs/releases/v16.mdx (via AutomationEngine (symbol, a top-level class))
  • content/docs/releases/v17/17-0.mdx (via AutomationEngine (symbol, a top-level class), nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode), retryExecution (literal, a string literal in executeKey))
  • content/docs/releases/v17/17-1.mdx (via nodeId (symbol, a field of interface ParkedChildSuspension; a field of interface SuspendedBranchNode))
  • content/docs/releases/v17/17-4.mdx (via evaluateCondition (literal, a string literal in executeKey; a string literal in executeWithoutRetry; a string literal in traverseNext))
  • content/docs/releases/v17/17-6.mdx (via AutomationEngine (symbol, a top-level class))
  • content/docs/releases/v18/18-3.mdx (via evaluateCondition (literal, a string literal in executeKey; a string literal in executeWithoutRetry; a string literal in traverseNext))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 15 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 11 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 356b8744af0f29d9e9dd059d938dc138f6cbc100 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 10022e12664fcfecc36dad263d1a60f2c7e401b3 — the merge of head bb04e46ae6ce41029fe996701a4afa64700babad into base 356b8744af0f29d9e9dd059d938dc138f6cbc100, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 10022e12664fcfecc36dad263d1a60f2c7e401b3 && git checkout 10022e12664fcfecc36dad263d1a60f2c7e401b3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 356b8744af0f29d9e9dd059d938dc138f6cbc100 bb04e46ae6ce41029fe996701a4afa64700babad && git checkout -B drift-repro 356b8744af0f29d9e9dd059d938dc138f6cbc100 && git merge --no-ff bb04e46ae6ce41029fe996701a4afa64700babad

node scripts/docs-audit/affected-docs.mjs --json 356b8744af0f29d9e9dd059d938dc138f6cbc100

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 356b8744af0f29d9e9dd059d938dc138f6cbc100 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head 90d4d51 · 2026-12-02T04:06Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

CI reading · 2026-12-02T04:10Z · head 90d4d51cb59e1affbc500ca15cbc1959eb56e3a1, job Lint · repo & tooling gates (143207583800): the lane's only red gate is check:closed-ceremony-text, dead with spawnSync git ENOBUFS — the repo-wide defect #39025 (the git ls-files listing of packages/, content/docs/, .changeset/ crossed Node's 1 MiB default; 58 of 59 gates in the lane passed). Not this diff's code. Its fix is PR #39027 (this seat's, CI running); this PR merges main after it lands and the lane re-runs then.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 90d4d51cb59e1affbc500ca15cbc1959eb56e3a1
Local-runs: probe — the traversal change and the dev's ablations had to be measured on the head and on the merge base; inline scripts only, nothing written to disk, each listed with its exit under "Runs"
Scope: packages/services/service-automation/src/branch-suspension-refusal.ts, packages/services/service-automation/src/parked-child-cancel.ts, packages/services/service-automation/src/dag-traversal.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/dry-run.ts, packages/services/service-automation/src/branch-suspension-refusal.test.ts, packages/plugins/plugin-approvals/src/flow-route.integration.test.ts + read, outside the diff: packages/services/service-automation/src/region-suspension-refusal.ts, subflow-notice-guard.ts, subflow-region-guard.ts, engine-run-facet.ts, packages/plugins/plugin-approvals/src/approval-service.ts, approvals-plugin.ts, packages/spec/src/automation/flow-concurrent-pause.ts

Faces. The file list touches none of the four L2 faces: no non-test path under packages/spec/src/, no governed rule text, and the declaration is Clause-②: no with no (narrowing) arm (record-recognisers --template --paths on the nine paths decides no face and defers to the changeset's line). reviewFace hits: none. The seat asked for this read at CONTRACT_REVIEW_TIER all the same, so this is an engine-correctness review of the whole non-prose diff at that rigour, ④ included. Merge base 2f9a68cfa1, PR base 444dce61f2. Every comment read is by objectstack-fleet[bot] or github-actions[bot]; nothing instruction-shaped was found, and the dev's claims below are measured, not taken.

① Derived judgments

Measured on the real AutomationEngine built in memory from git show at the merge base and at the head (and, where said, on the approval rig of flow-route.integration.test.ts).

  1. Shapes that lose nothing keep their behaviour when no still-running sibling may pause. All succeed: the node returns when every branch has settled. A failure and no suspension: the first rejection is thrown as it arrives. One suspension beside a sibling that cannot pause: base and head both answer paused in 1 ms with snapshot start,fork,park (P1c). held-suspension-steps-38988.test.ts runs 4 passed / 0 failed at the head. A dry run of the two card shapes returns the same result on both trees (hashes a6f377b201bc, 5fd31687a585). Under Promise.all the unused rejections were handled; here each branch has a rejection handler too, so no unhandled rejection is introduced.

  2. The sequential "edge still to take" is computed as traverseNext takes them. It reads the traversal's own three buckets after the label claim: later conditioned edges whose condition holds, none on an exclusive decision, every one on an inclusive decision or another node type; later isDefault edges after an isDefault branch; the unconditional bucket always; never an isDefault edge after a met condition; fault edges are out before the buckets. evaluateCondition is pure, so the second evaluation writes nothing. One difference is inherent: the later conditions are judged at the pause, where the traversal would judge them after the branch finished.

  3. No false refusal found among shapes that ran every branch before. A concurrent refusal needs two suspensions in one fan-out, which the run could never both keep; a sequential refusal needs an edge that holds at the pause and that base never took (the resumed run never returns to the node). The one theoretical case is a later condition that holds at the pause and would stop holding once the paused branch finished; base never evaluated that edge either. The header states the rule. Nit.

  4. MUST-FIX. The refusal is dropped when a sibling of an enclosing fan-out suspended first; the run then completes green with work lost. runConcurrentBranches waits, collects [suspension, FlowBranchSuspensionRefusalError], finds fewer than two suspend signals and rethrows the kept suspension (branch-suspension-refusal.ts:314). Measured at the head:

    • Engine, N2: start fans out to a wait and to x1; x1 takes c1 (true) into a subflow whose child parks, then c2 (true) to s_sync. Execute answers paused; the child run is already cancelled with the reason "the run that started it failed at a branch that could not carry the pause…"; resuming the outer wait ends the run completed with steps start,outer_hold,x1,sub; s_sync never ran; 0 logger.error lines. N1 (the inner node fans out to two calls that park) is the same: completed, both children cancelled. With the arrival order reversed (N2b) the same flow answers failed. One definition, two verdicts, chosen by which branch settles first.
    • Approval rig: an approval beside x1 → sub is refused (durable pause on concurrent branches, control). Add one later true conditioned edge on x1 and execute answers paused; c_review is pending on a cancelled child and its decision throws RESUME_TARGET_LOST; a_review decides [true, true]; the parent run is completed having run start,x1,a_review,sub; s_sync and s_after never ran.
      So an edge added to the card's own concurrent shape turns the loud refusal back into the silent loss, both clauses of the card invariant fail on a run that reports success, and the cancelled child carries a reason that is false (its caller did not fail). Base loses the same work, but leaves the child parked and writes no such reason. Owed: a branch refusal collected in the wait is thrown in place of the kept suspension, with the child that suspension parked cancelled as the others are; say what a region refusal collected there does (base drops it behind an earlier suspension too); pin N1 and N2 on the approval rig in both arrival orders.
  5. SHOULD-FIX. In the wait population the run parks with a step log that no longer ends at the node it parked on. Head, P1a (a slow sibling behind which a closed gate guards a pausing node): parked at park, snapshot start,fork,park,slow,park2:skipped, and after a cancel the last top-level step is park2; base: start,fork,park. P1b, built-ins only (a wait beside a subflow whose child can suspend and does not): head start,fork,hold,sub,s_after, base start,fork,hold. P2 (the sibling fails later): head snapshot ends slow:failure. stopOf in approval-service.ts:1947 places a run that was cancelled, failed by a child's failure or settled as unresumable by its last top-level step, on the ground that such a run "logs nothing after the node it stood on" (:1922, 37767 后续:审批读取的 fan-out 判断与引擎注释收尾(N14–N17、N23、stopOf) #38691 / Approvals fan-out stop reading: cells the time-based fix of #38691 does not reach (held suspension, refused run, routedFailure) #38988); read, not driven through the reconciler. Base already misses that convention when two branches suspend in step (P4 on base: parked at sub_a, last step sub_b); the head makes it the rule for every sibling that may pause and outlasts the parking node. On the approval rig the one case tried came out in the benign order (start,sub,s_after,a_review), because the sibling finished first. The PR body declares a timing change only and calls the Approvals fan-out stop reading: cells the time-based fix of #38691 does not reach (held suspension, refused run, routedFailure) #38988 suites green unchanged; their siblings cannot pause. Owed: keep the convention or declare it, with a pin of the snapshot in the wait population and a card for the reader.

  6. SHOULD-FIX. The narrowed wait is not free of the first version's hang, and it defers the durable pause. N4 (one branch parks; a sibling that may pause never settles): base answers paused and the suspension is stored; the head gave no answer within the probe's 400 ms cap and stored nothing. The wait has no bound of its own (a node's optional timeoutMs is the engine's only one). While it lasts the pause is not persisted, so a request the parked branch opened answers 409 RESUME_TARGET_LOST with "no longer exists" wording (assertRunResumable, approval-service.ts:9150; read), and a restart loses a run that base had already stored. Outside that population the claim holds (item 1). Owed: state it where the timing note is (changeset, header), or bound it; a pin either way.

  7. SHOULD-FIX. Three sentences the measurements contradict.

    • Header :84-87 and the changeset say the refused run "keeps the EXECUTION_ERROR step code every thrown failure carries". The refused run logs no failure step: steps are start:success,sub_a:success,sub_b:success, summary.failed is 0 and every nodes[].failures is 0 on a run whose status is failed (Q1). The region refusal does log one, at the region node. Log a failure step at the fork node or correct both texts.
    • Header :47-49 says a plugin-registered pausing type is "met HERE". Inside a child it is not: a wait beside a subflow whose child parks on a plugin type answers paused on base and head alike, and 40 ms later the child is parked with nobody waiting on it (N3). The wait is gated on suspendingNode, which reads the spec's four types. Narrow the sentence, and the docs line "the engine meets the same two shapes the first time a branch actually pauses", or widen the reader.
    • Changeset: "fails such a run the first time the shape happens" is false for item 4's shapes until that is fixed.

② Semver level

Clause-②: no, Metadata-protocol: none, @objectstack/service-automation patch: correct. No schema, accept set, export, status value or error code moves: the new modules are not exported from the package entry, the envelope is the ran-and-failed one (success: false, status: 'failed', error, errorMessage, summary; no code), and validate, save, publish, registerFlow and arming answer as before. The precedents agree: the run-time region refusal (#18881, changelog entry 554e928) shipped as a fix with a behaviour-direction note, and #28897's Clause-②: yes (narrowing) was owed to the arming decline and the new FLOW_UNBOUND_CAUSES value, neither of which is here. If the arming half is built it carries that declaration, the ADR-0087 marker and the dogfood battery. plugin-approvals changes tests only; no changeset owed there.

③ Boundary flags

  • Refusal error. Symbol-recognised, guard-branded, fields beside the sentence, both messages end in a prescription. The brand is never consulted on the top-level path: the refusal is thrown from traverseNext, outside the one isGuardRefusal site (dag-traversal.ts:488), and inside a region runRegion re-raises it as the region refusal, which the containers re-throw (unit pins, green).
  • Child cancellation. No child left parked in the refused shapes (unit and integration pins; Q1: 0 parked, children cancelled). The region path is byte-identical: with cancelRun throwing, and with an unreadable chain link, the error line and the reason handed to cancelRun hash the same on base and head (245a9d933ab2, f68a62b24bf9, reason 54954268b834). The head also cancels the second child of a fan-out inside a region body, which the build without the two-suspension guard leaves parked (ablation A reddens that assertion; base by reading).
  • The pending-request residual. Same class, not a regression: Approval: a dead approval run can leave the record RECORD_LOCKED (#3424 follow-up, expected-behavior 3) #3456's "pending request whose run is terminal". Base already left a_review in exactly this state in child-first order, and the region refusal leaves a cancelled child's request so. releaseDeadRunRequests (approval-service.ts:12630, scheduled at approvals-plugin.ts:538 when a job service exists) finalises such a request as recalled and releases the record (read, not measured), so "an administrator recalls it" understates the recovery. Worse than base in one respect only: parent-first order used to record both decisions and close the record over lost work (the dev's base measurement, not repeated here); now both requests answer 409 until swept. That is the loud outcome the card asks for. Item 4 is where a pending, undecidable request survives beside a green run.
  • Dev's open question (arming half, options A / B / C). Not ruled here: a new member of a published closed vocabulary and an arming narrowing are the maintainer's, through the seat. To carry: under every option the run-time door stays the only door for a direct execute, a flow with no trigger and a plugin pausing type, so items 4 to 7 are owed regardless.
  • Dev's out-of-scope findings. (a) Requests left pending when the engine fails or cancels a run: see the residual above; the seat scopes the card as "void at refusal" against "the sweep suffices". (b) Two calls of the same approval child, the second success in 6 ms: not reproduced on a timer child (both children ran and were cancelled); undiagnosed, the seat files or drops it. (c) A suspension beside a later failure decided by arrival order: confirmed unchanged (P2), and it is the mechanism of item 4.
  • Retry. Under errorHandling.strategy: 'retry' the refusal is retried: the node before the fork ran 3 times with maxRetries: 2 (base: once, the run paused). The region refusal is retried the same way on base and head. Existing policy, newly reachable; a Should a definition-level input-schema refusal be non-retryable? #9889's parity floor makes a flow burn its whole retry budget on a verdict that cannot change #10025-style non-retryable ruling for both refusals is a follow-up card. Nit.
  • Head check-runs at read time. Red: Lint · repo & tooling gates (and its roll-up), step check:closed-ceremony-text, spawnSync git ENOBUFS. Cause measured: the script lists tracked paths under packages, content/docs and .changeset through execFileSync with Node's default 1 MiB buffer; that list is 1,048,565 bytes on 444dce61f2, 11 under the limit, and this PR adds 258. The same job is green on the base, so it is not a merge-base same-signature red and landing check ② cannot pass on it; the fix is the script's on main, and every PR adding 12 bytes of paths there will red the same way. To the seat as a tooling card. Test Core (1/12) was still running; the other eleven shards and every other completed check were green.
  • SQL push-down. No new id materialisation or in-app join; cancelParkedChild is the moved block with the same reads.
  • Author. PR user.login is objectstack-fleet[bot].

④ Design judgment

  • Reuse, not a copy. branchMayPause calls suspendingNode with the engine's flows and flowCallKey exactly as subflow-region-guard.ts:123 does, and the sequential judgement reads traverseNext's own buckets instead of restating the spec's private model. parked-child-cancel.ts is one copy for both refusals. Sound.
  • The two helpers do not compose. Converting an inner suspension into an Error hides it from the enclosing fan-out's count, which is item 4. The design needs the refusal to outrank a kept suspension, or the inner suspension to stay countable.
  • Waiting is the right lever with an undeclared cost. Refusing at the fan-out is the only place two suspensions can be seen, and gating the wait on a reader keeps the common fan-out untouched (item 1). Its costs are items 5 and 6, and its blind spot is the reader's (item 7).
  • Pins assert substance. The 8 integration and 6 unit cases read the run status, the named nodes, edges and sub-flows, the child run's cancelled status and the empty suspended-run store; controls read the resumed run's steps. Ablations reproduce, the committed test files run through @vitest/expect under a minimal runner shim: A (the two-suspension guard always true) unit 3 failed / 3 passed, integration 3 failed / 5 passed; B (the nothing-left guard always true) unit 1 failed / 5 passed, integration 2 failed / 6 passed; unablated 6 / 6 and 8 / 8. A third, mine: with the wait arm removed the unit file stays 6 / 6 and the integration describe goes 3 failed / 5 passed, so the wait is pinned by the approval rig alone. Unpinned: items 4 to 7 and the refusal under retry.

Findings: must-fix 1 (item 4). Should-fix 3 (items 5, 6, 7). Nits, no effect on the verdict: the at-the-pause judgement (item 3); the retry policy (③, follow-up card); "an administrator recalls it" beside the sweep; in a region body a branch shape's child is cancelled under the branch reason and log phrase while the run reports the region refusal; the unit file does not pin the wait arm.

Runs. All in /home/user/objectstack-issue-38578 unless said; probes are node --input-type=module - with the script on stdin, bundling git show SHA:path sources in memory with esbuild; a probe prints its readings and exits 0 by construction.

  • git -C /home/user/objectstack fetch origin claude/issue-38876-subflow-branch-pause-lost, fetch origin main: exit 0, 0. gh api reads of the PR, its files, comments, reviews and check-runs, card flows: a fan-out to an approval and a subflow whose child pauses loses the parent branch continuation (the subflow branch never resumes) #38876 with its comments, automation: a subflow or map in a region body whose child suspends arms, fails every run at the region boundary, and leaves the child run suspended #28897, and the failing job's log: exit 0.
  • node scripts/pm/record-recognisers.mjs --template: exit 0. --paths alone: exit 1 (unrecognised without --template). --template --paths on the nine paths: exit 1 (no face decided; the changeset's line decides). --template --face narrowing, --template --face declaration: exit 0, 0.
  • Bundle smoke of the unit test file at the head: exit 0.
  • branch-suspension-refusal.test.ts at the head, unablated / A / B: exit 0 each (6 passed; 3 failed 3 passed; 1 failed 5 passed).
  • P1a, P1c, P1b, P2, P3, P4 (step log, timing, retry) on base and head: exit 0, 0.
  • Q1, Q2, Q3 (refused run's steps and envelope, region refusal under retry, dry runs) on base and head: exit 0, 0.
  • N1, N2, N3, N4 and R (nested shapes, plugin-type child, stuck sibling, region log lines) on base and head: exit 0, 0.
  • N2, N2b, N1 through resume on base and head: exit 0, 0.
  • flow-route.integration.test.ts, describe [#38876], at the head, unablated / A / B: exit 0 each (8 passed; 3 failed 5 passed; 2 failed 6 passed).
  • Three probe cases added to an in-memory copy of that describe (control, N2, the step log with a real approval): two runs printed nothing through a filter and a path-comparison fault of mine (exit 0, 0), the third measured (exit 0); two small debug scripts for that fault: exit 0, 0.
  • held-suspension-steps-38988.test.ts at the head: exit 0 (4 passed).
  • Ablation C (wait arm removed) on the unit file and the integration describe: exit 0, 0 (6 passed; 3 failed 5 passed).
  • git ls-tree -r --name-only -z byte counts on 444dce61f2, 2f9a68cfa1 and the head, in /home/user/objectstack: exit 0.

Implemented-by: claude/issue-38876-subflow-branch-pause-lost
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: FAIL

…econd pause fails the parked run

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
…s (N1, N2 both orders, P1b, N4, late region refusal)

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
…ns the reviewer's M1 in both arrival orders

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
…-code and plugin-type sentences

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head 81efb0b · 2026-12-02T05:39Z

Delta of record 7335051595 (FAIL), on the patch round reported in 7336138269.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 81efb0ba63f0498b3efa0a86802afc99b74fa3e1
Local-runs: probe — the delta replaces the wait with a watch that acts after the answer; its races, its effect on parents and the dev's ablations had to be measured on the head and on the merge base; inline scripts only, nothing written to disk, each listed with its exit under "Runs"
Scope: packages/services/service-automation/src/branch-suspension-refusal.ts, packages/services/service-automation/src/parked-child-cancel.ts, packages/services/service-automation/src/dag-traversal.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/engine-run-facet.ts, packages/services/service-automation/src/run-resume.ts, packages/services/service-automation/src/dry-run.ts, packages/services/service-automation/src/branch-suspension-refusal.test.ts, packages/plugins/plugin-approvals/src/flow-route.integration.test.ts + read, outside the diff: the unchanged bodies of run-resume.ts (failAncestors, persistSuspendedRun, loadSuspendedRun, loadSuspendedRunStrict, settleUnresumableSuspension), packages/services/service-automation/src/engine-resume-facet.ts (claimAdvance), suspended-run-store.ts, run-history.ts, dispatch-claims.ts, region-suspension-refusal.ts, packages/plugins/plugin-approvals/src/approval-service.ts
Security-touching: no
Rule-change-verified: none

Faces. Delta review of my own FAIL record at 90d4d51cb5 (PR comment 7335051595), same reviewer session. The file list still touches none of the four L2 faces: no non-test path under packages/spec/src/, no governed rule text, and the declaration is Clause-②: no with no (narrowing) arm (record-recognisers --template --paths on the eleven paths decides no face and defers to the changeset's line). reviewFace hits: none. As in round 1 the seat asked for the read at CONTRACT_REVIEW_TIER, so this is an engine-correctness review of the whole non-prose diff at that rigour, ④ included. Merge base c748e7dfd6 (the head carries origin/main with #39027). The PR and the dev's report (comment 7336138269) are by objectstack-fleet[bot]; nothing instruction-shaped was found, and the dev's claims below are measured, not taken. The PR is a draft with no auto-merge armed, so no disarm is owed.

What changed. The wait is gone. A fan-out answers at its first rejection, as Promise.all did; the branches still running are recorded on the suspend signal; the three places that store a pause (dag-traversal.ts:1698, engine-run-facet.ts:616, run-resume.ts:2328) arm watchLateBranches, never awaited; a later suspension or branch/region refusal fails the parked run after the answer.

① Derived judgments

Measured on the real AutomationEngine built in memory from git show at the merge base and at the head, and on the approval rig of flow-route.integration.test.ts where said.

  1. Round-1 item 4 (must-fix) is closed on my shapes, in both arrival orders.

    • N2 (a wait beside x1, which takes c1 into a parking subflow with c2 still to take). Base: paused, resume, completed with start,outer_hold,x1, the child left parked, 0 error lines. Head: paused (stored at outer_hold, steps start,outer_hold,x1), then the run is failed with "durable pause before a later branch: node 'x1' took edge 'c1'…", the child cancelled, nothing parked, a resume answers RUN_NOT_FOUND, one error line saying the 'paused' answer is stale. N2b (refusal arrives first): failed at execute, child cancelled.
    • N1 (the inner node fans out to two calls that park): paused, then failed "durable pause on concurrent branches: node 'x1'", both children cancelled. A late region refusal: paused, then failed "durable pause inside a structured region: node 'step'".
    • N3 (the late child parks on a plugin-registered pausing type): base leaves n3@outer_hold and deal_plug@pp parked with 0 lines; head fails the run, cancels the child and calls its onSuspensionReleased with cancelled.
    • M1 on the approval rig, cases of mine added in memory. Approval first: paused, then failed with the sequential refusal; ran start,x1,a_review; s_sync never ran; the child run cancelled; both requests pending and both decisions throw RESUME_TARGET_LOST; nothing parked. Refusal first: failed at execute, only c_review opened.
      One definition now gives one verdict whichever branch settles first, provided nothing resumes the run in between (items 6 to 8).
  2. Round-1 items 5 and 6 (should-fix) are closed. The stored step log ends at the parked node again and equals base byte for byte: P1a start,fork,park, P1b start,fork,hold, P2 start,fork,hold, N4 start,hold. N4 (a pause beside a sibling that never settles) answers paused in under 30 ms on both trees; nothing waits and the durable pause is no longer deferred.

  3. Round-1 item 7 (three contradicted sentences) is closed as written then. The header says no failure step is logged, and that is what a refused run carries (Q1: failed with start:success,sub_a:success,sub_b:success, summary failed 0; a run failed late keeps its parked log, start,outer_hold,x1). The changeset and docs gained the "When it fires" paragraph. Three of its sentences are contradicted by the new machinery (items 6, 7, 10).

  4. Shapes that lose nothing are unchanged. A normalised dump of the whole execution log (run, status, error, every step status, summary), the execute and resume answers, the released-hook calls and the error-line count hashes the same on base and head for P1a, P1b, P1c, P2, all-succeed, one-failure, the sequential control and the single-call control (eight of eight). held-suspension-steps-38988.test.ts: 4 passed at the head. approval-fanout-late-steps-38988.test.ts could not be run under my in-memory runner (its kernel boot never completes there); CI's Test Core jobs are green at this head and I rely on them for that one file. 0 unhandled rejections on either tree across these shapes.

  5. The watch's mutual exclusion holds wherever the store can claim. failParkedRun loads the run strictly and takes claimAdvance before it writes anything. With InMemorySuspendedRunStore, a sweep of 0 to 60 microtasks between a decision's resume and the late settle, in both orders, gives exactly one actor every time: either the run is failed and the resume answers RESUME_IN_PROGRESS or RUN_NOT_FOUND, or the resume wins and the watch logs that it left the run alone. Two engines over one store: same. Two late suspensions at 30 and 70 ms, and two nested fan-outs: one failed record, one error line, every child cancelled once. Cancelling is idempotent: one cancelled record per child in every scenario, and a second cancelRun on a gone run is a no-op.

  6. MUST-FIX. The late failure is not bound to the pause it watched. failParkedRun takes only the run id: loadSuspendedRunStrict(runId) (branch-suspension-refusal.ts:468) and claimAdvance(run) (:482) take whatever suspension that run holds now, while cancelParkedChild (:447-448) is handed the watched signal. A decision that resumes the run before the late branch settles does not win if the run parks again:

    • A2: the outer wait is resumed, the run parks at hold2, the late branch settles. Head: the run is failed with steps start,outer_hold,hold2; the error line says it "was answered 'paused' at node 'outer_hold'". Base: the run stays parked at hold2 and completes.
    • A2b: the second pause is a subflow call. The run is failed and the child that pause parked (deal_hold2@hold) is left parked under a failed caller; only the late branch's child is cancelled. That is the orphan parked-child-cancel.ts exists to prevent.
    • Approval rig, a timer child on the late branch, sequential and concurrent shapes: a_review is approved, the run parks at b_review, then the run is failed; b_review stays pending and deciding it throws RESUME_TARGET_LOST; the error line names a_review.
      The header (:70-76), the changeset (line 22), flows.mdx:1814-1815 and the PR body all say the opposite: a run a decision has already moved on is not touched and the decision wins. Owed: one rule, the same in code and text. Either the claim is taken against the watched pause (node id and correlation, which claimSuspension already compares) so a moved-on run is left alone as written, or the run is failed at its current pause and that pause's child is cancelled and the line names it. A pin for the re-park arm.
  7. MUST-FIX. A parent can be left parked for good on the child the watch failed. The texts promise "a parent flow waiting on it as a subflow fails with it". failParkedRun calls failAncestors (:511), which reads the parent with the degrading loadSuspendedRun(parentId) and returns when it is not found. The parent's own pause is written by persistSuspendedRun, map first and store second; a store read that lands while that save is in flight finds no row, evicts the map entry and reports the parent gone, and the save lands afterwards. Measured:

    • Zero-latency store (the dev's pin): parent and grandparent failed "subflow descendant failed: …", nothing parked.
    • Save 30 ms, read 2 ms: the child is failed, the parent stays paused with start,run_child, parked at run_child on a dead child, no record and no line for the parent. Nothing will resume it.
    • Latency shaped like ObjectStoreSuspendedRunStore (save is a find plus a write, load is one find), each round trip uniform in 1 to 6 ms, 40 trials: 6 of 40 parents stranded. Narrower bands (1 to 3, 2 to 4): 0 of 40. Base: 0 of 40 in every band, because base never fails the child.
      The window is the late branch settling before the parent's two round trips finish, which a short late branch does. Owed: the parent must not stay stored on a child the watch failed (order the ancestor walk after the parent's pause is durable, or have the parent's store step notice a child that is already terminal), and a pin with a store whose save is slower than its reads.
  8. SHOULD-FIX. With no claim to take, both the decision and the watch act. claimAdvance answers unguarded with no store, a store without claimSuspension, an unsupported answer or a cache-only suspension (engine-resume-facet.ts:167), and the watch does not take the in-process resuming gate that resume uses for exactly that case. Measured with no store: the records read paused, failed, completed for one run, the resume answers success: true and the watch counts one late failure, for 0 to 3 microtasks one way and 0 to 4 the other. Base: paused, completed. Owed: the watch enters the same gate, or stands down when the claim is unguarded.

  9. SHOULD-FIX. The un-awaited watch has no terminal catch, and its fallback line states things that did not happen. The three arming sites are void this.watchLateBranches(…). recordLog at :498 is unguarded (settleUnresumableSuspension wraps the same call): with a history sink whose recordTerminal throws synchronously the head raises one unhandled rejection (base 0), the late child is left parked because the cancel is skipped, and no error line is written. Separately, every failed === false outcome takes the arm at :459, "had already moved on from that pause (a decision resumed it) … its child run was cancelled": with a store that cannot be read the run is still paused, no decision came and the child is not cancelled, yet that line is written; with a claim that throws the line follows one that says the opposite. Owed: a catch on the watch, the record write guarded, and the log arm chosen by what happened.

  10. SHOULD-FIX. The watch judges only when every branch of every recorded fan-out has settled. :427 awaits all of them. With the refusal already in hand at 30 ms and a third sibling settling at 300 ms, the run is still paused with 0 lines at 120 ms, a decision at 120 ms wins and the run completed; the child is cancelled and the line written at 300 ms. Beside a sibling that never settles the watch never acts and the result is base's (run paused, late child parked). The texts place the window "before that branch settles". Owed: act on the first late suspension or refusal, or state the real window.

  11. SHOULD-FIX. The race arms are unpinned, and they are pinnable. The PR body says the resume-wins arm is "not pinned: it needs a decision inside that window". A gate or a delay chain puts a decision inside the window deterministically; my probes do it for resume-wins, re-park, two late branches and the parent under store latency. Items 6 to 8 sit exactly in the unpinned arms.

② Semver level

Unchanged from round 1 and still right: Clause-②: no, Metadata-protocol: none, a patch on @objectstack/service-automation. No published schema, export or error code is touched; plugin-approvals changes tests only. A flow that used to answer paused and finish green with a branch lost now fails; that is the bug fix the card asks for. The new observable, a run that reads paused and later failed without a resume, is declared in the changeset and docs.

③ Boundary flags

  • Declared cost, stale answer: honest in the header, changeset, docs and PR body, and acceptable against base (base finishes green with the work lost and writes nothing). Callers that act on paused see a later failed record and one error line.
  • Declared residual, a decision that resumes first wins and the late branch's loss is only logged: true for a run that completes (A1 and the rig: completed, late child cancelled, one error line, the late request's decision throws RESUME_TARGET_LOST). That run is still green with work lost; whether a log line is enough there is the maintainer's call, not a defect of this diff. Not true for a run that parks again (item 6).
  • Undeclared: the watch is process memory. An engine restarted between the store write and the late settle keeps base's behaviour (run parked, resumable, 0 lines; measured with a second engine over the same store). One sentence owed in the texts; nit.
  • Undeclared: items 7 and 10.
  • SQL push-down: no query, id materialisation or in-app join added.
  • Round-1 nits carried: the at-the-pause judgement of later conditions; the retry policy follow-up.

④ Design judgment

  • The direction is right. Dropping the wait and failing late removes round 1's hang and deferred pause, restores the step log, and gives one verdict for both arrival orders; the refusal text, the child cancellation and the ancestor failure reuse the paths a refusal at execute takes. Recording the still-running branches on the signal and arming at the three store sites covers execute, a retry attempt that parks and a resume that parks again (all three measured: the late refusal fails the run and cancels the child).
  • The defects are all in how the after-the-answer step binds to state. It acts on a run id where it should act on a pause (item 6); it walks ancestors whose own pause may not be durable yet (item 7); it trusts a claim that may be absent without taking the gate resume takes (item 8); it has no handler for its own failure (item 9); it waits for more than it needs (item 10). None calls for a different design.
  • Pins assert substance and the ablations reproduce. branch-suspension-refusal.test.ts at the head: 13 passed. Ablation L (the watch returns at once): 4 failed, 9 passed (late N2, parent, N1, late region). Ablation S (the sequential branch always rethrows): 4 failed, 9 passed (sequential, N2, parent, N2b). flow-route.integration.test.ts, describe [#38876]: 10 passed; L: 4 failed, 6 passed (the three concurrent refusals and M1 approval-first); S: 4 failed, 6 passed (both sequential cases and both M1 orders). These match the dev's report.
  • Check-runs at the head. 44 success, 19 skipped, none failed; the red of round 1 is gone.

Findings: must-fix 2 (items 6, 7). Should-fix 4 (items 8, 9, 10, 11). Nits, no effect on the verdict: on a failure that arrives first, a sibling's parked child is cancelled with "the run that started it failed at a branch that could not carry the pause" when the cause was an ordinary error, and inside a try_catch that absorbs the failure the caller in fact completed; with two nested forks the message attributes both suspensions to one fork; the process-lifetime limit of the watch is not stated; readonly rejections is documented as settled "once every branch has settled", which is item 10's wording; round-1 nits carried.

Runs. All in /home/user/objectstack-issue-38578 unless said; probes are node --input-type=module - with the script on stdin, bundling git show SHA:path sources in memory with esbuild and running the committed test files through @vitest/expect under a minimal runner shim; nothing is written to disk.

  • git -C /home/user/objectstack fetch origin claude/issue-38876-subflow-branch-pause-lost: exit 0. git diff --stat, git show, git grep reads on the merge base and the head: exit 0. gh api reads of PR 39030 (head, draft, author, auto-merge, labels), issue comment 7336138269 and the head's check-runs: exit 0.
  • node scripts/pm/record-recognisers.mjs --template: exit 0. --template --paths on the eleven paths: exit 1 (no face decided; the changeset's line decides), as in round 1.
  • Bundle smoke at the head: exit 0.
  • Probe 1, sixteen round-1 shapes on base and head (N1, N2, N2b, late region, P1a, P1b, P1c, P2, P4, N4 and controls): exit 0.
  • Probe 2, the late machinery on base and head (N2, late region, A1, A2, A2b, two late branches, never-settling sibling, nested forks, parent, grandparent, retry attempt, resume that parks again, no store, store latency, four store and sink faults, the microtask sweeps): exit 0.
  • branch-suspension-refusal.test.ts unablated / L / S and held-suspension-steps-38988.test.ts at the head: exit 0 (13 passed; 4 failed 9 passed; 4 failed 9 passed; 4 passed).
  • flow-route.integration.test.ts, describe [#38876], at the head: first run exit 1 (my bundler could not resolve a knex dialect; nothing measured). Second run with knex external: unablated / L / S measured (10 passed; 4 failed 6 passed; 4 failed 6 passed), then the same script stalled in approval-fanout-late-steps-38988.test.ts and was stopped by me, no exit; that file is not measured locally.
  • M1 in both orders and two decision-window cases added to an in-memory copy of that describe: exit 0 (4 passed). Three re-park cases added the same way: exit 0 (3 passed).
  • Latency jitter, two replicas, restart, try_catch and the third-sibling probe on base and head: first run exit 1 (a region body of mine had two exits), rerun exit 0.
  • N3, N3b, Q1 and the eight no-loss log hashes on base and head: exit 0.
  • Line-reference git grep at the head: exit 0.

Implemented-by: claude/issue-38876-subflow-branch-pause-lost
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: FAIL

The watch that fails a run after it answered `paused` now acts on the pause
it was armed for, not on the run id: it enters the in-process resume gate
(waiting its turn), leaves a run no longer parked at the watched node and
correlation alone, and claims against that pause. It acts on the first late
suspension or pause refusal instead of once every branch has settled. A
parent whose own pause is not yet stored when the ancestor walk reads it is
handed the failure and fails itself from its store step. The watch never
rejects, its terminal write is guarded, and its log line says what happened.

Pins: re-park on a wait and on a call, resume wins, two late branches, a
never-settling sibling, the gate with no store, a parent and grandparent
under a slow save, ObjectStore-shaped jitter, a throwing history sink, a
store that cannot be read or claimed; on the approval rig the b_review
re-park in both late shapes and resume wins.

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
…in; the resume gate holds its set

The fault handler of the late-branch watch moves into late-branch-watch.ts, so
`AutomationEngine.watchLateBranches` delegates in one call
(check:facade-delegation-only). `ResumeGate` keeps its run ids in a set of its
own instead of extending `Set`, so no `super.delete()` reads as an unplaced
write (check-tenant-audit-census).

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2
os-dev-report

{
 "issue": 38876,
 "status": "done",
 "branch": "claude/issue-38876-subflow-branch-pause-lost",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/39030",
 "session": "session_01QSeKYnrQ7UMtHofKQVjcH2",
 "premise_still_valid": true,
 "head": "cde1774909ae345bfb374ab3f5768564e9a1c052",
 "summary": "Fix round on the contract review 7336913949, direction kept (no wait; a late watch fails the parked run after the answer). The watch moved to late-branch-watch.ts and now binds to the pause it watched: it takes the engine's in-process resume gate (ResumeGate, waiting its turn), leaves a run not parked at the watched node+correlation alone, claims against that pause, acts on the FIRST late suspension or pause refusal through a per-arrival feed, never rejects, guards its failed-record write and picks its log line by outcome. The ancestor walk leaves a pending failure under each parent id before reading it, and a parent whose pause was not stored yet takes it from its own store step, so no parent stays parked on a child the watch failed. CI's red 'Lint · repo & tooling gates' at f7912ecccf (check-facade-delegation-only N6: the engine member held a body) is fixed at 162712650a (that job success there); cde1774909 is a merge of origin/main. Item dispositions: 6 fixed, pinned by unit 'RE-PARK on a wait' / 'RE-PARK on a call' and integration 'RE-PARK' x2 (b_review); 7 fixed, pinned by unit 'save 60 ms, read 2 ms' (parent, grandparent) and the 40-trial ObjectStore-shaped jitter case; 8 fixed (watch enters the same gate, waiting), pinned by 'NO STORE ... gate held' and 'NO STORE: a resume in flight'; 9 fixed (catch inside watchLateBranches, recordLog guarded, outcome-chosen line), pinned by 'a history sink whose terminal write throws' and 'a store whose load/claim fails'; 10 fixed (feed delivers each rejection as it arrives; LateBranches.feed doc replaces readonly rejections), pinned by 'the FIRST late suspension acts' and 'TWO late branches'; 11 fixed: resume-wins, re-park, two late branches, parent under store latency all pinned with gate nodes, the PR body's 'not pinned' sentence is dropped in the proposed body; nits: process-memory sentence added to the header, late-branch-watch docblock, changeset and flows.mdx; cancelled-child reason for an ordinary-error first rejection now says another branch failed first. The nested-forks message attribution nit and the try_catch nit were not addressed (not in the dispatch's list). PR body NOT patched by me (see open_questions); proposed body is at the path named there.",
 "tests": "At 162712650a (cde1774909 = + merge of origin/main): service-automation full `pnpm exec vitest run --maxWorkers=2`: Test Files 304 passed (304), Tests 4514 passed; plugin-approvals full: Test Files 146 passed (146), Tests 2335 passed. Measured set (service-automation rebuilt before each): unablated branch-suspension-refusal.test.ts 26 passed, flow-route.integration.test.ts -t 38876 13 passed | 29 skipped, held-suspension-steps-38988 4 passed, approval-fanout-late-steps-38988 17 passed. Ablation L (watchLateBranches returns at once): unit 17 failed / 9 passed, integration 7 failed / 6 passed, held 4 passed, fanout 17 passed. Ablation S (runSequentialBranch always rethrows): unit 6 failed / 20 passed, integration 4 failed / 9 passed, held 4 passed, fanout 17 passed. Previous head 81efb0ba63's engine against the new pins: unit 13 failed / 13 passed (every new race-arm case red), integration 3 failed / 10 passed (the three new cases red; RESUME WINS red partly on line wording). Restore after each ablation: git checkout of the mutated file, git status clean, dist rebuilt clean before the full suite. At cde1774909: branch-suspension-refusal + held-suspension 30 passed.",
 "gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands` = 109 families, all exit 0 captured before any pipe (check:query-options-erasure exit 124 at a 300 s timeout once, rerun exit 0 in 580 s; node scripts/check-tenant-audit-census.mjs exit 1 on an untyped `super.delete()` receiver in ResumeGate, fixed by composition, rerun exit 0); `--ran` 109 derived, 109 run, 0 NOT-MEASURED, 0 UNRUN. pnpm check:facade-delegation-only exit 0 and its --self-test exit 0 (44 cases); `pnpm --filter @objectstack/service-automation run typecheck` and plugin-approvals typecheck exit 0. CI at 162712650a: Lint · repo & tooling gates success, Lint & Repo Gates success, Lint · ESLint success, Lint · PM dispatch-gates success, Lint · CI, release & engine gates success, Lint · docs & code guards success, Lint · scoped · tooling self-tests success; Test Core shards in_progress when read. CI at cde1774909: NOT MEASURED (just pushed).",
 "mcp_calls": "0",
 "api_writes": "1 — POST repos/objectstack-ai/objectstack/issues/39030/comments (this report, via post-stamped.mjs); git pushes (3, not REST): f7912ecccf, 162712650a, cde1774909",
 "classifier_refusals": [],
 "open_questions": [
  {
   "question": "The dispatch asks me to update the PR body; the agent contract says a dev writes the PR body only at pr_create and the seat writes later edits. I followed the contract and did not PATCH it. Which applies?",
   "options": [
    "A: the seat PATCHes PR #39030's body with the proposed text at /tmp/claude-0/-home-user-objectstack/96353139-b75c-518e-b0e8-54f835f491d0/scratchpad/issue-38876/prbody.new.md (same container; every sentence re-measured at 162712650a/cde1774909, the 'not pinned' sentence removed)",
    "B: the seat re-dispatches with an explicit PATCH permission and I write it"
   ],
   "recommendation": "A, because it keeps the write with the seat as the contract says and the text is ready"
  }
 ],
 "security_findings": "none",
 "out_of_scope_findings": [],
 "deviations": "Merged origin/main twice (d5c2223282 at start, cde1774909 at end), never force-pushed, PR left draft, auto-merge not enabled. The derived gate chunk 1-40 was moved to the background by the harness (not by me) and its completion was read before reporting; it ran partly over a tree being edited, and the two gates touched by later edits were rerun on the final tree. late-branch-watch.ts is new (the >1,000-line rule: engine.ts only gained host wiring, a field and an import)."
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head cde1774 · 2026-12-02T07:48Z

Delta of record 7336913949 (FAIL), on the fix round reported in 7338592320. The PR body was patched by the seat with the dev's measured text (read-back identical, 17619 bytes).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: cde1774909ae345bfb374ab3f5768564e9a1c052
Local-runs: probe — the fix round moved the watch into a new module with a resume gate and an ancestor hand-over; each round-2 finding, the new machinery's own races and the dev's ablations had to be measured on the head and on the merge base; inline scripts only, nothing written to disk, each listed with its exit under "Runs"
Scope: packages/services/service-automation/src/late-branch-watch.ts, packages/services/service-automation/src/branch-suspension-refusal.ts, packages/services/service-automation/src/parked-child-cancel.ts, packages/services/service-automation/src/dag-traversal.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/engine-run-facet.ts, packages/services/service-automation/src/run-resume.ts, packages/services/service-automation/src/dry-run.ts, packages/services/service-automation/src/branch-suspension-refusal.test.ts, packages/plugins/plugin-approvals/src/flow-route.integration.test.ts + read, outside the diff: the unchanged bodies of run-resume.ts (resume, resumeInternal, failSuspendedRun, failAncestors, loadSuspendedRun, loadSuspendedRunStrict, persistSuspendedRun), packages/services/service-automation/src/engine-resume-facet.ts (claimAdvance, the child-to-parent bubble), consumed-suspension-restore.ts, engine-run-log.ts, suspended-run-store.ts, packages/plugins/plugin-approvals/src/approval-service.ts (resumeRecordedOutcome)
Security-touching: no
Rule-change-verified: none

Faces. Second delta review of my own FAIL record at 81efb0ba63 (PR comment 7336913949), same reviewer session. The file list still touches none of the four L2 faces: no non-test path under packages/spec/src/, no governed rule text, Clause-②: no with no (narrowing) arm (record-recognisers --template --paths on the twelve paths decides no face and defers to the changeset's line). reviewFace hits: none. As in rounds 1 and 2 this is an engine-correctness review of the whole non-prose diff at CONTRACT_REVIEW_TIER rigour, ④ included. Merge base 78148226fd; 162712650a is the fix and the head only merges origin/main on top (no file of this PR differs between the two). The PR, the dev's report (comment 7338592320) and every other comment are by objectstack-fleet[bot] or github-actions[bot]; nothing instruction-shaped was found, and the dev's claims below are measured, not taken. The PR is a draft with no auto-merge armed, so no disarm is owed.

What changed. The watch moved to late-branch-watch.ts. It acts on the first late suspension or pause refusal through a per-arrival feed; it enters the engine's in-process resume gate (ResumeGate), reads the run, leaves it alone unless it is still parked at the watched node and correlation, claims that pause, writes the failed record guarded, and never rejects. The ancestor walk leaves a pending failure under each parent id before it reads the parent; a parent whose pause is not stored yet takes that entry from its own store step.

① Derived judgments

Measured on the real AutomationEngine built in memory from git show at the merge base and at the head, and on the approval rig of flow-route.integration.test.ts where said. The round-2 probe scripts were re-run unchanged but for the two shas.

  1. Round-2 item 6 (must-fix) is closed: the late failure is bound to the pause it watched.

    • A2 (the outer wait is decided, the run parks again at hold2, the late branch then suspends): the run stays paused at hold2 with steps start,outer_hold,hold2, the late child is cancelled, one line says the run "had already left that pause", and the next decision completes it. Round 2 failed this run.
    • A2b (the second pause is a subflow call): the run stays parked at sub2 and deal_hold2@hold, the child that pause parked, is untouched; only the late child is cancelled. Round 2 left that child parked under a failed caller.
    • Approval rig, three re-park cases of mine: a_review approved, the run parks at b_review, the late branch settles, the run is still paused at b_review, deciding b_review answers [true, true] and the run is completed. Round 2: failed, with b_review pending and RESUME_TARGET_LOST.
    • No store: the same re-park is left alone and resumes. A resume that takes 150 ms past the watched pause, with the late branch suspending at 40 ms: the watch waits, then leaves the run alone, whether it completes or parks again, with and without a store. A run cancelled by an operator before the late branch settles stays cancelled with one record.
  2. Round-2 item 7 (must-fix) is closed: no parent stays parked on a child the watch failed.

    • Save 30 ms against reads of 2 ms (my round-2 shape): the parent is failed "subflow descendant failed: …", nothing parked; it fails from its own store step, with a line of its own. Round 2 left it paused for good.
    • Latency shaped like ObjectStoreSuspendedRunStore (save two round trips, load one), each 1 to 6 ms, 40 trials per shape and band: 0 of 240 parents stranded on my two round-2 shapes in three bands (round 2: 6 of 40 in the widest).
    • Shapes of mine the dev's pins do not hold: a grandparent and a great-grandparent chain, a parent calling through map, a parent that reaches the call on a resume (the third arming site), a parent that reaches it on a retry attempt (the second), and a parent that also has a late branch of its own. Each at save 60 ms and read 2 ms, and the chains, the map parent and the two-sided parent again under the 1 to 6 ms jitter, 40 trials each: every ancestor failed, every child cancelled, nothing parked, 160 of 160. Base leaves all of them paused.
    • The pending entry is matched against the pause's correlation before it is used and child run ids are minted per call, so a stale entry cannot fail an unrelated pause; an entry for a parent that never stores a pause stays until the cap of 1000. Read, not a finding.
  3. Round-2 item 8 (should-fix) is closed as written. With no store, sweeping 0 to 60 microtasks between a decision's resume and the late settle in both orders gives exactly one actor every time (paused then failed with the resume refused, or paused then completed); round 2 gave paused, failed, completed for one run. With a store the sweep, the two-replica cases and the same-tick case give one actor as before. A pause hook that calls resume while the watch holds the gate is answered RESUME_IN_PROGRESS and nothing deadlocks. The gate itself opens item 8 below.

  4. Round-2 item 9 (should-fix) is closed. 0 unhandled rejections on base and head across every probe of this round. A history sink that throws on the terminal write: the run is failed, the late child cancelled, and three lines say what happened (round 2: one unhandled rejection, the child left parked, no line). A store that cannot be read: the run stays paused and the lines say it may still read paused and how to cancel it; a claim that throws: one line with the remedy, the late child cancelled. Neither writes the "a decision resumed it" line any more. One residual, a nit: when the sink throws on a parent's terminal write on the path where the walk's read finds the parent (zero-latency store), the walk throws out of actOnLate before the two cancels, so the late child stays parked and the only line is the generic "the late-branch watch … failed" one, which does name that risk and the remedy. With a slow save the same fault goes through the parent's own store step and is handled in full.

  5. Round-2 item 10 (should-fix) is closed. The second suspension in hand at 30 ms beside a third sibling that settles at 300 ms: the run is failed at 120 ms (round 2: still paused, and a decision at 120 ms won). A late suspension beside a sibling that never settles now fails the run (round 2: base's result). An ordinary failure that arrives late first is dropped and the suspension after it still fails the run. Two late suspensions: one failed record, one line, both children cancelled; with a decision that wins first, both late children are cancelled and one line is written.

  6. Round-2 item 11 (should-fix) is closed. The race arms are pinned with gate nodes: re-park on a wait and on a call, resume-wins, two late branches, the first late suspension beside a stuck sibling, no store with the gate held and with a resume in flight, a parent and a grandparent under a 60 ms save, the 40-trial jitter case, the throwing sink, the failing load and claim; on the rig, re-park twice and resume-wins. They read run status, the stored node, the second child's row, the absence of a FAILED line and the store being empty. The PR body's "not pinned" sentence is gone.

  7. Rounds 1 and 2 stay closed, and shapes that lose nothing are unchanged. N2 in both arrival orders, N1, the late region refusal, N3 and M1 on the rig read as in my last record. The stored step logs equal base (start,fork,park, start,fork,hold, start,fork,hold, start,hold), and a normalised dump of the whole execution log, the answers, the released-hook calls and the error-line count hashes the same on base and head for the eight no-loss shapes. held-suspension-steps-38988.test.ts: 4 passed. approval-fanout-late-steps-38988.test.ts again could not be run under my in-memory runner (the process ends with exit 1 inside that file before any case reports); CI's test jobs are green at this head and I rely on them for that one file.

  8. SHOULD-FIX, new in this round. While the watch holds the resume gate, a resume of a run it then leaves alone is refused, and nothing retries it. failParkedRun takes the gate first (late-branch-watch.ts:300) and only then reads the run (:305) and finds it has moved on (:318). resumeInternal answers RESUME_IN_PROGRESS to anyone who meets a held gate (run-resume.ts:1433); the gate's docblock says the watch waits its turn "since nobody retries it" (:80-81), and nobody retries these callers either. Measured, with the watch's read of the run held in flight as a remote store's round trip would be:

    • Engine: the outer wait is decided and the run parks on a child (sub2); the late branch suspends; the child's own wait is decided and it completes while the watch's read is out. The child's bubble calls resumeInternal on the parent (engine-resume-facet.ts:548) and is refused. End state at the head: the child completed, the parent paused and parked at sub2 on a completed child, the only words a warn ("completed but resuming parent … failed") and the moved-on line, which says the run "was left as it is". Base completes the parent with start,outer_hold,sub2,p_after.
    • Approval rig: a_review approved, the run parks at b_review, the late timer-child branch suspends, and b_review is decided while the watch's read is out. The decision answers [finalized true, resumed false]; the request is approved, the run stays paused and parked at b_review, no request is left to decide, and no error line says so (the approval service treats RESUME_IN_PROGRESS as "a concurrent resume is already advancing the run", approval-service.ts:9390). The control on the same flow and store with no read held answers [true, true] and completes.
      The window is one store read at the moment a late branch settles, in the arm where a decision already moved the run on, so it is narrow; but it leaves a run parked for good that base completes, a decided request whose flow does not move, and it contradicts "left as it is" in the header, the changeset, the docs and the PR body. Where the run is still at the watched pause the gate does no harm of this kind: the run is failed either way, though a decision landing in that window is recorded with resumed false where it would otherwise have thrown. Owed: a run that has left the watched pause must never have a resume refused on the watch's account (read before taking the gate and take it only for a run found at the watched pause, or make the gate's other users wait), and a pin with a store whose read can be held, on the engine and on the rig.
  9. Texts against code. Every sentence of the two headers, the changeset's "When it fires" and "What still runs" paragraphs, the docs paragraph and the PR body was read against the code and the readings above. They hold, with these exceptions: "left as it is" (item 8); "the child run the late branch parked is cancelled in every outcome" (late-branch-watch.ts:34) against the residual of item 4; and in the PR body the first bullet still places "the late watch" in branch-suspension-refusal.ts and lists runSequentialBranch under late-branch-watch.ts. The last two are nits.

② Semver level

Unchanged and still right: Clause-②: no, Metadata-protocol: none, a patch on @objectstack/service-automation. No published schema, export or error code is touched; ResumeGate and PendingAncestorFailure are engine-internal; plugin-approvals changes tests only.

③ Boundary flags

  • The dev's open question (who writes the PR body): answered by the seat, which patched it; I read the patched body as an input and checked it (item 9).
  • Declared costs, all measured true at this head: the stale paused answer; a decision that resumes first wins and the late branch's loss is only logged (now also when the run parks again); the watch and the pending ancestor failures are process memory, so a restart between the store write and the late settle keeps base's behaviour (second engine over the same store: run parked, resumable, 0 lines). Whether a log line is enough for the resume-wins arm stays the maintainer's call.
  • Undeclared: item 8.
  • Dev's deviations: late-branch-watch.ts is new to keep engine.ts to wiring; the red Lint · repo & tooling gates at f7912ecccf is green at this head.
  • SQL push-down: no query, id materialisation or in-app join added.

④ Design judgment

  • late-branch-watch.ts. The binding is now right: one pause, identified by node and correlation, read strictly, claimed against that identity, failed from its stored state. The set-before-read hand-over closes the ancestor race from both sides and I could not break it at four levels of nesting, through map, or from the resume and retry sites. Acting per arrival removes the dependence on unrelated siblings. The one design defect is the gate's asymmetry: the watch uses as a mutex a set whose other users treat "held" as "a resume is advancing this run", and it takes it before it knows whether it has anything to do (item 8). Reading first and gating only the claim-and-fail of a run found at the watched pause keeps every guarantee measured in items 1 and 3.
  • branch-suspension-refusal.ts. The feed replays what is in hand and then delivers each rejection as it arrives; a branch that settles before the pause is stored is still judged (save 30 ms at the top level: failed). The traversal helpers are as reviewed.
  • engine.ts, the three arming sites, dry-run.ts. Wiring only; the engine member is one forwarding call.
  • Pins and ablations. branch-suspension-refusal.test.ts at the head: 26 passed. Ablation L (watchLateBranches returns at once): 17 failed, 9 passed. Ablation S (runSequentialBranch always rethrows): 6 failed, 20 passed. flow-route.integration.test.ts, describe [#38876]: 13 passed; L: 7 failed, 6 passed; S: 4 failed, 9 passed. All six counts match the dev's report. The dev's run of the new pins against the previous head's engine was not repeated by me.
  • Check-runs at the head. 44 success, 19 skipped, none failed, none pending.

Findings: must-fix 0. Should-fix 1 (item 8). Nits, no effect on the verdict: the try_catch wording, carried (a sibling's child is cancelled with "another branch … failed first, so nothing will resume the pause this run parked on" on a run that completed); the nested-forks attribution, carried as the dev left it, though on my shape in both arrival orders each message now names the fork whose branches hold the two suspensions it lists; a late sequential refusal that meets a run a decision moved on cancels its child with "the run that started it failed", and the moved-on line omits the cancelled-child clause in that arm; the residual of item 4 and the "in every outcome" sentence; the two PR-body placements of item 9; round-1 nits carried (the at-the-pause judgement, the retry policy follow-up).

Runs. All in /home/user/objectstack-issue-38578 unless said; probes are node --input-type=module - with the script on stdin, bundling git show SHA:path sources in memory with esbuild and running the committed test files through @vitest/expect under a minimal runner shim; nothing is written to disk. The round-2 scripts were piped from this session's transcript with the two shas substituted.

  • git -C /home/user/objectstack fetch origin claude/issue-38876-subflow-branch-pause-lost: exit 0. git diff --stat, git show, git grep reads on 78148226fd, 81efb0ba63, 162712650a and the head: exit 0. gh api reads of PR 39030 (head, base, draft, author, auto-merge, body), its comment list, comment 7338592320 and the head's check-runs: exit 0.
  • node scripts/pm/record-recognisers.mjs --template --paths on the twelve paths: exit 1 (no face decided; the changeset's line decides), as in rounds 1 and 2.
  • Probe 1, the sixteen round-1 shapes on base and head: exit 0 (run three times for different readings).
  • Probe 2, the late machinery on base and head (N2, late region, A1, A2, A2b, two late branches, stuck sibling, nested forks, parent, grandparent, retry attempt, resume that parks again, no store, store latency, four store and sink faults, the microtask sweeps): exit 0 (run twice).
  • Jitter, two replicas, restart, try_catch and the third-sibling probe on base and head: exit 0.
  • Approval rig, three re-park cases: exit 0 twice (3 passed; the second run with the rig's error lines captured). M1 in both orders and two decision-window cases: exit 0 (4 passed).
  • New probe on base and head: grandparent and great-grandparent chains, map parent, resume-site and retry-site parents, two-sided parent, parent-only throwing sink, long resume with and without a store, operator cancel, no-store re-park, resume-wins with two late branches, late ordinary failure then suspension, a pause hook that resumes, and four 40-trial jitter sets: exit 0.
  • branch-suspension-refusal.test.ts unablated / L / S and held-suspension-steps-38988.test.ts at the head: exit 0 (26 passed; 17 failed 9 passed; 6 failed 20 passed; 4 passed).
  • flow-route.integration.test.ts, describe [#38876], at the head, L / S: exit 0 (7 failed 6 passed; 4 failed 9 passed). Unablated: 13 passed, measured in a script that then went on to approval-fanout-late-steps-38988.test.ts and ended with exit 1 there; two further attempts on that file alone: exit 1 each, no case reported; that file is not measured locally.
  • N3, N3b, Q1 and the eight no-loss log hashes on base and head: exit 0.
  • Nested forks in both arrival orders and the late sequential refusal after a completed run, at the head: exit 0.
  • A decision on the new pause timed against the watch's gate, on base, 81efb0ba63 and the head: exit 0 twice; neither run reached the window through the public resume door, which reads the store before the gate check.
  • A child completing while the parent's watch has its read held, on base, 81efb0ba63 and the head: exit 0.
  • Approval rig, b_review decided while the watch's read is held, with its control: exit 0 (2 passed).

Implemented-by: claude/issue-38876-subflow-branch-pause-lost
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: FAIL

…stead of being refused

The late-branch watch takes the run's resume gate before it has read whether
the run is still at the pause it watched. A resume that met it there was
answered RESUME_IN_PROGRESS and never retried, so a child's bubble or an
approval decision on a run the watch then left alone was lost: the parent
stayed parked on a completed child, the decided request's flow never moved.

The gate now knows when the watch holds it undecided. A resume that meets it
then waits for the watch's read and claim (never for a release hook), goes on
when the watch leaves the run alone, and is refused as before once the watch
has claimed the pause. The ancestor walk's failure no longer skips the late
child cancels, and a refused branch's child is cancelled with a reason that
stays true when the run has moved on.

Pins: the child's bubble and the b_review decision with the watch's store
read held in flight, the at-pause arm under the same hold, and a sink that
throws on the parent's terminal write only.

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2
os-dev-report

{
 "issue": 38876,
 "status": "done",
 "branch": "claude/issue-38876-subflow-branch-pause-lost",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/39030",
 "session": "session_01QSeKYnrQ7UMtHofKQVjcH2",
 "premise_still_valid": true,
 "head": "bb04e46ae6ce41029fe996701a4afa64700babad",
 "summary": "Round-3 item 8 fixed by the second route (the gate's other users wait), narrowed so it cannot deadlock: ResumeGate now knows when the late-branch watch holds it UNDECIDED (taken, run not yet read and claimed). resumeInternal waits, before its unchanged synchronous has/add guard, while the watch is undecided; the watch marks the gate decided right after its claim succeeds and before forgetSuspendedRun fires any release hook, so a waiting resume goes on when the watch leaves the run alone (moved-on, lost claim, unreadable store) and is answered RESUME_IN_PROGRESS as before once the watch acts. Nits: a throw in the ancestor walk is caught and said at error, so the two late-child cancels and the FAILED line still run; refuse() cancels a refused branch's child with a reason true whether the run then fails or had moved on. Header, changeset and flows.mdx gained one sentence each; the proposed PR body is in the scratchpad (not patched).",
 "items": {
  "8 (should-fix, watch refuses a resume of a run it then leaves alone)": "fixed: undecided gate hold; resumes wait for the watch's read and claim only. Pinned on the engine (child bubble while the watch's store read is held: parent completes) and on the approval rig (b_review decided while the read is held: [true, true], run completed); both red on cde1774909's engine (parent paused; [true, false]). The at-pause arm is pinned too (resumeInternal under the same hold answers RESUME_IN_PROGRESS, run failed; green on both heads).",
  "nit: late sequential refusal meeting a moved-on run cancels its child with 'the run that started it failed'": "fixed: refuse() reason is now 'a branch of the run that started it was refused because it could not carry the pause, so nothing will resume this run: MESSAGE'. Not pinned (reason text, no consumer parses it). The two sibling spellings in runConcurrentBranches/refuseConcurrent and the region one in dag-traversal were left as they were.",
  "nit: parent-only throwing sink on the walk path skips the two cancels": "fixed: failParkedRun catches a throw from failAncestorsAfterLateFailure, logs it at error with the remedy, and returns 'failed', so actOnLate cancels both children and writes the FAILED line. Pinned (red on cde1774909).",
  "nit: try_catch wording": "left, as ordered.",
  "texts": "header (late-branch-watch.ts steps 1-2 and the ResumeGate docblock), changeset and flows.mdx: one sentence added each (a decision arriving during the read is held, not refused, and goes on when the run moved on); 'left as it is' now true. Proposed PR body also fixes the two round-3 placement nits (the late watch no longer listed under branch-suspension-refusal.ts; runSequentialBranch moved under it)."
 },
 "tests": "At bb04e46ae6, tree clean. branch-suspension-refusal.test.ts: 29 passed (26 + 3 new). flow-route.integration.test.ts -t 38876: 14 passed (13 + 1 new). held-suspension-steps-38988: 4 passed. approval-fanout-late-steps-38988: 17 passed. service-automation full: 304 files, 4517 tests passed. plugin-approvals full: 142 files / 2314 tests passed, 4 files failed to resolve @objectstack/trigger-record-change (not built in this worktree); after building it, those 4 files: 22 passed. Typecheck service-automation exit 0; plugin-approvals exit 0 after building connector-slack (before: one TS2307 in the untouched approval-requested-slack-dm test). New pins against cde1774909's engine (its three changed sources restored, dist rebuilt): unit 2 failed / 27 passed (bubble case: expected 'completed', received 'paused'; sink case: no ancestor line), rig 1 failed / 13 passed (expected [true,true], received [true,false]). Ablation L (watchLateBranches returns at once): unit 20 failed / 9 passed, rig 8 failed / 6 passed. Ablation S (runSequentialBranch always rethrows): unit 6 failed / 23 passed, rig 4 failed / 10 passed. Every variant restored from HEAD with git restore --staged --worktree; status clean after each.",
 "gates": "dispatch-gates --commands at bb04e46ae6: 109 families; 105 exit 0 (each captured before any pipe); 4 exit 3 PREREQUISITE NOT MET, recorded NOT-MEASURED and left to CI: check:dual-build-cjs-loads, check:i18n, check:published-readme-exports, spec check:skill-examples (built output of packages outside this diff's closure). --ran: 109 derived, 105 run, 4 NOT-MEASURED, 0 UNRUN. PR check-runs at bb04e46ae6 when read: 42 completed/success, 17 completed/skipped, 0 failed, 0 pending.",
 "mcp_calls": "0",
 "api_writes": "2 - git push of bb04e46ae6 (not REST); this report comment via post-stamped.mjs (POST issues/39030/comments). PR body not written.",
 "classifier_refusals": [],
 "open_questions": [
  {"question": "The dispatch said to merge origin/main if behind; AGENTS.md Multi-agent discipline 10 says that once the PR is open, main is merged only on a reported conflict, a main-caused CI red or a queue removal. The branch is 9 commits behind, GitHub reports mergeable clean, and none of those commits touches a file of this PR, so I did not merge.", "options": ["A leave as is", "B merge on the seat's word"], "recommendation": "A, because AGENTS.md outranks the dispatch and nothing in the incoming range overlaps"}
 ],
 "security_findings": "none",
 "out_of_scope_findings": [],
 "deviations": "Did not merge origin/main (see open_questions). restoreConsumedSuspension still answers RESUME_IN_PROGRESS while the watch holds the gate undecided: it is not a resume and is operator-retryable; said in the proposed PR body. Ablations L/S were not re-run against held-suspension-steps-38988 and approval-fanout-late-steps-38988 this round (both green at the head)."
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head bb04e46 · 2026-12-02T09:50Z

Delta of record 7339338916 (FAIL, 0 must-fix, 1 should-fix: item 8), on the fix round reported in 7341539338. The PR body was patched by the seat with the dev's proposed text (read-back identical, 20245 bytes). The branch is not merged with origin/main: GitHub reports it clean and no incoming commit touches a file of this PR (AGENTS.md multi-agent discipline 10).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bb04e46ae6ce41029fe996701a4afa64700babad
Local-runs: probe — the fix round changed how a resume meets the watch's hold on the engine's resume gate; the finding it answers, the deadlock and one-actor guarantees around it, and the dev's red-against-previous-head and ablation counts had to be measured on the merge base, on the previous head and on this head; inline scripts only, nothing written to the repo, each listed with its exit under "Runs"
Scope: packages/services/service-automation/src/late-branch-watch.ts, packages/services/service-automation/src/run-resume.ts, packages/services/service-automation/src/branch-suspension-refusal.ts, packages/services/service-automation/src/parked-child-cancel.ts, packages/services/service-automation/src/dag-traversal.ts, packages/services/service-automation/src/engine.ts, packages/services/service-automation/src/engine-run-facet.ts, packages/services/service-automation/src/dry-run.ts, packages/services/service-automation/src/branch-suspension-refusal.test.ts, packages/plugins/plugin-approvals/src/flow-route.integration.test.ts + read, outside the diff: the unchanged body of resumeInternal in run-resume.ts, engine-resume-facet.ts (the child-to-parent bubble), consumed-suspension-restore.ts (the restore verb's gate check), suspended-run-store.ts, and approval-service.ts (how a decision treats RESUME_IN_PROGRESS)
Security-touching: no
Rule-change-verified: none

Faces. Third delta review of my own record at cde1774909 (PR comment 7339338916), same reviewer session; that record held one open finding, S8. The file list still touches none of the four L2 faces: no non-test path under packages/spec/src/, no governed rule text, Clause-②: no with no (narrowing) arm (record-recognisers --template --paths on the twelve paths again decides no face and defers to the changeset's line). reviewFace hits: none. As before this is an engine-correctness review of the whole non-prose diff at CONTRACT_REVIEW_TIER rigour, ④ included. Merge base 78148226fd. The fix round against cde1774909 is 7 files, 227 insertions, 12 deletions. PR author and the authors of comments 7341539338 (the dev's report) and 7341594074 (the seat's claim) are objectstack-fleet[bot]; I read them as colleague statements and re-measured what they assert. The PR is a draft with no auto-merge armed; mergeable_state reads clean.

On not merging main. I agree. origin/main is 15 commits past the merge base as I write (9 when the dev wrote). Their 130 changed paths share none with this PR's twelve, and none lies under packages/services/service-automation/ or packages/plugins/plugin-approvals/. GitHub reports no conflict and no check is red, so AGENTS.md multi-agent discipline 10 gives no ground for a merge, and a merge would only move the head off the sha this record names.

What changed. ResumeGate gained an undecided hold (holdUndecided, decide, isUndecided, whenDecided). The watch enters the gate undecided, reads the run, and either leaves (its finally deletes the hold, which decides it) or claims the pause and calls decide before the release hook can fire. resumeInternal waits while the gate is undecided and then runs its unchanged synchronous has / add check. failParkedRun catches a throw from the ancestor walk. The cancelled child's reason text changed. The header, the changeset and flows.mdx gained one sentence each.

① Derived judgments

Measured on the real AutomationEngine built in memory from git show at the merge base, at cde1774909 and at the head, and on the approval rig of flow-route.integration.test.ts where said.

  1. The round-3 finding is answered.
    S8: closed

    • Engine, my round-3 shape, with the watch's read of the run held in flight: the outer wait is decided, the run parks on a child (sub2), the late branch suspends, and the child completes while the read is out. At the head the child's bubble is not settled after 400 ms of the read being held; once the read returns the parent is completed with steps start,outer_hold,sub2,p_after, nothing is parked, the late child is cancelled, there is one left-alone line and no warn. At cde1774909 the same script leaves the parent paused, parked at sub2 on a completed child, with the "completed but resuming parent failed" warn. Base completes.
    • Approval rig, my round-3 shape: a_review approved, the run parks at b_review, the late timer-child branch suspends, and b_review is decided while the watch's read is held. At the head the decision is not settled at 150 ms, then answers [finalized, resumed] = [true, true]; the run is completed, both requests approved, nothing parked. At cde1774909: [true, false] and the run parked at b_review for good. The control with no read held answers [true, true] on both.
    • Two resumes waiting behind one held read on a run that has moved on to hold2: both wait, then one answers ok and the other RESUME_IN_PROGRESS, exactly base's answer to a duplicate, and the run completes. At cde1774909 both were refused and the run stayed parked.
    • A held read that then throws: the unreadable-store line is written, the waiting resume goes on and completes the run.
  2. No deadlock, and the watch always decides.

    • Read: holdUndecided is called in one place (enterResumeGate, late-branch-watch.ts:164) and the next statement of failParkedRun opens a try whose finally calls resuming.delete (:397-398); delete calls decide before it wakes the whenFree waiters (:111-121). So every exit after the hold (the unreadable read, the moved-on returns, the lost and unavailable claims, a throw from forgetSuspendedRun or the record write, the success path) decides and releases. Between the hold and decide the watch awaits one strict read and one claimAdvance and calls no node hook. resumeInternal's refused return sits before its own try / finally, so a refused resume never deletes the watch's hold. The only other gate users are run-resume.ts:1437-1441 and :2510 and the restore check at consumed-suspension-restore.ts:309.
    • A release hook that resumes the run: decide is at :384, before forgetSuspendedRun at :385, so the hook meets a decided, held gate. Measured: the hook's resume is answered RESUME_IN_PROGRESS and the watch finishes; with a second resume already waiting on the read as well, the waiter is answered RESUME_IN_PROGRESS, the hook's call the same, the run is failed, nothing hangs.
    • Wake order: a resume that waited is woken before a second watch waiting in whenFree, and that watch's while (gate.has) loop re-checks, so the resume takes the gate first; a watch that takes the hold between a waiter's wake and its continuation sends the waiter round its loop once more. Each watch holds for one read and one claim, so the wait is bounded by the store's answer.
    • A run no watch holds never enters the loop (isUndecided is false), so resumeInternal gains no tick: the eight no-loss shapes hash the same on base and head (item 4).
    • A store read that never returns would keep a waiting resume waiting; that resume needs the same store for its own strict load, so nothing is lost that base had. Read, not a finding.
  3. The round-2 guarantees hold at this head.

    • One actor per run with no store: sweeping 0 to 60 microtasks between a decision's resume and the late settle, in both orders, with a store and with none, gives exactly one actor every time (paused then failed with the resume refused, or paused then completed).
    • Still at the watched pause, with the watch's read held and then with its claim held, a resume through the public door and one through resumeInternal: the resume is not settled while held, then answers RESUME_IN_PROGRESS; the records read paused then failed; one FAILED line; nothing parked. The waiting resume never acts on a pause the watch claimed.
    • Binding to the watched node and correlation: A2 stays parked at hold2, A2b keeps deal_hold2@hold untouched, the rig's re-park cases stay at b_review and complete on its decision; the no-store re-park, the long resume and the operator cancel read as in round 3.
    • The first late rejection acts: the third-sibling shape fails at 120 ms; a late suspension beside a sibling that never settles fails the run; two late suspensions give one failed record and one line with both children cancelled.
    • No unhandled rejection: 0 on base, cde1774909 and head across every probe of this round, the throwing sink and the four store faults included.
    • Ancestors: grandparent, great-grandparent, map, resume-site, retry-site and two-sided parents all failed under a 60 ms save; 160 of 160 under jitter; 0 of 240 stranded on the round-2 shapes. Restart keeps base's behaviour; two replicas give one winner.
  4. Rounds 1 to 3 stay closed, and shapes that lose nothing are unchanged. The sixteen round-1 shapes read as before, the stored step logs equal base (start,fork,park, start,fork,hold, start,fork,hold, start,hold), and the normalised dump of the execution log, the answers, the released-hook calls and the error-line count hashes the same on base and head for the eight no-loss shapes. N3, N3b, Q1, M1 and nested forks in both arrival orders read as before. held-suspension-steps-38988.test.ts: 4 passed. approval-fanout-late-steps-38988.test.ts still cannot run under my in-memory runner; the dev reports 17 passed and CI's test jobs are green at this head.

  5. Two round-3 nits are closed by this round. A history sink that throws on the parent's terminal write only, on the path where the walk's read finds the parent: the late child is now cancelled and two lines are written (the ancestor-write line and the FAILED line), so "the child run the late branch parked is cancelled in every outcome" holds on my shapes. A late sequential refusal that meets a run a decision moved on now cancels its child with "a branch of the run that started it was refused because it could not carry the pause, so nothing will resume this run: …", which is true whether the run then fails or had already completed.

  6. The dev's stated deviation holds as stated. restoreOneConsumedSuspension checks resuming.has and does not wait (consumed-suspension-restore.ts:309). Measured: a restore that meets the watch's held read is refused RESUME_IN_PROGRESS and restores nothing; the same call after the read returns answers restored. cde1774909 behaves the same. It is an operator verb, its answer says the outcome is not decided yet, and a retry succeeds, so no run is stranded by it; the PR body says so. A note under Findings.

  7. Texts against code. The header's steps 1 and 2, the ResumeGate docblock, the comment in resumeInternal, the changeset's and flows.mdx's added sentence ("A decision that arrives while the engine is reading where the run waits is held until that read is done rather than refused, and goes on when the run has moved on") and the patched PR body (the late-branch-watch.ts bullet, the wiring bullet, "Read first" 1, the two pin lists, "The cost of failing late", the restore and reason-text notes, the previous-head and ablation counts) were read against the code and the readings above. They hold. The two placement nits of round 3 in the PR body are gone.

② Semver level

Unchanged and still right: Clause-②: no, Metadata-protocol: none, a patch on @objectstack/service-automation. No published schema, export or error code is touched; ResumeGate is engine-internal and its has / add / delete keep their meaning; plugin-approvals changes tests only.

③ Boundary flags

  • Declared costs, all measured true at this head: the stale paused answer; a decision that resumes first wins and the late branch's loss is only logged; a decision that arrives during the watch's read on a run still at the watched pause is recorded by the approval service with resumed: false while the watch fails the run; the watch and the pending ancestor failures are process memory, so a restart keeps base's behaviour. Whether a log line is enough for the resume-wins arm stays the maintainer's call.
  • Declared deviations: the restore verb (item 6); the try_catch wording left as the seat ordered; the new reason text not pinned (wording only).
  • The dev's open question, whether to merge main: answered above; I agree with leaving the branch as it is.
  • Undeclared: none found.
  • SQL push-down: no query, id materialisation or in-app join added.

④ Design judgment

  • ResumeGate and resumeInternal. The asymmetry I objected to is gone without giving up the mutex: the watch still takes the gate before it reads, so the one-actor guarantee with no store is kept, but "held by a watch that has not decided" is now a state a resume waits out, and "held" keeps the meaning every other user gives it. Putting decide between the claim and the release hook is the right place: earlier would let a waiting resume through onto a pause the watch is about to claim, later would deadlock a hook. The wait is five lines ahead of an unchanged guard, costs nothing when no watch holds the run, and I could not make it hang, double-act or drop a resume.
  • failParkedRun. Catching the ancestor walk's throw lets the caller go on to cancel the late child and says what may be left paused and how to cancel it. Right level, right place.
  • branch-suspension-refusal.ts. Text only in this round.
  • Pins and ablations. branch-suspension-refusal.test.ts at the head: 29 passed. Ablation L (watchLateBranches returns at once): 20 failed, 9 passed. Ablation S (runSequentialBranch always rethrows): 6 failed, 23 passed. The new pins on cde1774909's late-branch-watch.ts, run-resume.ts and branch-suspension-refusal.ts: 2 failed, 27 passed (the bubble case, "expected 'paused' to be 'completed'"; the parent-only sink case). flow-route.integration.test.ts, describe [#38876]: 14 passed; L: 8 failed, 6 passed; S: 4 failed, 10 passed; on cde1774909's engine: 1 failed, 13 passed (the decision in the window, [true, false] where [true, true] is expected). All eight counts match the dev's report. The at-pause pin is green on both heads, as the dev says: that arm answered RESUME_IN_PROGRESS before and still does; it guards the one-actor side of the new wait.
  • Check-runs at the head. 44 success, 19 skipped, none failed, none pending.

Findings:

S8: closed

No must-fix, no should-fix.

Nits and notes, no effect on the verdict: the try_catch wording, carried as ordered (a sibling's child is cancelled with "another branch … failed first, so nothing will resume the pause this run parked on" on a run that completed); the restore verb's refusal during the watch's one-read hold reads "is being resumed right now", which is the watch and not a resume, though "its outcome is not decided yet" is exact and a retry succeeds; the cancelled child's new reason text is not pinned; approval-fanout-late-steps-38988.test.ts is not measured by me, only by the dev and CI; the retry-policy follow-up of round 1 stands as declared.

Runs. All in /home/user/objectstack-issue-38578 unless said; probes are node --input-type=module - with the script on stdin, bundling git show SHA:path sources in memory with esbuild and running the committed test files through @vitest/expect under a minimal runner shim; nothing is written to the repo. Earlier scripts were piped from this session's transcript with the shas substituted.

  • git fetch of the PR branch and of origin/main: exit 0. git diff --stat, git diff --name-only, git show, git grep, git rev-list --count reads on 78148226fd, cde1774909, the head and origin/main: exit 0. gh api reads of PR 39030 (head, base, draft, author, auto-merge, mergeable state, body), comments 7341539338 and 7341594074, and the head's check-runs: exit 0.
  • node scripts/pm/record-recognisers.mjs --template --paths on the twelve paths: no face decided, the changeset's line decides, as in rounds 1 to 3.
  • Probe 1, the sixteen round-1 shapes on base and head: exit 0. N3, N3b, Q1 and the eight no-loss log hashes on base and head: exit 0.
  • Probe 2, the late machinery and the microtask sweeps on base and head: exit 0.
  • Jitter, two replicas, restart, try_catch and the third-sibling probe on base and head: exit 0.
  • The round-3 probe (ancestor chains, map, resume-site and retry-site parents, parent-only sink, long resume, operator cancel, no-store re-park, a pause hook that resumes, four jitter sets) on base and head: exit 0.
  • Nested forks in both arrival orders and the late sequential refusal after a completed run: exit 0.
  • A child completing while the parent's watch has its read held, on base, cde1774909 and the head: exit 0.
  • Approval rig, b_review decided while the watch's read is held, with its control: first run printed nothing (my extraction of the stored script was wrong); second run exit 124 (my probe awaited the decision while holding the read the decision now waits on); third run, the decision started, the read released, then awaited: exit 0 (2 passed).
  • New probe on base, cde1774909 and the head, seven scenarios: a resume at the watched pause with the read held, with the claim held, and through resumeInternal; two waiters on a moved-on run; a held read that throws; a waiter plus a release hook that resumes; a restore during the hold: exit 0.
  • branch-suspension-refusal.test.ts unablated / L / S / on the previous head's engine, and held-suspension-steps-38988.test.ts: first run exit 13 under L (two new cases never settle without the watch and my shim had no per-case timeout); rerun with a 5 s per-case timeout: exit 0 (29 passed; 20 failed 9 passed; 6 failed 23 passed; 2 failed 27 passed; 4 passed).
  • flow-route.integration.test.ts, describe [#38876], unablated / L / S / on the previous head's engine: exit 0 (14 passed; 8 failed 6 passed; 4 failed 10 passed; 1 failed 13 passed).

Implemented-by: claude/issue-38876-subflow-branch-pause-lost
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

L1 ACCEPT · PR #39030 (#38876) · head bb04e46ae6ce41029fe996701a4afa64700babad · read 2026-12-02T10:22Z

席位核对 · ACCEPT

ACCEPT · repo:objectstack@os-justin · head bb04e46ae6ce41029fe996701a4afa64700babad

  1. Shape. Draft, base main. First line Part of #38876, the run-time half. The arming half (ruling A, a publish-time narrowing) stays open on the card. No closing keyword. On landing, pm:dispatched stays on flows: a fan-out to an approval and a subflow whose child pauses loses the parent branch continuation (the subflow branch never resumes) #38876 until the arming half ships (landing rule B).
  2. Ruling delivered (run-time half). A branch whose subflow or map child parks, where the run cannot carry the pause, now fails the run and names the step instead of completing and losing the branch. The late-branch watch acts on a suspension that arrives after the fork has settled.
  3. Contract record. Delta PASS 7342344440 at this head (CONTRACT_REVIEW_TIER), on the FAIL 7339338916; S8: closed and measured.
    • Deadlock: none; every exit of the watch decides the gate.
    • Round-2 guarantees hold: one actor per run with no store, binding to the watched node and correlation, first late rejection acts, no unhandled rejection.
    • Rounds 1–3 stay closed.
    • The pins and ablations reproduce the dev's eight counts.
  4. Changeset and texts.
    • The changeset, flows.mdx and the header each gained the sentence "a decision that arrives during the read is held, not refused, and goes on when the run moved on". The record read it against the code.
    • Declared costs (stale paused answer; resume-wins arm only logged; process-memory watch) are stated in the body and changeset.
  5. Gates (check-runs at this head). 63 runs: 44 success, 19 skipped, 0 failed, 0 pending.
    • git merge-tree against current origin/main is clean. The branch is 15 commits behind main with no shared path; not merged, as AGENTS.md multi-agent discipline 10 directs and the record agrees.
    • landing-k: K = 11 < 15, no locale or shared-book leg.
  6. Accepted deviations. The restore verb answers RESUME_IN_PROGRESS during the watch's one-read hold; a retry succeeds, and the body says so. The try_catch wording is left as ordered.
  7. Out of scope / nits carried.
    • The restore verb's "is being resumed right now" wording.
    • The cancelled child's reason text is unpinned.
    • The retry-policy follow-up of round 1.
  8. Landing. check-governed-merges --pr 39030: NOT governed, 0 of 12 paths. Size +2499 / −64 = 2563 lines.

Clause-②: no · Metadata-protocol: none

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Landing · PR #39030 · head bb04e46ae6ce41029fe996701a4afa64700babad · 2026-12-02T10:23Z

Probe Reading
check-governed-merges --pr 39030 NOT governed: 0 of 12 paths; 2563 lines ≤ 3000
landing-k --pr 39030 K = 11 < 15; no locale leg, no shared book

Status: ready + auto-merge armed on L1 ACCEPT 7342379498 and delta PASS 7342344440. #38876 keeps pm:dispatched: the arming half is still open.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 10:23
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit f037f1c Dec 2, 2026
64 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38876-subflow-branch-pause-lost branch December 2, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants