orchestrata_ultimate.knowledge_graph.context_pack

Reference › orchestrata_ultimate › knowledge_graph › context_pack

Deterministic context selector + packer (SPEC-106 FR-002/FR-003/FR-004).

The context_pack subpackage builds the graph context that a volk receives for a task, and it does so deterministically: the governing ruling (D11) is that the LLM never drives node selection, so the same request against the same state of the operational graph (orchkg on orchgraph) yields a byte-identical pack. It is the SPEC-106 pipeline behind ContextInjector.inject_for_task in context_injector, part of the knowledge_graph package.

Data flows through three stages, each in its own module. frame (FR-002) turns request text or a payload into a RequestFrame: a task type, entities linked to canonical graph nodes, a token budget and a requester. selector (FR-003) runs a per-task-type Cypher template, bounded to a few hops, and ranks the nodes into a RankedSubgraph. packer (FR-004) fits the ranked nodes into the token budget and renders an editable markdown ContextPack with provenance per section. Two modules sit beside the chain: relevance (FR-006) optionally re-ranks the selection with Prolog rules, and cache keeps rendered packs for a short time within a run.

The public entry points are the functions analyze_request, select, pack, render, parse and validate_pack, re-exported conceptually by init. Start reading with __init__ for the four-call flow, then frame, selector and packer in order. The narrative for the whole package is on the knowledge_graph module page.

6 modules, 1,348 lines of code.

Modules

Module Summary LOC
__init__ Deterministic context selector + packer (SPEC-106 FR-002/FR-003/FR-004). 70
cache In-memory render cache for context packs. 108
frame Deterministic request-frame analysis (SPEC-106 FR-002). 283
packer Budgeted packing + the editable pack format (SPEC-106 FR-004). 317
relevance Symbolic (Prolog) relevance refinement of a selected subgraph (SPEC-106 FR-006). 266
selector Deterministic selection — per-task-type templates + graph-signal ranking (SPEC-106 FR-003). 304

Dependency diagram

Package dependency diagram orchestrata_ultimate.knowledge_graph.context_pack