T1.c2: timeline --check: do not compare the latest row's Commits cell

This commit is contained in:
Drew T
2026-10-01 10:43:19 -06:00
parent 12e31f39a2
commit 2baecd375d
2 changed files with 13 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
# T1.c2 — timeline --check ignores latest row's Commits cell
- Change: tools/timeline.py main() --check: regex masks `| <rows[-1] date> | <n> |` Commits cell to `#` on both regenerated and on-disk text before comparing (md; svg carries no per-row count, mask is a no-op there). Docstring line for --check notes why. Write mode unchanged.
- Why: committing the regenerated docs/story-timeline.md bumps today's commit count → --check was always STALE same-day (committed 5 vs live 6+).
- Verified:
- before edit: `tools/timeline.py --check` → STALE ['story-timeline.md'] exit 1
- after: `--check` → fresh (81 rows) exit 0 (committed row 2026-10-01 shows 5)
- negative: edited 2026-09-30 Commits 93→94 in docs/story-timeline.md → STALE exit 1; `git checkout docs/story-timeline.md` → fresh exit 0
- Note: mask keys on the latest date; if committed file's last row is an older day, rows differ anyway → STALE (correct).
+5 -1
View File
@@ -4,6 +4,7 @@
tools/timeline.py # writes docs/story-timeline.md + docs/story-timeline.svg; exit 1 if the last row
# disagrees with docs/progress.json (the self-check)
tools/timeline.py --check # regenerate in memory and exit 1 if either committed file is stale
# (the latest row's Commits cell is not compared: committing the file bumps it)
Sources (all in the repository, keyed by DATE — never by commit hash, which the public-flip rewrite changed):
* every commit that touched docs/progress.fleet.md (the fleet digest, since 2026-06-16): the June single-metric
@@ -402,7 +403,10 @@ def main(argv):
selfcheck(rows)
md, svg = render_md(rows), render_svg(rows)
if a.check:
stale = [p.name for p, t in ((OUT_MD, md), (OUT_SVG, svg)) if not p.exists() or p.read_text() != t]
# mask the latest row's Commits cell on both sides: committing the regenerated file bumps today's count
last = re.compile(r"^(\| " + re.escape(rows[-1]["date"]) + r" \| )\d+( \|)", re.M)
mask = lambda t: last.sub(r"\1#\2", t)
stale = [p.name for p, t in ((OUT_MD, md), (OUT_SVG, svg)) if not p.exists() or mask(p.read_text()) != mask(t)]
if stale:
sys.exit(f"timeline --check: STALE {stale} — run tools/timeline.py")
print(f"timeline --check: fresh ({len(rows)} rows)")