AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
test(chat): fix the committee integration test and run integration tests in CI (#244)
Rufusca040ed4c223
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.mdindex da808071..0405bc7e 100644--- a/.github/CONTRIBUTING.md+++ b/.github/CONTRIBUTING.md@@ -7,8 +7,8 @@3. Copy `.env.example` to `.env` and add your `ANTHROPIC_API_KEY`4. Start the dev server: `make dev`5. Run the tests: `make test`-6. Before opening a PR: `make check` (lint, unit tests, the UI build if- `packages/ui` changed, and the PR rules below)+6. Before opening a PR: `make check` (lint, unit and integration tests, the UI+ build if `packages/ui` changed, and the PR rules below). No API key needed.## Branch Naming@@ -21,7 +21,7 @@## PR RequirementsAll PRs must:-1. Pass CI (ruff, mypy, unit tests, and `scripts/pr_checks.py` — the no-stubs,+1. Pass CI (ruff, mypy, unit and integration tests, and `scripts/pr_checks.py` — the no-stubs,eval-scenario and architecture-docs rules below)2. Include working code — no stubs, no placeholders3. Include tests for new behavior@@ -40,6 +40,10 @@ All PRs must:how it works, with the checklist filled in. PRs submitted with an emptytemplate will be closed; you're welcome to resubmit with the sectionscompleted.+8. **Address the automated review.** Claude reviews each non-draft PR opened+ from a branch in this repo and leaves inline comments. Fix each finding or+ reply saying why not. PRs from forks don't get it, because GitHub doesn't+ pass secrets to fork workflows; a maintainer reviews those.## Adding a New Specialist Agentdiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex c8436b17..1d2e980f 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -86,6 +86,11 @@ jobs:- name: Run unit testsrun: cd packages/core && uv run pytest tests/unit/ -n auto --dist loadfile --tb=short+ # Route-level tests against a temp SQLite DB, with the model calls+ # stubbed; no API key needed. Left out of CI, one rotted unnoticed.+ - name: Run integration tests+ run: cd packages/core && uv run pytest tests/integration/ -n auto --dist loadfile --tb=short+ui-typecheck:name: UI type checkruns-on: ubuntu-latestdiff --git a/CLAUDE.md b/CLAUDE.mdindex ee23c156..113f6ad9 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -199,16 +199,17 @@ See `.env.example`. Required: `ANTHROPIC_API_KEY`, `EXEC_EMAIL_ADDRESS` (no defa> is unaffected — lint the specific test files you touched rather than> `tests/` as a whole.-> **Known-red on `main`:** `tests/integration/test_chat_committee.py::-> test_chat_with_committee_streams_phases_and_revised_text` fails on the-> base commit independently of local changes; deselect it when comparing-> full-suite runs.+> **Integration tests need no API key:** `tests/integration/` drives the+> FastAPI routes against a temp SQLite DB with the model calls stubbed, and+> CI runs it next to `tests/unit/`. Stub `utils.session_title.generate_session_title`+> and `knowledge.retriever.retrieve` in any new route test, or it reaches the+> live API (see `patched_deps` in `test_chat_committee.py`).```bash# Unit tests (no API calls)pytest packages/core/tests/unit/ -v-# Integration tests (requires ANTHROPIC_API_KEY)+# Integration tests (route-level, stubbed model calls, no API key)pytest packages/core/tests/integration/ -v# Eval suitediff --git a/Makefile b/Makefileindex 249681ef..4db9ec50 100644--- a/Makefile+++ b/Makefile@@ -58,7 +58,7 @@ lint:BASE ?= origin/maincheck: lintcd packages/core && env -u BACKEND_SHARED_SECRET -u OE_PUBLIC_DEPLOYMENT \- uv run pytest tests/unit/ -n auto --dist loadfile -q+ uv run pytest tests/unit/ tests/integration/ -n auto --dist loadfile -q@if ! git diff --quiet $$(git merge-base $(BASE) HEAD) -- packages/ui \|| [ -n "$$(git ls-files --others --exclude-standard packages/ui)" ]; then \cd packages/ui && npm run build; \diff --git a/packages/core/tests/integration/test_chat_committee.py b/packages/core/tests/integration/test_chat_committee.pyindex 3a82f1d4..aed08ea6 100644--- a/packages/core/tests/integration/test_chat_committee.py+++ b/packages/core/tests/integration/test_chat_committee.py@@ -1,6 +1,7 @@"""Chat route integration tests for the Committee opt-in path."""from __future__ import annotations+import jsonfrom collections.abc import AsyncIteratorfrom pathlib import Pathfrom typing import Any@@ -37,6 +38,14 @@ def patched_deps(monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setattr(profile_builder, "load_or_create_profile", lambda: CompanyProfile())monkeypatch.setattr(retriever, "retrieve", lambda **_k: "")+ # Keep the turn off the live Anthropic API (the route titles new sessions).+ from openexecutive.utils import session_title++ async def _no_title(*_args: Any, **_kwargs: Any) -> None:+ return None++ monkeypatch.setattr(session_title, "generate_session_title", _no_title)+def test_chat_with_committee_streams_phases_and_revised_text(temp_db: Path, patched_deps: None, monkeypatch: pytest.MonkeyPatch@@ -103,9 +112,15 @@ def test_chat_with_committee_streams_phases_and_revised_text(assert '"type": "done"' in body# Persisted assistant message is the revised text, not the draft.- msgs = session_store.list_sessions(db_path=temp_db)- assert len(msgs) == 1- history = session_store.load_messages(msgs[0]["session_id"], db_path=temp_db)+ # The session id comes from the done event; list_sessions() is scoped+ # to an owner, which this unauthenticated test app doesn't have.+ events = [+ json.loads(line[len("data: "):])+ for line in body.splitlines()+ if line.startswith("data: ")+ ]+ session_id = next(e["session_id"] for e in events if e.get("type") == "done")+ history = session_store.load_messages(session_id, db_path=temp_db)assistant = [m for m in history if m["role"] == "assistant"]assert len(assistant) == 1assert assistant[0]["content"] == "Revised executive response."