Skip to content

Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.

Use navigation decisions in item order, not completion order

taeskim71dd9af740aa
diff --git a/packages/core/src/retrieve.ts b/packages/core/src/retrieve.ts
index 8c8ce0d..cfe310e 100644
--- a/packages/core/src/retrieve.ts
+++ b/packages/core/src/retrieve.ts
@@ -215,7 +215,11 @@ export async function retrieve(input: SearchInput, evaluator: Evaluator): Promis
}
budgetPaused = false;
}
- return results;
+ // Decisions return in item order, not batch completion order: the next level, pruned
+ // directories and relationship seeds are built from this order, and their batches are
+ // requests with cache keys.
+ const position = new Map(items.map((item, index) => [item, index]));
+ return results.sort((a, b) => position.get(a.item)! - position.get(b.item)!);
}
async function previewDirectory(path: string): Promise<DirectoryPreview | undefined> {
const preview: DirectoryPreview = {
diff --git a/specs/done/jevgrep/choices.md b/specs/done/jevgrep/choices.md
index 9caad03..61d0003 100644
--- a/specs/done/jevgrep/choices.md
+++ b/specs/done/jevgrep/choices.md
@@ -55,6 +55,14 @@ first, so it can legitimately produce a differently ordered later request. Sorti
that source by filename would introduce a different input to Jev, the relevance
classifier, even if every source byte were retained.
+Navigation has the same property one level up. A directory level can span several
+concurrent navigation requests, and its decisions determine the next level's
+items, pruned directories and relationship seeds, which are then regrouped into
+new requests. Decisions are therefore used in item order, not in the order their
+requests completed. With in-order responses this matches the earlier behavior;
+in a probe with 240 directories, five completion orders previously produced five
+different sets of later navigation requests and now produce one.
+
The reference fixture controls which source is selected so its comparison is
stable. It may sort independent whole HTTP requests before comparing them, but
never sorts the ordered questions or evidence inside a request:
diff --git a/test/discovery.test.ts b/test/discovery.test.ts
index 0fc2745..3bda223 100644
--- a/test/discovery.test.ts
+++ b/test/discovery.test.ts
@@ -610,7 +610,7 @@ testIfDocker(
);
testIfDocker(
- "relationship discovery follows controlled provider completion order",
+ "relationship discovery does not depend on provider completion order",
async () => {
const root = await mkdtemp(join(tmpdir(), "jg-completion-order-"));
try {
@@ -623,15 +623,20 @@ testIfDocker(
for (let i = 0; i < 30; i++)
await writeFile(join(root, dir, `f${i}.txt`), '\"'.repeat(2000));
}
- const actual = await trajectory(root, true);
- const descendant = actual.find((body) =>
- body.state.items?.[0]?.path.startsWith("src/relatedZ/"),
- );
- expect(descendant).toBeDefined();
- const firstDescendant = actual.find(
+ const navigation = (requests: Body[]) =>
+ requests.filter((body) => body.state.items).map((body) => JSON.stringify(body));
+ const inOrder = await trajectory(root);
+ // The later relationship branch answers first, as an asynchronous provider can.
+ const reversed = await trajectory(root, true);
+ expect(navigation(reversed)).toEqual(navigation(inOrder));
+ const descendants = reversed.filter(
(body) => body.state.relationAnchor && body.state.items?.[0]?.kind === "file",
);
- expect(firstDescendant?.state.items?.[0]?.path.startsWith("src/relatedZ/")).toBe(true);
+ expect(descendants.map((body) => body.state.items![0]!.path.split("/")[1])).toContain(
+ "relatedZ",
+ );
+ // Relationship seeds follow their directory order.
+ expect(descendants[0]?.state.items?.[0]?.path.startsWith("src/relatedA/")).toBe(true);
} finally {
await rm(root, { recursive: true, force: true });
}