symfonic.capabilities.memory.bridge¶
bridge ¶
The HMS capability bridge: the only place memory touches an invocation.
Three seams, one per phase of the ladder that memory has any business in:
- prompt/input — :meth:
HmsBridge.hydratecalls the retrieval port and turns what it returns into one declared contribution. It registers as a stage inprompt-assemblythat must precede the prompt compiler's own, because a recall that arrives after the compile is a recall that is not in the prompt. - post-response — :meth:
HmsBridge.recordcalls the write port inpost-model, once the turn has something to remember. - finalize — :meth:
HmsBridge.closeflushes infinalize. Notteardown: that phase is kernel-owned (a capability that could inject into it could outlive a run it does not own), and the ladder already guaranteespost-modelprecedesfinalizewithout anyone declaring an edge.
The kernel never imports any of this. The bridge declares
:class:~symfonic.kernel.contracts.stages.StageDescriptor values and holds
ports; the concrete HMS arrives pre-bound from a composition root. That is the
whole "no kernel imports of memory implementations" requirement, and it is
checked by the architecture gate rather than asserted here.
Transport degrades, contracts propagate. A store that is down produces an
empty, degraded result and the turn continues; a store that is misconfigured
raises. The one exception is :class:~.errors.ScopeViolation, which propagates
from both paths — a tenant boundary crossing is not a degraded turn.
HmsBridge ¶
HmsBridge(*, retrieval: MemoryRetrievalPort, writes: MemoryWritePort, lifecycle: MemoryLifecyclePort, contribution_id: str = 'memory.recall', order: int = 0)
Binds the three memory ports to the three invocation seams.
Source code in src/symfonic/capabilities/memory/bridge.py
close
async
¶
Commit this invocation's pending memories.
Source code in src/symfonic/capabilities/memory/bridge.py
forget
async
¶
Erase a subtree. The privacy seam (SEC-PRIV), not an invocation stage.
Source code in src/symfonic/capabilities/memory/bridge.py
hydrate
async
¶
Retrieve for query and declare the result as one contribution.
Source code in src/symfonic/capabilities/memory/bridge.py
record
async
¶
Write what the turn produced, reporting failure rather than hiding it.
Source code in src/symfonic/capabilities/memory/bridge.py
stages ¶
The three stages this capability contributes, in ladder order.
hydration is optional because the ladder is knowable before a turn
runs — a plan can be compiled and inspected without retrieving anything.
When it is supplied, the retrieval stage carries what was hydrated in its
frozen config, which is how "this plan recalled these memories" stays
checkable from the plan alone.
Source code in src/symfonic/capabilities/memory/bridge.py
Hydration
dataclass
¶
Hydration(query: MemoryQuery, result: RetrievalResult, contribution: MemoryContribution, request: MemoryRequest)
One completed prompt/input pass: what was asked, found, and declared.