Skip to content

Commit baa38c0

Browse files
docs(approvals): a record delete cancels the parked flow run (#38295)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu39QwNEMYYq9N1C1xLDGdAJ)_ Fixes #37763 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:写流程的开发者(和帮他写的 AI)在审批技能和审批指南里读到:单据在等审批时被删掉,等它的流程运行会被取消,批准、驳回两条后续都不走;要在删除时做事,写在单据的删除钩子上。指南还写明子流程、批量的情形,以及管理员如何找到此前遗留的暂停运行并手动取消。 - 为什么做:维护者在这张卡上选了「自动取消」,代码改动在另一个 PR;技能和指南此前没说删除后流程会怎样。 - 出错会怎样:只改说明文字,不改行为;技能页仍在字数上限内,新增的话由同页压缩旧措辞抵付,没有删规则。可直接撤回。 - 要你做什么:这个 PR 碰 `skills/**`,属受治理路径,需你审批合并;请在代码 PR #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 #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 #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 #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>
1 parent 326f9db commit baa38c0

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the approvals reference says what a deleted pending record leaves of its parked flow run
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- `skills/objectstack-automation/references/state-machines-and-approvals.md`, Approval Best Practices item 2: deleting the pending record now also cancels its parked run, and neither the `approve` nor the `reject` branch runs, so an action that must happen on the delete belongs in the record's delete hook.
11+
- Paid for on the same page by cutting restatements, with no rule dropped: "three roots — nothing else" drops "nothing else", "genuinely-optional inputs explicitly" is "optional inputs", "the child object" is "the child", item 3's prohibition is one clause, and item 4 is compressed. The file stays at its token ceiling (5927 of 5927).

‎content/docs/automation/approvals.mdx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,17 @@ the run that opened the request still write the lines. Children joined by a plai
418418
**Deleting the record while it is pending** is not refused: the delete lands and
419419
its pending request is cancelled (`status: 'cancelled'`, with `cancel_reason` on
420420
the row), and the request's timeline says so in a system note, in the reader's
421-
language. The delete removes the record's `master_detail` lines with it. In the
421+
language. The flow run that was waiting on that request is cancelled for the same
422+
reason, so neither the `approve` nor the `reject` branch runs: when the approval
423+
sits inside `subflow` steps on the same record, every run up that chain is
424+
cancelled too, and when the run is one item of a batch (`map`), the batch goes on
425+
to its next item and records the deleted one as cancelled. Runs left paused by
426+
deletes made before this release are not cleaned up automatically: find them by
427+
the cancelled request whose `cancel_reason` is `record_deleted`, which names its
428+
run in `flow_run_id`, and cancel that run by hand if it is still `paused`
429+
(requests voided by a delete after this release carry the same reason, and
430+
their runs already show `cancelled`). The delete removes the record's
431+
`master_detail` lines with it. In the
422432
cases below the server refuses the whole delete with `409 RECORD_LOCKED` instead, and
423433
the record, its lines and its pending request all stay:
424434

‎skills/objectstack-automation/references/state-machines-and-approvals.md‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ environment-wide (`ambiguous-in-environment`).
238238
### Dynamic approvers (`type: 'expression'`)
239239

240240
An `expression` approver computes WHO approves at the moment the node is
241-
entered. Its CEL source sees exactly **three roots** — nothing else:
241+
entered. Its CEL source sees exactly **three roots**:
242242

243243
| Root | Meaning |
244244
|:-----|:--------|
@@ -252,7 +252,7 @@ say which time you mean, `current.x` or `trigger.x`.
252252
Result contract: a user-id string, a CSV string, or an array of ids. An **empty**
253253
result (present-but-empty field/variable) triggers `onEmptyApprovers`. A
254254
**missing** key (`vars.never_written`) is a loud error, never a silent empty
255-
slate — guard genuinely-optional inputs explicitly, e.g.
255+
slate — guard optional inputs, e.g.
256256
`has(vars.picked) ? vars.picked : []`.
257257

258258
```typescript
@@ -370,19 +370,19 @@ These are wired on the **graph**, not in node config:
370370
the record and its `master_detail` child rows only: a `lookup` child shown
371371
in the record's details (`relatedList: 'primary'`) stays editable (warning
372372
`approval-detail-editable-while-pending`). Deleting the pending record
373-
still lands, cancelling the request and cascading its `master_detail` rows;
374-
it is refused (`409 RECORD_LOCKED`) where the cascade lacks one transaction
375-
or the child object declares a second cascading relation.
373+
still lands, cancelling the request and its parked run — neither `approve`
374+
nor `reject` runs, so a delete-time action goes in the record's delete
375+
hook — and cascading its `master_detail` rows; it is refused
376+
(`409 RECORD_LOCKED`) where the cascade lacks one transaction or the child
377+
declares a second cascading relation.
376378
3. **Notify the submitter from downstream nodes** wired to the `approve` /
377379
`reject` edges. Opening already tells each resolved approver
378-
(`approval.requested`); ⛔ no `notify` node for the opening: it tells
379-
them twice.
380+
(`approval.requested`): ⛔ a `notify` node there tells them twice.
380381
4. **A flow reacting to the mirrored status runs as the person who acted.**
381382
The `approvalStatusField` write is elevated but attributed — submit carries
382-
the submitter, approve / reject / recall / send-back the person who decided —
383-
so a `record_change` flow on that field stays `runAs: 'user'` and runs
384-
with the decider's own grants. Only the
385-
two machine-driven transitions carry no user — an SLA `escalation`
386-
auto-decision and the release of a record whose run died — and a
387-
`runAs: 'user'` flow fired by one has its data steps refused: a flow that
388-
must react to those too declares `runAs: 'system'`.
383+
the submitter, approve / reject / recall / send-back the decider — so a
384+
`record_change` flow on that field stays `runAs: 'user'`, with that person's
385+
grants. Only two machine-driven transitions carry no user — an SLA
386+
`escalation` auto-decision and the release of a record whose run died —
387+
and refuse a `runAs: 'user'` flow's data steps: to react to those too,
388+
declare `runAs: 'system'`.

0 commit comments

Comments
 (0)