Read one plain source.Package after the load - #148
Merged
Merged
Conversation
This was referenced Sep 14, 2026
There was a problem hiding this comment.
🟡 Changes recommended
internal/analysis/check.go has an unresolved moderate issue affecting definition source spans.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR introduces source.Package as a plain-data boundary and updates loading, generation, analysis, routing, and CLI wiring to use hydrated source data.
Changes:
- Adds source models and hydration helpers.
- Refactors Muxt, generation, and analysis to consume hydrated packages.
- Updates tests, CLI wiring, and architecture documentation.
File summaries
| File | Summary |
|---|---|
internal/source/source.go |
Defines plain source package, variable, definition, and call data. |
internal/muxt/unmarshal.go |
Uses source package imports for type detection. Nit: group third-party imports before internal imports. |
internal/muxt/name_error_test.go |
Adapts name-position testing. |
internal/muxt/definition.go |
Resolves definitions from source variables. |
internal/muxt/definition_test.go |
Updates definition tests. |
internal/muxt/definition_internal_test.go |
Updates internal definition tests. Nit: separate third-party and internal imports. |
internal/muxt/call.go |
Resolves calls from source.Package. |
internal/muxt/call_test.go |
Updates call resolution tests. Nit: separate third-party and internal imports. |
internal/muxt/call_internal_test.go |
Updates internal call tests. |
internal/load/templates_test.go |
Tests source hydration and directory handling. |
internal/load/source.go |
Hydrates loaded packages into source data. |
internal/load/package.go |
Adds directory-based package lookup. |
internal/load/hydrate.go |
Hydrates command-specific configurations. |
internal/generate/validation_test.go |
Simplifies generator test setup. |
internal/generate/template_route_path.go |
Reads encoding types from source imports. |
internal/generate/routes.go |
Generates routes from source packages. |
internal/generate/groups.go |
Groups source template variables. |
internal/generate/file.go |
Stores source package data in generated files. |
internal/generate/file_test.go |
Updates file and import tests. |
internal/cli/commands.go |
Wires CLI commands through hydration. |
internal/astgen/gen.go |
Simplifies the import manager interface. |
internal/asteval/parse.go |
Uses typed function maps. |
internal/analysis/template_calls.go |
Analyzes hydrated template calls. |
internal/analysis/template_callers.go |
Analyzes hydrated template callers. |
internal/analysis/routes.go |
Lists routes from source packages. |
internal/analysis/check.go |
Checks hydrated template data. Moderate: newGlobal leaves check.Global.Definitions nil, discarding stored source spans. |
CLAUDE.md |
Documents the new architecture. |
Review details
Suppressed comments (2)
internal/muxt/definition_internal_test.go:12
- Please add the blank line separating third-party imports from
internal/...imports, as established by the neighboring Muxt tests. This newly added import currently leaves the two groups merged.
"github.com/typelate/muxt/internal/source"
internal/muxt/unmarshal.go:13
- Keep third-party imports together before the blank line for internal packages. This change places
internal/sourcebetweengithub.com/typelate/domandgolang.org/x/net/html, unlike the established grouping ininternal/generate/routes.go:17-22.
"github.com/typelate/dom"
"github.com/typelate/muxt/internal/source"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
- Files reviewed: 27/27 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
crhntr
force-pushed
the
split/2-generation-fixes
branch
from
September 16, 2026 01:36
9633986 to
ec1fa6c
Compare
crhntr
force-pushed
the
split/3-source-package
branch
from
September 16, 2026 01:36
d59de39 to
38a38d8
Compare
crhntr
force-pushed
the
split/2-generation-fixes
branch
from
September 16, 2026 06:07
ec1fa6c to
e8aca9e
Compare
crhntr
force-pushed
the
split/3-source-package
branch
from
September 16, 2026 06:07
38a38d8 to
db40f24
Compare
crhntr
force-pushed
the
split/3-source-package
branch
from
September 16, 2026 06:22
db40f24 to
52afbac
Compare
crhntr
commented
Sep 16, 2026
There was a problem hiding this comment.
🟢 Approval recommended
Only minor import-grouping nits remain, with no blocking issues.
Review details
Suppressed comments (2)
internal/analysis/template_callers.go:14
- Please keep the new internal import in the established import group: third-party imports are followed by a blank line before
internal/...imports. The current block placesinternal/sourcedirectly aftergithub.com/typelate/check, unlike the grouping used throughout the repository.
"github.com/typelate/check"
"github.com/typelate/muxt/internal/source"
)
internal/analysis/template_calls.go:14
- Please keep the new internal import in the established import group: third-party imports are followed by a blank line before
internal/...imports. The current block placesinternal/sourcedirectly aftergithub.com/typelate/check, unlike the grouping used throughout the repository.
"github.com/typelate/check"
"github.com/typelate/muxt/internal/source"
)
- Files reviewed: 27/27 changed files
- Comments generated: 1
- Review effort level: Lite
crhntr
force-pushed
the
split/3-source-package
branch
2 times, most recently
from
September 16, 2026 06:42
edb59b9 to
49552c3
Compare
Every stage below the command line took []*packages.Package and dug through it for what it needed: a *types.Package to find the templates package's functions, a FileSet for positions, a search through the imports for net/http or encoding, and check.Templates for the template set, its definitions and the ExecuteTemplate calls on it. So nothing could run without a module on disk and the go command. internal/source now holds what they read, as plain data: a Package with its FileSet, its types, the packages it imports by path, and its templates variables. A Variable holds its template set, its functions, its definitions by template name, and its ExecuteTemplate calls, each with a position, the template name and the type of dot. No function fields, no interfaces, nothing that needs a loader. Imports, with Import and SearchImports, is how resolution finds net/http and encoding for now; the next change replaces it with a checker and removes it. - load.Package reads a load into a source.Package, failing at the first variable that does not evaluate. load.GenerateSource and load.RoutesSource hydrate generate's and the route listing's configurations, and still report a missing package, then a missing receiver, before any variable. Reporting a variable's failure when it is loaded, rather than when a stage reaches it, only changes which error is reported when two variables fail differently, and that muxt check stops before checking any variable when one named after it fails to load. Packages are found by directory, so a directory named like a Go file still holds the package. - muxt.Definitions takes a source.Variable and muxt.ResolveCall a source.Package, so muxt no longer links go/packages or typelate/check. - generate.TemplateRoutesFiles takes the package and the receiver, and generate no longer links go/packages. - analysis.Check and the template listings take the package, and build their check.Global from its data. The listings' configurations carry every templates variable, rather than being filled in once per loop pass. The mutation run still reads load.Templates; a later change moves it. Every generated file and report in the integration suite is unchanged. Assisted-by: Claude:claude-opus-5 gofumpt
crhntr
force-pushed
the
split/3-source-package
branch
from
September 16, 2026 06:58
49552c3 to
3b51c46
Compare
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.
Adds internal/source, a plain-data source.Package, which internal/load hydrates from a command's configuration. muxt, generate and analysis read only that. Imports on source.Package is temporary; the next PR removes it.
Part 3 of 8, stacked on #147. Replaces #145.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UjkpA4fvZ7xQAsY65Beprp