Expand description
LeanCTX | Hive engine↔service wire contract, protocol major 1.
The engine connector and the Hive service build against these types and
the golden fixtures in tests/fixtures/hive/. A contract change is a
fixture change that both sides review.
Conventions shared by every module:
- Base URL
https://hive.leanctx.com/v1; a self-hosted Hive may use anyhttpsURL (loopback may usehttp). - Every HTTP body carries
schema(leanctx.hive.<area>/v1). The one exception is the error body{"error":{...}}, which proxies may also emit. - Request types refuse unknown fields (the service rejects them with
invalid_request); response types accept unknown fields, so the service can add fields in a minor version without breaking older engines. - Timestamps are
YYYY-MM-DDTHH:MM:SSZ([UtcTimestamp]); unix seconds appear only where a value is signed as text (iat). - Keys, nonces, signatures and ciphertext are standard base64 with padding.
vault_idis 32 lowercase hex characters: the engine API renders the vault UUID in simple form (no dashes) while the web API keeps hyphenated UUIDs.- Signatures are Ed25519 over
domain || canonical_json(value), seecanonical_json. Signed objects are verified over the raw JSON that was received, never over a re-serialized typed value, so additive fields stay covered by the signature.
Re-exports§
pub use error::HiveErrorBody;pub use error::HiveErrorCode;pub use error::HiveErrorDetailV1;pub use error::HiveUploadKind;
Modules§
- anchor
- Code anchors (C0 1.9): where in the code a fact, or a piece of task evidence, applies.
- bus
- Bus leases (C5): one holder per resource across the machines of an organization, decided by the service clock.
- codegraph
- The published code graph (C0 1.9, section 8; plan N1).
- ctxpkg
- The ctxpkg object mapping (C0 1.9, section 7; plan O1).
- effective_
policy - Unified Control: the signed effective policy of one engine (Release B,
C0 2.x
schemas/policy.schema.json). - enroll
- Device-flow enrollment and instance access tokens.
- error
- Error body of every non-2xx Hive response:
{"error":{...}}. - facts
- Fact states (C0 1.9, section 3).
- gate
- G6, the test gate of process v1 (leanctx-hive
docs/process-v1.md§5,contracts/process-v1/gate-record.schema.json): what the Instance checks and records on submit (E47) and again before verify (E48). - graph
- The vault graph view (C0 1.9, section 3).
- knowledge
- Vault knowledge: the
ctxpkg.research-context.v1document, its revisions, and draft proposals streamed from engine sessions. - lease
- Instance lease and the Hive signing key set.
- managed
leanctx.managed-config/v1: what an organisation preconfigures on a machine through MDM (contract:docs/contracts/managed-config-v1.md).- metrics_
v2 - Engine metrics v2 (C0 2.0
schemas/metrics.schema.json, telemetry SPEC). - optin
- Engine opt-in (C0 1.9, section 4; owner decision O1).
- policy
- Filter packs.
- profiles
- Agent profiles and reputation (C0 1.9, section 5).
- receipts_
v2 - Engine receipts v2 (C0 2.5
schemas/receipts.schema.json, K2 review M3). - root_
cert - Self-host root certificates (1.7): LeanCTX vouches for the root of a self-hosted Hive.
- status
lean-ctx hive status --json: the one shape the local cockpit reads.- tasks
- Tasks, claims and results (C0 1.9, section 1).
- telemetry
- Cockpit metrics and receipts.
- vault
- Vault resolution: the engine never sends a path, remote or name, only an org-salted digest of its git repository’s stable identity. One git repository maps to exactly one vault.
Constants§
- FILTER_
PACK_ SIGNATURE_ DOMAIN - Domain of a filter-pack statement signature (Hive signing key).
- HEADER_
IDEMPOTENCY_ KEY - Client-chosen ULID on every
POST; replays return the first response. - HEADER_
INSTANCE - Instance id on authenticated requests.
- HEADER_
MIN_ ENGINE - Lowest engine version the service accepts; sent with
426. - HEADER_
NAMES - 1.9 VA (until the 3.12 release day): an engine that speaks the vault
names sends
NAMES_VAULThere on every request, the bus WebSocket upgrade included. Hive then answers in the vault form (vault_id,vault:channels); without it, in the earlier project form. Hive takes both forms as input. From the release day only the vault form remains and the header is ignored. - HEADER_
PROTOCOL major.minorthe sender speaks; sent on every request and response.- HIVE_
API_ PREFIX - Path prefix of every engine-facing route.
- HIVE_
DEFAULT_ URL - Hosted Hive origin.
- HIVE_
ENGINE_ CLIENT_ ID - OAuth-style client id the engine sends in the device flow.
- HIVE_
PROTOCOL_ MAJOR - Major protocol version; a different major is incompatible.
- HIVE_
PROTOCOL_ MINOR - Minor protocol version; minors only add optional response fields or routes.
- KEYSET_
SIGNATURE_ DOMAIN - Domain of the key-set signature (Hive root key).
- LEASE_
SIGNATURE_ DOMAIN - Domain of the lease signature (Hive signing key).
- MAX_
BODY_ BYTES - Largest request or response body either side accepts, except knowledge
documents (
knowledge::MAX_KNOWLEDGE_BODY_BYTES). - NAMES_
VAULT - The
HEADER_NAMESvalue of the vault form. - REPO_
IDENTITY_ DOMAIN - Domain of the stable repository identity digest input. The bytes keep their 1.0 name: a different domain would change every digest and unbind every linked vault.
- TOKEN_
ASSERTION_ DOMAIN - Domain of the instance token assertion (instance key).
Functions§
- canonical_
json - Canonical JSON encoding used under every Hive signature.
- invisible
- 1.9 R3-3e-1: characters that make a text read differently from what it is, or hide text a person reviewing it cannot see: bidi marks, embeddings, overrides and isolates, zero-width space, the invisible operators, a byte-order mark, tag characters and the variation selector supplement; and (1.9 erratum) the soft hyphen, the Mongolian vowel separator, the combining grapheme joiner, the Hangul fillers, the Khmer inherent vowels and the line and paragraph separators (not controls, so they would break a one-line text), the whole block U+2060–U+206F (with the deprecated format controls), the interlinear annotation characters (they hide annotation text) and the invisible format controls of Egyptian hieroglyphs, shorthand and musical notation. Every text field refuses them; engines strip them from foreign content. The joiners U+200C/U+200D and U+FE00–FE0F stay: emoji and Persian need them; the visible Arabic and Syriac signs (U+0600–0605, U+06DD, U+070F, U+08E2) too.
- parse_
protocol_ header - Parse an
Hive-Protocolheader into(major, minor). - protocol_
compatible - Whether a peer’s
Hive-Protocolheader is compatible with this crate. - protocol_
header_ value Hive-Protocolvalue this crate speaks.- signing_
input domain || canonical_json(value): the exact bytes an Ed25519 key signs.- signing_
input_ without_ signature - Signing input of an object that carries its own
signaturefield: the canonical form of the object without that field. - validate_
origin - Validate an origin:
https://host[:port], orhttp://for localhost/127.0.0.1/[::1]; no path, query, credentials or trailing slash. - validate_
vault_ id - Validate a Hive
vault_id: 32 lowercase hex characters (128 random bits), the same formleanctx.cloud-metrics/v1requires ofvault.id. The engine API renders the vault UUID in simple form (no dashes) while the web API keeps hyphenated UUIDs.