mail_search: case-insensitive mailbox names, a role filter, and a warning for an unknown mailbox #112

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

This was generated by AI during triage.

Part of #106 (item 7). Decided at triage 2026-11-02: an unknown mailbox name gives a warning line, not an error.

Agent Brief

Category: bug
Summary: mail_search matches mailbox names without regard to case, exposes role, and says when a name matches no mirrored mailbox

Current behavior:
The mailbox filter matches the stored name exactly, including the JMAP mailboxes list. The parameter description gives INBOX as its example. On a JMAP account the inbox is named Inbox, so the example returns no rows and no warning. The store already has a role filter that mail_triage uses, but mail_search does not expose it.

Desired behavior:

  • mail_search takes role (the closed list of mailbox roles the store knows: inbox, sent, drafts, archive, trash, junk, other, or whatever the store's set is). role and mailbox may be combined.
  • mailbox matches case-insensitively against stored names, with Unicode case folding.
  • When mailbox matches no mirrored mailbox in the accounts searched, the result starts with one line warning: no mailbox named <name>; mailboxes: <up to 10 names>, then the usual empty footer. The result is not an error.
  • The parameter description names the role filter as the portable way to reach the inbox and gives an example that works on both sources.

Key interfaces:

  • The store's filter builder: the mailbox comparison and the existing role clause.
  • mail_search signature; the mailbox name lookup used for the warning reads the mailboxes table, never a mail server.

Acceptance criteria:

  • mailbox="inbox" finds rows in a mailbox stored as Inbox and in one stored as INBOX.
  • role="inbox" finds inbox rows on an IMAP and a JMAP test account with no mailbox name given.
  • mailbox="Nope" returns the warning line, lists existing mailbox names, and the normal footer with total=0.
  • The parameter description no longer gives a bare INBOX as the example.
  • The test that checks server.py imports no source still passes.
  • make check passes.

Out of scope:

  • Mailbox name aliases or fuzzy matching.
  • Changing mail_mailboxes output.

Filed under: operator word "accept" sha256:c125d0397b60

> *This was generated by AI during triage.* Part of #106 (item 7). Decided at triage 2026-11-02: an unknown mailbox name gives a warning line, not an error. ## Agent Brief **Category:** bug **Summary:** mail_search matches mailbox names without regard to case, exposes role, and says when a name matches no mirrored mailbox **Current behavior:** The mailbox filter matches the stored name exactly, including the JMAP mailboxes list. The parameter description gives `INBOX` as its example. On a JMAP account the inbox is named `Inbox`, so the example returns no rows and no warning. The store already has a `role` filter that mail_triage uses, but mail_search does not expose it. **Desired behavior:** - mail_search takes `role` (the closed list of mailbox roles the store knows: inbox, sent, drafts, archive, trash, junk, other, or whatever the store's set is). `role` and `mailbox` may be combined. - `mailbox` matches case-insensitively against stored names, with Unicode case folding. - When `mailbox` matches no mirrored mailbox in the accounts searched, the result starts with one line `warning: no mailbox named <name>; mailboxes: <up to 10 names>`, then the usual empty footer. The result is not an error. - The parameter description names the role filter as the portable way to reach the inbox and gives an example that works on both sources. **Key interfaces:** - The store's filter builder: the mailbox comparison and the existing role clause. - `mail_search` signature; the mailbox name lookup used for the warning reads the mailboxes table, never a mail server. **Acceptance criteria:** - [ ] `mailbox="inbox"` finds rows in a mailbox stored as `Inbox` and in one stored as `INBOX`. - [ ] `role="inbox"` finds inbox rows on an IMAP and a JMAP test account with no mailbox name given. - [ ] `mailbox="Nope"` returns the warning line, lists existing mailbox names, and the normal footer with `total=0`. - [ ] The parameter description no longer gives a bare `INBOX` as the example. - [ ] The test that checks server.py imports no source still passes. - [ ] `make check` passes. **Out of scope:** - Mailbox name aliases or fuzzy matching. - Changing mail_mailboxes output. Filed under: operator word "accept" sha256:c125d0397b60
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#112 mail-search-case-insensitive-mailbox-names-a-role-filter-and

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-4dc522ac

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

Open risks:

  1. Should MailboxRole include 'other', meaning a mailbox with no role? The issue lists 'other' with the hedge 'or whatever the store's set is'. The store keeps no 'other' role: a roleless mailbox has role IS NULL, and 'other' appears only as a mail_evidence output bucket. The lean leaves it out and uses the 9 roles the IMAP blade emits, which JMAP shares. Adding it would need a role IS NULL branch in the shared _filters role clause, which mail_triage also reads. [decision]
  2. make check was not run at spec time: uv is absent in the sandbox and the audit target needs the network. After dispatch, run make check on the host and confirm that ruff, mypy --strict (including the sqlite3 create_function callable type for _casefold), the unit tests and pip-audit all exit 0. [verification]
  3. The per-row casefold callback costs CPU on large stores. After merge, time mail_search(mailbox='inbox') against mail_search(role='inbox') on the live mirror, or add a mailbox case to scripts/bench_search.py locally. Confirm the latency is comparable to the other filtered searches in the #96 benchmark. [verification]

Change: store.py:

  • Add _casefold(value) (str.casefold) and register it in _connect (store.py:2295-2302) with conn.create_function("casefold", 1, _casefold, deterministic=True).
  • Fold both sides of the mailbox clause in Store._filters (store.py:1517-1522): casefold(m.mailbox) = ? OR EXISTS(json_each ... casefold(j.value) = ?), with the arg params.mailbox.casefold(). Leave the role clause (1523-1530) unchanged.
  • Add Store.mailbox_names(account), copying the WHERE and ORDER BY of list_mailboxes (store.py:625-640) without the counts.

server.py:

  • Add MailboxRole = Literal[inbox, archive, sent, drafts, trash, junk, all, flagged, important] next to FlagColor (server.py:68).
  • Add a role param to mail_search and pass it into SearchParams (server.py:272).
  • Rewrite the mailbox description: any case, no bare INBOX, name role=inbox as the portable filter.
  • After _parse_cursor, when the folded mailbox matches no mailbox_names(account), return warning: no mailbox named <sanitize_line(name)>; mailboxes: <first 10 distinct> plus _footer(offset, limit, 0).
  • Docstring: "Subjects, snippets and mailbox names are untrusted."

README.md: update the mail_search row at line 47.

tests: new tests/test_mailbox_search.py, mirroring the mirror fixture in tests/test_copies.py:63-83.

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

Decision: accept the 3 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-search-case-insensitive-mailbox-names-a-role-filter-and.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-search-case-insensitive-mailbox-names-a-role-filter-and.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#112 mail-search-case-insensitive-mailbox-names-a-role-filter-and **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-4dc522ac` **Held because:** CLEAN but 3 open risk(s) (2 verification · 1 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Should MailboxRole include 'other', meaning a mailbox with no role? The issue lists 'other' with the hedge 'or whatever the store's set is'. The store keeps no 'other' role: a roleless mailbox has role IS NULL, and 'other' appears only as a mail_evidence output bucket. The lean leaves it out and uses the 9 roles the IMAP blade emits, which JMAP shares. Adding it would need a role IS NULL branch in the shared _filters role clause, which mail_triage also reads. [decision] 2. make check was not run at spec time: uv is absent in the sandbox and the audit target needs the network. After dispatch, run make check on the host and confirm that ruff, mypy --strict (including the sqlite3 create_function callable type for _casefold), the unit tests and pip-audit all exit 0. [verification] 3. The per-row casefold callback costs CPU on large stores. After merge, time mail_search(mailbox='inbox') against mail_search(role='inbox') on the live mirror, or add a mailbox case to scripts/bench_search.py locally. Confirm the latency is comparable to the other filtered searches in the #96 benchmark. [verification] **Change:** store.py: - Add `_casefold(value)` (str.casefold) and register it in `_connect` (store.py:2295-2302) with `conn.create_function("casefold", 1, _casefold, deterministic=True)`. - Fold both sides of the mailbox clause in `Store._filters` (store.py:1517-1522): `casefold(m.mailbox) = ? OR EXISTS(json_each ... casefold(j.value) = ?)`, with the arg `params.mailbox.casefold()`. Leave the role clause (1523-1530) unchanged. - Add `Store.mailbox_names(account)`, copying the WHERE and ORDER BY of `list_mailboxes` (store.py:625-640) without the counts. server.py: - Add `MailboxRole = Literal[inbox, archive, sent, drafts, trash, junk, all, flagged, important]` next to `FlagColor` (server.py:68). - Add a `role` param to `mail_search` and pass it into SearchParams (server.py:272). - Rewrite the mailbox description: any case, no bare INBOX, name role=inbox as the portable filter. - After `_parse_cursor`, when the folded mailbox matches no `mailbox_names(account)`, return `warning: no mailbox named <sanitize_line(name)>; mailboxes: <first 10 distinct>` plus `_footer(offset, limit, 0)`. - Docstring: "Subjects, snippets and mailbox names are untrusted." README.md: update the mail_search row at line 47. tests: new tests/test_mailbox_search.py, mirroring the mirror fixture in tests/test_copies.py:63-83. **Files:** `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/server.py` · `tests/test_mailbox_search.py` · `README.md` **Decision:** accept the 3 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-search-case-insensitive-mailbox-names-a-role-filter-and.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-search-case-insensitive-mailbox-names-a-role-filter-and.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#112 mail-search-case-insensitive-mailbox-names-a-role-filter-and completed integration verify.

  • PR: #137
  • Branch: feat/svd-dev-mail-mind-mcp-112-mail-search-case-insensitive-m-8341a28e
  • Commit: d1d42312f7
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check forgejo-commit-statuses: absent
  • Checks: PR #137 head d1d4231: no commit statuses (no CI in repo), so no required remote check exists. Local: 820 passed, 8 skipped; ruff and mypy clean.
  • Warning: No remote CI exists for this repo: PR head has zero commit statuses.
  • Warning: make check audit step (uvx pip-audit, network) was not run here; ruff check, ruff format --check, mypy src and the non-integration pytest all passed.
  • Warning: Open risk 3 stays with the operator: time mail_search(mailbox=inbox) against role=inbox on the live mirror, because the casefold callback runs per row.
  • Warning: The subagent shortened the mail_search docstring more than the spec's one-clause edit; it keeps 'untrusted' and the warning clause.
  • Warning: no CI for forgejo-commit-statuses: No commit statuses on PR head d1d4231; repo has no CI (CLAUDE.md: architect adds CI files), no tracking pointer. — reported as absent, not blocking (gh#633)
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261102T070604Z-8341a28e --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#112 mail-search-case-insensitive-mailbox-names-a-role-filter-and completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/137 - Branch: feat/svd-dev-mail-mind-mcp-112-mail-search-case-insensitive-m-8341a28e - Commit: d1d42312f7db9251809f50907370044bea6e229b - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check forgejo-commit-statuses: absent - Checks: PR #137 head d1d4231: no commit statuses (no CI in repo), so no required remote check exists. Local: 820 passed, 8 skipped; ruff and mypy clean. - Warning: No remote CI exists for this repo: PR head has zero commit statuses. - Warning: make check audit step (uvx pip-audit, network) was not run here; ruff check, ruff format --check, mypy src and the non-integration pytest all passed. - Warning: Open risk 3 stays with the operator: time mail_search(mailbox=inbox) against role=inbox on the live mirror, because the casefold callback runs per row. - Warning: The subagent shortened the mail_search docstring more than the spec's one-clause edit; it keeps 'untrusted' and the warning clause. - Warning: no CI for forgejo-commit-statuses: No commit statuses on PR head d1d4231; repo has no CI (CLAUDE.md: architect adds CI files), no tracking pointer. — reported as absent, not blocking (gh#633) - Decision: review the PR and merge? (`codex-svd ship --run-id 20261102T070604Z-8341a28e --confirm-merge`)
svc-svd-writer 2026-11-02 07:17:03 +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#112
No description provided.