Remove the remaining wall-clock flakes from the peer evidence tests #172

Closed
opened 2026-11-03 22:00:03 +00:00 by svc-agent-writer · 1 comment

Problem

tests/test_peer_evidence.py has more wall-clock bounds of 1 s or less than the two that #165 fixed. Each one can fail CI under load on the shared Woodpecker runner, as the old :831 and :423 bounds did on pipelines 22 and 27. None of the sites below has failed CI yet, so this change is preventive. The #165 gate kept them out of scope (#165 spec, Agent Adjustments item 1).

Line numbers are at main febfb55, after #173:

  1. :354 (test_real_lock_contention_is_busy_in_50_ms): assert 0.035 <= elapsed < 0.5.
  2. :402, :409, :410 (test_sql_progress_cancellation_closes_connection): in_sql.wait(1), future.result(timeout=1) and time.monotonic() - started < 1.
  3. :501, :502, :514, :516 (test_two_slots_timeout_cancellation_and_shutdown): started[0].wait and started[1].wait with 1 s, stopped[0].wait with 1 s, and time.monotonic() - at < 1.
  4. :547 (test_cancel_before_worker_start_releases_exactly_once): future.result(timeout=1).
  5. :751, :754, :755 (test_served_slow_peer_does_not_block_status_or_people): entered.wait with 1 s, asyncio.wait_for(..., 1) and time.monotonic() - started < 1.
  6. :932, :939, :944, :946 (test_running_job_cleanup_during_extraction_and_encoding): entered.wait with 1 s, asyncio.wait_for(task, 1), stopped.wait with 1 s, and time.monotonic() - at < 1.
  7. :978, :982 (test_parent_cancellation_records_outcome_once): entered.wait and stopped.wait with 1 s.

Change

Apply the #165 rule to each site. BOUNDED_WORK_SECONDS = 5 (tests/test_peer_evidence.py:33) is the shared margin.

  • A bound that guards bounded work or a prompt stop keeps its assertion and uses BOUNDED_WORK_SECONDS.
  • A bound that only measures latency leaves the CI test. The host benchmark or a documented host command measures it (ADR 0012 rule 14).
  • A wait timeout that only stops a hung test from blocking (for example event.wait(1) or future.result(timeout=1)) uses BOUNDED_WORK_SECONDS.
  • :354 guards a contract value: the 50 ms busy timeout of ADR 0008 (docs/adr/0008-evidence-scope.md:51). Keep the 0.035 lower bound, which proves that SQLite waited. Change the upper bound to BOUNDED_WORK_SECONDS. Add a direct assertion that the peer read connection opens with busy_timeout_ms=50, so the 50 ms value stays guarded exactly.

Acceptance

  • Every site listed above uses BOUNDED_WORK_SECONDS or is removed with a stated reason in the PR.
  • :354 keeps the 0.035 lower bound and gains a direct busy_timeout_ms=50 assertion that fails if the value changes.
  • No correctness assertion is removed.
  • make check passes.

Blocked by

None. #165 is closed (PR #173, febfb55).

Filed under: operator word "yes. proceed" sha256:8b8e998d2a5b

## Problem `tests/test_peer_evidence.py` has more wall-clock bounds of 1 s or less than the two that #165 fixed. Each one can fail CI under load on the shared Woodpecker runner, as the old `:831` and `:423` bounds did on pipelines 22 and 27. None of the sites below has failed CI yet, so this change is preventive. The #165 gate kept them out of scope (#165 spec, Agent Adjustments item 1). Line numbers are at `main` `febfb55`, after #173: 1. `:354` (`test_real_lock_contention_is_busy_in_50_ms`): `assert 0.035 <= elapsed < 0.5`. 2. `:402`, `:409`, `:410` (`test_sql_progress_cancellation_closes_connection`): `in_sql.wait(1)`, `future.result(timeout=1)` and `time.monotonic() - started < 1`. 3. `:501`, `:502`, `:514`, `:516` (`test_two_slots_timeout_cancellation_and_shutdown`): `started[0].wait` and `started[1].wait` with 1 s, `stopped[0].wait` with 1 s, and `time.monotonic() - at < 1`. 4. `:547` (`test_cancel_before_worker_start_releases_exactly_once`): `future.result(timeout=1)`. 5. `:751`, `:754`, `:755` (`test_served_slow_peer_does_not_block_status_or_people`): `entered.wait` with 1 s, `asyncio.wait_for(..., 1)` and `time.monotonic() - started < 1`. 6. `:932`, `:939`, `:944`, `:946` (`test_running_job_cleanup_during_extraction_and_encoding`): `entered.wait` with 1 s, `asyncio.wait_for(task, 1)`, `stopped.wait` with 1 s, and `time.monotonic() - at < 1`. 7. `:978`, `:982` (`test_parent_cancellation_records_outcome_once`): `entered.wait` and `stopped.wait` with 1 s. ## Change Apply the #165 rule to each site. `BOUNDED_WORK_SECONDS = 5` (`tests/test_peer_evidence.py:33`) is the shared margin. - A bound that guards bounded work or a prompt stop keeps its assertion and uses `BOUNDED_WORK_SECONDS`. - A bound that only measures latency leaves the CI test. The host benchmark or a documented host command measures it (ADR 0012 rule 14). - A wait timeout that only stops a hung test from blocking (for example `event.wait(1)` or `future.result(timeout=1)`) uses `BOUNDED_WORK_SECONDS`. - `:354` guards a contract value: the 50 ms busy timeout of ADR 0008 (`docs/adr/0008-evidence-scope.md:51`). Keep the `0.035` lower bound, which proves that SQLite waited. Change the upper bound to `BOUNDED_WORK_SECONDS`. Add a direct assertion that the peer read connection opens with `busy_timeout_ms=50`, so the 50 ms value stays guarded exactly. ## Acceptance - Every site listed above uses `BOUNDED_WORK_SECONDS` or is removed with a stated reason in the PR. - `:354` keeps the `0.035` lower bound and gains a direct `busy_timeout_ms=50` assertion that fails if the value changes. - No correctness assertion is removed. - `make check` passes. ## Blocked by None. #165 is closed (PR #173, `febfb55`). Filed under: operator word "yes. proceed" sha256:8b8e998d2a5b
Author
Member

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: Give every remaining wall-clock bound in tests/test_peer_evidence.py the #165 margin, and guard the 50 ms busy timeout by value, not by wall clock.

Current behavior:

  • Eighteen bounds at seven test sites in tests/test_peer_evidence.py use a hard-coded 1 s or 0.5 s. The issue body lists every site at main febfb55.
  • test_real_lock_contention_is_busy_in_50_ms (:354) proves the ADR 0008 50 ms busy timeout only through 0.035 <= elapsed < 0.5. A slow runner can fail it, and that failure is not a regression.
  • #165 (PR #173) added BOUNDED_WORK_SECONDS = 5 at :33 and used it in test_full_cap_pathological_bodies_finish_and_cancel_bounded only.

Desired behavior:

  • Each listed site uses BOUNDED_WORK_SECONDS, or the PR states why the bound was removed (a latency-only bound, per ADR 0012 rule 14).
  • :354 keeps 0.035 <= and uses < BOUNDED_WORK_SECONDS for the upper bound. A new assertion in that test, or in a sibling test, proves that the peer read connection opens with busy_timeout_ms=50. One way is to capture the busy_timeout_ms keyword of storage._connect (the test imports mail_mind_mcp.store as storage) through monkeypatch, as :397 already patches it. The assertion must fail if any peer reader passes another value.
  • Every other assertion in the file stays the same.

Already decided (cite, do not re-open):

  • The margin rule and the constant: the #165 gate and tests/test_peer_evidence.py:33.
  • Latency budgets belong on the host, not in CI: docs/adr/0012-mail-peer-feed-implementation.md, rule 14.
  • The 50 ms connect and busy timeout: docs/adr/0008-evidence-scope.md:51. The peer readers pass it at src/mail_mind_mcp/store.py:2686, :2753, :2860 and :2995.

Key interfaces:

  • BOUNDED_WORK_SECONDS in tests/test_peer_evidence.py.
  • storage._connect(path, *, read_only, busy_timeout_ms) (src/mail_mind_mcp/store.py:3542, default 30,000 ms), the seam for the direct assertion.
  • peer.PeerError with match="busy", which :354 already uses.

Acceptance criteria:

  • grep -nE 'wait\(1\)|wait, 1\)|wait_for\(.*, 1\)|timeout=1\b|< 1\b|< 0\.5' tests/test_peer_evidence.py prints no output. At febfb55 it prints the 18 listed sites. If a line stays, the PR names it and gives the reason.
  • :354 keeps the 0.035 lower bound.
  • A test asserts busy_timeout_ms=50 on the peer read connection, and it fails when the value is changed. Check this by hand once and say so in the PR.
  • No correctness assertion is removed. The pass set of uv run python3 -m pytest -q tests/test_peer_evidence.py is unchanged, plus any new test.
  • make check passes.

Out of scope:

  • Any change under src/.
  • Other test files. If they hold similar bounds, file a separate issue.
  • The value of BOUNDED_WORK_SECONDS.
  • The ADR 0008 limits themselves.
> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** Give every remaining wall-clock bound in `tests/test_peer_evidence.py` the #165 margin, and guard the 50 ms busy timeout by value, not by wall clock. **Current behavior:** - Eighteen bounds at seven test sites in `tests/test_peer_evidence.py` use a hard-coded 1 s or 0.5 s. The issue body lists every site at `main` `febfb55`. - `test_real_lock_contention_is_busy_in_50_ms` (`:354`) proves the ADR 0008 50 ms busy timeout only through `0.035 <= elapsed < 0.5`. A slow runner can fail it, and that failure is not a regression. - #165 (PR #173) added `BOUNDED_WORK_SECONDS = 5` at `:33` and used it in `test_full_cap_pathological_bodies_finish_and_cancel_bounded` only. **Desired behavior:** - Each listed site uses `BOUNDED_WORK_SECONDS`, or the PR states why the bound was removed (a latency-only bound, per ADR 0012 rule 14). - `:354` keeps `0.035 <=` and uses `< BOUNDED_WORK_SECONDS` for the upper bound. A new assertion in that test, or in a sibling test, proves that the peer read connection opens with `busy_timeout_ms=50`. One way is to capture the `busy_timeout_ms` keyword of `storage._connect` (the test imports `mail_mind_mcp.store as storage`) through `monkeypatch`, as `:397` already patches it. The assertion must fail if any peer reader passes another value. - Every other assertion in the file stays the same. **Already decided (cite, do not re-open):** - The margin rule and the constant: the #165 gate and `tests/test_peer_evidence.py:33`. - Latency budgets belong on the host, not in CI: `docs/adr/0012-mail-peer-feed-implementation.md`, rule 14. - The 50 ms connect and busy timeout: `docs/adr/0008-evidence-scope.md:51`. The peer readers pass it at `src/mail_mind_mcp/store.py:2686`, `:2753`, `:2860` and `:2995`. **Key interfaces:** - `BOUNDED_WORK_SECONDS` in `tests/test_peer_evidence.py`. - `storage._connect(path, *, read_only, busy_timeout_ms)` (`src/mail_mind_mcp/store.py:3542`, default 30,000 ms), the seam for the direct assertion. - `peer.PeerError` with `match="busy"`, which `:354` already uses. **Acceptance criteria:** - [ ] `grep -nE 'wait\(1\)|wait, 1\)|wait_for\(.*, 1\)|timeout=1\b|< 1\b|< 0\.5' tests/test_peer_evidence.py` prints no output. At `febfb55` it prints the 18 listed sites. If a line stays, the PR names it and gives the reason. - [ ] `:354` keeps the `0.035` lower bound. - [ ] A test asserts `busy_timeout_ms=50` on the peer read connection, and it fails when the value is changed. Check this by hand once and say so in the PR. - [ ] No correctness assertion is removed. The pass set of `uv run python3 -m pytest -q tests/test_peer_evidence.py` is unchanged, plus any new test. - [ ] `make check` passes. **Out of scope:** - Any change under `src/`. - Other test files. If they hold similar bounds, file a separate issue. - The value of `BOUNDED_WORK_SECONDS`. - The ADR 0008 limits themselves.
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#172
No description provided.