mail_trash on IMAP: tool, trash action kind, schema v18, cap, undo and mirror effect #192

Closed
opened 2026-11-12 05:52:16 +00:00 by svc-agent-writer · 7 comments

Part of epic #187. Implements ADR 0013 items 1 to 6 and the schema part of item 11, for IMAP.

Read docs/adr/0013-trash-forward-and-draft-edits.md and ADR 0004 first. ADR 0013 is the contract. If the code shows that a ruling cannot work, stop and report; do not change the ruling here.

Standing rules: tools only queue to the outbox and never call a mail server. The sync worker applies each action through the existing source apply interface. Logs carry counts, roles and error codes only. Secrets are files. Add no new test seam: use the tools over HTTP with the stand-in worker, the source apply interface with the fake IMAP session or the fake JMAP server, and the GreenMail and Stalwart integration targets.

What to build

  1. Schema v18: done. PR #199 landed the rebuild (slice 1). The actions table admits trash and edit. Add no schema change here. Replace the two test_runner_refuses rows that pin trash as invalid_argument on IMAP; keep the edit row.
  2. Tool mail_trash(message_ids). Scope write. It is absent without a write token file, like the other write tools. It carries destructiveHint=True; every other write tool keeps its hints. The docstring names its untrusted fields in one sentence.
  3. Cap trash_per_day. Default 20, in [writes]. It counts messages, not requests, from the deduplicated refs, in the same transaction as the enqueue. A request that would pass the cap is refused whole with rate_limited and queues nothing. Messages in refused or failed queued trash actions still count. Every other cap still counts requests.
  4. IMAP apply. Resolve exactly one mailbox with the trash role from the full server mailbox list at apply time, whether or not the mirror includes it. Zero or several is unsupported. Use MOVE, or COPY with UID EXPUNGE of the moved UIDs only. Record the source, Trash, the Trash UIDVALIDITY and the new UIDs as the inverse. Without new UIDs the action is unsupported.
  5. IMAP undo. Move back only the messages still in Trash at the recorded identity. If none remain, refuse with not_found and change nothing. The existing move undo stays all-or-nothing.
  6. Mirror effect. When the mirror excludes Trash, the source rows leave the mirror in the same transaction as the action result, with the normal change and peer deletion events. Never refresh or mirror an excluded Trash. After an undo, the rows return by the next worker pass at the latest.
  7. Unchanged refusals. mail_move still refuses Trash and Junk at the tool and at the source. Junk is never a target of any tool.
  8. Other readers of actions.kind. Update the worker undo dispatch, the per-kind branches of mail_undo and the action detail, the mail_actions display, the cap lookup and the daily count query. mail_actions detail carries counts and mailbox names only.
  9. JMAP until its own issue lands. A trash action on a JMAP account is refused with unsupported.

Design note from slice 1

Item 6 needs the rows to leave the mirror in the same transaction as the action result. Today the worker applies the action and then settles it in a separate store transaction. Add a settle path in the store that records the result, removes the rows and writes the change and peer deletion events in one transaction. Use it for trash only.

This is slice 2 of 2. If the work still exceeds the file ceiling, split by source of change: first the tool, cap and readers with the worker refusing trash as unsupported; then IMAP apply, undo and the mirror effect.

Acceptance criteria

  • mail_trash over HTTP queues one trash action and returns the outcome in the shape of the other write tools.
  • The tool list shows mail_trash with the destructive hint, and no other write tool has it. Update the existing test that asserts every write tool has a false destructive hint.
  • A request over the cap is refused whole with rate_limited. A request of 21 messages at the default cap is refused. Duplicate refs count once.
  • Fake IMAP session: apply with MOVE, apply without MOVE, zero trash mailboxes, two trash mailboxes, no new UIDs. Each gives the ruled outcome.
  • Undo restores only the messages still in Trash. Undo with none left gives not_found.
  • With Trash excluded from the mirror, the rows and their change events follow item 6 on apply and on undo.
  • GreenMail: trash then undo through the running worker.
  • make check passes.

Out of scope

JMAP trash. Forward drafts. Draft edits. README, SECURITY and release notes: the docs issue owns them.

Blocked by

  • #188 (ADR 0013 merged and accepted)
Part of epic #187. Implements ADR 0013 items 1 to 6 and the schema part of item 11, for IMAP. Read `docs/adr/0013-trash-forward-and-draft-edits.md` and ADR 0004 first. ADR 0013 is the contract. If the code shows that a ruling cannot work, stop and report; do not change the ruling here. Standing rules: tools only queue to the outbox and never call a mail server. The sync worker applies each action through the existing source `apply` interface. Logs carry counts, roles and error codes only. Secrets are files. Add no new test seam: use the tools over HTTP with the stand-in worker, the source `apply` interface with the fake IMAP session or the fake JMAP server, and the GreenMail and Stalwart integration targets. ## What to build 1. **Schema v18: done.** PR #199 landed the rebuild (slice 1). The `actions` table admits `trash` and `edit`. Add no schema change here. Replace the two `test_runner_refuses` rows that pin `trash` as `invalid_argument` on IMAP; keep the `edit` row. 2. **Tool `mail_trash(message_ids)`.** Scope `write`. It is absent without a write token file, like the other write tools. It carries `destructiveHint=True`; every other write tool keeps its hints. The docstring names its untrusted fields in one sentence. 3. **Cap `trash_per_day`.** Default 20, in `[writes]`. It counts messages, not requests, from the deduplicated refs, in the same transaction as the enqueue. A request that would pass the cap is refused whole with `rate_limited` and queues nothing. Messages in refused or failed queued trash actions still count. Every other cap still counts requests. 4. **IMAP apply.** Resolve exactly one mailbox with the trash role from the full server mailbox list at apply time, whether or not the mirror includes it. Zero or several is `unsupported`. Use MOVE, or COPY with UID EXPUNGE of the moved UIDs only. Record the source, Trash, the Trash UIDVALIDITY and the new UIDs as the inverse. Without new UIDs the action is `unsupported`. 5. **IMAP undo.** Move back only the messages still in Trash at the recorded identity. If none remain, refuse with `not_found` and change nothing. The existing move undo stays all-or-nothing. 6. **Mirror effect.** When the mirror excludes Trash, the source rows leave the mirror in the same transaction as the action result, with the normal change and peer deletion events. Never refresh or mirror an excluded Trash. After an undo, the rows return by the next worker pass at the latest. 7. **Unchanged refusals.** `mail_move` still refuses Trash and Junk at the tool and at the source. Junk is never a target of any tool. 8. **Other readers of `actions.kind`.** Update the worker undo dispatch, the per-kind branches of `mail_undo` and the action detail, the `mail_actions` display, the cap lookup and the daily count query. `mail_actions` detail carries counts and mailbox names only. 9. **JMAP until its own issue lands.** A `trash` action on a JMAP account is refused with `unsupported`. ## Design note from slice 1 Item 6 needs the rows to leave the mirror in the same transaction as the action result. Today the worker applies the action and then settles it in a separate store transaction. Add a settle path in the store that records the result, removes the rows and writes the change and peer deletion events in one transaction. Use it for `trash` only. This is slice 2 of 2. If the work still exceeds the file ceiling, split by source of change: first the tool, cap and readers with the worker refusing `trash` as `unsupported`; then IMAP apply, undo and the mirror effect. ## Acceptance criteria - [ ] `mail_trash` over HTTP queues one `trash` action and returns the outcome in the shape of the other write tools. - [ ] The tool list shows `mail_trash` with the destructive hint, and no other write tool has it. Update the existing test that asserts every write tool has a false destructive hint. - [ ] A request over the cap is refused whole with `rate_limited`. A request of 21 messages at the default cap is refused. Duplicate refs count once. - [ ] Fake IMAP session: apply with MOVE, apply without MOVE, zero trash mailboxes, two trash mailboxes, no new UIDs. Each gives the ruled outcome. - [ ] Undo restores only the messages still in Trash. Undo with none left gives `not_found`. - [ ] With Trash excluded from the mirror, the rows and their change events follow item 6 on apply and on undo. - [ ] GreenMail: trash then undo through the running worker. - [ ] `make check` passes. ## Out of scope JMAP trash. Forward drafts. Draft edits. README, SECURITY and release notes: the docs issue owns them. ## Blocked by - #188 (ADR 0013 merged and accepted)
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und

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: 20261112T060957Z-dca1101f

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

Open risks:

  1. Re-slice approval: does the architect approve splitting #192 into this slice (schema v18) and a slice-2 follow-up issue, with #192 left open or re-scoped until slice 2 lands? Slice 2 covers items 2-9: the mail_trash tool and destructive hint, the trash_per_day cap counted by messages, IMAP apply and undo, the mirror effect, the readers, and the JMAP unsupported refusal. It also covers the GreenMail acceptance. Its written set is about 13 files: server.py, config.py, store.py, source.py, actions.py, jmap.py, config.example.toml?, tests/test_write_tools.py, test_actions.py, test_store.py, test_config.py, test_jmap.py and tests/integration/test_greenmail_writes.py. Design note for that spec: item 6 needs the source rows deleted in the same transaction as the action result, but settle() (source.py:136-154) applies and then calls finish_action in a separate transaction. It needs a finish_action variant that deletes the rows and emits the change and peer events in one _tx. [decision]
  2. docs/adr/0013-trash-forward-and-draft-edits.md:3 still says 'Status: proposed', and ADR 0004:4 says 'Amended by ADR 0013 (proposed)'. The issue's blocker line reads '#188 (ADR 0013 merged and accepted)'. PR #190 merged at e2327a7, but #188's state was not in the issue-context snapshot. Is ADR 0013 accepted so dispatch may proceed, with the status-line flip left to the docs issue? [decision]
  3. The v17-reader test simulates the old reader by patching SCHEMA_VERSION=17 on current code. The reader path runs no DDL, so this is faithful, but it is not the 0.13.0 binary. Post-merge check: copy a v18-upgraded mirror, run the 0.13.0 image's mailmind api against it, and call mail_actions. It must list every row, a trash row showing of=None, and mail_flag must still queue. [verification]
  4. No numeric test baseline was taken: the host checkout has no .venv and the target repo is read-only in Half A. Before the first edit, dispatch must run make check and uv run python3 -m pytest -q over the 13 listed test files on pristine e2327a7, then assert that after the change only the new tests change state. [verification]
  5. README.md:123 and :308 (the 'first start on schema vNN' lists) need a 'schema v18 rebuilds the actions table once' line and a rollback note (a 0.13.0 image runs on the v18 file). The issue assigns README and release notes to the docs issue. Is that line tracked in the epic #187 docs issue? [decision]

Change: Slice 1 of 2 (re-sliced for the scope ceiling: the v18 bump alone breaks hard-coded version assertions in 12 test files, and the full issue needs about 22 files). Steps: (1) Follow the _SCHEMA = _TABLES.replace("{fts}", ...) placeholder pattern at store.py:388. Lift the actions DDL at store.py:176-204 into _ACTIONS_TABLE, whose kind CHECK gains 'trash' and 'edit', and _ACTIONS_GUARDS, a tuple of three indexes and three triggers. Splice them into _TABLES via {actions}, and set SCHEMA_VERSION = 18. (2) Add _migrate_actions(conn) beside _migrate_fts (store.py:3687-3702) and call it last in _add_columns (store.py:3677). It runs in the writer only, before the upward-only version upsert. It detects by structure ("'trash'" in sqlite_master.sql), not by version, which keeps the log-silence tests at test_sign_off.py:214 and test_attachments.py:637 green. In one BEGIN IMMEDIATE transaction it runs conn.execute per statement (never executescript): CREATE actions_v18, INSERT with explicit columns, DROP actions, RENAME, recreate the guards, COMMIT, with ROLLBACK on error. It then logs a counts-only "actions table rebuilt for schema v18". This was proven on a scratch DB this session. (3) Bump the 22 schema_version() == 17 sites and the 5 match="schema v17" sites to 18. Add tests to test_store.py: v17→v18 upgrade keeping rows, ids, triggers and indexes; a v18 store opening in a reader with SCHEMA_VERSION patched to 17; a fresh store with no rebuild. Add trash and edit invalid_argument rows to test_actions.py::test_runner_refuses. No reader of actions.kind changes in this slice; CONV-23 audit is in spec §3.

Files: src/mail_mind_mcp/store.py · tests/test_store.py · tests/test_actions.py · tests/test_attachment_vectors.py · tests/test_attachments.py · tests/test_copy_collapse.py · tests/test_embed_scans.py · tests/test_evidence.py · tests/test_mailbox_search.py · tests/test_peer_changes.py · tests/test_peer_snapshot.py · tests/test_recipients.py · tests/test_sign_off.py · tests/test_utc_dates.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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und **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:** `20261112T060957Z-dca1101f` **Held because:** CLEAN but 5 open risk(s) (2 verification · 3 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Re-slice approval: does the architect approve splitting #192 into this slice (schema v18) and a slice-2 follow-up issue, with #192 left open or re-scoped until slice 2 lands? Slice 2 covers items 2-9: the mail_trash tool and destructive hint, the trash_per_day cap counted by messages, IMAP apply and undo, the mirror effect, the readers, and the JMAP unsupported refusal. It also covers the GreenMail acceptance. Its written set is about 13 files: server.py, config.py, store.py, source.py, actions.py, jmap.py, config.example.toml?, tests/test_write_tools.py, test_actions.py, test_store.py, test_config.py, test_jmap.py and tests/integration/test_greenmail_writes.py. Design note for that spec: item 6 needs the source rows deleted in the same transaction as the action result, but settle() (source.py:136-154) applies and then calls finish_action in a separate transaction. It needs a finish_action variant that deletes the rows and emits the change and peer events in one _tx. [decision] 2. docs/adr/0013-trash-forward-and-draft-edits.md:3 still says 'Status: proposed', and ADR 0004:4 says 'Amended by ADR 0013 (proposed)'. The issue's blocker line reads '#188 (ADR 0013 merged and accepted)'. PR #190 merged at e2327a7, but #188's state was not in the issue-context snapshot. Is ADR 0013 accepted so dispatch may proceed, with the status-line flip left to the docs issue? [decision] 3. The v17-reader test simulates the old reader by patching SCHEMA_VERSION=17 on current code. The reader path runs no DDL, so this is faithful, but it is not the 0.13.0 binary. Post-merge check: copy a v18-upgraded mirror, run the 0.13.0 image's `mailmind api` against it, and call mail_actions. It must list every row, a trash row showing `of=None`, and mail_flag must still queue. [verification] 4. No numeric test baseline was taken: the host checkout has no .venv and the target repo is read-only in Half A. Before the first edit, dispatch must run `make check` and `uv run python3 -m pytest -q` over the 13 listed test files on pristine e2327a7, then assert that after the change only the new tests change state. [verification] 5. README.md:123 and :308 (the 'first start on schema vNN' lists) need a 'schema v18 rebuilds the actions table once' line and a rollback note (a 0.13.0 image runs on the v18 file). The issue assigns README and release notes to the docs issue. Is that line tracked in the epic #187 docs issue? [decision] **Change:** Slice 1 of 2 (re-sliced for the scope ceiling: the v18 bump alone breaks hard-coded version assertions in 12 test files, and the full issue needs about 22 files). Steps: (1) Follow the `_SCHEMA = _TABLES.replace("{fts}", ...)` placeholder pattern at store.py:388. Lift the actions DDL at store.py:176-204 into `_ACTIONS_TABLE`, whose kind CHECK gains 'trash' and 'edit', and `_ACTIONS_GUARDS`, a tuple of three indexes and three triggers. Splice them into `_TABLES` via `{actions}`, and set SCHEMA_VERSION = 18. (2) Add `_migrate_actions(conn)` beside `_migrate_fts` (store.py:3687-3702) and call it last in `_add_columns` (store.py:3677). It runs in the writer only, before the upward-only version upsert. It detects by structure (`"'trash'" in sqlite_master.sql`), not by version, which keeps the log-silence tests at test_sign_off.py:214 and test_attachments.py:637 green. In one BEGIN IMMEDIATE transaction it runs conn.execute per statement (never executescript): CREATE actions_v18, INSERT with explicit columns, DROP actions, RENAME, recreate the guards, COMMIT, with ROLLBACK on error. It then logs a counts-only "actions table rebuilt for schema v18". This was proven on a scratch DB this session. (3) Bump the 22 `schema_version() == 17` sites and the 5 `match="schema v17"` sites to 18. Add tests to test_store.py: v17→v18 upgrade keeping rows, ids, triggers and indexes; a v18 store opening in a reader with SCHEMA_VERSION patched to 17; a fresh store with no rebuild. Add trash and edit `invalid_argument` rows to test_actions.py::test_runner_refuses. No reader of actions.kind changes in this slice; CONV-23 audit is in spec §3. **Files:** `src/mail_mind_mcp/store.py` · `tests/test_store.py` · `tests/test_actions.py` · `tests/test_attachment_vectors.py` · `tests/test_attachments.py` · `tests/test_copy_collapse.py` · `tests/test_embed_scans.py` · `tests/test_evidence.py` · `tests/test_mailbox_search.py` · `tests/test_peer_changes.py` · `tests/test_peer_snapshot.py` · `tests/test_recipients.py` · `tests/test_sign_off.py` · `tests/test_utc_dates.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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md`</sub>
Collaborator

✅ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und

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: 20261112T060957Z-dca1101f

Files: src/mail_mind_mcp/store.py · tests/test_store.py · tests/test_actions.py · tests/test_attachment_vectors.py · tests/test_attachments.py · tests/test_copy_collapse.py · tests/test_embed_scans.py · tests/test_evidence.py · tests/test_mailbox_search.py · tests/test_peer_changes.py · tests/test_peer_snapshot.py · tests/test_recipients.py · tests/test_sign_off.py · tests/test_utc_dates.py

Write-set divergence: present table wins. 0 sourceHashes vs 25-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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md

### ✅ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und **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:** `20261112T060957Z-dca1101f` **Files:** `src/mail_mind_mcp/store.py` · `tests/test_store.py` · `tests/test_actions.py` · `tests/test_attachment_vectors.py` · `tests/test_attachments.py` · `tests/test_copy_collapse.py` · `tests/test_embed_scans.py` · `tests/test_evidence.py` · `tests/test_mailbox_search.py` · `tests/test_peer_changes.py` · `tests/test_peer_snapshot.py` · `tests/test_recipients.py` · `tests/test_sign_off.py` · `tests/test_utc_dates.py` **Write-set divergence:** present table wins. 0 sourceHashes vs 25-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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und completed integration verify.

  • PR: #199
  • Branch: feat/svd-dev-mail-mind-mcp-192-mail-trash-on-imap-tool-trash-fd23ff36
  • Commit: 62702f4858
  • 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/72/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: Woodpecker validation still pending at verdict time; the runner re-polls.
  • Warning: The spec-named test test_a_fresh_store_admits_trash_and_edit exists but the spec's -k fast filter does not select it; the full make check run covers it.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261112T062733Z-fd23ff36 --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/199 - Branch: feat/svd-dev-mail-mind-mcp-192-mail-trash-on-imap-tool-trash-fd23ff36 - Commit: 62702f48584a6214d56b4c35ca6e02f659f298e9 - 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/72/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: Woodpecker validation still pending at verdict time; the runner re-polls. - Warning: The spec-named test test_a_fresh_store_admits_trash_and_edit exists but the spec's -k fast filter does not select it; the full make check run covers it. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261112T062733Z-fd23ff36 --confirm-merge`)
Author
Member

Slice 1 (schema v18) landed in PR #199 as c01ef13. The issue body now describes slice 2: items 2 to 9.

Slice 1 (schema v18) landed in PR #199 as `c01ef13`. The issue body now describes slice 2: items 2 to 9.
Collaborator

⏸ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und

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: 20261112T064946Z-3980a278

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

Open risks:

  1. ADR 0013 still reads 'Status: proposed' (docs/adr/0013…md:3; ADR 0004:4 says 'Amended by ADR 0013 (proposed)'), but the issue's blocker line requires '#188 (ADR 0013 merged and accepted)'. What changed since the prior attempt: the architect dispatched and merged slice 1 (c01ef13) under the same status, and this slice is the first to put a destructive tool (mail_trash) behind a write token. Question: is ADR 0013 accepted, so this slice may ship with the status flip, CLAUDE.md, GLOSSARY and the README upgrade note left to the epic #187 docs issue, or must the status flip land first? [decision]
  2. ADR 0013 §2 says 'Without new UIDs the action is unsupported, since undo would be a guess.' The lean takes new UIDs from COPYUID first. It then falls back to _map_moved's existing search for a Message-ID that matches exactly one message in the examined Trash (the rule mail_move uses today). Only an empty mapping gives refused/unsupported. Question: does a unique Message-ID match count as 'new UIDs'? If it is a 'guess', drop the fallback for trash and require UIDPLUS before moving; otherwise a MOVE-only server would move the mail and then refuse it with no undo. [decision]
  3. The GreenMail tests depend on two facts Half A cannot check (no .venv; imap_blade_mcp is not on the host): (a) the pinned imap-blade-mcp v0.1.2 role_for gives the fixture's plain 'Trash' folder role 'trash', so exactly one is resolved and the default exclude_roles keeps it unmirrored; (b) GreenMail MOVE returns COPYUID, or the Message-ID fallback finds the message. Check in the dispatch worktree: read role_for under .venv/lib/python3.12/site-packages/imap_blade_mcp/. Then run make test-integration and confirm test_trash_then_undo records len(inverse['uids']) == 1 and store.get_mailbox('gm','Trash') is None. If (a) fails, stop and report rather than changing the role rule. [verification]
  4. No numeric test baseline was measured: the host checkout at c01ef13 has no .venv, and Half A is read-only. This differs from the prior attempt because the base moved from e2327a7 to c01ef13. Check: before the first edit on pristine c01ef13, run make check and uv run python3 -m pytest -q -m "not integration" tests/test_actions.py tests/test_store.py tests/test_write_tools.py tests/test_server.py tests/test_config.py tests/test_jmap.py and record the failure set. After the change, assert that only the new or updated tests changed state. [verification]

Change: Slice 2 of #192, on c01ef13 (schema v18 already merged; no schema change). (1) config.py:180-201: add trash_per_day=20 and cap('trash'). (2) store.py:3306-3333 and 3401-3407: one _day_count_sql(kind) helper. For trash it is SUM(json_array_length(params,'$.refs')); otherwise COUNT(*). Enqueue weight is len(refs) for trash and 1 otherwise; refuse when used+weight > cap. (3) store.py:1451-1477: extract the delete_uids body into Store._delete_uid_rows(conn,…), which keeps the DELETE, the changes del row and _emit. Add Store.finish_trash(...), which runs the actions UPDATE plus _delete_uid_rows in ONE _tx and deletes nothing when the action is not queued. Update the peer-writer guard set at test_store.py:840. (4) source.py:136-154: settle routes kind=='trash' with an inverse to _settle_trash. Non-empty uids → applied; empty uids (moved, no new UIDs) → refused/unsupported with the rows still removed in the same transaction. (5) actions.py: split _move_uids (318-344) into _transfer + _map_moved(refresh kwarg). _trash_mailbox resolves exactly one selectable role=='trash' mailbox from session.list_mailboxes(), else unsupported. _trash mirrors _move (291-309), refreshes Trash only when account.wanted() is true, and returns {from, from_uidvalidity, from_uids, to, uidvalidity, uids, message_ids} without deleting rows. _undo_trash examines Trash: a UIDVALIDITY mismatch or no present UIDs → not_found with no change; otherwise _move_uids moves back only the present UIDs. The _undo dispatch (378-386) gets an explicit trash/move/else. (6) server.py: WRITE_DESTRUCTIVE hint; mail_trash following mail_move (1574-1594), refusing a source mailbox with the trash role; _refs dedups by (mailbox, uidvalidity, uid); _outcome adds trashed=N; _action_detail shows counts and mailbox names; mail_undo docstring; WRITE_TOOLS and TOOL_HINTS. (7) jmap.py:487-509: trash → unsupported before any session call, plus an explicit undo fallthrough.

Files: src/mail_mind_mcp/server.py · src/mail_mind_mcp/config.py · src/mail_mind_mcp/store.py · src/mail_mind_mcp/source.py · src/mail_mind_mcp/actions.py · src/mail_mind_mcp/jmap.py · config.example.toml · tests/test_write_tools.py · tests/test_server.py · tests/test_actions.py · tests/test_store.py · tests/test_config.py · tests/test_jmap.py · tests/integration/test_greenmail_writes.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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md

### ⏸ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und **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:** `20261112T064946Z-3980a278` **Held because:** CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. ADR 0013 still reads 'Status: proposed' (docs/adr/0013…md:3; ADR 0004:4 says 'Amended by ADR 0013 (proposed)'), but the issue's blocker line requires '#188 (ADR 0013 merged and accepted)'. What changed since the prior attempt: the architect dispatched and merged slice 1 (c01ef13) under the same status, and this slice is the first to put a destructive tool (mail_trash) behind a write token. Question: is ADR 0013 accepted, so this slice may ship with the status flip, CLAUDE.md, GLOSSARY and the README upgrade note left to the epic #187 docs issue, or must the status flip land first? [decision] 2. ADR 0013 §2 says 'Without new UIDs the action is unsupported, since undo would be a guess.' The lean takes new UIDs from COPYUID first. It then falls back to _map_moved's existing search for a Message-ID that matches exactly one message in the examined Trash (the rule mail_move uses today). Only an empty mapping gives refused/unsupported. Question: does a unique Message-ID match count as 'new UIDs'? If it is a 'guess', drop the fallback for trash and require UIDPLUS before moving; otherwise a MOVE-only server would move the mail and then refuse it with no undo. [decision] 3. The GreenMail tests depend on two facts Half A cannot check (no .venv; imap_blade_mcp is not on the host): (a) the pinned imap-blade-mcp v0.1.2 role_for gives the fixture's plain 'Trash' folder role 'trash', so exactly one is resolved and the default exclude_roles keeps it unmirrored; (b) GreenMail MOVE returns COPYUID, or the Message-ID fallback finds the message. Check in the dispatch worktree: read role_for under .venv/lib/python3.12/site-packages/imap_blade_mcp/. Then run make test-integration and confirm test_trash_then_undo records len(inverse['uids']) == 1 and store.get_mailbox('gm','Trash') is None. If (a) fails, stop and report rather than changing the role rule. [verification] 4. No numeric test baseline was measured: the host checkout at c01ef13 has no .venv, and Half A is read-only. This differs from the prior attempt because the base moved from e2327a7 to c01ef13. Check: before the first edit on pristine c01ef13, run make check and uv run python3 -m pytest -q -m "not integration" tests/test_actions.py tests/test_store.py tests/test_write_tools.py tests/test_server.py tests/test_config.py tests/test_jmap.py and record the failure set. After the change, assert that only the new or updated tests changed state. [verification] **Change:** Slice 2 of #192, on c01ef13 (schema v18 already merged; no schema change). (1) config.py:180-201: add trash_per_day=20 and cap('trash'). (2) store.py:3306-3333 and 3401-3407: one _day_count_sql(kind) helper. For trash it is SUM(json_array_length(params,'$.refs')); otherwise COUNT(*). Enqueue weight is len(refs) for trash and 1 otherwise; refuse when used+weight > cap. (3) store.py:1451-1477: extract the delete_uids body into Store._delete_uid_rows(conn,…), which keeps the DELETE, the changes del row and _emit. Add Store.finish_trash(...), which runs the actions UPDATE plus _delete_uid_rows in ONE _tx and deletes nothing when the action is not queued. Update the peer-writer guard set at test_store.py:840. (4) source.py:136-154: settle routes kind=='trash' with an inverse to _settle_trash. Non-empty uids → applied; empty uids (moved, no new UIDs) → refused/unsupported with the rows still removed in the same transaction. (5) actions.py: split _move_uids (318-344) into _transfer + _map_moved(refresh kwarg). _trash_mailbox resolves exactly one selectable role=='trash' mailbox from session.list_mailboxes(), else unsupported. _trash mirrors _move (291-309), refreshes Trash only when account.wanted() is true, and returns {from, from_uidvalidity, from_uids, to, uidvalidity, uids, message_ids} without deleting rows. _undo_trash examines Trash: a UIDVALIDITY mismatch or no present UIDs → not_found with no change; otherwise _move_uids moves back only the present UIDs. The _undo dispatch (378-386) gets an explicit trash/move/else. (6) server.py: WRITE_DESTRUCTIVE hint; mail_trash following mail_move (1574-1594), refusing a source mailbox with the trash role; _refs dedups by (mailbox, uidvalidity, uid); _outcome adds trashed=N; _action_detail shows counts and mailbox names; mail_undo docstring; WRITE_TOOLS and TOOL_HINTS. (7) jmap.py:487-509: trash → unsupported before any session call, plus an explicit undo fallthrough. **Files:** `src/mail_mind_mcp/server.py` · `src/mail_mind_mcp/config.py` · `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/source.py` · `src/mail_mind_mcp/actions.py` · `src/mail_mind_mcp/jmap.py` · `config.example.toml` · `tests/test_write_tools.py` · `tests/test_server.py` · `tests/test_actions.py` · `tests/test_store.py` · `tests/test_config.py` · `tests/test_jmap.py` · `tests/integration/test_greenmail_writes.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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md`</sub>
Collaborator

✅ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und

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: 20261112T064946Z-3980a278

Files: src/mail_mind_mcp/server.py · src/mail_mind_mcp/config.py · src/mail_mind_mcp/store.py · src/mail_mind_mcp/source.py · src/mail_mind_mcp/actions.py · src/mail_mind_mcp/jmap.py · config.example.toml · tests/test_write_tools.py · tests/test_server.py · tests/test_actions.py · tests/test_store.py · tests/test_config.py · tests/test_jmap.py · tests/integration/test_greenmail_writes.py

Write-set divergence: present table wins. 0 sourceHashes vs 23-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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md

### ✅ SVD architect gate: dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und **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:** `20261112T064946Z-3980a278` **Files:** `src/mail_mind_mcp/server.py` · `src/mail_mind_mcp/config.py` · `src/mail_mind_mcp/store.py` · `src/mail_mind_mcp/source.py` · `src/mail_mind_mcp/actions.py` · `src/mail_mind_mcp/jmap.py` · `config.example.toml` · `tests/test_write_tools.py` · `tests/test_server.py` · `tests/test_actions.py` · `tests/test_store.py` · `tests/test_config.py` · `tests/test_jmap.py` · `tests/integration/test_greenmail_writes.py` **Write-set divergence:** present table wins. 0 sourceHashes vs 23-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-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und-slice-2.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und completed integration verify.

  • PR: #200
  • Branch: feat/svd-dev-mail-mind-mcp-192-mail-trash-on-imap-tool-trash-4b95e9c6
  • Commit: 2e6a4bb89f
  • 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/76/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: GreenMail integration tests (test_trash_then_undo, test_http_trash_and_undo_through_the_running_worker) were not run: Podman daemon unreachable. Both collect. Spec Open Risk 3 (role_for assigns trash to plain Trash; GreenMail UIDPLUS/COPYUID) stays unverified live; run make test-integration on the host.
  • Warning: Full suite emitted non-failing MCP session shutdown logging errors against closed capture streams.
  • Warning: self-review items were fixed per the deviations list; none left unfixed.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261112T071823Z-4b95e9c6 --confirm-merge)
spec-verify-dispatch Half B for dev/mail-mind-mcp#192 mail-trash-on-imap-tool-trash-action-kind-schema-v18-cap-und completed integration verify. - PR: https://git.groupthink.asia/dev/mail-mind-mcp/pulls/200 - Branch: feat/svd-dev-mail-mind-mcp-192-mail-trash-on-imap-tool-trash-4b95e9c6 - Commit: 2e6a4bb89f0c6f556ff8ad2c6f8d890475376dcd - 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/76/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: GreenMail integration tests (test_trash_then_undo, test_http_trash_and_undo_through_the_running_worker) were not run: Podman daemon unreachable. Both collect. Spec Open Risk 3 (role_for assigns trash to plain Trash; GreenMail UIDPLUS/COPYUID) stays unverified live; run make test-integration on the host. - Warning: Full suite emitted non-failing MCP session shutdown logging errors against closed capture streams. - Warning: self-review items were fixed per the deviations list; none left unfixed. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261112T071823Z-4b95e9c6 --confirm-merge`)
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#192
No description provided.