mail_read reads up to 20 ids in one call with a shared max_chars budget #133

Closed
opened 2026-11-02 06:33:51 +00:00 by svc-agent-writer · 3 comments

This was generated by AI during triage.

Part of #106 (item 6, batch read). Split from #109 at triage 2026-11-02, so that #109 stays under the dispatch file limit.

Agent Brief

Category: enhancement
Summary: mail_read takes up to 20 ids in one call, with one shared max_chars budget

Current behavior:
mail_read takes one id per call. A client that reads ten messages makes ten calls.

Desired behavior:

  • mail_read takes message_ids (1 to 20 ids) in place of a single id.
  • One max_chars budget is split evenly across the ids. A share that a message does not spend flows to the later messages.
  • The response puts a visible header before each message. It ends with a footer that names how many messages were read in full, how many were truncated, and which ids were not reached.
  • A missing id is reported in the footer, not as an error. Only when every id is missing is the result the usual not_found error.
  • A single-id call keeps its current output.

Key interfaces:

  • The mail_read signature and docstring.
  • The triage panel's calls into mail_read.

Acceptance criteria:

  • A call with 3 ids and max_chars=3000 returns the three bodies under one footer.
  • A call with one unknown id among three reports that id in the footer and returns the other two.
  • A call where every id is unknown returns the not_found error.
  • A single-id call gives the same output as before, byte for byte, on the test store.
  • The panel tests pass, and make check passes.

Out of scope:

  • The address cap and the cell and snippet changes (#109).
  • More than 20 ids in one call.

Blocked by

  • #109 (both change the mail_read signature and header)

Filed under: operator word "all" sha256:5ef5ef0364b6

> *This was generated by AI during triage.* Part of #106 (item 6, batch read). Split from #109 at triage 2026-11-02, so that #109 stays under the dispatch file limit. ## Agent Brief **Category:** enhancement **Summary:** mail_read takes up to 20 ids in one call, with one shared `max_chars` budget **Current behavior:** `mail_read` takes one id per call. A client that reads ten messages makes ten calls. **Desired behavior:** - `mail_read` takes `message_ids` (1 to 20 ids) in place of a single id. - One `max_chars` budget is split evenly across the ids. A share that a message does not spend flows to the later messages. - The response puts a visible header before each message. It ends with a footer that names how many messages were read in full, how many were truncated, and which ids were not reached. - A missing id is reported in the footer, not as an error. Only when every id is missing is the result the usual `not_found` error. - A single-id call keeps its current output. **Key interfaces:** - The `mail_read` signature and docstring. - The triage panel's calls into `mail_read`. **Acceptance criteria:** - [ ] A call with 3 ids and `max_chars=3000` returns the three bodies under one footer. - [ ] A call with one unknown id among three reports that id in the footer and returns the other two. - [ ] A call where every id is unknown returns the `not_found` error. - [ ] A single-id call gives the same output as before, byte for byte, on the test store. - [ ] The panel tests pass, and `make check` passes. **Out of scope:** - The address cap and the cell and snippet changes (#109). - More than 20 ids in one call. ## Blocked by - #109 (both change the `mail_read` signature and header) Filed under: operator word "all" sha256:5ef5ef0364b6
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c

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 substrate · dispatch effort high

Run: 20261102T122604Z-9be8cb90

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

Open risks:

  1. In a batch, should a malformed id (one ids.decode rejects) fail the whole call with invalid_argument (the lean, as _refs does for the write tools), or go in the footer next to not_found? A single-id call returns invalid_argument either way. [decision]
  2. The issue gives no format for the per-message header or the footer. The lean uses '=== message k of n ===' and 'full=N truncated=N not_found=ids|-', and reads 'ids not reached' as 'ids not found': with an even share and a floor of 10 characters, every found message is reached. Accept these strings, or name others before dispatch? The tests and README pin them. [decision]
  3. After deploy, list tools from the Grok connector. Confirm that mail_read shows message_ids with maxItems 20 and that a one-id call matches the old output. Clients with saved message_id prompts or schemas get a validation error until they re-list tools. [verification]

Change: In src/mail_mind_mcp/server.py, move lines 582-615 of mail_read, unchanged, into _read_text(message_id, row, max_chars, max_addresses) -> (text, truncated). Change the parameter to message_ids: Annotated[list[str], Field(min_length=1, max_length=MAX_READ_IDS=20)], shaped like mail_flag (server.py:1116-1121). Dedupe in request order with dict.fromkeys, as _refs does (server.py:1019-1028). Look up each id once; a malformed id raises invalid_argument for the whole call. If no id is found, raise the existing BladeError(CODE_NOT_FOUND, "message not found in the mirror"). With one unique id, return _read_text unchanged, so the output is byte-identical. With several, the k-th of m found messages gets share = (max_chars - used) // (m - k), so unspent characters flow forward. Each block is preceded by '=== message k of m ==='. The footer is 'full=N truncated=N not_found=ids|-', key=value like mail_thread (server.py:527). Change panel.html:144 to message_ids: [id] and update README.md:51. Update every caller of the old message_id form in 8 test files (CONV-23). Add tests/test_batch_read.py on the test_copies mirror fixtures. Add a single-id pin test next to test_mail_status_default_output_is_pinned (tests/test_server.py:83-108), proved on the pristine base first.

Files: src/mail_mind_mcp/server.py · src/mail_mind_mcp/panel.html · README.md · tests/test_batch_read.py · tests/test_server.py · tests/test_compact_rows.py · tests/test_attachments.py · tests/test_utc_dates.py · tests/test_attachment_signals.py · tests/test_ids.py · tests/test_evidence.py · tests/test_panel.py · tests/integration/test_greenmail.py

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-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c **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 `substrate` · dispatch effort `high` **Run:** `20261102T122604Z-9be8cb90` **Held because:** CLEAN but 3 open risk(s) (1 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. In a batch, should a malformed id (one ids.decode rejects) fail the whole call with invalid_argument (the lean, as _refs does for the write tools), or go in the footer next to not_found? A single-id call returns invalid_argument either way. [decision] 2. The issue gives no format for the per-message header or the footer. The lean uses '=== message k of n ===' and 'full=N truncated=N not_found=ids|-', and reads 'ids not reached' as 'ids not found': with an even share and a floor of 10 characters, every found message is reached. Accept these strings, or name others before dispatch? The tests and README pin them. [decision] 3. After deploy, list tools from the Grok connector. Confirm that mail_read shows message_ids with maxItems 20 and that a one-id call matches the old output. Clients with saved message_id prompts or schemas get a validation error until they re-list tools. [verification] **Change:** In src/mail_mind_mcp/server.py, move lines 582-615 of mail_read, unchanged, into _read_text(message_id, row, max_chars, max_addresses) -> (text, truncated). Change the parameter to message_ids: Annotated[list[str], Field(min_length=1, max_length=MAX_READ_IDS=20)], shaped like mail_flag (server.py:1116-1121). Dedupe in request order with dict.fromkeys, as _refs does (server.py:1019-1028). Look up each id once; a malformed id raises invalid_argument for the whole call. If no id is found, raise the existing BladeError(CODE_NOT_FOUND, "message not found in the mirror"). With one unique id, return _read_text unchanged, so the output is byte-identical. With several, the k-th of m found messages gets share = (max_chars - used) // (m - k), so unspent characters flow forward. Each block is preceded by '=== message k of m ==='. The footer is 'full=N truncated=N not_found=ids|-', key=value like mail_thread (server.py:527). Change panel.html:144 to message_ids: [id] and update README.md:51. Update every caller of the old message_id form in 8 test files (CONV-23). Add tests/test_batch_read.py on the test_copies mirror fixtures. Add a single-id pin test next to test_mail_status_default_output_is_pinned (tests/test_server.py:83-108), proved on the pristine base first. **Files:** `src/mail_mind_mcp/server.py` · `src/mail_mind_mcp/panel.html` · `README.md` · `tests/test_batch_read.py` · `tests/test_server.py` · `tests/test_compact_rows.py` · `tests/test_attachments.py` · `tests/test_utc_dates.py` · `tests/test_attachment_signals.py` · `tests/test_ids.py` · `tests/test_evidence.py` · `tests/test_panel.py` · `tests/integration/test_greenmail.py` **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-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c completed integration verify.

  • PR: #146
  • Branch: feat/svd-dev-mail-mind-mcp-133-mail-read-reads-up-to-20-ids-i-332bda05
  • Commit: 5af2ef1eb4
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: False
  • Check forgejo commit statuses: absent
  • Checks: PR #146 @5af2ef1: no remote CI exists (absent). Local: full unit run 895 passed 8 skipped; focused 264 passed. One PR-metadata blocker: the body does not name the message_id to message_ids rename.
  • Blocker: PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument message_id of mail_read becomes message_ids (1 to 20 ids), so clients with a cached schema must re-list tools.
  • Blocker cause: work for PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument message_id of mail_read becomes message_ids (1 to 20 ids), so clients with a cached schema must re-list tools.; no denial signature; evidence: Spec Agent Adjustments: "The PR body names the rename in one sentence." PR #146 body mentions no rename of message_id to message_ids.
  • Warning: No remote CI exists for this repo (no commit statuses, no .woodpecker); integration truth rests on local runs.
  • Warning: Optional GreenMail integration tests were not run; the call-form edits in tests/integration/test_greenmail.py are unexercised.
  • Warning: make check (mypy --strict, ruff, pip-audit) was not re-run in this invocation; only the unit suite and the focused run were executed. The subagent reports it passed.
  • Warning: Post-deploy check (Open Risk 3): list tools from the Grok connector and confirm mail_read shows message_ids with maxItems 20.
  • Warning: Batch overlap with #111: whichever PR merges second needs a rebase and re-integration (server.py, README.md, tests/test_server.py, tests/test_evidence.py).
  • Warning: PR commit trailer reads Co-Authored-By: gpt-6.1-sol — repo convention is one Co-Authored-By line; not verified against policy.
  • Warning: no CI for forgejo commit statuses: No commit statuses on PR head 5af2ef1 and the repo has no .woodpecker CI (CI files are added by the architect); no tracking pointer exists. — reported as absent, not blocking (gh#633)
  • Rework: 0 round(s), outcome metadata-hold
  • Escalation: PR metadata blocker(s) hold the run without code rework: PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument message_id of mail_read becomes message_ids (1 to 20 ids), so clients with a cached schema must re-list tools.; edit the PR title or body by hand, then re-run integrate or run the own-execution gate.
  • Decision: resolve the blockers above and rerun integrate, or park this PR for a human?
spec-verify-dispatch Half B for dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/146 - Branch: feat/svd-dev-mail-mind-mcp-133-mail-read-reads-up-to-20-ids-i-332bda05 - Commit: 5af2ef1eb43e0bdc4d83cfe4ef05c9fd19d0b329 - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: False - Check forgejo commit statuses: absent - Checks: PR #146 @5af2ef1: no remote CI exists (absent). Local: full unit run 895 passed 8 skipped; focused 264 passed. One PR-metadata blocker: the body does not name the message_id to message_ids rename. - Blocker: PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument `message_id` of `mail_read` becomes `message_ids` (1 to 20 ids), so clients with a cached schema must re-list tools. - Blocker cause: work for PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument `message_id` of `mail_read` becomes `message_ids` (1 to 20 ids), so clients with a cached schema must re-list tools.; no denial signature; evidence: Spec Agent Adjustments: "The PR body names the rename in one sentence." PR #146 body mentions no rename of message_id to message_ids. - Warning: No remote CI exists for this repo (no commit statuses, no .woodpecker); integration truth rests on local runs. - Warning: Optional GreenMail integration tests were not run; the call-form edits in tests/integration/test_greenmail.py are unexercised. - Warning: make check (mypy --strict, ruff, pip-audit) was not re-run in this invocation; only the unit suite and the focused run were executed. The subagent reports it passed. - Warning: Post-deploy check (Open Risk 3): list tools from the Grok connector and confirm mail_read shows message_ids with maxItems 20. - Warning: Batch overlap with #111: whichever PR merges second needs a rebase and re-integration (server.py, README.md, tests/test_server.py, tests/test_evidence.py). - Warning: PR commit trailer reads `Co-Authored-By: gpt-6.1-sol` — repo convention is one Co-Authored-By line; not verified against policy. - Warning: no CI for forgejo commit statuses: No commit statuses on PR head 5af2ef1 and the repo has no .woodpecker CI (CI files are added by the architect); no tracking pointer exists. — reported as absent, not blocking (gh#633) - Rework: 0 round(s), outcome metadata-hold - Escalation: PR metadata blocker(s) hold the run without code rework: PR metadata: add one sentence to the PR body naming the contract rename: the MCP argument `message_id` of `mail_read` becomes `message_ids` (1 to 20 ids), so clients with a cached schema must re-list tools.; edit the PR title or body by hand, then re-run integrate or run the own-execution gate. - Decision: resolve the blockers above and rerun integrate, or park this PR for a human?
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c completed integration verify.

  • PR: #146
  • Branch: feat/svd-dev-mail-mind-mcp-133-mail-read-reads-up-to-20-ids-i-332bda05
  • Commit: 5af2ef1eb4
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check commit statuses on PR head: absent
  • Checks: PR #146 at 5af2ef1: no remote checks exist. Local unit run: 895 passed, 8 skipped, 18 deselected. ruff and mypy --strict are clean.
  • Warning: No remote CI exists for this repo: the PR head has no commit statuses.
  • Warning: The GreenMail integration test was not run; only its call form changed.
  • Warning: The MCP argument rename from message_id to message_ids is intended. Check after deploy that the Grok connector lists message_ids with maxItems 20 (spec Open Risk 3).
  • Warning: Spec dev/stables#1315 asks for find . -mindepth 2 -name .git to print nothing before commit. It printed nothing here outside .venv.
  • Warning: no CI for commit statuses on PR head: The Forgejo statuses endpoint returns [] for 5af2ef1. The repo has no .woodpecker CI; the architect adds CI files. — reported as absent, not blocking (gh#633)
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261102T124455Z-332bda05 --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#133 mail-read-reads-up-to-20-ids-in-one-call-with-a-shared-max-c completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/146 - Branch: feat/svd-dev-mail-mind-mcp-133-mail-read-reads-up-to-20-ids-i-332bda05 - Commit: 5af2ef1eb43e0bdc4d83cfe4ef05c9fd19d0b329 - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check commit statuses on PR head: absent - Checks: PR #146 at 5af2ef1: no remote checks exist. Local unit run: 895 passed, 8 skipped, 18 deselected. ruff and mypy --strict are clean. - Warning: No remote CI exists for this repo: the PR head has no commit statuses. - Warning: The GreenMail integration test was not run; only its call form changed. - Warning: The MCP argument rename from message_id to message_ids is intended. Check after deploy that the Grok connector lists message_ids with maxItems 20 (spec Open Risk 3). - Warning: Spec dev/stables#1315 asks for `find . -mindepth 2 -name .git` to print nothing before commit. It printed nothing here outside .venv. - Warning: no CI for commit statuses on PR head: The Forgejo statuses endpoint returns [] for 5af2ef1. The repo has no .woodpecker CI; the architect adds CI files. — reported as absent, not blocking (gh#633) - Decision: review the PR and merge? (`codex-svd ship --run-id 20261102T124455Z-332bda05 --confirm-merge`)
svc-svd-writer 2026-11-02 20:58:45 +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#133
No description provided.