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
Gateway admin endpoints /search/optimize and /search/rebuild aren't fenced during staged rebuilds #165
Found in independent review of #162, which keeps reads serving from the published generation during a staged rebuild (#145).
Problem
The HTTP gateway's admin endpoints /search/optimize and /search/rebuild (mcp_server/gateway.py, around 2815 and 2875 on the #162 branch) write derived FTS data straight into the published index. They have never been gated on readiness. If a staged rebuild is in progress, the staged generation has already copied the active database, so whatever these endpoints write is superseded at publish, and they still report success.
These are secondary admin operations on derived data, so this doesn't block #162.
Suggested fix
Either refuse with rebuild_in_progress while a live rebuild owner exists, using the same RepoResolver.accepts_writes(ctx) and write-time generation check that #162 adds for summary writes, or run the maintenance inside the staged build instead of against the published DB. Add a test where the endpoint is called during a rebuild and nothing is written to the old generation.
Source review of bcc0f60 found two independent hazards. Both HTTP maintenance routes use the startup-global search backends and store. Resolving a registry entry for preflight can therefore select a different database from the one the route mutates. Even with the correct database, a staged rebuild can snapshot after preflight and before the maintenance commit.
Resolve the registered target using the existing search selector. Acquire the checkout writer fence before cold store or backend initialization, which can issue DDL. Under the lock, validate the captured generation and file binding and hold it through the final commit. Keep cache effects scoped to that store. Preserve legacy single-store behavior and semantic-only remediation. Registered fuzzy maintenance must use the selected generation's indexed content.
Regression coverage should use two registered stores plus a distinct global store, and exercise both orderings with a barrier: publication wins before maintenance admission, and maintenance holds the lock through commit. Include same-commit rebuilds, contention and same-path file replacement. This is a proposed fix based on source inspection.
Activity
ViperJuice commentedon Nov 23, 2026
Source review of
bcc0f60found two independent hazards. Both HTTP maintenance routes use the startup-global search backends and store. Resolving a registry entry for preflight can therefore select a different database from the one the route mutates. Even with the correct database, a staged rebuild can snapshot after preflight and before the maintenance commit.Resolve the registered target using the existing search selector. Acquire the checkout writer fence before cold store or backend initialization, which can issue DDL. Under the lock, validate the captured generation and file binding and hold it through the final commit. Keep cache effects scoped to that store. Preserve legacy single-store behavior and semantic-only remediation. Registered fuzzy maintenance must use the selected generation's indexed content.
Regression coverage should use two registered stores plus a distinct global store, and exercise both orderings with a barrier: publication wins before maintenance admission, and maintenance holds the lock through commit. Include same-commit rebuilds, contention and same-path file replacement. This is a proposed fix based on source inspection.