From 9cbdfb205cece9e6c63692276dbe03994c483c96 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 24 Nov 2026 14:24:53 -0500 Subject: [PATCH] feat(7833): each moment declares which kinds of record its search may consider, editable in Settings > Moments 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 --- frontend/src/api/moments.ts | 33 ++- frontend/src/components/MomentsSettings.vue | 2 + frontend/src/components/RecordKinds.vue | 130 +++++++++++ src/grimoire/mcp/tools/moments.py | 12 +- src/grimoire/routes/retrieval.py | 34 +++ src/grimoire/services/embeddings.py | 8 + src/grimoire/services/plugin_context.py | 3 + src/grimoire/services/record_deliveries.py | 10 +- src/grimoire/services/record_kinds.py | 226 ++++++++++++++++++++ src/grimoire/services/retrieval_pipeline.py | 65 ++++-- src/grimoire/services/retrieval_review.py | 5 + tests/conftest.py | 21 ++ tests/test_integration_record_kinds.py | 93 ++++++++ tests/test_moments.py | 6 +- tests/test_note_pipeline.py | 46 +++- tests/test_retrieval_review.py | 2 +- tests/test_routes_retrieval_tuning.py | 1 + 17 files changed, 654 insertions(+), 43 deletions(-) create mode 100644 frontend/src/components/RecordKinds.vue create mode 100644 src/grimoire/services/record_kinds.py create mode 100644 tests/test_integration_record_kinds.py diff --git a/frontend/src/api/moments.ts b/frontend/src/api/moments.ts index d939e177..180aca27 100644 --- a/frontend/src/api/moments.ts +++ b/frontend/src/api/moments.ts @@ -1,4 +1,4 @@ -import { apiGet, apiPost, apiDelete } from "@/api/client"; +import { apiGet, apiPost, apiPut, apiDelete } from "@/api/client"; import type { RuleEnforcement, RuleSalience, RuleTrigger } from "@/api/rulebooks"; /** @@ -279,6 +279,37 @@ export interface AdherencePayload { by_moment: MomentAdherenceRow[]; } +/** One door of the kind×moment table: where a record search fires, and + * the kinds of record it may consider. */ +export interface RecordKindsDoor { + /** A catalog moment, or `message` for the operator's message. */ + door: string; + label: string; + fires: string; + kinds: string[]; + default: string[]; + /** The user changed this door; otherwise it follows the shipped default. */ + changed: boolean; + /** Lines this door pushed of each kind, and how many were opened. */ + evidence: Record; +} + +export interface RecordKindsTable { + days: number; + evidence_failed: boolean; + kinds: { kind: string; label: string }[]; + doors: RecordKindsDoor[]; +} + +export function getRecordKinds(days = 30): Promise { + return apiGet(`/api/retrieval/record-kinds?days=${days}`); +} + +/** `kinds: null` puts the door back to its shipped default. */ +export function setRecordKinds(door: string, kinds: string[] | null): Promise { + return apiPut("/api/retrieval/record-kinds", { door, kinds }); +} + /** How a record arrived in front of a session. */ export type RecordWay = "pushed" | "asked" | "direct"; diff --git a/frontend/src/components/MomentsSettings.vue b/frontend/src/components/MomentsSettings.vue index f070755a..c4e7530a 100644 --- a/frontend/src/components/MomentsSettings.vue +++ b/frontend/src/components/MomentsSettings.vue @@ -4,6 +4,7 @@ import { useMomentsStore } from "@/stores/moments"; import MomentProposals from "@/components/MomentProposals.vue"; import MomentRuleUsage from "@/components/MomentRuleUsage.vue"; import WeightProposals from "@/components/WeightProposals.vue"; +import RecordKinds from "@/components/RecordKinds.vue"; import RecordReach from "@/components/RecordReach.vue"; import RuleAdherence from "@/components/RuleAdherence.vue"; import { getAdherence, getRecordReach } from "@/api/moments"; @@ -172,6 +173,7 @@ onMounted(async () => { +
  • diff --git a/frontend/src/components/RecordKinds.vue b/frontend/src/components/RecordKinds.vue new file mode 100644 index 00000000..681fa5fe --- /dev/null +++ b/frontend/src/components/RecordKinds.vue @@ -0,0 +1,130 @@ + + + + + + +