Auto-version and Release / release (push) Failing after 8s
CI Pipeline / best-practices (push) Successful in 8s
CI Pipeline / documentation (push) Successful in 4s
CI Pipeline / canary (push) Successful in 33s
CI Pipeline / lint (push) Successful in 44s
CI Pipeline / type-check (push) Successful in 31s
CI Pipeline / gitea-offline (push) Successful in 17s
CI Pipeline / unit-tests (push) Successful in 1m0s
CI Pipeline / required-checks (push) Successful in 1s
deploy / deploy (push) Successful in 38s
- tests/test_recall_mode_regression.py: deterministic fixture proving association-merged entries carry mode=association_merged (fails on old impl). #314 closed FIXED_VERIFIED. - scripts/gitea_auth.py: canonical Gitea API auth helper (GITEA_TOKEN env or git credential fill, never remote URL parsing) - tests/test_task_lifecycle.py: fault injection at route/model_selection/ execute boundaries — all terminalize, no immortal RUNNING - tests/test_route_isolation.py: task-scoped route instruction isolation - tests/test_release_convergence.py: correct target-version algorithm 1268 tests green; ratchet 352/80; henxels clean.
64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
"""#314 regression: recall_with_associations MUST include mode on
|
|
association-merged entries. This test FAILS on the old implementation."""
|
|
import os
|
|
import sqlite3
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
PKG_ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(PKG_ROOT / "src"))
|
|
|
|
from rune import memory_store # noqa: E402
|
|
|
|
|
|
class TestRecallAssociationsMode(unittest.TestCase):
|
|
"""Forced regression: seeded store, association edge, recall expansion,
|
|
assertion that association-merged entries carry mode."""
|
|
|
|
def _make_seeded_db(self):
|
|
"""Create a deterministic store with 2 entries + 1 association.
|
|
|
|
add_entry returns True, not the ID — use lastrowid from the db."""
|
|
db = memory_store.connect(":memory:")
|
|
memory_store.add_entry(
|
|
db, "the user prefers dark mode for all interfaces and dark UI themes",
|
|
memory_type="semantic", source="test")
|
|
memory_store.add_entry(
|
|
db, "the user strongly prefers dark blue color for all UI element backgrounds",
|
|
memory_type="semantic", source="test")
|
|
eid1 = db.execute("SELECT id FROM entries ORDER BY id LIMIT 1").fetchone()["id"]
|
|
eid2 = db.execute("SELECT id FROM entries ORDER BY id DESC LIMIT 1").fetchone()["id"]
|
|
db.execute(
|
|
"INSERT INTO associations (src_id, dst_id, strength, updated_at) VALUES (?, ?, ?, datetime('now'))",
|
|
(eid1, eid2, 0.9))
|
|
db.commit()
|
|
return db, eid1, eid2
|
|
|
|
def test_association_merged_entries_have_mode(self):
|
|
db, eid1, eid2 = self._make_seeded_db()
|
|
rows = memory_store.recall_with_associations(
|
|
db, "dark mode interface preferences", budget=8, min_score=0.0)
|
|
self.assertTrue(len(rows) >= 2, "need at least 2 results")
|
|
assoc_rows = [r for r in rows if r.get("via_association")]
|
|
self.assertTrue(len(assoc_rows) >= 1,
|
|
"at least one result must be association-merged")
|
|
for r in assoc_rows:
|
|
self.assertIn("mode", r, f"association-merged entry {r['id']} missing mode")
|
|
self.assertEqual(r["mode"], "association_merged",
|
|
f"unexpected mode value: {r['mode']}")
|
|
|
|
def test_base_recall_mode_intact(self):
|
|
db, eid1, eid2 = self._make_seeded_db()
|
|
rows = memory_store.recall(db, "dark mode", budget=4, min_score=0.0)
|
|
base_rows = [r for r in rows if not r.get("via_association")]
|
|
self.assertTrue(len(base_rows) > 0, "need at least one base result")
|
|
for r in base_rows:
|
|
self.assertIn("mode", r, f"base entry {r['id']} missing mode")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|