Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

fix(trace): report a --cap 0 path search as cut, not as no route

KageBinarye560a0aac663
diff --git a/ix-cli/src/cli/__tests__/trace-completeness.test.ts b/ix-cli/src/cli/__tests__/trace-completeness.test.ts
index bda7fdf6..9d05bc8e 100644
--- a/ix-cli/src/cli/__tests__/trace-completeness.test.ts
+++ b/ix-cli/src/cli/__tests__/trace-completeness.test.ts
@@ -125,6 +125,12 @@ describe('searchPath cut semantics', () => {
expect(cut).toEqual({ path: null, cut: true, cutReason: 'node-cap' });
});
+ it('reports a node-cap cut at cap zero, where not even the source is admitted', async () => {
+ const client = makeClient({ A: { out: [n('b')] } });
+ const cut = await searchPath(client as any, 'A', 'b', ['REL'], 10, 0);
+ expect(cut).toEqual({ path: null, cut: true, cutReason: 'node-cap' });
+ });
+
it('reports cut with reason depth when nodes beyond maxDepth remain unexplored', async () => {
const client = makeClient({ A: { out: [n('x')] }, x: { out: [n('y')] } });
const cut = await searchPath(client as any, 'A', 'B', ['REL'], 1, 10);
diff --git a/ix-cli/src/cli/commands/trace.ts b/ix-cli/src/cli/commands/trace.ts
index 0588bdf4..63d49169 100644
--- a/ix-cli/src/cli/commands/trace.ts
+++ b/ix-cli/src/cli/commands/trace.ts
@@ -268,7 +268,9 @@ export async function searchPath(
maxDepth: number,
maxNodes: number,
): Promise<{ path: PathNode[] | null; cut: boolean; cutReason?: "node-cap" | "depth" }> {
- if (maxNodes < 1) return { path: null, cut: false };
+ // A cap below one admits not even the source, so nothing was searched:
+ // that is the budget talking, not evidence that no route exists.
+ if (maxNodes < 1) return { path: null, cut: true, cutReason: "node-cap" };
if (fromId === toId) return { path: [{ id: fromId, name: "", kind: "" }], cut: false };
const nodeMap = new Map<string, { name: string; kind: string }>();