From 0beaac2133451afa68c90348e07ec3cda8798fd9 Mon Sep 17 00:00:00 2001 From: Tim Evans Date: Mon, 27 Jul 2026 14:09:16 +0100 Subject: [PATCH] Loosen surfacing governance defaults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Local tuning — recall was too quiet in practice. After one surface the old defaults required 10 further messages AND 300s before another, so a second relevant memory almost never appeared in a working session. threshold 0.30 -> 0.25 max_surfaces_per_session 5 -> 12 min_messages_between 10 -> 2 cooldown_seconds 300 -> 30 test_first_surface_ignores_spacing now passes an explicit config, so it exercises the spacing mechanism rather than tracking whatever the defaults happen to be. The value pin is updated to match. Not for upstream — keep off fix/passport-traits-email. Co-Authored-By: Claude Opus 5 --- .../memory/apps/handlers/governance/engine.py | 8 ++++---- src/aipass/memory/tests/test_governance.py | 17 ++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/aipass/memory/apps/handlers/governance/engine.py b/src/aipass/memory/apps/handlers/governance/engine.py index 000482ed..31945af9 100644 --- a/src/aipass/memory/apps/handlers/governance/engine.py +++ b/src/aipass/memory/apps/handlers/governance/engine.py @@ -26,10 +26,10 @@ from aipass.memory.apps.handlers.json import json_handler DEFAULT_CONFIG: Dict[str, Any] = { "enabled": True, - "threshold": 0.3, - "max_surfaces_per_session": 5, - "min_messages_between": 10, - "cooldown_seconds": 300, + "threshold": 0.25, + "max_surfaces_per_session": 12, + "min_messages_between": 2, + "cooldown_seconds": 30, } diff --git a/src/aipass/memory/tests/test_governance.py b/src/aipass/memory/tests/test_governance.py index 9b97c62f..81b611e6 100644 --- a/src/aipass/memory/tests/test_governance.py +++ b/src/aipass/memory/tests/test_governance.py @@ -142,20 +142,23 @@ class TestShouldSurfaceHappy: def test_first_surface_ignores_spacing(self): """Fresh session: first prompt with high relevance surfaces immediately.""" + # Explicit config: this exercises the spacing mechanism, so it must not + # move whenever DEFAULT_CONFIG is retuned. + cfg = {"min_messages_between": 10, "cooldown_seconds": 300} state = new_state() state["messages_since_last"] = 1 - ok, reason, updated = should_surface("compass-1", 0.8, state, current_time=100.0) + ok, reason, updated = should_surface("compass-1", 0.8, state, cfg, current_time=100.0) assert ok is True assert "ready" in reason.lower() for i in range(9): updated = record_message(updated) - ok, reason, _ = should_surface("compass-2", 0.8, updated, current_time=100.0 + 400 + i) + ok, reason, _ = should_surface("compass-2", 0.8, updated, cfg, current_time=100.0 + 400 + i) assert ok is False assert "spacing" in reason.lower() updated = record_message(updated) - ok, _, _ = should_surface("compass-2", 0.8, updated, current_time=600.0) + ok, _, _ = should_surface("compass-2", 0.8, updated, cfg, current_time=600.0) assert ok is True @@ -246,7 +249,7 @@ class TestConfigMerging: assert "threshold" in reason.lower() def test_default_config_values_match(self): - assert DEFAULT_CONFIG["threshold"] == 0.3 - assert DEFAULT_CONFIG["max_surfaces_per_session"] == 5 - assert DEFAULT_CONFIG["min_messages_between"] == 10 - assert DEFAULT_CONFIG["cooldown_seconds"] == 300 + assert DEFAULT_CONFIG["threshold"] == 0.25 + assert DEFAULT_CONFIG["max_surfaces_per_session"] == 12 + assert DEFAULT_CONFIG["min_messages_between"] == 2 + assert DEFAULT_CONFIG["cooldown_seconds"] == 30