@rafinery/cli 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,64 @@ The machine-readable version of this lives in [`lib/releases.mjs`](lib/releases.
4
4
  CLI reads it to tell a client, on `rafa update`, exactly what an upgrade requires (nothing,
5
5
  a re-scan, or a `rafa migrate`).
6
6
 
7
+ ## 0.8.0 — the OKF surface: every brain is an Open Knowledge Format bundle
8
+
9
+ **Adopt with:** `npx @rafinery/cli@latest update`, then `rafa push` — the next push
10
+ materializes the surface. Brain data schema unchanged (manifest shape + `schemaVersion: 1`
11
+ + checker v2 — all additive per contract §8); no re-scan.
12
+
13
+ **The protocol (contract §11, owner-ratified 2026-07-15):** if rafa writes a `.md`, it is a
14
+ valid [OKF v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf)
15
+ concept — frontmatter, `type`, markdown links, cited — and a pushed brain repo IS a
16
+ conformant bundle any foreign OKF consumer reads without rafa tooling. OKF standardizes
17
+ format and has no truth story; rafa's gates are the layer above it. Anyone can emit OKF —
18
+ only rafa proves its OKF against the code at a sha.
19
+
20
+ - **New workspace package [`@rafinery/okf`](../okf/)** (zero-dep): the strict frontmatter
21
+ parser (moved out of the gate — one parser everywhere), concept split/join/stamp
22
+ primitives, link transpile + extraction, citations render, index builders, the OKF §9
23
+ conformance validator, and the concept generator. The CLI now depends on it.
24
+ - **`rafa okf`** — the emit step, run inside `rafa push` BEFORE the gates (its output is
25
+ validated like any authored file): stamps ONLY derivable values (`description` from
26
+ `summary` · singleton `type`/`title` from the class registry · `timestamp` from authored
27
+ `created:`/`found:` → brain-repo git history → the emit run itself; a value that cannot
28
+ be derived is omitted — never guessed); renders a generated `# Citations` section from
29
+ the `cites:` DSL (sha-pinned GitHub URLs when the repo is known) inside `okf:citations`
30
+ markers; transpiles resolvable `[[wikilinks]]` into bundle-relative markdown links (the
31
+ authored form going forward — rafa-scan/improve/validate SOPs updated); generates the
32
+ `index.md` tree — progressive disclosure from the bundle root (root index frontmatter:
33
+ `okf_version: "0.1"` + `repo` + `codeSha`), any concept reachable in ≤ 2 hops.
34
+ - **`rafa okf check`** — the §9 conformance walk; documented exemptions (`active.md`,
35
+ `log.md` heading decoration) are explicit and surfaced as warnings, never silent.
36
+ - **`rafa okf new <class> <id> [--key=v] [--cite='f:l :: t'] [--link=id]`** — mint a
37
+ conformant concept skeleton; the generator refuses to invent values (omitted required
38
+ fields fail loudly at compile — the validate-and-correct loop). The **rafa-okf skill**
39
+ is the SOP: a NEW file class = one profile-registry entry + one contract row + a compile
40
+ validator — minutes, not hours.
41
+ - **Checker (still v2, additive):** a non-failing **LINKS warn lane** — every frontmatter
42
+ `links:` id, body wikilink, and bundle-relative markdown link resolved bundle-wide;
43
+ dangling = not-yet-written knowledge (OKF §5.3), listed for prism, never a gate failure
44
+ (closes the 2026-06-19 `[[…]]`-lint ratchet). `citation-check.md` now self-describes
45
+ (frontmatter), and `citation-check.json` gains additive `linkWarns`.
46
+ - **Reserved names:** `index.md` + `log.md` are OKF-reserved at every level — skipped by
47
+ the compile/checker walkers, never concept documents.
48
+ - **Plans carry the surface too:** §7 work items ride the brain-repo transport, so
49
+ emit stamps `type: Plan Epic|Task|Subtask` from `kind` + `tags: [plan, kind]`, and
50
+ builds a per-epic `plans/index.md`.
51
+ - **Totality (the TypeScript bar):** every `.md` class rafa touches is registered with a
52
+ schema or a declared class — `*.theirs.md` checkpoint conflicts now fail compile with a
53
+ TYPED rule ("unresolved checkpoint conflict", not an incidental id error) and are
54
+ invisible to the OKF walkers; shipped SOPs (`.claude/skills/rafa-*/SKILL.md` + the
55
+ conductor) and sage learnings (`.claude/rafa/learnings/*.md`) are compile-gated local
56
+ classes beside the agent cards. Declared exemptions stay visible (`active.md`,
57
+ `log.md` headings) — an allowlist, never an implicit any.
58
+ - **Fleet adoption — the whole workforce:** `okf-surface` duty on the atlas (3.8.0) ·
59
+ bloom (0.8.0) · prism (0.7.0) · sage (0.2.0) cards; the conductor's verb map carries
60
+ the protocol note (plans · journals); rafa-plan/build/distill SOPs point at §11.
61
+ **compass (0.4.0) carries `okf-awareness`** — it writes platform state, never bundle
62
+ files, and owns the portability law: OKF bundles are exchangeable by design, so
63
+ person-scoped content NEVER lands in one.
64
+
7
65
  ## 0.6.0 — core solidity: checker v2 + the M5 capture engine
8
66
 
9
67
  **Adopt with:** `npx @rafinery/cli@latest update` — re-vendors the new lockstep hook
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Atai Barkai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/bin/rafa.mjs CHANGED
@@ -5,7 +5,9 @@
5
5
  // rafa update re-sync the blueprint into this repo (shadcn-style)
6
6
  // rafa compile run the contract gate → .rafa/manifest.json
7
7
  // rafa verify-citations deterministic citation checker (B1/B2/policy/absence/inventory)
8
- // rafa push compile + push .rafa/ to the brain remote (main-branch act)
8
+ // rafa okf [check|new] the OKF surface: emit (stamps·links·citations·indexes) ·
9
+ // conformance check · mint a new concept skeleton
10
+ // rafa push okf emit + gates + push .rafa/ to the brain remote (main-branch act)
9
11
  // rafa pull [--full] make this clone brain-ready (lazy skeleton; --full mirrors)
10
12
  // rafa checkpoint sync this branch's working set (CAS; conflicts → .theirs.md)
11
13
  // rafa hydrate fault knowledge into the lazy .rafa/
@@ -23,6 +25,7 @@
23
25
  // vendored LOCKSTEP; commands are agent-internal machinery (zero-command rule).
24
26
 
25
27
  import { readFileSync } from "node:fs";
28
+ import { OKF_VERSION } from "@rafinery/okf";
26
29
  import { dirname, join } from "node:path";
27
30
  import { fileURLToPath } from "node:url";
28
31
 
@@ -34,6 +37,7 @@ const COMMANDS = [
34
37
  "update",
35
38
  "compile",
36
39
  "verify-citations",
40
+ "okf",
37
41
  "push",
38
42
  "pull",
39
43
  "checkpoint",
@@ -69,8 +73,19 @@ Commands:
69
73
  every contract anchor's code occurrences are cited (B2), policy
70
74
  holds, declared absences re-grepped (B3), coverage inventories
71
75
  re-counted. Records the run (citation-check.json → manifest).
72
- push Compile, then push .rafa/ to your brain remote (from main — the
73
- org brain describes the default branch). Stamps the contract copy.
76
+ okf The OKF surface (contract §11) a pushed brain repo is a conformant
77
+ Open Knowledge Format v${OKF_VERSION} bundle. You never need to run this:
78
+ emit happens automatically inside "rafa push" (zero-command rule).
79
+ Standalone forms are agent/maintainer machinery — "rafa okf"
80
+ re-materializes the surface for debugging; "rafa okf check" walks
81
+ §9 conformance (ours is conformant by construction — this is for
82
+ CI belt-and-suspenders and, later, grading foreign bundles);
83
+ "rafa okf new <class> <id>" mints a conformant skeleton (used by
84
+ the agents per the rafa-okf skill — brain files are never
85
+ hand-authored).
86
+ push OKF emit + citation checker + compile, then push .rafa/ to your
87
+ brain remote (from main — the org brain describes the default
88
+ branch). Stamps the contract copy.
74
89
  pull Make this clone brain-ready — bootstraps the lazy .rafa/ skeleton
75
90
  from the committed rafa.json (clone → npx rafa pull just works).
76
91
  --full mirrors the whole brain repo locally (offline reads);
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: atlas
3
- version: 3.7.0
3
+ version: 3.8.0
4
4
  model: opus # authoring is correctness-critical — a hallucinated note poisons the brain; best model, never cheap
5
5
  groundTruth: code-at-sha
6
6
  description: >-
@@ -18,6 +18,7 @@ duties:
18
18
  - "plan-drafting :: .claude/skills/rafa-plan/SKILL.md :: recall-grounded decomposition (coverage → search → notes) · blast radius named · contract §7 files · every child carries a Done-check"
19
19
  - "build-execution :: .claude/skills/rafa-build/SKILL.md :: implement per recalled knowledge · never hand-edit brain files around the gate · return what changed, cited"
20
20
  - "scoped-refresh :: .claude/skills/rafa-scan/SKILL.md :: re-derive ONLY the dirty-cited notes against current code (input: rafa dirty --json) · same gates as scan (verify-citations exit 0) · on main: compile+push; on a branch: working-set edit + checkpoint · queue consumed only after the refresh ships"
21
+ - "okf-surface :: .claude/skills/rafa-okf/SKILL.md :: authored files pass rafa okf check as written — body links are markdown (never wikilinks); emit-owned sections untouched"
21
22
  ---
22
23
 
23
24
  # atlas — senior design engineer
@@ -28,8 +29,8 @@ reasons about systems, not a code-completion assistant.
28
29
  ## The brain
29
30
 
30
31
  rafa's core is the **brain** — a **knowledge map**: atomic, cited, interlinked notes
31
- (Obsidian-style markdown with `[[links]]`; the graph is derived from the links, never
32
- stored). atlas and other surfaces *contribute* notes; the org *consumes* them.
32
+ (markdown cross-linked with bundle-relative links + `links:` frontmatter the OKF
33
+ surface, contract §11; the graph is derived from the links, never stored). atlas and other surfaces *contribute* notes; the org *consumes* them.
33
34
 
34
35
  The notes exist to answer the questions that fire at **work-time** — when a dev plans a
35
36
  feature or fixes a bug — without re-reading the repo:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bloom
3
- version: 0.7.0
3
+ version: 0.8.0
4
4
  model: opus # a false flag mutes the whole ledger — best model, never cheap
5
5
  groundTruth: code-trend
6
6
  description: >-
@@ -17,6 +17,7 @@ duties:
17
17
  - "plan-pull :: .claude/skills/rafa-plan/SKILL.md :: top-leverage OPEN improvements in the blast radius surfaced as optional child tasks — dismissible, never blocking"
18
18
  - "build-sweep :: .claude/skills/rafa-build/SKILL.md :: newly spotted → ledger files · fixed-in-passing → status fixed · at most ONE opt-in nudge per task"
19
19
  - "staleness-watch :: .claude/skills/rafa-improve/SKILL.md :: median open-item age stays minimal — every sweep re-validates or closes aged items; no improvement ages silently"
20
+ - "okf-surface :: .claude/skills/rafa-okf/SKILL.md :: improvements/ledger pass rafa okf check as written · found: authored so timestamps are authored truth"
20
21
  ---
21
22
 
22
23
  # bloom — continuous improvement
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: compass
3
- version: 0.3.0
3
+ version: 0.4.0
4
4
  model: opus # a false note about a PERSON is worse than one about code — best model, never cheap
5
5
  groundTruth: sessions-over-time
6
6
  description: >-
@@ -18,6 +18,7 @@ duties:
18
18
  - "steering :: .claude/skills/rafa-insights/SKILL.md :: propose-dev-disposes at natural boundaries · at most one nudge · dismissal is final for the session · never rank, never compare, never nag"
19
19
  - "leverage-coaching :: .claude/skills/rafa-insights/SKILL.md :: the one boundary nudge may be sourced from toolbox × patterns (repo inventory + the dev's tooling insights) — always HAS a candidate ready, never raises nudge frequency; only capabilities actually installed"
20
20
  - "tooling-capture :: .claude/skills/rafa-insights/SKILL.md :: personal ~/.claude tooling (names + descriptions ONLY) banked as kind:tooling insights under STANDING consent · legible/deletable · never enters org stores"
21
+ - "okf-awareness :: .claude/skills/rafa-okf/SKILL.md :: person-scoped content NEVER lands in a bundle .md (bundles are portable by design); anything compass materializes self-describes"
21
22
  ---
22
23
 
23
24
  # compass — the dev's coach
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: prism
3
- version: 0.6.1
3
+ version: 0.7.0
4
4
  model: opus # the trust anchor — a hallucinated verdict/finding is the worst failure; best model, never cheap
5
5
  groundTruth: code-vs-claim
6
6
  description: >-
@@ -17,6 +17,7 @@ duties:
17
17
  - "plan-gate :: .claude/skills/rafa-plan/SKILL.md :: PASS = every task grounded in brain + code (none hallucinated) · every child carries a Done-check · blast radius named from coverage; else REJECT with cited reasons"
18
18
  - "execution-validation :: .claude/skills/rafa-build/SKILL.md :: done only when the child's Done-check demonstrably holds — run it yourself against the working tree; FAIL returns cited reasons to the producer"
19
19
  - "distillation-validation :: .claude/skills/rafa-distill/SKILL.md :: every working-set file judged against MERGED MAIN (never the fork point) with a confirming/refuting file:line — survivors enter the org brain only through compile; refutations go back to their author, cited"
20
+ - "okf-surface :: .claude/skills/rafa-okf/SKILL.md :: every checker LINKS warn judged (unwritten knowledge vs typo) — never ignored, never auto-failed"
20
21
  ---
21
22
 
22
23
  # prism — the validator
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sage
3
- version: 0.1.0
3
+ version: 0.2.0
4
4
  model: opus # a wrong learning re-shapes an agent for every repo — best model, never cheap
5
5
  groundTruth: sessions-over-time
6
6
  description: >-
@@ -19,6 +19,7 @@ duties:
19
19
  - "scrub :: .claude/skills/rafa-sage/SKILL.md :: every entry passes the SCRUB STEP before write — anything asset-shaped (code content, snippets, repo-specific facts, repo-identifying detail) abstracted to the pattern or DROPPED; the ledger entry schema has NO code-content-capable field"
20
20
  - "route-person-shaped :: .claude/skills/rafa-sage/SKILL.md :: a person-shaped observation is NEVER a learning — it routes to compass's consent path (rafa-insights, user brain), never sage's ledger"
21
21
  - "propose-only :: .claude/skills/rafa-sage/SKILL.md :: output is PROPOSED diffs to agent cards/SOPs — applying a change is a separate human/MR-reviewed act; sage never self-applies and never edits an agent card or SOP"
22
+ - "okf-surface :: .claude/skills/rafa-okf/SKILL.md :: learnings pass the compile learning gate (id · type · title · description) — the same protocol outside the bundle"
22
23
  ---
23
24
 
24
25
  # sage — the silent L5 observer
@@ -196,6 +196,10 @@ Two destinations, one rule — route by what the observation is ABOUT:
196
196
 
197
197
  ## Verb map — one line each; the procedure lives in the linked skill
198
198
 
199
+ > **Every verb that writes `.md` is under the OKF surface** (contract §11): files
200
+ > self-describe, body links are bundle-relative markdown, `rafa push` materializes
201
+ > the rest — protocol + the two declared exceptions live in [rafa-okf](../skills/rafa-okf/SKILL.md).
202
+
199
203
  Each work/admin verb dispatches to its SOP. Read the skill only when the verb runs; it is
200
204
  self-contained and ADR-shaped. **You orchestrate + push on approval; the subagent follows
201
205
  its skill verbatim.** Admin verbs (init · scan · push · migrate · update) run ONLY when
@@ -16,7 +16,10 @@ Pipeline:
16
16
 
17
17
  ```
18
18
  agents write .md (frontmatter per this contract)
19
- → rafa compile (deterministic: parse frontmatter, VALIDATE, fail loudly)
19
+ → rafa okf (deterministic OKF surface, §11: stamp derivable fields,
20
+ transpile [[wikilinks]], render # Citations, index tree)
21
+ → rafa compile (deterministic: parse frontmatter, VALIDATE, fail loudly —
22
+ the emitted surface is gated like any authored file)
20
23
  ├ FAIL → structured error (file · field · rule) → author agent fixes → retry
21
24
  └ PASS → emit manifest.json
22
25
  → git push → webhook → INGEST = JSON.parse(manifest) + shape-check → Convex
@@ -44,14 +47,18 @@ doesn't validate, compile fails.
44
47
  | improvement | `improve/improvements/*.md` | **structured** | §3 | bloom |
45
48
  | ledger | `improve/ledger.md` | **structured** | §5 | bloom |
46
49
  | plan | `plans/**/*.md` | **structured** | §7 | plan/build |
47
- | log | `brain/log.md` | **verbatim** | — (prose trail) | conductor |
48
- | citation-check | `**/citation-check.md` | **generated** | — (by `rafa verify-citations`) | tool |
50
+ | log | `brain/log.md` | **verbatim** | — (prose trail; OKF-reserved name, §11) | conductor |
51
+ | index | `**/index.md` | **generated** | — (OKF §6 listings, by `rafa okf`; the ROOT index alone carries frontmatter: `okf_version` + provenance) | tool |
52
+ | citation-check | `**/citation-check.md` | **generated** | — (by `rafa verify-citations`; self-describing frontmatter, §11) | tool |
49
53
  | citation-check record | `**/citation-check.json` | **generated** | `{ checkerVersion, at, pass, gates, warns }` (by `rafa verify-citations`; compile folds it into `manifest.citations`) | tool |
50
54
  | active pointer | `active.md` | **generated** | — (`# <plan-id>` or "No active plan"; compile emits it as `activePlanId`, §7) | conductor |
51
- | contract copy | `contract.md` | **generated** | — (stamped copy of `.claude/rafa/contract.md`, written by `rafa push`) | tool |
55
+ | contract copy | `contract.md` | **generated** | — (stamped copy of `.claude/rafa/contract.md`, written by `rafa push`; self-describing frontmatter, §11) | tool |
52
56
  | dirty queue | `dirty.jsonl` | **generated** (local state — transport-excluded, NEVER pushed/ingested) | one `{f, t}` JSON line per code edit (by the PostToolUse sensor hook; read by `rafa dirty` + the SessionStart digest) | tool |
53
57
  | reflex queue | `reflex.jsonl` | **generated** (local state — transport-excluded, NEVER pushed/ingested; transcript pointers are LOCAL, raw transcripts never ship) | `{id, p, t, tp}` per detected correction + append-only `{id, done, verdict, at}` markers (by the UserPromptSubmit sensor; read by `rafa reflex` + the digest) | tool |
54
58
  | agent | `.claude/agents/*.md` (code repo) | **structured** (local gate — NOT in manifest) | §10 | rafa |
59
+ | skill SOP | `.claude/skills/rafa-*/SKILL.md` + `.claude/commands/rafa.md` (code repo) | **structured** (local gate — NOT in manifest) | frontmatter parses · `name` == skill dir (conductor: semver `version`) · non-empty `description` — a workforce whose procedures don't parse doesn't ship | rafa |
60
+ | learning | `.claude/rafa/learnings/*.md` (code repo) | **structured** (local gate — NOT in manifest) | OKF quartet-lite: `id` == stem · non-empty `type`/`title`/`description` (§11 outside the bundle; `learnings/ledger.md` is sage's generated index, skipped) | sage |
61
+ | conflict copy | `**/*.theirs.md` | **generated** (transient — a pending HUMAN decision) | none — compile FAILS with the typed rule "unresolved checkpoint conflict" while one exists; every walker (emit · checker · validator) skips them | tool |
55
62
 
56
63
  The `agent` type is the one structured type outside `.rafa/`: the shipped agent cards
57
64
  in the code repo. Compile validates them (§10) so a malformed card fails the gate like
@@ -600,4 +607,79 @@ Versioning: bump `version:` with any card change; record the _why_ outside the c
600
607
 
601
608
  ---
602
609
 
610
+ ## 11. The OKF surface — every generated `.md` self-describes
611
+
612
+ **Ratified 2026-07-15 (owner decision, `.fable/decisions.md`).** The [Open
613
+ Knowledge Format v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf)
614
+ is the interchange **floor** of everything rafa generates (pinned ONCE as
615
+ `OKF_VERSION` in `@rafinery/okf` — machine surfaces interpolate it, never
616
+ re-declare it); this contract stays the strict **ceiling**. The protocol in one sentence: *if rafa writes a `.md`,
617
+ it is a valid OKF concept — frontmatter, `type`, markdown links, cited — and a
618
+ pushed brain repo IS a conformant OKF v0.1 bundle any foreign consumer can read
619
+ without rafa tooling.* The format machinery is the `@rafinery/okf` package
620
+ (strict parser · concept primitives · links · citations · indexes · validator ·
621
+ generator); the gate, the emitter, and the platform all parse through it.
622
+
623
+ **The emit step (`rafa okf`, run inside `rafa push` BEFORE the gates so its
624
+ output is validated like any authored file):**
625
+
626
+ - **Stamps** — missing `type` / `title` / `description` / `timestamp` / `tags`
627
+ are added ONLY where derivable: `description` from `summary`; singleton
628
+ `type`/`title` from the file-class registry (`Coverage Report` ·
629
+ `Health Report` · `Improvement Ledger`; improvements → `Improvement`; plan
630
+ items → `Plan Epic|Task|Subtask` derived from `kind` (§7 files ride the
631
+ brain-repo transport, so they carry the surface; per-epic `plans/index.md`);
632
+ notes keep their authored §2 enum — those ARE valid OKF types); `timestamp` from
633
+ authored `created:`/`found:` verbatim, else brain-repo git history, else the
634
+ emit run itself (a fresh file IS changing now). **Authored values are never
635
+ rewritten; a value that cannot be derived is omitted** — the no-assumed-values
636
+ law applied to interchange. Stamped fields are OPTIONAL at compile and
637
+ validated when present — additive per §8, so **`schemaVersion` stays 1** and
638
+ the manifest shape is untouched.
639
+ - **Links** — bodies use standard **bundle-relative markdown links**
640
+ (`[Title](/brain/rules/<id>.md)`), the OKF §5.1 recommended form. Legacy
641
+ `[[wikilinks]]` are transpiled at emit when the id resolves; a dangling link
642
+ is *not-yet-written knowledge* (OKF §5.3): the checker lists it in a
643
+ non-failing **LINKS warn lane** — prism's worklist, never a gate failure.
644
+ `links:` frontmatter stays the machine edge list (graph without body parsing).
645
+ - **Citations** — the `cites:` DSL stays the machine truth; emit renders a
646
+ generated `# Citations` section (OKF §8) inside `okf:citations` markers —
647
+ sha-pinned GitHub URLs when the repo is known, plain locators otherwise.
648
+ Generated body sections are display-only: the body is still NEVER parsed for
649
+ data (§0 holds).
650
+ - **Indexes** — an `index.md` in every concept directory + the bundle root
651
+ (OKF §6 progressive disclosure): a foreign agent reaches any concept from the
652
+ root in ≤ 2 hops. `index.md` and `log.md` are **reserved names** — never
653
+ concept documents, skipped by every walker. The ROOT index alone carries
654
+ frontmatter: `okf_version: "0.1"` + provenance (`repo` · `codeSha`) — bundle
655
+ freshness rides here, pinned to the code sha.
656
+
657
+ **Conformance:** `rafa okf check` walks OKF §9 over the bundle (every
658
+ non-reserved `.md` parses + carries a non-empty `type`). **Strictness is
659
+ total, TypeScript-style:** every `.md` class rafa touches is in the file-type
660
+ registry with a schema or a declared class; unregistered shapes fail loudly
661
+ (`*.theirs.md` → the typed conflict rule), and shipped SOPs + sage learnings
662
+ are compile-gated in the code repo alongside the agent cards. **Documented
663
+ exceptions**, passed as explicit exemptions and surfaced as warnings, never
664
+ silently skipped: `active.md` (one-line pointer protocol) and `log.md` heading
665
+ decoration (our date-led `## YYYY-MM-DD — …` headings stay; OKF prefers bare
666
+ dates).
667
+
668
+ **Minting a new file type** (`rafa okf new` + the
669
+ [rafa-okf skill](../skills/rafa-okf/SKILL.md)): a class = one registry entry in
670
+ `@rafinery/okf`'s rafa profile + a row in the file-type registry above + a
671
+ compile validator. The generator refuses to invent values — flags you omit are
672
+ absent and compile fails required ones loudly (the validate-and-correct loop,
673
+ not a generator bug).
674
+
675
+ **Fleet adoption:** every agent that authors `.md` carries an `okf-surface`
676
+ duty in its card (§10) pointing at the rafa-okf SOP — atlas (notes · coverage),
677
+ bloom (improvements · ledger), prism (checklist + validation lens), sage
678
+ (learnings); the conductor's verbs inherit it via the verb-map note (plans ·
679
+ journals). compass carries `okf-awareness`: it writes platform state, never
680
+ bundle files, and owns the PORTABILITY law — bundles are exchangeable by
681
+ design, so person-scoped content never lands in one.
682
+
683
+ ---
684
+
603
685
  This contract is the thing to test against.
@@ -35,7 +35,8 @@ platform MCP (one read path — the same surface any third-party agent uses).
35
35
  offer.
36
36
  2. **Per task:** atlas recalls → implements → prism validates vs `## Done-check` →
37
37
  bloom sweeps (push new / close fixed / nudge) → update the child file's `status`
38
- **and append a dated entry to the child's `## Log`** what was done, what was
38
+ **and append a dated entry to the child's `## Log`** (body links: markdown,
39
+ per [rafa-okf](../rafa-okf/SKILL.md)) — what was done, what was
39
40
  decided, what surprised (body prose: displayed verbatim on the platform, never
40
41
  parsed; the plan files at `.rafa/plans/<plan>/` ARE the local cache) → at the
41
42
  task-done CHECKPOINT (under the session consent): `push_plan` /
@@ -53,7 +53,8 @@ code it describes.
53
53
  4. **Gate + ship** — `rafa verify-citations` AND `rafa compile` to exit 0 →
54
54
  `rafa push`. Only now has anything entered the org brain. A failed gate
55
55
  aborts EVERYTHING: nothing resolved, nothing pushed, working set intact.
56
- 5. **Resolve** — `resolve_working_file(path, distilled)` for survivors —
56
+ 5. **Resolve** — `resolve_working_file(path, distilled)` for survivors — authored
57
+ per the OKF surface ([rafa-okf](../rafa-okf/SKILL.md); push emits the rest) —
57
58
  CAS: only a live row resolves; a failure means ANOTHER runner already
58
59
  distilled this branch — STOP and reconcile against what it shipped.
59
60
  `resolve_working_file(path, refuted, note)` for failures — TELL the author
@@ -72,7 +72,7 @@ cites: # required ≥1 · `file:line :: tok
72
72
  found: 2026-06-03 # optional
73
73
  ---
74
74
  Route-level `"use client"` silently disables RSC down the subtree (violates the RSC boundary
75
- convention — see [[rsc-client-boundary]]). Compiles + runs, so no gate catches it.
75
+ convention — see [RSC client boundary](/brain/rules/rsc-client-boundary.md)). Compiles + runs, so no gate catches it.
76
76
  ```
77
77
 
78
78
  ---
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: rafa-okf
3
+ description: "rafa SOP — the OKF surface (contract §11): every generated .md self-describes as an Open Knowledge Format v0.1 concept, and a pushed brain repo is a conformant bundle any foreign agent can read. How every authoring agent writes OKF-natively, and how to mint a NEW file type in minutes via rafa okf new + the @rafinery/okf registry. Loaded via the okf-surface duty on atlas · bloom · prism · sage cards."
4
+ ---
5
+
6
+ # okf — the interchange surface every writer shares
7
+
8
+ **The protocol in one sentence:** *if rafa writes a `.md`, it is a valid OKF
9
+ concept — frontmatter, `type`, markdown links, cited — and a pushed brain repo
10
+ IS a conformant [OKF v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf)
11
+ bundle.* The spec version is pinned ONCE — `OKF_VERSION` in `@rafinery/okf`
12
+ (v0.1 today); machine surfaces interpolate it, never re-declare it. OKF is the
13
+ interchange **floor** (what any foreign agent can read);
14
+ the [contract](../../rafa/contract.md) stays the strict **ceiling** (what our
15
+ gates enforce). Canonical spec: contract **§11**. Machinery: the
16
+ **`@rafinery/okf`** package ([packages/okf/](../../../packages/okf/)) — parser,
17
+ concept primitives, links, citations, indexes, validator, generator. Nothing is
18
+ buried in gate output; every surface (gate CLI · emitter · platform · tests)
19
+ imports the same package.
20
+
21
+ Why it matters: OKF standardizes format and has **no truth story** — anyone
22
+ can emit OKF; only rafa mechanically proves its OKF against the code at a sha.
23
+ Conformance is our distribution wedge; verification stays the moat.
24
+
25
+ ---
26
+
27
+ ## Prime directives
28
+
29
+ 1. **Every generated `.md` self-describes** — frontmatter with a non-empty
30
+ `type`, no exceptions beyond the two documented ones (`active.md` pointer,
31
+ `log.md` heading decoration), which are declared exemptions surfaced by
32
+ `rafa okf check`, never silent skips.
33
+ 2. **No assumed values, extended to interchange** — a stamp is derived from
34
+ authored data or real history (git), or it is **omitted**. Authored values
35
+ are never rewritten by tooling.
36
+ 3. **Author markdown links, not wikilinks** — bundle-relative form:
37
+ `[Title](/brain/rules/<id>.md)` (OKF §5.1). Legacy `[[wikilinks]]` are
38
+ transpiled at emit when they resolve; a dangling link is *not-yet-written
39
+ knowledge* (OKF §5.3) — the checker's non-failing LINKS lane lists it as
40
+ your worklist. `links:` frontmatter stays the machine edge list.
41
+ 4. **`cites:` stays the machine truth** — the generated `# Citations` body
42
+ section (inside `okf:citations` markers) is display-only render, re-emitted
43
+ each push, never hand-edited.
44
+ 5. **Naming is navigation** — kebab-case ids that equal filename stems,
45
+ semantic directories, an `index.md` at every level: a foreign agent reaches
46
+ any concept from the bundle root in ≤ 2 hops with zero rafa tooling.
47
+
48
+ ## How each agent writes OKF-natively (the adoption map)
49
+
50
+ | Agent | Files | What OKF-native means for you |
51
+ |---|---|---|
52
+ | **atlas** | `brain/rules/` · `brain/playbooks/` · `brain/coverage.md` | author `type` (§2 enum) + `title` + `summary` as ever; body cross-links as markdown links; optionally author `description`/`tags` — emit derives them from `summary`/`domain` if you don't |
53
+ | **bloom** | `improve/improvements/` · `improve/ledger.md` | same; your files gain `type: Improvement` + `tags: [lens, priority]` at emit — author `found:` so timestamps are yours, not git's |
54
+ | **prism** | `brain/checklist.md` | verdict frontmatter as ever (emit stamps `type: Health Report` + a derived description); at validation, treat the checker's LINKS warns as a worklist — dangling links are claims of future knowledge |
55
+ | **sage** | `.claude/rafa/learnings/` | learnings are OKF concepts too: frontmatter + `type: Learning` + markdown links; outside the bundle but under the same protocol |
56
+ | **conductor / plan·build** | `plans/**` · `brain/log.md` | plan items gain `type` from `kind` at emit (per-epic `plans/index.md`); journals + bodies use markdown links; `log.md` stays the reserved trail |
57
+ | **compass** | — | writes platform state, never bundle `.md` — its duty is the PORTABILITY law: OKF bundles are exchangeable, so person-scoped content never lands in one; anything it ever materializes self-describes |
58
+
59
+ The tooling backstop: `rafa push` runs `rafa okf` (emit) → `verify-citations`
60
+ → `compile`, so the surface exists even where an agent forgot — but authoring
61
+ natively keeps stamps honest (your `created:`/`found:` beats git history).
62
+
63
+ ## Minting a NEW file type — minutes, not hours
64
+
65
+ A new generated file class is **four small moves**, conformant by construction:
66
+
67
+ 1. **Registry** — add the class to `FILE_CLASSES` in
68
+ [packages/okf/lib/profile-rafa.mjs](../../../packages/okf/lib/profile-rafa.mjs)
69
+ (dir or singleton path · OKF `type` name · index title) and, if any stamp is
70
+ derivable, a `derivedStamps` case. Derivation law: authored data or real
71
+ history, else omit.
72
+ 2. **Contract row** — one row in the contract's file-type registry
73
+ ([contract.md](../../rafa/contract.md), the §-table): path glob · class
74
+ (`structured`/`verbatim`/`generated`) · schema section · author. A
75
+ `structured` class also gets its schema section + a compile validator in
76
+ [packages/cli/lib/gate/compile.mjs](../../../packages/cli/lib/gate/compile.mjs)
77
+ (required fields fail loudly; enums closed).
78
+ 3. **Skeleton** — `rafa okf new <class> <id> --type=… --key=value
79
+ --cite="file:line :: token" --link=<id>` mints the file in the class's
80
+ directory. The generator REFUSES to invent values: flags you omit are
81
+ absent, and `rafa compile` fails required ones loudly — that is the
82
+ validate-and-correct loop working, not a bug to paper over.
83
+ 4. **Prove it** — `rafa verify-citations` (cites/anchors real) →
84
+ `rafa compile` (schema holds) → `rafa okf check` (bundle still conformant).
85
+ Add a case to the gate e2e
86
+ ([packages/cli/test/okf-gate.test.mjs](../../../packages/cli/test/okf-gate.test.mjs))
87
+ when the class carries new emit behavior.
88
+
89
+ Naming rules for new classes (directive 5): class name = singular kebab noun;
90
+ instances live in a plural semantic directory (`brain/<things>/`) or a fixed
91
+ singleton path; ids kebab-case = filename stem; the OKF `type` value is a
92
+ short, self-explanatory Title Case string (consumers route on it — OKF types
93
+ are unregistered by design).
94
+
95
+ ## Commands
96
+
97
+ ```bash
98
+ rafa okf # materialize the surface (runs automatically inside rafa push)
99
+ rafa okf check # OKF §9 conformance walk — errors fail, exemptions surface as warnings
100
+ rafa okf new … # mint a conformant concept skeleton (see above)
101
+ ```
@@ -53,6 +53,7 @@ Planning is a choreography, not one agent (spec: knowledge-mcp-build-agent):
53
53
  never plan to hand-roll what a capability already does.
54
54
  5. **prism plan-validation** → REJECT/fix loop until clean.
55
55
  6. **Approval gate** (owner). Then materialize `plans/<plan>/*.md` per contract §7
56
+ (plan files ride the OKF surface — markdown links in bodies; see [rafa-okf](../rafa-okf/SKILL.md))
56
57
  (parent + child-owned files, globally-unique prefixed ids) + `active.md` pointer
57
58
  → `rafa compile` (validate the files) → **`push_plan` + `set_active_plan`
58
59
  immediately, no second prompt — plan approval IS the push trigger** (the
@@ -14,7 +14,9 @@ You run this as a **context-isolated subagent spawned by the `/rafa` conductor**
14
14
  whole-repo read happens in *your* window, not the conductor's; return a coverage summary, not
15
15
  the raw reads. The conductor owns the validate/iterate loop (Gate 2, below).
16
16
 
17
- The notes ARE the knowledge map. They are cited markdown with `[[links]]`; the graph is
17
+ The notes ARE the knowledge map. They are cited markdown, cross-linked with
18
+ **bundle-relative markdown links** — `[Title](/brain/rules/<id>.md)` (the OKF §5.1
19
+ form; contract §11) — plus the `links:` frontmatter edge list; the graph is
18
20
  derived from the links, never stored. No `graph.json`.
19
21
 
20
22
  ## Governing law — memory must be net-positive
@@ -34,7 +36,7 @@ than none. Every rule below serves this law.
34
36
 
35
37
  A note earns its place only if it helps answer one of these, for a real feature/bug:
36
38
  - **"How does X flow end to end?"** → a `flow` playbook
37
- - **"What breaks if I touch Y?"** (blast radius) → `contract` rules + the `[[links]]`
39
+ - **"What breaks if I touch Y?"** (blast radius) → `contract` rules + the link graph
38
40
  - **"Where does Z live / what's the convention?"** → `convention` rules
39
41
  - **"How do I add W here?"** → a `how-to` playbook
40
42
 
@@ -47,7 +49,7 @@ Code is the source of truth; the brain is the **index over it**. A note's job is
47
49
  reproduce code that will go stale. Optimize each note for:
48
50
  - precise `cites` — *go here* (this is the navigation; a wrong pointer sends you wrong)
49
51
  - the durable contract / gotcha — *watch this*
50
- - `[[links]]` — *these connect*
52
+ - body markdown links + `links:` frontmatter — *these connect*
51
53
 
52
54
  The model then opens the cited files for current specifics. **Capture the durable, not
53
55
  the volatile** — don't copy implementation that drifts; copy the map and the warnings.
@@ -126,10 +128,11 @@ cites: # required ≥1 · `file:line :: token
126
128
  failure: silent # contracts only: silent|loud
127
129
  ---
128
130
  The string must match across all four sites or the agent silently never connects.
129
- See [[copilotkit-frontend-action-routing]] and [[agent-tool-to-ui-flow]].
131
+ See [frontend action routing](/brain/rules/copilotkit-frontend-action-routing.md)
132
+ and [agent tool → UI flow](/brain/playbooks/agent-tool-to-ui-flow.md).
130
133
  ```
131
134
  `summary` is the one-line the platform shows; **`links` in frontmatter** are the machine-read
132
- graph edges (body `[[links]]` are for human reading only). `cites` + `domain` + `links` are the
135
+ graph edges (body links are for human + foreign-agent reading). `cites` + `domain` + `links` are the
133
136
  retrieval index. Bodies read like a senior engineer explaining that one concept to a teammate.
134
137
 
135
138
  ---
@@ -296,7 +299,7 @@ A scan **PASSES only if every box below is true.** Any single failure → `itera
296
299
  - [ ] **C2** Every note answers ≥1 of the four questions. A note that only describes code = drop.
297
300
  - [ ] **C3** Every note has: `type` (convention|contract|flow|how-to), `domain`, ≥1 `cite`.
298
301
  Contracts also carry `failure: silent|loud`.
299
- - [ ] **C4** Contracts and flows `[[link]]` to the notes they touch — blast-radius and
302
+ - [ ] **C4** Contracts and flows link (bundle-relative markdown) to the notes they touch — blast-radius and
300
303
  end-to-end flow are traversable by following links.
301
304
 
302
305
  **D · Format & contract**
@@ -317,5 +320,7 @@ targets the exact failing box.
317
320
  verified, or it doesn't ship. (Off-by-N lines, wrong-file attribution, missed sites.)
318
321
  - **Absence-claims** ("none yet", "greenfield") without an exhaustive repo-wide grep.
319
322
  - Uncited claims; notes that describe code but answer none of the four questions.
320
- - Literal `[[...]]` in prose (write `wiki-links` instead) it pollutes the derived link graph.
323
+ - Literal `[[...]]` in prose legacy wikilinks are transpiled at emit when they resolve,
324
+ but AUTHOR bundle-relative markdown links (contract §11); a `[[...]]`-as-ellipsis literal
325
+ pollutes the link graph and lands in the checker's LINKS warn lane.
321
326
  - Silent truncation — if a domain is thin, say so.
@@ -78,7 +78,8 @@ agent. So:
78
78
  7. **Claim-truth check** — for a sample of notes, verify the note's *claim* matches the code
79
79
  (the checker only proved the cite *resolves*). A false/misleading claim → **blocker**
80
80
  (it violates the net-positive law: a wrong note is worse than none).
81
- 8. **Connectivity** — orphan notes, dangling `[[links]]`, literal `[[...]]` in prose minor.
81
+ 8. **Connectivity** — orphan notes, dangling links (the checker's LINKS warn lane
82
+ `citation-check.md` § Links — is your pre-built worklist), literal `[[...]]` in prose → minor.
82
83
 
83
84
  ## Severity + decision
84
85
  - **Blocker** — hard-gate failure, broken checker, or a wrong/misleading note. Must be **0**.
package/lib/blueprint.mjs CHANGED
@@ -43,6 +43,7 @@ export const BLUEPRINT = {
43
43
  ".claude/skills/rafa-insights",
44
44
  ".claude/skills/rafa-leverage",
45
45
  ".claude/skills/rafa-sage",
46
+ ".claude/skills/rafa-okf",
46
47
  ],
47
48
  lockstep: [".claude/rafa/contract.md"],
48
49
  // The M5 sensor hooks — deterministic protocol machinery (like the contract):