Implement the structured Mail peer evidence query #151
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#151
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
Implement the first independently usable slice of the approved shared mind contract: a structured, evidence-scoped
mail_peer_evidence_v1query. Preserve the existing agent-facing tools and text results. This work can proceed now; #148 landed in main and its release is not a code dependency. People Mind #45 is now merged as PR #46 and is not a blocker for this provider work.Decision substrate
Operator approved the shared contract/recovery model and instructed “proceed now” on 2026-11-03. Mail ADR 0010 owns the architecture; ADR 0008 owns the evidence field/privacy boundary. The implementation target is
contracts/mind-v1/at commit21e279da85eab618ef8c76bc8211daaa23e0ca52, with executable schemas/fixtures and recovery cases. This is implementation of that approved direction, not a decision to add a broker or broaden evidence access.Scope
mail_peer_evidence_v1, using its request definition and evidence-result/error definitions. Return MCP structuredContent and a correct outputSchema. Keep oldmail_evidencebyte-compatible; do not parse its text to construct machine data.throughis the existing committed change watermark from the same read view as evidence; it is an observation, not a feed cursor. Routine restart preserves identity. Missing initialization fails explicitly. No change-feed or snapshot operation is advertised in this slice.Acceptance criteria
validate_exchangefrom the pinned conformance kit accepts real synthetic-store results. Reject wrong versions and excessive bounds explicitly. No silent downgrade or human-text parsing.make checkpass. Include P08/P09 and the evidence-applicable I02/I03 observations from the recovery matrix; do not mark full v1 recovery certified.Non-goals
No change-feed/snapshot implementation, event-log migration, consumer edits, message bus, shared runtime library, image publication or live deployment. Do not advertise full v1 capability until the provider recovery work is implemented. No dependency on #148 issue closure: its landed diagnostic code is the baseline even if live observation remains open.
SVD verification notes
Spec from clean main at the origin tip, using the pinned contract as normative input and current implementation for locations. Use
python3 -m pytest, not bare pytest. Keep test temp trees outside the checkout, with a realmktemppath when needed. Mail has no enforced CI yet (#132); report actual local checks and remote status rather than fabricating CI green. Do not publish or merge as part of this work item.⏸ SVD architect gate: dev/mail-mind-mcp#151 implement-the-structured-mail-peer-evidence-query
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:
20261103T002028Z-89577546Held because: CLEAN but 7 open risk(s) (3 verification · 4 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: New pure module src/mail_mind_mcp/peer.py holds literal copies of the contract's request and response schema subsets (pinned to contracts/mind-v1 by an equality test, because the wheel and image ship only src/), the budget constants, WorkBudget, and the freshness, scope_id, error and result builders. store.py: the writer init (store.py:568-584) wraps an INSERT OR IGNORE of meta peer_source_id/peer_epoch plus the existing schema_version upsert in one _tx (store.py:666-677). SCHEMA_VERSION is not bumped (DD-271; about 20 v14 assertions in tests). The Store.evidence body (store.py:2081-2146) moves verbatim into _sender_evidence(conn,…). A new Store.peer_evidence opens a dedicated read-only connection (the last_ok_sync shape, store.py:2294-2303) and never takes Store._lock. It sets a progress handler for the budget and cancel flag, and reads identity, MAX(seq), sync_log and evidence inside one BEGIN…COMMIT. evidence.py: signatures_bounded returns a truncation flag and takes a cooperative check; signatures wraps it, so its output is unchanged. server.py: an async mail_peer_evidence_v1 is registered via FunctionTool.from_function(auth=require_scopes(SCOPE_EVIDENCE), annotations=READ_ONLY, output_schema=peer.OUTPUT_SCHEMA), with parameters overridden to peer.INPUT_SCHEMA. Its contract parameter is a str, so a wrong version returns a structured unsupported_version. A non-blocking BoundedSemaphore slot is released only in the worker thread's finally. The work runs via anyio.to_thread.run_sync(abandon_on_cancel=True); cancellation sets the budget's cancel flag. Rendering happens after COMMIT. Errors are returned as ToolResult(is_error=True, structured_content=err). The whole call runs inside _tool_call (server.py:279-294), mirroring mail_evidence at server.py:957-1003. The ADR 0008 §1/§2 amendment and the docs that list evidence tools are updated.
Files:
src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/server.py·tests/test_peer_evidence.py·tests/test_evidence.py·tests/test_server.py·docs/adr/0008-evidence-scope.md·CLAUDE.md·README.md·SECURITY.mdDecision: accept the 7 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-implement-the-structured-mail-peer-evidence-query.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-implement-the-structured-mail-peer-evidence-query.mdArchitect review: HOLD before implementation
The automated Half-A result above is CLEAN, but I have not approved dispatch. The concrete draft needs four technical corrections:
generated_atinto the future to hide clock skew. Keep generation time truthful and use a contract-conforming error if freshness cannot be represented honestly.unsupported_version; framework validation behavior cannot justify the draft's weaker fallback.These are corrections within the accepted contract, not requests for a new architecture decision. The draft is marked HOLD and must be reworked and verified before implementation approval. The shared contract at
21e279dis delivered; no runtime protocol support is claimed. The seven residual risks in the automatic packet also remain to be reconciled.✅ SVD architect gate: dev/mail-mind-mcp#151 implement-the-structured-mail-peer-evidence-query
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 effortunclassifiedRun:
20261103T002028Z-89577546Files:
src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/server.py·tests/test_peer_evidence.py·tests/test_evidence.py·tests/test_server.py·docs/adr/0008-evidence-scope.md·CLAUDE.md·README.md·SECURITY.mdWrite-set divergence: present table wins. 0 sourceHashes vs 34-row table.
Decision: dispatch this spec (
svd:go)?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-implement-the-structured-mail-peer-evidence-query.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-implement-the-structured-mail-peer-evidence-query.mdArchitect gate update: revised #151 spec verified CLEAN, zero blocking defects, no degraded or inconclusive lenses (run 20261103T002028Z-89577546; automatic comment 31201). The original lock-wait, single-body execution, fabricated generation-time and unsupported-version fallback defects are addressed in the operative plan. A synthetic FastMCP probe additionally found validation-value logging; the revised tool-local wrapper preserves validation without exposing rejected values.
No implementation dispatch or approval yet. The operator identified adjacent Rat 4414d294-4fe4-4583-94d9-26697646e5a9 / Half-A batch 99f271b89bb841579629f13b0416a6e1. Local run arguments confirm Mail #142 (20261103T005914Z-373020a9) and imap-blade #3 (20261103T005914Z-a98ad411). #142 and #151 overlap store.py. Keep #151 queued; resolve that lane first, then refresh the base/source hashes and review its final write set. This is dispatch sequencing, not a new protocol dependency. No changes made to either adjacent run.
Remaining verifier advisories to close at the refreshed gate: include config.example.toml's evidence-tool comment in the bounded documentation write set; explicitly cover served-tool call arguments/annotations and fixed-signature _connect test doubles; adjudicate persistent row/byte work-limit exhaustion versus retryable busy (bounded consumer retries prevent an infinite retry loop but do not make a permanent limit transient); document SQLite aggregate-row limits and sync-log retention's unknown freshness. Actual cancellation, RSS, HTTP privacy and PR CI remain implementation acceptance checks. Branch protection cannot be inferred from main's green CI and remains unreadable with this token.
Current source base
ff1d246includes Mail CI PR #153; main validation is green. The normative contract remains pinned to21e279d. No runtime, release or deployment change is claimed. Next sequence remains #151, #152, People #47 after coordination and the normal implementation gate.✅ SVD architect gate: dev/mail-mind-mcp#151 implement-the-structured-mail-peer-evidence-query
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 effortunclassifiedRun:
20261103T002028Z-89577546Files:
src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/server.py·tests/test_peer_evidence.py·tests/test_evidence.py·tests/test_server.py·docs/adr/0008-evidence-scope.md·CLAUDE.md·README.md·SECURITY.md·config.example.tomlWrite-set divergence: present table wins. 0 sourceHashes vs 36-row table.
Decision: dispatch this spec (
svd:go)?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-implement-the-structured-mail-peer-evidence-query.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-implement-the-structured-mail-peer-evidence-query.md✅ SVD architect gate: dev/mail-mind-mcp#151 implement-the-structured-mail-peer-evidence-query
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 effortunclassifiedRun:
20261103T002028Z-89577546Files:
src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/server.py·tests/test_peer_evidence.py·tests/test_evidence.py·tests/test_server.py·docs/adr/0008-evidence-scope.md·CLAUDE.md·README.md·SECURITY.md·config.example.tomlWrite-set divergence: present table wins. 0 sourceHashes vs 36-row table.
Decision: dispatch this spec (
svd:go)?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-implement-the-structured-mail-peer-evidence-query.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-implement-the-structured-mail-peer-evidence-query.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#151 implement-the-structured-mail-peer-evidence-query completed integration verify.
f5929a338epytestis unavailable outside the project venv; tests ran throughuv run --frozen python -m pytest. The spec's fast-verification file list collects 217 tests and all pass.codex-svd ship --run-id 20261103T041454Z-4e099dea --confirm-merge)