diff --git a/.changeset/34637-approval-fault-edge-skill.md b/.changeset/34637-approval-fault-edge-skill.md new file mode 100644 index 00000000000..3fde620a8ae --- /dev/null +++ b/.changeset/34637-approval-fault-edge-skill.md @@ -0,0 +1,12 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): `objectstack-automation` teaches the `fault` edge on a write after an approval decision, and what `RESUME_FAILED` carries without one + +Clause-②: no +Metadata-protocol: none + +`references/state-machines-and-approvals.md` § Branching, side-effects & rejection gains one bullet. When a step on the `approve` / `reject` branch writes a record that a record hook, a validation rule or a permission may refuse, the flow draws a `fault` edge from that step to a handler: the refusal takes that edge and the decision answers normally. Without the edge `POST …/approve` (or `/reject`) answers `500 RESUME_FAILED`: the decision stands (`finalized: true`), the run is stranded, and the body may carry `innerRefusal` (`{ code, message }`) and `userMessage`, the hook's declared sentence for the approver. One eval case covers it; its prompt asks for the flow as a TypeScript `defineFlow`. + +Paid in place, the token ceiling does not move. Four restatements were cut, each keeping another home: the send-back section's text diagram (the paragraph above it and the snippet below it trace the same path), and three bullets of § Branching: "Conditional step" (the discount-approval example's `needs_director` node and the list item above it that names the `e1` edge), the send-back pointer (the section it pointed to), and "Hard reject" (the examples' `reject` edges into an `end` node). diff --git a/skills/objectstack-automation/evals/approval-fault-edge.json b/skills/objectstack-automation/evals/approval-fault-edge.json new file mode 100644 index 00000000000..18d1cd94a00 --- /dev/null +++ b/skills/objectstack-automation/evals/approval-fault-edge.json @@ -0,0 +1,22 @@ +{ + "skill_name": "objectstack-automation", + "evals": [ + { + "id": 1, + "prompt": "Build a flow `mrp_plan_approval` on `purchase_plan`: when `status` becomes `submitted`, the planning manager approves or rejects, and on approve a step sets `status` to `adopted`. That object's `beforeUpdate` hook refuses the write when capacity is already taken. A refusal must send the plan back to its owner; the approver's click must not fail or leave the run stuck. None of the project's files are in this directory: write the flow as a TypeScript `defineFlow` in your answer.", + "expected_output": "A TypeScript `defineFlow`. An `approval` node (`type: 'approval'`, the planning manager as a `position` approver, not the deprecated `role` spelling) whose `label: 'approve'` edge enters an `update_record` step, and a `fault` edge from THAT step to a handler: `{ source: 'adopt_plan', target: 'bounce_back', type: 'fault' }`, the handler returning the plan to its owner (an `update_record` or a `notify`). The hook's refusal takes that edge, the decision answers normally and the run finishes. Without the edge `POST …/approve` answers `500 RESUME_FAILED`: the decision stands, the run is stranded, and the body may carry `innerRefusal` and `userMessage`, the hook's declared sentence. Not an ordinary edge labelled as an error (it traverses on success), and not the reject branch: the approver approved.", + "files": [], + "assertions": { + "must_contain": [ + "type: 'approval'", + "label: 'approve'", + "update_record", + "type: 'fault'" + ], + "must_not_contain": [ + "type: 'role'" + ] + } + } + ] +} diff --git a/skills/objectstack-automation/references/state-machines-and-approvals.md b/skills/objectstack-automation/references/state-machines-and-approvals.md index 709a08014be..825ace0e213 100644 --- a/skills/objectstack-automation/references/state-machines-and-approvals.md +++ b/skills/objectstack-automation/references/state-machines-and-approvals.md @@ -130,13 +130,6 @@ window*) where the record unlocks and the submitter reworks it, and an explicit *resubmit* re-enters the approval node over a **declared back-edge**, opening round N+1 with a fresh approver slate. -``` -approval ──approve──▶ … - ──reject───▶ … - ──revise───▶ approval_revise (record unlocked, submitter edits) - └──resubmit──[type:'back']──▶ approval (round N+1) -``` - Three pieces author it: 1. **`revise` out-edge** — a third branch label alongside `approve` / `reject`, @@ -362,14 +355,17 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data** These are wired on the **graph**, not in node config: -- **Conditional step** — put a `decision` node before the Approval node, or a - `condition` on the edge entering it. - **On approve / on reject** — wire downstream nodes (`update_record`, `http`, a `notify` node, …) to the `approve` / `reject` out-edge. +- **A write on that branch that may be refused** (a record hook, a validation + rule, a permission) — draw a `fault` edge from that step to a handler + (SKILL.md § Failure routing): the refusal takes it and the decision answers + normally. Without one, `POST …/approve` (or `/reject`) answers + `500 RESUME_FAILED`: the decision stands (`finalized: true`), the run is + stranded, and the body may carry `innerRefusal` (`{ code, message }`) and + `userMessage`, the hook's declared sentence for the approver. - **Roll back on reject** — route the `reject` edge as a **back-edge** to an earlier node so the submitter can revise. -- **Send back for revision (ADR-0044)** — see *Send-back for revision* above. -- **Hard reject** — route the `reject` edge to an `end` node. ### Approval Best Practices