fix(tests): session-scoped engine-state isolation — close the module-scope escape to the live life-store #100
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/test-engine-state-isolation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
T10 from the 2026-07-22 weekly audit (root cause behind the T2 warning churn).
Defect
The root-conftest isolation fixture (
_isolate_engine_state_default) is function-scoped, and pytest sets up higher-scoped fixtures first — so a module-/session-scoped fixture constructing a bareChatRuntime()bindsengine_state._DEFAULT_DIRbefore any patch exists.tests/test_achat.py's module-scopedruntimedid exactly that during smoke runs: it loaded the live life-store (emitting the ADR-0157 revision-mismatch warning against the real checkpoint — the "warning fatigue" T2 flagged) and committed real generations (observed: liveturn_count14989→14990,written_at_revisionre-stamped by the suite). Content pollution was nil in the observed instance (recognizers/candidates byte-identical), but lineage provenance was not test-free.Fix (TDD)
tests/test_conftest_engine_state_isolation.py::test_module_scoped_construction_cannot_bind_the_live_store— a module-scoped fixture constructs the default store and fails if it resolves to the repo dir (verified failing before the fix)._isolate_engine_state_session_baselinein rootconftest.py— session-scoped autouse fixture (set up before any narrower scope) pointingengine_state._DEFAULT_DIR+CORE_ENGINE_STATE_DIRat a session temp dir. The per-test fixture keeps providing per-test freshness on top;uses_default_engine_statestill opts out of the per-test layer only (resolution semantics preserved; the live store is unreachable at every scope).docs/issues/default-engine-state-test-hygiene.md: status updated + 2026-07-22 addendum with the evidence.Validation
-m "not quarantine and not slow" -n auto): 12,396 passed, 1 failed — the single failure (test_warmed_session_lane.py::…::test_telemetry_consistency_rate_is_one, rate 0.9444) is pre-existing on unmodified main (verified failing there both plain and state-isolated; it is the T13 #96 surface-override regression, ledgered separately). Zero new failures from this change.[Verification]:
uv run core test --suite smoke -qin worktreecore-wt-t2fix@ HEAD — 180 passed in 131.58s, exit 0.Merge on your authorization. Residual rulings tracked as T11 (live-store provenance review) in the audit ledger.