Skip to content

The prompt hook sends a picked answer's pointers when the first pick is module-level code or the lines of a class outside its methods - #2192

Merged
zlareb1 merged 8 commits into
mainfrom
fix/picked-module-level-place
Dec 5, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
fix/picked-module-level-place

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Related: #2172

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

For a bug report whose pointers the server's pick model chose and worded high or medium, the coding-agent plugins' prompt hook sends the pointers when the model's first pick is module-level code or the lines of a class outside its methods. Unless the report asks for tests, such an answer sent nothing before. Plugin 1.2.183.

Why

In Python, C and C++, TypeScript and JavaScript, Go, Rust and Java source the hook's place test (isPlace in lib/prompt-pack.mjs) passes definitions: kind function, class_skeleton or symbol. The index chunks everything else in such a file that is not its preamble as kind other: module-level code, the lines of a class outside its methods, a window of a file it could not parse. Kind other passes for one kind of request only, one that asks for tests (a word such as test, regression or ci among its terms), because a fixture and a CI definition are chunked that way. The rule was written for answers ranked by the search alone.

A picked answer adds a second rule: its first result decides, and when that result fails the place test nothing is sent, the definitions below it included. The pick model's instruction lists module-level code among its candidates, and the model reads the request against them before it puts one first. A fix can be made in such code: a setting assigned at module level, a class attribute. When the model picked that code first for a report that does not ask for tests, the kind rule refused it and the first-result rule then dropped the whole answer, so the session got no pointer for a report the model had answered high or medium.

The fix: for the first result of an answer worded high or medium, kind other passes the kind rule. isPlace takes a firstPick argument and places sets it for results[0] of a picked answer.

First result only, not every picked result. Two reasons, both from the code:

  • The reply proves one unit a pick, the first. The server clears pick_confidence on a page whose first unit is not the pick's first (server/code/app/search/window.py), and it marks no unit as a pick. Where the model picked fewer results than the page holds, the search's own ranking follows them, and the hook cannot tell the two apart.
  • The answers this was decided on are those whose first result is such a unit. What a relaxed test does at the ranks below was not counted, so those ranks keep the rule they have.

Applying it to every result would be one expression shorter (picked in place of picked && unit === results[0]) and is not taken for those reasons.

Scope and risk

Touches isPlace and places in integrations/claude-code-plugin/lib/prompt-pack.mjs, the header comment of hooks/loom-prompt-pack.mjs, the generated Codex copies of both, their pins in tests/unit/session_content_senders.json, both plugin manifests (1.2.183), and the text that states the place test: hooks/HOOKS.md, the plugin README's hook table, docs/features/integrations/claude-code.md and docs/guides/issue-code-pointers.md. docs/operations/code-index-operations.md does not state the place test and is unchanged.

Left alone:

  • Every rule on the path. A first pick in a test the request does not ask for, a document, a numbered Python migration, a vendored C or C++ file or a packaging script still sends nothing unless the prompt names the file.
  • Every other kind. A file's preamble (file_header), a comment_block and a unit with no kind are no place as a first pick either.
  • The results below the first. They keep the rule of an answer with no pick: a definition passes, and kind other only for a request that asks for tests.
  • An answer with no pick word and one worded low: picked is false there and firstPick with it.
  • The gate (accept), the caps of three and of one, the cause sentence and the test line.
  • The SDK pointer helpers. They send rerank: "none", get no pick word and have no pick branch. integrations/claude-code-plugin/tests/fixtures/pointer-block.json holds no reply with a pick word and is unchanged, so the three renderers build the same blocks as before.

What could go wrong: an answer that sent nothing sends up to three pointers (one where only the model's word admits it), and the first is a range with no name that can be long. When the model's first pick is wrong, the session reads a wrong pointer where it read none. The block's lead line still calls the pointers candidates. The existing range rules apply to that unit: a definition the answer holds inside it that the prompt names is sent in its place, and a range over 200 lines is listed by its first line and its length.

The hook sends no new request and no new field, and its timing and failure paths are unchanged.

The linked pull request is merged and is in this branch through a merge of main: accept admits an answer worded high or medium at any risk label, and where only the word admits it the hook sends its first result alone. That first result can be such a unit, and the new test asserts that it is sent.

Compatibility, rollout and rollback

  • Wire: none. No op, field or default changes.
  • Operator steps: none. No setting. Clients get the change with plugin 1.2.183.
  • Rollback: revert the commits. Nothing is stored.

Tests

  • node --test integrations/claude-code-plugin/tests/prompt-pack.test.mjs: 40 pass. The new test, "the first result of a picked answer is a place when it is source outside the definitions", is committed alone in the first commit, where it fails with [] for the two expected pointers. It covers each of the held languages' suffixes, the results below the first (for a request that asks for tests and for one that does not), an answer no model ordered, every kind and path rule that still drops a first pick, a first pick in a packaging script and in a test file the prompt names (sent; [] on main), a class-level range with a named definition inside it, and pointerBlock for high, medium, low and no word, at a low risk label and, for high and medium, at a medium one.
  • node --test integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs: 92 pass. The hook, run as a process against a stub server, prints the module-level unit first for high and medium, and for a reply with no word the block without it.
  • node --test --test-concurrency=2 integrations/claude-code-plugin/tests/*.test.mjs: 1251 of 1258 pass, 7 skipped, none failed. At the default concurrency on a loaded machine the tests that bound a hook process's time fail, a different set each run (in file-context-read.test.mjs, session-start.test.mjs, hook-contract.test.mjs and plugin-modes.test.mjs among others); none is in a test file this change touches.
  • node --test integrations/grep-shim/tests/*.test.mjs integrations/cline/tests/*.test.mjs: 46 pass, 1 skipped.
  • make format, make lint, make typecheck with LOOM_ENV_FILE=: clean; agent_plugin_sync --check reports the Codex copies current.
  • pytest tests/unit/test_session_content_senders.py tests/unit/test_codex_plugin.py tests/unit/test_agent_plugin.py tests/unit/test_plugin_code_query_contract.py tests/unit/test_sdk_pointer_block.py tests/unit/test_doc_links.py tests/unit/test_public_copy.py tests/unit/test_agent_instructions.py: 668 pass.
  • node --check over the plugins' hooks and lib/: clean.
  • claude plugin validate integrations/claude-code-plugin --profile directory --strict fails here on one warning about the bin/ folder, which this change does not touch.

The full unit suite, the TypeScript SDK's tests and the integration suite are left to CI.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked: the new test fails before the change and passes after it, the plugin test files above, and the diff of the generated Codex copies against the Claude Code plugin's files.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed. (Not changed.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code

zlareb1 and others added 4 commits December 5, 2026 06:23
…e 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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… 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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… place test for a picked answer's first result

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 2:22am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 2:22am UTC

Request Review

zlareb1 and others added 4 commits December 5, 2026 07:10
… 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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Main's gate change (`accept` admits a picked answer at any risk label, as its
first pick alone) and this branch's place test both stand. The hook table rows
of the plugin README and the Claude Code page carry both texts, the manifests
keep 1.2.183, and the four pins are the merged files' digests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…k 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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…e 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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit f100116 into main Dec 5, 2026
85 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant