Files
felhom.eu/documentation/audits/end-dates-list-2026-11-11/tools/check-pointers.py
T
admin 978666dde3
gates / gates (push) Successful in 2m2s
lists: the Clock list (70 jobs) and the End-dates list (39 things), 9 register rows, 4 decisions
Read-only review of every job on a timer and of everything that ends on a date,
with measurements from the three test boxes. Nothing ends in the next 14 days.
Register 236 -> 245 (R-1379..R-1387), pointer lines on twelve rows, D76-D79 in
STATUS.md. Part C: felhom-agent's clone address holds no token now; the other
clones wait for the operator's yes. R-1035's 4-week check moved to 2026-11-18
(operator read needed).

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
2026-11-11 11:54:42 +01:00

79 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""Print the text behind every pointer in a table file, so a person can read it.
Read-only by construction: it opens files for reading and prints. It runs on DooPlex against the
git clones only; it never touches a box.
Usage: check-pointers.py [FILE ...] (default: ../TABLE.md)
check-pointers.py --quiet [FILE] (only the verdict lines; rc 1 when a pointer is dead)
A pointer is a backticked token `PREFIX/path[:line[-line]]` with one of the prefixes below.
A pointer is DEAD when the file is missing or the line range lies beyond the end of the file.
The script cannot judge whether the line says what the table claims — that is the reader's job.
"""
import os
import re
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
AUDIT = os.path.dirname(HERE)
REPO = os.path.abspath(os.path.join(AUDIT, "..", "..", "..")) # felhom.eu
WORKSPACE = os.path.dirname(REPO)
PREFIX = {
"AG": os.path.join(WORKSPACE, "felhom-agent"),
"CT": os.path.join(WORKSPACE, "felhom-controller", "controller"),
"CAT": os.path.join(WORKSPACE, "app-catalog-felhom.eu"),
"HUB": os.path.join(REPO, "hub", "internal"),
"E": REPO,
"AR": os.path.join(REPO, "documentation", "architecture"),
"RB": os.path.join(REPO, "documentation", "runbooks"),
"EV": os.path.join(AUDIT, "evidence"),
}
TOKEN = re.compile(r"`((?:%s)/[^`:\s]+)(?::(\d+)(?:-(\d+))?)?`" % "|".join(PREFIX))
def main() -> int:
args = [a for a in sys.argv[1:] if a != "--quiet"]
quiet = "--quiet" in sys.argv[1:]
files = args or [os.path.join(AUDIT, "TABLE.md")]
seen, dead, total = set(), 0, 0
for table in files:
with open(table, encoding="utf-8") as fh:
text = fh.read()
for m in TOKEN.finditer(text):
key = m.group(0)
if key in seen:
continue
seen.add(key)
total += 1
pre, rest = m.group(1).split("/", 1)
path = os.path.join(PREFIX[pre], rest)
first = int(m.group(2)) if m.group(2) else None
last = int(m.group(3)) if m.group(3) else first
if not os.path.exists(path):
dead += 1
print(f"DEAD {key} (no such file: {path})")
continue
if first is None:
if not quiet:
print(f"OK {key} (file exists)")
continue
with open(path, encoding="utf-8", errors="replace") as fh:
lines = fh.readlines()
if last > len(lines):
dead += 1
print(f"DEAD {key} (file has {len(lines)} lines)")
continue
if quiet:
continue
print(f"OK {key}")
for n in range(first, min(last, first + 11) + 1):
print(f" {n:>5} {lines[n - 1].rstrip()[:200]}")
print(f"pointers: {total} dead: {dead}")
return 1 if dead else 0
if __name__ == "__main__":
sys.exit(main())