Skip to content

symfonic.memory.backends.mongo_native_publication

mongo_native_publication

Strict vector publication for the private exact native receipt domain.

remember_strict async

remember_strict(domain, scope, recall, records: tuple) -> int

Reject foreign ownership before embedding; latch owned publication failure.

Source code in src/symfonic/memory/backends/mongo_native_publication.py
async def remember_strict(domain, scope, recall, records: tuple) -> int:
    """Reject foreign ownership before embedding; latch owned publication failure."""
    # An inherited child must not publish or poison the actual owner's body.
    domain._session_for_call()
    try:
        from symfonic.capabilities.memory.records import MemoryRecord
        from symfonic.capabilities.memory.vector_recall import VectorRecall

        domain._require_tenant(scope)
        if type(recall) is not VectorRecall or recall._vectors is not domain.vector:
            raise MongoSessionError("Native vector publication requires its exact recall backend")
        if type(records) is not tuple or not records:
            raise MongoSessionError("Native vector publication requires nonempty records")
        if any(type(record) is not MemoryRecord or record.scope.identity_version != 1
               or NativeStorageScope.from_scope(record.scope) != scope for record in records):
            raise MongoSessionError(
                "Native vector publication requires the exact full record scope"
            )
        count = await recall.remember(scope, records)
        if type(count) is not int or count != len(records):
            raise MongoSessionError("Native vector publication did not write every record")
        return count
    except BaseException:
        domain._vector_publication_failed = True
        raise