feat(write-OKF): propose the page plan from a repo scan

Scaffold stopped assuming a fixed four-template skeleton. okf-scan walks a
repo and proposes one evidence-backed page per line; the user locks what
survives into index.md.

- feat(write-OKF): add scripts/okf-scan — analyses/ and modules/ candidates
  from two directory-shaped, language-blind signals, evidence per line
- docs(write-OKF): add taxonomy-scan.md — propose-never-write boundary, the
  producer seam, proposal to locked plan
- docs(write-OKF): rewrite scaffold steps 2-3 as scan, propose, lock,
  materialise only what a producer can fill
- feat(write-OKF): warrant the page templates; add CONTEXT/ROADMAP tpl,
  unmaterialised — scaffold output now passes okf-check
- docs(okf): tick roadmap phase 6, spend its path:line churn risk

implements blueprint 005
This commit is contained in:
Łukasz Boryń 2026-07-22 01:40:45 +02:00
parent e267800787
commit 8dc3e823be
13 changed files with 242 additions and 14 deletions

View File

@ -74,7 +74,9 @@ See [ARCHITECTURE.md](ARCHITECTURE.md); loop diagram in `README.md`.
the warranted scope — `OKF/*.md` plus `decisions/` — returns only the warranted scope — `OKF/*.md` plus `decisions/` — returns only
`index.md`; after moving a cited symbol, `okf-check` reports the `index.md`; after moving a cited symbol, `okf-check` reports the
broken cite and refresh leaves every judgement zone byte-identical. broken cite and refresh leaves every judgement zone byte-identical.
Ships as 004 (cites + fences) then 005 (taxonomy scan). Shipped as 004 (cites + fences) then 005 (taxonomy scan).
✅ verified 2026-07-22 (004, then 005 — two fixtures, two different
non-empty plans; scaffolded OKF passes okf-check, ROADMAP unwritten).
7. **Why-register + ferry collapse** — `OKF/decisions/` indexed by 7. **Why-register + ferry collapse** — `OKF/decisions/` indexed by
question with warrant frontmatter; moor gains the graduation and question with warrant frontmatter; moor gains the graduation and
collapse steps with the `sealed:` pin. **Verify:** every decision collapse steps with the `sealed:` pin. **Verify:** every decision
@ -91,9 +93,7 @@ into a contract for other repos. Numbers stay as issued — append-only.
## Risks & gotchas ## Risks & gotchas
- Open, for phase 6's blueprint: `cites:` pinned at `path:line` churns on None open — 004's `path:symbol` cite shape spent phase 6's churn risk.
every refactor — the staleness detector is also the maintenance bill.
Candidate mitigation `path:symbol` where the language allows.
## Out of scope ## Out of scope

View File

@ -1,6 +1,6 @@
--- ---
type: Blueprint type: Blueprint
status: locked status: implemented
traces-to: ROADMAP.md phase 6, part B (decisions 007, 009, 010) traces-to: ROADMAP.md phase 6, part B (decisions 007, 009, 010)
--- ---

View File

@ -26,7 +26,7 @@ your task needs. Humans welcome too.
- [002](blueprints/002-extract-why-register.md) — extract the why-register from ROADMAP — implemented - [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 - [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 — implemented - [004](blueprints/004-give-cites-teeth-and-fence-derived-zone.md) — give cites teeth and fence the derived zone — implemented
- [005](blueprints/005-propose-the-page-plan-from-a-repo-scan.md) — propose the page plan from a repo scan — locked - [005](blueprints/005-propose-the-page-plan-from-a-repo-scan.md) — propose the page plan from a repo scan — implemented
## Ferries ## Ferries

View File

@ -27,14 +27,19 @@ contract: [okf-layout.md](okf-layout.md).
## Scaffold mode ## Scaffold mode
1. **Confirm the first write** — creating `OKF/` in a repo is a new 1. **Confirm the first write** — creating `OKF/` in a repo is a new
convention; get a yes before writing anything. convention; get a yes before writing anything.
2. Materialise the skeleton from [templates/](templates/) — headers, 2. **Propose the page plan, don't assume one** — run
`type` frontmatter, and `TODO(scribe)` markers only. **Never invent `scripts/okf-scan <repo-root>`, show the candidate lines, and let the
facts**: an empty section with a TODO beats a fabricated architecture user cut, rename, and add the spine pages no tree walk can see. What
claim. survives becomes `index.md`, from [templates/](templates/). Contract:
3. Fill only what is *derivable from disk right now*: SUMMARY from an [taxonomy-scan.md](taxonomy-scan.md).
existing README, ARCHITECTURE bones from the directory tree and 3. **Materialise what the plan lists *and* a producer can fill.** A page
manifests, ROADMAP/CONTEXT stay TODO until is listed when planned, written when its producer has something to
[architect](../architect/SKILL.md) / model-domain produce them. say: SUMMARY from an existing README, ARCHITECTURE bones from the
directory tree and manifests, while ROADMAP and CONTEXT stay
listed-not-written until [architect](../architect/SKILL.md) /
model-domain produce them. **Never invent facts** — an empty section
with a TODO beats a fabricated architecture claim, and an unwritten
page beats an empty one.
4. Wire `AGENTS.md`: insert the block from 4. Wire `AGENTS.md`: insert the block from
[agents-md-hook.md](agents-md-hook.md) (create the file if absent; [agents-md-hook.md](agents-md-hook.md) (create the file if absent;
append if it exists — never overwrite prose). append if it exists — never overwrite prose).

View File

@ -21,9 +21,17 @@ OKF/
├── blueprints/ # NNN-<slug>.md only — flat, grep-able namespace ├── blueprints/ # NNN-<slug>.md only — flat, grep-able namespace
├── ferries/ # open: <topic>/ — MAP.md + D-<n>-<slug>.md files ├── ferries/ # open: <topic>/ — MAP.md + D-<n>-<slug>.md files
│ # moored: <topic>.md, pinned with sealed: │ # moored: <topic>.md, pinned with sealed:
├── modules/ # proposable, never mandatory: <name>.md per code
├── analyses/ # directory / analysis directory a scan found
└── LEARNINGS.md # debunked claims, gotchas — append-only, sourced └── LEARNINGS.md # debunked claims, gotchas — append-only, sourced
``` ```
The spine above is a diagram, not a required page set — `okf-check`
demands no particular page, only reachability, type, and warrant.
`modules/` and `analyses/` are *proposed* from a repo's shape by
[taxonomy-scan.md](taxonomy-scan.md); the rest have producers in the
loop, not on disk.
## Conformance (OKF v0.1) ## Conformance (OKF v0.1)
- Every page except `index.md` opens with YAML frontmatter carrying a - Every page except `index.md` opens with YAML frontmatter carrying a

View File

@ -0,0 +1,82 @@
#!/usr/bin/env python3
"""Propose OKF page candidates from a repo's shape. Usage: okf-scan <repo-root>
One candidate per line on stdout, index.md-ready:
<dir>/<name>.md — <evidence path>
Every line names the disk evidence that warranted it; no evidence, no
line. The scan proposes only — it never writes a page, never edits
index.md, never culls or ranks. Contract: ../taxonomy-scan.md
"""
import sys
from pathlib import Path
NOTEBOOKS = {".ipynb", ".Rmd", ".qmd"}
CODE = {".py", ".R", ".r", ".js", ".jsx", ".ts", ".tsx", ".go", ".rs",
".java", ".rb", ".c", ".h", ".cc", ".cpp", ".hpp", ".sh", ".sql"}
SOURCE_ROOTS = ("src", "lib", "R")
def directories(root):
"""Every directory under root, minus dot-directories and its own OKF/."""
for path in sorted(root.rglob("*")):
parts = path.relative_to(root).parts
if not path.is_dir() or parts[0] == "OKF":
continue
if any(part.startswith(".") for part in parts):
continue
yield path
def analysis_evidence(directory):
"""A directory holding a notebook, or one named analysis/analyses.
The notebook wins as evidence when both hold — a file is the more
concrete warrant.
"""
for entry in sorted(directory.iterdir()):
if entry.is_file() and entry.suffix in NOTEBOOKS:
return entry
return directory if directory.name in ("analysis", "analyses") else None
def module_evidence(directory, root):
"""A directory holding code, one level under the root or a source root."""
if str(directory.relative_to(root).parent) not in (".", *SOURCE_ROOTS):
return None
for entry in sorted(directory.iterdir()):
if entry.is_file() and entry.suffix in CODE:
return entry
return None
def main(argv):
if len(argv) != 2:
print("usage: okf-scan <repo-root>", file=sys.stderr)
return 2
root = Path(argv[1]).resolve()
if not root.is_dir():
print(f"not a directory: {root}", file=sys.stderr)
return 2
plan = {}
for directory in directories(root):
evidence, page = analysis_evidence(directory), "analyses"
if evidence is None:
evidence, page = module_evidence(directory, root), "modules"
if evidence is None:
continue
page = f"{page}/{directory.name}.md"
if page in plan:
continue
rel = evidence.relative_to(root)
plan[page] = f"{rel}/" if evidence.is_dir() else str(rel)
for page in sorted(plan):
print(f"{page} — {plan[page]}")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))

View File

@ -0,0 +1,64 @@
# Taxonomy scan contract
The page taxonomy is derived per repo, not fixed — a scan turns a repo's
shape into a page plan a user locks into `index.md`. Page set and
conformance: [okf-layout.md](okf-layout.md). Warrants:
[page-warrant.md](page-warrant.md).
## The boundary
**The scan proposes; it never writes and never culls.**
`scripts/okf-scan <repo-root>` prints one candidate per line to stdout,
index.md-ready, and exits 0 whatever it finds (2 on usage):
```
<dir>/<name>.md — <evidence path>
```
Every line names the disk evidence that warranted it. **No evidence, no
line.** The scan writes no page, edits no `index.md`, ranks nothing, and
removes nothing — culling is the user's, at lock time. It is not a
validator either; `okf-check` owns conformance.
## The two signals
Both directory-shaped, both language-blind. Dot-directories and the
repo's own `OKF/` are skipped.
- **`analyses/<name>.md`** — a directory holding a `.ipynb`, `.Rmd`, or
`.qmd`, or one named `analysis`/`analyses`. One page each, named for
the directory; the notebook is the evidence when both hold.
- **`modules/<name>.md`** — a directory holding at least one code file,
one level under the repo root or under a single source root (`src/`,
`lib/`, `R/`), and not already an analyses candidate.
A code file is one with a known source extension — that list is how you
spot code at all, not language awareness: no import graphs, no
per-language heuristics, no size thresholds, no ranking. **A threshold
is a decision to make**, and this scan makes none.
## What a scan cannot see
**A scan proposes only what a scan can see.** `modules/` and `analyses/`
are read off disk. The spine — `SUMMARY`, `ARCHITECTURE`, `CONTEXT`,
`ROADMAP`, `LEARNINGS`, `decisions/` — is written by loop skills out of
conversation, and no tree walk finds a glossary. That is the producer
seam [SKILL.md](SKILL.md) already draws at scaffold step 3; decision
[010](../../../OKF/decisions/010-two-zone-pages.md) draws it from the
other side, module and analysis pages being the only ones with a derived
zone at all. `context/<subroot>.md` has no disk signal either — a
bounded context is model-domain's to name.
## Proposal → locked plan
1. Run the scan; show the user the candidate lines.
2. The user edits the list — cut, rename, add spine pages the scan
cannot see. What survives goes into `index.md`, one line + hook each.
3. Materialise only the pages a producer can fill *now*.
**A page is listed when planned, written when its producer has something
to say.** `index.md` may name a page that does not exist yet; no TODO
shell is written for it. `okf-check` cuts both ways here — an absent
link target is skipped, so plan-without-page is legal, while a page
nobody lists errors `not reachable from index.md`. An unwritten page
cannot be an empty ceremonial one.

View File

@ -1,5 +1,9 @@
--- ---
type: Architecture type: Architecture
purpose: Map the modules, their seams, and the flows that explain most behaviour.
answers:
- "What are this project's modules and seams, and how does behaviour flow through them?"
# cites: one path per claim, added as the TODOs below are filled.
--- ---
# <project> — architecture # <project> — architecture

View File

@ -0,0 +1,19 @@
---
type: Glossary
purpose: Hold the one canonical glossary for this bounded context.
answers:
- "What does each domain term in this project mean, canonically?"
# cites: one path per term whose meaning a file carries.
---
# <project> — context
<!-- model-domain owns this content; scribe only places the page. One
canonical glossary per bounded context — never per issue.
Issue-local terms stay in their blueprint until they recur.
Entry format: CONTEXT-FORMAT.md in the model-domain skill. -->
## Terms
TODO(model-domain) — one entry per canonical term: the name, what it
means here, and what it is *not* to be confused with.

View File

@ -1,5 +1,9 @@
--- ---
type: Learnings type: Learnings
purpose: Keep what was believed, what turned out true, and the source that settled it.
answers:
- "Which beliefs about this project were debunked, and what replaced them?"
# cites: one path per claim, added as the TODOs below are filled.
--- ---
# <project> — learnings # <project> — learnings

View File

@ -0,0 +1,30 @@
---
type: Roadmap
purpose: Carry only what is still ahead — phases, their verify steps, and live risk.
answers:
- "What is this project building next, and how is each phase verified?"
# cites: decisions/index.md once the why-register has its first entry.
---
# <project> — roadmap
<!-- architect owns this content; scribe only places the page. Carries
what is *ahead* — a shipped phase keeps its verify evidence, a
spent risk is deleted. -->
## Locked decisions
TODO(architect) — the why-register: [decisions/index.md](decisions/index.md).
## Phases
TODO(architect) — numbered, append-only, each with a **Verify:** step
concrete enough to run.
## Risks & gotchas
TODO(architect) — what could still sink a phase, deleted once spent.
## Out of scope
TODO(architect) — what was considered and deliberately left out.

View File

@ -1,5 +1,9 @@
--- ---
type: Summary type: Summary
purpose: Say what this project is and where to read next, for an agent landing cold.
answers:
- "What is this project, and where should an agent start reading?"
# cites: one path per claim, added as the TODOs below are filled.
--- ---
# <project> — summary # <project> — summary

View File

@ -15,6 +15,14 @@ your task needs. Humans welcome too.
- [ROADMAP.md](ROADMAP.md) — phased plan with verify steps. - [ROADMAP.md](ROADMAP.md) — phased plan with verify steps.
- [LEARNINGS.md](LEARNINGS.md) — gotchas and debunked claims. - [LEARNINGS.md](LEARNINGS.md) — gotchas and debunked claims.
A page is listed when planned, written when its producer has something to
say — CONTEXT and ROADMAP wait for model-domain and architect.
## Modules & analyses
- TODO(scribe): the locked page plan from the taxonomy scan, one line
each — `modules/<name>.md`, `analyses/<name>.md`.
## Decisions ## Decisions
- `decisions/index.md` — TODO(scribe): the why-register; link it here - `decisions/index.md` — TODO(scribe): the why-register; link it here