{"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":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2846,"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":2828,"sourceCodeEnd":2853,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/analyzer-identity.ts#L2828-L2853","documentation":"Thrown by finalizeAnalyzerRunnerIdentity() immediately before metadata commit when the analyzer's build digest or dependency-runtime identity differs from the receipt captured at analysis start by captureAnalyzerIdentityBeforeLoad(). GitNexus stamps provenance metadata into the index so cached results are attributable and reproducible; if the analyzer module graph was mutated mid-run (e.g. a concurrent npm install or tsx hot-reload rewrote build artifacts), the receipt is stale and committing it would be dishonest. The check refuses to stamp rather than emit untrustworthy metadata.","triggerScenarios":"Called at run-analyze.ts:3586 (finalizeAnalyzerRunnerIdentity(import.meta.url, runnerIdentity)) right before writing meta.runnerIdentity. Triggers when resolveAnalyzerRunnerIdentity() returns a different build.digest or dependencyRuntime.identity than the startedWith receipt. Common during `npm run dev` (tsx watch rebuilds between capture and finalize), a concurrent `npm install`/`git checkout` that touches gitnexus/src or node_modules, or running two `analyze` processes against one install while one upgrades it.","commonSituations":"Running `analyze` inside `npm run dev` where tsx watch recompiles mid-analysis; a CI runner that reinstalls the package while a previous analysis is still finishing; switching git branches or running `npm install` in another terminal during a long index; Docker volume mounts that flap build artifacts.","solutions":["Run analyze from a stable installed build (npx gitnexus@latest analyze) instead of `npm run dev`, so nothing rewrites the module graph mid-run.","Do not run `npm install`, `git checkout`, or a second analyze that rebuilds in the same install while an analysis is in progress.","If developing against the dev build, disable tsx watch (use a single `tsx` invocation, not watch mode) for the analysis run.","Retry the analyze once the installation is stable — the receipt is recomputed fresh each run."],"exampleFix":"// before — dev watch recompiles between capture and finalize\n$ npm run dev -- analyze --embeddings\n// after — stable installed runner; capture and finalize see the same digest\n$ npx gitnexus@latest analyze --embeddings","handlingStrategy":"validation","validationCode":"// Before starting a long analysis, confirm the build artifacts are not being\n// watched/recompiled. Run analyze from a stable install.\n// import { existsSync, statSync } from 'node:fs';\n// const dist = require.resolve('gitnexus');\n// const mtime0 = statSync(dist).mtimeMs;\n// ... run analyze ...\n// const mtime1 = statSync(dist).mtimeMs;\n// if (mtime0 !== mtime1) console.warn('Build changed mid-run — re-run on a stable install.');","typeGuard":"import { analyzerRunnerIdentitiesEqual } from 'gitnexus/src/core/analyzer-identity.js';\n\n// Returns true when the captured receipt still matches the current identity,\n// i.e. it is safe to proceed to finalize without throwing.\nconst isIdentityStable = (\n  startedWith: unknown,\n  current: unknown,\n): boolean => analyzerRunnerIdentitiesEqual(startedWith, current);","tryCatchPattern":"// finalizeAnalyzerRunnerIdentity is called by the analyze runner itself; if you\n// invoke analysis programmatically, treat error 100 as non-retriable in-place\n// and re-run from a stable install.\ntry {\n  await runAnalyze(opts);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('changed during analysis')) {\n    // Stop concurrent installs/watches, then re-run.\n    throw new Error('Analyzer mutated mid-run. Stop npm run dev / npm install and retry.');\n  }\n  throw err;\n}","preventionTips":["Run analyze from a published install (npx gitnexus@latest) rather than `npm run dev`.","Do not run npm install, git checkout, or a second analyze in the same install while analysis is running.","In CI, install once into a clean cache and run analyze without re-installing mid-step.","If developing, use a single non-watch `tsx` invocation for the analysis run."],"tags":["integrity","analyzer-identity","concurrency","provenance"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}