Skip to content

docs(approvals): a record delete cancels the parked flow run - #38295

Merged
os-zhuang merged 4 commits into
mainfrom
claude/project-thread-sz9xxz-skills
Nov 28, 2026
Merged

os-zhuang merged 4 commits into
mainfrom
claude/project-thread-sz9xxz-skills

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #37763

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:写流程的开发者(和帮他写的 AI)在审批技能和审批指南里读到:单据在等审批时被删掉,等它的流程运行会被取消,批准、驳回两条后续都不走;要在删除时做事,写在单据的删除钩子上。指南还写明子流程、批量的情形,以及管理员如何找到此前遗留的暂停运行并手动取消。
  • 为什么做:维护者在这张卡上选了「自动取消」,代码改动在另一个 PR;技能和指南此前没说删除后流程会怎样。
  • 出错会怎样:只改说明文字,不改行为;技能页仍在字数上限内,新增的话由同页压缩旧措辞抵付,没有删规则。可直接撤回。
  • 要你做什么:这个 PR 碰 skills/**,属受治理路径,需你审批合并;请在代码 PR fix(approvals): a record delete cancels the flow run its voided approval gated #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 fix(approvals): a record delete cancels the flow run its voided approval gated #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 #37763, option A (card comment 7237973760): a record delete cancels the run parked on the approval it voids. The behaviour lands in #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 fix(approvals): a record delete cancels the flow run its voided approval gated #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.
Local runs

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.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind. (none added)
  • 3. No formatter ran.
  • 4. One issue, one branch off an up-to-date main, one pull request. (branch claude/project-thread-sz9xxz-skills; the code half is fix(approvals): a record delete cancels the flow run its voided approval gated #38293 on claude/project-thread-sz9xxz)
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: no.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is the maintainer summary).
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD

Deleting a record whose approval is still pending cancels the flow run
parked on that request, and neither the `approve` nor the `reject` branch
runs. The published automation skill and the approvals guide now say so.

- skills/objectstack-automation/references/state-machines-and-approvals.md,
  Approval Best Practices item 2: one clause teaches that the parked run is
  cancelled with the request and that a delete-time action belongs in the
  record's delete hook, not on a branch. Paid for on the same page by cutting
  restatements, with no rule dropped; the file stays at its token ceiling
  (5927 of 5927, 23706 bytes before and after, 388 lines before and after).
- content/docs/automation/approvals.mdx, "Deleting the record while it is
  pending": the run is cancelled, a `subflow` chain on the same record is
  cancelled with it, a batch (`map`) goes on to its next item, and runs left
  paused by earlier deletes are found through the cancelled request and
  cancelled by hand.

Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8001d106b25698f368372acf1980260704e767bd
Local-runs: none
Scope: skills/objectstack-automation/references/state-machines-and-approvals.md + none
Security-touching: yes

PR #38295 on card #37763, the teaching half of maintainer ruling 7237973760 (option A). Read: the card body and its three comments, the PR body, the three-file diff, the check-runs on this head, the skill page and skills/objectstack-automation/SKILL.md on main, and the tree of PR #38293 at 948f4494 (packages/plugins/plugin-approvals/src/approval-service.ts: cancelForDeletedRecord, cancelRunsOfVoidedRequest, voidedRunChain), which carries the behaviour the sentences describe.

Security-touching: yes is meant: the item 4 hunk rewords what the page teaches about runAs and whose grants a flow runs with. The teaching is unchanged (see ④), but the hunk is permission behaviour, so the low-risk arm does not apply.

① Derived judgments

② Semver level

.changeset/37763-skills-delete-cancels-parked-run.md: @objectstack/skills patch. The diff publishes reworded skill prose and nothing else in a package (content/docs/** ships in no package), so patch is the right level. Clause-②: no and Metadata-protocol: none are on both the PR body and the changeset, and are right: nothing is narrowed, no metadata key changes.

③ Boundary flags

  • Dev flag, "read the two item 4 rewordings": answered in ④ (N2); the teaching holds.
  • Dev flag, guide gets two sentences where the ruling's landing said one: accepted. The ruling itself requires the docs to say how to find the earlier runs (sub-question 2), and subflow plus batch do not fit one sentence. The guide is outside this record's scope (the lane seat's ACCEPT); read against fix(approvals): a record delete cancels the flow run its voided approval gated #38293 its sentences agree with the code. One observation for that ACCEPT, ungraded here: after fix(approvals): a record delete cancels the flow run its voided approval gated #38293 every delete-voided request carries cancel_reason: record_deleted, including those whose run was cancelled, so the finder also returns requests whose run is already ended; the sentence's subject ("runs left paused") carries the filter, but does not say it.
  • No open_questions on the card or PR.
  • SQL push-down: not applicable, no code in the diff.
  • Check-runs at this read (the gate verdicts): PR-body guards (claim · duplicate · Part-of · single-writer path) concluded FAILURE. Its three annotations: the card's newest Claim: comment has no parseable Branch: line (UNDETERMINED); fix(approvals): a record delete cancels the flow run its voided approval gated #38293 is read as already declaring the same issue; the branch name does not name the issue. None is a contract matter; all three are the seat's to clear before merge. ESCALATED to the seat.
  • Check-runs with NO conclusion at this read: Live E2E UI, Build Core, Build Docs, Plan Test Core shards, Type Check · consumer gates, Type Check · source gates, Type Check · debt ledger, Type Check · workspace, Lint · CI, release & engine gates, Lint · scoped · query-options erasure, Lint · scoped · tooling self-tests, Lint · repo & tooling gates, Lint · ESLint, Lint · PM dispatch-gates, Lint · docs & code guards, Check Changeset. The skills token ratchet (the PR's 5927 of 5927 claim) and the skill-docs / skill-refs gates are among the unconcluded lint runs, so that claim has no gate verdict yet and was not re-run here. This verdict is on the contract; the seat adopts it only once those runs conclude green.
  • Concluded success: Auto Label, Test UI, Dogfood Regression Gate, Lint · scoped · slot lookup & corpus, Spec property liveness, Check PR Size, Check Documentation Links, filter, Governed Surface Queue Guard. The rest concluded skipped.

④ Design judgment

skills/objectstack-automation/references/state-machines-and-approvals.md, the only hits file; no implementing file is in this diff.

The added clause (Approval Best Practices item 2), against #38293's tree:

  • "cancelling the request and its parked run": cancelForDeletedRecord voids every pending request, then cancelRunsOfVoidedRequest ends each request's run through the engine's cancelRun with the delete as the reason. Holds. A cancel that fails leaves the run parked and warns; the page teaches the designed outcome and need not carry the degraded one.
  • "neither approve nor reject runs": no resume is sent anywhere on this path except to a batch above the item, which records the item as cancelled. Holds, including inside a subflow chain (cancelled, never resumed).
  • "so a delete-time action goes in the record's delete hook": the same skill teaches beforeDelete / afterDelete and their flow triggers in SKILL.md § Trigger Types, so the pointer resolves inside the bundle. This is the sentence the card's business reason asks for (an author whose reject branch notifies or writes sees nothing on a mid-approval delete and is told why and where to put it). Holds.
  • The untouched rest of the sentence (cascade, the two 409 RECORD_LOCKED cases) still reads correctly around the inserted dashes.

The five paying cuts, each against what the page taught on main:

  • "three roots — nothing else" to "three roots": "exactly" stays, and the next paragraph still says record and bare field names fail the node. Nothing lost.
  • "guard genuinely-optional inputs explicitly" to "guard optional inputs": the has(...) example stays. Nothing lost.
  • "the child object declares" to "the child declares": same referent. Nothing lost.
  • Item 3 and item 4: the rules survive; see N1 and N2.

Tried to break: a second place in the bundle that still says the run stays parked (none: the delete of a pending record is taught only in item 2); a name the new clause uses that the bundle does not define (none); a rule silently dropped by a cut (none found).

No must-fix, no should-fix.

  • N1 (nit) — item 3 now reads "Opening already tells each resolved approver (approval.requested): ⛔ a notify node there tells them twice." "there" has to be read as "at the opening"; the only place the item names is the downstream approve / reject nodes of its first sentence. The colon and "them" (the approvers) carry the right reading, so the rule holds, but the old "no notify node for the opening" named its object. "for it" in place of "there" would restore that at the same length.
  • N2 (nit) — item 4 now makes the two machine-driven transitions the subject of "refuse a runAs: 'user' flow's data steps", and drops "fired by one". The item is about a flow reacting to the mirrored status, so the reading is the same and the instruction (runAs: 'system' to react to those too) is intact. "with that person's grants" is, if anything, more exact than "the decider's own grants", since on submit the person is the submitter.

Implemented-by: claude/project-thread-sz9xxz-skills
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA (isolated contract-review sub-agent)

VERDICT: PASS

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4d8dea85ee7abf8c783a7c8a36ccb733ecbc5a77
Local-runs: none
Scope: skills/objectstack-automation/references/state-machines-and-approvals.md + none
Security-touching: yes

Delta on record 7238666618 (PASS at 8001d106). Read: the compare 8001d106...4d8dea85 (one commit, one file, content/docs/automation/approvals.mdx, +3 −1), the PR's file list and labels, the check-runs on this head, PR #38293 at e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88 (its delta from 948f4494 and cancelRunsOfVoidedRequest there), and on main packages/spec/src/automation/execution.zod.ts and packages/services/service-automation/src/run-history.ts.

Security-touching: yes stands from the earlier record (the item 4 hunk); the security label is on the PR.

① Derived judgments

② Semver level

Unchanged: @objectstack/skills patch, Clause-②: no, Metadata-protocol: none. The delta adds docs prose only, which ships in no package. Right.

③ Boundary flags

  • The earlier record's ungraded guide observation is answered by the new half sentence; judged below at the seat's request (S1).
  • N1: accepted deviation (the seat's call: the page is at its ceiling and skills/** needs a tier writer).
  • N2: left as written, a nit with no effect on the teaching.
  • SQL push-down: not applicable, no code in the diff.
  • Check-runs on this head: none concluded failure. PR-body guards, failed on the earlier head, now concluded success (both runs), so that escalation is cleared.
  • NO conclusion at this read: Live E2E UI, Build Docs, Build Core, Plan Test Core shards, Check Changeset (both runs), Type Check · source gates, Type Check · consumer gates, Lint · docs & code guards, Lint · ESLint, Lint · CI, release & engine gates, Lint · repo & tooling gates. The skills token ratchet still has no gate verdict on either head (the page did not change, so the 5927 of 5927 claim is the same claim). The seat adopts only once these conclude green.
  • Concluded success: Test UI, Dogfood Regression Gate, filter, Auto Label, Type Check · debt ledger, Type Check · workspace, Lint · scoped · query-options erasure, Lint · scoped · slot lookup & corpus, Lint · scoped · tooling self-tests, Lint · PM dispatch-gates, Check PR Size, Spec property liveness, Check Documentation Links, Governed Surface Queue Guard. The rest concluded skipped.

④ Design judgment

skills/objectstack-automation/references/state-machines-and-approvals.md: unchanged since 8001d106; the earlier ④ holds whole. No implementing file is in the diff.

Scope widened to the one guide sentence the delta adds, as asked:

  • S1 (should-fix) — content/docs/automation/approvals.mdx, "cancel that run by hand if it is still suspended". A flow run has no suspended status. The published enum (ExecutionStatus in packages/spec/src/automation/execution.zod.ts) reads pending, running, paused, completed, failed, cancelled, …, and the run history lists a parked run as paused (run-history.ts, the ?status=paused filter). An administrator who looks for the literal in the code span finds no such run. The same paragraph already says "Runs left paused"; the span should read paused. The second half, "their runs already show cancelled", is right against fix(approvals): a record delete cancels the flow run its voided approval gated #38293 at e103c2e0 and the enum, and the logic of the addition (only a run still parked needs the hand cancel) is the right answer to the observation. One word, on the docs face, no token budget involved.

No must-fix.

Implemented-by: claude/project-thread-sz9xxz-skills
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA (isolated contract-review sub-agent)

VERDICT: PASS

Contract review 7238784724 S1: the ExecutionStatus enum and the run
history name a parked run `paused`.

Claude-Session: https://claude.ai/code/session_01L6bhgUpmvWke9Z2P4VKvaD
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4fdcc1aa013189bf4e241e6c1cb80f16b0d03854
Local-runs: none
Scope: skills/objectstack-automation/references/state-machines-and-approvals.md + none
Security-touching: yes

Delta on record 7238784724 (PASS at 4d8dea85, one finding open). Read: the compare 4d8dea85...4fdcc1aa (one commit, one file, content/docs/automation/approvals.mdx, +1 −1), the PR's file list and labels, the check-runs on this head, and PR #38293's head (still e103c2e0a384f5ddd1c2834fcf6b206e24a6ae88, open, not merged).

Security-touching: yes stands from the first record (the item 4 hunk of the skill page); the security label is on the PR.

① Derived judgments

② Semver level

Unchanged: @objectstack/skills patch, Clause-②: no, Metadata-protocol: none. The delta is docs prose, which ships in no package. Right.

③ Boundary flags

  • N1: accepted deviation.
  • N2: left as written, a nit.
  • SQL push-down: not applicable, no code in the diff.
  • Check-runs on this head: none concluded failure. One run of PR-body guards (claim · duplicate · Part-of · single-writer path) concluded cancelled (superseded); its second run has no conclusion yet.
  • NO conclusion at this read: Auto Label, PR-body guards (second run), Check Changeset (both runs), Lint · CI, release & engine gates, Lint · scoped · query-options erasure, Lint · scoped · tooling self-tests, Lint · scoped · slot lookup & corpus, Lint · PM dispatch-gates, Lint · ESLint, Lint · docs & code guards, Lint · repo & tooling gates, Type Check · consumer gates, Type Check · source gates, Type Check · debt ledger, Type Check · workspace, Spec property liveness. No Build Core, Build Docs, Test or E2E run was listed on this head yet. The skills token ratchet has had no gate verdict on any of the three heads; the page did not change, so it is the same 5927 of 5927 claim. The seat adopts only once these conclude green.
  • Concluded success: Check Documentation Links, Check PR Size, Governed Surface Queue Guard. The rest concluded skipped.

④ Design judgment

skills/objectstack-automation/references/state-machines-and-approvals.md: unchanged; the first record's ④ holds whole. No implementing file is in the diff.

The widened guide sentence, as it now stands: "cancel that run by hand if it is still paused (requests voided by a delete after this release carry the same reason, and their runs already show cancelled)". paused and cancelled are both members of ExecutionStatus (packages/spec/src/automation/execution.zod.ts on main), paused is what the run history lists a parked run under, and it matches "Runs left paused" at the head of the same sentence. Holds against #38293 at e103c2e0.

S1: closed — the code span now reads paused, the status a parked run carries.

No must-fix, no should-fix.

Implemented-by: claude/project-thread-sz9xxz-skills
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA (isolated contract-review sub-agent)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

席位核对 — ACCEPT · head 4fdcc1a · card #37763 · area s2-ai · 2026-11-28T12:12Z

L1 checklist

  • Shape and checks. Every check on the head is green apart from expected skips (33 success, 17 skipped; one earlier PR-body guards run cancelled and superseded by a green rerun); mergeable. The PR is a draft. It adds one sentence to Approval Best Practices item 2 of skills/objectstack-automation/references/state-machines-and-approvals.md, paid for by tightened phrasings on the same page (the page stays at its token ceiling, no ratchet row raised), adds sentences to the delete section of content/docs/automation/approvals.mdx, and one @objectstack/skills changeset.
  • Contract review at CONTRACT_REVIEW_TIER. Record 7238666618 is a PASS; delta 7238784724 raised S1 (the guide named a run status that does not exist) and delta 7238812521 on this head closes it and is a PASS. N1 is an accepted deviation; N2 stands as written. Their transcripts pass verify-review-tier; the seat adopts the record. The security label is on the PR because the paying rewrite touches the runAs teaching; the teaching is unchanged.
  • What changes for an author. The skill and the guide now teach what PR fix(approvals): a record delete cancels the flow run its voided approval gated #38293 does: deleting a record with an in-flight approval cancels the parked run, neither branch runs, and work owed on delete belongs in a delete hook. The guide says how to find runs parked before the fix (still paused) and cancel them by hand.
  • Order. The new sentences are true only on fix(approvals): a record delete cancels the flow run its voided approval gated #38293's tree: this PR merges after fix(approvals): a record delete cancels the flow run its voided approval gated #38293.
  • Declarations. Clause-②: no, Metadata-protocol: none, @objectstack/skills patch. Fixes #37763 is right.
  • Governance. skills/** is Tier H, so the maintainer's approval lands it. The skills text was written by an isolated fable sub-agent whose served tier the thread checked before push.

Tier: H. Landing: hand-off to the maintainer follows this record.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Tier H hand-off · 2026-11-28T12:14Z · head 4fdcc1a · approver os-zhuang

维护者速读

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 28, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 28, 2026 12:15
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit baa38c0 Nov 28, 2026
56 of 57 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-sz9xxz-skills branch November 28, 2026 12:59
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 28, 2026
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…val gated (objectstack-ai#38293)

<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu39QwNEMYYq9N1C1xLDGdAJ)_

Refs objectstack-ai#37763

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

## 维护者速读

-
用户能看到什么变化:单据在等审批时被删掉,等这条审批的流程运行现在当场结束,状态为「已取消」并写明原因是单据被删;批准、驳回两条后续都不走。审批套在子流程里时上层一并取消;批量审批里的一条被删,批量接着走下一条。
- 为什么做:维护者在这张卡上选了「自动取消」;此前这类运行永远停在「暂停」,和真在等人批的运行分不出来。
- 出错会怎样:取消失败不会让删除失败,那条运行照旧停着并在告警里点名,和今天一样;本 PR 之前留下的旧运行不自动清理。可直接撤回。
- 要你做什么:无。审批技能与审批指南各补的一句另开 PR(受治理路径,需你合并)。

## What changes

- `packages/plugins/plugin-approvals/src/approval-service.ts`
- `cancelForDeletedRecord`: after voiding every pending request of the
deleted record (unchanged), it ends the run each request gated through
the new private `cancelRunsOfVoidedRequest`. It answers a new
`cancelledRuns` list (a new member of a public method's answer on the
exported `ApprovalService`, hence `Clause-②: yes (widening)`);
`suspendedRuns` keeps 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 no `cancelRun` on the engine it logs at `error` in the
delete's own words (not the decision door's `missingRunCapability` line)
and the run is left.
- `cancelRunsOfVoidedRequest`: cancels the request's run with the reason
`approval request ID was cancelled because the record it is about was
deleted`, then every `subflow` parent above it on the same record,
deepest first, through the engine's existing `cancelRun`. If the top of
that chain is a `map` item, the batch above it is read first
(`batchAboveItem`, as the revise-window recall does) and woken
afterwards through the existing `resumeBatchOfRecalledItem`, which now
takes a `cause` so its log and message say which of the two cancelled
the item. ⛔ No resume is ever sent to a `subflow` parent; neither the
`approve` nor the `reject` branch runs.
- `voidedRunChain`: finds the chain with existing reads only. The
request row's `record_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`) through `suspensionOf`, one
keyed read per hop, until it reaches the request's `flow_run_id`, and
cuts the chain below its lowest `map:` link (a batch is woken, never
ended). Bounded at 32 hops.
- Docblocks of `cancelForDeletedRecord`, `REQUEST_STATUS_STRANDABILITY`
and `ApprovalResumeSurface.suspensionOf` updated to the ruling.
- Tests: the existing "must not cancel" pin in
`record-delete-cancel.integration.test.ts` is rewritten to the ruling,
plus a failed-cancel case; the real-engine cases are a new top-level
`describe` in `batch-item-recall-resumes-batch.test.ts` (the shared
harness for a cancelled batch item).
- Changeset: `.changeset/approval-delete-cancels-parked-run.md`,
`@objectstack/plugin-approvals` patch, which also says how an
administrator finds the runs left paused by earlier deletes.

⛔ Not changed: `service-automation` (no engine member added,
`run-resume.ts` untouched), `packages/spec`, the delete hook in
`lifecycle-hooks.ts` (it already calls `cancelForDeletedRecord` and
swallows its failures).

## Why

Maintainer ruling on objectstack-ai#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 objectstack-ai#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` + real `ApprovalService` over the fake
engine of `batch-item-recall-resumes-batch.test.ts`, in-memory
suspended-run store, on `main` `f19350b4`. Probe file and its output are
kept outside the repo (the project's shared folder,
`37763/probe-37763.test.ts` and `probe-37763-readings.txt`); 5/5 passed.

| premise | reading |
|:-|:-|
| ① `cancelRun` on a run parked at an approval node succeeds and leaves
no other state | `true`; history `cancelled` with the reason as `error`;
nothing parked; `hasSuspendedRun` false; `inspectConsumedSuspension`
answers `NO_CONSUMED_SUSPENSION`; a second call answers `false`; the
request row untouched (`cancelled` / `record_deleted`). On `main` the
run stays parked after the delete. |
| ② the existing wake-the-parent path moves a batch on |
`batchAboveItem` before, `cancelRun` on the item,
`resumeBatchOfRecalledItem` after: no error, item 2's request opens;
after approving it the batch completes, its reader ran once. |
| ③ inside a subflow the parent stays parked, and the existing cancel
suffices | Measured: after cancelling the child the parent stays parked
at the `subflow` node on `subflow:CHILD`. The parent is reachable with
existing surfaces: `record_run_id` names the top of the chain and
`suspensionOf` names each child; a three-level chain was cancelled
deepest first with all three `cancelled` and 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):

- The chain is cut below its lowest `map:` link, so a batch whose items
carry no record of their own is woken, not cancelled (the ruling's batch
rule, read literally).
- A request with no `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
without `suspensionOf`, 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.
- A `cancelRun` that throws stops the chain there: that run and the runs
above it are logged at `error` (as the revise-window recall's failed
cancel is) and named in the summary `warn`. A `false` answer (no
suspension under that id, or a store the engine could not read, which
the engine names at `error` itself) does not stop the chain.
- The runs are cancelled after every request of the record is voided, so
a failing cancel never leaves a later request in the inbox.

## Verification

- `batch-item-recall-resumes-batch.test.ts`, new `describe('a record
delete cancels the run its voided request gated (objectstack-ai#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, outside
`count`, next item opens, batch completes); a three-level subflow chain
(cancelled deepest first, every reason the delete, `resume` never
called, nothing after the subflow ran); a batch item whose sign-off is
in a subflow; a request with no `record_run_id` (own run cancelled, no
log); a `suspensionOf` that throws; a `cancelRun` that throws.
- `record-delete-cancel.integration.test.ts` (real ObjectQL + SQLite,
the real delete hook): the "runs no flow node" pin now asserts one
`cancelRun('run_1', reason)`, no `resume`, no left-behind warning; two
new cases: `cancelRun` rejects, the delete lands, the request is
`cancelled`, the run is named in the warning; and an engine with no
`cancelRun`, where the delete lands and the run is named in the delete's
own `error` line and in the warning.
- Reverse check: with `approval-service.ts` restored to `main`, 8 of the
new or rewritten cases fail (all 7 above, and the rewritten pin);
restored to the head (`git hash-object` equal to `HEAD`), all pass.

<details><summary>Local runs</summary>

Head `e103c2e0` (base `main` `f19350b4`; `e103c2e0` is the review fix on
top of `948f4494`; the 9 commits `main` gained since touch none of
`plugin-approvals`, `service-automation` or `objectql`).

- `pnpm --filter @objectstack/plugin-approvals test` (whole package,
under the verify lock): 131 files, 1988 tests passed, 0 failed (at the
head; 1987 at `948f4494`). `pnpm --filter @objectstack/plugin-approvals
typecheck`: exit 0.
- `npx eslint` on the four changed source and test files: exit 0.
- Reverse check above: 8 failed / 21 passed in the two touched test
files with `approval-service.ts` at `main`; 29/29 at `948f4494`; 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 (at `948f4494`; 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-loads` and
`check:i18n` (they read dists of packages not built in this container;
only the `plugin-approvals` closure is).

</details>

## Acceptance notes

- A record deleted while its request is `returned` (in a revision
window) is outside the ruling: only `pending` requests are voided by a
delete, so that run is untouched, as before.
- The approvals skill and the approvals guide gain one sentence each in
a separate PR, objectstack-ai#38295 (`skills/**` is Tier H); that one is the PR that
finishes the card, so this one only refers to it.

## 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.
- [x] 3. No formatter ran; eslint on the changed files passes (the full
`pnpm lint` was not run locally; CI runs it).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (branch `claude/project-thread-sz9xxz` is the harness-assigned
name)
- [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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation security size/s tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

review follow-ups of PR #37726: the approvals skill does not say what a deleted pending record leaves of its parked flow run

3 participants