Repository navigation
Keep a lease up while finished jobs' results are unfetched - #59
Conversation
A finished job whose retained workspace changes no client has downloaded yet now counts as work on the runner: /v0/info reports such jobs as unfetched, and the cloud peer's idle check counts them, so a lease is not released with results still on the machine, until max_lifetime. A client downloading the changes whole (fetch, --apply, or a run that applies them) records fetched.json in the job's receipt, which ends the count and outlives a restart. Persistent workspaces do not count. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7523e6b548
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A changes download could finish after finalize published the job's result but before it counted the job as unfetched. resultsFetched saw no count and returned without writing fetched.json, and finalize then counted the job for good, keeping the lease up until max_lifetime. The job now carries whether its changes were fetched, set from fetched.json at load and by every whole download, which always writes the record once. noteResultsLocked consults it, so the count and the record agree in whichever order the download and finalize run. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a199530e37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a199530e37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The unfetched count was global to the runner. On a reused machine, such as one from the static pool, results left by an earlier lease or by the machine's own users kept every probe busy, though the new owner could not fetch them, so the lease ran to max_lifetime. /v0/info now reports, by the runner's clock, when it admitted its most recent job and when it admitted the most recent job whose results are unfetched. The cloud peer records the first from the answer that found the lease ready, persisted with the lease, and counts results only when the second is later. Both are the runner's times, so the cloud peer's clock is never compared with them. A new machine has admitted nothing before the lease, so every result there still holds it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de1be43ce0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A job's terminal result was published under its own lock and counted as unfetched later under the daemon's. Job GC, which takes the daemon's lock, could see the result in between and remove the job, and the count then kept an entry for a job the runner no longer had until a restart. The result is now published and counted in one critical section of the daemon's lock, which fetch, job GC, admission rollback and /v0/info all take, so none of them sees a result before it is counted. Counting also requires the job to still be the runner's, and the count is keyed by job, so removing a job that is not counted does nothing. A job on a persistent workspace retains changes too, but they changed the workspace, which ends with a lease without holding it, so they are no longer counted. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a4353a2c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
1 similar comment
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Keeps both #57's workspace transfers and this branch's unfetched results: /v0/info reports transfers and the latest admitted/unfetched times, and the broker counts transfers as work alongside jobs and the lease's own results. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d4661320d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Before: a leased machine was released once its runner had no staging, starting, running or queued jobs for
idle_timeout, even when a finished job's retained workspace changes were still on it and no client had fetched them. A detached run, or a foreground run that does not apply, left its results on the machine, and they ended with the lease.After: a finished job whose retained changes no client has downloaded yet counts as work, as a running job does, if the runner admitted the job during the lease, so the lease stays up until they are fetched or
max_lifetimeends it. Results left on a reused runner (the static pool, or any provider that hands out existing machines) by an earlier lease or the machine's own users do not hold a new lease, since its owner cannot fetch them. On a new machine every job ran during the lease, so every result counts there. Once fetched, the lease is released at the next idle deadline as before. A job that changed nothing never counts. Persistent workspaces do not count, nor do the changes of a job run on one, so they cannot pin a lease to its lifetime by themselves; they still end with the lease. A foreground run that applies its changes is covered from the job's exit to its download: the job is counted before it leaves the running set.What "fetched" means: a client downloaded the job's retained change bundle whole through
GET /v0/jobs/<id>/changes, which is whaterrand fetch(stage, apply or--output),--applyand a run that applies its changes all do. Until now the runner kept no record of this, so the smallest one is added: on the first complete download it writesfetched.json({"fetched_at": ...}) once in the job's receipt directory, so the count survives a runner restart. Removing the job (errand gc jobs, or a client's change GC) also ends the count. Retention expiry does not exist for unfetched receipts today, somax_lifetimeremains the bound.How: the daemon keeps the finished jobs with unfetched changes,
Daemon.unfetched(job to admission time), under the lock/v0/infoalready takes, and a per-job flag under the same lock for whether the job's changes were fetched, set fromfetched.jsonat start-up and by every whole download. A job is counted when it finishes with a non-empty change bundle and no persistent workspace, or is loaded at start-up that way, unless it was fetched.finalizepublishes the terminal state and result and counts the job in oned.mucritical section, before the job leaves the running set. Fetch, job GC, admission rollback and/v0/infoall taked.mu, so none of them sees a result before it is counted. Counting requires the job to still be ind.jobs, so a removed job is never added, and removing a job that is not counted does nothing. A whole download always marks the job fetched, writesfetched.jsononce and drops the job. Removing the job also drops it. The daemon also keeps when it admitted its most recent job,Daemon.lastAdmitted, updated under the lock admission already holds and at start-up./v0/inforeports two runner-clock times (fields at the end ofproto.Info):latest_admitted, its most recent job, andlatest_unfetched, the most recent job whose changes are unfetched (a scan of the unfetched set, no I/O). When a lease becomes ready the cloud peer recordslatest_admittedfrom the answer that found it ready (admitted_before, persisted in the lease record so it survives a cloud peer restart; zero on a new machine), andbusycounts results only whenlatest_unfetchedis later. Both sides of that comparison are the runner's own times, so the cloud peer's clock is never compared with the runner's. Owner scoping was not used: the runner does not know a lease's owner, and over SSH the owner reaches it as a local user. Setup's quiesce does not count unfetched results: they survive a runner restart.Tests:
TestInfoCountsUnfetchedResults(a job that changed nothing never counts but is the latest admitted; the latest unfetched admission moves back when the newer job is downloaded; a second download changes nothing; both survive a restart; job GC ends the count).TestFetchBeforeResultsAreCountedIsRecorded(a download that finishes before the job is counted is recorded, and the count that follows sees it).TestWorkspaceJobResultsAreNotCounted(a workspace job's changes are not counted).TestJobGCRightAfterPublishLeavesNoCount(job GC run from a test hook as soon as the result is visible leaves no count behind).TestUnfetchedResultsKeepLease(unfetched results keep a lease past its idle deadline; after the fetch it is released at the next idle deadline; results never fetched keep it only untilmax_lifetime; the machine's clock is 3h behind the cloud peer's).TestEarlierResultsDoNotHoldLease(a reused machine with an old unfetched result: the new lease idles out, across a cloud peer restart; a later lease's own job's result holds it until fetched; the machine's clock is 3h ahead).This branch is cut from main, separate from #57; both add fields at the end of
proto.Infoand change the broker's busy expression, so whichever merges second has a small conflict there.Closes the #33 item "Results end with the lease".
🤖 Generated with Claude Code
https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Generated by Claude Code