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(trace): report cut searches with the existing truncated and depth_limited codes
KageBinary1e4ce93827d2
diff --git a/ix-cli/src/cli/__tests__/trace-completeness.test.ts b/ix-cli/src/cli/__tests__/trace-completeness.test.tsindex 9d05bc8e..73103301 100644--- a/ix-cli/src/cli/__tests__/trace-completeness.test.ts+++ b/ix-cli/src/cli/__tests__/trace-completeness.test.ts@@ -94,14 +94,14 @@ describe('renderTraceBothLlm completeness', () => {// ---------------------------------------------------------------------------describe('renderTracePathLlm cut visibility', () => {- it('adds a search_cut diagnostic after no_path when the search was budget-cut', () => {+ it('adds the cut\'s own code after no_path when the search was budget-cut', () => {const lines = renderTracePathLlm({ name: 'A', kind: 'function' }, { name: 'B', kind: 'function' }, 'mixed', [],'No route found from A to B within the requested search limits.',- CAP_HINT,+ { code: 'truncated', message: CAP_HINT },);expect(lines[1]).toBe('diagnostic code=no_path message="No route found from A to B within the requested search limits."');- expect(lines[2]).toBe(`diagnostic code=search_cut message="${CAP_HINT}"`);+ expect(lines[2]).toBe(`diagnostic code=truncated message="${CAP_HINT}"`);});it('adds nothing when no cut hint is given', () => {diff --git a/ix-cli/src/cli/__tests__/trace-path-budgets.test.ts b/ix-cli/src/cli/__tests__/trace-path-budgets.test.tsindex 8bb6bea0..53e33202 100644--- a/ix-cli/src/cli/__tests__/trace-path-budgets.test.ts+++ b/ix-cli/src/cli/__tests__/trace-path-budgets.test.ts@@ -100,21 +100,21 @@ describe("trace completeness in command output", () => {const codes = (out: { diagnostics?: Array<{ code: string }> }) => (out.diagnostics ?? []).map(d => d.code);- it("adds search_cut naming the cap when the node budget stopped a --to search", async () => {+ it("adds truncated when the node budget stopped a --to search", async () => {const out = JSON.parse(await run(["--cap", "2"]));- expect(codes(out)).toEqual(["no_path", "search_cut"]);+ expect(codes(out)).toEqual(["no_path", "truncated"]);expect(out.diagnostics[1].message).toContain("Node cap of 2 reached");});- it("adds search_cut naming the depth when the depth bound stopped a --to search", async () => {+ it("adds depth_limited when the depth bound stopped a --to search", async () => {const out = JSON.parse(await run(["--depth", "1"]));- expect(codes(out)).toEqual(["no_path", "search_cut"]);+ expect(codes(out)).toEqual(["no_path", "depth_limited"]);expect(out.diagnostics[1].message).toContain("Stopped descending at depth 1");});it("treats cap zero as a cut, not as proof that no route exists", async () => {const out = JSON.parse(await run(["--cap", "0"]));- expect(codes(out)).toEqual(["no_path", "search_cut"]);+ expect(codes(out)).toEqual(["no_path", "truncated"]);expect(out.diagnostics[1].message).toContain("Node cap of 0 reached");});@@ -134,14 +134,22 @@ describe("trace completeness in command output", () => {expect(codes(out)).toEqual(["depth_limited"]);});- it("carries the traversal bounds in both-direction json only when one was hit", async () => {+ it("carries each direction's bounds in its own summary in both-direction json", async () => {const limited = JSON.parse(await runTrace(["--depth", "1", "--format", "json"]));- expect(limited.traversal).toEqual({ truncated: false, depth_limited: true, node_cap: 100 });+ expect(limited.traversal).toBeUndefined();expect(limited.downstream.summary.depth_limited).toBe(true);expect(codes(limited)).toEqual(["depth_limited"]);const clean = JSON.parse(await runTrace(["--depth", "5", "--format", "json"]));- expect(clean.traversal.depth_limited).toBeUndefined();+ expect(clean.downstream.summary.depth_limited).toBeUndefined();+ expect(clean.upstream.summary.truncated).toBeUndefined();expect(clean.diagnostics).toBeUndefined();});++ it("names the direction that hit the node cap in both-direction json", async () => {+ const out = JSON.parse(await runTrace(["--cap", "1", "--depth", "5", "--format", "json"]));+ const cut = [out.upstream.summary.truncated, out.downstream.summary.truncated];+ expect(cut).toContain(true);+ expect(codes(out)).toEqual(["truncated"]);+ });});diff --git a/ix-cli/src/cli/commands/trace.ts b/ix-cli/src/cli/commands/trace.tsindex 63d49169..e172a403 100644--- a/ix-cli/src/cli/commands/trace.ts+++ b/ix-cli/src/cli/commands/trace.ts@@ -319,6 +319,19 @@ export async function searchPath(return { path: null, cut: depthCut, cutReason: depthCut ? "depth" : undefined };}+/**+ * A directional walk's JSON summary. `truncated` and `depth_limited` appear+ * only when true, matching the llm header fields of the same names.+ */+function traceSummary(r: { nodesVisited: number; maxDepthReached: number; truncated?: boolean; depthLimited?: boolean }) {+ return {+ nodes_visited: r.nodesVisited,+ max_depth: r.maxDepthReached,+ truncated: r.truncated ? true : undefined,+ depth_limited: r.depthLimited ? true : undefined,+ };+}+// ── Text rendering ───────────────────────────────────────────────────/** Return last 3 path components from a file URI, for compact display. */@@ -406,7 +419,7 @@ export function renderTracePathLlm(from: { name: string; kind: string }, to: { name: string; kind: string },relKind: string, pathNodes: PathNode[],noPathMessage?: string,- cutHint?: string,+ cutHint?: { code: "truncated" | "depth_limited"; message: string },): string[] {const lines = [llmLine("trace", [["mode", "path"], ["from", from.name], ["to", to.name], ["kind", relKind],@@ -414,7 +427,7 @@ export function renderTracePathLlm(])];if (pathNodes.length === 0) {lines.push(llmLine("diagnostic", [["code", "no_path"], ["message", noPathMessage ?? `No route found from ${from.name} to ${to.name}.`]]));- if (cutHint) lines.push(llmLine("diagnostic", [["code", "search_cut"], ["message", cutHint]]));+ if (cutHint) lines.push(llmLine("diagnostic", [["code", cutHint.code], ["message", cutHint.message]]));return lines;}for (const n of pathNodes) lines.push(llmLine("step", [["name", n.name], ["kind", n.kind]]));@@ -557,8 +570,13 @@ export function registerTraceCommand(program: Command): void {const { path: rawPath, cut: pathCut, cutReason } = await searchPath(client, fromTarget.id, toTarget.id, predicates, maxDepth, maxNodes);const bounded = Number.isFinite(maxDepth) || Number.isFinite(maxNodes);const noPathMessage = `No route found from ${fromTarget.name} to ${toTarget.name}${bounded ? " within the requested search limits" : ""}.`;+ // Coded like the directional modes' cuts, so a caller knows whether to+ // raise --cap or --depth without parsing the message.const pathHint = bounded && pathCut- ? traversalHint(maxDepth, maxNodes, { truncated: cutReason === "node-cap", depthLimited: cutReason === "depth" })+ ? {+ code: cutReason === "node-cap" ? "truncated" as const : "depth_limited" as const,+ message: traversalHint(maxDepth, maxNodes, { truncated: cutReason === "node-cap", depthLimited: cutReason === "depth" }),+ }: undefined;// Fill in the from-node name (was left blank above)@@ -582,22 +600,15 @@ export function registerTraceCommand(program: Command): void {output.summary = { path_length: pathNodes.length };} else {output.path = null;- // Both states print no_path, but a budget cut adds a recovery- // hint so the caller can tell "none exists" from "search stopped".- output.diagnostics = pathCut- ? [- {- code: "no_path",- message: noPathMessage,- },- { code: "search_cut", message: pathHint },- ]- : [- {- code: "no_path",- message: noPathMessage,- },- ];+ // Both states print no_path, but a budget cut adds the bound that+ // stopped it, so the caller can tell "none exists" from "search stopped".+ output.diagnostics = [+ {+ code: "no_path",+ message: noPathMessage,+ },+ ...(pathHint ? [pathHint] : []),+ ];}printJson(output);return;@@ -618,7 +629,7 @@ export function registerTraceCommand(program: Command): void {if (pathNodes.length === 0) {console.log(`\n${noPathMessage}`);- if (pathCut) console.log(chalk.dim(` ${pathHint}`));+ if (pathHint) console.log(chalk.dim(` ${pathHint.message}`));return;}@@ -676,18 +687,15 @@ export function registerTraceCommand(program: Command): void {direction: "both",kind: relKind,depth: maxDepth,- traversal: {- truncated: upResult.truncated || downResult.truncated,- depth_limited: upResult.depthLimited || downResult.depthLimited ? true : undefined,- node_cap: Number.isFinite(maxNodes) ? maxNodes : undefined,- },+ // Per direction, in the same summary fields single-direction+ // output uses, so a caller can see which side hit which bound.upstream: {tree: upResult.tree.map(compactTreeNode),- summary: { nodes_visited: upResult.nodesVisited, max_depth: upResult.maxDepthReached, depth_limited: upResult.depthLimited ? true : undefined },+ summary: traceSummary(upResult),},downstream: {tree: downResult.tree.map(compactTreeNode),- summary: { nodes_visited: downResult.nodesVisited, max_depth: downResult.maxDepthReached, depth_limited: downResult.depthLimited ? true : undefined },+ summary: traceSummary(downResult),},};const bothTruncated = upResult.truncated || downResult.truncated;@@ -772,7 +780,7 @@ export function registerTraceCommand(program: Command): void {kind: relKind,depth: maxDepth,tree: tree.map(compactTreeNode),- summary: { nodes_visited: nodesVisited, max_depth: maxDepthReached, depth_limited: depthLimited ? true : undefined },+ summary: traceSummary({ nodesVisited, maxDepthReached, truncated, depthLimited }),};if (tree.length === 0) {diff --git a/skills/ix/references/flags.md b/skills/ix/references/flags.mdindex 6bae94aa..1b74acb6 100644--- a/skills/ix/references/flags.md+++ b/skills/ix/references/flags.md@@ -66,8 +66,11 @@ surfaces (#575).unbounded, which on a hub is thousands of nodes the caller pays for beforeseeing any. The output distinguishes the two ways a walk ends:`truncated=true` means the node cap dropped nodes, `depth_limited=true` means- the walk stopped descending and there may or may not be more. `--depth` and- `--cap` take anything.+ the walk stopped descending and there may or may not be more. JSON carries+ them per direction in each `summary`. When `ix trace --to` finds no route, a+ search a bound cut short adds the same code after `no_path`; a bare `no_path`+ means the whole reachable graph was searched. `--depth` and `--cap` take+ anything.- **`ix ingest` honours `--exclude <glob>` and a `.ixignore` at the ingestroot.** A deliberate subset of `.gitignore`: `#` comments, `*`, `?`, `**`, aleading `/` to anchor at the root, a trailing `/` for directories only, and a