Skip to content

fix: compare the unrounded age in --stale_days checks - #390

Merged
izar merged 1 commit into
OWASP:masterfrom
G26karthik:fix-stale-days-negative-floor
Nov 11, 2026
Merged

izar merged 1 commit into
OWASP:masterfrom
G26karthik:fix-stale-days-negative-floor

Conversation

@G26karthik

Copy link
Copy Markdown
Contributor

With --stale_days 1, a source file that is only a minute older than the model is reported as "Model script model.py is only 1 days newer than source code file source.py". On a fresh clone, where all files get nearly the same mtime, this prints for every source file.

_stale takes (src_mtime - tm_mtime).days, and timedelta.days rounds negative deltas down, so -60 seconds becomes -1 day and the age <= -days branch fires a day early. Now the age is compared in exact days and rounded only for the message. The "This model is N days older" side keeps the same thresholds and output.

The new test in tests/test_stale_paths.py sets the source 60 seconds older than the model and runs --stale_days 1. It fails on master and passes with the change; the other stale tests still pass. Ruff and Black report nothing new on the changed lines.

I found no existing issue or PR for this.

timedelta.days floors negative deltas, so a source file a minute older than the model counted as a full day older and --stale_days 1 reported it. Compare the exact age in days and round only for the message.
@izar
izar merged commit e7395a4 into OWASP:master Nov 11, 2026
5 checks passed
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