Repository navigation
feat(approvals): the reconciler, and the door reads every run of an approval (ADR-0162 item 8, piece 4) - #38571
objectstack-fleet[bot] wants to merge 5 commits into
Conversation
A subflow step names the run it started on every exit, and a map step the item runs that execution started (childRunIds on the step log, ADR-0162 Execution item 8). A run that ends inside execute answers no runId, so the engine names the run it started for a context (runStartedFor), which the subflow and map nodes read. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my
…pproval The door walks the approval's run tree from the run that carries the record through the child runs each step records, so a sibling child, a middle run and a run being advanced are placed (ADR-0162 Execution item 8). The reconciler judges every marked approval oldest first on the sweep clock: a cancelled run, a process that died after a decision, past the age bound a run whose pause is gone or that is parked on an ended child, and a deleted record, whose marks it clears. The stranded-request report leaves stamped requests to it. A refused write tried again leaves its timeline line once. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my
…oval leaves Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my
📓 Docs Drift CheckThis PR changes 3 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 181 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b1d9979699ffda8d1f055a1883bc15f04b4acacb && git checkout b1d9979699ffda8d1f055a1883bc15f04b4acacb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 97f9f1f236d67647b8521f0bdd500d430afbe063 5a93cb0a76165126fdfdd6c82560ebb475a0a7a4 && git checkout -B drift-repro 97f9f1f236d67647b8521f0bdd500d430afbe063 && git merge --no-ff 5a93cb0a76165126fdfdd6c82560ebb475a0a7a4
node scripts/docs-audit/affected-docs.mjs --json 97f9f1f236d67647b8521f0bdd500d430afbe063
|
… 3 note stays as it is Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract-review-claim: session_01QsR2jSyQBDMyRnrrWKy7WS · head 5a93cb0 · 2026-11-29T12:18Z Seat 1's review thread R1 starts an isolated contract-review sub-agent at |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract reviewServed-tier: PR #38571, piece 4 of card #37767, base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M1 (must-fix) — M2 (must-fix) — a run with no row is cannot tell for good, and the walk now depends on rows the engine does not keep.
M3 (must-fix) — a regression of N46 c′ in S1 (should-fix) — a decision whose run was never resumed is in progress for good. Where a process dies after the decision's row lands and before the resume, the run is still parked at its own approval node with its pause intact. For any step but the last that node is in the stamped set ( S2 (should-fix) — the reconciler's scan can be held at its head. It reads the 200 oldest marked requests, in the same order on every pass, with no cursor. An approval that stays cannot tell (M2, a tree past 200 runs, a status the plugin does not place) or stays in progress with its mark (an allowed pause between two steps of an approval that holds nothing back) never leaves the head, and 200 such rows stop every newer approval from being read. The docblock's "the oldest is never starved" is true and beside the point: the newest are. The loop already clears an S3 (should-fix) — S4 (should-fix) — S5 (should-fix) — N1 (nit) — N2 (nit) — N3 (nit) — "on every exit" has two bounds the comments do not state: the N4 (nit) — the age bound is measured from the mark, not from the run's last movement. An approval that holds nothing back may pause between two steps for longer than an hour; a sweep that catches its next passage reads "paused, pause gone" as stopped and clears the mark early. Nothing is written, so it is harmless here; it is a note for piece 5, which reads the hold off that mark. Three must-fix (M1, M2, M3), five should-fix (S1 to S5), four nits. The engine half is small and close: the field, the copy onto the step and the two delegating nodes are sound once M1 and S5 are fixed. The door's walk needs a rule for a run that is not there before it can carry the judgement. Implemented-by: VERDICT: FAIL |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS The brief the isolated reviewer was handed for contract-review record 7255916895, as it stood (2026-11-29T12:35Z). The reviewer ran at BriefContract review brief — PR #38571 @
|
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS 席位核对 — REWORK · L1 · seat repo:objectstack#1, review thread R1 · Head-sha
|
Requested by Leehom · project thread
Part of #37767
维护者速读
childRunIds),在调用内就结束的子运行通过runStartedFor取到。Clause-②: yes (widening)
Metadata-protocol: added
What changes
Piece 4 of #37767: ADR-0162 D5 and Execution item 8, bullet "The reconciler", and the door's judgement over every run of the approval, which closes slice 3's S1 (seat ruling (b), recorded on #38497 as 7254288859). Everything in the plugin applies only to an approval the check stamped when it opened, so an object that declares no
closedStatesbehaves as before.The engine (service-automation, spec).
Metadata-protocol: added: the step log's schema is anauthorable-surfaceshard (packages/spec/authorable-surface/automation.jsonmoves by one key), so@objectstack/specis gradedminorin its own changeset; nothing an author writes in a flow changes.ExecutionStepLogSchemagains the optional, engine-writtenchildRunIds: string[], andNodeExecutionResultthe same member.dag-traversalcopies it onto the step's log entry on success, suspend and failure (stepChildRunsOf).subflowstep names the one run it started on every exit (paused, completed, failed, refused). Amapstep names the item runs that execution of the step started.executeanswers norunId, because the contract sets it on a paused run only.AutomationEngine.runStartedFor(context)answers the id of the run the lastexecutecall started for that very context object (aWeakMapkeyed by the caller's context; undererrorHandling.strategy: 'retry'the last attempt). Thesubflowandmapnodes read it for a child that ended inside the call. Without it, a sibling child that completed with a routed failure left no link.The door reads every run of the approval (
readCarryingRun→readApprovalRun). The walk starts at the run that carries the record (and the latest request's own run, for a run whose steps predate the link). It followschildRunIds: everysubflowchild, and amapitem run only where it is theflow_run_idof one of the approval's own requests (an item that is a record carries an approval of its own). A visited set, and a cap of 200 runs (past it: cannot tell). One run decides for the whole approval:__laterStepNotOpenednote: abandoned;The reconciler (
reconcileMarkedApprovals, on the sweep clock inapprovals-plugin.tsbeside the escalation, dead-run and stranded-request legs).sys_approval_requestwhereunjudged_sinceis set ($null: false, the column's index), ordered byunjudged_sincethenid, at most 200 a pass, and judges each approval (root run, object, record) among them once, through the door's own judgement (judgeApprovalAfterDoor, door "the reconciler"). The outcome is written in the name of the request's recorded decider (deciderOf), as the door does.RECONCILER_AGE_BOUND_MS, one hour, the bound the ADR leaves to the build): once every mark of the approval has stood past it, a run that reportspausedwhile its pause is gone is read as stopped at its last top-level step, and a run parked at a node of the set on asubflow:/map:correlation whose child run has ended is read as stopped at that node. Within the bound both are cannot tell and in progress, as at the door.hasTimelineLine), so a retry each sweep does not add a line each sweep. The administrators' notice is keyed per request and status, as before.inspectStrandedRequestsskips a request the check stamped: the reconciler takes its place there, as item 8 says.Carried from slice 3. The slice 3 changeset is left as it is on the base (a changeset this PR did not add is not edited, #17712); the reconciler's changeset says instead that a refusing end is an end of the flow, as the door already reads it.
stopOf's docblock names the two failures that log no step for the node the run died on (the re-entry guard, a suspension refused in a region). The N5 case (an abandoned auto-rejection sends no auto-rejected notice) is in the new file.The guide.
content/docs/automation/approvals.mdx: the closed-states section gains "When the outcome lands on the record" (held back, the four answers, the mark and the reconciler), "What an abandoned approval leaves" names the platform's own abandonment beside the three writers, and the host ground says the sweeps also judge an approval no action judged. The hold paragraph comes with piece 5. The new section is placed after "What an abandoned approval leaves", so it merges cleanly with #38562's new section before it (overlap-checkclean).Not in this PR: the hold (piece 5), with the Done-when lines "a hook's write-back" and "a cascade" and the deletion arm of item 8's hold bullet. The refusal on a host with no
jobservice was done in slice B.Why
ADR-0162 item 8: "The reconciler is what ends an approval that nobody is at the door for." Slice 3's L2 found that the door read two runs and answered finished in the shapes it missed, clearing the mark a reconciler would scan (S1, records 7253560285 and 7254001546); the seat ruled that this piece changes the door's own judgement, with any engine member it needs under its own Clause-② face.
Tests
approval-reconciler-37767.integration.test.ts, real kernel, ObjectQL, automation engine and sqlite, 14 cases:subflowchild whose node failed before its step, routed to its end (abandoned, not finished); the delegating steps record their child runs; a middle run two levels down that failed between two steps (abandoned); a middle run another process is advancing (cannot tell, the mark stays); an abandoned auto-rejection sendsapproval.abandonedand no auto-rejected notice;approver2); a refused outcome retried, noted once, the notice under one key, then written; an approval whose field the object does not close on (mark cleared, nothing written); a record deleted in a passage (marks cleared once, no notice, not scanned again); a run whose pause is gone, within and past the bound; a run parked at asubflowwhose child ended, within and past the bound; oldest mark first under a limit of 1; the stranded-request report leaves a stamped request (a failed run) and still reports an unstamped one.step-child-runs.test.ts(service-automation), 4 cases: asubflowwhose child completes inside the call, one whose child pauses (itscorrelationnames the same run), amapof three items, andrunStartedForfor a flow that is not registered.The slice 3 file (
approval-outcome-when-over-37767.integration.test.ts, 28 cases) is unchanged and green on the new walk.Ablations
scripts/ablation-replace.mjs, anchor hit as declared, blob moved and restored to HEAD each time:childRunsOfreturns nothing: 3 red (the sibling, the failed middle run, the advancing middle run).agedforcedfalse: 2 red (the pause that is gone, the parent parked on an ended child).recordIsGoneanswersfalse: 1 red (the deleted record).inspectStrandedRequestswithout the stamp skip: 1 red (the report case).hasTimelineLineanswersfalse: 1 red (the refused outcome, noted once).subflowwithout therunStartedForfallback: 1 red instep-child-runs(a child that completes inside the call);mapthe same: 1 red (themap);dag-traversalwithoutstepChildRunsOf: 3 red.Verification
@objectstack/plugin-approvals: 139 files, 2156 tests, green.@objectstack/service-automation: 300 files, 4443 tests, green. Typecheck clean on plugin-approvals, service-automation and spec.dispatch-gates.mjs --commandsfamilies: running against the trunk; the result is added when the green head is declared.overlap-check.mjs --base=origin/claude/o5-data-approvals-trunk: clean against the trunk, feat(lint): an approval's closed-state gap is refused at every authoring door, through the first request's one judge (ADR-0162 item 7, slice N45) #38562 and feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk #38497.Human Minimum
packages/specholds no runtime logic (one optional field on the step log's schema).pnpm lintpasses.claude/o5-data-approvals-trunk, per the trunk rule).packages/spec: one optional field, regenerated outputs committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/(the reference page is regenerated).🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5pigknx7rC8rXnA3my