You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a426d36
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-approvals): a revise-window recall on a batch item resumes the batch (#28228)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D66UdUaGFca5mMDQCSjqRhX)_
domain:server#4 · os-elon-musk · session_016WV4d13k5TVyAhqhiKKgN3
Fixes#28183
Clause-②: no (a batch run that nothing could wake after the recall now
continues, in the shape the cancelled-item ruling already set; no
schema, accept set, error code or result field changes)
Metadata-protocol: none
## 维护者速读
- 改了什么:批量签批(map 逐项审批)里,提交人在修改窗口(revise window)撤回某一项后,撤回现在会顺手恢复停在这一项上的批次
run;map 按 #28176 的形状把该项记成 `{ $status: 'cancelled', $itemRunId }`,`count`
不算它,然后开下一项或走完。
- 为什么改:实测 main(3a2f4c00):撤回只对该项 `cancelRun`,批次 run 一直停在 `map:<该项 run>`,第
2 项的审批永远不开,除非运维手动用批次 run id 恢复。按分诊与裁决 A(6523833308)的形状修,不新增标记或错误码。
- 风险与回滚:只在“修改窗口内撤回、`cancelRun` 确实取消了、且有 run 停在内置 `map`
节点上等这一项”时多做一次恢复;pending 撤回、无批次的撤回、全部决定完的批次不变(对照钉子)。回滚即 revert 本 PR。
- 先看:`packages/plugins/plugin-approvals/src/approval-service.ts` 的
`recall` 修改窗口分支与新私有方法 `resumeBatchOfRecalledItem`。
- 两分钟验证:`pnpm --filter @objectstack/plugin-approvals exec vitest run
src/batch-item-recall-resumes-batch.test.ts`,预期 5 passed。
- 需要你做的:无,席位在 CI 绿后按落地授权落地。
## What changes
- **`packages/plugins/plugin-approvals/src/approval-service.ts`.** In
`recall`'s revise-window branch, when `cancelRun` answers `true` (it
really cancelled the item's run), the new private
`resumeBatchOfRecalledItem(itemRunId, requestId)` looks for the run
parked on `map:<itemRunId>` (`listSuspendedRunsDurable`, a member the
surface already declares), checks through `getFlow` that the node it is
parked at is the built-in `map`, and resumes that run with
`serviceResume(batchRunId, {})`. The engine's existing parent-id resume
(PR #28176) does the rest: it reads the item's `cancelled` history,
records the marker in the item's slot, leaves it out of `count`, and the
map opens its next item or runs on. No `service-automation` change.
- **Failures are told as the recall tells its own.** The withdrawal
stands whatever happens to the batch. A refused batch resume (for
example `409 RESUME_CHILD_PENDING` when the item's history cannot be
read) or a lookup that throws fills `resumeError` and logs at `error`;
the engine's stranded exit, and a strand bubbled to a subflow parent
above the batch, also fill `resumeFailure` with `RESUME_FAILED`, the one
code this package's ledger row admits. `resumed` still describes the
recalled request's own run, which was cancelled, so it stays `false`.
- **Nothing is woken without proof.** No `listSuspendedRunsDurable` or
`getFlow` on the attached engine, no run parked on that item, or a
parked node that is not the built-in `map`: the recall answers exactly
as before. A home-grown node that parks on a `map:` link is never
re-run, because the engine records the cancelled item only for the
built-in `map`, and re-running another node would advance it past the
item with nothing recorded.
-
**`packages/plugins/plugin-approvals/src/batch-item-recall-resumes-batch.test.ts`**
(new). The real `AutomationEngine` with the built-in nodes and the
approval node, a `release_signoff` batch (`map` over `task_signoff`, an
approval with a revise window), the showcase's
`showcase_release_signoff` → `showcase_one_task_signoff` shape.
- **`scripts/engine-double-contract.pinned.json`.** Two generated rows
(`delete`, `update`) for the new test's engine double, written by
`check-engine-double-contract.mjs --write`.
- **`.changeset/28183-batch-item-recall-resumes-batch.md`.**
`@objectstack/plugin-approvals` patch.
## Why
### Before (measured at `origin/main` `3a2f4c00`)
Two tasks; item 1 sent back by the approver, then recalled by the
submitter from the revise window:
| | Before | After |
|:---|:---|:---|
| item 1's run | `cancelled` | `cancelled` |
| batch run | parked on `signoffs`, correlation `map:<item 1's run>`,
history `paused` | parked on `signoffs`, correlation `map:<item 2's
run>` |
| item 2's request | none | `pending` |
| recall answer | `resumed: false`, no `resumeError` | `resumed: false`,
no `resumeError` |
| after item 2 is approved | (never reached) | batch `completed`;
`signoffResults` = `[{ $status: 'cancelled', $itemRunId }, { decision:
'approved' }]`, `count` 1 |
### Why this path
Triage 6527285884 routed the card to ruling A (6523833308): a cancelled
item records `cancelled` and the map moves on, and the recall follows
the same shape by resuming the parent with the cancelled marker. PR
#28176 already built that resume behind the batch run's own id; the only
thing missing was a caller. So the fix stays in the recall path and
reuses that resume as is: no new marker shape, no new code, no
`packages/spec` edit.
## Tests
`batch-item-recall-resumes-batch.test.ts`, 5 cells:
1. the recall resumes the batch: item 1's slot is the marker, `count` 1,
item 2's request opens, and the batch completes after item 2 is approved
(red on `main`);
2. CONTROL: a revise-window recall on an approval with no batch above it
is unchanged, and a batch parked beside it is untouched;
3. CONTROL: a recall while `pending` resumes the item down `reject`, and
the map records `{ decision: 'rejected' }`;
4. CONTROL: a batch whose every item is decided (one through a send-back
and resubmit round) records both outputs, `count` 2;
5. CONTROL: a run parked on a `map:` link at a node other than the
built-in `map` is not woken.
Ablations through `scripts/ablation-replace.mjs`, each restored to the
HEAD blob with `git diff HEAD` empty:
| Ablation | Red |
|:---|:---|
| A1: drop the batch resume after `cancelRun` | cell 1 |
| A2: match any `map:` parent, not this item's | cell 2 |
| A3b: a `pending` recall takes the cancel path | cell 3 |
| A4: the decide door always resumes down `approve` | cell 4 |
| A5: drop the built-in `map` node check | cell 5 |
(A3, the batch resume also issued on the `pending` path, stayed green:
by then the item has completed and the map has moved to item 2, so no
run is parked on item 1 and the lookup finds nothing. Harmless, so not a
guard.)
## Verification
Head `acae6743`, after a whole-tree `turbo run build` and fetching the
teardown self-test's pinned commit.
- `pnpm --filter @objectstack/plugin-approvals exec vitest run`: 106
files, 1357 passed. `pnpm --filter @objectstack/plugin-approvals run
typecheck`: exit 0, test layer held at its ledger.
- `dispatch-gates --commands` (re-derived after the second commit): 71
families, all exit 0. `--ran`: 71 derived, 71 run, 0 NOT-MEASURED, 0
UNRUN. The first sweep caught the test double
(`check:engine-double-contract`, `check:objectql-double-limit`); the
second commit routes it through the dispatch asserts and adds its two
generated ledger rows.
- `pnpm lint`: exit 0. `check-commit-card-trailers --range
origin/main..HEAD`: exit 0.
## Out of scope
- `listSuspendedRunsDurable` reads a durable store's deployment-wide
page (`ObjectStoreSuspendedRunStore.list()`, 1000 rows). Past 1000
parked runs the batch run may not be on that page, and the recall then
answers as it did before this PR (the batch stays parked, nothing is
told). A precise lookup needs an engine member (the item run's
`$parentRunId`), which is outside this card's surface.
- `content/docs/automation/flows.mdx`'s cancelled-item paragraph and
`approvals.mdx`'s revise-window paragraph do not yet say that a recall
wakes the batch. Docs were outside the claimed surface.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4d13k5TVyAhqhiKKgN3
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-approvals): a revise-window recall on a batch sign-off item resumes the batch, which records the item as cancelled and goes on
6
+
7
+
Clause-②: no (a batch run that nothing could wake after the recall now continues, in the shape the cancelled-item ruling already set; no schema, accept set, error code or result field changes)
8
+
Metadata-protocol: none
9
+
10
+
A batch sign-off is a `map` node over the items, and each item's run parks on its own `approval`. When the submitter recalled an item from the revise window, the recall cancelled the item's run with `cancelRun`, which never touches the parent. The batch run stayed parked on that item with no request open for the next one, and nothing woke it short of an operator resuming the batch run by hand.
11
+
12
+
-**Now.** After the cancel, the recall resumes the batch run parked on that item. The map records the item's slot as `{ $status: 'cancelled', $itemRunId }`, leaves it out of `count`, and opens the next item, or runs on past the map when it was the last one.
13
+
-**Only the built-in `map`.** A run is woken only when it is parked at a `map` node on that item's run. Any other node parked on such a link is left alone, because nothing records the cancelled item for it.
14
+
-**Failures are told the way the recall tells its own.** A batch resume the engine refuses or strands does not fail the recall: the withdrawal stands, `resumeError` says which run did not move and why, and an engine-stranded batch is reported on `resumeFailure` with code `RESUME_FAILED`.
15
+
-**Unchanged.** A recall while the request is still `pending` (the item resumes down `reject` and the map records its output), a revise-window recall with no batch above it, and a batch whose items are all decided.
0 commit comments