Files
felhom.eu/documentation/audits/end-dates-list-2026-11-11/tools/make-matrix.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

132 lines
6.3 KiB
Python

#!/usr/bin/env python3
"""Build MATRIX.md from TABLE.md, and check the table's shape.
The same tool as `audits/endings-list-2026-11-10/tools/make-matrix.py`, made general: the list's own words are in `listconf.py`.
Read-only on everything but MATRIX.md in this folder. It runs on DooPlex against the git clone only.
Usage: make-matrix.py write ../MATRIX.md, print the totals
make-matrix.py --check write nothing; rc 1 when the table breaks a rule
Rules checked (a broken rule is printed and makes rc 1):
- a heading is `### <ID> — <name> · <seed kind> · NAMED|MENTIONED|UNNAMED`
- each block has exactly eight answer rows, numbered 1..8, each with one mark A, D, K or N
- an A row carries a backticked pointer; a K row an `R-<n>`; an N row one class from listconf.py and a search S<n>
"""
import os
import re
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import listconf as C
HERE = os.path.dirname(os.path.abspath(__file__))
AUDIT = os.path.dirname(HERE)
HEAD = re.compile(r"^### (" + C.ID_RE + r") — (.+?) · (?:" + "|".join(C.KINDS) + r") · (NAMED|MENTIONED|UNNAMED)\s*$")
ROW = re.compile(r"^\| ([1-8]) \| (.*) \| ([ADKN]) \| (.*) \|\s*$")
QUESTIONS = C.QUESTIONS
CLASS_ROW = C.CLASS_ROW
CLS = re.compile(r"\b(?:" + "|".join(C.CLASS_ROW) + r")\b")
def parse(path):
places, errors, cur = [], [], None
with open(path, encoding="utf-8") as fh:
for ln, line in enumerate(fh, 1):
if line.startswith("## TEST-ONLY") or line.startswith("## DOC-ONLY"):
cur = None
continue
if line.startswith("### "):
m = HEAD.match(line)
if not m:
errors.append(f"line {ln}: heading has the wrong shape: {line.strip()}")
cur = None
continue
cur = {"id": m.group(1), "name": m.group(2), "named": m.group(3), "marks": {}, "n": {}, "k": {}}
places.append(cur)
continue
m = ROW.match(line)
if not m or cur is None:
continue
q, mark, ptr = int(m.group(1)), m.group(3), m.group(4)
if q in cur["marks"]:
errors.append(f"{cur['id']}: question {q} is answered twice")
cur["marks"][q] = mark
if mark == "A" and "`" not in ptr:
errors.append(f"{cur['id']}-{q}: A with no pointer")
if mark == "K":
rows = re.findall(r"R-\d+", ptr)
if not rows:
errors.append(f"{cur['id']}-{q}: K with no row")
cur["k"][q] = rows
if mark == "N":
cls = CLS.findall(ptr)
if len(cls) != 1:
errors.append(f"{cur['id']}-{q}: N needs exactly one class, found {cls}")
elif not re.search(r"\bS\d+\b", ptr) and "NOBODY KNOWS" not in m.group(2):
errors.append(f"{cur['id']}-{q}: N with no search id")
cur["n"][q] = cls[0] if cls else "?"
for p in places:
if sorted(p["marks"]) != list(range(1, 9)):
errors.append(f"{p['id']}: has answers {sorted(p['marks'])}, wants 1..8")
return places, errors
def build(places):
out = ["# " + C.TITLE + " — the matrix", "",
"Made by `tools/make-matrix.py` from `TABLE.md`. Do not edit it by hand.", "",
"`A` answered · `D` decided, not built · `K` known gap (has a row) · `N` nobody asked. Columns are the eight",
"questions: " + " · ".join(f"{i} {q}" for i, q in enumerate(QUESTIONS, 1)) + ".",
"", "| " + C.WORD.capitalize() + " | Named | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | N |", "|---|---|---|---|---|---|---|---|---|---|---|"]
tot = {m: 0 for m in "ADKN"}
perq = {q: {m: 0 for m in "ADKN"} for q in range(1, 9)}
named = {"NAMED": 0, "MENTIONED": 0, "UNNAMED": 0}
members, krows = {c: [] for c in CLASS_ROW}, {}
for p in places:
named[p["named"]] += 1
cells = []
for q in range(1, 9):
mk = p["marks"].get(q, "?")
cells.append(f"**{mk}**" if mk == "N" else mk)
if mk in tot:
tot[mk] += 1
perq[q][mk] += 1
for q, c in p["n"].items():
members.setdefault(c, []).append(f"{p['id']}-{q}")
for q, rows in p["k"].items():
for r in rows:
krows.setdefault(r, []).append(f"{p['id']}-{q}")
out.append(f"| {p['id']} {p['name']} | {p['named'].lower()} | " + " | ".join(cells) + f" | {len(p['n'])} |")
n = len(places)
out += ["", "## Totals", "",
f"- {C.WORDS}: **{n}** in the table · named **{named['NAMED']}** · mentioned only **{named['MENTIONED']}** · "
f"named by no architecture document **{named['UNNAMED']}**.",
f"- Answers: **{n * 8}** · A **{tot['A']}** · D **{tot['D']}** · K **{tot['K']}** · N **{tot['N']}**.",
f"- {C.WORDS} with no N: **{sum(1 for p in places if not p['n'])}** of {n}.",
"", "| Question | A | D | K | N |", "|---|---|---|---|---|"]
for q in range(1, 9):
out.append(f"| {q} {QUESTIONS[q - 1]} | {perq[q]['A']} | {perq[q]['D']} | {perq[q]['K']} | {perq[q]['N']} |")
out += ["", "## The N answers, by class row", "", "| Class | Row | Count | Members (id-question) |", "|---|---|---|---|"]
for c in sorted(members):
out.append(f"| {c} | {CLASS_ROW.get(c, '?')} | {len(members[c])} | {', '.join(members[c])} |")
out += ["", "## The K answers, by existing row", "", "| Row | Count | Members |", "|---|---|---|"]
for r in sorted(krows, key=lambda x: int(x[2:])):
out.append(f"| {r} | {len(krows[r])} | {', '.join(krows[r])} |")
return "\n".join(out) + "\n", tot, named, members
def main() -> int:
places, errors = parse(os.path.join(AUDIT, "TABLE.md"))
for e in errors:
print("BROKEN " + e)
text, tot, named, members = build(places)
if "--check" not in sys.argv[1:]:
with open(os.path.join(AUDIT, "MATRIX.md"), "w", encoding="utf-8") as fh:
fh.write(text)
print(f"places {len(places)} named {named} marks {tot} "
+ " ".join(f"{c}={len(m)}" for c, m in sorted(members.items())) + f" broken {len(errors)}")
return 1 if errors else 0
if __name__ == "__main__":
sys.exit(main())