{"record":{"id":"9d84b4dec176e467","repo":"Egonex-AI/Understand-Anything","slug":"assembled-graph-json-is-missing-or-invalid-baseli","errorCode":null,"errorMessage":"assembled-graph.json is missing or invalid; baseline not advanced","messagePattern":"assembled-graph\\.json is missing or invalid; baseline not advanced","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/finalize-incremental.mjs","lineNumber":428,"sourceCode":"    if (!previousGraph || !Array.isArray(previousGraph.nodes) || !Array.isArray(previousGraph.edges)) {\n      throw new Error('knowledge-graph.json is missing or invalid; baseline not advanced');\n    }\n    const refreshedGraph = refreshGraphImports(\n      previousGraph,\n      scan.importMap ?? {},\n      importMapRefreshPaths,\n    );\n    atomicWriteJson(graphPath, {\n      ...refreshedGraph,\n      project: projectMetadata(previousGraph.project, plan, scan),\n    });\n  }\n\n  if (plan.action !== 'SKIP') {\n    const previousGraph = readJson(graphPath, {});\n    const assembledRaw = readJson(join(intermediateDir, 'assembled-graph.json'));\n    if (!assembledRaw || !Array.isArray(assembledRaw.nodes) || !Array.isArray(assembledRaw.edges)) {\n      throw new Error('assembled-graph.json is missing or invalid; baseline not advanced');\n    }\n    const assembled = refreshGraphImports(\n      normalizeAssembled(assembledRaw),\n      scan.importMap ?? {},\n      importMapRefreshPaths,\n    );\n    const nodeIds = new Set(assembled.nodes.map(node => node.id));\n    const pathIndex = buildPathIndex(assembled.nodes);\n    const missingAnalyzedPaths = plan.filesToReanalyze.filter(\n      path => !hasAnalyzedFileCoverage(assembled.nodes, path),\n    );\n    if (missingAnalyzedPaths.length > 0) {\n      throw new Error(\n        `Assembled graph is missing whole-file nodes for analyzed paths: ` +\n        `${missingAnalyzedPaths.join(', ')}; baseline not advanced`,\n      );\n    }\n    if (plan.rerunArchitecture && !existsSync(join(intermediateDir, 'layers.json'))) {","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/finalize-incremental.mjs#L410-L446","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rerun the incremental analysis steps (file-analyzer / graph assembly) so assembled-graph.json is regenerated, then finalize","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)\"","If intermediates were cleaned prematurely, restart the incremental run from planning; the unadvanced baseline ensures files are reanalyzed","Check for concurrent runs locking .ua/intermediate/ and serialize /understand invocations"],"exampleFix":"// before: finalizing without the assembled artifact\nnode finalize-incremental.mjs .\n// Error: assembled-graph.json is missing or invalid; baseline not advanced\n\n// after: guard in automation\nif (!fs.existsSync('.ua/intermediate/assembled-graph.json')) {\n  await rerunIncrementalAnalysis();\n}\nawait run('node finalize-incremental.mjs .');","handlingStrategy":"validation","validationCode":"const p = '.ua/intermediate/assembled-graph.json';\nif (!fs.existsSync(p)) throw new Error('Analysis assembly did not run; rerun incremental pipeline');\nconst a = JSON.parse(fs.readFileSync(p, 'utf8'));\nif (!Array.isArray(a.nodes) || !Array.isArray(a.edges)) throw new Error('Malformed assembled graph');","typeGuard":"const isValidAssembledGraph = (a) =>\n  !!a && Array.isArray(a.nodes) && Array.isArray(a.edges);","tryCatchPattern":"try {\n  await run('node finalize-incremental.mjs .');\n} catch (err) {\n  if (String(err.message).includes('assembled-graph.json is missing or invalid')) {\n    await rerunIncrementalAnalysisSteps();\n    await run('node finalize-incremental.mjs .');\n  } else throw err;\n}","preventionTips":["Run planning, analysis, assembly, and finalize as one uninterrupted sequence","Do not clean .ua/intermediate/ until finalize succeeds","Ensure analyzer agents complete before finalizing (check their exit codes)","Avoid concurrent /understand runs on the same project"],"tags":["incremental","pipeline","missing-artifact","knowledge-graph"],"backgroundTag":"missing-required-config-file","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}