From dd900bb771d358d912dcc925f0554bda2020fcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Magyar?= Date: Sat, 3 Oct 2026 20:37:08 +0100 Subject: [PATCH] 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. --- gitnexus/src/cli/embeddings-sync.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gitnexus/src/cli/embeddings-sync.ts b/gitnexus/src/cli/embeddings-sync.ts index 9848ef7c4..f6e2e9e18 100644 --- a/gitnexus/src/cli/embeddings-sync.ts +++ b/gitnexus/src/cli/embeddings-sync.ts @@ -56,6 +56,15 @@ export const embeddingsSyncCommand = async (inputPath?: string): Promise = 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.'); }