Repository navigation
code.symbol's lesson reads go through the sort key and finish within their bound - #1322
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1f47ad2 to
3c99a8a
Compare
|
rebase |
5b6b355 to
ad5b982
Compare
|
@enricoconvento98 is attempting to deploy a commit to the ClickHouse Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @enricoconvento98 , please resolve merge conflicts and mark Ready for Review |
…hin their bound code.symbol returned no lessons on a large deployment: its lesson read ran past code_enrich_timeout_s and was answered with none. Three of its statements read most of their table under FINAL. - The links by anchored_path and former.path: neither column is in the sort key. Their bloom filters select few granules, but FINAL adds every granule of every part whose sort-key range overlaps them. Measured on 1M links in 8 parts: 27 granules widened to 282, 306,176 rows read for 51. - The memory heads current_links reads and the excerpts of the matched memories: both by memory_id, which is not in loom.memory's sort key either, so 176 memories read the whole table (1,009,984 rows each). The links reads now take the keys of every matching version from the index without FINAL, and FINAL reads only those keys and judges each by its newest version: 35,840 rows. The memory reads go by the identity each link was made from, the table's sort key, and keep a row only while that identity still holds the linked memory_id: 70,784 rows each. Every read returns the same rows as before on the same data, including moved, deleted and replaced rows. A memory whose id now sits under another identity than the one its link was made from (a namespace restored into itself under another agent) is no longer found through that link until the link worker relinks it. Related: ClickHouse#644 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claude <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
…rpts than it serves A lessons read that failed or ran past code_enrich_timeout_s was replaced by an empty list, so the answer read the same as a symbol with no linked memories. The first definition now carries lessons_unread: true in that case; a symbol with none, a narrowed token and include_lessons: false still carry nothing. The excerpt read ranked and cut its rows in Python after reading every matched memory. It now orders them in SQL the same way (code that still matches, then pinned, then the most confident) and keeps limit rows, so a file with many linked memories reads only what the answer serves. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claude <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
With no changed code, the excerpt read orders pinned rows by confidence, so the pinned row at 0.2 comes before the pinned row at 0.1. The test expected the reverse; it runs only where the clickhouse binary is installed, which is how the wrong order went unseen. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
…ns test by what it checks A narrowed token makes no lessons read and carries no lessons_unread flag; no test ran code.symbol with a narrowed request. The test that stubbed the lessons read to None was named for a read past its bound, which it does not run; the bound has its own parametrized test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
…t off A symbol that matches several members reads each member's lessons. When one of those reads is cut off or fails, the lessons the other reads returned are still served, and the first definition carries lessons_unread: true, since lessons may be missing. The owning type's lessons, which fill in only when a method has none, are dropped when their read is cut off, like an empty read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
Regenerated with scripts/codegen/sdk_rust_gen.py; the generator also renumbers its default helpers after the new field's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
With matched members, lessons_unread can come with the lessons of the members that were read. The concept page and the field comment no longer say the flag comes instead of lessons. Two comments in symbol.py now say why an owner's cut-off read does not set the flag and what the unread list is for. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Enrico Convento <[email protected]>
ad5b982 to
4f40f08
Compare
|
Rebased on main. The conflict was with the per-member lessons read from #1332. For That makes this PR two changes: the lesson reads by sort key, which fix #644, and the |
zlareb1
left a comment
There was a problem hiding this comment.
The sort-key reads preserve newest-version selection and readable lesson namespaces. The response marks failed or timed-out reads and keeps lessons from matched members whose reads finish.
Checked 343 focused tests with ClickHouse 26.11, 589 scope and statement-corpus tests, and 275 documentation link checks. The Python and TypeScript SDK generators report no drift.
Closes: #644
Changelog category (leave one):
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):
code.symbolreturns a symbol's lessons on large tables again: their reads now go through each table's sort key and finish withincode_enrich_timeout_s. When the lessons read still fails or times out, the first definition carrieslessons_unread: true, so an empty list no longer looks the same as a symbol with no lessons.Why
code.symbolreads a symbol's lessons as a side read bounded bycode_enrich_timeout_s(0.5 s by default). A read that runs past the bound is cancelled and replaced by an empty list, by design, so the core answer never waits on it. On a large deployment every lessons read ran past the bound, and the answer said nothing about it.The reads filtered on columns that are not on the table's sort key:
memory_code_linksbyanchored_pathandformer.path, which have only bloom-filter skip indexes. UnderFINAL,use_skip_indexes_if_final_exact_modewidens the skip index's selection to every granule that may hold another version of the same key: in a test table, 27 of 984 granules became 282, and the read went from 27,648 rows withoutFINALto 306,176 with it.loom.memorybymemory_idalone. Ids are random against the sort key(org, namespace, agent, user_id, session_id, memory_key), so 176 ids touched nearly every granule.The fix reads by sort key instead:
anchored_pathandformer.pathfirst select the matching sort keys with a subquery that does not useFINAL, where the skip index narrows fully, and then readFINALonly on those keys. The outer read still judges each key by its newest version, so results do not change.namespaces_of_idinserver/memory/store/reads.pyalready uses this pattern.(namespace, agent, user_id, session_id, memory_key, memory_id), the sort key plus the id, and keep a row only while that identity still holds the linked id.LIMIT) instead of reading every matched memory and ranking in Python, so a file with many linked memories reads only the rows the answer serves.Rejected alternatives:
use_skip_indexes_if_final_exact_mode:FINALcould return a superseded version.anchored_path: not used underFINAL, and it needs a migration.code_enrich_timeout_s: the bound exists so enrichment never slows the core answer.Scope and risk
Touches the code-plane lesson reads (
server/memory/store/code_links.py,server/memory/store/code_plane_reads.py,server/memory/app/code_link_reads.py,server/memory/app/code_plane_reads.py) andcode.symbol's enrichment (server/code/app/symbol/symbol.py,server/code/app/enrich.py,server/code/domain/units.py). Reads only: no write path, schema, migration or setting changes. Tenant scoping is unchanged: every read keeps itsorgand readable-namespace filters.The memory-head read is shared.
current_links(server/memory/app/code_link_reads.py) now reads heads by identity, and it also servesmemory.for_file(its links andcode_state) and the decisions read behindcode.context_packand the review brief. Those paths get the same narrower read, with the same results except for the case below. The off-key link read changes onlycode.symbol's lessons: it is the one caller that asks for former paths.One behaviour change, on every path above: a memory is found only under the identity its link was made from. If a memory id now sits under another identity (for example a namespace restored under another agent), its link does not find it until the link worker relinks it. Before, the read by id alone found it anywhere in the org.
Compatibility, rollout and rollback
code.symboldefinitions gainlessons_unread: bool, serialized only when true. No field removed, no default changed. The SDK op tables are regenerated.Tests
New
tests/unit/test_code_link_reads_by_key.pyruns the real statements onclickhouse-localwith merges stopped, so each version of a row stays in its own part. It checks that a link is found by its anchored or former path as its newest version has it, that the off-key link reads take their keys from the index first, that a memory is read by its identity only while it holds the linked id, and that the excerpt read keeps the best rows up to its limit. It skips without theclickhousebinary; the three read-by-key checks fail onmain.tests/unit/test_code_symbol_concurrent_reads.pynow checks thatlessons_unreadis set when the lessons read fails or is cut off at its bound, and absent for a symbol with no lessons, for a narrowed token (which makes no lessons read) and forinclude_lessons: false.tests/integration/test_code_result_lessons.pycallsserved_excerptsdirectly; the call now passes the memory's identity and a limit, as the new signature takes.Rows read, measured on a test table of 1M links and 1M memories inserted in 8 batches with merges stopped, from
system.query_logfor the statementsmainand this branch send (same rows returned in each case):mainanchored_pathpathThese are rows read, not end-to-end latency; no
code.symbolcall was timed against a large table.Run locally:
make lintandmake typecheckpass; the four lesson-read unit files pass with theclickhousebinary onPATHin random order; the unit and integration suites pass except for tests that fail the same way onmain(test_read_scope_admission,test_read_scope_isolation:code.readis not classified;test_mcp_coding_toolset,test_mcp_initialize_surface;test_sdk_surface_contract: thecode.grepfields) and the signed-mirror cases that run only with auth on.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 by hand: the cause with
EXPLAIN indexes = 1andsystem.query_logon a test table, the rows each statement returns onmainand on this branch, and the test results above.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited. (No migration.)hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version. (No plugin file.)npm --prefix frontend run build) and its tests pass, iffrontend/changed. (Not changed.)docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.