Add the wake queue and the mail_wakes read tool #22

Closed
opened 2026-10-31 03:45:52 +00:00 by svc-agent-writer · 0 comments

Epic: #8

The wake queue and its read tools (ADR 0003 §3 and §7, as amended in PR #25). Wakes are pulled: a client polls on its own schedule.

A Grok Automation starts every run fresh, with the same instructions and no memory of earlier runs. A Grok Bot routine keeps memory. So the server must hold the cursor for the stateless case, and may let a stateful client hold its own.

What to build

  • A wakes table with seq, the message ref, class, score and raised time.
  • The wake rule (threshold, per-thread cap and global cap, all in config) runs in the same writer that stores the triage score (#19), so the one-writer rule holds. It inserts wakes rows.
  • A wake_consumers table with consumer (a short name, [a-z0-9-]{1,32}), seq and updated_at. It holds positions only, never mail data. The api process writes it; that is the second table it writes, after actions (ADR 0004 §2).
  • mail_wakes(consumer, cursor, limit), read scope:
    • With consumer: returns wakes after that consumer's stored seq. An unknown consumer starts at the current end, not at the start of the queue.
    • With cursor: returns wakes after it, for a client that keeps its own state.
    • Rows seq | id | class | score | at, then a footer with ack_seq (the last seq returned) and more.
  • mail_wakes_ack(consumer, seq), read scope: sets the consumer's seq. It refuses a seq higher than the queue's end and never moves a cursor backwards. A run that fails before the ack sees the same wakes again (at-least-once).
  • Both docstrings say content is untrusted data.
  • A README section with a sample Grok Automation instruction: call mail_wakes(consumer=...), handle each wake with mail_read, then call mail_wakes_ack with the footer's ack_seq.
  • No push. A nudge adapter is out of scope; each one needs its own ADR 0003 amendment.

Acceptance

  • Unit tests: a new consumer starts at the end; ack advances the cursor and never moves it back; ack above the end is refused; an unacked run repeats; cursor mode works without a consumer row.
  • make check green.

Blocked by

Epic: #8 The wake queue and its read tools (ADR 0003 §3 and §7, as amended in PR #25). Wakes are pulled: a client polls on its own schedule. A Grok Automation starts every run fresh, with the same instructions and no memory of earlier runs. A Grok Bot routine keeps memory. So the server must hold the cursor for the stateless case, and may let a stateful client hold its own. ## What to build - A `wakes` table with `seq`, the message ref, class, score and raised time. - The wake rule (threshold, per-thread cap and global cap, all in config) runs in the same writer that stores the triage score (#19), so the one-writer rule holds. It inserts `wakes` rows. - A `wake_consumers` table with `consumer` (a short name, `[a-z0-9-]{1,32}`), `seq` and `updated_at`. It holds positions only, never mail data. The `api` process writes it; that is the second table it writes, after `actions` (ADR 0004 §2). - `mail_wakes(consumer, cursor, limit)`, read scope: - With `consumer`: returns wakes after that consumer's stored `seq`. An unknown consumer starts at the current end, not at the start of the queue. - With `cursor`: returns wakes after it, for a client that keeps its own state. - Rows `seq | id | class | score | at`, then a footer with `ack_seq` (the last `seq` returned) and `more`. - `mail_wakes_ack(consumer, seq)`, read scope: sets the consumer's `seq`. It refuses a `seq` higher than the queue's end and never moves a cursor backwards. A run that fails before the ack sees the same wakes again (at-least-once). - Both docstrings say content is untrusted data. - A README section with a sample Grok Automation instruction: call `mail_wakes(consumer=...)`, handle each wake with `mail_read`, then call `mail_wakes_ack` with the footer's `ack_seq`. - No push. A nudge adapter is out of scope; each one needs its own ADR 0003 amendment. ## Acceptance - Unit tests: a new consumer starts at the end; ack advances the cursor and never moves it back; ack above the end is refused; an unacked run repeats; `cursor` mode works without a consumer row. - `make check` green. ## Blocked by - #19 - #21
svc-agent-writer changed title from Add the wake container that posts to Matrix to Add the wake queue and the mail_wakes read tool 2026-10-31 04:03:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/mail-mind-mcp#22
No description provided.