Skip to content

symfonic.memory.durability

durability

Node-class durability marker (v7.26.2 -- Shape C1).

Durability is an opt-in, cross-layer marker stored in MemoryNode.properties['durability']. It tells the sleep-consolidation pipeline whether a row is a durable fact about the world (promote freely), a transient state-bearing row (refuse promotion, age out fast), or an expired transient row (refuse promotion and prune on the next cleanup).

Zero schema migration: the marker lives entirely inside the existing properties dict, which all three graph backends already persist. Nodes without the key read as "durable" -- byte-identical to pre-v7.26.2 promotion behaviour.

Durability module-attribute

Durability = Literal['transient', 'durable', 'expired']

Cross-layer node durability marker.

  • "durable" -- default; promote freely (same as pre-v7.26.2).
  • "transient" -- write-time marker; refuse promotion, subject to a 1h TTL floor in Phase 8 cleanup.
  • "expired" -- runtime flip via upgrade_durability; refuse promotion AND mark for prune on the next Phase 8 run.

coerce_durability

coerce_durability(value: object) -> Durability

Coerce a raw value to a valid :data:Durability literal.

Empty / None coerces to "durable" (the safe default that preserves pre-v7.26.2 promotion behaviour). Unknown values raise :class:ValueError so that an adopter typo fails loud at write time rather than silently bypassing the consolidation gate.

Source code in src/symfonic/memory/durability.py
def coerce_durability(value: object) -> Durability:
    """Coerce a raw value to a valid :data:`Durability` literal.

    Empty / ``None`` coerces to ``"durable"`` (the safe default that
    preserves pre-v7.26.2 promotion behaviour).  Unknown values raise
    :class:`ValueError` so that an adopter typo fails loud at write time
    rather than silently bypassing the consolidation gate.
    """
    if value is None or value == "":
        return "durable"
    if isinstance(value, str) and value in _DURABILITY_VALUES:
        return value  # type: ignore[return-value]
    raise ValueError(
        f"Invalid durability {value!r}; must be one of "
        f"{sorted(_DURABILITY_VALUES)}",
    )