refactor(search): address PR #750 round 4 review feedback

- Guard eviction_task_group.start_soon against shutdown race so a
  RuntimeError on a closed group never surfaces as a search error.
- Correct ADR-019 news_item row: there is no per-item REST endpoint;
  verification batches via get_items(batch_size=-1) and intersects.
- Modernize models/semantic.py typing to PEP 604 / lowercase generics
  per CLAUDE.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-01 19:28:55 +02:00
co-authored by Claude Opus 4.7
parent aa4b9498a1
commit 926722b09d
3 changed files with 23 additions and 17 deletions
+9 -1
View File
@@ -462,7 +462,15 @@ async def verify_search_results(
if eviction_task_group is not None:
for doc_id, doc_type in inaccessible:
eviction_task_group.start_soon(evict, doc_id, doc_type)
# Guard against the lifespan task group having exited between
# the getattr() capture in server/semantic.py and this call —
# start_soon raises RuntimeError on a closed group, which
# would otherwise surface as a search error. Eviction is
# best-effort: the next query re-verifies and re-attempts.
try:
eviction_task_group.start_soon(evict, doc_id, doc_type)
except Exception:
logger.debug("Eviction task group closed; will retry on next query")
else:
async with anyio.create_task_group() as tg:
for doc_id, doc_type in inaccessible: