Documentation

Introduction

Getting started

Three ways to interact with the protocol: generate a package, read one, or validate one.

1. Generate a package

The fastest path is the in-browser Compiler. Paste any human text — an article, a policy, a transcript — pick a compression level and an output format, and you get a valid .ckf package.

ts
import { compileCkf } from "@/lib/ckf/compile";

const { pkg, warnings } = compileCkf(rawText, {
  sourceType: "article",
  compressionLevel: "standard",
  outputFormat: "markdown",
  language: "en",
});

2. Read a package

Every package is the same shape regardless of encoding. In TypeScript, the canonical type is CkfPackage exported from src/lib/ckf/types.ts. Iterate sections like any plain object; each item carries an id, a confidence score and a source_basis label.

3. Validate a package

A package is valid when (a) all required sections are present, (b) cross-references resolve (related_entities[].entity_id points at a real entity, etc.), and (c) every numeric field uses the protocol's confidence scale (0.00–1.00).

Heuristic compiler today, LLM-powered tomorrow

The reference implementation in this repo uses a deterministic, dependency-free compiler so it can run anywhere. Production deployments are expected to swap it for an LLM-backed extractor with the same compileCkf() contract.

Glossary

  • Package — a single .ckf file describing one knowledge unit.
  • Section — one of the 22 typed top-level fields of a package.
  • Item — one record inside a section (an entity, a concept, a rule…).
  • Source basis — how the item was derived from the source.
  • Confidence — a 0.00–1.00 score the extractor assigned to the item.