STET

agent_patch

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

4965 bytes

Back to adjudication
diff --git a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_node_suggestions.go b/app/v2/pkg/engine/plan/datasource_filter_node_suggestions.go
index 77b4441..b941b0e 100644
--- a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_node_suggestions.go
+++ b/app/v2/pkg/engine/plan/datasource_filter_node_suggestions.go
@@ -203,6 +203,25 @@ func (f *NodeSuggestions) SuggestionsForPath(typeName, fieldName, path string) (
 	return suggestions
 }
 
+func (f *NodeSuggestions) HasProvidedPath(path string) bool {
+	items, ok := f.pathSuggestions[path]
+	if !ok {
+		return false
+	}
+
+	for i := range items {
+		if items[i].IsOrphan {
+			continue
+		}
+
+		if items[i].IsProvided && items[i].Selected {
+			return true
+		}
+	}
+
+	return false
+}
+
 func (f *NodeSuggestions) HasSuggestionForPath(typeName, fieldName, path string) (dsHash DSHash, ok bool) {
 	items, ok := f.pathSuggestions[path]
 	if !ok {
diff --git a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/node_selection_visitor.go b/app/v2/pkg/engine/plan/node_selection_visitor.go
index bbcffd3..b66f217 100644
--- a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-02-28__13-38-10__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/node_selection_visitor.go
+++ b/app/v2/pkg/engine/plan/node_selection_visitor.go
@@ -7,6 +7,7 @@ import (
 
 	"github.com/wundergraph/graphql-go-tools/v2/pkg/ast"
 	"github.com/wundergraph/graphql-go-tools/v2/pkg/astvisitor"
+	"github.com/wundergraph/graphql-go-tools/v2/pkg/internal/unsafebytes"
 )
 
 // nodeSelectionVisitor walks through the operation multiple times to rewrite it
@@ -290,11 +291,91 @@ func (c *nodeSelectionVisitor) handleFieldRequiredByRequires(fieldRef int, paren
 		return
 	}
 
+	provided := c.areRequiresFieldsProvided(parentPath, requiresConfiguration)
 	// we should plan adding required fields for the field
 	// they will be added in the on LeaveSelectionSet callback for the current selection set
 	// and current field ref will be added to fieldDependsOn map
-	c.addPendingFieldRequirements(fieldRef, dsConfig.Hash(), requiresConfiguration, currentPath, false)
 	c.handleKeyRequirementsForBackJumpOnSameDataSource(fieldRef, dsConfig, typeName, parentPath)
+	if !provided {
+		c.addPendingFieldRequirements(fieldRef, dsConfig.Hash(), requiresConfiguration, currentPath, false)
+	}
+}
+
+func (c *nodeSelectionVisitor) areRequiresFieldsProvided(parentPath string, cfg FederationFieldConfiguration) bool {
+	if cfg.SelectionSet == "" {
+		return false
+	}
+
+	if err := cfg.parseSelectionSet(); err != nil {
+		c.walker.StopWithInternalErr(fmt.Errorf("failed to parse requires selection set %q: %w", cfg.SelectionSet, err))
+		return false
+	}
+
+	if len(cfg.parsedSelectionSet.FragmentDefinitions) == 0 {
+		return false
+	}
+
+	fragment := cfg.parsedSelectionSet.FragmentDefinitions[0]
+	if fragment.SelectionSet == ast.InvalidRef {
+		return false
+	}
+
+	fieldPaths := make([]string, 0)
+	c.collectLeafSelectionPaths(cfg.parsedSelectionSet, fragment.SelectionSet, parentPath, &fieldPaths)
+	if len(fieldPaths) == 0 {
+		return false
+	}
+
+	for _, path := range fieldPaths {
+		if !c.nodeSuggestions.HasProvidedPath(path) {
+			return false
+		}
+	}
+
+	return true
+}
+
+func (c *nodeSelectionVisitor) collectLeafSelectionPaths(doc *ast.Document, selectionSetRef int, basePath string, paths *[]string) {
+	if selectionSetRef == ast.InvalidRef {
+		return
+	}
+
+	for _, selectionRef := range doc.SelectionSets[selectionSetRef].SelectionRefs {
+		selection := doc.Selections[selectionRef]
+
+		switch selection.Kind {
+		case ast.SelectionKindField:
+			fieldRef := selection.Ref
+			fieldName := doc.FieldNameString(fieldRef)
+			if fieldName == "__typename" {
+				continue
+			}
+
+			currentPath := buildSelectionPath(basePath, fieldName)
+
+			if doc.FieldHasSelections(fieldRef) {
+				c.collectLeafSelectionPaths(doc, doc.Fields[fieldRef].SelectionSet, currentPath, paths)
+				continue
+			}
+
+			*paths = append(*paths, currentPath)
+		case ast.SelectionKindInlineFragment:
+			inlineSelectionSetRef := doc.InlineFragments[selection.Ref].SelectionSet
+			c.collectLeafSelectionPaths(doc, inlineSelectionSetRef, basePath, paths)
+		case ast.SelectionKindFragmentSpread:
+			fragmentName := doc.FragmentSpreadNameString(selection.Ref)
+			if fragmentRef, ok := doc.FragmentDefinitionRef(unsafebytes.StringToBytes(fragmentName)); ok {
+				c.collectLeafSelectionPaths(doc, doc.FragmentDefinitions[fragmentRef].SelectionSet, basePath, paths)
+			}
+		}
+	}
+}
+
+func buildSelectionPath(base, field string) string {
+	if base == "" {
+		return field
+	}
+	return base + "." + field
 }
 
 func (c *nodeSelectionVisitor) handleFieldsRequiredByKey(fieldRef int, parentPath, typeName, fieldName, currentPath string, dsConfig DataSource, sc SourceConnection) {