Skip to content

Python reference

Generated from the installed lokf package. Every entry below is the real signature and docstring of the shipped code.

Load and represent LOKF knowledge bundles.

A bundle is a directory of markdown concept files (OKF layout). This module lifts it into Python objects and, via the published JSON-LD context, into an RDF graph:

import lokf
bundle = lokf.load_bundle("examples/acme-knowledge")
g = bundle.graph() # rdflib.Graph of the whole bundle

load_bundle(path: 'str | pathlib.Path') -> 'Bundle'

Section titled “load_bundle(path: 'str | pathlib.Path') -> 'Bundle'”

Load a bundle directory into a Bundle.

index.md/log.md are reserved (OKF §3) and not parsed as concepts; the root index.md frontmatter becomes Bundle.meta.

One concept document: frontmatter data (with body) plus its file.

A knowledge bundle: root index.md metadata plus its concepts.

Resolve a Concept ID or IRI to an absolute Concept IRI.

Bundle.iri(self, concept: 'Concept') -> 'str'

Section titled “Bundle.iri(self, concept: 'Concept') -> 'str'”

A concept’s IRI: explicit id or base_iri + Concept ID.

Bundle.by_iri(self) -> 'dict[str, Concept]'

Section titled “Bundle.by_iri(self) -> 'dict[str, Concept]'”

IRI -> Concept index (built once, cached).

Bundle.duplicate_iris(self) -> 'list[tuple[str, list[str]]]'

Section titled “Bundle.duplicate_iris(self) -> 'list[tuple[str, list[str]]]'”

IRIs that more than one file declares, each with those files’ Concept IDs.

A second file carrying an existing id - a sync client’s conflict copy, a pasted duplicate, or an explicit id equal to another file’s path-derived one - validates on its own and then merges into the first in by_iri and in the projected graph, where nothing can tell two subjects were meant. Only the loaded bundle, before that merge, can see it; the schema validates concepts one at a time.

Bundle.get(self, ref: 'str') -> 'Concept | None'

Section titled “Bundle.get(self, ref: 'str') -> 'Concept | None'”

Look up a concept by IRI, Concept ID, or bundle-relative path.

Bundle.in_namespace(self, ref: 'str') -> 'bool'

Section titled “Bundle.in_namespace(self, ref: 'str') -> 'bool'”

Whether ref names something this bundle is responsible for.

A relative ref (metrics/wau, /glossary/active-user.md) always is - resolve mints it under base_iri. An absolute IRI is only if it sits under base_iri; anything else is an external resource, and a bundle cannot vouch for what it does not contain.

Bundle.dangling_refs(self, schema_path: "'str | pathlib.Path | None'" = None) -> 'list[tuple[str, str, str]]'

Section titled “Bundle.dangling_refs(self, schema_path: "'str | pathlib.Path | None'" = None) -> 'list[tuple[str, str, str]]'”

Typed-relation targets in this bundle’s namespace that resolve to no concept.

Covers every slot a Concept class holds concept ids in, single- or multivalued (isPartOf, dependsOn, about - see lokf.schema.Vocabulary.reference_slots), plus the target of each reified entry under the generic relations slot, whose domain is Relation rather than Concept and so is not in that set. JSON Schema cannot express this: a fabricated or stale IRI is a perfectly valid string.

Only targets satisfying in_namespace are checked. Several relation slots are documented as taking an external resource - definedBy is “a resource that formally defines this concept”, source “a resource from which this concept is derived” - so an off-site URL there is correct usage, not a broken link, and flagging it would make the check unusable on any bundle that cites the outside world.

A target containing whitespace is skipped: some slots (measures) are documented as accepting a description instead of an IRI, and no valid IRI or bundle-relative path contains a space.

schema_path should be the schema the caller validated against, so the relation vocabulary matches an explicit --schema; the default resolves independently and may disagree with one.

Returns (concept_id, slot, target) per unresolved target.

Each concept’s frontmatter with its IRI injected as id.

Bundle.to_jsonld(self, context: 'dict | None' = None) -> 'list[dict]'

Section titled “Bundle.to_jsonld(self, context: 'dict | None' = None) -> 'list[dict]'”

Each concept’s frontmatter as a JSON-LD document (context attached).

Bundle.graph(self, context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None)

Section titled “Bundle.graph(self, context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None)”

The whole bundle as one rdflib.Graph, under the domain vocabulary schema when one is given.

All concepts are parsed in a single pass (one @graph document) so the JSON-LD context is compiled once, not once per concept.

Programmatic access to the LOKF LinkML schema and its vocabulary.

The schema (lokf.yaml) and the published JSON-LD context are the single source of truth for LOKF’s types, typed-relation slots, and relation vocabulary. This module reads them so tools never hardcode the vocabulary.

Both files are resolved in this order: an explicit path argument, a walk up from the current directory for a repo checkout (so local edits always win), then the copies packaged under lokf/data/ (regenerated by lokf-build) so installed wheels work outside a checkout.

schema_path(path: 'str | pathlib.Path | None' = None) -> 'pathlib.Path'

Section titled “schema_path(path: 'str | pathlib.Path | None' = None) -> 'pathlib.Path'”

Resolve the LOKF schema file (lokf.yaml) to a filesystem path.

Resolution order (same as every other reader here): an explicit path, a lokf.yaml found in the current directory or an ancestor, the the copy shipped inside the installed lokf package - so a bundle can be validated without a schema file of its own.

project_schema(start: 'str | pathlib.Path | None' = None) -> 'pathlib.Path | None'

Section titled “project_schema(start: 'str | pathlib.Path | None' = None) -> 'pathlib.Path | None'”

The domain vocabulary the project declares, or None.

A project names it once, in the pyproject.toml that already pins lokf, so every command reads the same file without a --schema on each call:

[tool.lokf]
schema = "domain.yaml" # relative to this file

start is the bundle or concept file a command was given; the nearest pyproject.toml with a [tool.lokf] table, from there upwards, decides. The file is the bundle’s project’s, wherever the shell is, and a bundle reached through a link (knowledge_bundle -> .lokf/knowledge) is searched where it really lives. Without start, the search runs from the working directory. A declared file that does not exist raises FileNotFoundError: validating against core lokf.yaml instead would pass a bundle the project meant to check more strictly.

domain_schema(explicit: 'str | pathlib.Path | None' = None, start: 'str | pathlib.Path | None' = None) -> 'pathlib.Path | None'

Section titled “domain_schema(explicit: 'str | pathlib.Path | None' = None, start: 'str | pathlib.Path | None' = None) -> 'pathlib.Path | None'”

The domain vocabulary a command validates or projects under: explicit (--schema) when given, else the one the project around start declares (project_schema), else None for core LOKF.

load_schema(path: 'str | pathlib.Path | None' = None) -> 'dict'

Section titled “load_schema(path: 'str | pathlib.Path | None' = None) -> 'dict'”

Return the LOKF LinkML schema as a plain dict (cached per file).

load_context(path: 'str | pathlib.Path | None' = None) -> 'dict'

Section titled “load_context(path: 'str | pathlib.Path | None' = None) -> 'dict'”

Return the published JSON-LD @context mapping (cached per file).

authoring_context(context: 'dict') -> 'dict'

Section titled “authoring_context(context: 'dict') -> 'dict'”

Return a gen-jsonld-context @context mapping made fit for OKF frontmatter. lokf-build publishes LOKF’s own context this way, and schema_context builds a domain vocabulary’s the same way.

schema_context(schema_path: 'str | pathlib.Path | None' = None) -> 'dict'

Section titled “schema_context(schema_path: 'str | pathlib.Path | None' = None) -> 'dict'”

Return the @context that projects a bundle under schema_path.

With no schema_path, this is the published context (load_context). A domain vocabulary that imports: [lokf] gets a context generated from it, so its classes and slots expand to their own IRIs rather than to lokf: terms. Generating one needs LinkML (the build extra).

A schema name as a reader sees it: DataStage becomes “Data stage”, isPartOf “Is part of” and processing_step “Processing step”. A run of capitals stays one word (URLField becomes “URL field”).

vocabulary(schema_path: 'str | pathlib.Path | None' = None) -> 'Vocabulary'

Section titled “vocabulary(schema_path: 'str | pathlib.Path | None' = None) -> 'Vocabulary'”

Return the Vocabulary of the schema and every schema it imports (cached per file).

One relationship predicate: a frontmatter name bound to an RDF IRI.

A JSON-serializable row (the lokf vocab --json / MCP shape).

The LOKF vocabulary derived from the LinkML schema.

Vocabulary.references(self, type_name: 'str') -> 'set[str]'

Section titled “Vocabulary.references(self, type_name: 'str') -> 'set[str]'”

The slots a concept of type_name holds concept ids in. A type no class declares is a plain Concept (SPEC §8), so it gets Concept’s.

Vocabulary.subclasses_of(self, ancestor: 'str') -> 'set[str]'

Section titled “Vocabulary.subclasses_of(self, ancestor: 'str') -> 'set[str]'”

Class names descending from ancestor (inclusive), via is_a.

Vocabulary.induced_slots(self, class_name: 'str') -> 'dict[str, dict]'

Section titled “Vocabulary.induced_slots(self, class_name: 'str') -> 'dict[str, dict]'”

Fields a class declares or inherits, with their effective ranges and multiplicity.

Vocabulary.expand(self, curie: 'str') -> 'str'

Section titled “Vocabulary.expand(self, curie: 'str') -> 'str'”

Expand a prefix:local CURIE to a full IRI.

Vocabulary.compact(self, uri: 'str') -> 'str'

Section titled “Vocabulary.compact(self, uri: 'str') -> 'str'”

Compact a full IRI to a CURIE where a prefix matches.

Vocabulary.type_label(self, type_name: 'str') -> 'dict'

Section titled “Vocabulary.type_label(self, type_name: 'str') -> 'dict'”

How a site names concept type type_name: the class’s title, else its name made readable, with its description where it has one.

Vocabulary.relation_label(self, name: 'str') -> 'dict'

Section titled “Vocabulary.relation_label(self, name: 'str') -> 'dict'”

How a site names relation name in both directions. title reads from the subject (its title, else the name made readable). inverse_title reads from the object, as on the target’s page: the element’s inverse_title annotation, else the title of the slot its LinkML inverse names. With neither, it is left out.

Vocabulary.fields(self, type_name: 'str') -> 'list[dict]'

Section titled “Vocabulary.fields(self, type_name: 'str') -> 'list[dict]'”

The value fields concept type type_name adds to Concept’s own, in the order its classes declare them, each with a title (its title, else its name made readable) and description. A slot whose range is a class is left out: relations are drawn as edges, and nested objects have no single value to show.

Vocabulary.class_docs(self) -> 'list[dict]'

Section titled “Vocabulary.class_docs(self) -> 'list[dict]'”

Every non-abstract class, each with its schema description and aliases. is_type_value marks the subset that is also valid in a Concept’s type: field (Concept/Agent descendants); the rest are embedded object shapes (e.g. Parameter, Source, Verification) that only ever appear nested under another concept’s slots. slot_usage carries the class’s own narrowing of a slot, and its recommended fields, which no generated artifact otherwise reports.

Vocabulary.slot_docs(self) -> 'list[dict]'

Section titled “Vocabulary.slot_docs(self) -> 'list[dict]'”

Every schema slot that carries a description - the frontmatter field reference, with each slot’s range, multivalued flag, required and pattern where set, so a client that cannot run lokf validate can still check a value. A slot a class redefines locally under its own attributes: (e.g. Parameter.type, Source.id) is emitted as an additional row carrying class, so that class’s own description isn’t shadowed by the generic top-level one; a slot_usage narrowing is reported on the class row instead.

Vocabulary.enum_values(self, enum_name: 'str') -> 'list[dict]'

Section titled “Vocabulary.enum_values(self, enum_name: 'str') -> 'list[dict]'”

A schema enum’s permissible values, each with its meaning (CURIE/IRI), description, and aliases where the schema gives them. A value with no explicit meaning falls back to a minted lokf:<value> term, matching relation_types’ convention - so the same RelationType value reports the same curie/uri from vocab.relation_types and from here.

The full vocabulary as a JSON-serializable manifest - classes, slots, and the value enums, each carrying the schema’s own descriptions. The machine-readable reference a downstream tool (an editor’s field help, a docs site) consumes instead of parsing lokf.yaml or the generated JSON Schema itself.

Adapt a published LinkML schema into a LOKF domain vocabulary.

A domain vocabulary imports lokf.yaml (SPEC §6.2). LinkML merges the two into one namespace, so a copy of a published schema must share no element name with lokf.yaml. Its concepts must also descend from Concept to join the bundle’s concept union. adapt makes that copy from the schema as published, in seven mechanical moves:

  1. fold the schema’s own imports into one file, so the copy stands alone;
  2. drop the two slots that cannot coexist with LOKF’s, an identifier (LOKF’s id is the subject) and an rdf:type slot (LOKF’s type designates the class), and point what referenced them at LOKF’s;
  3. detach any slot that inherited from a dropped one, and demote every other type designator to an ordinary slot;
  4. rename every other shared name and pin its IRI, so biolink’s name becomes biolink_name and still projects as rdfs:label;
  5. fold a slot or class attribute into LOKF’s when it means what one of LOKF’s slots means: its IRI matches, or --fold names it. Unless --keep holds it back, drop it as step 2 does. Copy its constraints, such as required or pattern, into a slot_usage on every class that used it, so those classes still enforce them;
  6. re-root the schema’s top classes on Concept, and warn of an attribute on one of them that shadows a slot Concept lists;
  7. give classes CamelCase names and slots underscored ones: the forms type, frontmatter keys and the JSON-LD context use.

Everything works on the plain YAML dict. SchemaView, from the runtime the core install already has, verifies the result beside lokf.yaml.

fold_imports(vocab: 'pathlib.Path') -> 'tuple[dict, list[str]]'

Section titled “fold_imports(vocab: 'pathlib.Path') -> 'tuple[dict, list[str]]'”

The published schema with every schema it imports (transitively, except linkml: ones) merged into it. The importing schema’s definitions win on a shared name, as they do for LinkML. Returns the dict and the imports folded. An import is a sibling <name>.yaml, as LinkML resolves it.

shared_names(schema: 'dict', lokf: 'dict') -> 'dict[str, list[str]]'

Section titled “shared_names(schema: 'dict', lokf: 'dict') -> 'dict[str, list[str]]'”

Per section, the names in schema that lokf.yaml defines anywhere. LinkML keeps classes, slots, enums, types and subsets in one namespace (a type and a slot called unit is an overlap it warns about), and compares names as it normalises them (named thing is NamedThing).

rewrite_refs(schema: 'dict', r: 'Renames') -> 'None'

Section titled “rewrite_refs(schema: 'dict', r: 'Renames') -> 'None'”

Follow r through every reference in schema, definitions included: the keys of each section are renamed too.

drop_twins(schema: 'dict') -> 'tuple[dict[str, str], list[str]]'

Section titled “drop_twins(schema: 'dict') -> 'tuple[dict[str, str], list[str]]'”

Delete the schema’s identifier and rdf:type slots. A class can carry one of each, and LOKF’s id and type are those, so what listed the schema’s now lists LOKF’s. A slot that inherited from one is detached instead, or it would inherit LOKF’s designator (biolink’s category: is_a: type). Returns (dropped -> LOKF’s name, detached).

demote_designators(schema: 'dict') -> 'list[str]'

Section titled “demote_designators(schema: 'dict') -> 'list[str]'”

Strip designates_type (and is_class_field) from every remaining slot: LOKF’s type is the one designator a concept has.

rename_shared(schema: 'dict', shared: 'dict[str, list[str]]', prefix: 'str') -> 'dict[str, str]'

Section titled “rename_shared(schema: 'dict', shared: 'dict[str, list[str]]', prefix: 'str') -> 'dict[str, str]'”

Give every shared element another LinkML name and pin the IRI it had, explicitly where the schema left it to its default prefix. The old name goes to aliases. Slots, types and subsets become <prefix>_<name>, classes and enums <Prefix><Name>.

find_folds(schema: 'dict', lokf: 'dict', asked: 'dict[str, str] | None' = None, keep: 'list[str] | tuple[str, ...]' = (), dropped: 'dict[str, str] | None' = None, lokf_name: 'str' = 'lokf.yaml') -> 'tuple[dict[str, str], list[str], list[str]]'

Section titled “find_folds(schema: 'dict', lokf: 'dict', asked: 'dict[str, str] | None' = None, keep: 'list[str] | tuple[str, ...]' = (), dropped: 'dict[str, str] | None' = None, lokf_name: 'str' = 'lokf.yaml') -> 'tuple[dict[str, str], list[str], list[str]]'”

Which of the schema’s slots and class attributes fold into which of LOKF’s, the names --keep holds back, and the problems that refuse a fold. An attribute is keyed Class.attr throughout.

asked comes from --fold: a slot or Class.attr, in its own spelling or the canonical one, mapped to the LOKF slot it means. A name missing on either side is refused, and so is a slot drop_twins already dropped (dropped names the LOKF slot it was dropped for). keep comes from --keep: names left out of the IRI route, which must exist and not be in asked.

Every other slot and attribute folds by IRI, when its slot_uri or an exact_mappings entry is the slot_uri of a slot Concept lists, other than id, type or a deprecated slot. Only Concept’s slots count, because a fold becomes what a concept writes. LOKF’s name and relation_label describe other nodes, so schema:name folds into title. Two of Concept’s slots sharing an IRI refuse the fold until --fold chooses one. CURIEs expand with LOKF’s prefixes under the schema’s own, and the forms in _IRI_SYNONYMS compare equal.

A shape that differs from the target’s is refused however the fold was found (_shape_conflict); --fold does not override it. lokf_name is the file named in a refusal.

fold_twins(schema: 'dict', folds: 'dict[str, str]', renamed: 'dict[str, str] | None' = None, lokf: 'dict | None' = None) -> 'dict[str, str]'

Section titled “fold_twins(schema: 'dict', folds: 'dict[str, str]', renamed: 'dict[str, str] | None' = None, lokf: 'dict | None' = None) -> 'dict[str, str]'”

Delete each slot and Class.attr attribute in folds, and list LOKF’s slot in its place, as drop_twins does for an identifier. The slot’s constraints (_USAGE_CARRY) are copied into a slot_usage on every class that used it. Where that class already had a slot_usage for the slot, the class’s own values win. A slot that inherited from a folded one now inherits from LOKF’s. Runs after rename_shared, which skips folded slots, so one of the schema’s slots named like the target (its own title) is renamed first. renamed maps each class and attribute to its name since then. Returns folds in the schema’s order, slots first.

Rootless, non-mixin classes that list LOKF’s id (the schema’s identifier, after drop_twins): the classes whose instances are concepts. Biolink has exactly one, entity.

reroot(schema: 'dict', roots: 'list[str]') -> 'list[str]'

Section titled “reroot(schema: 'dict', roots: 'list[str]') -> 'list[str]'”

Make roots subclasses of Concept. tree_root comes off every class as well: LOKF’s document root is KnowledgeBundle, and LinkML warns about a second one. Returns the classes that carried it.

find_shadows(schema: 'dict', lokf: 'dict', roots: 'list[str]') -> 'list[str]'

Section titled “find_shadows(schema: 'dict', lokf: 'dict', roots: 'list[str]') -> 'list[str]'”

Warnings for an attribute on a class in roots, or under one, that has the name of a slot Concept lists but not its IRI (a fold took those). SchemaView keeps the imported slot, so the attribute overrides nothing; it shadows LOKF’s slot on its class alone, and a record of that class writes the attribute. Its name is the key such a record writes, so nothing is renamed, only reported.

canonical_names(schema: 'dict', prefix: 'str') -> 'tuple[dict[str, str], dict[str, str]]'

Section titled “canonical_names(schema: 'dict', prefix: 'str') -> 'tuple[dict[str, str], dict[str, str]]'”

Class names in CamelCase and slot names underscored: LinkML’s canonical forms, which OKF’s type, frontmatter keys and the JSON-LD context use. Derived IRIs do not change (in taxon was vocab:in_taxon already). Two names with one canonical form (biolink’s KnowledgeGraph and knowledge graph) would leave one definition after the rewrite, so first every such name but one is renamed as a shared name is, with its IRI pinned: the one already canonical keeps its name, else the first. Returns the collision renames and the canonical ones.

verify(adapted: 'pathlib.Path', lokf: 'pathlib.Path', *, beside: 'list[str | pathlib.Path] | tuple[str | pathlib.Path, ...]' = ()) -> 'list[str]'

Section titled “verify(adapted: 'pathlib.Path', lokf: 'pathlib.Path', *, beside: 'list[str | pathlib.Path] | tuple[str | pathlib.Path, ...]' = ()) -> 'list[str]'”

Load the copy beside lokf with SchemaView and report what does not hold: a reference no schema defines, a name still shared, a class that lists LOKF’s id but does not descend from Concept. beside adds other domain vocabularies to the load and checks their element and attribute names and prefix bindings for collisions.

dump(schema: 'dict', head: 'str' = '') -> 'str'

Section titled “dump(schema: 'dict', head: 'str' = '') -> 'str'”

adapt(vocab: 'str | pathlib.Path', *, lokf: 'str | pathlib.Path | None' = None, roots: 'list[str] | tuple[str, ...]' = (), prefix: 'str | None' = None, name: 'str | None' = None, folds: 'dict[str, str] | None' = None, keep: 'list[str] | tuple[str, ...]' = (), beside: 'list[str | pathlib.Path] | tuple[str | pathlib.Path, ...]' = ()) -> 'tuple[dict, Report]'

Section titled “adapt(vocab: 'str | pathlib.Path', *, lokf: 'str | pathlib.Path | None' = None, roots: 'list[str] | tuple[str, ...]' = (), prefix: 'str | None' = None, name: 'str | None' = None, folds: 'dict[str, str] | None' = None, keep: 'list[str] | tuple[str, ...]' = (), beside: 'list[str | pathlib.Path] | tuple[str | pathlib.Path, ...]' = ()) -> 'tuple[dict, Report]'”

The domain vocabulary copied from the published schema vocab, and a report of the moves. roots names classes to re-root on Concept, in the schema’s own spelling or CamelCase, instead of the detected ones. name is the copy’s name (default <stem>_lokf). folds maps one of the schema’s slots, or a Class.attr attribute, to the LOKF slot it means, beside those its IRI folds; keep names those its IRI must not. beside names other domain vocabularies whose element and attribute names the copy must avoid; their imports are included in the comparison.

Old name -> new name, per kind. elements covers classes, enums and types, which share the range position.

What adapt did, in the order it did it.

Parse OKF/LOKF concept markdown into JSON-LD-ready dictionaries.

These helpers are the seed of the LOKF toolkit’s parser: parse_concept splits a concept file into frontmatter + body, and isoify normalizes YAML-parsed dates to the ISO-8601 Z form used by the committed RDF projections.

Recursively convert datetime/date values to ISO-8601 strings.

+00:00 offsets are normalized to Z so JSON/RDF output matches the committed examples/*.nt projections byte-for-byte. key is the frontmatter key the value sits under: a bare date (YAML-typed or quoted) under a DATETIME_SLOTS key becomes midnight UTC of that day.

Read one concept markdown file into a dict of frontmatter + body.

Raises ValueError with a clear message if the file has no --- delimited YAML frontmatter (e.g. a plain markdown or reserved file).

split_frontmatter(raw: 'str') -> 'tuple[str, str, str] | None'

Section titled “split_frontmatter(raw: 'str') -> 'tuple[str, str, str] | None'”

Split markdown into (lead, frontmatter, body), or None with no closed block at the top.

The block comes first: only a byte order mark or blank lines may stand before it, and they are returned as lead for a caller that rewrites the file. It opens and closes at the first two delimiter lines, so a --- inside a value stays in the value.

parse_index_text(raw: 'str', where: 'str' = '<text>') -> 'dict'

Section titled “parse_index_text(raw: 'str', where: 'str' = '<text>') -> 'dict'”

The frontmatter of a bundle’s index.md, or {} for a plain page.

An index needs no block, unlike a concept. A page that opens with --- and has no closed block is an error all the same, as base_iri would go unread.

parse_concept_text(raw: 'str', where: 'str' = '<text>') -> 'dict'

Section titled “parse_concept_text(raw: 'str', where: 'str' = '<text>') -> 'dict'”

parse_concept for markdown already read; where names it in errors.

Convert LOKF markdown (a single concept or a whole bundle) to RDF.

This is the engine behind lokf convert. A concept file is lifted to JSON-LD via the published context and parsed with rdflib, so it serializes to any format rdflib supports.

from lokf import rdf
print(rdf.serialize("examples/acme-knowledge/metrics/weekly-active-users.md"))
print(rdf.serialize("examples/acme-knowledge", fmt="nt"))

docs_to_graph(docs: 'list[dict]', context: 'dict | None' = None, base: 'str | None' = None, schema: 'str | pathlib.Path | None' = None)

Section titled “docs_to_graph(docs: 'list[dict]', context: 'dict | None' = None, base: 'str | None' = None, schema: 'str | pathlib.Path | None' = None)”

Parse a list of concept docs into one rdflib.Graph.

The docs are wrapped in a single @graph JSON-LD document so the context is compiled once. This is the shared seam behind lokf.model.Bundle.graph and graph_of.

base (normally the bundle’s base_iri) anchors relative @id values — concept ids are injected absolute, but OKF v0.2 sources[].id keys are relative and would otherwise resolve against the local file system.

schema is a domain vocabulary to project under. Its context replaces the published one unless context is given, and its classes count as declared, so a domain type keeps its own class instead of reading as lokf:Concept.

graph_of(source: 'str | pathlib.Path', context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None)

Section titled “graph_of(source: 'str | pathlib.Path', context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None)”

RDF graph for a concept file or a bundle directory.

A directory is projected as a whole bundle. A single .md file is resolved against its enclosing bundle when one exists (so id follows the bundle’s base_iri); a standalone file falls back to its explicit id or a file:// IRI derived from its path. schema is as for docs_to_graph.

Copy a graph with canonical blank-node labels, preserving its triples.

The labels come from pyoxigraph’s RDFC-1.0, which resolves ties that refinement alone cannot (long paths and symmetric cycles). Its worst-case complexity is exponential for highly symmetric graphs. The common case uses the same algorithm as GraphStore.from_registry.

serialize_graph(g, fmt: 'str' = 'ttl', prefixes: 'dict[str, str] | None' = None) -> 'str'

Section titled “serialize_graph(g, fmt: 'str' = 'ttl', prefixes: 'dict[str, str] | None' = None) -> 'str'”

Serialize g to RDF text in fmt, the same bytes for the same graph.

Blank nodes, which rdflib labels at random, are relabelled from content, N-Triples lines sorted and JSON-LD arrays put in order, so N-Triples, Turtle, N3, TriG and JSON-LD come out the same every run. RDF/XML keeps the same labels, but rdflib may order its descriptions differently. prefixes are bound over rdflib’s defaults, which map schema: to https://schema.org/ and would leave LOKF’s http://schema.org/ terms as schema1:.

serialize(source: 'str | pathlib.Path', fmt: 'str' = 'ttl', context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None) -> 'str'

Section titled “serialize(source: 'str | pathlib.Path', fmt: 'str' = 'ttl', context: 'dict | None' = None, schema: 'str | pathlib.Path | None' = None) -> 'str'”

Serialize a concept file or bundle to RDF text in fmt (default Turtle), under the domain schema when one is given, the same bytes for the same bundle (see serialize_graph).

A pyoxigraph-backed RDF store for querying a LOKF knowledge base.

Load a bundle (or any RDF graph) into an in-memory Oxigraph store and run SPARQL over it — the knowledge-retrieval layer of the toolkit.

from lokf.store import GraphStore
store = GraphStore.from_bundle("examples/acme-knowledge")
for row in store.select("SELECT ?s WHERE { ?s a lokf:Metric }"):
print(row["s"])

The SPARQL query form: ‘select’, ‘ask’, ‘construct’, or ‘describe’.

Leading comments and PREFIX/BASE lines are skipped. Defaults to ‘select’ when no form keyword is found. Shared by the CLI, server, and MCP so all three classify a query identically.

An in-memory SPARQL store over a LOKF knowledge base.

prefixes (the schema’s namespace table) are prepended to every query and update, so lokf:/schema:/prov: and friends work without a per-query PREFIX block.

A store built from a registry holds one named graph per member and sets union: a query with no FROM or FROM NAMED of its own then reads the default graph as the union of all of them, and GRAPH ?g still names the member that asserted a triple. The union counts a triple once for each member that asserts it, so a count across members wants DISTINCT.

GraphStore.query(self, sparql: 'str', **kw)

Section titled “GraphStore.query(self, sparql: 'str', **kw)”

Run a SPARQL query with the schema prefixes in scope.

Returns pyoxigraph’s native result: QuerySolutions (SELECT), QueryBoolean (ASK), or QueryTriples (CONSTRUCT/DESCRIBE).

Federated SERVICE queries are rejected: the engine would issue an outbound request to a query-controlled host, which is an SSRF vector for the local lokf serve endpoint. (LOAD/INSERT/DELETE are already rejected by pyoxigraph’s read-only query.)

GraphStore.select(self, sparql: 'str', **kw) -> 'list[dict]'

Section titled “GraphStore.select(self, sparql: 'str', **kw) -> 'list[dict]'”

Run a SELECT and return rows as {var: python value} dicts.

Every selected variable is a key in every row (None when unbound), so the column set is complete even when a variable is unbound in all rows; bound bindings are reduced to their lexical value.

GraphStore.ask(self, sparql: 'str', **kw) -> 'bool'

Section titled “GraphStore.ask(self, sparql: 'str', **kw) -> 'bool'”

Run an ASK query and return the boolean.

GraphStore.construct(self, sparql: 'str', fmt: 'str' = 'ttl', **kw) -> 'str'

Section titled “GraphStore.construct(self, sparql: 'str', fmt: 'str' = 'ttl', **kw) -> 'str'”

Run a CONSTRUCT/DESCRIBE and serialize the resulting graph, the same bytes for the same answer (lokf.rdf.serialize_graph).

GraphStore.serialize_results(self, sparql: 'str', fmt: 'str' = 'json', **kw) -> 'bytes'

Section titled “GraphStore.serialize_results(self, sparql: 'str', fmt: 'str' = 'json', **kw) -> 'bytes'”

Run a SELECT/ASK and serialize results in the SPARQL results format.

GraphStore.rdflib_graph(self, sparql: 'str | None' = None)

Section titled “GraphStore.rdflib_graph(self, sparql: 'str | None' = None)”

The store (or a CONSTRUCT/DESCRIBE result) as an rdflib.Graph.

With no query, the whole store is returned (the union of its named graphs for a registry store). This backs the live graph visualization, which projects the graph to cytoscape elements.

GraphStore.dump(self, fmt=<RdfFormat Turtle>) -> 'bytes'

Section titled “GraphStore.dump(self, fmt=<RdfFormat Turtle>) -> 'bytes'”

Serialize the whole store as RDF text: the default graph, or for a registry store every named graph (a dataset format such as N-Quads) or their union (a triple format).

A local SPARQL endpoint + live graph visualization for a knowledge base.

lokf serve <bundle> loads the bundle into a ~lokf.store.GraphStore and publishes it over HTTP so agents (and people) can query and explore it locally — no external services, entirely offline:

  • GET|POST /sparql — the SPARQL 1.1 protocol. SELECT/ASK return application/sparql-results+json; CONSTRUCT/DESCRIBE return Turtle.
  • GET /graph.json — cytoscape.js elements for the whole graph.
  • GET / — an interactive cytoscape view with a live SPARQL box.

The server is stdlib-only (http.server); cytoscape.js ships in the package.

build_server(store: 'GraphStore', host: 'str' = '127.0.0.1', port: 'int' = 8000)

Section titled “build_server(store: 'GraphStore', host: 'str' = '127.0.0.1', port: 'int' = 8000)”

A ThreadingHTTPServer serving store (start/stop it yourself).

serve(source, host: 'str' = '127.0.0.1', port: 'int' = 8000, schema=None) -> 'None'

Section titled “serve(source, host: 'str' = '127.0.0.1', port: 'int' = 8000, schema=None) -> 'None'”

Load source, under the domain schema when one is given, and serve it until interrupted.

serve_store(store: 'GraphStore', label: 'str', host: 'str' = '127.0.0.1', port: 'int' = 8000) -> 'None'

Section titled “serve_store(store: 'GraphStore', label: 'str', host: 'str' = '127.0.0.1', port: 'int' = 8000) -> 'None'”

Serve an already-built store (a bundle’s or a registry’s) until interrupted.

Propose typed relations from the markdown links in concept bodies.

Concept prose often links to other concepts without asserting the relationship in frontmatter. This module extracts those links (extract_links), classifies each one against a cue-phrase table (propose), and can write accepted proposals back into the source files’ frontmatter without disturbing formatting (apply).

Section titled “extract_links(concept: 'Concept', bundle: 'Bundle') -> 'list[Link]'”

Markdown prose links in concept.body (code blocks/spans excluded).

propose(bundle: 'Bundle', vocab: 'Vocabulary | None' = None, concept: 'Concept | None' = None) -> 'list[Proposal]'

Section titled “propose(bundle: 'Bundle', vocab: 'Vocabulary | None' = None, concept: 'Concept | None' = None) -> 'list[Proposal]'”

Propose relations for prose links not already asserted in frontmatter.

proposal_row(proposal: 'Proposal', applied_ids: 'set[int] | None' = None) -> 'dict'

Section titled “proposal_row(proposal: 'Proposal', applied_ids: 'set[int] | None' = None) -> 'dict'”

A JSON-serializable row for a proposal.

Shared wire shape for lokf propose --json and the MCP propose_relations tool. When applied_ids is given (apply mode), the row gains an applied flag; in dry-run mode it is omitted.

apply(proposals: 'list[Proposal]', min_confidence: 'float' = 0.0) -> 'list[Proposal]'

Section titled “apply(proposals: 'list[Proposal]', min_confidence: 'float' = 0.0) -> 'list[Proposal]'”

Write accepted proposals into source frontmatter; return those written.

Slot relations append the target IRI under the slot key; non-slot relations append {predicate, target} to relations. Files are edited with round-trip YAML so comments, key order, and quoting survive; duplicates are never written, and everything outside the frontmatter block (a byte order mark or blank lines before its opening --- and the whole body after its closing one) is preserved byte-for-byte, and the block keeps the line endings it had.

One markdown prose link, resolved (where possible) to a bundle concept.

A proposed relation from source to link.target.

Graph and search projections of a bundle, derived without rdflib.

The knowledge-graph page and JSON-LD blocks in the docs are built in a CI environment that has neither rdflib nor the installed lokf package, so everything here is derived from concept frontmatter and the Vocabulary alone. to_cytoscape projects typed relations to edges (RDF predicates from typed relation slots and reified relations entries, never plain markdown body links); dataset_search_jsonld emits schema.org Dataset documents for Google Dataset Search.

to_cytoscape(bundle, vocab=None) -> 'dict'

Section titled “to_cytoscape(bundle, vocab=None) -> 'dict'”

Bundle as cytoscape.js elements (nodes + typed-relation edges).

Nodes are the bundle’s concepts; edges are RDF predicates drawn from each concept’s typed relation slots and reified relations entries. Local targets become display edges; external_edges keeps typed links to resources outside the bundle for concept pages without adding phantom nodes to the graph canvas.

Named-slot edges match the concept-to-concept subset of Bundle.graph one-to-one and carry data.reified = False. Reified relations entries are flattened to direct labeled edges for display (in the RDF projection they remain reified statements, not direct concept-to-concept triples) and are marked data.reified = True. Non-dict relations entries are skipped; validation reports them.

vocabulary_meta(graph: 'dict', vocab=None) -> 'dict'

Section titled “vocabulary_meta(graph: 'dict', vocab=None) -> 'dict'”

How a site labels what graph holds, read from the schema: a title (and description) for each node type; a title, and an inverse title where the schema gives one, for each edge slot; and each type’s own value fields. Only the types and relations the graph uses are listed.

graph_to_cytoscape(graph, vocab=None) -> 'dict'

Section titled “graph_to_cytoscape(graph, vocab=None) -> 'dict'”

Any rdflib.Graph as cytoscape.js elements.

Nodes are resources that carry an rdf:type in the graph (labelled by schema:name/rdfs:label when present, else the local IRI part); edges are triples whose predicate is a LOKF relation predicate and whose object is itself a node. This drives the live server’s visualization of a SPARQL CONSTRUCT result, mirroring to_cytoscape for a store.

dataset_search_jsonld(bundle, vocab=None) -> 'list[dict]'

Section titled “dataset_search_jsonld(bundle, vocab=None) -> 'list[dict]'”

schema.org Dataset JSON-LD docs for each Dataset/Table concept.

Shaped for Google Dataset Search; only keys with values are emitted, and bundle-relative references (url/isPartOf/hasPart) are resolved to absolute IRIs through Bundle.resolve.

Cross-bundle federation: a registry of LOKF bundles (meta-lokf).

A registry (lokf-registry.yaml) maps each member bundle’s base_iri to where its exported artifacts and source documents live. The one load-bearing operation is Registry.owner — longest-base_iri-prefix routing, the exact inverse of lokf.model.Bundle.iri minting — so following an IRI from one bundle into another is pure string math: no network, no shared database. See SPEC §11.

This module holds the offline core (Phase 1): loading/saving the manifest, building an entry from a local bundle or a released bundle archive, and resolving an IRI to its owning bundle + Concept ID + source URL. It also fetches each member’s graph for the federated store (Phase 2, see lokf.store.GraphStore.from_registry) and reports the relation targets no member holds.

release_difference(a: 'RepoEntry', b: 'RepoEntry') -> 'str | None'

Section titled “release_difference(a: 'RepoEntry', b: 'RepoEntry') -> 'str | None'”

What shows a and b describe different releases, or None.

Two checksums decide it alone: the same digest is the same bytes, whatever either entry says about where they are. One checksum without the other cannot be compared, so it counts as a difference. Otherwise every release field must match, including the local path and planning index. Without a digest, different local checkouts or changed counts cannot be assumed to describe the same release. title and status remain local notes.

fill_locations(held: 'RepoEntry', new: 'RepoEntry') -> 'bool'

Section titled “fill_locations(held: 'RepoEntry', new: 'RepoEntry') -> 'bool'”

Copy into held the locations new knows and it lacks, or knows only as a local path; True if any.

For one registrant adding a second location of a release it registered (the URL of a zip first added from disk, say). A walk of a registry tree never calls it: there a deeper registry could add an unchecked distribution.rdf to an entry a registry above it vouched for.

load_registry(path: 'str | pathlib.Path') -> 'Registry'

Section titled “load_registry(path: 'str | pathlib.Path') -> 'Registry'”

Load lokf-registry.yaml with a plain YAML reader (no LinkML).

Tolerant of a hand-edited manifest: a null repos: or null field values fall back to defaults rather than crashing a later lookup. A field of the wrong kind (a list where a string belongs, an entry without a base_iri) is a ValueError naming the entry, and a checksum is normalised to sha256: and lowercase hex, so a hand-written one compares equal to the digest the toolkit computes.

True for an entry that is a registry in turn: one that names its manifest in registry, or is typed dcat:Catalog (CURIE or IRI).

True unless entry is a catalog with no bundle of its own: one that only reserves a namespace for the registry it names.

load_tree(top: 'str | pathlib.Path | Registry', max_depth: 'int | None' = None, *, cleared_members=()) -> 'Registry'

Section titled “load_tree(top: 'str | pathlib.Path | Registry', max_depth: 'int | None' = None, *, cleared_members=()) -> 'Registry'”

A registry and every registry below it, as one flat registry.

top is a manifest path or an already loaded Registry. A catalog entry (is_catalog) is followed to the manifest its registry field names, resolved against the manifest that lists it, to max_depth tiers below the top (else the top’s max_depth, else DEFAULT_MAX_DEPTH); a deeper one is left out with a note. Every entry’s relative locations are read beside the manifest that lists it.

The walk goes tier by tier, so where registries name one bundle the entry nearest the top is the one kept; a registry two others name is read once. A catalog entry joins too, so its namespace stays reserved and a bundle of its own (path or a distribution) loads. A bundle named at two releases raises ValueError, since a named graph holds one release, and so does a registry that names itself or one above it. A sub-registry that cannot be read is left out and listed in skipped.

entry_for_bundle(bundle_dir: 'str | pathlib.Path', source_base: 'str | None' = None, allow_foreign_ids: 'bool' = False) -> 'RepoEntry'

Section titled “entry_for_bundle(bundle_dir: 'str | pathlib.Path', source_base: 'str | None' = None, allow_foreign_ids: 'bool' = False) -> 'RepoEntry'”

Build a RepoEntry from a local bundle directory.

Derives base_iri/title/publisher from the bundle’s index.md, computes a VoID planning index (triple + per-type counts), and harvests an id_index of explicit-id IRIs that diverge from base_iri + Concept ID (so they still route). path records the directory as an absolute path; lokf registry add writes it relative to the manifest.

Raises ValueError if the bundle has no base_iri, or if an explicit id lies outside base_iri and allow_foreign_ids is false: a bundle must declare that it mints IRIs in a namespace it does not route by prefix (SPEC §11.3 rule 3).

True when source names an archive to download rather than a local path.

open_url(url: 'str', timeout: 'float' = 60)

Section titled “open_url(url: 'str', timeout: 'float' = 60)”

Open an http(s) url, following only the redirects _Redirects allows. Raises OSError for anything that goes wrong on the wire and ValueError for a URL that is not http(s).

entry_for_archive(source: 'str | pathlib.Path', source_base: 'str | None' = None, checksum: 'str | None' = None, allow_foreign_ids: 'bool' = False, archive_url: 'str | None' = None) -> 'RepoEntry'

Section titled “entry_for_archive(source: 'str | pathlib.Path', source_base: 'str | None' = None, checksum: 'str | None' = None, allow_foreign_ids: 'bool' = False, archive_url: 'str | None' = None) -> 'RepoEntry'”

Build a RepoEntry from a released bundle zip, local or at a URL.

The zip is unpacked to a temporary directory and registered from there, so the entry never records a path. Its digest goes in checksum; when checksum is given (sha256:<hex> or bare hex) a mismatch is refused. distribution.archive records where the zip is published: archive_url when given (a CI job registers the local copy of a zip it is about to publish), else the URL it was read from, else its absolute local path, which lokf registry add writes relative to the manifest. Without source_base the entry has no source URL, as an unpacked copy is gone.

member_ntriples(entry: 'RepoEntry') -> 'str'

Section titled “member_ntriples(entry: 'RepoEntry') -> 'str'”

A member’s graph as N-Triples, offline first (SPEC §11.4).

Tries the local checkout in path, projected under the domain vocabulary its project declares; then distribution.rdf (a graph.nt from lokf export); then distribution.archive, checked against checksum and projected under core LOKF. Only the archive is checked: a distribution.rdf is trusted as the manifest lists it. Relative locations are read as Registry.located leaves them. Raises ValueError when the entry names none of them, or OSError when the one it names is unreachable.

unresolved_targets(registry: 'Registry', store) -> 'list[Unresolved]'

Section titled “unresolved_targets(registry: 'Registry', store) -> 'list[Unresolved]'”

Typed-relation targets outside the asserting member that do not resolve.

store is a lokf.store.GraphStore built with ~lokf.store.GraphStore.from_registry. This is --check-refs across bundles: a target under the asserting member’s own base_iri is that bundle’s own check, and is skipped here. So is a term of the LOKF vocabulary no member owns, which is not a concept, and a target whose owner failed to load, which cannot be checked (the load error says so).

One member bundle. base_iri is its identity and routing key.

The result of resolving an IRI against a registry.

A registry of LOKF bundles, loaded from lokf-registry.yaml.

Registry.owner(self, iri: 'str') -> 'RepoEntry | None'

Section titled “Registry.owner(self, iri: 'str') -> 'RepoEntry | None'”

The member bundle that owns iri, or None if external.

Registry.resolve(self, iri: 'str') -> 'Resolution'

Section titled “Registry.resolve(self, iri: 'str') -> 'Resolution'”

Resolve iri to its owning bundle, Concept ID, and source URL.

Registry.add(self, entry: 'RepoEntry') -> 'bool'

Section titled “Registry.add(self, entry: 'RepoEntry') -> 'bool'”

Validate and append entry; return False when it is already there.

A base_iri must be non-empty, end in a path separator (/ or #) so prefix routing respects segment boundaries (…/team/ never captures …/team-archive/), stay clear of the vocabulary namespace, and not nest with an existing member (that would make routing ambiguous). An entry for a registered base_iri is accepted, and not appended, when it describes the same release (see release_difference), so the union of two registries that name one bundle can be built; at another release it raises ValueError.

The manifest as a plain dict for YAML serialization.

A copy whose local locations are absolute, read against the manifest’s directory: a relative path or distribution value names a file beside the manifest, wherever the process runs.

Write the manifest back to path (block-style YAML).

A typed-relation target, asserted in graph, that the registry cannot follow: no member owns it (unowned), or its owner holds no such concept (missing).

Access and install the Claude Code agent skills bundled with LOKF.

The skills live under lokf/skills/<name>/SKILL.md, each a directory with a SKILL.md carrying YAML frontmatter (name/description) and a markdown body of instructions that drive the real lokf CLI. This module locates them (zip-safe, like lokf.schema), lists their frontmatter, and copies the tree into a project’s .claude/skills so an agent can use them.

Return the packaged skills directory (lokf/skills).

Return (name, description) from each skill’s SKILL.md frontmatter.

install(dest: 'str | pathlib.Path | None' = None) -> 'pathlib.Path'

Section titled “install(dest: 'str | pathlib.Path | None' = None) -> 'pathlib.Path'”

Copy the skills tree into dest (default .claude/skills); return it.

Parents are created and same-named skills are overwritten in place.

An MCP stdio server that exposes the LOKF toolkit to agents.

LOKF is a semantic profile of the Open Knowledge Framework: a knowledge base is a bundle of markdown concepts (frontmatter + prose) that projects to RDF and is queryable with SPARQL. The tools here let an agent list and inspect concepts, run SPARQL, convert markdown to RDF, propose typed relations from prose links, read the relation vocabulary, and summarize a bundle. Point tools at a bundle directory (e.g. examples/acme-knowledge) unless noted.

list_concepts(bundle: 'str') -> 'list[dict]'

Section titled “list_concepts(bundle: 'str') -> 'list[dict]'”

List every concept as {concept_id, type, title, iri, status, trust_tier}.

bundle is a LOKF bundle directory. A fast index of what the knowledge base contains — including each concept’s OKF v0.2 lifecycle status and derived trust tier — use describe_concept for the full record of any one.

describe_concept(bundle: 'str', concept_id: 'str') -> 'dict'

Section titled “describe_concept(bundle: 'str', concept_id: 'str') -> 'dict'”

Describe one concept: {iri, type, title, body, frontmatter, turtle}.

concept_id is a bundle-relative id (e.g. metrics/weekly-active-users, with or without .md). turtle is the concept’s RDF projection. Returns {error: …} if no concept matches.

sparql_query(bundle: 'str', query: 'str') -> 'dict'

Section titled “sparql_query(bundle: 'str', query: 'str') -> 'dict'”

Run a SPARQL query over a bundle’s in-memory graph.

Schema prefixes (lokf/schema/prov/dcterms/skos/foaf/rdf/rdfs/owl/xsd/dcat) are preset, so queries need no PREFIX block. SELECT returns {columns: […], rows: [{…}]}; ASK returns {boolean: bool}; CONSTRUCT/DESCRIBE returns {turtle: ‘…’}. Returns {error: …} on a bad query.

convert(source: 'str', format: 'str' = 'ttl') -> 'dict'

Section titled “convert(source: 'str', format: 'str' = 'ttl') -> 'dict'”

Convert LOKF markdown to RDF: {format, rdf}.

source is a concept .md file or a bundle directory; format is one of ttl | nt | jsonld | xml | n3 | trig. Returns {error: …} for a bad format.

propose_relations(bundle: 'str', min_confidence: 'float' = 0.0, apply: 'bool' = False) -> 'list[dict]'

Section titled “propose_relations(bundle: 'str', min_confidence: 'float' = 0.0, apply: 'bool' = False) -> 'list[dict]'”

Propose typed relations from the markdown links in concept prose.

Each proposal is {source, link_text, target, predicate, curie, confidence, rationale}. Proposals below min_confidence are dropped. When apply is True the accepted proposals are written into the source files’ frontmatter and each carries an applied flag.

get_vocabulary(all: 'bool' = False) -> 'dict'

Section titled “get_vocabulary(all: 'bool' = False) -> 'dict'”

Return the LOKF vocabulary: {classes, relations} by default.

classes maps class name -> CURIE. relations is a list of {name, curie, uri, frontmatter_key, description}, where frontmatter_key is True when the relation can be asserted as a frontmatter slot (else it is used via a relations: entry).

Pass all=True for the full schema reference instead: every class, frontmatter slot, and value enum with its own description (see Vocabulary.manifest()) - the same data as lokf vocab --all --json.

Summarize a bundle for quick orientation.

Returns {concept_count, types, triple_count, relation_edge_count, trust_tiers, stale_count}: the number of concepts, a per-type count, the size of the RDF projection, the number of typed-relation edges between concepts, a per-trust-tier count (OKF v0.2 §5.3), and how many concepts are past their stale_after date.

Run the LOKF MCP server over stdio.

Reproduce every generated LOKF artifact from the single source of truth (lokf.yaml), then assemble the reference bundle, validate it against the schema, and project it to RDF.

Run from anywhere inside the repository:

uv sync
uv run lokf-build # or: just build

Outputs (regenerated in place): lokf.context.jsonld JSON-LD context (+ type->@type, id->@id aliases) lokf.schema.json JSON Schema lokf.shacl.ttl SHACL shapes lokf.owl.ttl OWL ontology lokf.sql relational schema (CREATE TABLE DDL) src/lokf/datamodel.py LinkML dataclass bindings (from lokf.datamodel import …) examples/acme-knowledge.bundle.json assembled bundle (git-ignored) examples/acme-knowledge.nt RDF triples for the whole bundle examples/weekly-active-users.nt RDF triples for one concept

Echo cmd, then run it with subprocess.run(..., check=True).

Run the four LinkML generators, then publish the authoring context.

Assemble all concept files (+ root index.md metadata) into one bundle.

Validate the assembled bundle against the schema’s KnowledgeBundle root.

to_rdf(root: 'pathlib.Path', bundle: 'dict') -> 'None'

Section titled “to_rdf(root: 'pathlib.Path', bundle: 'dict') -> 'None'”

Project the bundle (and its Metric concept) to N-Triples in examples/.

Entry point for the lokf-build console script.