Skip to content

Pin the model end_date boundary in tests - #321

Merged
robkooper merged 1 commit into
mainfrom
lum-156-pin-end-date-boundary
Oct 29, 2026
Merged

robkooper merged 1 commit into
mainfrom
lum-156-pin-end-date-boundary

Conversation

@robkooper

Copy link
Copy Markdown
Member

What changed

Tests only, no production code changes. They pin the exact end_date instant (end_date == utcnow()) in all four places that check a model's end date:

  • _resolve_single_access in lumen/services/llm.py: blocked at NOW, allowed at NOW + 1µs. There is also an end-to-end check that get_model_access_status / get_model_access block at the exact instant.
  • ModelConfig.active in lumen/models/model_config.py: covers both the Python property and the SQL expression. It is inactive at NOW and active at NOW + 1s. The test uses 1 s because database sub-second precision varies.
  • ModelSnapshot.active in lumen/services/model_cache.py: resolve() hides the model at NOW and returns it at NOW - 1µs.

Every test patches the module-level utcnow of the module under test to a fixed naive-UTC 2030-01-01 12:00:00, so no test reads the real clock. The PR also adds one CHANGELOG bullet.

How I tested it

  • uv run pytest tests/unit/test_llm_access.py tests/unit/test_model_cache.py: pass.
  • Mutation checks, run locally and not committed. Each mutation made at least one new test fail:
    • llm.py:172: <= changed to <
    • model_config.py:73: > changed to >=
    • model_config.py:78: > changed to >=
    • model_cache.py:102: > changed to >=
  • Full uv run pytest passes locally. The PostgreSQL and Redis tests were skipped locally because no database services were available; CI runs them.

Fixes #311

Freeze the clock at a fixed instant and assert both sides of the
end_date boundary in the access gate, ModelConfig.active (Python and
SQL) and the model cache snapshot: a model is blocked and hidden from
the exact end instant.

Fixes #311
@robkooper

Copy link
Copy Markdown
Member Author

How to test
On a disposable local instance with a development user and dummy backend configured as described in the README, give a public test model a future UTC End Date in Admin → Configuration. Confirm an ordinary user can see and use it, then set the End Date to the past and save. After configuration reload, it should disappear from model listings and requests for it should be rejected. This PR only adds regression coverage, so existing behavior should stay the same.

@robkooper
robkooper merged commit 17a8e3d into main Oct 29, 2026
11 checks passed
@robkooper
robkooper deleted the lum-156-pin-end-date-boundary branch October 29, 2026 03:17
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.

[should-fix] Untested: model end_date boundary (end_date == now) in _resolve_single_access

1 participant