Skip to content

symfonic.memory.backends.postgres_accepted_envelope

postgres_accepted_envelope

Fresh privately owned graph-only phase snapshot, sealed before QUICK reservation.

snapshot_graph_only

snapshot_graph_only(runtime, domain)

Share only the exact domain-owned PostgreSQL graph, never phase/store aliases.

Source code in src/symfonic/memory/backends/postgres_accepted_envelope.py
def snapshot_graph_only(runtime, domain):
    """Share only the exact domain-owned PostgreSQL graph, never phase/store aliases."""
    require_graph_only(runtime, domain)
    if (type(domain.graph) is not PostgresReceiptGraph
            or type(domain.graph._backend) is not PostgresGraphBackend
            or domain.graph._backend._pool is not domain.pool):
        raise MemoryContractError("graph-only envelope requires exact domain PostgreSQL graph")
    strengthen = runtime._phases["strengthen"]
    window = strengthen._window
    weight, lookback, kind = (strengthen._spreading_weight, window._lookback_hours,
                              window._session_kind)
    if (type(weight) not in (int, float) or not math.isfinite(weight)
            or type(lookback) not in (int, float) or not math.isfinite(lookback)
            or lookback < 0 or type(kind) is not str or not kind):
        raise MemoryContractError("graph-only snapshot parameters refused")
    phases = quick_phases(graph=domain.graph, exact_session_owner=True,
                          session_kind=kind, spreading_weight=weight, lookback_hours=lookback)
    from symfonic.capabilities.memory.schedule import ConsolidationCycle

    owned = ConsolidationRuntime(phases=phases, cycles=(ConsolidationCycle.QUICK,),
                                 participants=(domain.graph,))
    require_graph_only(owned, domain)
    return owned