feat(import): Open Knowledge Format (OKF) import#101
Merged
Conversation
Map ExportPage to OKF frontmatter with x-llmwiki provenance block. Includes canonical body stripping, sha256 content-hash, safeRefName helper.
…st safeRefName traversal
…rences Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dempotent okf token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
llmwiki import --okf <dir> [--trusted], the inverse of the OKF export — it reads a conformant Open Knowledge Format (OKF) v0.1 bundle and maps each document back into a llmwiki page, reusing the shared, reversible OKF↔llmwiki mapping.reviewMode: imported, held reasonimported-okf) and flow through the existingreview list/show/approvelifecycle. External knowledge never reaches the live wiki without a human in the loop.--trusted: write live. Runs the identical pipeline (read → map → validate → collision-check) and only skips the human-staging step, writing pages straight intowiki/. It does not skip validation or collision safety, and the live write + index/MOC refresh run under the same.llmwikilock that compile and approve use.provenanceState: importedplus anokf:<bundle>source token that survives approval, so downstream retrieval and evals can always tell foreign knowledge from locally-compiled, citation-validated pages. Their locally-computed freshness isunverified.^[…]claim markers), and routes query pages back towiki/queries/. The page slug is identity (concepts/rag.md→rag).typemaps tokind: conceptwith the raw type preserved underx-okf.type; the full original frontmatter is snapshotted underx-okf.originalFrontmatter; unknown keys and broken links are kept, never rejected.Why
OKF is an emerging standard for portable agent knowledge. Pairing import with the export target makes compiled wikis a true round-trip surface — bundles can leave as OKF and come back without losing the compiler's richer provenance — while keeping foreign, untrusted bundles gated behind review.
Safety (untrusted-input ingestion)
Import treats every bundle as untrusted: a single confined, resource-bounded reader rejects (never truncates) bundles exceeding file-count / per-doc / total-size caps; every file is realpath-confined to the bundle root (symlink escapes are skipped); frontmatter parses on js-yaml's default safe schema; and both write paths run page validation and the skip-and-warn collision policy (never overwriting a live page, a pending candidate, or an intra-bundle duplicate).
Test plan
npx tsc --noEmit,npm run build,npm test(1599 passed),npx fallow(0 above threshold), CI-strict dupes cleancanonicalBody(imported) === canonicalBody(original), kind/sources/citations preserved, query page routed towiki/queries/importedprovenance +okf:token survive approval; nostate.jsonownership written--trusted), nested-slug non-collapse, freshnessunverified, and a subprocess CLI test