Repository navigation
[3821 by Claude Opus 5.5] Fly Machines: bake runtime packages into a derived agent image - #3825
Conversation
Fly Machines now bake the runtime packages into a derived agent image again, built once per base image digest and package list. I couldn't run the live acceptance here, so `fly-e2e.yml` (`agent_runtime=fly-machines`) still needs a run from your side. Typecheck and zero-warning lint pass on `packages/core`, and the unit, API and Settings UI suites I ran all pass. One overlap to decide on: the issue says a build Machine must count against `PROPR_FLY_MACHINES_MAX`, but that setting doesn't exist on the base branch; it's #3822's scope. To meet the requirement I put back the cap from before 53a9fb5 (`fly/capacity.ts`, its test, the config field, docs and `.env.example`) and extended it to build Machines. Expect a conflict with #3822's PR; keep whichever cap version you prefer, as long as build Machines and startup leftovers still take slots. Restored from `3807-derived-fly-image-reference` (cfbdeca): `derivedImage.ts`, `registry.ts`, `wrapperBuild.ts`, the wrapper's `build` mode and its test file. These were adapted to the current branch: package MCP servers, per-runtime package lists and the new index format. This includes the R0 publish-time check: every `dpkg -L` file must be in the layer, and the layer must be at least the installed size. New on top of that: - Capacity: - A build Machine takes a slot before it's created and frees it only once Fly confirms it deleted. - One whose deletion or lost create can't be confirmed keeps its slot, and the worker retries the delete in the background every minute. - A run waits for its agent Machine's slot only after any build it needed is gone, so on the Free Plan a run never has both Machines at once. - Leftovers at startup: before its first Fly run, each worker process lists the agent app's `propr-build-*` Machines, and each one holds a slot until it's gone. One older than any build could take is deleted. A younger one may be another worker's build in progress, so it is only waited out. - Lost agent creates: if a create response is lost and the follow-up lookup fails, the run keeps its slot until a lookup succeeds. - Compute usage: `imageWaitMs` (build wait) and `queueMs` (slot wait) are their own fields, and wall time is measured from dispatch. - Settings text: reads "Installed in a derived Fly Machine image" again. - Refactor: to stay under the 400-line lint limit, the build Machine code moved into new modules (`fly/imageBuilder.ts`, `fly/dispatch.ts`, `fly/exitPoll.ts`). Tests: the restored derived-image suite plus 3 new tests pass (36), and so does the capacity suite (9). The new tests cover a build Machine holding a slot so no agent Machine runs beside it, a stuck delete keeping its slot until the background retry, and leftovers found by prefix. I disabled the build Machine's slot and confirmed the two cap tests fail without it. `flyE2eMcpAutomation` fails only when `PROPR_DEMO_MODE=true` is set; it passes without it, and that test only exercises Sprites. Live workflow: - It now expects the "Installed agent runtime packages in a derived Fly Machine image" log line and records the digest the first run built. - A new step then checks from a fresh process: - the same list reuses that digest with no build Machine. - adding `cowsay` builds exactly one new digest. - no Machines are left in the agent app. - I checked that the YAML, shell and embedded script parse; actionlint isn't available here. Docs: the Fly Machines row of the per-runtime package table in `agent-runtime.md`, a new "Derived Fly images" section (build steps, fallback, tag cleanup, capacity), and the Fly tutorial. No previews: the only visible change is that one Settings sentence. ProPR-Agent: claude/claude-opus-5-5
|
/ultrafix goal=8 max=3 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 3) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR restores derived Fly package images with substantial lifecycle handling and tests. It needs changes before merge: the retry path can deadlock under the new capacity cap, and concurrent cache revalidation can start duplicate builds. ✅ Layer integrity checks — The worker verifies compressed and uncompressed digests and rejects layers lacking the wrapper’s dpkg verification. ✅ Cleanup obligations — Unconfirmed build deletion retains its capacity slot and schedules background reconciliation. ✅ Fallback coverage — Tests cover registry failures, installation failures, missing images, and recovery from lost build-create responses. This review is a static analysis of the supplied code; no commands were run. The authoritative check summary reports no failures and five pending checks. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Rebuilding after refusal deadlocks capacity
F2: 🔴 Concurrent rechecks discard replacement builds
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Record live acceptance evidenceRun the updated Fly workflow and attach its build, reuse, changed-list, and teardown results. The mocked registry and Machine tests provide useful coverage, but the implementation summary explicitly leaves live acceptance unverified. This is additional validation, not a separately demonstrated code blocker. ScoreThe integrity checks and extensive tests are valuable, but two concurrency defects remain in core image preparation and capacity handling. Current checks report no failures, with five still pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit ed91970
Summary of ChangesI fixed F1 and F2, and added a regression test for each. I checked that each test fails when its fix is removed: the F1 test hangs until its 15 s timeout, which is the deadlock, and the F2 test builds twice. With the fixes in, the four Fly suites pass (91 tests), and typecheck and zero-warning lint pass on F1: rebuild after a refused create deadlocked under the cap
F2: concurrent rechecks discarded a replacement build
I also added a sentence to the derived-image paragraph in I found nothing else to report. There are no previews, because nothing visible changed. Review digestRisk-tiered paths
Diff size: 4 files changed, +110/−9 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed F1 and F2, and added a regression test for each. I checked that each test fails when its fix is removed: the F1 test hangs until its 15 s timeout, which is the deadlock, and the F2 test builds twice. With the fixes in, the four Fly suites pass (91 tests), and typecheck and zero-warning lint pass on `packages/core`. **F1: rebuild after a refused create deadlocked under the cap** - **Fix:** when Fly refuses an agent create (HTTP 422, so no Machine exists), `createAgentMachine` now gives up the run's slot before it checks the registry or rebuilds. It waits for a slot again only if a retry will actually happen. If the same image comes back or the run is stopping, the run fails without taking the slot back. The build Machine can now get the slot even with `PROPR_FLY_MACHINES_MAX=1`. - **Slot ownership:** `dispatchFlyRun` (in `fly/dispatch.ts`) now holds the run's slot. Its `release()` frees whichever slot the run holds at that moment and does nothing the second time. The runtime's final cleanup, including keeping the slot after a lost create, still calls it unchanged, so a run that gave up its slot and then failed can't free it twice. - **Queue time:** any wait to take the slot back is added to `queueMs`. - **Sibling check:** I found no other place where a run holds its agent slot while waiting on a build. On the first selection the slot is still taken only after the image is ready, and build and leftover slots work as before. Because each refused run frees its own slot first, the larger-cap case where many refused runs used up every slot is covered too. - **Test:** "a refused create under PROPR_FLY_MACHINES_MAX=1 gives up its slot to rebuild the image, then takes it again". It checks the exact order: refused launch, create build, destroy build, create launch, destroy launch. It also checks that only one Machine ever runs at a time, and that a later run gets the freed slot. **F2: concurrent rechecks discarded a replacement build** - **Fix:** in `cachedImage`, a run that finds the tag missing now removes the cache entry only if it is still the entry it checked. If another run already started a replacement build, this run uses that build. - **Sibling check:** the other places that remove cache entries (`invalidate` and the failure handler in `startPreparation`) don't have this problem. - **Test:** "concurrent rechecks that both find the tag deleted share one replacement build". Two runs hold the deleted-tag lookup open at the same time. The test checks that exactly one replacement build runs and that both agent Machines start from the rebuilt image. I also added a sentence to the derived-image paragraph in `docs/docs/architecture/agent-runtime.md` explaining that a run gives up its slot while it rebuilds after a refusal. I found nothing else to report. There are no previews, because nothing visible changed. PR: #3825 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR restores derived Fly images with shared builds, registry caching, fallback installation, and capacity accounting. It needs changes before merge: lost agent creates can release capacity prematurely, and startup reconciliation can prevent cancellation from settling. ✅ Verified layer transfer — The worker checks compressed size, digest, and uncompressed diff ID before publishing. ✅ Rebuild capacity handling — A refused agent create releases its slot before rebuilding, avoiding a deadlock with a cap of one. ✅ Focused regression coverage — Added tests cover shared builds, registry failures, deleted tags, and failed builder cleanup. This is a static review of the supplied code; no commands were run. Current checks report 20 passed, three pending, and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F3: 🔴 Retain capacity for late agent creates
F4: 🔴 Allow cancellation during startup reconciliation
SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Exercise the rebuilt imageThe new live workflow verifies that changing packages publishes a new digest, but does not launch that digest and execute the added package. Extending the smoke test would strengthen end-to-end evidence that the rebuilt layer is usable. This is optional additional coverage; the existing tests already inspect layer contents and publication. ScoreThe implementation has substantial focused coverage, but two recovery and cancellation defects remain in the new capacity lifecycle. The reported checks have no failures, with three still pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 5d41d3e
Summary of ChangesI fixed F3 and F4 and added a regression test for each. Each new test fails on the old code and passes with the fix. F3: lost agent creates kept their slot too briefly
F4: cancelling a run blocked during startup reconciliation
Checks: the capacity suite (11) and the derived-image suite (39) pass. Typecheck and zero-warning lint on Independent discovery: none. Review digestRisk-tiered paths
Diff size: 5 files changed, +106/−11 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed F3 and F4 and added a regression test for each. Each new test fails on the old code and passes with the fix. **F3: lost agent creates kept their slot too briefly** - **Fix:** in `fly/capacity.ts`, an empty lookup after a lost create no longer frees the slot right away. The worker keeps looking the Machine up by name, and only an empty lookup at least 60 seconds after cleanup starts frees the slot. That matches the 60-second window build Machines already get. A failed lookup still frees nothing, and a Machine that turns up late is deleted before the slot is freed. - **Tests:** two new cases in `test/flyMachinesCapacity.test.ts`: - The create's lookups come back empty, then the original Machine appears. The slot stays held, the late Machine is deleted, and only then does the queued run create its own Machine. - Nothing ever appears. The slot is held for the whole window, then freed. - **Sibling paths:** the build-Machine path (`settleLostBuilder`) already had this window. The adopted-create path (`resolveBuilder`) relies on that earlier window, so neither needed changes. **F4: cancelling a run blocked during startup reconciliation** - **Fix:** `dispatchFlyRun` in `fly/dispatch.ts` now waits for the shared leftover reconciliation through `startupStep(signal, …)`. A cancelled run settles straight away with no Machine created. Reconciliation keeps going in the background, and the leftovers it found keep their slots until they are gone. - **Test:** one new case in `test/flyDerivedImage.test.ts` with `PROPR_FLY_MACHINES_MAX=1` and the young leftover listed first. The cancelled run settles at once without touching any Machine. Once the young leftover is gone, the old one takes the slot and is deleted, then the next run starts. **Checks:** the capacity suite (11) and the derived-image suite (39) pass. Typecheck and zero-warning lint on `packages/core` pass. I also updated the lost-create sentence in `docs/docs/architecture/agent-runtime.md`. **Independent discovery:** none. PR: #3825 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR restores derived Fly images with shared builds, registry reuse, fallback installation, and capacity accounting. The supplied code supports the intended approach, but live acceptance remains a material verification gap. ✅ Safe image publication — The worker verifies layer size, compressed digest, uncompressed digest, and the guest’s dpkg verification record before publishing. ✅ Careful capacity handling — Refused agent creates release their slot before rebuilding, avoiding a deadlock with ✅ Focused regression coverage — Added tests exercise concurrent reuse, deleted tags, fallback installation, delayed creates, cancellation, and cleanup failures. This was a static review of the supplied diff and context; no commands were run. Current checks show 21 passed, two pending, and no failures. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Complete live Fly acceptanceRun the updated S4: 🟢 Bound the layer transferConsider passing the remaining build deadline through ScoreThe implementation has substantial targeted coverage and no verified merge blocker from static inspection. Live Fly acceptance is still needed to establish confidence in the central image-building path. Score: 7/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
|
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryI resolved all 8 conflicted files and no conflict markers remain anywhere. The core type-check and lint pass, and the five Fly suites (capacity, runtime, create request, runtime packages, derived image) pass 105 of 105, including the target branch's two new tests. Background: this PR already carried an earlier version of the
The live Fly check in 🤖 Resolution Details
System-triggered merge conflict resolution |
#3823 (
|
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - .env.example - .github/workflows/fly-e2e.yml - docs/docs/architecture/agent-runtime.md - docs/docs/tutorials/setup-fly.md - packages/core/src/agents/runtime/fly/api.ts - packages/core/src/agents/runtime/fly/capacity.ts - packages/core/src/agents/runtime/flyMachinesRuntime.ts - test/flyMachinesCapacity.test.ts PR: #3825 Model: Claude Opus 5.5
|
✅ Applied the requested follow-up changes in commit 56c74bc Summary of ChangesI've reworked the epic merge so #3823's capacity code is the base. All the Fly suites, the core typecheck and zero-warning lint pass. The live Fly Machines runs (default, then cap mode) are still yours to do. The automatic merge commit (588d8cb) had resolved the conflict the wrong way. It deleted #3823's 1. Capacity code (
2. Builder Machine deletion: builder deletion now follows the same rule as R1. New test: every DELETE of a builder fails, then Fly's GET (through the real 3. Smoke workflow ( Tests:
I also added a sentence on the builder deletion rule to Review digestRisk-tiered paths
Diff size: 8 files changed, +146/−85 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've reworked the epic merge so #3823's capacity code is the base. All the Fly suites, the core typecheck and zero-warning lint pass. The live Fly Machines runs (default, then cap mode) are still yours to do. The automatic merge commit (588d8cb) had resolved the conflict the wrong way. It deleted #3823's `FlyMachineSlot` in favour of this PR's own helper, made `MachinesApi.find` optional, and left a second copy of the slot-holding logic in `fly/dispatch.ts`. I undid all three. **1. Capacity code (`fly/capacity.ts`)** - **Kept as-is:** `FlyMachineSlot`, `acquireFlyMachineSlot`, `releaseSlotWhenGone`, `releaseUndeletedFlyMachineSlot` and `MachineCreateUnconfirmedError`. `MachinesApi.gone` and `find` are required again, with #3823's wording. - **R1:** #3823's delete-or-confirm-gone code from `FlyMachineSlot.destroy` is now one function, `deleteFlyMachine`. A 404 on deletion counts as deleted, and so does a failed deletion once `api.gone` says the Machine is gone. Agent and builder Machines both use it. - **What this PR adds on top:** - **Builders count against the cap:** a builder Machine takes a `FlyMachineSlot` of its own. - **F1:** a refused agent create gives up its slot (`releaseUnused`) while it rebuilds the image, then takes it again. `queueMs` includes the second wait. - **F3:** a lost create, whether its lookup failed or found nothing yet, keeps its slot through the 60s lookup window. This applies to agent and builder Machines. - **F4:** a run cancelled during startup reconciliation still stops waiting at once. - **One copy:** the separate slot holder in `dispatch.ts` is gone. The runtime creates the run's `FlyMachineSlot` and passes it to dispatch. **2. Builder Machine deletion:** builder deletion now follows the same rule as R1. New test: every DELETE of a builder fails, then Fly's GET (through the real `MachinesClient`) starts answering 404, as if it had been deleted outside ProPR. The slot is freed, the run waiting behind it starts, and the retries stop. With the gone check removed, the queued run never starts, so the test fails. **3. Smoke workflow (`fly-e2e.yml`):** #3823's cap mode and its webhook delivery check (matched by issue number) are unchanged. The derived-image reuse, rebuild and teardown step now runs only in the default Fly Machines run, not in cap mode. The YAML parses; I couldn't run actionlint here. **Tests:** | Suite | Passed | | --- | --- | | Capacity | 13/13 | | Derived image | 40/40 | | Runtime | 42/42 | | Create request | 3/3 | | Runtime packages | 8/8 | | `flyE2eMcpAutomation` | 2/2 | `flyE2eMcpAutomation` still fails only when `PROPR_DEMO_MODE=true` is set, which isn't caused by this change. One existing test had relied on `find` being missing; it now makes the lookup fail on purpose. I also added a sentence on the builder deletion rule to `agent-runtime.md`. Nothing visual changed, so there are no previews. PR: #3825 Comment by: @integry (ID: 7207255537) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
My review of 56c74bcThe capacity merge looks right:
Please fix these four. They're failure modes that waste the Free Plan's 3 Machines or block runs for close to an hour: R1: a builder that dies mid-build is waited out for the whole deadlineIn
R2: no deadline on the layer download or the pushOnly
R3: a build that fails the same way every time is retried every 10 minutes, foreverEvery non-apt failure is handled the same way: back off for the fixed 10-minute
R4: the size check ignores dpkg
|
|
✅ Applied the requested follow-up changes in commit b3d423a Summary of ChangesI've fixed all four issues and both nits. The derived-image suite (50 tests, 8 of them new) and the other Fly suites pass: 116 tests in total. Typecheck and zero-warning lint on R1: builder dies mid-build
R2: download and push deadlines
R3: exponential backoff
R4: size check
Nits
I updated the "Derived Fly images" section of Review digestRisk-tiered paths
Diff size: 6 files changed, +395/−72 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've fixed all four issues and both nits. The derived-image suite (50 tests, 8 of them new) and the other Fly suites pass: 116 tests in total. Typecheck and zero-warning lint on `packages/core` are clean. I also put the old code back for R1, R3 and R4 and confirmed their new tests fail on it; the R1 test hangs on the old code, as you described. The cap-mode live run is still yours to do.
**R1: builder dies mid-build**
- **Gone check:** `waitForBuild` counts failed probes in a row. After 3 it calls `api.gone(id)` and fails the build straight away if the Machine is gone, so the run falls back without waiting out the deadline. If the `gone` lookup itself errors, polling just carries on.
- **Wrapper:** `build()` in `wrapperBuild.ts` now wraps the whole build. Any exception (from `snapshot()`, `dpkg_installed()` or the Popen) writes `build-error` with its message. It writes `build-failed` only when apt actually ran and failed.
**R2: download and push deadlines**
- **Download:** the result read and the layer download (`scanFile`) now get `AbortSignal.timeout` set to whatever is left of the build deadline.
- **Push:** `RegistryApi.upload`/`blob`/`push` take an optional signal. `pushDerived` runs under a new `pushTimeoutMs` setting (30 min).
- **Signature change:** to stay within the lint parameter limit, `upload` now takes `{ digest, size }` and `push` takes `{ mediaType, body }`.
- **Leftover age:** the startup search now uses a new `builderLifetimeMs`: the build deadline (which now includes the download), plus the deletion window and the lost-create window, plus a 10-minute margin. That works out to `PROPR_FLY_BOOT_TIMEOUT` plus 57 minutes.
**R3: exponential backoff**
- **Schedule:** a failed build backs off for 10 minutes, doubling after each further failure of the same build, up to 24 hours (new `failureBackoffMaxMs` setting).
- **Reset:** a new base manifest or a changed package list starts again at 10 minutes, and a successful build clears the backoff.
- **When it's counted:** each failure is counted once per shared build, however many runs were waiting on it, so concurrent runs can't push it up several steps. The warning is logged once per step, not once per run.
- **Unchanged:** apt failures and failures where a build Machine's deletion can't be confirmed keep their existing handling. A registry error before the base manifest resolves keeps the fixed 10 minutes.
**R4: size check**
- **New field:** the build Machine now reports `layerBytes`, the total size of the packages' regular files that are actually in the layer. It counts each inode once, because tar stores a hard link without data (git-core has many).
- **Check:** the worker requires the uncompressed layer to be at least `layerBytes`. Anything `path-exclude` kept out isn't on disk, so it can't be counted, and the check no longer compares against apt's Installed-Size.
- **Tests:**
- a Python test with a 2 MiB Installed-Size package whose docs are excluded.
- a hard-link test.
- a worker-level test where the layer is smaller than Installed-Size and still gets pushed.
**Nits**
- **Ageing leftover:** `watchUntilGone` now deletes a leftover that was young when found once it passes `builderLifetimeMs`, so it can't hold a slot for good.
- **Re-resolve:** once a run holds the builder slot, `buildLayer` looks up the derived tag again just before the create. If another worker has pushed it by then, the run uses it and creates no build Machine.
I updated the "Derived Fly images" section of `agent-runtime.md` to match. Nothing visible changes, so there are no previews.
PR: #3825
Comment by: @integry (ID: 7207678716)
Model: Claude Opus 5.5
ProPR-Agent: claude/claude-opus-5-5
Live on f095a52: the default mode passes; cap mode fails one log checkDefault Fly Machines mode passes: https://github.com/integry/propr/actions/runs/45980220361 ✅
Cap mode ( The packages did work: the agent's line 2 is the figlet banner, and the instance's
Also, for cap mode, put in the step summary which image the queued second run launched with (it should be the same derived digest, with no second build Machine). I'll run cap mode again once it's pushed. The default mode doesn't need to run again unless the runtime code changes. |
|
✅ Applied the requested follow-up changes in commit b434ca9 Summary of ChangesThe failing check was at fault, not the runtime. Issue #80's agent did launch from the derived image. I fixed the check without weakening it, and the cap-mode summary now says which image the queued run used. What happened in 45982542980: the step searched only What I found in the code: there was a real gap, though it isn't what failed this run. The build line is logged once per shared build, under whichever run started it. In cap mode that can be #81's run. A run that reuses the worker's cached image logged nothing at all, so the queued run's image couldn't be shown. Changes:
Testing:
Because this touches runtime code (one new log line, no behaviour change), you may want to run default mode once more along with cap mode. Default mode now also runs the new launch-line check for its first issue. Review digestRisk-tiered paths
Diff size: 4 files changed, +65/−10 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
The failing check was at fault, not the runtime. Issue #80's agent did launch from the derived image. I fixed the check without weakening it, and the cap-mode summary now says which image the queued run used. **What happened in 45982542980:** the step searched only `flyctl logs --no-tail`, which keeps just the most recent lines. When it ran at 10:44:22, the oldest line it had was from 10:43:16. Both runs had built and started around 10:41, and issue #81 (the queued one) finished at 10:43:18, before #80. So the build line had already dropped out of the buffer when the step looked. The worker process was the same one throughout (pid 20), so it wasn't a restart either. **What I found in the code:** there was a real gap, though it isn't what failed this run. The build line is logged once per shared build, under whichever run started it. In cap mode that can be #81's run. A run that reuses the worker's cached image logged nothing at all, so the queued run's image couldn't be shown. **Changes:** - **Runtime (`fly/derivedImage.ts`):** every agent Machine created from a derived image now logs `Launched the agent Fly Machine from the derived image`, with `run`, `machine`, `image` and the package-list digest. That covers a run that built the image, one that found the registry tag, one that used the cache, and the retry after Fly refuses a create. I added a sentence about it to `agent-runtime.md`. - **Workflow, "Observe idle stop…":** the full log stream (`$OUT/app-logs.jsonl`) now starts at the idle stop in every mode, not only MCP or cap mode. - **Workflow, "Verify the linked PR…":** - It reads the stream plus the `--no-tail` buffer, filtered to after the idle stop. - It still requires the `Installed agent runtime packages in a derived Fly Machine image` line, with the same digest, count and `registry.fly.io/$AGENT_APP@sha256:` checks. - It now also requires a launch line whose run name matches `issue-$ISSUE-` (the format is `<agent>-issue-<n>-<task id>`), with the same image as the build. - **Workflow, cap step:** - It requires a launch line for the run of `$ISSUE2` with the same `DERIVED_IMAGE`. - It requires exactly one build line since the idle stop. - The step summary now shows the queued run's name, its Machine, the image it launched from, and the build count. **Testing:** - I added a test where one run builds and a second run reuses the cached image; both log a launch line with the same image and the build is logged once. The derived-image, capacity and Fly runtime suites pass (117 tests). - Core typecheck and zero-warning lint pass. - The three changed steps parse with `bash -n`. - I ran the new jq selection on logs shaped like this run's. The old query comes back empty, and the new one finds the build and matches the launch line to `issue-80` (and not to `issue-8`). - I couldn't confirm the exact run-name format from real logs, because the failure dump redacts `run` as `<long>`. The `issue-<n>` match is based on the code (`buildClaudeContainerName`). If your cap run fails with "No 'Launched the agent Fly Machine…' record for the run of …", that match is the place to look. Because this touches runtime code (one new log line, no behaviour change), you may want to run default mode once more along with cap mode. Default mode now also runs the new launch-line check for its first issue. PR: #3825 Comment by: @integry (ID: 7216310644) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
Cap mode on b434ca9: the queued run hit Fly's machine limit (HTTP 422) even with PROPR_FLY_MACHINES_MAX=1https://github.com/integry/propr/actions/runs/45990086071. The first issue (#88) built the derived image ( The step then waited out its timeout: "No unique linked PR for the queued run integry/propr-fly-fixture#89". The likely cause: the queued run created its Machine the moment the slot was freed, and Fly still counted a Machine that was on its way out. That would be the first run's agent Machine (deletion returned but not yet removed from the org count), or this PR's builder Machine, if its slot is freed when the build finishes rather than when Fly confirms it's gone. The ProPR Machine plus that one plus the new one is 4 > 3. #3823's cap runs passed without a builder, which points at the builder. Fixes (all three):
Tests: a create that gets a 422 twice and then succeeds keeps one slot and launches once. A builder whose exit comes before The fix for the earlier cap-mode log check worked: the derived image was found and the install was logged. I'll rerun cap mode after this. |
|
✅ Applied the requested follow-up changes in commit 142907c Summary of ChangesI've made all three fixes. The Fly suites pass (capacity 15/15, derived image 52/52, runtime/create-request/packages 53/53), and typecheck and zero-warning lint pass on 1. Builder slot ( 2. 422 "machine limit" is now a capacity wait (new
3. Diagnostics. Each 422 logs Tests. The three you asked for are in, and each one fails when its fix is disabled:
Three existing tests changed because builders now get an extra Decision for you: your request says builders should wait for No previews: nothing visible changed. Review digestRisk-tiered paths
Diff size: 7 files changed, +202/−21 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've made all three fixes. The Fly suites pass (capacity 15/15, derived image 52/52, runtime/create-request/packages 53/53), and typecheck and zero-warning lint pass on `packages/core`. I couldn't reproduce the live cap-mode run here, so your rerun is the real check. **1. Builder slot (`fly/imageBuilder.ts`).** `removeBuilder` used to return as soon as the DELETE succeeded, and that freed the slot. It now deletes once, then keeps polling `api.gone(builder)` until Fly confirms the Machine is gone. Only then is the slot freed. If that isn't confirmed within the removal window, the builder becomes an unresolved Machine that keeps its slot and is retried in the background. This also covers the other places builders get deleted: lost creates, unresolved records and leftovers from an earlier worker. **2. 422 "machine limit" is now a capacity wait (new `fly/machineLimit.ts`).** - **Retry:** `createWithinMachineLimit` retries the same launch (same name) after 5, 10, 20, 40 and then 60 s waits, for up to 5 minutes. The run keeps its slot the whole time. Each retry logs `Fly organization machine limit reached; retrying create` with `attempt` and `delayMs`. - **Failure:** after the bound the run fails with `Fly organization machine limit reached: Fly refused the Machine create N times over Ns (…Fly's 422 message…). Delete Machines in the Fly organization or raise its limit, then retry the run.` - **Where it applies:** agent creates, including the retried create after a refusal, and builder creates. - **Derived image:** a machine-limit refusal no longer makes the worker discard its derived image and select again. - **Builder past the bound:** a builder still refused falls back to installing the packages at Machine start. - **Stopping:** a run that is being stopped ends the wait. **3. Diagnostics.** Each 422 logs `Fly organization machine limit reached; Machines in the agent app` with only `id`, `state` and `name` for each Machine. **Tests.** The three you asked for are in, and each one fails when its fix is disabled: - A create refused twice and then accepted keeps one slot: three POSTs with the same name, one Machine, the queued run never overlaps (peak 1), and two Machine-list logs. - A builder whose deletion returns but which Fly still lists holds the slot: no agent Machine is created until `gone` is true. - After the bound, the run fails with the machine-limit message and the next run gets the slot. Three existing tests changed because builders now get an extra `gone` check: one expected gone-check count went from 1 to 2, the fake-fetch test now answers `GET /machines/late1`, and the leftover fake now reports a deleted leftover as gone. The docs (`agent-runtime.md`, `setup-fly.md`) describe the retry, its log lines and the "gone, not just deleted" rule for builders. **Decision for you:** your request says builders should wait for `gone` "as for agent Machines", but agent Machines don't do that. Their slot is still freed when the DELETE returns (the same `deleteFlyMachine` rule from #3823); I left that alone because fix 1 named only the builder. So a deleted agent Machine that Fly still counts can still trigger a 422 on the next run, which the new retry now absorbs. Making agent slots also wait for `gone` would let the queued run wait in the queue instead of hitting a 422 at all. It's a small change if you want it. No previews: nothing visible changed. PR: #3825 Comment by: @integry (ID: 7218159098) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
Cap mode on 142907c: the 422 retry works, but the check rejects it, and we can't yet see what Fly countedhttps://github.com/integry/propr/actions/runs/46003305762. Both runs finished: the queued issue #96 opened PR #97 at 13:14:52, and the first issue #95 opened PR #98 at 13:15:49. So the new retry on HTTP 422 recovered. The step failed only because its check rejects any log line matching "machine limit": With Please:
I'll run cap mode again after this. |
|
✅ Applied the requested follow-up changes in commit 1045708 Summary of ChangesI've made changes 1 and 2. For change 3, I didn't change when slots are freed, because I still couldn't see what Fly counted. The record from run 46003305762 only existed in 1. Showing the diagnostic
2. A precise check
The tests now also check that destroyed Machines are requested, what the logged Machine list contains, and that exactly one outcome record is logged on success and when the bound is reached. The docs describe the new records. 3. What I found
Decision for you: the next cap-mode run will show what Fly counted. If it lists the other run's agent Machine ( Review digestRisk-tiered paths
Diff size: 6 files changed, +181/−22 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've made changes 1 and 2. For change 3, I didn't change when slots are freed, because I still couldn't see what Fly counted. The record from run 46003305762 only existed in `$OUT/app-logs.jsonl`, and the job log has only the step's error line. Also, Fly's default Machine list leaves out destroyed Machines, so that record may not have shown the cause anyway. The Fly suites, typecheck and zero-warning lint all pass. I ran the new report script against made-up logs for each case, but not in the real workflow, and actionlint isn't available here. **1. Showing the diagnostic** - **Destroyed Machines are now listed:** on each 422, the worker lists the agent app's Machines with `include_deleted=true`, so a Machine Fly destroyed but still counts shows up. Each one is still only `id`, `state` and `name`. - **Each retried create logs how it ended:** either `… create accepted after retries` or `… create given up`, with `attempts` and `waitedMs` (time since the first refusal). - **Output:** a new script, `.github/fly-e2e/machine-limit-report.sh`, prints every Machine list in the step output and as a table in the step summary. It also runs when the queued run opens no PR, so a failed run's list is shown before the step fails. - **Artifact:** a new `always()` step runs `app-logs.jsonl` through `redact_fly_tokens` and uploads it as `fly-e2e-worker-log-<attempt>` with `retention-days: 1`. Only the redacted copy is uploaded. I also replace GitHub token patterns (`gh?_…`, `github_pat_…`), since the artifact can be downloaded from a public repo. If a Fly token fragment turns up, the copy is still uploaded and that step fails. **2. A precise check** - **It fails when:** - a create was given up. - a run failed with Fly's raw 422 (any line mentioning "machine limit" that isn't one of the new records). - a create was refused but logged no outcome. - an accepted create needed more than 3 retries or more than 60 s. - **It warns** (`::warning::`, with the last Machine list) when a create was retried and then accepted within that bound. The tests now also check that destroyed Machines are requested, what the logged Machine list contains, and that exactly one outcome record is logged on success and when the bound is reached. The docs describe the new records. **3. What I found** - **`destroying` already counts as not gone.** `MachinesClient.gone` returns true only for `destroyed` or a 404, so no change was needed there. - **A 2 s settle delay would apply only to builders.** Builder slots are the only ones freed after `gone`. An agent Machine's slot is still freed as soon as its DELETE returns, without waiting for `gone`. - **My guess at the cause:** an agent Machine being torn down, not a builder. The queued #96 finished first, so #95's agent create likely came right after #96's Machine was deleted. I can't confirm that from the logs I had. **Decision for you:** the next cap-mode run will show what Fly counted. If it lists the other run's agent Machine (`destroying`, or `destroyed` but still counted), the fix is to free agent slots on `gone` plus a short settle delay, not the delay on builders alone. If it lists a `propr-build-*` Machine in `destroyed`, a settle delay after the builder's `gone` is enough. Tell me which and I'll add it. PR: #3825 Comment by: @integry (ID: 7219338238) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR restores derived Fly images with shared builds, registry reuse, fallback installation, and builder capacity accounting. It is merge-ready within the reviewed scope, conditional on the pending checks completing successfully. ✅ Capacity coordination — Image selection precedes agent-slot acquisition, and a refused derived-image create releases its slot before rebuilding, avoiding a deadlock with ✅ Builder cleanup — Builder deletion is confirmed through ✅ Image verification — Publication follows package-file verification and worker-side checks of the downloaded layer’s size, compressed digest, and uncompressed digest. This was a static review of the supplied diff and surrounding context. No commands were run. The supplied current-head status reports 19 passed checks, four pending, and no failures. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S7: 🟢 Exercise diagnostic reporting independentlyAdd small fixture-based tests for S8: 🟢 Refresh the smoke-test descriptionThe “Nightly smoke fixture” paragraph in ScoreThe implementation addresses the core objective and includes substantial coverage of failure, cleanup, and concurrency paths. No merge-blocking defect was established from the supplied code; final readiness remains conditional on the pending checks. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/ultrafix goal=8 max=3 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 3) First action:
|
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR restores derived Fly images keyed by base manifest and package list, with shared builds, start-time fallback, and capacity accounting. Based on the supplied diff and surrounding context, it is merge-ready within the reviewed scope. ✅ Safe build teardown — Build slots remain held until deletion is confirmed; unresolved creates and deletions retain cleanup obligations. ✅ Verified image transfer — The wrapper checks package-file coverage, and the worker validates compressed size, digest, and uncompressed diff ID before publishing. ✅ Focused regression coverage — Added tests exercise shared builds, cancellation, missing cached images, lost creates, and capacity retention. The authoritative checks report 24 passed, zero failed, and zero pending. This was a static review; no commands or live Fly tests were run. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S9: 🟢 Exercise multi-chunk registry uploadsThe registry test named “uploads in chunks” supplies a small layer that exercises only one PATCH. An additional fixture exceeding S10: 🟢 Record live acceptance evidenceAttach results from both the ordinary Fly Machines workflow and its capacity mode when available. These would complement the supplied unit coverage by exercising actual registry authentication, image application, and Fly deletion visibility. No failure in those external interactions is established by this review. ScoreThe implementation addresses the objective with substantial recovery and regression coverage, and all reported current-head checks pass. Static review found no demonstrated merge blocker. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3821
Branch:
3821/claude-opus-5-5-fly-machines-bake-runtime-20261126-2328-m2dCommits: ✅ Changes committed (d2359b4)
AI Processing Completed
Execution Details:
Summary:
Fly Machines now bake the runtime packages into a derived agent image again, built once per base image digest and package list. I couldn't run the live acceptance here, so
fly-e2e.yml(agent_runtime=fly-machines) still needs a run from your side. Typecheck and zero-warning lint pass onpackages/core, and the unit, API and Settings UI suites I ran all pass.One overlap to decide on: the issue says a build Machine must count against
PROPR_FLY_MACHINES_MAX, but that setting doesn't exist on the base branch; it's #3822's scope. To meet the requirement I put back the cap from before 53a9fb5 (fly/capacity.ts, its test, the config field, docs and.env.example) and extended it to build Machines. Expect a conflict with #3822's PR; keep whichever cap version you prefer, as long as build Machines and startup leftovers still take slots.Restored from
3807-derived-fly-image-reference(cfbdeca):derivedImage.ts,registry.ts,wrapperBuild.ts, the wrapper'sbuildmode and its test file. These were adapted to the current branch: package MCP servers, per-runtime package lists and the new index format. This includes the R0 publish-time check: everydpkg -Lfile must be in the layer, and the layer must be at least the installed size.New on top of that:
propr-build-*Machines, and each one holds a slot until it's gone. One older than any build could take is deleted. A younger one may be another worker's build in progress, so it is only waited out.imageWaitMs(build wait) andqueueMs(slot wait) are their own fields, and wall time is measured from dispatch.fly/imageBuilder.ts,fly/dispatch.ts,fly/exitPoll.ts).Tests: the restored derived-image suite plus 3 new tests pass (36), and so does the capacity suite (9). The new tests cover a build Machine holding a slot so no agent Machine runs beside it, a stuck delete keeping its slot until the background retry, and leftovers found by prefix. I disabled the build Machine's slot and confirmed the two cap tests fail without it.
flyE2eMcpAutomationfails only whenPROPR_DEMO_MODE=trueis set; it passes without it, and that test only exercises Sprites.Live workflow:
cowsaybuilds exactly one new digest.Docs: the Fly Machines row of the per-runtime package table in
agent-runtime.md, a new "Derived Fly images" section (build steps, fallback, tag cleanup, capacity), and the Fly tutorial.No previews: the only visible change is that one Settings sentence.
Review digest
Risk-tiered paths
.github/workflows/fly-e2e.yml(+62/−3): CI or workflow file.env.example(+3/−0)packages/core/src/agents/runtime/agentRuntimePackageIndex.ts(+7/−6)packages/core/src/agents/runtime/agentRuntimePackageProfile.ts(+1/−1)packages/core/src/agents/runtime/computeUsage.ts(+4/−0)packages/core/src/agents/runtime/fly/api.ts(+66/−7)packages/core/src/agents/runtime/fly/capacity.ts(added, +124/−0)packages/core/src/agents/runtime/fly/config.ts(+3/−1)packages/core/src/agents/runtime/fly/derivedImage.ts(added, +378/−0)packages/core/src/agents/runtime/fly/dispatch.ts(added, +78/−0)packages/core/src/agents/runtime/fly/exitPoll.ts(added, +70/−0)packages/core/src/agents/runtime/fly/imageBuilder.ts(added, +282/−0)packages/core/src/agents/runtime/fly/packages.ts(+5/−2)packages/core/src/agents/runtime/fly/registry.ts(added, +169/−0)packages/core/src/agents/runtime/fly/wrapper.ts(+31/−15)packages/core/src/agents/runtime/fly/wrapperBuild.ts(added, +246/−0)packages/core/src/agents/runtime/flyMachinesRuntime.ts(+41/−84)docs/docs/architecture/agent-runtime.md(+23/−5)docs/docs/tutorials/setup-fly.md(+2/−2)packages/api/test/agentRuntimeIndexRoutes.test.ts(+2/−2)packages/api/test/agentRuntimeRoutes.test.ts(+1/−1)propr-ui/src/pages/SettingsPage/AgentRuntimePackagesSection.test.tsx(+3/−3)test/agentRuntimePackagesRemoteSettings.test.ts(+4/−4)test/flyDerivedImage.test.ts(added, +1,090/−0)test/flyMachinesCapacity.test.ts(added, +281/−0)test/flyMachinesCreateRequest.test.ts(+2/−0)test/flyMachinesRuntime.test.ts(+2/−0)test/flyRuntimePackages.test.ts(+5/−1)Diff size: 28 files changed, +2,985/−137 lines
View task for the run's logs and conversation.
This PR was created automatically by ProPR after processing issue #3821.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!