Skip to content

feat(security): read the recycle bin's grants for restore and purge (#30237 PR 4) - #31438

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-py4hal
Nov 8, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-py4hal

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy

Body: seat refresh (round 2) · 2026-11-08T12:15Z

Requested by Leehom · project thread

Part of #30237

Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: follow-up #30847

Spec consent: 6718336940 (permission.zod.ts ObjectPermissionVerbTarget + objectPermissionGrants Q5 cells + describes/docblock; liveness/permission.json two rows planned→live) and 6720657486 (the allowRestore / allowPurge tombstone prescriptions and the restore / purge guidance strings name the recycle bin's grants). Reviews: 6719122724 (round 1), 6721290796 (delta, head 95d2a17). PR 4 of 5 (hand-over 6690307585): the recycle-bin permission reader. PR 5 (REST doors) follows after this merges.

维护者速读

  • 改了什么:回收站的两个权限键开始生效:restore 读 allowRestoreOwnDeleted,purge(清除单条、清空、永久删除)读 manageRecycleBin;普通成员只能恢复自己删除的记录,恢复别人删的需要 manageRecycleBin;被组织墙拒绝的调用者看不到任何回收站条目。共享层与 explain 按写入类别判定生命周期动词:按 id 的永久删除(purge)问 canDelete,无删除权限的调用者得 403(仅有编辑共享不够),security/explain 也按删除门报告 purge。
  • 为什么改:PR 1–3 已上线回收站,但两个键无人读取,非系统调用者的 restore/purge 一律被拒,回收站对用户不可用;同时关闭 PR 2 评审 should-fix 1(无活动组织的调用者 purge/empty 不受组织范围约束)。键一旦被读取,purge 便能到达共享层,故共享门与 explain 必须按删除类判定(评审 6719122724 SF1/SF2)。
  • 风险与回滚:放宽(Clause-② widening):持有两键或 modifyAllRecords 的人获得 restore/purge;allowDelete 不蕴含任何一项(Q5 = A)。无解析器或解析器抛错时,恢复他人条目一律拒绝(fail closed)。共享层对按 id 的 purge 是收紧方向(与普通 delete 同门)。回滚即 revert,无数据迁移。
  • 先看:packages/objectql/src/recycle-bin/restore.ts(assertCallerMayRestoreEntry,自有条目检查);packages/objectql/src/recycle-bin/purge.ts(recycleBinWallDenies 与 recordedVerdict);packages/plugins/plugin-sharing/src/sharing-plugin.ts(按写入类别选门);packages/core/src/security/lifecycle-verb-rls-operation.ts(rlsOperationForVerb / LIFECYCLE_VERB_RLS_OPERATION 移入 core 并导出,plugin-security 与 plugin-sharing 共用);packages/spec/src/security/permission.zod.ts(objectPermissionGrants 两个新单元与墓碑文案)。
  • 两分钟验证:pnpm --filter @objectstack/objectql exec vitest run src/recycle-bin/restore.test.ts src/recycle-bin/purge.test.ts 与 pnpm --filter @objectstack/plugin-sharing exec vitest run src/lifecycle-verb-write-gate.test.ts,预期全部通过,含「another member's entry … 403」「tenant wall」与「refuses FORBIDDEN when the row is not the caller's to delete」。
  • 需要你做的:无,席位落地(契约复核由席位执行)。

What changes

The mapping (plugin-security). OPERATION_TO_PERMISSION gains restore → allowRestoreOwnDeleted and purge → manageRecycleBin, spelled from RECYCLE_BIN_GRANT_KEYS. The evaluator answers both through the one fold (objectPermissionGrants, #18785); DESTRUCTIVE_OPERATIONS stays as the backstop for any future unmapped destructive verb. MODIFY_ALL_WRITE_KEYS now derives both keys, and crudBucketForOperation folds restore → update, purge → delete. The system context is unchanged.

The fold (spec, under consent 6718336940). objectPermissionGrants answers the two keys as Q5 = A: each bounded by read; modifyAllRecords implies both; manageRecycleBin implies allowRestoreOwnDeleted; allowDelete implies neither. OBJECT_PERMISSION_VERBS and can() are unchanged. Core's GRANT_BITS adds the two keys, so /me/permissions reports them.

The write-class map moves to core. LIFECYCLE_VERB_RLS_OPERATION / rlsOperationForVerb (transfer / restore → update, purge → delete) are now declared in packages/core/src/security/lifecycle-verb-rls-operation.ts and exported from @objectstack/core; plugin-security's module re-exports them, so its importers are unchanged and plugin-sharing reads the same map.

Every write-class site reads rlsOperationForVerb: rls-compiler.ts mapOperationToRLS, security-plugin-rls-filter.ts, security-plugin-addressed-writes.ts, security-plugin-cbp-write-gate.ts, platform-ownership-policies.ts. The authz middleware's epoch bump lists purge and restore beside the other writes.

The sharing write gate judges the write class (review SF1, plugin-sharing). buildSharingMiddleware picks its gate by rlsOperationForVerb(op): a by-id purge (the permanent delete) is asked admitsByIdWrite(object, id, 'delete', …), exactly as an ordinary delete is, so a caller without delete authority on the row is refused 403 FORBIDDEN; an edit share no longer suffices. A bulk purge is scoped by buildWriteFilter(object, ctx, 'delete'). The recycle bin's own doors (restore(entryId), purge(entryId), empty(object)) dispatch with no id and no AST: they address no live row, so the gate passes them on untouched.

security/explain reports by the write class (review SF2, plugin-security). explain-engine.ts derives writeClass = rlsOperationForVerb(engineOp) and uses it for the record's sharing gate, the authored-deferral verb, the queue guard and the fault sentence: purge is explained against canDeleteRecord, never canEditRecord, so explain no longer reports an edit share as admitting a purge the door refuses.

The engine's own-entry check (restore.ts). After the restore dispatch clears the evaluator, assertCallerMayRestoreEntry refuses 403 PERMISSION_DENIED when the entry's deleted_by is not the caller's userId, unless the caller's effective permissions (the registered _effectiveObjectPermissionsResolver) grant manageRecycleBin on the entry's object. No resolver, or a resolver that throws → refused. attributedUserId is not consulted (attribution only). No new engine member: the restore() / purge() / empty() host literals gain closures over existing state (amendment 6718183894).

The tenant wall on the bin (should-fix 1, purge.ts). recycleBinWallDenies answers deny for a caller the Layer-0 verdict denies: restore → null, purge → false, empty → 0, before anything is read. The purge and empty executors re-check against opCtx.tenantLayer0Verdict and pass { recordedVerdict } to the driver, so the removal is scoped by the verdict the security layer recorded. restore's executor makes the same check.

The retired keys' prose (spec + lint, under consent 6720657486). The allowRestore / allowPurge tombstone prescriptions, and the restore / purge guidance strings, now say the key granted nothing when it was retired and name the recycle bin's grants (allowRestoreOwnDeleted, manageRecycleBin, ADR-0148) instead of promising the bit back with M2; "Delete the key." stays its own sentence, so the lint's retiredKeyRemedy hint is unchanged. packages/lint/src/rule-explanations.ts says the same. References regenerated.

verify / core. observeWrites (packages/verify/src/handle.ts) now sees purge and restore. resolve-user-grants-cache.ts WRITE_OPERATIONS stays insert/update/delete: the bin never takes a platform object, and every object that cache watches is a sys_ object (comment added).

Docs. content/docs/permissions/system-context.mdx rows 29d/29e own the two new elevation reads (check:system-context-census). permissions/permissions-matrix.mdx (lifecycle callout) and protocol/objectql/security.mdx (the two flag rows and the retired note) now describe the live keys. References and liveness counts regenerated by check:generated --fix.

Tests

  • permission-evaluator.test.ts: named Q5 cells; exhaustive 3-state sweep over the six bits the bin keys read (729 × 2); a present/absent sweep over all ten bits × eight verbs (no bit widens another verb); cross-set read half.
  • security-plugin.test.ts: the old fail-closed pins of the unmapped verbs are rewritten: the object gate answers restore / purge from their keys and reads no row.
  • restore.test.ts: another member's entry refused with no resolver, with allowRestoreOwnDeleted only, with allowDelete only, with manage-without-read, with manage on another object, and with a throwing resolver; allowed with manageRecycleBin or modifyAllRecords; own entry asks no resolver; wall deny → null; recorded deny → null.
  • purge.test.ts: wall deny → false / 0 with no dispatch; recorded deny → false / 0; recorded organization verdict scopes the removal (cross-tenant purge through recordedVerdict); system exempt.
  • plugin-sharing/src/lifecycle-verb-write-gate.test.ts (new): a by-id purge is asked delete and refused FORBIDDEN when the row is not the caller's to delete, passed when admitted; a bulk purge is scoped by the delete filter; the bin's own restore / purge dispatches pass untouched with nothing asked; the ordinary by-id delete stays on the same gate.
  • plugin-security/src/explain-lifecycle-verb-sharing-gate.test.ts (new): purge and delete ask canDeleteRecord, not canEditRecord, and report the row not writable; update asks canEditRecord (control).
  • permission.test.ts (spec): the fold cells; the retirement pins name ADR-0148 and manageRecycleBin, not M2. validate-retired-permission-residue.test.ts (lint): the new explanation. effective-object-permissions.test.ts (core): the super-user wildcard shape.
Ablations (21, each red, each restored to HEAD by scripts/ablation-replace.mjs)

Mutations by scripts/ablation-replace.mjs (anchor must hit once; restore proven blob == HEAD). A* run restore.test.ts + purge.test.ts, B* permission-evaluator.test.ts + security-plugin.test.ts, C* spec permission.test.ts, D1–D2 plugin-sharing lifecycle-verb-write-gate.test.ts, D3 plugin-security explain-lifecycle-verb-sharing-gate.test.ts.

  • A1-not-manager-refusal: Tests 4 failed | 84 passed; restored=1; e.g. "refuses another member's entry for allowRestoreOwnDeleted only, 403"
  • A2-no-resolver-refusal: Tests 1 failed | 87 passed; restored=1; e.g. "refuses another member's entry, 403, when no permission resolver answers: it fails closed"
  • A3b: Tests 1 failed | 41 passed; restored=1; e.g. "refuses, 403, when the resolver throws: it fails closed"
  • A4-own-entry-check-call: Tests 6 failed | 82 passed; restored=1; e.g. "refuses another member's entry, 403, when no permission resolver answers: it fails closed"
  • A5-engine-wall-deny: Tests 3 failed | 85 passed; restored=1; e.g. "purge answers false for a caller the wall denies, before reading or dispatching anything"
  • A6-recorded-deny: Tests 3 failed | 85 passed; restored=1; e.g. "purge answers false, and removes nothing, when the security layer recorded a deny verdict on the dispatch"
  • A7-purge-recorded-scope: Tests 1 failed | 87 passed; restored=1; e.g. "purge's removal is scoped by the recorded verdict: an organization it does not name keeps its entry"
  • A8-empty-recorded-scope: Tests 1 failed | 87 passed; restored=1; e.g. "empty's removal is scoped by the recorded verdict, not by the caller's own organization"
  • A9-restore-executor-wall: Tests 1 failed | 87 passed; restored=1; e.g. "answers null when the security layer recorded a deny verdict on the dispatch"
  • A10-purge-pre-read-wall: Tests 1 failed | 87 passed; restored=1; e.g. "purge answers false for a caller the wall denies, before reading or dispatching anything"
  • A11-empty-pre-wall: Tests 1 failed | 87 passed; restored=1; e.g. "empty answers 0 for a caller the wall denies, and removes no organization's entries"
  • A12-restore-pre-wall: Tests 1 failed | 87 passed; restored=1; e.g. "answers null for a caller the tenant wall denies (no active organization), and leaves the entry"
  • B1-restore-map-row: Tests 9 failed | 260 passed; restored=1; e.g. "the Modify-All write-bypass CLASS is exactly what this file derives from its own dispatch map"
  • B2-purge-map-row: Tests 9 failed | 260 passed; restored=1; e.g. "the Modify-All write-bypass CLASS is exactly what this file derives from its own dispatch map"
  • B3-purge-maps-to-restore-key: Tests 5 failed | 264 passed; restored=1; e.g. "the Modify-All write-bypass CLASS is exactly what this file derives from its own dispatch map"
  • C1-spec-manage-reads-delete: Tests 1 failed | 121 passed; restored=1; e.g. "[engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 Q5 = A] folds the recycle-bin keys: bounded by read; manage implies restoring your own; modifyAll impl"
  • C2-spec-restore-unbounded: Tests 1 failed | 121 passed; restored=1; e.g. "[engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 Q5 = A] folds the recycle-bin keys: bounded by read; manage implies restoring your own; modifyAll impl"
  • C3-spec-manage-no-own-restore: Tests 1 failed | 121 passed; restored=1; e.g. "[engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237 Q5 = A] folds the recycle-bin keys: bounded by read; manage implies restoring your own; modifyAll impl"
  • D1-sharing-write-class: Tests 3 failed | 3 passed; restored=1; e.g. "asks canDelete (verb delete) of a by-id purge, and refuses FORBIDDEN when the row is not the c"
  • D2-sharing-bin-door-skip: Tests 2 failed | 4 passed; restored=1; e.g. "passes the recycle bin's own restore(entryId) dispatch on untouched: no id, no AST, nothing asked"
  • D3-explain-write-class: Tests 1 failed | 2 passed; restored=1; e.g. "purge asks canDeleteRecord, not canEditRecord, and reports the row not writable"

Acceptance notes

  • The purge(entryId) pre-dispatch entry read cannot carry the recorded verdict: it runs before the dispatch, so it is scoped by the engine's own verdict (which grants no exemption). The removal itself carries recordedVerdict.
  • plugin-security records opCtx.tenantLayer0Verdict only on AST operations, so for the AST-less restore / purge dispatches it is normally absent today and the engine verdict decides. The recorded-verdict path is exercised by a test middleware.
  • The CBP master gate and the delegated-admin gate do not judge id-less restore / purge (no predicate path; RBAC sys_ tables only), as before.
  • Accepted deviation (review 6719122724 (d)): the authz middleware's bulk-guard site still compares the operation literal rather than reading rlsOperationForVerb. It is AST-only, and [finding] The bulk AST write path passes opCtx.operation raw, so purge / transfer / restore derive no row scope while update / delete now do (#7665 asymmetry) #7809 keeps purge / restore AST-free, so no lifecycle verb reaches it.
  • The sharing gate's pass-through for the bin's id-less, AST-less restore / purge dispatches keeps restore (write class update) out of the bulk path; the delta review (6721290796) judged it unreachable by a request a caller can shape. An ordinary update / delete without id or AST is not passed through.
  • A super-user wildcard's /me/permissions map now shows the two bin keys on sys_ objects too, where the engine refuses to bin them; the map reports the grant, not the bin's reach.
  • The remaining "returns with M2" texts outside this PR's surface (conversion and semantic migration entry 18 and its registry row, the ui permission slice, the metadata plugin.ts comment, the dead liveness rows, the lint retiredKeyRemedy docblock) are tracked in permission: four texts still say allowRestore / allowPurge "return with M2" after #30237 PR 4 corrected the tombstones (migration entry 18, conversion entry 18, ui permission slice, metadata plugin comment) #31508.

Verification

Head 95d2a17f (origin/main db502314 merged). 39 files changed, +1088 / −325.

  • node scripts/pm/dispatch-gates.mjs --commands: 124 families; every one run with its exit captured before any pipe; --ran reconciliation: 124 derived, 124 run, 0 NOT-MEASURED, 0 UNRUN; 124/124 exit 0 on the final tree (after git fetch --unshallow and a full pnpm --workspace-concurrency=2 build).
  • check:system-context-census (two new isSystem reads) answered by rows 29d/29e + --write.
  • pnpm --filter {objectql,plugin-security,plugin-sharing,core,verify,spec,lint} typecheck: exit 0. eslint over the touched source: exit 0.
  • Tests:
Suite Files Tests
plugin-security (full) 250 5873
plugin-sharing (full) 71 1470
objectql (full) 570 11570
core (full) 143 3242
lint (full) 197 8363
spec security / conversions / migrations 39 1348
verify handle.observe-writes.test.ts 1 11
repo projects — core 96, objectql 5, spec 1556

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J

…r restore and purge (wip)

The evaluator maps restore to allowRestoreOwnDeleted and purge to
manageRecycleBin; plugin-security's write-class sites read
rlsOperationForVerb; the engine refuses a caller the tenant wall denies,
scopes the bin's removals by the recorded verdict, and restores another
caller's entry only for a recycle-bin manager.

Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
Co-authored-by: Claude <noreply@anthropic.com>
…o liveness rows go live

ObjectPermissionVerbTarget gains allowRestoreOwnDeleted and manageRecycleBin,
and objectPermissionGrants answers them as Q5 = A rules: each is bounded by
read, modifyAllRecords implies both, manageRecycleBin implies
allowRestoreOwnDeleted, and allowDelete implies neither. The [PLANNED]
describes and docblock now say what reads the keys, and the two liveness rows
cite the evaluator mapping and the engine's own-entry check.

Spec consent: 6718336940.

Co-Authored-By: Claude <noreply@anthropic.com>
… check and the tenant wall on purge/empty/restore

The evaluator's restore/purge cells (named, exhaustive over the bits the bin
keys read, and a present/absent sweep over all ten bits), the own-entry
check (another member's entry refused without manageRecycleBin, with a
throwing resolver, and with no resolver), and the deny verdict on purge,
empty and restore, engine and recorded. The old fail-closed pins of the
unmapped verbs are rewritten for the mapping. verify's write observer sees
purge and restore; the grants cache keeps its three write verbs.

Co-Authored-By: Claude <noreply@anthropic.com>
…; core pins the bin keys on a super-user wildcard

Regenerated by check:generated --fix (gen:docs, gen:liveness-counts).

Co-Authored-By: Claude <noreply@anthropic.com>
… elevation reads

Rows 29d (recycleBinWallDenies) and 29e (assertCallerMayRestoreEntry); the
site register regenerated by check-system-context-census --write.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 7 package(s): @objectstack/core, @objectstack/lint, @objectstack/objectql, @objectstack/plugin-security, @objectstack/plugin-sharing, @objectstack/spec, @objectstack/verify, touching 44 documentable anchor(s). ⚠️ 4 changed file(s) yielded no anchor (packages/core/src/security/index.ts, packages/core/src/security/resolve-user-grants-cache.ts, packages/spec/liveness/permission.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

35 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 7d0b47ca19c8c41563964b3889ae81e8e015788e.

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

What this run could not see
  • 4 changed file(s) yielded no anchor (packages/core/src/security/index.ts, packages/core/src/security/resolve-user-grants-cache.ts, packages/spec/liveness/permission.json, …) — pages documenting those are invisible to this run
  • 2 anchor(s) matched too much of the corpus to be a work list: ObjectQL (symbol, 80 pages), PERMISSION_DENIED (literal, 51 pages)
  • 6 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 64 of 227 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 104 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 — 182 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 7d0b47ca19c8c41563964b3889ae81e8e015788e → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 23e7487366c828a5040bf62fb348e81d2c20442e — the merge of head 95d2a17f6e585d9503a4ac3e7ca1626683ea27d7 into base 7d0b47ca19c8c41563964b3889ae81e8e015788e, 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 23e7487366c828a5040bf62fb348e81d2c20442e && git checkout 23e7487366c828a5040bf62fb348e81d2c20442e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7d0b47ca19c8c41563964b3889ae81e8e015788e 95d2a17f6e585d9503a4ac3e7ca1626683ea27d7 && git checkout -B drift-repro 7d0b47ca19c8c41563964b3889ae81e8e015788e && git merge --no-ff 95d2a17f6e585d9503a4ac3e7ca1626683ea27d7

node scripts/docs-audit/affected-docs.mjs --json 7d0b47ca19c8c41563964b3889ae81e8e015788e

⚠️ 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 7d0b47ca19c8c41563964b3889ae81e8e015788e → 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:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: aa6ae4c43c896a5836223ceb0719b15cbdd517cb
Local-runs: none
Scope: packages/spec/src/security/permission.zod.ts + packages/plugins/plugin-security/src/permission-evaluator.ts, packages/plugins/plugin-security/src/lifecycle-verb-rls-operation.ts, packages/plugins/plugin-security/src/rls-compiler.ts, packages/plugins/plugin-security/src/security-plugin-rls-filter.ts, packages/plugins/plugin-security/src/security-plugin-addressed-writes.ts, packages/plugins/plugin-security/src/security-plugin-cbp-write-gate.ts, packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/platform-ownership-policies.ts, packages/plugins/plugin-security/src/explain-engine.ts, packages/core/src/security/effective-object-permissions.ts, packages/core/src/security/resolve-user-grants-cache.ts, packages/objectql/src/recycle-bin/purge.ts, packages/objectql/src/recycle-bin/restore.ts, packages/objectql/src/engine.ts, packages/verify/src/handle.ts, packages/spec/liveness/permission.json, content/docs/permissions/system-context.mdx

Inputs read: card #30237 body and all 32 comments (one page); PR #31438 body and file list (29 files, +775/-229); the net diff origin/main...aa6ae4c4 (merge base db502314); the 42 check-runs on the head. Rulings judged against: hand-over 6690307585, Q5 = A 6676415868, Q3 = A 6676408264, ruling 6691358077 (app-authored bodies never delete for good), the PR 2 review 6689562965 (should-fix 1 is this PR's landing condition), claim 6718158676, amendment 6718183894, spec consent 6718336940. The read-only shape held: nothing built, run or re-run; code outside the diff was read with git show / git grep at the head.

① Derived judgments

The hits file, against consent 6718336940 and Q5 = A.

  • Right. (a) ObjectPermissionVerbTarget (permission.zod.ts:137-147) gains exactly allowRestoreOwnDeleted and manageRecycleBin. Its only consumers outside the evaluator are api-surface/security.json (a name list, no row owed) and ui/packages/permissions/src/MePermissionsProvider.tsx:487, a Record<string, ObjectPermissionVerbTarget> that is not exhaustive; nothing breaks on the widening.
  • Right, with one reading to record. (b) objectPermissionGrants (:294-296) adds manageRecycleBin: read ∧ (manageRecycleBin ∨ modifyAll) and allowRestoreOwnDeleted: read ∧ (allowRestoreOwnDeleted ∨ manageRecycleBin ∨ modifyAll). read is the fold's existing read cell (allowRead ∨ viewAllRecords ∨ modifyAllRecords, :286), not the bare allowRead the consent spells. That is the same read half every bounded cell uses (edit, delete, export) and the allowDelete describe states it; a viewAllRecords holder can read the object, so bounding on it is the ruling's "allowRead bounds both" as the file already means it. allowDelete appears in neither cell. OBJECT_PERMISSION_VERBS and can() are untouched (no hunk).
  • Right. (c) The [PLANNED] … Not read yet describes and the docblock (:682-695) now say the keys are read, name the fold and its four sentences, and say where the engine's own-entry half lives.
  • Right. The two liveness rows flip planned → live, dated 2026-11-08, citing OPERATION_TO_PERMISSION, objectPermissionGrants and assertCallerMayRestoreEntry; state-counts/permission.md moves 38/2 → 40/0. Spec property liveness is green on the head.

One fold (#18785). Right. The evaluator asks objectPermissionGrants(merged, permKey) (permission-evaluator.ts:337-338); mergeResolvedObjectPermissions (:250-268) merges every true boolean key, so the two new keys reach the fold. MODIFY_ALL_WRITE_KEYS is derived from the map and set and decides nothing (its docblock says so); crudBucketForOperation buckets restore → update, purge → delete for the ADR-0066 ⑤ AND-gate and the super-user bypass bit, which only narrows. Core's GRANT_BITS (effective-object-permissions.ts:336-339) lists the keys and every pass that uses it (foldSuperUserWildcardGrants, materializePlainWildcardCoverage, grantsAnyVerb) calls the spec fold. restore.ts:392-394 asks objectPermissionGrants(permission, RECYCLE_BIN_GRANT_KEYS.manage). No second copy of the implication exists in the diff or the live tree.

/me/permissions and the formula path. Right. The map the Console and the engine's can() read now carries the two keys on wildcard-materialised entries; toEvalPermissions (formula/src/eval-permissions.ts:50-69) parses each entry with EffectiveObjectPermissionSchema, which extends the base shape that has held both keys since #30235, so the wider map is accepted, not refused.

The mapping and the plugin-security sites the hand-over lists.

  • Right. OPERATION_TO_PERMISSION gains restore: RECYCLE_BIN_GRANT_KEYS.restoreOwnDeleted, purge: RECYCLE_BIN_GRANT_KEYS.manage (permission-evaluator.ts:83-84); DESTRUCTIVE_OPERATIONS keeps all three members as the backstop (:97); the gate asks the fold for a mapped verb before the backstop can answer (:324-338).
  • Right. Every write-class site now reads rlsOperationForVerb: rls-compiler.ts:1343 (mapOperationToRLS, whose default sent a lifecycle verb to select), security-plugin-rls-filter.ts:174-175 and :374, security-plugin-addressed-writes.ts:114 and :133, security-plugin-cbp-write-gate.ts:473, platform-ownership-policies.ts:359-361. The authz epoch bump lists purge and restore (:404-405). Steps 2.6, 2.7 and 2.8 already listed both verbs (:975, :994, :1069, :1280).
  • Right, by absence of a caller. security-plugin-authored-row-write.ts:108 still accepts update | delete only; its two callers hand it a literal 'update' (cbp-write-gate.ts:1121) or plugin-sharing's own update | delete verb (sharing-service.ts:1344), so no lifecycle verb reaches it. No change was owed.
  • Inert, left as is. security-plugin-authz-middleware.ts:2318 (the bulk-write guard target) still keys on update/delete; it sits inside if (opCtx.ast) and the [finding] The bulk AST write path passes opCtx.operation raw, so purge / transfer / restore derive no row scope while update / delete now do (#7665 asymmetry) #7809 pin keeps every purge/restore dispatch AST-free, so it cannot be reached with either verb. See ④ nit.
  • Right. packages/verify/src/handle.ts:605-612 records purge and restore; ObservedWrite.operation widens accordingly and @objectstack/verify is in the changeset.
  • Right. resolve-user-grants-cache.ts keeps WRITE_OPERATIONS at insert/update/delete with the reason: the bin never takes a platform object (recycleBinTakesObject, Q7) and every watched grant object is sys_, so a purge/restore never touches one. The hand-over offered either answer.

Security, tried along the brief's lines.

  • Cross-tenant or another person's entry without manageRecycleBin: not reachable. restore refuses a wall-denied caller before any read (restore.ts:375), reads the entry scoped by the engine's own verdict (:376-380, null for another organization's id), dispatches restore on the master's object (object gate: allowRestoreOwnDeleted, read-bounded), then in the executor re-checks the recorded verdict (:388) and asks assertCallerMayRestoreEntry (:389): the system passes; deleted_by === context.userId passes; otherwise the registered resolver's map must fold to manageRecycleBin on the entry's object, and no resolver, a throwing resolver, or a map without the object all refuse 403 PERMISSION_DENIED (:369-396). attributedUserId is not consulted; capture writes deleted_by from userId, else attributedUserId (capture.ts:287-293), so a human credited for a system-authorized delete still matches on their own userId. The own-entry check runs after the object gate, so a caller without the key never learns whether an entry exists.
  • purge(entryId) / empty(object): wall-denied callers answer false / 0 before any read (purge.ts:210, :258); the entry is read under the engine's verdict (:211-218); the dispatch on the entry's business object asks manageRecycleBin; the executor re-checks the recorded verdict and passes { recordedVerdict } to the bin's driver (:221-226, :260-265). The permanent delete keeps where.id and meets step 2.7 as a delete (floor plus the delete-class sharing verdict in resolvePreImageFloorDrop) and the 2.8 master gate.
  • allowDelete implying restore: nowhere. The two cells omit it; the evaluator tests and the spec test pin {allowRead, allowDelete} → false for both keys; security-plugin.test.ts pins the object gate refusing {allowRead, allowEdit, allowDelete, viewAllRecords} for both verbs.
  • System context: unchanged. The authz bypass at :418 is untouched; recycleBinWallDenies and assertCallerMayRestoreEntry both return early for isSystem; the two reads are registered in the system-context census (rows 29d/29e). Ruling 6691358077 holds: HookDeleteOptions still omits permanent, the hook face (hook-api.ts:279) exposes delete only, and the sandbox body runner exposes no restore, purge or empty, so an app-authored body still cannot reach the purge verb.
  • Deny-first ordering on the purge entry read: sound. The pre-read check and the read use the same engine verdict (recycleBinWallDenies and driverReadScope both fall back to engineLayer0Verdict), so a deny can never reach the driver as "no scope"; the executor's second check uses the recorded verdict when one exists, exactly as driverReadScope does. Under single the verdict is none for everyone, which is the posture, not a hole.

Landing condition (PR 2 review should-fix 1). Closed as asked. The two object-level dispatches carry recordedVerdict: opCtx.tenantLayer0Verdict (purge.ts:221-226, :260-265), and a deny verdict, engine or recorded, refuses before the driver is reached. The pre-dispatch entry read cannot carry a recorded verdict (nothing has been recorded yet); it is scoped by the engine's verdict and preceded by the deny check, which is the fall-open the review named. Note that plugin-security records opCtx.tenantLayer0Verdict only inside if (opCtx.ast) (authz-middleware.ts:2414), so for these AST-less dispatches the recorded path is exercised only by a custom middleware today; the engine's own verdict decides.

Check-runs on the head (read 2026-11-08 08:00Z): 42 check-runs; 13 success (Auto Label, Check Changeset, Check Documentation Links, Check PR Size, Dogfood Regression Gate, Flag docs affected, Governed Surface Queue Guard, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, PR-body guards, Plan Test Core shards, Spec property liveness, filter), 7 skipped, 22 in progress (Build Core, Build Docs, Build UI Deps, Lint · CI/release/engine gates, Lint · ESLint, Lint · docs & code guards, Lint · repo & tooling gates, two scoped Lints, Live E2E UI, Test Core 1-8, Type Check × 4). Every in-progress family is NOT MEASURED by this record, check:generated, check:system-context-census and the typecheck of the widened ObjectPermissionVerbTarget among them. None red.

② Semver level

Confirmed. .changeset/30237-recycle-bin-permission-reader.md declares patch for @objectstack/spec, plugin-security, core, objectql and verify, with Clause-②: yes (widening) and Metadata-protocol: none line-initial, matching the PR body and the claim. The authorable surface is unchanged: both keys have been authorable since #30235, no key, value or default moves, so none is right and takes patch (AGENTS.md step 3). The widening is real and named: a granted key (or modifyAllRecords) now opens restore / purge, which every non-system caller was refused; ObjectPermissionVerbTarget and ObservedWrite.operation widen; objectPermissionGrants answers two targets it did not. No narrowing hides in it: a caller holding neither key is refused exactly as before, allowDelete grants nothing new, and the wall-deny answers (null / false / 0) replace a path the backstop refused anyway. Check Changeset is green. The changeset body carries no Skills-docs: line (see ③).

③ Boundary flags

  • Author: objectstack-fleet[bot], attribution os-project-manager; no outside login to name.
  • Dev deviations (report 6719012131), each judged: (1) surface beyond the claim, content/docs/permissions/system-context.mdx rows 29d/29e plus the regenerated register, generated content/docs/references/**, liveness/state-counts, spec/permission.test.ts: all forced by check:system-context-census / check:generated or asked by the seat; right, and the seat should name them in the amendment since 6718183894 names engine.ts and the spec hunk only. (2) The purge pre-read cannot carry the recorded verdict: right, see ①. (3) restore gets the same deny refusal as purge/empty: right, the same fall-open class, and row 29d says so. (4) WRITE_OPERATIONS kept: right, the hand-over offered it. (5) Merge commit with git's default message: no rule touched.
  • Dev acceptance notes, each confirmed in the tree: the recorded verdict is written only on AST operations (authz-middleware.ts:2414); the CBP master gate and delegated-admin gate judge no id-less restore/purge (2.8 runs for them and finds no master to judge; a by-id purge is judged); a super-user wildcard's map now shows both bin keys on sys_ objects where the engine refuses 400 (a report of the grant, harmless, no change asked); the stale [REMOVED] describes are graded in ④.
  • security_findings: "withheld" in the dev report, where every earlier report on this card wrote "none". The seat should read what was withheld before ACCEPT; this record found no security defect of its own.
  • Skills-docs: line: hand-over 6690307585 says every PR of this card cites skills: objectstack-api still teaches that DELETE is unrecoverable and that there is no recycle bin (#30237, ADR-0148) #30847 on a Skills-docs: line, and PR 3's body does (Skills-docs: follow-up #30847); this PR's body and changeset carry none. No gate enforces it. A prose-face nit for the PR body.
  • Carried for the seat, outside this diff and not graded against it: plugin-sharing's own by-id write middleware (sharing-plugin.ts:1510) branches on update/delete only, so a by-id permanent delete (purge) is not asked its canDelete. plugin-security's step 2.7 judges that write as a delete and its floor drop asks the same delete-class sharing verdict (resolvePreImageFloorDrop, security-plugin-sharing-verdicts.ts:275-293), so wherever the platform ownership floor applies the refusal is preserved; where no floor policy applies, plugin-sharing's gate was the only per-record write authority and the by-id purge passes it unasked. PR 2 shipped the dispatch and this PR makes it grantable; a follow-up card or a one-line pin in plugin-sharing is owed, not a change to this PR's surface.
  • Hand-written docs outside the diff that this PR makes false: content/docs/permissions/permissions-matrix.mdx:78 and content/docs/protocol/objectql/security.mdx:111 still say the restore/purge operations do not exist and are denied unconditionally. Docs prose, not spec; a follow-up, named here so it is not lost.
  • open_questions: none in the report. pr5_spec_need: unmeasured by the dev, reported before PR 5 starts.
  • The spec hunk is inside consent 6718336940 (a, b, c and the two liveness rows). The fix ④ asks for (the retirement prose in the same file) is prose outside that consent's list; the seat records the maintainer's word, or its own reading that a prescription string is a prose face, before the delta.

④ Design judgment

packages/spec/src/security/permission.zod.ts, against Q5 = A, consent 6718336940, and its first consumer (the evaluator's object gate).

  • The two cells implement the ruling as written; the evaluator reads them through the merged entry so the read half may come from a different set than the grant, as for edit and delete; core's map, the Console's fold and the engine's own-entry check all read the one function. The widened ObjectPermissionVerbTarget docblock says the keys are read for restore / purge and that no verb resolves to them, which the unchanged OBJECT_PERMISSION_VERBS makes true.
  • Should-fix (prose made false by this PR). The same file still publishes, at :527-542 (the restore / purge guidance strings), :620-640 (the tombstone docblock) and :654-670 (the allowRestore / allowPurge retiredKey prescriptions), that "the restore ObjectQL operation it claimed to gate has never shipped (roadmap M2)", that "a dispatched restore / purge stays denied fail-closed by the permission evaluator's destructive-operation backstop", and that "the bit returns with the M2 lifecycle initiative". On this head the operations ship, the object gate answers them from allowRestoreOwnDeleted / manageRecycleBin, the backstop decides nothing (the evaluator's own docblock now says so), and the bits were respelled on purpose and never return. This is the parse-time prescription an author sees and it is regenerated verbatim into content/docs/references/api/auth.mdx, api/protocol.mdx and security/permission.mdx in this very diff, so the PR publishes a false security statement ("stays denied") beside the true one. The card already carried the obligation: 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's review should-fix 2 (6665087359) says the reader PR re-points "the restore / purge guidance, the allowRestore / allowPurge tombstone text and the liveness/permission.json notes at D5's answer (respelled; the tombstones stay through the ADR-0087 kit schedule)". The two dead liveness rows (permission.json:94, :100, "stays denied fail-closed via DESTRUCTIVE_OPERATIONS … the key RETURNS with M2") are the same stroke. The tombstones themselves stay; only the sentences change, to: the key was retired, the recycle bin (ADR-0148) ships restore / purge under the new spellings allowRestoreOwnDeleted / manageRecycleBin, delete this key and grant those. No effect on enforcement, so not a must-fix; a contract-prose defect, so not a nit. The protocol-18 conversion, retired-key and registry-template texts describe the protocol-18 state and are left alone.

Implementing files in the diff, each against the contract it implements.

  • permission-evaluator.ts: agrees sentence by sentence with Q5 = A and [finding] the super-user permission fold is now stated three times — spec's objectPermissionGrants, plugin-security's PermissionEvaluator and lint's buildAccessMatrix — one rule, three implementations #18785 (one fold, backstop stays, Modify-All class derived). crudBucketForOperation folds restore → update, purge → delete, the same classes lifecycle-verb-rls-operation.ts declares. Holds.
  • lifecycle-verb-rls-operation.ts: the docblock now lists every reader of the mapping; the map itself (transfer/restore → update, purge → delete) is unchanged. Holds.
  • rls-compiler.ts, security-plugin-rls-filter.ts, security-plugin-addressed-writes.ts, security-plugin-cbp-write-gate.ts, platform-ownership-policies.ts: each reads rlsOperationForVerb once and keys on the result; a by-id purge resolves its row through resolveEngineDeleteDispatch as a delete, and the id-less dispatches resolve no row, as the comments say. Hold.
  • security-plugin-authz-middleware.ts: the epoch bump covers the write set; the step-3 comment is now true (composition maps the verb itself). Nit: :2318 still keys the bulk-write guard target on update/delete while the hand-over asked each such site to read the mapping or list purge; it is unreachable with a lifecycle verb (AST-only, [finding] The bulk AST write path passes opCtx.operation raw, so purge / transfer / restore derive no row scope while update / delete now do (#7665 asymmetry) #7809 pin), so an accepted deviation or a one-line follow-up, not a change on this head.
  • explain-engine.ts: Should-fix. The file's own contract (:1206-1214, rewritten in this diff) is that the record story "stays the door's on the day they can be granted", and this PR is that day. Two sites still key on the raw engineOp where the door keys on the mapped class: :2017 picks the sharing write gate as engineOp === 'delete' ? canDeleteRecord : canEditRecord, so a by-id purge is explained against canEdit, while the door (step 2.7's resolvePreImageFloorDrop, asked with rlsOperationForVerb('purge') === 'delete') asks the delete-class verdict; and :2033-2036 says "restore and purge have no by-id door (the object gate refuses both), so nothing defers them", which is false now that the by-id purge has a door. ExplainOperation includes purge (EXPLAIN_TO_ENGINE_OP:252), so security/explain can report an edit-share-admitted row as writable for a purge the door refuses (ADR-0111 D3). The fix is rlsOperationForVerb(engineOp) at :2017 (the file already imports it for :1847 and :3390) and the comment at :2033-2036; :1979 and :2139 want the same reading for the message to name the right gate. A report defect, not an enforcement one.
  • effective-object-permissions.ts (core): GRANT_BITS carries the keys; the super-user fold and plain-wildcard coverage pull them true through the spec fold, so the map reports what the server grants (Q5 = A: modifyAllRecords implies both). Holds.
  • resolve-user-grants-cache.ts: comment only; the reason given is true in the tree (recycleBinTakesObject excludes sys_/cloud_/ai_). Holds.
  • recycle-bin/purge.ts: recycleBinWallDenies reads the recorded verdict exactly as driverReadScope does (a value that does not parse is absent) and falls back to the engine's verdict; both doors check before the read and again inside the executor; the executors pass the recorded verdict. Agrees with should-fix 1 and with row 29d. Holds.
  • recycle-bin/restore.ts: the docblock's two halves are the code's; assertCallerMayRestoreEntry fails closed on every unanswered path; deleted_by is read in the entry fetch; the refusal is 403 PERMISSION_DENIED, the object gate's own code. Holds.
  • engine.ts: no new member; the three host literals gain closures over _effectiveObjectPermissionsResolver and engineLayer0Verdict, as amendment 6718183894 says. Holds.
  • verify/src/handle.ts: the observer's documented set is the engine's write set. Holds.
  • liveness/permission.json: the two live rows cite the three readers that exist on this head. Holds; the two dead rows' notes are in the should-fix above.
  • content/docs/permissions/system-context.mdx: rows 29d/29e describe the two isSystem reads as the code behaves. Holds.

No must-fix. Two should-fixes (the retirement prose in the hits file and its liveness twins; explain-engine's raw engineOp for the by-id purge) earn a delta review of their fix; the nits end with this record.

Implemented-by: claude/project-thread-py4hal
Reviewed-by: session_01FEkQ5pXkgNXVpCn2GZDjyy

VERDICT: PASS

… write gate and in explain

Review round 1 of the recycle-bin permission reader. The sharing middleware
gated by-id writes on update/delete only, so a by-id purge (the permanent
delete) reached no canDelete once purge became grantable; it now picks the
gate by the write class (rlsOperationForVerb), and passes the bin's own
id-less, AST-less restore/purge dispatches through untouched. The mapping
moves to @objectstack/core so plugin-security and plugin-sharing read one
definition. security/explain picks the gate, the deferral verb and the fault
sentence by the same class. The permissions matrix and the ObjectQL security
page no longer say restore/purge do not exist; the changeset names the
skills follow-up and the sharing change.

Co-Authored-By: Claude <noreply@anthropic.com>
…cycle bin's grants

The tombstones and their accept set are unchanged. Their refusal text, the
bare restore/purge guidance and the docblock no longer say the operations
were never shipped and that the keys return with M2: the operations exist
with the recycle bin (ADR-0148), and their grants are spelled
allowRestoreOwnDeleted and manageRecycleBin. The "Delete the key" sentence
stays its own sentence, so the residue lint's fix line is unchanged. The
lint rule's explanation drops the same claim. References regenerated.

Consent: 6720657486.

Co-Authored-By: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 95d2a17f6e585d9503a4ac3e7ca1626683ea27d7
Local-runs: none
Scope: packages/spec/src/security/permission.zod.ts + packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/core/src/security/lifecycle-verb-rls-operation.ts, packages/core/src/security/index.ts, packages/plugins/plugin-security/src/lifecycle-verb-rls-operation.ts, packages/plugins/plugin-security/src/explain-engine.ts, packages/lint/src/rule-explanations.ts, content/docs/permissions/permissions-matrix.mdx, content/docs/protocol/objectql/security.mdx

This is the delta review of record 6719122724 (PASS on aa6ae4c4, SF1 tombstone prose, SF2 explain-engine). It judges git diff aa6ae4c4..95d2a17f — commits 8f951377 (sharing gate, explain, docs, core move) and 95d2a17f (tombstone prose, lint explanation), no merge commit, 18 files, +334/−117 — and the PR body as it stands at 11:57Z. Inputs read: card #30237's 35 comments, among them consent 6718336940, amendments 6718183894 / 6719131950 / 6721180956 and the tombstone-prose consent 6720657486; the PR body and file list; the check-runs on 95d2a17f; the card thread's handback (30237-pr4-round1-handback.md), read as a claim and verified line by line below. Everything the round-1 record found right and this delta does not touch stands as recorded there. The read-only shape held: nothing built, run or re-run; code outside the diff was read with git show / git grep at the head.

① Derived judgments

SF1 closed — the hits file, inside consent 6720657486.

  • Right. The three hunks in permission.zod.ts are :528-541 (the restore / purge lines of the guidance map), :617-636 (the tombstone docblock) and :652-668 (the allowRestore / allowPurge retiredKey arguments). Every changed token is inside a string literal or a comment: the retiredKey(…) calls, the strictObject shape, ObjectPermissionVerbTarget, objectPermissionGrants, OBJECT_PERMISSION_VERBS and can() are byte-identical to aa6ae4c4, so the accept set does not move and the schema's effect is the same. Exactly the three items the consent lists, nothing else in the file.
  • Right. Each of the four prescriptions keeps "Delete the key." as its own sentence followed by a space. retiredKeyRemedy (packages/lint/src/validate-retired-permission-residue.ts:121-131, outside the diff) slices at the sentence and cuts at the first . , so the residue lint's fix line is still exactly Delete the key; the 200-character dash fallback is no longer reached. The lint explanation's sentence that the fix line is "read from the tombstone … and cut, never retyped" stays true.
  • Right. The regenerated content/docs/references/{api/auth,api/protocol,security/permission}.mdx rows for allowRestore and allowPurge equal the concatenated retiredKey strings word for word (the generator keeps the [REMOVED] prefix and the os migrate meta tail). The new text says what the consent said it would: the operations exist (ADR-0148), the grants are spelled allowRestoreOwnDeleted / manageRecycleBin, delete the key; no "never shipped", "stays denied", "returns with M2" remains in the file. Spec property liveness and Lint · docs & code guards are green on the head.
  • Carried, not a defect of this delta: the two dead liveness rows (packages/spec/liveness/permission.json, allowRestore ~:94 and allowPurge ~:100) still say "a dispatched restore stays denied fail-closed via DESTRUCTIVE_OPERATIONS … the key RETURNS with the M2 lifecycle initiative". Consent 6720657486 names permission.zod.ts alone, so the dev was right to leave them; see ③ / N2.

SF2 closed — explain reads the write class as the door does.

  • Right. explain-engine.ts now asks rlsOperationForVerb(engineOp) at the queue-claim guard (:1979), the gate pick (:2019-2020, canDeleteRecord for the delete class, canEditRecord otherwise), the authored-row deferral verb (:2041-2042, writeClass when it is update or delete) and the fault sentence (:2144). The door it reports is plugin-sharing's buildSharingMiddleware, which picks admitsByIdWrite(…, 'delete') for a by-id purge by the same mapping (sharing-plugin.ts:1516-1518, :1563), and SharingService.admitsByIdWrite asks canDelete for 'delete' and defers through probeAuthoredRowWrite with the same verb. The two sides agree sentence by sentence. The rewritten comment (:2035-2039) is true: a restore explains a record the bin holds, and capture.ts snapshots the row before the physical delete, so fetchRecord finds nothing and recordExists is false.

The seat's added item — plugin-sharing's write gate (sharing-plugin.ts:1509-1528).

  • Right. writeClass = rlsOperationForVerb(op); the branch enters for the update / delete classes; a by-id purge resolves verb = 'delete' and is asked admitsByIdWrite(object, id, 'delete', exec) (:1563), refused 403 FORBIDDEN on false; a purge carrying an AST and no id is scoped by buildWriteFilter(object, exec, 'delete') (:1649). An ordinary update / delete keeps its path unchanged.
  • Right, tried along the brief's line: the pass-through if (id == null && !ctx.ast && op !== 'update' && op !== 'delete') return next(); (:1528) cannot be reached by a caller-shaped request. The engine's only caller-facing door onto purge is delete(object, { permanent: true }) (engine.ts:8614-8621), and readPermanentDelete (purge.ts:156-183) throws 400 VALIDATION_ERROR before the operation context exists unless resolveEngineDeleteDispatch answered by-id (a scalar where.id, engine-delete-dispatch.ts) with no multi: true and the object is one the bin takes. In that case inferTargetId (sharing-plugin.ts:1756-1757) reads the same options.where.id, so id != null and the by-id gate runs; { $in: […] } or a predicate where is multi and refused; stripping where.id keeps permanent and is refused. The only id-less, AST-less purge / restore dispatches in the tree are the bin's own purge(entryId) / empty(object) / restore(entryId) (purge.ts:219, :259, restore.ts:386), built as { object, operation, options: { context }, context } inside the engine from an entry the caller read under the engine's verdict; each is wall-checked, object-gated (manageRecycleBin / allowRestoreOwnDeleted) and, for restore, own-entry-checked (round 1), and each acts on the bin table only. No transport, hook face or sandbox runner lets a caller name the operation (round 1, ruling 6691358077); transfer is in the mapping but no engine dispatch issues it (git grep finds none outside tests and explain), so the branch's widening to that class is inert.
  • Right, no narrowing hides in it: before this delta a system by-id purge fell through to return next(); it now meets admitsByIdWrite, whose per-verb gate answers isSystem → true (sharing-service.ts:1429). A non-system by-id purge was refused at the object gate before PR 4 and is refused at this gate without delete authority after it; the change closes the path PR 4 opens, which is what amendment 6719131950 asked.

rlsOperationForVerb moved to @objectstack/core.

  • Right. One definition: packages/core/src/security/lifecycle-verb-rls-operation.ts:48-57 (map and function identical to the plugin-security original), exported from core/src/security/index.ts:355 and so from the package root (core/src/index.ts:73 re-exports ./security/index.js). plugin-security/src/lifecycle-verb-rls-operation.ts:9 is now a bare re-export from @objectstack/core, so every plugin-security reader the round-1 record listed resolves to the one map; plugin-security's own index.ts never exported it, so plugin-security's public surface is unchanged. plugin-sharing imports it from @objectstack/core (sharing-plugin.ts:27), on which it already depended (package.json:31); plugin-security depends on core too (package.json:29); core depends on neither plugin, so no cycle. The docblock's reader list adds plugin-sharing and is true of the tree.
  • Clause-②: yes (widening) still true: the two exports are additive, the gate change above narrows nothing a caller could reach, and the tombstone prose moves no accept set.

Lint and hand-written docs.

  • Right. rule-explanations.ts:5307-5316: "the key granted nothing when it was retired, and the recycle bin's restore and purge operations are granted by their own keys, allowRestoreOwnDeleted and manageRecycleBin (ADR-0148)" is what OPERATION_TO_PERMISSION and the fold do on this head; "the fix line is the 'Delete the key' sentence … cut, never retyped" stays true per above.
  • Right. permissions-matrix.mdx:78: restore asks allowRestoreOwnDeleted and restores only the caller's own entries, purge (entry, empty, permanent delete) asks manageRecycleBin, which also restores anyone's entry, each bounded by read, modifyAllRecords implies both, allowDelete implies neither, the old flags stay retired and refused — every clause is the evaluator's, the fold's and assertCallerMayRestoreEntry's. The transfer half is unchanged and still true.
  • Right. security.mdx:104-105 adds the two flag rows with the fold's exact bounds and implications, and :109-114 now says the operations did not exist when the flags were retired and exist now under the new spellings. True.

Check-runs on the head (read 2026-11-08 12:03Z): 66 check-runs; 27 success (Auto Label, Build Docs, Build UI Deps, Check Changeset ×2, Check Documentation Links, Check PR Size, Dogfood Regression Gate, Flag docs affected, Governed Surface Queue Guard, Lint & Repo Gates, Lint · CI/release/engine gates, Lint · ESLint, Lint · PM dispatch-gates, Lint · docs & code guards, Lint · repo & tooling gates, three scoped Lints, Live E2E UI, PR-body guards ×2, Plan Test Core shards, Spec property liveness, Type Check · debt ledger, Type Check · source gates, filter); 10 skipped; 29 in progress (Build & E2E UI, Build Core, Test Core 1-8, Test UI 1-16, Type Check UI, Type Check · consumer gates, Type Check · workspace). Every in-progress family is NOT MEASURED by this record — the new plugin-sharing / plugin-security / spec / lint tests, the workspace typecheck of the core export and of the writeClass narrowing among them. None red.

② Semver level

Confirmed. .changeset/30237-recycle-bin-permission-reader.md now declares patch for @objectstack/spec, plugin-security, plugin-sharing (added :9), core, objectql, verify and lint (added :13); Clause-②: yes (widening), Metadata-protocol: none and Skills-docs: follow-up #30847 (added :20) are line-initial and match the PR body. none takes patch by AGENTS.md step 3 ("the level follows the kind alone"), the new @objectstack/core exports included: no authorable key, value or default moves. The two added bullets (:28 record sharing on the permanent delete; :29 the retired keys' prescription) describe the delta truly. Check Changeset is green. The body names no @objectstack/core export by name — N1 below.

③ Boundary flags

  • Author unchanged (objectstack-fleet[bot], attribution os-project-manager); no outside login.
  • Handback claims, each verified in the tree: (a) sharing gate and pass-through — right (①); the "without the pass-through, restore→update would have entered the bulk path" reason is right (restore dispatches with no id and no AST, and the bulk path would compose a buildWriteFilter onto an AST the dispatch does not carry). (b) explain at four places — right (①). (c) docs — right (①). (d) Skills-docs: line now on the PR body and changeset — right, round-1 nit closed; the authz-middleware :2318 bulk guard stays the accepted deviation. (e) tombstone prose — right (①). The ablation counts and suite totals are the dev's local runs, not measured here.
  • Amendment 6721180956 is true of the tree: the core move, the lint explanation and its test, the three added changeset packages. Its follow-up list (conversion / migration entry 18 texts, ui permission-slice comments, metadata/src/plugin.ts comment) omits the two dead liveness rows the earlier amendment 6719131950 had named — N2.
  • open_questions: none in the handback. No new isSystem read, no new spec shape, no generated file outside the three reference pages.
  • The PR body's account of the tree is now behind it — N3. ⛔ Judged from the tree, so no finding of ④ rests on it.

④ Design judgment

packages/spec/src/security/permission.zod.ts, against consent 6720657486 and the code the new sentences cite: the prescriptions now say what OPERATION_TO_PERMISSION, objectPermissionGrants and the bin's doors do, the tombstones still refuse exactly as before (retiredKey → z.never with the guidance as its error), and the permission.test.ts pins read the new text. Holds; SF1 closed.

Implementing files in the delta, each against the contract it implements:

  • plugin-sharing/src/sharing-plugin.ts: the gate keys on the write class as plugin-security's step 2.7 does; the pass-through is reachable only from the engine's own bin doors (①). Holds.
  • core/src/security/lifecycle-verb-rls-operation.ts, core/src/security/index.ts, plugin-security/src/lifecycle-verb-rls-operation.ts: one map, one function, re-exported; the docblock names every reader. Hold.
  • plugin-security/src/explain-engine.ts: the report's gate, deferral verb and fault sentence are the door's for purge; SF2 closed. Holds.
  • lint/src/rule-explanations.ts: true of the evaluator and the residue lint's cut. Holds.
  • permissions-matrix.mdx, security.mdx: true of the code (①). Hold.

Findings — no must-fix, no should-fix; three nits, none moving the head:

  • N1 (nit, changeset prose). .changeset/30237-recycle-bin-permission-reader.md adds @objectstack/core: patch content without naming the new public exports LIFECYCLE_VERB_RLS_OPERATION / rlsOperationForVerb (packages/core/src/security/index.ts:355). The level is right and nothing stated is false; a consumer reading the CHANGELOG learns of the export only from the plugin-sharing bullet's wording. Fix, if a later head is cut for any other reason: one bullet, "@objectstack/core exports rlsOperationForVerb / LIFECYCLE_VERB_RLS_OPERATION (the write class of a lifecycle verb), read by plugin-security and plugin-sharing". Otherwise an accepted deviation.
  • N2 (nit, follow-up). Prose this PR leaves false outside the consent: packages/spec/liveness/permission.json dead rows allowRestore (:94) and allowPurge (:100), "stays denied fail-closed via DESTRUCTIVE_OPERATIONS … the key RETURNS with the M2 lifecycle initiative"; and the retiredKeyRemedy docblock, packages/lint/src/validate-retired-permission-residue.ts:114-119, "both keys' do: the clause after the dash, on what stays denied" (no prescription now runs past 200 characters or carries the dash). Fix: add both to the follow-up card that amendment 6721180956 opens for the entry-18 texts, and reword the two notes to "respelled as allowRestoreOwnDeleted / manageRecycleBin (ADR-0148, engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237); the tombstone stays". Register and code-comment prose; no effect on the gate or the lint's output.
  • N3 (nit, PR body — the seat's prose face). The body's 维护者速读 (改了什么 / 风险 / 先看) and "What changes" do not mention the delta: the by-id permanent delete now answers 403 FORBIDDEN under record sharing without delete authority (sharing-plugin.ts:1563), security/explain reports purge against the delete gate, and rlsOperationForVerb is a @objectstack/core export. The Acceptance-notes bullet "The [REMOVED] describes … still say … left for the seat" is false on this head, and "Verification" names aa6ae4c4 only. Fix: refresh those lines on the body (one 改了什么 clause for the sharing gate, packages/plugins/plugin-sharing/src/sharing-plugin.ts under 先看, drop the stale bullet, cite the handback's 95d2a17f verification). No effect on the tree.

Implemented-by: claude/project-thread-py4hal
Reviewed-by: session_01FEkQ5pXkgNXVpCn2GZDjyy

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy

席位意见:ACCEPT · Head-sha 95d2a17f6e585d9503a4ac3e7ca1626683ea27d7 · 2026-11-08T12:30Z。正文「维护者速读」与席位读到的 diff 一致。本 PR 不在 governed 面上,由席位落地,维护者不需要操作。

席位核对

  • 形态: draft,目标 main,Part of #30237(5 个 PR 中的第 4 个)。Clause-②: yes (widening)、Metadata-protocol: none 和 Skills-docs: follow-up #30847 都在行首,changeset 涵盖 7 个包,每个记一个 patch。
  • spec 改动有授权: permission.zod.ts 中 ObjectPermissionVerbTarget、objectPermissionGrants 的两个 Q5 单元以及 liveness 两行,依据维护者同意 6718336940。墓碑文案和 restore / purge 的引导字符串,依据维护者同意 6720657486(2026-11-08T10:59Z 选了 A)。
  • 契约复审(CONTRACT_REVIEW_TIER):
  • 发布面: 放宽。持有两个键或 modifyAllRecords 的人获得 restore/purge,allowDelete 不蕴含其中任何一项。共享层对按 id 的 purge 是收紧方向,与普通 delete 同一个门。凡是本 PR 让已发布文字失真的地方,都在本 PR 内改了:content/docs 下 6 页,以及 permission.zod.ts 的 describe。
  • 门禁(check-runs @ 95d2a17f): 共 73 个,61 success,12 skipped,0 失败,0 运行中。
  • 落地条款: check-governed-merges --pr 31438:39 个路径中 0 个命中 governed,+1088/−325,共 1413 行,不超过 3000,走普通队列。席位把它转为 ready 并开启 auto-merge。合并后不关闭 engine: snapshot deletes into the recycle bin, restore under original ids, purge, and the TTL reap (#3146 slice 3) #30237,PR 5(REST 门)接着做。

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 size/xl 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.

1 participant