fix: isolate NIM-benchmark evidence-currency fixture and fix spend-analytics usage_source classification - #1070
Conversation
Five tests in tests/test_nim_benchmark.py exercise unrelated run_mode="live" behavior (missing credential, transport wiring, a malformed-catalog contract failure, CLI exit codes) that incidentally passes through _require_current_actual_cost_evidence(). That check fails closed once nim_benchmark.ACTUAL_COST_EVIDENCE["valid_until_date"] — a human-reviewed date for NVIDIA's published hosted-endpoint terms — is in the past. Today (2026-09-05) is now one day past the literal "2026-09-04" recorded there, so all five started failing for a reason unrelated to what each actually asserts: a classic ticking-time-bomb hard-coded date, not a code regression. The production literal is deliberate and stays as-is: it is a real record of when someone last verified NVIDIA's terms, and live runs are meant to fail closed until that review happens again. tests/test_nim_benchmark_release_acceptance.py already covers that review-cadence invariant directly via explicit `today` injection into _require_current_actual_cost_evidence, and is unaffected. Added an autouse fixture in test_nim_benchmark.py that monkeypatches ACTUAL_COST_EVIDENCE's reviewed_at_date/valid_until_date to bracket real "now" for the duration of this file's tests only, so they stay green regardless of wall-clock date while still exercising the real evidence-gated code path. Verified: `python -m pytest tests/test_nim_benchmark.py -v` and `python tests/test_nim_benchmark.py` both 98 passed (previously 5 failed); tests/test_nim_benchmark_release_acceptance.py unaffected (28 passed); interrogate scoped to contextual_orchestrator/ stays 100%; git diff --check clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
|
Warning Review limit reachedNext included review available in 4 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The prior fix used an autouse fixture across all 98 tests in tests/test_nim_benchmark.py, silently giving every test synthetic current cost evidence and deriving dates from date.today() — too broad for a security/commercial fail-closed gate, since unrelated tests (present and future) would stop observing the literal production evidence dict. Make the fixture opt-in (current_actual_cost_evidence, no autouse) and request it explicitly only from the five tests that need to get past the evidence gate to reach their own live-path assertion. Production ACTUAL_COST_EVIDENCE is unchanged. Add a regression test proving a test that does not request the fixture still observes the literal production evidence and fails closed at the gate (verified RED against the reverted autouse design, GREEN against this fix). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
|
Pushed
Validated locally: the five named tests + the new regression test all pass ( Left as Draft per your instructions — no self-approval, no ready-for-review flip. Over to you for the full-gate re-run and Ready decision. Generated by Claude Code |
…ce tests test_live_run_rejects_unreviewed_pricing_before_egress and test_live_run_rejects_incomplete_or_expired_pricing_before_egress now request the current_actual_cost_evidence fixture so they exercise validate_live_pricing_scenario's own fail-closed branches (lines 1708/1718) instead of incidentally matching _require_current_actual_cost_evidence's "expired" error once ACTUAL_COST_EVIDENCE's literal valid_until_date lapsed. Restores 100% branch coverage on nim_benchmark.py's pricing-scenario gate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
|
Pushed What broke: that file's two pricing-scenario contract tests ( What's still red on this required check, and why it's not this PR's: With Generated by Claude Code |
test_live_run_without_evidence_fixture_still_fails_closed_on_expired_evidence asserted that a test not requesting the current_actual_cost_evidence fixture observes real-world ACTUAL_COST_EVIDENCE as expired -- true only because today happened to be past the literal valid_until_date at authoring time. Once #1073 refreshed that production evidence (reviewed_at_date=2026-09-05, valid_until_date=2026-10-05), this PR's own required "Tests and package quality" check failed for real: the evidence gate no longer raised, so the test fell through to a genuine network probe against NVIDIA's live API and got HTTP 403 -- the exact same class of ticking-time-bomb bug this PR is otherwise fixing, just introduced by this PR's own new regression test. Fix: the test now deliberately monkeypatches ACTUAL_COST_EVIDENCE to a fixed past window (2020) itself, proving the same opt-in-fixture-vs-file-wide mechanism without depending on real wall-clock time relative to whatever the production valid_until_date currently is. Verified locally against both the unmodified branch and a merge of this branch with current origin/main (post-#1073 evidence). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
spend_analytics()["by_model"][].usage_source was classified purely from each model's output-token source (reported/tokenizer/mixed/unavailable across that model's steps this run), while completely ignoring whether prompt tokens were ever available for that model. A model with exactly one step, exact-tokenizer output, and zero reported prompt tokens was labeled pure "tokenizer" — dishonestly implying full count-based knowledge of that model's usage when the prompt side was entirely unmeasured. Add per-model prompt-token tracking (`bucket["prompt_reported_steps"]`) alongside the existing per-model output-source counters, and require full per-model prompt availability before classifying a row as "reported" or "tokenizer". A model whose output is fully known but whose prompt tokens are partially or entirely unmeasured now correctly falls through to "mixed" — the same honest-composite label already used for genuinely mixed output sources. The four-way usage_source vocabulary (reported/tokenizer/mixed/unavailable) is unchanged, matching the documented contract in README.md. The existing report-wide `prompt_available` flag (used for `totals.prompt_tokens`/`measurement_status`) is untouched: it already forces "unavailable" whenever any step in the run lacks a valid reported prompt count, so this fix only tightens per-model row classification, not the report-level status. Validated: tests/test_spend_analytics.py now passes (previously failed with `'tokenizer' == 'mixed'`); full suite `PYTHONPATH=. python -m pytest tests -q --ignore=tests/test_psychometric_routing.py` now shows 3383 passed, 5 failed, 2 skipped — the 5 failures are pre-existing, unrelated `test_nim_benchmark.py` date-evidence-expiry failures (confirmed identical via `git stash` against unmodified origin/main), not caused by or related to this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
|
Root cause, self-inflicted: that regression test asserted the evidence gate fires "expired" by relying on real wall-clock time being past whatever Second failure in the same merge target, not caused by this PR: verifying against a real merge with current Verified locally: Generated by Claude Code |
|
Adjudication evidence (host 1 session, 2026-09-06 KST; full report with commands in #1080). Nothing here closes, flips, or retargets anything — the decision is the opener's. This head is byte-identical to #1071. Merging both would land the same diff twice; merging one makes the other empty. The owner ( |
|
Scheduled review-feedback autofix for this PR head.
|
Preserve opt-in current_actual_cost_evidence (not file-wide autouse) and prompt-aware usage_source classification while absorbing #1074 / main. Co-authored-by: Cursor <cursoragent@cursor.com>
… and review sidecar gap Append-only additions to AGENTS.md (two new sections), a one-line pointer in CLAUDE.md, and a CHANGELOG.md entry, recording lessons independently re-verified against this exact checkout and live GitHub state on 2026-09-05: the nim_benchmark.py evidence-gate recurring bug class (hardcoded valid_until_date literals causing silent branch-coverage loss once lapsed, diagnosed/repaired three times this cycle across PR #1070, PR #1071, and issue #1075), and the still-open central review sidecar/egress gap tracked in issue #1041 comment 5550412102 and ContextualWisdomLab/.github issue Documentation only: no code, test, or behavior change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
Identity correction, 2026-09-06
This PR's head became byte-identical to
#1071after both branches independently ported each other's fixes to pass against currentmain(three-dot diff againstmainis the same 385-line patch on both, confirmed independently viagit diff/cmp/merge-tree, corroborating a peer session's adjudication comment below). This is the designated survivor per that adjudication (owner call,contextual-orchestrator/issues/1080);#1071is being closed as a duplicate pointing here. The delta below is the exact current 6-file diff, not an approximation.Current repair state
Exact head
bcecfa16ea7910808605d8a16bba49c57ac28758. Effective base-to-head delta, verified againstorigin/main@2e414d15:CHANGELOG.md,README.md— documentation for both fixes below;tests/test_nim_benchmark.py— this PR's own fix (see "RED → causal GREEN");tests/test_nim_benchmark_release_acceptance.py— a third instance of the same hardcoded-expiry-date bug class, found and fixed while validating this PR (commit0eaca9f1; see PR comments);contextual_orchestrator/orchestrator.py,tests/test_spend_analytics.py— theusage_sourceclassification fix cherry-picked from#1071(commitse4cda9cc/bcecfa16), a legitimately separate, pre-existing base-branch bug ported here so this PR's own tests pass against currentmain.This PR remains Draft because fresh exact-head hosted/security evidence is non-terminal.
Production
ACTUAL_COST_EVIDENCEis intentionally unchanged. Live benchmark execution must continue to fail closed after that human-reviewed window expires until NVIDIA hosted-endpoint terms are actually re-reviewed. Tests may not make that production fact relative to wall-clock time — this PR's own added regression test hit exactly that trap and was fixed (1d5e77f9) to monkeypatch a fixed-past date instead of relying on real-world drift relative to whatever production evidence currently says.RED → causal GREEN (this PR's own fix)
The predecessor fix used an autouse fixture over all tests in
tests/test_nim_benchmark.py, which silently replaced the expired production evidence for unrelated and future tests. The current descendant narrows the seam instead of changing production behavior:current_actual_cost_evidenceis now an explicit opt-in pytest fixture, not autouse;Promotion gate
Keep Draft until the unchanged exact head has terminal focused/full/fuzz/docstring/security evidence and current review/thread state is clean. Do not extend the production review date, self-approve, bypass, weaken gates, force-update, destructively rebase, or add a no-op retrigger.
Generated by Claude Code