Skip to content

pm-stack: decision-events Worker loses Durable Object fan-out when ingest fails after the D1 commit (PR #9341 Codex P1) #9612

Closed

Description

@dezren39

Finding (from PR review)

PR #9341 (merged, feat(pm-stack): decision-set event pipeline — Turso sync + Cloudflare Worker/D1/DO (#9335)) adds the decision-events Worker. Codex's P1 finding: pending Durable Object fan-out is lost permanently when ingest fails after the D1 batch commits. The Worker fans out only events whose D1 INSERT OR IGNORE reported changes; if the Durable Object ingest then fails (non-OK response), the handler still returns HTTP 200, the sync client acknowledges the events, and on any retry the D1 inserts report zero changes — so the events are never fanned out to subscribers or the per-set coordination state.

"If the Durable Object ingest fails after the D1 batch commits, these events can never reach the object on retry: their next inserts report zero changes, so insertedEvents excludes them permanently. A non-OK ingest response is also converted into an HTTP 200 webhook response, causing the sync client to acknowledge the events despite the failed fan-out. Persist pending fan-out separately and retry it, with event-ID deduplication at the Durable Object, so transient failures do not permanently lose subscriber notifications and coordination state."

No-response evidence

Still-live evidence (verified 2026-11-14 on current main)

  • pm-stack/decision-events-worker/src/index.ts:160-186: the D1 batch runs first; insertedEvents is built only from rows with meta.changes > 0 (lines 161-167); the fan-out loop (line 170) iterates only insertedEvents; a non-OK ingest is recorded as { error: ... } in the fanout map (line 177) and the handler still returns Response.json({...}) with HTTP 200 (lines 180-186). A retry therefore excludes the already-stored events from fan-out forever.
  • The Durable Object /ingest handler (lines 91-96) increments state.fannedOut and overwrites last-event fields for every event it receives, with no event-ID deduplication — so a retry mechanism also needs the dedup the reviewer asked for.

Acceptance criteria

  • A failed Durable Object ingest no longer loses fan-out: pending fan-out is persisted/retried (or the webhook returns a non-200 the sync client will not acknowledge), and the Durable Object deduplicates by event ID.
  • A regression test covers: D1 commit succeeds, DO ingest fails, retry delivers the events exactly once.
  • Or: a documented decision on this issue that this loss mode is accepted, with the reasoning recorded.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/highImportant and time-sensitive
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 14, 2026
  2. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-any-a — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-any-a posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  4. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 14, 2026
  5. 98 remaining items

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 14, 2026
  7. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    worker: repo-worker-code
    lane: code-h
    task_id: 16157
    state: claimed
    note: Picked up small_fix for #9612. Creating worktree and inspecting pm-stack/decision-events-worker.

  8. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    worker: repo-worker-code
    lane: code-h
    task_id: 16157
    state: done
    note: Opened PR #9624 (#9624) fixing DO fan-out loss on ingest failure and adding eventId deduplication. bun test: 8 pass, 0 fail.

  9. added a commit that references this issue on Nov 17, 2026
  10. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    state: already_done (re-triage)
    lane: any-b, worker: repo-worker-code, task 19057

    Re-triage of #9612 (2026-11-17): already fixed and closed. Lane code-h verified the defect live on origin/main on 2026-11-14 (tasks 16156/16157) and landed PR #9624 — DO fan-out no longer lost when /ingest fails after the D1 commit, plus eventId deduplication in the Durable Object (bun test: 8 pass, 0 fail, per the closing note). PR merge state re-verified fresh this shift and recorded in the triage result. No further work.

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

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/highImportant and time-sensitivesource/pr-comment-reviewFiled by the pr-comment-review jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions