gitreins-worktree-guard-full-suite-shared-db-flake-wave-contention
The solution is written and verified. Full document at /workspace/solution/SOLUTION.md.
The wedge is a chain of four independent faults, not one bug:
dexdat_test; sibling suites mutate bootstrap/admin rows concurrently.DEGRADED PASS ... allowed, but the hook exits non-zero because nothing maps DEGRADED_PASS → 0. Workers therefore retry forever.| # | Change | Fixes |
|---|---|---|
| 1 | Path-scoped short-circuit: non-Python diff → SKIP, never spawn pytest |
zero-Python wedge |
| 2 | Per-worktree DB dexdat_test_<worktree> exported via DEXDAT_TEST_DSN |
sibling contention |
| 3 | Scoped test selection (impacted() / --testmon) |
timeout |
| 4 | Explicit guard exit contract: 0=PASS, 1=FAIL, 2=DEGRADED_PASS; hook maps 2→exit 0 |
the "lie" + infinite retry |
| 5 | Bounded, classified worker retry as defense-in-depth | livelock |
| 6 | Advisory-lock + rollback fixtures for the three flaky tests | flaky fixtures |
12 passed — covers empty/docs-only → skip, Python/manifest → run, and critically hook_exit(2) == 0.pre-commit hook and injected fake guards:guard_pass → exit 0guard_degraded → exit 0 (previously aborted)guard_hard_fail → exit 1skip, Python diff → runALL E2E CHECKS PASSEDArtifacts together: fix/gitreins_scope.py, fix/tier1-guard.sh, fix/pre-commit, verify/test_gitreins_scope.py, verify/e2e_hook_check.sh, plus the wave acceptance checklist in §4.3 of the doc.
# Evidence - Problem class: gitreins-worktree-guard-full-suite-shared-db-flake-wave-contention - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-25T03:28:37.730Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "In wave dispatch (one worker per git worktree), each worker Tier-1 guard runs the FULL pytest suite against the shared dexdat_test DB (conftest default localhost:5435). Under sibling concurrency the suite exceeds the 300s guard timeout or fails on the documented batched-DB-contention fixture tests (test_list_contexts_filter_by_type, test_first_user_admin_reaches_admin_gated_endpoint, test_admin_bootstrap_dangling), so commits wedge even when the diff contains zero Python files. Also: guard DEGRADED PASS with hook_timeout says commit allowed to proceed (fail-open) but the pre-commit hook still aborts, so the message lies and the worker retries forever.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "gitreins-worktree-guard-full-suite-shared-db-flake-wave-contention", "provider": "openrouter", "solved_at": "2026-09-25T03:28:37.730Z", "version": ""}