{"record":{"id":"11c0093df7a74f93","repo":"abhigyanpatwari/GitNexus","slug":"analyzer-dependency-runtime-changed-while-its-iden","errorCode":null,"errorMessage":"Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}","messagePattern":"Analyzer dependency runtime changed while its identity was being computed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/analyzer-identity.ts","lineNumber":2766,"sourceCode":"    runtimeVariant,\n  );\n\n  const packageVersion = dependencyInputs.packages[0]?.manifest.version;\n  if (typeof packageVersion !== 'string' || packageVersion.trim() === '') {\n    throw new Error(`GitNexus package version is unavailable in ${packageRoot}`);\n  }\n\n  const buildSnapshotAfter = buildSnapshot(\n    collectBuildEntries(buildRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(build.snapshot, buildSnapshotAfter)) {\n    throw new Error(`Analyzer build changed while its identity was being computed: ${buildRoot}`);\n  }\n  const dependencySnapshotAfter = dependencySnapshot(\n    collectDependencyInputs(packageRoot, options, traversalLimits),\n  );\n  if (!isDeepStrictEqual(dependencySnapshotBefore, dependencySnapshotAfter)) {\n    throw new Error(\n      `Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}`,\n    );\n  }\n\n  const nextCache: IdentityCachePayload = {\n    schemaVersion: IDENTITY_CACHE_SCHEMA_VERSION,\n    packageRoot,\n    buildRoot,\n    packageVersion,\n    buildKind: kind,\n    buildCanonicalization: BUILD_CANONICALIZATION,\n    dependencyCanonicalization: DEPENDENCY_RUNTIME_CANONICALIZATION,\n    traversalLimits,\n    runtimeVariant,\n    buildRootState: build.rootState,\n    buildDigest: build.digest,\n    buildEntries: build.entries,\n    buildDirectoryGuards: build.directoryGuards,","sourceCodeStart":2748,"sourceCodeEnd":2784,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/analyzer-identity.ts#L2748-L2784","documentation":"Companion to the build-tree race check: dependency inputs (manifests, lockfiles, runtime artifacts) are snapshotted before hashing and re-collected after. A deep-strict inequality means the dependency runtime mutated mid-computation (new node_modules content, lockfile rewrite, vendor/ change), so the identity is discarded with this error naming the package root.","triggerScenarios":"resolveAnalyzerRunnerIdentity() where between dependencySnapshot() calls something changes dependency inputs — npm install running concurrently, npm audit fix rewriting package-lock.json, a postinstall script materializing vendored grammars into node_modules, or an embeddings install adding the ONNX stack mid-analysis.","commonSituations":"`gitnexus embeddings install` racing an analyze (the analyzer auto-installs the optional stack with --embeddings), two CI jobs sharing an install directory, npm cache pruning touching the tree, or a partially completed install from a previous crashed run finishing via file watcher.","solutions":["Let any in-flight install finish, then re-run analyze — the retry on a quiescent tree succeeds.","Run `gitnexus embeddings install` as its own completed step before analyze --embeddings rather than concurrently.","Serialize CI jobs that share the installation directory (or give each job its own container/image layer).","After a crashed install, reinstall cleanly so no watcher 'finishes' writes during analysis."],"exampleFix":"# before: parallel CI steps share the install\n- run: gitnexus embeddings install &\n- run: npx gitnexus analyze --embeddings\n# Analyzer dependency runtime changed while its identity was being computed\n\n# after: sequential steps\n- run: gitnexus embeddings install\n- run: npx gitnexus analyze --embeddings","handlingStrategy":"retry","validationCode":"// Check nothing is mutating node_modules before analyze:\nimport { execSync } from 'node:child_process';\nfunction noConcurrentInstall(): boolean {\n  try {\n    const ps = execSync('ps ax -o command=', { encoding: 'utf8' });\n    return !/(npm|pnpm|yarn|bun)\\s+(i|install|ci|update)/.test(ps);\n  } catch {\n    return true;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await analyze({ repo: '.', embeddings: true });\n} catch (err) {\n  if (err instanceof Error && /dependency runtime changed while its identity was being computed/.test(err.message)) {\n    await waitForInstallsToFinish();\n    return analyze({ repo: '.', embeddings: true });\n  }\n  throw err;\n}","preventionTips":["Run `gitnexus embeddings install` as a completed step before analyze --embeddings.","Give each CI job its own container/layer instead of sharing one install directory.","Reinstall cleanly after a crashed install so no deferred postinstalls fire later.","Never run two package managers against the same tree concurrently."],"tags":["analyzer-identity","race-condition","dependencies","concurrent-modification"],"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"}