pub fn store_if_current(
cache: &PerBufferCache<ContextScopeCache>,
buffer_id: BufferId,
parse_version: u64,
scopes: Vec<ContextScope>,
) -> boolExpand description
TC.13: cache scopes for buffer_id unless a NEWER parse’s answer is
already there. Returns whether the write happened.
Producers run off-thread, so a slow one can land after a newer parse’s reply is already cached. The cache is keyed by parse version and the READ gate compares that key, but the write was unconditional — so a late reply replaced correct scopes with stale ones, pointing the strip at lines that have since moved. It self-heals on the next tick, and “wrong for one frame, then right” is exactly the flicker the UX contract vetoes.
A free function rather than a closure so the ordering rule is testable without racing two real producers, which is the kind of test that passes nine times in ten.