Repository navigation
fix(plugin-approvals): an approval step opens no request on a run another branch already ended - #39064
Conversation
…ady failed (red) Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…t has already ended Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
… on its approval Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…past its end, so a restored strand still opens Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…ume surface's declared type Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…38985-failed-run-orphan-approval Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 028d0bcaa0356de0e4fd609f3c3ed1a08341cc29 && git checkout 028d0bcaa0356de0e4fd609f3c3ed1a08341cc29
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2 ad7b8cc460ef68b8e4589c2281119d6d9bd009af && git checkout -B drift-repro e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2 && git merge --no-ff ad7b8cc460ef68b8e4589c2281119d6d9bd009af
node scripts/docs-audit/affected-docs.mjs --json e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ Final green head · 2026-12-02T07:05Z · zone osa-data
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 review · PR #39064 (#38985) · head 36b9c4b · 2026-12-02T07:06ZREWORK. There is one must-fix, in the declaration, and a contract-tier review is owed before ACCEPT. Must-fix
Contract-tier review owed (my call, as asked). This PR changes whether an approval step opens a request, and so whether an approver is asked and how the record ends (recalled at the door and the reconciler, with merged #39013). The seat asked for a contract-tier read on #39013 for the same class of change. I will run it in-house at L1 read on this head (it stands for the fix head if only the declaration moves)
Next: fix the declaration lines and send the green head. I then post the contract review and an L1 delta. |
…AutomationSurface gains optional getRun (#38985) Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ Final green head · declaration fix · 2026-12-02T07:30Z · zone osa-data
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head 594e140 · 2026-12-02T07:31Z |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract reviewServed-tier: PR #39064 (card #38985, phase 2), net diff against Check-runs on this head: 61, no failure. One ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix. S1 (should-fix) — the changeset states an outcome the diff does not deliver on an object whose approval field has no Against the brief's four questions, on
The changeset, sentence by sentence: the widening sentence is exact. Paragraph two (the run ends while other branches go on; the request was held until the sweep, every 5 minutes by default, never without a job service) agrees with The test file: both fan-out cells assert what the refusal promises (no row for Nits, none of which moves the head:
Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 delta · PR #39064 (#38985) · head 594e140 · 2026-12-02T07:39ZREWORK. The declaration must-fix from my L1 on 36b9c4b is closed: the changeset and PR body now read S1 needs an answer, then a changeset fix The changeset says "The record's outcome is … abandoned, never approved." That is not true on an object whose approval field declares no
That matches the card's Done-when ("the state the failed run implies (the same state as without the fan-out)"): a linear run that fails after step 1 also stays
Either way, a contract delta naming Read and right on this head: (a) no wrong refusal of a live run in one process; (b) every request opened on a dead run is recalled by the sweep, and the door answers |
…bject kind recalled (red on objects the judge does not judge) Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
… back where the dead-run sweep would, on every object Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…od declared, a fault edge taken on refusal Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
… the refused-step audit row Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…fallback a failed put-back reports through Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head a52afeb · 2026-12-02T08:36Z |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract reviewServed-tier: DELTA review from
① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix. S2 (should-fix) — S3 (should-fix) — Nits, none of which moves the head:
Implemented-by: VERDICT: PASS |
…iled-run-orphan-approval Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 delta — REWORK on
|
…ed (red, #38985 S3) The first approval sits in a subflow body; the parent then fans out and a late branch refuses. The decided request carries the child's run id, so the put-back finds none and the record stays approved. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…ened (#38985 S3, S2, N5) The put-back reads the latest request whose flow_run_id or root_run_id is the refusing run, in one keyed read, so a first approval inside a subflow body is found. The node's logger type is back to its main shape (info?, warn?): a failed put-back logs at warn, else info, and always rides on the step's error. The recall row names the request's own step, as the sweep's. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…led one is on the step's error (#38985) Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head 6a1f86f · 2026-12-02T09:31Z |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract reviewServed-tier: DELTA review from
① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix. S4 (should-fix) — the boundary is wider than the docblock states, and inside it the record still ends Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 delta — REWORK on
|
…iled-run-orphan-approval Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…gs' approval (red, #38985 S4) A subflow body fans out and fails; its late approval step refuses. The decided request was opened by the parent, or by a sibling child, so neither lookup arm matches the child's id and the record stays approved. A third cell pins that the put-back answers open, not a write, while the tree's newest request is pending. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
…ree opened (#38985 S4) The approval step hands its run's root (rootRunOf) to abandonAtRefusedStep, whose input gains an optional rootRunId; the read's second arm compares root_run_id with that root, so a child run that refuses reaches its parent's and its siblings' requests. Still one keyed read; without a root the run is its own root, as before. The changeset names the new input field and the tree. Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head ad7b8cc · 2026-12-02T10:25Z |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm Contract reviewServed-tier: DELTA review from
① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm L1 delta — ACCEPT on
|
|
repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ 2026-12-02T10:29Z · Landing: contract-tier delta PASS 7342528286 (no must-fix, no should-fix) and L1 ACCEPT 7342545519, both on head ad7b8cc. Route A2 per seat rulings 7338495013 / 7338562363 (every object ends |
Fixes #38985
Clause-②: yes (widening)
Metadata-protocol: none
The widening, two additions to
@objectstack/plugin-approvals: the exportedApprovalAutomationSurfacegains an optional member,getRun?: ApprovalResumeSurface['getRun'](L1 7337799728); and the exportedApprovalServicegains a public method,abandonAtRefusedStep({ runId, nodeId, object, recordId, runStatus, rootRunId? }), meant for the approval step only (seat ruling 7338562363).维护者速读
What changes
@objectstack/plugin-approvalsonly, phase 2 of this card on the seat's phase-1 pick (the plugin side, 7323394875) and the maintainer's ruling 7329450068 (a failed fan-out is abandoned, never approved). It builds on the fan-out judge from #38988 (PR #39013, merged ata0ee7d26and merged into this branch at36b9c4b5). Landing order: this PR must not land before #39013; that holds now, since #39013 is on main. On a tree without that judge the same refusal leavesapprovedon the record (measured, below), and the two outcome cells of the new test file go red there, so the pins hold the order too.approval-node.ts: before it opens a request, the approval step reads its run's log entry (getRun, now onApprovalAutomationSurfacewith the typeApprovalResumeSurfacealready declares). It refuses only where both hold:RUN_STATUS_LIVENESS(the classification the dead-run sweep acts on);completedAt, strictly: the engine going on with another branch after a failure (or a refusingend) ended the run, the same "late step" the 37767 后续:审批读取的 fan-out 判断与引擎注释收尾(N14–N17、N23、stopOf) #38691 and Approvals fan-out stop reading: cells the time-based fix of #38691 does not reach (held suspension, refused run, routedFailure) #38988 readers use.The refusal is answered the way the node answers its other refusals:
{ success: false, error }, a failed step naming the run and how it ended, plus aninfolog line. No request row, no notice, no approver index row. The run keeps the status and error it ended with (pinned:run.errorstaysnote failed).Why the second fact: status alone was the first cut and it broke restored continuations. A repaired strand is resumed again while
getRunstill answers the strand's durable terminal row (a restore recordspausedin the ring, but the terminal row wins once the resume has consumed the pause). Measured with status alone:restored-approval-continuation.test.tsPIN 7 and PIN 8 andstranded-resubmit-second-door.test.tsMEASUREMENT A and C went red (Approval node 'a2': its run '…' had already ended failed). The durable row is a snapshot taken at the end and carries no step after it (probed: the row holdsstart, first, fork, note; the ring entry holds… note, mid, second), so with the second fact those replays open their step again. Every other answer opens the step as before: live status (a run being resumed onto the step readspaused), unknown status, no entry, no readable end, nogetRun, a read that throws.Tests
New file
approval-node-ended-run-38985.test.ts: real kernel, ObjectQL, automation engine, approval node, driver-sql on sqlite, the card's flowfork_fail_side(firstapproved,forktonotethat fails at 30 ms andmidthat calls a slow child and reachessecond), on an object that closes on its approval.Red first on main (test commit 8011f64 over base ff491c4)
AssertionError: no request row for \second`: expected [ 'first:approved', 'second:pending' ] to deeply equal [ 'first:approved' ]`Tests 2 failed | 3 passed (5)The outcome needs #38988's judge (measured before #39013 merged)
AssertionError: expected 'approved' to be 'recalled'on both cells (door: no judgement; reconciler:judged: { finished: 1 }).b7ecc146): door and reconciler writerecalled, the timeline readsended failed while its branch at node 'mid', from which a step can still follow, had not finished, between two steps.Green at 36b9c4b (merged with origin/main a0ee7d2)
pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2:Test Files 147 passed (147),Tests 2327 passed (2327), includingrestored-approval-continuation,stranded-resubmit-second-door,resume-failure-refusal,recall-strand-discriminator,approval-revise, and the 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 fan-out pinspnpm --filter @objectstack/plugin-approvals typecheck: exit 0 (check:test-typecheck: OK)secondrow,approver2told 0 times,run.statusfailedwith its own error, recordrecalled,releaseDeadRunRequests()answers{ scanned: 0, released: 0 }); control: a running fan-out openssecond(run readspaused,approver2told once, recordpending); control: a flow with no fan-out openssecond; a run whosegetRunthrows opens the step as before.Ablation at 36b9c4b (approval-node.ts restored from ff491c4 on disk, then back from HEAD)
Tests 2 failed | 3 passed (5),no request row for \second`: expected [ 'first:approved', 'second:pending' ] to deeply equal [ 'first:approved' ]`Tests 5 passed (5)Acceptance notes
fork_direct, note failing at 0 ms) readingfailedonce andpausedtwice at open.subflowon the surviving branch) of a parent that already failed. The step reads its own run, which is live. Reading the root run's status too would also refuse a restored child continuation whose parent's row reads failed, so it was left out. Its reach is not measured.closedStateson the approval field, the fan-out judge does not run (its approvals carry no stamp), and the record keptapprovedafterfirstat594e1406.unchanged hereCorrected in Patch round 1 (S1, seat ruling 7338562363): the refusal now puts the record back torecalledthere too.faultout-edge: the refusal is a failed step, so the engine takes that edge on the ended run. It already keeps visiting nodes there.Verification
Read first:
approval-node.tsrunEndedAs(the two facts and the fail-open answers); the refusal inexecute(where it sits, before the root-run reads andopenNodeRequest);approval-node-ended-run-38985.test.tsthe two fan-out cells.Two minutes:
pnpm --filter @objectstack/plugin-approvals exec vitest run src/approval-node-ended-run-38985.test.tsshows 5 passed; withapproval-node.tsfrom main, the two fan-out cells fail on asecond:pendingrow.Patch round 1: route A2 (seat ruling 7338562363, claim amendment 3 7338578050)
Answers S1 of contract review 7338436183 and the L1 delta 7338459623 (an object whose approval field declares no
closedStatesendedapprovedon a failed fan-out). Seat ruling 7338495013 picked route (a), and 7338562363 approved A2: the record endsrecalledon every object.What changes
approval-service.ts: new public methodApprovalService.abandonAtRefusedStep({ runId, nodeId, object, recordId, runStatus }). The approval step calls it once, when it refuses on an ended run. It reads the latest request for that run and record. If that request is approved or rejected, it runs the abandon path's steps, as the dead-run sweep does: an actor-lessrecallaudit row naming the run, its status and the refused step;mirrorStatusField(… 'recalled' …);clearEarlierMarks. It writes no request row, so the first approver'sapprovedrow stays as written.judged: the fan-out judge already recalls, so nothing is written twice); latest request pending or closed (open); no request (none). The dead-run sweep is unchanged.ApprovalServiceis exported, so the method is reachable from outside the package. It is declared underClause-②: yes (widening)besidegetRun, as meant for the approval step only.error, elsewarn) and appended to the step's error ("The approval could not be put back: …"). The node'sMinimalLoggernow requireswarn(errorstays optional), percheck:optional-error-sink.organization_idthe same wayabandonForDeadRundoes.recalledon every object kind (replaces the S1 sentence); N4 added (an authoredfaultout-edge is taken on refusal); the widening sentence names the new method. N3: the test reads the run after the wait.Tests
685a81f2(test only, over594e1406): 4 failed, 5 passed,expected 'approved' to be 'recalled'on the no-closedStates (memo) and closedStates-on-another-field (ticket) cells, door and no-door.a52afebe: 10 pass on the real engine (6 fan-out cells over 3 object kinds × door/no-door, a failed put-back pin, 3 controls: a running fan-out, a chain,getRunthrowing).Engine measurement at
a52afebeSeat conditions (7338562363): (1) the first approver's row is unchanged; (2) every object kind ends
recalled; (3) approver 2 is never asked (no request forsecond, 0 notices); (4) the table above is the measurement on the new head. Nothing is written twice: on invoice the only write is the judge's; on ticket without the door the reconciler's own judge clears only its own mark.Gates: local
dispatch-gates84 derived, 81 exit 0, 3 NOT MEASURED (check:dual-build-cjs-loads,check:i18nprerequisite not met;check:query-options-erasurehit the local cap, CI success);--ranexit 0. CI ona52afebe: every check-run succeeded (41 success, 18 skipped).Patch round 2: contract delta 7339783716 / L1 delta 7339823196 (S2, S3, N5)
origin/main merged first (
00562b95, no file overlap).What changes
MinimalLoggeris back to its shape on main (info?,warn?, noerror); Patch round 1's requiredwarnis undone. A failed put-back is logged atwarn, elseinfo, and always goes on the refused step's error string ("The approval could not be put back: …"), which the node's docblock names as the guaranteed channel. Emitted declarations (tsc --emitDeclarationOnly) at this head against main's sources:registerApprovalNode(automation, service, logger?: MinimalLogger)andMinimalLogger { info?; warn? }identical;approval-node.d.tsdiffers only by the declaredgetRun?:(and its import);approval-service.d.tsonly byabandonAtRefusedStep.abandonAtRefusedStepis still one keyed read:where { object_name, record_id, $or: [{ flow_run_id: run }, { root_run_id: run }] }, latest bycreated_at,limit: 1. No column, index or engine change. Measured and pinned: a top-level run's request holds the run id in bothflow_run_idandroot_run_id; a subflow's request holds the child id inflow_run_idand the parent id inroot_run_id. Boundary, in thenonedocblock: when the refusing run is itself a child (a fan-out inside asubflowbody or amapitem), it reaches only its own requests, not sibling runs' under the same root.recallrow'sstep_nameis the request's own node, as in the sweep's row; the refused node stays in the comment. N6 left as is.Tests
1f705eca(test only): new cell oncrm_memo(no closedStates), approval inside a subflow, then a parent fan-out with a failing branch: 1 failed, 10 passed,expected 'approved' to be 'recalled'(request opened by the child run, run failed, no row forsecond, approver 2 told 0).e318c220: 11 pass; the cell also pins therecallrow'sstep_name=first; every top-level cell pinsflow_run_id=root_run_id.flow_run_idonly): 1 failed, same assertion; restored, hash checked.6a1f86f9: 147 files, 2333 tests pass. Typecheck exit 0.Gates:
check:optional-error-sink,check:durability-log-level,check-tenant-audit-census,check-nul-bytesexit 0;dispatch-gates84 derived, 81 exit 0, 3 NOT MEASURED as before (CI ran query-options-erasure: success);--ranexit 0. CI on6a1f86f9: 41 success, 18 skipped, 0 failed.Patch round 3: contract delta 7341149576 / L1 delta 7341170960 (S4)
origin/main merged first (
a3047515, no PR file touched).What changes
rootRunId: automation.rootRunOf?.(context)?.runId ?? null(rootRunOfis a pure read of the step's context). The declared public method's input gains one optional field:abandonAtRefusedStep({ runId, nodeId, object, recordId, runStatus, rootRunId? }); the changeset's widening sentence names it.object_name,record_id,$or: [{ flow_run_id: run }, { root_run_id: rootRunId || run }], newest first,limit: 1. A refusing child run now reaches requests opened by its root, its parent and its sibling children. With no root handed over, the run counts as its own root, as before. If the tree's newest request is pending, the answer isopenand nothing is written (new cell, with an older decided request present).nonedocblock names only what remains outside: a request with noroot_run_idopened by another run; with no root passed, a request whose root is another run.subflowbody or amapitem, so also the parent or a sibling of a run that is itself a child). Census unchanged.Tests
813e8043(test only): 3 failed, 11 passed. Two newcrm_memocells (a subflow body fans out, a branch fails, a late approval step refuses; the decided request opened by the parent / by a sibling child) fail withexpected 'approved' to be 'recalled'after every earlier assertion passed; the live-request cell fails withexpected 'none' to be 'open'.ad7b8cc4: 14 pass; both child cells endrecalledwith one actor-lessrecallrow naming the child run, the decided row unchanged, approver 2 told 0.ad7b8cc4: 147 files, 2336 tests pass. Typecheck exit 0.Gates:
check:optional-error-sink,check:durability-log-level,check-tenant-audit-census,check-nul-bytesexit 0;dispatch-gates84 derived, 81 exit 0, 3 NOT MEASURED as before;--ranexit 0. CI onad7b8cc4: 41 success, 18 skipped, 0 failed.Generated by Claude Code