Repository navigation
Description
Overview
The ⏱ performance surface now has both timing slices — workflow-level gates (ci_timing) and per-script smoke timings (smoke_timings, #202 / #203) — but its only "history" is the self-carried window: the aggregate steps re-read the previously published Pages board.json, cap the gate history at 30 entries and keep exactly one previous per-script observation. A publish gap loses it and nothing is ever committed. This task builds the permanent record: the daily heart-health.yml run appends the day's observations to committed, append-only files under timings/ in this repo, the two checks read their baselines from that record (the Pages self-carry becomes a fallback cache), and the board links to it.
Phase 2 of the ci-timing-fast-tests epic (PyAutoMind/draft/feature/pyautoheart/ci_timing_fast_tests_epic.md). Design reference: Plane C ("durable baselines") of PyAutoMind/docs/pyautoheart/test_performance_board_assessment.md.
Plan
- Add
heart/timings.py: a pure append-only record with two shapes — a per-day gates line (timings/gates.jsonl) and a per-repo, per-run scripts line (timings/scripts/<repo>.jsonl) — plus readers that hand the two checks their baselines. - Dedupe on identity, not date: a gates line per
date; a scripts line per(python leg, run_id). A quiet week must not write seven copies of one run (thescript_timing"one value repeated seven times" defect, phase 0 of the board arc). - Make
ci_timingandsmoke_timingsread the committed record first and the previousboard.jsononly as fallback; keep theboard.jsonshape unchanged so the Brain board and the dashboard tests are untouched. - Wire one workflow step after the checks that appends today's observations and commits
timings/onmainonly, in the same commit as the README badge update (one commit per day,[skip ci], stable line ordering, no rewrite of past lines). - Document the record in
timings/README.md(schema, dedupe rule, how to read it) and reserve the place phase 4 will mark the LEGACY epoch boundary.
Detailed implementation plan
Affected Repositories
- PyAutoHeart (primary, only)
Work Classification
Library (organ code) — no workspace follow-up.
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoHeart | main @ 7a286ea | clean |
Branch: claude/ci-test-timing-epic-ke2lul (designated for the epic; restarted from the merged main; cloud session, no task worktree).
The record (timings/)
timings/
README.md # schema + the rules below (doctrine, not a ledger entry)
gates.jsonl # one line per UTC date
scripts/<repo>.jsonl # one line per (python leg, run id) observation
gates.jsonlline —{"date": "2026-09-06", "ts": "...", "gates": {"<repo>/<workflow>": {"p50_s", "pr_median_s", "max_s", "queue_median_s", "runs"}}}— exactly the per-gate figuresci_timing.roll_historyalready stores per day, pluspr_median_s/max_s/queue_median_s. Keyed bydate: re-running the same day replaces nothing — the append is skipped when the date is already present (the workflow runs once a day; a manual re-dispatch must not double-write).scripts/<repo>.jsonlline — one per leg observation:{"date", "at", "python", "run_id", "run_url", "head_branch", "head_sha", "env_profile", "entries": {"<entry>": [seconds|null, "<status>", cap_s|null]}}with entries sorted by path. Keyed by(python, run_id): a day whose newest artifact is the same run as yesterday's appends nothing for that leg. This is the whole point of phase 1 stampingrun_idon every row.- Append-only:
append_*functions only ever add lines; a test asserts that existing lines are byte-identical after an append. Lines are compact single-line JSON with sorted keys so a daily diff is one or a few added lines. Files are created on first use; a missing file is an empty record. - Growth shape: gates ≈ 1 line/day (~3 KB); scripts ≤ 2 lines/day/repo (~2–5 KB each) — reviewable for years; note in the README when to consider yearly sharding (not now).
- Phase 4 reservation: the README names
timings/epochs.jsonlas the place a labeled epoch boundary (e.g.{"date", "label": "legacy", "note"}) will live, so drift never fires across it; do not create it here.
Implementation Steps
-
heart/timings.py(stdlib only, pure core + thin I/O):TIMINGS_DIR = HEART_HOME / "timings",GATES_FILE,scripts_file(repo).read_jsonl(path) -> list[dict](tolerates a missing file and skips unparseable lines, counting them so the caller can report them).gates_line_from_rollup(rollup, today, ts) -> dict(fromci_timing.json'sgates, only gates with a numericmedian_s);append_gates(path, line) -> bool(False whendatealready present).scripts_lines_from_rollup(rollup) -> dict[repo, list[line]](fromsmoke_timings.json'srepos+rows: one line per(repo, python, run_id)with non-emptyrun_id; entries include untimed rows withnullseconds so coverage is recorded);append_scripts(path, lines) -> int(count appended; skip lines whose(python, run_id)is already present).- Readers for the checks:
gates_history(path, cap) -> list[dict]in the exact shapeci_timing.history_baseline/_gate_sparkconsume ({"date", "gates": {key: {"p50_s", "runs"}}}, oldest first, lastcaplines);previous_script_rows(scripts_dir) -> dict[(repo, python, entry) -> {seconds, run_id, run_url}]= for each repo file, the latest line per python leg, in the shapesmoke_timings.prev_rows_ofreturns. main(argv):append --ci-timing FILE --smoke-timings FILE [--today YYYY-MM-DD] [--ts ISO] [--dir DIR](prints one summary line:timings: gates +1 line, scripts +N lines across M repos, K skipped (already recorded)), andshow [--dir DIR](a one-screen census: line counts per file, first/last date).
-
heart/checks/ci_timing.py—aggregate(...)gainsrecord_history: list | None = None: when given (non-empty) it is the history source; the previous board's history is used only when the record has no lines.main --aggregategains--record-dir DIR(defaultHEART_HOME/timings) and loadsgates_history(record/gates.jsonl, cap).roll_historystill runs soboard.jsonkeeps itsperformance.history(the cache/fallback and the Brain board's sparkline input) — shape unchanged. -
heart/checks/smoke_timings.py—aggregate(...)gainsrecord_prev_rows: dict | None = None, preferred overprev_rows_of(prev_board)when non-empty;main --aggregategains--record-dir DIR. Theboard.jsonperformance.scriptsblock is unchanged. -
Shell legs —
ci_timing.shandsmoke_timings.shpass--record-dir "$HEART_HOME/timings"in their aggregate calls (the record lives in the checkout the workflow runs from; on a dev box the same checkout). -
.github/workflows/heart-health.yml:- New step right after the checks and before the aggregate/render steps? No — the checks' aggregate passes already read the record for baselines, and today's observation must not be in the baseline it is compared against (ci_timing excludes today's date; scripts compare by run id, so ordering is safe either way). Put the step after "Run cloud-safe checks" and before "Aggregate snapshot":
PYTHONPATH="$PWD" python -m heart.timings append --ci-timing "$HEART_STATE_DIR/ci_timing.json" --smoke-timings "$HEART_STATE_DIR/smoke_timings.json". - The README step becomes "Commit the README block + today's timing record (own repo only, main only)":
git add README.md timings/and a commit messagedocs(heart): daily board block + timing record [skip ci]; thegit diff --quietguard covers both paths (git status --porcelain README.md timings/). Header comment updated. Nothing else in the job order moves. - Consider (and reject, with a comment) committing from the dev-box tick: only the workflow appends, so the record has one writer.
- New step right after the checks and before the aggregate/render steps? No — the checks' aggregate passes already read the record for baselines, and today's observation must not be in the baseline it is compared against (ci_timing excludes today's date; scripts compare by run id, so ordering is safe either way). Put the step after "Run cloud-safe checks" and before "Aggregate snapshot":
-
Dashboard —
heart/dashboard.py: the CI wall-clock and Smoke scripts sections gain one detail linerecord: timings/ (<n> days of gates, <m> script observations)whensnapshot["timings_record"]is present;heart/state.pyaggregates a smalltimings_recordcensus written byheart.timings append($HEART_STATE_DIR/timings_record.json:{gates_days, scripts_observations, repos, appended_today: {...}}). Absent → no line (an older snapshot renders identically). Nothing else on the board changes. -
timings/README.md— schema, the two dedupe keys and why (the phase-0 lesson), append-only rule (ledger, never edited by hand; a wrong line is superseded by a later one, never rewritten), theepochs.jsonlreservation for phase 4, and how to read it (python -m heart.timings show,jq). -
Tests —
tests/test_timings.py(fake names): gates line built from a rollup and skipped on a repeated date; scripts lines built per(repo, python, run_id), skipped on a repeated(python, run_id), appended for a new run of the same leg; existing bytes untouched after append (read the file before/after and assert prefix equality); sorted keys / single line per record; missing files = empty record; unparseable line skipped and counted;gates_historyshape matches whatci_timing.history_baselineanddashboard._gate_sparkread (feed it to them);previous_script_rowspicks the latest line per leg and matchessmoke_timings.classify_drift's expectations;main appendwrites both files and the census, prints the summary, and is idempotent when run twice with the same inputs.tests/test_ci_timing.py+tests/test_smoke_timings.py: record preferred over prev board, prev board used when the record is empty.tests/test_heart_health_wiring.py: the append step exists between the checks and the aggregate step, and the commit step addstimings/. Existing tests unmodified.
Key Files
heart/checks/ci_timing.py:398-500(history_baseline,roll_history,prev_history_of,aggregate) andheart/checks/smoke_timings.py(prev_rows_of,classify_drift,aggregate) — the readers the record feeds..github/workflows/heart-health.yml— the README commit step (git add README.md,[skip ci]) is the commit pattern to extend.heart/publish.py— the other committed-state precedent (state/devbox_board.json).tests/test_heart_health_wiring.py— the wiring assertions from phase 1 to extend.
Out of scope
- The legacy epoch marker and the first labeled snapshot (phase 4).
- Sharding the record by year, or a Pages "history" page beyond the record link.
Original Prompt
Click to expand starting prompt
# Permanent CI timing history stored in PyAutoHeart
Type: feature
Target: PyAutoHeart
Repos:
- PyAutoHeart
Difficulty: medium
Autonomy: safe
Priority: high
Status: formalised
Consequence: judge
Review-minutes: 20
Unattended: ready
Epic: ci-timing-fast-tests
Phase: 2
Permanent CI timing history stored in PyAutoHeart (replace the 30-day self-carried window).
Today the only "history" is the performance block's rolled-forward window: the aggregate
step re-reads the previously published Pages `board.json` (`heart/checks/ci_timing.sh:64-79`)
and caps at 30 entries (`history_cap: 30`) — a publish gap loses it and nothing is ever
committed to the repo. The user's intent: run-time information on all CI tests tracked with
the nightly run and stored in PyAutoHeart as a PERMANENT record, with the dashboard showing
the most recent times but having access to all history.
Build the durable record: the daily heart-health run appends the day's observations (the
workflow-level gates from ci_timing AND the per-script rows from the phase-1 ingester) to
committed history files in the PyAutoHeart repo (e.g. under `state/` or a dedicated
`timings/` tree — append-only, compact JSON/JSONL per repo, committed by the workflow the
way `state/devbox_board.json` already is). The board keeps rendering the recent window but
links/reads from the committed record; the 30-day Pages self-carry becomes a cache, not the
source of truth. Design reference: Plane C ("durable baselines") of
`PyAutoMind/docs/pyautoheart/test_performance_board_assessment.md`.
Mind the file-growth shape: daily append across ~26 gates + a few hundred script rows must
stay reviewable (one commit/day, stable ordering, no churn of past lines).
Activity
Jammy2211 commentedon Sep 5, 2026
Shipped
PyAutoHeart#205 →
7b4e109, merged 2026-09-05 (CI green on both matrix legs; suite 735 → 767).heart/timings.py+timings/README.md— the permanent, append-only timing record:timings/gates.jsonl(one line per date, every tracked gate's medians) andtimings/scripts/<repo>.jsonl(one line per python leg × run id, every timed script's seconds/status/cap with run provenance). Dedupe on identity (date; python leg + run id), never on the day.ci_timingandsmoke_timingsread their baselines from the record first; the publishedboard.jsonis the fallback. Theperformanceblock shape is unchanged.heart-health.ymlappends today's observations after the checks and commitstimings/beside the README block — one[skip ci]commit a day, single writer.record: …detail line under each timing row from the census; absent census renders byte-identically.timings/epochs.jsonlis reserved (not created) for phase 4's labeled LEGACY epoch boundary.The data files are created by the first scheduled run after this merge; check that the next daily commit carries them.
Phase 2 of the
ci-timing-fast-testsepic; phase 3 (bring the dead timing legs live) is next.Generated by Claude Code