Repository navigation
fly: flyApply — direct flaps REST applier (leases, wait, owned-only prune) (#739) - #753
Merged
Merged
Conversation
…ly prune (#739) Native applier that speaks flaps REST directly (D1: no flyctl, no state file), the peer of gcpApply. Consumes the #738 serializer plan and drives flaps in dependency order (app → [volumes #741] → machines): - Endpoint override (D3): FLY_FLAPS_BASE_URL or explicit endpoint, default https://api.machines.dev with the /v1 prefix — same knob points at real Fly or mudflaps. Bearer FLY_API_TOKEN sent when set. - Machines: GET-then-create/update/destroy; after each mutation poll GET .../wait?state=started&version=<new instance_id> (408/not-settled → re-poll, client self-caps past the server's 60s long-poll). - Owned-only prune (D2): only machines with config.metadata["managed-by"]=="chant" are touched; an unmarked machine survives an apply that would otherwise delete it. - Leases: acquire → mutate with the fly-machine-lease-nonce header → release; on a stale-nonce 409 (lease_currently_held / "machine is leased") re-acquire a fresh nonce and retry the mutation once. Pure logic (diff, prune filter, url/lease-conflict decisions) is factored into exported functions and unit-tested with an injected FlyHttp (21 tests). A live mudflaps integration test (#740 wrapper) proves the full acceptance loop and the lease-conflict retry against real wire behavior; it runs locally (docker) and skips deterministically in CI (CI env, no docker pull). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 11, 2026
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 #739 (Phase 1 spine — the meat of the epic). A native applier that speaks flaps REST directly, the peer of
gcpApply. Consumes the #738 serializer plan and drives flaps in dependency order (app → [volumes, #741] → machines).Decisions honored
flyctlshell-out, no state file.config.metadata["managed-by"] == "chant"; an unmarked machine survives an apply that would otherwise delete it.FLY_FLAPS_BASE_URL/ explicitendpointoverride (defaulthttps://api.machines.dev,/v1). Same knob points at real Fly or mudflaps.Bearer FLY_API_TOKENwhen set.The tricky paths (fidelity, from mudflaps' Go source)
GET .../wait?state=started&version=<new instance_id>; 408 / not-settled → re-poll (client self-caps past the server's 60s long-poll).fly-machine-lease-nonceheader → release. On a stale-nonce 409 (lease_currently_held/ "machine is leased"), re-acquire a fresh nonce and retry the mutation once.Tests — two layers
FlyHttp: endpoint resolution, wait-on-version, re-apply no-op, image-change update, owned-only prune (unmarked survives), and the lease-conflict retry (asserts the nonce carried on each attempt).CIenv — no docker pull, the only emulator-backed test in the repo).Full fly suite: 39 passing locally (incl. the live integration run).
validatetypes-compile +check-lexiconclean.Deferred to #741: volumes are ordered between apps and machines (hook in place); non-app/non-machine plan entries pass through the classifier untouched, ready for volume/IP/cert/secret handling.
🤖 Generated with Claude Code