Collection as an ETL pipeline; runs_clean.csv from every source; Report a run

- collection/pipeline.yaml declares every source (extract kind, transform,
  privacy rules, load target, run source); `python -m collection update|build`
- extract keeps data/raw/<source>/current + previous only (git-ignored);
  data/manifest.json records the current raw checksum and change date
- transforms are pure; validate checks runs against data/dictionary.yaml
  before load; load writes byte-stable files only when they change
- data/public/runs_clean.csv: every run from every source with a new
  `source` column (reddit spreadsheet, reddit thread, reported, bot,
  reddit pdf); the sheet's own row label moves to `entry`; run_id is text
- bot importer ported to Python (same output as bot.js on the fixture);
  labels and crosswalk in collection/specs/bot.yaml, written into graph.js
- Reddit through the official API (result links to add by hand); the 12
  result pages move to collection/manual/reddit_results.yaml
- "Report a run": a GitHub issue form generated from
  collection/specs/report_form.yaml, collected as source "reported", plus a
  site tab pointing to it, the community spreadsheet and the megathread
- analysis and the route model read runs_clean.csv (sources in
  measures.yaml); stats.json and policy.json unchanged apart from the
  factor's new name
- daily workflow runs the pipeline; the raw store is kept between runs in
  the Actions cache, encrypted with RAW_ARCHIVE_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-04 02:46:48 +00:00
co-authored by Claude Opus 5.5
parent 61bc50583c
commit 3b24a11f5a
64 changed files with 8626 additions and 6909 deletions
+5 -6
View File
@@ -1,21 +1,20 @@
"""The data dictionary describes every published column and value, and data/croissant.json matches it."""
import csv
import importlib.util
import json
import re
import sys
import unittest
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[2]
spec = importlib.util.spec_from_file_location("publish_metadata", ROOT / "collection" / "publish_metadata.py")
publish_metadata = importlib.util.module_from_spec(spec)
spec.loader.exec_module(publish_metadata)
sys.path.insert(0, str(ROOT))
from collection.etl import metadata as publish_metadata # noqa: E402
with open(ROOT / "data" / "dictionary.yaml", encoding="utf-8") as f:
DICT = yaml.safe_load(f)
with open(ROOT / "data" / "derived" / "runs_clean.csv", encoding="utf-8", newline="") as f:
with open(ROOT / "data" / "public" / "runs_clean.csv", encoding="utf-8", newline="") as f:
reader = csv.DictReader(f)
HEADER = reader.fieldnames
ROWS = list(reader)
@@ -61,7 +60,7 @@ class Croissant(unittest.TestCase):
def test_croissant_is_up_to_date(self):
expected = publish_metadata.render(publish_metadata.build(DICT))
actual = (ROOT / "data" / "croissant.json").read_text(encoding="utf-8")
self.assertEqual(actual, expected, "run python3 collection/publish_metadata.py")
self.assertEqual(actual, expected, "run python -m collection build")
def test_fields_and_checksums(self):
doc = json.loads((ROOT / "data" / "croissant.json").read_text(encoding="utf-8"))