mail_count: grouped message and unread counts under the mail_search filters #111
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #106 (item 4). Decided at triage 2026-11-02: a separate mail_count tool, not a group_by parameter on mail_search.
Agent Brief
Category: enhancement
Summary: mail_count: message and unread counts grouped by sender, mailbox or triage class under the mail_search filters
Current behavior:
mail_mailboxes counts per mailbox, mail_people per sender and mail_triage per class, and none of them takes the mail_search filters. A question such as "unread this week, by sender" needs every matching row.
Desired behavior:
A new read-scope tool
mail_counttakesgroup_by(one ofsender,mailbox,triage) and the same filter parameters as mail_search (account, mailbox, sender, since, before, unread, has_attachment, triage, attachment_flag, flag colour, and the full-text query), with no ranking parameters. It returns rowskey | messages | unread, largest first, then a footergroups=N shown=M more=K.limitis 1 to 100, default 20, and acursorpages the groups. A collapsed message counts once (#59). The mirror has no labels apart from mailboxes, and on JMAP a Fastmail label is a mailbox, somailboxcovers labels. The tool description says that keys are untrusted data.Key interfaces:
SearchParams: reused for the filters; a grouped query in the store besidesearch, sharing the collapse and filter CTEs.mail_countis in the read scope and in the test that lists the read tools.Acceptance criteria:
mail_count(group_by="sender", unread=true, since=<7 days ago>)on the test store returns the senders with their unread counts, largest first.groups=150 shown=20 more=130, and the cursor reaches all 150 without repeats.make checkpasses.Out of scope:
group_byparameter on mail_search.Blocked by
sinceandbeforeinSearchParams)rolefilter and case-insensitive mailbox names)Filed under: operator word "accept" sha256:c125d0397b60
⏸ SVD architect gate: dev/mail-mind-mcp#111 mail-count-grouped-message-and-unread-counts-under-the-mail
Status: CLEAN after 0 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
standard· dispatch effortmediumRun:
20261102T122604Z-d3eea1edHeld because: CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make checkon base0068371and then on the PR branch; it must exit 0, or show a failure set identical to base. [verification]Change: Store: add GroupBy = Literal['sender','mailbox','triage'] and Store.count_groups(params, group_by) -> (page of (key, messages, unread), total groups) directly after triage_counts (store.py:1805-1817), mirroring its shown-row grouping. Reuse _filters/_collapse_ctes unchanged. For a query, follow search_page's _fts_candidates loop with the OperationalError fallback (store.py:1741-1800). Sender/triage group the shown rows (each message counts once, #59). Mailbox groups every filter-passing copy over json_each(COALESCE(mailboxes, json_array(mailbox))), with key account/mailbox and the mailbox filter restricting the groups. Order messages DESC, key ASC; take the total plus an OFFSET page as in Store.people (store.py:2005-2012). The SQL was prototyped in the Half-A sandbox against a temp store and gave the right results for two-account copies, JMAP labels, the FTS fallback and 151-sender paging. Server: a new READ_ONLY, SCOPE_READ tool mail_count after mail_search. Its filter params are copied verbatim from mail_search (server.py:320-354); it uses the offset cursor via _parse_cursor/_page as in mail_people, rows
key | messages | unreadescaped with _cell, and the footernext_cursor=X groups=N shown=M more=Kin the mail_thread shape. Factor the unknown-mailbox warning (server.py:397-404) into a helper shared with mail_search, keeping its output byte-identical. Add mail_count to the exact read-tool lists in tests/test_server.py and tests/test_evidence.py, plus a README tool-table row.Files:
src/mail_mind_mcp/store.py·src/mail_mind_mcp/server.py·tests/test_mail_count.py·tests/test_server.py·tests/test_evidence.py·README.mdDecision: accept the 4 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-count-grouped-message-and-unread-counts-under-the-mail.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-count-grouped-message-and-unread-counts-under-the-mail.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#111 mail-count-grouped-message-and-unread-counts-under-the-mail completed integration verify.
93709193c89370919(absent, no CI in repo). Local: 964 passed, 8 skipped, 0 failed; ruff and mypy clean.9370919has no commit statuses. The repo has no CI; CI files (.woodpecker/*) are added by the architect. — reported as absent, not blocking (gh#633)codex-svd ship --run-id 20261102T123750Z-b5813783 --confirm-merge)