CIE-Unified

git clone 

CIE-Unified / tests
codex@macbookpro  ·  2026-03-31

test_sedimentation.py

 1from __future__ import annotations
 2
 3import unittest
 4
 5from cie import CIERuntime
 6
 7
 8class RuntimeSedimentationTests(unittest.TestCase):
 9    def test_repeated_activation_creates_explicit_sedimentation_profiles(self) -> None:
10        runtime = CIERuntime(capacity_limit=10.0)
11        for _ in range(2):
12            runtime.ingest("alpha beta alpha", anchors="anchor")
13            runtime.step()
14        profile = runtime.state.sedimentation["alpha"]
15        snapshot = runtime.snapshot_state()
16        self.assertEqual(profile.stage, "skill_belt")
17        self.assertGreaterEqual(profile.activation_hits, 2)
18        self.assertGreater(profile.candidate_score, 1.0)
19        self.assertTrue(any(event["node"] == "alpha" for event in snapshot["sedimentation_trace"]))
20
21    def test_trace_progresses_from_memory_to_ability_core(self) -> None:
22        runtime = CIERuntime(capacity_limit=10.0)
23        for _ in range(4):
24            runtime.ingest("alpha beta alpha", anchors="anchor")
25            runtime.step()
26        alpha_events = [
27            event
28            for event in runtime.snapshot_state()["sedimentation_trace"]
29            if event["node"] == "alpha"
30        ]
31        self.assertEqual([event["to"] for event in alpha_events], ["experience", "skill_belt", "ability_core"])
32        self.assertEqual(runtime.state.sedimentation["alpha"].stage, "ability_core")
33
34    def test_skill_belt_candidates_and_merge_events_appear_under_repeated_use(self) -> None:
35        runtime = CIERuntime(capacity_limit=10.0)
36        for _ in range(4):
37            runtime.ingest("alpha beta alpha", anchors="anchor")
38            runtime.step()
39        snapshot = runtime.snapshot_state()
40        alpha_candidate = next(item for item in snapshot["skill_belt_candidates"] if item["node"] == "alpha")
41        self.assertIn(alpha_candidate["stage"], {"skill_belt", "ability_core"})
42        self.assertGreaterEqual(alpha_candidate["stable_steps"], 2)
43        self.assertTrue(snapshot["merge_events"])
44        self.assertTrue(any(event["node"] == "alpha" for event in snapshot["merge_events"]))
45        self.assertEqual(snapshot["experience_regions"][0]["region"], "alpha")
46
47    def test_decay_events_can_demote_sedimentation_state(self) -> None:
48        runtime = CIERuntime(capacity_limit=10.0)
49        for _ in range(4):
50            runtime.ingest("alpha beta alpha", anchors="anchor")
51            runtime.step()
52        runtime.reset_session()
53        runtime.step(6)
54        snapshot = runtime.snapshot_state()
55        alpha_events = [
56            event
57            for event in snapshot["sedimentation_trace"]
58            if event["node"] == "alpha" and event["direction"] == "demote"
59        ]
60        self.assertTrue(alpha_events)
61        self.assertTrue(any(event["kind"] == "sedimentation_demote" for event in snapshot["decay_events"]))
62        self.assertEqual(runtime.state.sedimentation["alpha"].stage, "memory")
63
64
65if __name__ == "__main__":
66    unittest.main()