class documentation

class RenameMap:

View In Hierarchy

Identity correspondence derived by event-sourced op-log replay.

Despite the historical name, this value object no longer "folds renames": it is the product of replaying the whole op-log over the baseline to assign every entity a stable identity (see _replay_identities). It exposes exactly the identity correspondence the structural diff (ADR 0001) cannot infer from the two dict states alone — baseline name <-> current name, by identity — plus per-op-log-position resolution of an op's call-time names to the current name of whichever entity bore that name at the op's position.

Round-trips (A->B->A) collapse naturally (final name == baseline name => no entry) and recycles bind distinct identities (a recycled name's new identity has no baseline name => it is added, never matched to the original baseline entity).

Method class_current_name Return the current name of a class given its baseline identity.
Method property_current_name Return the current name of a property given its baseline identity.
Method resolve_class_at Resolve an op-log entry's call-time class name to its current name.
Method resolve_property_at Resolve an op-log entry's call-time (class, prop) to current names.
Instance Variable class_fate {baseline_class_name -> Optional[final_current_name]} for EVERY class that existed at baseline. None means the class's identity was ended (deleted) during the session, so a current class of the same name is a ...
Instance Variable classes {baseline_class_name -> current_class_name} for every class that survived to a different current name (genuine rename). A class born after baseline (no baseline name) never appears here.
Instance Variable entry_class_resolution Per op-log position, the final current name of whichever class bore that entry's call-time class_name at the entry's position (None if the class did not survive, or the entry carries no class name).
Instance Variable entry_prop_resolution Per op-log position, the (final_class_name, final_prop_name) of the property the entry's call-time (class_name, prop_name) referred to at its position (None if absent or not surviving).
Instance Variable prop_fate {(baseline_class_name, baseline_prop_name) -> Optional[final_current_name]} for every property that existed at baseline; None means its identity was deleted.
Instance Variable properties {(baseline_class_name, baseline_prop_name) -> current_prop_name} for every property that survived to a different current name. The key's class component is the owning class's baseline name, so a property rename stays correctly scoped even when its owning class was itself renamed.
def class_current_name(self, baseline_class_name: str) -> str:

Return the current name of a class given its baseline identity.

Parameters
baseline_class_name:strThe class name as it was at baseline.
Returns
strThe current class name, or baseline_class_name unchanged when the class was never renamed.
def property_current_name(self, baseline_class_name: str, baseline_prop_name: str) -> str:

Return the current name of a property given its baseline identity.

Parameters
baseline_class_name:strOwning class name as it was at baseline.
baseline_prop_name:strProperty name as it was at baseline.
Returns
strThe current property name, or baseline_prop_name unchanged when the property was never renamed.
def resolve_class_at(self, position: int, call_time_class_name: str) -> str:

Resolve an op-log entry's call-time class name to its current name.

Recycle-safe by construction: the resolution was captured by replaying the op-log, so an op issued under a name later freed and recycled by a different entity resolves to the entity that bore the name at the op's position. Falls back to the call-time name when the entry carries no recorded resolution (covers a class deleted later, or the no-rename case).

Parameters
position:intThe op-log entry's index in Schema._change_log.
call_time_class_name:strClass name as recorded in the op-log entry.
Returns
strThe class's final current name.
def resolve_property_at(self, position: int, call_time_class_name: str, call_time_prop_name: str) -> tuple[str, str]:

Resolve an op-log entry's call-time (class, prop) to current names.

Parameters
position:intThe op-log entry's index in Schema._change_log.
call_time_class_name:strOwning class name as recorded in the op-log.
call_time_prop_name:strProperty name as recorded in the op-log.
Returns
tuple[str, str](current_class_name, current_prop_name).
class_fate: dict[str, str | None] =

{baseline_class_name -> Optional[final_current_name]} for EVERY class that existed at baseline. None means the class's identity was ended (deleted) during the session, so a current class of the same name is a different identity (recycle), not this one. This is what lets the diff match by identity and never swallow a destructive delete behind a recycled name.

classes: dict[str, str] =

{baseline_class_name -> current_class_name} for every class that survived to a different current name (genuine rename). A class born after baseline (no baseline name) never appears here.

entry_class_resolution: list[str | None] =

Per op-log position, the final current name of whichever class bore that entry's call-time class_name at the entry's position (None if the class did not survive, or the entry carries no class name).

entry_prop_resolution: list[tuple[str, str] | None] =

Per op-log position, the (final_class_name, final_prop_name) of the property the entry's call-time (class_name, prop_name) referred to at its position (None if absent or not surviving).

prop_fate: dict[tuple[str, str], str | None] =

{(baseline_class_name, baseline_prop_name) -> Optional[final_current_name]} for every property that existed at baseline; None means its identity was deleted.

properties: dict[tuple[str, str], str] =

{(baseline_class_name, baseline_prop_name) -> current_prop_name} for every property that survived to a different current name. The key's class component is the owning class's baseline name, so a property rename stays correctly scoped even when its owning class was itself renamed.