refactor(usage): final round-6 nits on PR #871
- semantic.py: normalize both None and [] doc_types to null in the metadata so a future `metadata->'doc_types' IS NULL` query counts the all-types case consistently. - test: use a fixed past date in test_occurred_at_roundtrip instead of a future literal (deterministic, no "why this date" confusion). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c89f724585
commit
98de8f331f
@@ -548,10 +548,13 @@ def configure_semantic_tools(mcp: FastMCP):
|
||||
"user_id": username,
|
||||
"fusion": fusion,
|
||||
# Bounded copy — see _USAGE_METADATA_MAX_DOC_TYPES.
|
||||
# Both None and [] normalize to null so a future
|
||||
# metadata->'doc_types' IS NULL query counts the
|
||||
# all-types case consistently.
|
||||
"doc_types": (
|
||||
doc_types[:_USAGE_METADATA_MAX_DOC_TYPES]
|
||||
if doc_types
|
||||
else doc_types
|
||||
else None
|
||||
),
|
||||
},
|
||||
# The outer guard already confirmed the flag, so pass
|
||||
|
||||
@@ -185,7 +185,7 @@ async def test_occurred_at_roundtrip(storage, monkeypatch):
|
||||
_set_metering(monkeypatch, True)
|
||||
store = UsageEventStore(storage)
|
||||
eid = str(uuid.uuid4())
|
||||
when = datetime(2026, 6, 10, 12, 0, 0, tzinfo=timezone.utc)
|
||||
when = datetime(2026, 1, 15, 12, 0, 0, tzinfo=timezone.utc)
|
||||
await store.record_usage_event(
|
||||
metric="pages_chunks", value=1, event_id=eid, occurred_at=when
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user