feat(7832): records reach an edit and a message by structure first; resemblance offers notes
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 12s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Failing after 1m39s
CI & Build / integration (push) Successful in 2m17s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 12s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Failing after 1m39s
CI & Build / integration (push) Successful in 2m17s
CI & Build / Build & push image (push) Skipped
The kind×moment table's first measured defaults (baseline note #7892): - The edit door splits in two rows. work.change is what is recorded where the edit is (snippets beside the file, issues naming it or open in its area); work.change.similar is what the code resembles, notes by default. Issues and snippets no longer reach an edit by resemblance. - Snippets recorded beside the file are named by id in an "Also recorded beside this file" pointer line instead of taking menu lines. - The message door leaves lessons and issues out by default: a lesson arrives at its confirmed situation, an issue through its area or its id. Its lesson slot runs only for a user who turns lessons back on. - The static context teaches the new pointer line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
Three decisions are guarded here, and each has a way of going quietly wrong
|
||||
that these tests are shaped to catch rather than to describe:
|
||||
|
||||
WHICH ARM. The two note arms, and no new one. An arm that FILTERS kinds does
|
||||
not merely outrank a kind it omits — it makes it unreachable, and nothing
|
||||
reports an arm that never had the candidate. The write path filters;
|
||||
the prompt menu does not, but is project-scoped, which for a kind whose whole
|
||||
claim is that it transfers amounts to the same silence.
|
||||
WHICH ARM. By default neither note arm offers a lesson by resemblance: a
|
||||
lesson reaches the work through the situation confirmed for it
|
||||
(`lesson_situations`). A user can turn lessons on at the message door in
|
||||
the record-kinds table, and then the prompt menu reserves a slot for one,
|
||||
looking beyond the bound project, since a lesson's claim is that it
|
||||
transfers. The slot tests below run as that user.
|
||||
|
||||
WHOSE BUDGET. A reserved slot in the prompt menu, none on the write path.
|
||||
The slot has to be falsifiable, so it logs under its own source from the
|
||||
@@ -21,6 +22,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from grimoire.services import plugin_context as pc
|
||||
from grimoire.services import record_kinds
|
||||
from grimoire.services.lessons import LESSON_NOTE_TYPE
|
||||
from tests.helpers import fake_lesson, fake_note, writepath_cfg
|
||||
|
||||
@@ -33,9 +35,14 @@ _CFG = {"enabled": True, "threshold": 0.55, "top_k": 3}
|
||||
_BINDING_PHRASE = "it binds"
|
||||
|
||||
|
||||
# A user who has turned every kind on at the message door, lessons included.
|
||||
EVERY_KIND = frozenset(record_kinds.KINDS)
|
||||
|
||||
|
||||
async def _menu(main_hits, *, lesson_hits=None, reuse_hits=None, cfg=None,
|
||||
exclude_ids=None, rec=None, surf=None):
|
||||
"""Run the prompt menu with each query stubbed by the kinds it asks for."""
|
||||
exclude_ids=None, rec=None, surf=None, kinds=EVERY_KIND):
|
||||
"""Run the prompt menu with each query stubbed by the kinds it asks for.
|
||||
`kinds` is the user's message door; None is the shipped default."""
|
||||
calls: list[dict] = []
|
||||
|
||||
async def fake_search(*_a, **kw):
|
||||
@@ -52,7 +59,10 @@ async def _menu(main_hits, *, lesson_hits=None, reuse_hits=None, cfg=None,
|
||||
patch.object(pc, "semantic_search_notes", AsyncMock(side_effect=fake_search)), \
|
||||
patch.object(pc, "record_retrieval", rec or MagicMock()), \
|
||||
patch.object(pc, "record_surfaced", surf or MagicMock()), \
|
||||
patch.object(pc, "owner_names_for", AsyncMock(return_value={})):
|
||||
patch.object(pc, "owner_names_for", AsyncMock(return_value={})), \
|
||||
patch.object(record_kinds, "kinds_for", AsyncMock(
|
||||
return_value=record_kinds.DOORS[record_kinds.MESSAGE].default
|
||||
if kinds is None else kinds)):
|
||||
out = await pc.build_autoinject_hint(
|
||||
1, "two overlapping badges on the card", project_id=2,
|
||||
exclude_ids=exclude_ids or [],
|
||||
@@ -83,12 +93,24 @@ async def test_the_prompt_menu_looks_beyond_the_bound_project_for_a_lesson():
|
||||
assert calls[0]["include_global_kinds"] is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_the_prompt_menu_leaves_lessons_to_their_situation_by_default():
|
||||
"""The shipped message door does not offer a lesson by resemblance: its
|
||||
search leaves lessons out and the reserved lesson slot does not run."""
|
||||
_out, calls = await _menu(
|
||||
[(0.70, fake_note(id=1, user_id=1))],
|
||||
lesson_hits=[(0.61, fake_lesson(id=42, user_id=1))], kinds=None,
|
||||
)
|
||||
assert LESSON_NOTE_TYPE not in calls[0]["record_kinds"]
|
||||
assert _query_for_lessons(calls) is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_the_write_path_leaves_lessons_to_their_situation():
|
||||
"""An edit's words resemble a lesson far more often than the edit is its
|
||||
situation, so the edit door's search by meaning leaves lessons out; a
|
||||
lesson reaches an edit through a situation confirmed for it
|
||||
(`lesson_situations`). The kinds the door does consider stay."""
|
||||
(`lesson_situations`). By default that search considers notes only."""
|
||||
search = AsyncMock(return_value=[])
|
||||
with patch.object(pc, "get_writepath_config",
|
||||
AsyncMock(return_value=writepath_cfg(threshold=0.6))), \
|
||||
@@ -101,8 +123,7 @@ async def test_the_write_path_leaves_lessons_to_their_situation():
|
||||
await pc.build_write_path_hint(1, "src/ui/Badge.vue", code="x" * 400)
|
||||
|
||||
kw = search.await_args.kwargs
|
||||
assert LESSON_NOTE_TYPE not in kw["record_kinds"]
|
||||
assert {"snippet", "note"} <= set(kw["record_kinds"])
|
||||
assert kw["record_kinds"] == ["note"]
|
||||
assert kw["include_global_kinds"] is True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user