Egonex-AI/Understand-Anything · error

assembled-graph.json is missing or invalid; baseline not adv

Error message

assembled-graph.json is missing or invalid; baseline not advanced

What it means

For non-SKIP actions (reanalysis), finalize reads assembled-graph.json from the intermediate directory, which holds the merged output of the per-file analysis agents. If that file is missing or lacks valid nodes/edges arrays, the script throws instead of writing a partially updated graph, leaving the baseline unadvanced so the next run redoes the work.

Source

Thrown at understand-anything-plugin/skills/understand/finalize-incremental.mjs:428

    if (!previousGraph || !Array.isArray(previousGraph.nodes) || !Array.isArray(previousGraph.edges)) {
      throw new Error('knowledge-graph.json is missing or invalid; baseline not advanced');
    }
    const refreshedGraph = refreshGraphImports(
      previousGraph,
      scan.importMap ?? {},
      importMapRefreshPaths,
    );
    atomicWriteJson(graphPath, {
      ...refreshedGraph,
      project: projectMetadata(previousGraph.project, plan, scan),
    });
  }

  if (plan.action !== 'SKIP') {
    const previousGraph = readJson(graphPath, {});
    const assembledRaw = readJson(join(intermediateDir, 'assembled-graph.json'));
    if (!assembledRaw || !Array.isArray(assembledRaw.nodes) || !Array.isArray(assembledRaw.edges)) {
      throw new Error('assembled-graph.json is missing or invalid; baseline not advanced');
    }
    const assembled = refreshGraphImports(
      normalizeAssembled(assembledRaw),
      scan.importMap ?? {},
      importMapRefreshPaths,
    );
    const nodeIds = new Set(assembled.nodes.map(node => node.id));
    const pathIndex = buildPathIndex(assembled.nodes);
    const missingAnalyzedPaths = plan.filesToReanalyze.filter(
      path => !hasAnalyzedFileCoverage(assembled.nodes, path),
    );
    if (missingAnalyzedPaths.length > 0) {
      throw new Error(
        `Assembled graph is missing whole-file nodes for analyzed paths: ` +
        `${missingAnalyzedPaths.join(', ')}; baseline not advanced`,
      );
    }
    if (plan.rerunArchitecture && !existsSync(join(intermediateDir, 'layers.json'))) {

View on GitHub (pinned to 07edf82a04)

Solutions

  1. Rerun the incremental analysis steps (file-analyzer / graph assembly) so assembled-graph.json is regenerated, then finalize
  2. Validate the file before finalizing: node -e "const a=require('./.ua/intermediate/assembled-graph.json'); if(!Array.isArray(a.nodes)||!Array.isArray(a.edges)) process.exit(1)"
  3. If intermediates were cleaned prematurely, restart the incremental run from planning; the unadvanced baseline ensures files are reanalyzed
  4. Check for concurrent runs locking .ua/intermediate/ and serialize /understand invocations

Example fix

// before: finalizing without the assembled artifact
node finalize-incremental.mjs .
// Error: assembled-graph.json is missing or invalid; baseline not advanced

// after: guard in automation
if (!fs.existsSync('.ua/intermediate/assembled-graph.json')) {
  await rerunIncrementalAnalysis();
}
await run('node finalize-incremental.mjs .');
Defensive patterns

Strategy: validation

Validate before calling

const p = '.ua/intermediate/assembled-graph.json';
if (!fs.existsSync(p)) throw new Error('Analysis assembly did not run; rerun incremental pipeline');
const a = JSON.parse(fs.readFileSync(p, 'utf8'));
if (!Array.isArray(a.nodes) || !Array.isArray(a.edges)) throw new Error('Malformed assembled graph');

Type guard

const isValidAssembledGraph = (a) =>
  !!a && Array.isArray(a.nodes) && Array.isArray(a.edges);

Try / catch

try {
  await run('node finalize-incremental.mjs .');
} catch (err) {
  if (String(err.message).includes('assembled-graph.json is missing or invalid')) {
    await rerunIncrementalAnalysisSteps();
    await run('node finalize-incremental.mjs .');
  } else throw err;
}

Prevention

When it happens

Trigger: The incremental analysis agents failed or were interrupted before writing assembled-graph.json; the file was cleaned from .ua/intermediate/ mid-run; the assembler wrote malformed JSON without nodes/edges arrays; finalize was invoked manually without running the analysis steps first.

Common situations: LLM agent step crashed or timed out; user ran finalize-incremental.mjs standalone after clearing intermediate files; disk-full or permission error truncated the assembler write; concurrency between two runs deleted the artifact.

Related errors


AI-assisted analysis of Egonex-AI/Understand-Anything@07edf82a04 (2026-09-07). Data as JSON: /api/errors/9d84b4dec176e467. Report an issue: GitHub.