Skip idle disk-state scans until expiration

AL
1d ago
+204-5

The disk-state write worker lists and stats every state file on every idle tick, even when no file can expire. Remember the earliest possible expiration and skip disk cleanup until that deadline. Persisted writes and lifetime changes invalidate the cached scan; a generation check preserves invalidation during concurrent writes, and the worker reports the lifetime actually used so configuration changes cannot mislabel a deadline.

With 10,000 unexpired files, the idle disk-cleanup portion of a tick measured 32.60 ms before versus 0.0014 ms for the deadline guard (nine alternating pairs on Python 3.14.5 / Apple M5 Pro). This excludes the rest of the write worker and its queue delay. Startup and due scans still inspect the directory; this targets idle I/O.

Validation:

  • Full unit suite: 8,304 passed, 18 skipped, 75.98% coverage.
  • Worker regression verifies that idle ticks skip scans and expired files are removed. Additional tests cover newly discovered files, lifetime changes, clock rollback, and write/configuration races.
  • Both disk benchmark cases, repository-wide Ruff and Pyright passed.

Independent of the other performance drafts; based directly on main.