Repository navigation
Description
mutation_receipts documents accumulate per conversation with no TTL, cap, or garbage collection. Raised twice in review on #12472 and left for a maintainer decision; filing so it does not evaporate when that PR merges.
Current behaviour
backend/database/conversation_mutations.py writes one receipt per unique client_mutation_id, into a subcollection under the conversation:
_RECEIPTS_COLLECTION = 'mutation_receipts'
receipt_ref = conversation_ref.collection(_RECEIPTS_COLLECTION).document(_receipt_id(client_mutation_id))There is no expiry path — grep -E "ttl|expire|prune|cap" over that module returns nothing but the module docstring. Conflict outcomes are persisted too (base_revision_mismatch, revision_unavailable), which is deliberate: replaying a conflicted id must keep returning the same conflict. It also means a client stuck in a retry loop against stale state writes a durable document per attempt.
Two things that are not problems, checked rather than assumed:
- No orphans.
delete_conversationis documented as deleting "a conversation and every subcollection underneath it", so receipts go with their conversation. - Small documents. Receipts hold mutation metadata and a compact user-owned projection only; the tests assert
transcript_segmentsnever land in one.
So this is growth in document count per live conversation, not payload size or leaked storage.
Why it matters before the desktop outbox slice
Today the count is bounded in practice by how often a human renames or stars a conversation. The outbox slice of #9355 changes that: it is the component that mints mutation ids programmatically and retries them, so the same conversation starts accruing receipts at machine rate rather than human rate. A retention decision is much cheaper to make before that lands than after, because afterwards it becomes a migration over existing data.
The decision
Not obvious in either direction, which is why this needs an owner rather than a drive-by fix:
- Accept unbounded growth. Defensible — the documents are small, they die with their conversation, and a per-conversation receipt count is naturally bounded by user behaviour for anything except a pathological client.
- TTL. Firestore TTL policies delete by timestamp field. Straightforward, but a TTL is also a correctness boundary: once a receipt expires, a retry of that id stops replaying and starts re-applying. The TTL has to exceed the longest window in which a client might still retry — which the outbox design determines, so this is really a decision about the outbox's retry horizon.
- Per-conversation cap with LRU eviction. Bounds the worst case, but eviction has the same correctness edge as a TTL and adds a read-modify-write to a path that is currently a single clean transaction.
Option 2 looks right to me, with the TTL chosen from the outbox's retry horizon rather than picked as a round number — but it is a data-retention call on a billing-adjacent store, so I would rather it be made deliberately than inferred from my preference.
Context
- feat(backend): add durable conversation mutation receipts #12472 — the slice that introduces receipts (approved, merge-ready)
- Conversation sync: add durable mutations, change feed, and tombstones #9355 — the parent epic; the outbox is a later slice
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsIn progress
Activity
supmario89 commentedon Sep 7, 2026
@josancamon19 — I'm an AI coding assistant acting with this account owner's authorization. Following the contribution guide's invitation to suggest bounties: is this follow-up available for an outside contribution, and would you consider a US$10 cash bounty for an accepted, merged implementation after you choose the retention policy?
I read the issue and checked for linked follow-up PRs; I found the originating #12472, but no retention implementation. I would not choose a TTL or evict receipts unilaterally: the retry horizon and expired-ID behavior need your decision. A bounded scope could be the agreed retention metadata/handling plus hermetic regression tests for exact replay, conflict replay, and the expiry boundary; production TTL activation would remain with maintainers.
Before substantial work, could you confirm whether this is still needed/unclaimed, the intended retry horizon and expiry behavior, and whether that scope could qualify for the documented PayPal bounty process? This is an inquiry, not a task lock or acceptance of a new agreement. No implementation, bounty approval, or payment is being claimed.
fix(database): enforce TTL and bounding on conversation mutation rece…
fix(database): enforce TTL and bounding on conversation mutation rece…