Skip to content

Follow-ups from the #4157 review: bytes kept for a mail or chat holder are orphaned when it ends, and a chat attachment can outlive a retention destruction #4208

Open

Description

@yannickmonney

These are follow-ups from agent #2's independent post-merge review of #4157 (record 5974610832). #4157 merged at 8a88ffd10 (squash of 089fe9426) after root's acceptance (5973250800). The reviewer re-verified both MEDIUMs in the merged source, and its real-Postgres lane run (with moto S3) at the head passed the #4111 checks. The fleet manager (TALE-357) filed this so the follow-ups are tracked in one place.

MEDIUM 1: bytes kept for a mail or chat holder are never reconsidered when that holder ends, so they stay in the store forever

  • What happens: deleteFile deletes the row, sees the ref held, and returns (domains/files/service.ts:690-697). Nothing records that these bytes now have no row.
  • How a holder ends without a release:
    • a mail is sent, undone or discarded (send.ts:1177, :835, :1061);
    • an API source is removed (api-sync.ts:464);
    • a conversation is deleted: its release lists only conversation-bound file rows, not metadata.attachments (message-corpus.ts:62-128);
    • a chat thread is purged (retention/service.ts:1088,1171).
  • Nothing reclaims them later: the intent was consumed at registration, the sweep drops consumed intents, and there is no bucket reconcile. Tasks already have this closure (tasks/retire.ts:177-200 queues a release when a task drops a ref); mail and chat don't.
  • Scenario: reply with file F, delete F during the undo window (the bytes correctly stay), and the reply sends. F's bytes now have no row, no holder and no intent, permanently. The same happens to a chat-attached file deleted before its thread is purged. An explicit delete by the user then never removes the bytes, which matters for privacy and retention.
  • Why the tests miss it: the lane checks kept only while the holder lives, and the sent control turns sent before the delete.
  • Fix direction (from the review): when a holder ends, after commit, run deleteUnheldOrgBlobRefs on the refs it listed. Don't use the release seam, which treats a trashed, still-restorable row as dead. Decide whether undo, which hands the refs back to the composer, is excluded.

MEDIUM 2 (privacy and compliance; needs an owner decision): any reader can keep a file's bytes alive past its owner's delete, a document's purge or a retention destruction

  • Why: the chat door admits any readable, non-trashed file row, including document-bound ones (domains/chat/shim.ts:540-575). The chat arm holds any user message's ref, with no ownership or thread-status condition (files/blob-holders.ts:99-112). The mail and task doors, by contrast, require the sender's own upload.
  • Scenario:
    1. A reader of document D posts a chat turn with D's ref attached.
    2. Retention destroys D. The release seam (liveness.ts:121, which now includes the listed holders) keeps the bytes while the rows are deleted, and a destruction is recorded (retention/service.ts:1047-1061).
    3. The reader's turns keep replaying the image.
    4. Once that chat is purged, the bytes are orphaned (MEDIUM 1).
  • Before fix(platform): keep bytes a pending mail or a chat message lists #4157, the purge deleted those bytes.
  • Fix options: have the chat arm hold only the author's own or thread-bound uploads, or let destruction lanes override the listed holders. Choosing between them is a retention-policy decision for root.

LOW

  • sweepUploadIntents statement 2 has no LIMIT. On every upload it evaluates intentBlobHeld, which now includes the chat scan, for every expired backlog row (upload-intents.ts:317-323, files/routes.ts:150). With a store that refuses deletes, the backlog grows, and so does the cost of every mint. The docstring "pay this once per ref" (blob-holders.ts:87-88) is inaccurate.

INFO

  • Email path: the in-transaction proof runs under READ COMMITTED (send.ts:212). Two sends by one user that name the same files in opposite order can deadlock on intent rows, because firstForeignUpload iterates in client order. The result is a 500 with no retry; sorting the refs avoids it.
  • Failed mail: a failed mail holds its bytes until it is retried or discarded. This is by design.

Acceptance

  • MEDIUM 1: when a mail or chat holder ends, bytes left with no row, holder or intent are reclaimed. Test this with a real-Postgres lane: delete during the undo window, then send, purge, delete the conversation and remove the API source.
  • MEDIUM 2: carry out root's retention decision, with a lane that shows a destruction or owner delete is honoured, or the chosen exception is documented.
  • The LOW and INFO items: each is fixed or recorded as a decision.
  • An independent review by a distinct agent.

Related: #4157, #4111, #4104, #4110.

Activity

  1. added
    agent-ready
    on Nov 2, 2026
  2. tale-review-bot commented on Nov 2, 2026

    @tale-review-bot
    Collaborator

    Waits for a person: a maintainer of tale-project/tale confirms that the agents are to work what #4208 still asks, its MEDIUM 1 and MEDIUM 2.

    • What happened.

    • Why it waits.

    • The one act.

    • Decided now, so nothing else waits.

      • Kind, line and priority. Kind bug. Line: stable, because it corrects what main ships; 8e6b739a2 went to train as well. Priority p1. The kept bytes stay reachable only to people who could already read the file, so nothing new is exposed. But a deletion or a recorded destruction must remove them.
      • MEDIUM 2, the holding rule. The issue left this to an owner. It is a retention and privacy trade-off, so the Lead decides it.
        • The chat arm holds bytes only when the message's author uploaded them, or when they are bound to that chat's own thread.
        • Any other file attached in a chat turn does not keep its bytes alive: a document's file, or another person's upload. Its owner's delete, the document's purge and a retention destruction remove the bytes, and the turn shows the attachment as unavailable.
        • This is the rule the other doors already follow. The mail and API doors refuse another person's upload through firstForeignUpload, for example at services/platform/backend/domains/conversations/api-sync.ts:420.
        • Evidence: on main at f8eb4613f7c525a52d55d21548d4a4cda44a9bfe, listedBlobRefHeld in services/platform/backend/domains/files/blob-holders.ts holds the attachment of any role = 'user' message, with no condition on who uploaded it.
        • Weighed and rejected: letting the destruction lanes override the listed holders. It honours a retention destruction but not an owner's plain delete, and it adds an override to every destruction lane.
      • MEDIUM 1. Follow the issue's direction: when a holder ends, reclaim the refs it listed, after commit. Whether undo is excluded, and how the lane is built, are the Coder's to decide.
      • What done means.
        • A real-Postgres lane shows MEDIUM 1's scenarios reclaimed: a delete during the undo window followed by a send, a chat purge, a conversation delete and an API source removal.
        • A lane shows that a reader's chat turn no longer holds a file that its owner deleted, or that was purged or destroyed.
        • spec.md states the holding rule.
        • The squash message ends with Closes #4208, since 8e6b739a2 covers the LOW and INFO items.
    • What happens after. The Lead's next run moves TALE-427 to To do with all of the above.

    • Triage keeps TALE-427 in Backlog until a maintainer has done the act above.

  3. yannickmonney commented on Nov 3, 2026

    @yannickmonney
    ContributorAuthor

    The LOW and INFO items from #4238 and #4270 are on the stable train as "fix(platform): bound upload-intent sweeps and order ownership locks" (24286d63c; it reaches main with the next train pull request): the bounded sweepUploadIntents backlog and the sorted refs in firstForeignUpload, with two real-Postgres checks in the reject-blob lane that fail without the fix.

    Still open here: the MEDIUM items, that is bytes kept for a mail or chat holder are never reclaimed, and any reader can keep bytes alive past an owner's delete. Both drafts are closed and their branches deleted; the heads stay at refs/pull/4238/head (372353a61) and refs/pull/4270/head (d24091c79). The second item needs a retention-policy decision before anyone builds it, and the last native proof of the first was 53 of 58 cases with five stale-fixture failures (diagnosed 2026-10-05, never repaired).

  4. tale-review-bot commented on Nov 3, 2026

    @tale-review-bot
    Collaborator

    Waits for a person: a maintainer of tale-project/tale confirms that the agents are to work MEDIUM 1 and MEDIUM 2 of #4208, or says that a maintainer will do them.

    • What changed. yannickmonney commented on Follow-ups from the #4157 review: bytes kept for a mail or chat holder are orphaned when it ends, and a chat attachment can outlive a retention destruction #4208 at 09:19:54 UTC today (comment). The comment says where the issue stands, but not who works its two MEDIUM items, so the act below is still open. Its facts, checked:

      • The LOW and INFO items are on train as 24286d63c38a72cefb4c3420043bf68ca218005f, which replaces the 8e6b739a2 named in the Lead's last comment. train was 4 commits ahead of it, and 0 behind, at 10:12 UTC (GitHub's compare API). It reaches main with the next train pull request.
      • The drafts are closed, and their heads stay at refs/pull/4238/head (372353a61, "persist holder retirement and chat custody") and refs/pull/4270/head (d24091c79, "retire unheld chat and mail blobs").
      • MEDIUM 1's last native proof was 53 of 58 cases. The five failures are stale fixtures, diagnosed on 2026-10-05 and never repaired.
    • The retention rule for MEDIUM 2 is decided. The comment says that this item needs a retention-policy decision before anyone builds it. The Lead made that decision on 2026-11-02 (comment):

      • The chat arm keeps bytes alive only when the message's author uploaded them, or when they are bound to that chat's own thread.
      • No other file attached in a chat turn keeps its bytes alive. Its owner's delete, the document's purge and a retention destruction remove them, and the turn shows the attachment as unavailable.
      • A maintainer who wants another rule says so here, and the Lead's next run follows that answer.
    • The one act, unchanged.

    • What happens after. The Lead's next run moves TALE-427 to To do: kind bug, Line: stable, priority p1, done as the Lead's last comment says. The two draft heads and the five stale fixtures are the Coder's starting points. The squash message ends with Closes #4208.

    • Triage keeps TALE-427 in Backlog until a maintainer has done the act above.

  5. yannickmonney commented on Nov 14, 2026

    @yannickmonney
    ContributorAuthor

    Decision

    Rule. A chat message does not keep a file's content alive. Content stays only while one of these still uses it:

    • a file row, including a trashed, restorable one;
    • a document, as its current file or a kept version;
    • a task;
    • a mail that is still pending (queued or failed).

    An owner's delete, a document or trash purge, and every retention destruction remove the content, even when an earlier chat turn lists it. The turn then shows the attachment as removed, and the assistant is told the file is unavailable. When a mail holder ends, a durable job reclaims the content it listed, judged by the same rule plus an explicit open-upload check. A failure fails the job, so it is retried.

    Answers.

    • Do the agents work MEDIUM 1 and MEDIUM 2? Yes, as the units below. Base is main, through the stable train.
    • MEDIUM 2. The chat arm is removed from listedBlobRefHeld. This replaces both options in the issue.
    • MEDIUM 1. Each mail holder's end queues a files.reclaim_unheld job in the same transaction. The ends are a send or delivery, an undo, a discard, an API source removal, and a conversation delete, which must also collect the refs in metadata.attachments. The job judges with blobRefHeld plus an explicit open-intent check, never the release seam. It deletes through a strict helper, because the existing deleteUnheldOrgBlobRefs swallows check and store failures. Undo is included.
    • Content that is already orphaned is reclaimed once by an idempotent reconcile, dry-run first, over refs that chat and ended mail rows still list. Content whose listing rows are already deleted cannot be found that way. That limit is documented.
    • LOW and INFO are fixed on train in 24286d6. A failed mail keeps its content until it is retried or discarded, by design.

    Rationale. The chat door admits only refs with a live file row. So the chat arm only matters after that row is deleted on purpose, and each time it made the deletion or the recorded destruction false. The narrower rule still fails the most common case: user temp-file retention destroys exactly the files people upload in chat. Replay already handles a missing image, so dropping the arm costs only a visible placeholder. The reclaim needs a strict helper and an explicit intent check. deleteUnheldOrgBlobRefs never reports a failure, and blobRefHeld does not look at upload intents.

    Units.

    1. fix(platform): a chat message no longer keeps deleted or destroyed file content alive. Remove the chat arm and update FILE-R9 plus a new FILE rule. A real-Postgres lane shows the content gone after an owner's delete, a document purge and a temp-file destruction, while queued and failed mail keep theirs. (M)
    2. feat(platform): show a removed chat attachment as removed. An accessible placeholder, the string in every locale, and a manual-test box. (S, after 1)
    3. fix(platform): reclaim the file content a mail holder listed when it ends. The durable job and the strict helper. The lane covers delete in the undo window then send, then undo, then discard; an API source removal; and a conversation delete. Controls: a trashed row, a document, a task, an open intent, and a store failure that is retried. Repair the five stale fixtures. (M, after 1)
    4. fix(platform): reclaim content left orphaned by the former chat and mail holders. The one-off reconcile, dry-run first; a second run deletes nothing. Its squash message ends with Closes #4208. (S, after 1 and 3)

    Cross-issue amendments (decisions taken together with #5303, #5298, #5303):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions