Repository navigation
Prune old runs after each build poll so stale branches stop keeping rows [patch] - #398
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
…ows [patch] Every poll added the newest runs a provider reported and nothing removed them, so every branch that ever ran kept its own table row and the app data file grew without bound. After each build poll, Build.PruneRuns keeps ongoing runs, the 50 newest runs, the estimator's 20 newest successful runs, and the newest run of each branch that ran within 30 days, and drops the rest. Fixes #313 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2iZzaJLpHHri8a4vS
|
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 #313
What was wrong
Both providers add the newest 10 runs on every poll (
Runs.GetOrCreate), and nothing removed them except a GitHub 404 or File → Clear Data. Every Dependabot or feature branch that ever ran therefore kept its own row in the table indefinitely.Build.Runsis persisted, so the app data file grew without bound and was re-serialized on every run update.Change
New
Build.PruneRuns(now), called fromBuildSync.UpdateBuildAsyncright after the provider poll, so it covers both GitHub and Azure DevOps. It keeps a run when any of these holds:Build.RetainedNewestRuns);DurationEstimator.MaxSamplesToConsider, nowinternal). The estimator keeps its full sample even when every recent run failed;Build.BranchRetention).Everything else is removed. When anything is pruned, a save is queued. A merged and deleted branch drops out of the table once it is outside both the newest 50 and the 30-day window.
RunSyncs for removed runs were already cleaned up throughIsOrphaned, and only finished runs are pruned anyway.I also updated the "Entity Update Strategy" section of CLAUDE.md with a Run Retention rule, and corrected the "No data accumulation from stale entities" line to say it now covers runs.
Tests
New
RunRetentionTests:MoreRunsThanTheCapAreTrimmedToTheNewest: 80 runs → the 50 newest are kept.AnOldBranchOutsideTheNewestRunsLosesItsRow: the issue's Dependabot scenario.ABranchThatRanWithinTheRetentionWindowKeepsItsNewestRun: only the branch's newest run is kept.TheEstimatorKeepsItsFullSampleWhenRecentRunsFailed: the estimate is unchanged after pruning.RepeatedPollsOfABusyWorkflowStayBounded: a simulated year of daily polls stays under the bound.ABuildUnderTheCapKeepsEveryRunandAnOngoingRunIsNeverDropped: guards on what must be kept.Verified locally on Linux / .NET 10:
PruneRunsstubbed to return 0: the five behaviour tests fail, and the two guard tests pass as expected.Worth a look
The thresholds (50 newest, 30 days) are constants chosen inside the ranges the issue suggests. Adjust them if you'd rather keep more history.
Generated by Claude Code