feat(7833): each moment declares which kinds of record its search may consider, editable in Settings > Moments
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 1m35s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 1m35s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Build & push image (push) Skipped
The kind x moment table (services/record_kinds.py): - every record search fires at a door: the operator message, or a catalog moment (work.change for the write path); - each door considers a set of kinds (snippet, note, lesson, process, task:issue/work/spike/plan); a kind left out is never searched there; - the shipped defaults are today's behaviour; a user's change is stored per door, and putting a door back removes it. Both note arms read it, replacing their fixed kind lists, and a reserved slot whose kind is turned off is not reserved. The review re-run searches the same kinds. Settings > Moments shows and edits the table, with each cell's lines shown and opens from the record ledger. list_moments returns it as record_kinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -267,11 +267,41 @@ def test_the_pipelines_fan_out_sites_declare_every_notes_source():
|
||||
"grimoire/services/plugin_context.py::record_surfaced(source=arm)"]
|
||||
|
||||
|
||||
def test_the_filters_say_which_kinds_and_whose_records():
|
||||
assert rp.note_search_filters(rp.AUTO_INJECT) == {
|
||||
"include_global_kinds": True, "scope": "browse",
|
||||
}
|
||||
assert rp.note_search_filters(rp.WRITE_PATH) == {
|
||||
"note_type": ("snippet", "note", LESSON_NOTE_TYPE), "task_kind": "issue",
|
||||
"include_global_kinds": True, "scope": "browse",
|
||||
}
|
||||
def test_the_filters_say_whose_records_and_the_table_says_which_kinds():
|
||||
for arm in (rp.AUTO_INJECT, rp.WRITE_PATH):
|
||||
assert rp.note_search_filters(arm) == {"include_global_kinds": True, "scope": "browse"}
|
||||
assert rp.AUTO_INJECT.door == "message" and rp.WRITE_PATH.door == "work.change"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_an_arm_searches_only_the_kinds_its_door_allows():
|
||||
# The shipped defaults: the message door considers every kind, so its
|
||||
# search is unfiltered; the write path narrows to its row.
|
||||
_r, _io_, calls = await _run(rp.AUTO_INJECT, lambda kw: [])
|
||||
assert calls[0]["record_kinds"] is None
|
||||
_r, _io_, calls = await _run(rp.WRITE_PATH, lambda kw: [])
|
||||
assert calls[0]["record_kinds"] == ["lesson", "note", "snippet", "task:issue"]
|
||||
# A user's own row replaces the default.
|
||||
_r, _io_, calls = await _run(rp.WRITE_PATH, lambda kw: [], kinds=frozenset({"snippet"}))
|
||||
assert calls[0]["record_kinds"] == ["snippet"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_door_with_every_kind_off_searches_nothing_and_logs_nothing():
|
||||
result, io, calls = await _run(rp.AUTO_INJECT, lambda kw: [], kinds=frozenset())
|
||||
assert calls == [] and result.menu == []
|
||||
io.record_retrieval.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_slot_whose_kind_the_door_turned_off_is_not_reserved():
|
||||
main = [_note(1, 0.70), _note(2, 0.69), _note(3, 0.68)]
|
||||
reuse = [_note(9, 0.60, note_type="snippet")]
|
||||
lesson = [_note(42, 0.58, note_type=LESSON_NOTE_TYPE)]
|
||||
result, _io_, calls = await _run(
|
||||
rp.AUTO_INJECT, _routed(main, reuse, lesson), budget=3,
|
||||
kinds=frozenset({"note", "process"}),
|
||||
)
|
||||
# The reuse slot narrows to processes; the lesson slot does not run.
|
||||
assert [c.get("note_type") for c in calls] == [None, ("process",)]
|
||||
assert "lesson_slot" not in result.slot_ids
|
||||
|
||||
Reference in New Issue
Block a user