Skip to content

fix(plugin-approvals): an approval step opens no request on a run another branch already ended - #39064

Merged
objectstack-fleet[bot] merged 20 commits into
mainfrom
claude/issue-38985-failed-run-orphan-approval
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 20 commits into
mainfrom
claude/issue-38985-failed-run-orphan-approval

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #38985
Clause-②: yes (widening)
Metadata-protocol: none

The widening, two additions to @objectstack/plugin-approvals: the exported ApprovalAutomationSurface gains an optional member, getRun?: ApprovalResumeSurface['getRun'] (L1 7337799728); and the exported ApprovalService gains a public method, abandonAtRefusedStep({ runId, nodeId, object, recordId, runStatus, rootRunId? }), meant for the approval step only (seat ruling 7338562363).

维护者速读

  • 用户能看到什么变化:审批流程在审批后分成多条同时运行的分支、其中一条已经失败时,另一条分支走到下一个审批步骤不再发起新的审批请求,下一位审批人不再收到通知,记录也不会一直挂在"审批中",而是在所有对象上都判作废并退回(recalled),第一位审批人的通过记录保持原样。
  • 为什么做:这张孤儿审批卡的第二阶段(插件这一侧),落实你"分支审批中一条分支失败判作废、不判通过"的裁决;原先要等后台清理任务(默认 5 分钟,没有任务服务的环境永远不会)才收回这张多余的请求。
  • 出错会怎样:只影响分支并行、且一条分支已让运行结束后,另一条分支才走到的审批步骤;运行中的流程、正在恢复的流程、修复后重新续跑的流程都照旧发起请求,已用测试守住;本改动可直接撤回,撤回后回到"先发起、再由清理任务收回"的旧行为。
  • 要你做什么:无。

What changes

@objectstack/plugin-approvals only, 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 at a0ee7d26 and merged into this branch at 36b9c4b5). 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 leaves approved on 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 on ApprovalAutomationSurface with the type ApprovalResumeSurface already declares). It refuses only where both hold:

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 an info log line. No request row, no notice, no approver index row. The run keeps the status and error it ended with (pinned: run.error stays note failed).

Why the second fact: status alone was the first cut and it broke restored continuations. A repaired strand is resumed again while getRun still answers the strand's durable terminal row (a restore records paused in the ring, but the terminal row wins once the resume has consumed the pause). Measured with status alone: restored-approval-continuation.test.ts PIN 7 and PIN 8 and stranded-resubmit-second-door.test.ts MEASUREMENT 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 holds start, 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 reads paused), unknown status, no entry, no readable end, no getRun, 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 flow fork_fail_side (first approved, fork to note that fails at 30 ms and mid that calls a slow child and reaches second), on an object that closes on its approval.

Red first on main (test commit 8011f64 over base ff491c4)
  • both fan-out cells (the door judges / no door, the reconciler judges): AssertionError: no request row for \second`: expected [ 'first:approved', 'second:pending' ] to deeply equal [ 'first:approved' ]`
  • the three controls green: Tests 2 failed | 3 passed (5)
The outcome needs #38988's judge (measured before #39013 merged)
Green at 36b9c4b (merged with origin/main a0ee7d2)
Ablation at 36b9c4b (approval-node.ts restored from ff491c4 on disk, then back from HEAD)
  • ablated: Tests 2 failed | 3 passed (5), no request row for \second`: expected [ 'first:approved', 'second:pending' ] to deeply equal [ 'first:approved' ]`
  • restored: Tests 5 passed (5)
  • the second fact's own ablation is the status-only cut above: four restored-strand pins red.

Acceptance notes

  • Not closed: a branch whose approval step is the first node after the fan-out, where the failure lands before that step opens. Nothing is logged past the end yet, so the step opens as before and the dead-run sweep recalls it. Phase 1 measured this race (fork_direct, note failing at 0 ms) reading failed once and paused twice at open.
  • Not closed: an approval step inside a child run (a subflow on 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.
  • On an object with no closedStates on the approval field, the fan-out judge does not run (its approvals carry no stamp), and the record kept approved after first at 594e1406. unchanged here Corrected in Patch round 1 (S1, seat ruling 7338562363): the refusal now puts the record back to recalled there too.
  • An approval step with an authored fault out-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.ts runEndedAs (the two facts and the fail-open answers); the refusal in execute (where it sits, before the root-run reads and openNodeRequest); approval-node-ended-run-38985.test.ts the two fan-out cells.

Two minutes: pnpm --filter @objectstack/plugin-approvals exec vitest run src/approval-node-ended-run-38985.test.ts shows 5 passed; with approval-node.ts from main, the two fan-out cells fail on a second:pending row.

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 closedStates ended approved on a failed fan-out). Seat ruling 7338495013 picked route (a), and 7338562363 approved A2: the record ends recalled on every object.

What changes

  • approval-service.ts: new public method ApprovalService.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-less recall audit row naming the run, its status and the refused step; mirrorStatusField(… 'recalled' …); clearEarlierMarks. It writes no request row, so the first approver's approved row stays as written.
  • It does nothing in three cases: stamped with an object that closes on its approval field (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.
  • ApprovalService is exported, so the method is reachable from outside the package. It is declared under Clause-②: yes (widening) beside getRun, as meant for the approval step only.
  • A failed put-back is reported on the refused step's own log line (error, else warn) and appended to the step's error ("The approval could not be put back: …"). The node's MinimalLogger now requires warn (error stays optional), per check:optional-error-sink.
  • Tenant-audit census regenerated (plugin-approvals write call sites 51 → 52). The new insert sets organization_id the same way abandonForDeadRun does.
  • Changeset: recalled on every object kind (replaces the S1 sentence); N4 added (an authored fault out-edge is taken on refusal); the widening sentence names the new method. N3: the test reads the run after the wait.

Tests

  • Red first at 685a81f2 (test only, over 594e1406): 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.
  • Green at 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, getRun throwing).
  • Ablation (new call disabled on disk): the same 4 cells fail with the same assertion; restored, hash checked.
  • Full plugin-approvals suite under os-verify-lock: 147 files, 2332 tests pass. Typecheck exit 0.

Engine measurement at a52afebe

object door requests first row after refusal approver 2 told field after refusal reconcile sweep released end
crm_invoice (closes on approval) door first:approved unchanged 0 recalled n/a 0 recalled
crm_invoice no door first:approved unchanged 0 pending abandoned:1 0 recalled
crm_memo (no closedStates) door first:approved unchanged 0 recalled n/a 0 recalled
crm_memo no door first:approved unchanged 0 recalled nothing 0 recalled
crm_ticket (closedStates on another field) door first:approved unchanged 0 recalled n/a 0 recalled
crm_ticket no door first:approved unchanged 0 recalled ended:1 0 recalled

Seat conditions (7338562363): (1) the first approver's row is unchanged; (2) every object kind ends recalled; (3) approver 2 is never asked (no request for second, 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-gates 84 derived, 81 exit 0, 3 NOT MEASURED (check:dual-build-cjs-loads, check:i18n prerequisite not met; check:query-options-erasure hit the local cap, CI success); --ran exit 0. CI on a52afebe: 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

  • S2, no narrowing. MinimalLogger is back to its shape on main (info?, warn?, no error); Patch round 1's required warn is undone. A failed put-back is logged at warn, else info, 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) and MinimalLogger { info?; warn? } identical; approval-node.d.ts differs only by the declared getRun?: (and its import); approval-service.d.ts only by abandonAtRefusedStep.
  • S3, child runs reached. abandonAtRefusedStep is still one keyed read: where { object_name, record_id, $or: [{ flow_run_id: run }, { root_run_id: run }] }, latest by created_at, limit: 1. No column, index or engine change. Measured and pinned: a top-level run's request holds the run id in both flow_run_id and root_run_id; a subflow's request holds the child id in flow_run_id and the parent id in root_run_id. Boundary, in the none docblock: when the refusing run is itself a child (a fan-out inside a subflow body or a map item), it reaches only its own requests, not sibling runs' under the same root.
  • N5. The recall row's step_name is the request's own node, as in the sweep's row; the refused node stays in the comment. N6 left as is.
  • Changeset: the put-back reaches requests opened by the run or one of its child runs; a failed put-back is reported on the step's error, and the record keeps the value its last decision wrote. Declaration lines and the widening sentence unchanged. Census unchanged (52).

Tests

  • Red first at 1f705eca (test only): new cell on crm_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 for second, approver 2 told 0).
  • Green from e318c220: 11 pass; the cell also pins the recall row's step_name = first; every top-level cell pins flow_run_id = root_run_id.
  • Ablation (lookup back to flow_run_id only): 1 failed, same assertion; restored, hash checked.
  • Full plugin-approvals suite at 6a1f86f9: 147 files, 2333 tests pass. Typecheck exit 0.

Gates: check:optional-error-sink, check:durability-log-level, check-tenant-audit-census, check-nul-bytes exit 0; dispatch-gates 84 derived, 81 exit 0, 3 NOT MEASURED as before (CI ran query-options-erasure: success); --ran exit 0. CI on 6a1f86f9: 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

  • S4. On refusal, the approval step passes its run's root: rootRunId: automation.rootRunOf?.(context)?.runId ?? null (rootRunOf is 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.
  • The read stays one keyed read on the same index: 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 is open and nothing is written (new cell, with an older decided request present).
  • none docblock names only what remains outside: a request with no root_run_id opened by another run; with no root passed, a request whose root is another run.
  • Changeset: the put-back reaches any run of the approval's tree (the root run, a subflow body or a map item, so also the parent or a sibling of a run that is itself a child). Census unchanged.

Tests

  • Red first at 813e8043 (test only): 3 failed, 11 passed. Two new crm_memo cells (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 with expected 'approved' to be 'recalled' after every earlier assertion passed; the live-request cell fails with expected 'none' to be 'open'.
  • Green at ad7b8cc4: 14 pass; both child cells end recalled with one actor-less recall row naming the child run, the decided row unchanged, approver 2 told 0.
  • Ablation (second arm back to the run's own id): the same 3 fail; restored, hash checked.
  • Full plugin-approvals suite at ad7b8cc4: 147 files, 2336 tests pass. Typecheck exit 0.

Gates: check:optional-error-sink, check:durability-log-level, check-tenant-audit-census, check-nul-bytes exit 0; dispatch-gates 84 derived, 81 exit 0, 3 NOT MEASURED as before; --ran exit 0. CI on ad7b8cc4: 41 success, 18 skipped, 0 failed.


Generated by Claude Code

…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>
…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>
@github-actions github-actions Bot added size/m 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/plugin-approvals, touching 14 documentable anchor(s).

10 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 /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/ai/connect-mcp.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/automation/approvals.mdx (via ApprovalService (symbol, a top-level class), first_response (literal, a string literal in abandonAtRefusedStep), sys_approval_action (literal, a string literal in abandonAtRefusedStep), sys_approval_request (literal, a string literal in abandonAtRefusedStep), /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/automation/flows.mdx (via ApprovalService (symbol, a top-level class), getRun (symbol, a field of interface ApprovalAutomationSurface), first_response (literal, a string literal in abandonAtRefusedStep), getRun (literal, a string literal in getRun; a string literal in runEndedAs), sys_approval_action (literal, a string literal in abandonAtRefusedStep), sys_approval_request (literal, a string literal in abandonAtRefusedStep), /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/automation/workflows.mdx (via sys_approval_action (literal, a string literal in abandonAtRefusedStep), sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/data-modeling/field-types.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/frontend/plugins/plugin-detail.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/plugins/packages.mdx (via first_response (literal, a string literal in abandonAtRefusedStep), sys_approval_action (literal, a string literal in abandonAtRefusedStep), sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/ui/pages.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/ui/translations.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))

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

  • content/docs/releases/v16.mdx (via sys_approval_action (literal, a string literal in abandonAtRefusedStep), sys_approval_request (literal, a string literal in abandonAtRefusedStep))
  • content/docs/releases/v17/17-0.mdx (via getRun (symbol, a field of interface ApprovalAutomationSurface), getRun (literal, a string literal in getRun; a string literal in runEndedAs))
  • content/docs/releases/v17/17-1.mdx (via /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/releases/v17/17-6.mdx (via ApprovalService (symbol, a top-level class), sys_approval_request (literal, a string literal in abandonAtRefusedStep), /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/releases/v17/17-7.mdx (via sys_approval_action (literal, a string literal in abandonAtRefusedStep), /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it), /automation/:name/runs/:runId (route, the route ledger binds it to client method automation.getRun))
  • content/docs/releases/v18/18-1.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/releases/v18/18-2.mdx (via /api/v1/automation/:name/runs (route, bridged from symbol getRun — its route source's handler names it))
  • content/docs/releases/v18/18-4.mdx (via sys_approval_request (literal, a string literal in abandonAtRefusedStep))

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
  • 1 anchor(s) matched too much of the corpus to be a work list: created_at (literal, 49 pages)
  • 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 — 6 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 e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 028d0bcaa0356de0e4fd609f3c3ed1a08341cc29 — the merge of head ad7b8cc460ef68b8e4589c2281119d6d9bd009af into base e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2, 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 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

⚠️ 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 e9a5d4f42c5818d7645e729b1d7a4511cc51ebd2 → 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-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

Final green head · 2026-12-02T07:05Z · zone osa-data
Head-sha: 36b9c4b

  • CI at this head: 39 success, 18 skipped, 0 failure. Diff: 3 files, +339 / −1 (340 lines ≤ 3000). Not governed. Fixes #38985 (phase 2; phase 1 was read-only). Surface as amended (7336165504): approval-node.ts, a new card-named test, one changeset. origin/main merged at 36b9c4b5, carrying fix(plugin-approvals): a fan-out where one branch fails is abandoned, never approved, on the door and the reconciler #39013 (the fan-out judge this builds on).
  • What: an approval step refuses to open a request when its run's status is terminal (by RUN_STATUS_LIVENESS) AND the run logged a step completed after its own completedAt; it reads the run through an optional getRun on ApprovalAutomationSurface (the type ApprovalResumeSurface already declares). No request row, no notice, nothing pending; the refusal names the run and how it ended. The second condition keeps restored-strand replays opening (the status-only first version turned 4 restored-continuation / stranded-resubmit pins red).
  • Readings (dev report 7337305048): red first at 8011f649 (second opened on a failed run); with the merged judge the record ends recalled at the door and through the reconciler, releaseDeadRunRequests finds nothing; controls (running fan-out, no fan-out, a throwing getRun) open as before; ablation turns the 2 fan-out cells red; plugin-approvals 147 files / 2327 tests; 71 derived gates, 69 run, 2 NOT MEASURED (CI ran them).
  • Noted in Acceptance notes, not filed: the first node after the fan-out can still open in the race phase 1 measured (the sweep recalls it); an approval step in a child run whose parent failed still opens; objects without closedStates keep approved as before.
  • Sent to osa-L1-a for L1.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 review · PR #39064 (#38985) · head 36b9c4b · 2026-12-02T07:06Z

REWORK. There is one must-fix, in the declaration, and a contract-tier review is owed before ACCEPT.

Must-fix

  1. Clause-② reads no, but the diff widens an exported interface of a published package. @objectstack/plugin-approvals is published, and its index exports ApprovalAutomationSurface (index.ts: type ApprovalAutomationSurface). The interface gains the optional member getRun?: ApprovalResumeSurface['getRun']. A new optional member on an exported interface of a published package is a public-surface widening. This follows the precedent applied to fix(metadata-protocol): a list_drafts verdict no longer re-collects its package closure per draft #39048 and fix(console): the record edit dialog opens locked with the closed sentence on a closed record (ADR-0162) #39019: being "the plugin's own" interface does not keep it off the surface a host compiles against. Change the declaration to Clause-②: yes (widening) in the changeset and the PR body, naming the member. patch and Metadata-protocol: none stay. The declaration then owes a TIER_DEFAULT declaration review, which the contract review below covers.

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 CONTRACT_REVIEW_TIER on the fix head, in one pass with the declaration.

L1 read on this head (it stands for the fix head if only the declaration moves)

  • runEndedAs returns a terminal status only when both of these hold: the status is terminal under RUN_STATUS_LIVENESS (the dead-run sweep's classification), and some step's completedAt is strictly after the run's completedAt. Every unreadable answer opens the step as before, and so does a missing getRun, a throw, or a non-terminal or unknown status. This fails open, toward a request the dead-run sweep later recalls, never toward a silent approval.
  • The refusal is a failed step with a sentence naming the run and how it ended, logged at info. The run's own status and error are untouched.
  • The wiring passes the engine (approvals-plugin.ts:757), whose getRun the type is drawn from.
  • The three noted-not-filed edges in the acceptance notes (first-node race, child run of a failed parent, objects with no closedStates) are each named in the changeset or the docblock as opening the step as before.
  • Face: l1-face CLEAN. 39 checks succeeded, 18 skips were expected, 0 failed, 0 pending, and mergeable_state is clean. Not governed. +339/−1. Fixes #38985 (phase 2).

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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

Final green head · declaration fix · 2026-12-02T07:30Z · zone osa-data
Head-sha: 594e140

  • CI at this head: 40 success, 20 skipped, 0 failure (one PR-body guards run cancelled by the body edit, superseded by its passing re-run on this head). Diff: 3 files, +341 / −1. Not governed. Fixes #38985.
  • Closes L1 7337799728 must-fix 1: the changeset and the PR body now read Clause-②: yes (widening) (verified with readClause2Line: declared, yes, widening), naming the member: the exported ApprovalAutomationSurface gains optional getRun?: ApprovalResumeSurface['getRun']. patch and Metadata-protocol: none unchanged. Only the changeset moved (36b9c4b5..594e1406); source and tests identical to the L1-read head.
  • Sent to osa-L1-a for the contract-tier review (with the declaration) and the L1 delta.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head 594e140 · 2026-12-02T07:31Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 594e1406b9d737796c27310351a62a03171c2e51
Local-runs: none
Scope: packages/plugins/plugin-approvals/src/approval-node.ts + packages/plugins/plugin-approvals/src/approval-node-ended-run-38985.test.ts, .changeset/38985-ended-run-approval-step.md

PR #39064 (card #38985, phase 2), net diff against main at merge base a0ee7d26: 3 files, +341 / −1. The PR touches no path on the governed register; the L1 asked for this tier because the diff changes an approval outcome path (L1 7337799728). This record is also the declaration review for Clause-②: yes (widening). Read: the card body and all six comments (ruling 7329450068 included), ruling 7329430078 on #38988, the PR body and its comments, the diff, and the cited code in the tree of this head (approval-service.ts, approvals-plugin.ts, index.ts, and in service-automation: run-history.ts, engine.ts, dag-traversal.ts, run-resume.ts, consumed-suspension-restore.ts, engine-run-facet.ts). Nothing was built or run.

Check-runs on this head: 61, no failure. One PR-body guards run is cancelled and superseded by a successful run of the same check on the same head; the rest are success or an expected skip (Test Core and its 12 shards, TypeScript Type Check, Lint & Repo Gates, Check Changeset, Governed Surface Queue Guard all success).

① Derived judgments

  • Public surface: one widening, declared right. ApprovalAutomationSurface is exported from the package index (index.ts:43) and gains the optional member getRun?: ApprovalResumeSurface['getRun']. ApprovalResumeSurface is exported too (index.ts:22), so the member's type is nameable by a host. A host that passes an object without getRun compiles and behaves as before (runEndedAs answers null on typeof automation.getRun !== 'function'). The one host shape it can refuse at compile time is an object that already carries a getRun of another signature; the only in-repo caller passes the engine, whose getRun(runId, options?: { strict?: boolean }) matches.
  • No accept-set change. No schema, no spec, no metadata key, no node config key. The approval node's descriptor and configSchema are untouched. Metadata-protocol: none is right.
  • Behaviour published by the diff: an approval step can now answer { success: false, error } where it used to open a request. The message is prose, not a coded error, and no caller in the tree matches on it. One info log line is new.
  • The wired object is the engine. approvals-plugin.ts reads ctx.getService('automation') and passes it to registerApprovalNode; service-automation/src/plugin.ts:2311 registers this.engine under that name. The same object goes to attachAutomation(automation: ApprovalResumeSurface), so it already satisfied this getRun type before the diff.
  • The call against the engine's getRun. automation.getRun(runId) is a method call on the engine (the receiver is kept), with no strict. That is the right read for this use: a store failure degrades to the ring entry or null, both of which open the step, and a strict read's throw would be caught and open it as well. The engine answers ExecutionLogEntry | null; the surface type omits null and the step field completedAt, and the code guards both (run?., the local cast with its comment).

② Semver level

patch on @objectstack/plugin-approvals, with Clause-②: yes (widening) on the changeset and on the PR body, both naming the member. That matches what the diff publishes: one optional member on an exported interface and a bug fix behind it, no removal, no narrowed type, no new required member. It follows the repo's own precedent for an optional member on an exported interface of a published package (#39048, #39019, cited by the L1). Check Changeset is success on this head. The declaration stands.

③ Boundary flags

  • open_questions in the dev report (7337305048): empty. Nothing to answer.
  • Dev flag, first node after the fan-out (the failure lands before any step is logged past the end): accepted. The step opens, as before the diff, and releaseDeadRunRequests recalls it: it lists status: 'pending' requests, reads getRun, and on a terminal status calls abandonForDeadRun, which writes the request recalled, clears its approver index, mirrors the field and clears earlier marks. A decision on such a request is refused by assertRunResumable with RESUME_TARGET_LOST and nothing recorded. Neither path writes approved. The changeset states this case.
  • Dev flag, an approval step inside a child run of a parent that already failed: accepted as fail-open. The step reads $runId, the child's own run, which is live or has no entry, so it opens as before the diff. No wrong refusal, no new outcome. Its reach is not measured and it has no carrier: escalated to the seat for a follow-up card.
  • Dev flag, an object with no closedStates on the approval field: not accepted as written; see S1. The PR body calls it unchanged, and the tree says otherwise for the card's own flow.
  • Dev flag, an authored fault out-edge on the approval step: accepted. The refusal is a failed step, so the engine takes that edge on the ended run; it was already visiting nodes there.
  • SQL push-down: clean. The diff adds one getRun per approval step: a ring scan, then at most two keyed store reads. No id materialisation, no in-app join.
  • Landing order: fix(plugin-approvals): a fan-out where one branch fails is abandoned, never approved, on the door and the reconciler #39013 is on main at a0ee7d26 and is merged into this branch at 36b9c4b5, so the constraint in ruling 7329450068 (not before the fan-out judge) holds.

④ Design judgment

No must-fix.

S1 (should-fix) — the changeset states an outcome the diff does not deliver on an object whose approval field has no closedStates, and on such an object the diff changes how the record ends. The sentence: "The record's outcome is the one the approval plugin gives a fan-out where one branch fails: abandoned, never approved." On an object that closes on its approval this holds, and both test cells pin recalled. On an object that does not, the fan-out judge does not run (stampOf is undefined, holdsBackDecision is false), so the decision on first mirrors approved at once (approval-service.ts:8974). On main the surviving branch then opened second, which mirrored pending, and the dead-run sweep mirrored recalled (abandonForDeadRun). With this diff second opens nothing, so nothing writes the field again: it stays approved on a failed run with the approver of second never asked. That is the state the card's Done-when names ("the same state as without the fan-out"), and it is also the state ruling 7329430078 says a failed fan-out never ends in. This was derived by reading, not measured, and no cell pins it. Owed: the changeset sentence is scoped to objects that close on their approval and says what the field reads on the others; and the seat or the maintainer says whether approved is the intended end there, or whether the refusal must leave the field as the sweep left it.

Against the brief's four questions, on approval-node.ts:

  • (a) A wrong refusal on a run that is not dead. runEndedAs refuses only on a terminal status together with a step completed strictly after the run's completedAt. Read against each case:
    • A run still running on its first execution has no log entry (getRun answers null): opens.
    • A run being resumed onto this step reads this process's paused ring entry with no terminal row in the store: opens. The chain control pins it.
    • A restored strand resumed again: the restore logs paused (consumed-suspension-restore.ts:469), the resume consumes the pause, so terminalRowUnlessParked answers the durable failed row. That row's steps are copied when the run ends (compactStepsForHistory runs inside recordLog, before the write), so it holds no step after its own end: opens. The same holds after a restart, where the durable row answers alone, and at a later approval step of the same restored run, since the old row is not rewritten until the run ends again. Test Core is success with the restored-continuation and stranded-resubmit pins in it.
    • Equal timestamps: the comparison is strict, so a step in the run's own millisecond opens the step.
    • A retried flow: each attempt takes a new run id (dag-traversal.ts:1427), so an earlier attempt's failed entry is never read for a later one.
    • A child run of a failed parent: reads its own run and opens (③).
    • A run whose end is written before its last step (a failure, a timeout or a cancel that lands while a branch is in flight): this is the case the diff targets, and the run cannot resume, so the refusal is right.
  • (b) Opening where it should refuse. Every unreadable answer opens the step, and each such request is on a terminal run: the dead-run sweep recalls it and the door refuses a decision on it (③, first flag). No path from a missed refusal writes approved. On a host with no job service the request stays pending as it did before the diff, which the changeset says.
  • (c) and (d) are answered in ① and below.

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 executeNode's Promise.all over unconditional edges and with the sweep's schedule in approvals-plugin.ts. Paragraph three is exact on the refusal, the failed step and the run keeping its status and error; its last sentence is S1. Paragraph four is exact on the live run, the resumed run, the unreadable run and the first-node case; its restored-strand sentence is true wherever the durable row answers (N1).

The test file: both fan-out cells assert what the refusal promises (no row for second, no notice, the run's own error, recalled, an empty sweep), through the door and through the reconciler; three controls hold the opening paths.

Nits, none of which moves the head:

  • N1 (nit, follow-up card). One read can refuse a live restored run, and it needs three things at once: more than one replica; a strand whose failed resume was itself a fan-out with a late step; and a restore taken on another replica than the one that ran that resume. On the replica that ran it, the ring's last entry for the run is the terminal one, getRun answers it without asking the store, and that entry's step array kept growing with the late branch. The root is the engine's rule that a terminal ring entry is never outranked, which is outside this diff and already misreads such a run for every other reader. Derived by reading, not measured.
  • N2 (nit). runEndedAs's docblock leans on the plugin's other late-step readers but not on their clock caveat (loggedAfterEnd), and the direction differs: there a clock that steps back errs toward undetermined, here toward refusing a live restored run. The reach is a skew larger than the time the run was parked.
  • N3 (nit). In the two fan-out cells run is read before the 50 ms wait, so "the refusal does not replace how the run ended" would not see an entry logged after it. The behaviour holds by construction: the surviving branch rejects into a Promise.all that has already rejected, and no second recordLog runs.
  • N4 (nit, prose face). The changeset does not say that a fault out-edge authored on the approval step is taken when the step refuses.

Implemented-by: claude/issue-38985-failed-run-orphan-approval
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta · PR #39064 (#38985) · head 594e140 · 2026-12-02T07:39Z

REWORK. The declaration must-fix from my L1 on 36b9c4b is closed: the changeset and PR body now read Clause-②: yes (widening) and name getRun, and nothing else moved. The contract review on this head (CONTRACT_REVIEW_TIER, which also covers the declaration) is a PASS but leaves S1 (should-fix) open (comment 7338436183), so the queue guard refuses this head.

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 closedStates, and this diff changes how the record ends there:

  • On main: step 1 approved → the late branch's step 2 opened (field pending) → the dead-run sweep recalled it (recalled).
  • With this diff: step 2 opens nothing, so the field stays approved on a failed run whose second approver was never asked.

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 approved. But it is the end ruling 7329430078 on #38988 says a failed fan-out never reaches. The two read differently here, so the seat or the maintainer should say which one governs this case.

  • If approved is intended (the card's reading): scope the changeset sentence to objects that declare closedStates, say what an object without them shows, correct the PR body's "unchanged", and pin the cell.
  • If not: the step must leave the record abandoned or recalled there too, and that is a code change.

Either way, a contract delta naming S1: closed and my L1 delta follow on the new head.

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 RESUME_TARGET_LOST, so no path writes approved through the door; (c) the non-strict getRun against the wired engine. N1 to N4 are nits. N1 (a multi-replica restored strand) and the record's escalation of the child-run-of-a-failed-parent case are follow-up cards for the seat. CI: 61 runs, 0 failed.

…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>
@github-actions github-actions Bot added size/l and removed size/m labels Dec 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head a52afeb · 2026-12-02T08:36Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a52afebed59e142f9095621a8919867d8a3031a9
Local-runs: none
Scope: packages/plugins/plugin-approvals/src/approval-node.ts, packages/plugins/plugin-approvals/src/approval-service.ts + packages/plugins/plugin-approvals/src/approval-node-ended-run-38985.test.ts, .changeset/38985-ended-run-approval-step.md, docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-approvals.md

DELTA review from 594e1406b9d737796c27310351a62a03171c2e51 (record 7338436183) to this head: 5 commits, 5 files, +184 / −43. Read: seat rulings 7338495013 and 7338562363, claim amendment 3 (7338578050), the diff between the two heads, and the cited code in this head's tree. Nothing was built or run. Check-runs on this head: 63, of which 43 success and 20 skipped, none failed or pending.

  • S1: closed. The seat ruled route (a), built as A2. Its five conditions, read in the tree:
    • The first approver's row is unchanged: abandonAtRefusedStep updates no sys_approval_request row, and each fan-out cell compares the decided row (id, status, completed_at, pending_approvers, node, config) before and after the refusal.
    • Every object kind ends recalled: three kinds (closes on the approval field, no closed state, closed states on another field), each through the door and without it, six cells.
    • Approver 2 is never asked: each cell pins zero notices and no row for second.
    • The measurement is repeated on this head: those cells are in the test file at this head and Test Core is success on it.
    • Clause-②: yes (widening) is declared for the new public method, on the changeset and the PR body.
  • N3: closed. The cells read the run after the wait.
  • N4: closed. The changeset states the fault out-edge.
  • N1 and N2 stand as written; the seat routed N1 and the child-run flag to follow-up cards (7338495013).

① Derived judgments

  • Public surface, widened: ApprovalService is exported and gains the public method abandonAtRefusedStep. It is not on IApprovalService, no route or other caller reaches it, and the only caller is the approval node. Declared.
  • Public surface, narrowed, not declared: see S2.
  • No accept-set change. No schema, no metadata key. Metadata-protocol: none stands.
  • The census moves 51 to 52 write call sites for the one new sys_approval_action insert, against a tenancy-enabled object with an elevated context and organization_id taken from the request, as abandonForDeadRun does.

② Semver level

patch stands for what is declared. The declaration is incomplete by one item (S2).

③ Boundary flags

  • The seat's question, is the skip logic race-free against the judge: yes, in its outcome. The judged skip reads two facts that do not change during the run (the request's stamp and the object's closedStates), so it cannot flip between the judge and the step. Where the approval is stamped but its object does not close on the approval field, both the judge and the step act; the cells for that kind pin one recall row, recalled on the field and nothing left for the reconciler, in both orders (door first, step first). Where the skip is taken and the judge cannot tell, the decision stays held and the field reads pending, never approved.
  • The seat's question, is the audit row consistent with the existing recall rows: the columns, the null actor (ADR-0118 D1), step_index, the action and the actionRow wrapper match abandonForDeadRun. One difference is N5.
  • SQL push-down: clean. One keyed read with orderBy and limit: 1; no id materialisation, no in-app join.
  • No new open_questions.

④ Design judgment

No must-fix.

S2 (should-fix) — MinimalLogger.warn became required, which narrows a published signature and is not declared. MinimalLogger is not exported by name, but it is the type of the optional third parameter of the exported registerApprovalNode and is emitted into the package's declarations. A host that passed a logger without warn (an info-only sink, say) type-checked at 594e1406 and no longer does. Nothing changes at run time, and the in-repo caller passes the kernel logger. The changeset reads "The widening, two additions" and is silent on this. Owed, one of: the narrowing is declared as AGENTS.md's Post-Task item 3 asks; or it is avoided, by reporting the failed put-back through a sink that needs no new member on this type; or the seat rules that a required warn beside an optional error (the check:optional-error-sink convention) is not a narrowing under Clause-②, and the changeset says so.

S3 (should-fix) — abandonAtRefusedStep finds the approval by flow_run_id equal to the refusing run, so it answers none and writes nothing where the approval's decided request was opened by a child run. The shape: a parent flow whose first approval sits inside a subflow, then a top-level fan-out in the parent where one branch fails and a late branch reaches an approval step. The step reads the parent run, refuses, and asks for requests on the parent's run id; the decided request carries the child's. On an object that does not close on its approval field the record then stays approved, the end ruling 7338495013 excludes, and on main the sweep ended it recalled. The docblock's reading of none ("the refused step would have been the approval's first") is not true there. Derived by reading, not measured; no cell covers it. Owed: the lookup reaches the approval's requests across its child runs (the row carries record_run_id and root_run_id), with a cell; or the seat routes it to a follow-up card and the changeset's "on every object" is scoped.

Nits, none of which moves the head:

  • N5 (nit). The new audit row sets step_name to the refused node while actionRow fills step_label from the decided request, so one row names two steps. The sweep's row names the request's own node in both. The refused node is already in the comment.
  • N6 (nit). As in the sweep, the mirror on a field the object does not close on is best-effort: a refused write is logged at warn and the method still answers abandoned, so the node's loud report covers a thrown read or insert only.

Implemented-by: claude/issue-38985-failed-run-orphan-approval
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

…iled-run-orphan-approval

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta — REWORK on a52afebed59e142f9095621a8919867d8a3031a9 (two should-fix owe an answer)

This review covers the patch round on route A2 (seat ruling 7338562363). The contract-tier delta record 7339783716 is on this head and reads PASS.

Closed:

  • S1 is closed: all five seat conditions hold in the tree.
    • The first approver's row is unchanged.
    • Every object kind ends recalled (3 kinds × door/no-door).
    • Approver 2 is told nothing.
    • The measurement is repeated on this head.
    • The new public ApprovalService.abandonAtRefusedStep is declared under Clause-②: yes (widening).
  • N3 and N4 are closed as well.
  • CI: 43 success, 20 skipped.

Owed before ACCEPT. Each needs a fix or a seat ruling.

  • S2. MinimalLogger.warn became required, and that narrowing is undeclared. I checked it in the tree. MinimalLogger is not exported by name, but it is the type of registerApprovalNode's third parameter (approval-node.ts:154-157). registerApprovalNode is exported from the package index (index.ts:42). So a host that passes a logger without warn stops type-checking on upgrade. Nothing changes at run time. Pick one:

    • declare it (Clause-②: yes (narrowing) names the parameter);
    • keep warn optional at that signature and default it inside;
    • get a seat ruling that the check:optional-error-sink convention is not a Clause-② narrowing.
  • S3. Approvals opened by a child run fall through. abandonAtRefusedStep finds the request with where: { flow_run_id: input.runId, … } (approval-service.ts). A request that a subflow child run opened therefore answers none. The case: a first approval inside a subflow, then a parent fan-out that fails at a later approval step. On an object that does not close on its approval field, the record then stays approved, where main ended it recalled through the sweep. The L2 derived this by reading, and no cell covers it. Pick one:

    • widen the lookup across the child runs (root_run_id / record_run_id) and add a cell for it;
    • get a seat-routed follow-up card, and scope the changeset's "on every object" to approvals opened by the refusing run.

Nits, not owed:

  • N5. The new audit row's step_name is the refused node, while its step_label comes from the decided request, so one row names two steps. The sweep's row names the request's own node in both.
  • N6. The field mirror on a non-closing field is best-effort: a refused write logs warn and still answers abandoned, as the sweep does.

The judge-versus-step skip is race-free in outcome (both orders are pinned). The audit row matches abandonForDeadRun apart from N5.

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head 6a1f86f · 2026-12-02T09:31Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 6a1f86f9f4c810a5a5f734ccafe1f6a8d0b6e985
Local-runs: none
Scope: packages/plugins/plugin-approvals/src/approval-node.ts, packages/plugins/plugin-approvals/src/approval-service.ts + packages/plugins/plugin-approvals/src/approval-node-ended-run-38985.test.ts, .changeset/38985-ended-run-approval-step.md, docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-approvals.md

DELTA review from a52afebed59e142f9095621a8919867d8a3031a9 (the second record of this review, on that head) to this head. Since then: a merge of origin/main at 00562b95, then three commits. The merge moves none of the PR's five files (git diff a52afebe 00562b95 over them is empty), so the PR's own change is git diff 00562b95 to this head plus the reading already made at a52afebe. Nothing was built or run. Check-runs on this head: 63, of which 43 success and 20 skipped, none failed or pending.

  • S2: closed. MinimalLogger is back to the shape it has on main (info?, warn?); the diff against main no longer touches the interface. The published surface this PR moves is the optional getRun and the public abandonAtRefusedStep, both declared.
  • S3: closed. The lookup is now flow_run_id equal to the run or root_run_id equal to the run, on the same object and record. A new cell on an object with no closed state, with first opened by a child run, ends recalled with the decided row unchanged and approver 2 not asked; the column contents it relies on are pinned in that cell and in the six fan-out cells.
  • N5: closed. step_name is the request's own node, and the cell pins it.
  • N6 is left as it was, by the zone's choice; N1 and N2 stand as follow-ups.

① Derived judgments

  • Published surface against main: one optional member on ApprovalAutomationSurface, one public method on ApprovalService. No narrowing remains.
  • No accept-set change. Metadata-protocol: none stands.

② Semver level

patch with Clause-②: yes (widening) matches what the diff publishes. The declaration stands.

③ Boundary flags

  • Which request limit: 1 picks. The newest request on the record among those the run or a run of its tree opened. A record holds at most one pending request (openNodeRequestBody refuses a second with DUPLICATE_REQUEST), and no request can be created while one is pending, so where a pending request exists it is the newest and the method answers open and writes nothing. It therefore cannot write recalled over a live request by picking an older decided one, in either direction (parent pending and child decided, or the reverse). A top-level run's own request matches both arms and is still one row. The order rests on created_at from one clock, as the plugin's other readers do; two requests of one approval are a human decision apart.
  • SQL push-down (Prime Directive 5): clean. One read, no id materialisation, no in-app join. object_name and record_id stand outside the $or, so the declared index on (object_name, record_id) bounds the read to one record's requests, and (root_run_id, object_name, record_id) serves the second arm whole. No full scan, no new index needed.
  • The logger change, run-time truth. A failed put-back is always on the refused step's error, which the run's log entry keeps (pinned). The log line goes to warn, else info, and its text says what is true: the record was not put back, it keeps its last decision's value, no sweep revisits it, and what to do. A sink with neither member logs nothing and the step's error still carries it. Nothing here claims a write that did not happen.
  • The stated boundary: see S4.

④ Design judgment

No must-fix.

S4 (should-fix) — the boundary is wider than the docblock states, and inside it the record still ends approved. The docblock says a refusing run that is itself a child does not reach the requests of runs beside it. It does not reach its ancestors' either: both arms compare against the refusing run's own id, and a child is not the root. The shape: a parent flow with an approval step, then a subflow whose body fans out, one branch fails and a late branch reaches an approval step. The child run ends failed with a late step, the step refuses, and the lookup asks for requests the child opened or is the root of. The decided request was opened by the parent and carries the parent's id in both columns, so the answer is none. On an object that does not close on its approval field the record keeps approved; on main the child's request opened and the dead-run sweep ended the record recalled. That is the end ruling 7338495013 excludes, in the same class as S3. The same holds where the decided request was opened by a sibling child. Derived by reading, not measured; no cell covers it. Owed: the node already reads the run's root (automation.rootRunOf(context), a few lines below the refusal) and can hand it over, so the second arm compares root_run_id with the root of the refusing run and stays one keyed read on the same index, with a cell; or the seat routes it to a follow-up card and the changeset's "on every object" and the docblock say which shapes are outside it.

Implemented-by: claude/issue-38985-failed-run-orphan-approval
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta — REWORK on 6a1f86f9f4c810a5a5f734ccafe1f6a8d0b6e985 (one should-fix owes an answer)

The contract-tier delta record 7341149576 is on this head. S2, S3 and N5 are closed.

  • MinimalLogger is back to main's shape. The published difference is now only the declared getRun? and abandonAtRefusedStep.
  • The $or lookup is in, and the crm_memo subflow cell is pinned (red at 1f705ec, green from e318c22).
  • step_name is the request's own node.
  • The merge of main at 00562b95 does not touch the PR's five files.
  • CI: 43 success, 20 skipped.

The L2 checked three more points:

  • limit 1, newest by created_at. It cannot recall over a live request, because a record holds at most one pending request (DUPLICATE_REQUEST).
  • The $or. It is bounded by the (object_name, record_id) index, and the second arm is served by (root_run_id, object_name, record_id).
  • The logger. It stays truthful: a failed put-back always lands on the step's error string.

Owed: S4 (should-fix). Fix it, or get a seat ruling. The boundary is wider than the docblock states. Both $or arms compare against the refusing run's own id. So a refusing child run misses its siblings' requests, and also its parent's and ancestors' requests.

The case: a parent-level approval is decided, then a subflow whose body fans out and fails at a late approval step inside the child. The decided request carries the parent's id in both columns, so the lookup answers none. On an object that does not close on its approval field, the record keeps approved, where main recalls it through the sweep. This is the same class as S3. The L2 derived it by reading; no cell covers it.

Pick one:

  • (a) Pass the node's rootRunOf(context) to abandonAtRefusedStep, so the second arm compares root_run_id with the refusing run's root. This is still one keyed read on the same index. Add a cell for a parent approval followed by a refusing child.
  • (b) The seat routes it to a follow-up card, and the changeset's "on every object" and the docblock are scoped to approvals opened by the refusing run or its children.

Nits left as the zone chose: N6, plus N1 and N2 as follow-ups.

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract-review-claim: session_01WGufzhGA3zoCFquQgku4pm · head ad7b8cc · 2026-12-02T10:25Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ad7b8cc460ef68b8e4589c2281119d6d9bd009af
Local-runs: none
Scope: packages/plugins/plugin-approvals/src/approval-node.ts, packages/plugins/plugin-approvals/src/approval-service.ts + packages/plugins/plugin-approvals/src/approval-node-ended-run-38985.test.ts, .changeset/38985-ended-run-approval-step.md, docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-approvals.md

DELTA review from 6a1f86f9f4c810a5a5f734ccafe1f6a8d0b6e985 (the third record of this review, on that head) to this head: a merge of origin/main at a3047515, a test commit 813e8043 and the fix ad7b8cc4. The merge moves no file of the PR and none under service-automation (git diff --name-only 6a1f86f9 a3047515 names neither), so rootRunOf and the run log read as they did. The PR's own change is git diff a3047515 ad7b8cc4: 4 files, +93 / −16. Nothing was built or run. Check-runs on this head: 63, of which 43 success and 20 skipped, none failed or pending.

  • S4: closed. The node hands over its run's root (automation.rootRunOf?.(context)?.runId ?? null) and the read's second arm compares root_run_id with it. A refusing child now reaches a request its root, its parent or a sibling child opened, each of which carries the root's id in root_run_id. Two new cells on an object with no closed state (the parent opened the decided request; a sibling child opened it) end recalled, with the decided row unchanged, approver 2 not asked, and one actor-less recall row whose comment names the child run, which shows the refusing run is the child.

① Derived judgments

  • rootRunOf on a nested tree: right. The engine stamps $rootRun once on the run with no parent and every child inherits that stamp through its context (root-run.ts, stampRootRun), so a run at any depth reads the same root. rootRunOf is a pure read of the step's context.
  • The root run refusing: its root is itself, both arms compare against one id, and the read is what it was at 6a1f86f9. The six top-level cells still hold it.
  • No root handed over (an engine without rootRunOf, or a child the engine could not place, whose stamp is null): rootRunId || run falls back to the run's own id, the behaviour of the previous head.
  • Published surface against main: unchanged in kind. The public method this PR adds takes one more optional input member.

② Semver level

patch with Clause-②: yes (widening) stands. rootRunId? is an optional member on the input of a method this same PR introduces, so against main it is part of one addition, and the changeset's widening sentence spells the input with it.

③ Boundary flags

  • SQL push-down: clean, no regression. Still one read, newest first, limit: 1, no id materialisation and no in-app join. object_name and record_id stand outside the $or; the second arm is exactly the declared index (root_run_id, object_name, record_id), and (object_name, record_id) bounds the whole read to one record's requests.
  • A pending newest request: the method answers open before any write. The new cell pins it with an older decided request present (first: approved, second: pending, called with the tree's root): the answer is open, the field stays pending, no recall row.
  • The none docblock, sentence by sentence: true. "No run of the run's tree opened a request on the record" is what an empty read means when the root is handed over. The two cases it names as outside the read are the two the code leaves outside: a request with an empty root_run_id that another run opened matches neither arm; and with no root handed over, the second arm compares against the refusing run, so a request naming another run as root is not matched.
  • The new cells test what they claim. Each child cell asserts that the refusing run is not the root and did not open the decided request before it asserts the outcome. Read against 813e8043, where the second arm still compared against the refusing run: the child cells get none and keep approved, and the live-request cell gets none where it expects open, which is the red the PR body reports. Green is Test Core on this head.

④ Design judgment

No must-fix, no should-fix.

  • N7 (nit, follow-up). Where a parent routes its child's failure down a fault out-edge and goes on, the put-back now writes recalled and a recall row for an approval whose parent run is still live. On main the same shape opened the child's request and the sweep wrote recalled as well, so the end is not new. Derived by reading, not measured.
  • N1, N2 and N6 stand as recorded, for the follow-up cards the seat routed.

Implemented-by: claude/issue-38985-failed-run-orphan-approval
Reviewed-by: session_01WGufzhGA3zoCFquQgku4pm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta — ACCEPT on ad7b8cc460ef68b8e4589c2281119d6d9bd009af

The contract-tier delta record 7342528286 is on this head: PASS, no must-fix, no should-fix. S4 is closed, so the REWORK in 7341170960 is answered. CI: 43 success, 20 skipped, 0 failed; mergeable_state clean.

Verified on the tree:

  • Merge. a3047515 is a pure merge of main: git merge-tree --write-tree equals its tree, and it moves no PR file.
  • The fix (option a). The approval node passes rootRunId: automation.rootRunOf?.(context)?.runId ?? null, and rootRunOf? is the surface's existing member. The read's second arm is root_run_id = rootRunId || runId. It is still one keyed read on the declared root_run_id / object_name / record_id index, bounded by the record, limit: 1, newest first. A refusing child run now reaches requests opened by its root, its parent and its siblings. When the root itself refuses, or no root is handed over, the read is exactly the round-3 read.
  • Pending newest. If the tree's newest request is pending, the answer is open and nothing is written. This is pinned with an older decided request present.
  • Tests. There are three new cells (parent-opened, sibling-opened, live guard), red at 813e8043 and green on this head. Each child cell first asserts that the refusing run is not the root and did not open the decided request.
  • Declaration. The changeset spells the input abandonAtRefusedStep({ …, rootRunId? }). Clause-②: yes (widening) and patch stand: against main the optional member is part of the one new method. The bullet on the tree and the none docblock are true sentence by sentence: the two cases they place outside the read are the two the code leaves outside.

Carried to the seat (nits, not owed): N7: where a parent routes a child's failure down a fault out-edge and goes on, the put-back writes recalled while the parent run is live. main's sweep wrote the same end, so it is not new; it is a follow-up candidate. N1, N2 and N6 stand for the follow-ups already routed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 recalled, the first approver's row unchanged, approver 2 never asked; measured on the head). Not governed, 635 lines ≤ 3000, Clause-②: yes (widening) declared, CI 43 success / 0 failure, mergeable clean. Ready for review and auto-merge (squash). Fixes #38985: the merge closes the card. Follow-ups to be filed as cards citing 7338436183: the failed parent's child run, N1 (multi-replica restored strand); N7 carried to the seat.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 10:30
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit d0bce70 Dec 2, 2026
64 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38985-failed-run-orphan-approval branch December 2, 2026 10:58
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/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants