Skip to content

refactor(codegen): generated app foundation and module mount safety#87

Merged
samzong merged 3 commits into
mainfrom
refactor/generated-app-foundation
Jul 2, 2026
Merged

refactor(codegen): generated app foundation and module mount safety#87
samzong merged 3 commits into
mainfrom
refactor/generated-app-foundation

Conversation

@samzong

@samzong samzong commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What's changed?

  • Add docs/contracts.md as an index of machine-readable contracts for generated CLIs, agents, and sibling tooling
  • Introduce internal/codegen/app.App so codegen parses, normalizes, and validates every configured source before writing any output
  • Reject namespaced module names that shadow reserved root commands (auth, search, login, etc.) at codegen time and in runtime.Build
  • Bump SchemaVersion to 9; runtime.Build returns an error on mount collision instead of panicking

Why

  • New tools should name the contract they consume or produce before touching Lathe internals
  • A failing source no longer leaves earlier modules partially written
  • Namespaced modules could previously mount duplicate root commands over runtime-owned commands without any conflict check

Verification

  • make check
  • Regenerated examples/petstore — output byte-identical for the app-model refactor
  • Built petstore and ran __lathe verify --json (ok: true, catalog schema intact)

samzong and others added 3 commits July 2, 2026 03:43
Index the versioned machine-readable contracts that generated CLIs,
agents, and sibling tooling integrate through: generated code schema,
command catalog, verify report, structured errors and exit codes, and
the pinned durable inputs. New tools and capabilities should name the
contract they consume or produce before touching Lathe internals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
… writing

Introduce internal/codegen/app.App as the model of one codegen run:
runCodegen now parses, normalizes, and validates every configured
source into the app first, then writes all outputs in one pass. A
failing source no longer leaves earlier modules partially written.

The model is internal to codegen and not a stable extension API.
Generated output is byte-identical: regenerating examples/petstore
with the previous binary and this one produces no diff.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
Namespaced module mounts previously reached the root command without
any conflict check: a source named auth, search, or login silently
mounted a duplicate root command over the runtime's own. Codegen now
validates namespaced module names against reserved root commands and
duplicate mounts before writing any output, and runtime.Build refuses
to mount a module whose name collides with an existing root command,
matching the check BuildFlat already had.

runtime.Build now returns an error instead of panicking, and the
generated Mount function propagates it. SchemaVersion is bumped to 9
so stale generated code fails fast with a re-run codegen instruction
instead of silently discarding mount errors. The reserved list also
gains login, which NewHiddenLoginCommand mounts at the root.

Verified with make check, then regenerated examples/petstore, built
it, and ran __lathe verify --json (ok true, catalog schema intact).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
@samzong

samzong commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@samzong

samzong commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@scydas

scydas commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

LGTM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e002cf0cef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/codegen/render/render.go
@samzong samzong merged commit b715248 into main Jul 2, 2026
3 checks passed
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.

2 participants