Give the remaining peer evidence timing bounds a runner-proof margin #174

Merged
svc-agent-writer merged 1 commit from fix/172-peer-evidence-wall-clock-bounds into main 2026-11-03 22:52:49 +00:00

Summary

Test-only. Every remaining wall-clock bound of 1 s or less in the peer evidence tests gets the #165 margin, without weakening what each test proves.

 BOUNDED_WORK_SECONDS = 5
+STUCK_SECONDS = 2 * BOUNDED_WORK_SECONDS   # a blocked worker outlives every bound

 test_real_lock_contention_is_busy_in_50_ms
-  assert 0.035 <= elapsed < 0.5
+  assert 0.035 <= elapsed < BOUNDED_WORK_SECONDS   # 50 ms pinned by value at :324

 18 waits and bounds at 7 sites (#172 body)
-  event.wait(1) / wait_for(..., 1) / future.result(timeout=1) / elapsed < 1
+  ... BOUNDED_WORK_SECONDS

 workers that stop on their own
-  cancelled.wait(2) / release.wait(2) / release.wait(3)
+  ... STUCK_SECONDS

 test_sql_progress_cancellation_closes_connection
-  recursive CTE to 1e8 rows   (~10 s uninterrupted)
+  recursive CTE to 1e9 rows

 tests/test_peer_changes.py
+  test_peer_identity_reads_with_the_50_ms_busy_timeout

STUCK_SECONDS is the part the issue did not list. Four workers used to stop by themselves after 2–3 s. Under a 5 s bound, a broken cancellation would have finished inside it and passed. They now wait 10 s, so a missing cancel still fails the bound.

peer_identity was the one peer reader with no 50 ms guard. peer_evidence, peer_changes and peer_snapshot already had one, at test_peer_evidence.py:324, test_peer_changes.py:586 and test_peer_snapshot.py:64.

Evidence

  • Acceptance grep (grep -nE 'wait\(1\)|wait, 1\)|wait_for\(.*, 1\)|timeout=1\b|< 1\b|< 0\.5' tests/test_peer_evidence.py):
    Before: 18 lines at febfb55.
    After: no output.
  • Guards still fail when broken (each change made by hand, then reverted):
    • busy_timeout_ms=50 changed to 60 in peer_identity: test_peer_identity_reads_with_the_50_ms_busy_timeout fails its kw == {"read_only": True, "busy_timeout_ms": 50} assertion. The same change in peer_evidence fails the same assertion in the existing :324 test.
    • budget.cancelled.set() removed from the cancel path in peer.Jobs.run: test_two_slots_timeout_cancellation_and_shutdown and test_parent_cancellation_records_outcome_once fail.
  • Host timings: tests/test_peer_evidence.py passes all 66 tests in 18 s, about the same as before. The 1e9 CTE is still interrupted at once.
  • make check: lint, mypy on src, 1320 passed, 18 deselected, pip-audit clean. A --- Logging error --- traceback in the test output also appears on main. It does not come from this branch.

Merge Danger

Door: two-way

Tests only, with no change under src/. A revert is one commit.

Blast Radius: CI

A real regression now fails at 5 s, not 1 s. One failure mode gets slower: if SQL progress cancellation breaks, test_sql_progress_cancellation_closes_connection hangs for about two minutes before it fails, because the executor waits for the 1e9 CTE to finish.

Closes #172

🤖 Generated with Claude Code

## Summary Test-only. Every remaining wall-clock bound of 1 s or less in the peer evidence tests gets the #165 margin, without weakening what each test proves. ```diff BOUNDED_WORK_SECONDS = 5 +STUCK_SECONDS = 2 * BOUNDED_WORK_SECONDS # a blocked worker outlives every bound test_real_lock_contention_is_busy_in_50_ms - assert 0.035 <= elapsed < 0.5 + assert 0.035 <= elapsed < BOUNDED_WORK_SECONDS # 50 ms pinned by value at :324 18 waits and bounds at 7 sites (#172 body) - event.wait(1) / wait_for(..., 1) / future.result(timeout=1) / elapsed < 1 + ... BOUNDED_WORK_SECONDS workers that stop on their own - cancelled.wait(2) / release.wait(2) / release.wait(3) + ... STUCK_SECONDS test_sql_progress_cancellation_closes_connection - recursive CTE to 1e8 rows (~10 s uninterrupted) + recursive CTE to 1e9 rows tests/test_peer_changes.py + test_peer_identity_reads_with_the_50_ms_busy_timeout ``` `STUCK_SECONDS` is the part the issue did not list. Four workers used to stop by themselves after 2–3 s. Under a 5 s bound, a broken cancellation would have finished inside it and passed. They now wait 10 s, so a missing cancel still fails the bound. `peer_identity` was the one peer reader with no 50 ms guard. `peer_evidence`, `peer_changes` and `peer_snapshot` already had one, at `test_peer_evidence.py:324`, `test_peer_changes.py:586` and `test_peer_snapshot.py:64`. ## Evidence - **Acceptance grep** (`grep -nE 'wait\(1\)|wait, 1\)|wait_for\(.*, 1\)|timeout=1\b|< 1\b|< 0\.5' tests/test_peer_evidence.py`): **Before:** 18 lines at `febfb55`. **After:** no output. - **Guards still fail when broken** (each change made by hand, then reverted): - `busy_timeout_ms=50` changed to `60` in `peer_identity`: `test_peer_identity_reads_with_the_50_ms_busy_timeout` fails its `kw == {"read_only": True, "busy_timeout_ms": 50}` assertion. The same change in `peer_evidence` fails the same assertion in the existing `:324` test. - `budget.cancelled.set()` removed from the cancel path in `peer.Jobs.run`: `test_two_slots_timeout_cancellation_and_shutdown` and `test_parent_cancellation_records_outcome_once` fail. - **Host timings:** `tests/test_peer_evidence.py` passes all 66 tests in 18 s, about the same as before. The 1e9 CTE is still interrupted at once. - **`make check`:** lint, mypy on `src`, 1320 passed, 18 deselected, `pip-audit` clean. A `--- Logging error ---` traceback in the test output also appears on `main`. It does not come from this branch. ## Merge Danger **Door:** two-way Tests only, with no change under `src/`. A revert is one commit. **Blast Radius:** CI A real regression now fails at 5 s, not 1 s. One failure mode gets slower: if SQL progress cancellation breaks, `test_sql_progress_cancellation_closes_connection` hangs for about two minutes before it fails, because the executor waits for the 1e9 CTE to finish. Closes #172 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Give the remaining peer evidence timing bounds a runner-proof margin
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
46683443f1
Every wall-clock bound and test wait of 1 s or less in tests/test_peer_evidence.py now uses BOUNDED_WORK_SECONDS, and so does the I02 writer's gate wait. A worker that blocks on purpose now waits STUCK_SECONDS, twice the bound, before it gives up. A cancel that never arrives therefore still fails the test, instead of passing on the worker's own 2 s or 3 s timeout.

The SQL progress test's recursive CTE now runs to 1e9 rows. At 1e8 it took about 10 s on the host, too close to the 5 s bound on a faster machine. If progress cancellation breaks, the test now hangs for about two minutes before it fails.

The lock-contention test keeps its 0.035 s lower bound and points at the test that pins ADR 0008's 50 ms busy timeout by value. A new test in tests/test_peer_changes.py pins the same value for peer_identity, the one peer reader that had no such guard.

Closes #172

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
svc-agent-writer deleted branch fix/172-peer-evidence-wall-clock-bounds 2026-11-03 22:52:50 +00:00
Sign in to join this conversation.
No description provided.