{"record":{"id":"d1bd1bcf0e1a51e1","repo":"abhigyanpatwari/GitNexus","slug":"analyzer-build-or-dependency-runtime-changed-durin","errorCode":null,"errorMessage":"Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata. Retry with a stable GitNexus installation.","messagePattern":"Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata\\. Retry with a stable GitNexus installation\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2870,"sourceCode":"export async function captureAnalyzerIdentityBeforeLoad<T>(\n  analyzerModuleUrl: string,\n  loader: () => Promise<T>,\n  options: AnalyzerIdentityResolveOptions = {},\n): Promise<{ runnerIdentity: AnalyzerRunnerIdentity; loaded: T }> {\n  const runnerIdentity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);\n  const loaded = await loader();\n  return { runnerIdentity, loaded };\n}\n\n/** Re-resolve immediately before commit and reject analyzer mutation mid-run. */\nexport function finalizeAnalyzerRunnerIdentity(\n  analyzerModuleUrl: string,\n  startedWith: AnalyzerRunnerIdentity,\n  options: AnalyzerIdentityResolveOptions = {},\n): AnalyzerRunnerIdentity {\n  const finalIdentity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);\n  if (!analyzerRunnerIdentitiesEqual(startedWith, finalIdentity)) {\n    throw new Error(\n      'Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata. ' +\n        'Retry with a stable GitNexus installation.',\n    );\n  }\n  return finalIdentity;\n}\n","sourceCodeStart":2852,"sourceCodeEnd":2877,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/analyzer-identity.ts#L2852-L2877","documentation":"finalizeAnalyzerRunnerIdentity() re-resolves the analyzer identity immediately before metadata is stamped into the index and compares it to the identity captured when analysis started (analyzerRunnerIdentitiesEqual). Any difference — build digest change, dependency runtime change, version change — means the installation mutated during the run, so results would be stamped with inconsistent provenance and the run is rejected with retry guidance.","triggerScenarios":"A long analyze run during which the GitNexus installation changes: upgrading gitnexus mid-run, npm install rewriting node_modules, embeddings stack installing concurrently, or a dev watcher rebuilding dist/. At finalize time the re-resolved identity != startedWith.","commonSituations":"Auto-updaters or CI patching the tool during a job, a user running npm install -g gitnexus while an analyze/MCP session is active, or scheduled rebuild tasks overlapping long indexing runs on big repositories.","solutions":["Re-run the analysis after the installation change completes; the retry will capture a consistent identity.","Freeze the tool version during long jobs (pin gitnexus@<version> in CI, disable auto-update).","Do not run npm install or gitnexus embeddings install while an analyze is in progress.","For MCP servers, restart the server after upgrading so it never straddles two installs."],"exampleFix":"# before: upgrade lands mid-run\nT1: npx gitnexus analyze --embeddings   # long run\nT2: npm install -g gitnexus@latest\n# Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata. Retry with a stable GitNexus installation.\n\n# after: pin and sequence\nT2: (wait for T1 to finish)\nnpx gitnexus@1.14.0 analyze --embeddings","handlingStrategy":"retry","validationCode":"// Prevent mid-run upgrades: pin the version in CI and disable auto-update.\n// Example GitHub Actions step:\n//   - run: npx gitnexus@1.14.0 analyze --embeddings   # pinned, immutable during the job","typeGuard":null,"tryCatchPattern":"try {\n  await runAnalysis();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('refusing to stamp metadata')) {\n    // Install changed mid-run: re-run once against the now-stable installation\n    return runAnalysis();\n  }\n  throw err;\n}","preventionTips":["Pin the gitnexus version (npx gitnexus@x.y.z) for long jobs so upgrades cannot land mid-run.","Do not run npm install -g or gitnexus embeddings install while analysis is active.","Restart MCP servers after every upgrade so identity start/end match one install.","Schedule rebuild/upgrade windows that do not overlap big-repository indexing."],"tags":["analyzer-identity","race-condition","upgrade","metadata-integrity"],"backgroundTag":"concurrent-modification-detected","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}