Skip to content

symfonic.memory.backends.mongo_native_read

mongo_native_read

Private native read snapshot prerequisite; no public HMS/Agent admission.

arm_receipt_read_owner async

arm_receipt_read_owner(domain, scope, journal, owner, revision)

Private exact owner CAS inside a native read snapshot; no general writes.

Source code in src/symfonic/memory/backends/mongo_native_read.py
async def arm_receipt_read_owner(domain, scope, journal, owner, revision):
    """Private exact owner CAS inside a native read snapshot; no general writes."""
    from symfonic.capabilities.memory.operation_journal import InvocationOwner
    from symfonic.capabilities.memory.owner_verifier import OwnerVerified
    from symfonic.memory.backends.mongo_operation_journal import MongoOperationJournal
    from symfonic.memory.backends.mongo_session import MongoSessionError, _settle

    _owned_pair(domain.graph, domain.vector)
    session = domain._session_for_call()
    if (type(scope) is not NativeStorageScope or type(journal) is not MongoOperationJournal
            or type(owner) is not InvocationOwner
            or scope != NativeStorageScope.from_scope(owner.full_scope)
            or type(revision) is not int or revision < 0
            or not domain._read_only or session is None or domain._native_scope != scope
            or domain._receipt_database != journal._database
            or domain._client.address is None
            or domain._client.address != journal._client.address
            or journal._closed or journal._uncertain):
        raise MongoSessionError("Native receipt read owner refused")
    if type(await journal.verify_owner(owner, revision)) is not OwnerVerified:
        raise MongoSessionError("Native receipt read owner changed")
    expected = journal._owner_binding(owner, revision)
    result = await _settle(
        domain._client[domain._receipt_database]["__symfonic_invocation_journal"].update_one(
            {**expected, "completion": {"$exists": False}},
            {"$inc": {"read_guard": 1}},
            session=session,
        ),
    )
    if result.matched_count != 1:
        raise MongoSessionError("Native receipt read owner CAS lost")

read_snapshot_for

read_snapshot_for(graph, vector)

Private exact pair only; public read dispatch deliberately remains closed.

Source code in src/symfonic/memory/backends/mongo_native_read.py
def read_snapshot_for(graph, vector):
    """Private exact pair only; public read dispatch deliberately remains closed."""
    _owned_pair(graph, vector)
    return _NativeReadSnapshot(graph, vector)