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

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:
2026-11-24 14:24:53 -05:00
co-authored by Claude Opus 5.5
parent b0fab00fe2
commit 9cbdfb205c
17 changed files with 654 additions and 43 deletions
+2 -8
View File
@@ -34,6 +34,7 @@ from grimoire.models.record_delivery import ASKED, DIRECT, PUSHED, RecordDeliver
from grimoire.models.retrieval_log import RetrievalLog
from grimoire.services import rule_deliveries
from grimoire.services.access import readable_notes_clause
from grimoire.services.record_kinds import kind_of
from grimoire.services.background import spawn
logger = logging.getLogger(__name__)
@@ -88,13 +89,6 @@ def flush(kept: set[int] | None = None) -> None:
spawn(_insert(rows), site="record_delivery_write")
def _kind(note_type: str | None, status: str | None, task_kind: str | None) -> str:
# A task is told by its status; its kind says what sort of task it is.
if status is not None:
return f"task:{task_kind or 'work'}"
return note_type or "note"
async def _kinds(session, user_id: int, ids) -> dict[int, str]:
"""`{note_id: kind}` for the ids this user may read; any other id is left
out, so the ledger never records a record its reader could not open."""
@@ -102,7 +96,7 @@ async def _kinds(session, user_id: int, ids) -> dict[int, str]:
select(Note.id, Note.note_type, Note.status, Note.task_kind)
.where(Note.id.in_(list(ids)), readable_notes_clause(user_id))
)).all()
return {int(i): _kind(t, s, k) for i, t, s, k in rows}
return {int(i): kind_of(t, s, k) for i, t, s, k in rows}
async def _insert(rows: list[dict]) -> None: