gates / gates (push) Successful in 2m2s
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
127 lines
6.2 KiB
Python
127 lines
6.2 KiB
Python
#!/usr/bin/env python3
|
|
"""make-table.py — build TABLE.md from the helpers' answers (evidence/helpers/resolved-*.json), marks.py and listconf.py.
|
|
|
|
The same tool as `audits/endings-list-2026-11-10/tools/make-table.py`, made general: what differs between two lists
|
|
(the heading words, the helper names, the kinds, the questions) is in `listconf.py` beside it.
|
|
|
|
A cell with an entry in marks.py carries the MAIN SESSION's words. Every other cell carries the helper's words and the
|
|
mark A; its pointers were opened by resolve-helper.py (the file and the line exist; the name the helper gave stands at
|
|
the line). A dead pointer is dropped here. Read-only but for TABLE.md.
|
|
"""
|
|
import json, os, re, subprocess, sys
|
|
import marks, listconf as C
|
|
HERE = os.path.dirname(os.path.abspath(__file__)); AUDIT = os.path.dirname(HERE)
|
|
REPO = os.path.abspath(os.path.join(HERE, "..", "..", "..", "..")); WS = os.path.dirname(REPO)
|
|
PREFIX = {"AG": os.path.join(WS, "felhom-agent"), "CT": os.path.join(WS, "felhom-controller", "controller"),
|
|
"CAT": os.path.join(WS, "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")}
|
|
TOK = re.compile(r"`((?:AG|CT|CAT|HUB|E|AR|RB|EV)/[^`:\s]+)(?::(\d+)(?:-(\d+))?)?`")
|
|
R = {h: json.load(open(os.path.join(AUDIT, "evidence", "helpers", f"resolved-{h}.json")))["endings"] for h in C.HELPERS}
|
|
dropped = []
|
|
|
|
|
|
def live(tok):
|
|
m = TOK.fullmatch(tok)
|
|
pre, rest = m.group(1).split("/", 1)
|
|
p = os.path.join(PREFIX[pre], rest)
|
|
if not os.path.exists(p):
|
|
return False
|
|
if m.group(2):
|
|
n = sum(1 for _ in open(p, encoding="utf-8", errors="replace"))
|
|
return int(m.group(3) or m.group(2)) <= n
|
|
return True
|
|
|
|
|
|
def split(ans, eid, q):
|
|
"""helper answer -> (plain text, [live pointers])"""
|
|
ptrs = []
|
|
for m in TOK.finditer(ans):
|
|
t = m.group(0)
|
|
if live(t):
|
|
if t not in ptrs:
|
|
ptrs.append(t)
|
|
else:
|
|
dropped.append(f"{eid}-{q} {t}")
|
|
t = TOK.sub("", ans)
|
|
t = re.sub(r"`~?:\d+(?:-\d+)?`", "", t)
|
|
t = re.sub(r"\(\s*(?:called|creator|see)?\s*[,;]?\s*\)", "", t)
|
|
t = re.sub(r"\s+([,.;:)])", r"\1", t)
|
|
t = re.sub(r"\(\s+", "(", t)
|
|
t = re.sub(r"([,;:])(?:\s*[,;:])+", r"\1", t)
|
|
t = re.sub(r"\s{2,}", " ", t).replace("|", "/").strip(" ;,·")
|
|
t = re.sub(r"\(\)", "", t)
|
|
if len(t) > 380:
|
|
cut = max(t.rfind(". ", 0, 380), t.rfind("; ", 0, 380))
|
|
t = t[:cut + 1 if cut > 150 else 377].rstrip(" ;") + " …"
|
|
return t, ptrs
|
|
|
|
|
|
def named(m):
|
|
kind, why = m["named"]
|
|
if kind != "grep":
|
|
return kind, f"architecture: {why}"
|
|
r = subprocess.run(["/usr/bin/grep", "-rEic", "--include=*.md", why, PREFIX["AR"]], capture_output=True, text=True)
|
|
files = [l for l in r.stdout.split("\n") if l and not l.endswith(":0")]
|
|
lines = sum(int(l.rsplit(":", 1)[1]) for l in files)
|
|
return ("MENTIONED" if lines else "UNNAMED"), f"architecture folder: {lines} lines in {len(files)} files match `/{why}/` (a machine count, not a reading)"
|
|
|
|
|
|
def main():
|
|
out = [open(os.path.join(HERE, "table-head.md"), encoding="utf-8").read().rstrip(), ""]
|
|
kindmap, bad, body = {}, [], []
|
|
for eid, m in sorted(marks.M.items()):
|
|
e = R[m["src"][0]][m["src"][1]]
|
|
st, why = named(m)
|
|
worst, rows = "A", []
|
|
for q in range(1, 9):
|
|
if q in m["o"]:
|
|
mark, text, ptr = m["o"][q]
|
|
if ptr is None or ptr.startswith("+"): # "+ rest" = the helper's pointers, then rest
|
|
_, ps = split(e["answers"].get(str(q), ""), eid, q)
|
|
ptr = (" ".join(ps[:4]) + (ptr[1:] if ptr else "")).strip(" ·")
|
|
else:
|
|
mark = "A"
|
|
text, ps = split(e["answers"].get(str(q), ""), eid, q)
|
|
ptr = " ".join(ps[:4])
|
|
if q == 8 and eid in marks.MEASURED:
|
|
mt, mp = marks.MEASURED[eid]
|
|
text = mt + " · " + text
|
|
ptr = (mp + " " + ptr).strip()
|
|
if mark == "A" and "`" not in ptr: # borrow the code path from question 1, then 2
|
|
for alt in (1, 2, 3):
|
|
_, ps = split(e["answers"].get(str(alt), ""), eid, alt)
|
|
if ps:
|
|
ptr = " ".join(ps[:2]) + f" (the code path of question {alt})"
|
|
break
|
|
if mark == "A" and "`" not in ptr:
|
|
bad.append(f"{eid}-{q}: A with no pointer")
|
|
if not text:
|
|
bad.append(f"{eid}-{q}: empty answer")
|
|
rows.append(f"| {q} | {text} | {mark} | {ptr} |")
|
|
worst = max(worst, mark, key="ADKN".index)
|
|
kindmap.setdefault(m["seed"], []).append((eid, st, worst))
|
|
body += [f"### {eid} — {m['name']} · {m['seed']} · {st}", "",
|
|
f"{why} · helper section: {m['src'][0]} „{e['title'].strip()}”", "",
|
|
"| # | Answer | Mark | Pointer |", "|---|---|---|---|"] + rows + ["", f"**Hand step in a runbook?** {m['rb']}", ""]
|
|
out += [f"## The kinds, and where each {C.WORD} is", "", f"| Kind | {C.WORDS} (worst mark) | Named · mentioned · named nowhere |", "|---|---|---|"]
|
|
for kind in C.KINDS:
|
|
v = kindmap.get(kind, [])
|
|
c = {s: sum(1 for x in v if x[1] == s) for s in ("NAMED", "MENTIONED", "UNNAMED")}
|
|
out.append(f"| {kind} | " + ", ".join(f"{x[0]} ({x[2]})" for x in v) + f" | {c['NAMED']} · {c['MENTIONED']} · {c['UNNAMED']} |")
|
|
for k in kindmap:
|
|
if k not in C.KINDS:
|
|
bad.append(f"kind {k} is not in listconf.KINDS")
|
|
out += ["", "## Not in the table", "",
|
|
"**Tiny (named once, not tabled):** " + " · ".join(marks.TINY) + ".", "",
|
|
"**Left out for another reason:**", ""] + [f"- {a} — {b}." for a, b in marks.LEFT_OUT]
|
|
out += ["", "---", ""] + body
|
|
open(os.path.join(AUDIT, "TABLE.md"), "w", encoding="utf-8").write("\n".join(out).rstrip() + "\n")
|
|
print(f"{C.WORDS} {len(marks.M)} · dead pointers dropped {len(dropped)} · broken {len(bad)}")
|
|
for b in bad + dropped:
|
|
print(" " + b)
|
|
return 1 if bad else 0
|
|
|
|
|
|
sys.exit(main())
|