Copy triage and vectors across accounts by the #59 collapse key #86

Closed
opened 2026-11-01 03:29:26 +00:00 by svc-agent-writer · 3 comments

Split from #59 (item 4 of its triage rulings, 2026-11-01).

Filed under: operator word "accept four leanings on #59" sha256:c22f5f83e0ab

The assessor and the embedder copy a result to a row with the same Message-ID inside one account, so Jev is not asked twice and the model does not run twice. A copy in a second account of the same instance is assessed and embedded again: one Jev call and one model run per extra account.

Proposal

  • Copy the triage class and score, and the vector, from any account's row with the same collapse key that #59 defines: Message-ID, From and Date all equal, all present. A row without one of them is never a copy.
  • No consent check is needed. ADR 0003 §8 records consent per instance, and an instance is one owner (README, "One instance per person"). Every account in an instance has the same owner.
  • The copy runs where the same-account copy runs today, in the sync process. The api writes nothing new.

Acceptance

  • A message assessed in account A and mirrored later in account B gets A's class and score with no Jev call.
  • The same holds for the vector: no model run.
  • Same Message-ID with a different From or Date: assessed and embedded on its own.
  • The Jev request count in the logs drops by one per copy; logs carry counts only.

Blocked by

  • #59 (the collapse key)
Split from #59 (item 4 of its triage rulings, 2026-11-01). Filed under: operator word "accept four leanings on #59" sha256:c22f5f83e0ab The assessor and the embedder copy a result to a row with the same Message-ID inside one account, so Jev is not asked twice and the model does not run twice. A copy in a second account of the same instance is assessed and embedded again: one Jev call and one model run per extra account. ## Proposal - Copy the triage class and score, and the vector, from any account's row with the same collapse key that #59 defines: Message-ID, From and Date all equal, all present. A row without one of them is never a copy. - No consent check is needed. ADR 0003 §8 records consent per instance, and an instance is one owner (README, "One instance per person"). Every account in an instance has the same owner. - The copy runs where the same-account copy runs today, in the sync process. The api writes nothing new. ## Acceptance - A message assessed in account A and mirrored later in account B gets A's class and score with no Jev call. - The same holds for the vector: no model run. - Same Message-ID with a different From or Date: assessed and embedded on its own. - The Jev request count in the logs drops by one per copy; logs carry counts only. ## Blocked by - #59 (the collapse key)
Author
Member

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: Copy the triage result, the vector and the attachment text to every copy of a message, in any account, by the #59 collapse key, and by that key only.

Blocked by: #59. It defines the collapse key. Build on its single definition; do not write a second one.

Operator rulings (2026-11-01). Where this brief differs from the issue body, the brief holds.

  1. The attachment-text copy is in scope. All three copy paths move to the collapse key: triage, vectors and attachment text.
  2. The same-account copy tightens too. Today each copy path matches on Message-ID alone, and the sender controls that header. After this issue, no path copies on Message-ID alone, inside one account or across accounts.

Already decided, so no work is needed:

  • A consent check across accounts. ADR 0003 §8 records consent per instance, and an instance is one owner (README, "One instance per person").
  • A wake for a copied class. A copied class never raises a wake today: only Jev answers go to the wake rule. Keep it so.

Current behavior:

  • Store.copy_assessments(account) gives an unassessed row the class and score of an assessed row with the same Message-ID in the same account.
  • Store.copy_embeddings(account, model=...) gives a row with no vector the vector of a row with the same Message-ID in the same account.
  • The attachment-text copy gives a row the stored attachment text of a row in the same account with the same Message-ID and the same attachment count.
  • A copy in a second account is assessed, embedded and parsed again: one Jev call, one model run and one child-process parse per attachment, per extra account.

Desired behavior:

  • Each copy path takes its source from any row, in any account, with the same collapse key: Message-ID, From and Date header, all equal and all present.
  • The attachment-text path keeps its own extra condition, the same attachment count, on top of the key.
  • A row without a Message-ID, a From or a Date is never a copy source and never a copy target.
  • Same Message-ID with a different From or a different Date: no copy. The row is assessed, embedded and parsed on its own.
  • When several sources exist, the choice is deterministic, as today: the lowest row id.
  • The copies run where they run today, in the sync process. The api process writes nothing new.
  • Dates compare as stored. Both sources store the Date header with its offset. A server that rewrites the date to UTC misses a copy, and a miss only costs one extra call: never relax the key to catch it.

Key interfaces:

  • Store.copy_assessments, Store.copy_embeddings and the attachment-text copy: the match changes from Message-ID in one account to the collapse key in any account. The account argument names the rows that receive a copy, not the rows that give one.
  • The assessor and the embedder call these as today, once per account per tick.

Acceptance criteria:

  • A message assessed in account A and mirrored later in account B gets A's class and score, with no Jev call for B's row.
  • The same holds for the vector: no model run for B's row.
  • The same holds for attachment text: no child-process parse for B's attachments.
  • Same Message-ID, different From: no copy on any path, in one account or across accounts.
  • Same Message-ID, different Date: no copy on any path.
  • A row with no Message-ID gets no copy and gives none.
  • A copied class raises no wake.
  • Copy counts in the logs are counts only. No address, subject or Message-ID is logged.
  • The existing copy tests for one account pass. Change only those that rely on a Message-ID match with a different From or Date.

Out of scope:

  • The display collapse in the read tools (#59).
  • Any new column or table.
  • Fuzzy matching: a resent message with a new Message-ID stays two messages.
  • Any change to what is sent to Jev or how a vector is computed.
> *This was generated by AI during triage.* ## Agent Brief **Category:** enhancement **Summary:** Copy the triage result, the vector and the attachment text to every copy of a message, in any account, by the #59 collapse key, and by that key only. **Blocked by:** #59. It defines the collapse key. Build on its single definition; do not write a second one. **Operator rulings (2026-11-01).** Where this brief differs from the issue body, the brief holds. 1. **The attachment-text copy is in scope.** All three copy paths move to the collapse key: triage, vectors and attachment text. 2. **The same-account copy tightens too.** Today each copy path matches on Message-ID alone, and the sender controls that header. After this issue, no path copies on Message-ID alone, inside one account or across accounts. **Already decided, so no work is needed:** - A consent check across accounts. ADR 0003 §8 records consent per instance, and an instance is one owner (README, "One instance per person"). - A wake for a copied class. A copied class never raises a wake today: only Jev answers go to the wake rule. Keep it so. **Current behavior:** - `Store.copy_assessments(account)` gives an unassessed row the class and score of an assessed row with the same Message-ID in the same account. - `Store.copy_embeddings(account, model=...)` gives a row with no vector the vector of a row with the same Message-ID in the same account. - The attachment-text copy gives a row the stored attachment text of a row in the same account with the same Message-ID and the same attachment count. - A copy in a second account is assessed, embedded and parsed again: one Jev call, one model run and one child-process parse per attachment, per extra account. **Desired behavior:** - Each copy path takes its source from any row, in any account, with the same collapse key: Message-ID, From and Date header, all equal and all present. - The attachment-text path keeps its own extra condition, the same attachment count, on top of the key. - A row without a Message-ID, a From or a Date is never a copy source and never a copy target. - Same Message-ID with a different From or a different Date: no copy. The row is assessed, embedded and parsed on its own. - When several sources exist, the choice is deterministic, as today: the lowest row id. - The copies run where they run today, in the sync process. The `api` process writes nothing new. - Dates compare as stored. Both sources store the Date header with its offset. A server that rewrites the date to UTC misses a copy, and a miss only costs one extra call: never relax the key to catch it. **Key interfaces:** - `Store.copy_assessments`, `Store.copy_embeddings` and the attachment-text copy: the match changes from Message-ID in one account to the collapse key in any account. The `account` argument names the rows that receive a copy, not the rows that give one. - The assessor and the embedder call these as today, once per account per tick. **Acceptance criteria:** - [ ] A message assessed in account A and mirrored later in account B gets A's class and score, with no Jev call for B's row. - [ ] The same holds for the vector: no model run for B's row. - [ ] The same holds for attachment text: no child-process parse for B's attachments. - [ ] Same Message-ID, different From: no copy on any path, in one account or across accounts. - [ ] Same Message-ID, different Date: no copy on any path. - [ ] A row with no Message-ID gets no copy and gives none. - [ ] A copied class raises no wake. - [ ] Copy counts in the logs are counts only. No address, subject or Message-ID is logged. - [ ] The existing copy tests for one account pass. Change only those that rely on a Message-ID match with a different From or Date. **Out of scope:** - The display collapse in the read tools (#59). - Any new column or table. - Fuzzy matching: a resent message with a new Message-ID stays two messages. - Any change to what is sent to Jev or how a vector is computed.
Collaborator

⏸ SVD architect gate: dev/imap-mailmind-mcp#86 copy-triage-and-vectors-across-accounts-by-the-59-collapse-k

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: 20261101T074016Z-c97d10e9

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

Open risks:

  1. Date comparison: should it be by instant (#59's key) or as stored (the brief)? The brief says 'Dates compare as stored ... never relax the key' and also 'build on its single definition; do not write a second one'. #59's merged _same_message (store.py:352-359) compares datetime(date) instants; the #59 gate accepted that, and tests/test_copies.py pins it with DATE/UTC_DATE. Lean: reuse _same_message as it stands, so a UTC-rewriting server still gets the copy (one fewer call), and pin this with test 6. The alternative is a second, stricter key for copy paths only. Which does the architect want? [decision]
  2. Per-tick cost of the cross-account probes. Check: on a synthetic writer store of 100k messages in one account with about 5% copied into a second account, time copy_assessments(acct) and copy_embeddings(acct, model=MODEL_NAME) with nothing to copy, 5 runs each, before and after the change; report the medians in the PR. Stop if either median passes 250 ms. EXPLAIN QUERY PLAN should show messages_copies (or an autoindex) for the s probe, not a full scan. [verification]
  3. IMAP->JMAP switch on a real server. Check: after merge, run make test-stalwart; tests/integration/test_stalwart.py::test_a_switch_from_imap_keeps_the_class must pass unchanged. This proves the IMAP Date header and the JMAP sentAt give the same datetime() instant and the Froms match, so the tightened _finish_switch still keeps classes. It needs the Stalwart container, so it cannot run in a worktree. [verification]
  4. No unit-test baseline was measured in Half A (the target is read-only and no tests ran). Check: on af0898c, before the first edit, run make check and record the failure set. After the change, the set must be identical, the only new tests are in tests/test_cross_account_copies.py, and the only edited tests are the three named in the lean. [verification]

Change: Reuse #59's collapse-key fragment _same_message(row, copy) (store.py:352-359) verbatim in all four Message-ID-only copy paths, with the target in the row slot and the source in the copy slot. The paths are copy_assessments (store.py:791-803; keep the IN prefilter minus account, add an EXISTS key test, ORDER BY s.id LIMIT 1), copy_embeddings (store.py:828-841; only the JOIN clause changes, MIN(e.vec) stays), copy_attachment_texts (store.py:869-886; keep s.attachments = m.attachments and MIN(s.id)), and _adopt_attachment_text (store.py:676-690; self-join on the inserted target row t). Remove the account restriction on the source side only; account still names the receiving rows. Mirror #59's f-string-plus-fragment SQL style with noqa S608 (store.py:1288/1337/1422). Callers (assess.py:245, embed.py:135/147, source.py:233, jmap.py:638-639) are unchanged. Update only the jmap._finish_switch docstring. Amend four ADR sentences (0003:17, 0005:29, 0006:13/28, 0007:62) in the house 'Amended (#86):' form. Add tests/test_cross_account_copies.py reusing the test_copies, test_assess, test_embed and test_attachments helpers. Fix the three existing tests whose 'moved copy' differs in Date or From (test_attachments x2, test_jmap switch).

Files: src/imap_mailmind_mcp/store.py · src/imap_mailmind_mcp/jmap.py · tests/test_cross_account_copies.py · tests/test_attachments.py · tests/test_jmap.py · docs/adr/0003-data-boundaries-for-external-judgement.md · docs/adr/0005-local-embeddings.md · docs/adr/0006-pluggable-mail-sources.md · docs/adr/0007-attachment-text.md

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-01-copy-triage-and-vectors-across-accounts-by-the-59-collapse-k.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-01-copy-triage-and-vectors-across-accounts-by-the-59-collapse-k.md

### ⏸ SVD architect gate: dev/imap-mailmind-mcp#86 copy-triage-and-vectors-across-accounts-by-the-59-collapse-k **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:** `20261101T074016Z-c97d10e9` **Held because:** CLEAN but 4 open risk(s) (3 verification · 1 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Date comparison: should it be by instant (#59's key) or as stored (the brief)? The brief says 'Dates compare as stored ... never relax the key' and also 'build on its single definition; do not write a second one'. #59's merged _same_message (store.py:352-359) compares datetime(date) instants; the #59 gate accepted that, and tests/test_copies.py pins it with DATE/UTC_DATE. Lean: reuse _same_message as it stands, so a UTC-rewriting server still gets the copy (one fewer call), and pin this with test 6. The alternative is a second, stricter key for copy paths only. Which does the architect want? [decision] 2. Per-tick cost of the cross-account probes. Check: on a synthetic writer store of 100k messages in one account with about 5% copied into a second account, time copy_assessments(acct) and copy_embeddings(acct, model=MODEL_NAME) with nothing to copy, 5 runs each, before and after the change; report the medians in the PR. Stop if either median passes 250 ms. EXPLAIN QUERY PLAN should show messages_copies (or an autoindex) for the s probe, not a full scan. [verification] 3. IMAP->JMAP switch on a real server. Check: after merge, run `make test-stalwart`; tests/integration/test_stalwart.py::test_a_switch_from_imap_keeps_the_class must pass unchanged. This proves the IMAP Date header and the JMAP sentAt give the same datetime() instant and the Froms match, so the tightened _finish_switch still keeps classes. It needs the Stalwart container, so it cannot run in a worktree. [verification] 4. No unit-test baseline was measured in Half A (the target is read-only and no tests ran). Check: on af0898c, before the first edit, run `make check` and record the failure set. After the change, the set must be identical, the only new tests are in tests/test_cross_account_copies.py, and the only edited tests are the three named in the lean. [verification] **Change:** Reuse #59's collapse-key fragment _same_message(row, copy) (store.py:352-359) verbatim in all four Message-ID-only copy paths, with the target in the row slot and the source in the copy slot. The paths are copy_assessments (store.py:791-803; keep the IN prefilter minus account, add an EXISTS key test, ORDER BY s.id LIMIT 1), copy_embeddings (store.py:828-841; only the JOIN clause changes, MIN(e.vec) stays), copy_attachment_texts (store.py:869-886; keep s.attachments = m.attachments and MIN(s.id)), and _adopt_attachment_text (store.py:676-690; self-join on the inserted target row t). Remove the account restriction on the source side only; `account` still names the receiving rows. Mirror #59's f-string-plus-fragment SQL style with noqa S608 (store.py:1288/1337/1422). Callers (assess.py:245, embed.py:135/147, source.py:233, jmap.py:638-639) are unchanged. Update only the jmap._finish_switch docstring. Amend four ADR sentences (0003:17, 0005:29, 0006:13/28, 0007:62) in the house 'Amended <date> (#86):' form. Add tests/test_cross_account_copies.py reusing the test_copies, test_assess, test_embed and test_attachments helpers. Fix the three existing tests whose 'moved copy' differs in Date or From (test_attachments x2, test_jmap switch). **Files:** `src/imap_mailmind_mcp/store.py` · `src/imap_mailmind_mcp/jmap.py` · `tests/test_cross_account_copies.py` · `tests/test_attachments.py` · `tests/test_jmap.py` · `docs/adr/0003-data-boundaries-for-external-judgement.md` · `docs/adr/0005-local-embeddings.md` · `docs/adr/0006-pluggable-mail-sources.md` · `docs/adr/0007-attachment-text.md` **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-01-copy-triage-and-vectors-across-accounts-by-the-59-collapse-k.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-01-copy-triage-and-vectors-across-accounts-by-the-59-collapse-k.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/imap-mailmind-mcp#86 copy-triage-and-vectors-across-accounts-by-the-59-collapse-k completed integration verify.

  • PR: dev/imap-mailmind-mcp#94
  • Branch: feat/svd-dev-imap-mailmind-mcp-86-copy-triage-and-vectors-acr-4ed83bcd
  • Commit: ba5a5a16ee
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check forgejo commit statuses on PR head: absent
  • Checks: PR #94 is open and mergeable at ba5a5a1. The PR head has no remote CI statuses. Local make check passed: 351 passed, 4 skipped. The focused suite passed: 160 passed, 3 skipped.
  • Warning: self-review: ADR 0006 Consequences still promises no Jev calls or embedding for every source switch -> not fixed: outside the specified amendment locations; amended §1 states the key requirement.
  • Warning: Stalwart integration test (Open Risk 3, JMAP switch with the Date/sentAt and From match) is deferred to the architect at integrate (R6). It did not run here.
  • Warning: No remote CI statuses exist on the PR head: the repo has no .woodpecker CI files.
  • Warning: Behaviour tightening: a moved IMAP copy with a missing or unparseable Date is now assessed and embedded again, at the cost of one Jev call. The operator accepted this.
  • Warning: no CI for forgejo commit statuses on PR head: The PR head ba5a5a1 has no commit statuses on git.groupthink.asia. The CLAUDE.md states the architect adds .woodpecker CI files, and none exist in the tree. — reported as absent, not blocking (gh#633)
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261101T075025Z-4ed83bcd --confirm-merge)
spec-verify-dispatch Half B for dev/imap-mailmind-mcp#86 copy-triage-and-vectors-across-accounts-by-the-59-collapse-k completed integration verify. - PR: https://git.groupthink.asia/dev/imap-mailmind-mcp/pulls/94 - Branch: feat/svd-dev-imap-mailmind-mcp-86-copy-triage-and-vectors-acr-4ed83bcd - Commit: ba5a5a16ee7e19dd689c47aa4268f56b4ef45f22 - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check forgejo commit statuses on PR head: absent - Checks: PR #94 is open and mergeable at ba5a5a1. The PR head has no remote CI statuses. Local make check passed: 351 passed, 4 skipped. The focused suite passed: 160 passed, 3 skipped. - Warning: self-review: ADR 0006 Consequences still promises no Jev calls or embedding for every source switch -> not fixed: outside the specified amendment locations; amended §1 states the key requirement. - Warning: Stalwart integration test (Open Risk 3, JMAP switch with the Date/sentAt and From match) is deferred to the architect at integrate (R6). It did not run here. - Warning: No remote CI statuses exist on the PR head: the repo has no .woodpecker CI files. - Warning: Behaviour tightening: a moved IMAP copy with a missing or unparseable Date is now assessed and embedded again, at the cost of one Jev call. The operator accepted this. - Warning: no CI for forgejo commit statuses on PR head: The PR head ba5a5a1 has no commit statuses on git.groupthink.asia. The CLAUDE.md states the architect adds .woodpecker CI files, and none exist in the tree. — reported as absent, not blocking (gh#633) - Decision: review the PR and merge? (`codex-svd ship --run-id 20261101T075025Z-4ed83bcd --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#86
No description provided.