Repository navigation
A token mint, namespace.list_mine, memory.for_file and four code passes derive the configured repositories once - #2194
Merged
Merged
Conversation
… at a time A token mint, a token's namespace list, a pre-edit file lookup, the link recheck of a refresh, the risk refit, the backport-gap pass and a document's decision extraction each ask a helper about one namespace per item, and each ask derives every configured entry. Each call's answer is asserted beside the count; the eight count tests fail until the call derives the entries once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…positories once A token mint, a token's namespace list, a pre-edit file lookup, the link recheck of a refresh, the risk refit, the backport-gap pass and a document's decision extraction each asked a one-namespace helper per item outside a derived_once block, so each ask parsed the operator's configuration and took a realpath and a stat of every clone directory. Each now runs its lookups inside one block. No lookup's answer and no gate changes; a block ends with the call or pass that opened it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The architecture page names every call and pass that runs its per-item lookups inside repos.derived_once(): the token mints, a token's namespace list, the file lookup, a refresh's link recheck, the risk refit, the backport-gap pass and a document's decision extraction join the list. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…mbol itself The count of a document's decision extraction covers the lookup of each code name it mentions: code.symbol runs over an empty index, in place of the fixture's stand-in. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…mint that names a home `personal_tokens.create` opens its own block, which no test entered. `admin/token.mint` for a namespace before `*` reads that namespace's kind after its block has ended: the count test reports 2 derivations for it. The mint fixture clears the namespace kinds, which are cached per org, so a count no longer depends on which test read them first. `HELD` is the list of names its one reader walks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…s block The mint's last configuration read, the kind of the namespace a `*` token saves to, ran after its `derived_once` block: a second derivation of the entries in one call. The block now ends after that read. `memory.for_file` imports `derived_once` beside its other code imports, and the block's comment stands apart from the comment on the read inside it. The architecture page names a fix and a code name among what the loops run over, and says which mints ask for a bound tracker. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…t_mine notes say what is asked The `owner` fixture cleared the namespace kinds before a mint and not after, so a later test in the same process read this file's configured kinds for 30 s. The token-mint line of the architecture page and the mint test's docstring said the tracker is asked of each namespace: only `service_accounts.create` and `personal_tokens.create` ask it, and only of a restricted one. The comment on the `namespace.list_mine` block named a loop that is in `_inherited_rows`: it now says the block also holds the configured kinds. 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>
…aller may not read; every test of the file drops the namespace kinds it read The memory.for_file answer test asserted only what the link store was asked for. It now serves two of the caller's memories linked to the file, one in a trunk the caller may read and one in a trunk they may not, routes their rows, and asserts the hits and their code state: the memory reached only by the link in the unreadable trunk is not a hit. With the per-link gate bypassed the test fails with both memories served. A file lookup with the `all_mine` default scope reads the org's namespace kinds, which are kept per org for 30 s. The reset the mint fixture made is now a fixture every test of the file runs under, so no kind is left for a later test on the same worker. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The handler runs the read for the request's namespaces and the read for the caller's other namespaces side by side, so which one reaches the store first is the event loop's order, not part of the answer. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
With many configured repositories, minting a token, listing a token's namespaces, the pre-edit
memory.for_filelookup, the memory-link recheck aftercode.refresh, the risk refit, the nightly backport-gap pass and decision extraction held the server's event loop for a time that grew with the repositories times the items they handled. Each now derives the configured repositories once per call or pass.Why
configured_repos()derives the configured entries on every call: a parse of the configuration, then aRepoConfig, arealpathand astatper entry. A lookup of one namespace (repo_for_namespace,trunk_namespace,is_restricted, the tracker bound to it, the gate) derives them all. #2135, #2139 and #2170 put the loops that walk every entry, memory, hit or directory row insiderepos.derived_once(). #2170 named the loops of the same shape it did not reach. This change measures each of them and fixes those over a fixed bar: at 400 entries, 100 ms of event-loop time on a path a request reaches, or 1 s on a worker pass.Failing cases, with the derivations one call makes over the test's nine entries:
service_accounts.create,personal_tokens.create)admin/token.mint)*: its kindnamespace.list_minememory.for_filerepo:tag for its trunk, each link for its memory's trunk and each trunk for its gate, for the request's namespaces and again for the caller's other namespacescode.refresh(recheck_repository)loom decisions extractThe mint and
memory.for_filecounts are with the org's namespace kinds already read (namespace_kinds.kind_mapkeeps them 30 s per org). A call that finds them unread derives the entries once more to read them: the tests clear the kinds, so without the blocks the mints report 38 and 9 and the file lookup 30.Pattern: a call or a pass that asks a helper taking one namespace once per item (a namespace a token names, a grant, a changed file, an entry, a fix, a code name), outside a
derived_onceblock.Fix: each of them runs those lookups inside
repos.derived_once(). No lookup changes and none is skipped; the entries are derived once per block instead of once per lookup.Event-loop time of the lookups each loop makes at the size given, bare and inside one block (the script is under Tests; one laptop, so read the ratios). The lookups per item are the counts above. Decision extraction's block is per document, so its last cell is 40 blocks:
namespace.list_mine, 50 inherited grantsmemory.for_file, one call with 2 linksThree of the sizes are caps: the 40 documents of decision extraction and of the knowledge source sync are a sync pass's
knowledge_source_sync_documents_per_pass, and the risk refit's is every configured entry with a tracker bound to it. The others are what one call or pass of a large deployment handles, not limits the code sets, so their bare times are not worst cases. A mint's namespace list, the grants a token inherits, the links of a file and the files a push changes have no cap. The backport-gap pass takes up tocode_backport_gaps_prs_per_passfixes a trunk (300). The SCIP apply pass takes three batches for each namespace with a complete upload. Bare, a larger size costs in proportion to its lookups.The recheck's row holds only its lookups on the loop: two a pass and one per changed file. The four per moved link (80 for 20 files) run under
asyncio.to_threadand hold no event-loop time, so they are not in the row. The block covers them as well: the thread runs in a copy of the caller's context, which carries what the block holds.The first eight are over the bar and are fixed. The last two are under it and are left alone. Decision extraction is the closest call. The 9 in the first table is a run that names a repository, as
loom decisions extract --repodoes. The sync worker names none: a document with one decision makes two lookups in a memory namespace (0.8 s for 40 documents at 400 entries, under the bar) and three in a branch's code namespace (1.2 s, over it), and each further decision adds a lookup for each code name it mentions. Its block is per document, so a pass of 40 documents derives the entries 40 times, about 0.4 s at 400 entries, instead of 80 times or more.Scope and risk
Nine
with derived_once():blocks and the list of them indocs/architecture/code-index-architecture.md.recheck_repository, not around thecode.refreshhandler: a refresh that does not wait runs the recheck as a task that outlives the handler. The recheck awaits its worker thread inside the block; a thread that a cancelled recheck leaves running finds the block ended at its next lookup and derives the entries itself.memory.for_filestarts its link read and its bounded read of the caller's other namespaces inside the block, and a call that answers has awaited both there. The admin mint's block ends after its last configuration read, the kind of the namespace a*token names before*, and its audit row is written inside it. Two tasks can also outlive their block. One is a write that a document's extraction leaves running when it ends. The other is the read of the caller's other namespaces when the request's own read ofmemory.for_fileraises:asyncio.gatherraises at once and leaves that read running to its bound (_OWN_ROWS_SECONDS, 0.5 s), as it does without this change. Each derives the entries itself, since no task reads what a block held once the block has ended.namespace_classificationand the gate read them as before.code_repos_jsonis not a live setting, so it changes only at a restart. Thestatof each clone directory is as of the block's first lookup; it feeds only the check that two entries do not hold one clone under two spellings, and the next block reads it again.code_backport_gaps_max_pass_seconds), which already lists its trunks once at the start, and one document's extraction (its model calls).Left alone, with what each costs at 400 entries:
knowledge_source_sync_documents_per_passdocuments (40): 368 ms, under the bar.code.backport_gapop makes about six lookups a call, about 60 ms, under the bar for a request.Compatibility, rollout and rollback
Tests
tests/unit/test_namespace_loops_derive_once.pyruns the real configuration parse and the real gate over the entries oftest_repo_listings_derive_once.py: two orgs, repositories of several branches, a branch added from the page, entries the caller may only ask to join or may not see. Each site has a test of its answer and a test of its derivation count. The mint's count runs throughservice_accounts.createand throughpersonal_tokens.create, and the admin mint's for a list of namespaces and for a namespace before*. The tests of the eight sites were committed before the change: the eight answer tests passed and the eight counts were the numbers in the first table, except the file lookup's. Its test then served one link, with the kinds read by the test before it, and reported 23. It now serves a second link, in a trunk the caller may not read, and asserts the hits: with the gate on each link's trunk bypassed it fails with both memories served, and with the block replaced bycontextlib.nullcontextit reports 30. The count for an admin mint of["notes", "*"]was committed while the block ended before the read of that namespace's kind, and reported 2. The count throughpersonal_tokens.createwas added after its block; with that block replaced bycontextlib.nullcontextit reports 38. With the change all 19 pass, and each count is 1.Three counts are lower bounds. The recheck's test replaces the mirror, the link store and the policy step. The backport-gap test's read of a fix is the test's own: its three helper calls make five lookups, one fewer than the composed read. The extraction test uses a fake model, and
code.symbolitself over an empty index.The unit files that name
admin_routes,for_file,me_service_accountsorpersonal_tokenswere run withtest_package_contracts.py,test_repo_snapshot_contract.py,test_public_copy.pyandtest_doc_links.py: 2,379 tests pass. Eleven tests oftest_store_names_refused.pyandtest_mirror_names_refused.pyrun the migrations through a localclickhousebinary and fail on that binary'sUnknown setting 'enable_quantized_codec'; they call nothing this change edits. CI runs the full suites.The timing script
Run it with
LOOM_ENV_FILE= .venv/bin/python -P <file>from the repository root.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: each block's extent against what runs inside it and what outlives it, the derivation counts before and after, and that the answer tests pass on the unchanged code.
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), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/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.🤖 Generated with Claude Code