fix: emit warning when config.LoadFromDir rejects invalid config - #226
Open
jflowers wants to merge 5 commits into
Open
fix: emit warning when config.LoadFromDir rejects invalid config#226jflowers wants to merge 5 commits into
jflowers wants to merge 5 commits into
Conversation
Add OpenSpec change artifacts for issue unbound-force#155: emit warning when config.LoadFromDir silently rejects invalid config. Artifacts: - proposal.md: problem statement and IO Writer approach - design.md: D1-D5 decisions, coverage strategy - specs/config-load-warning.md: Given/When/Then scenarios - tasks.md: 4 groups, 13 tasks, spec-review passed
Change LoadFromDir signature from func(moduleDir string) *GazeConfig to func(moduleDir string, stderr io.Writer) *GazeConfig. When config.Load returns a validation or parse error, LoadFromDir now writes a warning to stderr before falling back to DefaultConfig(). File-not-found remains a silent fallback (handled by config.Load). Updated call sites: - internal/aireport/runner_steps.go: qualityPipelineDeps.loadConfig type, runDocscanStep, runClassifyStep - internal/aireport/runner.go: pipelineStepFuncs.docscanStep and classifyStep types - internal/provider/goprovider/contract.go: buildContractCoverageFuncDeps.loadConfig type - cmd/gaze/main.go: initExternalSession, resolveBaselinePath, loadAndCompare Added 5 new tests for LoadFromDir warning behavior. Updated all existing test fakes across 4 test files. Closes unbound-force#155
Consolidate TestLoadFromDir_MalformedYAML_EmitsWarning, TestLoadFromDir_MissingFile_NoWarning, and TestLoadFromDir_ValidConfig_NoWarning into the existing TestLoadFromDir_InvalidYAML, TestLoadFromDir_MissingFile, and TestLoadFromDir_ValidConfig — the originals already contain the same assertions after their io.Writer updates. Add missing .gaze.yaml path assertion to TestLoadFromDir_InvalidYAML for warning format coverage.
- Add 3 Dewey learning files (io-writer DI cascade pattern, test duplication avoidance gotcha, config.Load error handling) - Add PR feedback state Assisted-by: claude-opus-4 Generated with AI assistance (claude-opus-4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #155.
config.LoadFromDirpreviously silently discarded validationerrors from
config.Loadand returnedDefaultConfig()with no indicationto the user. This created a behavioral inconsistency: commands using
config.Loaddirectly (gaze analyze,gaze quality) surfaced configerrors, while commands using
LoadFromDir(gaze crap,gaze report)silently substituted defaults — a CI gate integrity issue where threshold
gates could evaluate against incorrectly-computed scores.
The fix adds an
io.Writerparameter toLoadFromDir. Whenconfig.Loadreturns a validation or parse error, a warning is emitted before falling
back to defaults. File-not-found remains a silent fallback (the config
file is optional). Nil-safe: passing
nilsilently discards warnings.Remediates Constitution Principle II (silent assumption) and Principle III
(no actionable guidance) violations confirmed by all five Divisor panel
agents during triage.
How to Test
Key acceptance scenarios from the spec:
How to Demo
.gaze.yamlwith an invalid threshold:contractual: 500gaze crap ./...-- observe the warning on stderrcontractual: 80)gaze crap ./...again -- no warningKey Files Changed
Production (5 files):
internal/config/config.go--LoadFromDirgainsstderr io.Writerparam + warning logicinternal/aireport/runner_steps.go-- DI type update, 4 call sites passstderrinternal/aireport/runner.go--pipelineStepFuncstype updates for docscan/classifyinternal/provider/goprovider/contract.go-- DI type update, 1 call sitecmd/gaze/main.go-- 3 call sites, 2 function signature changesTests (4 files):
internal/config/config_test.go-- 5 new tests, 3 updated for new signatureinternal/aireport/pipeline_internal_test.go-- 4 fake function updatesinternal/aireport/runner_steps_test.go-- 7 call site updatesinternal/provider/goprovider/contract_internal_test.go-- 4 fake updatesSpec artifacts (4 files):
openspec/changes/config-load-warning/-- proposal, design, specs, tasksThis PR was generated by /uf.finale (AI-assisted).