Preserve native glossary loading error classifications

This commit is contained in:
2026-11-26 21:14:32 +00:00
parent bf3184cf0a
commit 4b1812995f
5 changed files with 34 additions and 14 deletions

View File

@@ -123,8 +123,9 @@ Work:
explanation records the single CLI override, while preliminary failures retain
the library's available file/source diagnostics.
8. Keep context cancellation checks and error causes consistent with existing
acquisition. Preliminary input failures should use the existing input-error
handling; do not classify every application/bootstrap failure as an input error.
acquisition. Preliminary loading failures use the existing native diagnostic
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:
two files and an import, matching-ID whole-record replacement, retention of
unmatched entries between CLI files, and final configured-list replacement.
@@ -168,7 +169,8 @@ Work:
destination as the successful counterpart without duplicating all collision
combinations already covered by existing tests.
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.
Acceptance:

View File

@@ -11,7 +11,14 @@ application code.
## 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`,
`internal/appconfig/config.go:126`, and

View File

@@ -218,8 +218,10 @@ retain ConfigKit's available source diagnostics.
Run ordinary application configuration validation and processing preflight on
the final values. Missing files, malformed input, unusable collections, and
invalid selections should flow through the existing input-error handling with
useful diagnostics. Native inspection remains independent of processing readiness.
invalid selections use the existing error handling with useful diagnostics.
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
failures. Empty collections remain valid configuration; glossary processing
stages still require at least one selected entry under existing preflight rules.

View File

@@ -32,8 +32,7 @@ func runProcess(inv commandkit.Invocation, input processInput) commandkit.Outcom
var loadErr *ck.LoadError
if errors.As(err, &loadErr) {
_, explanation := ckconfig.AdaptDiagnostics("Application configuration:\n", loadErr.Sources(), loadErr.Diagnostics())
var glossaryErr *appconfig.GlossaryInputError
if inv.Context.Err() == nil && (errors.As(err, &glossaryErr) || ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage) {
if inv.Context.Err() == nil && ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage {
return commandkit.Usage(loadErr.Error(), explanation.Details...).WithCause(err)
}
return commandkit.Failure(loadErr.Error(), explanation.Details...).WithCause(err)

View File

@@ -76,15 +76,25 @@ func TestProcessRuntimeGlossaryFailures(t *testing.T) {
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
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)
if status != 2 {
t.Fatalf("%s: status=%d stderr=%s", name, status, stderr.String())
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 != tc.status || !strings.Contains(stderr.String(), tc.diagnostic) {
t.Fatalf("%s: status=%d stderr=%s", tc.name, status, stderr.String())
}
if _, err := os.Stat(output); !os.IsNotExist(err) {
t.Fatalf("%s: output prepared: %v", name, err)
for _, name := range []string{"output.json", "errors.yml", "recoveries.yml", "report.md"} {
if _, err := os.Stat(filepath.Join(dir, name)); !os.IsNotExist(err) {
t.Fatalf("%s: output %s prepared: %v", tc.name, name, err)
}
}
}
}