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
POST /v1/knowledge-graph/rebuild deletes the legacy graph before the rebuild worker runs, with no recovery if the worker dies #11796
The delete is committed and the 200 is returned before any rebuild work happens. Two consequences:
If the background task never runs to completion — process restart, pod eviction, an LLM error inside rebuild_knowledge_graph — the user is left with no knowledge graph at all and no signal beyond a 200 that said "rebuilding".
_rebuild_graph_task re-evaluates the gate after the delete. An account that becomes assertion-backed between the route's check and the task's check hits the != ALLOWED early return, so the task no-ops and the legacy graph stays deleted. The same is now true for the UNVERIFIED arm added in the mutation-gate hardening PR: a head read that times out in the window between the two checks stops the rebuild after the delete already landed.
This is the pre-5724a10084 contract restored by #11783, not a regression introduced by it — the ordering has been this way since the route existed. Flagging it because there is no test covering "delete succeeded, rebuild failed", and the hardening PR deliberately did not restructure it.
Plausible fixes, none of them free: build into a shadow collection and swap at the end; make the task idempotent and retryable with a persisted "rebuild pending" marker; or drop the eager delete and have rebuild_knowledge_graph overwrite in one transaction.
Evidence: backend/routers/knowledge_graph.pyrebuild_graph / _rebuild_graph_task; found in adversarial review of #11783 (rated a nit, not blocking).
Activity
fix(backend): only a genuinely absent state head may unlock the legac…
fix(backend): stop deleting the knowledge graph before the rebuild th…