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
+26
View File
@@ -606,3 +606,29 @@ async def test_list_rules_carries_usage_only_when_asked():
assert usage.await_args.args[0] == [1, 2]
assert usage.await_args.kwargs["since"] is not None
lessons.assert_awaited_once_with(7, [1, 2])
@pytest.mark.asyncio
async def test_list_rules_counts_a_closed_window_when_a_review_names_one():
"""A review read after its period passes both ends, so a later deploy
stays out of the counts. A bare `until` date covers that whole day, and
an unparseable bound is refused rather than widened to the default."""
from datetime import datetime, timezone
from grimoire.mcp.tools import rulebooks as tools
usage = AsyncMock(return_value={})
with patch.object(tools.rulebooks_svc, "list_rules", AsyncMock(return_value=[fake_rule(id=1)])), \
patch.object(tools.rulebooks_svc, "list_rule_moments", AsyncMock(return_value={})), \
patch.object(tools, "usage_for_rules", usage), \
patch.object(tools, "confirmed_lesson_counts", AsyncMock(return_value={})):
await tools.list_rules(with_usage=True, since="2026-10-23", until="2026-11-24")
kw = usage.await_args.kwargs
assert kw["since"] == datetime(2026, 10, 23, tzinfo=timezone.utc)
assert kw["until"].date().isoformat() == "2026-11-24"
assert kw["until"] > datetime(2026, 11, 24, 23, 0, tzinfo=timezone.utc)
refused = await tools.list_rules(with_usage=True, since="last tuesday")
assert "error" in refused
backwards = await tools.list_rules(with_usage=True, since="2026-11-24", until="2026-10-23")
assert "error" in backwards