Repository navigation
Description
Depends on: #739 (flyApply, merged), #741 (breadth resources, merged) · Related: #743 (ownership)
The fly lexicon has the write path (build → serialize →
flyApply) but not the read-back seam, sochant diffand drift detection can't see live Fly state. chant already provides the plan/drift machinery (lifecycle/change-set.ts, thediffcommand, reconcile/observe Ops); aws, gcp, azure, and k8s wire it viadescribeResources. fly does not. This adds it.
Context
chant's plan/drift is a framework feature: packages/core/src/lifecycle/change-set.ts classifies every resource create/update/delete/adopt/noop and tags it owned/foreign/unknown, and there's a diff CLI command plus reconcile/observe Ops. It needs one thing from each lexicon: describeResources (and optionally exportResources) on the plugin — list what's live, with an ownership verdict. The fly plugin implements neither, so no plan and no drift for fly.
The applier already computes the diff it needs internally (flyApply does GET-then-create/update, configEqual for noop vs update, and owned-only prune via the managed-by: chant marker). This issue surfaces that read side through the standard seam so it feeds the core change-set, rather than living only inside the apply loop.
What to build (in lexicons/fly/src/)
describeResources({ env, owned? })onflyPlugin(mirrorlexicons/gcp/src/plugin.ts→describe-resources.tsandlexicons/aws). List live Fly resources over flaps — apps and their machines (GET /v1/apps/{app}/machines), and the breadth types (volumes, IPs, certs) — and returnRecord<string, ResourceMetadata>withownership: "owned" | "foreign". Machines:ownedwhenconfig.metadata["managed-by"] === "chant"(reuseisChantOwned/FLY_METADATA_OWNERSHIP_KEYSfrom fly lexicon: ownership convention — machine metadata + app boundary (ties #686) #743). Metadata-less types: report app-boundary ownership consistent with the applier's prune (fly lexicon: Volume + IPAddress + Certificate + Secret (apply-only) resources #741, fly lexicon: ownership convention — machine metadata + app boundary (ties #686) #743). Honor theownedfilter; when a type has no marker channel, log that ownership is unavailable rather than silently returning everything (the seam's contract).- Endpoint + auth: reuse the applier's
resolveEndpoint(FLY_FLAPS_BASE_URL/FLY_API_TOKEN) sodescribeResourcesruns against mudflaps or real Fly, exactly likeflyApply. - Wire the diff: confirm
chant diff(and a fly reconcile/observe Op, if added) now produce a change-set of declared-vs-live for fly. Reuse the applier'sconfigEqualfor the update/noop decision so plan and apply agree. - Optional stretch: a
flyApplydry-run /--planmode that renders the change-set (renderChangeSet) without mutating, so a plan can be reviewed before apply.
Tests
- Unit:
describeResourcesmaps a live flaps machine list toResourceMetadatawith the right ownership verdict (owned vs unmarked). Injected HTTP, like the applier tests. - Integration (against mudflaps, the CI-skip guard): apply an App + Machine, then
describeResourcessees it asowned; a directly-created unmarked machine is reportedforeign; a declared-then-removed machine shows as a delete in the change-set.
Acceptance criteria
-
flyPlugin.describeResourceslists live Fly resources withowned/foreignverdicts, gated by theownedfilter. -
chant diffproduces a declared-vs-live change-set for fly (create/update/noop/delete), agreeing with whatflyApplywould do. - An unmarked machine is
foreignand never appears as a delete. - Runs against mudflaps and (smoke) real Fly via the same endpoint override as the applier.
Out of scope
- A continuous WatchOp/ReconcileOp loop for fly (a natural follow-up once describeResources lands).
exportResources/chant importfor fly (separate).
Activity
fly: describeResources for plan + drift (#767) (#775)
feat(core): observer harness — shared bind/concurrent/tri-state read …