Repository navigation
Commit ef4af73
fix(core)!: a platform object exposing delete is no longer annotated restore/purge, and the recycle-bin texts say the bin exists (#31877)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi93koVFxhFV4XSN9LDjNtxEf)_
Fixes #31629
Clause-②: no (narrowing). Measured on base ad622d3 and head c272ca8:
on base, a `sys_` / `cloud_` / `ai_` object exposing `delete` is
annotated `restore` and `purge` (3 of the 4 new pins red); on head it is
not, and a business object keeps both (pins green). The doors are
unchanged.
Metadata-protocol: none
Skills-docs: `skills/**` never names the effective `apiOperations`
annotation, and `skills/objectstack-api/SKILL.md` already describes the
recycle bin as taking business-object rows, so no skill text changes.
`skills/objectstack-api/SKILL.md:414` belongs to #30847 and is
untouched.
## 维护者速读
- 改了什么:平台对象(`sys_`/`cloud_`/`ai_`)开放 `delete` 时,有效权限里的 `apiOperations`
注解不再列出 `restore`/`purge`;业务对象照旧。另外 spec 和 core 里六处说“没有回收站”的文字改成真话。
- 为什么改:回收站按 ADR-0148 D5
不收平台对象,门本来就拒绝(404/400),注解却说可以,界面会给出点了必失败的按钮;文字也误导作者和 AI。
- 风险与回滚:只收窄一个计算出来的注解,门的答复逐字节不变;平台对象开放 `delete`
时现在总会带注解(与外部只读数据源同一规则)。回滚就是回退本 PR。
- 先看:`packages/core/src/security/effective-object-permissions.ts` 的
`annotateEffectiveApiOperations`(`noRecycleBin`
那一行);`effective-object-permissions.test.ts` 的 `[#31629]`
块;`packages/spec/src/data/object.zod.ts` 三段提示文字。
- 两分钟验证:`pnpm --filter @objectstack/core exec vitest run
src/security/effective-object-permissions.test.ts -t 31629`,预期 4 个用例全过。
- 需要你做的:无,席位落地。
## What changes
**N1, the annotation (core).** `annotateEffectiveApiOperations` now
withholds `restore` and `purge` from an object where
`hasPlatformObjectPrefix(obj)` holds. The recycle bin takes no object in
the platform namespaces (ADR-0148 D5), and the derivation table is a
pure function of `enable` that never sees the object's name, so the
refusal is folded at the annotation, the same way the external write
gate is (#30370). A platform object that exposes `delete` is therefore
always annotated, because it is served less than its derived closure.
Every other operation it lists is unchanged. A business object keeps
`restore` and `purge` exactly as before.
**The doors are unchanged (门未改).** No file under `packages/objectql` or
`packages/rest` is in the diff, and no server path reads `apiOperations`
for enforcement (`git grep apiOperations` outside tests and spec finds
only a docblock in plugin-hono-server). On a platform object a restore
or purge of an entry still answers `404 RECORD_NOT_FOUND`, and a list,
an empty or a permanent delete still answers `400 VALIDATION_ERROR`.
There is no 405.
**`packages/spec/src/data/api-derivation.ts`:** one docblock clause on
`API_METHOD_DERIVATION`: a platform object has no bin, its bin doors
refuse whatever `apiMethods` says, and the annotation withholds the two
verbs there.
**N2, the texts.** Each now says the recycle bin exists for business
objects and why platform objects have none:
- `object.zod.ts` `LEGACY_API_METHOD_GUIDANCE.restore` / `.purge`
(printed by the strip warning): "declare ['delete'], `restore` / `purge`
derives from delete", in place of "never derives … soft-delete work is
parked".
- `object.zod.ts` `CAPABILITIES_RETIRED_KEY_GUIDANCE.trash` (claim
amendment 6735175859): no longer says soft delete is parked.
- `object.zod.ts` the `softDelete` tombstone: no longer says there is no
soft-delete or recycle-bin runtime.
- `webhook.zod.ts` the `undelete` note: the engine now has a restore
that publishes `data.record.restored`, and no webhook trigger maps it
yet.
- `effective-object-permissions.ts` the
`EXTERNAL_WRITE_GATED_OPERATIONS` docblock: `restore` / `purge` derive
from `delete`, in place of "never derive today".
- `connector.zod.ts:191-194`, a code comment (claim amendment
6735175859): no longer says every delete is a hard delete.
**Deliberately unchanged:**
`packages/spec/src/migrations/entries/semantic/17.audit-log-action-restore-retired.ts`.
It is the dated record of a past retirement and its text was true when
it shipped (seat ruling, claim amendment 6735175859). CHANGELOG history
is untouched.
## Tests
- New top-level `describe('[#31629] …')` in
`packages/core/src/security/effective-object-permissions.test.ts`, 4
cases: an unrestricted platform object is annotated without `restore` /
`purge` while a business object keeps both (CONTROL); a platform object
that would otherwise need no annotation is annotated; an `apiMethods`
subset with `delete` loses the two verbs on a platform object only; a
platform object without `delete`, or with its API closed, is annotated
as before.
- **Forced test edits**, all in `packages/spec/src/data/object.test.ts`,
each pinning the corrected sentence in place of the false one: line 92
(`trash` guidance, named by the claim amendment), line 1314
(`softDelete` tombstone needle `hard deletes`), and lines 2707-2713 (the
`restore` / `purge` strip guidance).
<details><summary>Step 0 on base ad622d3: the pin, red</summary>
```
× an unrestricted platform object is annotated without restore / purge; a business object keeps both (CONTROL)
× a platform object that would otherwise need no annotation is annotated, so the client offers no bin door
× an apiMethods subset that includes delete loses restore / purge on a platform object only
Tests 3 failed | 1 passed | 55 skipped (59)
```
| object | `enable` | annotation on base | annotation on head | door
(files byte-identical on base and head) |
|:--|:--|:--|:--|:--|
| `sys_widget` | default | `… search, restore, purge, import` | `…
search, import` | restore/purge entry `404`, list/empty/permanent `400`
|
| `cloud_widget` | `apiMethods: [get, list, delete]` | `get, list,
delete, aggregate, search, restore, purge` | `get, list, delete,
aggregate, search` | same |
| `crm_widget` (CONTROL) | default | `… restore, purge, import` |
unchanged | serves the bin |
</details>
<details><summary>Ablation: the platform-prefix fold removed, pins red,
restored</summary>
`node scripts/ablation-replace.mjs` replaced the line `&& !(noRecycleBin
&& RECYCLE_BIN_OPERATIONS.has(operation)));` (anchor 1 → 0, blob
84d154a → 91593f6c) and ran the core file: `Tests 3 failed | 56 passed
(59)`, the three `[#31629]` cases. Restored: blob after restore 84d154a
= blob at HEAD, `git diff HEAD` empty. The subject is imported from
`src` relatively, so no build sat between mutation and run.
</details>
<details><summary>Test runs</summary>
- core full suite on d07a0cd (core unchanged since): `Test Files 139
passed (139)`, `Tests 3198 passed (3198)`; `pnpm --filter
@objectstack/core typecheck` exit 0.
- spec full suite on c272ca8: `Test Files 826 passed | 1 skipped
(827)`, `Tests 26126 passed | 1 skipped | 1 todo`; `pnpm --filter
@objectstack/spec typecheck` exit 0; `check:generated`: all 14 generated
artifacts up to date.
- consumers of the map: plugin-hono-server
`effective-api-operations.test.ts` +
`current-user-endpoints-effective-objects.test.ts` 36/36;
plugin-security `get-effective-object-permissions.test.ts` 68/68.
- door CONTROL at head: objectql
`recycle-bin/{list,purge,restore,capture}.test.ts` 141/141 (includes
"refuses a platform object, 400"); rest `recycle-bin-routes.test.ts`
33/33 (includes the two 404s).
- full dogfood on d07a0cd: `Test Files 441 passed | 3 skipped (444)`,
`Tests 3662 passed | 42 skipped`. The final head differs from d07a0cd
by a code comment in `connector.zod.ts` and the three spec test pins
only.
- eslint `--no-inline-config` over the seven touched source and test
files: exit 0 (core and spec declare no `lint` script).
</details>
<details><summary>Derived gates on c272ca8</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 90 commands; all 90 ran on c272ca8
and exited 0. Reconciliation: `✓ dispatch-gates --ran: 90 derived
famil(ies) accounted for — 90 run, 0 NOT-MEASURED (a DERIVED zero — all
90 recorded an exit code and none of them is 3)`. Two first attempts
exited 3 for prerequisites, not findings, and were re-run green:
`check-plugin-teardown-shape --self-test` (shallow clone, deepened) and
`check:dual-build-cjs-loads` (needed a full `pnpm build`); five spec
dist readers (`check:api-surface`, `check:browser-reachable-entries`,
`check:dual-source-exports`, `check:entry-nameability`,
`check:exported-any`) were re-run after a spec rebuild on c272ca8.
`check:nul-bytes` exit 0. Note: the derivation flagged two gate scripts
changed on origin/main since the merge base
(`check-cli-test-child-env.mjs`, `platform-object-tenancy-census.mjs`);
the local run read the base copies, and CI runs the merge ref.
</details>
## Acceptance notes
- After this PR, a full grep of `packages/spec/src` and
`packages/core/src` (migration and conversion entries excluded, per the
seat's ruling) for the "no recycle bin" sentence family finds only true
statements: a platform object has no bin, a composition may register
none, and the bin did not exist before ADR-0148 (past tense).
```
git grep -n -i -E "no (soft-delete|recycle.bin)|never derive[s]? (today|\()|soft-delete work is parked|soft delete is parked|no restore (capability|operation)|recycle-bin runtime|deletes are hard deletes|every delete is a hard delete|neither built yet" HEAD -- packages/spec/src packages/core/src ':!packages/spec/src/migrations/**' ':!packages/spec/src/conversions/**'
```
Six hits, all true: the two `[#31629]` lines (a platform object has no
bin), `protocol.zod.ts:3222` (a composition with no recycle bin),
`webhook.test.ts:18` and `api-derivation.ts:137` (past tense), and the
corrected `softDelete` tombstone (past tense).
## Verification
`pnpm --filter @objectstack/core exec vitest run
src/security/effective-object-permissions.test.ts -t 31629`: 4 passed.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSUHRNK5dMrwwgj6z4)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1a66fcf commit ef4af73
8 files changed
Lines changed: 130 additions & 30 deletions
File tree
- .changeset
- packages
- core/src/security
- spec/src
- automation
- data
- integration
| 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 | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
564 | 610 | | |
565 | 611 | | |
566 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
537 | 545 | | |
538 | 546 | | |
539 | 547 | | |
| |||
556 | 564 | | |
557 | 565 | | |
558 | 566 | | |
| 567 | + | |
| 568 | + | |
559 | 569 | | |
| 570 | + | |
560 | 571 | | |
561 | 572 | | |
562 | | - | |
| 573 | + | |
| 574 | + | |
563 | 575 | | |
564 | 576 | | |
565 | 577 | | |
566 | | - | |
567 | | - | |
568 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
569 | 582 | | |
570 | 583 | | |
571 | 584 | | |
| |||
577 | 590 | | |
578 | 591 | | |
579 | 592 | | |
580 | | - | |
581 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
582 | 596 | | |
583 | 597 | | |
584 | 598 | | |
585 | 599 | | |
586 | 600 | | |
587 | 601 | | |
588 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
589 | 611 | | |
590 | 612 | | |
591 | 613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
1311 | 1311 | | |
1312 | 1312 | | |
1313 | 1313 | | |
1314 | | - | |
| 1314 | + | |
1315 | 1315 | | |
1316 | 1316 | | |
1317 | 1317 | | |
| |||
2704 | 2704 | | |
2705 | 2705 | | |
2706 | 2706 | | |
2707 | | - | |
| 2707 | + | |
2708 | 2708 | | |
2709 | 2709 | | |
2710 | 2710 | | |
2711 | 2711 | | |
2712 | | - | |
| 2712 | + | |
| 2713 | + | |
2713 | 2714 | | |
2714 | 2715 | | |
2715 | 2716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
1664 | 1666 | | |
1665 | 1667 | | |
1666 | 1668 | | |
1667 | | - | |
1668 | | - | |
1669 | | - | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1670 | 1675 | | |
1671 | 1676 | | |
1672 | 1677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
| |||
0 commit comments