Skip to content

FlyMachinesRuntime (restart, Astra): ephemeral Fly Machine per run, one authoritative output path #3798

Done

Description

@integry

Restart of #3767 (FlyMachinesRuntime). The first attempt, #3784, works on real Fly but grew to about 5,400 lines and 36 review findings, mostly from reconciling two output paths (live logs and capture files). Build it fresh from the epic branch with the simpler design below. You may read #3784 for API details, but follow THIS spec where they differ.

Goal

PROPR_AGENT_RUNTIME=fly-machines (or an agent's runtime: fly-machines) runs a Claude Code or Codex agent run in an ephemeral Fly Machine booted from the propr/agent image (Dockerfile.agent), using the clone workspace transport and per-run credential copies, behind the AgentRuntime interface (packages/core/src/agents/runtime/types.ts). Model the structure on the merged Sprites runtime (spritesRuntime.ts, sprites/) and use the shared run pipeline (runPipeline.ts) for workflow markers, the cost cap, the watchdog and secret redaction.

Design (non-negotiable)

  1. One authoritative output path. The run writes stdout, stderr and an exit-status file to a run directory on the Machine. After the agent exits, the runtime reads those files through the Machines exec/file API, bounded (for example a 16 MiB cap per stream, truncating the start and saying so). Only these files feed the result, cost accounting and workflow markers, scanned in full once at the end. Live logs (Machines log API) are display only: best-effort, never reconciled, never used for accounting or status. If an output file cannot be read, the result is marked failed, with an explicit output-unavailable error, never success.
  2. One status file. The wrapper writes a single status file atomically (temp file in the same directory, fsync, rename) with running, then exited <code>. No multi-phase protocol.
  3. Lifecycle. One Machine per run: restart: no, auto_destroy: true, region and size from config. release() (or completion with nothing left to read) destroys the Machine right away. Keep no lingering Machine: the Free plan allows 3 Machines, and a stopped Machine counts toward that limit. stop(signal, timeout) signals the Machine; if it hasn't exited after the timeout, kill and destroy it.
  4. Capabilities. supportsExtensions: false (admission refuses extension runs), supportsBindMounts: false, and no restricted network (refused at admission) unless that's trivial. MCP is reachable over .internal when the control plane is on Fly; otherwise reachable-url.
  5. Secrets. The Fly token never reaches the Machine or the logs. Credential files and secret env go in through the Machine config files and secret env, not the image or the logs.
  6. Size budget. About 1,500 lines of non-test code. Prefer small, flat modules: api client, config, launch and wrapper, handle.

Verified live on real Fly (keep these)

  • Image by digest. A remote build on an app with no releases pushes by digest only, so the tag does not resolve. Document PROPR_FLY_IMAGE=registry.fly.io/<app>@sha256:… and how to find the digest (the build's pushing manifest … @sha256: line).
  • Root, then drop to node. The image's default user is node. Run as root via the Machine config's processes: [{ user: 'root', entrypoint: [...], cmd: [...] }]. The entrypoint and cmd must be explicit; otherwise Fly runs the image default and reports a fake success in about 0.5 s. The wrapper then drops to node the way the Docker entrypoints do.
  • Git ownership. The safe.directory fix is already on the epic branch, in workspaceTransportScript.ts.
  • Timings. About 25–50 s to create the Machine and pull the image; a stop via handle.stop() took effect in 2.3 s with exit 143. The transport still saved its result bundle.

Acceptance

  • Unit tests with a fake Machines API:
    • the happy path;
    • a failed output read gives a failed result;
    • stop() during a run gives exit 143, the Machine destroyed and the result bundle still readable before destroy;
    • release() destroys the Machine;
    • status-file atomicity;
    • extension refusal;
    • a failing workflow hook fails the run (through the shared pipeline);
    • the Fly token is never in the Machine env or logs.
  • A live test, skipped without PROPR_FLY_LIVE_TOKEN and PROPR_FLY_LIVE_APP, covering the task and the stop.
  • Docs in docs/docs/architecture/agent-runtime.md (config, digest image, Free-plan Machine limit) and .env.example.
  • In the PR description, list what still needs live verification. A maintainer will run the live Fly E2E before merge.

Activity

  1. propr-dev commented on Nov 25, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using codex agent with gpt-6.2-astra model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-6.2-astra
    • Branch: 3798/gpt-6.2-astra-flymachinesruntime-restar-20261125-0640-gs1
    • Base Branch: 3758-epic-runtime-abstraction-sc0
    • Worktree: issue-3798-20261125-0640-gpt-6.2-astra-gs1

    🔍 Track Task Execution

  2. integry commented on Nov 25, 2026

    @integry
    OwnerAuthor

    Done via #3801 (FlyMachinesRuntime restart), merged into the epic after live Fly verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions