From 1b6a5c3ae81d9e5b37cf01a08225875e8adc0a1f Mon Sep 17 00:00:00 2001 From: Lukasz Boryn Date: Wed, 22 Jul 2026 00:33:55 +0200 Subject: [PATCH] feat(write-OKF): give cites teeth and fence the derived zone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blueprint 004. A `cites:` entry now takes three shapes: `path`, `path:line` (the number is a reading aid, never validated), and `path:symbol`, which resolves only if the symbol is a literal substring of the file — so a cite breaks when the thing it cites moves. Cite drift belongs to okf-check, not refresh: a cite needs only the working tree, so decision 017's visibility split leaves refresh's DRIFT rule covering `sealed:` pins alone. okf-check also validates derived-zone shape — at most one begin/end pair per page, begin first — with each marker anchored to its whole line, so a page that documents the markers is not fenced by mentioning them. The warrant contract and the `sealed:` block move to page-warrant.md, buying okf-layout.md the headroom for the two new contracts. ROADMAP phase 6 records its split into 004 (cites + fences) and 005 (taxonomy scan) and corrects the two Verify clauses this change made false. Blueprint 004's Verify: PASS. Co-Authored-By: Claude Opus 4.8 --- OKF/LEARNINGS.md | 6 +++ OKF/ROADMAP.md | 6 ++- ...give-cites-teeth-and-fence-derived-zone.md | 2 +- OKF/index.md | 2 +- skills/loop/write-OKF/SKILL.md | 10 ++++- skills/loop/write-OKF/okf-layout.md | 34 +++++++------- skills/loop/write-OKF/page-warrant.md | 37 +++++++++++++++ skills/loop/write-OKF/scripts/okf-check | 45 ++++++++++++++++--- 8 files changed, 111 insertions(+), 31 deletions(-) create mode 100644 skills/loop/write-OKF/page-warrant.md diff --git a/OKF/LEARNINGS.md b/OKF/LEARNINGS.md index 315d683..d5b1706 100644 --- a/OKF/LEARNINGS.md +++ b/OKF/LEARNINGS.md @@ -41,6 +41,12 @@ status: live deepwiki-skill's `toc.yaml`; decision 9 is the same move minus a config format. Source: , (scanned 2026-07-21). +- Believed: a marker-shape check can match its markers anywhere in the + page. True: octobot's own blueprint 004 *documents* the `okf:derived` + markers, so an unanchored match read them as a third fence and failed + the repo's own OKF. A delimiter must be anchored to its whole line, or + the page that specifies it becomes invalid. Source: weave of blueprint + 004. - Believed: shedding both registers would bring ROADMAP under the 110-line cap. True: the warrant `okf-check` requires costs ~7 frontmatter lines a page, which the blueprint's arithmetic (184 − 58 − 16 = 110) did not diff --git a/OKF/ROADMAP.md b/OKF/ROADMAP.md index 5d6670a..5bec25f 100644 --- a/OKF/ROADMAP.md +++ b/OKF/ROADMAP.md @@ -71,8 +71,10 @@ See [ARCHITECTURE.md](ARCHITECTURE.md); loop diagram in `README.md`. against two fixtures — an analysis repo (`analysis/` dirs, no plotting module) and a plain library repo — yields two different non-empty page plans with zero empty ceremonial pages; `grep -rL "^purpose:"` over - `OKF/**.md` returns only `index.md`; after moving a cited symbol, - refresh reports DRIFT and leaves every judgement zone byte-identical. + the warranted scope — `OKF/*.md` plus `decisions/` — returns only + `index.md`; after moving a cited symbol, `okf-check` reports the + broken cite and refresh leaves every judgement zone byte-identical. + Ships as 004 (cites + fences) then 005 (taxonomy scan). 7. **Why-register + ferry collapse** — `OKF/decisions/` indexed by question with warrant frontmatter; moor gains the graduation and collapse steps with the `sealed:` pin. **Verify:** every decision diff --git a/OKF/blueprints/004-give-cites-teeth-and-fence-derived-zone.md b/OKF/blueprints/004-give-cites-teeth-and-fence-derived-zone.md index 88a7beb..b176b9e 100644 --- a/OKF/blueprints/004-give-cites-teeth-and-fence-derived-zone.md +++ b/OKF/blueprints/004-give-cites-teeth-and-fence-derived-zone.md @@ -1,6 +1,6 @@ --- type: Blueprint -status: locked +status: implemented traces-to: ROADMAP.md phase 6, part A (decision 017) --- diff --git a/OKF/index.md b/OKF/index.md index 5dd3a09..05f4b70 100644 --- a/OKF/index.md +++ b/OKF/index.md @@ -25,7 +25,7 @@ your task needs. Humans welcome too. - [001](blueprints/001-add-write-readme-r.md) — add write-readme-r skill — draft - [002](blueprints/002-extract-why-register.md) — extract the why-register from ROADMAP — implemented - [003](blueprints/003-graduate-and-collapse-ferries.md) — graduate ferry decisions and collapse the moored ferry — implemented -- [004](blueprints/004-give-cites-teeth-and-fence-derived-zone.md) — give cites teeth and fence the derived zone — locked +- [004](blueprints/004-give-cites-teeth-and-fence-derived-zone.md) — give cites teeth and fence the derived zone — implemented ## Ferries diff --git a/skills/loop/write-OKF/SKILL.md b/skills/loop/write-OKF/SKILL.md index ceb1f86..3e3ce8a 100644 --- a/skills/loop/write-OKF/SKILL.md +++ b/skills/loop/write-OKF/SKILL.md @@ -50,7 +50,9 @@ contract: [okf-layout.md](okf-layout.md). pointer to the replacement, mirroring [architect/revise.md](../architect/revise.md) discipline. 4. Every ARCHITECTURE.md claim must be **traceable to a file** — cite - `path` (or `path:line`) inline. A claim you can't cite doesn't go in. + `path:symbol` when a symbol carries the claim, `path` or `path:line` + otherwise; grammar in [okf-layout.md](okf-layout.md). A claim you + can't cite doesn't go in. 5. Keep `index.md` complete: every page and every `blueprints/` entry listed, one line each (`NNN — title — status`); every ferry one line, in the shape its state calls for per @@ -58,6 +60,12 @@ contract: [okf-layout.md](okf-layout.md). 6. **Resolve the pins**: for each moored `ferries/.md`, check its `sealed:` change id against the repo and report DRIFT if it is gone. `okf-check` validates the pin's shape; only refresh can resolve it. + DRIFT stops at pins — a cite needs no repo, so `okf-check` owns cite + drift whole. +7. **Regenerate inside the fences only**: a page's `okf:derived` region + is rewritten wholesale, and every byte outside it is judgement zone — + append or supersede, never scan-edit. An unfenced page is all + judgement. ## Output / done criteria - **`scripts/okf-check ` run and its output pasted**, exiting 0. diff --git a/skills/loop/write-OKF/okf-layout.md b/skills/loop/write-OKF/okf-layout.md index 68b1cff..c2893e5 100644 --- a/skills/loop/write-OKF/okf-layout.md +++ b/skills/loop/write-OKF/okf-layout.md @@ -33,11 +33,19 @@ OKF/ - Page types: `Summary`, `Architecture`, `Glossary` (CONTEXT and `context/*`), `Roadmap`, `Learnings`, `Decision`, `Index`, `Blueprint`, `Ferry Map`. New page kinds coin a new type — types are producer-defined. -- **Warrant** — durable pages carry `purpose`, `answers[]`, `cites[]` - after `type`. Zero `answers`, or a question another page owns, makes the - page inadmissible; an unresolvable `cites` path is drift. Scope: the - root pages and `decisions/`. `blueprints/` and `ferries/` carry their - own frontmatter contracts and are exempt. +- **Warrant and pins** — `purpose`, `answers[]`, `cites[]`, their scope, + and the moored-ferry `sealed:` block: [page-warrant.md](page-warrant.md). +- **Cite grammar** — a `cites:` entry is `path`, `path:line`, or + `path:symbol`; all three resolve only if the path exists. `path:symbol` + additionally needs the symbol as a literal substring of the file — that + is the shape that breaks when the thing it cites moves. A `path:line` + number is a reading aid, never validated. +- **Derived zone** — a page carries at most one region delimited by + `` and ``, each marker + alone on its line. Refresh regenerates the inside wholesale and may not + touch a byte outside it; outside is the judgement zone, append/supersede + only. `okf-check` validates the fence's *shape* — balanced, `begin` + first, at most one pair — never its content. - Conformance check: `scripts/okf-check ` — reach for it from this skill's own base directory, never a repo-relative path. Exit 1 on any error; over-cap pages and pages with no `cites` are warnings. @@ -73,20 +81,8 @@ OKF/ numbers — indexed ` — moored → .md`. The two shapes may never coexist. A moored page carries `sealed:` after its `type`, pinning the deliberation it dropped to the commit *before* the - collapse: - - ```yaml - sealed: - change: - commit: - date: - ``` - - Pin drift splits by what each tool can see: `okf-check` validates the - **shape** (all three fields, hex hash, ISO date), because it must exit - 0 on a tree copied outside its jj repo; **refresh** has the repo in - hand and validates **resolution**, reporting DRIFT when the change id - no longer resolves. + collapse — fields and drift rule in + [page-warrant.md](page-warrant.md). - **LEARNINGS.md** — what was believed / what is true / source. Never edited retroactively, only appended or superseded. diff --git a/skills/loop/write-OKF/page-warrant.md b/skills/loop/write-OKF/page-warrant.md new file mode 100644 index 0000000..12b4479 --- /dev/null +++ b/skills/loop/write-OKF/page-warrant.md @@ -0,0 +1,37 @@ +# Page warrant contract + +Why a page is admitted, and how a moored ferry pins what it dropped. The +page set and the rest of conformance: [okf-layout.md](okf-layout.md). + +## Warrant + +Durable pages carry `purpose`, `answers[]`, `cites[]` after `type`. Zero +`answers`, or a question another page owns, makes the page inadmissible; +an unresolvable `cites` path is drift. + +Scope: the root pages and `decisions/`. `blueprints/` and `ferries/` +carry their own frontmatter contracts and are exempt. + +Cite grammar — the three shapes and what each one detects — lives with +the layout contract, in [okf-layout.md](okf-layout.md). + +## `sealed:` — the moored-ferry pin + +A moored page carries `sealed:` after its `type`, pinning the +deliberation it dropped to the commit *before* the collapse: + +```yaml +sealed: + change: + commit: + date: +``` + +Pin drift splits by what each tool can see: `okf-check` validates the +**shape** (all three fields, hex hash, ISO date), because it must exit 0 +on a tree copied outside its jj repo; **refresh** has the repo in hand +and validates **resolution**, reporting DRIFT when the change id no +longer resolves. + +A cite needs no repo, so cite drift does not split the same way — it +belongs to `okf-check` whole. diff --git a/skills/loop/write-OKF/scripts/okf-check b/skills/loop/write-OKF/scripts/okf-check index f7ef7af..e81b9be 100755 --- a/skills/loop/write-OKF/scripts/okf-check +++ b/skills/loop/write-OKF/scripts/okf-check @@ -2,10 +2,10 @@ """Validate an OKF bundle. Usage: okf-check Errors (exit 1): missing type, missing warrant, duplicate answer, -unresolvable cite, page unreachable from index.md, register index line -disagreeing with its decision file, moored ferry with a malformed -`sealed:` pin or a surviving directory. Warnings (exit 0): page over the -110-line cap, page with no cites. +unresolvable cite, malformed `okf:derived` fence, page unreachable from +index.md, register index line disagreeing with its decision file, moored +ferry with a malformed `sealed:` pin or a surviving directory. Warnings +(exit 0): page over the 110-line cap, page with no cites. 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 @@ -90,11 +90,39 @@ def reachable(okf, pages): def cite_resolves(cite, page, okf): - path = cite.split("#")[0].split(":")[0].strip() + """`path` and `path:line` need the path; `path:symbol` needs both. + + The symbol is matched as a literal substring — no language awareness, + no tags file. A `:suffix` that parses as an integer is a reading aid, + never validated: a check that cannot fail is not a check. + """ + path, _, symbol = cite.split("#")[0].partition(":") + path, symbol = path.strip(), symbol.strip() if not path: return False - roots = [page.parent, okf, okf.parent] - return any((root / path).exists() for root in roots) + if symbol.isdigit(): + symbol = "" + for root in (page.parent, okf, okf.parent): + target = root / path + if not target.exists(): + continue + if not symbol: + return True + if target.is_file() and symbol in target.read_text(): + return True + return False + + +def fence_error(text): + """Shape of the derived zone: at most one region, begin before end. + + A fence owns its whole line, so a page that merely *mentions* the + markers in prose or in a command is not fenced. + """ + marks = re.findall(r"^$", text, re.M) + if marks and marks != ["begin", "end"]: + return f"malformed okf:derived fence: {' '.join(marks)}" + return None def pin(text): @@ -170,6 +198,9 @@ def main(argv): if page not in seen: errors.append(f"{rel}: not reachable from index.md") + fence = fence_error(text) + if fence: + errors.append(f"{rel}: {fence}") if page == index: continue if not fields.get("type"):