Hand checked processing selections to execution
This commit is contained in:
@@ -158,12 +158,7 @@ func validate(c *Config, v *ck.Validation) {
|
||||
check(entry.Plural == nil || *entry.Plural != "", path.Key("plural"), "plural must not be empty")
|
||||
}
|
||||
}
|
||||
check(c.LLM.TransientRetries >= 0, ck.Keys("llm", "transient_retries"), "retry budget must be non-negative")
|
||||
check(c.LLM.RepairAttempts >= 0 && c.LLM.RepairAttempts <= 3, ck.Keys("llm", "repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(c.LLM.CorrectionRepairAttempts >= 0, ck.Keys("llm", "correction_repair_attempts"), "correction repair attempts must be non-negative")
|
||||
check(c.LLM.CorrectionRepairProfile == nil || *c.LLM.CorrectionRepairProfile != "", ck.Keys("llm", "correction_repair_profile"), "correction repair profile must not be empty; use null to clear it")
|
||||
check(c.LLM.OperationTimeout > 0, ck.Keys("llm", "operation_timeout"), "operation timeout must be positive")
|
||||
check(c.LLM.ValidationProfile == nil || *c.LLM.ValidationProfile != "", ck.Keys("llm", "validation_profile"), "validation profile must not be empty; use null to clear it")
|
||||
validateRuntimeSettings(check, ck.Keys(), c.LLM, c.Validation, c.Context)
|
||||
validateSelections := func(values []string, path ck.Path) {
|
||||
for i, name := range values {
|
||||
_, exists := c.GlossaryCollections[name]
|
||||
@@ -183,17 +178,9 @@ func validate(c *Config, v *ck.Validation) {
|
||||
}
|
||||
validateSelections(item.Glossaries, path.Key("glossaries"))
|
||||
validateSelections(item.ProtectedTerms, path.Key("protected_terms"))
|
||||
check(item.LLM.ValidationProfile == nil || *item.LLM.ValidationProfile != "", path.Key("llm").Key("validation_profile"), "validation profile must not be empty; use null to clear it")
|
||||
check(item.LLM.CorrectionRepairAttempts >= 0, path.Key("llm").Key("correction_repair_attempts"), "correction repair attempts must be non-negative")
|
||||
check(item.LLM.CorrectionRepairProfile == nil || *item.LLM.CorrectionRepairProfile != "", path.Key("llm").Key("correction_repair_profile"), "correction repair profile must not be empty; use null to clear it")
|
||||
check(item.LLM.TransientRetries >= 0, path.Key("llm").Key("transient_retries"), "retry budget must be non-negative")
|
||||
check(item.LLM.RepairAttempts >= 0 && item.LLM.RepairAttempts <= 3, path.Key("llm").Key("repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(item.LLM.OperationTimeout > 0, path.Key("llm").Key("operation_timeout"), "operation timeout must be positive")
|
||||
check(item.Validation.MaxPromptTokens > 0, path.Key("validation").Key("max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
check(len(strings.TrimSpace(item.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, path.Key("context").Key("description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
validateRuntimeSettings(check, path, item.LLM, item.Validation, item.Context)
|
||||
}
|
||||
check(outputschema.IsSupported(c.Output.Schema), ck.Keys("output", "schema"), "unsupported output schema")
|
||||
check(c.Validation.MaxPromptTokens > 0, ck.Keys("validation", "max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
check(c.Chunking.MaxSectionTokens > 0, ck.Keys("chunking", "max_section_tokens"), "maximum section tokens must be positive")
|
||||
check(c.Chunking.MinSectionTokens > 0 && c.Chunking.MinSectionTokens <= c.Chunking.MaxSectionTokens, ck.Keys("chunking", "min_section_tokens"), "minimum section tokens must be positive and no greater than maximum")
|
||||
check(c.Chunking.TargetSections == nil || *c.Chunking.TargetSections > 0, ck.Keys("chunking", "target_sections"), "target sections must be positive when set")
|
||||
@@ -201,5 +188,16 @@ func validate(c *Config, v *ck.Validation) {
|
||||
check(c.Normalization.EllipsisGap >= 0, ck.Keys("normalization", "ellipsis_gap"), "ellipsis gap must be non-negative")
|
||||
check(c.Normalization.MaxSegmentDuration > 0, ck.Keys("normalization", "max_segment_duration"), "maximum segment duration must be positive")
|
||||
check(c.Normalization.MaxSegmentTokens > 0, ck.Keys("normalization", "max_segment_tokens"), "maximum segment tokens must be positive")
|
||||
check(len(strings.TrimSpace(c.Context.Description)) <= DefaultTranscriptDescriptionMaxChars, ck.Keys("context", "description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
}
|
||||
|
||||
func validateRuntimeSettings(check func(bool, ck.Path, string), base ck.Path, settings LLM, validation Validation, context Context) {
|
||||
llm := base.Key("llm")
|
||||
check(settings.TransientRetries >= 0, llm.Key("transient_retries"), "retry budget must be non-negative")
|
||||
check(settings.RepairAttempts >= 0 && settings.RepairAttempts <= 3, llm.Key("repair_attempts"), "repair attempts must be between zero and three")
|
||||
check(settings.CorrectionRepairAttempts >= 0, llm.Key("correction_repair_attempts"), "correction repair attempts must be non-negative")
|
||||
check(settings.CorrectionRepairProfile == nil || *settings.CorrectionRepairProfile != "", llm.Key("correction_repair_profile"), "correction repair profile must not be empty; use null to clear it")
|
||||
check(settings.OperationTimeout > 0, llm.Key("operation_timeout"), "operation timeout must be positive")
|
||||
check(settings.ValidationProfile == nil || *settings.ValidationProfile != "", llm.Key("validation_profile"), "validation profile must not be empty; use null to clear it")
|
||||
check(validation.MaxPromptTokens > 0, base.Key("validation").Key("max_prompt_tokens"), "validation prompt budget must be positive")
|
||||
check(len(strings.TrimSpace(context.Description)) <= DefaultTranscriptDescriptionMaxChars, base.Key("context").Key("description"), fmt.Sprintf("description must be at most %d bytes after trimming", DefaultTranscriptDescriptionMaxChars))
|
||||
}
|
||||
|
||||
@@ -20,24 +20,46 @@ func defaultNames(r *ck.Resolution, path ck.Path, target *[]string, inherited []
|
||||
}
|
||||
}
|
||||
|
||||
// resolveRoleProfile inherits only an explicitly selected root role. An
|
||||
// explicit null clears inheritance and derives the role from its own proposal.
|
||||
func resolveRoleProfile(r *ck.Resolution, role, proposal ck.Path, target **string, proposalValue *string, name string, inheritedPath ck.Path, inherited *string) {
|
||||
info, _ := r.EntryInfo(role)
|
||||
reason := name + " defaults to proposal profile"
|
||||
if r.IsExplicit(role) && info.Null {
|
||||
*target = cloneSelection(proposalValue)
|
||||
r.RecordDerivedDefault(role, reason, proposal)
|
||||
} else if inherited != nil {
|
||||
ck.Default(r, role, target, cloneSelection(inherited), "inherit "+name+" profile", inheritedPath)
|
||||
} else {
|
||||
ck.Default(r, role, target, cloneSelection(proposalValue), reason, proposal)
|
||||
}
|
||||
}
|
||||
|
||||
func explicitProfile(r *ck.Resolution, path ck.Path, value *string) *string {
|
||||
info, _ := r.EntryInfo(path)
|
||||
if r.IsExplicit(path) && !info.Null {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// resolveSettings records root-derived defaults after all explicit assignments.
|
||||
func resolveSettings(c *Config, r *ck.Resolution) error {
|
||||
glossaries := ck.Keys("glossaries")
|
||||
protection := ck.Keys("protected_terms")
|
||||
defaultNames(r, protection, &c.ProtectedTerms, c.Glossaries, "protection defaults to selected glossaries", glossaries)
|
||||
rootValidation := ck.Keys("llm", "validation_profile")
|
||||
rootValidationInfo, _ := r.EntryInfo(rootValidation)
|
||||
inheritedValidation := r.IsExplicit(rootValidation) && !rootValidationInfo.Null && c.LLM.ValidationProfile != nil
|
||||
rootRepair := ck.Keys("llm", "correction_repair_profile")
|
||||
rootRepairInfo, _ := r.EntryInfo(rootRepair)
|
||||
inheritedRepair := r.IsExplicit(rootRepair) && !rootRepairInfo.Null && c.LLM.CorrectionRepairProfile != nil
|
||||
rootLLM := ck.Keys("llm")
|
||||
rootProposal := rootLLM.Key("proposal_profile")
|
||||
rootValidation := rootLLM.Key("validation_profile")
|
||||
rootRepair := rootLLM.Key("correction_repair_profile")
|
||||
inheritedValidation := explicitProfile(r, rootValidation, c.LLM.ValidationProfile)
|
||||
inheritedRepair := explicitProfile(r, rootRepair, c.LLM.CorrectionRepairProfile)
|
||||
for i := range c.Pipeline.Stages {
|
||||
item := &c.Pipeline.Stages[i]
|
||||
base := ck.Keys("pipeline", "stages").Index(i)
|
||||
defaultNames(r, base.Key("glossaries"), &item.Glossaries, c.Glossaries, "inherit root glossaries", glossaries)
|
||||
defaultNames(r, base.Key("protected_terms"), &item.ProtectedTerms, c.ProtectedTerms, "inherit root protection", protection)
|
||||
llm := base.Key("llm")
|
||||
rootLLM := ck.Keys("llm")
|
||||
proposal := llm.Key("proposal_profile")
|
||||
ck.Default(r, proposal, &item.LLM.ProposalProfile, cloneSelection(c.LLM.ProposalProfile), "inherit proposal profile", rootLLM.Key("proposal_profile"))
|
||||
ck.Default(r, llm.Key("transient_retries"), &item.LLM.TransientRetries, c.LLM.TransientRetries, "inherit retry budget", rootLLM.Key("transient_retries"))
|
||||
@@ -46,38 +68,10 @@ func resolveSettings(c *Config, r *ck.Resolution) error {
|
||||
ck.Default(r, llm.Key("operation_timeout"), &item.LLM.OperationTimeout, c.LLM.OperationTimeout, "inherit operation timeout", rootLLM.Key("operation_timeout"))
|
||||
ck.Default(r, base.Key("validation").Key("max_prompt_tokens"), &item.Validation.MaxPromptTokens, c.Validation.MaxPromptTokens, "inherit validation budget", ck.Keys("validation", "max_prompt_tokens"))
|
||||
ck.Default(r, base.Key("context").Key("description"), &item.Context.Description, c.Context.Description, "inherit description", ck.Keys("context", "description"))
|
||||
repair := llm.Key("correction_repair_profile")
|
||||
repairInfo, _ := r.EntryInfo(repair)
|
||||
if r.IsExplicit(repair) && repairInfo.Null {
|
||||
item.LLM.CorrectionRepairProfile = cloneSelection(item.LLM.ProposalProfile)
|
||||
r.RecordDerivedDefault(repair, "correction repair defaults to proposal profile", proposal)
|
||||
} else if inheritedRepair {
|
||||
ck.Default(r, repair, &item.LLM.CorrectionRepairProfile, cloneSelection(c.LLM.CorrectionRepairProfile), "inherit correction repair profile", rootRepair)
|
||||
} else {
|
||||
ck.Default(r, repair, &item.LLM.CorrectionRepairProfile, cloneSelection(item.LLM.ProposalProfile), "correction repair defaults to proposal profile", proposal)
|
||||
}
|
||||
validation := llm.Key("validation_profile")
|
||||
info, _ := r.EntryInfo(validation)
|
||||
if r.IsExplicit(validation) && info.Null {
|
||||
item.LLM.ValidationProfile = cloneSelection(item.LLM.ProposalProfile)
|
||||
r.RecordDerivedDefault(validation, "validation defaults to proposal profile", proposal)
|
||||
} else if inheritedValidation {
|
||||
ck.Default(r, validation, &item.LLM.ValidationProfile, cloneSelection(c.LLM.ValidationProfile), "inherit validation profile", rootValidation)
|
||||
} else {
|
||||
ck.Default(r, validation, &item.LLM.ValidationProfile, cloneSelection(item.LLM.ProposalProfile), "validation defaults to proposal profile", proposal)
|
||||
}
|
||||
}
|
||||
if r.IsExplicit(rootRepair) && rootRepairInfo.Null {
|
||||
c.LLM.CorrectionRepairProfile = cloneSelection(c.LLM.ProposalProfile)
|
||||
r.RecordDerivedDefault(rootRepair, "correction repair defaults to proposal profile", ck.Keys("llm", "proposal_profile"))
|
||||
} else {
|
||||
ck.Default(r, rootRepair, &c.LLM.CorrectionRepairProfile, cloneSelection(c.LLM.ProposalProfile), "correction repair defaults to proposal profile", ck.Keys("llm", "proposal_profile"))
|
||||
}
|
||||
if r.IsExplicit(rootValidation) && rootValidationInfo.Null {
|
||||
c.LLM.ValidationProfile = cloneSelection(c.LLM.ProposalProfile)
|
||||
r.RecordDerivedDefault(rootValidation, "validation defaults to proposal profile", ck.Keys("llm", "proposal_profile"))
|
||||
} else {
|
||||
ck.Default(r, rootValidation, &c.LLM.ValidationProfile, cloneSelection(c.LLM.ProposalProfile), "validation defaults to proposal profile", ck.Keys("llm", "proposal_profile"))
|
||||
resolveRoleProfile(r, llm.Key("correction_repair_profile"), proposal, &item.LLM.CorrectionRepairProfile, item.LLM.ProposalProfile, "correction repair", rootRepair, inheritedRepair)
|
||||
resolveRoleProfile(r, llm.Key("validation_profile"), proposal, &item.LLM.ValidationProfile, item.LLM.ProposalProfile, "validation", rootValidation, inheritedValidation)
|
||||
}
|
||||
resolveRoleProfile(r, rootRepair, rootProposal, &c.LLM.CorrectionRepairProfile, c.LLM.ProposalProfile, "correction repair", rootRepair, nil)
|
||||
resolveRoleProfile(r, rootValidation, rootProposal, &c.LLM.ValidationProfile, c.LLM.ProposalProfile, "validation", rootValidation, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user