The renderer nobody has used since 2023
A worked example of Google's Open Knowledge Format on a JS/TS monorepo: bundle layout, the concept that says don't, a scaffold script and CI wiring.
TL;DRthe 30-second version
- The Open Knowledge Format (OKF) is a directory of markdown files with one required field,
type. It turns a repo's tribal knowledge into a graph that people and agents can both follow. - Scope it to where the postmortems point, and write at least one concept whose whole job is to say don't delete this.
- Scaffold the boilerplate from
package.json, leave visible TODOs, and wire a CI nudge that warns without blocking merges. - Point
CLAUDE.mdat the bundle so the knowledge lives in one place, then measure whether the loop fires: nudges acted on, deletions caught in review, agent proposals that respect the tags.
Picture a survey platform with a file like MatrixV1.tsx. Nobody has created a Matrix v1 question in three years, because the editor stopped offering it when v2 shipped. Every signal says dead code: no imports from the editor, zero coverage, ESLint flags it, and the bundle analyser would love to see it go.
So someone deletes it. Two weeks later a customer opens a PDF export of a 2022 employee-engagement study and every matrix question is blank. Hundreds of thousands of historical responses still store answers in the v1 shape, and the export pipeline needs that renderer to display them. The knowledge existed, in a closed PR review comment, a Slack thread and one engineer’s memory, but nobody could retrieve it in under a day, and the coding agent couldn’t retrieve it at all.
Google Cloud introduced the Open Knowledge Format (OKF) in June 2026 for this class of problem. Its examples are all data warehouse: tables, datasets, metrics. This post works through the other half of the enterprise, a product codebase: a TypeScript and React survey platform in a pnpm monorepo. The platform is a worked example, built to show the moves; the format and the tooling are real.
OKF in 30 seconds
OKF is the envelope, not the letter. It says nothing about what you write; it standardises the shape so any system can route it.
- A bundle is a directory of UTF-8 markdown files.
- A concept is one file: YAML frontmatter, then a markdown body.
- A concept’s id is its path minus
.md, sopackages/logic-engine.mdispackages/logic-engine. No registry and no minted IDs: the filesystem does the naming. - Concepts link to each other with ordinary markdown links, which turns the directory into a graph.
index.mdandlog.mdare reserved filenames, for the directory listing and the change history.- Exactly one field is required:
type. Everything else is yours, and consumers must tolerate fields and types they don’t recognise.
If you can cat a file, you can read it. If you can git clone, you can ship it. Google’s post describes v0.1; the spec has since moved to its own repository and reached v0.3, which replaced the old timestamp field with generated: { by, at }. The examples below use v0.3.
Why a JS product codebase needs this more than a warehouse does
JSDoc and inline comments answer what does this function do. They’re bad at why is it like this, what still depends on it and what did we already try. In a JavaScript monorepo the problem is sharper, because three things routinely make live code look deletable:
- Published packages. The embed SDK is on npm and pinned in customer HTML you don’t control. There’s no such thing as removing an export.
- Persisted data shapes. Responses stored in Postgres JSONB are a schema you can’t migrate away from without touching millions of rows.
- Isomorphic code. The same module runs in the browser and on the server, and divergence between the two is invisible until a respondent hits submit.
Tree-shaking and coverage tools are confidently wrong about all three. Code is the current state; a knowledge bundle is the constraints around it. Git versions the first perfectly, and OKF lets you version the second in the same PR.
Step 1: Scope it small, keep it in the repo
Don’t start with “document the platform”. Start where the postmortems point.
knowledge/
├── index.md
├── log.md
├── packages/
│ ├── index.md
│ ├── survey-editor.md
│ ├── logic-engine.md
│ └── embed-sdk.md
├── question-types/
│ ├── index.md
│ └── matrix-v1.md
├── contracts/
│ └── response-shape-v4.md
├── integrations/
│ └── webhook-delivery.md
└── gotchas/
└── question-id-stability.md
type values are yours to define, so use words the team already says: Package, Question Type, Contract, Integration, Gotcha, ADR, Deprecation.
Step 2: Write the first concept
knowledge/packages/logic-engine.md:
---
type: Package
title: "@survey/logic-engine"
description: Evaluates branching, skip logic, and piping. Runs in both browser and Node.
resource: https://git.example.com/survey/tree/main/packages/logic-engine
tags: [tier-1, isomorphic, shared]
generated:
by: survey-runtime-team
at: 2026-09-05T10:05:00Z
---
# Ownership
Team: Survey Runtime. Rotation: `#runtime-oncall`.
Consumed by [survey-editor](/packages/survey-editor.md) (live preview),
[embed-sdk](/packages/embed-sdk.md) (respondent runtime), and `response-api`
(server-side validation).
# Boundaries
Owns: rule evaluation, page visibility, answer piping, quota checks.
Does **not** own: rendering (that's the editor and SDK) or persistence.
The engine must be **pure and deterministic**. No `Date.now()`, no `Math.random()`,
no `fetch`, no `window`. Time and randomization are injected via the context
object, because the server replays evaluation on submit and must reach the same
verdict the browser did.
# Change risk
This is the most dangerous package in the repo. It ships in three places on
three release cadences: the editor deploys continuously, the API deploys daily,
and the SDK is **pinned by customers, possibly for years**.
A rule type added here is only safe if old evaluators treat it as
"always visible." Anything that makes an old evaluator throw or hide a page
means a respondent sees a question the server will reject on submit — a silent
mid-survey dead end with no error surface.
| Changing... | Safe? |
|---|---|
| Adding an optional field to a rule | Yes |
| Adding a new operator | Only with a fallback branch in v-1 |
| Changing operator semantics | No. Add a new operator instead. |
| Tightening validation | No. Old drafts contain invalid rules. |
# Testing
`pnpm test:parity` runs the same fixture set through the browser build and the
Node build and diffs the verdicts. If you touch evaluation, that suite is not
optional. It has caught four production incidents; do not `--skip` it.
That change-risk table is a guardrail. It’s what a staff engineer would type into a PR review, written down once, where a human reviewer and an agent both meet it before writing code.
Step 3: The concept that says “don’t”
If you write only one concept this quarter, write this kind. Negative knowledge is invisible in the code and expensive when missed.
knowledge/question-types/matrix-v1.md:
---
type: Question Type
title: Matrix v1
description: Retired from the editor in 2023. Renderer is NOT removable — historical responses depend on it.
resource: https://git.example.com/survey/tree/main/packages/renderers/MatrixV1.tsx
tags: [do-not-remove, legacy, read-path-only]
generated:
by: survey-runtime-team
at: 2026-08-31T14:10:00Z
---
# Status
**Write path closed, read path permanently open.** The editor hasn't offered
Matrix v1 since 2023-04, so no new questions use it. Static analysis therefore
reports the renderer as unreachable. It isn't.
~900k stored responses hold answers in the v1 shape (`{rows: {[rowId]: colId}}`,
a flat map) rather than the v2 shape (`{rows: [{rowId, colId, weight}]}`).
Three read paths still hydrate that shape:
- PDF/XLSX export (`packages/export`)
- The report builder's crosstab widget
- The public results-share page
# What we already tried
- 2025-Q3: deleted the renderer after the bundle analyzer flagged it. Exports
rendered blank matrix cells for ~2 weeks before a customer reported it.
No error was thrown — the renderer registry falls back to `null`. Reverted
in `e91c04d`.
- 2026-Q1: wrote a v1→v2 backfill migration. Abandoned: weights are not
recoverable from the v1 shape, so migrating silently changes historical
crosstab numbers. Finance and legal both objected. See CLM-8802.
# Removal criteria
Removable only when the renderer registry throws loudly on unknown types
*and* no response older than the retention window uses the v1 shape:
```sql
SELECT count(*) FROM responses
WHERE answers @> '[{"type":"matrix_v1"}]' AND created_at > now() - interval '7 years';
```
Must return 0. It currently returns ~412k.
“What we already tried” is the section every wiki lacks and every team needs. It’s the difference between an agent making a fresh mistake and an agent re-enacting last year’s incident.
Step 4: Let the links carry the graph
OKF links are deliberately plain: a markdown link asserts these two are related, and the prose says how. Write the relationship into the sentence:
Question IDs are minted by [survey-editor](/packages/survey-editor.md) and
treated as immutable by [webhook-delivery](/integrations/webhook-delivery.md),
because customer ETL jobs key on them. Read
[question-id-stability](/gotchas/question-id-stability.md) before any change
that regenerates IDs — including "harmless" duplicate-survey refactors.
Prefer bundle-absolute links (/packages/embed-sdk.md) to relative ones. You’ll reorganise the tree eventually, and absolute links survive git mv far better.
What static analysis sees, then what the bundle says
matrix-v1 through a registry lookup keyed by a string, so no import graph sees them.A handful of files, and already a graph with a load-bearing node. matrix-v1 has three inbound links from read paths that never appear in an import graph, because none of them import the renderer directly: they reach it through a registry lookup keyed by a string. That’s exactly the edge static analysis can’t draw and a markdown link can.
Step 5: index.md is a token budget
Skip this and your agent reads sixty files to find one answer. index.md is for progressive disclosure: read the index, decide where to go, and never load the rest.
knowledge/packages/index.md:
# Packages
| Concept | Consumers | Read this before |
|---------|-----------|------------------|
| [logic-engine](/packages/logic-engine.md) | editor, sdk, api | any change to rule evaluation |
| [embed-sdk](/packages/embed-sdk.md) | customer sites (unpinned) | changing *any* public export |
| [survey-editor](/packages/survey-editor.md) | web app | touching question ID generation |
| [renderers](/packages/renderers.md) | editor, sdk, export | deleting a "dead" question type |
The last column does the real work. It’s a routing hint, so a reader can pick the right file from the index alone.
Step 6: Generate concepts from the repo
The format is small enough that scaffolding is a short script. The platform is JS, so write the producer in JS: walk the pnpm workspace, pull what’s already machine-readable, and emit stubs for people and agents to fill in.
Show tools/scaffold-okf.mjs (70 lines)
#!/usr/bin/env node
// tools/scaffold-okf.mjs — generate OKF Package concepts from a pnpm workspace.
import { readFile, writeFile, mkdir, readdir, access } from "node:fs/promises";
import path from "node:path";
const ROOT = "packages";
const OUT = "knowledge/packages";
const NOW = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
const exists = async (p) => access(p).then(() => true, () => false);
const codeowners = (await readFile("CODEOWNERS", "utf8"))
.split("\n")
.filter((l) => l.trim() && !l.startsWith("#"))
.map((l) => l.trim().split(/\s+/))
.map(([pattern, ...owners]) => ({ pattern: pattern.replace(/^\/|\/$/g, ""), owner: owners.join(" ") }));
const ownerFor = (dir) =>
[...codeowners].reverse().find((c) => dir.startsWith(c.pattern))?.owner ?? "UNOWNED";
await mkdir(OUT, { recursive: true });
for (const entry of await readdir(ROOT, { withFileTypes: true })) {
if (!entry.isDirectory()) continue;
const dir = path.join(ROOT, entry.name);
const target = path.join(OUT, `${entry.name}.md`);
if (await exists(target)) continue; // never clobber curated knowledge
if (!(await exists(path.join(dir, "package.json")))) continue;
const pkg = JSON.parse(await readFile(path.join(dir, "package.json"), "utf8"));
const internal = Object.entries({ ...pkg.dependencies, ...pkg.peerDependencies })
.filter(([, range]) => String(range).startsWith("workspace:"))
.map(([name]) => name.replace(/^@survey\//, ""))
.sort();
const published = pkg.private !== true;
const exportsPublic = Object.keys(pkg.exports ?? {});
const front = [
"---",
"type: Package",
`title: "${pkg.name}"`,
`description: ${pkg.description ?? "TODO: one line on what this owns."}`,
`resource: https://git.example.com/survey/tree/main/${dir}`,
`tags: [scaffolded${published ? ", published" : ""}]`,
"generated:",
" by: tools/scaffold-okf.mjs",
` at: ${NOW}`,
"---",
];
const body = ["", "# Ownership", "", `Team: ${ownerFor(dir)}`, ""];
if (internal.length) {
body.push("# Depends on (internal)", "", ...internal.map((d) => `- [${d}](/packages/${d}.md)`), "");
}
if (published) {
body.push(
"# Public surface",
"",
`Published to npm as \`${pkg.name}\` — consumers may pin old versions indefinitely.`,
exportsPublic.length ? `Entry points: ${exportsPublic.map((e) => `\`${e}\``).join(", ")}` : "",
""
);
}
body.push("# Change risk", "", "TODO: what breaks when this changes?");
await writeFile(target, [...front, ...body].join("\n") + "\n");
console.log(`wrote ${target}`);
}Note the small piece of real inference in there: private !== true, plus a scan for workspace: dependencies, tells you which packages are published and which are internal. That’s the distinction that decides whether removing an export is safe. It’s cheap to derive, and it’s the fact an agent most needs.
Expect the first run to overshoot: one stub per directory with a package.json. That’s fine. Scaffold generously, then let usage decide the granularity, folding small internal packages into the concept of the package that uses them.
Step 7: Make CI stop the rot
Knowledge bundles decay like test suites: silently, then all at once.
# .github/workflows/knowledge.yml
name: knowledge
on: [pull_request]
jobs:
okf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Conformance + hygiene
run: |
# 1. every concept has a non-empty `type` (the one hard requirement)
# 2. no broken bundle-relative links
# 3. no tier-1 concept whose `generated.at` is older than 180 days
node tools/okf-check.mjs knowledge/
- name: Nudge on coupled changes
run: |
CHANGED=$(git diff --name-only origin/main...)
if echo "$CHANGED" | grep -q '^packages/logic-engine/'; then
echo "$CHANGED" | grep -q '^knowledge/packages/logic-engine.md' \
|| echo "::warning::logic-engine changed; consider updating its concept"
fi
Step 8: Wire up the consumer side
A bundle nobody reads is a filing cabinet. Two patterns work.
Point your agent’s convention file at the bundle, so the knowledge lives in one place. In AGENTS.md or CLAUDE.md:
Before modifying anything under `packages/`, read the matching concept in
`knowledge/packages/`. Before deleting a renderer, question type, or "unused"
export, check `knowledge/question-types/index.md` — several types are retired
from the write path but required on the read path. Never assume coverage or
bundle-analyzer output proves code is dead. Log material changes to
`knowledge/log.md`.
Serve the bundle over MCP for agents outside the repo. Navigation is plain graph traversal (read the index, follow a link, read a concept), so you get grounded answers with no vector database. There’s nothing to re-embed and no retrieval to tune, and every citation is a file path a person can open and check.
The loop that keeps a bundle honest
The bundle pays for itself only when all of these fire on the same pull request. A concept nobody reads is as useless as one nobody wrote.
What to measure after a quarter
Judge the bundle by whether the loop fires:
| Metric | How to measure it | What it tells you |
|---|---|---|
| Curated concepts | Files in knowledge/ without a scaffolded tag or a TODO | Whether people are writing concepts or only generating them |
| Nudge fire rate | CI warnings ÷ PRs touching tier-1 packages | How often the coupling between code and concept is tested |
| Nudge → concept updated | Warned PRs that also changed the concept | The real cost of a warning that doesn’t block |
| Time to catch a “safe” deletion | Review or revert timestamps on flagged code | Whether the guardrail works before customers notice |
| Agent proposals that respect tags | Ask the agent to “clean up dead code” and check its candidates | Whether the consumer side is wired up |
Expect the nudge-to-update ratio to sit well below 100%. That’s what a warning that doesn’t block produces, and it’s why the removal-criteria query and the staleness check matter more than the nudge: they catch what the nudge misses before someone trusts a stale concept.
What not to put in a bundle
- Anything the code states better. Don’t mirror type definitions; they drift, and you’ll trust the stale copy. Link to the
.d.tsinstead. - Secrets, tokens, customer data. Bundles are built to be portable, so assume yours gets tarballed and shared.
- Ticket-level churn. Concepts hold durable constraints. Sprint status belongs in your tracker.
- Prose where a table works. Skimming people and agents both do better with the table.
The bet OKF makes is that storage was never the hard part. The hard part was that every team built a slightly different box, so nothing could move between them. Plain markdown in git isn’t a clever answer, and that’s the point: it has the fewest ways to fail, and your agents can read it today with no integration at all.