mailmind Source: one envelope address with whitespace fails the whole pass with mailmind-protocol #39

Closed
opened 2026-11-02 04:50:44 +00:00 by piers · 3 comments
Owner

Problem

On the gate instance (image 0.1.0-rc.3, people-mind-mcp 5e0a500) the first full mailmind pass runs paced at about 3.2 requests per second for 8 minutes, accepts about 1,500 mail_changes pages (cursor 150200), then fails with code=mailmind-protocol.

Traced in the sync container with a structure-only spy on _call (no values printed): the failing page has 101 lines, a matching footer, 100 add rows of 7 cells, every seq numeric, every address cell matchable, and exactly one normalised address handle that contains whitespace. _addresses raises SourceError("mailmind-protocol") for that one handle, so the whole pass fails and every later pass fails at the same page.

One malformed envelope address in a 150,000-change mailbox should not stop the Source. The protocol check is for the shape mailmind promises (columns, footer, sequence order); a single address value that does not normalise is data quality, not protocol breakage.

Fix

In src/people_mind_mcp/sources/mailmind.py:

  1. _addresses no longer raises on an unmatchable handle or a handle containing whitespace. It drops that handle and reports the count, so the caller can add it to self.unreadable.
  2. The row is otherwise processed as today. If the sender is dropped, the row yields no interaction. If one to/cc address is dropped, the others still count.
  3. The pass log line keeps unreadable=N as the only trace. No address is logged.

Keep the strict shape checks (cell count, numeric seq, kinds, footer) unchanged.

Acceptance

  • A unit test feeds a mail_changes page whose rows include one address with internal whitespace and one without an @; the pass completes, unreadable counts 2, the other addresses on those rows produce interactions, and no SourceError is raised.
  • Existing protocol tests still fail the pass for a bad cell count, a non-numeric seq, and a footer mismatch.
  • Live on the gate instance: source=mail kind=mailmind status=ok (recorded on #10).

Primary files

  • src/people_mind_mcp/sources/mailmind.py (_addresses and its call site in _fetch)
  • tests/test_mailmind.py

Blocked by

None.

## Problem On the gate instance (image 0.1.0-rc.3, people-mind-mcp 5e0a500) the first full mailmind pass runs paced at about 3.2 requests per second for 8 minutes, accepts about 1,500 `mail_changes` pages (cursor 150200), then fails with `code=mailmind-protocol`. Traced in the sync container with a structure-only spy on `_call` (no values printed): the failing page has 101 lines, a matching footer, 100 `add` rows of 7 cells, every `seq` numeric, every address cell matchable, and exactly one normalised address handle that contains whitespace. `_addresses` raises `SourceError("mailmind-protocol")` for that one handle, so the whole pass fails and every later pass fails at the same page. One malformed envelope address in a 150,000-change mailbox should not stop the Source. The protocol check is for the shape mailmind promises (columns, footer, sequence order); a single address value that does not normalise is data quality, not protocol breakage. ## Fix In `src/people_mind_mcp/sources/mailmind.py`: 1. `_addresses` no longer raises on an unmatchable handle or a handle containing whitespace. It drops that handle and reports the count, so the caller can add it to `self.unreadable`. 2. The row is otherwise processed as today. If the sender is dropped, the row yields no interaction. If one `to`/`cc` address is dropped, the others still count. 3. The pass log line keeps `unreadable=N` as the only trace. No address is logged. Keep the strict shape checks (cell count, numeric `seq`, kinds, footer) unchanged. ## Acceptance - A unit test feeds a `mail_changes` page whose rows include one address with internal whitespace and one without an `@`; the pass completes, `unreadable` counts 2, the other addresses on those rows produce interactions, and no `SourceError` is raised. - Existing protocol tests still fail the pass for a bad cell count, a non-numeric `seq`, and a footer mismatch. - Live on the gate instance: `source=mail kind=mailmind status=ok` (recorded on #10). ## Primary files - `src/people_mind_mcp/sources/mailmind.py` (`_addresses` and its call site in `_fetch`) - `tests/test_mailmind.py` ## Blocked by None.
Collaborator

⏸ SVD architect gate: dev/people-mind-mcp#39 mailmind-source-one-envelope-address-with-whitespace-fails-t

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: 20261102T050617Z-0fca5b4b

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

Open risks:

  1. Should a From cell that mailmind sends with two handles always be a shape violation (mailmind-protocol), even when one handle is malformed? Lean: yes. The check len(sender) + from_dropped > 1 keeps today's behaviour. The alternative treats it as data quality: drop the bad handle and keep the remaining sender. [decision]
  2. Should this PR also document mailmind's unreadable meaning (envelope address handles dropped on accepted pages) in ADR 0004 or the README? ADR 0004 currently defines unreadable only for vCard and CardDAV. Lean: no. The issue names two files, and this would be a one-line docs follow-up. [decision]
  3. Live check on the gate instance, to record on dev/people-mind-mcp#10. The issue's literal status=ok is printed by no code path; grep -rn "status=" src finds only status=error and status=missing. After deploying the merged image, check that the sync container logs the run_pass success line source=mail kind=mailmind seen=… unreadable=N fetched=…, that no source=mail kind=mailmind status=error line appears for the pass that crosses cursor 150200, and that the latest sync_log row for source 'mail' has error IS NULL and unreadable >= 1. [verification]
  4. There is no measured test baseline, because the Half-A sandbox refused to execute .venv/bin/python3. Before the first edit, dispatch must run uv run python3 -m pytest tests/test_mailmind.py -q on pristine base 5e0a500. After the change, it must confirm the failure set is unchanged apart from the new and extended tests passing. [verification]

Change: Change _addresses (mailmind.py:95-101) to return (kept_handles, dropped_count). It keeps a handle only when handle.matchable is true and its value has no whitespace (today's predicate, negated), dedups the kept handles with dict.fromkeys, and no longer raises. In _fetch: set self.unreadable = 0 at the start of the pass, mirroring CardDAVSource.fetch at carddav.py:240. Count drops per page in a local page_unreadable and add it to self.unreadable just before cursor = footer[1] (:218), so only accepted pages count. Change the single-sender check to len(sender) + from_dropped > 1, so a two-handle From cell is still a protocol error. A dropped sender yields no interaction (targets = sender = ()). Leave every other shape check unchanged. Add no logger line: the unreadable=N that sync.py:92 already prints is the only trace. Tests mirror test_mailmind_interactions_both_directions_and_idempotent (tests/test_mailmind.py:236-251) and extend the parametrize of test_bad_change_rows_are_protocol_errors with a non-numeric seq case and a two-handle From case.

Files: src/people_mind_mcp/sources/mailmind.py · tests/test_mailmind.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-mailmind-source-one-envelope-address-with-whitespace-fails-t.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mailmind-source-one-envelope-address-with-whitespace-fails-t.md

### ⏸ SVD architect gate: dev/people-mind-mcp#39 mailmind-source-one-envelope-address-with-whitespace-fails-t **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:** `20261102T050617Z-0fca5b4b` **Held because:** CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Should a From cell that mailmind sends with two handles always be a shape violation (mailmind-protocol), even when one handle is malformed? Lean: yes. The check `len(sender) + from_dropped > 1` keeps today's behaviour. The alternative treats it as data quality: drop the bad handle and keep the remaining sender. [decision] 2. Should this PR also document mailmind's `unreadable` meaning (envelope address handles dropped on accepted pages) in ADR 0004 or the README? ADR 0004 currently defines unreadable only for vCard and CardDAV. Lean: no. The issue names two files, and this would be a one-line docs follow-up. [decision] 3. Live check on the gate instance, to record on dev/people-mind-mcp#10. The issue's literal `status=ok` is printed by no code path; `grep -rn "status=" src` finds only status=error and status=missing. After deploying the merged image, check that the sync container logs the run_pass success line `source=mail kind=mailmind seen=… unreadable=N fetched=…`, that no `source=mail kind=mailmind status=error` line appears for the pass that crosses cursor 150200, and that the latest sync_log row for source 'mail' has error IS NULL and unreadable >= 1. [verification] 4. There is no measured test baseline, because the Half-A sandbox refused to execute .venv/bin/python3. Before the first edit, dispatch must run `uv run python3 -m pytest tests/test_mailmind.py -q` on pristine base 5e0a500. After the change, it must confirm the failure set is unchanged apart from the new and extended tests passing. [verification] **Change:** Change `_addresses` (mailmind.py:95-101) to return `(kept_handles, dropped_count)`. It keeps a handle only when `handle.matchable` is true and its value has no whitespace (today's predicate, negated), dedups the kept handles with `dict.fromkeys`, and no longer raises. In `_fetch`: set `self.unreadable = 0` at the start of the pass, mirroring `CardDAVSource.fetch` at carddav.py:240. Count drops per page in a local `page_unreadable` and add it to `self.unreadable` just before `cursor = footer[1]` (:218), so only accepted pages count. Change the single-sender check to `len(sender) + from_dropped > 1`, so a two-handle From cell is still a protocol error. A dropped sender yields no interaction (`targets = sender = ()`). Leave every other shape check unchanged. Add no logger line: the `unreadable=N` that sync.py:92 already prints is the only trace. Tests mirror `test_mailmind_interactions_both_directions_and_idempotent` (tests/test_mailmind.py:236-251) and extend the parametrize of `test_bad_change_rows_are_protocol_errors` with a non-numeric seq case and a two-handle From case. **Files:** `src/people_mind_mcp/sources/mailmind.py` · `tests/test_mailmind.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-mailmind-source-one-envelope-address-with-whitespace-fails-t.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mailmind-source-one-envelope-address-with-whitespace-fails-t.md`</sub>
Author
Owner

Architect gate (Half-A CLEAN, run 20261102T050617Z-0fca5b4b). Spec approved with two rulings edited into the spec body and its tables (not only the Agent Adjustments section, per dev/stables#1842):

  • D1 reversed from the Half-A lean: data quality, not shape. The single-sender check stays len(sender) > 1 over the kept handles. A malformed From handle is dropped and counted like a to/cc handle, and the row proceeds with whatever sender remains. Two well-formed From handles stay mailmind-protocol. Reason: this issue's own principle is that an address value that does not normalise is data quality, and dev/mail-mind-mcp#129 shows the formatter can emit a display name with a comma. Under the Half-A lean that row would kill the pass again.
  • D2: no documentation in this PR. Write set stays the two Primary files.
  • V1 is post-merge and architect-run on the gate instance, recorded on #10. Note the acceptance bullet above says status=ok; no code prints that. The live evidence is the run_pass success line for source=mail kind=mailmind and a sync_log row with error IS NULL and unreadable >= 1.
  • V2 baseline measured on the host at 5e0a500: 65 passed in tests/test_mailmind.py, 175 across the four neighbour files.

Riders in the spec: basetemp on every pytest command, python3 -m pytest, no nested .git. Operator pastes svd:go to release Half-B.

**Architect gate (Half-A CLEAN, run 20261102T050617Z-0fca5b4b).** Spec approved with two rulings edited into the spec body and its tables (not only the Agent Adjustments section, per dev/stables#1842): - **D1 reversed from the Half-A lean: data quality, not shape.** The single-sender check stays `len(sender) > 1` over the kept handles. A malformed From handle is dropped and counted like a `to`/`cc` handle, and the row proceeds with whatever sender remains. Two well-formed From handles stay `mailmind-protocol`. Reason: this issue's own principle is that an address value that does not normalise is data quality, and dev/mail-mind-mcp#129 shows the formatter can emit a display name with a comma. Under the Half-A lean that row would kill the pass again. - **D2: no documentation in this PR.** Write set stays the two Primary files. - **V1 is post-merge and architect-run** on the gate instance, recorded on #10. Note the acceptance bullet above says `status=ok`; no code prints that. The live evidence is the `run_pass` success line for `source=mail kind=mailmind` and a `sync_log` row with `error IS NULL` and `unreadable >= 1`. - **V2 baseline measured on the host at 5e0a500:** 65 passed in `tests/test_mailmind.py`, 175 across the four neighbour files. Riders in the spec: basetemp on every pytest command, `python3 -m pytest`, no nested `.git`. Operator pastes `svd:go` to release Half-B.
Collaborator

spec-verify-dispatch Half B for dev/people-mind-mcp#39 mailmind-source-one-envelope-address-with-whitespace-fails-t completed integration verify.

  • PR: #40
  • Branch: feat/svd-dev-people-mind-mcp-39-mailmind-source-one-envelope-42f87828
  • Commit: c611a19eb0
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Checks: No remote checks on c611a19: Forgejo returned an empty status list and the repo has no CI config. Local: 295 passed, 5 skipped; ruff and mypy clean.
  • Warning: Bare python3 -m pytest --collect-only failed outside uv (No module named 'phonenumbers' in conftest); collection was proven with uv run python3 -m pytest instead: 10 tests collected, covering all named spec tests.
  • Warning: No commit statuses exist on the PR head and the repo has no CI configuration; no remote checks to report.
  • Warning: Post-merge V1 (live gate-instance pass, dev/people-mind-mcp#10) remains architect-run.
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261102T052121Z-42f87828 --confirm-merge)
spec-verify-dispatch Half B for dev/people-mind-mcp#39 mailmind-source-one-envelope-address-with-whitespace-fails-t completed integration verify. - PR: https://git.groupthink.asia/dev/people-mind-mcp/pulls/40 - Branch: feat/svd-dev-people-mind-mcp-39-mailmind-source-one-envelope-42f87828 - Commit: c611a19eb0546b156a1586e5b5aee09828d1ee0a - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Checks: No remote checks on c611a19: Forgejo returned an empty status list and the repo has no CI config. Local: 295 passed, 5 skipped; ruff and mypy clean. - Warning: Bare `python3 -m pytest --collect-only` failed outside uv (No module named 'phonenumbers' in conftest); collection was proven with `uv run python3 -m pytest` instead: 10 tests collected, covering all named spec tests. - Warning: No commit statuses exist on the PR head and the repo has no CI configuration; no remote checks to report. - Warning: Post-merge V1 (live gate-instance pass, dev/people-mind-mcp#10) remains architect-run. - Decision: review the PR and merge? (`codex-svd ship --run-id 20261102T052121Z-42f87828 --confirm-merge`)
piers closed this issue 2026-11-02 05:27:44 +00:00
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/people-mind-mcp#39
No description provided.