fix(search): let cancelled live reads stop instead of reporting partial coverage

Merged
WA
1mo ago
+105-7

Summary

  • A cancelled or timed-out live read could resolve as a successful, partially covered document. readDiscussionSection turns every per-section failure into a "could not be fully retrieved" warning, including the caller's abort, so Drive, Linear, and GitHub reads kept going after Stop, a cancelled MCP request, or the 15s read budget
  • readLiveDocument now decides cancellation by the signal's state right after the provider read (signal.throwIfAborted(), before verifyCurrent), as search already does. That covers every abort reason: Copilot Stop's string reasons, custom abort errors, an MCP cancel reason, AbortError, and TimeoutError, on every provider path. Genuine provider failures still degrade to partial coverage
  • Notion: a notion-ai-search result without a type is reported as partial instead of complete; an explicit workspace_search fallback stays complete
  • Linear: backwards (oldest-first) reads validate hasPreviousPage, the flag they actually page on
  • Meeting content and discussion entries are cut with truncateAtCodePoint, so a cut never splits a surrogate pair and the discussion cap is exact

Type of Change

  • Bug fix

Testing

  • readLiveDocument rejects with the exact reason for a string reason, AbortError, and TimeoutError during a Drive discussion read, and a connection reset on the comments request still returns the document with the coverage warning
  • Notion missing-type → partial; Linear backwards read without hasPreviousPage → rejected
  • With staging's sources swapped in, all five new cases fail
  • lib/sim-search suites (303 tests), type-check, lint, and check:audits pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)