feat(8118,8119): telemetry reads take a closed window, and every enter_project records whether it carried the family line
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 17s
CI & Build / integration (push) Failing after 2m15s
CI & Build / Python tests (push) Successful in 2m23s
CI & Build / Build & push image (push) Skipped

#8119: retrieval_telemetry and list_rules(with_usage) take `since` and
`until` (ISO date or datetime) besides `days`. Every windowed count is
bounded at both ends: sources, note/rule/system/moment usage, record
reach, judged lines and the floor-moved check. A review read after its
period can now keep a later deploy out of its counts. A bad bound is
refused rather than widened.

#8118: enter_project writes one AppLog row (family / enter_project) per
entry: the project, whether the family line was shown, its counts, and
whether the readout failed. It is spawned, so the handshake does not wait.
retrieval_telemetry gains a `family_line` block: per project, entries,
entries that carried the line, first and last shown, and the latest
counts. Review #5132's "did the project's sessions see the line" is now
answerable from this deploy on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 00:01:19 -05:00
co-authored by Claude Opus 5.5
parent 0e946ffac8
commit 577a8e8621
12 changed files with 389 additions and 29 deletions
+12 -4
View File
@@ -235,8 +235,10 @@ async def mark_opened(user_id: int, session_id: str | None, note_id: int, plugin
return DIRECT
async def summary(user_id: int, days: int = 30) -> dict:
"""How records reached this user's sessions over the last `days`.
async def summary(user_id: int, days: int = 30, *, since: datetime | None = None,
until: datetime | None = None) -> dict:
"""How records reached this user's sessions over the last `days`, or over
[`since`, `until`) when the caller bounds the window itself.
Per kind: `delivered` and `opened` rows for each way a record arrived
(`pushed` by a hook, `asked` through the session's own search, `direct`
@@ -244,8 +246,12 @@ async def summary(user_id: int, days: int = 30) -> dict:
row is always opened; it is counted so the readout shows how much a
session reaches without being shown.
"""
days = max(1, min(int(days or 30), rule_deliveries.RETAIN_DAYS))
since = datetime.now(timezone.utc) - timedelta(days=days)
until = until or datetime.now(timezone.utc)
if since is None:
days = max(1, min(int(days or 30), rule_deliveries.RETAIN_DAYS))
since = until - timedelta(days=days)
else:
days = round((until - since).total_seconds() / 86400, 2)
async with async_session() as session:
rows = (await session.execute(
select(
@@ -255,12 +261,14 @@ async def summary(user_id: int, days: int = 30) -> dict:
func.count(func.distinct(RecordDelivery.session_id)),
)
.where(RecordDelivery.user_id == user_id, RecordDelivery.delivered_at >= since,
RecordDelivery.delivered_at < until,
RecordDelivery.plugin.is_not(None))
.group_by(RecordDelivery.kind, RecordDelivery.way, RecordDelivery.source)
)).all()
sessions = (await session.execute(
select(func.count(func.distinct(RecordDelivery.session_id)))
.where(RecordDelivery.user_id == user_id, RecordDelivery.delivered_at >= since,
RecordDelivery.delivered_at < until,
RecordDelivery.plugin.is_not(None))
)).scalar_one()