From d731e490d318a9daf52a1bff924021c63f2996a9 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 06:23:04 +0530 Subject: [PATCH 1/6] test(plugin): a picked answer whose first result is source outside the definitions sends its pointers The prompt hook's place test holds source in the languages the index chunks by definition to definitions, and a picked answer whose first result fails the test sends nothing. So an answer the pick model worded high or medium sends nothing when the model put module-level code or class-level source first. These tests state the rule for that first result and fail until the place test follows it. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- .../tests/prompt-pack-hook.test.mjs | 11 ++++ .../tests/prompt-pack.test.mjs | 57 +++++++++++++++++++ 2 files changed, 68 insertions(+) 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 93c5b62ee4..605f2d609d 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs @@ -790,6 +790,17 @@ test("a bug report asks for the server's pick, with no switch, and is sent by th assert.deepEqual(await (await contractFixture(t, misplaced(pick))).ask(report), SILENT, pick); const unpicked = await contractFixture(t, misplaced("")); assert.match(context(await unpicked.ask(report)), /^[^\n]+\n- src\/parser2\.py:10-14 combine2\n/); + // A first pick that is module-level code is a place: the model read the candidates and put it first. + const setting = { path: "src/defaults.py", start_line: 305, end_line: 307, symbol: "", kind: "other" }; + const outside = (pick) => ({ + "code.search": { ...answer(pick)["code.search"], results: [setting, ...results.slice(1)] }, + }); + for (const pick of ["high", "medium"]) { + const block = context(await (await contractFixture(t, outside(pick))).ask(report)); + assert.match(block, /^[^\n]+\n- src\/defaults\.py:305-307\n- src\/parser2\.py:10-14 combine2\n/, pick); + } + const served = await contractFixture(t, outside("")); + assert.match(context(await served.ask(report)), /^[^\n]+\n- src\/parser2\.py:10-14 combine2\n/); }); test("a bug report waits for the pick's bound, a question for its own, and neither past it", async (t) => { diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index c8cec68047..33774cf9bf 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -357,6 +357,63 @@ test("a picked answer lists the first pick's file first", () => { assert.deepEqual(places({ results: [long, other, method] }, { query, picked: true }), [method, other]); }); +test("the first result of a picked answer is a place when it is source outside the definitions", () => { + const at = (kind, path, start, end, symbol = "") => ({ path, start_line: start, end_line: end, symbol, kind }); + const query = "uploaded files get the wrong permissions"; + const picks = (results, text = query) => places({ results }, { query, text, picked: true }); + const setting = at("other", "pkg/conf/defaults.py", 305, 307); + const method = at("function", "pkg/files/storage.py", 215, 217, "Storage::file_mode"); + // The pick model read the candidates and put module-level code first: it is sent, and the places below it. + assert.deepEqual(picks([setting, method]), [setting, method]); + for (const path of INTENT.definition_source_paths) + assert.deepEqual(picks([unit("other", path)]), [unit("other", path)], path); + // An answer no model ordered is held to definitions. + assert.deepEqual(places({ results: [setting, method] }, { query }), [method]); + // The first result only: the same code below it is no place. + const constant = at("other", "pkg/files/storage.py", 1, 9); + assert.deepEqual(picks([setting, constant, method]), [setting, method]); + assert.deepEqual(picks([method, setting]), [method]); + // Every other rule of the place test holds for the first result: its kind, and a path the prompt does not name. + const dropped = [ + at("file_header", "pkg/conf/defaults.py", 1, 4), + at("comment_block", "pkg/conf/defaults.py", 1, 4), + { path: "pkg/conf/defaults.py", start_line: 305, end_line: 307 }, + at("other", "", 305, 307), + at("other", "tests/test_defaults.py", 305, 307), + ...INTENT.not_source_paths.map((path) => at("other", path, 6, 47)), + ]; + for (const first of dropped) assert.deepEqual(picks([first, method]), [], `${first.kind} ${first.path}`); + // It is a range as any place is: a definition inside it that the prompt names is the pointer. + const source = at("other", "pkg/core/function.py", 1053, 1227); + const skeleton = at("class_skeleton", "pkg/core/function.py", 1053, 1172, "Derivative"); + const create = at("function", "pkg/core/function.py", 1268, 1383, "Derivative::__new__"); + assert.deepEqual(picks([source, skeleton, create], "Derivative reports the wrong kind"), [skeleton, create]); + assert.deepEqual(picks([source, skeleton, create]), [source, create]); + + // By the model's word: `high` and `medium` send it, `low` nothing, and no word the answer under the plain rules. + const report = "why do uploaded files get the wrong permissions"; + const body = searchBody({ org: "o", namespace: "code-x" }, report, { token: "" }); + assert.equal(body.rerank, PICK); + const answer = (word) => ({ + abstain: false, + retrieval_risk: "low", + results: [setting, method], + ...(word === undefined ? {} : { pick_confidence: word }), + }); + for (const word of ["high", "medium"]) { + const block = pointerBlock(body, answer(word), report); + assert.deepEqual(block.pointers, [setting, method], word); + assert.match( + block.text, + /\n- pkg\/conf\/defaults\.py:305-307\n- pkg\/files\/storage\.py:215-217 Storage::file_mode$/, + word, + ); + } + assert.deepEqual(pointerBlock(body, answer("low"), report), { pointers: [], text: "" }); + for (const word of ["", undefined]) + assert.deepEqual(pointerBlock(body, answer(word), report).pointers, [method], String(word)); +}); + test("a range over the stated length is pointed at by its first line and its length", () => { assert.equal(LONG_RANGE_LINES, 200); const line = (unit) => renderPack({ results: [unit] }).text.split("\n")[1]; From 8aae499406113faf5a2acb90f3416e99be1b85ae Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 06:38:15 +0530 Subject: [PATCH 2/6] The prompt hook counts the first result of a picked answer as a place when it is source outside the definitions In the languages the index chunks by definition the place test passes definitions only, and a picked answer whose first result fails the test sends nothing. That rule is for an answer no model has read. The pick model's candidates hold module-level code and the lines of a class outside its methods, and it reads the request against them before it puts one first; a fix can be made there, in a setting or a class attribute. So for the first result of an answer the model worded high or medium, kind other passes. The rules on the path, the rule on a file's preamble, the results below the first and an answer with no pick word are unchanged. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- .../.claude-plugin/plugin.json | 2 +- .../hooks/loom-prompt-pack.mjs | 5 +++- .../claude-code-plugin/lib/prompt-pack.mjs | 28 +++++++++++++------ .../codex-plugin/.codex-plugin/plugin.json | 2 +- .../codex-plugin/hooks/loom-prompt-pack.mjs | 5 +++- integrations/codex-plugin/lib/prompt-pack.mjs | 28 +++++++++++++------ tests/unit/session_content_senders.json | 8 +++--- 7 files changed, 54 insertions(+), 24 deletions(-) diff --git a/integrations/claude-code-plugin/.claude-plugin/plugin.json b/integrations/claude-code-plugin/.claude-plugin/plugin.json index 2fd806675c..57b9395717 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.178", + "version": "1.2.183", "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/loom-prompt-pack.mjs b/integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs index 8f39f9fc8f..57157f525d 100644 --- a/integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs +++ b/integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs @@ -21,7 +21,10 @@ // lib/prompt-pack.mjs). In Python, C and C++, TypeScript and JavaScript, Go, // Rust and Java source a definition passes, and leading comments, imports // and module-level code do not; a unit of any other file passes whatever its -// kind. A test or a file of a test data directory passes when the prompt asks +// kind. Module-level code passes as the first result of an answer the pick +// model worded `high` or `medium` (below): the model read the prompt against +// its candidates and put that unit first. A test or a file of a test data +// directory passes when the prompt asks // for tests or names its file, a document when the prompt asks for // documentation or names its file, and a numbered Python migration, a C or // C++ file in a directory below a directory named `external`, a top-level diff --git a/integrations/claude-code-plugin/lib/prompt-pack.mjs b/integrations/claude-code-plugin/lib/prompt-pack.mjs index 7a162da033..dbe992cb77 100644 --- a/integrations/claude-code-plugin/lib/prompt-pack.mjs +++ b/integrations/claude-code-plugin/lib/prompt-pack.mjs @@ -410,9 +410,10 @@ export function accept(res, minConfidence = null) { // too: the index chunks a pytest fixture and a CI definition written as // assignments as `other`, on paths (`conftest.py`, `ci/`) that are not test // paths, and its ranking applies no kind prior to such a query for that -// reason. A unit of any other file is that file's content and counts whatever -// its kind: a line window of a file the index reads as text, a notebook's -// cells, a component's template, a schema, a shell script, configuration. +// reason. So does the `other` a picked answer puts first (`isPlace`). A unit +// of any other file is that file's content and counts whatever its kind: a +// line window of a file the index reads as text, a notebook's cells, a +// component's template, a schema, a shell script, configuration. const DEFINITION_KINDS = new Set(["function", "class_skeleton", "symbol"]); const DEFINITION_SOURCE_RE = /\.(?:py|pyi|pyw|c|cc|cpp|cxx|h|hpp|hxx|ipp|inl|ts|tsx|mts|cts|js|jsx|mjs|cjs|go|rs|java)$/i; @@ -563,8 +564,17 @@ function namesFile(text, path) { * not made in (`NOT_SOURCE_RES`) only when `text` names it. In source the * hook holds to definitions a place is a definition, whatever names the * file: not a file's preamble and, unless the query asks for tests, not its - * module-level code. */ -function isPlace(unit, asks, text) { + * module-level code. + * + * `firstPick` says the unit is the first result of a picked answer. There + * `other` is a place as a definition is: module-level code, the lines of a + * class outside its methods, a window of a file the index could not parse. + * The rule on definitions is for an answer no model has read. The pick + * model's candidates hold such units, and it read the request against them + * before it put this one first; a fix can be made outside any definition, + * in a setting or a class attribute. The rules on the path hold for that + * unit, and a file's preamble is no place there either. */ +function isPlace(unit, asks, text, firstPick = false) { const path = String(unit.path || ""); if (!path) return false; const named = namesFile(text, path); @@ -574,7 +584,7 @@ function isPlace(unit, asks, text) { if (!named) return false; } else if (!named && ((matches(DOCUMENT_RES) && !asks.docs) || matches(NOT_SOURCE_RES))) return false; if (DEFINITION_KINDS.has(unit.kind) || !DEFINITION_SOURCE_RE.test(path)) return true; - return asks.tests && unit.kind === "other"; + return (asks.tests || firstPick) && unit.kind === "other"; } const firstLine = (unit) => Number(unit.start_line || 0); @@ -628,11 +638,13 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; const prompt = String(text || ""); const results = (res?.results || []).slice(0, picked ? cap : undefined); - if (picked && results.length && !isPlace(results[0], asks, prompt)) return []; + // Of a picked answer the reply proves one unit a pick, the first: it marks none below it. + const place = (unit) => isPlace(unit, asks, prompt, picked && unit === results[0]); + if (picked && results.length && !place(results[0])) return []; const seen = new Set(); const ranked = results.filter((unit) => { const pointer = pointerOf(unit); - if (seen.has(pointer) || !isPlace(unit, asks, prompt)) return false; + if (seen.has(pointer) || !place(unit)) return false; seen.add(pointer); return true; }); diff --git a/integrations/codex-plugin/.codex-plugin/plugin.json b/integrations/codex-plugin/.codex-plugin/plugin.json index c23952753b..b7f4c3e924 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.178", + "version": "1.2.183", "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/hooks/loom-prompt-pack.mjs b/integrations/codex-plugin/hooks/loom-prompt-pack.mjs index 8f39f9fc8f..57157f525d 100644 --- a/integrations/codex-plugin/hooks/loom-prompt-pack.mjs +++ b/integrations/codex-plugin/hooks/loom-prompt-pack.mjs @@ -21,7 +21,10 @@ // lib/prompt-pack.mjs). In Python, C and C++, TypeScript and JavaScript, Go, // Rust and Java source a definition passes, and leading comments, imports // and module-level code do not; a unit of any other file passes whatever its -// kind. A test or a file of a test data directory passes when the prompt asks +// kind. Module-level code passes as the first result of an answer the pick +// model worded `high` or `medium` (below): the model read the prompt against +// its candidates and put that unit first. A test or a file of a test data +// directory passes when the prompt asks // for tests or names its file, a document when the prompt asks for // documentation or names its file, and a numbered Python migration, a C or // C++ file in a directory below a directory named `external`, a top-level diff --git a/integrations/codex-plugin/lib/prompt-pack.mjs b/integrations/codex-plugin/lib/prompt-pack.mjs index 7a162da033..dbe992cb77 100644 --- a/integrations/codex-plugin/lib/prompt-pack.mjs +++ b/integrations/codex-plugin/lib/prompt-pack.mjs @@ -410,9 +410,10 @@ export function accept(res, minConfidence = null) { // too: the index chunks a pytest fixture and a CI definition written as // assignments as `other`, on paths (`conftest.py`, `ci/`) that are not test // paths, and its ranking applies no kind prior to such a query for that -// reason. A unit of any other file is that file's content and counts whatever -// its kind: a line window of a file the index reads as text, a notebook's -// cells, a component's template, a schema, a shell script, configuration. +// reason. So does the `other` a picked answer puts first (`isPlace`). A unit +// of any other file is that file's content and counts whatever its kind: a +// line window of a file the index reads as text, a notebook's cells, a +// component's template, a schema, a shell script, configuration. const DEFINITION_KINDS = new Set(["function", "class_skeleton", "symbol"]); const DEFINITION_SOURCE_RE = /\.(?:py|pyi|pyw|c|cc|cpp|cxx|h|hpp|hxx|ipp|inl|ts|tsx|mts|cts|js|jsx|mjs|cjs|go|rs|java)$/i; @@ -563,8 +564,17 @@ function namesFile(text, path) { * not made in (`NOT_SOURCE_RES`) only when `text` names it. In source the * hook holds to definitions a place is a definition, whatever names the * file: not a file's preamble and, unless the query asks for tests, not its - * module-level code. */ -function isPlace(unit, asks, text) { + * module-level code. + * + * `firstPick` says the unit is the first result of a picked answer. There + * `other` is a place as a definition is: module-level code, the lines of a + * class outside its methods, a window of a file the index could not parse. + * The rule on definitions is for an answer no model has read. The pick + * model's candidates hold such units, and it read the request against them + * before it put this one first; a fix can be made outside any definition, + * in a setting or a class attribute. The rules on the path hold for that + * unit, and a file's preamble is no place there either. */ +function isPlace(unit, asks, text, firstPick = false) { const path = String(unit.path || ""); if (!path) return false; const named = namesFile(text, path); @@ -574,7 +584,7 @@ function isPlace(unit, asks, text) { if (!named) return false; } else if (!named && ((matches(DOCUMENT_RES) && !asks.docs) || matches(NOT_SOURCE_RES))) return false; if (DEFINITION_KINDS.has(unit.kind) || !DEFINITION_SOURCE_RE.test(path)) return true; - return asks.tests && unit.kind === "other"; + return (asks.tests || firstPick) && unit.kind === "other"; } const firstLine = (unit) => Number(unit.start_line || 0); @@ -628,11 +638,13 @@ export function places(res, { query, text = query, cap = 3, picked = false } = { const asks = { tests: asksForTests(query), docs: asksForDocs(query) }; const prompt = String(text || ""); const results = (res?.results || []).slice(0, picked ? cap : undefined); - if (picked && results.length && !isPlace(results[0], asks, prompt)) return []; + // Of a picked answer the reply proves one unit a pick, the first: it marks none below it. + const place = (unit) => isPlace(unit, asks, prompt, picked && unit === results[0]); + if (picked && results.length && !place(results[0])) return []; const seen = new Set(); const ranked = results.filter((unit) => { const pointer = pointerOf(unit); - if (seen.has(pointer) || !isPlace(unit, asks, prompt)) return false; + if (seen.has(pointer) || !place(unit)) return false; seen.add(pointer); return true; }); diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index 5ff93acde6..85223d140f 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -390,14 +390,14 @@ "integrations/claude-code-plugin/hooks/loom-code-shunt.mjs": "f4f761e9f5ed207c8cf4abd6759c1401f9354cddcae2b9065bda9835d778f04b", "integrations/claude-code-plugin/hooks/loom-flush.mjs": "a7634c8a3115aa98f0d7f5d098469cc3a87af4018fb2737c1a90fd27fc19c6e0", "integrations/claude-code-plugin/hooks/loom-namespace-health.mjs": "5f2bd718a88587c5f66b9823317bc77c18ce6a124f0602368b254d2c8c733ddb", - "integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs": "f9bf11cd98b0ca8ad110fe2db631f7af9ab9ce94ca07ab88a603128f0bdebdc6", + "integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs": "5e3552a6035df2ab8603f4849cb0b1be330fde49340135f9af9b4b6a4f434fbb", "integrations/claude-code-plugin/hooks/loom-session-start.mjs": "31ba0130495c6cbd40a3e4e673d9709deafb0cefb0b655b117d22a2437502b78", "integrations/claude-code-plugin/lib/collections-line.mjs": "4415df00d8af1cbb64f5bc25fa1ba1176433b122c1ae35f809b3981f4439c8c9", "integrations/claude-code-plugin/lib/first-session.mjs": "ea5c41ac14f173aa81c8fefc894d72a6661be66e242d0b614f502a0de98b8646", "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "33b83b0977c4a39d11bf0e9de44bc6bccd6c2bfef56f1639a26b54e14a6b7f4c", "integrations/claude-code-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/claude-code-plugin/lib/prompt-pack.mjs": "5a4583c0792984a5d751b9aa02b896913445f80ba4a3860df1d62bf55676b673", + "integrations/claude-code-plugin/lib/prompt-pack.mjs": "7ef235367952f0b2f94329cd3a4af4b1cf06a21e84766a7e8d8596742ed51a17", "integrations/claude-code-plugin/lib/repo-scope.mjs": "1fe69b8ecaf5637dc778fb1c8593336afc74d5029f5487b9419f87bc832dd07c", "integrations/claude-code-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/claude-code-plugin/lib/session-start.mjs": "60675fae31105740885c3b76a34f50e7d18e31447d792bbea5e7c03fc1b30627", @@ -405,14 +405,14 @@ "integrations/codex-plugin/hooks/loom-code-shunt.mjs": "f4f761e9f5ed207c8cf4abd6759c1401f9354cddcae2b9065bda9835d778f04b", "integrations/codex-plugin/hooks/loom-flush.mjs": "a7634c8a3115aa98f0d7f5d098469cc3a87af4018fb2737c1a90fd27fc19c6e0", "integrations/codex-plugin/hooks/loom-namespace-health.mjs": "5f2bd718a88587c5f66b9823317bc77c18ce6a124f0602368b254d2c8c733ddb", - "integrations/codex-plugin/hooks/loom-prompt-pack.mjs": "f9bf11cd98b0ca8ad110fe2db631f7af9ab9ce94ca07ab88a603128f0bdebdc6", + "integrations/codex-plugin/hooks/loom-prompt-pack.mjs": "5e3552a6035df2ab8603f4849cb0b1be330fde49340135f9af9b4b6a4f434fbb", "integrations/codex-plugin/hooks/loom-session-start.mjs": "31ba0130495c6cbd40a3e4e673d9709deafb0cefb0b655b117d22a2437502b78", "integrations/codex-plugin/lib/collections-line.mjs": "4415df00d8af1cbb64f5bc25fa1ba1176433b122c1ae35f809b3981f4439c8c9", "integrations/codex-plugin/lib/first-session.mjs": "ea5c41ac14f173aa81c8fefc894d72a6661be66e242d0b614f502a0de98b8646", "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "33b83b0977c4a39d11bf0e9de44bc6bccd6c2bfef56f1639a26b54e14a6b7f4c", "integrations/codex-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/codex-plugin/lib/prompt-pack.mjs": "5a4583c0792984a5d751b9aa02b896913445f80ba4a3860df1d62bf55676b673", + "integrations/codex-plugin/lib/prompt-pack.mjs": "7ef235367952f0b2f94329cd3a4af4b1cf06a21e84766a7e8d8596742ed51a17", "integrations/codex-plugin/lib/repo-scope.mjs": "1fe69b8ecaf5637dc778fb1c8593336afc74d5029f5487b9419f87bc832dd07c", "integrations/codex-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/codex-plugin/lib/session-start.mjs": "60675fae31105740885c3b76a34f50e7d18e31447d792bbea5e7c03fc1b30627", From 3d37f6694c0e01d89b3d6b6fd1645c016ade2206 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 06:38:15 +0530 Subject: [PATCH 3/6] The hook notes, the Claude Code page and the pointers guide state the place test for a picked answer's first result Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 10 ++++++++-- docs/guides/issue-code-pointers.md | 4 ++++ integrations/claude-code-plugin/README.md | 2 +- integrations/claude-code-plugin/hooks/HOOKS.md | 9 ++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index 5bb4a477a0..66594e1ecb 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -691,7 +691,13 @@ file lifts the rule on its path, not the rule on definitions. A test counts when request asks for tests or the prompt names the test's file. For a request that asks for tests module-level code, and a unit of a source file the index could not parse, count too: a pytest fixture in `conftest.py` and a CI definition written as assignments are -module-level code outside any test directory. The hook reads whether a request asks for +module-level code outside any test directory. The same units count as the first result +of a [picked answer](#model-picked-pointers-for-a-bug-report), as do the lines of a +class outside its methods, which the index chunks as it chunks module-level code. The +pick model's candidates hold such units, and it read the request against them before it +put that one first; a fix can be made outside any definition, in a setting or a class +attribute. The results below the first are held to definitions: the reply marks none of +them as a pick. The hook reads whether a request asks for tests as the search ranking does: from every search term (a word or a part of an identifier) of a request of at most 48 terms, and from the first 16 of a longer one, so an issue that names a test where the fault showed does not ask for tests. Whether a @@ -1077,7 +1083,7 @@ The wiring is `hooks/hooks.json`; `hooks/HOOKS.md` has per-hook notes. | Event | Script | Effect | Off switch | | ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | | SessionStart | `loom-session-start.mjs` | one budgeted `context.pack` primer (working-memory note, profile, the session's memory stack, recent runs with `LOOM_CONTEXT_RUNS`; and the memories, decisions and procedures a search for the project finds or, where a new or cleared conversation's prompts get the recall, the pinned and newest ones, listed), one line naming an indexed checkout's code namespace and the repository's memory tag (left out in a new session whose MCP connection carries the checkout: the server then applies both), a line naming the project's saved session briefs, a task-inbox line (`task.counts`), a few lines naming the collections the token can read (`collection.list`), and a line when [the instruction block](#the-instruction-block) needs setup | `LOOM_INJECT_CONTEXT=false`, `LOOM_CODE_MAP=false`, `LOOM_TASK_INBOX_LINE=off`, `LOOM_COLLECTIONS_LINE=off`, `LOOM_SETUP_LINE=off` | -| UserPromptSubmit | `loom-prompt-pack.mjs` | no request with `prompt_pack` off; at its default no prompt text unless this Loom holds the checkout's own repository ([what a prompt gets](#what-a-prompt-gets)); otherwise up to three `code.search` pointers for the prompt, only when the index rates its answer low-risk (or it reaches `LOOM_PROMPT_PACK_MIN_CONF`) and then only the answer's places to edit, one pointer per place: a definition, a unit of a file the hook does not hold to definitions, a document or a test when the prompt names it or asks for documentation or tests, a Python migration or a release script only if named, and module-level code when it asks for tests; below them the test line for a pointer whose definition the prompt names ([the test gate](#the-test-gate)) | off unless `prompt_pack` or `LOOM_PROMPT_PACK=on`; `LOOM_PROMPT_CONTEXT=off` | +| UserPromptSubmit | `loom-prompt-pack.mjs` | no request with `prompt_pack` off; at its default no prompt text unless this Loom holds the checkout's own repository ([what a prompt gets](#what-a-prompt-gets)); otherwise up to three `code.search` pointers for the prompt, only when the index rates its answer low-risk (or it reaches `LOOM_PROMPT_PACK_MIN_CONF`) and then only the answer's places to edit, one pointer per place: a definition, a unit of a file the hook does not hold to definitions, a document or a test when the prompt names it or asks for one, a Python migration or a release script only if named, and module-level code when it asks for tests or as a first pick; below them the test line for a pointer whose definition the prompt names ([the test gate](#the-test-gate)) | off unless `prompt_pack` or `LOOM_PROMPT_PACK=on`; `LOOM_PROMPT_CONTEXT=off` | | UserPromptSubmit | `loom-prompt-recall.mjs` | one bounded `context.pack` recall for the prompt (memories, decisions, procedures), injected only when memory does not abstain: whole records, and none of code as it was before a commit the checkout already has; of a record linked to a file of the checkout that the prompt does not name, one line: its key and the file | `LOOM_PROMPT_RECALL=first` (default) / `on` / `off`; `LOOM_PROMPT_CONTEXT=off` | | UserPromptSubmit | `loom-run.mjs` | opens the session's run (`run.begin`, `run_id = cc-`, goal = the first prompt); the prompt does not wait for it | `LOOM_RUN_LEDGER=off` | | PreToolUse (Read, Grep; Bash for a command that runs `gh`) | `loom-code-shunt.mjs` | the code shunt and the tracker shunt ([next section](#the-code-shunt)) | `LOOM_CODE_SHUNT=off`, `LOOM_TRACKER_SHUNT=off` | diff --git a/docs/guides/issue-code-pointers.md b/docs/guides/issue-code-pointers.md index f16851da7a..cd8ca2a124 100644 --- a/docs/guides/issue-code-pointers.md +++ b/docs/guides/issue-code-pointers.md @@ -215,6 +215,10 @@ What the plugins do and the SDKs do not: `Cause (a candidate a model wrote from the indexed code, not checked): `. An SDK's answer has no pick and so no sentence: its block ends with its last pointer. +- **Count a first pick outside the definitions as a place.** The first result of an + answer the pick model words `high` or `medium` is a place also when it is module-level + code or the lines of a class outside its methods. An SDK's answer has no pick, so the + rule for its first result is the rule for every result. - **The install's options.** The test line under the pointers reads the checkout, and `LOOM_PROMPT_PACK_MIN_CONF` changes the gate. The SDK method has the default gate and no test line. diff --git a/integrations/claude-code-plugin/README.md b/integrations/claude-code-plugin/README.md index d637b47eb4..40c5fed5d7 100644 --- a/integrations/claude-code-plugin/README.md +++ b/integrations/claude-code-plugin/README.md @@ -285,7 +285,7 @@ the duplicate, run `claude mcp remove -s user`. | `PostToolUse` (Bash / PowerShell) | `loom-test-gate.mjs` | **A changed file's own test is named when the file changes.** After a shell command in a loom-indexed repo, asks `code.test_gate` about each file the command changed (a dirty path it names, written since the session began) and, for a file that has a test of its own, attaches its command and what the index knows of it: `Loom test for src/router.py: .venv/bin/python -m pytest -q -rf tests/test_router.py`, then `It is the one test file named for that file.` and what the checkout proves of the command. Once per file and once per test per session, on the tool result, so it costs no model request; an edit tool's call gets the same line from `loom-blast-radius.mjs`. A file with no such test, a runner the checkout does not configure, a comment-only change and a prompt that ruled a test run out get nothing, and a command that only reads (`grep`, `cat`, `sed -n`, `git diff`) starts no git process and asks nothing (**Tests at edit time**, below). `LOOM_TEST_GATE=off` disables; `LOOM_TEST_GATE_DEPTH` sets the hops (1–3). | | `PostToolUse`, `PostToolUseFailure` (Bash) | `loom-test-report.mjs` | **Why a test failed, on the run whose output was cut.** In a checkout that configures pytest, SessionStart adds its result-file option to `PYTEST_ADDOPTS` for the session's shell commands, so every pytest run writes a private result file. After a test command whose visible output names no failure's reason (`pytest ... \| tail -3`), the hook adds a digest of that file to the tool result: the totals, up to three groups of failures by message, each with its first test and where it was raised; at most 700 characters. No request and nothing stored (**The test report**, below). `LOOM_TEST_REPORT=off` disables. | | `UserPromptSubmit` | `loom-prompt-recall.mjs` | **Default `first`**: one bounded recall on the first qualifying prompt of a session, including empty or abstaining answers. Clear named code-only questions skip default recall without consuming the attempt; mixed memory requests still qualify. `LOOM_PROMPT_RECALL=on` (or the install option `prompt_recall`) for every prompt, `off` to disable; `LOOM_PROMPT_CONTEXT=off` disables it too ([what a prompt gets](#what-a-prompt-gets)). One `context.pack` per prompt restricted to `memories`, `decisions`, `procedures` with the prompt as the query; injects the records the session has not seen (each plane's under its tag; memories that answer alone under none), only when memory is not abstaining and `retrieval_confidence ≥ 0.5`, whole records within 1,600 chars (`LOOM_PROMPT_RECALL_MAX_CHARS`; one that does not fit is left out; a block's only record that the pack cut, or the first when none fits, is cut at its last whole sentence and names the call that reads it whole, the one the server's mark on the line names, or else the key to read it whole by). A record of code as it was before a commit the checkout's `HEAD` already has is left out, and a fix record whose commit it has is added as one line that names the commit. A record linked to a file of the checkout is added as one line, its key and that file, unless the prompt names the file or the definition, or asks memory: `loom-file-context` adds the record's own line after a local read of the file or before an edit of it. With `LOOM_FILE_CONTEXT=off`, or outside a checkout of a repository this Loom indexes, the prompt gets the record whole. The memory-side sibling of the prompt pack: active retrieval — the model gets what memory knows about the prompt without asking — done per prompt, never per tool turn. | -| `UserPromptSubmit` | `loom-prompt-pack.mjs` | Runs where the Loom the session talks to holds the checkout's own repository in its code index (`LOOM_PROMPT_PACK=off` stops it; [what a prompt gets](#what-a-prompt-gets)). One bounded lookup: `code.symbol`, `code.callers` or `code.impact` for an explicit named question, otherwise `code.search` (top 3, no bodies). The repository lookup and the answer share one bound (`LOOM_PROMPT_PACK_TIMEOUT_MS`, 2.5 s; a searched bug report asks for the server's pick and has 6 s): what comes later is skipped. Self-contained requests, local-only changes and explicit memory questions skip code retrieval. Search emits only where the index labels its own answer low-risk (or, with `LOOM_PROMPT_PACK_MIN_CONF` set, from that confidence), without abstention, and sends only the answer's places to edit, one pointer per place: a definition, a unit of a file the hook does not hold to definitions, a document or a test when the prompt names it or asks for documentation or tests, a Python migration or a release script only if named, and module-level code when it asks for tests; its pointers are candidates, and nothing tells the model to stop searching; typed answers preserve ambiguity and static-analysis limits. Named implementation or behavior questions request a whole definition body within 600 server-budget tokens; location/signature requests stay pointer-only and oversized bodies stay elided. No fallback request follows an empty typed answer. Pointers are deduplicated within the current answer, so later prompts can receive changed evidence. Below the pointers of a search answer goes the test gate's line (**Tests at edit time**, below) when a pointer's definition is named in the prompt and its Python file has exactly one test file named after it, in a checkout that configures pytest; it adds no request and a session gets a test once. | +| `UserPromptSubmit` | `loom-prompt-pack.mjs` | Runs where the Loom the session talks to holds the checkout's own repository in its code index (`LOOM_PROMPT_PACK=off` stops it; [what a prompt gets](#what-a-prompt-gets)). One bounded lookup: `code.symbol`, `code.callers` or `code.impact` for an explicit named question, otherwise `code.search` (top 3, no bodies). The repository lookup and the answer share one bound (`LOOM_PROMPT_PACK_TIMEOUT_MS`, 2.5 s; a searched bug report asks for the server's pick and has 6 s): what comes later is skipped. Self-contained requests, local-only changes and explicit memory questions skip code retrieval. Search emits only where the index labels its own answer low-risk (or, with `LOOM_PROMPT_PACK_MIN_CONF` set, from that confidence), without abstention, and sends only the answer's places to edit, one pointer per place: a definition, a unit of a file the hook does not hold to definitions, a document or a test when the prompt names it or asks for one, a Python migration or a release script only if named, and module-level code when it asks for tests or as a first pick; its pointers are candidates, and nothing tells the model to stop searching; typed answers preserve ambiguity and static-analysis limits. Named implementation or behavior questions request a whole definition body within 600 server-budget tokens; location/signature requests stay pointer-only and oversized bodies stay elided. No fallback request follows an empty typed answer. Pointers are deduplicated within the current answer, so later prompts can receive changed evidence. Below the pointers of a search answer goes the test gate's line (**Tests at edit time**, below) when a pointer's definition is named in the prompt and its Python file has exactly one test file named after it, in a checkout that configures pytest; it adds no request and a session gets a test once. | | `Stop` | `loom-test-gate.mjs` | **Off by default; with the `stop_test_gate` option (or `LOOM_TEST_GATE=stop`), holds a session that ran no test since its last code change.** A held stop costs the session at least one more model request, so it is yours to turn on. Then, with uncommitted changes **this session made** in a loom-indexed repo (the dirty paths the transcript shows an edit tool targeted or a shell command named, written since the session began, by the file's modification time; a tree left dirty before the session gates nothing, even when a command reads or runs its files), asks `code.test_gate` what the change obliges — the tests to run, in evidence order with a `run` command when the harness is derivable, and the touched definitions a coverage run measured unexecuted — and blocks the stop **once** per distinct change with a reason that names them. The second stop on the same change passes. Any test run since the last code change lets the stop pass, and nothing is asked (**Stops that pass**, below); with `LOOM_TEST_GATE=block` only a run of the named tests does (**Answered stops**, below). `LOOM_TEST_GATE=off` disables the gate at both events. | | `Stop` | `loom-validate-gate.mjs` | **Compile green before done**: collects the memory keys this session wrote from the transcript, asks `namespace.validate` for a report scoped to exactly those keys, and blocks the stop **once** per distinct key set with the error and warning findings that name them (a conflict you opened, a fact whose `valid_to` has passed, an attestation your edit made stale) and each check's remedy. `info` findings never block; the second stop on the same keys passes. `LOOM_VALIDATE_GATE=off` disables. | | `Stop` | `loom-namespace-health.mjs` | **The store tells you when the namespace is misused**: once per session, one `namespace.audit` over the last day (no samples) for the session's namespace, asked by the first prompt's detached process so that a stop does not wait for it (a stop asks in place only when that process died before its answer); when it carries a critical finding — exact-key reads dwarfing searches, double-encoded values, rows the embedder gave up on, leases in the memory plane — you get **one line** naming the codes and `/loom-optimize`, once per session, at the first stop that finds the verdict, as a block-once reason (the one channel a Stop hook has to the model). Healthy namespace, no token, slow or down server: nothing. The same summary rides `context.pack` as the `namespace_health` section at session start. `LOOM_NAMESPACE_HEALTH=off` disables. | diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index 3e8cfbe8ce..d47f83abe8 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -895,7 +895,14 @@ in. asks for tests module-level code, and a unit of a source file the index could not parse, count too: a pytest fixture in `conftest.py` and a CI definition written as assignments are module-level code outside any test - directory. The hook reads whether a request asks for tests as the search + directory. The same units count as the first result of a picked answer + (**The listwise pick**, below), as do the lines of a class outside its + methods, which the index chunks as it chunks module-level code. The pick + model's candidates hold such units, and it read the request against them + before it put that one first; a fix can be made outside any definition, in + a setting or a class attribute. The results below the first are held to + definitions: the reply marks none of them as a pick. The hook reads whether + a request asks for tests as the search ranking does: from every search term (a word or a part of an identifier) of a request of at most 48 terms, and from the first 16 of a longer one, so an issue that names a test where the fault showed does not ask for tests. From 00226a27f9759034e5f617e2bb2a50ae799c383b Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 07:10:23 +0530 Subject: [PATCH 4/6] The place test's text counts the lines of a class for a tests request and a first pick alike The hook notes and the Claude Code page added the lines of a class outside its methods to the first-pick rule alone. The index chunks them as kind `other`, and one expression passes that kind for a request that asks for tests and for a picked answer's first result, so the text names them among the units both rules share. A first pick of kind `other` in a file the prompt names is sent: the test asserts it for a packaging script and a test file. `isPlace` has one caller, which passes `firstPick`, so the parameter has no default. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 6 +++--- integrations/claude-code-plugin/hooks/HOOKS.md | 6 +++--- integrations/claude-code-plugin/lib/prompt-pack.mjs | 2 +- integrations/claude-code-plugin/tests/prompt-pack.test.mjs | 5 +++++ integrations/codex-plugin/lib/prompt-pack.mjs | 2 +- tests/unit/session_content_senders.json | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index 66594e1ecb..05fdf82c29 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -691,9 +691,9 @@ file lifts the rule on its path, not the rule on definitions. A test counts when request asks for tests or the prompt names the test's file. For a request that asks for tests module-level code, and a unit of a source file the index could not parse, count too: a pytest fixture in `conftest.py` and a CI definition written as assignments are -module-level code outside any test directory. The same units count as the first result -of a [picked answer](#model-picked-pointers-for-a-bug-report), as do the lines of a -class outside its methods, which the index chunks as it chunks module-level code. The +module-level code outside any test directory. The same units, among them the lines of a +class outside its methods (the index chunks them as it chunks module-level code), count +as the first result of a [picked answer](#model-picked-pointers-for-a-bug-report). The pick model's candidates hold such units, and it read the request against them before it put that one first; a fix can be made outside any definition, in a setting or a class attribute. The results below the first are held to definitions: the reply marks none of diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index d47f83abe8..4623888132 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -895,9 +895,9 @@ in. asks for tests module-level code, and a unit of a source file the index could not parse, count too: a pytest fixture in `conftest.py` and a CI definition written as assignments are module-level code outside any test - directory. The same units count as the first result of a picked answer - (**The listwise pick**, below), as do the lines of a class outside its - methods, which the index chunks as it chunks module-level code. The pick + directory. The same units, among them the lines of a class outside its + methods (the index chunks them as it chunks module-level code), count as + the first result of a picked answer (**The listwise pick**, below). The pick model's candidates hold such units, and it read the request against them before it put that one first; a fix can be made outside any definition, in a setting or a class attribute. The results below the first are held to diff --git a/integrations/claude-code-plugin/lib/prompt-pack.mjs b/integrations/claude-code-plugin/lib/prompt-pack.mjs index dbe992cb77..048c638936 100644 --- a/integrations/claude-code-plugin/lib/prompt-pack.mjs +++ b/integrations/claude-code-plugin/lib/prompt-pack.mjs @@ -574,7 +574,7 @@ function namesFile(text, path) { * before it put this one first; a fix can be made outside any definition, * in a setting or a class attribute. The rules on the path hold for that * unit, and a file's preamble is no place there either. */ -function isPlace(unit, asks, text, firstPick = false) { +function isPlace(unit, asks, text, firstPick) { const path = String(unit.path || ""); if (!path) return false; const named = namesFile(text, path); diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index 33774cf9bf..35276da62e 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -383,6 +383,11 @@ test("the first result of a picked answer is a place when it is source outside t ...INTENT.not_source_paths.map((path) => at("other", path, 6, 47)), ]; for (const first of dropped) assert.deepEqual(picks([first, method]), [], `${first.kind} ${first.path}`); + // A prompt that names the file lifts the rule on its path, as for any place. + for (const path of ["setup.py", "tests/test_defaults.py"]) { + const named = at("other", path, 6, 47); + assert.deepEqual(picks([named, method], `${path} sets the wrong mode`), [named, method], path); + } // It is a range as any place is: a definition inside it that the prompt names is the pointer. const source = at("other", "pkg/core/function.py", 1053, 1227); const skeleton = at("class_skeleton", "pkg/core/function.py", 1053, 1172, "Derivative"); diff --git a/integrations/codex-plugin/lib/prompt-pack.mjs b/integrations/codex-plugin/lib/prompt-pack.mjs index dbe992cb77..048c638936 100644 --- a/integrations/codex-plugin/lib/prompt-pack.mjs +++ b/integrations/codex-plugin/lib/prompt-pack.mjs @@ -574,7 +574,7 @@ function namesFile(text, path) { * before it put this one first; a fix can be made outside any definition, * in a setting or a class attribute. The rules on the path hold for that * unit, and a file's preamble is no place there either. */ -function isPlace(unit, asks, text, firstPick = false) { +function isPlace(unit, asks, text, firstPick) { const path = String(unit.path || ""); if (!path) return false; const named = namesFile(text, path); diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index 85223d140f..d74e05c246 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -397,7 +397,7 @@ "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "33b83b0977c4a39d11bf0e9de44bc6bccd6c2bfef56f1639a26b54e14a6b7f4c", "integrations/claude-code-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/claude-code-plugin/lib/prompt-pack.mjs": "7ef235367952f0b2f94329cd3a4af4b1cf06a21e84766a7e8d8596742ed51a17", + "integrations/claude-code-plugin/lib/prompt-pack.mjs": "20d02edf4be6338079c23e4b8c596fdcc878152aece43f2e1ce38687e9650792", "integrations/claude-code-plugin/lib/repo-scope.mjs": "1fe69b8ecaf5637dc778fb1c8593336afc74d5029f5487b9419f87bc832dd07c", "integrations/claude-code-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/claude-code-plugin/lib/session-start.mjs": "60675fae31105740885c3b76a34f50e7d18e31447d792bbea5e7c03fc1b30627", @@ -412,7 +412,7 @@ "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "33b83b0977c4a39d11bf0e9de44bc6bccd6c2bfef56f1639a26b54e14a6b7f4c", "integrations/codex-plugin/lib/namespace-health.mjs": "c8a9aab01f1e996c97643aee7b8f367bf6447f7a6c74dec01a70dc50a0caa182", - "integrations/codex-plugin/lib/prompt-pack.mjs": "7ef235367952f0b2f94329cd3a4af4b1cf06a21e84766a7e8d8596742ed51a17", + "integrations/codex-plugin/lib/prompt-pack.mjs": "20d02edf4be6338079c23e4b8c596fdcc878152aece43f2e1ce38687e9650792", "integrations/codex-plugin/lib/repo-scope.mjs": "1fe69b8ecaf5637dc778fb1c8593336afc74d5029f5487b9419f87bc832dd07c", "integrations/codex-plugin/lib/session-brief.mjs": "3aee492198a400ed0fa5fee733b4a4e04463efcc4d0b22ff760e1b765a76e28b", "integrations/codex-plugin/lib/session-start.mjs": "60675fae31105740885c3b76a34f50e7d18e31447d792bbea5e7c03fc1b30627", From d8f7549ca525660664635056df71b80140c813c8 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 07:25:26 +0530 Subject: [PATCH 5/6] test(plugin): an answer only the pick's word admits sends a first pick that is source outside the definitions Where the risk label holds a picked answer back, the hook sends its first result alone. That result passes the place test as a first pick when it is kind `other`, so the two rules together send one pointer. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- integrations/claude-code-plugin/tests/prompt-pack.test.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index 6ff7f07a02..2f96b8c626 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -419,6 +419,8 @@ test("the first result of a picked answer is a place when it is source outside t /\n- pkg\/conf\/defaults\.py:305-307\n- pkg\/files\/storage\.py:215-217 Storage::file_mode$/, word, ); + // Where only the word admits the answer, the first pick alone is sent, and it is that unit. + assert.deepEqual(pointerBlock(body, { ...answer(word), retrieval_risk: "medium" }, report).pointers, [setting]); } assert.deepEqual(pointerBlock(body, answer("low"), report), { pointers: [], text: "" }); for (const word of ["", undefined]) From 08b657980107e8485fd9b0f77fcc897e11faf7f5 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sat, 5 Dec 2026 07:50:23 +0530 Subject: [PATCH 6/6] The place test's text states the rule below the first pick as the rule of an answer with no pick Below the first result of a picked answer module-level code is still a place for a request that asks for tests; the text said those results are held to definitions. The test asserts that case, and its unit helper has a name of its own: the file's `at` takes its arguments in another order. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- docs/features/integrations/claude-code.md | 3 +- .../claude-code-plugin/hooks/HOOKS.md | 7 ++-- .../tests/prompt-pack.test.mjs | 32 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/docs/features/integrations/claude-code.md b/docs/features/integrations/claude-code.md index 098f78755a..f3faf43cb9 100644 --- a/docs/features/integrations/claude-code.md +++ b/docs/features/integrations/claude-code.md @@ -700,7 +700,8 @@ class outside its methods (the index chunks them as it chunks module-level code) as the first result of a [picked answer](#model-picked-pointers-for-a-bug-report). The pick model's candidates hold such units, and it read the request against them before it put that one first; a fix can be made outside any definition, in a setting or a class -attribute. The results below the first are held to definitions: the reply marks none of +attribute. A result below the first counts as in an answer with no pick, a definition +always and such a unit only for a request that asks for tests: the reply marks none of them as a pick. The hook reads whether a request asks for tests as the search ranking does: from every search term (a word or a part of an identifier) of a request of at most 48 terms, and from the first 16 of a longer one, so diff --git a/integrations/claude-code-plugin/hooks/HOOKS.md b/integrations/claude-code-plugin/hooks/HOOKS.md index 056b00102d..b2e7e0abcd 100644 --- a/integrations/claude-code-plugin/hooks/HOOKS.md +++ b/integrations/claude-code-plugin/hooks/HOOKS.md @@ -902,9 +902,10 @@ in. the first result of a picked answer (**The listwise pick**, below). The pick model's candidates hold such units, and it read the request against them before it put that one first; a fix can be made outside any definition, in - a setting or a class attribute. The results below the first are held to - definitions: the reply marks none of them as a pick. The hook reads whether - a request asks for tests as the search + a setting or a class attribute. A result below the first counts as in an + answer with no pick, a definition always and such a unit only for a request + that asks for tests: the reply marks none of them as a pick. The hook reads + whether a request asks for tests as the search ranking does: from every search term (a word or a part of an identifier) of a request of at most 48 terms, and from the first 16 of a longer one, so an issue that names a test where the fault showed does not ask for tests. diff --git a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs index 2f96b8c626..fbcb19f623 100644 --- a/integrations/claude-code-plugin/tests/prompt-pack.test.mjs +++ b/integrations/claude-code-plugin/tests/prompt-pack.test.mjs @@ -364,40 +364,42 @@ test("a picked answer lists the first pick's file first", () => { }); test("the first result of a picked answer is a place when it is source outside the definitions", () => { - const at = (kind, path, start, end, symbol = "") => ({ path, start_line: start, end_line: end, symbol, kind }); + const chunk = (kind, path, start, end, symbol = "") => ({ path, start_line: start, end_line: end, symbol, kind }); const query = "uploaded files get the wrong permissions"; const picks = (results, text = query) => places({ results }, { query, text, picked: true }); - const setting = at("other", "pkg/conf/defaults.py", 305, 307); - const method = at("function", "pkg/files/storage.py", 215, 217, "Storage::file_mode"); + const setting = chunk("other", "pkg/conf/defaults.py", 305, 307); + const method = chunk("function", "pkg/files/storage.py", 215, 217, "Storage::file_mode"); // The pick model read the candidates and put module-level code first: it is sent, and the places below it. assert.deepEqual(picks([setting, method]), [setting, method]); for (const path of INTENT.definition_source_paths) assert.deepEqual(picks([unit("other", path)]), [unit("other", path)], path); - // An answer no model ordered is held to definitions. + // An answer no model ordered keeps the plain rule: for a request that asks for no test, definitions. assert.deepEqual(places({ results: [setting, method] }, { query }), [method]); - // The first result only: the same code below it is no place. - const constant = at("other", "pkg/files/storage.py", 1, 9); + // The first result only: below it the plain rule decides, and the same code is a place for a tests request alone. + const constant = chunk("other", "pkg/files/storage.py", 1, 9); assert.deepEqual(picks([setting, constant, method]), [setting, method]); assert.deepEqual(picks([method, setting]), [method]); + const fixture = "which pytest fixture builds the temporary database"; + assert.deepEqual(places({ results: [method, setting] }, { query: fixture, picked: true }), [method, setting]); // Every other rule of the place test holds for the first result: its kind, and a path the prompt does not name. const dropped = [ - at("file_header", "pkg/conf/defaults.py", 1, 4), - at("comment_block", "pkg/conf/defaults.py", 1, 4), + chunk("file_header", "pkg/conf/defaults.py", 1, 4), + chunk("comment_block", "pkg/conf/defaults.py", 1, 4), { path: "pkg/conf/defaults.py", start_line: 305, end_line: 307 }, - at("other", "", 305, 307), - at("other", "tests/test_defaults.py", 305, 307), - ...INTENT.not_source_paths.map((path) => at("other", path, 6, 47)), + chunk("other", "", 305, 307), + chunk("other", "tests/test_defaults.py", 305, 307), + ...INTENT.not_source_paths.map((path) => chunk("other", path, 6, 47)), ]; for (const first of dropped) assert.deepEqual(picks([first, method]), [], `${first.kind} ${first.path}`); // A prompt that names the file lifts the rule on its path, as for any place. for (const path of ["setup.py", "tests/test_defaults.py"]) { - const named = at("other", path, 6, 47); + const named = chunk("other", path, 6, 47); assert.deepEqual(picks([named, method], `${path} sets the wrong mode`), [named, method], path); } // It is a range as any place is: a definition inside it that the prompt names is the pointer. - const source = at("other", "pkg/core/function.py", 1053, 1227); - const skeleton = at("class_skeleton", "pkg/core/function.py", 1053, 1172, "Derivative"); - const create = at("function", "pkg/core/function.py", 1268, 1383, "Derivative::__new__"); + const source = chunk("other", "pkg/core/function.py", 1053, 1227); + const skeleton = chunk("class_skeleton", "pkg/core/function.py", 1053, 1172, "Derivative"); + const create = chunk("function", "pkg/core/function.py", 1268, 1383, "Derivative::__new__"); assert.deepEqual(picks([source, skeleton, create], "Derivative reports the wrong kind"), [skeleton, create]); assert.deepEqual(picks([source, skeleton, create]), [source, create]);