Skip to main content

Compliance linter for OKF (Open Knowledge Format) documentary bases — the Ruff of documentation.

Project description

okflint

The Ruff of documentation. A deterministic compliance linter for documentary bases in Open Knowledge Format (OKF).

MIT License Python Documentation


Why

When a project's value migrates into its documentary base, that base must be held to a standard — just as code is by a linter. okflint verifies, in a deterministic, reproducible, LLM-free way, that Markdown documents conform to an OKF standard declared in a YAML manifest.

Two commands:

  • okflint audit — inventory and descriptive diagnostic of a base (statistics, broken links, split candidates). Always exit 0.
  • okflint validate — normative compliance gate. exit 0 if conformant, exit 1 otherwise. Designed for pre-commit hooks and CI.

Installation

# Via uv (recommended)
uv tool install okflint

# Or via pip
pip install okflint

For development:

git clone https://github.com/mattdav/okflint
cd okflint
uv sync --all-extras
uv pip install -e .

Quick start

  1. Copy the example manifest to the root of your documentary base:
cp okf-base.example.yaml /path/to/my-base/okf-base.yaml
  1. Adapt it to your taxonomy (types, required fields, status vocabulary).

  2. Validate:

okflint validate --manifest /path/to/my-base/okf-base.yaml /path/to/my-base

The manifest

okflint is a generic engine: it knows no type vocabulary in hard code. The okf-base.yaml manifest defines your standard. See okf-base.example.yaml for an annotated template.

Each type declares its required/optional fields and its status policy:

status_values Semantics
[list] status field required, value constrained to the list
false status field forbidden for this type
null (or absent) status field optional, value free

OKF resourcesOfficial Google Cloud spec · openknowledgeformat.com (examples, templates, online validator) · okf.md (annotated guide)


Key concepts

Term Definition
bundle A root folder of the documentary base to audit or validate. All .md files it contains (recursively) are analysed. Multiple bundles can be declared via base.roots in the manifest.
vault The root folder(s) of all your Markdown (may be larger than the bundle). Used only to resolve [[...]] wikilinks. When using --manifest, all roots serve as the vault automatically.
manifest The okf-base.yaml file you write to describe your standard: which concept types you use, which fields are required, which status vocabulary applies. Declares one or more roots via base.roots. See okf-base.example.yaml for an annotated template.
target For validate only: one or more paths to folders or .md files to validate. If omitted, all roots declared in the manifest are validated.

Usage

okflint audit — Inventory and diagnostic

audit scans one or more bundle roots and produces a descriptive report: OKF conformance statistics, broken wikilinks, broken Markdown links, split candidates. This command is always exit 0 — it is an observation tool, not a gate.

# Multi-root scan from the manifest (recommended)
okflint audit --manifest /path/to/okf-base.yaml

# Write the full JSON report to .okflint/
okflint audit --manifest /path/to/okf-base.yaml --apply

# Single-root scan (legacy form, backward compatible)
okflint audit --bundle /path/to/my-base --vault /path/to/my-vault

# Manifest + --bundle as a sub-filter (scans only files under --bundle)
okflint audit --manifest /path/to/okf-base.yaml --bundle /path/to/sub-folder

Either --manifest or both --bundle and --vault must be provided.

Options:

Option Required Description
--manifest <path> conditional OKF manifest; base.roots defines the bundle and vault roots
--bundle <path> conditional Root folder to audit; acts as a sub-filter when --manifest is also set
--vault <path> conditional Vault root for wikilink resolution (required when using --bundle alone)
--apply no Writes the full JSON report to .okflint/YYYY-MM-DD_audit_vN.json

When scanning multiple roots, the console output includes per-root file counts.

Concrete example — Obsidian vault:

okflint audit \
  --bundle ~/Obsidian/My-project/docs \
  --vault ~/Obsidian \
  --apply
# Produces: .okflint/2026-06-28_audit_v1.json

Concrete example — multi-root from manifest:

okflint audit --manifest ./okf-base.yaml --apply

okflint validate — Compliance gate

validate checks the conformance of Markdown files to OKF and to the profile declared in your manifest. Returns exit 0 if no errors, exit 1 otherwise. Designed for pre-commit hooks and CI.

# Validate all roots declared in the manifest (no explicit targets)
okflint validate --manifest okf-base.yaml

# Validate an entire base
okflint validate --manifest okf-base.yaml /path/to/my-base

# Validate a single sub-folder
okflint validate --manifest okf-base.yaml /path/to/my-base/ADR

# Validate specific files
okflint validate --manifest okf-base.yaml concept1.md concept2.md

# Machine-readable JSON output (for CI, scripts)
okflint validate --manifest okf-base.yaml --json /path/to/my-base

Options:

Option Required Default Description
--manifest <path> no okf-base.yaml Path to the OKF manifest
--json no JSON output instead of human-readable text
<targets...> no all manifest roots One or more paths (folders or .md files) to validate

Exit codes:

Code Meaning
0 No errors (warnings may still be present)
1 At least one conformance error
2 Invalid or unreadable manifest

Concrete example — CI GitHub Actions integration:

- name: Validate docs
  run: |
    pip install okflint
    okflint validate --manifest docs/okf-base.yaml docs/

Concrete example — git pre-commit hook:

# .git/hooks/pre-commit
okflint validate --manifest okf-base.yaml docs/ || exit 1

Development

inv lint     # ruff + mypy
inv clean    # clean build artefacts
inv repomix  # pack the codebase for an LLM

See CONTRIBUTING.md for the full contribution guide, the release process, and commit conventions.

The full API documentation (generated from docstrings) is available at mattdav.github.io/okflint.


Architecture

src/okflint/
├── cli.py        ← dispatcher: okflint audit | validate
├── scanner.py    ← shared primitives (scan, frontmatter, links)
├── audit.py      ← audit command (descriptive)
├── validate.py   ← validate command (normative gate)
└── __main__.py   ← python -m okflint

Validation manifest: manifest.py (contract loading + validation).


Roadmap

Envisioned evolutions beyond v0.1 (semantic cohesion for finer splitting, verifiable reading-grid expectations) are described in ROADMAP.md.


What okflint does not do

okflint is a static, deterministic gate. By design, it will never:

  • Execute a reading traversal for an agent — that is the harness's role.
  • Judge the content of a concept via LLM (summarise, classify, rewrite).
  • Decide on a split or reorganisation — it signals, it does not rule.
  • Impose a convention not declared by your manifest — no hardcoded vocabulary, no imposed language.

License

MIT@mattdav

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okflint-0.1.2.tar.gz (105.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okflint-0.1.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file okflint-0.1.2.tar.gz.

File metadata

  • Download URL: okflint-0.1.2.tar.gz
  • Upload date:
  • Size: 105.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for okflint-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c2e7d6654030a93dcf6a5770f3640317c17cb7ec061b2291ff2ac05d712756e3
MD5 6db59155d1c40949190254d7b518b022
BLAKE2b-256 642aa8616540d322bc82d2d542a03762f39158a096237fe6ec4c3c12b293faf6

See more details on using hashes here.

Provenance

The following attestation bundles were made for okflint-0.1.2.tar.gz:

Publisher: release.yml on mattdav/okflint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file okflint-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: okflint-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for okflint-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24db173116fa948649ae2a7bae478af928b71407991350b979671c2abef54e6c
MD5 aab916115bcabf30222681bf28996130
BLAKE2b-256 c227f79d0131643fef26867c4524be9b29da77ac3ca644b64c6c60dd753a473a

See more details on using hashes here.

Provenance

The following attestation bundles were made for okflint-0.1.2-py3-none-any.whl:

Publisher: release.yml on mattdav/okflint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page