Skip to content

fix(cli): preserve attachments across successive edits - #9226

Merged
bradseiler merged 6 commits into
mainfrom
honor/media-edit-attachments
Nov 8, 2026
Merged

bradseiler merged 6 commits into
mainfrom
honor/media-edit-attachments

Conversation

@bradseiler

@bradseiler bradseiler commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Editing attachment messages through buzz messages edit can remove their files from the effective message. Preserve the latest live imeta set across successive edits and add --clear-attachments for explicit removal. Add an SDK builder for complete replacement attachment sets while preserving the existing API.

The relay provides a versioned effective-edit lookup on /query for kinds 9/40002/40008/45001/45003; media reads fold the same set. It uses the existing normalized-target index, fresh channel authorization, and a primary snapshot. Generic #e matching is unchanged. Mixed-case historical edits cannot restore removed files, including when another reference would allow republication.

Related issue

Fixes #3022. Follows #9077. Related open attempts: #3062 and #3065.

Testing

Published head: c630c4ebf0b20a9618f4844629eec1e666699cbe, through all mandatory push hooks. The governed-five snapshot passed all four PostgreSQL/HTTP acceptance tests with RUST_MIN_STACK unset and 3,333 affected-package tests. The committed test-only array correction passed clippy and the preflight rerun.

Independent mutations detected dropped read/lookup kinds, the CLI two-kind split, and preflight ordering, channel and live-edit errors. The published follow-up adds forum preview retention/suppression and a deleted-original preflight fixture; both surviving mutations now fail as intended. Independent review verified the fixes. All four acceptance tests pass; the full DB/relay run had two NIP-FI failures that passed in isolation. The actual standalone MCP workflow passed against this relay and clean local app 5b583b8c69596353bc37e9f3938eca1aabcd081e: 15 MCP edits, 10 direct publications and 60 member GET/HEAD checks across five isolated blob pairs. Both tested heads are now published. Relay hosted checks report 80 successful and 31 skipped, with none pending or failed; app hosted checks and human upload → edit → clear → edit → GET/HEAD confirmation remain pending. No human acceptance is claimed.

Rollout

The lookup, CLI preservation/clear and media reads use kinds 9/40002/40008/45001/45003. Deploy the relay before releasing the CLI and paired MCP producer. New clients abort without publishing against an unsupported relay. Old CLI edits emit empty imeta and now revoke diff/forum attachments that previously remained readable. Other channel-tagged kinds retain the historical plain-edit path. No additional schema change is needed beyond migration 0086.

Readiness remains blocked by mobile edits that omit imeta, the app UI fold that can restore older files, unaudited SDK/direct callers and unmeasured historical exposure. Run docs/sql/private-media-edit-preflight.sql for each community; producer updates do not repair signed historical edits. No enforce activation is authorized. off skips policy checks, shadow changes policy metrics while allowing policy failures, and enforce denies inaccessible references.

Observe buzz_media_publication_access_total{mode="shadow",reason="denied"}. Prefer rolling back the client release while retaining the additive lookup. A relay rollback makes new CLI/MCP edits fail closed; already-published imeta remains valid under the older reference rules. Concurrent edits still use (created_at,id) without compare-and-swap.

Generated with Codex

bradseiler and others added 4 commits November 6, 2026 18:10
Carry the latest live replacement metadata and provide explicit clearing. Order successive edits after their observed head and fail on incomplete history.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
Resolve live originals and the latest edit in a primary snapshot. Require a versioned response so older relays cannot silently provide incomplete attachment state.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
Recognize partition child indexes, box large CLI and ingest futures, and verify fresh reader authorization through HTTP. Include both journeys in the media acceptance recipe.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
@bradseiler
bradseiler marked this pull request as ready for review November 7, 2026 00:00
@bradseiler
bradseiler requested a review from a team as a code owner November 7, 2026 00:00
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: f3b127e3af5c14d2314faa2b63556c3f51ec6743...c630c4ebf0b20a9618f4844629eec1e666699cbe
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings identified in the authorized PR range.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not executed, as instructed.

Generated by Codex Security Review |
Requested by: @bradseiler |
Workflow run

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Approving. I checked the parts that carry the risk:

  • Read authorization on the new effective_edit lookup. It runs after relay-member admission and the existing /query gates. Its SQL rule (channel not deleted, and visibility='open' or an active channel_members row) matches what get_readable_named_only_channels grants a filter that names the channel. It then applies event_visible_to_reader to both the original and the edit, so a reader gets nothing here that the normal explicit-channel read wouldn't give them. Missing and inaccessible both return the same 404.
  • Edit selection. The latest-edit SQL doesn't filter by pubkey. That's fine because validate_edit_ownership only accepts 40003s from the effective author or the owning human, so every stored live edit already comes from an authorized editor. Carried files are still publication-checked per signer.
  • CLI. It refuses to publish unless it gets the exact v1 envelope back, so a new CLI against an old relay fails closed. It re-checks the returned original's id, kind and channel. Stamping max(now, head+1) with a 60s ceiling stays well inside the relay's 900s future bound.
  • SDK. Rejecting non-imeta tags in build_edit_with_media closes off injecting a target, channel or auth tag.

Nonblocking:

  • The PostgreSQL and E2E lanes were still running when I looked, and the description mentions two Postgres fixture fixes that haven't been pushed yet. Once they land, the Testing paragraph's in-progress status can come out.
  • buzz-relay now has a dev-dependency on buzz-cli just for the CLI end-to-end test. That's reasonable, but it does grow the relay's test build graph.

Share the attachment-governed kind set across the CLI, lookup and media reads. Preserve attachments through edits and keep explicit clear effective for diff and forum messages. Add isolated access journeys and a historical exposure preflight.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 7, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 7, 2026
Check preview retention and sticky suppression after forum edits, exclude deleted originals from historical exposure counts, and clarify legacy producer behavior and rollback requirements.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 7, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 7, 2026
@bradseiler
bradseiler enabled auto-merge (squash) November 8, 2026 16:17

@kazemek21 kazemek21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kyle reviewed this PR and the Nexus review-tracker notes and approves.

Posted by Codex (gpt-6.1-sol) on behalf of kylez

@bradseiler
bradseiler merged commit 8130cd9 into main Nov 8, 2026
111 checks passed
@bradseiler
bradseiler deleted the honor/media-edit-attachments branch November 8, 2026 18:55
morgmart added a commit that referenced this pull request Nov 9, 2026
…ived-solo-read

* origin/main:
  fix(relay): say "channel owner or admin" in the call_webhook save refusal (#9169)
  feat(mobile): consolidate Solo chat settings in one sheet (#9255)
  fix(cli): preserve attachments across successive edits (#9226)
  fix(mobile): swipe left to reply so swipe-back keeps rightward drags (#9127)
  mobile: long-press a message link for open, copy and share (#9135)
  feat(mobile): long-press a Solo chat to open its details sheet (#9163)
  fix(mobile): shimmer loading photos in the iOS carousel (#9167)
bostonaholic added a commit that referenced this pull request Nov 9, 2026
…ction-p

* origin/main: (111 commits)
  feat(mobile): tag the reacted-to message author on reactions (#9141)
  fix(mobile): steady New DM picker rows and animate picks (#9249)
  perf(mobile): keep remote images on disk and show small ones as thumbnails (#9158)
  fix(relay): deliver slow cross-node events late instead of closing their recipients (#9235)
  fix(mobile): read only shown events from filtered Activity rows (#9215)
  fix(mobile): show the channel name as the notification subtitle (#9173)
  fix(mobile): keep Home's header clean under sheets (#9152)
  fix(mobile): show already-loaded custom emoji in the iOS reactions sheet (#9150)
  mobile: add follow and remind actions to inbox row menu (#9142)
  fix(mobile): start no threads in Solo chats (#9123)
  mobile: persist user profiles so names and avatars render on launch (#9116)
  fix(mobile): keep a sent thread reply above the composer (#9026)
  [buzz] Recover database pool capacity after stalled connections (#9267)
  feat: send a User-Agent on relay WebSocket upgrades (#9246)
  Record why relay connections close and quiet close warnings (#9245)
  fix(relay): say "channel owner or admin" in the call_webhook save refusal (#9169)
  feat(mobile): consolidate Solo chat settings in one sheet (#9255)
  fix(cli): preserve attachments across successive edits (#9226)
  fix(mobile): swipe left to reply so swipe-back keeps rightward drags (#9127)
  mobile: long-press a message link for open, copy and share (#9135)
  ...

Signed-off-by: Matthew Boston <mboston@squareup.com>
bradseiler added a commit to block/buzz-app that referenced this pull request Nov 10, 2026
## Why

MCP text edits copy the original message's attachments. A later edit can
restore a removed file or discard files changed by an earlier edit.

## What

Retain the latest live attachment set, including an empty set, through
the relay's versioned effective-edit lookup. Both app-hosted and
standalone agents use their own access.

## How

Verify the signed original and replacement, including their target and
channel. Abort before publication on unsupported, failed or invalid
lookups. Reuse the bounded notes/canvas wait to date each edit after the
observed head.

## Risk

Deploy relay support from block/buzz#9226 first,
including compatibility for diff messages and forum posts/comments. This
client requires the exact `[9,40002,40008,45001,45003]` lookup filter;
relay and client heads must match. Older relays refuse edits safely. The
relay still authorizes every retained file for its signer; denial does
not retry with attachments removed. Concurrent writers retain relay
ordering without a compare-and-swap guarantee.

## Rollout

Upgrade each community relay before releasing this client. Every MCP
agent edit stops working on relays without the versioned lookup. Observe
`buzz_media_publication_access_total` denials and MCP edit errors during
rollout. Rolling back the client restores the original-attachment
resurrection bug.

## Testing

Real standalone MCP workflow passed at app
`5b583b8c69596353bc37e9f3938eca1aabcd081e` and relay
`c630c4ebf0b20a9618f4844629eec1e666699cbe`. All five supported kinds
retained replacement attachments and preserved an empty set after
removal. The run recorded 15 accepted MCP edits and 60 member GET/HEAD
checks with isolated blobs; unsupported kinds were denied. No browser
journeys were added.

The full local run at prior app head
`5b583b8c69596353bc37e9f3938eca1aabcd081e` passed 19,747 tests with 22
skipped, including all 177 broker tests. The comparable pre-fix run
passed 19,427 tests with 22 skipped. An earlier run at `eec0c8f1e` had
five broker failures (localhost connection timeout, presence timeout and
subsequent origin failures) and six aborts. Those failures did not
reproduce in the isolated run or either uninterrupted comparison; their
root cause remains unconfirmed. No assertions or timeouts were weakened.

Rebased onto main `bd344a52d18523f4939ee3cef1db43081ef4d89c` at
`b206249ecb4f151703f2e56458b2b6900b32c0df`. All three patches are
equivalent in range-diff, with no conflicts. Main's #3144 repairs the
two Activity navigation selectors that failed on the prior head. No
extra product or test changes were needed. The full
`focus-navigation.spec.mjs` file passed all 22 cases across Chromium and
WebKit at this head (37.9s locally). Normal pre-push types, related unit
tests and design checks passed. [Current-head
CI](https://github.com/block/buzz-app/actions/runs/42756328867) passed
on tested merge `0b6109462506e5a7922ebb3415fe7dc508bcc22f` (parents:
main `bd344a52d18523f4939ee3cef1db43081ef4d89c`, PR head
`b206249ecb4f151703f2e56458b2b6900b32c0df`). Independent code/rebase
review found no issues; final disposition after CI is pending. Prior
paired MCP workflow evidence remains historical; the effective-edit
patches are unchanged. Human acceptance remains pending; the existing
ready state is preserved.

## Bigger picture

This is the app producer counterpart to relay PR #9226. Release after
that relay contract deploys. Human acceptance remains required before
merge. Other app UI/mobile producers and historical media exposure
remain separate relay enforcement gates.

Generated with Codex

---------

Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>

This branch was previously deployed

1 inactive deployment
codex-review — c630c4eb Deployed Nov 7, 2026 by bradseiler via Run Codex Security Review #13767
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz messages edit silently deletes the message's attachments

3 participants