Cut the per-call cost of mail_peer_changes_v1 to meet the I02 search budget #167
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#167
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?
Problem
mail_peer_changes_v1fails the ADR 0012 rule 14 search budget. On the 210k-row store,mail_searchp95 under back-to-back feed polling is 1.6× to 2.04× its idle p95. The budget is 1.25×. The other I02 budgets pass: feed page p99 118 ms, health p99 77 ms, RSS growth 7.4 MiB (PR #166, ADR 0008).The architect measured
scripts/bench_feed.pyon voyager with a pause added between feed calls:mail_searchp95The control shows that the benchmark is fair: the slowdown comes from the feed calls, and it grows with their rate. Each feed call costs about 90 ms of server time for a short indexed read. Candidate costs, not yet proved:
Store.peer_changes);apiprocess, shared withmail_search;Change
Profile one feed call. Cut its server cost until the unchanged budget passes with the #166 benchmark's back-to-back polling. Do not change the budget or the load model (ADR 0012 rule 14). Keep the dedicated read view and the invariants of #151 and #160: no shared reader lock, one read transaction per page, and bounded work.
Acceptance
scripts/bench_feed.pypasses every I02 budget on the 210k-row store. The PR quotes theI02line with host and commit.make checkpasses.Blocks
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
⏸ SVD architect gate: dev/mail-mind-mcp#167 cut-the-per-call-cost-of-mail-peer-changes-v1-to-meet-the-i0
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 effortmediumRun:
20261103T105845Z-c8879574Held because: CLEAN but 3 open risk(s) (1 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Recommendation: no. The same pollers, arguments, back-to-back cadence, searcher, health probe, window and budgets apply, and the server receives more feed calls (73–74 per poller vs 30).
Evidence: the spec-time probe on voyager shows that no server-only cut passes while the pollers' client-side jsonschema validation (~20 ms per page) runs in the measured process. With the server cut alone the ratio was 1.53/1.63; with both cuts, 1.07/1.09.
If the architect rules the bench must stay single-process, this scope cannot meet the budget, and the budget or the contract page size needs a decision. [decision]
2. Is it acceptable to drop the MCP SDK's server-side output-schema re-validation for peer success results?
Recommendation: yes. The documents are correct by construction. Every served shape is proven by the contract validator (validate_exchange with FormatChecker) in tests. Consumers validate on receipt per MCP. Peer errors already bypass the check today.
The alternative, a cached server-side validator, still costs 13.1 ms per page on the GIL-holding job thread and was not shown to pass. [decision]
3. The I02 pass is proven only after the change, on the host. Check: run
uv run python3 scripts/bench_feed.pyon voyager at least twice. Each I02 line must show passes.search == true (loaded/idle search p95 <= 1.25) with feed, health and rss also true, and is quoted in the PR with host, base_commit and implementation_sha256. This spec's 1.07/1.09 came from a monkeypatched simulation, not the implemented code. [verification]Change: The spec-time profile (Half-A sandbox, host voyager) found the cost is not in the store. Store.peer_changes plus render_changes take ~1.3 ms per page, and the connection with its PRAGMAs takes 0.05–0.24 ms. About 92% of each feed call is jsonschema.validate of the result's structuredContent, run twice per call: once server-side in mcp/server/lowlevel/server.py:566-575 and once client-side in mcp/client/session.py:417 (the bench client shares the server's process). Each run costs ~20 ms per 100-event page.
pollchild process (same entry file, ready/go/stop over stdin, token over stdin). The load model, budgets, report keys and passes logic stay unchanged; one key, feed_pollers, is added. The server, searcher, health probe and RSS sampler stay in the bench process.A simulation of both cuts gave ratios 1.07 and 1.09 (pass). Each cut alone failed: 1.53/1.63 and 1.63/1.50.
Files:
src/mail_mind_mcp/peer.py·scripts/bench_feed.py·tests/test_peer_changes.py·docs/adr/0008-evidence-scope.mdDecision: accept the 3 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-cut-the-per-call-cost-of-mail-peer-changes-v1-to-meet-the-i0.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-cut-the-per-call-cost-of-mail-peer-changes-v1-to-meet-the-i0.md