Back off by itself when the server is slow; read the library overnight (5,000 titles a night)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 3m1s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 2m0s
release-gate / verify (push) Successful in 9m19s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 13:32:04 +00:00
co-authored by Claude Opus 5.5
parent b9ea5773ef
commit b6f133f452
6 changed files with 67 additions and 4 deletions
@@ -58,4 +58,23 @@ class SafetyLimitsTest {
while (background()) made++
assertEquals(100, made)
}
@Test fun backgroundEasesOffWhenTheServerIsSlowAndRecovers() {
BackgroundPacing.run {
repeat(3) { BackgroundPacing.observe(3_000, true) } // three slow answers
assertEquals(12_000L, BackgroundPacing.gapMs); assertTrue(BackgroundPacing.easedOff)
repeat(10) { BackgroundPacing.observe(100, false) } // errors: up to the ceiling, no further
assertEquals(BackgroundPacing.MAX_GAP_MS, BackgroundPacing.gapMs)
repeat(40) { BackgroundPacing.observe(100, true) } // quick again: back to normal, not below
assertEquals(BackgroundPacing.GAP_MS, BackgroundPacing.gapMs); assertFalse(BackgroundPacing.easedOff)
}
// Watching never moves it.
BackgroundPacing.observe(30_000, false)
assertEquals(BackgroundPacing.GAP_MS, BackgroundPacing.gapMs)
}
@Test fun theOvernightReadOnlyRunsInTheSmallHours() {
assertEquals(1..5, OVERNIGHT_HOURS)
assertEquals(5_000, OVERNIGHT_HOURS.count() * OVERNIGHT_PAGES_PER_HOUR * CATALOGUE_PAGE_SIZE)
}
}