Skip to content

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.md
index 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 Requirements
All 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 placeholders
3. Include tests for new behavior
@@ -40,6 +40,10 @@ All PRs must:
how it works, with the checklist filled in. PRs submitted with an empty
template will be closed; you're welcome to resubmit with the sections
completed.
+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 Agent
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c8436b17..1d2e980f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -86,6 +86,11 @@ jobs:
- name: Run unit tests
run: 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 check
runs-on: ubuntu-latest
diff --git a/CLAUDE.md b/CLAUDE.md
index 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 suite
diff --git a/Makefile b/Makefile
index 249681ef..4db9ec50 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ lint:
BASE ?= origin/main
check: lint
cd 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.py
index 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 json
from collections.abc import AsyncIterator
from pathlib import Path
from 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) == 1
assert assistant[0]["content"] == "Revised executive response."