Skip to content

fly: semantic lint rules + cross-file mount↔volume check (#742) - #758

Merged
lex00 merged 1 commit into
mainfrom
fly-lint-742
Jul 11, 2026
Merged

lex00 merged 1 commit into
mainfrom
fly-lint-742

Conversation

@lex00

@lex00 lex00 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Closes #742 (Phase 2 breadth). Replaces the FLY001 placeholder with a real starter rule set so obvious Fly mistakes fail at chant build, not at apply. Mirrors the gcp/aws catalogs.

AST lint rules (lintRules())

ID Rule Severity
FLY001 valid-region — machine region must be a known Fly region error
FLY002 guest-sizing — cpu_kind/cpus/memory_mb must be a valid guest preset error
FLY004 no-secret-literals — inline credential values belong in secrets (D7) or a ref warning

no-secret-literals is conservative: it fires only when a credential-looking key (password/token/secret/api_key/…) has a plain string literal value that isn't a reference/placeholder — so a secrets reference is never flagged.

Whole-stack post-synth check (postSynthChecks())

  • FLY011 mount-references-declared-volume — every machine config.mounts[].volume must resolve to a Volume declared anywhere in the stack.

This one is a post-synth check (reads ctx.entities), not an AST rule, because "in the stack" is inherently cross-file — the AST lint seam only sees one source file at a time. A live Declarable/AttrRef mount is skipped (can't dangle by construction); only string volume names are validated.

Bonus: fixes a latent FLY010 bug

The pre-existing FLY010 (machine-requires-image) read config.image directly, which false-flags a machine whose config was authored as a MachineConfig instance (constructor args nest under a non-enumerable .props). Both checks now share a readProps helper (fly-helpers.ts) that unwraps either authoring style; a new FLY010 test proves the instance form passes.

Notes

  • Region list and guest presets are documented representative sets — the generated types type region as plain string, so there's no enum to import; unit tests stay network-free.
  • 83 fly tests pass; barrel-freshness guard, validate, and check-lexicon Tier 1 all clean.

🤖 Generated with Claude Code

Replace the FLY001 placeholder with a real starter rule set so obvious Fly
mistakes fail at chant build, not at apply. Mirrors the gcp/aws catalogs.

AST lint rules (lintRules(), src/lint/rules/):
- FLY001 valid-region  — machine `region` must be a known Fly region (error).
- FLY002 guest-sizing  — cpu_kind/cpus/memory_mb must be a valid guest preset (error).
- FLY004 no-secret-literals — inline credential values under secret-looking keys
  belong in `secrets` (apply-only, D7) or a reference (warning; conservative
  heuristic keyed on credential names + literal, non-reference values).

Whole-stack post-synth check (postSynthChecks(), src/lint/post-synth/):
- FLY011 mount-references-declared-volume — every machine config.mounts[].volume
  must resolve to a Volume declared anywhere in the stack. Implemented as a
  post-synth check (ctx.entities) rather than an AST rule so it is genuinely
  cross-file, which is what the rule requires. A live Declarable/AttrRef mount is
  skipped (it can't dangle by construction); only string names are validated.

Also fixes a latent bug in the pre-existing FLY010 (machine-requires-image): it
read config.image directly, which false-flags a machine whose config was
authored as a MachineConfig instance (args nested under .props). Both checks now
share a readProps helper (src/lint/post-synth/fly-helpers.ts) that unwraps either
authoring style; a new FLY010 test proves the instance form passes.

Region list and guest presets are documented representative sets (the generated
types type `region` as plain string). 83 fly tests pass; barrel guard, validate,
and check-lexicon Tier 1 clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lex00
lex00 merged commit 0730b1c into main Jul 11, 2026
5 checks passed
@lex00
lex00 deleted the fly-lint-742 branch July 11, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fly lexicon: semantic lint rules (regions, guest sizing, mounts↔volumes, no secret literals)

1 participant