httk.store.db.graph

Logical storage edges derived from the resolved schema declarations.

The SQL schema deliberately has more than one relationship shape. Keeping those relationships here makes the bulk algorithms independent of whether a backend happens to expose physical foreign-key constraints.

Attributes

Classes

LogicalEdge

One typed relationship in the logical storage graph.

LogicalEdgeGraph

Deterministic typed edges for a set of resolved table declarations.

Module Contents

httk.store.db.graph.EdgeKind[source]
class httk.store.db.graph.LogicalEdge[source]

One typed relationship in the logical storage graph.

source_table and target_table describe the traversal direction. source_column is the forward sid column for reference, child-element, and dispatch edges. Ownership is traversed from parent to child, so its parent sid column is carried as target_column on the child table.

kind: EdgeKind[source]
source_table: str[source]
target_table: str[source]
source_column: str | None = None[source]
target_column: str | None = None[source]
class httk.store.db.graph.LogicalEdgeGraph[source]

Deterministic typed edges for a set of resolved table declarations.

edges: tuple[LogicalEdge, Ellipsis][source]
tables: tuple[str, Ellipsis][source]
classmethod from_schemas(schemas, dispatches=())[source]

Build edges from parent schemas, recursively including their targets.

classmethod from_store(store, schemas)[source]

Build a graph using the store’s configured entry-family dispatches.

sid_columns()[source]

Return table -> (sid_column, referenced_table) mappings.

This is the compatibility view used by remapping and reachability code; it includes the parent column of ownership edges as well as the forward columns of the other edge kinds.

referrers(target_table)[source]

Return all (referrer_table, sid_column) pairs for a target.

ownership()[source]

Return parent-to-child ownership edges in deterministic order.

dependency_order(table_names=None)[source]

Return a deterministic dependency order, including cyclic schemas.

Reference and child-element dependencies are condensed into strongly connected components. The physical load order places referenced rows before referrers, parents before owned child rows, and backing rows before dispatch rows. Both component selection and members use the lexicographically smallest available table name as their tiebreaker.

reachability_scc_order()[source]

Return SCCs in forward logical-reachability order.

Unlike dependency_order(), this follows a reference from its source to its target and ownership from parent to child. Consumers propagating root reachability can therefore complete acyclic SCCs in one wave, reserving iteration for genuine cycles.