Skip to content

feat(spec): declare the recycle-bin surface: the sys_recycle_bin entry contract, the retention hook, the restore refusals, the restored event and two grant keys (ADR-0148) - #30577

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-uwrsn3
Nov 5, 2026

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #30235

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #30237 — skills/objectstack-api/SKILL.md teaches that the trash surface is retired and that there is no recycle bin (the apiMethods section and the delete note); both stay true after this PR, which declares and reads nothing, so the rewrite rides the engine slice that ships the reader.

维护者速读

  • 改了什么:在 @objectstack/spec 里声明回收站的契约:sys_recycle_bin 条目的字段表与值形状、宿主保留期钩子(只认天数)、三个恢复拒绝码、data.record.restored 事件名、两个对象权限键;运行时一行未动。
  • 为什么改:ADR-0148 D5 把这些拼写交给本卡,引擎(engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237)和控制台(ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239)要在它上面建;没有它,删除仍然不可恢复。
  • 风险与回滚:纯新增,可选键无默认值,已有元数据和已解析的权限条目不变;回滚就是 revert 本 PR。
  • 先看:packages/spec/src/data/recycle-bin.zod.ts(钩子签名与拒绝文案)、packages/spec/src/security/permission.zod.ts(两个新键)、packages/spec/src/api/error-code-ledger.zod.ts(三个拒绝码先于生产者登记)。
  • 两分钟验证:pnpm --filter @objectstack/spec exec vitest run --project local src/data/recycle-bin.zod.test.ts,预期 1 个文件、16 个用例全过。
  • 需要你做的:无,席位落地。

What changes

The spec half of the recycle bin (ADR-0148 D5, Rollout step 2; ruling 6629858351 on #3146, D7's eight choices ratified 6659364907 on #30234). Every name below is declared here and read elsewhere: nothing in this PR writes or reads the bin, and every delete is still a physical delete.

  • packages/spec/src/data/recycle-bin.zod.ts (new, exported from @objectstack/spec/data):
    • RECYCLE_BIN_OBJECT = 'sys_recycle_bin' and RECYCLE_BIN_ENTRY_FIELDS, the entry's one field list (id, object_name, record_id, record_count, snapshot, deleted_by, deleted_at, retention_days, purge_after), all read-only; RecycleBinEntrySchema is its value shape, key for key. The object file, its plugin registration and its PLATFORM_OBJECTS_BY_PACKAGE row are the engine slice's (seat decision 2): that registry means "a table exists".
    • RecycleBinSnapshotSchema (with RecycleBinSnapshotRowSchema, RecycleBinClearedReferenceSchema): the cascade set, master first, secret-channel refs left out (D4), plus the set_null references the delete cleared (D2's re-link rule).
    • The retention hook (D3): RecycleBinRetentionResolver = (token: string | undefined) => number | undefined, the same token type resolveFeatures takes in packages/cloud-connection/src/runtime-config-plugin.ts; RECYCLE_BIN_RETENTION_DAYS_ENV = 'OS_RECYCLE_BIN_RETENTION_DAYS', RECYCLE_BIN_DEFAULT_RETENTION_DAYS = 30; RecycleBinRetentionDaysSchema / RecycleBinRetentionDaysEnvSchema refuse zero and every non-whole-number with recycleBinRetentionRefusal(source, value), which names the source and the fix and no plan.
    • RECYCLE_BIN_RESTORE_REFUSAL_CODES (three codes) and RECYCLE_BIN_RESTORE_REFUSAL_STATUS = 409.
    • RECORD_RESTORED_EVENT = 'data.record.restored', a spec constant only (seat decision 1): DataEventType / RealtimeEventType list emitted events, so it joins them in the change that emits it.
    • RECYCLE_BIN_GRANT_KEYS.
  • Error-code ledger (packages/spec/src/api/error-code-ledger.zod.ts): RESTORE_UNIQUE_VALUE_TAKEN, RESTORE_PARENT_PURGED, RESTORE_PACKAGE_UNINSTALLED under @objectstack/objectql, ahead of their producer (seat decision 4).
  • Object permissions (packages/spec/src/security/permission.zod.ts): allowRestoreOwnDeleted and manageRecycleBin, optional with no default, so no parsed entry grows a key. Both enter liveness/permission.json as planned, naming their readers (engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 evaluator mapping and engine doors, ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239 Console) (seat decision 3). The tombstoned allowRestore / allowPurge stay refused.
  • Regenerated artifacts: api-surface, export-origins, declaration-map, authorable-surface, json-schema manifest, content/docs/references/**, the strictness-ledger counts, liveness state counts, llms.txt, and the type-alias pin (+6 isomorphic pins, 831 → 837).
  • Changeset: @objectstack/spec minor.

⛔ Not here: the engine's delete path, restore, purge, empty, the TTL reap, the permission mapping, the REST doors (#30237); the Console (#30239); any tombstoned key (enable.trash, softDelete, allowRestore, allowPurge, the retired apiMethods values).

Why

A deleted record is gone for good today. ADR-0148 rules a separate bin store and leaves the spellings to this card (D6); the engine and Console slices build on them, and ADR-0049's enforce-or-remove gate is passed by naming each reader in its liveness row.

Tests

All readings at head 25af14cf, after origin/main c23eafa8 was merged in and the build state refreshed.

  • packages/spec/src/data/recycle-bin.zod.test.ts (new, 16 cases): the three names; the hook takes the resolveFeatures token and answers days or nothing; RecycleBinRetentionDaysSchema accepts 1/7/30/365 and refuses 0, -1, 1.5, NaN, Infinity, null, '30', true with the refusal text; the env schema accepts '1' '30' '365' and refuses '0' '030' '-7' '7.5' ' 7' 'thirty' ''; the refusal names the source and the remedy and no plan; the snapshot round-trips and refuses zero rows; the field contract (types, required, read-only, deleted_by → sys_user) builds a valid ObjectSchema under sys_recycle_bin; RecycleBinEntrySchema matches the field keys one for one; the refusal codes are registered and answer 409; data.record.restored stays out of DataEventType / RealtimeEventType; the two grant keys parse, are never defaulted, and the retired allowRestore / allowPurge stay refused.
  • packages/spec/src/api/error-code-ledger.test.ts: the three codes parse as ErrorCode, sit under @objectstack/objectql, and need no standard-synonym waiver.
  • packages/spec/src/type-alias-convention.pin.test.ts: +6 isomorphic pins (831 → 837).
Commands and results
  • pnpm --filter @objectstack/spec build · VERDICT command-exit 0
  • pnpm --filter @objectstack/spec check:generated · exit 0 · all 14 generated artifacts up to date
  • pnpm --filter @objectstack/spec test (vitest --project local) · VERDICT command-exit 0 · Test Files 816 passed (816) · Tests 25660 passed, 1 todo
  • pnpm --filter @objectstack/spec typecheck (tsc, scripts typecheck, test typecheck) · VERDICT command-exit 0
  • turbo run build --filter=!@objectstack/docs · 119 successful, 119 total
  • Downstream consumers (...@objectstack/spec direction), the three the diff's widened types reach (object permissions, the error-code union): pnpm --filter @objectstack/plugin-security typecheck · @objectstack/core typecheck · @objectstack/objectql typecheck · each VERDICT command-exit 0
  • pnpm --filter @objectstack/plugin-security test · Test Files 244 passed (244) · Tests 5379 passed, 45 skipped
  • @objectstack/core vitest run src/security · Test Files 63 passed (63) · Tests 1221 passed
  • @objectstack/lint vitest run src/validate-security-posture.test.ts src/validate-retired-permission-residue.test.ts · Test Files 2 passed · Tests 209 passed

No ablation: the diff changes no tested runtime behaviour (declarations only). No dogfood battery: no ! in the title and no (narrowing) arm.

Acceptance notes

  • Resumed work, re-verified. The previous card thread pushed five commits to claude/project-thread-jpl1gr (last 884764a2). Each hunk was re-read against ADR-0148 and the seat's four decisions; all are kept. One correction: the changeset's Clause-②: line carried a free-text arm, and now reads yes (widening), the claim's form (25af14cf). The net diff touches no file outside packages/spec, content/docs/references/**, docs/audits/2026-07-unknown-key-strictness-ledger* and .changeset/; the object file the first commit wrote under platform-objects was moved out by the predecessor itself (seat decision 2).
  • Why the grants are object-permission keys. ADR-0148 D5 says OPERATION_TO_PERMISSION in packages/plugins/plugin-security/src/permission-evaluator.ts must map restore / purge to the new grants; that map targets object-permission keys, so both keys live on the per-object entry. manageRecycleBin is bin administration on that object; emptying purges every entry the holder manages.
  • What the readers must add (the engine and Console cards, not this PR). EffectiveObjectPermission (the /auth/me/permissions shape) gains both optional keys because it derives from the same base; nothing fills them yet. GRANT_BITS in packages/core/src/security/effective-object-permissions.ts, ObjectPermissionVerbTarget / objectPermissionGrants in packages/spec/src/security/permission.zod.ts, and CAPS in ui/packages/app-shell/src/views/metadata-admin/previews/PermissionPreview.tsx list neither key today. Carrier: engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 (merge, fold, evaluator map, flipping both liveness rows to live) and ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239 (the Console columns).
  • Strictness. The four object sites in recycle-bin.zod.ts are z.object and triaged wire in the strictness ledger: persisted runtime state the engine writes and reads, never authored; the snapshot's values carry whatever fields the deleted rows had.
  • No ADR anchor file. ADR-0148's id sits in the code at each declaration; no scripts/adr-anchors/ entry was added, because the claim's file surface does not name one. The seat may ask for it.
  • Timestamps. deleted_at / purge_after accept ISO 8601 with an offset (datetime({ offset: true })), a little wider than the repository's common datetime() form, so an engine writing a local offset is not refused.

Verification

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at head 25af14cf (29 paths vs merge base c23eafa8, +852 / -18) derived 106 commands. All 106 ran serially on that head after the full build, each exit code captured before any pipe: 106 × exit 0. --ran reconciliation: 106 derived, 106 run, 0 NOT-MEASURED, 0 UNRUN (a derived zero). pnpm lint and the rest of the CI farm are CI's run; the PR's check-runs are the record for them.

The 106 derived commands, all exit 0
  • check-adr-0087-registration --base origin/main (no declared-breaking changeset; 1 non-breaking seen) and --self-test; check-changeset-no-major --base origin/main (no major bump; protocol lockstep 18 / 18.3.0; re-run offline with this body as the --event payload: LEVEL AXIS ✓, yes (widening) + added, no moved package graded patch); check-empty-changeset; check-issue-citations (13 citations resolve on the board); check-adr-links; check-closing-keyword-parity; check-comment-mask-adoption, check-comment-mask-corpus; check-doc-route-spelling --advisory; check-docs-section-name; check-section-landing-index; check-plugin-teardown-shape (fixture 621a4876 fetched for the self-test); check-dev-prereqs, check-dts-emitted, assert-turbo-remote-cache, plan-test-core-shards, prune-turbo-cache, release-rehearsal-clone, release-pending-publish self-tests; docs-audit/check-affected-docs, check-drift-comment.
  • @objectstack/spec: check:api-surface, check:authorable-surface, check:browser-reachable-entries, check:docs, check:dual-source-exports, check:duration-unit-keys, check:empty-state, check:entry-nameability (626 probes, 0 new unnameable mentions), check:error-code-provenance, check:export-origins, check:exported-any, check:generated, check:liveness, check:llms-txt, check:skill-examples, check:skill-refs, check:strictness-ledger, check:variant-docs, check:yaml-examples.
  • @objectstack/lint: check:doc-formula-expressions, check:doc-security-posture.
  • Root: check:changeset-gate-self-tests, ci-filter-parity, closed-ceremony-text, corpus-claim-drift, cross-package-test-inputs, dispatcher-error-vocabulary, doc-anchors, doc-authoring, doc-frontmatter, docs-audit-scope, docs-redirects, docs-single-h1, docs-spec-enumerations, docs-transcript-drift, driver-memory-census, dts-closure, dual-build-cjs-loads, engine-double-contract, error-code-casing, error-status-conformance, gitlink-declared, issue-citations, keyed-text-bounds, lean-entry-closure, logger-receiver-detach, merge-driver, nul-bytes, objectql-double-limit, org-identifier, page-declaration-shape, platform-checklist, platform-object-tenancy-census, pm-prior-rulings, published-files, published-readme-links, query-options-erasure, react-page-adapter-contract, refd-timer-probe, registry-log-declared, rest-log-spy-declared, role-word, skill-identifier-liveness, slot-lookup, sourcemap-no-sources-content, spec-docblock-symbol-anchors, spec-parsed-alias, system-context-census, test-source-alias, tier-file-adoption, type-check-coverage, type-check-debt, undeclared-dep-imports, vendor-version-stamps, watch-hint-literal, where-matcher.

Branch: claude/project-thread-uwrsn3, the card thread's harness-pinned branch (a measured platform exception to claude/issue-30235-…), resumed from claude/project-thread-jpl1gr@884764a2 by merge, never rebase; every picked-up hunk was re-read and every check re-run on this head.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgWAJDEGE4g7p29M3zq

…tention hook, the restore refusals, the restored event and the two grant keys

ADR-0148 D5/D6, Rollout step 2. Declared ahead of the readers the ADR names:
the engine slice writes and reads, the Console lists, the cloud distribution
calls the hook.

Claude-Session: https://claude.ai/code/session_01WGufzetvYmJLKYUzZnwSke
Co-authored-by: Claude <noreply@anthropic.com>
…the emitted-event enums; regenerate the spec artifacts

DataEventType and RealtimeEventType list only emitted events (pinned equal in
realtime.test.ts); the engine's restore adds the member to both in the change
that emits it, spelled through RECORD_RESTORED_EVENT. The grant keys' planned
liveness rows cite the module that names them; state-counts and export-origins
regenerated.

Claude-Session: https://claude.ai/code/session_01WGufzetvYmJLKYUzZnwSke
Co-authored-by: Claude <noreply@anthropic.com>
…eness rows carry no author warning the lint cannot reach

Claude-Session: https://claude.ai/code/session_01WGufzetvYmJLKYUzZnwSke
Co-authored-by: Claude <noreply@anthropic.com>
…tract; the object file and its registration move to the engine slice

PLATFORM_OBJECTS_BY_PACKAGE means "a table exists" (lint and stack.zod.ts
read it so), so the name joins it only with the table. The spec now carries
RECYCLE_BIN_ENTRY_FIELDS, the one field list the object is built from, and
RecycleBinEntrySchema, its value shape.

Claude-Session: https://claude.ai/code/session_01WGufzetvYmJLKYUzZnwSke
Co-authored-by: Claude <noreply@anthropic.com>
…h its type aliases; ledger rows and regenerated artifacts

The module moves to recycle-bin.zod.ts so the docs generator gives it its own
reference page, and each exported schema gains its z.input type alias with an
isomorphism pin (ADR-0122). The strictness ledger classifies its four object
sites as wire (persisted runtime state the engine writes and reads), llms.txt
counts the new data schema, and api-surface, export-origins, declaration-map,
the reference docs and the strictness counts are regenerated.

Claude-Session: https://claude.ai/code/session_01WGufzetvYmJLKYUzZnwSke
Co-authored-by: Claude <noreply@anthropic.com>
…losed arm form

The claim declares `Clause-②: yes (widening)`; the changeset carried a
free-text arm the declaration rule does not accept. The prose moves to the
body's first sentence.

Claude-Session: https://claude.ai/code/session_01L6bhgWAJDEGE4g7p29M3zq
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 52 documentable anchor(s). ⚠️ 10 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/authorable-surface/data.json, packages/spec/authorable-surface/security.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

22 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 27b0bc79895e47eb416d0041385004cb92050925.

⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 10 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/authorable-surface/data.json, packages/spec/authorable-surface/security.json, …) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: sys_user (literal, 49 pages)
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 170 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 27b0bc79895e47eb416d0041385004cb92050925 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from f7507b4a76edb1211e2842ecff124a3204432d9d — the merge of head 25af14cf1fd660284bb2f44722a788ffbe6a0f32 into base 27b0bc79895e47eb416d0041385004cb92050925, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin f7507b4a76edb1211e2842ecff124a3204432d9d && git checkout f7507b4a76edb1211e2842ecff124a3204432d9d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 27b0bc79895e47eb416d0041385004cb92050925 25af14cf1fd660284bb2f44722a788ffbe6a0f32 && git checkout -B drift-repro 27b0bc79895e47eb416d0041385004cb92050925 && git merge --no-ff 25af14cf1fd660284bb2f44722a788ffbe6a0f32

node scripts/docs-audit/affected-docs.mjs --json 27b0bc79895e47eb416d0041385004cb92050925

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 27b0bc79895e47eb416d0041385004cb92050925 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#3 · os-sales · session_01L6bhgTqqeHSwZYJmApbDCa

Contract-review-claim: session_01L6bhgTqqeHSwZYJmApbDCa · head 25af14c · 2026-11-05T16:36Z

Full review at CONTRACT_REVIEW_TIER (published schema face: error-code-ledger.zod.ts, data/index.ts, data/recycle-bin.zod.ts, security/permission.zod.ts), run by an isolated at-tier subagent of this seat.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#3 · os-sales · session_01L6bhgTqqeHSwZYJmApbDCa

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 25af14cf1fd660284bb2f44722a788ffbe6a0f32
Local-runs: none
Scope: packages/spec/src/api/error-code-ledger.zod.ts, packages/spec/src/data/index.ts, packages/spec/src/data/recycle-bin.zod.ts, packages/spec/src/security/permission.zod.ts + docs/adr/0148-recycle-bin-separate-store-restore-under-original-ids-retention-in-days.md, packages/cloud-connection/src/runtime-config-plugin.ts, packages/plugins/plugin-security/src/permission-evaluator.ts, packages/core/src/security/effective-object-permissions.ts, packages/objectql/src/engine-cascade-planning.ts, packages/objectql/src/engine-delete-cascade.ts, packages/objectql/src/engine-referential-integrity.ts, packages/objectql/src/engine.ts, packages/spec/src/data/field.zod.ts, packages/spec/src/api/events.zod.ts, packages/spec/src/system/constants/platform-object-names.ts, packages/spec/src/system/constants/system-names.ts, packages/spec/liveness/permission.json, packages/spec/scripts/liveness/check-liveness.mts, packages/spec/scripts/check-error-code-provenance.ts, scripts/check-error-status-conformance.mjs, scripts/check-adr-anchors.mjs, scripts/adr-anchors/README.md, packages/spec/src/data/recycle-bin.zod.test.ts, packages/spec/src/api/error-code-ledger.test.ts, .changeset/30235-recycle-bin-spec-surface.md

Inputs: card #30235 (body and all five comments: claims 6659592591 and 6659650100, takeover 6662490518, claim 6662561348, dev report 6663467611), PR #30577 (body, the 29-path file list, the net diff against main at the head), the check-runs on the head, ADR-0148 on main, rulings 6629858351 (#3146) and 6659364907 (#30234). The rest of the diff (regenerated artifacts, content/docs/references/**, the strictness-ledger rows, llms.txt, the type-alias pin, the changeset) is the lane seat's ACCEPT at TIER_DEFAULT; the cited code was read, never reviewed. PR author is objectstack-fleet[bot], so no outside-relay login to name.

Gate verdicts: every check-run on the head, read at 2026-11-05T17:03Z once the last one completed — 65 runs, 57 success, 8 skipped by paths filter or opt-in (Lint UI, Temporal Conformance, UI Published Artifacts, Dogfood Verify CLI, the Dogfood Regression Gate matrix, Packed-tarball smoke, the schedule gate, the 18.x upgrade harness), 0 failed, 0 pending. The ten queue-required contexts: Lint & Repo Gates, TypeScript Type Check, Test Core (aggregate and 8/8 shards), Build Core, Governed Surface Queue Guard, Type Check UI, Test UI (aggregate and 16/16 shards), Build & E2E UI and Live E2E UI all success; Lint UI skipped (no ui/ path in the diff). These conclusions are this record's verdicts on every derived gate family (check:generated, check:liveness, check:error-code-provenance, check:adr-anchors, the changeset gates, typecheck, tests); nothing was built, run or re-run locally.

① Derived judgments

  1. @objectstack/spec/data public surface widens by 24 exports — 15 values (RECYCLE_BIN_OBJECT, RECYCLE_BIN_RETENTION_DAYS_ENV, RECYCLE_BIN_DEFAULT_RETENTION_DAYS, recycleBinRetentionRefusal, the six Zod schemas, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_RESTORE_REFUSAL_CODES, RECYCLE_BIN_RESTORE_REFUSAL_STATUS, RECORD_RESTORED_EVENT, RECYCLE_BIN_GRANT_KEYS) and 9 types; api-surface/data.json +24, export-origins +24, declaration-map +12, json-schema.manifest +6, authorable-surface/data.json +18 (the four object schemas' keys). Right: additive only, regenerated from the build, no name shadows an existing data/ export, and the Lint lane carrying check:dual-source-exports / check:exported-any is green.
  2. ErrorCode (the ApiErrorSchema.code accept set) grows by three under @objectstack/objectql. Right: SCREAMING_SNAKE; RESTORE is a token no standard member carries, so standardSynonymOf is undefined for all three (pinned in error-code-ledger.test.ts); the provenance gate reconciles stamp sites to rows and waivers to sites, never a row to a site, so a row ahead of its producer is admitted; the status-conformance deriver pins a status only for codes it finds a producer for, so 409 is a spec constant today and becomes a gate input when engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 stamps it. Registering ahead of the producer is what ADR-0148 D5 orders for this card.
  3. ObjectPermissionSchema (authoring, strict) accepts two new optional booleans, and EffectiveObjectPermissionSchema (wire, strip) gains them through the shared base, so the /auth/me/permissions shape may carry them (authorable-surface/security.json +4). Right: no Zod default (pinned: a bare entry does not grow a key); the allowRestore / allowPurge tombstones, the retired-default residue stage and the restore / purge guidance are untouched (pinned); checkWriteImpliesRead and checkScopeAgainstSuperUserBits do not read the new keys; ObjectPermissionVerbTarget, objectPermissionGrants, OBJECT_PERMISSION_KEY_ALIASES, core's GRANT_BITS and the evaluator's OPERATION_TO_PERMISSION are unchanged, so nothing grants, folds or materialises on them — correct while nothing reads them.
  4. Not widened, and rightly: DataEventType / RealtimeEventType (seat decision 1; pinned to stay out until the emitter adds the member); PLATFORM_OBJECTS_BY_PACKAGE (its header ties every row to the owning package's registration conformance test, so the row lands with the object file in engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 — seat decision 2 holds against the registry's own contract); SystemObjectName (a partial registry of 25 names — sys_attachment, sys_file and some ninety other sys_* objects live outside it — so RECYCLE_BIN_OBJECT living in data/ breaks no rule); OPERATION_TO_PERMISSION / DESTRUCTIVE_OPERATIONS (a dispatched restore / purge stays denied fail-closed, the ADR-0049 posture D2 keeps).
  5. liveness/permission.json gains two planned rows naming engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 / ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239; state-counts/permission.md 42 → 44. Right: planned is in the gate's vocabulary (MARKER_RE.planned matches the [PLANNED] describe prefix case-insensitively; EVIDENCE_SCANNED_STATUSES includes it) and the Spec property liveness check-run is green; authorWarn is omitted for the reason stated (the author-side lint resolves the per-object objects entry's keys without fanning out, so a warned row would warn nobody), and the gate forbids authorWarn only on a live row.
  6. Strictness ledger: four z.object sites in recycle-bin.zod.ts triaged wire. Right: engine-written persisted state with no authoring door; the module's one host-written input is a bare number schema.
  7. Tests: recycle-bin.zod.test.ts (16 cases), the ledger pin, the type-alias pin +6. Right: the pins hold the spellings the readers will assert by value; the six new isomorphic pins are correct (no default, no transform, so z.input equals z.infer).

② Semver level

.changeset/30235-recycle-bin-spec-surface.md: @objectstack/spec: minor, Clause-②: yes (widening), Metadata-protocol: added. Right on all three: the diff publishes only additions — new exports, three new ErrorCode members, two new authorable keys on the per-object permission entry, two new optional wire keys on the effective-permission response; nothing is removed, tombstoned, refused or re-meant, so added takes at least minor on the one package the diff moves (AGENTS.md Post-Task Checklist #3); no other released package moves; no skip-changeset. The PR body carries the same two declaration lines, the changeset's Clause-②: arm is in the closed form (corrected at the head), and Check Changeset is green. The changeset body names every new spelling and says nothing reads them yet, which is what the tree does.

Clause-②: yes (widening) — confirmed against the diff.

③ Boundary flags

Dev report 6663467611: open_questions: []; five deviations, three out_of_scope_findings. Each answered:

  • D1 commit trailers (model-free pair, harness Co-Authored-By not used): conforms to AGENTS.md (an agent commit ends with Claude-Session + Co-authored-by: Claude; the harness trailer is a reporting exemption, not a rule). Verified on the head commit. The merge commit 8307de6d carrying no trailer is a merge commit; the pre-push hook passed it. No action.
  • D2 harness post-create step not taken (no assignee, no reviewer on pr_create): conforms — the dispatched executor never writes the assignee; the seat sets it at hand-over. No action.
  • D3 PR-subscription posture not taken: accepted; this record reads the head's check-runs itself.
  • D4 branch claude/project-thread-uwrsn3 instead of claude/issue-30235-slug: accepted — the newest Claim: (6662561348) names this branch as the card thread's own, and the PR-body guards (claim · duplicate · Part-of · single-writer path) check-run is green on the head. Implemented-by: signs it.
  • D5 no scripts/adr-anchors entry for recycle-bin.zod.ts — answered from the gate: check-adr-anchors.mjs verifies the registered entries (the file exists, every listed id resolves to a record, every id still appears in the file) and audits that every cited ADR-NNNN in the tree resolves; it never demands an entry for a file. The README's rule is to add one where the decision would look arbitrary to a reader of that file alone; recycle-bin.zod.ts cites ADR-0148 and the decision (D1 to D5) in every docblock, with the invariant at the spot it protects (zero refused, never "purge now" or "keep forever"; days, never plans; new spellings, never the tombstones). Not owed; no action. The seat may still add one as a convenience, naming the retention refusal as the invariant.
  • O1 GRANT_BITS, ObjectPermissionVerbTarget / objectPermissionGrants, OPERATION_TO_PERMISSION list neither key — carrier engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237: confirmed by reading, with one addition: the '*' wildcard materialisation and the verb-less-entry fold in effective-object-permissions.ts both key on GRANT_BITS, so a wildcard entry carrying only the new keys materialises nothing and an entry granting only them is not folded in — correct today, on engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237's list beside the map and the verb-target type (that type widening is a spec edit riding the engine card, with its own Clause-②: yes).
  • O2 CAPS in PermissionPreview.tsx shows neither key — carrier ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239: confirmed.
  • O3 skills/objectstack-api/SKILL.md says there is no recycle bin — carrier engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237: confirmed; true until the engine slice ships; skills/** is Tier H and untouched here.

Escalations: none.

④ Design judgment

packages/spec/src/data/recycle-bin.zod.ts — against ADR-0148 D1 to D5 and D7 (ratified 6659364907) and its first consumers (#30237 the engine; the cloud distribution as the hook's caller):

  • Names: sys_recycle_bin, OS_RECYCLE_BIN_RETENTION_DAYS, default 30 — D7 item 1. Holds. OS_RECYCLE_BIN_RETENTION_DAYS is Prime Directive [WIP] Create a new release version #9's OS_{DOMAIN}_{NAME} form.
  • The hook: (token: string | undefined) => number | undefined takes the input resolveFeatures takes on main (runtime-config-plugin.ts, (token: string | undefined) => RuntimeFeatureOverrides), answers days or nothing; RecycleBinRetentionDaysSchema refuses 0, negatives, fractions, NaN, Infinity, null, strings and booleans with a refusal that names the source and the fix and no plan, tier or entitlement word (pinned); the env schema refuses the same plus leading zeros and whitespace — D6 left the refusal text to this card, and "no leading zero" is a defensible narrowing of "the decimal digits of a positive whole number". Holds.
  • The entry: object_name, record_id, record_count, snapshot, deleted_by, deleted_at, retention_days, purge_after plus id, every field readonly — D1's "what was removed, who, when, the stamped deadline" plus the days answered, so the sweep reads one column (D3) and the toast shows a date. Every Field.* builder used exists on main; id: Field.text({ readonly: true }) follows the sys_attachment / sys_metadata_* precedent (those also say required: true; a harmless difference). deleted_by is optional in the value schema (a system-context delete has no principal), consistent with D2 because a principal-less entry is then admin-only. Holds.
  • The snapshot: rows, master first, plus clearedReferences; D4's secrets-out rule is prose the engine enforces, since no shape can. Holds.
  • The refusals: D2's three reasons exactly, all 409 (the entry is intact; the live state conflicts). Holds.
  • The event: data.record.restored follows events.zod.ts's data.record.{action} pattern and stays out of the emitted enums until emitted — right, a subscription must never wait on a name that does not fire. Holds.
  • The grants: RECYCLE_BIN_GRANT_KEYS equal the permission keys (pinned through the parse). Holds.
  • Break attempt 1, multi-valued lookups — should-fix. RecycleBinClearedReferenceSchema's docblock and describe fix the re-link rule as "re-linked on restore only if the field still holds no value". On main the cascade walk clears a set_null member of a multi-valued lookup by removing that member and keeping the rest (engine-cascade-planning.ts, remainderAfterMemberRemoval; engine-referential-integrity.ts names the empty array as the multi-value "no link"), so after the delete the field still holds its other members and the spec's sentence, read literally, never re-links a multi-valued reference — while D2 rules "re-linked on restore only if nothing has changed it since" (the Salesforce rule it cites). The shape already carries what both arities need (field plus the removed value); only the sentence is wrong for one arity. Fix: restate the rule as the ADR's — a single-valued field is re-linked when it still holds no value, a multi-valued one when it no longer holds the member — one docblock and describe edit plus gen:docs; carrier this PR, or engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 before it implements re-link. Not a FAIL: no reader exists, the ADR binds the reader, and the shape needs no change.
  • Break attempt 2, predicate deletes: a delete(object, { where }) walks N masters as one cascade set (engine.ts, objectql: since #26930 a predicate delete walks every matched row one by one; 1,001 rows cost ~1.7 s (18×), and rest's nested-object-door cap test now nears its 5 s budget in the merge queue #27004) and the entry fixes one record_id. D4 keeps bulk out of v1 (one delete and its cascade; bulk later, with a cap), so v1's engine writes one entry per master, and when bulk lands record_id loosens as a widening. Holds for v1; noted, no finding.
  • Break attempt 3, managedBy against D4's purge-on-organization-delete: engine-owned rows are kept on an organization delete (engine-cascade-planning.ts, seat decision 6307135388) and the test builds the object with managedBy: 'engine-owned'; the object file is engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237's, so the engine card owes D4's "an organization's entries go with it" against whatever managedBy it picks. Not this PR's surface; a carrier note for engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237.
  • Prime Directive ✨ Set up Copilot instructions #2: recycleBinRetentionRefusal is a refusal-text builder on the hook-refusal-codes pattern, not runtime logic. Holds.

packages/spec/src/security/permission.zod.ts — against D2 / D5 and its first consumer (permission-evaluator.ts through OPERATION_TO_PERMISSION, #30237):

  • Two optional booleans inside ObjectPermissionBaseSchema, after the tombstones, no default — the allowExport precedent and the right call: a default would materialise the key into every parsed entry, and an older runtime refuses a key it does not know. The describes carry [PLANNED] (the liveness marker) and "not read yet"; no tracker number in a runtime string. The tombstones' prescriptions ("delete the key; the bit returns with M2") stay true on this tree: nothing reads the new keys yet, so pointing an author at them now would be the false affordance ADR-0049 removed. Holds.
  • Per-object placement follows D5's own sentence (the evaluator's map targets object-permission keys), so "an admin sees all" is manageRecycleBin per object or on the '*' wildcard; the D7 ratification named "the two permission keys" without fixing the level, so the level is within the card's D6 remit. Holds.
  • Should-fix (prose, carrier engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237): the describes leave two relations unstated that allowExport states for itself — whether modifyAllRecords implies the grants (the evaluator's bypass is derived from map plus set, so the answer appears when engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 maps them) and whether either is bounded by allowRead (a restore writes rows back that the caller may not be able to read). One sentence each, written when the reader lands so the claim is never ahead of enforcement; in the same stroke the restore / purge guidance and the allowRestore / allowPurge tombstone text are re-pointed at the live keys, and the liveness/permission.json notes on allowRestore / allowPurge ("drop the tombstone only if M2 respells it") are re-read against ADR-0148 D5, which answers them: respelled, and the tombstones stay through the ADR-0087 kit schedule.

packages/spec/src/api/error-code-ledger.zod.ts — against ADR-0112 D3 admission and the provenance gate: three rows under @objectstack/objectql, each with a comment stating the status, the reachability reading and the "ahead of producer" fact; the ledger's own rules (casing, no standard synonym, a framework-package owner) hold, and the gate's direction (sites to rows) admits a row with no site. Holds.

packages/spec/src/data/index.ts — a plain export * with an ADR-0148 D5 comment, in the barrel's existing order; no name in the module shadows a data/ export. Holds.

Must-fix: none. Should-fix: 2 — the cleared-reference rule's wording for multi-valued lookups (this PR or #30237 before re-link lands); the two grants' unstated relations and the tombstone / guidance / liveness prose that re-points at them (carrier #30237, with the reader).

Implemented-by: claude/project-thread-uwrsn3
Reviewed-by: session_01L6bhgTqqeHSwZYJmApbDCa

VERDICT: PASS


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#3 · os-sales · session_01L6bhgTqqeHSwZYJmApbDCa

维护者速读

  • 改了什么:在 @objectstack/spec 里声明回收站的契约:sys_recycle_bin 条目的字段表与值形状、快照形状、宿主保留期钩子(只认正整数天)、三个恢复拒绝码(409)、data.record.restored 事件名、对象权限上的两个新键 allowRestoreOwnDeleted / manageRecycleBin;运行时一行未动,删除仍是物理删除。
  • 为什么改:ADR-0148 D5 把这些拼写交给本卡,引擎(engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237)和控制台(ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239)要在它上面建;没有它,删除仍然不可恢复。
  • 风险与回滚:纯新增,两个权限键可选、无默认值,已有元数据和已解析的权限条目不变;已退役的 allowRestore / allowPurge 仍然被拒。回滚就是还原本 PR。
  • 先看:packages/spec/src/data/recycle-bin.zod.ts(钩子签名、拒绝文案、快照里被清空的引用)、packages/spec/src/security/permission.zod.ts(两个新键,标 [PLANNED])、packages/spec/src/api/error-code-ledger.zod.ts(三个拒绝码先于生产者登记)。
  • 两分钟验证:pnpm --filter @objectstack/spec exec vitest run --project local src/data/recycle-bin.zod.test.ts,预期 1 个文件、16 个用例全过。
  • 需要你做的:无,席位落地。

席位意见:fable 契约复审一轮 PASS,无必改。两条建议都写的是引擎将来的行为(多值查找字段的回链规则;两个权限键与 modifyAllRecords / allowRead 的关系),本 PR 不读它们,ADR-0148 约束读者,所以随实现方 #30237 一并改,不在这里补一轮。

席位核对 — ACCEPT · domain:spec#3 · head 25af14cf1fd660284bb2f44722a788ffbe6a0f32

  • Shape: 29 files (+852 −18), draft, base main, first content line Fixes #30235. Hand-written: packages/spec/src/data/recycle-bin.zod.ts and its 16-case test, the two optional keys in permission.zod.ts with planned rows in liveness/permission.json, three rows in error-code-ledger.zod.ts and their pin, the type-alias pin (+6), the data index export, the changeset. The rest is regenerated (api-surface, export-origins, declaration-map, authorable-surface, json-schema manifest, content/docs/references/**, strictness-ledger rows and counts, liveness state counts, llms.txt). No file outside packages/spec, content/docs/references/**, docs/audits/2026-07-unknown-key-strictness-ledger* and .changeset/; no content/docs/releases/ edit.
  • Premise measured: git grep -E 'sys_recycle_bin|RECYCLE_BIN_|allowRestoreOwnDeleted|manageRecycleBin|RESTORE_PARENT_PURGED' origin/main -- packages ui at 739c9727 answers 0 files, so none of the spellings exists on main; the evaluator on main keeps restore / purge out of OPERATION_TO_PERMISSION and in DESTRUCTIVE_OPERATIONS (permission-evaluator.ts :61-104), the fail-closed backstop the changeset cites.
  • Gates: check-runs on this head: 65, 57 success, 8 skipped, 0 red; check-expected-skips --pr 30577: all 8 skips in main's roster (exit 0). Lint & Repo Gates and TypeScript Type Check both success on 25af14cf. Dev report 6663467611: 106/106 derived gates exit 0, --ran 0 NOT-MEASURED; spec 816 files (25660 passed), typecheck exit 0; plugin-security, core, objectql typecheck exit 0 and plugin-security 244 files (5379 passed). git merge-tree against main 739c9727 merges clean. No ablation (declarations only) and no dogfood battery (no !, no (narrowing)), both right for this diff.
  • Contract review: 6664134926 on 25af14cf: PASS, Served-tier: CONTRACT_REVIEW_TIER, no must-fix, two should-fix (carried below). Its ③ answers all five dev deviations and the three out-of-scope carriers.
  • Declarations: Clause-②: yes (widening), Metadata-protocol: added, @objectstack/spec minor, in the body and the changeset alike. Skills-docs: follow-up #30237 holds: skills/objectstack-api/SKILL.md :268 and :417 say the trash surface is retired and there is no recycle bin, still true at this head. ADR-0087 not needed. Changeset sentences checked against the diff: the field list, the hook signature, the 409 status, "no default, so no parsed entry grows a key" (pinned in the test), and "their schema descriptions say they are not read yet" (permission.zod.ts :674-675).
  • Accepted deviations: the card-thread branch claude/project-thread-uwrsn3 (the claim's measured exception); no scripts/adr-anchors entry (check-adr-anchors.mjs is entry-driven, so none is owed); the model-free commit trailers. mcp_calls: 7, all reads.
  • Carried: to engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237: should-fix 1, RecycleBinClearedReferenceSchema's re-link sentence restated as ADR-0148 D2's rule for both arities (a multi-valued lookup re-links when it no longer holds the member) before the engine implements re-link; should-fix 2, the two grant keys' describes state their relation to modifyAllRecords and allowRead, and the restore / purge guidance, the allowRestore / allowPurge tombstone text and the liveness/permission.json notes are re-pointed at D5's respelled answer; GRANT_BITS, the '*' wildcard materialisation, the verb-less fold, ObjectPermissionVerbTarget / objectPermissionGrants and OPERATION_TO_PERMISSION gain both keys and the liveness rows flip to live; the object file's managedBy answers D4's "an organization's entries go with it"; the Skills-docs rewrite. To ui: the admin recycle-bin page (list, restore, empty) and the 已删除 · 撤销 toast (#3146 slice 4) #30239: CAPS in PermissionPreview.tsx.
  • Landing: not governed (check-governed-merges --pr 30577: 0 of 29 paths, 870 lines ≤ 3000). The hand-off is pr_ready plus automerge_enable, through the merge queue.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:data size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec: declare the recycle-bin surface — the sys_recycle_bin object, the retention hook and the restore refusals (#3146 slice 2)

1 participant