Documentation
/ Concepts
The pipeline, end to end
How a raw vendor document becomes a grounded answer inside an agent. This is the long-form reference: every stage, every gate, and the mechanisms layered on top of them.
Architecture is the short version. Read that first if you want the shape; read this when you need to know how a stage actually works.
Diagrams are Mermaid, render inline on GitHub, and follow the diagram style guide: one question each, six node roles, and a model drawn dashed and lilac wherever one runs.
Contents
- The big picture
- Design principles
- Assistant ingest and records (
hive-ingest) - Legacy scripted Stage 1: document preparation (
hive-prep) - Legacy scripted Stage 2: card creation (
hive-gen) - The layers on top
- Stage 3: serving
- The two stores
- End to end, one thread
The big picture
Hive turns a pile of raw documentation into a curated, cross-linked knowledge base of concept cards and exact source records in git, and serves both to an agent, with a per-person work ledger underneath.
On the active ingest route, hive-ingest runs locally beside
the source files over MCP to scan every file into a ledger, build exact records (documents, field
mappings, tables and diagrams), turn API specifications into dbobject cards via
hive-apispec, map corpus gaps, and propose where elements
belong. An assistant drafts cards and corrections through the
Hive App connector, reviewers approve
them before publication, and hive-serve serves the corpus.
The older three-stage scripted pipeline - hive-prep (kept for scripted
runs and legacy Office files) feeding hive-gen's
deprecated model stages - remains documented in
Stage 1 and Stage 2 below for existing
consumers. hive-gen's card model, post-promote passes (facets, conformance, index) and
hivegen-citation-lint remain active on both routes.
The whole thing is LLM-free at serving time by default. The agent is the reasoning loop, and
with no TYPESAFE_API_KEY configured the serving path makes no model call at all. An optional,
key-gated semantic layer may make bounded typed-judgment calls (TypeSafe System One) to rank
retrieval candidates; it is off unless a key is set, it never egresses client-sensitive text, and it
fails open to the deterministic path, so the keyless, portable serving mode is always available. The
model id is opaque - any id the TypeSafe System One API accepts can be configured - and a model
without a declared calibration posture never influences decisions (the labelled deterministic
fallback / abstention split applies). See
hive-serve.
Design principles
| Principle | What it means in practice |
|---|---|
| Portable | No SaaS knowledge product, no external index. A model gateway and a document converter, both swappable by configuration. |
| Git is the system of record | Cards are plain markdown. Curation gates are pull requests and diffs. Zero infrastructure, auditable, and readable without Hive. |
| The model proposes, a human disposes, git records | Every model stage writes a reviewable artifact and stops. Nothing reaches the corpus without a human flip. |
| LLM-free serving (by default) | With no key configured the serving layer calls no model: it retrieves cards and records work state. An optional, key-gated semantic layer may rank candidates with bounded typed-judgment calls, never touching client-sensitive text and failing open to this path. |
| Two clean stores | Knowledge is read-only versioned git. Work state is mutable per-person rows in Postgres. Never mixed. |
| Small and recoverable | One new piece of infrastructure, a Postgres database, which is one your platform already knows how to back up. The text conversion tier needs no GPU; see conversion tiers for what happens when the vision tier is unavailable. |
Assistant ingest and records (hive-ingest)
Goal: account for every file in a folder, extract checked, secret-masked records (exact
source content), map what a corpus lacks, and propose where each element belongs - without writing
a concept card. The only corpus write is the API dbobject cards that apispec puts in its --out
folder.
Packages: tooling/hive-ingest (module hiveingest, CLI/MCP hiveingest) and
tooling/hive-apispec (module hiveapispec, CLI hiveapispec).
- Scan, credentials and file ledger (
scan/scan_folder). Walks every entry without following symlinks, hashes content, excludes credential files (and ZIP archives or Office packages containing one) before any handler sees them, detects format by content, asks the handler registry, applies optionalhive-ingest-routing.tomlpins, and enforces a ledger gate. - Escalation ladder (
decide,pending,answer,queue,settle). Settles ambiguous files, diagram pictures/edges/transcriptions, grey-zone bloat passages, spreadsheet header/title questions and placement choices in order: deterministic code -> Jev (key-gated System One) -> the assistant session -> a person queue (disagreement,failed-check,card-override,unhandled-file).decideandplaceneed the Jev key once a question reaches Jev. Without it the command stops withno Jev key, and that question does not reach the assistant. - Exact records (
extract,extract-sheets,diagrams,apispec).- Document records: Docling reads DOCX, PPTX, PDF, HTML, Markdown and plain text, preserving
DOCX tracked changes as CriticMarkup, recovering pictures Docling drops, masking secrets as
[masked], checking output against an independent source count, and removing bloat with a restorable removal list (hiveingest restore). - Mapping and table records: native XLSX/CSV readers preserve every cell, formula, format, link, comment and hidden row/column, keeping each field and its mapping values in one row, verified against a second read.
- Diagram records: code reads VSDX and PPTX shapes/connectors and EMF/WMF text; the assistant transcribes unread pictures, verified by OCR label checks and edge/text review.
- API specifications:
hive-apispecturns OpenAPI 3, JSON Schema, XSD, WSDL and Postman collections/environments intodbobjectcards with secret redaction and an independent round-trip check. They are reached throughfind_db_objectsor by card id, notfind_recordsorget_record.
- Document records: Docling reads DOCX, PPTX, PDF, HTML, Markdown and plain text, preserving
DOCX tracked changes as CriticMarkup, recovering pictures Docling drops, masking secrets as
- Gap map and placement (
gaps,place,changes,write).gapsscans the corpus for missing/thin taxonomy topics, API gaps, open questions, eval gaps and uncited/unheld records.placeproposes which card (or new concept) each record element belongs in, and the assistant writes proposedfill a gap,extendorcorrectchanges - then drafts cards through the Hive App connector for human review.
Module-level detail: hive-ingest reference and hive-apispec reference.
Stage 1: document preparation
Scripted path.
hive-prepis not deprecated; it stays for scripted runs without an assistant session and for legacy Office files (.doc,.xls,.ppt) via LibreOffice. For assistant-driven ingest, use hive-ingest.
Goal: take a folder of raw, messy vendor documents and produce atomic markdown, one clean single-topic file per source, labelled with metadata, for scripted runs.
Package: tooling/hive-prep (module hiveprep, CLI hiveprep).
The pipeline, short form:
The flow
The governing idea: put the intelligence up front in one reviewable file, then let deterministic code do the rest. A single model pass decides what to keep and how to label it. Everything after it is repeatable code operating on an approved plan.
Three kinds of actor, and it helps to know which is which:
| Actor | Good at | Where |
|---|---|---|
| A model (the curation agent) | judgment, reading content | curate: what to keep, how to label it |
| Deterministic code | repeatable, free | scan, dups, validate, dedup, normalize, transform, stamp |
| You | approval, accountability | the two review gates |
The curation agent is deployment-supplied. Hive ships the mechanism; the agent that makes the judgment call knows a particular corpus's vocabulary, so it lives with that corpus. See building a corpus.
The converter, in detail
transform.py profiles each normalized PDF (average characters per page, image dominance) and
routes it:
- Text-rich goes to the text tier: the file is sent to Docling (best tables and
layout), falling back to local
pymupdf4llmon any failure, so the pipeline still runs with no GPU. - Image-dominant, a scan or a screenshot-heavy deck, goes to the vision tier: each page is rendered and described by an OpenAI-compatible VLM. Most born-digital corpora barely touch this tier; it is the fallback for scanned material.
- Already-text formats (
.vm,.xsd,.xml,.json,.sql,.properties) go to passthrough: fenced into markdown as-is.
Immediately before an atomic file is written, output from the text and vision tiers (never passthrough, because you do not regex-scrub fenced code) passes through the boilerplate stripper: tunable YAML rules that remove copyright lines, trademark notices, confidentiality banners, "Page X of Y" footers, and table-of-contents dot leaders. Rules are scoped to footer and header form so they cannot delete real prose.
That is separate from strike-trimming, which removes tracked-change text earlier, at the .docx
level, inside normalize.
Every atomic file records how it was made:
---
title: "Platform Architecture"
slug: platform-architecture
topic: platform architecture
doc_type: technical-spec # a closed, validated vocabulary
version: unknown
product: EXAMPLE
platform: EXAMPLE_PLATFORM
source_doc: "Platform_Architecture.pptx"
extracted_via: text # text | vision | passthrough
status: active
---
Module-level detail: hive-prep reference.
Stage 2: card creation
Model stages deprecated. Taxonomy, assignment and distillation are for existing consumers; the post-promote passes stay. See what is deprecated and what replaces it.
Goal: distil atomic markdown into concept cards, one card per concept, cross-linked.
Package: tooling/hive-gen (module hivegen). Concept-centric and gate-aware: it does one
stage, writes a reviewable artifact, and stops.
The flow, three gates
- Load reads atomic markdown into a source-agnostic
Doc {id, name, text}. The slice lever is the area registry plus theSLICE_AREAsetting: distillation runs one functional area at a time, so a corpus is built area by area rather than all at once. - Taxonomy asks the model for a fine-grained list of concepts. Gate 1: you curate what concepts exist. This is the highest-leverage gate in the system, because getting the concept list right is most of getting the corpus right, and a list of titles is far cheaper to fix than a directory of distilled prose.
- Assign classifies each document into exactly one concept, or
exclude. - Distill concatenates a concept's assigned documents and produces
{title, description, tags, related, body}. Therelatedids are constrained to the real taxonomy, so links cannot be hallucinated. Output lands indrafts/asstatus: draft. Gate 2: you review and flip. - Promote validates required frontmatter and that every
related:id resolves, then moves valid approved drafts intoconcepts/. Gate 3: only approved and valid land.
Which model runs each step is configuration. See the configuration reference.
The card, anatomy
A card is markdown with frontmatter and curated prose. The frontmatter makes it a node in a graph:
related: gives the edges, sources: gives the provenance.
---
type: concept
title: Replenishment Logic, Excess Wave Need Processing
description: Logic for moving inventory from reserve to pick locations during a wave…
tags: [replenishment, wave, pick-location]
resource: /card/example/base-replenishment-logic # a PATH, not a host
sources:
- kind: vendor-doc
ref: example-2013-replenishment-logic.md # traces back to the atomic source
related:
- example/shipping-wave-replenishment-subprocess # path-id edges into the graph
- example/replenishment-process-flow
distilled_at: '2026-06-30'
timestamp: '2026-06-30'
status: approved
product: example # facets: selection and isolation
platform: example-platform
version: ['2018', '2020']
---
## Overview
…self-contained, reusable prose (the bulk of the value)…
## Related
- [Shipping Wave Replenishment Subprocess](/example/shipping-wave-replenishment-subprocess.md)
# Citations
1. `example-2013-replenishment-logic.md`
The card lives at concepts/<product>/<id>.md and its concept id is that path. ## Related
and # Citations are regenerated from the frontmatter, so the graph and the provenance are visible
to any OKF consumer, not only to hive-serve.
resourceis a path by default, deliberately. A card outlives any one deployment's hostname. One corpus was written with absolute URIs and every card had to be rewritten when the deployment changed domains. Override withCARD_BASE_URLonly where absolute URIs are genuinely needed, and expect to pay that rewrite next time.
Post-promote: facets, conformance, citation lint, index
Promotion (or publication from Hive App) lands cards in concepts/<product>/, and deterministic,
idempotent, LLM-free passes keep the corpus servable-ready:
| Step | Runs | What it does |
|---|---|---|
| Facet stamp | scripts/product_facet_apply.py |
stamps product, platform, version onto the product's cards |
| Version facet | scripts/version_apply.py |
derives version from source-reference years. No model, no gate |
| Regime facet | scripts/regime_apply.py |
stamps a within-product either-or facet from a human-reviewed classification; drives the cross-regime expansion guard |
| Conformance | hivegen-conformance-pass |
sets resource, adds timestamp, regenerates ## Related and # Citations |
| Citation lint | hivegen-citation-lint |
resolves every record id cited in sources: and flags records whose newest version changed |
| Index | hivegen-index-generate |
writes the root and per-product index.md progressive-disclosure listings |
This takes the corpus from formally conformant (parseable frontmatter) to idiomatically conformant: path-id identity, a graph expressed as inline links, citations, and a spec-shaped index. Every pass is idempotent, so re-running leaves conformant cards untouched.
Optional, key-gated: the closed-taxonomy facet pass. One further pass is a model pass, not an
LLM-free one, and is off by default: hivegen-facet-pass classifies each concept card against the
closed facet taxonomy (one System One Choice per dimension) and stamps a facets: mapping block,
which
serving then indexes deterministically as the no-model recall floor. It runs only when BOTH
TYPESAFE_API_KEY and FACET_TAXONOMY_PATH are set (and only for a model id with a declared
calibration posture; without one it stamps nothing and says so), is idempotent (a card with a
facets block is
skipped) and fail-closed (a dimension the model cannot settle confidently is left unlabelled,
never
guessed), so a corpus that never runs it is unchanged and serves exactly as before. See the
semantic layer it feeds.
The isolation eval is the deploy gate. Before deploy, the eval harness over a product's question set must show zero cross-product bleed, plus no regime or version regression. No product ships without it.
Module-level detail: hive-gen reference.
The layers on top
Four mechanisms sit above the base concept corpus. Each solves a problem concept cards alone cannot.
Corrections: fixing a card without editing it
A card can be wrong or stale without anyone wanting to edit the distilled prose, which is a reviewed artifact whose value is partly that it records what the source said.
A correction is an ordinary card at concepts/<product>/corrections/<slug>.md with
type: correction and corrects: <path-id>.
- Surface, do not resolve. The resolver reverse-looks-up the active corrections of every selected concept and co-pulls them into the bundle after the concept's own traversal, deliberately unbudgeted, because a correction must never be dropped or the wrong fact stands. The answer prompt treats it as authoritative.
- Never selected, never listed. Corrections are excluded from the selectable index and from index listings. They only ride along with their target.
- Supersede, do not delete. A newer correction can
supersedes:older ones, flipping them tostatus: superseded, kept in git for history. More than one active correction on a concept is a lint warning for a human, never an auto-merge.
Memory: what a practitioner learned
Concepts and corrections describe how the product works. Memory captures what someone learned, especially client-specific operational knowledge. It lives in two tiers:
- Personal, private, in the ledger. Jotted with
remember, recalled withrecall(deterministic filtering, no model at serve time), removed withforget. Never enters git, never visible to another owner. - Global, shared, client-scoped, in git. A promoted memory is a
type: memorycard atclients/<client>/memory/<slug>.md. Selectable, unlike a correction, within client context.
The invariant: memory is client-specific and lives in a clients/<client>/ namespace, so it
structurally cannot touch concepts/. A lesson belonging in core knowledge is a correction or
a new concept, never a memory. Core documentation cannot be polluted by client specifics.
For selection and traversal, see the resolver's client-scope rules. These are retrieval controls, not authorization; see the serving trust boundary.
The write path, and why the read door holds no forge credential
hive-serve is keyless by default and never writes a card. Its only writes are each person's
own ledger rows, and its retrieval tool profile makes none. Contributions go to a separate
service: an assistant files a draft through the
Hive App connector, reviewers
approve or decline it, and only an approved card is
published.
Deprecated.
hive-author(vf-hive-author), which files contributions as issues on the corpus repository, is deprecated and planned for removal in a later release. The Hive App connector is the only supported write route. See the deprecation notice.
The connector files a new card with submit_card. It also keeps two older, hard-separated tool
names: submit_memory_promotion (requires a client) and submit_correction (targets a core
concept id).
Conflict is a two-layer gate. When a promoted memory would collide with another for the same client on the same subject, a deterministic lint enumerates candidate pairs and an LLM judge scores each. A genuine conflict blocks the PR until a human resolves it. The scorer is fail-safe: any model error scores as a conflict and blocks.
The database-object tier
Concept cards describe how a product works. They do not describe the data model: tables, columns, types, keys, stored procedures.
This is a different mechanism from stages 1 and 2. Concept cards are distilled by a model from messy prose, which involves judgment and paraphrase. Schema is exact and must stay exact, so this tier is produced by a deterministic parser with no model in the loop, and its output is verbatim. The engine is sqlglot: a real dialect-aware tokenizer and AST, never regex.
parse_tablesturns eachCREATE TABLEinto columns, primary key and inline constraints, degrading gracefully via a token-level fallback where the parser bails on storage clauses.parse_auxoverlays out-of-line facts:COMMENT ONkept verbatim as the human description, foreign keys, indexes, sequences.parse_plsqlcaptures every programmatic unit with its signature and full body copied verbatim. Unit boundaries come from the tokenizer, not line heuristics: a/terminates a unit only when it stands alone on its line, so a division inside a body cannot truncate it.reconcilematches definitions of the same object across dialects, records per-column and per-body deltas, and merges a package spec with its body.
For gate requirements, failed-output handling and duplicate rules, see the hive-dbparse reference.
Served on demand, kept out of the concept index. This tier can be many times the size of the
concept corpus and is schema-level rather than narrative, so putting it in list_concepts would
drown concept retrieval. Db cards are reached only through find_db_objects.
Exact source records and API specifications
Concept cards summarise how a system works; they are not meant to duplicate every table row, field mapping, diagram or API operation. Two mechanisms keep exact values alongside cards:
- Source records (
hive-ingest). Document, mapping, table and diagram records copied intoRECORDS_DIR(shared) orCLIENTS_DIR(client-scoped) are searched and read verbatim byhive-serve'sfind_recordsandget_recordtools with no model involved. Cards cite exact elements by record id (such aswidget/doc/bench-guide@v1.2#t4.r9), andhivegen-citation-lintverifies every citation and flags when a newer version of the source record changed it. - API specifications (
hive-apispec). OpenAPI 3, JSON Schema, XSD, WSDL and Postman collections/environments becomedbobjectcards deterministically with secret redaction and an independent round-trip check. They are reached throughfind_db_objectsor by card id; see hive-apispec.
The issue-journal tier
Deprecated importer. See the
hive-zendeskdeprecation and replacement workflow.
Neither concepts nor memory record what has actually gone wrong at a site. The issue journal
adds one thin type: issue card per closed support ticket under clients/<client>/issues/.
A journal entry is deliberately not a knowledge card. Distilling each ticket into an explanation would restate the concept corpus thousands of times and dilute retrieval. An entry carries what happened, how it closed, and links to the concepts that explain the behaviour. Its purpose is awareness. The skills state the contract explicitly: an entry is a lead, never a root cause.
Two properties follow:
- Client-scoped, like memory. One client's incidents never reach another's answer.
- Linking is a separate stage from distillation. The distiller has never seen the corpus, so
any card id it invents resolves rarely. Cards are emitted with
related: []and linked afterwards against real ids by a model shown a shortlist and free to decline.
Stage 3: serving
Goal: serve cards to people and tools, and track each person's work, without reintroducing a heavy retrieval stack.
Package: tooling/hive-serve (module hiveserve, CLI hiveserve).
One core, two doors, two stores
Two transports, one codebase: serve --stdio runs MCP over stdio; serve --http serves the REST
routes and a mounted MCP streamable-HTTP app from one FastAPI process.
Door 1, REST. Read-only. Auto-generated OpenAPI at /docs.
| Method | Path | Returns |
|---|---|---|
GET |
/healthz |
liveness. Does not check the corpus |
GET |
/metrics |
Prometheus exposition |
GET |
/concepts |
the lean index: ids, titles, products, types |
GET |
/find_concepts |
lean metadata hits from search over metadata and cached body words |
GET |
/card/{card_id} |
one card as JSON {"id", "markdown"} |
POST |
/resolve |
a bundle of cards, neighbours, and any active corrections |
Door 2, MCP. 17 tools and no prompts, or the 7 retrieval tools alone under the retrieval
tool profile. Behaviour lives in skills that travel with the
client, not in the connector: a connector should offer capabilities, while when to investigate
versus plan versus teach belongs with the agent.
| Group | Tools |
|---|---|
| Retrieval | list_concepts, find_concepts, get_card, resolve |
| Database objects | find_db_objects |
| Records | find_records, get_record |
| Work ledger | start_objective, list_objectives, get_objective, append_entry, set_status, record_quiz_result |
| Personal memory | remember, recall, forget, promote |
find_db_objects is LLM-free, the same family as recall: keyword matching over
each product's db/manifest.jsonl, ranked by where a word is found and how rare it is, filterable by
kind or module. Find an object by
name, or by what it means through its verbatim COMMENT ON text, then read the exact schema.
find_records and get_record read records, the exact content
of source files. They call no model.
/healthzdoes not check the corpus. A service with a stale or empty mount answers{"ok":true}while serving nothing. Alert on the card-count gauge; see metrics.
The skills
The behaviour that used to live as connector prompts now ships as skills in skills/,
installed through a plugin. A skill is auto-selected from the user's intent and carries the
standing rules: ground every claim in a card's sources:, respect isolation, track work in the
ledger.
| Skill | Auto-engages on | What it does |
|---|---|---|
hive (base) |
any product question | grounds every answer in cards and records, cites sources, reaches for tools proactively, honours isolation |
diagnose-an-issue |
a live ticket, "why did X fail" | client cards first, then baseline product cards, then prior issues; separates client-modified from vanilla behaviour |
plan-an-implementation |
"help me set up / redesign X" | grounds a change in concept and client cards; offers a test-plan or spec artifact |
learn-a-topic |
only an explicit "teach me X" | a tracked, quiz-based curriculum that resumes across sessions via the ledger; untracked on a retrieval connector |
contribute |
"this card is wrong", "remember this" | interviews, drafts a card, then files through the Hive App connector after confirmation |
review |
reviewing waiting cards | lists tasks, opens one card at a time, and records reviewer decisions through the Hive App connector only on the reviewer's word |
A one-off "explain X" stays on the base skill. No learning plan.
The work ledger
One Postgres database, named by LEDGER_DSN. It holds per-owner state, never canonical
knowledge, and it is the only thing here that is not a file in git. See
the ledger for the storage contract and why it is not a
file.
The third table, memory, is owned the same way and joins neither of the other two:
Identity and owner-scoping. The app is auth-agnostic. It reads the caller's identity from a
trusted header injected by the gate and keys every row on it as owner; for stdio it falls
back to a configured default. owner is always derived server-side, never a tool
parameter, so one person can never read or write another's objectives or memory.
A session in motion
The diagnose skill sets the behaviour, the agent is the loop, and the layer retrieves and records:
Module-level detail: hive-serve reference.
The two stores
A simple way to hold the whole system in mind:
Knowledge is what is true. Per-owner state is what a person is doing and privately knows. They
touch only through citations: an entry records the card_ids it relates to.
Blow away the ledger and you lose work history and private notes, not knowledge. The git cards are untouched.
The one bridge from private to shared is promotion: a sanitised, human-approved personal note becomes a client-scoped memory card in git.
End to end, one thread
- Ingest.
hive-ingestscans the folder into a file ledger, runs credential checks, converts the PDF with Docling, masks secrets, removes bloat with a removal list, and places each element against the corpus. - Draft and review. The assistant drafts or updates a card citing the record id (verified by
hivegen-citation-lint) and files it through the Hive App connector; reviewers approve and publish it to git alongside the copied record. (On the legacy scripted route,hive-prepandhive-gen's deprecated model stages ran offline instead.) - Serve. A consultant asks the agent. The skill engages, calls
resolvefor the concept card, its neighbours and any active corrections, callsget_recordif an exact table row or value is needed, and answers citing the card'ssources:and record ids. Findings are logged to the ledger, so the investigation resumes later.
No vector database, no re-embedding, no external index. Git files and an agent, with a thin relational memory beside them.
See also
- Architecture, the short version
- Cards, the OKF format in detail
- Principles, the decisions that constrain everything
- Building a corpus, the operator's path through ingest and corpus builds