AnalysisSession Persistent analysis handle.
Concurrency: not safe across overlapping calls. Serialize externally
(each caller awaits the previous setFile/setFiles before starting the
next). The LS underneath is sync, but the resolver phase awaits I/O for
async resolvers (Vite/Rollup), so the session does cross await boundaries.
Cache-hit semantics: per-entry, all-or-nothing. The implementation must not split the guarantee across separate caches (e.g. transform-cache hit + lex re-run). The match criterion is mode-discriminated:
- lex+resolve mode: existing.content === incoming.content AND
existing.resolverIdentity === incoming.resolverIdentity.
- pre-resolved mode: existing.content === incoming.content AND
arraysShallowEqual(existing.preResolvedDepsSnapshot, incoming.dependencies).
Mode flips (an entry previously ingested as lex+resolve now arrives with
dependencies, or vice versa) always cache-miss.
Promise resolution: setFile / setFiles resolve only after the
serial LS push (phase 3) completes for every file in the batch. Awaiting
the returned promise is sufficient — no separate flush step.