test(usage): cover search metering hook; log dedup metering skip (round 4)
Round-4 claude-review findings (no blockers): - 🟡 Untested server-layer metering hook (raised across rounds): extracted the nc_semantic_search embeddings_queries recording into a module-level record_search_usage() helper (mirroring record_indexing_usage) and added tests/unit/server/test_semantic_metering.py — value = query token count, flag-off no-op, None token → 0, doc_types metadata bounding, best-effort failure swallowed. - 🟡 Dedup-hit skipped metering invisibly: the existing dedup info log now states "no embedding/usage recorded" so a "fewer embeddings_queries rows than expected" audit lands on the dedup path directly. Deferred 🟢 nits (stated on the PR): search 0-token rows are recorded deliberately (the query embedding ran; zero is a sum no-op) — documented in the helper; embed_tokens closure locality and the OpenAI embed() dual path are unchanged (correct as-is / separate refactor). Deck #67. 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
9ac9e1ab09
commit
df03d33fd4
@@ -657,9 +657,13 @@ async def _index_document(
|
||||
doc_type="file",
|
||||
user_id=doc_task.user_id,
|
||||
)
|
||||
# No embedding ran, so no usage is recorded here — stated
|
||||
# explicitly so a "fewer embeddings_queries rows than expected"
|
||||
# audit lands on the dedup path rather than reconstructing it
|
||||
# from Qdrant claim logs.
|
||||
logger.info(
|
||||
"Dedup hit for file %s (etag=%s); claimed for user %s "
|
||||
"without reprocessing",
|
||||
"without reprocessing (no embedding/usage recorded)",
|
||||
doc_task.doc_id,
|
||||
doc_task.etag,
|
||||
doc_task.user_id,
|
||||
|
||||
Reference in New Issue
Block a user