AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
test(scheduler): keep the runner tests off the default database (#247)
Rufusb0f24dc18e87
diff --git a/CLAUDE.md b/CLAUDE.mdindex 217fb6c9..1f814c90 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -190,6 +190,14 @@ See `.env.example`. Required: `ANTHROPIC_API_KEY`, `EXEC_EMAIL_ADDRESS` (no defa> "handled overnight" block). Patch it in an autouse fixture, and delete a> stray `packages/core/episodic_memory.db` (gitignored) if one appears.+> **Patching `episodic.DB_PATH` isn't enough:** most readers in+> `memory/episodic.py` (`format_for_prompt`, `get_active_initiatives`, …)+> bind `DB_PATH` as a default argument at import, and the audit logger keeps+> its own path, so both still use `./episodic_memory.db`. If a stray copy of+> that file lacks the `decisions` table, the test fails with "no such table"+> depending on what ran before it. Point them at the test DB too, as the `db`+> fixture in `tests/integration/test_scheduler_runner.py` does.+> **ContextVar leaks between tests:** a *sync* fixture or test that sets> `current_session` (or any module-level ContextVar) and doesn't reset it> leaves that value bound for every later test in the process.diff --git a/packages/core/tests/integration/test_scheduler_runner.py b/packages/core/tests/integration/test_scheduler_runner.pyindex e76ee27b..71774bd8 100644--- a/packages/core/tests/integration/test_scheduler_runner.py+++ b/packages/core/tests/integration/test_scheduler_runner.py@@ -8,10 +8,13 @@ from __future__ import annotationsimport asynciofrom datetime import UTC, datetime, timedelta+from functools import partialfrom pathlib import Pathimport pytest+from openexecutive.audit import logger as audit_logger+from openexecutive.memory import episodicfrom openexecutive.memory.episodic import (ScheduledAction,claim_due_actions,@@ -27,6 +30,16 @@ def db(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:db_path = tmp_path / "episodic.db"initialize_db(db_path)monkeypatch.setattr("openexecutive.memory.episodic.DB_PATH", db_path)+ # Patching DB_PATH misses two things _execute_action touches:+ # format_for_prompt() bound DB_PATH as a default argument at import, and+ # the audit logger keeps its own path. Both fell back to+ # ./episodic_memory.db in the working directory, so the retry test failed+ # with "no such table: decisions" whenever that file held only the audit+ # rows an earlier test had written there.+ monkeypatch.setattr(+ episodic, "format_for_prompt", partial(episodic.format_for_prompt, db_path=db_path)+ )+ monkeypatch.setattr(audit_logger, "_default_logger", audit_logger.AuditLogger(db_path=db_path))return db_path@@ -208,7 +221,7 @@ def test_scheduler_dispatches_due_actions_when_company_profile_active(assert action_id in dispatched-def test_runner_loop_cancellable() -> None:+def test_runner_loop_cancellable(db: Path) -> None:"""The loop must respect asyncio cancellation."""async def _runner() -> None: