Skip to content

Commit 270a105

Browse files
committed
docs(skills): the automation skill says a record under approval can still be deleted
Best practice 2 of the approvals reference now says a delete of a pending record lands, cancels the request and cascades its master_detail rows, and where it is refused instead. The lockRecord config row states its edit bound again, and the redundant field-group arm is dropped. The pending changeset of the earlier data-model wording is reworded to match what shipped. Every added token is paid for by deletion in the same file. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVUz5oS8fMgmncxU96
1 parent 80519b5 commit 270a105

3 files changed

Lines changed: 36 additions & 18 deletions

File tree

‎.changeset/37529-skills-data-model-publish-checks.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Metadata-protocol: none
99

1010
Published prose and evals only; the checks already run.
1111

12-
- `objectstack-data` `rules/relationships.md`: a roll-up whose child object has no `lookup` or `master_detail` field referencing the parent, or whose `relationshipField` is no field of the child, is refused at publish (`rollup/child-without-parent-reference`).
12+
- `objectstack-data` `rules/relationships.md`: a roll-up is refused at publish (`rollup/child-without-parent-reference`) when it omits `relationshipField` and the child object has no `lookup` or `master_detail` field referencing the parent, or when its `relationshipField` names no field of the child.
1313
- `objectstack-data` `rules/field-types.md`: only `lookup`, `master_detail`, `user` and `tree` read `reference`; on any other type but `summary`, publish refuses it (`field/reference-on-non-reference-type`).
14-
- `objectstack-automation` `references/state-machines-and-approvals.md`: `lockRecord` locks the record and its `master_detail` child rows only; a `lookup` child drawn as a body table stays editable while pending, reported as the warning `approval-detail-editable-while-pending`.
14+
- `objectstack-automation` `references/state-machines-and-approvals.md`: `lockRecord` locks the record and its `master_detail` child rows only; a `lookup` child shown in the record's details (`relatedList: 'primary'`) stays editable while pending, reported as the warning `approval-detail-editable-while-pending`.
1515

1616
No file grew past its ceiling: each addition is paid for by shorter wording in the same file.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the automation skill says a record under approval can still be deleted
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Published prose only; no behaviour changes.
11+
12+
`objectstack-automation` `references/state-machines-and-approvals.md`:
13+
14+
- Best practice 2 now says that deleting a record whose approval is pending is not refused: the delete lands, cancels the request and cascades the record's `master_detail` child rows. It is refused whole with `409 RECORD_LOCKED` only where that cascade has no single transaction to run in, or a child row has a second cascading parent.
15+
- The `lockRecord` config row states its bound again: it locks the record from edits.
16+
- Best practice 2 no longer names a parent field group as a way a `lookup` child is shown in the record's details: a group places a `lookup` child only when it already declares `relatedList: 'primary'`.
17+
18+
The file did not grow past its ceiling: each addition is paid for by deletion in the same file.

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fragments.
66

77
### State Machine — a `state_machine` validation rule (ADR-0020)
88

9-
Since **ADR-0020** there is **no `workflow` metadata type** and no
9+
There is **no `workflow` metadata type** and no
1010
`object.stateMachines` map. A record state machine is **one `state_machine`
1111
validation rule** in the object's `validations` array: a flat `field` +
1212
`{ from: [allowedTo] }` transition table. It is **enforced on the write path**:
@@ -33,7 +33,6 @@ const rule: StateMachineValidation = {
3333
};
3434
```
3535

36-
Notes:
3736
- **One rule per field.** Parallel lifecycles (`status` + `payment_status`)
3837
are separate `state_machine` rules.
3938
- **`initialStates`** gates INSERT: a record created in a state outside
@@ -61,7 +60,7 @@ Notes:
6160

6261
### Approvals (Flow Nodes)
6362

64-
Since **ADR-0019** there is no standalone approval-process type. An approval is
63+
There is no standalone approval-process type (ADR-0019). An approval is
6564
authored as an **Approval node** (`type: 'approval'`) on an ordinary flow — the
6665
run **suspends** when it reaches the node and **resumes** down the node's
6766
`approve` / `reject` out-edge once a decision is recorded. Multi-step review is
@@ -125,22 +124,20 @@ the same literal goes inside `defineFlow(...)`, and `` cel`…` `` builds each
125124

126125
**Send back for revision** is distinct from `reject` (terminate) and from a
127126
comment thread (the request stays pending).
128-
Send-back is a **flow movement**: the request finalizes as `returned`, the run
127+
It is a **flow movement**: the request finalizes as `returned`, the run
129128
walks a **`revise`** out-edge to an **`approval_revise`** node (the *revise
130129
window*) where the record unlocks and the submitter reworks it, and an explicit
131130
*resubmit* re-enters the approval node over a **declared back-edge**, opening
132131
round N+1 with a fresh approver slate.
133132

134-
Three pieces:
135-
136-
1. **`revise` out-edge** — a third branch label alongside `approve` / `reject`,
137-
targeting an **`approval_revise`** node. It must be that node type: the window
133+
1. **`revise` out-edge** — targets an **`approval_revise`** node. It must be
134+
that node type: the window
138135
is a *service-owned* pause (`resumeAuthority: 'service'`), ended only by
139136
`POST /api/v1/approvals/requests/:id/resubmit`; a `wait` is
140137
`resumeAuthority: 'any'`, so a raw run-resume would walk the back-edge
141-
unchecked. The node takes **no config** — there is no signal to wait on.
138+
unchecked. The node takes **no config**.
142139
2. **`type: 'back'` resubmit edge** — the edge from the revise window back into
143-
the approval node MUST be typed `'back'`. Only this
140+
the approval node MUST be typed `'back'`. This
144141
legalizes the cycle: `registerFlow` validates the graph **minus `back` edges**
145142
as a DAG, so an **unmarked** cycle is rejected. At
146143
run time a back-edge traverses normally.
@@ -173,7 +170,7 @@ A decision is recorded through `ApprovalService.decide()` (or the REST routes
173170
`POST /api/v1/approvals/requests/:id/approve` | `/reject`), a reject always
174171
with a non-blank `comment`, its reason (else `400 VALIDATION_ERROR`). That
175172
finalizes the `sys_approval_request` and **resumes** the suspended run down the
176-
matching branch — you never resume the flow by hand, and you *cannot*: the
173+
matching branch — you *cannot* resume the flow by hand: the
177174
`approval` node declares `resumeAuthority: 'service'`, so
178175
`POST /api/v1/automation/:name/runs/:runId/resume` answers **403** for a run
179176
parked on one (including via a `subflow` pause) and changes nothing.
@@ -339,7 +336,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data**
339336
| `approvers` | Who may act (≥ 1 — see Approver Types above). Each approver may carry an optional **`group`** label (e.g. `{ type: 'position', value: 'crm_auditor', group: 'finance' }`) — with `behavior: 'per_group'`, approvers sharing a label form one group; unlabelled approvers each form their own |
340337
| `behavior` | `first_response` (first approver decides), `unanimous` (all must approve), `quorum` (`minApprovals` of N — M-of-N collective sign-off), or `per_group` (EACH approver `group` must reach `minApprovals` — one-from-each-group sign-off). In every mode a single rejection finalizes the node as `rejected`. Default `first_response` |
341338
| `minApprovals` | Approvals required — total for `quorum`, per group for `per_group`. Omitted ⇒ ALL resolvable approvers under `quorum`, `1` per group; clamped at runtime so a misconfiguration can never deadlock |
342-
| `lockRecord` | Lock the record while pending. Default `true` |
339+
| `lockRecord` | Lock the record from edits while pending. Default `true` |
343340
| `approvalStatusField` | Business-object field to mirror `pending`/`approved`/`rejected`/`returned`/`recalled` onto (should be readonly) |
344341
| `onEmptyApprovers` | What an EMPTY resolved slate does: `admin_rescue` (default — request opens on the organization's administrators; never waves through, never kills the run), `fail` (node fails — treat an empty slate as a config bug), `auto_approve` (skip the request, continue down `approve` with `output.autoApproved = true` — opt-in because it silently waves the record through), `fallback` (request opens on the sibling `fallbackApprovers` instead — same shape as `approvers`, required by this policy and refused under any other; a fallback that itself resolves to nobody degrades to `admin_rescue`). Declare it explicitly on any node with an `expression` approver (linted) |
345342
| `excludeSubmitter` | `true` drops the run's submitter (`submitter_id`) from the resolved slate, whatever approver type produced them — segregation of duties; a slate it empties takes the `onEmptyApprovers` route, never a silent pass. `onEmptyApprovers: 'auto_approve'` is **refused** beside it (it would approve exactly the request this exists to stop): use `admin_rescue`, `fail` or `fallback`. Default `false` |
@@ -371,17 +368,20 @@ These are wired on the **graph**, not in node config:
371368
without joining `sys_approval_request`.
372369
2. **Keep `lockRecord: true`**, or approvers chase a moving target. It locks
373370
the record and its `master_detail` child rows only: a `lookup` child shown
374-
in the record's details (`relatedList: 'primary'`, or a parent field group)
375-
stays editable (warning `approval-detail-editable-while-pending`).
371+
in the record's details (`relatedList: 'primary'`) stays editable (warning
372+
`approval-detail-editable-while-pending`). Deleting the pending record
373+
still lands, cancelling the request and cascading those rows; it is refused
374+
whole (`409 RECORD_LOCKED`) where the cascade lacks one transaction or
375+
a row has a second cascading parent.
376376
3. **Notify the submitter from downstream nodes** wired to the `approve` /
377377
`reject` edges. Opening already tells each resolved approver
378378
(`approval.requested`); ⛔ no `notify` node for the opening: it tells
379379
them twice.
380380
4. **A flow reacting to the mirrored status runs as the person who acted.**
381381
The `approvalStatusField` write is elevated but attributed — submit carries
382382
the submitter, approve / reject / recall / send-back the person who decided —
383-
so a `record_change` flow on that field ("when the invoice is approved, do
384-
X") stays `runAs: 'user'` and runs with the decider's own grants. Only the
383+
so a `record_change` flow on that field stays `runAs: 'user'` and runs
384+
with the decider's own grants. Only the
385385
two machine-driven transitions carry no user — an SLA `escalation`
386386
auto-decision and the release of a record whose run died — and a
387387
`runAs: 'user'` flow fired by one has its data steps refused: a flow that

0 commit comments

Comments
 (0)