Separate final configuration record validation
This commit is contained in:
@@ -626,6 +626,11 @@ documentation is updated.
|
|||||||
focused changed-seam cases retain final values, paths and relevant error meaning.
|
focused changed-seam cases retain final values, paths and relevant error meaning.
|
||||||
This stage changes organization, not configuration acceptance policy.
|
This stage changes organization, not configuration acceptance policy.
|
||||||
|
|
||||||
|
Completion: final-handoff traversal retains its resource index and delegates
|
||||||
|
backend, profile, and prompt records to focused validators. Configuration tests
|
||||||
|
and focused public configuration, validation, inspection, and source tests pass
|
||||||
|
on Go 1.27.3; the extracted checks preserve their existing paths and rules.
|
||||||
|
|
||||||
## Stage 24: Separate Prompt Capture And Effective Target Construction
|
## Stage 24: Separate Prompt Capture And Effective Target Construction
|
||||||
|
|
||||||
**Catalog:** 22, completion. **Files:** configuration prompts/targets and tests.
|
**Catalog:** 22, completion. **Files:** configuration prompts/targets and tests.
|
||||||
|
|||||||
@@ -419,7 +419,18 @@ func validateEffective(config *document, validation *configkit.Validation) {
|
|||||||
}
|
}
|
||||||
for _, resources := range sets {
|
for _, resources := range sets {
|
||||||
for index, backend := range resources.backends {
|
for index, backend := range resources.backends {
|
||||||
base := resources.bases.backends.Index(index)
|
validateBackendRecord(backend, resources.bases.backends.Index(index), validation)
|
||||||
|
}
|
||||||
|
for index, profile := range resources.profiles {
|
||||||
|
validateProfileRecord(profile, resources.bases.profiles.Index(index), backendIDs, validation)
|
||||||
|
}
|
||||||
|
for index, prompt := range resources.prompts {
|
||||||
|
validatePromptRecord(prompt, resources.bases.prompts.Index(index), validation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateBackendRecord(backend backendConfig, base configkit.Path, validation *configkit.Validation) {
|
||||||
validateBackendEndpoints(backend, base, validation)
|
validateBackendEndpoints(backend, base, validation)
|
||||||
if !domain.IsValidLocalResourceKey(backend.ID) {
|
if !domain.IsValidLocalResourceKey(backend.ID) {
|
||||||
validation.Error(base.Key("id"), "backend ID must be a nonblank local key without a slash")
|
validation.Error(base.Key("id"), "backend ID must be a nonblank local key without a slash")
|
||||||
@@ -462,9 +473,9 @@ func validateEffective(config *document, validation *configkit.Validation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for index, profile := range resources.profiles {
|
|
||||||
base := resources.bases.profiles.Index(index)
|
func validateProfileRecord(profile profileConfig, base configkit.Path, backendIDs map[string]struct{}, validation *configkit.Validation) {
|
||||||
if profile.Endpoint != nil && *profile.Endpoint != "" {
|
if profile.Endpoint != nil && *profile.Endpoint != "" {
|
||||||
if _, err := domain.NormalizeOpenAICompatibleBaseEndpoint(*profile.Endpoint); err != nil {
|
if _, err := domain.NormalizeOpenAICompatibleBaseEndpoint(*profile.Endpoint); err != nil {
|
||||||
validation.Error(base.Key("endpoint"), err.Error())
|
validation.Error(base.Key("endpoint"), err.Error())
|
||||||
@@ -504,17 +515,15 @@ func validateEffective(config *document, validation *configkit.Validation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
validateExtraParams(profile.ExtraParams, base.Key("extra_params"), false, validation)
|
validateExtraParams(profile.ExtraParams, base.Key("extra_params"), false, validation)
|
||||||
}
|
}
|
||||||
for index, prompt := range resources.prompts {
|
|
||||||
base := resources.bases.prompts.Index(index)
|
func validatePromptRecord(prompt promptConfig, base configkit.Path, validation *configkit.Validation) {
|
||||||
if !domain.IsValidLocalResourceKey(prompt.ID) {
|
if !domain.IsValidLocalResourceKey(prompt.ID) {
|
||||||
validation.Error(base.Key("id"), "prompt ID must be a nonblank local key without a slash")
|
validation.Error(base.Key("id"), "prompt ID must be a nonblank local key without a slash")
|
||||||
}
|
}
|
||||||
if prompt.DefaultProfile != nil && *prompt.DefaultProfile != "" && !domain.IsValidResourceID(*prompt.DefaultProfile) {
|
if prompt.DefaultProfile != nil && *prompt.DefaultProfile != "" && !domain.IsValidResourceID(*prompt.DefaultProfile) {
|
||||||
validation.Error(base.Key("default_profile"), "default profile reference is malformed")
|
validation.Error(base.Key("default_profile"), "default profile reference is malformed")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateExtraParams(values map[string]any, path configkit.Path, backend bool, validation *configkit.Validation) {
|
func validateExtraParams(values map[string]any, path configkit.Path, backend bool, validation *configkit.Validation) {
|
||||||
|
|||||||
Reference in New Issue
Block a user