Improve context selection cacheability and request-level scope performance
Follow-up to: #3582504 **Description:** Improve selection performance and cache correctness on the selection path. Scope plugins were being re-instantiated repeatedly during one request, and `AiContextResult` cache metadata did not reflect route/path/target-entity variation even though selection can depend on those contexts. During implementation and review, **per-plugin value memoization was removed** (`452aa76`). It conflicted with `AiContextEntityTargetResolver::setCurrentEntity()` mid-request and broke entity bundle / target entity tests. Most scope `doGetCurrentValue()` implementations are cheap in-memory reads; the real win is **plugin instance** memoization plus batch plugin loading in the resolver. Entity bundle scope is the main exception; bundle resolution is memoized on **`AiContextEntityTargetResolver`**, not on plugin instances. **Scope:** - Request-level memoization for `AiContextScopeManager::getScopePlugins()` (cleared when plugin definitions are cleared). - Load scope plugins once per `filterByCurrentContext()` batch (reuse memoized instances). - Add selection cache contexts: `url.path`, `route`, `ai_context.target_entity` (plus existing `languages:language_content`, `user.permissions`); bubble target entity cache tags when present. - Register `ai_context` parent + `ai_context.target_entity` cache context services. - Verify `ai_context_item_list` is the core list tag; document in code/test — no custom invalidation added. - Entity bundle: `getCurrentEntityBundle()` on target resolver with request-scoped memo (resets on `setCurrentEntity()` / `clearCurrentEntity()`). - Tests: plugin instance memoization, filter batch plugin-load contract, cache metadata on `AiContextResult`, entity bundle resolver memoization, list tag verification. **Out of scope (needs follow-up issues):** - Referer-based language detection vs `languages:language_content` cache context (pre-existing AJAX mismatch). - Optional conditional cache contexts when path/route/target scopes are inactive. - Stronger cache-key variation tests (path → resolved keys via `cache_contexts_manager`). **Acceptance criteria:** - [x] Repeated `getScopePlugins()` calls in one request reuse the same plugin instances. - [x] `filterByCurrentContext()` loads scope plugins once per batch, not once per item. - [x] Scope current values are resolved live per check (no plugin-instance value cache); entity bundle loads are memoized on the target entity resolver for the current target. - [x] `AiContextResult` cache metadata includes `url.path`, `route`, and `ai_context.target_entity`, and bubbles target entity tags when applicable (empty and non-empty results). - [x] `ai_context_item_list` behavior verified; documented by comment and kernel test. - [x] Kernel/unit coverage for instance memoization, filter batch behavior, cache metadata, and entity bundle resolver memoization. **AI usage disclosures:** - [x] AI Assisted Issue - [x] AI Generated Code
issue