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(search): do not count ix map regions as a definition of the term
KageBinary6d45ee011dee
diff --git a/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts b/ix-cli/src/cli/__tests__/resolver-definitions-first.test.tsindex 2ff3f3cd..99cfa8ed 100644--- a/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts+++ b/ix-cli/src/cli/__tests__/resolver-definitions-first.test.ts@@ -78,6 +78,19 @@ describe("resolver: definitions over imports", () => {expect(result.resolved && result.entity.id).toBe("file");});+ it("looks further when the window holds only a map region of the name, not a definition", async () => {+ // `ix map` names regions after directories and modules (`Format`, `Search`,+ // `CLI`), with provenance `ix:map`. A region is not a code definition, so+ // it must not stop the lookup for the defining file.+ const fake = client([+ { id: "region", name: "Format", kind: "region", provenance: { sourceUri: "ix:map" }, attrs: {} } as any,+ ...Array.from({ length: 40 }, (_, i) => n(`json-${i}`, "format", "config_entry", `pkg${i}/package.json`)),+ n("file", "format.ts", "file", "src/cli/format.ts"),+ ]);+ const result = await resolveEntityFull(fake, "format", ALL_KINDS, { format: "json" } as any);+ expect(result.resolved && result.entity.id).toBe("file");+ });+it("does not look further when a definition is in the window", async () => {const fake = client([n("fn", "parseConfig", "function", "src/config.ts"),diff --git a/ix-cli/src/cli/__tests__/search-definitions-first.test.ts b/ix-cli/src/cli/__tests__/search-definitions-first.test.tsindex cc82ad35..c1be77e8 100644--- a/ix-cli/src/cli/__tests__/search-definitions-first.test.ts+++ b/ix-cli/src/cli/__tests__/search-definitions-first.test.ts@@ -103,6 +103,16 @@ describe("search: definitions rank above import entities", () => {expect(out.results.length).toBe(10);});+ it("looks for the defining file when the window holds only a map region of the name", async () => {+ dataset([+ { id: "region", name: "Format", kind: "region", provenance: { sourceUri: "ix:map" }, attrs: { _search_weight: 100 } },+ ...Array.from({ length: 40 }, (_, i) => n(`json-${i}`, "format", "config_entry", `pkg${i}/package.json`, 100)),+ n("file", "format.ts", "file", "src/cli/format.ts", 60),+ ]);+ const out = await run("format");+ expect(ids(out)[0]).toBe("file");+ });+it("does not spend an extra request when a definition is already in the window", async () => {dataset([n("fn", "parseConfig", "function", "src/config.ts", 100),diff --git a/ix-cli/src/cli/resolve.ts b/ix-cli/src/cli/resolve.tsindex 2b56eeeb..b6e982db 100644--- a/ix-cli/src/cli/resolve.ts+++ b/ix-cli/src/cli/resolve.ts@@ -456,12 +456,23 @@ export async function resolveEntityFull(return { resolved: false, ambiguous: false, hiddenTestCount, ...(suggestions.length ? { suggestions } : {}) };}-/** True when some candidate is a code definition named `symbol` (or its defining file). */+/**+ * True when some candidate is a code definition named `symbol` (or its defining file).+ *+ * Code kinds only: `candidateOrigin` calls anything it cannot place a+ * definition, and that includes the `region` nodes `ix map` names after+ * directories and modules (`Format`, `Search`, `CLI`, provenance `ix:map`).+ * Counting one would skip the lookup for the file that defines the name.+ */export function hasDefinitionOf(nodes: any[], symbol: string): boolean {const symbolLower = symbol.toLowerCase();return nodes.some((n: any) => {const name = String(n.name || n.attrs?.name || "").toLowerCase();- return (name === symbolLower || isFileStemMatch(n, symbol)) && candidateOrigin(n) === "definition";+ const sourceUri = String(n.provenance?.sourceUri ?? n.provenance?.source_uri ?? "");+ return (name === symbolLower || isFileStemMatch(n, symbol))+ && STRUCTURAL_KINDS.has(String(n.kind || "").toLowerCase())+ && !sourceUri.startsWith("ix:")+ && candidateOrigin(n) === "definition";});}