Accept ConfigKit integers in module options

This commit is contained in:
2026-09-13 16:41:14 +00:00
parent cf17dd7bd0
commit d770e19c17
7 changed files with 72 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ import (
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
units "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/chunk/units"
jsonoutput "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/output/json"
)
func TestLoadedConfigConvertsDocumentsAndResolvesRuntimePipeline(t *testing.T) {
@@ -91,6 +93,40 @@ pipelines:
}
}
func TestLoadedConfigPreservesConfigKitIntegerOptionsForModules(t *testing.T) {
t.Parallel()
loaded, err := loadConfigSource(configkit.Bytes("document.yml", []byte(`version: 5
pipelines:
session:
input: {module: input}
chunk:
module: generic
options:
max_units: 3
overlap_units: 1
output:
module: json
options:
evidence_context:
enabled: true
lanes: [score]
window_units: 2
`)), LoadOptions{})
if err != nil {
t.Fatalf("loadConfigSource() error = %v", err)
}
profile := loaded.Config.Pipelines["session"]
chunkOptions, err := units.DecodeOptions(profile.Chunk.Options)
if err != nil || chunkOptions.MaxUnits != 3 || chunkOptions.OverlapUnits != 1 {
t.Fatalf("chunk options = %#v, %v", chunkOptions, err)
}
outputOptions, err := jsonoutput.DecodeOptions(profile.Output.Options)
if err != nil || !outputOptions.EvidenceContext.Enabled || outputOptions.EvidenceContext.WindowUnits != 2 {
t.Fatalf("output options = %#v, %v", outputOptions, err)
}
}
func pipelineProfileWithChangedOption(profile pipeline.PipelineProfile) pipeline.PipelineProfile {
profile = clonePipelineProfile(profile)
nested := profile.Artifacts["score"].Extract.Options["nested"].(map[string]any)