Clean up CCC cacheability and access metadata
## Problem/motivation
Follow-up to:
#3586258+s
Parent:
#3586298+s
**1. Cacheability And Access Metadata**
**Priority:** High
**Why group these together:** These fixes all involve Drupal render/cacheability
metadata and access-result cache contexts. They should be reviewed together to
avoid fixing one stale-cache path while leaving related cacheability gaps.
Includes:
- `AiContextOverviewController` cache metadata.
- Duplicate overview query cleanup.
- `AiContextRenderer` settings cache dependency.
## Solution
### 1.1 Add cache metadata to the overview page
**Files:**
- `src/Controller/AiContextOverviewController.php`
- `templates/ai-context-overview.html.twig`
**Problem:**
`AiContextOverviewController::overview()` builds output from:
- published `ai_context_item` entity queries;
- loaded `ai_context_item` entities;
- `ai_context.agents` configuration;
- current-user permission checks;
- an optional embedded settings form.
The returned render array has no `#cache` metadata.
**Recommended fix:**
- Add cache tags for the `ai_context_item` list and relevant loaded entities.
- Add the `config:ai_context.agents` cache dependency.
- Add user/permission cache context where permission-gated output changes.
- Ensure the embedded settings form does not accidentally make the whole page
cache incorrectly.
- Consider deriving `has_context_items` from the existing published ID query to
avoid the separate count query.
### 1.2 Preserve cacheability for revision access checks
**Files:**
- `src/AiContextItemListBuilder.php`
- revision overview/controller/form code, especially revision operation access
**Problem:**
Revision-related operation links use boolean access checks such as:
```php
$entity->access('view all revisions')
```
Boolean access checks discard access-result cacheability, including permission
contexts. The duplicate operation already uses cacheable access results, so the
revision operation should follow that pattern.
**Recommended fix:**
- Request access results with `return_as_object: TRUE`.
- Add the access result as a cacheable dependency.
- Use `isAllowed()` to decide whether to add the operation.
- Review revision overview access checks for the same pattern.
### 1.3 Add `ai_context.settings` cache dependency to rendered context
**File:**
- `src/Service/AiContextRenderer.php`
**Problem:**
`AiContextRenderer::render()` reads `ai_context.settings` for debug logging and
provider/model information, but the returned `CacheableMetadata` only includes
per-item cache tags.
**Recommended fix:**
- Add the `ai_context.settings` config object as a cacheable dependency whenever
settings affect rendering, token trimming, model selection, or debug behavior.
- Keep existing per-item cache tags.
---
## AI usage
- [x] AI assisted issue
issue