From c420f6981b6dc6a3b7d177a25a8b0d9e3620e89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Magyar?= Date: Sat, 3 Oct 2026 20:34:56 +0100 Subject: [PATCH] fix(embeddings): retain recovery receipts during in-place retries Address PR #3463: preserve the complete validated old receipt whenever this run cannot create a new recoverable staged generation. Continue publishing measured in-place embedding counts, and replace the receipt only after successful finalization. --- gitnexus/src/core/run-analyze.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gitnexus/src/core/run-analyze.ts b/gitnexus/src/core/run-analyze.ts index b144065a8..5f43df3e2 100644 --- a/gitnexus/src/core/run-analyze.ts +++ b/gitnexus/src/core/run-analyze.ts @@ -4632,16 +4632,14 @@ async function runFullAnalysisInner( stagedCheckpointEmbeddingCount = embeddings; } const latestMeta = (await loadMeta(metaDir)) ?? existingMeta; - // The supported manual-checkpoint opt-out cannot prove durability of - // this stage. Keep an earlier proven generation and its original - // identity/progress intact until the replacement is published. - if ( - useAtomicSwap && + // An in-place write or manual-checkpoint opt-out cannot create a new + // recoverable staged generation. Keep the complete previous receipt: + // updated progress or unsafe nodes would describe different source bytes. + const preservedRecoveryCheckpoint = !stagedRecoveryEnabled && resolveEmbeddingRecovery(metaDir, latestMeta?.embeddingCheckpoint) - ) { - return; - } + ? latestMeta?.embeddingCheckpoint + : undefined; // First-ever analyze of this repo: no meta exists on disk yet (the // pre-wipe dirty stamp only fires when one does). Mint the minimum // RepoMeta requires, with `lastCommit: ''` — never `currentCommit` — @@ -4664,7 +4662,7 @@ async function runFullAnalysisInner( : { stats: { ...base.stats, embeddings } }), // Written by a run that is still IN FLIGHT — see the `kind` doc in // repo-manager.ts. - embeddingCheckpoint: { + embeddingCheckpoint: preservedRecoveryCheckpoint ?? { ...interrupted, ...(stagedRecoveryEnabled ? {