Skip to content

Commit 84f6776

Browse files
committed
chore(imi): sync graph state and format tests
1 parent 0c86ef0 commit 84f6776

6 files changed

Lines changed: 74 additions & 43 deletions

File tree

imi_memory.graph.json

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,24 +4325,41 @@
43254325
"edge_type": "causal",
43264326
"weight": 0.7758483290672302,
43274327
"label": "auto-detected (cos=0.78)"
4328+
},
4329+
{
4330+
"source_id": "6d68dad6c477",
4331+
"target_id": "intent_f2a35a75",
4332+
"edge_type": "causal",
4333+
"weight": 1.0,
4334+
"label": "fulfills"
4335+
},
4336+
{
4337+
"source_id": "intent_f2a35a75",
4338+
"target_id": "6d68dad6c477",
4339+
"edge_type": "causal",
4340+
"weight": 1.0,
4341+
"label": "fulfills"
4342+
},
4343+
{
4344+
"source_id": "302a4d0e96ee",
4345+
"target_id": "3d3364c4b2da",
4346+
"edge_type": "causal",
4347+
"weight": 0.7812060117721558,
4348+
"label": "auto-detected (cos=0.78)"
4349+
},
4350+
{
4351+
"source_id": "3d3364c4b2da",
4352+
"target_id": "302a4d0e96ee",
4353+
"edge_type": "causal",
4354+
"weight": 0.7812060117721558,
4355+
"label": "auto-detected (cos=0.78)"
43284356
}
43294357
],
43304358
"reconsolidation_log": [],
43314359
"annealing": {
4332-
"iteration": 112,
4333-
"temperature": 0.003367597566851453,
4360+
"iteration": 123,
4361+
"temperature": 0.0019154898067750877,
43344362
"energy_history": [
4335-
83900.46388707779,
4336-
83341.98683752389,
4337-
81418.72307862318,
4338-
82600.26525115717,
4339-
81995.15464549146,
4340-
81080.57671459673,
4341-
80294.38160583166,
4342-
79586.97837370969,
4343-
79537.06860552181,
4344-
80280.02219088754,
4345-
81061.88165631486,
43464363
81574.51204881578,
43474364
80959.16982344395,
43484365
80137.98979541461,
@@ -4381,7 +4398,18 @@
43814398
76221.2037821686,
43824399
77394.22769265148,
43834400
76233.06308110128,
4384-
76144.97319200187
4401+
76144.97319200187,
4402+
78245.47000167651,
4403+
79690.29457717849,
4404+
79405.7609880386,
4405+
73628.75460003095,
4406+
73151.73853221866,
4407+
75207.81813950994,
4408+
74862.5956624744,
4409+
74593.91183199547,
4410+
75261.65635748084,
4411+
75323.25993466885,
4412+
74801.27313590187
43854413
],
43864414
"converged": false
43874415
}

tests/test_fcm_bridge.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
import json
1010
import os
11-
import shutil
12-
from datetime import datetime, timezone
13-
from pathlib import Path
11+
from datetime import datetime
1412
from types import SimpleNamespace
1513

1614
import pytest
@@ -251,7 +249,7 @@ def test_unknown_trust_defaults_to_0_3(self, tmp_path):
251249
class TestEchoPrevention:
252250
def test_poll_ignores_own_source_events(self, tmp_path):
253251
"""poll_clawvault_events should skip events from the bridge's own source."""
254-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
252+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
255253

256254
bridge = FCMBridge(source="imi")
257255

@@ -274,7 +272,7 @@ def test_poll_ignores_own_source_events(self, tmp_path):
274272

275273
def test_poll_accepts_clawvault_source(self, tmp_path):
276274
"""poll_clawvault_events should accept events from source=clawvault."""
277-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
275+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
278276

279277
bridge = FCMBridge(source="imi")
280278

@@ -297,7 +295,7 @@ def test_poll_accepts_clawvault_source(self, tmp_path):
297295

298296
def test_poll_rejects_non_clawvault_non_self(self, tmp_path):
299297
"""poll_clawvault_events only accepts source=clawvault."""
300-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
298+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
301299

302300
bridge = FCMBridge(source="imi")
303301

@@ -323,7 +321,7 @@ def test_poll_rejects_non_clawvault_non_self(self, tmp_path):
323321

324322
class TestLoopPrevention:
325323
def test_poll_skips_events_with_federated_tag(self, tmp_path):
326-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
324+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
327325

328326
bridge = FCMBridge(source="imi")
329327

@@ -344,7 +342,7 @@ def test_poll_skips_events_with_federated_tag(self, tmp_path):
344342
assert len(events) == 0
345343

346344
def test_poll_skips_events_with_from_imi_tag(self, tmp_path):
347-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
345+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
348346

349347
bridge = FCMBridge(source="imi")
350348

@@ -365,7 +363,7 @@ def test_poll_skips_events_with_from_imi_tag(self, tmp_path):
365363
assert len(events) == 0
366364

367365
def test_poll_skips_from_clawvault_tag(self, tmp_path):
368-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
366+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
369367

370368
bridge = FCMBridge(source="imi")
371369

@@ -386,7 +384,7 @@ def test_poll_skips_from_clawvault_tag(self, tmp_path):
386384
assert len(events) == 0
387385

388386
def test_poll_skips_from_external_tag(self, tmp_path):
389-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
387+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
390388

391389
bridge = FCMBridge(source="imi")
392390

@@ -412,7 +410,7 @@ def test_poll_skips_from_external_tag(self, tmp_path):
412410

413411
class TestMarkConsumed:
414412
def test_moves_file_to_processed(self, tmp_path):
415-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR, FCM_PROCESSED_DIR
413+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCM_PROCESSED_DIR, FCMBridge
416414

417415
bridge = FCMBridge(source="imi")
418416

@@ -429,7 +427,7 @@ def test_moves_file_to_processed(self, tmp_path):
429427
assert (FCM_PROCESSED_DIR / "consume_test.json").exists()
430428

431429
def test_tracks_consumed_id(self, tmp_path):
432-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
430+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
433431

434432
bridge = FCMBridge(source="imi")
435433

@@ -445,7 +443,7 @@ def test_tracks_consumed_id(self, tmp_path):
445443
assert "consume-test-2" in bridge._consumed_ids
446444

447445
def test_consumed_events_skipped_in_poll(self, tmp_path):
448-
from imi.integrations.fcm_bridge import FCMBridge, FCM_EVENTS_DIR
446+
from imi.integrations.fcm_bridge import FCM_EVENTS_DIR, FCMBridge
449447

450448
bridge = FCMBridge(source="imi")
451449

tests/test_graph_adaptive.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from __future__ import annotations
44

55
import numpy as np
6-
import pytest
76

87
from imi.adaptive import AdaptiveRW, QueryIntent
9-
from imi.causal import detect_causal_candidates, auto_link_causal
10-
from imi.graph import Edge, EdgeType, MemoryGraph
8+
from imi.causal import auto_link_causal, detect_causal_candidates
9+
from imi.graph import EdgeType, MemoryGraph
1110
from imi.node import MemoryNode
1211
from imi.store import VectorStore
1312

tests/test_mcp_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"""Tests for the MCP server tools."""
22

33
import json
4-
import pytest
4+
55
import numpy as np
6+
import pytest
67

78
import imi.mcp_server as mcp_mod
8-
from imi.space import IMISpace
99
from imi.mcp_server import (
10+
im_drm,
1011
im_enc,
12+
im_glnk,
1113
im_nav,
12-
im_drm,
1314
im_sact,
1415
im_sts,
15-
im_glnk,
1616
)
17+
from imi.space import IMISpace
1718

1819

1920
class DummyEmbedder:

tests/test_storage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55

66
from __future__ import annotations
77

8-
import json
98
import time
109

1110
import numpy as np
1211
import pytest
1312

14-
from imi.events import ENCODE, CONSOLIDATE, MemoryEvent
13+
from imi.events import CONSOLIDATE, ENCODE, MemoryEvent
1514
from imi.graph import EdgeType
1615
from imi.node import MemoryNode
1716
from imi.reconsolidate import ReconsolidationEvent
1817
from imi.space import IMISpace
1918
from imi.storage import JSONBackend, SQLiteBackend
2019
from imi.temporal import TemporalContext
2120

22-
2321
# ---------------------------------------------------------------------------
2422
# Helpers
2523
# ---------------------------------------------------------------------------

tests/test_tiering.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""Tests for L0-L3 tiering."""
2-
import pytest
3-
import time
42
import numpy as np
5-
from imi.node import MemoryNode
3+
64
from imi.affect import AffectiveTag
75
from imi.affordance import Affordance
6+
from imi.node import MemoryNode
87
from imi.tiering import (
9-
L0Identity, L1HotFacts, generate_l1, compute_tier,
10-
apply_tiering, get_tier_stats,
8+
L0Identity,
9+
apply_tiering,
10+
compute_tier,
11+
generate_l1,
12+
get_tier_stats,
1113
)
1214

1315

@@ -92,7 +94,12 @@ def test_channel_weights_boost(self):
9294
assert l1.facts[0]["tags"][0] == "channel_a"
9395

9496
def test_affordances_extraction(self):
95-
aff = Affordance(action="deploy service", confidence=0.95, conditions="when tests pass", domain="ops")
97+
aff = Affordance(
98+
action="deploy service",
99+
confidence=0.95,
100+
conditions="when tests pass",
101+
domain="ops",
102+
)
96103
nodes = [_make_node("deploy decision", salience=0.8, affordances=[aff])]
97104
l1 = generate_l1(nodes)
98105
assert len(l1.affordances) >= 1

0 commit comments

Comments
 (0)