Repository navigation
feat(rest): the recycle bin has REST doors, and a delete answer names the entry to undo (#30237 PR 5) - #31595
Conversation
…the delete answer's recycleBinEntryId
The recycle bin (ADR-0148) is reachable over HTTP, one object at a time,
under {data}/:object/recycle-bin: GET lists the object's entries for a
caller who manages its bin (FLS on each row), POST /:entryId/restore writes
one entry back, DELETE /:entryId purges one and DELETE empties the bin. An
entry addressed under another object is not found; every door has a closed
query-parameter set and passes the object's API exposure, where restore and
purge now derive from delete.
The engine gains listRecycleBin (fail-closed manager check), an optional
object on restore/purge, and an onRecycleBinEntry delete callback that the
protocol's deleteData uses to answer recycleBinEntryId. The client gains
client.recycleBin.list/restore/purge/empty.
Spec consent: 6721939207 (DeleteDataResponseSchema.recycleBinEntryId, the
EngineDeleteOptions callback, restore/purge derived from delete).
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
…tract 0 through unknown; regenerate the protocol reference Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
…ngine's options, not on the spec type; pay lazy loads at collection in the touched tests Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
📓 Docs Drift CheckThis PR changes 5 package(s): 70 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 16 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 180 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c39a68c749eb31eb1b92add629bd33220d67f0eb && git checkout c39a68c749eb31eb1b92add629bd33220d67f0eb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin cb7b3ccbc71ecbcf6bc8acea6478e74eec59ea10 b18b209442336a431e51c44587873c8f85e09145 && git checkout -B drift-repro cb7b3ccbc71ecbcf6bc8acea6478e74eec59ea10 && git merge --no-ff b18b209442336a431e51c44587873c8f85e09145
node scripts/docs-audit/affected-docs.mjs --json cb7b3ccbc71ecbcf6bc8acea6478e74eec59ea10
|
… new it.each tuples restore and purge derive from delete since the recycle bin's doors landed, so the full closure the security layer annotates now carries both; the it.each tables in the two new test files are typed so the package test layers compile. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
|
domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy Contract reviewServed-tier: Inputs read: card #30237 body and all 41 comments (consent 6721939207 S1–S3 = A; amendments 6721792971, 6721834323; hand-over 6690307585; rulings Q1–Q7, 6691358077, 6718336940, 6720657486), PR #31595 body and 34-file list, ① Derived judgmentsEach accept-set or public-surface change the diff implies, judged against the tree:
② Semver level
③ Boundary flags
④ Design judgment
Implementing files, sentence by sentence against the contract they implement:
Findings (graded; none is a must-fix or should-fix):
Tried to break: an anonymous caller (401 before anything is listed, pinned); a caller with Implemented-by: VERDICT: PASS |
|
domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy 席位意见:ACCEPT · Head-sha 席位核对
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 42506290340 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
…ormance matrix The four doors open with the anonymous floor; the proof drives each one anonymously (401) and with the admin on one boot. The rest ledger now holds 20 families. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J
|
domain:server#3 · os-project-manager · session_01FEkQ5pXkgNXVpCn2GZDjyy 席位意见:ACCEPT · Head-sha 席位核对(delta
|
Requested by Leehom · project thread
Part of #30237
Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: follow-up #30847
Spec consent: 6721939207 (S1
DeleteDataResponseSchema.recycleBinEntryId, optional; S3api-derivation.tsderivesrestore/purgefromdelete, docblock corrected). S2 (theEngineDeleteOptionsout-channel) is NOT committed in spec: the callback is typed in objectql instead, see Acceptance notes. Claim amendment 6721792971. PR 5 of 5 (hand-over 6690307585): the recycle bin's REST doors. Also answers #30239 (the delete answer names the entry to undo).维护者速读
GET /data/:object/recycle-bin列出条目(仅manageRecycleBin持有者,行值按调用者在该对象上的字段级权限裁剪,掩码字段不返回),POST …/:entryId/restore恢复一条,DELETE …/:entryId清除一条,DELETE …/recycle-bin清空该对象的回收站。DELETE /data/:object/:id的应答在写入回收站条目时带上recycleBinEntryId,客户端可据此提供"撤销"。引擎新增listRecycleBin,restore/purge可限定条目所属对象;客户端新增client.recycleBin.list / restore / purge / empty。Metadata-protocol: semantic:对象的 API 派生集合在暴露delete时现在包含restore/purge(此前恒为关闭),撤去delete的对象四个入口一律 405。列表在无权限解析器时拒绝(fail closed)。回滚即 revert,无数据迁移。packages/rest/src/recycle-bin-routes.ts(四个入口、字段裁剪servedFieldsOf、恢复回执restoreReceipt、错误应答answerThrown);packages/objectql/src/recycle-bin/list.ts(listRecycleBin与assertCallerManagesRecycleBin);packages/objectql/src/engine.ts(按 id 删除后的onRecycleBinEntry);packages/spec/src/data/api-derivation.ts(S3)。pnpm --filter @objectstack/rest exec vitest run src/recycle-bin-routes.test.ts与pnpm --filter @objectstack/objectql exec vitest run src/recycle-bin/list.test.ts,预期全部通过,含「answers 405 at every door of an object whose API withholdsdelete」「with only a read projection, withholds every field that declares a maskingRule」「refuses, 403, when no permission resolver answers」。What changes
The doors (
packages/rest/src/recycle-bin-routes.ts, new; seat ruling S4). Four routes under{data}/:object/recycle-bin, registered insideapi.enableCrudbefore CRUD's/:object/:id(first match wins, the export precedent):GET {data}/:object/recycle-binrestorelistRecycleBin(object, { context, limit, offset }){ object, entries, hasMore }; each row's values cut to the caller's fieldsPOST {data}/:object/recycle-bin/:entryId/restorerestorerestore(entryId, { context, object })null→404 RECORD_NOT_FOUND; a stale roll-up →200with what was writtenDELETE {data}/:object/recycle-bin/:entryIdpurgepurge(entryId, { context, object }){ object, entryId, purged: true };false→404DELETE {data}/:object/recycle-binpurgeempty(object, { context }){ object, removed }limit/offsetonly; the acts take none. Unknown or repeated parameters →400 VALIDATION_ERROR.limit/offsetare read throughreadDeclaredQueryNumberagainst declared bounds (limit1–200,offset≥ 0). A refused value →400 VALIDATION_FAILED, withdetails.fieldsnaming the parameter ([finding] class closure: the rest of rest-server.ts's bare-Number() query reads. /history ?sinceSeq, /audit ?limit and /search ?perObject answer 200 on an unreadable value; close the family with one census pin #20139).getQueryableFieldson the row's live object: readable minus masked. If the service has onlygetReadableFields, every field that declares amaskingRuleis dropped, whoever asks. If there is no answer, a row keeps itsidalone. If there is no security service, values are served as stored. The snapshot and its cleared references are never served.entryId,object,recordId,rowsas{ object, id }, andrelinked. No record body is served (The write-response internal-field tripwire walks the protocol class only — a direct engine write mouth outside it (rest-server's batch ql.update) is covered by the fix but not by the guard #8497).detailscarryentryId,object,recordId,field,parentObject,parentId,parentEntryIdandparam, so a client can restore a parent entry first. An unreadable authorization input answers503. A sandbox fault answers as the data doors do. Anything else is a500with its text withheld.The engine (objectql).
listRecycleBin(object, { context, limit, offset })is a host-literal delegation.400, and a badlimit/offset400naming the parameter.assertCallerManagesRecycleBinrefuses403 PERMISSION_DENIEDunless the effective permissions grantmanageRecycleBinon the object. It fails closed when no resolver answers or the resolver throws. The system is exempt.deleted_at desc, id desc), withlimit + 1rows fetched to answerhasMore.restore/purgetake an optionalobject. An entry of another object answersnull/falseand nothing is dispatched.callerRecycleBinManagementwas factored out of the restore check, which keeps its text.recycleBinPlatformObjectRefusalis exported frompurge.ts.The delete answer names the entry (#30239; seat ruling S2).
deletetellsoptions.onRecycleBinEntry(entryId)the entry it wrote. It does so after the transaction commits, and only when the driver reports the row removed (notfalseor0).RecycleBinDeleteObservability, andObjectQL.deletetakesEngineDeleteOptions & RecycleBinDeleteObservability. This is theWriteObservabilityOptionsshape update already uses.ENGINE_DELETE_OPTION_KEYSadmits the key, and the drift pin lists it as delete's one type-only extra.deleteDataanswersrecycleBinEntryIdwhen it is told one.@objectstack/clientDeleteDataResultgains the key.Spec (consent 6721939207; S1 and S3).
DeleteDataResponseSchema.recycleBinEntryId: z.string().optional().restore: { all: ['delete'] },purge: { all: ['delete'] }. The docblock and theisApiOperationAllowedcomment are corrected, andapi-derivation.test.tsis updated.authorable-surface/api.jsonwas regenerated by the build (one row).Client.
client.recycleBin.list(object, { limit, offset }),.restore(object, entryId),.purge(object, entryId)and.empty(object). TheRecycleBinPageandRecycleBinRestoreReporttypes are added.Route ledger, OpenAPI, discovery.
recycle-binrows (dispositionsdk, clientsrecycleBin.*)./openapi.jsonthroughgetRoutes().routes.data(S4, noApiRoutesSchemachange).Docs.
content/docs/protocol/kernel/http-protocol.mdx: the "no recycle-bin runtime" warning is replaced. It gains a "Recycle Bin" section with the doors table, and the delete answer example now showsrecycleBinEntryId.content/docs/permissions/system-context.mdx: row 29f owns the list check'sisSystemread. The register was regenerated with--write.Tests
packages/rest/src/recycle-bin-routes.test.ts(new, 33):getQueryableFields; the read-projection fallback withholdsmaskingRulefields; no answer leaves only theid.details, and 404s.delete→ 405 at all four doors, and no engine verb is called.packages/objectql/src/recycle-bin/list.test.ts(new, 26):manageRecycleBin/modifyAllRecordsallowed.allowRestoreOwnDeletedonly,allowDeleteonly, manage without read, manage on another object, and a throwing resolver are each refused 403 with no read.restore/purgeunder another object.onRecycleBinEntry: told after removal; not told for permanent, no bin, a platform object, or a driver answeringfalse/0; not told when the removal throws, and the entry goes with it.packages/metadata-protocol/src/protocol.delete-recycle-bin-entry.test.ts(new): the answer carriesrecycleBinEntryIdand parses againstDeleteDataResponseSchema; no key when no entry was written.objectql-slot-consumer-census(8)REST_SERVER_REGISTRAR_FILESapi.enableCrudremoves the four doors)no-record-echorows)check:route-envelope({ responses: 0, ok: 0, err: 0 })recycleBin.list)engine-unknown-optiondrift pinAblations (9, each red, each restored to HEAD by scripts/ablation-replace.mjs)
A1–A4b run objectql
src/recycle-bin/list.test.ts, A5–A9 run restsrc/recycle-bin-routes.test.ts.A1-list-manager(the manager refusal never throws): 6 failed | 18 passed; e.g. "refuses, 403, when no permission resolver answers: it fails closed, and reads nothing"A2-restore-object(object mismatch line deleted): 1 failed | 23 passed; "restore answers null, and dispatches nothing, for an entry of another object"A3-purge-object(object mismatch line deleted): 1 failed | 23 passed; "purge answers false, and dispatches nothing, for an entry of another object"A4b-callback-on-unremoved(entry told whatever the driver answered): 2 failed | 24 passed; "does not call back when the driver answers false (not found)", "… 0 (kept)"A5-rest-exposure(the purge door's exposure gate removed): 1 failed | 32 passed; "answers 405 at every door of an object whose API withholdsdelete, and calls no engine verb"A6-fls-fields(every value served): 3 failed | 30 passed; e.g. "lists the object's entries as the caller, with each row's values cut to the fields it may query on"A7-mask-fallback(fallback keeps masked fields): 1 failed | 32 passed; "with only a read projection, withholds every field that declares a maskingRule"A8-restore-receipt(engine report served verbatim): 1 failed | 32 passed; "answers a receipt, never a record body: a member the report carries beyond its five is not served (The write-response internal-field tripwire walks the protocol class only — a direct engine write mouth outside it (rest-server's batch ql.update) is covered by the fix but not by the guard #8497)"A9-paging-declared(limitdeclared as any number): 3 failed | 30 passed; e.g. "refuses {"limit":"1.5"} through its declaration (limit), 400 naming the parameter"A first A4 leg (entry id taken before
driver.delete) stayed green. A throwing removal skips the callback by exception propagation alone, so that pin cannot see the placement. The "driver answersfalse/0" pin (A4b) was added for the case that the placement does decide.Acceptance notes
Deviations from the claim surface (6721792971), each needed by the delete answer or by a gate:
packages/metadata-protocol(deleteDataanswers the key)packages/client(recycleBin.*, theDeleteDataResultpin)api-derivation.test.tscontent/docs/references/api/protocol.mdx(one row, from S1)authorable-surface/api.jsonscripts/check-route-envelope.mjs(the new module's declaration)Metadata-protocol: semantic, and@objectstack/specisminor. The authorable-surface shard moved, sononeis refused bycheck-changeset-no-major, and the derived restore/purge exposure changes meaning. The other four packages arepatch.A row the driver does not remove keeps its bin entry. A by-id delete whose driver answers
false/0still leaves the entry written before it. The answer no longer names it. Compensating it there would also drop any cascaded children captured in the same entry, so it is left as it was before this PR (PR 1 behaviour) and is not changed here.S2 was taken out of spec. Putting the callback on
EngineDeleteOptionshad two effects:check:spec-parsed-alias(ADR-0122) asked for a line to be deleted fromtype-alias-convention.pin.test.ts.HookDeleteOptions = Omit<EngineDeleteOptions, …>(hook-api.ts) would have given app hook bodies the callback.Both files are outside consent 6721939207. The callback is therefore typed in objectql, beside the options, the way update's
WriteObservabilityOptionsare.data-engine.zod.tsis byte-identical to main. The spec diff is now S1 + S3 only, which is narrower than the consent.The list rides the
restoreexposure gate (there is nolistverb on the bin). Purge and empty ridepurge.Verification
Head
274a8241fc(origin/main6ed533f6b6merged). 32 files changed, +1804 / −49.node scripts/pm/dispatch-gates.mjs --commands: 140 families, each run with its exit captured before any pipe. Every one exits 0 on the final tree.--ranreconciliation:140 derived, 140 run, 0 NOT-MEASURED, 0 UNRUN.check:dts-closure,check:dual-build-cjs-loads,check:type-check-debtandcheck:skill-examplescheck:docs(the protocol reference regenerated)check:spec-parsed-alias(answered by taking S2 out of spec)check:test-source-alias(module-top side-effect imports in six touched tests)spec check:generated: exit 0.check:system-context-census(row 29f +--write) andcheck:route-envelope: exit 0.tsc --noEmitfor spec, objectql, metadata-protocol, client and rest: exit 0. eslint (--no-inline-config) over the 27 touched source files: exit 0.src/data+src/apiAblations A1–A3 and A5–A9 were measured at
3e3d14d7b4(those files are unchanged since). A4b was re-measured at the final guard text: 2 failed | 24 passed, restored to HEAD.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5nYzXijPZzrM68FB5J