Skip to content

mail watch --off leaves staged deliveries queued, and they can duplicate #304

Description

@scgopi

Found by accident while cleaning up after a test loop, on the shipped 0.1.64-beta2 (build 252).

What happens

A loop watching the Mailroom while it is busy has matching posts staged to its memory rather than typed in live — that is the documented design, the same path a --follow-up message takes. But:

  1. graphcode mail watch --off removes the subscription and does not cancel or drain what is already staged.
  2. Staged deliveries keep arriving for many minutes afterwards, in strict post order.
  3. They arrive even though the reader's cursor is already past themlastMailroomRead = 353 while posts #276, #277, #280, #281 were still being delivered.
  4. At least one was delivered twice (#280 arrived two times).

Evidence

The watching node's persisted state after --off shows no watch at all:

PerfTriage mailroom-related keys: ['lastMailroomRead']
  lastMailroomRead = 353

So the subscription is genuinely gone from the graph, and the deliveries are coming from a queue that --off does not reach.

Sequence observed: filler 1 of 70, 2 of 70, 3, 4, 5, 5 (duplicate), 6 … continuing after the watch was turned off twice, re-scoped to a different topic in between, and the inbox marked read to #353.

Why it matters

  • There is no way to stop it. --off is the only control, and it does not apply to in-flight deliveries. A loop that accidentally subscribes to a busy topic will be fed that backlog into its context regardless of what its operator does — and for an agent session, that is context budget spent on posts it has already read.
  • The duplicate is the more serious half. Delivery is supposed to be at-most-once into a session; a post arriving twice means a watcher cannot treat delivery as a signal to act exactly once.
  • Redundant with the cursor: delivering posts below lastMailroomRead contradicts what the cursor is for.

Suggested behaviour

  • --off should drop staged-but-undelivered posts for that watcher, not just the subscription.
  • A staged post whose id is at or below the reader's lastMailroomRead should be dropped rather than delivered.
  • Delivery should be idempotent per post id per watcher.

Related

This is the delivery half of the Mailroom, which #293 did not touch — that PR rewrote how mail is read. Every review in the #288 series concentrated on the read path, so delivery has had no scrutiny. MailWatcher was created to test exactly this and found the ordering side; this is the teardown side.

Related: #288, #293

🤖 Generated with Claude Code

https://claude.ai/code/session_01BP43ags4cn8fq2ZZdv85J9

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions