From a7e4ceefb3402065f815300b951e11dacafa6897 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 00:12:29 +0530 Subject: [PATCH 1/6] A pointer block lists the first-ranked file's place first The places of a search answer were listed by the rank of the unit sent for each. A long class ranked first is sent as a method the answer holds inside it, and a first result that is no place (a file's leading comments) is sent as nothing, so a unit of another file ranked between them took the first line of the block although the first-ranked file had a place in it. `places` in the prompt hook's library, its Codex copy and the Python and TypeScript SDK helpers moves the first place in the first result's file to the front after the place rules ran. The other places keep rank order, as all do when that file has no place. A picked answer keeps the order its model chose. The pointers sent are the same unless the place moved to the front ranked below the count, where it takes the last one's line. The request is unchanged. Plugin 1.2.165. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 6 +- docs/guides/issue-code-pointers.md | 5 +- .../.claude-plugin/plugin.json | 2 +- .../claude-code-plugin/hooks/HOOKS.md | 7 +- .../claude-code-plugin/lib/prompt-pack.mjs | 13 +- .../tests/fixtures/pointer-block.json | 157 ++++++++++++++++++ .../tests/prompt-pack.test.mjs | 6 + .../codex-plugin/.codex-plugin/plugin.json | 2 +- integrations/codex-plugin/lib/prompt-pack.mjs | 13 +- sdk/python/loom/pointers.py | 12 +- sdk/typescript/src/pointers.ts | 8 +- tests/unit/session_content_senders.json | 4 +- 12 files changed, 219 insertions(+), 16 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index edf70e3b64..64decf6d43 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -624,7 +624,11 @@ chosen so, when it is a range of more than 200 lines, gives way to the first-ran definition the answer holds inside it, which is the part of it the search matched, so a long class the prompt names is sent as that method; with none inside it, it is sent as its first line, the definition's signature, with its length -(`path:643 Permutation (372 lines)`). The low-risk label says the index holds code about +(`path:643 Permutation (372 lines)`). The first place in the file of the answer's first +result is listed first, also when that result is no place itself or is sent as a +definition ranked below another file's; the other places keep the index's order, as all +do when that file has no place or the answer is a picked one +([below](#model-picked-pointers-for-a-bug-report)). The low-risk label says the index holds code about the prompt, not that the pointers are where a fix is made, and no field of the answer tells the two apart. The place test reads a unit's path and kind and does not tell them apart either: an answer that holds only other places is sent. diff --git a/docs/guides/issue-code-pointers.md b/docs/guides/issue-code-pointers.md index 1eb38940fa..6b1da1af3a 100644 --- a/docs/guides/issue-code-pointers.md +++ b/docs/guides/issue-code-pointers.md @@ -162,7 +162,10 @@ lists the answer's places to edit: class when the prompt names it, else the one the index ranked first. A range over 200 lines gives way to a definition the answer holds inside it, and is otherwise listed as its first line and its length. -- Entries keep the index's order, and a span is listed once. +- The first place in the file of the answer's first result is listed first, also when + that result is no place itself or is sent as a definition ranked below another file's. + The other entries keep the index's order, as all do when that file has no place. A + span is listed once. - Paths are relative to the repository root, after the checkout prefix when one is given, and the lines are those of the indexed commit. diff --git a/integrations/claude-code-plugin/.claude-plugin/plugin.json b/integrations/claude-code-plugin/.claude-plugin/plugin.json index f882a34cba..6746e2a9cd 100644 --- a/integrations/claude-code-plugin/.claude-plugin/plugin.json +++ b/integrations/claude-code-plugin/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "loom", "displayName": "ClickHouse Loom", - "version": "1.2.158", + "version": "1.2.165", "description": "Shared long-term memory and code intelligence for Claude Code, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.", "author": { "name": "ClickHouse" diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index 71718d01bf..706b06fee4 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -870,7 +870,12 @@ in. part of it the search matched, so a long class the prompt names is sent as that method; with none inside it, it is sent as its first line, the definition's signature, with its length - (`path:643 Permutation (372 lines)`). For a + (`path:643 Permutation (372 lines)`). + **The first result's file leads.** The first place in the file of the + answer's first result is listed first, also when that result is no place + itself or is sent as a definition ranked below another file's. The other + places keep the index's order, as all do when that file has no place and + in a picked answer. For a picked answer (`LOOM_PROMPT_PACK_PICK`) the model's confidence is in its first result, and the pick was measured on its first three: when the first is no place nothing is sent, and no result below the third is. The low-risk label says the index holds code about the prompt, not that the pointers are where diff --git a/integrations/claude-code-plugin/lib/prompt-pack.mjs b/integrations/claude-code-plugin/lib/prompt-pack.mjs index ab5eab82a8..7eb308518c 100644 --- a/integrations/claude-code-plugin/lib/prompt-pack.mjs +++ b/integrations/claude-code-plugin/lib/prompt-pack.mjs @@ -574,6 +574,11 @@ export const LONG_RANGE_LINES = 200; * and kind: it does not say the fix is made there, and no rule here drops an * answer that holds only other places. * + * The first-ranked result's file leads: the first of the pointers in that + * file is listed first, also when the unit sent for it ranks below another + * file's (a class sent as a method, a first result that is no place). The + * others keep rank order, as all do when that file has no pointer. + * * A range and the ranges inside it (a class and its own methods) send one * pointer, chosen in two steps: * 1. The names (`byName`): each innermost definition inside the range that @@ -590,8 +595,8 @@ export const LONG_RANGE_LINES = 200; * a mention anywhere in it counts, also in a sentence that tells the agent * what not to edit and in a pasted traceback). For a `picked` answer the * server's confidence is in its first result, and the pick was measured on - * its first `cap`: when the first is no place nothing is sent, and no result - * below them is. + * its first `cap`: when the first is no place nothing is sent, no result + * below them is, and the places keep rank order. */ export function places(res, { query, text = query, cap = 3, picked = false } = {}) { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; @@ -623,7 +628,9 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { const sent = new Set(outermost.flatMap(byName).map(byLength)); // No range inside another: two ranges that overlap without one holding the other can each choose a unit inside both. const apart = (unit) => ![...sent].some((other) => other !== unit && within(unit, other)); - return ranked.filter((unit) => sent.has(unit) && apart(unit)).slice(0, cap); + const chosen = ranked.filter((unit) => sent.has(unit) && apart(unit)); + const lead = picked ? undefined : chosen.find((unit) => unit.path === results[0].path); + return (lead ? [lead, ...chosen.filter((unit) => unit !== lead)] : chosen).slice(0, cap); } export function pointerOf(unit) { diff --git a/integrations/claude-code-plugin/tests/fixtures/pointer-block.json b/integrations/claude-code-plugin/tests/fixtures/pointer-block.json index 4b6f39e10f..02ee2fdab4 100644 --- a/integrations/claude-code-plugin/tests/fixtures/pointer-block.json +++ b/integrations/claude-code-plugin/tests/fixtures/pointer-block.json @@ -1310,6 +1310,163 @@ }, "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/parser.c:10-60 parse_record\n- src/parser.c:40-90 parse_tail" }, + { + "name": "the first place is one of the first-ranked file, also when its class is sent as a method ranked below another file", + "prompt": "objects are written twice when memory runs low", + "query": "objects are written twice when memory runs low", + "reply": { + "abstain": false, + "retrieval_risk": "low", + "retrieval_confidence": 0.82, + "results": [ + { + "path": "src/store.py", + "start_line": 10, + "end_line": 300, + "kind": "class_skeleton", + "symbol": "store::Store" + }, + { + "path": "src/cache.py", + "start_line": 12, + "end_line": 20, + "kind": "function", + "symbol": "cache::Cache::evict" + }, + { + "path": "src/store.py", + "start_line": 50, + "end_line": 90, + "kind": "function", + "symbol": "store::Store::put_object" + } + ] + }, + "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/store.py:50-90 store::Store::put_object\n- src/cache.py:12-20 cache::Cache::evict" + }, + { + "name": "a first-ranked unit that is no place gives the first slot to a place of its file", + "prompt": "the transfer is never tried again after the bucket answers slowly once", + "query": "the transfer is never tried again after the bucket answers slowly once", + "reply": { + "abstain": false, + "retrieval_risk": "low", + "retrieval_confidence": 0.82, + "results": [ + { + "path": "src/uploads/retry.py", + "start_line": 1, + "end_line": 3, + "kind": "file_header", + "symbol": "" + }, + { + "path": "src/uploads/client.py", + "start_line": 20, + "end_line": 23, + "kind": "function", + "symbol": "uploads.client::Client::put" + }, + { + "path": "src/uploads/retry.py", + "start_line": 6, + "end_line": 15, + "kind": "function", + "symbol": "uploads.retry::retry_upload" + } + ] + }, + "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/uploads/retry.py:6-15 uploads.retry::retry_upload\n- src/uploads/client.py:20-23 uploads.client::Client::put" + }, + { + "name": "a first-ranked file with no place leaves the places in rank order", + "prompt": "objects are written twice when memory runs low", + "query": "objects are written twice when memory runs low", + "reply": { + "abstain": false, + "retrieval_risk": "low", + "retrieval_confidence": 0.82, + "results": [ + { + "path": "src/uploads/settings.py", + "start_line": 1, + "end_line": 2, + "kind": "file_header", + "symbol": "" + }, + { + "path": "src/store.py", + "start_line": 10, + "end_line": 300, + "kind": "class_skeleton", + "symbol": "store::Store" + }, + { + "path": "src/cache.py", + "start_line": 12, + "end_line": 20, + "kind": "function", + "symbol": "cache::Cache::evict" + }, + { + "path": "src/store.py", + "start_line": 50, + "end_line": 90, + "kind": "function", + "symbol": "store::Store::put_object" + } + ] + }, + "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/cache.py:12-20 cache::Cache::evict\n- src/store.py:50-90 store::Store::put_object" + }, + { + "name": "a place of the first-ranked file ranked below the count is listed first, and the last of the others is not listed", + "prompt": "objects are written twice when memory runs low", + "query": "objects are written twice when memory runs low", + "reply": { + "abstain": false, + "retrieval_risk": "low", + "retrieval_confidence": 0.82, + "results": [ + { + "path": "src/store.py", + "start_line": 10, + "end_line": 300, + "kind": "class_skeleton", + "symbol": "store::Store" + }, + { + "path": "src/cache.py", + "start_line": 12, + "end_line": 20, + "kind": "function", + "symbol": "cache::Cache::evict" + }, + { + "path": "src/uploads/client.py", + "start_line": 20, + "end_line": 23, + "kind": "function", + "symbol": "uploads.client::Client::put" + }, + { + "path": "src/uploads/retry.py", + "start_line": 6, + "end_line": 15, + "kind": "function", + "symbol": "uploads.retry::retry_upload" + }, + { + "path": "src/store.py", + "start_line": 50, + "end_line": 90, + "kind": "function", + "symbol": "store::Store::put_object" + } + ] + }, + "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/store.py:50-90 store::Store::put_object\n- src/cache.py:12-20 cache::Cache::evict\n- src/uploads/client.py:20-23 uploads.client::Client::put" + }, { "name": "a line carries the name and the signature cut at 80 characters; a span is listed once", "prompt": "the handler ignores the strict flag for uploads", diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index 4ccdaf57ad..ba777a0c7b 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -341,6 +341,12 @@ test("a picked answer is sent only when its first result is a place", () => { const ranked = [second, { ...first, kind: "class_skeleton" }, third]; assert.deepEqual(places({ results: ranked }, { query, picked: true, cap: 2 }), [second]); assert.deepEqual(places({ results: ranked }, { query, cap: 2 }), [second, third]); + // A model chose a picked answer's order: its places keep it, where an unpicked answer lists the first-ranked file's place first. + const long = { path: "pkg/store.py", start_line: 10, end_line: 300, symbol: "Store", kind: "class_skeleton" }; + const method = { path: "pkg/store.py", start_line: 50, end_line: 90, symbol: "Store::put_object", kind: "function" }; + const unnamed = "objects are written twice when memory runs low"; + assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed, picked: true }), [third, method]); + assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed }), [method, third]); }); test("a range over the stated length is pointed at by its first line and its length", () => { diff --git a/integrations/codex-plugin/.codex-plugin/plugin.json b/integrations/codex-plugin/.codex-plugin/plugin.json index 33322e89d6..681af33330 100644 --- a/integrations/codex-plugin/.codex-plugin/plugin.json +++ b/integrations/codex-plugin/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "loom", - "version": "1.2.158", + "version": "1.2.165", "description": "Shared long-term memory and code intelligence for Codex, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.", "author": { "name": "ClickHouse" diff --git a/integrations/codex-plugin/lib/prompt-pack.mjs b/integrations/codex-plugin/lib/prompt-pack.mjs index ab5eab82a8..7eb308518c 100644 --- a/integrations/codex-plugin/lib/prompt-pack.mjs +++ b/integrations/codex-plugin/lib/prompt-pack.mjs @@ -574,6 +574,11 @@ export const LONG_RANGE_LINES = 200; * and kind: it does not say the fix is made there, and no rule here drops an * answer that holds only other places. * + * The first-ranked result's file leads: the first of the pointers in that + * file is listed first, also when the unit sent for it ranks below another + * file's (a class sent as a method, a first result that is no place). The + * others keep rank order, as all do when that file has no pointer. + * * A range and the ranges inside it (a class and its own methods) send one * pointer, chosen in two steps: * 1. The names (`byName`): each innermost definition inside the range that @@ -590,8 +595,8 @@ export const LONG_RANGE_LINES = 200; * a mention anywhere in it counts, also in a sentence that tells the agent * what not to edit and in a pasted traceback). For a `picked` answer the * server's confidence is in its first result, and the pick was measured on - * its first `cap`: when the first is no place nothing is sent, and no result - * below them is. + * its first `cap`: when the first is no place nothing is sent, no result + * below them is, and the places keep rank order. */ export function places(res, { query, text = query, cap = 3, picked = false } = {}) { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; @@ -623,7 +628,9 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { const sent = new Set(outermost.flatMap(byName).map(byLength)); // No range inside another: two ranges that overlap without one holding the other can each choose a unit inside both. const apart = (unit) => ![...sent].some((other) => other !== unit && within(unit, other)); - return ranked.filter((unit) => sent.has(unit) && apart(unit)).slice(0, cap); + const chosen = ranked.filter((unit) => sent.has(unit) && apart(unit)); + const lead = picked ? undefined : chosen.find((unit) => unit.path === results[0].path); + return (lead ? [lead, ...chosen.filter((unit) => unit !== lead)] : chosen).slice(0, cap); } export function pointerOf(unit) { diff --git a/sdk/python/loom/pointers.py b/sdk/python/loom/pointers.py index a77cba4311..a2ee3b1fc3 100644 --- a/sdk/python/loom/pointers.py +++ b/sdk/python/loom/pointers.py @@ -594,6 +594,10 @@ def _places( was asked with (it says whether tests or documentation were asked for) and `text` the whole prompt (it says what is named). + The first-ranked result's file leads: the first of the pointers in that file is + listed first, also when the unit sent for it ranks below another file's. The others + keep rank order, as all do when that file has no pointer. + A range and the ranges inside it (a class and its own methods) send one pointer: each innermost definition inside the range that `text` names; else the range when `text` names it; else what ranks first of the range and the ranges inside it. What @@ -640,12 +644,16 @@ def by_length(unit: Mapping[str, Any]) -> Mapping[str, Any]: sent = [by_length(chosen) for unit in outermost for chosen in by_name(unit)] # No range inside another: two ranges that overlap without one holding the other can # each choose a unit inside both. - return [ + listed = [ unit for unit in ranked if any(unit is one for one in sent) and not any(other is not unit and _within(unit, other) for other in sent) - ][:cap] + ] + lead = next((unit for unit in listed if unit.get("path") == results[0].get("path")), None) + if lead is not None: + listed = [lead, *(unit for unit in listed if unit is not lead)] + return listed[:cap] # ---------------------------------------------------------------- the block diff --git a/sdk/typescript/src/pointers.ts b/sdk/typescript/src/pointers.ts index 7c6c18344b..d967850d4a 100644 --- a/sdk/typescript/src/pointers.ts +++ b/sdk/typescript/src/pointers.ts @@ -490,6 +490,10 @@ function pointerOf(unit: PointerUnit): string { * with (it says whether tests or documentation were asked for) and `text` the whole * prompt (it says what is named). * + * The first-ranked result's file leads: the first of the pointers in that file is listed + * first, also when the unit sent for it ranks below another file's. The others keep rank + * order, as all do when that file has no pointer. + * * A range and the ranges inside it (a class and its own methods) send one pointer: each * innermost definition inside the range that `text` names; else the range when `text` * names it; else what ranks first of the range and the ranges inside it. What that @@ -528,7 +532,9 @@ function places(results: PointerUnit[], query: string, text: string, cap: number // No range inside another: two ranges that overlap without one holding the other can // each choose a unit inside both. const apart = (unit: PointerUnit) => ![...sent].some((other) => other !== unit && within(unit, other)); - return ranked.filter((unit) => sent.has(unit) && apart(unit)).slice(0, cap); + const chosen = ranked.filter((unit) => sent.has(unit) && apart(unit)); + const lead = chosen.find((unit) => unit.path === results[0].path); + return (lead ? [lead, ...chosen.filter((unit) => unit !== lead)] : chosen).slice(0, cap); } // ---- the block --------------------------------------------------------------- diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index e40123b41f..bb56f351cc 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -393,7 +393,7 @@ "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "e4bf6fe545e0527bb793f05d92240d462ecf19e7fabb1f88dedeca6c08ab9500", "integrations/claude-code-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/claude-code-plugin/lib/prompt-pack.mjs": "efd318401aebf0a13fb51289b971ae4bab6138b4d175cc8150902f325a5d9101", + "integrations/claude-code-plugin/lib/prompt-pack.mjs": "3fecf2f7c245cbfadab644b4b10a93b60297517589ee765d045676ac0d2253f6", "integrations/claude-code-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/claude-code-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/claude-code-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", @@ -408,7 +408,7 @@ "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "e4bf6fe545e0527bb793f05d92240d462ecf19e7fabb1f88dedeca6c08ab9500", "integrations/codex-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/codex-plugin/lib/prompt-pack.mjs": "efd318401aebf0a13fb51289b971ae4bab6138b4d175cc8150902f325a5d9101", + "integrations/codex-plugin/lib/prompt-pack.mjs": "3fecf2f7c245cbfadab644b4b10a93b60297517589ee765d045676ac0d2253f6", "integrations/codex-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/codex-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/codex-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", From 84124c09475a0c487eefe634c6fd309a87659437 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 00:59:15 +0530 Subject: [PATCH 2/6] The first result's file leads in a picked answer too A picked answer kept rank order, on the reason that its model chose the order. The model chose the first result, not the unit the place rules send for it: a first pick that is a long class is sent as a method ranked lower, and a unit of another file between them was listed first. That is the case the rule fixes for an unpicked answer, so `places` now applies it to both. The pointers of a picked answer are the same ones: its results are cut to the cap before the rules run. The comment on `places` in the four copies states the order once, and `test_an_issue_gets_the_places_it_is_about` asserts the rule as it is: the first place of the first result's file, then the others in rank order. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 3 +-- integrations/claude-code-plugin/hooks/HOOKS.md | 3 +-- .../claude-code-plugin/lib/prompt-pack.mjs | 16 ++++++++-------- .../tests/prompt-pack.test.mjs | 4 ++-- integrations/codex-plugin/lib/prompt-pack.mjs | 16 ++++++++-------- sdk/python/loom/pointers.py | 8 ++++---- sdk/typescript/src/pointers.ts | 8 ++++---- tests/unit/session_content_senders.json | 4 ++-- tests/unit/test_sdk_pointer_block.py | 9 ++++++--- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index 9dc4122a7e..444fd32281 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -647,8 +647,7 @@ its first line, the definition's signature, with its length (`path:643 Permutation (372 lines)`). The first place in the file of the answer's first result is listed first, also when that result is no place itself or is sent as a definition ranked below another file's; the other places keep the index's order, as all -do when that file has no place or the answer is a picked one -([below](#model-picked-pointers-for-a-bug-report)). The low-risk label says the index holds code about +do when that file has no place. The low-risk label says the index holds code about the prompt, not that the pointers are where a fix is made, and no field of the answer tells the two apart. The place test reads a unit's path and kind and does not tell them apart either: an answer that holds only other places is sent. diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index e477bdc4b1..cae0ccdf07 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -876,8 +876,7 @@ in. **The first result's file leads.** The first place in the file of the answer's first result is listed first, also when that result is no place itself or is sent as a definition ranked below another file's. The other - places keep the index's order, as all do when that file has no place and - in a picked answer. For a + places keep the index's order, as all do when that file has no place. For a picked answer (`LOOM_PROMPT_PACK_PICK`) the model's confidence is in its first result, and the pick was measured on its first three: when the first is no place nothing is sent, and no result below the third is. The low-risk label says the index holds code about the prompt, not that the pointers are where diff --git a/integrations/claude-code-plugin/lib/prompt-pack.mjs b/integrations/claude-code-plugin/lib/prompt-pack.mjs index 7eb308518c..0d4e8306a6 100644 --- a/integrations/claude-code-plugin/lib/prompt-pack.mjs +++ b/integrations/claude-code-plugin/lib/prompt-pack.mjs @@ -568,11 +568,11 @@ export const LONG_RANGE_LINES = 200; /** * The pointers a search answer sends: the units that pass the place test - * (`isPlace`), in rank order, at most `cap`, and no range inside another. The - * model re-reads the pointers on every later request, so a unit that fails - * the test is not carried by one that passes. The test reads a unit's path - * and kind: it does not say the fix is made there, and no rule here drops an - * answer that holds only other places. + * (`isPlace`), at most `cap`, and no range inside another. The model re-reads + * the pointers on every later request, so a unit that fails the test is not + * carried by one that passes. The test reads a unit's path and kind: it does + * not say the fix is made there, and no rule here drops an answer that holds + * only other places. * * The first-ranked result's file leads: the first of the pointers in that * file is listed first, also when the unit sent for it ranks below another @@ -595,8 +595,8 @@ export const LONG_RANGE_LINES = 200; * a mention anywhere in it counts, also in a sentence that tells the agent * what not to edit and in a pasted traceback). For a `picked` answer the * server's confidence is in its first result, and the pick was measured on - * its first `cap`: when the first is no place nothing is sent, no result - * below them is, and the places keep rank order. + * its first `cap`: when the first is no place nothing is sent, and no result + * below them is. */ export function places(res, { query, text = query, cap = 3, picked = false } = {}) { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; @@ -629,7 +629,7 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { // No range inside another: two ranges that overlap without one holding the other can each choose a unit inside both. const apart = (unit) => ![...sent].some((other) => other !== unit && within(unit, other)); const chosen = ranked.filter((unit) => sent.has(unit) && apart(unit)); - const lead = picked ? undefined : chosen.find((unit) => unit.path === results[0].path); + const lead = chosen.find((unit) => unit.path === results[0].path); return (lead ? [lead, ...chosen.filter((unit) => unit !== lead)] : chosen).slice(0, cap); } diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index ba777a0c7b..1972371935 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -341,11 +341,11 @@ test("a picked answer is sent only when its first result is a place", () => { const ranked = [second, { ...first, kind: "class_skeleton" }, third]; assert.deepEqual(places({ results: ranked }, { query, picked: true, cap: 2 }), [second]); assert.deepEqual(places({ results: ranked }, { query, cap: 2 }), [second, third]); - // A model chose a picked answer's order: its places keep it, where an unpicked answer lists the first-ranked file's place first. + // The first pick's file leads as in an unpicked answer: a long first pick is sent as its method, ahead of another file's. const long = { path: "pkg/store.py", start_line: 10, end_line: 300, symbol: "Store", kind: "class_skeleton" }; const method = { path: "pkg/store.py", start_line: 50, end_line: 90, symbol: "Store::put_object", kind: "function" }; const unnamed = "objects are written twice when memory runs low"; - assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed, picked: true }), [third, method]); + assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed, picked: true }), [method, third]); assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed }), [method, third]); }); diff --git a/integrations/codex-plugin/lib/prompt-pack.mjs b/integrations/codex-plugin/lib/prompt-pack.mjs index 7eb308518c..0d4e8306a6 100644 --- a/integrations/codex-plugin/lib/prompt-pack.mjs +++ b/integrations/codex-plugin/lib/prompt-pack.mjs @@ -568,11 +568,11 @@ export const LONG_RANGE_LINES = 200; /** * The pointers a search answer sends: the units that pass the place test - * (`isPlace`), in rank order, at most `cap`, and no range inside another. The - * model re-reads the pointers on every later request, so a unit that fails - * the test is not carried by one that passes. The test reads a unit's path - * and kind: it does not say the fix is made there, and no rule here drops an - * answer that holds only other places. + * (`isPlace`), at most `cap`, and no range inside another. The model re-reads + * the pointers on every later request, so a unit that fails the test is not + * carried by one that passes. The test reads a unit's path and kind: it does + * not say the fix is made there, and no rule here drops an answer that holds + * only other places. * * The first-ranked result's file leads: the first of the pointers in that * file is listed first, also when the unit sent for it ranks below another @@ -595,8 +595,8 @@ export const LONG_RANGE_LINES = 200; * a mention anywhere in it counts, also in a sentence that tells the agent * what not to edit and in a pasted traceback). For a `picked` answer the * server's confidence is in its first result, and the pick was measured on - * its first `cap`: when the first is no place nothing is sent, no result - * below them is, and the places keep rank order. + * its first `cap`: when the first is no place nothing is sent, and no result + * below them is. */ export function places(res, { query, text = query, cap = 3, picked = false } = {}) { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; @@ -629,7 +629,7 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { // No range inside another: two ranges that overlap without one holding the other can each choose a unit inside both. const apart = (unit) => ![...sent].some((other) => other !== unit && within(unit, other)); const chosen = ranked.filter((unit) => sent.has(unit) && apart(unit)); - const lead = picked ? undefined : chosen.find((unit) => unit.path === results[0].path); + const lead = chosen.find((unit) => unit.path === results[0].path); return (lead ? [lead, ...chosen.filter((unit) => unit !== lead)] : chosen).slice(0, cap); } diff --git a/sdk/python/loom/pointers.py b/sdk/python/loom/pointers.py index a2ee3b1fc3..59f2de63c3 100644 --- a/sdk/python/loom/pointers.py +++ b/sdk/python/loom/pointers.py @@ -589,10 +589,10 @@ def _pointer(unit: Mapping[str, Any]) -> str: def _places( results: list[Mapping[str, Any]], *, query: str, text: str, cap: int ) -> list[Mapping[str, Any]]: - """The pointers a search answer sends: the units that pass the place test, in rank - order, at most `cap`, and no range inside another. `query` is the text the search - was asked with (it says whether tests or documentation were asked for) and `text` - the whole prompt (it says what is named). + """The pointers a search answer sends: the units that pass the place test, at most + `cap`, and no range inside another. `query` is the text the search was asked with + (it says whether tests or documentation were asked for) and `text` the whole prompt + (it says what is named). The first-ranked result's file leads: the first of the pointers in that file is listed first, also when the unit sent for it ranks below another file's. The others diff --git a/sdk/typescript/src/pointers.ts b/sdk/typescript/src/pointers.ts index d967850d4a..43c2da5601 100644 --- a/sdk/typescript/src/pointers.ts +++ b/sdk/typescript/src/pointers.ts @@ -485,10 +485,10 @@ function pointerOf(unit: PointerUnit): string { } /** - * The pointers a search answer sends: the units that pass the place test, in rank order, - * at most `cap`, and no range inside another. `query` is the text the search was asked - * with (it says whether tests or documentation were asked for) and `text` the whole - * prompt (it says what is named). + * The pointers a search answer sends: the units that pass the place test, at most `cap`, + * and no range inside another. `query` is the text the search was asked with (it says + * whether tests or documentation were asked for) and `text` the whole prompt (it says + * what is named). * * The first-ranked result's file leads: the first of the pointers in that file is listed * first, also when the unit sent for it ranks below another file's. The others keep rank diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index c66bed7a4d..34f3f4c9bd 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -393,7 +393,7 @@ "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "2dda1d7c9c04ec1d3f207e12cb1d1dc65571afa298bbbb8e4238115261784dd8", "integrations/claude-code-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/claude-code-plugin/lib/prompt-pack.mjs": "3fecf2f7c245cbfadab644b4b10a93b60297517589ee765d045676ac0d2253f6", + "integrations/claude-code-plugin/lib/prompt-pack.mjs": "4d7e1615e42b67c5044a0bc5f6442d4ffe8e0216a8a83a68bc9db735db157810", "integrations/claude-code-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/claude-code-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/claude-code-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", @@ -408,7 +408,7 @@ "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "2dda1d7c9c04ec1d3f207e12cb1d1dc65571afa298bbbb8e4238115261784dd8", "integrations/codex-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/codex-plugin/lib/prompt-pack.mjs": "3fecf2f7c245cbfadab644b4b10a93b60297517589ee765d045676ac0d2253f6", + "integrations/codex-plugin/lib/prompt-pack.mjs": "4d7e1615e42b67c5044a0bc5f6442d4ffe8e0216a8a83a68bc9db735db157810", "integrations/codex-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/codex-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/codex-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", diff --git a/tests/unit/test_sdk_pointer_block.py b/tests/unit/test_sdk_pointer_block.py index 3e4b52b63c..d18699be56 100644 --- a/tests/unit/test_sdk_pointer_block.py +++ b/tests/unit/test_sdk_pointer_block.py @@ -564,8 +564,7 @@ async def test_an_issue_gets_the_places_it_is_about(deployment: Deployment) -> N first = await bot.code.pointer_block(ISSUE, namespace="code-uploads") lead, *entries = block.split("\n") assert lead == pointers.LEAD - # Places to edit, in the index's order: the test and the document the answer - # holds are left out. + # Places to edit: the test and the document the answer holds are left out. served = deployment.answers[0]["results"] assert len(served) == 5 assert any(u["path"].startswith("tests/") for u in served) @@ -577,7 +576,11 @@ async def test_an_issue_gets_the_places_it_is_about(deployment: Deployment) -> N ] listed = [entry.split(" ")[1] for entry in entries] ranked = [f"{u['path']}:{u['start_line']}-{u['end_line']}" for u in served] - assert listed == [pointer for pointer in ranked if pointer in listed] + # The first place in the first result's file leads; the others keep the index's order. + in_order = [pointer for pointer in ranked if pointer in listed] + first_file = served[0]["path"] + ":" + front = [pointer for pointer in in_order if pointer.startswith(first_file)][:1] + assert listed == front + [pointer for pointer in in_order if pointer not in front] # Unasked, the answer is three results, and the block lists the places among them. assert len(deployment.answers[1]["results"]) == 3 assert first.split("\n") == [lead, *entries[: len(first.split("\n")) - 1]] From df015f64e78611ea197c735df1973fe911542bcb Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 01:15:20 +0530 Subject: [PATCH 3/6] The docs say the highest-ranked place of the first result's file leads "The first place in the file" could be read as the place on the earliest line. The rule takes the place the index ranked highest in that file. The three doc pages, the comments on the four copies of the rule and the SDK test comment now say so, and a shared fixture case holds the four copies to it: of two places in the first-ranked file, the higher-ranked one is listed first though it starts on a later line. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 4 +- docs/guides/issue-code-pointers.md | 8 ++-- .../claude-code-plugin/hooks/HOOKS.md | 4 +- .../claude-code-plugin/lib/prompt-pack.mjs | 8 ++-- .../tests/fixtures/pointer-block.json | 41 +++++++++++++++++++ integrations/codex-plugin/lib/prompt-pack.mjs | 8 ++-- sdk/python/loom/pointers.py | 6 +-- sdk/typescript/src/pointers.ts | 6 +-- tests/unit/session_content_senders.json | 4 +- tests/unit/test_sdk_pointer_block.py | 2 +- 10 files changed, 66 insertions(+), 25 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index 444fd32281..9bfc4a18bc 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -644,8 +644,8 @@ chosen so, when it is a range of more than 200 lines, gives way to the first-ran definition the answer holds inside it, which is the part of it the search matched, so a long class the prompt names is sent as that method; with none inside it, it is sent as its first line, the definition's signature, with its length -(`path:643 Permutation (372 lines)`). The first place in the file of the answer's first -result is listed first, also when that result is no place itself or is sent as a +(`path:643 Permutation (372 lines)`). The highest-ranked place in the file of the answer's +first result is listed first, also when that result is no place itself or is sent as a definition ranked below another file's; the other places keep the index's order, as all do when that file has no place. The low-risk label says the index holds code about the prompt, not that the pointers are where a fix is made, and no field of the answer diff --git a/docs/guides/issue-code-pointers.md b/docs/guides/issue-code-pointers.md index 6b1da1af3a..930350c17d 100644 --- a/docs/guides/issue-code-pointers.md +++ b/docs/guides/issue-code-pointers.md @@ -162,10 +162,10 @@ lists the answer's places to edit: class when the prompt names it, else the one the index ranked first. A range over 200 lines gives way to a definition the answer holds inside it, and is otherwise listed as its first line and its length. -- The first place in the file of the answer's first result is listed first, also when - that result is no place itself or is sent as a definition ranked below another file's. - The other entries keep the index's order, as all do when that file has no place. A - span is listed once. +- The highest-ranked place in the file of the answer's first result is listed first, + also when that result is no place itself or is sent as a definition ranked below + another file's. The other entries keep the index's order, as all do when that file has + no place. A span is listed once. - Paths are relative to the repository root, after the checkout prefix when one is given, and the lines are those of the indexed commit. diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index cae0ccdf07..d04644277a 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -873,8 +873,8 @@ in. that method; with none inside it, it is sent as its first line, the definition's signature, with its length (`path:643 Permutation (372 lines)`). - **The first result's file leads.** The first place in the file of the - answer's first result is listed first, also when that result is no place + **The first result's file leads.** The highest-ranked place in the file of + the answer's first result is listed first, also when that result is no place itself or is sent as a definition ranked below another file's. The other places keep the index's order, as all do when that file has no place. For a picked answer (`LOOM_PROMPT_PACK_PICK`) the model's confidence is in its diff --git a/integrations/claude-code-plugin/lib/prompt-pack.mjs b/integrations/claude-code-plugin/lib/prompt-pack.mjs index 0d4e8306a6..1739e9844d 100644 --- a/integrations/claude-code-plugin/lib/prompt-pack.mjs +++ b/integrations/claude-code-plugin/lib/prompt-pack.mjs @@ -574,10 +574,10 @@ export const LONG_RANGE_LINES = 200; * not say the fix is made there, and no rule here drops an answer that holds * only other places. * - * The first-ranked result's file leads: the first of the pointers in that - * file is listed first, also when the unit sent for it ranks below another - * file's (a class sent as a method, a first result that is no place). The - * others keep rank order, as all do when that file has no pointer. + * The first-ranked result's file leads: the highest-ranked of the pointers + * in that file is listed first, also when the unit sent for it ranks below + * another file's (a class sent as a method, a first result that is no place). + * The others keep rank order, as all do when that file has no pointer. * * A range and the ranges inside it (a class and its own methods) send one * pointer, chosen in two steps: diff --git a/integrations/claude-code-plugin/tests/fixtures/pointer-block.json b/integrations/claude-code-plugin/tests/fixtures/pointer-block.json index 02ee2fdab4..07b5849df7 100644 --- a/integrations/claude-code-plugin/tests/fixtures/pointer-block.json +++ b/integrations/claude-code-plugin/tests/fixtures/pointer-block.json @@ -1467,6 +1467,47 @@ }, "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/store.py:50-90 store::Store::put_object\n- src/cache.py:12-20 cache::Cache::evict\n- src/uploads/client.py:20-23 uploads.client::Client::put" }, + { + "name": "of two places in the first-ranked file the higher-ranked is listed first, not the one on the earlier line", + "prompt": "the transfer is never tried again after the bucket answers slowly once", + "query": "the transfer is never tried again after the bucket answers slowly once", + "reply": { + "abstain": false, + "retrieval_risk": "low", + "retrieval_confidence": 0.82, + "results": [ + { + "path": "src/uploads/retry.py", + "start_line": 1, + "end_line": 3, + "kind": "file_header", + "symbol": "" + }, + { + "path": "src/uploads/client.py", + "start_line": 20, + "end_line": 23, + "kind": "function", + "symbol": "uploads.client::Client::put" + }, + { + "path": "src/uploads/retry.py", + "start_line": 40, + "end_line": 52, + "kind": "function", + "symbol": "uploads.retry::backoff_delay" + }, + { + "path": "src/uploads/retry.py", + "start_line": 6, + "end_line": 15, + "kind": "function", + "symbol": "uploads.retry::retry_upload" + } + ] + }, + "block": "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n- src/uploads/retry.py:40-52 uploads.retry::backoff_delay\n- src/uploads/client.py:20-23 uploads.client::Client::put\n- src/uploads/retry.py:6-15 uploads.retry::retry_upload" + }, { "name": "a line carries the name and the signature cut at 80 characters; a span is listed once", "prompt": "the handler ignores the strict flag for uploads", diff --git a/integrations/codex-plugin/lib/prompt-pack.mjs b/integrations/codex-plugin/lib/prompt-pack.mjs index 0d4e8306a6..1739e9844d 100644 --- a/integrations/codex-plugin/lib/prompt-pack.mjs +++ b/integrations/codex-plugin/lib/prompt-pack.mjs @@ -574,10 +574,10 @@ export const LONG_RANGE_LINES = 200; * not say the fix is made there, and no rule here drops an answer that holds * only other places. * - * The first-ranked result's file leads: the first of the pointers in that - * file is listed first, also when the unit sent for it ranks below another - * file's (a class sent as a method, a first result that is no place). The - * others keep rank order, as all do when that file has no pointer. + * The first-ranked result's file leads: the highest-ranked of the pointers + * in that file is listed first, also when the unit sent for it ranks below + * another file's (a class sent as a method, a first result that is no place). + * The others keep rank order, as all do when that file has no pointer. * * A range and the ranges inside it (a class and its own methods) send one * pointer, chosen in two steps: diff --git a/sdk/python/loom/pointers.py b/sdk/python/loom/pointers.py index 59f2de63c3..934c7f177d 100644 --- a/sdk/python/loom/pointers.py +++ b/sdk/python/loom/pointers.py @@ -594,9 +594,9 @@ def _places( (it says whether tests or documentation were asked for) and `text` the whole prompt (it says what is named). - The first-ranked result's file leads: the first of the pointers in that file is - listed first, also when the unit sent for it ranks below another file's. The others - keep rank order, as all do when that file has no pointer. + The first-ranked result's file leads: the highest-ranked of the pointers in that file + is listed first, also when the unit sent for it ranks below another file's. The + others keep rank order, as all do when that file has no pointer. A range and the ranges inside it (a class and its own methods) send one pointer: each innermost definition inside the range that `text` names; else the range when diff --git a/sdk/typescript/src/pointers.ts b/sdk/typescript/src/pointers.ts index 43c2da5601..58f3607ca1 100644 --- a/sdk/typescript/src/pointers.ts +++ b/sdk/typescript/src/pointers.ts @@ -490,9 +490,9 @@ function pointerOf(unit: PointerUnit): string { * whether tests or documentation were asked for) and `text` the whole prompt (it says * what is named). * - * The first-ranked result's file leads: the first of the pointers in that file is listed - * first, also when the unit sent for it ranks below another file's. The others keep rank - * order, as all do when that file has no pointer. + * The first-ranked result's file leads: the highest-ranked of the pointers in that file + * is listed first, also when the unit sent for it ranks below another file's. The others + * keep rank order, as all do when that file has no pointer. * * A range and the ranges inside it (a class and its own methods) send one pointer: each * innermost definition inside the range that `text` names; else the range when `text` diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index 34f3f4c9bd..2c7fff9692 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -393,7 +393,7 @@ "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "2dda1d7c9c04ec1d3f207e12cb1d1dc65571afa298bbbb8e4238115261784dd8", "integrations/claude-code-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/claude-code-plugin/lib/prompt-pack.mjs": "4d7e1615e42b67c5044a0bc5f6442d4ffe8e0216a8a83a68bc9db735db157810", + "integrations/claude-code-plugin/lib/prompt-pack.mjs": "2cdbcecb6d5b19c821d73f0e1597b17de79e6c40e56bb63052f87ca3d3589b59", "integrations/claude-code-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/claude-code-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/claude-code-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", @@ -408,7 +408,7 @@ "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "2dda1d7c9c04ec1d3f207e12cb1d1dc65571afa298bbbb8e4238115261784dd8", "integrations/codex-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/codex-plugin/lib/prompt-pack.mjs": "4d7e1615e42b67c5044a0bc5f6442d4ffe8e0216a8a83a68bc9db735db157810", + "integrations/codex-plugin/lib/prompt-pack.mjs": "2cdbcecb6d5b19c821d73f0e1597b17de79e6c40e56bb63052f87ca3d3589b59", "integrations/codex-plugin/lib/repo-scope.mjs": "961eafc828f667daf59e94407bf363c7243890e3f4d1d35c5b9d04e2db72eefe", "integrations/codex-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/codex-plugin/lib/session-start.mjs": "6b410afc84c63d539f539b9f6e9325a91ab6d8431637541c3b6c8a8e58079ca1", diff --git a/tests/unit/test_sdk_pointer_block.py b/tests/unit/test_sdk_pointer_block.py index d18699be56..fbc8870ff7 100644 --- a/tests/unit/test_sdk_pointer_block.py +++ b/tests/unit/test_sdk_pointer_block.py @@ -576,7 +576,7 @@ async def test_an_issue_gets_the_places_it_is_about(deployment: Deployment) -> N ] listed = [entry.split(" ")[1] for entry in entries] ranked = [f"{u['path']}:{u['start_line']}-{u['end_line']}" for u in served] - # The first place in the first result's file leads; the others keep the index's order. + # The highest-ranked place in the first result's file leads; the others keep the index's order. in_order = [pointer for pointer in ranked if pointer in listed] first_file = served[0]["path"] + ":" front = [pointer for pointer in in_order if pointer.startswith(first_file)][:1] From 9614859dd86845430560354f141aae7ffc2a2f49 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 01:33:05 +0530 Subject: [PATCH 4/6] A hook test pins which file's test line follows the pointer order The test line under the pointers is for the first listed pointer whose definition the prompt names (`checkPointer`), so it follows the order `places` lists. With the first result's file leading, a prompt that names a definition in each of two files gets the test of the first result's file where it got the test of the file whose unit ranked higher. A prompt carries one test line, so the other file's test is not named with it; the test gate names it when the session edits that file. No test had an answer with two named pointers. The new case in `prompt-pack-hook.test.mjs` sends a first result that is no place, a function of another file and a function of the first file: the first file's function is listed first and the line names its test. The same answer without the leading result lists the other file first and names that file's test. With `places` of `main` the first assertion fails: the other file is listed first and its test is named. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- .../tests/prompt-pack-hook.test.mjs | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs index 68fde5bfa3..6ba9e4f48d 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs @@ -958,13 +958,14 @@ const context = (result) => (result.out ? JSON.parse(result.out).hookSpecificOut const POINTERS = "Loom index pointers for this prompt, candidates: Read a line range to check one, search if none fits:\n" + "- src/parser.py:10-14 Parser.parse_record — (value)"; -/** The test line for the fixture's file, behind the interpreter `parserCheckout` left in `dir`. */ -const testLine = (dir) => - `Loom test for src/parser.py: ${path +/** The test line for `src/.py`, by default the fixture's file, behind the interpreter + * `parserCheckout` left in `dir`. */ +const testLine = (dir, stem = "parser") => + `Loom test for src/${stem}.py: ${path .relative(dir, venvPython(path.join(dir, ".venv"))) .split(path.sep) .join("/")} ` + - "-m pytest -q -rf tests/test_parser.py\n" + + `-m pytest -q -rf tests/test_${stem}.py\n` + "It is the one test file named for that file. With -q -rf the last lines are one " + "`FAILED ::` line per failing test, then the totals."; // The fixture's pointer is Parser.parse_record in src/parser.py: this prompt names it. @@ -1061,6 +1062,27 @@ test("the test line runs pytest the way the checkout does: its options and its - ); }); +test("the test line is for the first listed pointer the prompt names: the first result's file", async (t) => { + const { ask, dir, replies } = await contractFixture(t, structuredClone(REPLIES)); + parserCheckout(dir, { + tests: ["tests/test_parser.py", "tests/test_records.py"], + files: { "pytest.ini": "", "src/records.py": "def merge_prefixes(parts):\n return parts\n" }, + }); + const [parser] = replies["code.search"].results; + const header = { path: "src/parser.py", start_line: 1, end_line: 3, kind: "file_header", symbol: "" }; + const records = { path: "src/records.py", start_line: 1, end_line: 2, kind: "function", symbol: "merge_prefixes" }; + const listed = "- src/records.py:1-2 merge_prefixes"; + const [lead, parsers] = POINTERS.split("\n"); + // The prompt names a definition of each file, and each file has one test named after it. + const both = "Why does parse_record drop the prefix that merge_prefixes built?"; + // The first result is no place: its file's function is listed first, and the line is for that file. + replies["code.search"].results = [header, records, parser]; + assert.equal(context(await ask(both, "one")), `${POINTERS}\n${listed}\n${testLine(dir)}`); + // The other file's function ranked first is listed first, and the line is for its file. + replies["code.search"].results = [records, parser]; + assert.equal(context(await ask(both, "two")), `${lead}\n${listed}\n${parsers}\n${testLine(dir, "records")}`); +}); + test("a prompt carries no test line where the checkout shows no single test or no pytest", async (t) => { for (const [why, shape] of [ ["no pytest configuration", { files: { "setup.cfg": "[flake8]\nexclude = build\n" } }], From 52a7ed293245e18e631b69d5693f75731b84027b Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 01:53:49 +0530 Subject: [PATCH 5/6] The SDK pointer test asserts index order where the lead rule moves nothing The answer of test_an_issue_gets_the_places_it_is_about cannot trigger the lead rule, so its assertion is the one-line order check again; the shared fixture cases hold the rule. The hook test names its two block lines after the pointers they are. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- .../claude-code-plugin/tests/prompt-pack-hook.test.mjs | 8 ++++---- tests/unit/test_sdk_pointer_block.py | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs index 6ba9e4f48d..45d21e5314 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs @@ -1071,16 +1071,16 @@ test("the test line is for the first listed pointer the prompt names: the first const [parser] = replies["code.search"].results; const header = { path: "src/parser.py", start_line: 1, end_line: 3, kind: "file_header", symbol: "" }; const records = { path: "src/records.py", start_line: 1, end_line: 2, kind: "function", symbol: "merge_prefixes" }; - const listed = "- src/records.py:1-2 merge_prefixes"; - const [lead, parsers] = POINTERS.split("\n"); + const recordsLine = "- src/records.py:1-2 merge_prefixes"; + const [lead, parserLine] = POINTERS.split("\n"); // The prompt names a definition of each file, and each file has one test named after it. const both = "Why does parse_record drop the prefix that merge_prefixes built?"; // The first result is no place: its file's function is listed first, and the line is for that file. replies["code.search"].results = [header, records, parser]; - assert.equal(context(await ask(both, "one")), `${POINTERS}\n${listed}\n${testLine(dir)}`); + assert.equal(context(await ask(both, "one")), `${POINTERS}\n${recordsLine}\n${testLine(dir)}`); // The other file's function ranked first is listed first, and the line is for its file. replies["code.search"].results = [records, parser]; - assert.equal(context(await ask(both, "two")), `${lead}\n${listed}\n${parsers}\n${testLine(dir, "records")}`); + assert.equal(context(await ask(both, "two")), `${lead}\n${recordsLine}\n${parserLine}\n${testLine(dir, "records")}`); }); test("a prompt carries no test line where the checkout shows no single test or no pytest", async (t) => { diff --git a/tests/unit/test_sdk_pointer_block.py b/tests/unit/test_sdk_pointer_block.py index fbc8870ff7..5fe9ef4e84 100644 --- a/tests/unit/test_sdk_pointer_block.py +++ b/tests/unit/test_sdk_pointer_block.py @@ -576,11 +576,8 @@ async def test_an_issue_gets_the_places_it_is_about(deployment: Deployment) -> N ] listed = [entry.split(" ")[1] for entry in entries] ranked = [f"{u['path']}:{u['start_line']}-{u['end_line']}" for u in served] - # The highest-ranked place in the first result's file leads; the others keep the index's order. - in_order = [pointer for pointer in ranked if pointer in listed] - first_file = served[0]["path"] + ":" - front = [pointer for pointer in in_order if pointer.startswith(first_file)][:1] - assert listed == front + [pointer for pointer in in_order if pointer not in front] + # The lead rule moves nothing in this answer: the block is in the index's order. + assert listed == [pointer for pointer in ranked if pointer in listed] # Unasked, the answer is three results, and the block lists the places among them. assert len(deployment.answers[1]["results"]) == 3 assert first.split("\n") == [lead, *entries[: len(first.split("\n")) - 1]] From 02f23d46211aec862745db60a52ca72ab500c3d0 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Fri, 4 Dec 2026 02:04:13 +0530 Subject: [PATCH 6/6] The lead rule for a picked answer has its own plugin test Its assertion sat inside the test of another rule, and the unpicked assertion beside it repeated a shared fixture case. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- .../claude-code-plugin/tests/prompt-pack.test.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index 1972371935..d3ee929482 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -341,12 +341,15 @@ test("a picked answer is sent only when its first result is a place", () => { const ranked = [second, { ...first, kind: "class_skeleton" }, third]; assert.deepEqual(places({ results: ranked }, { query, picked: true, cap: 2 }), [second]); assert.deepEqual(places({ results: ranked }, { query, cap: 2 }), [second, third]); - // The first pick's file leads as in an unpicked answer: a long first pick is sent as its method, ahead of another file's. +}); + +test("a picked answer lists the first pick's file first", () => { + // A long first pick is sent as its method, ahead of another file's function ranked between them. const long = { path: "pkg/store.py", start_line: 10, end_line: 300, symbol: "Store", kind: "class_skeleton" }; + const other = { path: "pkg/solvers/other.py", start_line: 1, end_line: 9, symbol: "later", kind: "function" }; const method = { path: "pkg/store.py", start_line: 50, end_line: 90, symbol: "Store::put_object", kind: "function" }; - const unnamed = "objects are written twice when memory runs low"; - assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed, picked: true }), [method, third]); - assert.deepEqual(places({ results: [long, third, method] }, { query: unnamed }), [method, third]); + const query = "objects are written twice when memory runs low"; + assert.deepEqual(places({ results: [long, other, method] }, { query, picked: true }), [method, other]); }); test("a range over the stated length is pointed at by its first line and its length", () => {