Types
Every OKF concept has a type, such as Customer or Metric, and OKF lets
each team add whatever frontmatter fields it likes. To keep a type’s concepts
alike, give the type a JSON Schema: which fields
they carry, what each may hold, and which they must have. Every concept of
that type must then match it, and the
okforest/type-schema rule reports each
field that doesn’t, as an error.
Type schemas are an OKForest convention, not part of the Open Knowledge Format. They’re optional: a type without one isn’t checked against one.
To start from what your concepts already hold, run
okforest types init: it drafts a
schema for each type that has none, which every concept of the type matches,
for you to tighten.
Naming conventions
Section titled “Naming conventions”OKF doesn’t register types or say how to write them: a type is “a short string identifying the kind of concept”. These are conventions, not requirements: how the specification’s examples and Google’s sample bundles write them. Follow them, and your bundle reads like others:
- Types are capitalized words with spaces, naming one thing:
Metric,Product Summary,API Endpoint,BigQuery Table,Attested Computation(the one type OKF itself defines). Notmetric,product-summary, orProduct_Summary. Keep acronyms and product names as they’re usually written. - Files are lowercase with hyphens: the type’s schema
(
product-summary.schema.json, with"title": "Product Summary"), and every concept’s path, which theokforest/slugrule warns about. - Tags are lowercase with hyphens, as in the specification’s examples:
tags: [finance, income-statement].
Whichever way you write a type, write it the same way everywhere: a type is
matched exactly, so metric and Metric are two types, and only the one
its schema names is checked. The
okforest/similar-type and
okforest/similar-tag rules warn about
a type or tag written another way than the rest of the bundle writes it
(another case, other punctuation, a plural, or a typo), and suggest the one
you probably meant.
Where the files go
Section titled “Where the files go”One file per type, in .okforest/types/ inside the bundle’s root folder (next
to .okforest/settings.yaml), named
<type>.schema.json:
.okforest/ settings.yaml types/ customer.schema.json metric.schema.jsonExample
Section titled “Example”{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Customer", "description": "An organization that buys from us.", "type": "object", "properties": { "x-relationship": { "enum": ["prospect", "active", "former"] }, "x-account-owner": { "type": "string", "format": "email" }, "x-since": { "type": "string", "format": "date" } }, "required": ["x-relationship", "x-account-owner"]}A concept of this type, and what checking it reports:
---type: Customertitle: Acme Corpx-relationship: lostx-since: 2026-13-45---2:1 error Missing `x-account-owner`, which the Customer type requires.4:1 error `x-relationship` must be one of `prospect`, `active`, `former` (got `lost`).5:1 error `x-since` must be a date like `2026-06-30` (got `2026-13-45`).How a schema applies
Section titled “How a schema applies”- Its
titleis the type, exactly as concepts write it intype:Customer, notcustomer. The file is named for the type, in lowercase with hyphens:customer.schema.json, andcustomer-profile.schema.jsonforCustomer Profile, asokforest types initnames it. A file named for another type still works, butokforest/type-file-namewarns about it, since it misleads anyone reading the folder. - It lists the type’s own fields. OKF’s fields (
title,description,tags,status,verified, and the rest) are checked by the OKF rules, and left out of what a type’s schema checks unless it names them inproperties, to narrowtags, say. So"additionalProperties": falserejects fields the type doesn’t have, without rejecting OKF’s. - Its order is the order the App shows them in, in a page’s
Details, so list fields that go together together.
OKF’s
type,tags, andresourcecome before them, andsources,verified, andgeneratedafter, unless the schema names one inproperties, which places it there:"resource": { "type": "string", "format": "uri" }beforex-status-pageshows a Vendor’s links side by side, and the page editor asks for it as text. - Its fields start with
x-in a tree on OKF 0.3 (x-owner): they’re keys OKF doesn’t define, and OKF promises never to define one starting withx-, so a later version can’t give them another meaning (okf/extension-key). No tool’s or company’s name is needed: the fields are the tree’s own. - Any JSON Schema draft from draft 4 to 2020-12, by its
$schema; 2020-12 if it names none. - Dates needn’t be quoted. YAML reads
renewal: 2027-03-01as a date, which is checked as the text it was written as, so"type": "string"with"format": "date", or with"pattern": "^\\d{4}-\\d{2}-\\d{2}$", accepts it. - Patterns are JavaScript regular expressions with the
uflag: apattern, inpropertyNamestoo, can use Unicode classes such as\p{Lu}, but not inline flags such as(?i), which JavaScript doesn’t have (the schema can’t be used: “Invalid group”). Spell both cases out instead,[Aa]. - References stay within the file: a
$refcan point into the schema (#/$defs/email) or at an$anchor, not at another file or address. - One schema per type: a second schema with the same
titleis reported, and the first by path is used.
A schema that can’t be used is reported on its own file, and no concept is
checked against it: one that isn’t valid JSON, isn’t an object, has no
title, or has a $ref that leads nowhere.
A type’s tags
Section titled “A type’s tags”To keep a type’s tags to an agreed list, name tags in its schema’s
properties with the tags it may use:
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Metric", "description": "A number the business tracks.", "type": "object", "properties": { "tags": { "type": "array", "items": { "enum": ["revenue", "churn", "headline-metric"] } } }}A Metric tagged [churn, kpi] then reports:
5:15 error `tags[1]` must be one of `revenue`, `churn`, `headline-metric` (got `kpi`).A new tag is then a change to the schema, in the same pull request as the first concept that uses it, where reviewers see it.
Where it’s checked
Section titled “Where it’s checked”The same rule runs everywhere, with the same findings:
okforest validate, in the CLI;- the OKForest Validate action, on every pull request;
- a tree’s Checks page in the OKForest App, for each commit. The App reads schemas of up to 64 KB, far more than any needs.
Where it’s shown
Section titled “Where it’s shown”A type’s schema also says what its concepts hold, for people and AI assistants alike:
- in the OKForest App, searching one tree for one type (a type in its “By type” list) shows the type’s description and a table of its fields: what each holds, and whether it’s required;
- over MCP, the
list_typestool gives, for each tree that has a schema for a type, its description and fields, so an assistant knows what to fill in.
Templates
Section titled “Templates”A type can also have a template beside its schema: the page a new concept of
that type starts as, like GitHub’s issue templates. It’s optional, and a type
can have a template without a schema. It’s named for the type as its schema
is: customer-profile.template.md.
.okforest/types/ metric.schema.json what a Metric must hold metric.template.md what a new Metric starts as---type: Metrictitle:status: draftx-unit:x-owner:# x-target: # the number it should reach, if it has onetags: [metric]---
<!-- One sentence: what is counted, and over what period. -->
# Definition
<!-- The exact calculation, including what's left out. -->
# Why it matters
# Source
<!-- Where the number comes from: a table, a dashboard, a report. -->- It’s the page as it starts, not a form: its front matter, in its own
order, and its body. Whoever creates the page gives its title and
description, which go where the template has them, or after
type. - Its own
typesays which type it’s for, as a schema’stitledoes. Name the file after the type, in lowercase with hyphens (metric.template.md); the name itself doesn’t matter. - Guidance goes in HTML comments, which authors see while writing and readers don’t.
- It needn’t match the type’s schema. An empty
x-owner:is how a template says “fill this in”: the new page is checked like any concept, so theokforest/type-schemarule reports it until someone does. - Leave empty only the fields the type requires. An empty field is
reported whether or not it’s required (
`x-target` must be a number (got null)), so put optional fields in comments, asx-targetis above, for authors to uncomment when they have a value. - It’s never a concept: nothing in
.okforest/is, so it isn’t listed, searched, or checked as one. Theokforest/type-templaterule checks that it names itstype, and that a type has one template.
A new page starts from its type’s template:
- in the OKForest App, with New page in a folder: choose the type, and the page starts from its template. Its fields stay in the template’s order, in the App’s usual YAML style, and fields added later go where the template would put them;
- over MCP,
list_typesgives each tree’s template for a type, so an assistant proposing a new page starts from it; - in the CLI, with
okforest new, which keeps the template exactly as written.
Types that drift
Section titled “Types that drift”Two notes keep a tree’s types and its pages in step, often after a type is renamed or a tree is split:
okforest/unused-type: a type no page gives any more, with its schema and template. A type defined before its first page is written is fine; remove its files if no page will use it.okforest/undeclared-type: in a tree with schemas, a type its pages give that has none, so their fields aren’t checked.okforest types initdrafts one.
Editor support
Section titled “Editor support”Editors such as VS Code check a file named *.schema.json against JSON Schema
itself, so a mistyped keyword is flagged as you write the schema.