Documentation
/ Guides
Building a corpus
Source files in, reviewed cards and exact records out.
This is the part that takes real effort. Extraction runs deterministically where code can read the structure and escalates only open decisions, while a person always approves what enters the corpus. That is the trade Hive makes: curation is work, and the system exists to make it verifiable and sustainable rather than to skip review.
Before you start
You need somewhere for the corpus to live. It is a git repository of its own, not this one, laid out like this:
concepts/
<product>/
<card>.md
corrections/
db/
clients/
<client>/
memory/
issues/
documents/ # optional client records (copied from hive-ingest)
mappings/
tables/
diagrams/
sources/ # optional shared records (pointed to by RECORDS_DIR)
<product>/
documents/
mappings/
tables/
diagrams/
hive-serve is pointed at concepts/, and optionally at clients/ (CLIENTS_DIR) and sources/
(RECORDS_DIR) at runtime. Keep the folder name sources/: hiveingest gaps and place read the
shared records of a corpus only from there.
Active route: assistant ingest (hive-ingest) and Hive App
New ingest runs hive-ingest beside your source files over local
MCP (or CLI) and publishes reviewed cards through the
Hive App connector.
cd tooling/hive-ingest
uv sync --extra dev
Scan the folder into a job ledger. Every file is accounted for by content, credential files (including inside ZIP archives and Office packages) are excluded before any handler sees them, and optional
hive-ingest-routing.tomlpins apply:uv run hiveingest scan /path/to/source-folderSettle ambiguous files and judgments on the escalation ladder. Code settles plain cases, key-gated Jev (
HIVE_INGEST_TYPESAFE_API_KEYorpass) settles confident ones, your assistant session answerspendingdecisions, and a person settles the four-kindqueueviahiveingest settle:uv run hiveingest decide <job>decideneeds the Jev key once a question reaches Jev. Without it the command stops withno Jev key, and that question does not reachpending.Extract exact, secret-masked records. Run the extractors for your folder's content types:
uv run hiveingest --docling-url http://127.0.0.1:5001 extract <job> --namespace <scope> uv run hiveingest extract-sheets <job> --namespace <scope> uv run hiveingest diagrams <job> --namespace <scope> uv run hiveingest apispec <job> --out /path/to/corpus/concepts/<api-product> --product <api-product> --id-prefix <api-product>Run
decide <job>again afterwards to judge grey-zone bloat passages, diagram pictures/edges and sheet structure questions, usehiveingest restore <job> <element> --reason "..."if a left-out document element should come back, and check the whole job withhiveingest coverage <job>.Map corpus gaps and place record elements.
uv run hiveingest gaps /path/to/corpus --scope <scope> uv run hiveingest place <job> '<element-id>' --corpus /path/to/corpus --scope <scope>placeproposes which existing card (or new concept) each element belongs in; your assistant session readspending_changesand records proposedfill a gap,extendorcorrectchanges viawrite_changes.hive-ingestwrites no concept card. Its only corpus write is the APIdbobjectcards thatapispecputs in its--outfolder.placeneeds the same Jev key when an element has a candidate card, because that question goes to Jev. Without it the command stops withno Jev key.Copy records, file drafts for review, and run post-promote passes. Copy the job's
documents/,mappings/,tables/anddiagrams/records/(intodiagrams/) folders into the product folder underRECORDS_DIRor the client folder underCLIENTS_DIR. Have the assistant draft cards citing those record ids and file them through the Hive App connector for reviewer approval. Once published, run the post-promote passes (includinghivegen-citation-lint).
See hive-ingest for MCP registration and every tool, and hive-apispec for standalone API specification builds.
Scripted preparation route (hive-prep)
hive-prep is not deprecated: it stays for scripted runs without an assistant session, and for
legacy Office files (.doc, .xls, .ppt) via LibreOffice until hive-ingest reads them. See
what still uses hive-prep.
A scripted run also needs a model gateway for the curation pass and any vision pages. Any OpenAI-compatible endpoint works. See configuration.
hive-prep converts a pile of source documents into atomic markdown: one clean,
single-topic file per source, with metadata frontmatter.
cd tooling/hive-prep
uv sync --extra dev
The commands run in sequence. hiveprep <command> --help has the arguments.
| Step | Does |
|---|---|
scan |
walk the source tree and write a file inventory CSV with folder-derived hints |
dups |
report byte-identical duplicate sets |
validate-plan |
check the curation plan is well formed (gate 1) |
dedup-formats |
collapse same-document format variants, such as X.doc beside X.docx, so each document has one slug |
normalize |
convert the plan's includes to PDF intermediates, through LibreOffice |
route |
report how many files land in each conversion tier, without using a GPU |
transform |
convert to atomic markdown and strip boilerplate |
stamp |
write plan metadata into the frontmatter of the explicit --atomic directory |
validate-atomic |
check every output is well formed: unique slugs, enums, relations |
Stamping always needs an explicit directory, even when ATOMIC_DIR is set for hive-gen:
hiveprep stamp --plan curation.yaml --atomic ./hive-work/atomic
Gate 1: the curation plan
scan and the curation pass produce a plan file listing every source document with a proposed
decision: include, exclude, duplicate-of, supersedes, plus derived metadata.
Read it. Edit it. Only then continue.
This is the highest-leverage twenty minutes in the whole pipeline. The plan is one file. Getting it wrong means distilling documents you did not want, or missing ones you did, and discovering that after two model stages have run over them.
The design principle underneath: put the intelligence up front in one reviewable artifact, then let deterministic code do the rest. Everything after gate 1 is ordinary software operating on an approved decision, which means it is reproducible and explainable.
Every include needs a product. It is the first segment of the slug that transform, stamp
and R2 all key on, so there is nothing sensible to assume when it is absent. validate-plan reports
a product-less entry here, and names the products your corpus profile declares in curation.products
so you can fix it in the plan rather than in the output.
The tier tally, before transform
route is a precheck. It reports how many files will go through each conversion tier - text,
vision, passthrough - and uses no GPU and no model doing it.
Look at the vision count before running transform. That is the one that costs money, and
route exists so the bill is a number you approved rather than one you discovered. A tally far
larger than you expected usually means the plan is including scanned material you did not mean to
keep, which is cheaper to fix in the plan than after conversion.
Boilerplate stripping
transform strips copyright lines, page footers and confidentiality notices using regex rules in
hiveprep/stripper_rules/. The product ships one generic set, default.yaml.
Vendor-specific rules go in <product>.yaml beside it and are opt-in via STRIP_PRODUCT.
They are corpus-side, and they belong with your corpus rather than here, for a reason worth
understanding: rules tuned to one vendor's footers will happily delete another vendor's prose.
Rules are anchored to footer and header form, never to a vendor name alone. In a corpus of one vendor's manuals, that vendor's name appears in thousands of legitimate sentences.
Legacy Stage 2: atomic markdown to cards (hive-gen)
Deprecated. The model stages below (the taxonomy, assignment and draft distillation) are deprecated and planned for removal in a later release; they remain for existing consumers. New ingest goes through the active assistant route (
hive-ingest+ Hive App connector). Post-promote is not deprecated; see what is deprecated and what stays.
hive-gen runs two model passes with a gate after each.
cd tooling/hive-gen
uv sync --extra dev
Gate 2: the taxonomy
Given the documents for one functional area, the model proposes the distinct concepts in them and
which documents cover each. It writes taxonomy.<area>.draft.yaml and stops.
CARD_CORPUS_ROOT=/path/to/your/corpus SLICE_AREA=<area> uv run python -m hivegen.run
CARD_CORPUS_ROOT is your card corpus working tree, and is required: the taxonomy is written there,
not beside the engine. It is a different tree from hive-prep's CORPUS_ROOT - that one names the
raw documents going in, this one is the cards coming out.
hive-gen numbers its own two gates package-locally, so the terminal disagrees with this page by
one: the run prints GATE 1 when it proposes the taxonomy, which is gate 2 here, and GATE 2 when
it writes the drafts, which is gate 3.
Review the draft, edit it, save it as taxonomy.<area>.yaml.
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. Expect to merge concepts that are really one thing, split ones that are really two, and delete ones that are an artifact of how a document was organised rather than a real idea.
Gate 3: the drafts
Re-run the same command with an approved taxonomy present. The model now reads each concept's
source documents and writes one card per concept into drafts/, each carrying status: draft.
Review them. Flip the good ones to status: approved.
Card bodies are the substance of the corpus, so this is a genuine read rather than a skim. Watch for over-summarising: the prompt asks for specifics such as parameters and rules to be preserved, and a card that has lost them is pleasant to read and useless to work from.
Promotion
from hivegen.promote import promote
promote("drafts", "concepts", "<product>")
Approved drafts move into concepts/<product>/. Ids are derived from the resulting paths.
Post-promote
These passes are not deprecated and apply to cards however they entered the corpus. In order (one optional in-tree script for scripted builds, then the installed commands):
uv run python scripts/product_facet_apply.py concepts/ <atomic_dir> <product> <platform>
uv run hivegen-conformance-pass concepts/
uv run hivegen-citation-lint concepts/ --clients clients/ --records sources/
uv run hivegen-index-generate concepts/
product_facet_apply stamps the product facet. hivegen-conformance-pass normalises frontmatter
and writes the resource URL, reading its base from CARD_BASE_URL. hivegen-citation-lint
resolves every record id cited in sources: and flags records whose newest version changed
(omit --clients or --records if your corpus has none). hivegen-index-generate regenerates
index.md at the root and per product. Optionally run hivegen-facet-pass when TYPESAFE_API_KEY
and FACET_TAXONOMY_PATH are configured.
Then check isolation before you serve anything:
cd ../hive-serve
CONCEPTS_DIR=/path/to/your/corpus/concepts EVAL_DIR=/path/to/your/corpus/eval \
uv run python -m hiveserve.run_eval progressive <your-qa-set>
<your-qa-set> is a bare set name, resolved under EVAL_DIR, or a path to a .jsonl.
The corpus profile
Everything Hive needs to know that is true of your corpus and false of every other one lives in a
single corpus-profile.yaml: the functional areas, the sub-slices, the guide-topic vocabulary, the
product folder aliases, and the facet values the validators gate on.
It ships with the corpus, not with Hive, and is found via CORPUS_PROFILE, the working directory,
or beside ATOMIC_DIR for local input. Document generation with ATOMIC_SOURCE=r2 ignores
ATOMIC_DIR, so use CORPUS_PROFILE or the working directory in that mode.
corpus-profile.example.yaml at the root of this repository documents every section and, more
usefully, how to get each one wrong.
A missing profile is not an error. It becomes one only when something asks for a vocabulary that nothing defines, and that error names the setting rather than saying "unknown area".
Keeping it true
A corpus is not finished when it is built. Cards go stale, and clients turn out to differ from the general case. That is what corrections and memory are for.