Skip to content

DIVE-3809: serialise the pending drain across processes, and stop calling collection delivery - #47

Merged
lodar merged 2 commits into
mainfrom
dive-3809-drain-lock
Aug 30, 2026
Merged

DIVE-3809: serialise the pending drain across processes, and stop calling collection delivery#47
lodar merged 2 commits into
mainfrom
dive-3809-drain-lock

Conversation

@5dive-bot

Copy link
Copy Markdown
Collaborator

Delivers DIVE-3809.

Opened by 5dive push --open-pr (DIVE-2605): the branch and this pull request went out on the same root-side rail, as 5dive-bot. The authoring agent holds no GitHub credential.

lodar and others added 2 commits August 29, 2026 17:37
…ling collection delivery

The `draining`/`rerun` pair is module state — it serialises the three callers
inside one process and is blind to a second one. Two plugin processes for the
same agent each fetch the SAME pending rows and push every message twice,
because the ack lands only after the notifications are sent.

DIVE-3806 REFUTED this as the cause of the loss it observed (lifecycle.log
showed exactly one live process across that window). It is still a real race
and it is scope 3 of DIVE-3809.

- an O_EXCL lock file at $STATE_DIR/pending-drain.lock, TIME-BOUNDED at 2min so
  a drain killed mid-flight cannot wedge the collect path permanently — which
  would turn an intermittent loss into a total one.
- a filesystem that cannot support the lock degrades to today's per-process
  guard rather than blocking the collect.
- log wording: the ack attests COLLECTION, never display. The SDK's send() has
  no reject path and a client with nothing subscribed drops the notification
  silently, so 'healed N undelivered' was a claim this code cannot make.

test/dive3809-drain-lock.test.ts runs TWO real server.ts processes against one
stub control plane and one shared state dir; dashboard-collect-now.test.ts runs
a single process and stays green with the lock deleted, so it could not grade
this. Graded by mutation: with acquireDrainLock stubbed to `return true`, both
arms go red.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts:
#	plugins/dashboard/server.ts
@lodar
lodar merged commit dc86868 into main Aug 30, 2026
2 checks passed
@lodar
lodar deleted the dive-3809-drain-lock branch August 30, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants