Settings.json hot-reload flow
Overview
The whitelist exposes settings.json loading primitives and a globalConfig mtime cache with a freshness watcher, but no settings.json-specific mtime cache or watcher function is visible . What follows traces the settings read path and the adjacent globalConfig freshness mechanism that the whitelist does expose .
Steps
- A caller entering the settings read path goes through
getInitialSettings, which delegates togetSettingsWithErrors. getSettingsWithErrorsfirst checks the session-level cache and returns early on hit, avoiding any disk I/O .- On miss, it calls
loadSettingsFromDiskand stores the result back into the session cache viasetSessionSettingsCache. loadSettingsFromDiskguards against reentry usingisLoadingSettings, then merges plugin settings and iterates enabled setting sources in priority order .- Per-source parsing is memoized through
parseFileCacheandperSourceCache, so repeat reads within one load avoid re-parsing files . - Invalidation of the merged cache happens through
resetSettingsCache, which clears the session cache plus both per-source maps in one shot . - One caller of that reset is
getRemoteManagedSettingsSyncFromCache, which flushes the merged cache the first time the remote-managed policy layer becomes visible so the next read re-merges with that layer included . - For the adjacent
globalConfigfile,getGlobalConfigtakes a pure memory fast path offglobalConfigCache.configand only falls through to a sync stat+read on the cold startup miss . - On that slow path it stats the file before reading, recording
mtimeMsinto the cache so a concurrent writer racing the read self-corrects on the next watcher tick . - A background freshness watcher — gated by
freshnessWatcherStarted— is what picks up other instances' writes without blocking the fast path, per the comment ingetGlobalConfig. - Writes back to settings go through
updateSettingsForSource, which bypassesperSourceCacheexplicitly becausemergeWithmutates its target and a failed write would otherwise leak unpersisted state into the cache . - The whitelist does not expose a
settings.jsonmtime cache, file watcher, or change-detection function — only the session/per-source/parse caches above and the separateglobalConfigmtime+watcher pair — so a full settings-file hot-reload path cannot be traced from the provided source .
State touched
Decisions
(None in whitelist — the decisions section is empty .)