Commit a9d2179
committed
fix(0.17.1): static lease reaper missed same-day expirations
The static lease manager wrote expires_at via toISOString()
('2026-05-15T10:00:00.000Z') but compared with SQLite's
datetime('now') ('2026-05-15 10:00:00'). At position 10 of those
two strings, 'T' (0x54) lex-compares greater than ' ' (0x20), so
ANY approved lease whose expires_at fell on the same UTC calendar
day as the current moment lex-compared as still-in-the-future.
Effect:
- listActive() kept expired-today rows in the Active Leases page.
- reapExpired() never revoked them; they sat with revoked=0 until
the UTC date rolled over. Audit confirmed: zero lease.reap
events in our retained history.
Dynamic leases already converted to SQLite format on write
(dynamic/manager.ts:357) and were unaffected.
Fix: every static-lease WHERE that compared expires_at or
request_expires_at to datetime('now') now uses
strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), which produces the
byte-identical format toISOString emits. No DB migration needed
(stored format is unchanged). No API or wire change.
Existing test masked the bug by manually setting expires_at via
SQLite's space-separated datetime() instead of going through the
production write path. Test now writes via toISOString() like
production does. Added a regression test specifically for the
same-day expiration case.
568/568 tests pass.1 parent 8442325 commit a9d2179
4 files changed
Lines changed: 46 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
8 | 17 | | |
9 | 18 | | |
10 | 19 | | |
| |||
196 | 205 | | |
197 | 206 | | |
198 | 207 | | |
199 | | - | |
| 208 | + | |
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
| |||
434 | 443 | | |
435 | 444 | | |
436 | 445 | | |
437 | | - | |
| 446 | + | |
438 | 447 | | |
439 | 448 | | |
440 | 449 | | |
| |||
453 | 462 | | |
454 | 463 | | |
455 | 464 | | |
456 | | - | |
| 465 | + | |
457 | 466 | | |
458 | 467 | | |
459 | 468 | | |
| |||
554 | 563 | | |
555 | 564 | | |
556 | 565 | | |
557 | | - | |
| 566 | + | |
558 | 567 | | |
559 | 568 | | |
560 | 569 | | |
| |||
576 | 585 | | |
577 | 586 | | |
578 | 587 | | |
579 | | - | |
| 588 | + | |
580 | 589 | | |
581 | 590 | | |
582 | 591 | | |
| |||
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
588 | | - | |
| 597 | + | |
589 | 598 | | |
590 | 599 | | |
591 | 600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | 111 | | |
113 | 112 | | |
114 | | - | |
115 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
126 | 146 | | |
127 | 147 | | |
128 | 148 | | |
| |||
0 commit comments