Skip to content

test(scoring): defuse the repo_quality recency time bomb that turned main red - #60

Merged
Shaan-alpha merged 1 commit into
mainfrom
fix/repo-quality-fixture-time-bomb
Jul 31, 2026
Merged

test(scoring): defuse the repo_quality recency time bomb that turned main red#60
Shaan-alpha merged 1 commit into
mainfrom
fix/repo-quality-fixture-time-bomb

Conversation

@Shaan-alpha

Copy link
Copy Markdown
Owner

main went red on 2026-07-31 with nobody pushing anything. Found while investigating why #59's backend check failed — it reproduces identically on main, so it is not caused by that PR.

Root cause

repo_quality.score() awards recent_activity (6 pts) for a non-fork commit inside a rolling 90-day window measured from datetime.now(UTC) (app/scoring/repo_quality.py:48). The fixtures carry hardcoded last_commit_at values.

profile_oss.json's newest commit is 2026-05-01 — exactly 91 days before today. The window lapsed overnight, the signal stopped firing, and test_oss_profile_scores_twenty_without_deployment_hint went assert 14 == 20.

profile_senior.json's newest is 2026-05-10, 82 days out. test_senior_profile_scores_twenty_six_until_license_signal_lands was 8 days from the same failure (2026-08-08).

Fix

Pin the recency-sensitive dates relative to now in the test, which is the convention test_consistency.py and test_learning_trajectory.py already use for the other time-windowed scorers — they load the same static fixtures and then override the time-sensitive fields. test_repo_quality.py was the one file relying on the baked-in dates. No production code and no fixture files change, and no new dependency.

Also adds test_recent_activity_does_not_fire_once_every_commit_is_stale. The old suite only asserted the negative direction by accident of how old a fixture happened to be; now both directions are stated.

Scope

Checked the other fixture-driven scoring tests before settling on this. test_engine.py asserts invariants (report.total == report.breakdown.total()) rather than absolute scores, so it rides out the drift; test_badges.py, test_consistency.py, test_depth.py and test_learning_trajectory.py already build their time-sensitive state relative to now. test_repo_quality.py was the only exposed file.

Four scorers call datetime.now(UTC) internally (badges, consistency, learning_trajectory, repo_quality) and none take an injectable clock. Threading one through would be the deeper fix and would let these tests pin an exact instant instead of working relative to a moving one — deliberately not done here, since this PR exists to get main green and that refactor touches production signatures across all four.

Verification

uv run pytest -q360 passed, 72 skipped (was 358 passed / 1 failed, plus the 1 new test). ruff check clean, ruff format --check clean on 164 files.

main went red on 2026-07-31 with no code change behind it. repo_quality
awards recent_activity (6 pts) for a non-fork commit inside a rolling
90-day window measured from datetime.now(UTC), but the fixtures carry
hardcoded last_commit_at values. profile_oss.json's newest commit
(2026-05-01) turned 91 days old overnight, so the 20-point expectation
became 14. profile_senior.json (2026-05-10) was 8 days from the same fate.

Pin the recency-sensitive dates relative to now, the convention
test_consistency.py and test_learning_trajectory.py already use for the
other time-windowed scorers, so these assert the scoring rule rather than
the calendar. Both directions are now stated explicitly: a new test covers
recent_activity NOT firing once every commit is stale, which the old
suite only ever asserted by accident of the fixture's age.
Copilot AI review requested due to automatic review settings July 31, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Shaan-alpha added a commit that referenced this pull request Jul 31, 2026
All CHANGELOG/PROGRESS_LOG entries for the three open PRs are consolidated
here so the branches do not conflict on these two files. Records the merge
order (#60 first -- it is what makes CI green) and which audit findings
remain unfixed.
@Shaan-alpha
Shaan-alpha merged commit 9074991 into main Jul 31, 2026
5 checks passed
@Shaan-alpha
Shaan-alpha deleted the fix/repo-quality-fixture-time-bomb branch July 31, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants