refactor(codegen): generated app foundation and module mount safety#87
Merged
Conversation
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>
Collaborator
Author
|
@codex review |
1 similar comment
Collaborator
Author
|
@codex review |
Collaborator
|
LGTM |
There was a problem hiding this comment.
💡 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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
docs/contracts.mdas an index of machine-readable contracts for generated CLIs, agents, and sibling toolinginternal/codegen/app.Appso codegen parses, normalizes, and validates every configured source before writing any outputauth,search,login, etc.) at codegen time and inruntime.BuildSchemaVersionto 9;runtime.Buildreturns an error on mount collision instead of panickingWhy
Verification
make checkexamples/petstore— output byte-identical for the app-model refactor__lathe verify --json(ok: true, catalog schema intact)