From 51ffca5a6a8ca5154e9dbbf9307796ad303d0385 Mon Sep 17 00:00:00 2001 From: Lukasz Boryn Date: Thu, 30 Jul 2026 20:17:18 +0200 Subject: [PATCH] feat(okf-check): error on an unprefixed register cite in prose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R-022 ruled that a prose cite carries its register's prefix — B-NNN for a blueprint, R-NNN for the why-register — and its own Consequences noted nothing enforced it. This is the enforcement: a bare three-digit run naming a live file in either register, standing in the body of a root or decisions/ page, is an error. The exclusions are the rule's hard half and all mechanical: frontmatter, fenced blocks, code spans, whole markdown links (the path already says which register), the page's own H1, a number touching / - . or a word character, and type: Learnings pages — append-only by their own header, per R-022 §Consequences. Typing that last exemption rather than naming LEARNINGS.md is what will survive the split into learnings/.md. Blueprints and ferries sit outside the check for the same reason their warrants do: a locked blueprint's prose cannot be legally repaired. One live site fired — R-022's own example sentence naming the three collided numbers — repaired with code spans, which the rule permits. blueprint 021, rule 2. --- ...022-prose-cites-carry-a-register-prefix.md | 4 +- skills/loop/write-OKF/scripts/okf-check | 45 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/OKF/decisions/022-prose-cites-carry-a-register-prefix.md b/OKF/decisions/022-prose-cites-carry-a-register-prefix.md index 47c4e20..e914576 100644 --- a/OKF/decisions/022-prose-cites-carry-a-register-prefix.md +++ b/OKF/decisions/022-prose-cites-carry-a-register-prefix.md @@ -15,8 +15,8 @@ reversible: yes — drop the prefixes; numbers, filenames and links never moved # 022 — a prose cite carries its register's prefix Blueprints and the why-register number independently, so the same three -digits already name two unrelated pages three times over: 013, 017 and -019 each exist in both. A markdown link is safe — its path says which — +digits already name two unrelated pages three times over: `013`, `017` +and `019` each exist in both. A markdown link is safe — its path says which — but a bare number in prose is not, and `B-019` (the render lint) against `R-019` (recon may self-fire) is the kind of collision a reader resolves wrongly without noticing. **In prose: `B-NNN` for a blueprint, `R-NNN` diff --git a/skills/loop/write-OKF/scripts/okf-check b/skills/loop/write-OKF/scripts/okf-check index 8676254..8f42b0a 100755 --- a/skills/loop/write-OKF/scripts/okf-check +++ b/skills/loop/write-OKF/scripts/okf-check @@ -2,11 +2,11 @@ """Validate an OKF bundle. Usage: okf-check Errors (exit 1): missing type, missing warrant, duplicate answer, -unresolvable cite, malformed `okf:derived` fence, page unreachable from -index.md, page over its line cap, register index line disagreeing with -its decision file, moored ferry with a malformed `sealed:` pin or a -surviving directory. Warnings (exit 0): page with no cites, blueprint -locked without a `sounded:` stamp. +unresolvable cite, unprefixed register cite in prose, malformed +`okf:derived` fence, page unreachable from index.md, page over its line +cap, register index line disagreeing with its decision file, moored ferry +with a malformed `sealed:` pin or a surviving directory. Warnings +(exit 0): page with no cites, blueprint locked without a `sounded:` stamp. Pin *shape* only — whether the change id still resolves needs the repo in hand, which is write-OKF refresh's job, not a validator that must exit 0 @@ -116,6 +116,32 @@ def cite_resolves(cite, page, okf): return False +def register_numbers(okf): + """Three-digit numbers naming a live file in either register.""" + return {p.name[:3] for register in ("blueprints", "decisions") + for p in (okf / register).glob("[0-9][0-9][0-9]-*.md")} + + +def prose_cites(text, numbers): + """Bare register numbers standing in a page's prose. + + Blueprints and the why-register number independently, so a bare `019` + names two unrelated pages and a reader resolves it by guessing. The + exclusions are the rule's hard half and all mechanical: frontmatter, + fenced blocks, code spans, whole markdown links (text and target + both — the path already says which register), and the page's own H1. + A number touching `/`, `-`, `.` or a word character is part of a path, + a date or a `superseded-by-NNN`, never a cite. + """ + body = text.partition("\n---")[2] if text.startswith("---\n") else text + body = re.sub(r"^```.*?^```", " ", body, flags=re.M | re.S) + body = re.sub(r"`[^`]*`", " ", body) + body = re.sub(r"\[[^\]]*\]\([^)]*\)", " ", body) + body = re.sub(r"^#.*$", " ", body, flags=re.M) + found = re.findall(r"(?.md split. + if fields.get("type") != "Learnings": + for number in prose_cites(text, numbers): + errors.append(f"{rel}: unprefixed register cite: {number}") + check_ferries(okf, errors) check_register(okf, warrants, errors)