feat: merge_aliases() + OMPU_BUS_ALIASES — fixes phantom negative z-scores from agent name evolution
This commit is contained in:
parent
a8b6b08fcc
commit
105fe5857e
|
|
@ -520,3 +520,44 @@ if __name__ == "__main__":
|
||||||
shadow = " [SHADOW]" if ns.is_shadow else ""
|
shadow = " [SHADOW]" if ns.is_shadow else ""
|
||||||
print(f" {nid}: echo={ns.echo_coefficient:.4f}, "
|
print(f" {nid}: echo={ns.echo_coefficient:.4f}, "
|
||||||
f"sent={ns.total_sent}, recv={ns.total_received}{shadow}")
|
f"sent={ns.total_sent}, recv={ns.total_received}{shadow}")
|
||||||
|
|
||||||
|
|
||||||
|
# ── Agent-alias merging ──────────────────────────────────
|
||||||
|
# Agents that change names mid-corpus create phantom signals
|
||||||
|
# in temporal analysis. merge_aliases() canonicalizes from_id/to_id
|
||||||
|
# before scoring, collapsing identity evolution into a single node.
|
||||||
|
|
||||||
|
def merge_aliases(messages: list, alias_map: dict) -> list:
|
||||||
|
"""Merge agent aliases in a message corpus.
|
||||||
|
|
||||||
|
alias_map: {old_name: canonical_name, ...}
|
||||||
|
Returns new list with from_id/to_id replaced by canonical names.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
alias_map = {
|
||||||
|
'petrovich': 'petrovich-codex',
|
||||||
|
'hausmaster': 'φ-hausmaster',
|
||||||
|
'konstantин': 'кот-констант',
|
||||||
|
'кот-константин': 'кот-констант',
|
||||||
|
}
|
||||||
|
merged = merge_aliases(messages, alias_map)
|
||||||
|
"""
|
||||||
|
merged = []
|
||||||
|
for m in messages:
|
||||||
|
m2 = m.copy()
|
||||||
|
m2['from_id'] = alias_map.get(m2.get('from_id', ''), m2.get('from_id', ''))
|
||||||
|
m2['to_id'] = alias_map.get(m2.get('to_id', ''), m2.get('to_id', ''))
|
||||||
|
merged.append(m2)
|
||||||
|
return merged
|
||||||
|
|
||||||
|
|
||||||
|
# Default alias map for the OMPU bus corpus
|
||||||
|
OMPU_BUS_ALIASES = {
|
||||||
|
'petrovich': 'petrovich-codex',
|
||||||
|
'hausmaster': 'φ-hausmaster',
|
||||||
|
'phi': 'φ-hausmaster',
|
||||||
|
'phi_hausmaster': 'φ-hausmaster',
|
||||||
|
'phi-hausmaster': 'φ-hausmaster',
|
||||||
|
'константин': 'кот-констант',
|
||||||
|
'кот-константин': 'кот-констант',
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue