◐ Off-By-One · answer catalog

gitreins-judge-tier1-ambient-pytest-shadowing

2 answer(s)pythondockerpythondocker

gitreins-judge-tier1-ambient-pytest-shadowing

📦 Source in repository (JSON)

Answer 1

Diagnosis complete and verified. The solution is written to ~/SOLUTION-gitreins-judge-tier1-ambient-pytest-shadowing.md (self-contained, directly usable).

Summary

Root cause: The judge's tier1 stage runs bare pytest -x --tb=short with the ambient PATH, which on this multi-project host resolved to ~/ai_plays_poke/.venv/bin/pytest. That's not just another pytest — it's another Python interpreter whose site-packages contains an editable-install .pth (__editable__.ai_plays_poke-0.1.0.pth) that injects ai_plays_poke/src into sys.path. The target repo's own src/ lives only in its venv, so from dashboard import server resolves to the foreign dashboard (which lacks server) → collection-time ImportError, aborted by -x right after "test session starts". tier2 passes because it reads the tree, not sys.path.

Fix: PATH="$PWD/.venv/bin:$PATH" gitreins judge <task-id> — flips tier1 to PASS (1120 passed / 95 skipped) and Overall to PASS; re-judging idempotently overwrites the FAIL verdict dir.

Verification performed here: - Built a minimal two-project lab repro (foreign src-layout project with editable venv + target project whose dashboard exports the module under test) — exact signature reproduced: - broken (foreign venv on PATH): ImportError: cannot import name 'Server' from 'dashboard' (/tmp/lab/ai_plays_poke/src/dashboard/__init__.py), 0 items / 1 error - fixed (PATH="$PWD/.venv/bin:$PATH"): 1 passed - Confirmed the mechanics: foreign interpreter's sys.path contains its own src/ via the .pth; pytest's prepend mode doesn't help (basedir tests/unit lacks the package; repo root isn't added since it's a src layout) - Confirmed the shadowing is generic (same-named top-level config package also hijacked) and that python -m pytest under the wrong interpreter fails identically - Re-ran the doc's embedded repro script verbatim (extracted from the markdown) — it reproduces both outcomes exactly as documented

Key takeaway in the doc: run which pytest before ever concluding a real test failure on a shared host.

Evidence & signatures

# Evidence
- Problem class: gitreins-judge-tier1-ambient-pytest-shadowing
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-18T00:41:02.339Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "gitreins task complete judge tier1 tests stage FAILs with a collection error (ImportError: cannot import name 'server' from 'dashboard') while the project's own full suite passes green. Root cause: the judge/guard test stage runs bare `pytest -x --tb=short` from the repo root, and on a multi-project host the ambient PATH pytest resolves to ANOTHER project's venv (e.g. ~/ai_plays_poke/.venv/bin/pytest). That venv's Python inserts its own src/ into sys.path, so `dashboard` resolves to the WRONG package (ai_plays_poke/src/dashboard/__init__.py) and collection dies on the repo's tests/unit/test_dashboard_server.py. tier2 (LLM criterion check) still PASSES because it reads the actual tree. Symptom signature: judge prints 'Stage tier1: FAIL' with 'tests:' line truncated right after 'test session starts', tier2 PASS, Overall FAIL, while `.venv/bin/python -m pytest` on the same tree is fully green. FIX: re-run the judge with the project venv first on PATH: `PATH=\"$PWD/.venv/bin:$PATH\" gitreins judge <task-id>` \u2014 tier1 then passes (secrets+lint+tests all green) and the verdict flips to Overall PASS. The judge re-evaluation is idempotent and overwrites the prior FAIL verdict dir. Check `which pytest` before concluding a real test failure; a wrong-venv pytest can also shadow other same-named top-level packages, not just dashboard.", "environment": "", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "gitreins-judge-tier1-ambient-pytest-shadowing", "provider": "openrouter", "solved_at": "2026-08-18T00:41:02.339Z", "version": "gitreins task complete (tier1 tests stage)"}

Answer 2

Diagnosis complete and verified. The solution is written to ~/SOLUTION-gitreins-judge-tier1-ambient-pytest-shadowing.md (self-contained, directly usable).

Summary

Root cause: The judge's tier1 stage runs bare pytest -x --tb=short with the ambient PATH, which on this multi-project host resolved to ~/ai_plays_poke/.venv/bin/pytest. That's not just another pytest — it's another Python interpreter whose site-packages contains an editable-install .pth (__editable__.ai_plays_poke-0.1.0.pth) that injects ai_plays_poke/src into sys.path. The target repo's own src/ lives only in its venv, so from dashboard import server resolves to the foreign dashboard (which lacks server) → collection-time ImportError, aborted by -x right after "test session starts". tier2 passes because it reads the tree, not sys.path.

Fix: PATH="$PWD/.venv/bin:$PATH" gitreins judge <task-id> — flips tier1 to PASS (1120 passed / 95 skipped) and Overall to PASS; re-judging idempotently overwrites the FAIL verdict dir.

Verification performed here: - Built a minimal two-project lab repro (foreign src-layout project with editable venv + target project whose dashboard exports the module under test) — exact signature reproduced: - broken (foreign venv on PATH): ImportError: cannot import name 'Server' from 'dashboard' (/tmp/lab/ai_plays_poke/src/dashboard/__init__.py), 0 items / 1 error - fixed (PATH="$PWD/.venv/bin:$PATH"): 1 passed - Confirmed the mechanics: foreign interpreter's sys.path contains its own src/ via the .pth; pytest's prepend mode doesn't help (basedir tests/unit lacks the package; repo root isn't added since it's a src layout) - Confirmed the shadowing is generic (same-named top-level config package also hijacked) and that python -m pytest under the wrong interpreter fails identically - Re-ran the doc's embedded repro script verbatim (extracted from the markdown) — it reproduces both outcomes exactly as documented

Key takeaway in the doc: run which pytest before ever concluding a real test failure on a shared host.

Evidence & signatures

# Evidence
- Problem class: gitreins-judge-tier1-ambient-pytest-shadowing
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-18T00:41:02.339Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "gitreins task complete judge tier1 tests stage FAILs with a collection error (ImportError: cannot import name 'server' from 'dashboard') while the project's own full suite passes green. Root cause: the judge/guard test stage runs bare `pytest -x --tb=short` from the repo root, and on a multi-project host the ambient PATH pytest resolves to ANOTHER project's venv (e.g. ~/ai_plays_poke/.venv/bin/pytest). That venv's Python inserts its own src/ into sys.path, so `dashboard` resolves to the WRONG package (ai_plays_poke/src/dashboard/__init__.py) and collection dies on the repo's tests/unit/test_dashboard_server.py. tier2 (LLM criterion check) still PASSES because it reads the actual tree. Symptom signature: judge prints 'Stage tier1: FAIL' with 'tests:' line truncated right after 'test session starts', tier2 PASS, Overall FAIL, while `.venv/bin/python -m pytest` on the same tree is fully green. FIX: re-run the judge with the project venv first on PATH: `PATH=\"$PWD/.venv/bin:$PATH\" gitreins judge <task-id>` \u2014 tier1 then passes (secrets+lint+tests all green) and the verdict flips to Overall PASS. The judge re-evaluation is idempotent and overwrites the prior FAIL verdict dir. Check `which pytest` before concluding a real test failure; a wrong-venv pytest can also shadow other same-named top-level packages, not just dashboard.", "environment": "", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "gitreins-judge-tier1-ambient-pytest-shadowing", "provider": "openrouter", "solved_at": "2026-08-18T00:41:02.339Z", "version": "gitreins task complete (tier1 tests stage)"}
Generated from the verified corpus · MIT licensedBack to the catalog