Stop the evidence drain on the first mailmind-unavailable #53

Closed
opened 2026-11-03 21:55:31 +00:00 by piers · 4 comments
Owner

Outcome

When Mail Mind is unreachable, a People sync pass ends after the first failed evidence request instead of trying every address in the batch.

Context

Found at the #49 grill (2026-11-04). _mail_drain (src/people_mind_mcp/sync.py:440-512) catches mailmind-unavailable, increments attempts and continues with the next address. It raises only after the whole batch, which holds up to page_limit addresses (default 100). With the defaults (request_timeout_seconds 60, page_limit 100), a Mail port that drops packets holds one sync pass for about 100 minutes. A refused connection ends it in about 22 s at the 4/s pacer. people_find keeps answering, so this is a freshness defect, not an outage.

README.md:117 says a request over the timeout "fails the pass". The code does not do that today.

This bug does not gate #49: ADR 0009 Amendment 1 makes the I01 deadline per request.

Scope

  1. In _mail_drain, on the first mailmind-unavailable, record the attempt for that address and stop the batch; raise the failure after the transaction that records it.
  2. Keep the current behaviour for mailmind-busy: record the attempt and continue.
  3. Add a test in tests/test_mailpeer.py that queues more addresses than one, makes the first request fail as unavailable, and asserts that the pass ends after one request and that only that address's attempts changed.

Acceptance criteria

  • The new test passes, and the existing tests/test_mailpeer.py tests pass unchanged.
  • README.md:117 is true as written.

Filed under: operator word "accept/agree. yes. go" sha256:f76d6cac557a (#49 #50 grill)

## Outcome When Mail Mind is unreachable, a People sync pass ends after the first failed evidence request instead of trying every address in the batch. ## Context Found at the #49 grill (2026-11-04). `_mail_drain` (`src/people_mind_mcp/sync.py:440-512`) catches `mailmind-unavailable`, increments `attempts` and continues with the next address. It raises only after the whole batch, which holds up to `page_limit` addresses (default 100). With the defaults (`request_timeout_seconds` 60, `page_limit` 100), a Mail port that drops packets holds one sync pass for about 100 minutes. A refused connection ends it in about 22 s at the 4/s pacer. `people_find` keeps answering, so this is a freshness defect, not an outage. `README.md:117` says a request over the timeout "fails the pass". The code does not do that today. This bug does not gate #49: ADR 0009 Amendment 1 makes the I01 deadline per request. ## Scope 1. In `_mail_drain`, on the first `mailmind-unavailable`, record the attempt for that address and stop the batch; raise the failure after the transaction that records it. 2. Keep the current behaviour for `mailmind-busy`: record the attempt and continue. 3. Add a test in `tests/test_mailpeer.py` that queues more addresses than one, makes the first request fail as unavailable, and asserts that the pass ends after one request and that only that address's `attempts` changed. ## Acceptance criteria - The new test passes, and the existing `tests/test_mailpeer.py` tests pass unchanged. - `README.md:117` is true as written. Filed under: operator word "accept/agree. yes. go" sha256:f76d6cac557a (#49 #50 grill)
Collaborator

⏸ SVD architect gate: dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable

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: 20261103T221217Z-d7f441f2

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

Open risks:

  1. Issue AC 'existing tests/test_mailpeer.py tests pass unchanged' cannot be met: test_retry_exhaustion_preserves_work_without_starving_other_addresses[unavailable] (:420-454) asserts OTHER is requested in the same pass (:444), only ADDRESS stays pending (:445), and the recovery pass requests only ADDRESS (:451), which is the behaviour #53 removes. Question: does the architect accept narrowing its parametrization to ["busy"], with the new test owning the unavailable case, as the restated criterion? [decision]
  2. No pass/fail baseline was measured: the Half-A sandbox denied executing .venv/bin/python3. Check: on pristine 511e7ce before the first edit, run uv run python3 -m pytest tests/test_mailpeer.py -q and record the failure set. After the change it must be identical except the removed [unavailable] id and the two new passing ids. [verification]
  3. 'Pass ends after one request' is read as one evidence request (one address). A structured peer 'unavailable' error still makes MAX_RETRIES+1 = 6 wire calls inside that request (sources/mailpeer.py:276-309); the timeout case makes exactly 1. Question: is that reading right, or should the in-request retry budget for structured unavailable also be cut? That would touch mailpeer.py's shared retry contract and belongs in a separate issue. [decision]

Change: In _mail_drain (src/people_mind_mcp/sync.py:449-458), keep the existing busy/unavailable handler and its with transaction(conn) attempts increment. After that block, add if exc.code == "mailmind-unavailable": raise before failure = exc; continue. The attempt commits first, then the batch ends; busy still continues and raises at :510-511. In tests/test_mailpeer.py, add test_unavailable_evidence_ends_the_pass_after_one_address, parametrized over [error, timeout]. Its setup mirrors the retry-exhaustion test (:420-454) and the timeout test (:1053-1073). It queues ADDRESS and OTHER and checks: the pass raises mailmind-unavailable; only ADDRESS is requested ([ADDRESS]*(MAX_RETRIES+1) in error mode, [ADDRESS] in timeout mode); pending attempts are [(ADDRESS,1),(OTHER,0)]; the cursor is "2" with applied_at None; and the recovery pass calls [OTHER, ADDRESS] and leaves nothing pending. Narrow the existing test's parametrization at :420 from ["busy","unavailable"] to ["busy"], because its unavailable case encodes the defect.

Files: src/people_mind_mcp/sync.py · tests/test_mailpeer.py

Decision: 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):

  • 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-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md

### ⏸ SVD architect gate: dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable **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:** `20261103T221217Z-d7f441f2` **Held because:** CLEAN but 3 open risk(s) (1 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Issue AC 'existing tests/test_mailpeer.py tests pass unchanged' cannot be met: test_retry_exhaustion_preserves_work_without_starving_other_addresses[unavailable] (:420-454) asserts OTHER is requested in the same pass (:444), only ADDRESS stays pending (:445), and the recovery pass requests only ADDRESS (:451), which is the behaviour #53 removes. Question: does the architect accept narrowing its parametrization to ["busy"], with the new test owning the unavailable case, as the restated criterion? [decision] 2. No pass/fail baseline was measured: the Half-A sandbox denied executing .venv/bin/python3. Check: on pristine 511e7ce before the first edit, run `uv run python3 -m pytest tests/test_mailpeer.py -q` and record the failure set. After the change it must be identical except the removed [unavailable] id and the two new passing ids. [verification] 3. 'Pass ends after one request' is read as one evidence request (one address). A structured peer 'unavailable' error still makes MAX_RETRIES+1 = 6 wire calls inside that request (sources/mailpeer.py:276-309); the timeout case makes exactly 1. Question: is that reading right, or should the in-request retry budget for structured unavailable also be cut? That would touch mailpeer.py's shared retry contract and belongs in a separate issue. [decision] **Change:** In `_mail_drain` (src/people_mind_mcp/sync.py:449-458), keep the existing busy/unavailable handler and its `with transaction(conn)` attempts increment. After that block, add `if exc.code == "mailmind-unavailable": raise` before `failure = exc; continue`. The attempt commits first, then the batch ends; busy still continues and raises at :510-511. In tests/test_mailpeer.py, add `test_unavailable_evidence_ends_the_pass_after_one_address`, parametrized over [error, timeout]. Its setup mirrors the retry-exhaustion test (:420-454) and the timeout test (:1053-1073). It queues ADDRESS and OTHER and checks: the pass raises mailmind-unavailable; only ADDRESS is requested ([ADDRESS]*(MAX_RETRIES+1) in error mode, [ADDRESS] in timeout mode); pending attempts are [(ADDRESS,1),(OTHER,0)]; the cursor is "2" with applied_at None; and the recovery pass calls [OTHER, ADDRESS] and leaves nothing pending. Narrow the existing test's parametrization at :420 from ["busy","unavailable"] to ["busy"], because its unavailable case encodes the defect. **Files:** `src/people_mind_mcp/sync.py` · `tests/test_mailpeer.py` **Decision:** 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`): - 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-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md`</sub>
Collaborator

spec-verify-dispatch drift guard halted dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable before implementation.

  • Spec: /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md
  • Drift:
    • docs/adr/0009-shared-mind-contract-and-recovery.md: expected 0ae35ff6624d, got 12e2b2814c32
    • docs/contracts/mail-peer-v1.md: expected c7f54e1cc568, got 04af38d2dd44
  • Risk: implementing against a stale spec ships code whose review evidence (source hashes) no longer matches the tree.
  • Decision: re-run produce/verify against the current tree — or, if the drift is known-benign, re-dispatch with baseBranchOverride/allowNoHashes deliberately?
spec-verify-dispatch drift guard halted dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable before implementation. - Spec: `/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md` - Drift: - docs/adr/0009-shared-mind-contract-and-recovery.md: expected 0ae35ff6624d, got 12e2b2814c32 - docs/contracts/mail-peer-v1.md: expected c7f54e1cc568, got 04af38d2dd44 - Risk: implementing against a stale spec ships code whose review evidence (source hashes) no longer matches the tree. - Decision: re-run produce/verify against the current tree — or, if the drift is known-benign, re-dispatch with `baseBranchOverride`/`allowNoHashes` deliberately?
Collaborator

⏸ SVD architect gate: dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable

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: 20261103T230126Z-e173245c

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

Open risks:

  1. Still no pass/fail baseline. Changed since the prior attempt: the base moved 511e7ce→f4dd669, and the measurement was retried this session (.venv/bin/python3 -m pytest tests/test_mailpeer.py -q -p no:cacheprovider). The Half-A sandbox refused again with 'Operation not permitted'. f4dd669 did not touch tests/test_mailpeer.py. Check: on pristine f4dd669 before the first edit, run uv run python3 -m pytest tests/test_mailpeer.py -q and record the failure set. After the change it must be identical, except that retry_exhaustion[unavailable] is removed and the two new test_unavailable_evidence_ends_the_pass_after_one_address ids pass. [verification]

Change: In _mail_drain (src/people_mind_mcp/sync.py:449-458), keep the existing busy/unavailable handler and its with transaction(conn) attempts increment. Directly after that block, add if exc.code == "mailmind-unavailable": raise, then the existing failure = exc; continue. The attempt commits first and then the batch ends. Busy still continues and raises at :510-511. Mirror the single exc.code membership-test shape at :450. In tests/test_mailpeer.py, add test_unavailable_evidence_ends_the_pass_after_one_address, parametrized over ["error","timeout"]. Its setup mirrors :420-454 and :1053-1073. It queues ADDRESS and OTHER and asserts:

  • the pass raises mailmind-unavailable;
  • the evidence calls are [ADDRESS]*(MAX_RETRIES+1) in error mode and [ADDRESS] in timeout mode;
  • the attempts rows are [(ADDRESS,1),(OTHER,0)];
  • the cursor is ("2", None);
  • the recovery pass calls [OTHER, ADDRESS] and leaves nothing pending.
    Narrow the existing test's parametrization at :420 to ["busy"], as approved at the prior gate. This is the approved prior lean, re-derived at base f4dd669, where the code is hash-identical.

Files: src/people_mind_mcp/sync.py · tests/test_mailpeer.py

Decision: accept the 1 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-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md

### ⏸ SVD architect gate: dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable **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:** `20261103T230126Z-e173245c` **Held because:** CLEAN but 1 open risk(s) (1 verification) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Still no pass/fail baseline. Changed since the prior attempt: the base moved 511e7ce→f4dd669, and the measurement was retried this session (`.venv/bin/python3 -m pytest tests/test_mailpeer.py -q -p no:cacheprovider`). The Half-A sandbox refused again with 'Operation not permitted'. f4dd669 did not touch tests/test_mailpeer.py. Check: on pristine f4dd669 before the first edit, run `uv run python3 -m pytest tests/test_mailpeer.py -q` and record the failure set. After the change it must be identical, except that retry_exhaustion[unavailable] is removed and the two new test_unavailable_evidence_ends_the_pass_after_one_address ids pass. [verification] **Change:** In `_mail_drain` (src/people_mind_mcp/sync.py:449-458), keep the existing busy/unavailable handler and its `with transaction(conn)` attempts increment. Directly after that block, add `if exc.code == "mailmind-unavailable": raise`, then the existing `failure = exc; continue`. The attempt commits first and then the batch ends. Busy still continues and raises at :510-511. Mirror the single `exc.code` membership-test shape at :450. In tests/test_mailpeer.py, add `test_unavailable_evidence_ends_the_pass_after_one_address`, parametrized over ["error","timeout"]. Its setup mirrors :420-454 and :1053-1073. It queues ADDRESS and OTHER and asserts: - the pass raises mailmind-unavailable; - the evidence calls are [ADDRESS]*(MAX_RETRIES+1) in error mode and [ADDRESS] in timeout mode; - the attempts rows are [(ADDRESS,1),(OTHER,0)]; - the cursor is ("2", None); - the recovery pass calls [OTHER, ADDRESS] and leaves nothing pending. Narrow the existing test's parametrization at :420 to ["busy"], as approved at the prior gate. This is the approved prior lean, re-derived at base f4dd669, where the code is hash-identical. **Files:** `src/people_mind_mcp/sync.py` · `tests/test_mailpeer.py` **Decision:** accept the 1 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-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-stop-the-evidence-drain-on-the-first-mailmind-unavailable.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable completed integration verify.

  • PR: #61
  • Branch: feat/svd-dev-people-mind-mcp-53-stop-the-evidence-drain-on-th-de8f174b
  • Commit: 955e248083
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/73/pipeline/21/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: Remote CI ci/woodpecker/pr/validation is still running; the runner should re-poll.
  • Warning: Spec's baseline run on the pristine base was not re-measured here; the PR body reports 69 passed on the pristine module and both new cases red before the fix. This run confirms 70 passed after the change.
  • Warning: PR body carries a 'Co-Authored-By: gpt-6.1-sol' trailer; cosmetic only.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261103T232309Z-de8f174b --confirm-merge)
spec-verify-dispatch Half B for dev/people-mind-mcp#53 stop-the-evidence-drain-on-the-first-mailmind-unavailable completed integration verify. - PR: https://git.groupthink.asia/dev/people-mind-mcp/pulls/61 - Branch: feat/svd-dev-people-mind-mcp-53-stop-the-evidence-drain-on-th-de8f174b - Commit: 955e248083fe58f30761440688adedd33ca7108f - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/73/pipeline/21/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: Remote CI ci/woodpecker/pr/validation is still running; the runner should re-poll. - Warning: Spec's baseline run on the pristine base was not re-measured here; the PR body reports 69 passed on the pristine module and both new cases red before the fix. This run confirms 70 passed after the change. - Warning: PR body carries a 'Co-Authored-By: gpt-6.1-sol' trailer; cosmetic only. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261103T232309Z-de8f174b --confirm-merge`)
svc-svd-writer 2026-11-03 23:38:47 +00:00
  • closed this issue
  • removed the
    svd:go
    label
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/people-mind-mcp#53
No description provided.