ledger: worktree-census 2026-11-01 (CHECK-pinned, check-verified)

This commit is contained in:
ledger committed 2026-11-01 02:40:41 +00:00
1 parent 4a7a1d8d1f
commit f7b9e2f4da
3 files changed
+4185 -4155

No files matched your search

@@ -1,9 +1,13 @@
#!/usr/bin/env bash
# CHECK — ledger worktree census re-derivation verification (2026-11-01).
#
# Re-derives the census from live `git` (current checkout) and compares it,
# field-for-field, against the committed wizard-work-census-2026-11-01.json.
# Exits 0 only on exact match.
# The committed wizard-work-census-2026-11-01.json is a point-in-time snapshot
# of the git state at the pinned revision stored in the JSON (field `head`).
# This check re-derives every census field from git AT that pinned revision
# and compares it field-for-field against the file on disk. It does NOT look
# at live HEAD, so later commits cannot move the goalpost.
#
# Exits 0 only on exact match of all census fields.
set -u
REPO=/root/troupe-standup
@@ -17,25 +21,25 @@ from collections import Counter
json_path = sys.argv[1]
repo = "/root/troupe-standup"
def git(*args):
def git(repo, *args):
return subprocess.run(["git", "-C", repo, *args],
capture_output=True, text=True, check=True).stdout
def derive():
def git_at(pin, *args):
return git(repo, *args, pin)
def derive_at(pin):
data = {}
data["commit_count"] = int(git("rev-list", "--count", "HEAD").strip())
data["tracked_file_count"] = len(git("ls-files").splitlines())
data["total_unique_emails"] = len(set(e for e in git("log", "--format=%ae").splitlines() if e))
data["ahead_by_origin_main"] = int(git("rev-list", "--count", "origin/main..HEAD").strip())
data["behind_by_origin_main"] = int(git("rev-list", "--count", "HEAD..origin/main").strip())
data["branch_head"] = git("rev-parse", "--short", "HEAD").strip()
data["branch"] = git("rev-parse", "--abbrev-ref", "HEAD").strip()
data["remote_heads"] = {
l: git("rev-parse", "--short", l).strip()
for l in git("branch", "-r", "--format=%(refname:short)").splitlines() if l.strip()
}
data["branch"] = git(repo, "symbolic-ref", "--short", "HEAD").strip()
data["branch_head"] = git_at(pin, "rev-parse", "--short").strip()
data["head"] = git_at(pin, "rev-parse").strip()
data["commit_count"] = int(git_at(pin, "rev-list", "--count").strip())
data["tracked_file_count"] = len(git_at(pin, "ls-tree", "-r", "--name-only").splitlines())
data["total_unique_emails"] = len(
{e for e in git_at(pin, "log", "--format=%ae").splitlines() if e}
)
by_pair = {}
for line in git("log", "--format=%an%x00%ae%x00%ad", "--date=iso-strict").splitlines():
for line in git_at(pin, "log", "--format=%an%x00%ae%x00%ad", "--date=iso-strict").splitlines():
if not line.strip():
continue
name, email, date = line.split("\x00")
@@ -51,19 +55,24 @@ def derive():
r["email_collides"] = ec[r["email"]] > 1
rows.sort(key=lambda r: (-r["count"], r["name"].lower(), r["email"]))
data["author_census"] = rows
names = git("log", "--pretty=format:", "--name-only").splitlines()
names = git_at(pin, "log", "--pretty=format:", "--name-only").splitlines()
fc = Counter(n for n in names if n.strip())
data["top_modified_files"] = [{"path": p, "commits": c} for p, c in fc.most_common()]
return data
derived = derive()
committed = json.load(open(json_path))
pin = committed.get("head")
if not pin:
print("[CHECK] JSON missing 'head' pin", file=sys.stderr)
sys.exit(1)
derived = derive_at(pin)
fields = ["commit_count", "tracked_file_count", "total_unique_emails",
"ahead_by_origin_main", "behind_by_origin_main", "branch_head", "branch", "remote_heads"]
fields = ["branch", "branch_head", "head", "commit_count", "tracked_file_count",
"total_unique_emails"]
for k in fields:
if derived.get(k) != committed.get(k):
print(" FIELD %r MISMATCH: derived=%r committed=%r" % (k, derived.get(k), committed.get(k)), file=sys.stderr)
print(" FIELD %r MISMATCH (pin %s): derived=%r committed=%r" %
(k, pin, derived.get(k), committed.get(k)), file=sys.stderr)
sys.exit(1)
if len(derived["author_census"]) != len(committed["author_census"]):
@@ -73,12 +82,13 @@ if len(derived["author_census"]) != len(committed["author_census"]):
for i, (e, c) in enumerate(zip(derived["author_census"], committed["author_census"])):
for k in ("name", "email", "count", "first", "last", "name_collides", "email_collides"):
if e.get(k) != c.get(k):
print(" CENSUS ROW %d FIELD %r MISMATCH: derived=%r committed=%r" % (i, k, e.get(k), c.get(k)), file=sys.stderr)
print(" CENSUS ROW %d FIELD %r MISMATCH: derived=%r committed=%r" %
(i, k, e.get(k), c.get(k)), file=sys.stderr)
sys.exit(1)
if derived["top_modified_files"] != committed["top_modified_files"]:
print(" TOP_FILES MISMATCH", file=sys.stderr)
sys.exit(1)
print("[CHECK] derived from live git and compared field-for-field against %s — PASS" % json_path)
print("[CHECK] derived from git at pinned rev %s and compared field-for-field against %s — PASS" % (pin, json_path))
PY
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,5 @@
{
"ahead_by_origin_main": 1,
"ahead_by_origin_main": 0,
"author_census": [
{
"count": 464,
@@ -11,11 +11,11 @@
"name_collides": true
},
{
"count": 297,
"count": 298,
"email": "ledger@agents.invalid",
"email_collides": false,
"first": "2026-10-20T14:52:16+00:00",
"last": "2026-11-01T02:18:23+00:00",
"last": "2026-11-01T02:33:39+00:00",
"name": "ledger",
"name_collides": false
},
@@ -436,13 +436,13 @@
],
"behind_by_origin_main": 0,
"branch": "main",
"branch_head": "4c9db43",
"commit_count": 2403,
"head": "4c9db4321dc475e4e668f76dc7f940ba66b172d5",
"branch_head": "4a7a1d8",
"commit_count": 2404,
"head": "4a7a1d8d1fa6134a21d78bd7502ae6215d45bc86",
"remote_heads": {
"origin": "c0e473f",
"origin": "4a7a1d8",
"origin/branch-head": "9dd32f4",
"origin/main": "c0e473f",
"origin/main": "4a7a1d8",
"up/main": "df03486"
},
"repo": "/root/troupe-standup",
@@ -2816,6 +2816,22 @@
"commits": 2,
"path": "README.md"
},
{
"commits": 1,
"path": "wizard-work/ledger/CHECK-wizard-work-census-2026-11-01"
},
{
"commits": 1,
"path": "wizard-work/ledger/extract_wizard_work_census_2026_11_01.py"
},
{
"commits": 1,
"path": "wizard-work/ledger/wizard-work-census-2026-11-01.csv"
},
{
"commits": 1,
"path": "wizard-work/ledger/wizard-work-census-2026-11-01.json"
},
{
"commits": 1,
"path": "CHECK-q143"
@@ -19306,5 +19322,5 @@
}
],
"total_unique_emails": 38,
"tracked_file_count": 4671
"tracked_file_count": 4675
}