> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 10. Tests and team tooling

> The tests that guard all of the above, and the setup that keeps four people and their AI assistants in step.

The project was built by four people, mostly with AI assistants, so it relies on rules a machine checks rather than rules people remember.

## The big idea

* **Tests gate every commit.** A Claude Code hook (`.claude/hooks/pre-commit-tests.sh`, which Cursor runs too) runs `python3 -m pytest -q` on a copy of exactly what the commit will contain, and refuses the commit if anything fails.
* **The tests check rules, not just code:** contracts in the docs equal contracts in the code; `config/` follows its rules; no script types a ticker, event, year or path that `config/` or `common/` defines; the clean files match their contracts; the streaming logic, the batch study, the comparison, the model's features, the dashboard, the live feed, the recording and the published data each have their own tests.
* **These docs stay in sync the same way:** `scripts/build_docs.py` regenerates the site, and `tests/test_docs_site.py` fails if the site is out of date or a file has no place in the tour.
* **Shared AI context:** `AGENTS.md` (the team's rules for any assistant), `CLAUDE.md` (Claude Code specifics), project skills (`/sync`, `/handoff`, `/decision`), a session-start hook that prints the team's status, and a contract-checker subagent.

### Read these files in this order

**1. tests/test\_contracts.py**

The written contracts (docs/data-contracts.md) and the code (src/common/contracts.py) must always describe the same schemas. If one changes without the other, these tests fail. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_contracts.md)

**2. tests/test\_config.py**

The registries in config/ (retailers, Wikipedia articles, retail series) must follow their contracts, so anyone can add a retailer, an article or a series by adding a row without breaking the pipeline. The event calendar has its own tests (test\_event\_calendar.py). [Read it](https://calendar-effects.mintlify.site/reference/tests/test_config.md)

**3. tests/test\_event\_calendar.py**

The event calendar (config/event\_types.csv and config/event\_dates.csv) must follow its contract, so anyone can add an event by adding a row without breaking the pipeline. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_event_calendar.md)

**4. tests/test\_expand\_events.py**

The date-rule expander (common.contracts.expand\_events) turns event\_types.csv rules and event\_dates.csv listed dates into actual per-year occurrences. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_expand_events.md)

**5. tests/test\_clean\_files.py**

The committed clean files (clean/\*.parquet) must match their contracts and what config/ and common.study say should be in them. A file that is out of date, such as a retailer added to config/retailers.csv without re-running the ETL, fails here with the script to re-run. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_clean_files.md)

**6. tests/test\_no\_hardcoding.py**

Pipeline code must not type in a value that config/ or common/ already defines (decision 0005). Otherwise adding a retailer, an event or a year means hunting through scripts, and the copies drift apart. If a test here fails, import the value instead: [Read it](https://calendar-effects.mintlify.site/reference/tests/test_no_hardcoding.md)

**7. tests/test\_streaming\_signals.py**

The streaming job's per-ticker logic (src/streaming/signals.py), tested without Spark. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_streaming_signals.md)

**8. tests/test\_eventstudy.py**

The batch event study (src/eventstudy/) on small hand-made data where the right answer is known in advance. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_eventstudy.md)

**9. tests/test\_compare.py**

Tests for streaming.compare, the streaming vs batch comparison (task #9). [Read it](https://calendar-effects.mintlify.site/reference/tests/test_compare.md)

**10. tests/test\_ml\_features.py**

Tests for ml.features: the calendar and retailer features of the big-move model (decision 0007). [Read it](https://calendar-effects.mintlify.site/reference/tests/test_ml_features.md)

**11. tests/test\_dashboard.py**

Tests for the dashboard (decisions 0008 and 0013): it reads only finished micro-batches, and every view runs without errors, on a laptop and hosted (where there is no local stream). [Read it](https://calendar-effects.mintlify.site/reference/tests/test_dashboard.md)

**12. tests/test\_hosting.py**

Tests for the dashboard's snapshot data, the live feed and the Hugging Face publishing (decisions 0010 and 0013). [Read it](https://calendar-effects.mintlify.site/reference/tests/test_hosting.md)

**13. tests/test\_docs\_site.py**

The documentation site (docs-site/, decision 0011) must cover every file and be up to date. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_docs_site.md)

**14. tests/test\_ai\_usage.py**

The AI usage logs (AGENTS.md rule 7) stay in step with the work. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_ai_usage.md)

**15. tests/test\_commit\_hook.py**

The commit hook (.claude/hooks/pre-commit-tests.sh) blocks exactly the commits whose tests fail, judged on what the commit will contain. Each test builds a throwaway git repo with one test file and feeds the hook a Bash command the way Claude Code does. [Read it](https://calendar-effects.mintlify.site/reference/tests/test_commit_hook.md)

**16. pyrightconfig.json**

See the file. [Read it](https://calendar-effects.mintlify.site/reference/pyrightconfig-json.md)

**17. .gitignore**

Data and outputs: never commit [Read it](https://calendar-effects.mintlify.site/reference/gitignore.md)

**18. AGENTS.md**

Calendar Effects (CMPT 732, Fall 2026) [Read it](https://calendar-effects.mintlify.site/reference/AGENTS-md.md)

**19. CLAUDE.md**

Claude Code specifics [Read it](https://calendar-effects.mintlify.site/reference/CLAUDE-md.md)

**20. .claude/settings.json**

See the file. [Read it](https://calendar-effects.mintlify.site/reference/claude/settings-json.md)

**21. .claude/hooks/session-brief.sh**

Team briefing printed at the start of every Claude Code session. Claude Code adds whatever this prints to Claude's context (SessionStart hook, configured in .claude/settings.json). Keep it fast and offline: no network calls. [Read it](https://calendar-effects.mintlify.site/reference/claude/hooks/session-brief-sh.md)

**22. .claude/hooks/pre-commit-tests.sh**

PreToolUse hook (configured in .claude/settings.json): before Claude runs a Bash command that runs `git commit`, run the test suite on exactly what will be committed and block the commit if it fails. Exit code 2 tells Claude Code to block the tool call and show stderr to Claude. [Read it](https://calendar-effects.mintlify.site/reference/claude/hooks/pre-commit-tests-sh.md)

**23. scripts/build\_docs.py**

Build the documentation site in docs-site/ (Mintlify) from the code and docs/ (decision 0011). [Read it](https://calendar-effects.mintlify.site/reference/scripts/build_docs.md)

**24. scripts/sync\_docs\_site.sh**

Push docs-site/ to the docs repository Mintlify deploys from (decision 0011). [Read it](https://calendar-effects.mintlify.site/reference/scripts/sync_docs_site-sh.md)

**25. scripts/sync\_dashboard\_app.sh**

Push the hosted dashboard's files to the repository Streamlit Community Cloud deploys from (decision 0013). The hosted app is src/dashboard/app.py itself, with only the code it imports, the config/ lists and the recorded snapshot; nothing with prices. [Read it](https://calendar-effects.mintlify.site/reference/scripts/sync_dashboard_app-sh.md)

**26. scripts/sync\_live\_stream.sh**

Copy what the cloud streamer runs into the `project` branch of the team's private live-stream repository on github.com (decision 0015), so its workflow needs no access to github.sfu.ca. The copy is only what scripts/demo\_live.sh needs: src/, config/, clean/master.parquet (the replay's input), the demo script, requirements.txt and pyproject.toml. The model comes from Hugging Face. [Read it](https://calendar-effects.mintlify.site/reference/scripts/sync_live_stream-sh.md)

**27. scripts/install\_git\_hooks.sh**

Install this repository's git hooks on your machine (decision 0011). Optional, per person. [Read it](https://calendar-effects.mintlify.site/reference/scripts/install_git_hooks-sh.md)

**28. scripts/install\_workflows.sh**

Put the cloud streamer's workflow and page into the team's private live-stream repository on github.com (decision 0015): hosting/workflows/live-stream.yml -> Calendar-Effects/live-stream/.github/workflows/ hosting/live-stream/README.md -> Calendar-Effects/live-stream/README.md Run it again after changing either. It signs in with the GitHub CLI (gh auth login, with the workflow scope: gh auth refresh -h github.com -s workflow), and pushes only what changed. The code the workflow runs is a separate copy on the repository's `project` branch (scripts/sync\_live\_stream.sh). [Read it](https://calendar-effects.mintlify.site/reference/scripts/install_workflows-sh.md)

**29. CITATION.cff**

GitHub shows this as "Cite this repository"; it also credits every team member (decision 0013). [Read it](https://calendar-effects.mintlify.site/reference/CITATION-cff.md)

## Questions you should be able to answer

> [accordion] How do you know the project works?
>
> Every commit passes the test suite; the stream matches a direct numpy recomputation and an independent batch study on all 2,280 windows; the clean files match their contracts.

> [accordion] What happens when someone adds a new file?
>
> `tests/test_docs_site.py` fails until the file is placed in a chapter of `docs-site/reading_order.json` and the site is rebuilt, so the tour always covers the whole codebase.

> [accordion] Why run git add and git commit separately?
>
> The hook copies what is staged when the command starts. In `git add x && git commit` the add has not happened yet, so the tests would miss it; the hook refuses that form.

## Ideas to improve it

* Run the same tests in CI on every push, so commits made without the hook are checked too.
* Add a small end-to-end test: replay a month of data through the job and compare with the batch study.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.