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.

fix: tighten retrieval review coverage

David Zhang54ab869d7912
diff --git a/packages/core/src/retrieve.ts b/packages/core/src/retrieve.ts
index ba00097..e992892 100644
--- a/packages/core/src/retrieve.ts
+++ b/packages/core/src/retrieve.ts
@@ -730,8 +730,8 @@ export async function retrieve(input: SearchInput, evaluator: Evaluator): Promis
await select();
const evidence: Evidence[] = [];
// Donor order is part of every follow-up request and its cache key. Files are selected
- // concurrently, so completion order depends on network timing; donors use the order in
- // which sequential selection would finish them instead: fewer groups first, then path.
+ // concurrently, so completion order depends on network timing; donors use a deterministic
+ // policy instead: fewer declaration groups first, then path.
const donors = [...declarations.keys()].sort(
(a, b) => groupCounts.get(a)! - groupCounts.get(b)! || (a < b ? -1 : a > b ? 1 : 0),
);
diff --git a/packages/core/src/selection.ts b/packages/core/src/selection.ts
index 199262d..3fc9138 100644
--- a/packages/core/src/selection.ts
+++ b/packages/core/src/selection.ts
@@ -182,7 +182,7 @@ export async function selectFile(
`Source lines ${unit.range.startLine}-${unit.range.endLine}; source bytes ${unit.sourceByteStart}-${unit.sourceByteEnd}:\n${sourceForUnit(snapshot, unit)}`,
)
.join("\n")
- : bytes.length <= 16000
+ : bytes.length <= wholeFileContextBytes
? snapshot.source
: `Opening context:\n${lines.slice(0, 20).join("\n")}\nSource lines ${first}-${last}:\n${lines.slice(first - 1, last).join("\n")}`;
return evidenceRequest(
diff --git a/specs/done/jevgrep/README.md b/specs/done/jevgrep/README.md
index 64bdd14..b8a8df9 100644
--- a/specs/done/jevgrep/README.md
+++ b/specs/done/jevgrep/README.md
@@ -61,8 +61,8 @@ order must not be normalized to make a comparison pass.
- One evaluator owns retries, cancellation and actual request accounting. Cache
entries contain validated answers keyed by exact semantic request and namespace,
never source or credentials. Cross-file evidence has a deterministic order, so
- unchanged selections rebuild identical follow-up requests on a warm search, and
- identical native requests reuse successful answers.
+ unchanged selections rebuild identical evidence follow-up requests on a warm
+ search, and identical native requests reuse successful answers.
- Selected and rendered ranges remain distinct, and returned source is attributable
to snapshot bytes. The current renderer places source before detailed reading leads; see the [architecture](../../../docs/architecture.md). Explicit
source-budget overrides do not remove qualifying file locations.
diff --git a/specs/done/jevgrep/choices.md b/specs/done/jevgrep/choices.md
index c48be65..05c58c8 100644
--- a/specs/done/jevgrep/choices.md
+++ b/specs/done/jevgrep/choices.md
@@ -55,11 +55,12 @@ Files A and B both produce selected source, and both enter the next cross-file
request. Files are selected concurrently and used to enter in completion order.
Most files need a single declaration group, so that order depended on provider
timing: with jittered provider latency, warm searches resent 26 to 36 follow-up
-requests in half to all of the runs. Donors are now ordered explicitly: fewer
-declaration groups first, as sequential selection would finish them, then path.
-A warm search with unchanged selections therefore rebuilds the same follow-up
-requests. Sorting by filename alone would give Jev, the relevance classifier, a
-different input from the measured strategy, even if every source byte were retained.
+requests in half to all of the runs. Donors are now ordered explicitly by
+declaration-group count, then path, so the evidence pass does not inherit
+completion timing. The declaration groups themselves overlap, so this is a
+deterministic request policy rather than a claim about which file finishes first.
+A warm search with unchanged selections therefore rebuilds the same evidence
+requests; a filename-only order would be a different provider input.
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
@@ -67,7 +68,9 @@ 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 four
-different sets of later navigation requests and now produce one.
+different sets of later navigation requests and now produce one. Budget pauses and
+source confirmation remain bounded probes whose choices can reflect completion
+timing; the item-order rule covers the decisions that build later navigation.
The reference fixture controls which source is selected so its comparison is
stable. It may sort independent whole HTTP requests before comparing them, but
diff --git a/test/retrieval.test.ts b/test/retrieval.test.ts
index 282834d..6314426 100644
--- a/test/retrieval.test.ts
+++ b/test/retrieval.test.ts
@@ -664,14 +664,14 @@ testIfDocker(
async () => {
const root = await mkdtemp(join(tmpdir(), "jg-donor-order-"));
try {
- // Twenty declarations need three groups; one declaration needs one.
+ // More than the per-request declaration limit needs multiple groups; one declaration needs one.
await writeFile(
- join(root, "many.ts"),
- Array.from({ length: 20 }, (_, i) => `export function many${i}() {return ${i};}\n`).join(
+ join(root, "a-many.ts"),
+ Array.from({ length: 260 }, (_, i) => `export function many${i}() {return ${i};}\n`).join(
"",
),
);
- await writeFile(join(root, "few.ts"), "export function few() {return 0;}\n");
+ await writeFile(join(root, "z-few.ts"), "export function few() {return 0;}\n");
const donorOrders = async (slow: string) => {
const orders: string[][] = [];
await retrieve(
@@ -696,11 +696,11 @@ testIfDocker(
);
return orders;
};
- for (const slow of ["few.ts", "many.ts"]) {
+ for (const slow of ["z-few.ts", "a-many.ts"]) {
const orders = await donorOrders(slow);
expect(orders.length).toBeGreaterThan(0);
- // Fewer declaration groups first, as sequential selection used to finish them.
- for (const order of orders) expect(order).toEqual(["few.ts", "many.ts"]);
+ // Group count is the primary key; path is the tie-breaker.
+ for (const order of orders) expect(order).toEqual(["z-few.ts", "a-many.ts"]);
}
} finally {
await rm(root, { recursive: true, force: true });