From 4ef847ce30a2a8ca9b23b59f796f12065b815270 Mon Sep 17 00:00:00 2001 From: "Claude (agent-stats)" Date: Thu, 24 Sep 2026 23:07:25 -0700 Subject: [PATCH] test(tooling): the repo-stats suite tells a sparse model from a padded one, and --out refuses a foreign CSV (improvise-1xfb.5.1) Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze --- scripts/repo-stats | 6 ++++++ scripts/repo-stats-test.sh | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/scripts/repo-stats b/scripts/repo-stats index b89577c4..6444d2a8 100755 --- a/scripts/repo-stats +++ b/scripts/repo-stats @@ -302,6 +302,12 @@ def main(): ap.add_argument("-C", dest="repo", default=".", help="the repository (default .)") a = ap.parse_args() os.makedirs(a.out, exist_ok=True) + ours = {f"{n}.csv" for n in ["churn"] + ANALYSES} + foreign = sorted(f for f in os.listdir(a.out) if f.lower().endswith(".csv") and f not in ours) + if foreign: + print(f"repo-stats: {a.out} holds CSVs this script did not write, and " + f"`improvise import` would merge them: {', '.join(foreign)}", file=sys.stderr) + return 2 try: r = report(a.repo, a.ref, a.since, a.min_revs, os.path.abspath(a.out)) except ImproviseFailed as e: diff --git a/scripts/repo-stats-test.sh b/scripts/repo-stats-test.sh index 5a7378b7..2e138dbd 100755 --- a/scripts/repo-stats-test.sh +++ b/scripts/repo-stats-test.sh @@ -170,8 +170,26 @@ if run "$work/stats" text; then views="$(grep -c '^## View: ' "$work/stats/repo-stats.improv")" [ "$views" = 10 ] && ok "the model keeps a view per file and the report's four" \ || bad "the model keeps a view per file and the report's four" "$views views" + # Sparse, not padded: a padded merge has the same numbers and views, but a + # `-` item in every category and per-file views seated on the padding. + dashes="$(grep -c '|-|' "$work/stats/repo-stats.improv")" + [ "$dashes" = 0 ] && ok "the sparse model has no padding item" \ + || bad "the sparse model has no padding item" "$dashes lines name |-|" + churn_view="$(awk '/^## View: churn$/,/^$/' "$work/stats/repo-stats.improv")" + for seat in "date: row" "agent-rules: none" "coupled: none" "crosses-crate: none"; do + grep -qx -- "$seat" <<< "$churn_view" && ok "the churn view seats $seat" \ + || bad "the churn view seats $seat" "$(tr '\n' ' ' <<< "$churn_view")" + done fi +# An --out holding a CSV this script did not write is refused, since the folder +# import would merge it. The script's own CSVs, from a rerun, are not foreign. +mkdir -p "$work/foreign"; echo "x,y" > "$work/foreign/other.csv" +"$STATS" -C "$repo" --since 2026-06-01 --out "$work/foreign" > /dev/null 2>&1 +got=$? +[ "$got" = 2 ] && ok "a foreign CSV in --out is refused with exit 2" \ + || bad "a foreign CSV in --out is refused with exit 2" "exit $got" + # The window is scoped to the ref: at the tag, the shrink has not happened. if run "$work/at-tag" json --ref before-shrink; then row "--ref scopes the log" by-area "web and harness" '["11","0","0.000"]'