symfonic.memory.orchestrator.orchestrator_writes¶
orchestrator_writes ¶
The orchestrator's write path: extract, commit, and upgrade durability.
Split out of :mod:symfonic.memory.orchestrator.orchestrator (307 lines
against the 300-line budget). MemoryOrchestrator has two halves that share
construction and nothing else: hydrate_context reads memory for a turn, and
the three methods here write what the turn produced -- extraction into
operations, dispatch of those operations onto their layers, and the
after-the-fact durability upgrade.
The class mixes this in, so MemoryOrchestrator.commit_pending and its
siblings are reached exactly as before.
OrchestratorWriteMixin ¶
Extraction, commit, and durability upgrade for MemoryOrchestrator.
Supplied by the host orchestrator; declared so the mixin's reads are typed.
commit_pending
async
¶
Apply pending operations to the appropriate layers.
Filters operations below the write_policy.min_importance_threshold before committing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
operations
|
list[MemoryOperation]
|
List of operations to apply. |
required |
Source code in src/symfonic/memory/orchestrator/orchestrator_writes.py
extract_memories
async
¶
extract_memories(scope: TenantScope, interaction: dict[str, Any], llm: Any, *, callback_manager: Any = None, run_id: str = '') -> list[MemoryOperation]
Extract structured memory operations from a conversation turn.
Uses the LLM to analyze the interaction and produce MemoryOperations for each memory layer as appropriate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
TenantScope
|
Tenant scope for isolation. |
required |
interaction
|
dict[str, Any]
|
Dict with 'user_message' and 'assistant_response'. |
required |
llm
|
Any
|
LLM instance for extraction. |
required |
callback_manager
|
Any
|
v7.4.3 (adopter Ask 5) -- forwarded to the
underlying |
None
|
run_id
|
str
|
Engine run identifier for callback correlation. |
''
|
Returns:
| Type | Description |
|---|---|
list[MemoryOperation]
|
List of MemoryOperations to be applied via commit_pending. |
Source code in src/symfonic/memory/orchestrator/orchestrator_writes.py
upgrade_durability
async
¶
Flip the durability marker on a stored graph node (v7.26.2).
The explicit promotion / retirement signal for the consolidation
gate. Typical use: write a transient row ("syncing..."), then once
the state stabilises write a durable row ("complete: 42 messages")
and call upgrade_durability(transient_id, "expired") so the
transient row is pruned on the next Phase 8 cleanup.
Implementation (Contract E, verified per-backend at T0): all three
graph backends' update_node either REPLACE the whole properties
dict (InMemory, Postgres) or route a top-level properties key to
a full $set (Mongo, after the v7.26.2 translation fix). A flat
durability key cannot be used because it collides with the
read-only MemoryNode.durability computed property. So this is a
read-modify-write: fetch the node, mutate the properties dict, write
the FULL dict back. This preserves every OTHER property on the node.
Raises:
| Type | Description |
|---|---|
ValueError
|
on an unknown durability literal (fail-loud). |
KeyError / backend error
|
when the node does not exist. |