From e18668f9e19fde7ac2730080a2ba5d4903fed493 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sat, 22 Aug 2026 13:15:52 +0200 Subject: [PATCH] instructions_gate: CLOSED-ITEMS.md is the third register source Compressing a finished row out of OPEN-ITEMS.md into CLOSED-ITEMS.md is the documented housekeeping act. The gate read only OPEN-ITEMS.md and ROADMAP.md, so the first compression (ef6ac6f) turned every citation of a compressed item into 'a reference to nothing' and failed CI on the next push, in felhom-controller, for a rule file nobody had touched. CLOSED-ITEMS.md now answers 'does this ID exist', and answers 'closed' for the rows it owns. OPEN-ITEMS.md stays the sole authority on OPENNESS: a row it already claims as open is not overridden. Both controls still convict: an ID present nowhere fails, and a citation claiming a closed item is still open fails. --- scripts/instructions_gate.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/instructions_gate.py b/scripts/instructions_gate.py index 646795e6..c2d4c2bf 100644 --- a/scripts/instructions_gate.py +++ b/scripts/instructions_gate.py @@ -482,6 +482,12 @@ def register_state(workspace_root): base = os.path.join(workspace_root, "felhom.eu", "documentation", "backlog") reg = os.path.join(base, "OPEN-ITEMS.md") hist = os.path.join(base, "ROADMAP.md") + # CLOSED-ITEMS.md is the third source, and it is not optional. Compressing a finished row out of + # OPEN-ITEMS.md into it is the DOCUMENTED housekeeping act — and on 2026-08-22 (commit ef6ac6f) + # the first such compression turned every citation of a compressed item into "a reference to + # nothing", failing CI on the next push for a file nobody had touched. The register did not + # break; the gate's idea of where the register lives did. + closed = os.path.join(base, "CLOSED-ITEMS.md") if not os.path.exists(reg): return None @@ -491,6 +497,10 @@ def register_state(workspace_root): if os.path.exists(hist): with io_open(hist) as fh: hist_text = fh.read() + closed_text = "" + if os.path.exists(closed): + with io_open(closed) as fh: + closed_text = fh.read() state = {} for line in reg_text.split("\n"): @@ -518,9 +528,17 @@ def register_state(workspace_root): state[m.group(1)] = "closed" break + # A row that OWNS a line in CLOSED-ITEMS.md is CLOSED — but only if OPEN-ITEMS.md did not + # already claim it as open work. OPEN-ITEMS.md stays the authority on openness; this file only + # answers "does this ID exist at all", and answers "closed" for the ones it holds. + for line in closed_text.split("\n"): + m = re.match(r"\|\s*\*\*(R-\d+[a-z]?)\*\*\s*\|", line) + if m and m.group(1) not in state: + state[m.group(1)] = "closed" + mentioned = set(re.findall(r"\bR-\d+[a-z]?\b", reg_text)) | set( re.findall(r"\bR-\d+[a-z]?\b", hist_text) - ) + ) | set(re.findall(r"\bR-\d+[a-z]?\b", closed_text)) for item in mentioned: state.setdefault(item, "historical") return state