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.
This commit is contained in:
Gergő Magyar 2026-10-03 20:34:56 +01:00 • committed by GitHub
parent 403320ae3e
commit c420f6981b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
? {