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
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:
@@ -64,6 +64,9 @@ def bind_session(session_id: str | None, plugin: str | None = None) -> None:
|
||||
_session.set(clean_session(session_id))
|
||||
_plugin.set(_UNSAFE.sub("_", (plugin or "").strip())[:_PLUGIN_MAX])
|
||||
_pending.set([])
|
||||
# The record ledger delivers to the same session, under the same binding.
|
||||
from grimoire.services import record_deliveries
|
||||
record_deliveries.reset()
|
||||
|
||||
|
||||
def flush(kept: set[int] | None = None) -> None:
|
||||
@@ -91,6 +94,11 @@ def current_session() -> str:
|
||||
return _session.get()
|
||||
|
||||
|
||||
def current_plugin() -> str | None:
|
||||
"""The plugin version that sent this request, or None when it sent none."""
|
||||
return _plugin.get() or None
|
||||
|
||||
|
||||
def clean_session(session_id: str | None) -> str:
|
||||
# The plugin's own filename-safe form of the id, so a hook that sends the
|
||||
# raw id and one that sends the safe one name the same session.
|
||||
@@ -252,8 +260,9 @@ async def retired(user_id: int, rule_ids: list[int]) -> set[int]:
|
||||
|
||||
|
||||
async def prune(retain_days: int = RETAIN_DAYS) -> int:
|
||||
"""Delete deliveries older than `retain_days`, and the adherence verdicts
|
||||
on them (`rule_adherence`), which mean nothing without their delivery."""
|
||||
"""Delete deliveries older than `retain_days`, the adherence verdicts on
|
||||
them (`rule_adherence`), which mean nothing without their delivery, and
|
||||
the record deliveries of the same age (`record_deliveries`)."""
|
||||
from grimoire.services import rule_adherence
|
||||
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=retain_days)
|
||||
@@ -263,6 +272,8 @@ async def prune(retain_days: int = RETAIN_DAYS) -> int:
|
||||
)
|
||||
await session.commit()
|
||||
await rule_adherence.prune(cutoff)
|
||||
from grimoire.services import record_deliveries
|
||||
await record_deliveries.prune(cutoff)
|
||||
return int(result.rowcount or 0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user