Skip to content

A pointer block lists the first-ranked file's place first - #2104

Merged
zlareb1 merged 7 commits into
mainfrom
fix/pointer-first-file-leads
Dec 3, 2026
Merged

zlareb1 merged 7 commits into
mainfrom
fix/pointer-first-file-leads

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Related: #2015

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):

The code pointers a prompt gets list the highest-ranked place in the first search result's file first, in the plugins' prompt hook and the Python and TypeScript SDKs. Plugin 1.2.165.

Why

places() listed the pointers by the rank of the unit sent for each. Three of its own rules move a file's pointer down from the rank the search gave the file:

  • A long class is sent as a method. A first-ranked class of more than 200 lines gives way to the first method the answer holds inside it. With the class at rank 1, a function of another file at rank 2 and the method at rank 3, the block listed the other file's function first and the method second.
  • A class is sent as the method the prompt names. A first-ranked class of any length gives way to the innermost definition inside it that the prompt names. With the class at rank 1, a function of another file at rank 2 and the named method at rank 3, the block listed the other file's function first.
  • A first result that is no place sends nothing. With a file's leading comments at rank 1, a function of another file at rank 2 and a function of the first file at rank 3, the block listed the other file first.

In all three, the file the search ranked first had a place in the block and was not on its first line.

places() now runs its rules as before and then moves the first of the chosen places whose path is the first result's path to the front. The other places keep rank order.

The rule holds for a picked answer (LOOM_PROMPT_PACK_PICK) as for any other. Its 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 another file's unit between them was listed first. The pointers of a picked answer are the same ones in the new order: its results are cut to the cap before the rules run.

Two limits keep the rule narrow:

  • A first-ranked file with no place leaves the order as it is. The rule does not walk on to the next file.
  • The place test, the choice among a class and its methods, and the cap are not touched. The pointers sent are the same ones, with one exception: when the place moved to the front ranked below the cap in an answer longer than the cap, it takes a line and the last of the others is not listed.

Scope and risk

  • places() in integrations/claude-code-plugin/lib/prompt-pack.mjs, its Codex copy, _places in sdk/python/loom/pointers.py and places in sdk/typescript/src/pointers.ts: three lines at the return of each JavaScript and TypeScript copy, four in Python. The four share integrations/claude-code-plugin/tests/fixtures/pointer-block.json, whose cases each one's tests run.
  • Docs: one rule sentence in docs/guides/issue-code-pointers.md, hooks/HOOKS.md and docs/features/integrations/claude-code.md.
  • Left alone: the request (searchBody, top_k, the token budget), the hook file, isPlace, pickHolds, the pick request, the block's lead line and shape, the cap of three, the SDK signatures and the server.
  • Risk: when the search ranks a wrong file first and that file has a place in the block, that place is now listed ahead of a right one. No place is dropped for it unless the answer is longer than the cap, as above.
  • The test line under the pointers is for the first listed pointer whose definition the prompt names (checkPointer), so it follows the new order. 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.
  • The prompt hook and the SDK pointer blocks list only the first place when the prompt names none of them #2015 rewrites the same lines of places() in all copies. Whichever lands second merges by hand. Under its rule (the first pointer only, when the prompt names none of them) this order decides which pointer is kept.

Compatibility, rollout and rollback

  • Wire: none. No op, field or default changes, and the request the hook and the SDKs send is the same.
  • Operator steps: none.
  • Rollback: revert the pull request. Nothing is stored.

Tests

Five cases added to integrations/claude-code-plugin/tests/fixtures/pointer-block.json, run by the plugin's tests, tests/unit/test_sdk_pointer_block.py and sdk/typescript/src/pointers.test.ts:

  • a first-ranked long class, another file's function, then a method of that class: the method is listed first;
  • a first result that is no place, another file's function, then a function of the first file: that function is listed first;
  • a first-ranked file with no place: the order is the rank order;
  • a place of the first-ranked file ranked below the cap in a longer answer: it is listed first and the last of the others is not listed;
  • two places in the first-ranked file: the higher-ranked one is listed first, though it starts on a later line.

One test added to prompt-pack.test.mjs: in a picked answer, a first-ranked long class, another file's function and a method of that class list the method first. The first fixture case holds the same for an unpicked answer.

One case added to prompt-pack-hook.test.mjs, run through the hook: a prompt names a definition in each of two files that each have one test, and the answer is a first result that is no place, the other file's function, then the first file's function. The first file's function is listed first and the test 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.

test_an_issue_gets_the_places_it_is_about in tests/unit/test_sdk_pointer_block.py keeps its rank-order assertion: the lead rule moves nothing in its answer. Only its comment changed.

Before the change, with sdk/python/loom/pointers.py and lib/prompt-pack.mjs of main under the tests of this branch: tests/unit/test_sdk_pointer_block.py fails the first, second, fourth and fifth new fixture case (4 failed, 97 passed), and node --test integrations/claude-code-plugin/tests/prompt-pack.test.mjs fails its shared-fixture test and the new picked-answer test (2 of 34). The third case passes before and after: it pins that the rule does not walk on to the next file. The TypeScript suite was first run after the change.

After the change:

  • node --test integrations/claude-code-plugin/tests/prompt-pack.test.mjs integrations/claude-code-plugin/tests/prompt-pack-hook.test.mjs: 123 pass.
  • pytest tests/unit/test_sdk_pointer_block.py tests/unit/test_session_content_senders.py tests/unit/test_agent_instructions.py tests/unit/test_doc_links.py tests/unit/test_public_copy.py tests/unit/test_codex_plugin.py tests/unit/test_plugin_code_query_contract.py: 655 pass.
  • npm --prefix sdk/typescript run check: 792 tests pass, no type errors. npm --prefix sdk/typescript run check:dist ran before main was merged in.
  • No block of the cases that were in the fixture changes.
  • make format, make lint (every generator's --check, the Codex copy included) and make typecheck: pass. claude plugin validate integrations/claude-code-plugin --profile directory --strict and node --check on both copies of prompt-pack.mjs: pass.
  • node --test integrations/claude-code-plugin/tests/*.test.mjs: 1,148 pass and 7 skip before main was merged in. On the pushed head one run gave 1,150 pass, 7 skip and one failed timing test of file-context-read.test.mjs on a loaded machine; that file passes when run alone and does not call places().

Not run locally, left to CI: the full unit suite, the Python SDK wheel steps and the integration suite. No benchmark was run and no provider was called.

make format on the merged head also rewraps one line of frontend/src/views/assistant/Chat.test.tsx, a file this pull request does not touch. That change is not included here: the format check fails on that line on main too, and #2107 formats it.

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. The agent wrote the fixture cases, saw them fail, made the change in the four copies and ran the checks above; no human has reviewed the diff yet.

  • 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.
  • 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.
  • 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


Note

Medium Risk
Reordering can surface a wrong-file pointer first when retrieval ranks the wrong file at #1; cap can drop the last pointer if the promoted one was below the limit.

Overview
Code pointer blocks now lead with the first search hit’s file. After the existing place-selection rules (places() / _places), the highest-ranked pointer whose path matches the first search result’s file is moved to the top of the list. Other entries keep index rank order; if that file has no place, ordering is unchanged.

The same logic ships in Claude Code and Codex prompt-pack.mjs, Python loom/pointers.py, and TypeScript pointers.ts. Docs and hook copy describe the new ordering. Plugin version is 1.2.165. Shared fixture cases and hook/SDK tests cover long-class-as-method, non-place first results, cap overflow, and pytest test-line attachment following the first listed named pointer.

Reviewed by Cursor Bugbot for commit 02f23d4. Bugbot is set up for automated code reviews on this repo. Configure here.

zlareb1 and others added 2 commits December 4, 2026 00:12
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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Both plugin manifests keep 1.2.165, above the 1.2.162 main holds.

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

vercel Bot commented Dec 3, 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 3, 2026 8:36pm UTC
loom-telemetry Ready Ready Preview Dec 3, 2026 8:36pm UTC

Request Review

zlareb1 and others added 5 commits December 4, 2026 00:59
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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
"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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…thing

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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
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 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 46a5370 into main Dec 3, 2026
86 of 89 checks passed
zlareb1 added a commit that referenced this pull request Dec 3, 2026
Main took plugin 1.2.165 (#2104) and another open PR now holds 1.2.167;
both manifests move to 1.2.169, which no open PR uses. The sender pins
are renewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
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