Read the exact committed manifest; UNKNOWN never adopts node IDs.
Historical receipts without a manifest remain unrecoverable. This does
not replay a mutation or infer an aborted reservation.
Source code in src/symfonic/memory/backends/postgres_receipt_write.py
| async def reconcile_write(self, operation: MemoryOperation) -> Any:
"""Read the exact committed manifest; UNKNOWN never adopts node IDs.
Historical receipts without a manifest remain unrecoverable. This does
not replay a mutation or infer an aborted reservation.
"""
from symfonic.memory.backends.postgres_operation_receipt import _exact
if (type(operation) is not MemoryOperation
or operation.verb is not MemoryOperationVerb.WRITE):
raise MemoryContractError("WRITE reconciliation requires an exact WRITE identity")
conn = await self.pool.acquire()
try:
row = await conn.fetchrow(
"SELECT * FROM memory_operation_receipts "
"WHERE tenant_id=$1 AND operation_id=$2",
operation.scope.tenant, operation.operation_id,
)
if (row is None or not _exact(row, operation) or row["state"] != "COMMITTED"
or row["write_manifest"] is None):
return None
document = row["write_manifest"]
manifest = SelectedRecordManifest.from_document(
json.loads(document) if isinstance(document, str) else document,
)
manifest.require_scope(operation.scope)
if any(claim.owner != operation.scope for claim in manifest.claims):
raise MemoryContractError("WRITE manifest owner mismatch")
return manifest
finally:
await self.pool.release(conn)
|