Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8011f64
test(plugin-approvals): an approval step on a run another branch alre…
claude Dec 2, 2026
0c5537c
fix(plugin-approvals): an approval step opens no request on a run tha…
claude Dec 2, 2026
d49d76b
test(plugin-approvals): the ended-run cells use an object that closes…
claude Dec 2, 2026
7413448
chore(changeset): an approval step on a run that has already ended
claude Dec 2, 2026
9e5a578
fix(plugin-approvals): refuse only where the ended run's log went on …
claude Dec 2, 2026
4b9043e
fix(plugin-approvals): the approval node reads getRun through the res…
claude Dec 2, 2026
36b9c4b
Merge origin/main (with the fan-out judge, #39013) into claude/issue-…
claude Dec 2, 2026
594e140
chore(changeset): declare #38985 as Clause-② yes (widening): Approval…
claude Dec 2, 2026
685a81f
test(plugin-approvals): a refused step on an ended run leaves every o…
claude Dec 2, 2026
4d50111
fix(plugin-approvals): a step refused on an ended run puts the record…
claude Dec 2, 2026
99d3d3b
chore(changeset): recalled on every object kind, the new service meth…
claude Dec 2, 2026
f5ba015
chore(audit): regenerate the plugin-approvals tenant-audit census for…
claude Dec 2, 2026
a52afeb
fix(plugin-approvals): the approval node's logger declares warn, the …
claude Dec 2, 2026
00562b9
Merge remote-tracking branch 'origin/main' into claude/issue-38985-fa…
claude Dec 2, 2026
1f705ec
test(approvals): a refused step reaches the approval a child run open…
claude Dec 2, 2026
e318c22
fix(approvals): a refused step reaches the approval its child runs op…
claude Dec 2, 2026
6a1f86f
docs(changeset): the put-back reaches child runs' requests, and a fai…
claude Dec 2, 2026
a304751
Merge remote-tracking branch 'origin/main' into claude/issue-38985-fa…
claude Dec 2, 2026
813e804
test(approvals): a refusing child run reaches its parent's and siblin…
claude Dec 2, 2026
ad7b8cc
fix(approvals): a refusing child run reaches the approval its whole t…
claude Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/38985-ended-run-approval-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@objectstack/plugin-approvals': patch
---

fix(plugin-approvals): an approval step opens no request on a run that has already ended

Clause-②: yes (widening)
Metadata-protocol: none

The widening, two additions: the exported `ApprovalAutomationSurface` gains an optional member, `getRun?: ApprovalResumeSurface['getRun']`, the run log read the approval step makes before it opens a request (a host that passes an engine without it opens the step as before); and the exported `ApprovalService` gains a public method, `abandonAtRefusedStep({ runId, nodeId, object, recordId, runStatus, rootRunId? })`, which the approval step calls once when it refuses, described below. It is meant for the approval step only.

When a flow's node fans out to branches that run together and one branch fails, the run ends while the other branches keep going. A branch that reached an approval step after that still opened a request there: the step's approver was notified and asked to decide for a run that can never resume, and the record was held `pending` until the dead-run sweep recalled the request (every 5 minutes by default, and never on a host with no job service).

The approval step now reads its run's log before it opens a request. Where the run has already ended (completed, failed, cancelled, timed out, refused or missed) and the log shows a step completed after that end, so another branch went on to this step, it opens no request, sends no notice and leaves nothing pending. The step is logged as failed with a sentence naming the run and how it ended; the run keeps the status and error it ended with. Because the step fails, an authored `fault` out-edge on it is taken, on the run that has already ended.

The record then ends `recalled` (or its value at submit, where its options do not declare `recalled`) on every object, abandoned and never approved, and the approver of the next step is never asked:

- On an object that closes on its approval field, the decision before the fan-out was held back, and the plugin's fan-out judge puts the record back, through the door or the reconciler. The refusal writes nothing more there.
- On any other object, the decision before the fan-out was already written to the field (`approved`, say), and no judge runs. The refusal puts the record back itself, as the dead-run sweep does for an approval whose run died: one `recall` row with no actor on the approval's latest request on the record, whether the run itself or any run of its tree opened it (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), naming the run, how it ended and the step that opened nothing, then the status field set to `recalled`. That latest request keeps the decision its approver recorded; no request row is written. If the put-back fails, the step's error says so, and the record keeps the value its last decision wrote.

A run that is still running, or still being resumed onto the step, opens it as before. So does a run that stranded and was restored and is now resumed again: its log still reads the end it stranded with, but nothing logged after it. A run whose status cannot be read also opens the step: an unreadable run is not taken for an ended one. Where a branch reaches the step before it has logged any step past the run's end (the step is the first node after the fan-out and the failure landed first), the step still opens, and the dead-run sweep recalls the request as before.
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ a row or a number here — fix the code, or the census, and regenerate.

| Measure | Value |
|---|---:|
| Write call sites | 51 |
| Object name statically decidable | 49 |
| Write call sites | 52 |
| Object name statically decidable | 50 |
| Object name chosen at run time | 2 |
| Object name spelled inline | 47 |
| Object name spelled inline | 48 |
| Object name spelled through a `const` | 2 |
| Object name is an `object: string` parameter | 1 |
| Object name is some other run-time expression | 1 |
| Against a tenancy-enabled object | 49 |
| Against a tenancy-enabled object | 50 |
| Against an object declaring tenancy off | 0 |
| Threading a tenant context | 51 |
| Threading a tenant context | 52 |
| Provably carrying none (options read, no context key) | 0 |
| …and decidably tenancy-enabled | 0 |
| Options argument unreadable | 0 |
| …and decidably tenancy-enabled | 0 |
| Threading a decidably elevated (`isSystem`) context | 49 |
| Threading a decidably elevated (`isSystem`) context | 50 |
| Threading a decidably non-elevated context | 0 |
| Threading a context of undecidable elevation | 2 |
| Receiver carried a readable engine type | 51 |
| Receiver carried a readable engine type | 52 |
| Receiver erased, placed by the object NAME | 0 |
| Receiver erased, placed by an `object: string` PARAMETER | 0 |
| Receiver erased, placed by an `UNTYPED_RECEIVERS` row | 0 |
Expand All @@ -50,7 +50,7 @@ a row or a number here — fix the code, or the census, and regenerate.
| `packages/plugins/plugin-approvals/src/action-slot-backfill.ts` | `update` | `sys_approval_action` | enabled | elevated | 2 |
| `packages/plugins/plugin-approvals/src/approval-activity-feed.ts` | `insert` | `sys_activity` | enabled | elevated | 1 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `update` | `object` | undecidable | context, elevation undecidable | 1 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `insert` | `sys_approval_action` | enabled | elevated | 20 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `insert` | `sys_approval_action` | enabled | elevated | 21 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `delete` | `sys_approval_approver` | enabled | elevated | 2 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `insert` | `sys_approval_approver` | enabled | elevated | 2 |
| `packages/plugins/plugin-approvals/src/approval-service.ts` | `insert` | `sys_approval_request` | enabled | elevated | 1 |
Expand Down
Loading
Loading