test: snapshot_idf vs corpus_idf + colluding-third — 23/23 (20 invariants + 3 known-defeats)
This commit is contained in:
parent
105fe5857e
commit
906eb26188
|
|
@ -408,6 +408,55 @@ def test_genuine_novel_concept_zero_echo():
|
||||||
# for concepts that have had time to propagate.
|
# for concepts that have had time to propagate.
|
||||||
|
|
||||||
|
|
||||||
|
def test_snapshot_idf_vs_corpus_idf():
|
||||||
|
"""snapshot_idf=True should compute IDF at emission time, not on full corpus.
|
||||||
|
|
||||||
|
Setup: alice introduces 'novel-x' at t=-5d, nobody else uses it until
|
||||||
|
charlie uses it at t=-1d. With corpus IDF, novel-x has IDF=log(N/2)
|
||||||
|
at scoring time because charlie used it too. With snapshot IDF,
|
||||||
|
novel-x has IDF=log(N/1) at emission time because charlie hadn't
|
||||||
|
used it yet.
|
||||||
|
|
||||||
|
Snapshot IDF should give HIGHER weight to novel-x because at the time
|
||||||
|
alice introduced it, it was used by only 1 agent (alice herself).
|
||||||
|
Corpus IDF gives lower weight because by the end, 2 agents used it.
|
||||||
|
|
||||||
|
This is ColonistOne's IDF endogeneity fix: the concept became common
|
||||||
|
BECAUSE it diffused, so post-hoc IDF penalizes successful diffusion."""
|
||||||
|
msgs = [
|
||||||
|
# alice introduces novel-x
|
||||||
|
{"from_id": "alice", "to_id": "bob",
|
||||||
|
"timestamp": now - 5*day, "concepts": ["novel-x"]},
|
||||||
|
# bob uses it back (echo)
|
||||||
|
{"from_id": "bob", "to_id": "charlie",
|
||||||
|
"timestamp": now - 4*day, "concepts": ["novel-x"]},
|
||||||
|
# charlie picks it up too (more echo for alice)
|
||||||
|
{"from_id": "charlie", "to_id": "dave",
|
||||||
|
"timestamp": now - 1*day, "concepts": ["novel-x"]},
|
||||||
|
# background noise
|
||||||
|
{"from_id": "dave", "to_id": "eve",
|
||||||
|
"timestamp": now - 0.5*day, "concepts": ["common-stuff"]},
|
||||||
|
{"from_id": "eve", "to_id": "frank",
|
||||||
|
"timestamp": now - 0.3*day, "concepts": ["common-stuff"]},
|
||||||
|
]
|
||||||
|
|
||||||
|
echo_corpus = score_echo(msgs, use_idf=True, snapshot_idf=False)
|
||||||
|
echo_snapshot = score_echo(msgs, use_idf=True, snapshot_idf=True)
|
||||||
|
|
||||||
|
alice_corpus = echo_corpus.get("alice", 0)
|
||||||
|
alice_snapshot = echo_snapshot.get("alice", 0)
|
||||||
|
|
||||||
|
# Snapshot should give alice higher or equal echo because at emission
|
||||||
|
# time, novel-x was rarer (only alice had used it)
|
||||||
|
assert alice_snapshot >= alice_corpus, \
|
||||||
|
f"Snapshot IDF should give >= corpus IDF for novel concepts: " \
|
||||||
|
f"snapshot={alice_snapshot:.4f}, corpus={alice_corpus:.4f}"
|
||||||
|
|
||||||
|
# Both should be positive (concept did propagate)
|
||||||
|
assert alice_corpus > 0, f"Alice should have positive echo (corpus): {alice_corpus}"
|
||||||
|
assert alice_snapshot > 0, f"Alice should have positive echo (snapshot): {alice_snapshot}"
|
||||||
|
|
||||||
|
|
||||||
def test_colluding_third_party_echo():
|
def test_colluding_third_party_echo():
|
||||||
"""Adversarial case #3 (Atomic Raven, Colony 2026-07-28): three agents
|
"""Adversarial case #3 (Atomic Raven, Colony 2026-07-28): three agents
|
||||||
in a trench coat manufacturing echo.
|
in a trench coat manufacturing echo.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue