Package 'okf'

Title: Open Knowledge Format (OKF) Ingestion
Description: Read, validate, and load Open Knowledge Format (OKF) bundles (a directory of markdown files with YAML frontmatter) into a portable DuckDB catalog, build the concept graph, render to HTML, and optionally embed concept bodies for semantic search. Deterministic and agent-free: the same bundle always yields the same catalog, graph, and render, with no LLM calls in the core. Implements the OKF v0.3 specification; bundles that declare an earlier version are read with the fallbacks the specification allows.
Authors: Travis Jakel [aut, cre]
Maintainer: Travis Jakel <[email protected]>
License: Apache License (>= 2)
Version: 0.14.2
Built: 2026-11-30 22:07:46 UTC
Source: https://github.com/travisjakel/okf-ingest

Help Index


Bind parameter values into an Attested Computation, deterministically.

Description

The agent supplies *values* for the declared 'parameters' and MUST NOT author or edit the computation (SPEC 10.3). Binding the computation with those values into the executable artifact is the consumer's job, and the attester independently re-derives the same binding to compare against what actually ran. Shipping that derivation here – in the deterministic layer, with no execution – is what lets an attester be three lines: bind, canonicalise, compare.

Usage

okf_bind(contract, params = list())

Arguments

contract

One row of [okf_computations()].

params

Named list of parameter values.

Details

Substitution is textual and runtime-agnostic: every occurrence of '@name', '$name' or '{{name}}' becomes the supplied value. An undeclared parameter name and a missing required parameter are both errors, because a silent partial binding is exactly the failure attestation exists to catch.

Value

A list with 'artifact' (the bound text), 'canonical', and 'hash' (sha1 of the canonical form).


Canonicalize a computation artifact for comparison.

Description

Collapses runs of whitespace, trims each line and drops blank lines, so a re-derived binding and a receipt's recorded artifact compare equal despite formatting. Deliberately conservative: it does NOT touch case, comments or token order, because a consumer that normalises too much stops detecting the rewrite it exists to detect.

Usage

okf_canonicalize(txt)

Arguments

txt

Computation text.

Value

The canonical form.


Split a concept body into chunks on paragraph boundaries.

Description

Split a concept body into chunks on paragraph boundaries.

Usage

okf_chunk_body(body, target_chars = 600L)

Arguments

body

Concept body text.

target_chars

Approximate maximum chunk size in characters.

Value

Character vector of chunks.


Deterministic community labels via synchronous label propagation.

Description

Operates on the undirected resolved-link graph. Each node starts in its own community; nodes iteratively adopt the most common label among neighbours, ties broken by the lexicographically smallest label (so the result is fully reproducible – no randomness). Isolated nodes keep their own label.

Usage

okf_clusters(con, max_iter = 50L, include_reserved = FALSE)

Arguments

con

An open DuckDB connection to an okf catalog.

max_iter

Maximum propagation sweeps.

include_reserved

Include reserved concepts ('index.md'/'log.md') as nodes – useful for graph visualization, where 'index.md' is the hub.

Value

A data.frame with 'path' and integer 'cluster' (1-based, stable order).


Read the Attested Computation contracts in a bundle (SPEC 10).

Description

Reads and binds only – nothing here executes or attests anything. The computation is either an inline fenced block under a '# Computation' heading (SPEC 10.3) or a file named by the 'computation' path field; declaring both, or neither, is a defect [okf_doctor()] reports.

Usage

okf_computations(rd, now = NULL)

Arguments

rd

A bundle as returned by [okf_read()].

now

Reference time passed through to [okf_trust()].

Value

A data.frame with 'path', 'title', 'runtime', 'computation_path', 'computation' (the text, from whichever form is present), 'form' ('inline'/'file'/'none'/'both'), 'n_parameters', 'parameters' (JSON), 'executor', 'receipt' (JSON), 'attester', plus 'status', 'stale_after', 'is_stale' and 'trust_tier' from [okf_trust()], and 'attestable': SPEC 10.2 and 10.3 say a value MUST NOT be shown as attested without a 'runtime' and an attester, and that a computation which cannot be found makes the concept not attestable.


Assemble an index-first, link-following slice of a bundle as one markdown blob for direct LLM consumption.

Description

This is the OKF / "LLM wiki" consume primitive (Karpathy): hand the agent 'index.md' plus the relevant concept(s) and their link-neighborhood to read directly. It uses the concept graph – **no embeddings, no vector search**. With 'start', it walks the (undirected) link graph from that concept to 'depth'; without 'start', it packs all concepts. Output is capped to roughly 'max_tokens' (estimated at ~4 chars/token).

Usage

okf_context(
  con,
  start = NULL,
  depth = 1L,
  max_tokens = 8000L,
  include_index = TRUE,
  rank = c("bfs", "ppr"),
  query = NULL,
  now = NULL,
  current_only = FALSE
)

Arguments

con

An open DuckDB connection to an okf catalog.

start

Optional concept path to center the neighborhood on.

depth

Link-graph radius around 'start' (ignored when 'start' is NULL or when 'rank = "ppr"').

max_tokens

Approximate output budget.

include_index

Prepend 'index.md' (the map) when present.

rank

Neighborhood selection: '"bfs"' (default; everything within 'depth', in discovery order) or '"ppr"' (rank the whole graph by Personalized PageRank from 'start' via [okf_rank()] and budget-fill by relevance – hubs no longer drown out the pages that matter).

query

Free-text query as an alternative to 'start': seed concepts are chosen lexically via [okf_seeds()], then the graph is ranked by multi-seed PPR (weights proportional to lexical scores) and the budget fills by relevance. Deterministic hybrid retrieval – no embeddings.

now

Optional ISO-8601 reference time. Supplied, each included concept whose SPEC 5.5 'stale_after' has passed carries a staleness note. Lifecycle state is annotated, never used to demote or drop a concept: SPEC 11 asks a consumer to surface it, and a deprecated concept is still a real link target.

current_only

Apply the SPEC 5.4 filter to current knowledge: a concept that is deprecated, or whose 'status' is outside the vocabulary, is left out, and a deprecated concept that names a replacement with 'superseded_by' is swapped for it in place. Off by default: a deprecated concept is still a real link target, and a bundle whose producer writes its own status vocabulary would otherwise lose every page. The result then lists what was 'replaced' and 'excluded', so the filter is never silent.

Value

A list with 'text' (the markdown blob), 'included'/'omitted' concept paths, 'est_tokens', (for 'query') the 'seeds' used, and (for 'current_only') 'replaced' and 'excluded'.


Concept-level diff between two states of an OKF knowledge base.

Description

Compares two bundle states and reports what changed as knowledge structure rather than text hunks: concepts added / removed / changed (by 'content_hash' of the body), frontmatter 'type' and 'title' changes, and concept-graph deltas (resolved edges added/removed, links newly broken or fixed). Fully deterministic: pure hash and set comparison, all output sorted by path, no wall clock.

Usage

okf_diff(
  a,
  b,
  bundle_id_a = NULL,
  bundle_id_b = NULL,
  untyped = c("skip", "keep")
)

Arguments

a

The "before" side.

b

The "after" side.

bundle_id_a, bundle_id_b

Optional bundle id when a side is a catalog holding more than one bundle.

untyped

Passed to [okf_read()] for a side given as a directory: '"skip"' (OKF, the default) or '"keep"' (read a file with no 'type' as a concept anyway, which is what a directory of plain notes needs).

Details

Each side can be a bundle directory, a bundle from [okf_read()], a path to a '.duckdb' catalog, or an open DBI connection to one. Diffing a catalog against its source directory answers "what drifted since the last ingest"; diffing two directories compares two snapshots.

Value

A list with 'identical' (logical), 'added'/'removed'/'changed' (character path vectors), 'type_changed'/'retitled' (data.frames of 'path'/'from'/'to'), 'links_added'/'links_removed' (data.frames of 'src_path'/'dst_path'), 'broken_added'/'broken_fixed' (data.frames of 'src_path'/'dst_raw'), and 'summary' (named counts, including 'unchanged').


Health / maintenance report for an ingested OKF catalog.

Description

Combines the validation findings already stored in the catalog (conformance errors, files that are not concepts, broken links, orphans, ...) with maintenance checks: duplicate titles; duplicate identity (the same normalized id/alias claimed by more than one concept – breaks by-name/wikilink resolution); hub concentration (info severity: pages whose outbound links mostly point at high in-degree hubs); and, when 'now' is supplied, future/stale timestamps. Health 'score' = the percentage of non-reserved concepts with zero error/warn findings – 'info' findings never affect it. Fully deterministic.

Usage

okf_doctor(con, now = NULL, stale_days = NULL)

Arguments

con

An open DuckDB connection to an okf catalog.

now

Optional ISO-8601 "current time" enabling stale/future-timestamp checks (kept explicit so the function stays deterministic; the CLI passes the wall clock).

stale_days

Optional integer; with 'now', flag timestamps older than this many days.

Value

A list with 'score', 'n_concepts', 'n_healthy', 'n_error', 'n_warn', 'n_info', 'by_rule' (named counts), and 'issues' (a data.frame of path/severity/rule/message; severity is 'error', 'warn', or 'info').


Apply only unambiguously-safe maintenance fixes to a bundle's source files.

Description

Two mechanical, deterministic repairs (never invents content):

  • **timestamps** – a parseable non-ISO 'timestamp:' is rewritten to ISO-8601.

  • **moved links** – a broken link whose basename matches *exactly one* concept is re-pointed to that concept (relative to the linking file).

Edits files in place. Anything ambiguous is left for [okf_doctor()] to report. Pages carrying 'reviewed: true' in frontmatter are human-validated and are never modified (protected pages).

Usage

okf_doctor_fix(root)

Arguments

root

A bundle directory path.

Value

A data.frame of changes ('path', 'kind', 'before', 'after'); zero rows if nothing was safely fixable.


Chunk and embed concept bodies into the catalog for semantic search.

Description

Populates 'okf_chunk' with one row per chunk plus its embedding vector and the concept's 'content_hash'. By default replaces all chunks. With 'incremental = TRUE', only concepts whose 'content_hash' differs from what was last embedded are re-embedded (and removed concepts' chunks are dropped) – the expensive embedder calls are skipped for unchanged concepts.

Usage

okf_embed(con, embedder = NULL, target_chars = 600L, incremental = FALSE)

Arguments

con

An open DuckDB connection to an okf catalog.

embedder

An embedder function; defaults to [okf_ollama_embedder()].

target_chars

Approximate chunk size in characters.

incremental

Re-embed only concepts whose content changed.

Value

The number of chunks (re)written this call (invisibly usable as an integer).


Materialize an OKF bundle from a directory, git URL, or tar/zip archive.

Description

Local directories are used in place. Git URLs (github/gitlab/bitbucket, '.git', or 'git@') are shallow-cloned. Tar/zip archives (local path or 'http(s)' URL) are downloaded if remote and extracted. The caller MUST invoke the returned 'cleanup()' when done to remove any temporary files.

Usage

okf_fetch(source, subdir = NULL, branch = NULL)

Arguments

source

A directory path, git URL, or tar/zip path/URL.

subdir

Optional bundle path within the cloned/extracted tree.

branch

Optional git branch or tag (git sources only).

Value

A list with 'dir' (the resolved bundle directory), 'source_kind' ('"dir"'/'"git"'/'"tar"'/'"zip"'), and 'cleanup' (a function).


Render the concept graph as one self-contained interactive HTML page.

Description

A force-directed graph drawn on a '<canvas>' with hand-rolled vanilla JS (no CDN, no framework) – pan, zoom, drag, type-to-search, nodes coloured by community ([okf_clusters()]). Clicking a node navigates to its rendered '.html' (relative), so dropping 'graph.html' into an [okf_html()] site root makes the graph a live map of the site. Fully offline; embeds the node/edge model as JSON.

Usage

okf_graph_html(con, out, site_title = NULL)

Arguments

con

An open DuckDB connection to an okf catalog.

out

Output '.html' file path.

site_title

Optional page title; defaults to the bundle directory name.

Value

The output path (invisibly).


Export the concept graph as portable JSON (nodes and edges).

Description

Returns a JSON object with 'nodes' and 'edges'. Nodes carry 'id' (path), 'type', 'title', 'tags', 'cluster' (from [okf_clusters()]), and 'href' (the rendered '.html' path). Edges are resolved links with 'source' and 'target' fields. Feeds any external graph visualizer – the same "core is a contract" idea as the DuckDB catalog.

Usage

okf_graph_json(con, pretty = TRUE)

Arguments

con

An open DuckDB connection to an okf catalog.

pretty

Pretty-print the JSON.

Value

A JSON string (invisibly also suitable for writing to a file).


Render the concept graph as a Mermaid 'graph LR' diagram.

Description

A text diagram for embedding directly in markdown (READMEs, docs, GitHub renders it natively) – the lightweight complement to the interactive [okf_graph_html()]. Node ids are sanitized; labels are the concept titles.

Usage

okf_graph_mermaid(con)

Arguments

con

An open DuckDB connection to an okf catalog.

Value

A Mermaid diagram as a single string (a ““ “'mermaid ““ block).


Render an ingested OKF catalog to HTML for viewing.

Description

Two modes. As a navigable **site** ('single = FALSE', the default), writes one self-contained ‘.html' per concept under 'out/' (mirroring the bundle’s directory tree) plus an 'index.html' landing page; internal '.md' links are rewritten to '.html'. As a **single file** ('single = TRUE'), writes one self-contained '.html' at path 'out', with each concept an anchored '<section>' and intra-bundle links rewritten to in-page anchors. No JavaScript; CSS is inlined so output is portable. Reserved concepts ('index.md', 'log.md') are rendered too. Bodies are rendered with the commonmark package; broken/orphan links are surfaced in a per-page footer badge from the validation findings.

Usage

okf_html(con, out, single = FALSE, site_title = NULL)

Arguments

con

An open DuckDB connection to an okf catalog (from [okf_ingest()]).

out

Output directory (site mode) or output '.html' file path (single).

single

Emit one self-contained file instead of a per-concept site.

site_title

Optional title for the landing page / single-file header; defaults to the bundle directory name.

Value

A list with 'files' (paths written), 'n_concepts', and 'mode' (invisibly).


Which '.md' files in a bundle its '.okfignore' excludes.

Description

Reports what the ignore file is doing, so an over-broad pattern cannot quietly shrink a bundle: an ignored file produces no findings at all, which is indistinguishable from a clean one unless something counts it.

Usage

okf_ignored(root)

Arguments

root

Path to the bundle directory.

Value

Character vector of bundle-relative paths, possibly empty.


Link-impact ("ripple") of a concept.

Description

Reports direct 'outbound' (concepts it links to), direct 'inbound' (concepts linking to it, i.e. backlinks), and 'transitive' – every concept that can reach it by following resolved links (what a change here could ripple to).

Usage

okf_impact(con, path)

Arguments

con

An open DuckDB connection to an okf catalog.

path

Bundle-relative concept path.

Value

A list with 'path', 'outbound', 'inbound', 'transitive' (all sorted character vectors).


Ingest an OKF bundle into a DuckDB catalog.

Description

Reads, validates, and loads the bundle into the 'okf_bundle', 'okf_concept', 'okf_link', and 'okf_validation' tables of a (file or in-memory) DuckDB database.

Usage

okf_ingest(
  root,
  db_path = ":memory:",
  ingested_at = NULL,
  bundle_id = NULL,
  source_kind = "dir",
  subdir = NULL,
  branch = NULL,
  incremental = FALSE,
  untyped = c("skip", "keep")
)

Arguments

root

A bundle directory path, a git URL, a tar/zip path or URL, or a bundle list from [okf_read()]. Non-directory sources are fetched via [okf_fetch()] and cleaned up afterwards.

db_path

DuckDB path; defaults to in-memory '":memory:"'.

ingested_at

Optional ISO-8601 timestamp; defaults to the current time.

bundle_id

Optional stable bundle id.

source_kind

How the bundle was obtained (e.g. '"dir"'); auto-set for fetched sources.

subdir

Optional bundle path within a cloned/extracted source.

branch

Optional git branch or tag (git sources only).

incremental

Only rewrite concepts whose 'content_hash' changed since a prior ingest of the same bundle into 'db_path' (added/removed handled too); links and validation are always recomputed (they are graph-global). Falls back to a full load if the bundle is not already present. The 'summary' then includes 'changed'/'added'/'removed'/'cached' counts.

untyped

Passed to [okf_read()]: '"skip"' (OKF, the default) or '"keep"' (read a file with no 'type' as a concept anyway).

Value

A list with the open 'con', the 'bundle_id', and a 'summary' (counts, conformance, link totals). The caller owns/closes 'con'.


Build an embedder backed by a local Ollama embeddings model.

Description

An embedder is a function of 'texts' returning a list of numeric vectors. Swap in any such function (e.g. an OpenAI client) for [okf_embed()] / [okf_rag()].

Usage

okf_ollama_embedder(
  model = "nomic-embed-text",
  url = NULL,
  embed_texts = getOption("okf.embed_texts")
)

Arguments

model

Embedding model name.

url

Optional base URL of an Ollama host. An explicit value still means "that Ollama box"; leave it 'NULL' to resolve from the environment.

embed_texts

Optional '(texts, model, url) -> matrix' backend. Defaults to 'getOption("okf.embed_texts")', and to the built-in client when unset.

Details

The endpoint is resolved, never hard-coded: llama-server / llama-swap speak the OpenAI ‘/v1/embeddings' shape and do NOT serve Ollama’s '/api/embeddings'. Resolution order is 'url', then 'LLM_EMBED_URL', then 'LLM_LOCAL_BACKEND=llamaswap' (via 'LLAMASWAP_URL'), then 'OLLAMA_URL'. The request/response shape follows from the resolved path, so a host that names 'OLLAMA_URL' keeps working untouched. Mirrors 'okf.rag._embed_endpoint'.

A host project may instead supply its own backend with 'embed_texts': a function '(texts, model, url) -> matrix' with one row per text, settable once per session via 'options(okf.embed_texts = <fn>)'.

Value

A function 'texts -> list(numeric)'. Requires the httr2 package.


Parse the YAML frontmatter and body of a single OKF concept file.

Description

Parse the YAML frontmatter and body of a single OKF concept file.

Usage

okf_parse_file(path)

Arguments

path

Path to a markdown file.

Value

A list with 'meta' (parsed frontmatter, or 'NULL'), 'body', and 'err' ('NA' on success, else '"no_frontmatter"', '"unclosed_frontmatter"', '"duplicate_key"' or '"yaml_parse_error"').


Query helpers over an ingested OKF catalog.

Description

Query helpers over an ingested OKF catalog.

Usage

okf_concepts(con)

okf_graph_df(con)

okf_findings(con)

okf_search(con, term, current_only = FALSE)

Arguments

con

An open DuckDB connection to an okf catalog.

term

Search term for [okf_search()] (matched against concept bodies).

current_only

For [okf_search()]: apply the SPEC 5.4 filter to current knowledge, leaving out deprecated concepts and concepts whose 'status' is outside the vocabulary.

Value

A data.frame: concepts ([okf_concepts]), link edges ([okf_graph_df]), validation findings ([okf_findings]), or body matches ([okf_search]).


Semantic search over an embedded catalog.

Description

Embeds ‘query' and returns the top-k most cosine-similar chunks (via DuckDB’s native 'list_cosine_similarity'). Run [okf_embed()] first.

Usage

okf_rag(con, query, embedder = NULL, k = 5L)

Arguments

con

An open DuckDB connection to an embedded okf catalog.

query

Query string.

embedder

An embedder function; defaults to [okf_ollama_embedder()].

k

Number of results to return.

Value

A data.frame with 'path', 'title', 'chunk_id', 'score', 'text'.


Personalized PageRank scores for the concept graph.

Description

Exact power-iteration PPR seeded at 'start', over the undirected resolved-link graph. Deterministic: no sampling, fixed lexicographic node order, scores rounded to 10 decimals. Reserved pages (index.md / log.md) participate in the walk (they carry real link structure) but can be filtered by the caller.

Usage

okf_rank(
  con,
  start,
  damping = 0.85,
  tol = 1e-12,
  max_iter = 200L,
  k = 20L,
  weights = NULL
)

Arguments

con

An open DuckDB connection to an okf catalog.

start

Concept path(s) to personalize on. A vector spreads the teleport across several seeds (see 'weights') – this is how [okf_context()] serves free-text queries via [okf_seeds()].

damping

Continue-walk probability (teleport = 1 - damping).

tol

L1 convergence tolerance.

max_iter

Iteration cap.

k

Return the top k concepts (Inf for all with score > 0).

weights

Optional non-negative weights for multiple 'start' seeds (normalized internally; default equal).

Value

A data.frame of 'path', 'score', 'title', 'reserved', sorted by score descending (ties broken by path).


Read an OKF bundle from a directory into an in-memory representation.

Description

A '.md' file is a concept when it is not reserved ('index.md', 'log.md'), is not excluded by '.okfignore', and has frontmatter with a non-empty 'type' (SPEC 3.2). A file with no frontmatter or no 'type' is skipped: it stays in the file set, so a link to it still resolves, and it is reported as 'not_a_concept', never as an error.

Usage

okf_read(
  root,
  bundle_id = NULL,
  source_kind = "dir",
  untyped = c("skip", "keep")
)

Arguments

root

Path to the bundle directory.

bundle_id

Optional stable id; defaults to a hash of the root path.

source_kind

How the bundle was obtained (e.g. '"dir"').

untyped

What to do with a '.md' file that has no frontmatter or no non-empty 'type'. '"skip"' (the default) is OKF: the file is not a concept. '"keep"' reads it as a concept anyway, with no type – an okf extension for a notes vault or any directory of markdown that was never written as OKF, where '"skip"' would leave nothing to read. Each kept file is reported as 'untyped_concept'.

Value

A list with 'bundle_id', 'root', 'okf_version', 'source_kind', 'concepts' (parsed per-file records), 'known' (all concept paths), 'files' (every file in the tree), 'dirs', 'ignored', 'not_concepts', the SPEC 8.1 bundle metadata 'title' / 'description' / 'license', and 'root_fallback' (whether the declared version still allows the v0.2 path fallback).


Resolve a path field to a bundle-relative path.

Description

SPEC 6 first: a leading '/' is from the bundle root, anything else from the directory of the concept's own file. If that names nothing and 'fallback' is set, the value is tried from the bundle root.

Usage

okf_resolve_path(raw, src_rel, targets, fallback = TRUE, dirs = character(0))

Arguments

raw

The field value as written.

src_rel

Bundle-relative path of the concept carrying the field.

targets

Character vector of candidate bundle-relative paths.

fallback

Whether a value that does not resolve from its own file may be tried from the bundle root.

dirs

Character vector of the bundle's directories; a path field may name one.

Details

The fallback is the v0.2 reading. Upstream's v0.2 reference bundles wrote root-relative paths *without* the leading slash (12 of 12 in 'acme_retail'), so v0.3 keeps it for a bundle that declares 'okf_version' 0.2 or earlier, or no version, and for no other (SPEC 6.2, 12.1). Pass 'fallback = rd$root_fallback'.

Value

A list with 'path' (or 'NA') and 'how': '"spec"', '"root"', '"external"' (the value leaves the bundle root) or 'NA' (it names nothing).


Deterministic lexical seed selection for a free-text query.

Description

Tokenizes 'query' (lowercase alphanumeric runs, length >= 3, fixed stopword list) and scores every non-reserved concept by simple term presence: +3 per distinct token found in the title, +2 in the description or tags, +1 in the body. No embeddings, no model – the same query always yields the same seeds. Feed the result to [okf_rank()] as multi-seed personalization (done for you by 'okf_context(query = ...)').

Usage

okf_seeds(con, query, k = 5L)

Arguments

con

An open DuckDB connection to an okf catalog.

query

Free-text query.

k

Number of seed concepts to return.

Value

A data.frame of 'path', 'score', 'title' for concepts with score > 0, sorted by score descending (ties by path); zero rows if nothing matches.


Extract the 'sources' provenance entries of a bundle (SPEC 5.1).

Description

One row per 'sources[]' entry, with the per-source credibility signals kept as authored – the spec records signals and refuses to store a score, so this does not compute one either. 'cited' records whether the body attributes a claim to the entry through a markdown footnote whose label is the entry's 'id': the join key the spec defines, keyed rather than positional so that reordering the list cannot silently misattribute.

Usage

okf_sources(rd)

Arguments

rd

A bundle as returned by [okf_read()].

Value

A data.frame with 'path', 'idx', 'id', 'resource', 'title', 'author', 'usage_count', 'last_modified', 'is_scope', 'cited'.


Derive the OKF v0.3 trust and lifecycle state of every concept.

Description

Trust tiers follow SPEC 5.3: no *current* verification event is 'unverified', current events by non-'human:' actors only is 'machine-confirmed', and a current event by a 'human:<id>' actor is 'human-reviewed'. An event is current when it is at or after 'generated.at', so a review of an earlier text does not count. Staleness follows SPEC 5.5: a concept is stale when 'now >= stale_after', an absolute instant, and a 'stale_after' that does not parse is never treated as fresh.

Usage

okf_trust(rd, now = NULL)

Arguments

rd

A bundle as returned by [okf_read()].

now

Reference time as an ISO-8601 string; defaults to the current UTC time. Supply it to keep a report reproducible.

Value

A data.frame with one row per concept: 'path', 'status' ('NA' when absent or outside the SPEC 5.4 vocabulary), 'status_raw', 'stale_after', 'is_stale', 'trust_tier', 'verified_at' (the latest valid event), 'verified_by', 'generated_by', 'n_verified' (valid events), 'is_current' (the SPEC 5.4 filter to current knowledge: stable or draft, so neither deprecated nor a status outside the vocabulary), 'superseded_by', 'stale_after_malformed' and 'n_current' (events that count toward the tier).


Validate a bundle against the OKF v0.3 conformance rules (permissively).

Description

Errors are exactly the conformance failures SPEC 11.1 names: a frontmatter block that is not a YAML mapping with unique keys ('frontmatter_unparseable', 'duplicate_key'), and a reserved file that breaks section 8 or 9 ('index_frontmatter', 'log_frontmatter', 'log_heading_not_date'). Everything else is a warning or an info note: a '.md' file that is not a concept ('not_a_concept'), missing recommended fields, non-ISO timestamps, broken links, orphans. Never rejects the bundle – returns findings.

Usage

okf_validate(rd)

Arguments

rd

A bundle as returned by [okf_read()].

Value

A data.frame with 'path', 'severity', 'rule', 'message'.