- Date: 2026-11-16
- Status: Agreed 2026-11-25 (proposed by Mahad; merged to
mainso everyone’s AI assistant sees it) - Agreed by: Sanchi (2026-11-18), Mahad (2026-11-25)
Context
Decision 0003 made events data instead of code, but nothing else was:- The tickers were a list in
etl/prices_download.py. The ETL guide’slookup/tickers.csvwas never made, so the retailer labels lived nowhere. - The years 2016–2025 were typed into 7 files, the FRED series into
etl/retail_clean.py, and the Kafka topic and servers into 4 scripts. - Every script used paths relative to the folder it was run from, and
join_master.pyneeded asys.pathchange to importcommon. - The contracts still described the original plan (hourly
priceswithtimestamp_utc, anattentiontable), not the files the ETL built.pageviewsandretail_saleshad no contract, andvolumewas int32 where the contract said long.
Decision
- What is studied lives in
config/, one CSV per list, each a contract with a loader incommon.contractsthat checks the header:event_types.csvandevent_dates.csv(as in 0003)retailers.csv(new; replaces the ticker list and the plannedtickers.csv; hasin_scope, like events)wiki_articles.csv(moved fromlookup/wiki_to_ticker.csv, plus anotescolumn)retail_series.csv(new; replaces the dict inretail_clean.py)
- How it is studied stays in
common.study. It gainsSTUDY_STARTandSTUDY_END. The market index is not a retailer;price_tickers()adds it to the downloads. - Where things are goes in
common.settings: theconfig/,raw/,clean/,data/andcheckpoints/paths,clean_path(dataset), the run folders (REPLAY_DIR,STREAM_DIR,RESULTS_DIR), andKAFKA_BOOTSTRAP, which the environment variable of the same name overrides. - The contracts describe the files as built:
prices(daily,volumelong),pageviews,retail_sales,retailers,wiki_articles,retail_series.attentionand the unusedprices/attentionKafka topics are removed. - Every ETL script validates its output with
require_contract(dataset, pandas_columns(df))before writing. src/is an installable package (pyproject.toml;requirements.txtinstalls it with-e .), so scripts run from any folder withoutsys.pathchanges.src/ingest/build_events.pymoved toetl/build_events.py;src/ingest/andlookup/are gone.- Enforced by tests. A hook that Claude Code and Cursor both run tests a copy of what each commit will contain, so each commit has to work on its own (
tests/test_commit_hook.pytests the hook itself).tests/test_no_hardcoding.py: no ticker, event, title, series, year, path, topic or server in the code ofetl/,src/orscripts/, whether as a literal or as a word inside a string. A line ending# not-config: <reason>is the visible exception for values that only look like config.tests/test_config.py: every registry row is valid and consistent.tests/test_clean_files.py: the committed clean files match their contracts andconfig/, cover the whole study period, and carry exactly the calendar’s events. When they don’t, the failure names the script to re-run.
Alternatives considered
- One Python settings module with lists of tickers and series: simpler, but lists in code invite copies, and a CSV is easier for teammates to edit and review.
- Labels only in
config/retailers.csv, not inmaster: the first version of this decision. Meanwhile Anushiya builtlookup/tickers.csvand put the labels intomaster, as the ETL guide planned (commit 14531b0). The merge (2026-11-17) keeps both ideas.mastercarriescountryandretailer_type, so analyses can split online vs store directly, andetl/join_master.pycopies them fromconfig/retailers.csv, so they are typed once.lookup/tickers.csv,etl/tickers_build.pyandclean/tickers.parquetwere removed as copies. - Moving
etl/intosrc/ingest/andclean/intodata/clean/, as the first layout proposed: more change for everyone and no benefit. The docs now describe the layout the team actually uses. - Wrapping each ETL script in functions: skipped. The flat scripts are short, each has one owner, and they read top to bottom for teammates who are learning.
Consequences
- Everyone: run
pip install -r requirements.txtonce more (it installssrc/as a package; without itimport commonfails). Runpython3 -m pytest -qbefore committing; Claude Code and Cursor do it automatically, and refusegit addandgit commitin one command. To add a retailer, an article or a series, see “How to add or change things” in AGENTS.md. - The rewritten scripts give the same data. The old and new versions were run on the same raw files and produced identical values. The only change is that
pricesandmasternow storevolumeas long, so both files were regenerated. - Mahad:
etl/prices_download.py,etl/prices_clean.py, the producers, the streaming job andscripts/check_streaming.pychanged. - Sanchi, please review:
etl/pageviews_download.py,etl/pageviews_clean.py,etl/join_master.py,src/producers/replay_master.py,scripts/create_topics.py,scripts/peek_topic.py, andconfig/wiki_articles.csv(moved fromlookup/).join_master.pyno longer waits forclean/tickers.parquet, andpageviews_clean.pycuts the raw views to the study period before picking each ticker’s current title. - Anushiya, please review:
config/retailers.csv(the ticker list, with three candidates markedin_scope = no) andetl/build_events.py(moved fromsrc/ingest/; it now writes todata/events.parquet). Also the merge with your tickers work:masterkeeps yourcountryandretailer_typecolumns, now read fromconfig/retailers.csv(Shopify’s country isCAthere,Canadain your list), solookup/tickers.csv,etl/tickers_build.pyandclean/tickers.parquetare gone andrun_everything.shno longer calls the build script. - Areej, please review:
etl/retail_clean.py(now castssalesback to whole numbers after dropping FRED’s missing values) andconfig/retail_series.csv. The batch study should take its tickers, events, windows and paths from the same places, and write underRESULTS_DIR(.claude/rules/event-study.md).src/eventstudy/now has an__init__.py. - Open: TSX candidates (
L.TO,CTC-A.TO) would need a TSX market index, soMARKET_TICKERwould become per country. Decide that before putting them in scope.