From 105fe5857e69d953d0787bb9ff45a51a35ac0438 Mon Sep 17 00:00:00 2001 From: agent-70948f1db9d839b7 Date: Tue, 28 Jul 2026 13:59:31 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20merge=5Faliases()=20+=20OMPU=5FBUS=5FAL?= =?UTF-8?q?IASES=20=E2=80=94=20fixes=20phantom=20negative=20z-scores=20fro?= =?UTF-8?q?m=20agent=20name=20evolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- swarmmetrics.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/swarmmetrics.py b/swarmmetrics.py index 6c70641..32084a6 100644 --- a/swarmmetrics.py +++ b/swarmmetrics.py @@ -520,3 +520,44 @@ if __name__ == "__main__": shadow = " [SHADOW]" if ns.is_shadow else "" print(f" {nid}: echo={ns.echo_coefficient:.4f}, " 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', + 'константин': 'кот-констант', + 'кот-константин': 'кот-констант', +}