GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — okfctl/docs/concepts.md at main · cwest/okfctl

Expand file tree

/

concepts.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
277 lines (227 loc) · 9.93 KB
/

concepts.md

Copy path

File metadata and controls

277 lines (227 loc) · 9.93 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Concepts

This page is for you if you store notes as a folder of linked Markdown files and want to know what okfctl does with them. It explains the ideas the rest of the docs take for granted: bundles, nodes, the two files okfctl writes for you, links, and templates.

The Open Knowledge Format (OKF) is an open format for that kind of folder. People and AI agents can read an OKF folder in a text editor. The spec asks for little beyond Markdown. Each note opens with a short YAML header naming what kind of thing it is. Any folder can hold an index.md listing what's in it and a log.md recording changes. Notes link to each other with ordinary Markdown links, by file path.

Markdown itself enforces none of that. Rename tannin.md with mv and the link in oak.md goes nowhere, and you find out the day someone clicks it. okfctl is a command-line tool for OKF folders. okfctl node mv renames the file and fixes oak's link in one step. Other commands write new notes, rebuild index.md and log.md as you go, and check the folder against the spec.

Each example below builds on one bundle of wine notes. To follow along, install okfctl and run the blocks in order in an empty directory.

A bundle is a folder of Markdown files

$ okfctl bundle init kb
Initialized OKF bundle in kb
$ okfctl bundle info kb
nodes: 0
reserved: 2
okf_version: 0.3 (declared in index.md)
$ cat kb/index.md
---
okf_version: "0.3"
---

# Knowledge Base

_Progressive-disclosure entry point. Add "start here" links as nodes land._

A bundle is the folder and everything under it. bundle init made the folder and two files in it, index.md and log.md. Those two are the reserved: 2 line. There are no notes so far, and nodes is 0.

Look at the header at the top of index.md, between the two --- lines. It declares the version of the spec the bundle follows. bundle info prints that version along with the file it read it from. okfctl writes OKF version 0.3 and reads bundles from older versions too. How okfctl reads a bundle's OKF version explains how.

A node is one note with a type

OKF calls each note a concept. okfctl's commands call it a node. Either way it's one Markdown file:

$ okfctl node new wine/tannin --type Concept --title Tannin --bundle kb
Created kb/wine/tannin.md
$ head -3 kb/wine/tannin.md
---
type: Concept
title: Tannin

The header is YAML, and the spec calls it frontmatter. node new wrote the type and title you gave it, then (below the three lines head shows) created and modified timestamps and a # Tannin heading.

type is the one key the spec insists on, and node new refuses to run with no --type. The spec has no list of allowed types. Any name works:

$ okfctl node new wine/oak --type "Barrel Note" --title Oak --bundle kb
Created kb/wine/oak.md
$ okfctl validate kb
OK: bundle conforms to the OKF spec floor

validate checks the bundle against what all OKF bundles have to meet. okfctl calls that the spec floor. Barrel Note is a type no other bundle uses, and the bundle still passes.

A Markdown file with no header (or with a header but no type) isn't a node. okfctl skips it with a warning. That's how a README.md can live in a bundle. A header that isn't valid YAML is different. It breaks the bundle, and validate exits 1:

$ printf -- '---\ntype: [Concept\n---\n' > kb/wine/broken.md
$ okfctl validate kb
FAIL wine/broken.md: unparseable frontmatter
okfctl: 1 conformance finding(s)
$ rm kb/wine/broken.md

The unclosed [ is the whole problem. FAIL names the file, and the exit code is what fails a CI job. The last command deletes the file to leave the bundle clean for the next example.

Headers that parse, plus well-formed index.md and log.md files, are all the spec's conformance rules require. Everything else okfctl checks is advice. You pick which of it fails CI.

okfctl writes index.md and log.md for you

$ find kb -name '*.md' | sort
kb/index.md
kb/log.md
kb/wine/index.md
kb/wine/oak.md
kb/wine/tannin.md
$ cat kb/wine/index.md
# Wine

## Concepts

* [Oak](oak.md)
* [Tannin](tannin.md)
$ tail -n 2 kb/log.md
* created wine/oak.md
* created wine/tannin.md

You didn't write wine/index.md or either log entry. node new did. The spec reserves these two names in all folders, and neither file is ever a node. index.md lists the folder's notes by title. People and agents read that one file to learn what the folder holds. log.md records changes under date headings, newest on top. The two entries above sit under today's date.

Node commands update the index as they go. Make a file some other way, like the printf below, and it stays off the index until you rebuild. index check exits 1 until then:

$ printf -- '---\ntype: Concept\ntitle: Acidity\n---\n\n# Acidity\n' > kb/wine/acidity.md
$ okfctl index check kb
index.md is out of date; run `okfctl index build` to regenerate
okfctl: index.md is out of date
$ okfctl index build kb
Wrote 2 index.md file(s) under kb
$ okfctl index check kb
OK: index.md is current
$ head -3 kb/index.md
---
okf_version: "0.3"
---

index build rewrote the two index files. The root header came through untouched, and the bundle still declares its version. The index and freshness guide lists what else a rebuild preserves. If you change a note by hand, record it with okfctl log append.

Links connect nodes into a graph

$ printf '\nOak aging adds [tannin](tannin.md) to the wine.\n' >> kb/wine/oak.md
$ okfctl graph export --format dot kb
digraph okf {
  rankdir=LR;
  "wine/acidity.md" [label="Acidity"];
  "wine/oak.md" [label="Oak"];
  "wine/tannin.md" [label="Tannin"];
  "wine/oak.md" -> "wine/tannin.md";
}
$ okfctl search --neighbors wine/tannin.md kb
wine/oak.md                              Barrel Note  depth=1

Nodes link to each other with ordinary Markdown links, and each link is an arrow in the bundle's graph. The export has one arrow, from oak to tannin. Tannin has no link back. Even so, search --neighbors finds oak one hop away: okfctl ignores direction when it walks the graph. --format dot prints Graphviz, short enough to read here. graph export writes JSON by default, and okfctl serve draws the same graph in your browser.

A link names its target by path. Rename tannin.md with plain mv and oak's link points at nothing. node mv renames the file and rewrites the links that point to it:

$ okfctl node mv wine/tannin wine/tannins --bundle kb
Moved wine/tannin.md -> wine/tannins.md (1 inbound link(s) rewritten)
$ tail -1 kb/wine/oak.md
Oak aging adds [tannin](tannins.md) to the wine.

The first line counts one link rewritten. The second shows it, with oak now pointing at tannins.md. node mv rewrites links to the moved node. The moved node's own links stay as written, and after a move to another folder okfctl lint finds any of them that no longer resolve.

The spec's rules, and your team's rules on top

validate checks only the spec floor. A team may want more. Say each playbook needs an owner and a ## Steps section. You write that down as a type template, an ordinary node whose type is Type Template, stored in the bundle with your other notes. Templates are okfctl's idea. The spec doesn't define them.

Save this as kb/templates/playbook.md:

---
type: Type Template
title: Playbook template
target_type: Playbook
required_fields: [owner]
body_sections: [Steps]
---

# Playbook template
$ okfctl node new runbooks/deploy --type Playbook --title Deploy --bundle kb
Created kb/runbooks/deploy.md (from Playbook template)
$ tail -n 6 kb/runbooks/deploy.md
owner: TODO
---

# Deploy

## Steps

node new found the template by its target_type and started the playbook from it. You got owner: TODO to fill in and an empty ## Steps section.

Now write a playbook by hand that ignores the template:

$ printf -- '---\ntype: Playbook\ntitle: Rollback\n---\n\n# Rollback\n' > kb/runbooks/rollback.md
$ okfctl validate kb
OK: bundle conforms to the OKF spec floor
$ okfctl validate --templates kb
warning runbooks/rollback.md: missing required field: owner (template Playbook)
warning runbooks/rollback.md: missing body section: Steps (template Playbook)
2 drift warning(s)
$ okfctl validate --templates --strict kb
warning runbooks/rollback.md: missing required field: owner (template Playbook)
warning runbooks/rollback.md: missing body section: Steps (template Playbook)
2 drift warning(s)
okfctl: 2 drift warning(s)

Plain validate passes. The spec floor never reads templates, and a header key the spec doesn't define (x-acme-owner, say) never fails it either. --templates reports what rollback is missing as warnings and still exits 0. Add --strict and the same warnings exit 1 (the form to use in CI). okfctl's word for a note that stops matching something it should is drift, and here it's the template. okfctl template list prints the templates a bundle has.

Next

  • Starting and authoring a bundle walks through new, move, remove, and templates on a fresh bundle. It also shows how two bundles can use one set of templates.
  • How okfctl reads a bundle's OKF version is for bundles written for an older version of the spec, and for one that names a version okfctl doesn't know.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.