Repository navigation
fix(approvals): a record delete cancels the flow run its voided approval gated - #38293
Conversation
…val gated The record-delete void now cancels the run parked on the request it voids, with the reason, cancels every subflow parent above it on the same record (deepest first, never resumed), and wakes the batch whose item it was. A failed cancel never fails the delete. Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 6 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 0aee8367a823928a74300e87a99330ba68e4d951 && git checkout 0aee8367a823928a74300e87a99330ba68e4d951
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 73ec085afa2f9689ef96263a9c25b82cde6fda47 e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88 && git checkout -B drift-repro 73ec085afa2f9689ef96263a9c25b82cde6fda47 && git merge --no-ff e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88
node scripts/docs-audit/affected-docs.mjs --json 73ec085afa2f9689ef96263a9c25b82cde6fda47
|
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA Contract reviewServed-tier: Inputs read: card #37763 (body, triage 7207999396, ruling 7237973760, claim 7238037976); PR #38293 body, its 5 files and the net diff against ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL Close-out: fix M1 (both declaration lines to |
…e no-record-run and no-cancelRun texts Contract review 7238672789 on the #37763 services change: - M1: `cancelForDeletedRecord` answers a new `cancelledRuns` member on the exported `ApprovalService`, so the changeset declares `Clause-②: yes (widening)`. - S1: a request with no `record_run_id` cancels only its own run and logs nothing (a flat run on an engine that hands no record run); the docblock and the test title now say so, and the test pins no log. - N1: the docblock no longer claims a run is never cancelled while the run it waits on is parked; a `false` from `cancelRun` goes on up. - N2: with no `cancelRun` on the engine the delete path logs in its own words instead of the decision door's `missingRunCapability` line, pinned in the integration test. Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD Co-authored-by: Claude <noreply@anthropic.com>
…cancelled From #38293 on, every request a delete voids carries `cancel_reason: record_deleted`, including those whose run was cancelled in the same step, so the guide says to cancel by hand only a run that is still `suspended`. (Contract review 7238666618.) Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA Contract reviewServed-tier: This is a delta review against the round-1 record 7238672789 (FAIL at Inputs read:
Everything outside the delta stands as judged in round 1. ① Derived judgments
② Semver level
③ Boundary flagsM1: closed —
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — ACCEPT · head e103c2e · card #37763 · area s2-ai · 2026-11-28T12:10ZL1 checklist
Tier: M. Landing: ready and auto-merge in this stroke. |
…tack-ai#38295) <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu39QwNEMYYq9N1C1xLDGdAJ)_ Fixes objectstack-ai#37763 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:写流程的开发者(和帮他写的 AI)在审批技能和审批指南里读到:单据在等审批时被删掉,等它的流程运行会被取消,批准、驳回两条后续都不走;要在删除时做事,写在单据的删除钩子上。指南还写明子流程、批量的情形,以及管理员如何找到此前遗留的暂停运行并手动取消。 - 为什么做:维护者在这张卡上选了「自动取消」,代码改动在另一个 PR;技能和指南此前没说删除后流程会怎样。 - 出错会怎样:只改说明文字,不改行为;技能页仍在字数上限内,新增的话由同页压缩旧措辞抵付,没有删规则。可直接撤回。 - 要你做什么:这个 PR 碰 `skills/**`,属受治理路径,需你审批合并;请在代码 PR objectstack-ai#38293 合入后再合,免得文档先于行为。 ## What changes - `skills/objectstack-automation/references/state-machines-and-approvals.md`, Approval Best Practices item 2: deleting the pending record now also cancels its parked run; neither `approve` nor `reject` runs, so a delete-time action goes in the record's delete hook. The page is at its token ceiling (headroom 0); the clause is paid for on the same page by cutting restatements, no rule dropped: - "exactly **three roots** — nothing else" drops "nothing else"; - "guard genuinely-optional inputs explicitly" is "guard optional inputs"; - item 2's "the child object declares" is "the child declares"; - item 3's prohibition is one clause ("⛔ a `notify` node there tells them twice"); - item 4 is compressed. Two rewordings there are worth a look: "a `runAs: 'user'` flow fired by one has its data steps refused" now reads "and refuse a `runAs: 'user'` flow's data steps" (the two transitions as subject), and "runs with the decider's own grants" reads "with that person's grants" (which also covers the submitter on submit). - `content/docs/automation/approvals.mdx`, the paragraph on deleting a pending record: two sentences. The flow run waiting on the request is cancelled for the same reason, so neither branch runs; inside `subflow` steps on the same record every run up the chain is cancelled; a batch (`map`) item's batch goes on to its next item and records the deleted one as cancelled. Runs left paused by earlier deletes are not cleaned up: find them by the cancelled request whose `cancel_reason` is `record_deleted`, which names its run in `flow_run_id`, and cancel that run by hand if it is still `paused`: requests voided by a delete after objectstack-ai#38293 carry the same reason, and their runs already show `cancelled` (half-sentence added at `4d8dea85` per contract review 7238666618 ③; `paused` per 7238784724 at `4fdcc1aa`). - Changeset: `.changeset/37763-skills-delete-cancels-parked-run.md`, `@objectstack/skills` patch (a `skills/**` change releases that package). ## Why Maintainer ruling on objectstack-ai#37763, option A (card comment 7237973760): a record delete cancels the run parked on the approval it voids. The behaviour lands in objectstack-ai#38293, which only refers to the card (this PR is the one that closes it); the ruling's landing names one sentence in the approvals skill (paid for on the same page) and one in the approvals guide, which unlocks the card's second checkbox. The guide's addition is two sentences: subflow, batch and the hand clean-up of earlier runs did not fit one. ## Verification - Token ratchet: `state-machines-and-approvals.md` 5927 before, 5927 after (ceiling 5927); bytes 23706 → 23706; lines 388 → 388; whole skills bundle 303542 → 303542. Ceiling and baseline untouched. - Wording checked against the shipped code in objectstack-ai#38293 (`cancelForDeletedRecord`, `cancelRunsOfVoidedRequest`): the run's cancel reason is a sentence, not `record_deleted`, so the guide says "for the same reason" and keeps `record_deleted` for the request's `cancel_reason`. <details><summary>Local runs</summary> Head `4fdcc1aa` (base `main` `216524a2`); `4d8dea85` and `4fdcc1aa` touch only `content/docs/automation/approvals.mdx`, the skill page and its tokens are as at `8001d106`. Written by an isolated sub-agent served at the contract-review tier for every turn (`verify-review-tier.mjs` on its transcript: PASS). - `node scripts/pm/dispatch-gates.mjs --commands` (derived before the changeset commit): 62 families; 58 exit 0 (5 of them after building `@objectstack/lint...` and `@objectstack/client-react...`, their prerequisite), 4 NOT MEASURED, exit 3, needing a whole-repo build: `check:dts-closure`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`, `check:sourcemap-no-sources-content` (they read package dists; this diff touches none). `check:skill-docs`, `check:skill-refs`, `check-skills-token-ratchet.mjs` and its `--self-test` exit 0. The changeset-only families are left to CI. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. (none added) - [x] 3. No formatter ran. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. (branch `claude/project-thread-sz9xxz-skills`; the code half is objectstack-ai#38293 on `claude/project-thread-sz9xxz`) - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: no. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is the maintainer summary). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD <!-- signed: repo:objectstack#2 · os-sales · session_01L6bhgUpmvWke9Z2P4VKvaD --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Sales · project thread
Refs #37763
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
packages/plugins/plugin-approvals/src/approval-service.tscancelForDeletedRecord: after voiding every pending request of the deleted record (unchanged), it ends the run each request gated through the new privatecancelRunsOfVoidedRequest. It answers a newcancelledRunslist (a new member of a public method's answer on the exportedApprovalService, henceClause-②: yes (widening));suspendedRunskeeps its meaning, the runs left behind, which are now only the runs that could not be cancelled, and the warning fires only for those. With nocancelRunon the engine it logs aterrorin the delete's own words (not the decision door'smissingRunCapabilityline) and the run is left.cancelRunsOfVoidedRequest: cancels the request's run with the reasonapproval request ID was cancelled because the record it is about was deleted, then everysubflowparent above it on the same record, deepest first, through the engine's existingcancelRun. If the top of that chain is amapitem, the batch above it is read first (batchAboveItem, as the revise-window recall does) and woken afterwards through the existingresumeBatchOfRecalledItem, which now takes acauseso its log and message say which of the two cancelled the item. ⛔ No resume is ever sent to asubflowparent; neither theapprovenor therejectbranch runs.voidedRunChain: finds the chain with existing reads only. The request row'srecord_run_id(ADR-0162 Execution item 7) is the highest run over the same record; the walk goes down from it along each parent's correlation (subflow:CHILD,map:CHILD) throughsuspensionOf, one keyed read per hop, until it reaches the request'sflow_run_id, and cuts the chain below its lowestmap:link (a batch is woken, never ended). Bounded at 32 hops.cancelForDeletedRecord,REQUEST_STATUS_STRANDABILITYandApprovalResumeSurface.suspensionOfupdated to the ruling.record-delete-cancel.integration.test.tsis rewritten to the ruling, plus a failed-cancel case; the real-engine cases are a new top-leveldescribeinbatch-item-recall-resumes-batch.test.ts(the shared harness for a cancelled batch item)..changeset/approval-delete-cancels-parked-run.md,@objectstack/plugin-approvalspatch, which also says how an administrator finds the runs left paused by earlier deletes.⛔ Not changed:
service-automation(no engine member added,run-resume.tsuntouched),packages/spec, the delete hook inlifecycle-hooks.ts(it already callscancelForDeletedRecordand swallows its failures).Why
Maintainer ruling on #37763, option A (card comment 7237973760): the run parked on a request its record's delete voided is cancelled in the same step, end state
cancelled, reason the delete; neither branch runs; the delete is never refused and a failed cancel never fails it; a batch item wakes its batch (as PR #28228 does for a revise-window recall); inside a subflow the parent chain is cancelled too, never resumed; runs parked by earlier deletes are not cleaned up.The ruling's three premises, measured before writing
Probe: real
AutomationEngine+ realApprovalServiceover the fake engine ofbatch-item-recall-resumes-batch.test.ts, in-memory suspended-run store, onmainf19350b4. Probe file and its output are kept outside the repo (the project's shared folder,37763/probe-37763.test.tsandprobe-37763-readings.txt); 5/5 passed.cancelRunon a run parked at an approval node succeeds and leaves no other statetrue; historycancelledwith the reason aserror; nothing parked;hasSuspendedRunfalse;inspectConsumedSuspensionanswersNO_CONSUMED_SUSPENSION; a second call answersfalse; the request row untouched (cancelled/record_deleted). Onmainthe run stays parked after the delete.batchAboveItembefore,cancelRunon the item,resumeBatchOfRecalledItemafter: no error, item 2's request opens; after approving it the batch completes, its reader ran once.subflownode onsubflow:CHILD. The parent is reachable with existing surfaces:record_run_idnames the top of the chain andsuspensionOfnames each child; a three-level chain was cancelled deepest first with all threecancelledand nothing run after the subflow; a batch item that runs its sign-off in a subflow was cancelled as a chain and the batch moved on. No new contract surface.Small decisions taken in the thread (listed for review):
map:link, so a batch whose items carry no record of their own is woken, not cancelled (the ruling's batch rule, read literally).record_run_id(opened before requests recorded it, or on an engine that hands no record run) cancels only its own run and logs nothing: that is also every flat run on such an engine, where a warning would be noise (seat ruling on review finding S1). An engine withoutsuspensionOf, or a walk that does not reach the request's run, cancels the request's own run alone and warns that a run above it may stay parked.cancelRunthat throws stops the chain there: that run and the runs above it are logged aterror(as the revise-window recall's failed cancel is) and named in the summarywarn. Afalseanswer (no suspension under that id, or a store the engine could not read, which the engine names aterroritself) does not stop the chain.Verification
batch-item-recall-resumes-batch.test.ts, newdescribe('a record delete cancels the run its voided request gated (#37763)'), 7 cases: a flat run (cancelled with the reason, neither branch's node ran, nothing parked, no log); a batch item (cancelled marker in its slot, outsidecount, next item opens, batch completes); a three-level subflow chain (cancelled deepest first, every reason the delete,resumenever called, nothing after the subflow ran); a batch item whose sign-off is in a subflow; a request with norecord_run_id(own run cancelled, no log); asuspensionOfthat throws; acancelRunthat throws.record-delete-cancel.integration.test.ts(real ObjectQL + SQLite, the real delete hook): the "runs no flow node" pin now asserts onecancelRun('run_1', reason), noresume, no left-behind warning; two new cases:cancelRunrejects, the delete lands, the request iscancelled, the run is named in the warning; and an engine with nocancelRun, where the delete lands and the run is named in the delete's ownerrorline and in the warning.approval-service.tsrestored tomain, 8 of the new or rewritten cases fail (all 7 above, and the rewritten pin); restored to the head (git hash-objectequal toHEAD), all pass.Local runs
Head
e103c2e0(basemainf19350b4;e103c2e0is the review fix on top of948f4494; the 9 commitsmaingained since touch none ofplugin-approvals,service-automationorobjectql).pnpm --filter @objectstack/plugin-approvals test(whole package, under the verify lock): 131 files, 1988 tests passed, 0 failed (at the head; 1987 at948f4494).pnpm --filter @objectstack/plugin-approvals typecheck: exit 0.npx eslinton the four changed source and test files: exit 0.approval-service.tsatmain; 29/29 at948f4494; the two touched files 30/30 at the head.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE(exit codes recorded before any pipe): 72 derived, 69 run, 3 NOT-MEASURED, 0 UNRUN, every run family exit 0 (at948f4494; the review fix touches the same four files and re-ran the package suite, typecheck and eslint). NOT MEASURED (exit 3, prerequisite not met):check-plugin-teardown-shape.mjs --self-test(its fixture commit is outside this shallow clone),check:dual-build-cjs-loadsandcheck:i18n(they read dists of packages not built in this container; only theplugin-approvalsclosure is).Acceptance notes
returned(in a revision window) is outside the ruling: onlypendingrequests are voided by a delete, so that run is untouched, as before.skills/**is Tier H); that one is the PR that finishes the card, so this one only refers to it.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintwas not run locally; CI runs it).main, one pull request. (branchclaude/project-thread-sz9xxzis the harness-assigned name)packages/spectouched: no.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD