{"id":"XE-1487","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":227,"title":"Worker crash mid-flush_outbox re-sends already-sent replies","area":"dao-harness","claimed_tier":"minor","assessed_tier":"minor","verdict":"likely-valid","duplicate_of":null,"tracked":true,"internal_ref":"dao@55ee9d4","internal_url":"","status":"awarded","closed_reason":null,"github_state":"","disclosed_at":"2026-11-08T21:43:28.963575+00:00","award_xe":100000000,"award_approved":true,"paid_ref":"","created_at":"2026-11-08T10:49:43.939733+00:00","updated_at":"2026-11-08T21:43:33.086614+00:00","source_created_at":null,"told_at":"2026-11-08T20:18:42.314155+00:00","status_changed_at":"2026-11-08T21:43:33.093815+00:00","url":"https://bounty.xe.network/XE-1487","body":"Summary\r\nA worker crash or restart in the middle of flush_outbox re-sends replies that already went out. flush_outbox sends up to 10 queued rows per tick but never commits inside the loop — it only marks rows \"sent\" in memory, and the single commit happens in job_outbox after flush returns. If the process dies or the task is cancelled mid-flush, the session rolls back, every row already sent stays \"queued\", and the next tick re-sends them with fresh envelope ids, so the recipient gets the same reply twice. The codebase's own exactly-once discipline is not applied to the outbox, even though the inbox side is idempotent.\r\n\r\nLocation\r\nRepository: xeprotocol/dao, commit bbbba82.\r\n- dao/dao/services/inbox.py:137 flush_outbox(): selects OutboxMessage rows with status \"queued\", limit 10; per row it builds a fresh envelope (new_envelope per send), calls chat_send, then sets o.status = \"sent\" and o.sent_at in memory. There is no db.commit() anywhere inside the loop or in flush_outbox.\r\n- dao/dao/worker.py:78 job_outbox(): calls flush_outbox, then mark_run, then the single await db.commit() — after flush returns.\r\n- Contrast: the fees path follows an exactly-once discipline (XE-0486/XE-0488: commit per row, settle marks settling+nonce before the send, crash reconciled from the chain). The outbox does not. The inbox side is idempotent (dedups by id); the outbox side is not.\r\n\r\nReproduction (local only, no live DAO, no real chat)\r\nI executed the real DAO code against a real Postgres 16 database (fake only at the chat_send boundary). Test 1: a synthetic CancelledError on the 2nd send — the error propagated, the session rolled back, all rows were still \"queued\" although sends 1 and 2 had gone out; a re-flush re-sent rows 1 and 2 with different envelope ids. Test 2 (control, uninterrupted): each row was sent exactly once. Test 3: a real asyncio task.cancel() after the 1st send — the actual SIGTERM path, with 0.3s/send latency so the cancel lands mid-flush — the task was cancelled, row 1 was still \"queued\" after its send went out, and a re-flush sent row 1 again with a different envelope id. All PoC scripts were throwaway and deleted, the test database was dropped, and no repository files were modified.\r\n\r\nImpact\r\nDuplicate chat replies, up to 10 per interrupted flush; AUTO_ACKs duplicate too. No funds, no state corruption, no privilege issue. I am grading this Low, while being open that triage may grade it Info: the effect is duplicate replies, and it needs a crash or restart landing inside the flush window — though that is a routine event on deploys and restarts.\r\n\r\nWhy this is not a duplicate\r\nI checked the public board with keyword searches for outbox, duplicate, redeliver, flush, resend, twice, and double-send and found no outbox ticket — all \"duplicate\" hits are unrelated (XE-0992, XE-1081, XE-0993, XE-1297, XE-1086). GitHub issues in xeprotocol/dao for \"outbox\" and \"duplicate reply\" return zero as well.\r\n\r\nSuggested fix\r\nCommit per sent row inside flush_outbox (mark sent + commit after each successful chat_send), mirroring the fees.py exactly-once discipline; or mark sent and commit per row before moving to the next.","patch_refs":[{"id":432,"repo":"xeprotocol/dao","kind":"commit","ref":"55ee9d4","title":"","url":"https://github.com/xeprotocol/dao/commit/55ee9d4","note":"","state":"","author":"","added_by":"token:5","created_at":"2026-11-08T21:15:43.516226+00:00"}],"thread":[{"id":1009,"source":"desk","source_ref":"reply:554","author":"Joseph Denne","team":true,"body":"Thanks for the report and for keeping the reproduction local. We have confirmed the behaviour you describe in the DAO worker and it is being handled. We will update this ticket when the fix has shipped.","created_at":"2026-11-08T20:17:41.885067+00:00"}]}