Resolve producer modes turn allowances cache controls and shared workers
This commit is contained in:
@@ -41,12 +41,12 @@ func TestPipelineInheritancePreservesAndUpsertsSteps(t *testing.T) {
|
||||
pipelines:
|
||||
parent:
|
||||
input: {module: input}
|
||||
structured_output_repair_attempts: 2
|
||||
max_additional_turns: 2
|
||||
steps:
|
||||
- id: prepare
|
||||
artifacts:
|
||||
score:
|
||||
extract: {module: extract, retries: 2}
|
||||
extract: {module: extract, max_additional_turns: 2}
|
||||
- id: summarize
|
||||
artifacts:
|
||||
notes:
|
||||
@@ -54,7 +54,7 @@ pipelines:
|
||||
child:
|
||||
extends: parent
|
||||
llm_profile: local
|
||||
structured_output_repair_attempts: 0` + test.childSteps + "\n"
|
||||
max_additional_turns: 0` + test.childSteps + "\n"
|
||||
loaded, err := loadConfigSource(configkit.Bytes("inheritance.yml", []byte(source)), LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("loadConfigSource() error = %v", err)
|
||||
@@ -66,10 +66,10 @@ pipelines:
|
||||
t.Fatalf("parent/child inputs = %#v / %#v", parent.Input, child.Input)
|
||||
}
|
||||
if child.LLMProfile != "local" ||
|
||||
child.StructuredOutputRepairAttempts == nil || *child.StructuredOutputRepairAttempts != 0 {
|
||||
child.MaxAdditionalTurns == nil || *child.MaxAdditionalTurns != 0 {
|
||||
t.Fatalf("child overrides = %#v", child)
|
||||
}
|
||||
if parent.StructuredOutputRepairAttempts == nil || *parent.StructuredOutputRepairAttempts != 2 {
|
||||
if parent.MaxAdditionalTurns == nil || *parent.MaxAdditionalTurns != 2 {
|
||||
t.Fatalf("parent settings changed: %#v", parent)
|
||||
}
|
||||
if len(child.Steps) != len(test.wantStepIDs) {
|
||||
@@ -116,20 +116,20 @@ pipelines:
|
||||
input: {module: input}
|
||||
artifacts:
|
||||
base:
|
||||
extract: {module: extract, retries: 2}
|
||||
extract: {module: extract, max_additional_turns: 2}
|
||||
derived:
|
||||
extends: base
|
||||
extract: {retries: 4}
|
||||
extract: {max_additional_turns: 4}
|
||||
`)), LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("loadConfigSource() error = %v", err)
|
||||
}
|
||||
|
||||
lanes := loaded.Config.Pipelines["session"].Artifacts
|
||||
if lanes["base"].Extract.Module != "extract" || lanes["base"].Extract.Retries != 2 {
|
||||
if lanes["base"].Extract.Module != "extract" || *lanes["base"].Extract.MaxAdditionalTurns != 2 {
|
||||
t.Fatalf("base lane = %#v", lanes["base"])
|
||||
}
|
||||
if lanes["derived"].Extract.Module != "extract" || lanes["derived"].Extract.Retries != 4 {
|
||||
if lanes["derived"].Extract.Module != "extract" || *lanes["derived"].Extract.MaxAdditionalTurns != 4 {
|
||||
t.Fatalf("derived lane = %#v", lanes["derived"])
|
||||
}
|
||||
if _, err := loaded.Config.Resolve(ResolveInput{PipelineID: "session", Catalog: effectiveCatalog(t)}); err != nil {
|
||||
@@ -144,7 +144,7 @@ func TestInheritedPresenceOverridesRemainExplicit(t *testing.T) {
|
||||
pipelines:
|
||||
parent:
|
||||
input: {module: input}
|
||||
structured_output_repair_attempts: 3
|
||||
max_additional_turns: 3
|
||||
chunk:
|
||||
module: generic
|
||||
validators: []
|
||||
@@ -155,7 +155,7 @@ pipelines:
|
||||
validators: [{module: configured-a}]
|
||||
child:
|
||||
extends: parent
|
||||
structured_output_repair_attempts: 0
|
||||
max_additional_turns: 0
|
||||
artifacts:
|
||||
score:
|
||||
extract:
|
||||
@@ -178,11 +178,11 @@ pipelines:
|
||||
parent.Artifacts["score"].Extract.Validators.Validators[0].Module != "configured-a" {
|
||||
t.Fatalf("parent extraction validators = %#v", parent.Artifacts["score"].Extract.Validators)
|
||||
}
|
||||
if parent.StructuredOutputRepairAttempts == nil || *parent.StructuredOutputRepairAttempts != 3 {
|
||||
t.Fatalf("parent repair budget = %#v", parent.StructuredOutputRepairAttempts)
|
||||
if parent.MaxAdditionalTurns == nil || *parent.MaxAdditionalTurns != 3 {
|
||||
t.Fatalf("parent turn allowance = %#v", parent.MaxAdditionalTurns)
|
||||
}
|
||||
if child.StructuredOutputRepairAttempts == nil || *child.StructuredOutputRepairAttempts != 0 {
|
||||
t.Fatalf("child zero repair budget = %#v", child.StructuredOutputRepairAttempts)
|
||||
if child.MaxAdditionalTurns == nil || *child.MaxAdditionalTurns != 0 {
|
||||
t.Fatalf("child zero turn allowance = %#v", child.MaxAdditionalTurns)
|
||||
}
|
||||
extract := child.Artifacts["score"].Extract
|
||||
if !extract.Validators.Set || extract.Validators.Validators == nil || len(extract.Validators.Validators) != 0 {
|
||||
@@ -197,8 +197,8 @@ pipelines:
|
||||
t.Fatalf("Resolve(child) error = %v", err)
|
||||
}
|
||||
lanes := resolved.ResolvedPipeline.AllArtifactLanes()
|
||||
if len(lanes) != 1 || lanes[0].Extract.StructuredOutputRepairAttempts == nil || *lanes[0].Extract.StructuredOutputRepairAttempts != 0 {
|
||||
t.Fatalf("resolved child repair budget = %#v", lanes)
|
||||
if len(lanes) != 1 || lanes[0].Extract.MaxAdditionalTurns == nil || *lanes[0].Extract.MaxAdditionalTurns != 0 {
|
||||
t.Fatalf("resolved child turn allowance = %#v", lanes)
|
||||
}
|
||||
if !resolved.ResolvedPipeline.Chunk.Validators.Set || len(resolved.ResolvedPipeline.Chunk.Validators.Validators) != 0 ||
|
||||
!lanes[0].Extract.Validators.Set || len(lanes[0].Extract.Validators.Validators) != 0 {
|
||||
@@ -234,42 +234,6 @@ pipelines:
|
||||
}
|
||||
}
|
||||
|
||||
func TestInheritedAndDirectNullRepairBudgetsRemainInvalid(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
source string
|
||||
path string
|
||||
}{
|
||||
{
|
||||
name: "child null",
|
||||
source: `version: 6
|
||||
pipelines:
|
||||
parent: {input: {module: input}, structured_output_repair_attempts: 2}
|
||||
child:
|
||||
extends: parent
|
||||
structured_output_repair_attempts: null
|
||||
`,
|
||||
path: "/pipelines/child/structured_output_repair_attempts",
|
||||
},
|
||||
{
|
||||
name: "inherited null",
|
||||
source: `version: 6
|
||||
pipelines:
|
||||
parent: {input: {module: input}, structured_output_repair_attempts: null}
|
||||
child: {extends: parent}
|
||||
`,
|
||||
path: "/pipelines/parent/structured_output_repair_attempts",
|
||||
},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, err := loadConfigSource(configkit.Bytes("null.yml", []byte(test.source)), LoadOptions{})
|
||||
assertDocumentDiagnosticAt(t, err, test.path)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOverlayInheritancePrecedesOverrides(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -283,12 +247,12 @@ func TestOverlayInheritancePrecedesOverrides(t *testing.T) {
|
||||
pipelines:
|
||||
parent:
|
||||
input: {module: input}
|
||||
structured_output_repair_attempts: 1
|
||||
max_additional_turns: 1
|
||||
inherited:
|
||||
extends: parent
|
||||
overridden:
|
||||
extends: parent
|
||||
structured_output_repair_attempts: 0
|
||||
max_additional_turns: 0
|
||||
cancelled:
|
||||
extends: parent
|
||||
input: {module: input}
|
||||
@@ -297,7 +261,7 @@ pipelines:
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(overlays, "development.yml"), []byte(`pipelines:
|
||||
parent:
|
||||
structured_output_repair_attempts: 2
|
||||
max_additional_turns: 2
|
||||
cancelled:
|
||||
extends: null
|
||||
`), 0o600); err != nil {
|
||||
@@ -308,32 +272,32 @@ pipelines:
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if got := *loaded.Config.Pipelines["inherited"].StructuredOutputRepairAttempts; got != 2 {
|
||||
t.Fatalf("overlay-inherited repair budget = %d, want 2", got)
|
||||
if got := *loaded.Config.Pipelines["inherited"].MaxAdditionalTurns; got != 2 {
|
||||
t.Fatalf("overlay-inherited turn allowance = %d, want 2", got)
|
||||
}
|
||||
if got := *loaded.Config.Pipelines["overridden"].StructuredOutputRepairAttempts; got != 0 {
|
||||
t.Fatalf("child replacement repair budget = %d, want 0", got)
|
||||
if got := *loaded.Config.Pipelines["overridden"].MaxAdditionalTurns; got != 0 {
|
||||
t.Fatalf("child replacement turn allowance = %d, want 0", got)
|
||||
}
|
||||
if loaded.Config.Pipelines["cancelled"].StructuredOutputRepairAttempts != nil {
|
||||
if loaded.Config.Pipelines["cancelled"].MaxAdditionalTurns != nil {
|
||||
t.Fatalf("cancelled child inherited parent settings: %#v", loaded.Config.Pipelines["cancelled"])
|
||||
}
|
||||
|
||||
withOverride, err := Load(main, LoadOptions{
|
||||
Overlay: "development",
|
||||
Overrides: []configkit.Override{{
|
||||
Path: configkit.Keys("pipelines", "parent", "structured_output_repair_attempts"),
|
||||
Path: configkit.Keys("pipelines", "parent", "max_additional_turns"),
|
||||
Value: 3,
|
||||
Flag: "--repair-budget",
|
||||
Flag: "--set",
|
||||
}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Load() with explicit override error = %v", err)
|
||||
}
|
||||
if got := *withOverride.Config.Pipelines["inherited"].StructuredOutputRepairAttempts; got != 2 {
|
||||
t.Fatalf("inherited repair budget after parent override = %d, want 2", got)
|
||||
if got := *withOverride.Config.Pipelines["inherited"].MaxAdditionalTurns; got != 2 {
|
||||
t.Fatalf("inherited turn allowance after parent override = %d, want 2", got)
|
||||
}
|
||||
if got := *withOverride.Config.Pipelines["parent"].StructuredOutputRepairAttempts; got != 3 {
|
||||
t.Fatalf("parent override repair budget = %d, want 3", got)
|
||||
if got := *withOverride.Config.Pipelines["parent"].MaxAdditionalTurns; got != 3 {
|
||||
t.Fatalf("parent override turn allowance = %d, want 3", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +429,7 @@ func TestInheritedInspectionRetainsOriginsRedactionAndOwnership(t *testing.T) {
|
||||
if err := os.WriteFile(parentFile, []byte(`pipelines:
|
||||
parent:
|
||||
input: {module: input}
|
||||
structured_output_repair_attempts: 2
|
||||
max_additional_turns: 2
|
||||
references:
|
||||
source: {path: ./shared.txt}
|
||||
artifacts:
|
||||
@@ -485,7 +449,7 @@ func TestInheritedInspectionRetainsOriginsRedactionAndOwnership(t *testing.T) {
|
||||
if err := os.WriteFile(childFile, []byte(`pipelines:
|
||||
child:
|
||||
extends: parent
|
||||
structured_output_repair_attempts: 0
|
||||
max_additional_turns: 0
|
||||
`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -518,8 +482,8 @@ config:
|
||||
if got := child.References["source"].Path; got != wantPath {
|
||||
t.Fatalf("runtime inherited path = %q, want %q", got, wantPath)
|
||||
}
|
||||
if child.StructuredOutputRepairAttempts == nil || *child.StructuredOutputRepairAttempts != 0 {
|
||||
t.Fatalf("runtime inherited repair setting = %#v", child.StructuredOutputRepairAttempts)
|
||||
if child.MaxAdditionalTurns == nil || *child.MaxAdditionalTurns != 0 {
|
||||
t.Fatalf("runtime inherited turn allowance = %#v", child.MaxAdditionalTurns)
|
||||
}
|
||||
|
||||
var effective bytes.Buffer
|
||||
@@ -527,7 +491,7 @@ config:
|
||||
t.Fatalf("WriteEffective() error = %v", err)
|
||||
}
|
||||
if !strings.Contains(effective.String(), wantPath) || strings.Contains(effective.String(), "extends:") ||
|
||||
!strings.Contains(effective.String(), "structured_output_repair_attempts: 0") {
|
||||
!strings.Contains(effective.String(), "max_additional_turns: 0") {
|
||||
t.Fatalf("effective configuration is inconsistent with runtime conversion: %s", effective.String())
|
||||
}
|
||||
for _, secret := range []string{"fake-parent-secret", "fake-overlay-secret"} {
|
||||
@@ -540,7 +504,7 @@ config:
|
||||
name string
|
||||
path configkit.Path
|
||||
}{
|
||||
{name: "repair setting", path: configkit.Keys("pipelines", "child", "structured_output_repair_attempts")},
|
||||
{name: "turn allowance", path: configkit.Keys("pipelines", "child", "max_additional_turns")},
|
||||
{name: "normalized reference", path: configkit.Keys("pipelines", "child", "references", "source", "path")},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user