symfonic.agent.context.stratified¶
stratified ¶
StratifiedHMSContextManager -- full HMS body with inline hydration.
Maps to the pre-7.2 FrameworkConfig.jit_context=False path -- the
production deployment shape for shipping Jarvio post-7.0.13. The
strategy hydrates memory layers on every turn, then renders the full
HMS system prompt with the optional L0/L1/L2 stratigraphic wrap.
Byte-identity by delegation. Rather than copying ~250 lines of
hydration logic and ~200 lines of prompt-rendering logic out of
engine.py, the strategy receives the engine's existing private
methods as injected callables. The strategy is a pure orchestration
adapter; the byte-identity invariant is preserved by construction
because no logic was moved.
This deviates from design §5.2 ("body moves verbatim into a private helper inside the strategy") in favour of the safer delegation shape. The acceptance criterion -- byte-identical stratigraphic prompt output -- is preserved either way; the delegation path is the one that cannot silently regress.
StratifiedHMSContextManager ¶
StratifiedHMSContextManager(
*,
hydrate: Callable[..., Awaitable[HydratedMemory]],
resolve_tools: Callable[
..., Awaitable[list[str] | None]
],
build_prompt: Callable[..., Awaitable[str | None]],
read_strat_overrides: Callable[[], dict[str, Any]],
enable_hms_prompt: bool,
)
Full-HMS strategy with inline hydration.
Constructor takes two injected callables:
hydrate(query, scope, intent_verdict) -> HydratedMemory-- bound to the engine's existing_hydratemethod which already fireson_hydration_completeframework hooks (preserves the Phase 4 OTel emit-site behaviour).build_prompt(scope, memory_context, active_tools, prospective_tasks, activation_log, query) -> str | None-- bound to the engine's existing_build_hms_system_promptmethod which honours the stratigraphic L0/L1/L2 wrap and stashesbrain_prompt_version/system_prompt_hashon the engine.
The third injected callable surfaces engine-side state that the
builder mutates: read_strat_overrides() -> dict[str, Any] reads
the per-call stratigraphic metadata after the builder returns and
moves it into AssembledContext.state_overrides -- replacing the
legacy _apply_strat_metadata_to_overrides side-channel pour.
Wire the strategy to engine-side helpers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hydrate
|
Callable[..., Awaitable[HydratedMemory]]
|
Async callable with signature
|
required |
resolve_tools
|
Callable[..., Awaitable[list[str] | None]]
|
Async callable resolving the per-turn
tool manifest. Bound to
:meth: |
required |
build_prompt
|
Callable[..., Awaitable[str | None]]
|
Async callable matching
:meth: |
required |
read_strat_overrides
|
Callable[[], dict[str, Any]]
|
Sync callable returning a dict of
|
required |
enable_hms_prompt
|
bool
|
Mirrors
:attr: |
required |
Source code in src/symfonic/agent/context/stratified.py
assemble
async
¶
assemble(
*,
query: str,
scope: FrameworkTenantScope | None,
intent_verdict: Any | None,
auto_hydrate: bool = True,
) -> AssembledContext
Hydrate memory, render the HMS prompt, return the bundle.
v7.7.8 (Jarvio 9th-recurrence): hydration gates on the explicit
auto_hydrate flag, NOT on scope is None. Pre-7.7.8 the
engine misused scope=None to signal "skip hydration" --
but that ALSO stripped tenant_id from the prompt template
(the L1 body rendered Tenant: unknown) AND from the
plugin-render state dict at engine.py:4397 / 4713. Result:
every adopter running auto_hydrate=False saw the L1
PRE-FLIGHT block silently degrade to empty -- even with
v7.7.6/v7.7.7 fixes in place -- because the active-skills
getter resolved a missing tenant. Same architectural class as
v7.6.4 / v7.7.1 / v7.7.3 / v7.7.6 / v7.7.7: a parallel control
flag misroutes a value the render path requires.