Skip to content

symfonic.capabilities.memory.native_vector_publication

native_vector_publication

Owner-collision refusal before in-memory native graph publication.

publish_native_vectors async

publish_native_vectors(scope, pending, vectors, recall) -> bool

Batch native owners through the concrete backend's all-owner preflight.

This prevents partial publication on ownership refusal. It does not roll vectors back if a later graph update fails.

Source code in src/symfonic/capabilities/memory/native_vector_publication.py
async def publish_native_vectors(scope, pending, vectors, recall) -> bool:
    """Batch native owners through the concrete backend's all-owner preflight.

    This prevents partial publication on ownership refusal. It does not roll
    vectors back if a later graph update fails.
    """
    if not scope.identity_version or type(vectors) is not InMemoryVectorBackend:
        return False
    if pending:
        await recall.remember_owned(
            tuple(_adapter_scope(node_scope(node)) for node in pending),
            tuple(record_from_legacy_node(node_payload(node)) for node in pending))
    return True

remember_owned async

remember_owned(vectors, embedder, owners, records) -> int

Degrade unavailable vectors; propagate only explicit owner conflicts.

Source code in src/symfonic/capabilities/memory/native_vector_publication.py
async def remember_owned(vectors, embedder, owners, records) -> int:
    """Degrade unavailable vectors; propagate only explicit owner conflicts."""
    import logging

    from symfonic.capabilities.memory.vector_recall import vector_metadata
    from symfonic.memory.errors import VectorOwnershipConflict

    try:
        embeddings = await embedder.embed_batch([record.text for record in records])
        await vectors.add_owned_batch([
            (owner, record.record_id, embedding, vector_metadata(record), record.text)
            for owner, record, embedding in zip(owners, records, embeddings, strict=True)
        ])
    except VectorOwnershipConflict:
        raise
    except Exception:  # noqa: BLE001 - outages stay lexical
        logging.getLogger(__name__).warning(
            "vector write failed; recall stays lexical", exc_info=True)
        return 0
    return len(records)