abhigyanpatwari/GitNexus · error · Error

Analyzer build or dependency runtime changed during analysis

Error message

Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata. Retry with a stable GitNexus installation.

What it means

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.

Source

Thrown at gitnexus/src/core/analyzer-identity.ts:2846

export async function captureAnalyzerIdentityBeforeLoad<T>(
  analyzerModuleUrl: string,
  loader: () => Promise<T>,
  options: AnalyzerIdentityResolveOptions = {},
): Promise<{ runnerIdentity: AnalyzerRunnerIdentity; loaded: T }> {
  const runnerIdentity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);
  const loaded = await loader();
  return { runnerIdentity, loaded };
}

/** Re-resolve immediately before commit and reject analyzer mutation mid-run. */
export function finalizeAnalyzerRunnerIdentity(
  analyzerModuleUrl: string,
  startedWith: AnalyzerRunnerIdentity,
  options: AnalyzerIdentityResolveOptions = {},
): AnalyzerRunnerIdentity {
  const finalIdentity = resolveAnalyzerRunnerIdentity(analyzerModuleUrl, options);
  if (!analyzerRunnerIdentitiesEqual(startedWith, finalIdentity)) {
    throw new Error(
      'Analyzer build or dependency runtime changed during analysis; refusing to stamp metadata. ' +
        'Retry with a stable GitNexus installation.',
    );
  }
  return finalIdentity;
}

View on GitHub (pinned to d540b00184)

Solutions

  1. Run analyze from a stable installed build (npx gitnexus@latest analyze) instead of `npm run dev`, so nothing rewrites the module graph mid-run.
  2. Do not run `npm install`, `git checkout`, or a second analyze that rebuilds in the same install while an analysis is in progress.
  3. If developing against the dev build, disable tsx watch (use a single `tsx` invocation, not watch mode) for the analysis run.
  4. Retry the analyze once the installation is stable — the receipt is recomputed fresh each run.

Example fix

// before — dev watch recompiles between capture and finalize
$ npm run dev -- analyze --embeddings
// after — stable installed runner; capture and finalize see the same digest
$ npx gitnexus@latest analyze --embeddings
Defensive patterns

Strategy: validation

Validate before calling

// Before starting a long analysis, confirm the build artifacts are not being
// watched/recompiled. Run analyze from a stable install.
// import { existsSync, statSync } from 'node:fs';
// const dist = require.resolve('gitnexus');
// const mtime0 = statSync(dist).mtimeMs;
// ... run analyze ...
// const mtime1 = statSync(dist).mtimeMs;
// if (mtime0 !== mtime1) console.warn('Build changed mid-run — re-run on a stable install.');

Type guard

import { analyzerRunnerIdentitiesEqual } from 'gitnexus/src/core/analyzer-identity.js';

// Returns true when the captured receipt still matches the current identity,
// i.e. it is safe to proceed to finalize without throwing.
const isIdentityStable = (
  startedWith: unknown,
  current: unknown,
): boolean => analyzerRunnerIdentitiesEqual(startedWith, current);

Try / catch

// finalizeAnalyzerRunnerIdentity is called by the analyze runner itself; if you
// invoke analysis programmatically, treat error 100 as non-retriable in-place
// and re-run from a stable install.
try {
  await runAnalyze(opts);
} catch (err) {
  if (err instanceof Error && err.message.includes('changed during analysis')) {
    // Stop concurrent installs/watches, then re-run.
    throw new Error('Analyzer mutated mid-run. Stop npm run dev / npm install and retry.');
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/d1bd1bcf0e1a51e1. Report an issue: GitHub.