#16991: fix(config): add missing defaults to config snapshot path
stale
size: S
Cluster:
Config Management Improvements
## Summary
- The `readConfigFileSnapshotInternal` function's file-exists path was missing `applyCompactionDefaults` and `applyContextPruningDefaults` in its defaults chain, while `loadConfig` and the no-file-exists path both correctly included them. This caused config snapshots read from existing files to lack compaction and context pruning defaults.
- Added the two missing calls in the same nesting order as `loadConfig`, so all three paths now apply a consistent set of defaults.
## Test plan
- Added `src/config/io.snapshot-defaults.test.ts` with two tests:
- Verifies `compaction.mode` is set to `"safeguard"` when a config file exists with `agents.defaults`
- Verifies the same default is applied when no config file exists (existing behavior, regression guard)
- Existing `io.write-config.test.ts` tests continue to pass
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes an inconsistency in the config defaults chain within `readConfigFileSnapshotInternal` in `src/config/io.ts`. The file-exists path was missing calls to `applyCompactionDefaults` and `applyContextPruningDefaults`, while both `loadConfig` and the no-file-exists path correctly included them. This caused config snapshots read from existing files to lack compaction and context pruning defaults (e.g., `compaction.mode` not being set to `"safeguard"`).
- Adds `applyCompactionDefaults(applyContextPruningDefaults(...))` wrapping in the file-exists path of `readConfigFileSnapshotInternal`, matching the same nesting order as `loadConfig` (lines 582-590)
- Adds a new test file `io.snapshot-defaults.test.ts` with two focused tests covering both the file-exists and no-file-exists paths
- The fix is minimal, correctly ordered, and well-tested
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it adds two missing function calls to align a defaults chain with existing correct patterns.
- The change is a straightforward, low-risk bug fix that adds two missing defaults function calls (`applyCompactionDefaults`, `applyContextPruningDefaults`) to match the already-correct patterns in `loadConfig` and the no-file-exists path. The nesting order is verified to be consistent across all three paths. New tests cover the exact scenario. No behavioral regressions are expected.
- No files require special attention.
<sub>Last reviewed commit: 20b65ad</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#15613: fix(config): align default pipelines across loadConfig and readConf...
by AI-Reviewer-QS · 2026-02-13
91.4%
#19510: fix(config): preserve configured values on invalid config validatio...
by yash27-lab · 2026-02-17
77.4%
#12048: fix: deduplicate config warnings to log once instead of on every re...
by mcaxtr · 2026-02-08
77.0%
#11873: fix: eliminate TOCTOU race in readExecApprovalsSnapshot
by Yida-Dev · 2026-02-08
76.5%
#4897: fix: config logic issues (#4689, #4654)
by lailoo · 2026-01-30
75.3%
#22711: fix: post-compaction audit skips non-existent required files
by taw0002 · 2026-02-21
74.8%
#21124: fix(config): preserve missing keys from original in restoreRedacted...
by Marvae · 2026-02-19
74.6%
#16301: fix: preserve custom config keys during configure wizard
by superlowburn · 2026-02-14
74.1%
#18997: fix: improve context overflow error messages and docs
by realhoratiobot · 2026-02-17
74.0%
#15948: fix(logging): prevent recursive logger/config stack overflow
by Glucksberg · 2026-02-14
73.8%