httk.store.db.layout

Versioned physical layout for httk.store.db.store.SqlStore.

Attributes

STORAGE_PROTOCOL_VERSION

The persisted SqlStore layout protocol implemented by this package.

METADATA_TABLE_NAME

Reserved key/value table holding the store protocol and entry declaration.

WRITE_PROFILE_VOCABULARY

Exceptions

StorageLayoutUpgradeRequiredError

A database does not exactly implement the current persisted store layout.

StoreUnderConstructionError

A new open found an interrupted empty-store bulk ingest.

Classes

EntryFamilyLayout

One immutable configured entry family and its concrete records.

StorageLayout

The immutable normalized entry declaration of an initialized store.

BackendFacts

Dialect capabilities used by the SQL storage protocol.

Functions

declaration_json(layout)

Serialize a normalized declaration in its exact deterministic persisted form.

backend_facts_for_dialect(dialect_name)

Resolve the hardcoded protocol facts for one supported dialect.

normalize_entry_records(entry_records)

Normalize a declaration and apply SQL physical-name validation.

expected_metadata(layout)

Return SQLAlchemy metadata for all protocol-owned tables of layout.

metadata_table_for(metadata)

Return the reserved protocol key/value table in metadata.

actual_schema_objects(connection)

Return application schema-object names mapped to their stable object kinds.

actual_table_names(connection)

Return application base-table names without SQLAlchemy reflection.

read_store_metadata(connection)

Read the marker values, or return None when no metadata table exists.

Module Contents

class httk.store.db.layout.EntryFamilyLayout[source]

One immutable configured entry family and its concrete records.

name: str
family: type
record_names: tuple[str, Ellipsis]
records: tuple[type, Ellipsis]
class httk.store.db.layout.StorageLayout[source]

The immutable normalized entry declaration of an initialized store.

protocol_version: str
families: tuple[EntryFamilyLayout, Ellipsis]
property entry_records: collections.abc.Mapping[type, tuple[type, Ellipsis]]

Configured family classes mapped to their ordered concrete record classes.

property declaration: collections.abc.Mapping[str, tuple[str, Ellipsis]]

Configured stable family names mapped to their ordered stable record names.

exception httk.store.db.layout.StorageLayoutUpgradeRequiredError(diff)[source]

Bases: RuntimeError

A database does not exactly implement the current persisted store layout.

diff is immutable and JSON-shaped. Its top-level keys are stable categories (currently protocol, declaration and schema), so a caller can present a precise upgrade diagnostic without parsing the human-readable exception message.

diff: collections.abc.Mapping[str, object]
httk.store.db.layout.declaration_json(layout)[source]

Serialize a normalized declaration in its exact deterministic persisted form.

httk.store.db.layout.STORAGE_PROTOCOL_VERSION: Final = 'v2.4.0'[source]

The persisted SqlStore layout protocol implemented by this package.

httk.store.db.layout.METADATA_TABLE_NAME: Final = '_httk_store_metadata'[source]

Reserved key/value table holding the store protocol and entry declaration.

httk.store.db.layout.WRITE_PROFILE_VOCABULARY: Final[source]
exception httk.store.db.layout.StoreUnderConstructionError[source]

Bases: RuntimeError

A new open found an interrupted empty-store bulk ingest.

Crash window for new SQLite/DuckDB opens: before the marker commits the old clean state remains accepted; after the marker and through ingest, finalize, or before marker clear the store is rejected; after clear it is accepted again. The marker is intentionally not a resume protocol.

ClickHouse marker residue is fail-closed: the default recovery is to drop the database and re-ingest. Clearing the marker is valid only after an operator has restored and verified the declared empty-store invariant.

class httk.store.db.layout.BackendFacts[source]

Dialect capabilities used by the SQL storage protocol.

transactional_ddl: bool[source]
transactional_dml: bool[source]
supports_sequences: bool[source]
atomic_upsert: bool[source]
serial_stage_format: Literal['sqlite', 'duckdb-attach', 'parquet'][source]
parallel_shard_format: Literal['sqlite', 'parquet'][source]
supports_deferred_finalize: bool[source]
supports_degraded: bool[source]
write_profiles: tuple[str, Ellipsis][source]
metadata_backend: Literal['table', 'keepermap'][source]
supports_incremental_save: bool[source]
system_catalog: Literal['sqlite', 'duckdb', 'clickhouse'][source]
stage_load: Literal['attach', 'duckdb-views', 'client-stream'][source]
finalize_map_maintenance: Literal['update', 'swap'][source]
supports_adhoc_indexes: bool[source]
httk.store.db.layout.backend_facts_for_dialect(dialect_name)[source]

Resolve the hardcoded protocol facts for one supported dialect.

httk.store.db.layout.normalize_entry_records(entry_records)[source]

Normalize a declaration and apply SQL physical-name validation.

httk.store.db.layout.expected_metadata(layout)[source]

Return SQLAlchemy metadata for all protocol-owned tables of layout.

httk.store.db.layout.metadata_table_for(metadata)[source]

Return the reserved protocol key/value table in metadata.

httk.store.db.layout.actual_schema_objects(connection)[source]

Return application schema-object names mapped to their stable object kinds.

The DuckDB SQLAlchemy inspector presently routes column inspection through a PostgreSQL catalogue relation DuckDB does not expose, so the whole layout path intentionally uses the dialect catalogues directly.

httk.store.db.layout.actual_table_names(connection)[source]

Return application base-table names without SQLAlchemy reflection.

httk.store.db.layout.read_store_metadata(connection)[source]

Read the marker values, or return None when no metadata table exists.