Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
13731a0
chore(approvals): carry the plugin half of the reworked reconciler as…
claude Nov 29, 2026
ae94d6c
test(approvals): the cases the reworked reconciler fails, before the …
claude Nov 29, 2026
724d41e
test(approvals): a note that lands while the runs are read, before th…
claude Nov 29, 2026
8dd667b
fix(approvals): the kept reading is safe to judge from (ADR-0162 item 8)
claude Nov 29, 2026
dc5895d
fix(approvals): the notice that a flow did not go on says what to do …
claude Nov 29, 2026
033c2f6
docs(approvals): the changeset and the guide say what the rebuilt rec…
claude Nov 29, 2026
e0eae8b
test(approvals): a run in progress beside a sibling that failed (ADR-…
claude Nov 29, 2026
5ab38fb
test(approvals): a truncated map step and a step log the row cut, bef…
claude Nov 29, 2026
1a09d57
fix(approvals): a step log that does not name every child run is cann…
claude Nov 29, 2026
c593184
docs(approvals): a step log that does not name every child run, in th…
claude Nov 29, 2026
96d05da
Merge the engine half (PR #38618 at ee8203b011) into the plugin core
claude Nov 30, 2026
0be4d5d
test(approvals): the cases the rework on review 7266979193 owes, fail…
claude Nov 30, 2026
bed4551
fix(approvals): a tree one judgement cannot read has an end, and a ma…
claude Nov 30, 2026
de5e665
test(approvals): the pins N20 to N22 of review 7266979193 owe; the N2…
claude Nov 30, 2026
898c05a
fix(approvals): the step last decided is placed in the flow its reque…
claude Nov 30, 2026
292dc62
docs(approvals): the changeset, the guide and the notice say what the…
claude Nov 30, 2026
b49e04a
test(approvals): three more pins on the S11 and S12 rules (ADR-0162 i…
claude Nov 30, 2026
04635fc
test(approvals): the real-engine case of 201 item runs carries its ow…
claude Nov 30, 2026
c885ffc
docs(approvals): the compacted-log gap is stated as the limit the mai…
claude Nov 30, 2026
596ee28
test(approvals): the cases S14 of delta review 7269135624 owes, faili…
claude Nov 30, 2026
9e225b1
fix(approvals): past the bound, a run is placed only once two judgeme…
claude Nov 30, 2026
e29d097
fix(approvals): the title of the administrators' notice says what its…
claude Nov 30, 2026
3c80901
docs(approvals): the bound places on two readings in a row, and the t…
claude Nov 30, 2026
b048058
docs(approvals): a reading that is never kept holds an approval with …
claude Nov 30, 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
29 changes: 29 additions & 0 deletions .changeset/37767-reconciler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@objectstack/plugin-approvals': patch
'@objectstack/service-messaging': patch
---

feat(approvals): the reconciler, and the door reads every run of an approval (ADR-0162 Execution item 8)

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

Widened: `ApprovalService` gains `reconcileMarkedApprovals(options?)`, which the plugin runs on the sweep clock beside the escalation, dead-run and stranded-request sweeps; the `getRun` member of the automation surface the plugin declares types the step log's `childRunIds` and `childRunIdsTruncated`, the run's `trigger`, `completedAt` and `summary`, and an optional `{ strict }` read; the plugin's message catalog gains `approvalFlowNotContinuedTitle` and `approvalFlowNotContinuedBody` in all 11 locale packs, sent to the organization's administrators on the topic `approval.flow_not_continued`; `PLATFORM_NOTIFICATION_TOPICS` of `@objectstack/service-messaging`, the topics a notification preference may name, gains that topic.

Only for an approval the check stamped when it opened (one with a step that can act on an object that declares `closedStates`):

- **The door reads every run of the approval.** Where it read the run that carries the record and the latest request's own run, it now walks the tree from the run that carries the record, following the child runs each delegating step records: every `subflow` child, and every `map` item run that does not carry another record (an item that is a record carries an approval of its own). It reads the whole tree before it answers, and one run decides for the whole approval: one that the store could not answer for, or that reports a status of a run in motion (`pending`, `running`, `retrying`), makes it cannot tell; otherwise one parked at a node a step can follow, in progress; otherwise one that ended between two steps, abandoned. A run parked at such a node on a child run says what its child says, so the walk reads the child, at any depth. The automation engine reports none of those three statuses for a flow run today: a run it is advancing reads as paused with its pause gone, or as a run with no row, and is held by the rule for a run that stopped, below. So a sibling child whose failure the flow routed, a middle run two levels down that failed, an item run that failed before its step, and a run between two others that is being advanced are no longer read as finished. A failure routed to a pause no step follows is read as abandoned, as on the base. A stop is answered where a request of the approval opened after it. One judgement reads at most 200 runs beside those it kept as ended: past them it is cannot tell, keeps what it read, and the next judgement reads on. That has an end: once the approval's marks have stood for the hour of the age bound, a judgement reads on only while it keeps a run the approval had not kept (the kept list holds 200 runs), and the judgement that keeps none places the approval by the step last decided, below. Two costs come with that rule. A tree the judgements cannot finish is placed without being finished, and from about 399 runs a tree can be one no judgement finishes: the walk reads the runs it starts from before the runs below them, so for a `map` of 199 items that each call a `subflow`, every judgement reads the run and its 199 items and none of the runs below them. And the placement follows from the shape of the flow, so an approval submitted again on the same flow can meet the same end: the remedy is the flow's, not the submitter's. Reading on can take up to 200 further visits of the reconciler after the hour: one each sweep (every 5 minutes by default, the plugin's `escalationScanIntervalMs`), or one each turn of its walk where more requests are marked than one sweep reads. A run parked on a child run that such a judgement did not get to says nothing of its own, and the child a parked run waits on is read next, before the runs beside it.
- **The plugin keeps what it read.** At every door, one that leaves the next request pending included, and as each request opens, the approval's latest request keeps, in its config snapshot (`__runsRead`): the runs that are not read again (`ended`), the runs read to their end over a child run that was not (`open`), a failure between two steps found in a run that ended, and the states the last judgement read that say a run has stopped (`stood`), which the rule for a run that stopped uses, below. A run is kept as ended only once it was read to an end and every child run its steps name is kept as ended too. So a child whose read failed, a child with no row, and the runs past the 200 one judgement reads are read on the next pass, which starts from the open runs as well. A run that a stored step names and that a pass did not read is never left out without a word: it is read on a later pass, it counts as passed by the rule below, or the approval is cannot tell and then placed. A run that no stored step names any more is not covered by that: see the limit of this release, below. A run the plugin read before the automation engine trimmed its history is not needed again, so an approval whose refused outcome is tried again after its run's history went is judged as it would have been.
- **A run with no row, under a run that went on past it, is passed.** A run the engine has no row for counts as passed, and is kept as ended, where a run the plugin read went on past the step that names it: that step succeeded, and the run reached an end of its flow, or logged a later step and is not parked at that step. So an early child run trimmed before the plugin read it does not hold the approval back. A step that failed is never passed, also where the flow routed the failure and went on. A run the plugin had read to its end over an unread child, and whose own row is gone since, is not passed either: nothing names that child any more.
- **A step log the engine marked, or the history row cut, is cannot tell.** Two logs are read as cut, and are not judged from as they stand: one with a step that carries the engine's mark `childRunIdsTruncated` (its execution started more child runs than the 200 a step names, or the history row shed the step's list to fit its size), and the log of a run that ended whose history row keeps fewer steps than the run logged (the row bounds the log by bytes, to a tail of it or to none, while the run's summary still counts every step). Within the age bound nothing is written; past it the approval is placed by the step last decided, as for a run with no row, below. A run whose log is cut is not kept as ended, the child runs it does name are still read, and it speaks for none of them: no run it names counts as passed. A summary that is absent or dropped its per-node detail gives nothing to compare, and reads as cut.
- **The limit of this release: a log that loses whole steps carries no mark (ruling 7268216330 on #37767).** The engine marks one thing: a step whose child-run links were shed carries `childRunIdsTruncated`, above. A log that loses whole steps carries no mark, whichever way it loses them: the engine's compaction of a log of more than 200 steps, the history row's halving of a log over its 64 KB cap, a row stored as null. The plugin reads what the log kept, and a child run named only by a dropped step reads as one the run went past: it is not read. For a halved row and a null row the plugin can still tell that steps are missing, from the run's summary, which counts every step: that is the second log read as cut, above, and the approval is held and then placed. For a compacted log it cannot tell. A run that logged more than 200 steps is stored with 200 of them: every top-level step and every failed step, then the most recent of the rest (the most recent 200 of the top-level and failed steps, where those alone pass 200), and it is judged from those, as before this change. What an operator gets in that case: a `subflow` or `map` step the compaction dropped (one that succeeded inside a `loop`, `parallel` or `try_catch` region, or an early step of a very long run) no longer names the child runs it started; a failure the flow routed inside such a child run, between two steps, is not seen; and the approval can be written as finished, with no notice and no line in the log. A process that still holds the run in memory reads its whole log, so this is a judgement made once that process is gone. No approval is judged worse than before this change, whose door read no child run.
- **The kept reading is its own key.** It is written onto the snapshot read again just before the write, and only while the column still reads the same, at most three times. It cannot write a stale snapshot over a note another writer left there (`__laterStepNotOpened`, `__strandedContinuation`). The judgement reads the note that a later step could not open once it has read the runs, so a note that lands while they are read is judged with.
- **A run that stopped, placed by the step last decided.** A run the engine has no row for and that no run the plugin read speaks for (its history is gone, or a process stopped while advancing it), a run whose step log is cut, above, a tree of more runs than the judgements can read in full, above, and the latest request's own run still parked at the step its decision was recorded on (a process stopped before the run was resumed), in the run that carries the record or in a child run any number of levels below it, are cannot tell for an hour from the approval's marks (the age bound). Past it, each has stopped at the step last decided once two judgements in a row read it in the same state, for the same run. The hour is counted from the marks and not from the run's last movement, and a run the engine is resuming reads as paused with its pause gone or as a run with no row; so an approval whose flow waits longer than the hour between two steps by design (a `wait` node, a batch over records whose items are approved one by one, a child run parked outside the approval's steps) is past the bound whenever it resumes. Only an approval that holds nothing back can wait so: the check at its opening refuses each of the three between two steps of an approval on a field its object closes on. There a placement ends the hold and writes nothing. The judgement that reads a run in such a state first therefore does not place it (it cannot tell, and a run parked on a child that has ended is in progress), and keeps the state it read (`stood` in `__runsRead`); the next judgement places the run if it reads the same, and reads it anew if it does not. A judgement within the hour keeps what it read as well, a door's included, so an approval read in that state within the hour is placed by the first visit past it, and one that was not takes one visit more. A reading that could not be kept leaves on the request the reading kept before it: the next judgement stands on that earlier one, so a state kept earlier can still count, and where none was kept nothing is placed. An approval whose reading is never kept is therefore held with no end. Two passes that each fall inside a resume of the same run still read it as stopped. Whether a later step can follow that step is asked in the flow its request records, so a node of another flow that carries the step's id does not answer for it. Where one can, the approval is abandoned: the record is put back, the submitter is told and submits again, the decisions already made stay on their requests, and a run still parked there is cancelled, with the runs that wait on it up to the run that carries the record, through a `map` whose items are not records as through a `subflow`. The cancel follows the put-back, and is not tried again once the put-back has landed: where it fails, or the process stops between the two, the run stays parked, the approval stays abandoned, and the door that continues a restored run refuses it. At the last step, the outcome is written and, once that write has landed, the administrators are told that the flow could not be seen through to its end after that step; the run's pause is left for an operator. A refused write sends no such notice, and the pass on which the write lands sends it. The notice says what to do in each case: continue or cancel a run that is still paused, and where the run has ended or no run is left, check that the steps after the decision were done. An approval placed for a cut log or a tree too large to read can be one whose flow did go on, which the plugin could not read in full: at its last step the administrators get the notice for a flow that ran, and where a later step can follow, the submitter submits again.
- **The reconciler.** Each pass reads two windows of at most 200 marked requests (`unjudged_since`): the oldest marks, and the next page of a walk over every marked request by id, so that marks which stay cannot keep the newer ones from being read. It judges each approval among them once, as the door would have: it writes the outcome in the name of the request's recorded decider, abandons the approval, or, where nothing was held back, clears the mark and writes nothing (where it concluded that a run had stopped, a line in the log says so). It ends what no door saw: a run that was cancelled, a parent run cancelled while its child's request was pending, and the stopped runs above. Past the age bound it also reads as stopped where it stood a run that reports paused while its pause is gone, and a run parked at a `subflow` or a `map` whose child run has ended or has no row, each once two judgements in a row read it so, as above. The item run of a `map` whose items are records is such a child once it is in a terminal status: its steps are an approval of the item's own record and are not read, only whether it has ended, and it is kept as ended only once it has.
- **A refused write is tried again.** A refused outcome or put-back leaves the marks, and the next pass tries it again. The timeline line and the administrators' notice (keyed per request and status) are left once for one refusal; the same holds for the line an abandoned approval leaves.
- **A deleted record.** Where the approval's record was deleted, the reconciler clears the marks of its requests and writes nothing: no retry and no notice.
- **The stranded-request report** (`inspectStrandedRequests`) leaves a decided request the check stamped to the door and the reconciler, and still reports a returned one.

- **A refusing end is an end.** The door reads a run that reached an end of the flow as having ended there, a refusing end (`outcome: 'refused'`) included, as it already did for a completed run.

Unchanged: an object that declares no `closedStates`; an approval that opened before its object declared the key.
Loading
Loading