Skip to content

fix(licensing): evaluate expiry in UTC; tz-aware datetimes — closes #502 - #2922

Merged
squid-protocol merged 3 commits into
mainfrom
chore/dtz-utc-licensing
Sep 9, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
chore/dtz-utc-licensing

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What

Resolves the DTZ005/DTZ007 (naive-datetime) findings (#502). These are correctness decisions, not cosmetic auto-fixes, so each is handled deliberately.

Changes

  • licensing.py — the important one. License expiry is now evaluated in UTC: the stored YYYYMMDD is parsed as UTC-midnight (.replace(tzinfo=timezone.utc)) and compared against datetime.now(timezone.utc). This fixes two latent issues:
    1. Crash risk: making only one side tz-aware would raise TypeError on the naive-vs-aware comparison and break the license gate entirely.
    2. Policy: expiry previously landed on the server's local midnight. It is now a single global UTC-midnight instant (per the agreed dateline).
      Adds a regression test that freezes now() to a fixed UTC instant and asserts same-UTC-day → EXPIRED, next-day → VALID.
  • cobol_refractor_controller.py / cobol_jcl_forge.py: the two datetime.now() calls that build output-directory name suffixes now use UTC — also making the suffixes monotonic across DST rollbacks (avoids dir collisions).

Note on scope

This is intentionally split from the mechanical lint PRs (#2920, #2921) because the licensing change is a real behavior/policy change that warrants its own review + test — flagged during a per-site review of the #469 backlog.

Verification

  • ruff check --select DTZ005,DTZ007 → clean. python tests/ruff_audit.py --ci → no new findings beyond the regenerated 66-key baseline (was 70). Pinned ruff==0.16.0.
  • tests/core_engine/test_licensing.py → 10 passed (incl. the new UTC test).

Closes #502

🤖 Generated with Claude Code

https://claude.ai/code/session_01QBL6TAMVXRUY7iQyy9Ysvi

squid-protocol and others added 2 commits September 9, 2026 11:51
ruff DTZ005/DTZ007 flagged naive datetimes. These are correctness decisions,
not cosmetics, so they're handled deliberately rather than auto-fixed:

- licensing.py: license expiry is now evaluated in UTC. The stored YYYYMMDD is
  parsed as UTC-midnight and compared against `datetime.now(timezone.utc)`.
  This fixes two latent issues: (a) a naive-vs-aware comparison would raise
  TypeError if only one side were made aware, and (b) expiry previously landed
  on the server's LOCAL midnight -- it is now a single global UTC instant, per
  the UTC-midnight dateline decision. Adds a regression test that freezes now()
  to a fixed UTC instant and asserts same-UTC-day = EXPIRED, next-day = VALID.
- cobol_refractor_controller.py / cobol_jcl_forge.py: the two `datetime.now()`
  calls that build output-directory name suffixes now use UTC, which also makes
  the timestamps monotonic across DST rollbacks (avoids collisions).

Lint pinned to ruff==0.16.0. tests/ruff_audit_baseline.json regenerated 70 -> 66
(4 DTZ findings resolved); `python tests/ruff_audit.py --ci` passes.
tests/core_engine/test_licensing.py: 10 passed.

Closes #502

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QBL6TAMVXRUY7iQyy9Ysvi
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 8c3f62f into main Sep 9, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the chore/dtz-utc-licensing branch September 9, 2026 16:06
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.

Ruff DTZ005/DTZ007: naive datetime findings

1 participant