mail_changes envelope and mail_people: emit parseable addresses only #129
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#129
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?
Observation
dev/people-mind-mcp#39: on a 150,000-change mailbox, one
mail_changesenvelope row (envelope=true) carries an address cell whose normalised handle contains internal whitespace (the people-mind client lowercases and strips the ends, splits on,, and rejects any remaining whitespace). Every other row of the page parsed. No value was logged; the finding is a count from a structure-only probe.The consumer side is being made tolerant (#39 there). Question for this side: should the envelope columns emit only addresses that parse as
local@domainwith no whitespace, dropping or quoting the rest, so every consumer sees one shape? A header like"first last"@exampleor a display name leaking into the address field are the likely sources.Fix candidate
In the envelope formatter, pass each address through the same parse the mirror uses for the
peopletable and emit-for a cell with no parseable address. Document the rule in themail_changesdocstring.Blocked by
None.
Agent Brief
Category: bug
Summary:
mail_changesenvelope cells andmail_peoplerows emit only addresses that parse: an@and no whitespace. Every other value is left out.Current behavior:
Reproduced on
mainat538ef5f.mail_changesenvelope (envelope=true, ADR 0008 §3) emits the from cell as the storedfrom_addr, lowercased, with no check. A quoted local part ("first last"@example) is stored asfirst last@example, and that value reaches the cell. A group address with no host is stored with no@, and it reaches the cell too. For example,_envelopewithfrom_addr="First Last@Example.test"givesfirst last@example.test, andfrom_addr="undisclosed-recipients"givesundisclosed-recipients.evidence.addresses()drops any address that has whitespace or no@.mail_peoplelists correspondents grouped on the rawmessages.from_addrinStore.people(). It returns the same unparseable values as rows, and counts them intotal.People Mind rejects such a value (dev/people-mind-mcp#39).
Correction to the issue text: the mirror has no
peopletable, and no parse runs formail_people. The parse to reuse is the rule inevidence.addresses().Desired behavior:
One rule for both tools: an address parses when it contains an
@and no whitespace. This is the ruleevidence.addresses()already applies to To and Cc.mail_changeswithenvelope=true: the from cell holds the lowercased address when it parses, and-when it does not. The to and cc cells do not change.mail_people: a correspondent whosefrom_addrdoes not parse is not a row. Apply the filter in theStore.people()query, not after paging, sototal,moreandnext_cursorstay consistent with the rows.from_addrvalues pass throughsanitize_line, so the only whitespace they can hold is a space. To be safe, the SQL predicate also excludes tab, LF and CR.mail_changesandmail_peopledocstrings each state the rule in one short sentence.Key interfaces:
_envelope(row)in the server: the from cell goes through the parse rule.evidence.addresses(stored): keep its behavior. If you add a one-address helper beside it (for exampleevidence.address(value) -> str | None),addresses()should use the same predicate, so that one rule exists.Store.people(...): the WHERE clause gains the parse predicate besidem.from_addr != ''. The signature does not change.Acceptance criteria:
addrow withfrom_addrfirst last@example.testemits-as its from cell, and a row withfrom_addrundisclosed-recipientsemits-. A row with a normal address is unchanged.test_envelope_cells_are_addresses_onlyandtest_envelope_leaves_other_kinds_and_the_default_unchanged.Store.people()test: messages froma@example.test,first last@example.testandnohostgive one row,a@example.test, andtotal == 1. A paging case confirmstotalcounts only parseable rows.test_people_pages_excludes_self_and_filters_the_tail,test_people_and_statusandtest_people_count_a_copy_once.make checkis green. Tests run asuv run python3 -m pytest.Primary files (current paths; they may move):
src/mail_mind_mcp/server.py(_envelope, themail_changesandmail_peopledocstrings)src/mail_mind_mcp/evidence.py(only if you add a shared one-address helper)src/mail_mind_mcp/store.py(Store.people)tests/test_evidence.pytests/test_store.pyREADME.md(themail_changesandmail_peoplerows)Out of scope:
-, or there is no row.from_addr, or any schema change or migration. Stored rows stay as they are.mail_evidence. It takes an address as an argument, and an unparseable argument simply finds no evidence.exclude,exclude_sent,include_self), and any new field or tool. ADR 0008 needs no amendment, because §3 already says the cells hold addresses only.mail_changes envelope: an address cell can contain internal whitespace; emit parseable addresses onlyto mail_changes envelope and mail_people: emit parseable addresses only⏸ SVD architect gate: dev/mail-mind-mcp#129 mail-changes-envelope-and-mail-people-emit-parseable-address
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:
20261102T050631Z-c903172dHeld because: CLEAN but 2 open risk(s) (2 verification) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make checkwas not run at spec time. Its audit step needs network access (uvx pip-audit), and uv is absent in the Half-A sandbox. Check: on the host, on the PR branch, runmake check. lint, type, test and audit must all exit 0, and the test pass set must equal the pre-change set plus the new tests. [verification]Change: evidence.py: add
address(value) -> str | Noneaboveaddresses()(evidence.py:148). It returns the lowercased value when the value has an '@' and no whitespace (str.isspace). Rewrite theaddresses()loop to use it, with no behaviour change. server.py: in_envelope(server.py:511), the from cell becomesevidence.address(row.from_addr) or "", so the existingcell or "-"path emits-. Add one sentence each to the mail_changes docstring (lines 484-486) and the mail_people docstring (lines 593-595), keeping "untrusted". store.py: add a module-level SQL helper_address_parses(column), mirroring_same_message/_copy_keyat store.py:257-286. It is instr '@' > 0 AND NOT (space, char(9), char(10) or char(13)). Append it towhereinStore.people(store.py:1843), so the COUNT(*) total and the paged rows share the filter. Update README.md rows 49-50 by one clause each. No schema, ingest, mail_evidence or ADR change.Files:
src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/server.py·src/mail_mind_mcp/store.py·tests/test_evidence.py·tests/test_store.py·README.mdDecision: accept the 2 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-changes-envelope-and-mail-people-emit-parseable-address.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mail-changes-envelope-and-mail-people-emit-parseable-address.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#129 mail-changes-envelope-and-mail-people-emit-parseable-address completed integration verify.
2c58e395812c58e39: no Forgejo commit statuses (no CI configured, absent). Local make check green (ruff, mypy, 813 passed, pip-audit clean).2c58e39and the repo has no CI config (CLAUDE.md: CI files are added by the architect); no run in history. — reported as absent, not blocking (gh#633)codex-svd ship --run-id 20261102T052155Z-c29c2a3f --confirm-merge)