Compose pipeline steps using native identities
This commit is contained in:
@@ -64,13 +64,14 @@ func normalizeDocumentPipelines(document *Document, resolution *configkit.Resolu
|
||||
return
|
||||
}
|
||||
validateDocumentPipelinePresence(document, resolution)
|
||||
normalizer := documentNormalizer{Resolution: resolution}
|
||||
pipelinesPath := configkit.Keys("pipelines")
|
||||
for _, id := range sortedPipelineDocumentKeys(document.Pipelines) {
|
||||
profile := document.Pipelines[id]
|
||||
normalizePipelineDocument(&profile, pipelinesPath.Key(id), resolution, state)
|
||||
normalizePipelineDocument(&profile, pipelinesPath.Key(id), normalizer, state)
|
||||
document.Pipelines[id] = profile
|
||||
}
|
||||
document.Pipelines = normalizeDocumentMap(document.Pipelines, pipelinesPath, "pipeline identifier", resolution, state)
|
||||
document.Pipelines = normalizeDocumentMap(document.Pipelines, pipelinesPath, "pipeline identifier", normalizer, state)
|
||||
}
|
||||
|
||||
func validateDocumentPipelinePresence(document *Document, resolution *configkit.Resolution) {
|
||||
@@ -174,7 +175,7 @@ func validateDocumentPolicyPresence(policy *ValidationPolicyDocument, path confi
|
||||
rejectDocumentNull(resolution, path.Key("validator_failure"), policy.ValidatorFailure == nil)
|
||||
}
|
||||
|
||||
func normalizePipelineDocument(profile *PipelineDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizePipelineDocument(profile *PipelineDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
normalizePipelineDocumentString(resolution, path.Key("llm_profile"), &profile.LLMProfile, "trimmed pipeline LLM profile")
|
||||
normalizeDocumentBinding(&profile.Input, path.Key("input"), resolution, state)
|
||||
if profile.Chunk != nil {
|
||||
@@ -193,18 +194,20 @@ func normalizePipelineDocument(profile *PipelineDocument, path configkit.Path, r
|
||||
for index := range profile.Steps {
|
||||
step := &profile.Steps[index]
|
||||
stepPath := path.Key("steps").Index(index)
|
||||
normalizeDocumentValue(resolution, stepPath.Key("id"), &step.ID, strings.TrimSpace(step.ID), "trimmed step identifier")
|
||||
step.References = normalizeDocumentReferences(step.References, stepPath.Key("references"), resolution, state)
|
||||
stepNormalizer := resolution
|
||||
stepNormalizer.covered = step.ID != strings.TrimSpace(step.ID)
|
||||
normalizeDocumentValue(stepNormalizer, stepPath.Key("id"), &step.ID, strings.TrimSpace(step.ID), "trimmed step identifier")
|
||||
step.References = normalizeDocumentReferences(step.References, stepPath.Key("references"), stepNormalizer, state)
|
||||
for _, laneID := range sortedLaneDocumentKeys(step.Artifacts) {
|
||||
lane := step.Artifacts[laneID]
|
||||
normalizeArtifactLaneDocument(&lane, stepPath.Key("artifacts").Key(laneID), resolution, state)
|
||||
normalizeArtifactLaneDocument(&lane, stepPath.Key("artifacts").Key(laneID), stepNormalizer, state)
|
||||
step.Artifacts[laneID] = lane
|
||||
}
|
||||
step.Artifacts = normalizeDocumentMap(step.Artifacts, stepPath.Key("artifacts"), "artifact lane identifier", resolution, state)
|
||||
step.Artifacts = normalizeDocumentMap(step.Artifacts, stepPath.Key("artifacts"), "artifact lane identifier", stepNormalizer, state)
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeArtifactLaneDocument(lane *ArtifactLaneDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizeArtifactLaneDocument(lane *ArtifactLaneDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
normalizeDocumentBinding(&lane.Extract, path.Key("extract"), resolution, state)
|
||||
if lane.Merge != nil {
|
||||
normalizeDocumentBinding(lane.Merge, path.Key("merge"), resolution, state)
|
||||
@@ -217,7 +220,7 @@ func normalizeArtifactLaneDocument(lane *ArtifactLaneDocument, path configkit.Pa
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeDocumentBinding(binding *BindingDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) {
|
||||
func normalizeDocumentBinding(binding *BindingDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) {
|
||||
normalizeDocumentValue(resolution, path.Key("module"), &binding.Module, strings.TrimSpace(binding.Module), "trimmed module identifier")
|
||||
normalizePipelineDocumentString(resolution, path.Key("llm_profile"), &binding.LLMProfile, "trimmed binding LLM profile")
|
||||
binding.References = normalizeDocumentReferences(binding.References, path.Key("references"), resolution, state)
|
||||
@@ -226,12 +229,12 @@ func normalizeDocumentBinding(binding *BindingDocument, path configkit.Path, res
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeValidatorDocument(validator *ValidatorDocument, path configkit.Path, resolution *configkit.Resolution) {
|
||||
func normalizeValidatorDocument(validator *ValidatorDocument, path configkit.Path, resolution documentNormalizer) {
|
||||
normalizeDocumentValue(resolution, path.Key("module"), &validator.Module, strings.TrimSpace(validator.Module), "trimmed validator module identifier")
|
||||
normalizePipelineDocumentString(resolution, path.Key("llm_profile"), &validator.LLMProfile, "trimmed validator LLM profile")
|
||||
}
|
||||
|
||||
func normalizeDocumentReferences(references map[string]ReferenceDocument, path configkit.Path, resolution *configkit.Resolution, state *documentLoadState) map[string]ReferenceDocument {
|
||||
func normalizeDocumentReferences(references map[string]ReferenceDocument, path configkit.Path, resolution documentNormalizer, state *documentLoadState) map[string]ReferenceDocument {
|
||||
for _, name := range sortedReferenceDocumentKeys(references) {
|
||||
source := references[name]
|
||||
sourcePath := path.Key(name)
|
||||
@@ -245,7 +248,7 @@ func normalizeDocumentReferences(references map[string]ReferenceDocument, path c
|
||||
return normalizeDocumentMap(references, path, "reference name", resolution, state)
|
||||
}
|
||||
|
||||
func normalizeDocumentValue[T comparable](resolution *configkit.Resolution, path configkit.Path, target *T, value T, reason string) {
|
||||
func normalizeDocumentValue[T comparable](resolution documentNormalizer, path configkit.Path, target *T, value T, reason string) {
|
||||
if target == nil || !resolution.IsExplicit(path) {
|
||||
return
|
||||
}
|
||||
@@ -255,7 +258,7 @@ func normalizeDocumentValue[T comparable](resolution *configkit.Resolution, path
|
||||
}
|
||||
}
|
||||
|
||||
func normalizePipelineDocumentString(resolution *configkit.Resolution, path configkit.Path, target **string, reason string) {
|
||||
func normalizePipelineDocumentString(resolution documentNormalizer, path configkit.Path, target **string, reason string) {
|
||||
if target == nil || *target == nil || !resolution.IsExplicit(path) {
|
||||
return
|
||||
}
|
||||
@@ -266,7 +269,7 @@ func normalizePipelineDocumentString(resolution *configkit.Resolution, path conf
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeDocumentMap[T any](values map[string]T, path configkit.Path, kind string, resolution *configkit.Resolution, state *documentLoadState) map[string]T {
|
||||
func normalizeDocumentMap[T any](values map[string]T, path configkit.Path, kind string, resolution documentNormalizer, state *documentLoadState) map[string]T {
|
||||
if len(values) == 0 {
|
||||
return values
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user