Skip to content

Epic: Fly.io apply path — a Fly lexicon + flaps applier + fake-flaps emulator #736

Closed
8 of 8 issues completed

Description

@lex00

Epic: Fly.io apply path — a Fly lexicon + flaps applier + mudflaps emulator

Status: PLANNING / ready for pickup. Decomposed into 8 child issues (#737–#744) across
4 phases. Each child is written for cold pickup: context, dependencies, concrete paths,
references, and testable acceptance criteria. Start at the critical path (below).

What this is (for someone new to the repo)

chant is a type system for operations: typed TypeScript resources → pure local chant build
→ a spec-native artifact → a native applier that reconciles the artifact against a live
system using cloud-side ownership markers, with no state file. Each provider is a
lexicon (typed resources + lint + serializer + an applier). Today: aws/azure/gcp/k8s/
helm/gitlab/github/forgejo/docker/temporal. This epic adds fly.

The closest existing peer to copy is lexicons/gcp — a direct-REST applier that does its
own diff + owned-only prune (not a stack-deploy like CloudFormation/ARM). Read
lexicons/gcp/src/op/activities/gcp-apply.ts and floci-gcp.ts before starting anything.

Goal

A @intentius/chant-lexicon-fly package + a flyApply applier that speaks Fly's Machines
API (flaps) REST directly and is endpoint-overridable, so the same code targets real Fly or a
local emulator. Plus mudflaps, a standalone stateful flaps emulator (its own repo) that
makes the whole loop runnable offline.

Decisions log (settled — do not re-litigate)

  • D1. Direct flaps REST, no flyctl shell-out, no state file. Same stateless model as the
    other appliers.
  • D2. Ownership marker = machine metadata managed-by: chant (+ a stack/env key). The
    Fly app is the ownership boundary for resource types that lack arbitrary metadata
    (volumes, secrets, certs, IPs). Wire the convention via ownership: lexicons declare their ownership key convention (drop core's aws-tag/azure-tag map) #686.
  • D3. Endpoint override = FLY_FLAPS_BASE_URL (default https://api.machines.dev, all
    paths prefixed /v1). The same mechanism points the applier at real Fly or at mudflaps
    with zero code change. Verified in superfly/fly-go flaps/flaps.go.
  • D4. The lexicon + applier are TypeScript (chant is TS on Bun), living in lexicons/fly.
  • D5. The emulator (mudflaps) is its own repo, written in Go — so it imports
    superfly/fly-go's types (Machine, MachineConfig, MachineLease, state constants,
    NonceHeader) directly and cannot drift from the real wire contract. Shipped as a Docker
    image; chant consumes it only via a flapsUp/Down wrapper (exactly how the gcp lexicon
    consumes the external floci-gcp image).
  • D6. Types are generated from the OpenAPI 3.0.1 spec at
    https://docs.machines.dev/spec/openapi3.json, cross-checked against superfly/fly-go.
  • D7. Secrets are apply-only (set-only, no read-back) — excluded from drift/diff.
  • D8. A stateful flaps emulator is confirmed vacant (nothing on GitHub/npm/crates; only the
    real clients override FLY_FLAPS_BASE_URL). A Prism/WireMock schema mock is not a
    substitute — it has no state machine, leases, or version churn. This is why mudflaps
    exists.

Repo layout (target)

  • lexicons/fly/ — the lexicon (mirror lexicons/gcp/src/**):
    src/spec/openapi3.json, src/generated/, src/codegen/, src/op/activities/{fly-apply.ts,flaps.ts,index.ts},
    src/lint/rules/, src/composites/ (deploy Op). Package name @intentius/chant-lexicon-fly.
  • examples/local-fly/ — the starter example (mirror examples/local-cloud-trio/).
  • mudflaps (separate repo, Go) — the emulator + its own tests; published as a Docker
    image. Done: https://github.com/INTENTIUS/mudflaps v0.3.0 (ghcr.io/intentius/mudflaps, 42
    endpoints, full lease/version/wait fidelity, CI green, MIT). fly lexicon: chant-side flaps wrapper (boot the mudflaps image for local tests) #740 is now only the chant-side wrapper.

The catch (be honest)

  • No server-side declarative apply — flyApply owns the plan→CRUD loop (the gcp model).
  • Local testing is not free: Floci covers AWS/Azure/GCP only and isn't chant's to extend, so
    mudflaps is net-new (Phase 1, un-deferred).
  • Ownership markers are uneven outside Machines (D2) — lean on the app boundary; document it.
  • chant is the typed-spec + lint + drift + reconcile layer above fly deploy, not a
    replacement for its rollout mechanics.

Child issues by phase

Phase 0 — Lexicon scaffold

Phase 1 — The spine (applier + emulator, built together)

Phase 2 — Breadth

Phase 3 — Op + example

Suggested build order (critical path)

#737 → #738 → (#739 ∥ #740) → #744, then breadth (#741/#742/#743) in any order.
#739 and #740 are developed together: the applier is validated against the emulator. #744 is
the integration proof (green offline run). Breadth issues extend an already-working spine.

Definition of done (epic)

  • flyApply deploys App + Machine to mudflaps over REST — create → /wait started →
    update (new version) → owned-only prune — offline, no token.
  • Endpoint override proven: same applier hits real Fly (with a token) and mudflaps with
    only the FLY_FLAPS_BASE_URL change.
  • examples/local-fly runs green with no Fly account and, unchanged, against a real org.
  • Lint catches an invalid region and a mount referencing an undeclared volume at build.

Out of scope

No flyctl shell-out; no state file; not replacing fly deploy's rollout. Not a full flaps
reimplementation (mudflaps covers the applier's endpoint subset + state transitions). Not
upstreaming Fly into Floci.

Related

Applier peers awsApply #734, azApply #707, gcpApply #706; appliers-in-lexicons #714;
ownership seam #686; audit-rule metadata #687; GCP starter pattern #711.

Follow-ups (post-epic)

Beyond the original apply-path scope, tracked separately:

Not pursued: Sprite-as-declarable resource — the create body ({name, wait_for_capacity, url_settings}) has no reconcilable desired state, so #762's Op-primitive model stands.

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Activity

  1. added
    enhancement
    on Jul 10, 2026
  2. changed the title [-]chant has no Fly.io apply path: add a Fly lexicon + applier (direct flaps REST → floci-fly / real Fly)[/-] [+]chant has no Fly.io apply path: add a Fly lexicon + applier (direct flaps REST → real Fly, standalone fake-flaps emulator later)[/+] on Jul 10, 2026
  3. added
    epic
    and removed
    enhancement
    on Jul 10, 2026
  4. changed the title [-]chant has no Fly.io apply path: add a Fly lexicon + applier (direct flaps REST → real Fly, standalone fake-flaps emulator later)[/-] [+]Epic: Fly.io apply path — a Fly lexicon + flaps applier + fake-flaps emulator[/+] on Jul 10, 2026
  5. lex00 commented on Jul 10, 2026

    @lex00
    ContributorAuthor

    Phase-1 update: the mudflaps emulator (#740) now has a live repo — https://github.com/INTENTIUS/mudflaps (Go, MIT, CI green). The local-testing target for flyApply (#739) exists; the applier can be developed against it.

  6. lex00 commented on Jul 11, 2026

    @lex00
    ContributorAuthor

    Epic complete — all sub-issues landed on main

    The Fly.io apply path is built end to end:

    # What PR
    #737 OpenAPI-driven generator (curated, k8s-modeled — 41 resources) #750
    #738 App + Machine serializer (flaps create bodies, D2 marker) #751
    #739 flyApply — direct flaps REST applier (leases / wait-on-version / owned-only prune) #753
    #740 chant-side flaps wrapper (boots mudflaps for local tests) —
    #741 Volume + IPAddress + Certificate + Secret (apply-only, D7) #754
    #742 semantic lint rules + cross-file mount↔volume post-synth check #758
    #743 ownership convention via the #686 seam (single-sourced managed-by) #755
    #744 deploy Op + examples/local-fly (App+Machine end-to-end) #759

    Proven against the live mudflaps emulator: #739's applier integration tests (lease-conflict retry, wait-on-new-version, owned-only prune) and #744's full deploy Op loop (Emulator → Build → Apply → Verify started → Teardown, ok:true) both run against a real container locally and skip cleanly in CI.

    Decisions honored: D1 direct REST (no flyctl/state file), D2 managed-by machine metadata + app-boundary ownership, D3 FLY_FLAPS_BASE_URL override (same code → mudflaps or real Fly), D7 apply-only secrets excluded from drift/diff.

    Closing the epic.

  7. lex00 commented on Jul 14, 2026

    @lex00
    ContributorAuthor

    Follow-ups closed out: #847 (#856), #848 (#850), #849 (#854) all merged to main. Remaining: #855 — spritzer must serve the new fs/policy/services/tasks endpoints (they're fake-only until then).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions