STET

agent_patch

runs/2026-02-28__13-38-10__gpt-5-3-codex/flux-pr-1380/flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-3-codex/agent-logs/agent.patch

5226 bytes

Back to adjudication
diff --git a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-3-codex/app/v2/pkg/engine/plan/path_builder_visitor.go b/app/v2/pkg/engine/plan/path_builder_visitor.go
index 7ccb90b..949cac4 100644
--- a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-3-codex/app/v2/pkg/engine/plan/path_builder_visitor.go
+++ b/app/v2/pkg/engine/plan/path_builder_visitor.go
@@ -689,13 +689,10 @@ func (c *pathBuilderVisitor) addFieldDependencies(fieldRef int, typeName, fieldN
 	if !ok {
 		c.walker.StopWithInternalErr(fmt.Errorf("missing field requirements configuration for field %s.%s fieldRef %d", typeName, fieldName, fieldRef))
 	}
-	for _, requiresConfiguration := range requiresConfigurations {
-		// add required fields to the current planner to pass it in the representation variables
-		c.planners[currentPlannerIdx].RequiredFields().AppendIfNotPresent(requiresConfiguration)
-	}
 
 	// add dependency to current field planner for all fields which we were waiting for
 	fetchConfiguration := c.planners[currentPlannerIdx].ObjectFetchConfiguration()
+	requiresCrossPlannerDependency := false
 	for _, waitingForFieldRef := range fieldRefs {
 		// we do not check if it exists, because we should not be able to plan a field with requires
 		// in case we haven't planned all required fields
@@ -708,6 +705,7 @@ func (c *pathBuilderVisitor) addFieldDependencies(fieldRef int, typeName, fieldN
 			if plannerIdx == currentPlannerIdx {
 				continue
 			}
+			requiresCrossPlannerDependency = true
 
 			notified := slices.Contains(fetchConfiguration.dependsOnFetchIDs, plannerIdx)
 			if !notified {
@@ -716,6 +714,15 @@ func (c *pathBuilderVisitor) addFieldDependencies(fieldRef int, typeName, fieldN
 			}
 		}
 	}
+
+	if !requiresCrossPlannerDependency {
+		return
+	}
+
+	for _, requiresConfiguration := range requiresConfigurations {
+		// add required fields to the current planner to pass them in representation variables
+		c.planners[currentPlannerIdx].RequiredFields().AppendIfNotPresent(requiresConfiguration)
+	}
 }
 
 func (c *pathBuilderVisitor) isPlannerDependenciesAllowsToPlanField(fieldRef int, currentPlannerIdx int) bool {
diff --git a/app/v2/pkg/engine/plan/path_builder_visitor_test.go b/app/v2/pkg/engine/plan/path_builder_visitor_test.go
new file mode 100644
index 0000000..561fc99
--- /dev/null
+++ b/app/v2/pkg/engine/plan/path_builder_visitor_test.go
@@ -0,0 +1,100 @@
+package plan
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func testPlannerConfiguration(hash DSHash, fetchID int) PlannerConfiguration {
+	ds := &dataSourceConfiguration[any]{
+		DataSourceMetadata: &DataSourceMetadata{},
+		hash:               hash,
+		id:                 fmt.Sprintf("ds-%d", hash),
+		name:               fmt.Sprintf("ds-%d", hash),
+	}
+
+	return &plannerConfiguration[any]{
+		plannerPathsConfiguration: newPlannerPathsConfiguration("query", PlannerPathObject, nil),
+		dataSourceConfiguration:   ds,
+		objectFetchConfiguration: &objectFetchConfiguration{
+			fetchID: fetchID,
+		},
+	}
+}
+
+func TestPathBuilderVisitor_AddFieldDependencies(t *testing.T) {
+	t.Run("does not attach requires on same planner dependencies", func(t *testing.T) {
+		const (
+			dsHash   = DSHash(11)
+			fieldRef = 100
+			depRef   = 101
+		)
+
+		p := &pathBuilderVisitor{
+			planners: []PlannerConfiguration{
+				testPlannerConfiguration(dsHash, 0),
+			},
+			fieldDependsOn: map[fieldIndexKey][]int{
+				{fieldRef: fieldRef, dsHash: dsHash}: {depRef},
+			},
+			fieldsPlannedOn: map[int][]int{
+				depRef: {0},
+			},
+			fieldRequirementsConfigs: map[fieldIndexKey][]FederationFieldConfiguration{
+				{fieldRef: fieldRef, dsHash: dsHash}: {
+					{
+						TypeName:     "Address",
+						FieldName:    "street",
+						SelectionSet: "zip",
+					},
+				},
+			},
+		}
+
+		p.addFieldDependencies(fieldRef, "Address", "street", 0)
+
+		require.Empty(t, p.planners[0].RequiredFields())
+		require.Empty(t, p.planners[0].ObjectFetchConfiguration().dependsOnFetchIDs)
+		require.NotContains(t, p.fieldDependsOn, fieldIndexKey{fieldRef: fieldRef, dsHash: dsHash})
+	})
+
+	t.Run("attaches requires on cross planner dependencies", func(t *testing.T) {
+		const (
+			targetDS = DSHash(11)
+			sourceDS = DSHash(22)
+			fieldRef = 200
+			depRef   = 201
+		)
+
+		p := &pathBuilderVisitor{
+			planners: []PlannerConfiguration{
+				testPlannerConfiguration(targetDS, 0),
+				testPlannerConfiguration(sourceDS, 1),
+			},
+			fieldDependsOn: map[fieldIndexKey][]int{
+				{fieldRef: fieldRef, dsHash: targetDS}: {depRef},
+			},
+			fieldsPlannedOn: map[int][]int{
+				depRef: {1},
+			},
+			fieldRequirementsConfigs: map[fieldIndexKey][]FederationFieldConfiguration{
+				{fieldRef: fieldRef, dsHash: targetDS}: {
+					{
+						TypeName:     "Address",
+						FieldName:    "street",
+						SelectionSet: "zip",
+					},
+				},
+			},
+		}
+
+		p.addFieldDependencies(fieldRef, "Address", "street", 0)
+
+		require.Len(t, *p.planners[0].RequiredFields(), 1)
+		require.Equal(t, []int{1}, p.planners[0].ObjectFetchConfiguration().dependsOnFetchIDs)
+		require.NotContains(t, p.fieldDependsOn, fieldIndexKey{fieldRef: fieldRef, dsHash: targetDS})
+	})
+}
+