Skip to content

fly lexicon: scaffold chant-lexicon-fly (chant init lexicon + OpenAPI generate) #737

Closed

Description

@lex00

Epic: #736 · Phase: 0 · Depends on: nothing · Blocks: #738, #739, #741, #742, #743

Reviewed 2026-07-11 for cold-handoff. chant has a first-class scaffolder
(chant init lexicon) and a generatePipeline/check-lexicon workflow — use
those, don't hand-mirror another lexicon. The local-test target (mudflaps)
now exists and is built from the same OpenAPI spec this issue generates from.

Context

First issue of the Fly apply-path epic (#736 — read it for the decisions log). Stand up the
@intentius/chant-lexicon-fly package and generate typed Machines-API models so every later
issue builds on real types. The generated types are the shared vocabulary for #738 (resources),
#739 (flyApply), and #742 (lint).

Decisions that constrain this (from #736)

  • D4 — TypeScript, in lexicons/fly, package @intentius/chant-lexicon-fly.
  • D6 — types generated from the OpenAPI 3.0.1 spec
    https://docs.machines.dev/spec/openapi3.json, cross-checked against superfly/fly-go.

What to build

  1. Scaffold with the built-in command (do NOT hand-copy another lexicon):

    chant init lexicon fly     # → lexicons/fly, package @intentius/chant-lexicon-fly
    cd lexicons/fly && npm install

    This generates a compilable LexiconPlugin with all four required lifecycle methods
    (generate/validate/coverage/package) plus serializer, codegen/, spec/, lsp/
    stubs, package.json, tsconfig, a justfile, and tests. It mirrors the AWS lexicon.
    Derived names: plugin flyPlugin, serializer flySerializer, rule prefix FLY.
    Ref: chant init lexicon,
    Scaffold a Lexicon.

  2. Point src/spec/fetch.ts at the OpenAPI spec — fetch (with cache)
    https://docs.machines.dev/spec/openapi3.json. (Swagger copy: /swagger/doc.json.)

  3. Write src/spec/parse.ts — an OpenAPI-3 parser producing one ParsedResult per
    Machines-API schema (Machine, MachineConfig, App, Volume, …). This is the bulk of the work.

    • ParsedResult contract + the generatePipeline callbacks (fetchSchemas, parseSchema,
      createNaming, generateRegistry, generateTypes, generateRuntimeIndex) are documented in
      Implement Generate.
    • Peer to mirror: lexicons/aws/src/spec/parse.ts + lexicons/aws/src/codegen/generate.ts
      (aws parses the CloudFormation spec; fly parses OpenAPI — same ParsedResult contract, different
      input format). NOTE: lexicons/gcp parses Config Connector CRDs, so it is not the parser
      peer, only a structural reference.
  4. Generate + verify field fidelity:

    chant dev generate           # → src/generated/{index.ts,index.d.ts,lexicon.json}

    Cross-check generated field names against superfly/fly-go machine_types.go /
    volume_types.go (instance_id, metadata, state constants) — these are the exact JSON tags
    mudflaps mirrors, so a mismatch here would break both the applier and the emulator target.

  5. Wire it in: add "fly" to the consuming project's chant.config.ts
    lexicons: [...] (that is how a lexicon is loaded — resolution is by short name to the
    @intentius/chant-lexicon-fly package, not a central registry), then
    chant dev onboard fly to wire CI / Docker smoke / npm publish.

Where it lives

lexicons/fly/{package.json,tsconfig.json,justfile}, lexicons/fly/src/{index.ts,plugin.ts,serializer.ts},
lexicons/fly/src/spec/{fetch.ts,parse.ts}, lexicons/fly/src/codegen/{generate.ts,package.ts,naming.ts},
lexicons/fly/src/generated/ (output). The scaffolder creates this layout.

References

  • Authoring: Scaffold,
    Generate,
    Completeness Checklist.
  • LexiconPlugin interface: packages/core/src/lexicon.ts (the 4 required methods).
  • Parser/pipeline peer: lexicons/aws/src/{spec/parse.ts,codegen/generate.ts}. Structure peer: lexicons/gcp.
  • Oracle: github.com/superfly/fly-go (machine_types.go, volume_types.go). Spec: https://docs.machines.dev/spec/openapi3.json.
  • Local-test target (already built): github.com/INTENTIUS/mudflaps — a stateful flaps
    emulator (v0.3.0, public image ghcr.io/intentius/mudflaps) generated from the same OpenAPI
    spec. fly lexicon: chant-side flaps wrapper (boot the mudflaps image for local tests) #740 now only tracks the chant-side flapsUp/Down wrapper, not the emulator itself.

Acceptance criteria

  • chant init lexicon fly scaffolds and lexicons/fly compiles.
  • chant dev generate produces committed Machine/App/Volume types in src/generated/ from
    openapi3.json, with field names matching superfly/fly-go.
  • A project with lexicons: ["fly"] in chant.config.ts loads it; chant list resolves the lexicon.
  • chant dev check-lexicon lexicons/fly passes Tier 1 (required checks).

Out of scope

Resource authoring (#738), the flyApply applier (#739), lint rules (#742). The emulator itself
(#740) already exists as mudflaps; only its chant-side wrapper remains.

Activity

  1. added
    enhancement
    on Jul 10, 2026
  2. changed the title [-]fly lexicon: chant-lexicon-fly package + LexiconPlugin skeleton (types from Machines API OpenAPI)[/-] [+]fly lexicon: scaffold chant-lexicon-fly (chant init lexicon + OpenAPI generate)[/+] on Jul 11, 2026
  3. lex00 commented on Jul 11, 2026

    @lex00
    ContributorAuthor

    Complete OpenAPI-driven generator landed — #750 (merged).

    Rather than clone the aws/CFN generator, this is modeled on k8s, because the Fly Machines OpenAPI spec has no resource marker (136 schemas, ~62 RPC DTOs + config fragments + macaroon/token plumbing). So it's a curated generator: spec-driven shapes, human-curated resource selection.

    Core-3 resources generated: Fly::Machines::{App,Machine,Volume} — writable props from each Create*Request, read-only attributes from the response schema, and the fly.MachineConfig ref-graph walked into 35 typed property-type classes so Machine.config is fully typed (Machines-JSON-shaped — settles the fly.toml-vs-Machines-JSON question in favor of mirroring the wire API, the k8s precedent).

    npm run generate → 3 resources + 35 property types; types-compile, 10 package tests, and check-lexicon Tier 1 all pass.

    Remaining under this epic:

  4. lex00 commented on Jul 11, 2026

    @lex00
    ContributorAuthor

    Scaffold + complete OpenAPI generator landed (#750). generate → 41 curated resources (App/Machine/Volume/IPAddress/Certificate/Secret) + property-type graph, all spec-driven. Serializer (#738/#751), applier (#739/#753), and breadth (#741/#754) all merged on top.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions