nit(security): account_lockout ordering assumes the wall clock never steps backwards — document it, optionally clamp

Author: LearningCircuitCreated Sep 27, 2026Updated Sep 28, 2026
Labelssecuritypriority: lowpythonseverity:nitfrom-review-extractionfollow-up-work-in-progress

Summary

The lockout table's ordering guarantee (iteration order == stamp order) assumes datetime.now never steps backwards; a backward step of a window or more can leave an older stamp after a newer one and linger an expired counter up to one extra window. The direction is conservative and pre-existing - the fix is a docstring/comment note, with stamp clamping as the optional hardening.

Field Value
Severity nit
Origin Review of #6787 (post-merge extraction)
Review section Prose review notes (final re-review)
Classification main-existing
Verified at main@43061a14ebff
Dedup distinct · 1 hit reviewed

Trigger

A wall-clock step backwards of at least one lockout window (NTP correction, VM resume) between two record_failure calls.

Impact

Conservative direction only: nothing releases early, is_locked stays correct, and the stale entry self-heals after one extra window. The new comment at the lock read does not state the assumption.

Pinned evidence

  • 43061a14ebff:src/local_deep_research/security/account_lockout.py:L100-L102 - the under-lock clock-read comment (no clock-step caveat)

Fix direction

Add "assuming the clock doesn't step back" to the comment; if hardening is ever wanted, clamp stamps (max(latest_seen, now)) or order on a monotonic clock.

Targeted tests

None required for the comment; a clamp would deserve a backward-step regression test via the public API.

Provenance

Extracted from review of PR #6787 (post-merge extraction).

Source: LearningCircuit/local-deep-research