Skip to main content
Version: latest

agrag.schema.stored.write_stored_schema

write_stored_schema(graph_store:GraphStore, schema:GraphSchema, *, expected_fingerprint:str | None = None) -> None

Publish schema as the graph's current schema.

The publication is a compare-and-swap against expected_fingerprint. A writer that observed a schema publishes only while that schema is still stored; a first publication passes no expected fingerprint and creates the singleton record. The id uniqueness constraint makes concurrent first publications and stale writers fail instead of leaving two records or overwriting a newer one.

Parameters:

  • graph_store (GraphStore) – The store that receives the record.
  • schema (GraphSchema) – The schema to store.
  • expected_fingerprint (str | None) – The fingerprint the writer observed, or None for a first publication.

Raises:

  • StaleSchemaError – The stored schema no longer matches what the writer expected, so the caller must reopen against the current schema.