sokf-core
sokf-core is the core library of sokf, the
validator for Superdev Open Knowledge Format (SOKF) knowledge stores.
This crate is the library half of the
sokfcommand-line tool. If you want to validate a knowledge store, install thesokftool, not this crate. The maintainers publish the library API mainly so that the binary can depend on a released version. The API isn't stable.
What it does
The binary parses the arguments and renders the output. This crate holds the logic that the binary calls, so that tests can run that logic without starting a process. The crate exposes these entry points:
initcreates a knowledge store: the manifest, the two generated indexes, and the configuration entry that makes the directory a root. It reads only the configuration and the filesystem, and it checks every reason to refuse before it writes anything.harness_installandharness_statusintegrate agent harnesses, the programs that run AI coding agents, such as Claude Code, Codex, and Cursor, through agent-harness-adapter. sokf declares one integration, and each harness writes it as parts in its own files: whole files, blocks in files, and entries in JSON or TOML files. These functions work out the state of each part from the tree, the embedded content, and the record under/.sokf/.harness_installwrites the files that bring the tree in line with the integration.harness::hookhandles a harness'sstopevent: it runsvalidatewithfix. If errors remain, the hook makes the agent keep working and reports the errors to it, in the harness's own form. It blocks on the same errors only once in a session.validatewalks the repository, parses every document, pairs every asset with its sidecar, the document that describes the asset, and compiles every schema against the schema language. It works out the expected content of every generated block and of every directory's index. It repairs the files withfix. It runs the document check of the SOKF validation specification. It returns aReport, whose JSON form the command-line contract defines.info_grammarandinfo_formatsreturn the schema language (the tramlines core grammar, the tramlines-md grammar, and then SOKF's schema extension) and the three-layer format registry.newbuilds a document of the given type from the template in that type's schema. It drops each part of the template whosesokf:onlymarker excludes the requested states. It fills in the id with the next sequence number, and fills in the title and the lifecycle keys. It rewrites each heading that is bound to a frontmatter key to the value of that key. It places the document in the directory that its states determine. It writes the document when the caller setswrite.newbuilds aSchemadocument from the grammar's own template.graphbuilds a graph of the knowledge, with nodes and edges, and adds the inverse of every edge. It runs a query that starts at any node and follows edges to a given depth. JMESPath predicates filter the documents, the edges, and the edge targets that the query reaches. It returns the result as a tree and in the bounded JSON form that the tool specification defines.locatefinds the filesystem path of a document by its id, and, when asked, the path of the asset that a sidecar describes.markdown,grammar,include,check,fix,graph, andExprare the layers behind these entry points, exposed for tests and tooling.ErrorandResultare the crate's one error type and its result type. The command-line tool prints theDisplayoutput of anErrorunchanged aftererror:, and exits with code 2 for every variant.
At build time, the crate embeds SOKF's schema extension from the
repository's sokf-spec/ knowledge store, and the shared formats from
knowledge/formats/.
The tramlines core grammar and the tramlines-md grammar come with the
tramlines-core and tramlines-md crates.
For the full reference, see the sokf-core API documentation on docs.rs.
License
sokf-core is released under the Elastic License 2.0. See the
LICENSE file.