Repository navigation
Commit fca72df
docs(skills): teach the fault edge on a write after an approval decision and the RESUME_FAILED refusal members (#35002)
Fixes #34637
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:自动化技能的审批参考新增一条:审批通过或拒绝之后的「改记录」步骤,如果可能被记录钩子、校验规则或权限拒绝,就从这一步画一条
fault 边到处理节点,拒绝走这条边,审批照常返回;不画时审批接口回 500 `RESUME_FAILED`,决定照旧生效,错误体带
`innerRefusal` 和 `userMessage`。另加一条评测用例。
- 为什么改:技能不教,AI 写审批流程时不会画这条边,钩子一拒绝流程就卡住,审批人只看到 500。
- 风险与回滚:只动技能文字和评测,不动运行时。为了不抬 token 上限,同一文件删了四处重复内容,每处都另有出处。回滚就是 revert 本
PR。
- 先看:①
`skills/objectstack-automation/references/state-machines-and-approvals.md`
里 Branching 一节新增的那一条,以及同文件被删的四处;②
`skills/objectstack-automation/evals/approval-fault-edge.json`;③
`.changeset/34637-approval-fault-edge-skill.md`。
- 两分钟验证:跑 `node scripts/check-skills-token-ratchet.mjs`,预期这份参考文件一行读作
`5913 tokens (ceiling 5916; headroom 3)`,末行是 ✓。
- 需要你做的:审批本 PR(受管面 `skills/**`)。
> **Review round (supersedes the readings below where they differ).**
Contract review 7009057594 on fcf9e05: PASS with S1 should-fix. Head
c242d97 merges origin/main 819c067. S1: the eval prompt now ends
"None of the project's files are in this directory: write the flow as a
TypeScript `defineFlow` in your answer." N1: the reference reads "the
body may carry `innerRefusal` … and `userMessage`". N3: the changeset
points to the list item that names the `e1` edge. N2 left. Budget on the
merged tree: `state-machines-and-approvals.md` 5933 / 5936 tokens (388
lines, 23732 bytes). The eval case is unmeasured with the new prompt (no
live round, by order). Gates: 48 derived, 46 exit 0, 2 not measured
locally (CI runs them); overlap clean. The page teaches that a
permission refusal on a post-decision write routes down a `fault` edge,
so the PR carries `security`.
## What changes
`skills/objectstack-automation/references/state-machines-and-approvals.md`,
section *Branching, side-effects & rejection*, gains one bullet. It
teaches the two points the card orders, in the wording of the merged
approvals docs callout and the `ApprovalDecisionResult.resumed`
docblock:
1. When a step on the `approve` / `reject` branch writes a record that a
record hook, a validation rule or a permission may refuse, draw a
`fault` edge from that step to a handler. The refusal takes that edge
and the decision answers normally.
2. Without the edge, `POST …/approve` (or `/reject`) answers `500
RESUME_FAILED`. The decision stands (`finalized: true`), the run is
stranded, and the body carries `innerRefusal` (`{ code, message }`) and
`userMessage`, the hook's declared sentence to show the approver.
The bullet points to SKILL.md, section *Failure routing*, for the edge
shape, so the shape is not restated.
One eval case is added in a new file,
`skills/objectstack-automation/evals/approval-fault-edge.json`: an
approval flow whose step after the decision updates a record guarded by
a refusing `beforeUpdate` hook. It is graded on the approval node, the
`approve` out-edge, the `update_record` step and the `type: 'fault'`
edge.
A `@objectstack/skills` patch changeset is included, because `skills/**`
ships in that package.
### The status code, checked against the merged code and the ruling
The card says "status 500 per the standing ruling". The merged code
answers the same:
- `packages/rest/src/approvals-routes.ts` maps the `RESUME_FAILED`
prefix to status 500 and spreads the recognised stranded-decision
envelope into the body.
- `packages/rest/src/rest-approvals-wire-codes.test.ts` pins status 500
and the exact body key set `code`, `decision`, `error`, `finalized`,
`innerRefusal`, `repairable`, `runId`, `userMessage`.
-
`packages/plugins/plugin-approvals/src/hook-refusal-after-decision.test.ts`
pins both halves: no fault edge gives `RESUME_FAILED` with the two
members, and a fault edge on the step gives `finalized: true, resumed:
true` with nothing left parked.
The ruling the code cites is the maintainer ruling of 2026-09-04,
decision batch #37, option 1B, recorded in comment 5541861039 on issue
#13807. From that record: "`POST …/reject` (and the sibling decision
doors on the same path) **keeps its status code** — the 500-class
`RESUME_FAILED` — and stops discarding what the engine said". The record
gives the maintainer's word as verbatim 「同意」 on the presented
recommendation `1B · 2及`. The approvals docs page states the 500 and
cites no ruling id of its own; the id is in the code comments
(`approvals-routes.ts`, `packages/types/src/stranded-decision.ts`).
### Scope fence
Only the decision doors' thrown `RESUME_FAILED` envelope is taught, as
merged by PR #34619. The text names `POST …/approve` and `/reject`. It
does not mention `resumeFailure`, the recall door or the subflow-parent
strand, and it does not say those answers carry the pair.
### Budget
The reference file was at 5916 tokens against a ceiling of 5916,
headroom 0. No ceiling moves. The new bullet is paid for by deleting
content. Four restatements were cut, each keeping another home:
| Cut | Bytes | Where the content still lives |
|:--|--:|:--|
| The text diagram in *Send-back for revision* | 261 | The paragraph
directly above it and the snippet below it trace the same path |
| Bullet "Conditional step" | 119 | The discount-approval example: the
`needs_director` decision node and the comment on edge `e1` |
| Bullet "Send back for revision (ADR-0044)", a pointer | 80 | The
section it pointed to, in the same file |
| Bullet "Hard reject" | 64 | The examples' `reject` edges into an `end`
node (`e3`, `e7`) |
The cuts remove 524 bytes and the new bullet adds 515, so the file is 9
bytes smaller. None of the four is a re-wrap: each removes text.
| Reading | Before (`fff0ad0c18`) | After (`fcf9e05cbe`) |
|:--|--:|--:|
| `state-machines-and-approvals.md`, lines | 412 | 408 (net -4; budget
was at most +10) |
| `state-machines-and-approvals.md`, bytes | 23661 | 23652 |
| `state-machines-and-approvals.md`, tokens / ceiling | 5916 / 5916 |
5913 / 5916 |
| All 12 `SKILL.md` files, lines summed | 4728 | 4728 |
| All 12 `SKILL.md` files, bytes summed | 246476 | 246476 |
| Ratcheted authored total, tokens / ceiling sum | 191126 / 196699 |
191123 / 196699 |
| `evals/approval-fault-edge.json` (eval fixture, not ratcheted), tokens
| absent | 388 |
No `SKILL.md` is touched. `skills/objectstack-automation/SKILL.md` stays
at 6903 / 6903.
## Tests
No package source changes, so no package test suite is owed. What ran,
at head `fcf9e05cbe`:
- `pnpm --filter @objectstack/skills build` under the shared verify
lock: `VERDICT command-exit 0`; "99 file(s) across 12 skill(s) copied
from skills/** into dist/skills and read back byte-identical".
- The new eval case, by hand. The `skill-evals` runner has no
single-case selector, so five turns of this one case were run with the
runner's own argv from `packages/qa/scenarios/src/skill-evals/arms.ts`
(a fresh directory, the bundle copied without `evals/` on the with-skill
arm, an empty directory on the no-skill arm) and graded by literal
substring as `grade.ts` does. This is a hand replication, not a runner
round, and no round record was filed.
| Turn | Arm | Reference text it read | Verdict under the final tokens |
|:--|:--|:--|:--|
| ws1 | with-skill | first revision (`5fa36a038b`) | pass |
| ws2 | with-skill | final text | pass |
| ws3 | with-skill | final text | pass |
| ns1 | no-skill | none | fail: `label: 'approve'` missing, `type:
'role'` present |
| ns2 | no-skill | none | fail: `label: 'approve'` missing, `type:
'role'` present |
All three with-skill answers drew the `type: 'fault'` edge from the
`update_record` step, and all three said that without it the approve
call answers `500 RESUME_FAILED`. All three launched the skill and read
the reference file.
Stated limits: the token lists were settled after reading these answers,
so the five turns are not an independent test of the final lists. Two
things changed on the way. Both no-skill answers also wrote `type:
'fault'`, so the case now also requires `label: 'approve'` and forbids
`type: 'role'`. The first draft forbade `label: 'error'`, and one
with-skill answer that drew the fault edge correctly quoted that label
while explaining why it does not catch a failure, so that token was
dropped. The prompt was the same on all five turns.
## Acceptance notes
- The first eval draft appended a case to
`evals/flows-triggers-approvals.json`. `node
scripts/pm/overlap-check.mjs` then answered `VERDICT overlap exit 1`
against PR #34793, which appends its own case with the same `id: 24` at
the same position. The case moved to its own file and the shared file is
byte-identical to `main` again. The re-run answers `VERDICT clean exit
0` against `origin/main` (`44c7a4a415`) and 0 PR heads.
- The discount-approval example in the reference keeps its `mark_won`
step without a `fault` edge. The new rule is conditional (a write that
may be refused), and adding a handler node and two edges to the example
did not fit the budget. Noted, not changed.
- `ui/scripts/check-skill-eval-tokens.mjs` scans the bundle under
`ui/skills` only (1 bundle, 11 eval files), so it does not judge this
case. The four `must_contain` tokens were checked by hand as taught in
the bundle: `type: 'approval'` and `label: 'approve'` in the reference,
`update_record` in SKILL.md and the references, `type: 'fault'` in
SKILL.md. The forbidden token `type: 'role'` occurs nowhere in the
bundle.
- Case 5 of `evals/flows-triggers-approvals.json` forbids `label:
'error'` and has the same exposure measured above on a different prompt.
Noted, not filed.
## Verification
`node scripts/pm/dispatch-gates.mjs --commands` at `fcf9e05cbe` derived
47 commands (change set: 3 paths against merge base `fff0ad0c1`). All 47
ran at that head with the exit code captured before any pipe.
Reconciliation: `✓ dispatch-gates --ran: 47 derived famil(ies) accounted
for — 45 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).`
<details>
<summary>Gates that read the changed files</summary>
```text
node scripts/check-skills-token-ratchet.mjs :: exit 0
✓ check-skills-token-ratchet: skills/objectstack-automation/references/state-machines-and-approvals.md is 5913 tokens (ceiling 5916; headroom 3).
✓ check-skills-token-ratchet: skills/objectstack-automation/evals/approval-fault-edge.json is 388 tokens — eval fixture, measured but not ratcheted.
✓ check-skills-token-ratchet: 58 authored bundle file(s) within their ceilings; 10 generator-owned file(s) and 31 eval fixture(s) measured, not ratcheted.
node scripts/check-skills-token-ratchet.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:skill-refs :: exit 0
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
pnpm check:skill-links :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:skill-compatibility :: exit 0
pnpm check:skill-frame-sync :: exit 0
pnpm check:role-word :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
```
</details>
<details>
<summary>Not measured locally, and two partial readings</summary>
```text
pnpm check:dual-build-cjs-loads :: exit 3 PREREQUISITE NOT MET — this gate reads built output, and some package has no dist/.
pnpm check:lean-entry-closure :: exit 3 PREREQUISITE NOT MET — this gate loads BUILT entry points, and some target is absent
pnpm check:dts-closure :: exit 0 partial: "6 built package(s) swept"
pnpm check:sourcemap-no-sources-content :: exit 0 partial: "6 built package(s) swept"
```
The diff touches no package source, so no whole-workspace build is owed
locally. Only `@objectstack/formula`, `@objectstack/lint` and their
dependencies were built, to let the doc-formula gate run. These four are
whole-build readers and are left to CI.
</details>
The remaining 28 derived commands are self-tests and whole-tree gates;
each exited 0.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No schema touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is left to CI (no code file
changed).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [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: not touched.
- [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.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C)_
<!-- signed: repo:objectstack#4 · os-lizheng ·
session_012MmDsS4GoHCgYwA2uv3n3C -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0d9d982 commit fca72df
3 files changed
Lines changed: 41 additions & 11 deletions
File tree
- .changeset
- skills/objectstack-automation
- evals
- references
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | 133 | | |
141 | 134 | | |
142 | 135 | | |
| |||
362 | 355 | | |
363 | 356 | | |
364 | 357 | | |
365 | | - | |
366 | | - | |
367 | 358 | | |
368 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
369 | 367 | | |
370 | 368 | | |
371 | | - | |
372 | | - | |
373 | 369 | | |
374 | 370 | | |
375 | 371 | | |
| |||
0 commit comments