Serve the Mail peer snapshot and its feed handoff #161
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Outcome
A new peer can bootstrap from a consistent snapshot of Mail at watermark H and continue on the feed with no gap. Unit 3 of the epic #152; it completes the Mail provider claims P01–P09.
Decision substrate
ADR 0012 (rules 5, 10, 11, 13, 14), ADR 0010, the contract kit
contracts/mind-v1/(README "Snapshot and handoff",schema.json, fixtures,recovery.md), and ADR 0008. The grill record is on #152.Scope and acceptance criteria
mail_peer_snapshot_v1with the exact negotiated schemas, evidence scope and the existing rate-limit bucket. The first call (snapshot_cursor: null) captures H and returnssnapshot_id,snapshot_at,through=H,expires_at(snapshot_atplussnapshot_lease_seconds),complete,next_snapshot_cursorandresume_cursor.entity_idunder BINARY collation. Rows carry identity, revision at H, mutation time and envelope; no row has a revision above H.complete=true,next_snapshot_cursor=nulland a feedresume_cursorimmediately after H; an empty snapshot is an explicit final page. Page retries are byte-identical. An expired lease returnssnapshot_expired; every page is reauthorised; a cursor from another scope returnsinvalid_cursor.mail_peer_infoadvertisessnapshotonly after the cases below pass. ADR 0008 tool-list amendment.resume_cursor) and P07 (lease expiry and token revocation mid-pagination; no further rows). Check the ADR 0012 assumption that anentity_idis never reused after deletion, for IMAP and JMAP ids.mail_peer_evidence_v1's watermarkthroughreads thepeer_eventshigh-water mark, notMAX(seq)from the legacychangestable (store.py, the #151 evidence query). The contract has People hold invalidations until the feed catches up, which compares the evidence watermark with the feedthrough, so both must be the same counter. Ruled at the #160 gate, 2026-11-03.mail_searchp95 at most 25 % above idle, snapshot and feed page p99 at most 250 ms, RSS growth at most 64 MiB.make checkpasses.Non-goals
People consumer changes, pair acceptance (I01–I04), release or deploy, a broker.
Blocked by
⏸ SVD architect gate: dev/mail-mind-mcp#161 serve-the-mail-peer-snapshot-and-its-feed-handoff
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 efforthighRun:
20261103T115256Z-50d1adc3Held because: CLEAN but 6 open risk(s) (3 verification · 3 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
uv run python3 scripts/bench_feed.pythree times on host voyager at the PR head. Each report must show passes = {feed, health, rss, search, snapshot} all true, snapshot p99 <= 250 ms, and loaded/idle search p95 <= 1.25. Record the lines in ADR 0008 'Local implementation observations (#161)' and the PR. A failure blocks advertising snapshot. [verification]Change: Store.peer_snapshot copies the skeleton of Store.peer_changes (store.py:2697-2800): a dedicated read-only connection, BEGIN…ROLLBACK, identity, key and floor validation, and closed error mapping. It then does a keyset scan of peer_entities ordered by entity (BINARY):
account = ?oraccount IN (...),entity > after, and tombstones at or below H filtered in SQL. Each row follows ADR 0012 rule 5. A row with revision ≤ H is served from the projection. A row with revision > H is decided by its first peer_events row after H: an add means the entity did not exist at H; any other kind means it existed, at prev_revision and prev_at. That lookup is served by a new idempotent index, peer_events_entity (entity, seq), added in _SCHEMA after store.py:241; schema version stays 16 (DD-271, mirroring #160's peer_events_account). peer.render_snapshot mirrors render_changes (peer.py:595-648): the same byte cut, record_too_large at the head, a resume_cursor sealed as a changes cursor at H, and next_snapshot_cursor from a new seal_snapshot_cursor/open_snapshot_cursor pair. The pair shares a factored MAC-before-parse helper with open_cursor, whose behaviour stays unchanged. The cursor carries snapshot_id, H, snapshot_at, expires_at, the last entity and the captured freshness, so retries are byte-identical. server.mail_peer_snapshot_v1 and PeerSnapshotTool mirror mail_peer_changes_v1 and PeerChangesTool (server.py:1040-1042, 1134-1177, 1198-1205). store.py:2860 switches the evidence watermark to the sqlite_sequence peer_events high-water mark (the same statement as :2756). OPERATIONS becomes ("changes","snapshot","evidence") last, once the P06 and P07 tests pass. bench_feed.py gains a snapshot pager leg. ADR 0008 gains §10; ADR 0012, README, SECURITY.md and CLAUDE.md list the tool. One finding goes into ADR 0012: entity_id reuse after deletion is reachable (JMAP _refresh→delete_sources→_add, and IMAP drop_mailbox and re-add). Rule 5 stays correct because a reused id names the same immutable message.Files:
src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/server.py·tests/test_peer_snapshot.py·tests/test_peer_changes.py·tests/test_peer_evidence.py·tests/test_evidence.py·tests/test_server.py·scripts/bench_feed.py·docs/adr/0008-evidence-scope.md·docs/adr/0012-mail-peer-feed-implementation.md·README.md·SECURITY.md·CLAUDE.mdDecision: accept the 6 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-serve-the-mail-peer-snapshot-and-its-feed-handoff.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-serve-the-mail-peer-snapshot-and-its-feed-handoff.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#161 serve-the-mail-peer-snapshot-and-its-feed-handoff completed integration verify.
cc56ba7139codex-svd ship --run-id 20261103T185336Z-3ff10f55 --confirm-merge)