You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: syncRagDocumentScopes can fail silently, leaving corpus scope stamps stale #2990
convex/documents/internal_actions.ts → syncRagDocumentScopes re-stamps a corpus row's team_ids / project_id when a document's scope changes. It is scheduled fire-and-forget, and its failure path is a warning and nothing else:
}catch(error){console.warn(`[syncRagDocumentScopes] corpus update failed for org ${orgSlug}:`,errorinstanceofError ? error.message : error,);}
No retry, no reconciliation, no signal. If the knowledge database is briefly unreachable, the Convex row says "project X" while the corpus row still says NULL/NULL/NULL, indefinitely.
Not a leak — but not harmless
Correctness survives, because retrieval re-checks every document hit against live Convex truth (filterRetrievableRagFileIds) rather than trusting the SQL projection. The unstamped row is filtered out after the fact.
The cost is silent degradation instead:
an unstamped row reads as a hub row in the SQL pre-filter (team_ids IS NULL AND team_id IS NULL AND project_id IS NULL), so it is returned to every caller and rejected afterwards
the pre-filter stops pre-filtering, so searches scan and post-filter more than they should
nothing anywhere reports the drift, so it accumulates
The fail-open-then-catch design is deliberate and documented — unstamped rows keep org-wide visibility so pre-scoping rows stay retrievable. That is defensible. Having no way to notice the divergence is the gap.
Suggested
Retry, or record the failure somewhere reconcilable, rather than only warning.
A periodic reconcile comparing Convex document scope against corpus stamps, reporting mismatches — the RAG watchdog already does an analogous corpus reconcile and could carry it.
Activity