Size / Priority
Affected files
Background
This is the general-purpose version of #248. The broker-specific helper in #248 is one application; the framework has at least:
- Broker settings (8 brokers).
- Cache settings (3 caches).
- Journal settings (3 journals).
- Cluster settings.
- HTTP backend settings.
All do similar three-source merging. A single typed helper:
// src/util/Settings.ts (new)
export function applyDefaults<S extends Record<string, unknown>>(
partial: Partial<S>,
defaults: S,
): S;
export function resolveSettings<S extends Record<string, unknown>>(
defaults: S,
configKey: string,
configObj: Config,
ctorArgs?: Partial<S>,
): S;
applyDefaults is the simple "missing fields filled in" case; resolveSettings is the three-source version (delegate to applyDefaults for the merging logic).
Coordination
This issue is largely the umbrella for both (and a few more sites — cache, journal, cluster settings). Coordinated implementation.
Integration / risk
- No behavioural change.
- Migrate site-by-site.
Test plan
- Per-site regression — each settings consumer behaves identically.
- Edge cases — empty config, partial config, missing keys fall through to defaults.
Acceptance criteria
Size / Priority
Affected files
Background
This is the general-purpose version of #248. The broker-specific helper in #248 is one application; the framework has at least:
All do similar three-source merging. A single typed helper:
applyDefaultsis the simple "missing fields filled in" case;resolveSettingsis the three-source version (delegate toapplyDefaultsfor the merging logic).Coordination
resolveSettingsinternally.settings.x ?? DEFAULT_Xpattern #266 (defaults at call sites) — coversapplyDefaultsconsolidation across the codebase.This issue is largely the umbrella for both (and a few more sites — cache, journal, cluster settings). Coordinated implementation.
Integration / risk
Test plan
Acceptance criteria
applyDefaults+resolveSettingsexported.settings.x ?? DEFAULT_Xpattern #266 as covered if this lands.