mixle.experimental.typed_runtime.graph_memory module

Partitioned, version-checked, bounded cache for revisitable context graphs.

class CachedGraphPartition(partition, content_hash, graph_version, measured_token_count, boundary_edge_ids, pinned=False)[source]

Bases: object

Partition content fingerprint captured at cache insertion.

Parameters:
  • partition (GraphPartition)

  • content_hash (str)

  • graph_version (int)

  • measured_token_count (int)

  • boundary_edge_ids (tuple[str, ...])

  • pinned (bool)

class GraphMemoryCache(*, maximum_tokens, maximum_partitions)[source]

Bases: object

LRU partition cache bounded by both tokens and partition count.

Parameters:
  • maximum_tokens (int)

  • maximum_partitions (int)

property resident_tokens: int

Total tokens in resident partitions.

get(partition_id, graph)[source]

Return a current partition, dropping stale content fingerprints.

Parameters:
  • partition_id (str)

  • graph (ContextGraph)

Return type:

CachedGraphPartition | None

put(partition, graph, *, pinned=False)[source]

Insert/refresh one partition and return evicted ids.

Parameters:
  • partition (GraphPartition)

  • graph (ContextGraph)

  • pinned (bool)

Return type:

tuple[str, …]

prefetch(plan, graph, partition_ids)[source]

Load requested partitions in order under LRU bounds.

Parameters:
  • plan (GraphPartitionPlan)

  • graph (ContextGraph)

  • partition_ids (tuple[str, ...])

Return type:

GraphPrefetchReceipt

as_dict()[source]

Return resident cache metadata in LRU order.

Return type:

dict[str, Any]

class GraphPartition(partition_id, node_ids, token_count, source_ids)[source]

Bases: object

Bounded graph region and its source-locality metadata.

Parameters:
as_dict()[source]

Return a JSON-compatible partition descriptor.

Return type:

dict[str, Any]

class GraphPartitionPlan(partitions, boundary_edge_ids)[source]

Bases: object

Complete node ownership and cross-partition edge list.

Parameters:
  • partitions (tuple[GraphPartition, ...])

  • boundary_edge_ids (tuple[str, ...])

partition(partition_id)[source]

Return a partition by id.

Parameters:

partition_id (str)

Return type:

GraphPartition

owner(node_id)[source]

Return the unique partition that owns a node.

Parameters:

node_id (str)

Return type:

str

as_dict()[source]

Return a JSON-compatible partition plan.

Return type:

dict[str, Any]

class GraphPrefetchReceipt(requested, loaded, evicted, resident_tokens, resident_before=None)[source]

Bases: object

Requested, loaded, and evicted partition ids for one prefetch.

Parameters:
property eviction_claim_verified: bool

Whether this receipt’s eviction claim was checked against real residency.

A machine-readable verdict rather than an inference from a field being None (MXR-080-0643). False means the receipt was built without resident_before, so its eviction list is an assertion nothing was able to test – the cache’s own producer always supplies it, so a receipt that reports False did not come from a prefetch.

as_dict()[source]

Return a JSON-compatible prefetch receipt.

Return type:

dict[str, Any]

partition_context_graph(graph, *, maximum_tokens, maximum_nodes)[source]

Greedily partition connected/source-local regions under hard bounds.

Parameters:
  • graph (ContextGraph)

  • maximum_tokens (int)

  • maximum_nodes (int)

Return type:

GraphPartitionPlan