feat(7831): every record a session is shown, asks for or opens on its own is recorded per session, by kind
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / Python tests (push) Successful in 1m59s
CI & Build / integration (push) Successful in 2m6s
CI & Build / Build & push image (push) Successful in 32s

A ledger beside the rule deliveries (record_deliveries, migration 0136):
- every note, snippet, issue, lesson or process line a plugin door pushes
  is recorded against the session, only when the payload kept it;
- a search the session runs itself records its results as asked, matched
  to the server log of that call;
- an open is stamped on the delivery it followed, or recorded as direct
  when nothing showed the record first.

The plugin reports opens and searches from the tool calls
(grimoire_record_read.sh). The readout is in retrieval_telemetry
(record_reach), at /api/retrieval/record-reach, and in Settings > Moments
as "How records reach the work". Plugin 2026.11.24.1827.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 13:27:13 -05:00
co-authored by Claude Opus 5.5
parent 394f83427d
commit b0fab00fe2
21 changed files with 951 additions and 9 deletions
@@ -0,0 +1,44 @@
"""record deliveries: each non-rule record put in front of a session, and whether it was opened
Revision ID: 0136
Revises: 0135
Create Date: 2026-11-24
The note-side twin of `rule_deliveries`. A row per record a hook pushed, a
search the session ran returned, or the session opened with nothing
delivering it first, so opens can be told apart by the way the record
arrived.
"""
import sqlalchemy as sa
from alembic import op
revision = "0136"
down_revision = "0135"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"record_deliveries",
sa.Column("id", sa.BigInteger(), primary_key=True),
sa.Column("user_id", sa.BigInteger(), nullable=False),
sa.Column("session_id", sa.Text(), nullable=False),
sa.Column("note_id", sa.BigInteger(), nullable=False),
sa.Column("kind", sa.Text(), nullable=False),
sa.Column("way", sa.Text(), nullable=False),
sa.Column("source", sa.Text(), nullable=False),
sa.Column("delivered_at", sa.DateTime(timezone=True), nullable=False,
server_default=sa.func.now()),
sa.Column("opened_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("plugin", sa.Text(), nullable=True),
)
op.create_index("ix_record_deliveries_session_note", "record_deliveries",
["user_id", "session_id", "note_id", "delivered_at"])
op.create_index("ix_record_deliveries_delivered_at", "record_deliveries", ["delivered_at"])
def downgrade() -> None:
op.drop_index("ix_record_deliveries_delivered_at", table_name="record_deliveries")
op.drop_index("ix_record_deliveries_session_note", table_name="record_deliveries")
op.drop_table("record_deliveries")