Implement durable Mail peer changes and snapshot handoff #152

Closed
opened 2026-11-03 00:19:16 +00:00 by svc-agent-writer · 2 comments

Outcome

Implement durable direct Mail peer changes and snapshot handoff under the approved shared mind contract. Existing text feeds remain compatible; direct deployments need no broker or Kubernetes.

Decision substrate

Operator-approved ADR 0010 and the versioned contract kit at 21e279da85eab618ef8c76bc8211daaa23e0ca52 (contracts/mind-v1/). ADR 0008 continues to bound evidence disclosure. The contract is an implementation target; its wire tests alone do not prove runtime recovery.

Scope and acceptance criteria

  1. Implement mail_peer_info, mail_peer_changes_v1 and mail_peer_snapshot_v1 with exact negotiated schemas and evidence auth. Advertise only implemented/tested operations. Add the corresponding ADR 0008 tool-list amendment without widening payload authority.
  2. Commit domain change and immutable authorised event/envelope atomically at every relevant Store mutation path (IMAP and stable-id sources). Do not reconstruct old add envelopes from mutable message rows. Preserve event identities on retry; reject corrupt conflicting repeats. Inventory all writers/readers in the spec.
  3. Migrate existing installations into a consistent current reference projection and explicit v1 history boundary; do not invent missing historical envelopes. Preserve the structured-query source identity rules; explicitly change epoch if continuity cannot be proved. Never let old cursors cross epochs/scopes or silently reset to now.
  4. Implement bounded retention/cursor floors, stable snapshots at H, lease expiry/reauthorization and a gap-free snapshot-to-feed handoff. Page retries must be consistent under concurrent inserts/moves/deletes. Large snapshots must not block interactive service with an unbounded transaction or unbounded in-memory list.
  5. Preserve the existing single-writer service topology; design snapshot preparation and API access explicitly. No API mirror writes or new cross-mind database access. Use scoped references/envelopes only; no bodies, signatures or subjects in the feed.
  6. Pass wire/exchange conformance plus P01–P09 recovery cases, including real writer termination, rollback/restore discontinuity, add-then-delete-before-read, scope revocation and concurrent snapshot mutation. Record I02 latency/resource budgets before the run. All applicable existing tests and make check pass.

Non-goals

People consumer changes, release/deploy, broker transport, fabric mapping, calendar/attention implementation and any widening of evidence authority. Future bus work must derive from canonical dev/fabric-spec only when fan-out/workload justifies it.

Blocked by

Sub-issues

Split in the grill of 2026-11-03 (ADR 0012, #162). Each unit is dispatched after the previous one merges. This epic closes when all three are merged and P01–P09 pass.

  1. dev/mail-mind-mcp#159 — event log, projection, v16 migration, epoch continuity, retention (P01–P04, P05 writer half).
  2. dev/mail-mind-mcp#160 — mail_peer_info and mail_peer_changes_v1 (P05 reader half, P08, P09).
    2a. dev/mail-mind-mcp#167 — cut the feed's per-call cost to meet the I02 search budget (added at the #160 gate); blocks #161.
  3. dev/mail-mind-mcp#161 — mail_peer_snapshot_v1 and the feed handoff (P06, P07).
## Outcome Implement durable direct Mail peer changes and snapshot handoff under the approved shared mind contract. Existing text feeds remain compatible; direct deployments need no broker or Kubernetes. ## Decision substrate Operator-approved ADR 0010 and the versioned contract kit at `21e279da85eab618ef8c76bc8211daaa23e0ca52` (`contracts/mind-v1/`). ADR 0008 continues to bound evidence disclosure. The contract is an implementation target; its wire tests alone do not prove runtime recovery. ## Scope and acceptance criteria 1. Implement `mail_peer_info`, `mail_peer_changes_v1` and `mail_peer_snapshot_v1` with exact negotiated schemas and evidence auth. Advertise only implemented/tested operations. Add the corresponding ADR 0008 tool-list amendment without widening payload authority. 2. Commit domain change and immutable authorised event/envelope atomically at every relevant Store mutation path (IMAP and stable-id sources). Do not reconstruct old add envelopes from mutable message rows. Preserve event identities on retry; reject corrupt conflicting repeats. Inventory all writers/readers in the spec. 3. Migrate existing installations into a consistent current reference projection and explicit v1 history boundary; do not invent missing historical envelopes. Preserve the structured-query source identity rules; explicitly change epoch if continuity cannot be proved. Never let old cursors cross epochs/scopes or silently reset to now. 4. Implement bounded retention/cursor floors, stable snapshots at H, lease expiry/reauthorization and a gap-free snapshot-to-feed handoff. Page retries must be consistent under concurrent inserts/moves/deletes. Large snapshots must not block interactive service with an unbounded transaction or unbounded in-memory list. 5. Preserve the existing single-writer service topology; design snapshot preparation and API access explicitly. No API mirror writes or new cross-mind database access. Use scoped references/envelopes only; no bodies, signatures or subjects in the feed. 6. Pass wire/exchange conformance plus P01–P09 recovery cases, including real writer termination, rollback/restore discontinuity, add-then-delete-before-read, scope revocation and concurrent snapshot mutation. Record I02 latency/resource budgets before the run. All applicable existing tests and `make check` pass. ## Non-goals People consumer changes, release/deploy, broker transport, fabric mapping, calendar/attention implementation and any widening of evidence authority. Future bus work must derive from canonical dev/fabric-spec only when fan-out/workload justifies it. ## Blocked by - dev/mail-mind-mcp#151 — source identity and structured evidence query baseline. ## Sub-issues Split in the grill of 2026-11-03 (ADR 0012, #162). Each unit is dispatched after the previous one merges. This epic closes when all three are merged and P01–P09 pass. 1. dev/mail-mind-mcp#159 — event log, projection, v16 migration, epoch continuity, retention (P01–P04, P05 writer half). 2. dev/mail-mind-mcp#160 — `mail_peer_info` and `mail_peer_changes_v1` (P05 reader half, P08, P09). 2a. dev/mail-mind-mcp#167 — cut the feed's per-call cost to meet the I02 search budget (added at the #160 gate); blocks #161. 3. dev/mail-mind-mcp#161 — `mail_peer_snapshot_v1` and the feed handoff (P06, P07).
Author
Member

Grill record (2026-11-03, operator accepted)

The grill replaced SVD for #152, because it implements a substrate contract (CONV-40). ADR 0012 (#162) records every ruling in full.

# Question Ruling
Q1 One unit or split Three units: #159, #160, #161
Q2 Event log storage A separate peer_events table with AUTOINCREMENT; changes and mail_changes unchanged
Q3 Snapshot at H Reconstructed read-only from peer_entities plus each event's previous revision; no copy, no API write
Q4 Continuity (P04) Marker {source_id, epoch, max_seq} after each emitting commit; a missing marker or a database behind it means a new epoch; source_id kept; clones go through mailmind peer new-identity
Q5 scope_id A salted hash of source, epoch, contract and account selection; a change to the configured accounts means a new scope
Q6 Retention and lease 604,800 s and 3,600 s, in a [peer] config section; floor recorded before trimming
Q7 Cursors HMAC-SHA256; key in meta, replaced with the epoch
Q8 Migration v16 in one transaction at the first writer start; keeps #151's identity and epoch
Q9 Emission Store._emit beside every changes insert, plus a guard test
Q10 I02 budgets health p99 ≤ 100 ms; mail_search p95 ≤ +25 %; page p99 ≤ 250 ms; RSS growth ≤ 64 MiB
Q11 Tracking #152 becomes an epic; People #47 is blocked by #161
Q12 Record ADR 0012, landed first as a docs-only PR
Q13 Epoch rotation Rebuild: delete the events, rebuild the projection, write a new epoch, key and marker
Q14 Marker write failure Fail closed
Q15 Tool rollout #159 adds no tools; #160 adds info and changes; #161 adds snapshot; each amends ADR 0008
Q16 Route SVD one unit at a time, each after its predecessor merges

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

## Grill record (2026-11-03, operator accepted) The grill replaced SVD for #152, because it implements a substrate contract (CONV-40). ADR 0012 (#162) records every ruling in full. | # | Question | Ruling | | --- | --- | --- | | Q1 | One unit or split | Three units: #159, #160, #161 | | Q2 | Event log storage | A separate `peer_events` table with AUTOINCREMENT; `changes` and `mail_changes` unchanged | | Q3 | Snapshot at H | Reconstructed read-only from `peer_entities` plus each event's previous revision; no copy, no API write | | Q4 | Continuity (P04) | Marker `{source_id, epoch, max_seq}` after each emitting commit; a missing marker or a database behind it means a new epoch; `source_id` kept; clones go through `mailmind peer new-identity` | | Q5 | `scope_id` | A salted hash of source, epoch, contract and account selection; a change to the configured accounts means a new scope | | Q6 | Retention and lease | 604,800 s and 3,600 s, in a `[peer]` config section; floor recorded before trimming | | Q7 | Cursors | HMAC-SHA256; key in `meta`, replaced with the epoch | | Q8 | Migration | v16 in one transaction at the first writer start; keeps #151's identity and epoch | | Q9 | Emission | `Store._emit` beside every `changes` insert, plus a guard test | | Q10 | I02 budgets | health p99 ≤ 100 ms; `mail_search` p95 ≤ +25 %; page p99 ≤ 250 ms; RSS growth ≤ 64 MiB | | Q11 | Tracking | #152 becomes an epic; People #47 is blocked by #161 | | Q12 | Record | ADR 0012, landed first as a docs-only PR | | Q13 | Epoch rotation | Rebuild: delete the events, rebuild the projection, write a new epoch, key and marker | | Q14 | Marker write failure | Fail closed | | Q15 | Tool rollout | #159 adds no tools; #160 adds `info` and `changes`; #161 adds `snapshot`; each amends ADR 0008 | | Q16 | Route | SVD one unit at a time, each after its predecessor merges | Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Member

Closing. All units are merged:

The P01–P09 cases are in the merged test suites. I02 passes every ADR 0012 rule 14 budget at cc56ba7 (three voyager runs, recorded in ADR 0008): feed, snapshot, health, search and RSS. dev/people-mind-mcp#47, which #161 blocked, is closed.

Closing. All units are merged: - #159 in #163, with the ADR 0012 amendment in #164 - #160 in #166 - #167 in #168 - #161 in #169, released in 0.11.0 (#170) The P01–P09 cases are in the merged test suites. I02 passes every ADR 0012 rule 14 budget at `cc56ba7` (three voyager runs, recorded in ADR 0008): feed, snapshot, health, search and RSS. dev/people-mind-mcp#47, which #161 blocked, is closed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#152
No description provided.