Skip to content

symfonic.core.learning.durability_gate

durability_gate

Consolidation durability gate (v7.26.2 -- Shape C1).

Shared predicate used by the promotion phases (10/11/12) to refuse surfacing transient/expired rows, plus a lightweight counter object that carries the per-run rejection tally back to the ConsolidationReport.

Contract G ("no silent drops"): every rejection increments the counter AND emits a logger.info line carrying the rejecting phase + a stable entry identifier, so adopters can audit why a row was not consolidated.

DurabilityGate

DurabilityGate()

Mutable per-run rejection counter for the consolidation gate.

Source code in src/symfonic/core/learning/durability_gate.py
def __init__(self) -> None:
    self.rejected = 0

is_gated

is_gated(entry: Any, *, phase: str) -> bool

Return True when entry must be skipped by a promotion phase.

Increments :attr:rejected and emits a logger.info audit line on every rejection (Contract G).

Source code in src/symfonic/core/learning/durability_gate.py
def is_gated(self, entry: Any, *, phase: str) -> bool:
    """Return True when *entry* must be skipped by a promotion phase.

    Increments :attr:`rejected` and emits a ``logger.info`` audit line
    on every rejection (Contract G).
    """
    durability = entry_durability(entry)
    if durability in _GATED_VALUES:
        self.rejected += 1
        entry_id = getattr(entry, "id", None) or getattr(
            entry, "node_id", "?"
        )
        logger.info(
            "consolidation.transient_rejected phase=%s entry=%s "
            "durability=%s",
            phase, entry_id, durability,
        )
        return True
    return False

entry_durability

entry_durability(entry: Any) -> str

Read a durability marker from an episodic entry's metadata.

Episodic entries carry their properties under metadata (the orchestrator commit path copies node.properties -> MemoryEntry .metadata). Returns "durable" when no marker is present -- byte-identical to pre-v7.26.2 promotion behaviour.

Source code in src/symfonic/core/learning/durability_gate.py
def entry_durability(entry: Any) -> str:
    """Read a durability marker from an episodic entry's metadata.

    Episodic entries carry their properties under ``metadata`` (the
    orchestrator commit path copies ``node.properties`` -> ``MemoryEntry
    .metadata``).  Returns ``"durable"`` when no marker is present --
    byte-identical to pre-v7.26.2 promotion behaviour.
    """
    md = getattr(entry, "metadata", None) or {}
    raw = md.get("durability")
    if isinstance(raw, str) and raw in {"transient", "durable", "expired"}:
        return raw
    return "durable"