Skip to content

go: fix Go self-call schema names and cover dependency use - #2

Merged
eunomie merged 2 commits into
eunomie:workspace-go-no-codegen-at-runtimefrom
grouville:go-self-call-introspection-fix
May 27, 2026
Merged

eunomie merged 2 commits into
eunomie:workspace-go-no-codegen-at-runtimefrom
grouville:go-self-call-introspection-fix

Conversation

@grouville

Copy link
Copy Markdown

This PR is a follow-up against eunomie's workspace-go-no-codegen-at-runtime branch.

That branch changes how Go modules with SELF_CALLS provide the schema used to generate their own Go client. My manual review led to those findings:

  • Go self-calls worked when called directly.
  • Go self-calls also worked when the SELF_CALLS module was used as a dependency.
  • They also worked through a transitive dependency.
  • A separate real issue showed up with exported fields.

The actual bug

A Go module can expose fields on its root object:

type Test struct {
  Message string
}

The engine exposes that field as message, but the new self-call schema emitter was exposing it as Message.

That mismatch can break the generated Go client. In the failing case, generated code could end up with a field and a method using the same Go name, so the code would not compile.

What changed:

  • Emit exported fields in the self-call schema with the same name the engine uses --> Message now becomes message.
  • Extend the existing Go self-call fixture with a Message field.
  • Add an integration test that queries message, proving the generated client compiles and the schema name is correct.
  • Add dependency fixtures to lock down the review concern even though the exact reported failure did not reproduce.

Dependency coverage added:

  • caller -> dep
  • caller -> middle -> dep

The dep module is the only module with SELF_CALLS enabled. That keeps the tests focused on the case from the review.

The new tests verify:

  • a dependency function can self-call through dag.Dep()
  • a container returned by a dependency self-call is still usable by the caller
  • self-calls also work from a secondary object
  • self-calls work when the SELF_CALLS module is a transitive dependency

Tested with:

dagger call engine-dev test --pkg ./core/integration --run '^TestModule/TestSelfCalls' --test-verbose --count=1 --failfast --timeout=20m

Result: 17 passed.

grouville added 2 commits May 26, 2026 16:16
Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>
Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

@eunomie eunomie left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks a lot, I'll merge it 👍

@eunomie
eunomie merged commit 93bf755 into eunomie:workspace-go-no-codegen-at-runtime May 27, 2026
eunomie pushed a commit that referenced this pull request May 27, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request May 27, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request May 28, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request May 28, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request May 28, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request May 28, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request May 29, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request May 29, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request May 30, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request May 30, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 1, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 1, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 2, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 2, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 4, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 4, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 5, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 5, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 8, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 8, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Jun 9, 2026
* go: fix self-call field names

Problem:
When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema
that is then used to generate the module's own Go client.

For exported fields, that schema was using the Go name directly. So a field
called Message was exposed as Message.

The engine exposes that same field as message. Because of that mismatch, the
generated Go client could be wrong. In the case we found, it could generate a
field and a method with the same Go name, which does not compile.

Fix:
Emit exported fields with the same name the engine uses. Message now becomes
message.

Test:
Add a Message field to the existing Go self-call fixture and query message from
the integration test. This proves the generated Go code compiles and the field
is available under the expected name.

Signed-off-by: Guillaume de Rouville <[email protected]>

* tests: cover self-calls from dependencies

Problem:
The review raised a possible failure where a Go module with SELF_CALLS works
when called directly, but breaks when another module depends on it.

If that happened, the caller could still generate Go code for dag.Dep(), but
the running engine would not expose dep at runtime. The user would only see the
failure when calling the function.

We did not reproduce that exact failure, but this is still a useful area to
cover because it is easy to miss. A module dependency is loaded through a
different path than the module being called directly.

Solution:
Add two small Go fixtures:

- self-calls-as-dep: caller -> dep
- self-calls-transitive: caller -> middle -> dep

Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency
case from the review.

Tests:
viaDep calls a dependency function that calls itself through dag.Dep().

viaDepContainer returns a container created by that self-call and then reads
stdout from the caller. This proves the returned object is still usable.

viaDepWorker calls back into dag.Dep() from a secondary object. This proves the
case is not limited to methods on the root object.

viaTransitiveDep calls through caller -> middle -> dep. This proves the
self-call still works when the module with SELF_CALLS is a dependency of a
dependency.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit that referenced this pull request Jun 9, 2026
The self-call introspection emitter must reproduce exactly the names the
engine exposes (the TypeDef path passes raw Go names and lets the engine
normalize them). PR #2 fixed exported struct fields. Apply the same to the
remaining names:

- enum values -> ToScreamingSnake (Active -> ACTIVE); previously always
  mismatched, so a self-called enum value sent the wrong wire name.
- function/constructor arguments -> ToLowerCamel (matches the engine; only
  bit non-lowerCamel params such as acronyms).
- object/interface/enum type names and their type references -> ToCamel
  (only bit acronym type names, e.g. HTTPProxy -> HttpProxy).

Add a Color enum to the Go self-calls fixture and a self-call that passes an
enum argument, covering the enum-value casing end to end.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie pushed a commit that referenced this pull request Oct 9, 2026
A copy-on-write full checkout still rewrote the whole worktree: it removed
the source snapshot's worktree, which cannot be trusted (a workspace
repository carries pending edits), and checked out every file again. On
dagger/dagger (16.5k files, 253MB) `git checkout -f` alone took 6.3s under
load; GitRef.__fullCheckout was #2 on the resume critical path.

When the ref has a checkout base (withCommit and pulls record one, see
LocalGitRef.incrementalCheckoutIneligible), start instead from the base's own
__fullCheckout: a clean worktree of that commit by construction, never
edited. In a copy-on-write child of it:

- fetch only what the base lacks from the source repository, negotiating from
  its HEAD (a checkout's HEAD is usually detached: without the tip, fetch
  would receive the whole history again), keeping packs whole so no
  inherited pack is freshened;
- apply the tree delta to the worktree with the same plan and writer as
  incremental source trees (planIncrementalGitCheckout,
  applyIncrementalGitCheckout), which also gate on ancestry, gitlinks and
  attribute changes; .gitmodules falls back too;
- rebuild .git's metadata as before, but set HEAD and the refs as the
  checkout would (gitCheckoutRefs) instead of running it, and normalize
  timestamps under .git only.

The base checkout is materialized cold only at the top level, as for
incremental trees (incrementalParentTree). Otherwise, and for refs without a
checkout base, unusual ref names, or any failure, the wipe path runs as
before, then the full checkout.

Each copy-on-write checkout now records the path it took (delta, wipe, full),
its detail and the skipped paths' reasons as dagger.git.checkout.cow.path,
.detail and .skipped, and a zero-length wcprof marker of class
git.checkout.<path>[...]. TestCowGitCheckoutDelta compares the result with a
fresh checkout file for file across branch, tag, detached and commit-named
refs and directory/file/symlink reshapes, and bounds the fetched objects by
the delta. In the engine test, the committed head's checkout layer is 0.5MiB
instead of 21MiB.

Signed-off-by: Alex Suraci <[email protected]>
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