Hive Intelligence

Documentation

/ Guides

Serving cards

0.9.0 docs, commit 05e2eb4PyPI packages at 0.9.0docs/guides/serving-cards.mdpublic repository on GitHub

hive-serve is one core with two doors. By default it makes no model calls, it holds no credential that can change the corpus, and it does not authenticate callers.

That last point is the one to read twice.

Running it

CONCEPTS_DIR=/path/to/corpus/concepts \
CLIENTS_DIR=/path/to/corpus/clients \
LEDGER_DSN=postgresql://user:password@host:5432/hive_ledger \
uv run hiveserve serve --http     # or --stdio for MCP

--http serves REST and MCP over HTTP. --stdio is MCP over stdio, which is what most desktop and editor agents speak directly. Neither starts without LEDGER_DSN, unless TOOL_PROFILE is retrieval, which serves the retrieval tools alone and opens no ledger - see a remote connector.

CLIENTS_DIR is optional: leave it empty to disable client memory and client records entirely. RECORDS_DIR is optional too: set it to serve shared records through find_records and get_record; if set, it must name a directory holding at least one product record folder or the server refuses to start. CONCEPTS_DIR is required and has no default - see configuration for why it lost the one it had, and the table for the full set.

What a deployment looks like

A deployment is a fork of this repository plus a corpus. It copies the neutral example files, edits them, and points at a corpus it owns. Where the engine itself comes from is then one choice, and the examples as shipped make it for you:

Where a deployment's engine comes from
Rendered at build time from the document's own Mermaid source, in the repository's house style.

As shipped, the example builds from source. compose.example.yml sets context: ../../.. and deploy/Dockerfile runs pip install ./hive-gen ./hive-serve against that checkout, so a fork that copies both files unchanged runs whatever its own tree currently holds. That suits a fork that tracks the engine and expects to change it.

To pin a published engine instead, a deployment supplies its own Dockerfile - one that installs vf-hive-serve==0.9.0, which pins vf-hive-gen to the same version - and points the service at that rather than at this repository's build context. Nothing else in the compose file changes, and pip show vf-hive-serve then answers which engine is running.

What that deployment then runs. Only the corpus mount and the ledger hold anything; the service itself is stateless, and the proxy is what makes the identity header mean something:

What a deployment runs
Rendered at build time from the document's own Mermaid source, in the repository's house style.

The engine ships no corpus and no deployment, deliberately; see the product and deployment boundary for the rule, and distributing the engine for what a consumer pins.

Identity, and what it is not

hive-serve trusts a header. It does not verify one.

IDENTITY_HEADER names the header carrying the caller's identity, and whatever arrives in it becomes the owner for ledger operations. It does not select or authorize a retrieval client. There is no signature check, no token validation, and no session.

Hive serves one trusted organization. Authenticated personnel may select any client as retrieval context; there is no per-client authorization or cross-organization tenancy. Operators must keep confidential client information out of shared knowledge. That operating expectation is not evidence that an existing corpus contains no confidential material; private corpora and raw evaluation reports must still be handled privately.

This means anything that can reach the port can claim to be anyone. The binding in the example compose file defaults to loopback for exactly this reason. In any deployment reachable beyond the host, an authenticating proxy is required to restrict access to organization personnel and establish ledger ownership. It does not restrict which client's knowledge an authenticated operator can read.

The design is deliberate: authentication belongs to whatever your organisation already uses, and a service that implements its own is a service with its own auth bugs. But it is only safe if the proxy is actually there and actually strips the header from inbound requests.

Which door can see what, and what identity does: REST serves shared cards only and never loads the clients tree, rejecting a client field on POST /resolve outright; MCP takes a caller-selected client as retrieval context, not authorization, and takes the ledger owner from the header the proxy is trusted to set.

Two doors, one scope rule
Rendered at build time from the document's own Mermaid source, in the repository's house style.

The REST door

Route Returns
GET /healthz {"ok":true} if the process is alive
GET /metrics Prometheus exposition
GET /concepts lean index: id, title, product, type
GET /find_concepts?q= metadata-only hits from keyword search over metadata and cached body words
GET /card/{card_id} one card as JSON {"id", "markdown"}
POST /resolve a bundle: several cards plus their corrections

/healthz is not a corpus check

It reports that the process is running. A service whose corpus mount has gone stale or empty returns {"ok":true} and serves nothing.

This is not hypothetical. It has cost one outage of about two hours, during which health checks were green throughout. Alert on the card-count gauge, never on health. See metrics.

REST serves shared knowledge only

Use MCP for client context. See the REST contract for its shared-only surface and how unsupported client parameters are handled.

/resolve is the interesting one

Given ids, it returns a bundle: the cards, the cards they link to up to depth, and any approved corrections that target any of them. Bounded by MAX_CARDS and MAX_CHARS so a bundle cannot grow without limit.

Corrections arrive whether or not they were asked for. An agent reading a bundle cannot see a superseded claim without also seeing the amendment.

The MCP door

Seventeen tools in three groups, under the default full tool profile. Each one tells a client whether it is read-only, an additive write or a destructive one; the reference has the exact hints.

Retrieval

Tool Does Declared
list_concepts the lean index, optionally filtered by product or client read-only
find_concepts ranked keyword search read-only
get_card one card by id read-only
resolve a bundle, with corrections attached read-only
find_db_objects search the database-object tier, which is excluded from the index read-only
find_records keyword search over records: the exact content of source files read-only
get_record one section, row, mapping row or diagram element by its record id read-only

Work ledger

Tool Does Declared
start_objective begin a piece of work in a mode additive write
list_objectives this owner's objectives read-only
get_objective one objective with its entries read-only
append_entry add a finding, note or decision additive write
set_status move an objective on, replacing its status destructive write
record_quiz_result record a self-check against a concept additive write

Personal memory

Tool Does Declared
remember store a private note additive write
recall retrieve private notes read-only
forget delete one destructive write
promote propose a private note become shared knowledge destructive write

promote does not write to the corpus. It prepares a submission for the agent to file; see corrections and memory. It does mark the note promotion_requested in the ledger, and no tool undoes that.

A declaration tells a client how to present a tool and when to ask before calling it. It stops nothing: every tool above runs when it is called, whatever it declares. What limits a caller is the tool profile, which decides which tools exist, and the ledger's owner scoping, which rests on the identity header.

A remote connector

An assistant that runs in a vendor's cloud - a web or mobile chat app that accepts custom connectors - calls an MCP server from that cloud, so a connector for one is serve --http at a public address, with MCP at /mcp. Three things are then required, and tool declarations replace none of them:

  • HTTPS. hive-serve speaks plain HTTP. TLS terminates in front of it.
  • Authentication in front. The proxy authenticates every caller, sets IDENTITY_HEADER and strips any inbound copy of it, as above. It has to use a method the assistant supports, and a per-person ledger needs one that identifies each person rather than a key they all share.
  • A tool profile chosen on purpose. The default full profile is not read-only: seven of its tools write the ledger rows of whoever the identity header names, and one of them, forget, deletes a memory. For a connector that must not write, set TOOL_PROFILE=retrieval: the seven retrieval tools, no ledger connection, and no LEDGER_DSN to hold. See tool profiles, including how to check from outside which profile a deployment is really serving.

Retrieval is read-only, not public. It still hands a client's memory cards, issue cards and records to anyone who names that client, so it needs the same authentication in front. Leave CLIENTS_DIR empty to keep client cards and records off a connector entirely. Never expose hive-serve without the proxy, in either profile.

Client context

Select the client whose system the question concerns, so its modifications and incidents do not become another site's guidance. See the resolver's scope rules and search candidates for the per-tool contract.

As explained in the trust boundary, this is retrieval context, not access control. Anyone who can read the corpus repository can also read all of it. Deployments requiring an independent trust boundary need separate corpora and separately controlled access.

The ledger

Postgres, at LEDGER_DSN, holding objectives, their entries, and personal memory, keyed by owner. The hive-serve reference has the storage contract; this page will not repeat it.

It is the only state in the system that is not in git. Cards can be restored from any clone. The ledger cannot be restored from anywhere unless you have backed it up. If you take one operational action after reading this page, make it that one - and note that being a database someone's platform will back up is precisely why it stopped being a file.

Corpus freshness

Cards are read live from disk. A card edited in the corpus is served on the next request with no restart and no rebuild.

Code changes need a rebuild. Corpus changes do not.

One exception worth knowing, because it is a foot-gun: if the corpus directory is a bind mount and the host directory is deleted and recreated, the container keeps the old inode and keeps serving the old, now-detached contents. Re-seeding a corpus in place requires a restart. Editing files within it does not.