mail_status(quick=true) returns sync health without the table counts #110

Closed
opened 2026-11-01 20:54:34 +00:00 by svc-agent-writer · 2 comments

This was generated by AI during triage.

Part of #106 (item 1). Decided at triage 2026-11-02: a quick flag, not a counts table.

Agent Brief

Category: enhancement
Summary: mail_status(quick=true) returns sync health without the table counts

Current behavior:
Every mail_status call counts messages per account, attachment text rows, the attachment backlog through a NOT EXISTS per message, and attachment chunk vectors. Each count reads a whole table, so the call slows as the mirror grows. The health endpoint is unaffected because it reads only the last sync time (#90).

Desired behavior:
mail_status takes quick (default false). With quick=true the result holds every per-account sync field (last sync, lag, source kind, errors) and the mirror-level status lines, and omits every count. The omitted counts are shown as - or the lines are dropped, with one line stating that counts were skipped, so a caller never reads a missing count as zero. The default call is unchanged. The tool description says which fields quick omits and why.

Key interfaces:

  • Store.status: the count queries become skippable without duplicating the sync-health part.
  • mail_status signature and docstring.

Acceptance criteria:

  • quick=true runs no COUNT query (assert through the SQLite trace callback or a query log in the test).
  • quick=true output holds the same sync lag and last-sync values as the default call on the same store.
  • quick=true output states that counts were skipped and shows no numeric count.
  • The default call is byte-for-byte unchanged on the test store.
  • make check passes.

Out of scope:

  • A counts table maintained by the sync worker.
  • Changing the health endpoint.

Filed under: operator word "accept" sha256:c125d0397b60

> *This was generated by AI during triage.* Part of #106 (item 1). Decided at triage 2026-11-02: a `quick` flag, not a counts table. ## Agent Brief **Category:** enhancement **Summary:** mail_status(quick=true) returns sync health without the table counts **Current behavior:** Every mail_status call counts messages per account, attachment text rows, the attachment backlog through a NOT EXISTS per message, and attachment chunk vectors. Each count reads a whole table, so the call slows as the mirror grows. The health endpoint is unaffected because it reads only the last sync time (#90). **Desired behavior:** mail_status takes `quick` (default false). With `quick=true` the result holds every per-account sync field (last sync, lag, source kind, errors) and the mirror-level status lines, and omits every count. The omitted counts are shown as `-` or the lines are dropped, with one line stating that counts were skipped, so a caller never reads a missing count as zero. The default call is unchanged. The tool description says which fields quick omits and why. **Key interfaces:** - `Store.status`: the count queries become skippable without duplicating the sync-health part. - `mail_status` signature and docstring. **Acceptance criteria:** - [ ] `quick=true` runs no COUNT query (assert through the SQLite trace callback or a query log in the test). - [ ] `quick=true` output holds the same sync lag and last-sync values as the default call on the same store. - [ ] `quick=true` output states that counts were skipped and shows no numeric count. - [ ] The default call is byte-for-byte unchanged on the test store. - [ ] `make check` passes. **Out of scope:** - A counts table maintained by the sync worker. - Changing the health endpoint. Filed under: operator word "accept" sha256:c125d0397b60
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#110 mail-status-quick-true-returns-sync-health-without-the-table

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 effort medium

Run: 20261102T063839Z-b84e731b

Held because: CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:

Open risks:

  1. The brief lists 'lag' and 'source kind' as per-account sync fields, but the default mail_status prints neither (server.py:692-707). The lean adds neither, so quick keeps exactly the non-count fields the default prints. Question: should quick, or both modes, also print per-account lag_seconds= and source=imap|jmap? Adding them to the default breaks the byte-for-byte criterion, so if wanted it belongs in a follow-up issue under #106. [decision]
  2. Rendering contract: the lean drops the count fields and adds the literal line 'counts: skipped (quick=true); call mail_status without quick for them'. The brief also allows 'messages=-'-style placeholders. Question: is the dropped-field shape and this exact skip line acceptable as the caller-facing contract? The tests pin the literal. [decision]
  3. No test or make check ran in the Half-A sandbox: .venv/bin/python returned 'Operation not permitted', and the audit target needs the network. Check: on the host, run uv run python3 -m pytest -q -m "not integration" on pristine 7927f74 before the first edit. Then run make check on the branch and confirm the failure set is unchanged, apart from the six new tests passing. [verification]
  4. The unit tests prove only that quick runs no count statement and no SCAN messages, not the wall-clock gain. Check after deploy: against the production api container, time mail_status with and without quick=true on the live mirror. Expect quick to stay roughly constant while the default scales with the message count. [verification]

Change: Store.status (store.py:2118) gets counts: bool = True. When counts is false it skips the four whole-table aggregates: the accounts COUNT/SUM, attachment_text, the backlog NOT EXISTS, and attachment_embeddings. It omits their three dict keys. It lists accounts through a new module constant _STATUS_ACCOUNTS: a recursive MIN(account) loose index scan over the (account, …) indexes at store.py:112-114. The plan was verified in scratch SQLite 3.53.3 as SEARCH-only, and it returns the same account set as the default. The sync-health reads stay shared: mailboxes, last_ok_sync(), last_errors, change_seq, db and WAL size. mail_status (server.py:673-711) gets quick: Annotated[bool, Field(...)] = False, following the idiom at server.py:231. With quick it calls status(counts=False) and keeps the six mirror lines. It appends the literal counts: skipped (quick=true); call mail_status without quick for them. Each account line becomes account=X last_ok_sync=Y. The default branch is unchanged character for character, and the docstring names the omitted fields and why. README.md:54 gets one sentence. The tests mirror the two-connection trace in tests/test_server.py:235-259.

Files: src/mail_mind_mcp/store.py · src/mail_mind_mcp/server.py · README.md · tests/test_server.py · tests/test_store.py

Decision: 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):

  • add label svd:go — approve; Half-B dispatch accepts exactly this spec (open risks accepted)
  • add label svd:fire beside svd:go — approve AND authorise the Half-B fire from the phone; never on its own
  • add label svd:skip — park it; dispatch refuses it and the issue stays for a human
  • add label svd:respec — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context

Spec: /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-status-quick-true-returns-sync-health-without-the-table.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-status-quick-true-returns-sync-health-without-the-table.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#110 mail-status-quick-true-returns-sync-health-without-the-table **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 effort `medium` **Run:** `20261102T063839Z-b84e731b` **Held because:** CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. The brief lists 'lag' and 'source kind' as per-account sync fields, but the default mail_status prints neither (server.py:692-707). The lean adds neither, so quick keeps exactly the non-count fields the default prints. Question: should quick, or both modes, also print per-account lag_seconds= and source=imap|jmap? Adding them to the default breaks the byte-for-byte criterion, so if wanted it belongs in a follow-up issue under #106. [decision] 2. Rendering contract: the lean drops the count fields and adds the literal line 'counts: skipped (quick=true); call mail_status without quick for them'. The brief also allows 'messages=-'-style placeholders. Question: is the dropped-field shape and this exact skip line acceptable as the caller-facing contract? The tests pin the literal. [decision] 3. No test or make check ran in the Half-A sandbox: .venv/bin/python returned 'Operation not permitted', and the audit target needs the network. Check: on the host, run `uv run python3 -m pytest -q -m "not integration"` on pristine 7927f74 before the first edit. Then run `make check` on the branch and confirm the failure set is unchanged, apart from the six new tests passing. [verification] 4. The unit tests prove only that quick runs no count statement and no SCAN messages, not the wall-clock gain. Check after deploy: against the production api container, time mail_status with and without quick=true on the live mirror. Expect quick to stay roughly constant while the default scales with the message count. [verification] **Change:** Store.status (store.py:2118) gets `counts: bool = True`. When counts is false it skips the four whole-table aggregates: the accounts COUNT/SUM, attachment_text, the backlog NOT EXISTS, and attachment_embeddings. It omits their three dict keys. It lists accounts through a new module constant `_STATUS_ACCOUNTS`: a recursive MIN(account) loose index scan over the (account, …) indexes at store.py:112-114. The plan was verified in scratch SQLite 3.53.3 as SEARCH-only, and it returns the same account set as the default. The sync-health reads stay shared: mailboxes, last_ok_sync(), last_errors, change_seq, db and WAL size. mail_status (server.py:673-711) gets `quick: Annotated[bool, Field(...)] = False`, following the idiom at server.py:231. With quick it calls status(counts=False) and keeps the six mirror lines. It appends the literal `counts: skipped (quick=true); call mail_status without quick for them`. Each account line becomes `account=X last_ok_sync=Y`. The default branch is unchanged character for character, and the docstring names the omitted fields and why. README.md:54 gets one sentence. The tests mirror the two-connection trace in tests/test_server.py:235-259. **Files:** `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/server.py` · `README.md` · `tests/test_server.py` · `tests/test_store.py` **Decision:** 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`): - add label `svd:go` — approve; Half-B dispatch accepts exactly this spec (open risks accepted) - add label `svd:fire` **beside** `svd:go` — approve AND authorise the Half-B fire from the phone; never on its own - add label `svd:skip` — park it; dispatch refuses it and the issue stays for a human - add label `svd:respec` — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context <sub>Spec: `/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-status-quick-true-returns-sync-health-without-the-table.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-status-quick-true-returns-sync-health-without-the-table.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#110 mail-status-quick-true-returns-sync-health-without-the-table completed integration verify.

  • PR: #135
  • Branch: feat/svd-dev-mail-mind-mcp-110-mail-status-quick-true-returns-d7c640e2
  • Commit: 2f015641f3
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Checks: No remote checks: the Forgejo commit statuses for 2f01564 are empty. Local suite: 819 passed, 8 skipped, 18 deselected.
  • Warning: The Forgejo commit-status list for the PR head is empty. The repo has no CI (CLAUDE.md: no .woodpecker files here), so no remote check exists.
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261102T065919Z-d7c640e2 --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#110 mail-status-quick-true-returns-sync-health-without-the-table completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/135 - Branch: feat/svd-dev-mail-mind-mcp-110-mail-status-quick-true-returns-d7c640e2 - Commit: 2f015641f37e841adea28b2957dc3478709abc77 - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Checks: No remote checks: the Forgejo commit statuses for 2f01564 are empty. Local suite: 819 passed, 8 skipped, 18 deselected. - Warning: The Forgejo commit-status list for the PR head is empty. The repo has no CI (CLAUDE.md: no .woodpecker files here), so no remote check exists. - Decision: review the PR and merge? (`codex-svd ship --run-id 20261102T065919Z-d7c640e2 --confirm-merge`)
svc-svd-writer 2026-11-02 07:16:55 +00:00
  • closed this issue
  • removed the
    svd:go
    label
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#110
No description provided.