Files
pad/plugin
xarmian 237333681b feat(attachments): attach binds an unattached upload to an item, so its share renders it (TASK-2247) (#1652)
The July audit's share-page broken-image finding was fixed by BUG-2389 and
TASK-2637: the share byte endpoint serves variants of attachments the
shared item OWNS. What was left: an image uploaded with
`pad attachment upload -` (item_id NULL) and then embedded is never owned,
so its share shows the placeholder. A census of this workspace found 4
such refs out of 13, all from that path.

Lead ruling (option C): fix it explicitly, with no implicit binding on
content writes.

- POST /workspaces/{ws}/attachments/{id}/attach {item}. It binds a live,
  unattached original in this workspace, and its live variants, to an
  item. Every UPDATE requires item_id IS NULL, so an attached row is never
  moved, and the bind is exclusive with the never-attached GC claim. The
  item is pinned like CreateAttachmentForLiveItem.
- Authorization: the caller can see and edit the item, and uploaded the
  attachment or is a workspace owner. An attached row answers 409 to a
  caller who can see its owner, and the shared 404 to anyone else.
  Restricted members and guests cannot read unattached rows, so they get
  the 404. That closes the case where a guest binds an id they know to an
  item they can edit and publishes it through its share.
- The attachment_attach capability. `pad attachment attach <id> <item-ref>`
  refuses against a server that does not advertise it, because an older
  build's bare 404 would read as "attachment not found".
- The `upload -` help text, the attachment group help, both skill copies
  and CLAUDE.md say an unattached image does not render on share pages.
- No MCP surface: pad_attachment has no upload.

Tests: 12 server/store tests, including an end-to-end share leg (404
before, variant bytes after), and 9/9 mutants killed. CLI capability
gate: 2 tests, mutant killed. e2e: the share renders the image after
attach; with attach made a no-op it goes red at "attached: no
placeholder".

Claude-Session: https://claude.ai/code/session_01NidgPePY7UvHcEJCMkD2Qz
2026-09-28 19:25:55 -04:00
..