Preserve native glossary loading error classifications
This commit is contained in:
@@ -123,8 +123,9 @@ Work:
|
|||||||
explanation records the single CLI override, while preliminary failures retain
|
explanation records the single CLI override, while preliminary failures retain
|
||||||
the library's available file/source diagnostics.
|
the library's available file/source diagnostics.
|
||||||
8. Keep context cancellation checks and error causes consistent with existing
|
8. Keep context cancellation checks and error causes consistent with existing
|
||||||
acquisition. Preliminary input failures should use the existing input-error
|
acquisition. Preliminary loading failures use the existing native diagnostic
|
||||||
handling; do not classify every application/bootstrap failure as an input error.
|
classification, distinguishing invalid input from operational source failures.
|
||||||
|
Do not classify every preliminary/application/bootstrap failure as an input error.
|
||||||
9. Add package-level tests with real ConfigKit for both composition boundaries:
|
9. Add package-level tests with real ConfigKit for both composition boundaries:
|
||||||
two files and an import, matching-ID whole-record replacement, retention of
|
two files and an import, matching-ID whole-record replacement, retention of
|
||||||
unmatched entries between CLI files, and final configured-list replacement.
|
unmatched entries between CLI files, and final configured-list replacement.
|
||||||
@@ -168,7 +169,8 @@ Work:
|
|||||||
destination as the successful counterpart without duplicating all collision
|
destination as the successful counterpart without duplicating all collision
|
||||||
combinations already covered by existing tests.
|
combinations already covered by existing tests.
|
||||||
5. Cover a missing/malformed runtime input and an empty selected glossary stage
|
5. Cover a missing/malformed runtime input and an empty selected glossary stage
|
||||||
as input failures before model work/output preparation. Preserve quiet-mode
|
before model work/output preparation, using native loading classifications
|
||||||
|
and the existing preflight input-error classification. Preserve quiet-mode
|
||||||
destination validation and cancellation behavior.
|
destination validation and cancellation behavior.
|
||||||
|
|
||||||
Acceptance:
|
Acceptance:
|
||||||
|
|||||||
@@ -11,7 +11,14 @@ application code.
|
|||||||
|
|
||||||
## R1 — Preserve native operational error classification for preliminary loads
|
## R1 — Preserve native operational error classification for preliminary loads
|
||||||
|
|
||||||
**Priority:** P2. **Stages:** 2–4. **Status:** Open.
|
**Priority:** P2. **Stages:** 2–4. **Status:** Complete.
|
||||||
|
|
||||||
|
**Completion:** Removed the preliminary-load blanket usage classification.
|
||||||
|
Processing now uses native diagnostic classification, matching inspection.
|
||||||
|
Regression coverage distinguishes missing sources, invalid YAML, and empty
|
||||||
|
selected glossaries, retains diagnostics, and checks that transcript/report
|
||||||
|
files are not prepared. Clarified the planning language.
|
||||||
|
Validation: `go test ./internal/cli` passed with Go 1.27.4.
|
||||||
|
|
||||||
**Locations:** `internal/cli/process.go:35`,
|
**Locations:** `internal/cli/process.go:35`,
|
||||||
`internal/appconfig/config.go:126`, and
|
`internal/appconfig/config.go:126`, and
|
||||||
|
|||||||
@@ -218,8 +218,10 @@ retain ConfigKit's available source diagnostics.
|
|||||||
|
|
||||||
Run ordinary application configuration validation and processing preflight on
|
Run ordinary application configuration validation and processing preflight on
|
||||||
the final values. Missing files, malformed input, unusable collections, and
|
the final values. Missing files, malformed input, unusable collections, and
|
||||||
invalid selections should flow through the existing input-error handling with
|
invalid selections use the existing error handling with useful diagnostics.
|
||||||
useful diagnostics. Native inspection remains independent of processing readiness.
|
Native loading diagnostics distinguish invalid input from operational source
|
||||||
|
failures; processing preflight retains its input-error classification.
|
||||||
|
Native inspection remains independent of processing readiness.
|
||||||
The override does not bypass earlier ConfigKit parsing, inheritance, or decoding
|
The override does not bypass earlier ConfigKit parsing, inheritance, or decoding
|
||||||
failures. Empty collections remain valid configuration; glossary processing
|
failures. Empty collections remain valid configuration; glossary processing
|
||||||
stages still require at least one selected entry under existing preflight rules.
|
stages still require at least one selected entry under existing preflight rules.
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ func runProcess(inv commandkit.Invocation, input processInput) commandkit.Outcom
|
|||||||
var loadErr *ck.LoadError
|
var loadErr *ck.LoadError
|
||||||
if errors.As(err, &loadErr) {
|
if errors.As(err, &loadErr) {
|
||||||
_, explanation := ckconfig.AdaptDiagnostics("Application configuration:\n", loadErr.Sources(), loadErr.Diagnostics())
|
_, explanation := ckconfig.AdaptDiagnostics("Application configuration:\n", loadErr.Sources(), loadErr.Diagnostics())
|
||||||
var glossaryErr *appconfig.GlossaryInputError
|
if inv.Context.Err() == nil && ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage {
|
||||||
if inv.Context.Err() == nil && (errors.As(err, &glossaryErr) || ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage) {
|
|
||||||
return commandkit.Usage(loadErr.Error(), explanation.Details...).WithCause(err)
|
return commandkit.Usage(loadErr.Error(), explanation.Details...).WithCause(err)
|
||||||
}
|
}
|
||||||
return commandkit.Failure(loadErr.Error(), explanation.Details...).WithCause(err)
|
return commandkit.Failure(loadErr.Error(), explanation.Details...).WithCause(err)
|
||||||
|
|||||||
@@ -76,15 +76,25 @@ func TestProcessRuntimeGlossaryFailures(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, name := range []string{"missing.yml", "bad.yml", "empty.yml"} {
|
for _, tc := range []struct {
|
||||||
|
name string
|
||||||
|
status int
|
||||||
|
diagnostic string
|
||||||
|
}{
|
||||||
|
{"missing.yml", 1, "source.missing"},
|
||||||
|
{"bad.yml", 2, "yaml.invalid"},
|
||||||
|
{"empty.yml", 2, "no glossary entries"},
|
||||||
|
} {
|
||||||
var stdout, stderr bytes.Buffer
|
var stdout, stderr bytes.Buffer
|
||||||
output := filepath.Join(dir, "output.json")
|
output := filepath.Join(dir, "output.json")
|
||||||
status := Run(context.Background(), []string{"process", "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, name), "--output", output, filepath.Join(dir, "input.json")}, &stdout, &stderr)
|
status := Run(context.Background(), []string{"process", "--config", filepath.Join(dir, "config.yml"), "--glossary-file", filepath.Join(dir, tc.name), "--output", output, filepath.Join(dir, "input.json")}, &stdout, &stderr)
|
||||||
if status != 2 {
|
if status != tc.status || !strings.Contains(stderr.String(), tc.diagnostic) {
|
||||||
t.Fatalf("%s: status=%d stderr=%s", name, status, stderr.String())
|
t.Fatalf("%s: status=%d stderr=%s", tc.name, status, stderr.String())
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(output); !os.IsNotExist(err) {
|
for _, name := range []string{"output.json", "errors.yml", "recoveries.yml", "report.md"} {
|
||||||
t.Fatalf("%s: output prepared: %v", name, err)
|
if _, err := os.Stat(filepath.Join(dir, name)); !os.IsNotExist(err) {
|
||||||
|
t.Fatalf("%s: output %s prepared: %v", tc.name, name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user