Skip to content

Commit ef4af73

Browse files
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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/core': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(core): a platform object exposing `delete` is no longer annotated `restore` / `purge`, and the spec and core texts no longer say the recycle bin does not exist
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
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 here.
11+
12+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value, export, type or stored shape changes. The narrowing is in a computed annotation the server builds for `/auth/me/permissions` and `ISecurityService.getEffectiveObjectPermissions`, so there is nothing for a metadata migration to rewrite and no tombstone. -->
13+
14+
**BREAKING** only for a client that read `restore` or `purge` in the effective `apiOperations` of a platform object (`sys_`, `cloud_`, `ai_`). The recycle bin takes no object in those namespaces (ADR-0148 D5), so the bin's doors already refused there: a restore or purge of an entry answers `404`, and a list, an empty or a permanent delete answers `400`. Those answers are unchanged. Only the annotation stops offering two verbs no request could use.
15+
16+
A platform object that exposes `delete` is now always annotated, because it is served less than its derived closure. That is the same rule as an object whose external write gate is closed, and every other operation it lists is unchanged. A business object keeps `restore` and `purge` exactly as before.
17+
18+
The texts corrected are the strip-warning guidance for the legacy `apiMethods` values `restore` and `purge`, the `enable.trash` and `softDelete` tombstones, the note on why `undelete` is not a webhook trigger, and the external write gate's docblock in core. Each now says the recycle bin exists for business objects and why platform objects have none.

‎packages/core/src/security/effective-object-permissions.test.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,52 @@ describe('[#30370] an object whose external write gate is closed grants no write
561561
});
562562
});
563563

564+
describe('[#31629] a platform object exposing delete is not annotated restore / purge: it has no recycle bin', () => {
565+
// ADR-0148 D5: the bin takes no object in the platform namespaces (`sys_`,
566+
// `cloud_`, `ai_`), so its doors refuse there whatever `apiMethods` says.
567+
// The derivation table is a pure function of `enable` and cannot see that.
568+
const SCHEMAS: Record<string, any> = {
569+
sys_widget: { name: 'sys_widget' },
570+
cloud_widget: { name: 'cloud_widget', enable: { apiMethods: ['get', 'list', 'delete'] } },
571+
ai_widget: { name: 'ai_widget', enable: { apiEnabled: true } },
572+
crm_widget: { name: 'crm_widget' },
573+
crm_narrow: { name: 'crm_narrow', enable: { apiMethods: ['get', 'list', 'delete'] } },
574+
sys_reader: { name: 'sys_reader', enable: { apiMethods: ['get', 'list'] } },
575+
sys_closed: { name: 'sys_closed', enable: { apiEnabled: false } },
576+
};
577+
const source = { allSchemas: () => Object.values(SCHEMAS), schemaOf: (n: string) => SCHEMAS[n] };
578+
const EVERY = { allowRead: true, allowCreate: true, allowEdit: true, allowDelete: true };
579+
const SUPER = { ...EVERY, viewAllRecords: true, modifyAllRecords: true };
580+
const FULL = ['get', 'list', 'create', 'update', 'delete', 'upsert', 'bulk', 'aggregate', 'search', 'restore', 'purge', 'import'];
581+
const withoutBin = (ops: string[]) => ops.filter((op) => op !== 'restore' && op !== 'purge');
582+
583+
it('an unrestricted platform object is annotated without restore / purge; a business object keeps both (CONTROL)', () => {
584+
const map: any = buildEffectiveObjectPermissions([{ objects: { '*': SUPER } }], source);
585+
expect(map.sys_widget.apiOperations).toEqual(withoutBin(FULL));
586+
expect(map.ai_widget.apiOperations).toEqual(withoutBin(FULL));
587+
expect(map.crm_widget.apiOperations).toEqual(FULL);
588+
});
589+
590+
it('a platform object that would otherwise need no annotation is annotated, so the client offers no bin door', () => {
591+
const map: any = buildEffectiveObjectPermissions([{ objects: { '*': { ...EVERY, allowExport: true } } }], source);
592+
expect(map.sys_widget.apiOperations).toEqual([...withoutBin(FULL), 'export']);
593+
// CONTROL: the business object keeps its whole closure, so it still carries no annotation.
594+
expect(map.crm_widget).not.toHaveProperty('apiOperations');
595+
});
596+
597+
it('an apiMethods subset that includes delete loses restore / purge on a platform object only', () => {
598+
const map: any = buildEffectiveObjectPermissions([{ objects: { '*': SUPER } }], source);
599+
expect(map.cloud_widget.apiOperations).toEqual(['get', 'list', 'delete', 'aggregate', 'search']);
600+
expect(map.crm_narrow.apiOperations).toEqual(['get', 'list', 'delete', 'aggregate', 'search', 'restore', 'purge']);
601+
});
602+
603+
it('a platform object without delete, or with its API closed, is annotated exactly as before', () => {
604+
const map: any = buildEffectiveObjectPermissions([{ objects: { '*': SUPER } }], source);
605+
expect(map.sys_reader.apiOperations).toEqual(['get', 'list', 'aggregate', 'search']);
606+
expect(map.sys_closed.apiOperations).toEqual([]);
607+
});
608+
});
609+
564610
describe('[#30440] a guarded managed object grants no verb its write guard refuses, modifyAllRecords included', () => {
565611
const SCHEMAS: Record<string, any> = {
566612
// engine-owned, nothing opted in: the guard refuses every user-context write.

‎packages/core/src/security/effective-object-permissions.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
type EnableLike,
4141
} from '@objectstack/spec/data';
4242
import { objectPermissionGrants, type EffectiveObjectPermission } from '@objectstack/spec/security';
43+
import { hasPlatformObjectPrefix } from '@objectstack/spec/system';
4344

4445
/**
4546
* Does the `'*'` entry carry the super-user READ bypass?
@@ -534,6 +535,13 @@ export function seedSuperUserRestrictedObjects(
534535
* each one `403 EXTERNAL_WRITE_FORBIDDEN` whatever the permission sets say,
535536
* and such an object is always annotated, since the client's default-allow
536537
* path would offer every write. Without it, the answer is what it was.
538+
*
539+
* [#31629] A platform object (`sys_`, `cloud_`, `ai_`; `hasPlatformObjectPrefix`)
540+
* is served without `restore` and `purge` ({@link RECYCLE_BIN_OPERATIONS}): the
541+
* recycle bin takes no object in those namespaces (ADR-0148 D5), so its doors
542+
* refuse there whatever `apiMethods` says. The derivation table is a pure
543+
* function of `enable` and cannot see the object's name, so the refusal is
544+
* folded here, the same way the external write gate is.
537545
*/
538546
export function annotateEffectiveApiOperations(
539547
objects: Record<string, any>,
@@ -556,16 +564,21 @@ export function annotateEffectiveApiOperations(
556564
// the set; any other `enable` leaves the closure as it is.
557565
// [#30370] And only what the external write gate admits: a closed gate
558566
// refuses every write operation on the data plane.
567+
// [#31629] And only what the recycle bin admits: a platform object has
568+
// no bin, so its bin doors serve nothing there.
559569
const writeForbidden = isExternalWriteForbidden?.(obj) === true;
570+
const noRecycleBin = hasPlatformObjectPrefix(obj);
560571
const served = closure.filter((operation) =>
561572
canServeApiOperation(enable, operation)
562-
&& !(writeForbidden && EXTERNAL_WRITE_GATED_OPERATIONS.has(operation)));
573+
&& !(writeForbidden && EXTERNAL_WRITE_GATED_OPERATIONS.has(operation))
574+
&& !(noRecycleBin && RECYCLE_BIN_OPERATIONS.has(operation)));
563575
// Annotate when the object tightens via `apiMethods`, when the export
564576
// axis removes `export` from an otherwise-open object (so the client
565577
// hides the Export button), OR when the door serves less than the closure
566-
// (an API-disabled object, or [#30370] a closed external write gate). An
567-
// unrestricted object with every operation still served needs no
568-
// annotation — the client keeps its default-allow path.
578+
// (an API-disabled object, [#30370] a closed external write gate, or
579+
// [#31629] a platform object, which has no recycle bin). An unrestricted
580+
// object with every operation still served needs no annotation — the
581+
// client keeps its default-allow path.
569582
if (eff.mode === 'unrestricted' && userExportAllowed && served.length === closure.length) continue;
570583
acc.apiOperations = served;
571584
}
@@ -577,15 +590,24 @@ export function annotateEffectiveApiOperations(
577590
* refuses on an object whose gate is closed: the three primitives it judges
578591
* (`insert` is `create`), and every derived operation built on them —
579592
* `upsert` (create ∧ update), `bulk` (batched create / update / delete),
580-
* `import` (create ∨ update), and `restore` / `purge`, which never derive
581-
* today but write when they do. The read operations (`get`, `list`,
593+
* `import` (create ∨ update), and `restore` / `purge`, the recycle bin's
594+
* doors, which derive from `delete` (ADR-0148) and write a row back or remove
595+
* one for good. The read operations (`get`, `list`,
582596
* `aggregate`, `history`, `search`, `export`) are untouched: the gate judges
583597
* writes only.
584598
*/
585599
const EXTERNAL_WRITE_GATED_OPERATIONS: ReadonlySet<ApiOperation> = new Set<ApiOperation>([
586600
'create', 'update', 'delete', 'upsert', 'bulk', 'import', 'restore', 'purge',
587601
]);
588602

603+
/**
604+
* [#31629] The recycle bin's two doors, `restore` and `purge`, which derive
605+
* from `delete` (ADR-0148). The bin takes no object in the platform namespaces
606+
* (ADR-0148 D5), so neither is served there: the doors refuse, and
607+
* {@link annotateEffectiveApiOperations} withholds both.
608+
*/
609+
const RECYCLE_BIN_OPERATIONS: ReadonlySet<ApiOperation> = new Set<ApiOperation>(['restore', 'purge']);
610+
589611
/**
590612
* [#30370] Re-clamp the map by the THIRD server-side enforcement layer
591613
* permission sets do not model: the external write gate (ADR-0015 §5.3

‎packages/spec/src/automation/webhook.zod.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ import { strictObject } from '../shared/strict-object';
2828
* the other direction. A webhook that wants both subscribes to both.
2929
*
3030
* Deliberately NOT triggers (#3196):
31-
* - `undelete` — there is no soft-delete / restore capability in the engine
32-
* (`delete` is a hard delete; no `deleted_at` convention, no restore
33-
* operation, no `data.record.undeleted` emit), so it had no event source.
34-
* Reintroduce it only alongside a real restore subsystem that emits an
35-
* undelete event.
31+
* - `undelete` — it was removed when the engine had no restore at all, so it
32+
* had no event source. The recycle bin (ADR-0148) has since added one: a
33+
* restore of a business object's entry publishes `data.record.restored` per
34+
* row (a platform object, `sys_` / `cloud_` / `ai_`, has no bin, so nothing
35+
* is restored there). No webhook trigger maps that event yet; a restore
36+
* trigger is a deliberate addition with its own delivery shape, not a
37+
* revival of this bare value.
3638
* - `api` (manual/programmatic fire) — no manual fire path exists (the only
3739
* webhook HTTP surface re-queues already-failed deliveries). Reintroduce it
3840
* with a real "fire this webhook now" endpoint/service, not as a bare enum

‎packages/spec/src/data/api-derivation.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ interface DerivationRule {
138138
* retired by #2377/ADR-0049 with no runtime consumer); the bin shipped with
139139
* #30237, so they are live derived verbs. Who may restore or purge is the
140140
* security layer's question (`allowRestoreOwnDeleted`, `manageRecycleBin`);
141-
* this table only says whether the object's API exposes the verb.
141+
* this table only says whether the object's API exposes the verb. A platform
142+
* object (`sys_`, `cloud_`, `ai_`) has no bin (ADR-0148 D5): its bin doors
143+
* refuse whatever `apiMethods` says, and the effective `apiOperations`
144+
* annotation withholds the two verbs there. This table cannot see that, since
145+
* it reads `enable` and never the object's name.
142146
*/
143147
export const API_METHOD_DERIVATION: Record<LegacyApiMethod, DerivationRule> = {
144148
upsert: { all: ['create', 'update'] },

‎packages/spec/src/data/object.test.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ describe('ObjectCapabilities', () => {
8383
expect(message).toContain('This edit left `os migrate meta` with the protocol-16.x conversions');
8484
expect(message).not.toContain('os migrate meta --from 16');
8585
}
86-
// `trash` additionally points at the parked soft-delete issue — the
87-
// parking spot the 2026-08-02 #3207 ruling designates (#1893, the old
88-
// pointer, closed 2026-07-24).
86+
// `trash` additionally points at the recycle bin that shipped after the
87+
// flag was retired (ADR-0148), which has no flag to set (#31629; it used
88+
// to say soft delete was parked, which the bin made untrue).
8989
const trash = ObjectCapabilities.safeParse({ trash: false });
9090
expect(trash.success).toBe(false);
9191
const trashMsg = trash.success ? '' : trash.error.issues.map((i) => i.message).join('\n');
92-
expect(trashMsg).toContain('soft delete is parked');
92+
expect(trashMsg).toContain('The recycle bin that shipped later (ADR-0148) has no flag');
9393
expect(trashMsg, 'the prescription carries ADR ids and the migration command, never a tracker id')
9494
.not.toMatch(/#\d{3,5}/);
9595
});
@@ -1311,7 +1311,7 @@ describe('ObjectSchema.create()', () => {
13111311
it('tombstone: dead metadata keys removed in 16.0 carry upgrade guidance', () => {
13121312
const cases: Array<[string, unknown, string]> = [
13131313
['versioning', { enabled: true }, 'trackHistory'],
1314-
['softDelete', { enabled: true }, 'hard deletes'],
1314+
['softDelete', { enabled: true }, 'the recycle bin that shipped later (ADR-0148)'],
13151315
['search', { fields: ['name'] }, 'searchableFields'],
13161316
['recordName', { type: 'autonumber' }, 'autonumber'],
13171317
['keyPrefix', 'ACC', 'no effect'],
@@ -2704,12 +2704,13 @@ describe('apiMethods legacy-value strip (ObjectCapabilities)', () => {
27042704
expect(result.success).toBe(false);
27052705
});
27062706

2707-
it('restore/purge strip carries the retired-trash guidance', () => {
2707+
it('restore/purge strip carries the recycle-bin guidance: both derive from delete', () => {
27082708
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
27092709
const result = ObjectCapabilities.parse({ apiMethods: ['delete', 'restore', 'purge'] });
27102710
expect(result.apiMethods).toEqual(['delete']);
27112711
const msg = warn.mock.calls.map((c) => c[0]).join('\n');
2712-
expect(msg).toContain('`enable.trash` was retired because no runtime ever read it');
2712+
expect(msg).toContain("`restore` derives from delete: it is the recycle bin's restore door");
2713+
expect(msg).toContain("`purge` derives from delete: it is the recycle bin's purge door");
27132714
});
27142715

27152716
it('the authored enum itself no longer admits legacy values', () => {

‎packages/spec/src/data/object.zod.ts‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export const LEGACY_API_METHOD_GUIDANCE: Record<LegacyApiMethod, string> = {
8181
aggregate: "declare ['list'] — `aggregate` derives from list",
8282
history: "declare ['get'] with `enable.trackHistory: true` — `history` derives from get ∧ trackHistory",
8383
search: "declare ['list'] (with `searchable` not false) — `search` derives from list ∧ searchable",
84-
restore: "delete the value — `restore` never derives (`enable.trash` was retired because no runtime ever read it); it returns only with a real recycle bin, and that soft-delete work is parked",
85-
purge: "delete the value — `purge` never derives (`enable.trash` was retired because no runtime ever read it)",
84+
restore: "declare ['delete'] — `restore` derives from delete: it is the recycle bin's restore door (ADR-0148), served on a business object only, because a platform object (`sys_`, `cloud_`, `ai_`) has no bin",
85+
purge: "declare ['delete'] — `purge` derives from delete: it is the recycle bin's purge door (ADR-0148), served on a business object only, because a platform object (`sys_`, `cloud_`, `ai_`) has no bin",
8686
import: "declare ['create'] and/or ['update'] — `import` derives from create ∨ update (writeMode-precise at the gate)",
8787
export: "declare ['list'] — `export` derives from list",
8888
};
@@ -169,12 +169,14 @@ export function stripLegacyApiMethods(
169169
const CAPABILITIES_RETIRED_KEY_GUIDANCE: Record<string, string> = {
170170
trash:
171171
'`enable.trash` was removed from @objectstack/spec in the 16.x line (' +
172-
'ADR-0049) — it never had a runtime consumer: every delete has always been a ' +
173-
'hard delete, and a default-true flag promising a recycle bin was a false ' +
172+
'ADR-0049) — it never had a runtime consumer: every delete was then a hard ' +
173+
'delete, and a default-true flag promising a recycle bin was a false ' +
174174
'affordance (authors wrote `trash: false` believing they were opting out of a ' +
175-
'soft-delete that never ran). Delete the key. For recoverability use per-field ' +
176-
'`trackHistory` (audit trail) or a `lifecycle` policy; soft delete is parked, ' +
177-
'and if built returns as a live enforced flag (ADR-0049 prune-or-build). ' +
175+
'soft-delete that never ran). Delete the key. The recycle bin that shipped ' +
176+
'later (ADR-0148) has no flag: it takes every by-id delete of a business ' +
177+
'object, and none of a platform object (`sys_`, `cloud_`, `ai_`), whose ' +
178+
'deletes stay permanent. For history use per-field `trackHistory` (audit ' +
179+
'trail), and for retention a `lifecycle` policy. ' +
178180
'This edit left `os migrate meta` with the protocol-16.x conversions: apply it by hand, or run the tool on a release that still carries the conversion — https://objectstack.ai/docs/protocol-upgrade.',
179181
mru:
180182
'`enable.mru` was removed from @objectstack/spec in the 16.x line (' +
@@ -1664,9 +1666,12 @@ const UNKNOWN_KEY_GUIDANCE: Record<string, string> = {
16641666
'layout derives from `fieldGroups` + `Field.group`.',
16651667
softDelete:
16661668
'`softDelete` was removed from the spec in 16.0 (ADR-0049 ' +
1667-
'enforce-or-remove) — there is no soft-delete/recycle-bin runtime, so it ' +
1668-
'stored nothing and implied restore semantics that do not exist. Deletes ' +
1669-
'are hard deletes; remove the key.',
1669+
'enforce-or-remove) — no soft-delete runtime read it then, so it stored ' +
1670+
'nothing and implied restore semantics that did not exist. Remove the key: ' +
1671+
'the recycle bin that shipped later (ADR-0148) has no per-object switch. It ' +
1672+
'takes every by-id delete of a business object, which can then be restored ' +
1673+
'or purged; a platform object (`sys_`, `cloud_`, `ai_`) has no bin, so its ' +
1674+
'deletes are permanent.',
16701675
versioning:
16711676
'`versioning` was removed from the spec in 16.0 (ADR-0049) — no ' +
16721677
'record-versioning engine ever read it (it snapshotted no history). Use ' +

‎packages/spec/src/integration/connector.zod.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ import { findConnectorUrlCredentials, type ConnectorUrlCredential } from './conn
189189
// registry; and no engine ran a strategy, a direction, a batch, a watermark, a
190190
// conflict policy or a delete policy. The defaults read as configured policy
191191
// and did nothing: `latest_wins` resolved no conflict, and `soft_delete` named
192-
// a mode the platform does not have — every delete is a hard delete.
192+
// a delete mode no sync engine ran. (The recycle bin that shipped later,
193+
// ADR-0148, keeps a by-id delete of a business object restorable; it is not a
194+
// sync delete policy, and a platform object's delete is still permanent.)
193195
//
194196
// The capability is mainstream, so it was ruled ENFORCE rather than RETIRE —
195197
// but not on the connector. Every mainstream platform binds a sync definition

0 commit comments

Comments
 (0)