Repository navigation
feat(service-storage): rename an attachment by the delete rule, and the Attachments tab names other people's uploads - #36458
Conversation
…el Rename Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…d the uploader cannot edit Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…rate record-page reference doc and tenant-audit census Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…ver the sent one Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…ploader elevation is observable; regenerate zh-Hant Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 40 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 179 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 6de301737e7505c06e3653fb21ff6427a81122f2 && git checkout 6de301737e7505c06e3653fb21ff6427a81122f2
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9 f4edf7037bbbd16e75ca46e20f4cb49b67b0f764 && git checkout -B drift-repro 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9 && git merge --no-ff f4edf7037bbbd16e75ca46e20f4cb49b67b0f764
node scripts/docs-audit/affected-docs.mjs --json 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9
|
…nt the rename door The rename door writes a non-uploader's rename as the caller, which needs the edit grant on sys_attachment, so the row menu stops offering Rename to a delete-only reader. The attachments access page gains the rename door. Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…t grant The rename door renames an uploader's own attachment with no edit grant, so the row menu now follows its two limbs: behind the delete grant, Rename is offered on the caller's own rows, and on every row to an edit-grant holder. Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…uploads too Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
Brings the branch onto main 85a9954 so the eager-closure gate weighs against the ceilings in force (PER_CHUNK_GZIP_CEILINGS moved on main). Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
…ant map The console census refuses a CRUD grant read outside the map, so the panel's edit-grant half of Rename is now the map's attachmentRename row. Claude-Session: https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTyyBmoPBsURQjeJGq Final green head · 2026-11-22T14:08Z
|
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC Contract reviewServed-tier: Inputs read: card #35724 body and all five comments (triage 7029758904, claim 7077769852, dev reports 7079248362, 7079463814, 7079944559), PR #36458 body, file list and net diff at the head, the check-runs on the head (62 success, 11 skipped, one cancelled PR-body guards run whose rerun on this head is success; nothing failing or pending). Code outside the diff was read on the main checkout only: ① Derived judgments
② Semver levelClause-②: yes (widening) is correct on the PR body and the changeset, and Metadata-protocol: none is correct (nothing an author can write changes). Patch on N1 (nit): ③ Boundary flags
④ Design judgment
Server-side authorization of the rename, judged on
The UI gate is narrower than the server in two places, both correct and both stated in the docs page: the server asks no delete grant on either limb (the uploader limb needs no grant at all, and an edit-grant parent editor without the delete grant can already rename through the data door), while the panel asks the delete grant first. The panel offers one case the server refuses (delete and edit grants, not the uploader, not a parent editor), which the panel cannot see and answers in words.
N3 (nit): No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jSpi3g1dQNTvN6zEuH 席位核对L1 (L1-e) on head Landing condition. The panel still offers Delete only to a holder of the
Read
|
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTyyBmoPBsURQjeJGq Landing · 2026-11-22T14:24Z · head
Ready + auto-merge in this stroke; |
Requested by Steedos · project thread
Fixes #35724
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
Rulings (quoted from the card): "The attachments read the panel uses returns the uploader's display name (an expand of
uploaded_by, or a name field the server stamps), shaped by the reader's existing user-read rights, and no wider." and "Add a rename route on the attachment service (same permission as Delete: uploader or parent editor), and a Rename item in the row ⋮ menu that calls it."uploaded_by, the way the activity stream already expandsactor_id: the record page payload'sattachmentspart (packages/rest/src/record-page-routes.ts, the producer of the panel's first read, so the fix lands there rather than inservice-storage) and the panel's own list read ($expand: ['uploaded_by']). The expansion is the engine's$expandsub-read ofsys_useras the caller (CRUD gate, row scope, field security), so a reader who may read the uploader gets the user row and itsname, and a reader who may not keeps the stored id, which the panel never renders. The spec's stream table (record-page.zod.tsJSDoc, prose only, restating the ruling) and its generated reference page say so.PATCH /api/v1/attachments/:idwith exactly{ "file_name" }, mounted beside the uploader's removal door at the same route (attachment-removal-routes.ts, a ledger row per door). It reads the row as the caller (404 RECORD_NOT_FOUNDfor an unreadable or unknown id), then writes by the delete rule's two limbs without restating it: the uploader is renamed under a system context attributed to them, as the removal door removes (no edit grant needed), and anyone else's rename runs as the caller through the engine, so the object's edit grant and the attachment update gate (whoseauthorizeRowsis the same function the delete gate runs) decide. A caller who reads the record but cannot edit it gets the update gate's403 RECORD_NOT_ACCESSIBLE. Onlysys_attachment.file_namechanges;sys_fileis untouched.content/docs/permissions/attachments-access.mdxgains a rename-door section (who may rename, the edit grant, the uploader's self-rename, the 400/401/403/404 answers) and an enforcement-summary row.@object-ui/core's affordance-to-grant map gains the rowattachmentRename(crud: null, grantupdate), with its expectation in the census testaffordanceGrantMap-12082. The panel asks this row for the edit-grant half of Rename, because the census refuses a CRUD grant read outside the map.canDelete), following the rename door's two limbs (canRename, seat ruling in rework): on the caller's own uploads, and on every row to a reader who also holds the edit grant onsys_attachment. It opens a name prompt; Save is disabled for a blank or unchanged name; a refused rename keeps the dialog open with the rule in words. Four new i18n keys in all eleven locale packs.Read first, by risk:
packages/services/service-storage/src/attachment-removal-routes.ts—renameAttachment: the owner comparison is the only thing that admits the elevated write.packages/rest/src/record-page-routes.ts—answerAttachmentsnow expandsuploaded_by(wire change for that part's rows).ui/packages/app-shell/src/views/RecordAttachmentsPanel.tsx—handleRenameandAttachmentRenameDialog.Tests
All runs on the tree of
78e903181, underscripts/pm/os-verify-lock.sh(VERDICT command-exit 0).@objectstack/service-storage: fullpnpm test, 87/87 files, 1708 passed, 1 skipped.typecheckexit 0. New pins inattachment-removal-routes.integration.test.tsrun against a real ObjectQL on in-memory sqlite withStorageServicePlugin:sys_fileuntouched);PERMISSION_DENIED; a reader who is not an editor gets 403RECORD_NOT_ACCESSIBLE;RECORD_NOT_FOUND; anonymous gets 401; bad bodies and any query parameter get 400VALIDATION_ERROR;uploaded_byas{ id, name }; a reader refusedsys_userkeeps the bare id and gets no name.@objectstack/rest:pnpm test --project local, 427 files, 8776 passed, 351 skipped.typecheckexit 0.record-page-routes.test.tspins the attachments part's read withuploaded_byexpanded.@object-ui/app-shelland@object-ui/i18n: the four attachments-panel test files plus the i18n tests, 110 files, 2039 passed, 13 skipped. New pins:uploaded_by; an expanded row shows the uploader's name; a bare-id row shows no id, no name and no title;uploaded_byand for an expanded one; delete+edit sees Rename on every row, and no delete grant means no Rename. Panel tests at6582d7525: 4 files, 63 tests, under the lock (VERDICT command-exit 0).f4edf7037(after merging main and adding the map row), under the lock (VERDICT command-exit 0):affordanceGrantMap-12082, coreaffordanceGrant-35684and the i18n tests passed, 112 files, 2098 passed, 13 skipped.record-page-routes.test.tspassed, 37/37.Ablations (each one: mutate with scripts/ablation-replace.mjs, run, restore proven by blob == HEAD and an empty git diff HEAD)
row[ownerField] === callerIdreplaced byfalse). The first run stayed green, 15/15: the fixture had no edit-grant stand-in, so that reading is void. After adding the edit-grant stand-in and the no-grant uploader pin, it went red: 1 failed, 15 passed (16), on "the uploader renames their own attachment with no edit grant". Restored, blob43dbe9a9e46e.expand: relationMap(['uploaded_by'])removed:record-page-routes.test.tsred, 1 failed, 36 passed (37). Restored, blobf91616543c2e.$expand: ['uploaded_by']removed:RecordAttachmentsPanel.test.tsxred, 1 failed, 45 passed (46), on "the list read expands the uploader". The first attempt ran no tests because the@objectstack/clientdist was missing, so that reading is void; it was rerun after building the client. Restored, blob0b11778a08b5.canDeleteguard:affordanceGrant-12047red, 3 failed, 5 passed (8). Restored, blob0b11778a08b5.927ff8061: Rename gated on the delete grant alone (canRename = canDelete).affordanceGrant-12047went red, 1 failed, 8 passed (9), on "a reader who may delete but holds no edit grant sees Delete and no Rename". Restored, blob930fe40d0cfe. The first attempt at this ablation was void: the fresh worktree had no@objectstack/specdist, so no tests ran. It was rerun after building the@objectstack/client...closure. (Superseded by round 2's gate.)6582d7525and again at the final headf4edf7037(same reading both times): the uploader limb ofcanRenameremoved (return !!callerId && uploaderId === callerId;replaced byreturn false;).affordanceGrant-12047went red, 2 failed, 8 passed (10), on both uploader pins (bare-id and expanded). Restored, blobc269fef686b4, withgit diff HEADempty.No ablation test file is kept.
Acceptance notes
packages/rest/src/record-page-routes.ts, not inservice-storage. The expand is added at that producer, with its test pin. Other files outside the claim, all following from that:packages/spec/src/api/record-page.zod.ts(prose only, restating the ruling; no Zod shape changes);content/docs/references/api/record-page.mdx;service-storage(one new write call site, decidable assys_attachment);403 RECORD_NOT_ACCESSIBLE, not the delete gate'sATTACHMENT_DELETE_DENIED. A new verb takes the standard code.ui/packages/core/src/utils/affordanceGrants.ts(the new row) andui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx(its expectation).@object-ui/coreis added to the changeset as a patch.content/docs/permissions/attachments-access.mdx).sys_usergets the stored bare id back from the server, which is the engine's ADR-0104 stored form. The panel never renders it: no name, no id, no title. The pin asserts what the panel renders.sys_attachment.file_name. The storedsys_file, its bytes, and the file name a download carries are unchanged. That a download keeps the original name is noted here and not filed.sys_attachment.file_nameis still described on the object as a denormalised copy ofsys_file.name. After this door the two can differ. That wording fix is outside this diff.sys_attachmentdelete grant. The member grant has none (attachment-member-grant.ts). So a member is offered neither verb on their own upload, although both doors admit them. This gap predates this PR, which widens it by one verb. Carried by Attachments tab offers a member neither Delete nor Rename on their own upload, though both server doors admit the uploader #36488.Verification
Two-minute check:
pnpm --filter @objectstack/service-storage exec vitest run src/attachment-removal-routes.integration.test.ts— expect 16 passed: the uploader and a parent editor rename (200, name stored, file untouched), a reader-not-editor gets 403RECORD_NOT_ACCESSIBLE, an outsider 404, anonymous 401, malformed requests 400; an attachment read expands the uploader for a reader of that user and keeps the bare id for one refused it.Local subset only; CI runs the full set. Rework at
927ff8061: the derived gate list is unchanged (126 families). The docs families, check:nul-bytes, check:cross-package-test-inputs, check:i18n-stale-fill, check:test-source-alias and spec check:docs were rerun: all exit 0 except spec check:skill-examples, which exited 3 (PREREQUISITE NOT MET, no spec declarations in the fresh worktree) and is NOT MEASURED for the rework. It had exited 0 at78e903181, and the rework does not touch spec or skills.Rework round 2: Build & E2E UI was red on
927ff8061(job 137217115981). That was not a size regression and not this PR's change:check:eager-closurerefused because main had movedPER_CHUNK_GZIP_CEILINGS(ui-components451100 -> 445144) after the branch's base, and the gate's log reads "NOTHING GREW" (measuredui-components344.5 KB against a 440.5 KB ceiling). The fix named by the gate was applied:origin/main(85a995452) was merged in, and no ceiling was touched. Post-merge local gates all exited 0: tenant-audit-census, check:test-source-alias, check:route-envelope, check:i18n-stale-fill, check:nul-bytes, check:doc-anchors and check:cross-package-test-inputs. The docs families on6582d7525all exited 0, and overlap-check was clean. The eager-closure gate itself needs the full UI build and is left to CI.Test UI (15/16) was red on
927ff8061(job 137217116142). This one was this PR's: the round-1 panel read the edit grant with a directperms.can('sys_attachment','update'). The census testaffordanceGrantMap-12082("no console source outside the map reads a CRUD grant on its own") listedRecordAttachmentsPanel.tsx, the only failure in 442 files. The fix is theattachmentRenamemap row read throughresolveAffordance; no OUT_OF_FAMILY entry was added and no test was skipped. That red CI run is the before-leg; the after-leg is the census passing atf4edf7037.--commandsderived gate list was run at1bc31906e(103 commands), and the 22 families added by later commits plus every earlier failure were rerun at78e903181. Exit codes are in the report.check:dual-build-cjs-loadsandcheck:i18n: their prerequisite builds are absent (exit 3);check-plugin-teardown-shape --self-test: shallow clone (exit 3);@object-ui/app-shelltype-check: the ui dist is not built, so it reports 1986 "Cannot find module '@object-ui/*'" errors before reaching any check;pnpm --dir ui exec vitest run scripts/and the dogfood suite: not run.Generated by Claude Code