feat(runner): bound auto-summarize to a recency window

In automatic mode the scheduler now only summarizes videos published within
TAPIR_AUTO_SUMMARIZE_WINDOW (default ~7d). Older videos are still discovered
and listed — they keep the manual "Summarize" affordance — but are not
auto-processed, so a large back-catalogue (the maintainer's ~256-deep queue)
stops self-inflicting 429s against the per-IP caption gate each cycle (UX
review B1, recency design).

- runner.WithAutoWindow + Stats.SkippedTooOld; tooOld() treats a zero window
  as disabled and an undated video as never-aged-out (processed, not stranded).
- An explicit manual request bypasses the bound even in auto mode (requested
  videos are loaded in auto mode when a window is active).
- Wired through cmdRun, the scheduler's per-user runner, sumStats, and pass
  logging. config: TAPIR_AUTO_SUMMARIZE_WINDOW (default 168h), .env.example.
- Account copy (A7) updated to match: "Automatic summarizes new videos from
  about the last week; older videos stay browsable — summarize on demand."

The rate gate is untouched; the manual path still serialises through it. This
bounds auto LOAD, it does not fetch harder.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 13:48:04 +02:00
co-authored by Claude Opus 4.8
parent 4a0a56e152
commit 2384c47b81
9 changed files with 199 additions and 42 deletions
+15 -8
View File
@@ -48,18 +48,22 @@ func TestLoad_AppliesDefaults(t *testing.T) {
if c.FetchBackoff != defaultFetchBackoff {
t.Errorf("FetchBackoff = %v, want default %v", c.FetchBackoff, defaultFetchBackoff)
}
if c.AutoSummarizeWindow != defaultAutoSummarizeWindow {
t.Errorf("AutoSummarizeWindow = %v, want default %v", c.AutoSummarizeWindow, defaultAutoSummarizeWindow)
}
}
func TestLoad_ParsesValues(t *testing.T) {
setEnv(t, map[string]string{
"TAPIR_USER_ID": "11111111-1111-1111-1111-111111111111",
"TAPIR_GATEWAY_URL": "http://example/v1",
"TAPIR_GATEWAY_KEY": "sk-test",
"TAPIR_SUMMARIZER_MODEL": "iguana/deepseek-r1-14b",
"TAPIR_SUMMARIZER_TIMEOUT": "90s",
"TAPIR_DB_DSN": "postgres://x",
"TAPIR_POLL_INTERVAL": "10m",
"TAPIR_FETCH_BACKOFF": "30m",
"TAPIR_USER_ID": "11111111-1111-1111-1111-111111111111",
"TAPIR_GATEWAY_URL": "http://example/v1",
"TAPIR_GATEWAY_KEY": "sk-test",
"TAPIR_SUMMARIZER_MODEL": "iguana/deepseek-r1-14b",
"TAPIR_SUMMARIZER_TIMEOUT": "90s",
"TAPIR_DB_DSN": "postgres://x",
"TAPIR_POLL_INTERVAL": "10m",
"TAPIR_FETCH_BACKOFF": "30m",
"TAPIR_AUTO_SUMMARIZE_WINDOW": "48h",
})
c, err := Load()
@@ -84,6 +88,9 @@ func TestLoad_ParsesValues(t *testing.T) {
if c.FetchBackoff != 30*time.Minute {
t.Errorf("FetchBackoff = %v, want 30m", c.FetchBackoff)
}
if c.AutoSummarizeWindow != 48*time.Hour {
t.Errorf("AutoSummarizeWindow = %v, want 48h", c.AutoSummarizeWindow)
}
}
func TestLoad_RejectsBadDuration(t *testing.T) {