Repository navigation
Commit b96dd30
fix(approvals)!: a request whose stamped flow package was uninstalled never reads another package's flow of that name (#33297)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDZYUbJbnXUTqZoZ56k4czR)_
Fixes #32647
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or docs page teaches how an approval
request reads its flow once its package is uninstalled; the moved
answers are runtime refusals at approval doors, nothing an author
writes.
## 维护者速读
- **改了什么**:审批单记着打开它的包(`process_package`)。这个包卸载后,如果另一个包还发同名
flow,审批单不再去读那个包的 flow:退回(send-back)和停滞的重新提交改为 409 拒绝并列出所有持有者,详情读取不再给出
`flow_route` / `flow_steps`,队列包按"没有 flow"处理。
- **为什么改**:ADR-0150 D8 R7 规定审批单属于打开它的那个包的 flow;之前卸载后会按裸名或按运行的 key
读到别的包的同名 flow,审批人看到并操作的是一张从没跑过这单的流程图。
- **风险与回滚**:只影响"打开它的包已卸载、而别的包持有同名 flow"的审批单(第一方调用方 0
个);记下的包仍持有该名、单子没记包、或已无任何持有者时答案不变。回滚即 revert 本 PR。
- **先看**:`packages/plugins/plugin-approvals/src/approval-service.ts` 的
`requestFlowSlot`(新增已卸载分支)、`requestFlow`(拒绝)、`requestFlowKey`;再看
`approval-revise.test.ts` 新增的 `[#32647]` describe。
- **两分钟验证**:`pnpm --filter @objectstack/plugin-approvals exec vitest run
--maxWorkers=2 src/approval-revise.test.ts`,预期 29 个用例全绿,其中 3 个是
`[#32647]`。
- **需要你做的**:无,席位落地。
## What changes
`ApprovalService.requestFlowSlot`
(`packages/plugins/plugin-approvals/src/approval-service.ts`) now
answers a request stamped with a package (`process_package`) by that
package's slot ONLY. When the stamped package holds no slot of the
request's flow name (uninstalled, or no longer shipping the flow), it
answers a withdrawn marker naming the slots that do hold the name, and
never falls through to the run's key or the bare read: both served
another package's flow (the bare read once a second holder was left
alone; the run's key once another package installed the name after the
stamped package left, because the key is the bare name again).
- `requestFlow` (send-back's edge check, the stranded-resubmit
continuation's revise window, the request read's `flow_route` /
`flow_steps`): a withdrawn stamp with holders throws
`PackageScopedNameRefusedError` (`409 RESOURCE_CONFLICT`), reason
`not-held-by-qualifier` with the stamped package as the qualifier and
every holder as a candidate, and a sentence of the request's own (the
qualifier read's "address it by its holder" is no move an approver has).
With no holder left it answers `null`, the deleted-flow answer the bare
read gave, unchanged.
- `requestFlowKey` (the queue package a re-resolved slate reads a
`queue` name from): a withdrawn stamp answers `null`, the no-flow
answer.
- The request-open path (`input.flowName`, no package asked) is
unchanged; it narrows the new union type away.
Declared FROM → TO per door, for a request whose stamped package
withdrew while another package holds the name:
| Door | FROM (measured, ablation) | TO |
|:--|:--|:--|
| send-back (`POST /approvals/requests/ID/revise`) | the other package's
revise edge checked; unit harness, run carrying the bare name: request
`returned` on the other graph; booted stack, record-triggered run:
passes the edge check, then `409 RESUME_TARGET_LOST` | `409
RESOURCE_CONFLICT` naming every holder, nothing written |
| request read `flow_route` / `flow_steps` | the other package's route
and steps (`Iota gate`) | neither served |
| stranded resubmit's revise window | the other package's window
(`wait_revision`) | `409 RESOURCE_CONFLICT` |
| queue package | the other package (`com.acme.beta`) | none
(environment-wide read) |
## Tests
- `packages/plugins/plugin-approvals/src/approval-revise.test.ts`, new
`[#32647]` describe beside the `[#31696]` one (real `AutomationEngine`,
loader set attached so the queue door's package is readable): (1)
withdrawn beside a second holder, (2) install / open / uninstall /
another package installs the name (with a CONTROL leg: no holder left
answers as a deleted flow, as on `main`), (3) CONTROL: stamped package
still holds the name, alone and beside a second holder, every door reads
its own flow.
-
`packages/qa/dogfood/test/approval-flow-name-per-namespace.dogfood.test.ts`,
new top-level describe on a booted stack: host stack + install-local
alpha, open a request through alpha's record-triggered flow, `DELETE
/marketplace/install-local/ALPHA`, CONTROL (no holder: send-back
`VALIDATION_FAILED`, no route or steps), install iota's same-named flow
(filed under the bare key the run carries), then send-back `409
RESOURCE_CONFLICT` naming alpha and iota, read with no route or steps,
row still `pending`.
## Acceptance notes
- One-holder answers are unchanged and pinned (CONTROL test 3, and the
`[#31696]` describe stays green).
- In the unit harness, a run started by bare name while its package was
the name's one holder resumed on the other package's graph once that
package held the name (the send-back FROM `returned` above): the
engine's run-key lookup, not this service's. On the booted stack the
record-triggered run carried its package-qualified key and the engine
refused the resume (`RESUME_TARGET_LOST`). Not measured through a public
door for a by-name run; carrier: none.
- Local gates were targeted per the dispatch (affected package tests and
typecheck, the new pins, one ablation per moved answer); CI runs the
farm.
## Verification
All readings at head `bb3fbd644` (branch merged with `origin/main` at
`199e36244`), each under `scripts/pm/os-verify-lock.sh`.
<details><summary>plugin-approvals typecheck + tests: exit 0</summary>
```
pnpm --filter @objectstack/plugin-approvals typecheck && pnpm --filter @objectstack/plugin-approvals test
check:test-typecheck: OK (8 file(s) / 321 error(s) / 27 pinned signature(s) held in test-typecheck-debt.json, unchanged)
Test Files 119 passed (119)
Tests 1635 passed (1635)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Full dogfood battery (narrowing arm): typecheck exit
0, tests green</summary>
```
pnpm --filter @objectstack/dogfood typecheck -> DOGFOOD_TYPECHECK_EXIT=0
pnpm --filter @objectstack/dogfood test (no OS_TEST_SHARD, no path)
Test Files 464 passed | 3 skipped (467)
Tests 3928 passed | 42 skipped (3970)
os-verify-lock: VERDICT batch-last-exit 0
```
</details>
<details><summary>Ablation, one per moved answer: the stamped branch
mutated to `if (false as boolean)` through scripts/ablation-replace.mjs,
restored to HEAD by blob</summary>
Unit suite `src/approval-revise.test.ts` under the mutation: 2 failed,
27 passed. The two withdrawn cases go red with the FROM answers: steps
`Beta Review`, route present, queue package `com.acme.beta`, resubmit
window `wait_revision`, send-back `returned` (run carrying the bare
name); CONTROL stays green. Restore: blob after restore equals HEAD
(`3a6234935de2`), diff against HEAD empty.
Booted pin (dogfood aliases `@objectstack/plugin-approvals` to source)
under the same mutation: 1 failed, 1 passed; FROM read `[200, "route",
["Iota gate"]]`, send-back `[409, "RESUME_TARGET_LOST"]`. Restored the
same way.
</details>
<details><summary>Targeted gates: each exit 0</summary>
`check-adr-0087-registration --base origin/main` (disposition
`not-required (no-migration-prescription)` read),
`check-changeset-no-major`, `check-empty-changeset`,
`check:doc-authoring`, `check:nul-bytes`, `check:issue-citations` (and
the script run), `check:cross-package-test-inputs`,
`check:engine-double-contract`, `check:closed-ceremony-text`.
`dispatch-gates --ran`: 74 derived, 10 run, 64 left to CI (declared
narrowing per the dispatch).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1bbeb94 commit b96dd30
4 files changed
Lines changed: 327 additions & 5 deletions
File tree
- .changeset
- packages
- plugins/plugin-approvals/src
- qa/dogfood/test
| 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 | |
|---|---|---|---|
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
843 | 964 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
1320 | 1322 | | |
1321 | 1323 | | |
1322 | 1324 | | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
1323 | 1362 | | |
1324 | 1363 | | |
1325 | 1364 | | |
| |||
3749 | 3788 | | |
3750 | 3789 | | |
3751 | 3790 | | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
3752 | 3799 | | |
3753 | 3800 | | |
3754 | 3801 | | |
3755 | 3802 | | |
3756 | | - | |
| 3803 | + | |
3757 | 3804 | | |
3758 | 3805 | | |
3759 | 3806 | | |
3760 | 3807 | | |
3761 | 3808 | | |
3762 | 3809 | | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
3763 | 3813 | | |
3764 | 3814 | | |
3765 | 3815 | | |
| |||
3775 | 3825 | | |
3776 | 3826 | | |
3777 | 3827 | | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
| 3831 | + | |
| 3832 | + | |
3778 | 3833 | | |
3779 | 3834 | | |
3780 | 3835 | | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
3781 | 3840 | | |
3782 | 3841 | | |
3783 | 3842 | | |
3784 | 3843 | | |
3785 | | - | |
| 3844 | + | |
| 3845 | + | |
| 3846 | + | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
3786 | 3850 | | |
3787 | 3851 | | |
3788 | 3852 | | |
3789 | | - | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
3790 | 3856 | | |
3791 | 3857 | | |
3792 | 3858 | | |
| |||
4602 | 4668 | | |
4603 | 4669 | | |
4604 | 4670 | | |
4605 | | - | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
4606 | 4674 | | |
4607 | 4675 | | |
4608 | 4676 | | |
| |||
0 commit comments