Skip to main content
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
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
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
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
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
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
7

tests/test_streaming_signals.py

The streaming job’s per-ticker logic (src/streaming/signals.py), tested without Spark. Read it
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
9

tests/test_compare.py

Tests for streaming.compare, the streaming vs batch comparison (task #9). Read it
10

tests/test_ml_features.py

Tests for ml.features: the calendar and retailer features of the big-move model (decision 0007). Read it
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
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
13

tests/test_docs_site.py

The documentation site (docs-site/, decision 0011) must cover every file and be up to date. Read it
14

tests/test_ai_usage.py

The AI usage logs (AGENTS.md rule 7) stay in step with the work. Read it
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
16

pyrightconfig.json

See the file. Read it
17

.gitignore

Data and outputs: never commit Read it
18

AGENTS.md

Calendar Effects (CMPT 732, Fall 2026) Read it
19

CLAUDE.md

Claude Code specifics Read it
20

.claude/settings.json

See the file. Read it
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
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
23

scripts/build_docs.py

Build the documentation site in docs-site/ (Mintlify) from the code and docs/ (decision 0011). Read it
24

scripts/sync_docs_site.sh

Push docs-site/ to the docs repository Mintlify deploys from (decision 0011). Read it
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
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
27

scripts/install_git_hooks.sh

Install this repository’s git hooks on your machine (decision 0011). Optional, per person. Read it
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
29

CITATION.cff

GitHub shows this as “Cite this repository”; it also credits every team member (decision 0013). Read it

Questions you should be able to answer

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.
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.
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.