Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(incremental): verify unowned callables independently of graph classes
Lum11040fd70094d26c
diff --git a/tests/skill/understand/test_incremental_symbols.test.mjs b/tests/skill/understand/test_incremental_symbols.test.mjsindex 8d9583e2..0f1f5886 100644--- a/tests/skill/understand/test_incremental_symbols.test.mjs+++ b/tests/skill/understand/test_incremental_symbols.test.mjs@@ -71,6 +71,24 @@ describe('incremental symbol matching', () => {expect(compare(nodes, nodes, code, code).missing).toEqual([]);});+ it('verifies generic callables even when neither graph contains class nodes', () => {+ const nodes = [node('run', { lineRange: [1, 1] })];+ expect(compare(nodes, nodes, 'class A { run() {} }', 'class B { run() {} }')+ .missing[0].status).toBe('unknown');+ const opaqueIds = [node('run', { id: 'function:src/a.ts:method.run', lineRange: [1, 1] })];+ expect(compare(opaqueIds, opaqueIds, 'class A { run() {} }', 'class B { run() {} }')+ .missing[0].status).toBe('unknown');+ expect(compare(nodes, [node('run', { lineRange: [2, 2] })],+ 'class A { run() {} }', 'class A { run() {} }\nclass B { run() {} }')+ .missing[0].status).toBe('still-present');+ expect(compare(nodes, nodes, 'class A { run() {} }', 'class A { run() {} added() {} }').missing).toEqual([]);+ const unknown = { status: 'unsupported' };+ expect(compareFileSymbols(graph(nodes), graph(nodes), unknown, unknown).missing[0].status).toBe('unknown');+ // Preserving identical current descriptors within one HEAD is a different+ // operation from accepting an old symbol across source revisions.+ expect(compareFileSymbols(graph(nodes), graph(nodes), unknown, unknown, true).missing).toEqual([]);+ });+it('confirms genuine function, class, and method deletions without restoring them', () => {const result = compare([node('gone'), node('Old', { type: 'class' }), node('A.removed')], [],'function gone() {} class Old {} class A { removed() {} keep() {} }',diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjsindex 6e42f048..7eb23a1f 100644--- a/tests/skill/understand/test_prepare_incremental.test.mjs+++ b/tests/skill/understand/test_prepare_incremental.test.mjs@@ -232,6 +232,25 @@ afterEach(async () => {});describe('incremental symbol publication gate', { timeout: 30_000 }, () => {+ it('checks generic method identity against source when both graphs omit every class node', () => {+ const f = symbolFixture(2, { 'src/a.ts': 'export class A { run() {} }\n' });+ const generic = { ...f.methodNodes[0], id: 'function:src/a.ts:run', name: 'run', lineRange: [1, 1] };+ const previous = JSON.parse(f.persisted()[0]);+ previous.nodes = previous.nodes.filter(node => node.filePath !== 'src/a.ts' || node.type === 'file');+ previous.nodes.push(generic);+ previous.edges = [];+ writeFileSync(join(f.dataDir, 'knowledge-graph.json'), JSON.stringify(previous));+ writeProjectFile(f.root, 'src/a.ts', 'export class B { run() {} }\n');+ commit(f.root, 'change owning class');+ const before = f.persisted();+ prepare(f.root, f.baseCommit);+ f.write('batch-1.json', { nodes: [f.fileNode, generic], edges: [] });+ expect(spawnSync(python, [mergeScript, f.root]).status).toBe(1);+ expect(f.read('incremental-symbol-report.json').files[0].missing[0]).toMatchObject({ id: generic.id, status: 'unknown' });+ expect(spawnSync(process.execPath, [finalizeScript, f.root]).status).toBe(1);+ expect(f.persisted()).toEqual(before);+ });+it.each([false, true])('preserves current endpoint meanings when baseline IDs are reused (rename again=%s)', renameAgain => {const service = names => `export class Service { ${names.map(name => `${name}() { return 1; }`).join(' ')} }\n`;const other = 'export class Other { method0() { return 2; } }\n';diff --git a/understand-anything-plugin/hooks/auto-update-prompt.md b/understand-anything-plugin/hooks/auto-update-prompt.mdindex f69fb045..25ddce05 100644--- a/understand-anything-plugin/hooks/auto-update-prompt.md+++ b/understand-anything-plugin/hooks/auto-update-prompt.md@@ -79,7 +79,7 @@ Dispatch only `batches[]` from `incremental-symbol-retry.json`, with the usual fIf the helper, repair dispatch, or second merge fails, **STOP** with diagnostics and leave `knowledge-graph.json`, `fingerprints.json`, and `meta.json` unchanged. Other merge failures without eligible unresolved files also stop immediately.-Languages without a deterministic structural parser (including `.sh`, `.ps1`, and `.bat`) cannot have missing symbols automatically confirmed as deleted. These omissions remain `unknown`, including genuine deletions, and require manual investigation or parser support. Do not use supplemental LLM inspection or regex guesses to waive the gate.+Languages without a deterministic structural parser (including `.sh`, `.ps1`, and `.bat`) cannot have missing symbols automatically confirmed as deleted. Callables without explicit class containment also require source verification when their IDs/names are unchanged, regardless of whether class nodes were emitted; unverified identities block publication. These cases remain `unknown` and require manual investigation or parser support. Do not use supplemental LLM inspection or regex guesses to waive the gate.Do not dispatch assemble-reviewer or graph-reviewer for automatic updates.diff --git a/understand-anything-plugin/skills/understand/SKILL.md b/understand-anything-plugin/skills/understand/SKILL.mdindex 10b68af1..7cbb203a 100644--- a/understand-anything-plugin/skills/understand/SKILL.md+++ b/understand-anything-plugin/skills/understand/SKILL.md@@ -426,7 +426,7 @@ This helper revalidates the candidate, records attempt 1/1 for the base/head comIf repair preparation, the repair dispatch, or the second merge fails, **STOP** and retain diagnostics. Do not publish or advance `knowledge-graph.json`, `fingerprints.json`, or `meta.json`. Never concatenate old nodes or old semantic edges into the candidate to satisfy the gate. Other merge failures without eligible unresolved files stop immediately. On success, continue to the applicable architecture/tour phases.-Parser limitation: languages without a deterministic structural parser (including `.sh`, `.ps1`, and `.bat`) cannot have missing symbols automatically confirmed as deleted. Such omissions remain `unknown`, even for genuine deletions, and stop publication pending manual investigation or parser support. Supplemental LLM source inspection and regex guesses are not deletion evidence. Preserved symbols with unchanged IDs/names and unambiguous ownership do not require a parser. An unchanged generic method ID cannot stand in for a different class's method; changed or ambiguous containment requires source identity verification.+Parser limitation: languages without a deterministic structural parser (including `.sh`, `.ps1`, and `.bat`) cannot have missing symbols automatically confirmed as deleted. Such omissions remain `unknown`, even for genuine deletions, and stop publication pending manual investigation or parser support. Supplemental LLM source inspection and regex guesses are not deletion evidence. Callables without explicit class containment require source identity verification even when their IDs/names stay unchanged and neither graph emits class nodes; unsupported or unextractable callables therefore also block in this case. Dots in an opaque ID are not ownership evidence. Stable explicit class ownership can establish preservation without parsing. Identical current descriptors within one HEAD may preserve repair references; this does not waive verification of the previous published symbols across revisions.---diff --git a/understand-anything-plugin/skills/understand/validate-incremental-symbols.mjs b/understand-anything-plugin/skills/understand/validate-incremental-symbols.mjsindex 7f99f019..0159b3f2 100644--- a/understand-anything-plugin/skills/understand/validate-incremental-symbols.mjs+++ b/understand-anything-plugin/skills/understand/validate-incremental-symbols.mjs@@ -94,7 +94,7 @@ function classOwners(node, graph) {return graph.nodes.filter(parent => parent.type === 'class' && parents.has(parent.id));}-function hasPreservedIdentity(node, previous, current) {+function hasPreservedIdentity(node, previous, current, sameRevision = false) {const candidate = current.nodes.find(candidate => candidate.id === node.id&& symbolKind(candidate) === symbolKind(node) && candidate.name === node.name);if (!candidate) return false;@@ -102,11 +102,12 @@ function hasPreservedIdentity(node, previous, current) {.map(owner => JSON.stringify([owner.id, owner.name])).sort();const oldOwners = owners(node, previous);if (JSON.stringify(oldOwners) !== JSON.stringify(owners(candidate, current))) return false;- // Generic method IDs do not encode scope. Without a contains owner, class- // context requires unique source mapping even if the ID/name stayed equal.+ // An unowned callable cannot prove its scope: missing class nodes may itself+ // be analyzer under-reporting. Across revisions always verify it in source.+ // Within one HEAD, identical descriptors preserve existing current refs;+ // changed source locations still require matching against that HEAD.if (symbolKind(node) === 'callable' && oldOwners.length === 0- && ![...nodeNames(node)].some(name => name.includes('.'))- && [...previous.nodes, ...current.nodes].some(item => item.type === 'class')) return false;+ && (!sameRevision || JSON.stringify(node.lineRange) !== JSON.stringify(candidate.lineRange))) return false;return true;}@@ -132,7 +133,7 @@ function resolveSymbol(node, graph, symbols) {return candidates.length === 1 ? candidates[0] : null;}-export function compareFileSymbols(previous, current, baseEvidence, headEvidence) {+export function compareFileSymbols(previous, current, baseEvidence, headEvidence, sameRevision = false) {const oldSymbols = previous.nodes.filter(symbolKind);const newSymbols = current.nodes.filter(symbolKind);const baseSource = sourceSymbols(baseEvidence);@@ -143,7 +144,7 @@ export function compareFileSymbols(previous, current, baseEvidence, headEvidenceconst replacements = [];for (let index = 0; index < oldSymbols.length; index++) {const node = oldSymbols[index];- if (hasPreservedIdentity(node, previous, current)) continue;+ if (hasPreservedIdentity(node, previous, current, sameRevision)) continue;const entry = { id: node.id, name: node.name, type: node.type, status: 'unknown', reason: '' };const old = oldMappings[index];if (!old || baseEvidence?.status !== 'succeeded' || headEvidence?.status !== 'succeeded') {@@ -305,9 +306,9 @@ export async function validateIncrementalSymbols(projectRoot, { graph, intermedi// old published graph. Both sides therefore map against HEAD source.for (const previous of hasRetry ? retry.currentFiles : []) {const current = fileGraph(previous.filePath);- const needsEvidence = previous.nodes.some(node => symbolKind(node) && !hasPreservedIdentity(node, previous, current));+ const needsEvidence = previous.nodes.some(node => symbolKind(node) && !hasPreservedIdentity(node, previous, current, true));const evidence = needsEvidence && previous.filePath ? await parseHead(previous.filePath) : undefined;- const result = compareFileSymbols(previous, current, evidence, evidence);+ const result = compareFileSymbols(previous, current, evidence, evidence, true);const missing = new Set(result.missing.map(node => node.id));const aliases = new Map(result.replacements.map(({ oldId, newId }) => [oldId, newId]));for (const node of previous.nodes) {