fix(code-review): make override-cache tests independent of wall-clock date - #194
Merged
Merged
Conversation
… date Three tests pinned an override's asserted_at to a fixed 2026-05-29 timestamp and asserted the override was honored. Once that timestamp aged past the 90-day overrides TTL they began failing with no code change. Derive the timestamp relative to now instead. Renames the existing _stale_cached_at() helper to _iso_days_ago() to match its already-generic docstring, and routes the two override TTL boundary tests through it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011QjUMmrqfGU4QNXDDRLPrN
Collaborator
|
Beginning a code-review. Please allow time for me to finish before merging the PR |
shafty023
approved these changes
Sep 10, 2026
peterulsteen
added a commit
that referenced
this pull request
Sep 10, 2026
Resolve CHANGELOG.md: main released code-review v3.7.1 (#194), so this branch's entry moves to v3.7.2 above it and plugin.json bumps to match. Without the bump the plugin-version-bump CI job fails against the new merge base.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three tests in
test_code_review_helpers.pywere failing onmainwith no accompanying code change:They are time bombs. Each writes an override with a hardcoded
asserted_atof2026-05-29T22:00:00+00:00and then asserts the override is honored — landing inoverride_hits, or routed to aRE_ASSERTEDverdict.The overrides cache has a 90-day TTL (
CACHE_TTL_DAYS["overrides"]), enforced by_override_is_expired. The tests passed while that fixed date was recent. Once wall-clock passed 2026-08-27,_override_is_validcorrectly began returningFalse,override_hitscame back empty, and the assertions broke.The production code is correct — expiring a 100-day-old override is exactly the intended behavior. Only the fixtures were wrong.
Fix
Derive
asserted_atrelative to now, so the tests exercise the honored-override path whenever they run.The file already had a helper for this —
_stale_cached_at(days_ago), returning an ISO timestamp N days in the past — and two sibling TTL tests already used the relative idiom inline. Rather than add a near-duplicate, this reuses the existing helper and renames it to_iso_days_ago()so the name matches its already-generic docstring (it is used for both within-TTL and past-TTL fixtures, so "stale" was misleading). All 6 existing call sites updated, plus the two override TTL boundary tests, which now delegate instead of inliningdatetime.now(timezone.utc) - timedelta(...).Scope check: is this the only time bomb?
Swept every hardcoded timestamp feeding TTL-checked fields across all plugins' tests. Two remain, both safe by construction:
test_code_review_helpers.py:3560,3586cached_at: 2025-01-01test_code_review_helpers.py:10071asserted_at: 2026-05-29The rot-prone pattern is specifically "hardcoded recent timestamp expected to be within TTL", and all three instances are fixed here.
Also included
/update-documentationis mandatory before push in this repo, and its README-verification step flagged two pre-existing inaccuracies inplugins/code-review/README.md. Both are unrelated to the test fix but verified correct, so they are included rather than left wrong:config/cli.json,config/stages.json,signal_taxonomy.json,conftest.py.Verification
pytest plugins/— 2107 passed, 3 skipped (was 3 failed, 2107 passed)uv run ruff check .— cleanuv run pyright— 0 errorsNo production code changed — test fixtures, one test-helper rename, README, CHANGELOG, and a PATCH version bump (3.7.0 → 3.7.1).
🤖 Generated with Claude Code
https://claude.ai/code/session_011QjUMmrqfGU4QNXDDRLPrN