Implement error check for staged embeddings during sync

Add error handling for syncing embeddings with staged checkpoints.Address PR #3463: embeddings sync cannot recover staged vectors, so reject a recovery-bearing checkpoint under the index lock before detaching a shared graph, opening the writable database, or spending embedding work. Direct users to gitnexus analyze first.
This commit is contained in:
Gergő Magyar 2026-10-03 20:37:08 +01:00 • committed by GitHub
parent c420f6981b
commit dd900bb771
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,6 +56,15 @@ export const embeddingsSyncCommand = async (inputPath?: string): Promise<void> =
lock,
`Cannot acquire the index lock at ${metaDir}; refusing an unlocked embeddings sync.`,
);
// Sync writes the published graph and cannot recover a staged generation.
// Reject even malformed receipts before detaching a shared graph or writing.
const recoveryCheckpoint = (await loadMeta(metaDir))?.embeddingCheckpoint;
if (recoveryCheckpoint && Object.hasOwn(recoveryCheckpoint, 'recovery')) {
throw new Error(
'Cannot sync embeddings: the index checkpoint references staged embeddings. ' +
'Run `gitnexus analyze` to recover them first.',
);
}
if (!(await ensurePrivateSharedGraph(metaDir, (m) => console.log(` ${m}`)))) {
throw new Error('The shared graph this checkout reads is gone. Run gitnexus analyze first.');
}