test(metering): assert tokens-before-pages ordering invariant
Round-2 review nit (PR #879): lock the intentional record ordering (tokens_embedded before the conditional pages_embedded) with an assertion in test_parsed_file_records_pages_and_tokens, so a refactor that reverses it fails a test rather than only contradicting a comment. 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
a3178cf1fa
commit
9d6592860b
@@ -46,6 +46,11 @@ async def test_parsed_file_records_pages_and_tokens(store_spy):
|
||||
by_metric = {c.kwargs["metric"]: c.kwargs["value"] for c in calls}
|
||||
# pages_embedded is the real parsed-page count, NOT the chunk count.
|
||||
assert by_metric == {"pages_embedded": 12, "tokens_embedded": 4242}
|
||||
# Intentional ordering: tokens (recorded for every doc) before pages (the
|
||||
# conditional parsing cost). Asserted so a refactor can't silently reverse
|
||||
# it — a comment alone is easier to delete than a failing test.
|
||||
assert calls[0].kwargs["metric"] == "tokens_embedded"
|
||||
assert calls[1].kwargs["metric"] == "pages_embedded"
|
||||
for c in calls:
|
||||
# Hot-path fast-gate + tenant-local attribution metadata.
|
||||
assert c.kwargs["enabled"] is True
|
||||
|
||||
Reference in New Issue
Block a user