The adoption pass reads the runs inside its window, not the whole archive (#1607) - #1630
Merged
Conversation
…hive (#1607) The cloud-work pass wants the settled web runs of the last 48 hours. It asked the store for every archived run the project has ever had, parsed each one, and then threw away everything outside the window — every ten minutes, forever, while the archive only grows. An archived run is filed as `<id>.json` and an id is the run's start time, so the filename already dates the record. `listAgents` now takes an optional `since` and answers it from the directory listing: a name that parses as one of our ids and is older than the cutoff is skipped before it is opened. On this repo today that is 162 reads per pass down to 4. A name that does not parse as one of our ids is read as before — an id handed in from outside is not a date, and rejecting it unread would hide it from every caller that passes a window. The id is allocated when a run is spawned and `startedAt` written when it first opens its store, so the name can be the older of the two by the length of a spawn; a caller filtering on `startedAt` sees a record leave the window at most that much early, against a window measured in days. The history list, the boot reconcile and every by-id lookup pass no `since` and read the archive whole, as they must. Closes #1607. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
suleimansh
added a commit
that referenced
this pull request
Aug 22, 2026
…hive (#1607) (#1630) The cloud-work pass wants the settled web runs of the last 48 hours. It asked the store for every archived run the project has ever had, parsed each one, and then threw away everything outside the window — every ten minutes, forever, while the archive only grows. An archived run is filed as `<id>.json` and an id is the run's start time, so the filename already dates the record. `listAgents` now takes an optional `since` and answers it from the directory listing: a name that parses as one of our ids and is older than the cutoff is skipped before it is opened. On this repo today that is 162 reads per pass down to 4. A name that does not parse as one of our ids is read as before — an id handed in from outside is not a date, and rejecting it unread would hide it from every caller that passes a window. The id is allocated when a run is spawned and `startedAt` written when it first opens its store, so the name can be the older of the two by the length of a spawn; a caller filtering on `startedAt` sees a record leave the window at most that much early, against a window measured in days. The history list, the boot reconcile and every by-id lookup pass no `since` and read the archive whole, as they must. Closes #1607. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #1607 — its last open note.
The cost
The cloud-work adoption pass wants the settled web runs of the last 48 hours. It asked the store for every archived run the project has ever had, parsed each one, and then let
waitingRunsdrop everything outside the window. That ran every ten minutes, forever, against a directory that only grows.The change
An archived run is filed as
<id>.json, and an id is the run's start time — so the filename already dates the record.listAgentstakes an optionalsince(epoch ms) and answers it from the directory listing: a name that parses as one of our ids and is older than the cutoff is skipped before it is ever opened.Measured on this repo's real archive, through the compiled code with a counting
readseam:Two edges, both deliberate
startedAtis written when it first opens its store. So the name can be the older of the two by the length of a spawn, and a caller filtering onstartedAtsees a record leave the window at most that much early — against a window measured in days.The history list, the boot reconcile and every by-id lookup pass no
sinceand read the archive whole, as they must.Verification
0, exactly those two fail and nothing else does.