Repository navigation
Commit 8f49499
fix(approvals): a recall or subflow-parent strand reports the hook refusal that stranded the run (#34999)
Fixes #34638
Clause-②: yes
Metadata-protocol: none
## 维护者速读
- 改了什么:审批「撤回」这扇门,以及子流程把父流程卡住的那条路,以前在成功响应里用 `resumeFailure`
报告「运行卡住了」,但不带原因。现在 `resumeFailure` 带上 `innerRefusal`(拒绝码与原文)和
`userMessage`(钩子声明的、按发起该运行的人的语言给出的那句话;无人发起的运行给出原文),与决策门抛出的
`RESUME_FAILED` 用同样的字段名和形状。
- 为什么改:同一种「被钩子拒绝而卡住」,从决策门进来能看到原因,从撤回门或子流程进来却看不到,审批人只知道卡住、不知道为什么。
- 风险与回滚:只新增两个可选字段(拒绝时才出现,故障时不出现),`code` / `repairable` 的读法不变;是对已发布类型
`ResumeFailureReport` 的放宽(`Clause-②: yes`),落地前欠一次契约审核。回滚即 revert。
-
先看:`packages/spec/src/contracts/approval-service.ts`(`ResumeFailureReport`
两个新字段与文档块)、`packages/plugins/plugin-approvals/src/approval-service.ts`(撤回门与子流程父流程的填充点)、`packages/services/service-automation/src/engine.ts`(`takeSubflowParentStrand`
带回拒绝)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-approvals exec vitest run
src/resume-failure-refusal.test.ts`,预期全部通过。
- 需要你做的:无,席位落地;落地前席位路由一次契约审核(L2)。
## What changes
When an approval decision strands its flow run because the next step was
refused (a record hook's declared refusal, a validation rule, a
permission), the thrown `RESUME_FAILED` already carries `innerRefusal`
and the refusal's marked `userMessage` (#34579, PR #34619). Two doors
report a stranded run on a success answer instead, through
`resumeFailure`: the recall door, whose own resume stranded, and a
subflow parent that stranded after the run this door resumed advanced
(through `decide` and through `recall`). Those reports carried `code`,
`runId`, `status` and `repairable` only.
- `ResumeFailureReport`
(`packages/spec/src/contracts/approval-service.ts`) gains two optional
members, `innerRefusal` (`{ code, message }`, the engine's
`AutomationResult.innerRefusal`) and `userMessage`. The names and shapes
are the thrown `RESUME_FAILED`'s. `innerRefusal` is absent when the
strand met no refusal; `userMessage` can ride alone. Both are read the
way the thrown `RESUME_FAILED` reads them: an `innerRefusal` outside its
declared shape and a blank or non-string `userMessage` are dropped.
`userMessage` is in the run's locale (`AutomationContext.locale`, the
starter's). `ResumeFailureDetailsSchema` is unchanged: on the resume
door these members already ride the error envelope.
- `packages/services/service-automation/src/engine.ts`:
`takeSubflowParentStrand` returns the stranded parent's `innerRefusal` /
`userMessage` beside `runId`, `repairable` and `error`, read from the
parent's own result (`inner-refusal.ts` docblock kept true).
- `packages/plugins/plugin-approvals/src/approval-service.ts`: the
recall door's own strand, the batch resume's strand and the
subflow-parent sites (now built by one helper) fill both members when
the strand met a refusal. Both members are read once, through
`recognisedRefusal` (the spec `FlowInnerRefusalSchema` plus
`declaredUserMessage`), in `serviceResume` and `parentStrandReport` (L2
S2).
- `scripts/engine-double-contract.pinned.json`: the gate-required ledger
row for the new test's engine double.
## Tests
- `packages/plugins/plugin-approvals/src/resume-failure-refusal.test.ts`
(new): recall into a refusing hook, and the subflow-parent strand
through `decide` and `recall`, each carry `innerRefusal` and the marked
`userMessage`; a CONTROL strand that met no refusal carries neither
(absent, not empty).
-
`packages/services/service-automation/src/resume-failure-refusal.test.ts`
(new): the engine's subflow-parent strand carries the parent's refusal.
- `packages/spec/src/contracts/resume-failure-report.pin.test.ts`: the
type pin restated for the two optional members.
- `resume-failure-refusal.test.ts` (L2 round): a plugin node's malformed
pair (blank `userMessage`, unregistered code, non-string members)
reaches recall's `resumeFailure` without those members, on the own
strand and the parent strand; a well-formed pair rides whole (CONTROL).
- `batch-item-recall-resumes-batch.test.ts`: a refused batch resume
carries the pair (N3).
## Acceptance notes
- Opened by the seat on the maintainer's order (「#34638、#34756 由席位代开
PR」): the cloud dev session `session_012MmDsNmJFXm6DALa3xPdkp` pushed
this branch, and its own permission classifier refused its relay
`pr_create`. This body is the seat's, written from the pushed commits
and changeset.
- The dev's open question, where the pair is declared, goes to the
contract review: on `ResumeFailureReport` only (as pushed; the contracts
interface), or on `ResumeFailureDetailsSchema` (the shared zod schema).
The dev recommends the former, so nothing is declared that a channel
does not fill.
- Out of the claim's listed surface: `inner-refusal.ts` (a docblock in
the same package) and `scripts/engine-double-contract.pinned.json`
(written by the gate's `--write`).
## Verification
L2 fix round, final head 8c0b7ce (origin/main merged, no conflict),
under the shared verify lock: plugin-approvals 124/124 files, 1766/1766
tests; spec 855/855 files, 27365 passed + 1 todo; service-automation
289/289 files, 4184/4184 tests; all three typechecks exit 0. Ablations:
the `serviceResume` read reverted, 3 red (the malformed shapes on the
recall's own strand); the `parentStrandReport` read reverted, 3 red (the
parent strand); the batch arm's spread removed, 1 red (N3); CONTROL
green throughout, restore checked by hash. `dispatch-gates --commands`:
103 derived, 100 exit 0, 3 NOT MEASURED locally (need a full workspace
build; green in CI). Overlap-check clean. CI on 8c0b7ce: 58 success,
11 skipped, 0 failed.
Earlier round, superseded:
Reported by the dev at 9b417c9 (origin/main e9f65a3 merged in): spec,
service-automation and plugin-approvals typecheck exit 0;
plugin-approvals 123 / 123 files, 1731 / 1731 tests; service-automation
288 / 288 files, 4134 / 4134 tests; spec 848 / 848 files;
`dispatch-gates --commands` 103 derived, 103 run, all exit 0;
overlap-check clean. Ablations: the recall spread removed (2 red), the
pair removed from the parent-strand helper (4 red), the engine carry
removed (the engine pin red, and after a rebuild the approvals pins 4
red); controls held. CI on this PR is the seat's to read.
---
_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 e6e5224 commit 8f49499
10 files changed
Lines changed: 766 additions & 62 deletions
File tree
- .changeset
- packages
- plugins/plugin-approvals/src
- services/service-automation/src
- spec/src/contracts
- scripts
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
441 | 442 | | |
442 | 443 | | |
443 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
444 | 449 | | |
445 | | - | |
| 450 | + | |
446 | 451 | | |
447 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
448 | 456 | | |
449 | 457 | | |
450 | 458 | | |
| |||
5987 | 5995 | | |
5988 | 5996 | | |
5989 | 5997 | | |
5990 | | - | |
| 5998 | + | |
5991 | 5999 | | |
5992 | 6000 | | |
5993 | 6001 | | |
| |||
6005 | 6013 | | |
6006 | 6014 | | |
6007 | 6015 | | |
6008 | | - | |
6009 | | - | |
6010 | | - | |
6011 | | - | |
6012 | | - | |
6013 | | - | |
6014 | | - | |
6015 | | - | |
| 6016 | + | |
| 6017 | + | |
| 6018 | + | |
| 6019 | + | |
| 6020 | + | |
| 6021 | + | |
| 6022 | + | |
6016 | 6023 | | |
6017 | 6024 | | |
6018 | 6025 | | |
| |||
6046 | 6053 | | |
6047 | 6054 | | |
6048 | 6055 | | |
6049 | | - | |
| 6056 | + | |
| 6057 | + | |
6050 | 6058 | | |
6051 | 6059 | | |
6052 | 6060 | | |
6053 | 6061 | | |
6054 | 6062 | | |
| 6063 | + | |
| 6064 | + | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
| 6068 | + | |
| 6069 | + | |
| 6070 | + | |
| 6071 | + | |
| 6072 | + | |
| 6073 | + | |
| 6074 | + | |
| 6075 | + | |
| 6076 | + | |
| 6077 | + | |
| 6078 | + | |
| 6079 | + | |
| 6080 | + | |
| 6081 | + | |
| 6082 | + | |
| 6083 | + | |
| 6084 | + | |
| 6085 | + | |
| 6086 | + | |
| 6087 | + | |
| 6088 | + | |
| 6089 | + | |
| 6090 | + | |
| 6091 | + | |
| 6092 | + | |
| 6093 | + | |
| 6094 | + | |
| 6095 | + | |
| 6096 | + | |
| 6097 | + | |
| 6098 | + | |
| 6099 | + | |
| 6100 | + | |
| 6101 | + | |
| 6102 | + | |
| 6103 | + | |
| 6104 | + | |
| 6105 | + | |
| 6106 | + | |
| 6107 | + | |
| 6108 | + | |
| 6109 | + | |
| 6110 | + | |
6055 | 6111 | | |
6056 | 6112 | | |
6057 | 6113 | | |
| |||
6306 | 6362 | | |
6307 | 6363 | | |
6308 | 6364 | | |
6309 | | - | |
6310 | | - | |
6311 | | - | |
6312 | | - | |
6313 | | - | |
6314 | | - | |
| 6365 | + | |
6315 | 6366 | | |
6316 | 6367 | | |
6317 | 6368 | | |
| |||
6732 | 6783 | | |
6733 | 6784 | | |
6734 | 6785 | | |
6735 | | - | |
6736 | | - | |
6737 | | - | |
6738 | | - | |
6739 | | - | |
6740 | | - | |
| 6786 | + | |
6741 | 6787 | | |
6742 | 6788 | | |
6743 | 6789 | | |
| |||
6765 | 6811 | | |
6766 | 6812 | | |
6767 | 6813 | | |
6768 | | - | |
| 6814 | + | |
| 6815 | + | |
| 6816 | + | |
| 6817 | + | |
| 6818 | + | |
| 6819 | + | |
| 6820 | + | |
| 6821 | + | |
6769 | 6822 | | |
6770 | 6823 | | |
6771 | 6824 | | |
| |||
6859 | 6912 | | |
6860 | 6913 | | |
6861 | 6914 | | |
6862 | | - | |
| 6915 | + | |
6863 | 6916 | | |
6864 | 6917 | | |
6865 | 6918 | | |
| |||
6871 | 6924 | | |
6872 | 6925 | | |
6873 | 6926 | | |
6874 | | - | |
| 6927 | + | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
| 6932 | + | |
6875 | 6933 | | |
6876 | 6934 | | |
6877 | 6935 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
| 192 | + | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
0 commit comments