Skip to content

feat(go): find files outside the module from go.mod - #63

Merged
grouville merged 11 commits into
mainfrom
go-mod-include-engine-form
Oct 14, 2026
Merged

grouville merged 11 commits into
mainfrom
go-mod-include-engine-form

Conversation

@eunomie

@eunomie eunomie commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Removes //go:resources (unreleased) and #60's Workspace form. From go.mod, generation lists each required local replace target's go.mod, Go files of packages imported from it, and their //go:embed files, erring wide (all build tags, module tests, whole embed directories). dagger v1.0.0-beta.17 (dagger/dagger#14639) loads this resources list into the module context and digest, so edits give fresh results.

Refused: a target leaving the workspace root or without go.mod, an imported package without Go files, an invalid or cross-module embed, a symlinked path, and outside files before v1.0.0-beta.17. Other modules generate byte-identical output.

Other outside files are absent at run time; regenerate after changing replaces, imports or embeds.

On dagger/dagger the scan picks 3-7 files for three modules and none for three, replacing include; all six build offline.

All engine-e2e checks pass on the beta.17 pin and floors.

Non-test: +373/-468.

Walkthrough: https://gistpreview.github.io/?f7660f53e9de013b03da2d3255d4f14d

@eunomie
eunomie force-pushed the go-mod-include-engine-form branch from de979e5 to 69ac267 Compare October 13, 2026 14:01
@eunomie eunomie changed the title feat(go): build from the module context on resource engines feat(go): require the engine's resource support for //go:resources Oct 13, 2026
A module's build can read files outside its directory through the
local replace directives of go.mod. Generation now finds them itself:
the go.mod of each replace target go.mod requires, the Go files of
every package the module imports from one, transitively, and the files
those packages embed, with their assembly, header and syso files. The
list becomes the resources member of the generated entrypoint, so the
engine loads the files with the module, and the entrypoint builds and
runs the module from the module context.

Loading resources needs dagger v1.0.0-beta.17, whose CurrentModule has
contextDirectory and sourceSubpath. Generation refuses a module that
reads files outside its directory on an older engine. A module that
reads nothing outside generates as before.

The //go:resources directive is removed. Generation refuses a replace
target that leaves the workspace root or has no go.mod, an imported
package without Go files, and a path through a symlink, at the go.mod
line or import that needs it.

Signed-off-by: Yves Brissaud <[email protected]>
Pin the target engine to the v1.0.0-beta.17 release, the first that
loads entrypoint resources. The include fixture no longer lists its
files: generation finds them from its replace directive. The module
builds from its context, reuses results across sessions until an
included file changes, and runs from another repository and from a git
source; generation refuses it on the beta.16 floor. The refusals check
covers a replace target that leaves the workspace root, one without
go.mod, an imported package without Go files and a target that
.gitignore hides.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the go-mod-include-engine-form branch from 69ac267 to 7f77348 Compare October 13, 2026 17:54
@eunomie eunomie changed the title feat(go): require the engine's resource support for //go:resources feat(go): find files outside the module from go.mod Oct 13, 2026
@grouville

grouville commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

@eunomie I stacked (and merged) #64 on this PR, targeting go-mod-include-engine-form and retaining your local Go input scanner. The engine resource hook from #60 is not mandatory under this workspace contract, so it is removed.

The confusion was between compiler input selection and function-cache invalidation. Transitive Go imports and embedded files need both: the SDK must provide their current contents, and a cached function result must not skip that work. Receiving a workspace only in the constructor is insufficient if another affected function has no fresh workspace input.

In #64, modules with external compiler inputs must take a required ws *dagger.Workspace on every affected exported constructor and function, and callers must forward it. The fresh workspace participates in the call before cache lookup. The SDK then discovers imports, local replace targets and go:embed at runtime and materializes the selected files. Module developers still filter the files their own pipelines read; the SDK handles compilation filtering for Go.

This reruns discovery for fresh calls, while unchanged selected file contents can reuse compilation caches. I verified it on the unmodified beta.17 engine: changing only an external embedded file changes one to two across fresh CLI sessions without regeneration. Adding an unrelated file still returns two.

So resources are optional for this approach because the workspace contract supplies invalidation. Removing the resource list alone, without that contract, would still allow stale results. The engine rollback and repository module ports will remain separate PRs.

grouville and others added 9 commits October 13, 2026 15:42
Rediscover imported packages, local replacements and embedded files for
workspace-dependent entrypoint calls. Require a workspace on affected
constructors and functions so a cached result cannot skip discovery.

Adapt the local package scanner from Yves Brissaud’s PR #63.

Co-authored-by: Yves Brissaud <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
feat(go): discover external compilation inputs from workspaces
@grouville
grouville merged commit 3d4c37a into main Oct 14, 2026
9 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