Skip to content

test(cold-start): hermetic SessionStart banner — kill live-env dependency (#174 follow-up)#183

Merged
cdeust merged 1 commit into
mainfrom
fix/cold-start-hermetic-174
Jul 25, 2026
Merged

test(cold-start): hermetic SessionStart banner — kill live-env dependency (#174 follow-up)#183
cdeust merged 1 commit into
mainfrom
fix/cold-start-hermetic-174

Conversation

@cdeust

@cdeust cdeust commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Follow-up to #174 / #180 (merged). The first full-suite run after #180 surfaced two more failures in the same test-isolation family; this PR fixes the one that is a genuine test defect.

test_cold_start.py::test_normal_session_with_memories — live-environment dependency

Root cause: the test ran session_start.py as a subprocess under the inherited real environment. The SessionStart backend gate reads the developer's live backend marker (~/.claude/methodology/backend.json); the banner then reads the real ~/.claude/methodology/memory.db (or a live PostgreSQL); and the subprocess additionally spawned detached consolidate/reanalyze workers against the real HOME and repo. The in-process remember seed landed in the per-process test DB while the subprocess read a different live store — so the assertion outcome depended on whose machine ran it (failed on this developer's populated home, passed on an empty CI home). The seed's raw UPDATE ... NOW() is also PostgreSQL-only, silently mismatched under the SQLite default.

Fix (test-side — the SQLite banner path itself is already proven correct by tests_py/hooks/test_sqlite_hook_paths.py): rewritten to the canonical hermetic pattern — seed an ephemeral SqliteMemoryStore in tmp_path and drive _sqlite_context in-process via a monkeypatched get_shared_store, asserting the seeded memory is injected and no PostgreSQL install guidance leaks. Deterministic and environment-independent; same behavior verified (DB has memories -> banner injected, not cold start).

The second failure — test_I2_no_unauthorized_heat_writes — is NOT a code defect

test_I2 is a stateless static source scan (rglob mcp_server/**/*.py, compare SET heat_base sites to a line-pinned allow-list). It holds no runtime state, so it cannot carry hidden shared state between tests. Its one observed failure occurred in a working tree a second concurrent agent was actively mutating (running its own pytest tests_py/ and editing test_I2 + pg_store.py/sqlite_store.py on another branch in the same checkout); a git checkout/edit landing mid-run shifts the pinned offsets so the scan reads source that no longer matches the allow-list. It passes standalone and in every controlled/isolated run — no code change is warranted (hardening the scan against a concurrently-mutated tree would only weaken the invariant it guards).

Gates: ruff check + ruff format --check pass. Full suite verified green in an isolated worktree (own source via PYTHONPATH, own throwaway DB via conftest), immune to the concurrent agent's mutations.

🤖 Generated with Claude Code

…ependency (#174)

test_normal_session_with_memories ran session_start.py as a subprocess
under the inherited real environment: the SessionStart backend gate read
the developer's live backend marker (~/.claude/methodology/backend.json),
the banner then read the real ~/.claude/methodology/memory.db (or a live
PostgreSQL), and the subprocess additionally spawned detached
consolidate/reanalyze workers against the real HOME and repo. The
in-process `remember` seed landed in the per-process test DB while the
subprocess read a *different* live store, so the assertion outcome
depended on whose machine ran it (it failed on this developer's machine,
passed on an empty CI home). The raw `UPDATE ... NOW()` seed is also
PostgreSQL-only, silently mismatched under the SQLite default.

Rewritten to the canonical hermetic pattern already used by
tests_py/hooks/test_sqlite_hook_paths.py: seed an ephemeral
SqliteMemoryStore in tmp_path and drive the SQLite banner path
(_sqlite_context) in-process via a monkeypatched get_shared_store,
asserting the seeded memory is injected and no PostgreSQL install
guidance leaks. Same behavior verified (DB has memories -> banner
injected, not cold start), now deterministic and environment-independent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cdeust

cdeust commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

Full-suite proof (this machine, live ~/.claude present)

Run on current main + this cold_start fix, in an isolated git worktree (own source via PYTHONPATH, own per-process throwaway DB via conftest) so the result is immune to a second agent's concurrent pytest + git checkout activity in the shared checkout:

5352 passed, 12 skipped, 9 warnings in 2673.84s (0:44:33)
EXITCODE=0

Zero failures. The three originally-failing test_rebuild_profiles cases (fixed in merged #180), the rewritten test_cold_start::test_normal_session_with_memories, and test_I2_no_unauthorized_heat_writes are all green. I2 needed no code change — it is a stateless static source scan whose one prior failure was concurrent shared-checkout mutation, not hidden state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant