Skip to content

symfonic.capabilities.memory.phases.deep_native_graph_port

deep_native_graph_port

Required atomic mutation seam for native DEEP graph maintenance.

A concrete deployment adapter must stage these operations in the active cycle journal and replay them under the same transaction as its other writes. The existing node JSON patch and generic edge upsert do not satisfy this contract.

NativeGraphMutationPort

NativeGraphMutationPort(graph: JournalledGraph, journal: CycleJournal)

Exact graph and journal binding plus two guarded operation contracts.

Source code in src/symfonic/capabilities/memory/phases/deep_native_graph_port.py
def __init__(self, graph: JournalledGraph, journal: CycleJournal) -> None:
    self.graph = graph
    self.journal = journal

guarded_cooccurrence async

guarded_cooccurrence(scope: NativeStorageScope, source: Any, target: Any, source_version: OwnedNodeVersion, target_version: OwnedNodeVersion, *, weight: float, max_degree: int) -> bool

Atomically guard endpoints, owner, degree, then insert/reinforce edge.

Existing CO_OCCURRED edges may be reinforced when degree is full. Return false if the degree cap prevents staging a new edge. At replay, a full degree skips that edge; stale endpoints or owner changes abort the receipt transaction. Existing edges can be reinforced at full degree.

Source code in src/symfonic/capabilities/memory/phases/deep_native_graph_port.py
async def guarded_cooccurrence(
    self, scope: NativeStorageScope, source: Any, target: Any,
    source_version: OwnedNodeVersion, target_version: OwnedNodeVersion,
    *, weight: float, max_degree: int,
) -> bool:
    """Atomically guard endpoints, owner, degree, then insert/reinforce edge.

    Existing CO_OCCURRED edges may be reinforced when degree is full.
    Return false if the degree cap prevents staging a new edge. At replay,
    a full degree skips that edge; stale endpoints or owner changes abort
    the receipt transaction. Existing edges can be reinforced at full degree.
    """
    raise NotImplementedError("journalled guarded edge adapter is required")

patch_importance async

patch_importance(scope: NativeStorageScope, node_id: Any, expected: OwnedNodeVersion, importance: float) -> bool

CAS exact owner, incarnation, revision; update only importance.

Source code in src/symfonic/capabilities/memory/phases/deep_native_graph_port.py
async def patch_importance(
    self, scope: NativeStorageScope, node_id: Any,
    expected: OwnedNodeVersion, importance: float,
) -> bool:
    """CAS exact owner, incarnation, revision; update only importance."""
    raise NotImplementedError("journalled importance CAS adapter is required")