| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import numpy as np |
| import pytest |
|
|
| from neuro_foundation import StepResult |
| from openclaw_hook import NeuroGraphMemory |
|
|
|
|
| @pytest.fixture |
| def ng(tmp_path): |
| """Real NeuroGraphMemory, isolated workspace per test, no singleton bleed.""" |
| return NeuroGraphMemory(workspace_dir=str(tmp_path)) |
|
|
|
|
| def _format(ng, surfaced_items): |
| """Exercise the REAL SurfacingMonitor.format_context() β no stand-ins.""" |
| return ng._surfacing_monitor.format_context(surfaced_items) |
|
|
|
|
| def test_renders_score_as_salience_two_decimals(ng): |
| |
| context = _format(ng, [{"node_id": "n1", "content": "a surfaced concept", "score": 1.23}]) |
|
|
| assert "(salience: 1.23)" in context |
| assert "- a surfaced concept (salience: 1.23)" in context |
|
|
|
|
| def test_contains_salience_and_neither_confidence_nor_percent(ng): |
| |
| context = _format(ng, [{"node_id": "n1", "content": "a surfaced concept", "score": 1.23}]) |
|
|
| assert "salience:" in context |
| assert "confidence:" not in context |
| assert "%" not in context |
|
|
|
|
| def test_above_one_salience_never_renders_as_percentage(ng): |
| |
| |
| context = _format(ng, [{"node_id": "n-hi", "content": "highly salient concept", "score": 1.80}]) |
|
|
| assert "(salience: 1.80)" in context |
| assert "180" not in context |
| assert "%" not in context |
|
|
|
|
| def test_full_after_step_path_renders_salience(ng): |
| |
| |
| |
| ng.graph.create_node(node_id="n-salience") |
| ng.vector_db.insert( |
| id="n-salience", |
| embedding=np.zeros(8), |
| content="a fired concept surfaced through the real path", |
| metadata={}, |
| ) |
| ng._surfacing_monitor.after_step(StepResult(fired_node_ids=["n-salience"])) |
|
|
| context = ng._surfacing_monitor.format_context() |
|
|
| assert "[NeuroGraph Surfaced Knowledge]" in context |
| assert "a fired concept surfaced through the real path" in context |
| assert "salience:" in context |
| assert "confidence:" not in context |
| assert "%" not in context |
|
|
|
|
| def test_empty_surfaced_items_still_returns_empty_string(ng): |
| |
| assert _format(ng, []) == "" |
|
|