{"record":{"id":"c8630d15f95be5b7","repo":"abhigyanpatwari/GitNexus","slug":"could-not-verify-persisted-embedding-count","errorCode":null,"errorMessage":"Could not verify persisted embedding count.","messagePattern":"Could not verify persisted embedding count\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/embeddings-sync.ts","lineNumber":216,"sourceCode":"          },\n        },\n      );\n\n      const embeddings = await countEmbeddings();\n      if (embeddings === undefined) {\n        // Keep last-known stats.embeddings. An interrupted window marker would\n        // fail the identity gate on the next run even though this run finished;\n        // unverified-count is the recovery kind that forces a recount (#2790).\n        await persistMeta(() => ({\n          embeddingCheckpoint: result.failedNodeIds.length\n            ? mintPartialCheckpoint(identity, result, resumedFrom)\n            : mintUnverifiedCountCheckpoint(identity, {\n                nodesProcessed: result.nodesProcessed,\n                totalNodes: result.nodesProcessed,\n                chunksProcessed: result.chunksProcessed,\n              }),\n        }));\n        throw new Error('Could not verify persisted embedding count.');\n      }\n      await persistMeta((latest) => ({\n        stats: { ...latest.stats, embeddings },\n        embeddingCheckpoint: result.failedNodeIds.length\n          ? mintPartialCheckpoint(identity, result, resumedFrom)\n          : undefined,\n      }));\n      cliInfo(`Embeddings ready: ${embeddings}`);\n    } finally {\n      await closeLbug().catch(() => {});\n      await reapEmbeddingSidecarSafely();\n    }\n  } finally {\n    lock.release();\n  }\n};\n","sourceCodeStart":198,"sourceCodeEnd":233,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/embeddings-sync.ts#L198-L233","documentation":"Thrown by embeddingsSyncCommand after the embedding pipeline finishes but countEmbeddings() returns undefined, meaning the number of persisted embeddings in the database could not be determined. Before throwing, the command deliberately persists an unverified-count (or partial) checkpoint so the next run forces a recount instead of trusting a possibly-wrong count. This is a conservative integrity guard, not a data-loss signal.","triggerScenarios":"Calling `gitnexus embeddings sync` and having countEmbeddings() return undefined after runEmbeddingPipeline completes — typically because the LadybugDB count query failed, the connection was interrupted mid-count, or the database was closed/unavailable at verification time.","commonSituations":"Flaky embedded-database state after long syncs; containerized runs where the LadybugDB file lock is contended; a sync interrupted during the final verification step.","solutions":["Rerun `gitnexus embeddings sync` — the unverified-count checkpoint forces a recount and the count usually verifies on the retry.","Check the LadybugDB index files are readable and not locked by another process (e.g. a concurrent `gitnexus serve`).","If it persists, verify the index with the doctor command / reopen the repo to rule out database corruption.","Inspect logs for the countEmbeddings() failure right before the throw to identify the underlying query error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await embeddingsSyncCommand(...);\n} catch (err) {\n  if (err.message === 'Could not verify persisted embedding count.') {\n    // safe to retry: unverified-count checkpoint forces a recount next run\n    await embeddingsSyncCommand(...);\n  }\n}","preventionTips":["Avoid running `gitnexus serve` or other processes holding the LadybugDB lock during sync","Let the sync finish before killing the process — the verification happens at the end","Rerun sync after any interruption; the checkpoint design makes the retry a recount"],"tags":["embedding","database","verification","cli"],"backgroundTag":"empty-result-set","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}