fix(mcp): scan the whole window for backup problems, not the newest rows (audit M9) - #439
Merged
Merged
Conversation
`find_backup_problems` advertises "failed runs in the last 24h", but only inspected the 20 newest runs per group (5 for maintenance) and applied the time and outcome tests in Rust afterwards. The row cap therefore decided which runs got looked at, and the effective window shrank in proportion to how often a group backs up. A group reporting ~120 runs a day with a failure 8h ago followed by more than 20 successes reports no `failed_run` at all, even though the failure sits squarely inside the advertised window. The busier the group, the smaller its window — the opposite of what an operator would assume. Same shape for `stuck_maintenance`. Both scans now select on outcome and time in SQL. The per-group cap stays as a noise bound, but it now bounds real problems rather than deciding which ones are visible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGfH1cdFKPnKpM7ytRThft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes M9 (medium) from the audit in #370.
The bug
find_backup_problemsadvertises "failed runs in the last 24h", but only inspected the 20 newest runs per group (5 for maintenance), applying the time and outcome tests in Rust afterwards. The row cap therefore decided which runs got looked at, and the effective window shrank in proportion to how often a group backs up.A group reporting ~120 runs/day with a failure 8h ago followed by more than 20 successes reports no
failed_runat all — the failure is squarely inside the advertised window. The busier the group, the smaller its window, which is the opposite of what an operator would assume. Same shape forstuck_maintenancebehind its cap of 5.The fix
Both scans use the existing filtered queries —
BackupRunFilters { outcome: Failure, since: now - 24h }andMaintenanceOutcomeFilter::Running— so selection happens in SQL. The per-group cap survives as a noise bound (PROBLEM_LIMIT), but it now bounds real problems rather than deciding which ones are visible.Tests
backup_problems_finds_a_failure_behind_many_later_successes(private-server, through the real/api/mcpendpoint) — a ready group with a failure 8h ago and 30 later successes, all inside the window. Confirmed to fail against the unfixed scan, which reportsproblems: [].Last of four in the audit's "filter-after-LIMIT in the MCP layer" pattern (M7, M8, M9, L14).
Generated by Claude Code