Complete pipeline preflight verification

This commit is contained in:
2026-11-28 04:45:29 +00:00
parent d5056d77b6
commit c08e5ab670
9 changed files with 114 additions and 29 deletions

View File

@@ -35,6 +35,15 @@ type Targets struct {
Access []AccessTarget
}
// TargetError identifies the binding whose initial target could not be selected.
type TargetError struct {
Scope BindingScope
Cause error
}
func (err *TargetError) Error() string { return err.Cause.Error() }
func (err *TargetError) Unwrap() error { return err.Cause }
// DiscoverTargets identifies initial request targets without invoking providers.
func DiscoverTargets(ctx context.Context, resolved pipeline.ResolvedPipeline, catalog pipeline.ModuleCatalog, engine *promptkit.Engine) (Targets, error) {
var targets Targets
@@ -46,7 +55,12 @@ func DiscoverTargets(ctx context.Context, resolved pipeline.ResolvedPipeline, ca
}
profiles := make(map[string]int)
access := make(map[string]int)
add := func(scope BindingScope, class contracts.ExecutionClass, profile string, prompts []string) error {
add := func(scope BindingScope, class contracts.ExecutionClass, profile string, prompts []string) (failure error) {
defer func() {
if failure != nil {
failure = &TargetError{Scope: scope, Cause: failure}
}
}()
if class != contracts.ExecutionClassLLMBacked {
return nil
}

View File

@@ -69,6 +69,11 @@ prompts:
resolved.Chunk.LLMProfile = "missing"
if _, err := DiscoverTargets(context.Background(), resolved, catalog, engine); !errors.Is(err, promptkit.ErrProfileNotFound) {
t.Fatalf("missing profile cause = %v", err)
} else {
var targetErr *TargetError
if !errors.As(err, &targetErr) || targetErr.Scope.Module != "chunk" {
t.Fatalf("missing profile binding scope = %v", err)
}
}
resolved.Chunk.LLMProfile = ""
resolved.Chunk.Module = "dynamic"