Define typed producer assessment and native execution dependencies
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
@@ -19,9 +19,9 @@ type Document struct {
|
||||
}
|
||||
|
||||
type PipelineDocument struct {
|
||||
Mode *pipeline.ExecutionMode `yaml:"mode,omitempty"`
|
||||
Mode *contracts.ExecutionMode `yaml:"mode,omitempty"`
|
||||
MaxAdditionalTurns *int `yaml:"max_additional_turns,omitempty"`
|
||||
Cache *pipeline.CacheMode `yaml:"cache,omitempty"`
|
||||
Cache *contracts.CacheMode `yaml:"cache,omitempty"`
|
||||
LLMProfile *string `yaml:"llm_profile,omitempty"`
|
||||
Input BindingDocument `yaml:"input"`
|
||||
Chunk *BindingDocument `yaml:"chunk,omitempty"`
|
||||
@@ -49,9 +49,9 @@ type ArtifactLaneDocument struct {
|
||||
// deliberately finite subset so nested validator-only fields are rejected by
|
||||
// ConfigKit's strict decoder.
|
||||
type BindingDocument struct {
|
||||
Mode *pipeline.ExecutionMode `yaml:"mode,omitempty"`
|
||||
Mode *contracts.ExecutionMode `yaml:"mode,omitempty"`
|
||||
MaxAdditionalTurns *int `yaml:"max_additional_turns,omitempty"`
|
||||
Cache *pipeline.CacheMode `yaml:"cache,omitempty"`
|
||||
Cache *contracts.CacheMode `yaml:"cache,omitempty"`
|
||||
Module string `yaml:"module"`
|
||||
LLMProfile *string `yaml:"llm_profile,omitempty"`
|
||||
Options map[string]any `yaml:"options,omitempty"`
|
||||
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
)
|
||||
|
||||
type ResolveInput struct {
|
||||
CacheOverride *pipeline.CacheMode
|
||||
CacheOverride *contracts.CacheMode
|
||||
PipelineID string
|
||||
Only []string
|
||||
Catalog pipeline.ModuleCatalog
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
@@ -449,21 +450,21 @@ func sortedDocumentKeys[T any](values map[string]T) []string {
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
func normalizeDocumentControls(mode **pipeline.ExecutionMode, cache **pipeline.CacheMode, path configkit.Path, resolution documentNormalizer) {
|
||||
func normalizeDocumentControls(mode **contracts.ExecutionMode, cache **contracts.CacheMode, path configkit.Path, resolution documentNormalizer) {
|
||||
if *mode != nil {
|
||||
value := pipeline.ExecutionMode(strings.TrimSpace(string(**mode)))
|
||||
value := contracts.ExecutionMode(strings.TrimSpace(string(**mode)))
|
||||
if **mode != value {
|
||||
normalizeDocumentValue(resolution, path.Key("mode"), mode, &value, "trimmed execution mode")
|
||||
}
|
||||
}
|
||||
if *cache != nil {
|
||||
value := pipeline.CacheMode(strings.TrimSpace(string(**cache)))
|
||||
value := contracts.CacheMode(strings.TrimSpace(string(**cache)))
|
||||
if **cache != value {
|
||||
normalizeDocumentValue(resolution, path.Key("cache"), cache, &value, "trimmed cache mode")
|
||||
}
|
||||
}
|
||||
}
|
||||
func validateDocumentControls(mode *pipeline.ExecutionMode, turns *int, cache *pipeline.CacheMode, path configkit.Path, validation *configkit.Validation) {
|
||||
func validateDocumentControls(mode *contracts.ExecutionMode, turns *int, cache *contracts.CacheMode, path configkit.Path, validation *configkit.Validation) {
|
||||
if mode != nil {
|
||||
if _, err := pipeline.ParseExecutionMode(string(*mode)); err != nil {
|
||||
validation.Error(path.Key("mode"), err.Error())
|
||||
|
||||
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ pipelines:
|
||||
t.Fatal(err)
|
||||
}
|
||||
profile := loaded.Config.Pipelines["main"]
|
||||
if profile.Mode == nil || *profile.Mode != pipeline.ModePermissive {
|
||||
if profile.Mode == nil || *profile.Mode != contracts.ModePermissive {
|
||||
t.Fatalf("mode = %v", profile.Mode)
|
||||
}
|
||||
if profile.Artifacts["lane"].Extract.Mode != nil || profile.Artifacts["lane"].Extract.MaxAdditionalTurns != nil {
|
||||
@@ -39,19 +40,19 @@ pipelines:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != (pipeline.ProducerControls{Mode: pipeline.ModeStrict, MaxAdditionalTurns: 0, Cache: pipeline.CacheBypass}) {
|
||||
if got != (contracts.ProducerControls{Mode: contracts.ModeStrict, MaxAdditionalTurns: 0, Cache: contracts.CacheBypass}) {
|
||||
t.Fatalf("chunk controls = %#v", got)
|
||||
}
|
||||
got, err = pipeline.ResolveProducerControls(profile.Artifacts["lane"].Extract, profile, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != (pipeline.ProducerControls{Mode: pipeline.ModePermissive, MaxAdditionalTurns: 5, Cache: pipeline.CacheRefresh}) {
|
||||
if got != (contracts.ProducerControls{Mode: contracts.ModePermissive, MaxAdditionalTurns: 5, Cache: contracts.CacheRefresh}) {
|
||||
t.Fatalf("inherited controls = %#v", got)
|
||||
}
|
||||
invocation := pipeline.CacheAuto
|
||||
invocation := contracts.CacheAuto
|
||||
got, err = pipeline.ResolveProducerControls(profile.Chunk, profile, &invocation)
|
||||
if err != nil || got.Cache != pipeline.CacheAuto {
|
||||
if err != nil || got.Cache != contracts.CacheAuto {
|
||||
t.Fatalf("invocation cache = %#v, %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user