"""Scope / undefined-reference guard for the static JS bundle (issue #3696). Why this exists: #3696 was a brick-class regression — `_sessionAttentionState` was declared *inside* `renderSessionListFromCache()` but called (un-guarded) from a separate top-level function `_sidebarRowHasVisibleMessages`. Function hoisting is scoped to the enclosing function, so the call threw `ReferenceError: _sessionAttentionState is not defined` on every sidebar cache-render and the session list went blank (v0.51.269, regressed by #3672). Nothing caught it: `node --check` is a syntax check (a nested function IS valid syntax), source-presence tests asserted the strings existed (they did — in the wrong scope), and the existing `no-const-assign` runtime gate only covers const-reassign / import-assign. This is a DIFFERENT runtime-error class: referencing a name that isn't in scope. `scripts/scope_undef_gate.py` models the WebUI's classic-`