Reply from the arrival address (ADR 0014) #212

Closed
opened 2026-11-13 22:08:15 +00:00 by svc-agent-writer · 3 comments

Implements ADR 0014 (docs/adr/0014-reply-from-the-arrival-address.md). Read it first. A reply or forward draft goes out from the address the original arrived at, when that address is in the account's trusted own set. This keeps Fastmail masked addresses and iCloud aliases unlinked from the real address.

What to build

  1. Config: a new account key reply_from_arrival: bool = False, on both IMAP and JMAP accounts. config.example.toml documents it.
  2. JMAP worker: on each full pass, when the session has the https://www.fastmail.com/dev/maskedemail capability, call MaskedEmail/get with properties email and state only. Record the enabled addresses for the account in the store. Without the capability, record an empty list. Never call MaskedEmail/set. Never store any other MaskedEmail field.
  3. One sender rule, shared by server.py's early refusal and by both sources' _compose (actions.py, jmap.py). It builds on the #211 helper. With reply_from_arrival on and an original (reply or forward), it takes the first address in the original's To, then Cc, that is in the trusted own set: the identity, aliases, and the recorded masked list. Otherwise it returns the account identity. A draft edit uses the replaced action's params, so the edit keeps its From.
  4. mail_draft and mail_draft_edit answers add from=<address>.
  5. Logs: counts and origins (identity, alias, masked) only, never an address. Extend the write-path log privacy tests from #209 to cover a masked From.
  6. Docs: README ([[accounts]] row, mail_draft row, a note that only aliases this account can send from belong in aliases when the key is on), SECURITY.md (the Masked Email scope widens the sync credential), CLAUDE.md and GLOSSARY ("arrival address", "trusted own set").

If the store needs a new table rather than a meta key, it is schema v19 under the existing writer-only migration rules.

Acceptance criteria

  • With the key off, every draft's From is unchanged.
  • With the key on, a reply to mail sent to an enabled masked address has that address as From.
  • A reply to mail sent to a configured alias has the alias as From.
  • A To or Cc address outside the trusted set never becomes the From. A disabled or deleted masked address does not count.
  • A forward follows the same rule. An edit keeps the From of the draft it replaces.
  • Without the Masked Email capability, the worker makes no MaskedEmail call and the set holds only aliases.
  • No log record carries an address. No MaskedEmail field other than email and state is stored.
  • The api never calls the mail server (tests/test_source.py).
  • Unit tests with a fake JMAP session cover the masked cases; IMAP tests cover aliases. make check passes.

Out of scope

Creating, disabling or deleting masked addresses. iCloud Hide My Email discovery (no public API). Any send path. Changing mail_people's own-address list.

Blocked by

Implements ADR 0014 (docs/adr/0014-reply-from-the-arrival-address.md). Read it first. A reply or forward draft goes out from the address the original arrived at, when that address is in the account's trusted own set. This keeps Fastmail masked addresses and iCloud aliases unlinked from the real address. ## What to build 1. Config: a new account key `reply_from_arrival: bool = False`, on both IMAP and JMAP accounts. `config.example.toml` documents it. 2. JMAP worker: on each full pass, when the session has the `https://www.fastmail.com/dev/maskedemail` capability, call `MaskedEmail/get` with properties `email` and `state` only. Record the enabled addresses for the account in the store. Without the capability, record an empty list. Never call `MaskedEmail/set`. Never store any other MaskedEmail field. 3. One sender rule, shared by `server.py`'s early refusal and by both sources' `_compose` (`actions.py`, `jmap.py`). It builds on the #211 helper. With `reply_from_arrival` on and an original (reply or forward), it takes the first address in the original's To, then Cc, that is in the trusted own set: the identity, `aliases`, and the recorded masked list. Otherwise it returns the account identity. A draft edit uses the replaced action's params, so the edit keeps its From. 4. `mail_draft` and `mail_draft_edit` answers add `from=<address>`. 5. Logs: counts and origins (`identity`, `alias`, `masked`) only, never an address. Extend the write-path log privacy tests from #209 to cover a masked From. 6. Docs: README (`[[accounts]]` row, `mail_draft` row, a note that only aliases this account can send from belong in `aliases` when the key is on), SECURITY.md (the Masked Email scope widens the sync credential), CLAUDE.md and GLOSSARY ("arrival address", "trusted own set"). If the store needs a new table rather than a `meta` key, it is schema v19 under the existing writer-only migration rules. ## Acceptance criteria - [ ] With the key off, every draft's From is unchanged. - [ ] With the key on, a reply to mail sent to an enabled masked address has that address as From. - [ ] A reply to mail sent to a configured alias has the alias as From. - [ ] A To or Cc address outside the trusted set never becomes the From. A disabled or deleted masked address does not count. - [ ] A forward follows the same rule. An edit keeps the From of the draft it replaces. - [ ] Without the Masked Email capability, the worker makes no MaskedEmail call and the set holds only aliases. - [ ] No log record carries an address. No MaskedEmail field other than `email` and `state` is stored. - [ ] The api never calls the mail server (`tests/test_source.py`). - [ ] Unit tests with a fake JMAP session cover the masked cases; IMAP tests cover aliases. `make check` passes. ## Out of scope Creating, disabling or deleting masked addresses. iCloud Hide My Email discovery (no public API). Any send path. Changing `mail_people`'s own-address list. ## Blocked by - #211
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014

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: 20261113T231449Z-d132b23a

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

Open risks:

  1. MaskedEmail/get failure handling. Lean: catch BladeError around only that call, log the error code, keep the last recorded list and continue the pass. Question: should a failure instead clear the list or fail the whole pass? Clearing makes replies fall back to the real identity, which links the masked address (the harm ADR 0014 prevents). Failing the pass stops mail sync on a server that advertises the capability but refuses the method. Keeping the list can briefly honour an address disabled since the last good read. ADR 0014 §4 is silent. [decision]
  2. Rollback note: with extra=forbid, a pre-#212 image refuses a config that sets reply_from_arrival. Question: should this PR's README carry the note, or the release PR's upgrade paragraph, as was done for trash_per_day (README.md:56)? The spec leaves it to the release PR. [decision]
  3. ADR 0014 says it amends ADR 0004 §6 and ADR 0006 §11, but the issue does not list pointer edits to those ADRs. Earlier amendments landed as separate doc PRs (#207, #215). Question: follow-up doc PR, or fold into this PR? Folding them in would raise the file count to 17, over the 16-file ceiling, so the spec excludes them. [decision]
  4. No test baseline was measured (Half-A sandbox is read-only). Check: before the first edit, run uv run python3 -m pytest -q -m "not integration" tests/test_jmap.py tests/test_actions.py tests/test_write_tools.py tests/test_config.py tests/test_source.py on pristine f51dbbd. After the change, assert that only new tests were added and the failure set is otherwise unchanged; then make check must pass on the host. [verification]
  5. Live Fastmail shape is unproven by fakes. Check, post-merge: with a token that has the Masked Email scope, run one sync pass. Logs should show 'masked addresses recorded' with count>0, and a reply drafted to mail sent to a masked address should carry that address as From in Fastmail Drafts. [verification]

Change: Put one pure rule, outbox.arrival_sender(identity, original, *, reply_from_arrival, aliases, masked) -> (address, origin in identity|alias|masked). It walks evidence.addresses(original.to_addrs) and then cc_addrs (evidence.py:313-325) and returns the first address in the trusted set; otherwise it returns the identity. Model the Arrived Protocol on Original/Forwarded (outbox.py:50-79). Store the masked list as a meta key, masked_addresses:{account}, holding a JSON list (no schema v19). Mirror session_sender/record_session_sender exactly (store.py:2048-2069), including the writer-only assertion. Add reply_from_arrival: bool = False to MirrorScope (config.py:310-318) so IMAP and JMAP accounts both get it. JMAP: add a MASKED_EMAIL constant and a using=() keyword on JmapClient.call (jmap.py:239-242). Add _masked_addresses() beside _session_sender (jmap.py:533-541) and call it from run_pass after _session_sender. Without the capability it records [] and makes no call. With it, it calls MaskedEmail/get with properties ["email","state"] and keeps state == enabled. A BladeError keeps the last list and the pass continues. Log the count only. Call sites, all reading the store: JmapSource._compose (jmap.py:989-1007), ActionRunner._compose (actions.py:217-238) and server._draft_sender(account, original) (server.py:1462-1468). The worker logs 'draft sender' with origin only. mail_draft and mail_draft_edit append ' from=' after _outcome. The edit tool loads the reply original via a _ref_row helper that mirrors JmapSource._row (jmap.py:757-761). Edits and undo-edits already compose from the replaced params, so they keep their From.

Files: src/mail_mind_mcp/config.py · src/mail_mind_mcp/outbox.py · src/mail_mind_mcp/store.py · src/mail_mind_mcp/jmap.py · src/mail_mind_mcp/actions.py · src/mail_mind_mcp/server.py · config.example.toml · README.md · SECURITY.md · CLAUDE.md · GLOSSARY.md · tests/test_jmap.py · tests/test_actions.py · tests/test_write_tools.py · tests/test_config.py

Decision: accept the 5 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-13-reply-from-the-arrival-address-adr-0014.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-13-reply-from-the-arrival-address-adr-0014.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014 **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:** `20261113T231449Z-d132b23a` **Held because:** CLEAN but 5 open risk(s) (2 verification · 3 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. MaskedEmail/get failure handling. Lean: catch BladeError around only that call, log the error code, keep the last recorded list and continue the pass. Question: should a failure instead clear the list or fail the whole pass? Clearing makes replies fall back to the real identity, which links the masked address (the harm ADR 0014 prevents). Failing the pass stops mail sync on a server that advertises the capability but refuses the method. Keeping the list can briefly honour an address disabled since the last good read. ADR 0014 §4 is silent. [decision] 2. Rollback note: with extra=forbid, a pre-#212 image refuses a config that sets reply_from_arrival. Question: should this PR's README carry the note, or the release PR's upgrade paragraph, as was done for trash_per_day (README.md:56)? The spec leaves it to the release PR. [decision] 3. ADR 0014 says it amends ADR 0004 §6 and ADR 0006 §11, but the issue does not list pointer edits to those ADRs. Earlier amendments landed as separate doc PRs (#207, #215). Question: follow-up doc PR, or fold into this PR? Folding them in would raise the file count to 17, over the 16-file ceiling, so the spec excludes them. [decision] 4. No test baseline was measured (Half-A sandbox is read-only). Check: before the first edit, run `uv run python3 -m pytest -q -m "not integration" tests/test_jmap.py tests/test_actions.py tests/test_write_tools.py tests/test_config.py tests/test_source.py` on pristine f51dbbd. After the change, assert that only new tests were added and the failure set is otherwise unchanged; then `make check` must pass on the host. [verification] 5. Live Fastmail shape is unproven by fakes. Check, post-merge: with a token that has the Masked Email scope, run one sync pass. Logs should show 'masked addresses recorded' with count>0, and a reply drafted to mail sent to a masked address should carry that address as From in Fastmail Drafts. [verification] **Change:** Put one pure rule, outbox.arrival_sender(identity, original, *, reply_from_arrival, aliases, masked) -> (address, origin in identity|alias|masked). It walks evidence.addresses(original.to_addrs) and then cc_addrs (evidence.py:313-325) and returns the first address in the trusted set; otherwise it returns the identity. Model the Arrived Protocol on Original/Forwarded (outbox.py:50-79). Store the masked list as a meta key, masked_addresses:{account}, holding a JSON list (no schema v19). Mirror session_sender/record_session_sender exactly (store.py:2048-2069), including the writer-only assertion. Add reply_from_arrival: bool = False to MirrorScope (config.py:310-318) so IMAP and JMAP accounts both get it. JMAP: add a MASKED_EMAIL constant and a using=() keyword on JmapClient.call (jmap.py:239-242). Add _masked_addresses() beside _session_sender (jmap.py:533-541) and call it from run_pass after _session_sender. Without the capability it records [] and makes no call. With it, it calls MaskedEmail/get with properties ["email","state"] and keeps state == enabled. A BladeError keeps the last list and the pass continues. Log the count only. Call sites, all reading the store: JmapSource._compose (jmap.py:989-1007), ActionRunner._compose (actions.py:217-238) and server._draft_sender(account, original) (server.py:1462-1468). The worker logs 'draft sender' with origin only. mail_draft and mail_draft_edit append ' from=<sender>' after _outcome. The edit tool loads the reply original via a _ref_row helper that mirrors JmapSource._row (jmap.py:757-761). Edits and undo-edits already compose from the replaced params, so they keep their From. **Files:** `src/mail_mind_mcp/config.py` · `src/mail_mind_mcp/outbox.py` · `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/jmap.py` · `src/mail_mind_mcp/actions.py` · `src/mail_mind_mcp/server.py` · `config.example.toml` · `README.md` · `SECURITY.md` · `CLAUDE.md` · `GLOSSARY.md` · `tests/test_jmap.py` · `tests/test_actions.py` · `tests/test_write_tools.py` · `tests/test_config.py` **Decision:** accept the 5 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-13-reply-from-the-arrival-address-adr-0014.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-13-reply-from-the-arrival-address-adr-0014.md`</sub>
Collaborator

✅ SVD architect gate: dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014

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 unclassified · dispatch effort unclassified

Run: 20261113T231449Z-d132b23a

Files: src/mail_mind_mcp/config.py · src/mail_mind_mcp/outbox.py · src/mail_mind_mcp/store.py · src/mail_mind_mcp/jmap.py · src/mail_mind_mcp/actions.py · src/mail_mind_mcp/server.py · config.example.toml · README.md · SECURITY.md · CLAUDE.md · GLOSSARY.md · tests/test_jmap.py · tests/test_actions.py · tests/test_write_tools.py · tests/test_config.py

Write-set divergence: present table wins. 0 sourceHashes vs 21-row table.

Decision: dispatch this spec (svd:go)?

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-13-reply-from-the-arrival-address-adr-0014.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-13-reply-from-the-arrival-address-adr-0014.md

### ✅ SVD architect gate: dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014 **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 `unclassified` · dispatch effort `unclassified` **Run:** `20261113T231449Z-d132b23a` **Files:** `src/mail_mind_mcp/config.py` · `src/mail_mind_mcp/outbox.py` · `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/jmap.py` · `src/mail_mind_mcp/actions.py` · `src/mail_mind_mcp/server.py` · `config.example.toml` · `README.md` · `SECURITY.md` · `CLAUDE.md` · `GLOSSARY.md` · `tests/test_jmap.py` · `tests/test_actions.py` · `tests/test_write_tools.py` · `tests/test_config.py` **Write-set divergence:** present table wins. 0 sourceHashes vs 21-row table. **Decision:** dispatch this spec (`svd:go`)? **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-13-reply-from-the-arrival-address-adr-0014.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-13-reply-from-the-arrival-address-adr-0014.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014 completed integration verify.

  • PR: #219
  • Branch: feat/svd-dev-mail-mind-mcp-212-reply-from-the-arrival-address-2df80318
  • Commit: e9f3668d10
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/72/pipeline/116/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: Remote CI ci/woodpecker/pr/validation was still pending at verification time; the runner should re-poll it.
  • Warning: Four spec-table test names are covered by differently named tests: test_arrival_off_keeps_the_identity, test_reply_to_an_alias_uses_it, test_untrusted_recipient_never_becomes_from and test_forward_uses_the_arrival_address are parametrised cases of tests/test_actions.py::test_arrival_address_on_imap_drafts (ids arrival_off, alias, untrusted_cc, untrusted_only, forward_uses). Every spec filter (-k arrival_off, alias, untrusted, forward_uses or edit_keeps) collects them, so the behaviour is covered. The exact names do not exist.
  • Warning: Subagent changed three existing exact-response assertions for the from= suffix, as it declared. The change is non-blocking.
  • Warning: Merge class: config.example.toml is unplaced (dev/stables#1844), so ship refuses this PR as T4. The operator merges it pinned to the gated head.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261113T233108Z-2df80318 --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#212 reply-from-the-arrival-address-adr-0014 completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/219 - Branch: feat/svd-dev-mail-mind-mcp-212-reply-from-the-arrival-address-2df80318 - Commit: e9f3668d10df8e9fa4d12b695433f4f20d05a0ca - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/72/pipeline/116/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: Remote CI ci/woodpecker/pr/validation was still pending at verification time; the runner should re-poll it. - Warning: Four spec-table test names are covered by differently named tests: test_arrival_off_keeps_the_identity, test_reply_to_an_alias_uses_it, test_untrusted_recipient_never_becomes_from and test_forward_uses_the_arrival_address are parametrised cases of tests/test_actions.py::test_arrival_address_on_imap_drafts (ids arrival_off, alias, untrusted_cc, untrusted_only, forward_uses). Every spec filter (-k arrival_off, alias, untrusted, forward_uses or edit_keeps) collects them, so the behaviour is covered. The exact names do not exist. - Warning: Subagent changed three existing exact-response assertions for the from= suffix, as it declared. The change is non-blocking. - Warning: Merge class: config.example.toml is unplaced (dev/stables#1844), so ship refuses this PR as T4. The operator merges it pinned to the gated head. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261113T233108Z-2df80318 --confirm-merge`)
svc-agent-writer 2026-11-14 00:04:51 +00:00
piers referenced this issue from a commit 2026-11-14 00:10:21 +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/mail-mind-mcp#212
No description provided.