orchestrata_ultimate.knowledge_graph.context_pack
Reference › orchestrata_ultimate › knowledge_graph › context_pack › init
The facade of the deterministic context selector and packer (SPEC-106 FR-002, FR-003 and FR-004). Its docstring records the ruling constraint D11: the LLM never drives node selection, so the same request against the same graph state produces a byte-identical pack. The documented flow is four calls, analyze_request, select, pack and render, from frame, selector and packer. The module defines no classes or functions of its own; context_injector and a benchmark script import it. See the package page.
At a glance
| Source | src/orchestrata_ultimate/knowledge_graph/context_pack/__init__.py |
| Lines of code | 70 |
| Classes | 0 |
| Functions | 0 |
| Imports (internal) | orchestrata_ultimate.knowledge_graph.context_pack.cache, orchestrata_ultimate.knowledge_graph.context_pack.frame, orchestrata_ultimate.knowledge_graph.context_pack.packer, orchestrata_ultimate.knowledge_graph.context_pack.selector |
| Imported by | orchestrata_ultimate.knowledge_graph.context_injector, scripts.benchmark_context_pack, scripts.context_pack |
| Tests that import it | tests/knowledge_graph/context_pack/test_relevance.py, tests/knowledge_graph/test_context_pack_performance.py |
Class diagram
No classes; see Functions.
Dependency diagram
API
No public API: the module defines no classes, functions or constants.
Source
"""Deterministic context selector + packer (SPEC-106 FR-002/FR-003/FR-004).
D11 (plans/decisions-2026-07-06.md) is the ruling constraint this whole
subpackage exists to satisfy: the LLM never drives node selection. Given the
same request and the same graph state, this pipeline produces a
byte-identical pack::
from orchestrata_ultimate.knowledge_graph.context_pack import (
analyze_request, select, pack, render,
)
frame = analyze_request(
"refactor PolicyEngine", repo=repo, budget=2000, requester="agent"
)
subgraph = select(frame, repo)
context_pack = pack(subgraph, frame)
body = render(context_pack)
``analyze_request`` (frame.py, FR-002) links request text/payload to
canonical graph entities and classifies a task type — no LLM calls.
``select`` (selector.py, FR-003) expands a k-hop-bounded, per-task-type
subgraph rooted at those entities and ranks it from graph signals only.
``pack``/``render``/``parse``/``validate_pack`` (packer.py, FR-004) greedily
fit the ranked subgraph into an explicit token budget and render/recover the
editable markdown-with-YAML-frontmatter pack file.
"""
from orchestrata_ultimate.knowledge_graph.context_pack.cache import (
ContextPackCache,
)
from orchestrata_ultimate.knowledge_graph.context_pack.frame import (
LinkedEntity,
RequestFrame,
analyze_request,
)
from orchestrata_ultimate.knowledge_graph.context_pack.packer import (
ContextPack,
PackSection,
ParsedPack,
ParsedSection,
empty_pack,
pack,
parse,
render,
validate_pack,
)
from orchestrata_ultimate.knowledge_graph.context_pack.selector import (
RankedNode,
RankedSubgraph,
select,
)
__all__ = [
"LinkedEntity",
"RequestFrame",
"analyze_request",
"ContextPack",
"ContextPackCache",
"PackSection",
"ParsedPack",
"ParsedSection",
"empty_pack",
"pack",
"parse",
"render",
"validate_pack",
"RankedNode",
"RankedSubgraph",
"select",
]