ADR 008 — Cache ownership and host boundary
Status: Accepted
Date: 2026-05-12
Deciders: Abdisamed Mohamed
Related ADRs: ADR 006, ADR 010
Context
Project scan reuse (files.json, analysis.json), translation L2 (translations/<code>.json), and locale-write invalidation interact with every major command. Early work split hints between CLI and core; drift caused inconsistent rebuild behavior. v1 locked policy in core and host wiring in CLI/IDE.
Decision
- Core owns cache policy:
resolveCacheConfig,decideAnalysisRebuild,decideProjectAnalysisCacheInvalidation, read/write underpackages/core/src/cache/**. - Hosts own flags and adapters:
--no-cache,--debug-cache,--cache-profile,I18NPRUNE_HOME, logger[cache]lines — CLI passesCacheRuntimeinto core; no forked delta logic inpackages/cli. - Explicit
cache.rebuild: 'full'in config overrides profile defaults → always full analysis scan;--debug-cachereportsfull (config rebuild=full). - Locale deltas (from
decideAnalysisRebuild):- Target locale only → reuse analysis arrays.
- Source locale only → partial (
missingKeysrefresh, no fullsrc/**walk). - Source + target together → full scan.
- Layout fingerprint change → full scan.
- Same-run locale writes (
sync/generate) invalidateanalysis.jsonfor the next command in the process; target-only writes skip delete so the next dispatch can reuse scan arrays. - Translate L1/L2 are for
generateprovider reuse only — not a substitute for locale JSON or--resume.
Implementation
ts
// packages/core/src/cache/rebuildPolicy.ts — decision entry
decideAnalysisRebuild({
config: resolvedRebuildConfig,
classified: fileDelta,
hasPrevious: Boolean(analysisJson),
trackedSrcCount,
});ts
cache: {
profile: 'balanced',
rebuild: 'full', // overrides profile → always full scan
}Consequences
Positive
- CLI, SDK, and future IDE hosts share one rebuild story.
--debug-cachelines map directly toAnalysisRebuildReasonvalues.
Negative
- Contributors must read core before adding “quick” cache shortcuts in CLI.
- WSL vs Windows native Node use different home paths — documented under CLI cache.
Mitigation
- CLI cache and Cache config for operators.
- Solved: locale layout mismatch rebuild for layout fingerprint cases.
Alternatives Considered
CLI-owned cache dispatch
- Pros: Faster to wire one command.
- Cons: SDK and worker hosts would diverge; already rejected in tree refactors (T5).
No disk cache (always full scan)
- Pros: Simplest mental model.
- Cons: Unacceptable on large monorepos; partial rebuild shipped in Phase 2–4.
References
- CLI cache
- Cache config
- Solved: locale layout mismatch rebuild
- Git:
02653b7locale-aware rebuild;71b9190target-only invalidation skip;58e9f32profiles;2ab8b17types intypes/cache