Skip to content

feat(codegen): shared lexicon regen-validate + API surface-diff tooling #524

Closed

Description

@lex00

Part of #523.

Shared backend both upgrade pipelines depend on: regenerate a lexicon from its current spec source, validate the result, and diff the generated public API surface against last-known-good so a reviewer sees added / changed / removed resources and properties.

Scope

  • A reusable step (CLI or library, e.g. chant check-lexicon-adjacent) that for a given lexicon runs the existing prepack chain — generate → bundle → validate → build (tsx src/codegen/generate-cli.ts, src/validate-cli.ts) — plus chant lint and the example harness for that lexicon's examples.
  • API surface snapshot + diff. Extract the generated public surface (resource/property-type names and their prop shapes) into a stable, serializable snapshot; compare a fresh regen against the committed snapshot; classify each change as additive (new resource/optional prop), changed (type/enum/required change), or removed. Emit a human-readable delta + machine-readable JSON, with a rolled-up severity (additive vs breaking) so the pipelines can label PRs and drive design: per-lexicon independent versioning & publish (republish one lexicon without a monorepo release) #528's semver.
  • A committed per-lexicon surface.snapshot.json (or similar) as the last-known-good baseline the diff runs against and a PR updates.

Supply-chain hardening

  • The spec fetch is pinned/verified (digest or known source). Codegen treats the fetched spec strictly as data — it never executes spec-provided input. This tool is the single choke point where untrusted upstream enters an automated pipeline, so the guarantee lives here.

Validation, never auto-fix

  • Build/lint/example/test failures on a regen are captured and returned with the diff for the runner to surface as a report/issue. This tool never rewrites examples or masks a failure.

Acceptance criteria

Notes

  • Generated code is gitignored, so the baseline for the diff is the committed surface snapshot, not the generated files.

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