Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(php): don't emit duplicate claims for a two-kind call
KageBinarye786f20df62c
diff --git a/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts b/core-ingestion/src/__tests__/patchBuilder.resolution.test.tsindex a49dbde3..14943a82 100644--- a/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts+++ b/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts@@ -452,4 +452,24 @@ function handler(): void { log(); Logger::log(); }expect(callEdges).toHaveLength(1);});++ it('emits one claim when two PHP call kinds name the same callee', () => {+ // Same root cause as the edge case above, and it fires on ordinary untyped+ // PHP: `handle()` and `$obj->handle()` are two relationships once+ // phpCallKind splits the key, but a claim carries no kind, so the two ops+ // are byte-identical.+ const consumer = parseFile(+ '/repo/Caller.php',+ `<?php+function handler($obj): void { handle(); $obj->handle(); }+`,+ )!;++ const patch = buildPatchWithResolution(consumer, 'hash', '', []);+ const claims = patch.ops.filter(+ (op) => op.type === 'AssertClaim' && op.field === 'calls:handle',+ );++ expect(claims).toHaveLength(1);+ });});diff --git a/core-ingestion/src/__tests__/queries.php.test.ts b/core-ingestion/src/__tests__/queries.php.test.tsindex 1556d435..d68d042f 100644--- a/core-ingestion/src/__tests__/queries.php.test.ts+++ b/core-ingestion/src/__tests__/queries.php.test.ts@@ -262,7 +262,7 @@ final class Unionit('scopes every declaration in a large file without rescanning the top level',- { timeout: 10_000 },+ { timeout: 3_000 },() => {// Resolving each definition's namespace by rescanning the file's top-level// nodes is O(definitions x nodes). This file is ordinary, valid PSR-12 anddiff --git a/core-ingestion/src/patch-builder.ts b/core-ingestion/src/patch-builder.tsindex 01d35910..7434c164 100644--- a/core-ingestion/src/patch-builder.ts+++ b/core-ingestion/src/patch-builder.ts@@ -366,12 +366,21 @@ export function buildPatch(}// AssertClaim for each relationship (feeds the confidence/conflict engine)+ // phpCallKind splits the relationship dedup key, so `handle(); $obj->handle();`+ // arrives as two relationships that produce byte-identical claims. The kind is+ // not part of a claim, so nothing downstream can tell them apart.+ const emittedClaims = new Set<string>();for (const r of relationships) {const srcKey = resolveKey(r.srcName);+ const entityId = nodeId(idPath, srcKey);+ const field = `${r.predicate.toLowerCase()}:${r.dstName}`;+ const claimIdentity = `${entityId}\x00${field}`;+ if (emittedClaims.has(claimIdentity)) continue;+ emittedClaims.add(claimIdentity);ops.push({type: 'AssertClaim',- entityId: nodeId(idPath, srcKey),- field: `${r.predicate.toLowerCase()}:${r.dstName}`,+ entityId,+ field,value: r.dstName,confidence: null,});@@ -684,12 +693,21 @@ export function buildPatchWithResolution(});}+ // phpCallKind splits the relationship dedup key, so `handle(); $obj->handle();`+ // arrives as two relationships that produce byte-identical claims. The kind is+ // not part of a claim, so nothing downstream can tell them apart.+ const emittedClaims = new Set<string>();for (const r of relationships) {const srcKey = resolveKey(r.srcName);+ const entityId = nodeId(idPath, srcKey);+ const field = `${r.predicate.toLowerCase()}:${r.dstName}`;+ const claimIdentity = `${entityId}\x00${field}`;+ if (emittedClaims.has(claimIdentity)) continue;+ emittedClaims.add(claimIdentity);ops.push({type: 'AssertClaim',- entityId: nodeId(idPath, srcKey),- field: `${r.predicate.toLowerCase()}:${r.dstName}`,+ entityId,+ field,value: r.dstName,confidence: null,});