Repository navigation
Lite: prove the Agent-status SQL, not just the decision it feeds - #1730
Merged
Merged
Conversation
#1725's tests all run against constructed AgentStatusRow values. That is the right shape for pinning what a row MEANS, but it leaves the query that produces those rows unproven, and it is not trivial SQL: ever_seen_running is a window aggregate that must see the whole retained partition while the surrounding query collapses to the newest row per server. Both ways that goes wrong return a plausible boolean and pass every model-level test: - Collapse to the newest row, and a server that ran Agent yesterday and stopped today reads "never ran Agent" - so a genuine outage renders neutral. That is the failure the fix exists to prevent, reached from the other side. - Leak the partition, and one real server's history makes every Agent-less container read as a server that runs Agent, putting the red "Stopped" back exactly where #1725 removed it. Six real-DuckDB round-trips cover both, plus newest-row-wins, collection_time driving staleness, and the fresh case not being suppressed. Verified non-vacuous by mutation: dropping PARTITION BY server_id from the shipped query fails two of them. Also pins that the stale window stays longer than the collector's own cadence, read from CollectorScheduleDefaults so it follows a retune. That is a live trap, not a hypothetical - the shared ServerHealthThresholds.StaleThreshold is two minutes derived from the FASTEST collector's one-minute cadence, looks like the obvious thing to unify this with, and would render a healthy Agent as "unknown (stale)" most of the time because agent_status collects every five. Tests only. No production code; the shipped query passes as written. Lite.Tests 1510 passed / 0 failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
erikdarlingdata
enabled auto-merge
July 26, 2026 22:33
…ql-roundtrip # Conflicts: # CHANGELOG.md
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.
Tests only. No production code — the shipped query passes as written.
Follow-up to #1725, which I duplicated: I was assigned the same header-honesty job and #1725 landed first. My PR (#1723) is closed as superseded — theirs is complete and I was not going to replace working shipped code with a parallel implementation of the same thing. This is the one piece that was genuinely missing from both.
What was untested
#1725's tests all run against constructed
AgentStatusRowvalues. That is the right shape for pinning what a row means, but it leaves the query that produces those rows unproven — and it is not trivial SQL.ever_seen_runningis a window aggregate that must see the whole retained partition while the surrounding query collapses to the newest row per server.Both ways that goes wrong return a plausible boolean and pass every model-level test:
What this adds
Six real-DuckDB round-trips through
GetAgentStatusAsync:IsAgentProblemnot presentunknown (stale)collection_timePlus a pin that the stale window stays longer than the collector's own cadence, read from
CollectorScheduleDefaultsso it follows a retune.That last pin is a live trap, not a hypothetical
The shared
ServerHealthThresholds.StaleThresholdis 2 minutes, derived from the fastest collector's 1-minute cadence. It looks exactly like the thing someone should unifyAgentStatusRow.StaleWindowwith. Butagent_statuscollects every 5 minutes, so adopting it would render a perfectly healthy Agent asunknown (stale)most of the time. The pin fails if anyone tries.Verification
Lite.Testsfull suite: 1510 passed, 0 failed.OVER (PARTITION BY server_id)toOVER ()and re-ran: 2 of the 6 fail. Restored and re-ran the full suite green. A test that cannot fail is not evidence, and these are load-bearing enough to be worth checking.git statusshows one new test file and the CHANGELOG.Note for whoever coordinates this
Two of us built the same fix in parallel. Worth a look at how the item was assigned, since the duplicated effort was real. Convergent detail worth recording though: independently, #1725 and I both landed on a 30-minute window mirroring the headless service, the same
!IsStale && !AgentRunning && EverSeenRunningrule, and the sameMAX(CASE WHEN agent_running THEN 1 ELSE 0 END) OVER (PARTITION BY server_id)derivation. When two implementations agree that closely the design is probably right.🤖 Generated with Claude Code