Skip to content

feat(service-storage): rename an attachment by the delete rule, and the Attachments tab names other people's uploads - #36458

Merged
objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/issue-35724-attachment-uploader-rename
Nov 22, 2026
Merged

objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/issue-35724-attachment-uploader-rename

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

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."

  • Uploader, expanded through the reader's own read. No name column is stamped. Both reads the panel uses now expand uploaded_by, the way the activity stream already expands actor_id: the record page payload's attachments part (packages/rest/src/record-page-routes.ts, the producer of the panel's first read, so the fix lands there rather than in service-storage) and the panel's own list read ($expand: ['uploaded_by']). The expansion is the engine's $expand sub-read of sys_user as the caller (CRUD gate, row scope, field security), so a reader who may read the uploader gets the user row and its name, and a reader who may not keeps the stored id, which the panel never renders. The spec's stream table (record-page.zod.ts JSDoc, prose only, restating the ruling) and its generated reference page say so.
  • Rename door. PATCH /api/v1/attachments/:id with 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_FOUND for 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 (whose authorizeRows is the same function the delete gate runs) decide. A caller who reads the record but cannot edit it gets the update gate's 403 RECORD_NOT_ACCESSIBLE. Only sys_attachment.file_name changes; sys_file is untouched.
  • Docs. content/docs/permissions/attachments-access.mdx gains 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.
  • Affordance map. @object-ui/core's affordance-to-grant map gains the row attachmentRename (crud: null, grant update), with its expectation in the census test affordanceGrantMap-12082. The panel asks this row for the edit-grant half of Rename, because the census refuses a CRUD grant read outside the map.
  • Panel. The row ⋮ menu offers Rename behind the delete grant (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 on sys_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:

  1. packages/services/service-storage/src/attachment-removal-routes.ts — renameAttachment: the owner comparison is the only thing that admits the elevated write.
  2. packages/rest/src/record-page-routes.ts — answerAttachments now expands uploaded_by (wire change for that part's rows).
  3. ui/packages/app-shell/src/views/RecordAttachmentsPanel.tsx — handleRename and AttachmentRenameDialog.

Tests

All runs on the tree of 78e903181, under scripts/pm/os-verify-lock.sh (VERDICT command-exit 0).

  • @objectstack/service-storage: full pnpm test, 87/87 files, 1708 passed, 1 skipped. typecheck exit 0. New pins in attachment-removal-routes.integration.test.ts run against a real ObjectQL on in-memory sqlite with StorageServicePlugin:
    • the uploader with no edit grant renames (200; the name is trimmed and stored; sys_file untouched);
    • a parent editor renames another user's upload (200);
    • an editor without the edit grant renaming another user's upload gets 403 PERMISSION_DENIED; a reader who is not an editor gets 403 RECORD_NOT_ACCESSIBLE;
    • a caller who cannot read the record, and an unknown id, get 404 RECORD_NOT_FOUND; anonymous gets 401; bad bodies and any query parameter get 400 VALIDATION_ERROR;
    • a reader of the uploader reads uploaded_by as { id, name }; a reader refused sys_user keeps the bare id and gets no name.
    • The route-ledger conformance test now enumerates both doors.
  • @objectstack/rest: pnpm test --project local, 427 files, 8776 passed, 351 skipped. typecheck exit 0. record-page-routes.test.ts pins the attachments part's read with uploaded_by expanded.
  • @object-ui/app-shell and @object-ui/i18n: the four attachments-panel test files plus the i18n tests, 110 files, 2039 passed, 13 skipped. New pins:
    • the panel's list read expands uploaded_by; an expanded row shows the uploader's name; a bare-id row shows no id, no name and no title;
    • Rename sends a PATCH with the trimmed name and shows the stored name; a 403 keeps the dialog open with the rule in words; a blank or unchanged name leaves Save disabled;
    • with no delete grant there is no Rename; with the delete grant but no edit grant, the menu is Download, Delete attachment; with both, it is Download, Rename, Delete attachment.
  • Rework round 2: the uploader holding delete but not edit sees Rename on their own row and no Rename on another's row. This is pinned for a bare-id uploaded_by and for an expanded one; delete+edit sees Rename on every row, and no delete grant means no Rename. Panel tests at 6582d7525: 4 files, 63 tests, under the lock (VERDICT command-exit 0).
  • Final head f4edf7037 (after merging main and adding the map row), under the lock (VERDICT command-exit 0):
    • UI: the four attachments-panel files, the affordance-map census affordanceGrantMap-12082, core affordanceGrant-35684 and the i18n tests passed, 112 files, 2098 passed, 13 skipped.
    • service-storage: the rename-door integration test and the route-ledger conformance test passed, 2 files, 19 tests.
    • rest: record-page-routes.test.ts passed, 37/37.
    • Run alone, the census file also passed, 55/55.
Ablations (each one: mutate with scripts/ablation-replace.mjs, run, restore proven by blob == HEAD and an empty git diff HEAD)
  1. The uploader's elevated write removed (row[ownerField] === callerId replaced by false). 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, blob 43dbe9a9e46e.
  2. The record page's expand: relationMap(['uploaded_by']) removed: record-page-routes.test.ts red, 1 failed, 36 passed (37). Restored, blob f91616543c2e.
  3. The panel's $expand: ['uploaded_by'] removed: RecordAttachmentsPanel.test.tsx red, 1 failed, 45 passed (46), on "the list read expands the uploader". The first attempt ran no tests because the @objectstack/client dist was missing, so that reading is void; it was rerun after building the client. Restored, blob 0b11778a08b5.
  4. Rename offered without the canDelete guard: affordanceGrant-12047 red, 3 failed, 5 passed (8). Restored, blob 0b11778a08b5.
  5. Rework, at 927ff8061: Rename gated on the delete grant alone (canRename = canDelete). affordanceGrant-12047 went red, 1 failed, 8 passed (9), on "a reader who may delete but holds no edit grant sees Delete and no Rename". Restored, blob 930fe40d0cfe. The first attempt at this ablation was void: the fresh worktree had no @objectstack/spec dist, so no tests ran. It was rerun after building the @objectstack/client... closure. (Superseded by round 2's gate.)
  6. Rework round 2, at 6582d7525 and again at the final head f4edf7037 (same reading both times): the uploader limb of canRename removed (return !!callerId && uploaderId === callerId; replaced by return false;). affordanceGrant-12047 went red, 2 failed, 8 passed (10), on both uploader pins (bare-id and expanded). Restored, blob c269fef686b4, with git diff HEAD empty.

No ablation test file is kept.

Acceptance notes

  • Landing spot outside the claimed surface. The panel's first read is the record page payload, and that payload is produced in packages/rest/src/record-page-routes.ts, not in service-storage. The expand is added at that producer, with its test pin. Other files outside the claim, all following from that:
    • the spec's JSDoc prose in packages/spec/src/api/record-page.zod.ts (prose only, restating the ruling; no Zod shape changes);
    • its generated reference page content/docs/references/api/record-page.mdx;
    • the tenant-audit write census for service-storage (one new write call site, decidable as sys_attachment);
    • the dogfood record-page streams test, which now asserts the expanded uploader.
  • Refusal code. A reader who is not an editor gets the update gate's standard 403 RECORD_NOT_ACCESSIBLE, not the delete gate's ATTACHMENT_DELETE_DENIED. A new verb takes the standard code.
  • Deviations.
    • The UI gates Rename by the rename door's two limbs, beyond the card's wording "a reader who may delete". Behind the delete grant, Rename is offered on the caller's own uploads, and on every row to a reader who also holds the edit grant. This matches the server exactly: the door renames an uploader's own attachment with no edit grant, and writes anyone else's rename as the caller, which needs the edit grant. So the gate changes no permission; it only stops offering a door the server refuses. This is a seat ruling (f7-text relay, rounds 1 and 2).
    • Two files outside the claim surface were touched to clear that census: ui/packages/core/src/utils/affordanceGrants.ts (the new row) and ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx (its expectation). @object-ui/core is added to the changeset as a patch.
    • The docs paragraph on the rename door is added in this PR (content/docs/permissions/attachments-access.mdx).
  • "No name and no id." A reader refused sys_user gets 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.
  • What a rename changes. Only sys_attachment.file_name. The stored sys_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.
  • Known, not fixed here (L2 N4). sys_attachment.file_name is still described on the object as a denormalised copy of sys_file.name. After this door the two can differ. That wording fix is outside this diff.
  • Member uploads on the Attachments tab. The panel offers Delete, and so Rename, only to a holder of the sys_attachment delete 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 403 RECORD_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 at 78e903181, 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-closure refused because main had moved PER_CHUNK_GZIP_CEILINGS (ui-components 451100 -> 445144) after the branch's base, and the gate's log reads "NOTHING GREW" (measured ui-components 344.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 on 6582d7525 all 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 direct perms.can('sys_attachment','update'). The census test affordanceGrantMap-12082 ("no console source outside the map reads a CRUD grant on its own") listed RecordAttachmentsPanel.tsx, the only failure in 442 files. The fix is the attachmentRename map row read through resolveAffordance; 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 at f4edf7037.

  • The --commands derived gate list was run at 1bc31906e (103 commands), and the 22 families added by later commits plus every earlier failure were rerun at 78e903181. Exit codes are in the report.
  • NOT MEASURED locally, for these reasons:
    • check:dual-build-cjs-loads and check:i18n: their prerequisite builds are absent (exit 3);
    • check-plugin-teardown-shape --self-test: shallow clone (exit 3);
    • @object-ui/app-shell type-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.
  • CI's Type Check UI, Test Core and dogfood jobs cover these.

Generated by Claude Code

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>
@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 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/rest, @objectstack/service-storage, @objectstack/spec, touching 21 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/src/api/record-page.zod.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

40 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 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9.

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

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/src/api/record-page.zod.ts) — pages documenting those are invisible to this run
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 68 of 251 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 179 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 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 6de301737e7505c06e3653fb21ff6427a81122f2 — the merge of head f4edf7037bbbd16e75ca46e20f4cb49b67b0f764 into base 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9, 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 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

⚠️ 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 2c5b90db052ee980fb6cf8e1d7dabbd87b99c1d9 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…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>
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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jTyyBmoPBsURQjeJGq

Final green head · 2026-11-22T14:08Z
Head-sha: f4edf7037bbbd16e75ca46e20f4cb49b67b0f764
CI on this head: 62 success, 11 skipped, 0 failing or pending; mergeable clean. One PR-body guards run was cancelled by a body edit, and its rerun on this head is green.
This round:

  • Ruling B: canRename = canDelete && (edit grant || the row's uploaded_by is the caller), pinned for a bare-id and an expanded uploaded_by, with an ablation.
  • The Build & E2E UI red came from a ceiling main moved after the branch base. Cured by merging origin/main; no ceiling was edited.
  • The Test UI 15/16 red was this PR's: the affordance census flagged a direct CRUD-grant read. Cured by a new attachmentRename row in @object-ui/core AFFORDANCE_GRANTS, plus its census expectation.
  • The body now names both off-surface files.
    Dev delta: Attachments tab: blank uploader for other people's files (uploaded_by arrives as a bare id) and no Rename in the file-row menu (follow-up to #35602) #35724 comment 7079944559.
    Declarations: see the PR body. packages/spec/src/api/record-page.zod.ts is edited (JSDoc), so CONTRACT_REVIEW_TIER applies.
    Review: L1 owed (+1154/−198, 29 files) and an L2 at CONTRACT_REVIEW_TIER (seat), both requested via the seat on this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f4edf7037bbbd16e75ca46e20f4cb49b67b0f764
Local-runs: none
Scope: packages/spec/src/api/record-page.zod.ts + packages/rest/src/record-page-routes.ts, packages/services/service-storage/src/attachment-removal-routes.ts, packages/services/service-storage/src/attachment-removal-route-ledger.ts, packages/services/service-storage/src/storage-service-plugin.ts, ui/packages/core/src/utils/affordanceGrants.ts, ui/packages/app-shell/src/views/RecordAttachmentsPanel.tsx, content/docs/permissions/attachments-access.mdx

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: packages/core/src/security/own-row-delete-routes.ts, packages/services/service-storage/src/attachment-access-hooks.ts, attachment-files-opt-in.ts, attachment-lifecycle.ts, packages/platform-objects/src/audit/sys-attachment.object.ts, packages/core/src/security/resolve-authz-context.ts, the plugin-security middleware registration, and the HTTP server contract.

① Derived judgments

  • New route PATCH /api/v1/attachments/:id, body exactly file_name. Right: a new door, ledgered as a gap row beside the removal door, and the conformance test enumerates both.
  • New capability: the uploader renames their own attachment with no edit grant on sys_attachment. Right, and it is the widening the card asks for ("same permission as Delete: uploader or parent editor"); it mirrors the removal door's elevation line for line.
  • A rename by anyone else adds no capability: it is the update the data door already admits (edit grant, then the update gate's uploader-or-parent-editor row rule), reached through a second route. Right.
  • The record page payload's attachments rows now carry uploaded_by expanded where the reader may read the user, and the stored id otherwise. Right as a change the response schema admits (RecordPageStreamRowsSchema rows are open records), and it is the same expansion the activity part already makes of actor_id. A consumer that compared the field with an id must read .id; the changeset says so.
  • @object-ui/core AFFORDANCE_GRANTS gains attachmentRename (crud: null, grant update). Right: an added row, with its census expectation.
  • mountAttachmentRemovalDoor now mounts neither door on a server lacking DELETE or PATCH. Right: the IHttpServer contract declares both verbs, so no conforming server loses the removal door.
  • No Zod shape changes in record-page.zod.ts: prose only. Right.

② Semver level

Clause-②: 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 @objectstack/service-storage, @objectstack/rest, @object-ui/app-shell, @object-ui/i18n and @object-ui/core follows the rule that a non-protocol change ships patch. Check Changeset is success on the head.

N1 (nit): @objectstack/spec is not in the changeset although its JSDoc (which ships in the declarations) and its generated reference page changed. Prose only, the gate accepted it; left as an accepted deviation.
N2 (nit): the changeset says "no answer narrowed" while its own second bullet tells a consumer of uploaded_by to read .id. The note is there, so the reader is served; the opening sentence is slightly generous.

③ Boundary flags

  • Open question 1 (delete grant without edit grant): answered by the seat as B, then B again on the uploader row. Implemented in the panel as canDelete and (edit grant or the row's uploader is the caller). The server is unchanged by both rulings, which is correct: see section ④.
  • Open question 2 (bare id reaching a reader refused sys_user): answered A. The engine's stored form stays, and the panel renders no id, no name and no title; pinned.
  • Rework 1 question (uploader row exemption): answered B, implemented, pinned for a bare id and an expanded value.
  • Docs follow-up from the first report: done in this PR (attachments-access.mdx).
  • Download keeps the original sys_file name after a rename: declared in the PR and in the docs, not filed. Accepted.
  • Deviations (files outside the claim, refusal code RECORD_NOT_ACCESSIBLE for the new verb, the two census files): each explained and each follows from where the producer or the census lives. Accepted.
  • Process note for the seat: the two rulings are not comments on the card thread; this record takes them from the dev reports that quote them (7079463814, 7079944559).
  • SQL push-down: no new id materialisation and no in-app join. The door is one by-id read and one by-id write; the uploader name comes from the engine's own expand, the mechanism the activity part already uses.

④ Design judgment

packages/spec/src/api/record-page.zod.ts: the two edited sentences say the attachments part is the sys_attachment read "with $count and its uploader expanded" and, in the table, "uploaded_by expanded". The route does exactly that: answerAttachments passes expand: relationMap(['uploaded_by']) through the same readStream the activity part uses, so the surrounding sentence ("asked of the data door as the caller") still holds for the expansion. The first consumer (the panel) reads both the expanded and the bare form, and its own fallback list read asks the same $expand, so the part stays "the read it replaces". The JSDoc matches what the server serves. The JSDoc makes no statement about rename, so there is nothing in it to hold against the rename door.

Server-side authorization of the rename, judged on renameAttachment against the update gate on main:

  • The rule is enforced on the server, not only in the panel. The row is read as the caller first (grant, organization wall, parent-derived read visibility), and an unreadable row answers the unknown id's 404.
  • Uploader limb: the only thing that admits the elevated write is row.uploaded_by === callerId on the row just read as the caller. uploaded_by is server-stamped on create and readonly on update, so a caller cannot make themselves the uploader. A hidden, null or expanded value fails the comparison and falls to the caller limb, so it fails closed. The elevated write carries only file_name, so the gates it skips (re-point, file reference, files opt-in) have nothing to judge, and the row rule it skips would have passed the uploader anyway. The column's length rule is the record validator's and is not skipped.
  • Caller limb: engine.update as the caller. plugin-security's check is an engine middleware every operation passes, and the attachment beforeUpdate gate runs authorizeRows, the same function the delete gate runs. So the edit grant and uploader-or-parent-editor decide, as the door's JSDoc says.
  • The handler is the removal door's handler step for step (caller resolution, anonymous refusal, held sign-in, no query, id, then the body), and the body admits one key with a non-blank string.
  • API-key scopes on this platform add permissions and never narrow, and the door accepts no OAuth token, so the elevation opens nothing through a narrower credential.

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.

content/docs/permissions/attachments-access.mdx, the door's JSDoc, the ledger note and the changeset all describe the same rule as the code, sentence by sentence, including the five refusal codes.

N3 (nit): affordanceGrants.ts says the panel asks the attachmentRename row "only for rows the caller did not upload". The panel resolves it once per render and tests it before the uploader comparison. The verdict is identical for every row; only the sentence is looser than the code.
N4 (nit): sys_attachment.file_name is still described on main as a "Denormalised copy of sys_file.name"; after this door it can differ. A follow-up wording fix, outside this diff.
N5 (nit): the grant-dependent answers of the door (uploader with no edit grant 200, non-uploader without the grant 403) are pinned against a fixture middleware standing in for plugin-security, and no pin exercises a name over 255 characters. The lane seat's remainder; a dogfood pin on the real stack would be the stronger form.

No must-fix, no should-fix.

Implemented-by: claude/issue-35724-attachment-uploader-rename
Reviewed-by: session_01QsR2jTeURPvEm465RcoYEC

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jSpi3g1dQNTvN6zEuH

席位核对

L1 (L1-e) on head f4edf7037b, card #35724: ACCEPT, with one landing condition (body only). The contract-tier L2 owns the depth reading of the door's elevation.

Landing condition. The panel still offers Delete only to a holder of the sys_attachment delete grant (attachmentDelete, through dataSource.delete). The member grant is { allowRead, allowCreate } (attachment-member-grant.ts:66). So a member who uploaded a file is offered neither Delete nor Rename on it, although both doors admit them: the removal door since #33010, and this PR's rename door. As a result, canRename's uploader limb never reaches a member.

  • This is the "console half" the ledger names ("it moves to this route in the console half of the same ruling"). I found no open card for it.
  • This PR makes the gap wider by one verb. It does not cause it. Rename follows the panel's existing canDelete, as the card's "a reader who may delete" reads, and the docs say so plainly ("offers Rename to a reader who holds the delete grant").
  • Before landing, file a card, or name an existing one, for "the Attachments tab offers a member neither Delete nor Rename on their own upload". Add "carried by #N" to the Acceptance notes.

Read

  • Shape (l1-face.mjs --pr 36458): open, draft, base main, Fixes #35724, Clause-②: yes (widening), Metadata-protocol: none.
    • The face flags changeset for @objectstack/spec and @object-ui/plugin-form. The spec touch is JSDoc prose in record-page.zod.ts with no Zod shape change. The plugin-form touch is one test expectation. Neither owes an entry.
    • Gates: 62 success, 11 expected skip. The one cancelled PR-body guards row superseded at this head is not a red.
  • Fixes is right.
    • Done-when 1: the record page payload's attachments part and the panel's own list read both expand uploaded_by, as the caller. A reader who may read the user gets the row. One who may not keeps the stored id, which the panel never renders (uploaderOf: an object's name, the viewer's own name, else ''). Both sides are pinned.
    • Done-when 2: Rename persists, pinned end to end on both halves. The panel sends PATCH /api/v1/attachments/:id with exactly { file_name } (trimmed), and the door stores it and answers { id, file_name }. A reader who may not delete sees no Rename, pinned and ablated.
  • The door. It reads as the caller first (findOne with context), so a row out of sight is 404 alike with an unknown id. Then it uses one of two limbs:
    • The uploader (uploaded_by === callerId, the only test that admits elevation) writes under isSystem with attributedUserId and the caller's tenantId. That is the removal door's elevation for the same ruling (6879388034).
    • Anyone else updates as the caller, so the edit grant and the update gate (whose row rule is the delete rule) judge it.
    • The body takes exactly file_name (non-blank, trimmed). Query parameters are refused, and unknown keys are refused, not ignored. An update that matches nothing answers 404, not 200.
    • Refusals carry code and status (the ADR-0112 envelope), asserted in the integration test, for example [403, 'RECORD_NOT_ACCESSIBLE'].
  • Ruling B (canRename = canDelete && (edit grant || uploader)) matches the door exactly: anyone else's rename needs the edit grant. It goes through the new AFFORDANCE_GRANTS.attachmentRename row, so the census holds without an OUT_OF_FAMILY entry. Both limbs are ablated red.
  • Scope. The surface reached outside the claim (the record-page producer, the spec prose and its generated page, the tenant-audit census, the dogfood stream test, the grants row) is each named in the body with its reason, and each follows from the expand or the census.
  • Sentences, checked one by one. The changeset, attachments-access.mdx (the code table, the limbs, "only the name the attachment is listed under changes") and record-page.mdx are true of the diff. The consumer note in the changeset (uploaded_by.id where the reader may read the user) is the one shape change, and the panel's own comparisons read both forms.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jTyyBmoPBsURQjeJGq

Landing · 2026-11-22T14:24Z · head f4edf7037bbbd16e75ca46e20f4cb49b67b0f764 · L1-e ACCEPT 7080423901 · L2 PASS 7080422574 (CONTRACT_REVIEW_TIER)

probe reading
check-governed-merges.mjs --pr 36458 NOT governed · 1352 changed lines ≤ 3000
landing-k.mjs --pr 36458 K = 3 < 15
checks on head 62 success, 11 skipped, 0 failing · mergeable clean (body-guard reruns after the body edits: success)
landing condition (L1) the member-upload gap is carried by #36488, in the Acceptance notes
L2 nits N4 is in the Acceptance notes as known; N1-N3 and N5 are accepted as nits

Ready + auto-merge in this stroke; Fixes #35724 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 14:24
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit c9b0a23 Nov 22, 2026
82 of 83 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35724-attachment-uploader-rename branch November 22, 2026 14:53
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.

Attachments tab: blank uploader for other people's files (uploaded_by arrives as a bare id) and no Rename in the file-row menu (follow-up to #35602)

2 participants