Repository navigation
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>
This branch has not been deployed
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 mint tests clear the kinds, so without the blocks they report 38 and 9.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 its bound, bare and inside one block (the script is under Tests; one laptop, so read the ratios). The lookups per item are the counts above:
namespace.list_mine, 50 inherited grantsmemory.for_file, one callThe 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 and awaits its link read and its bounded read of the caller's other namespaces inside the block. 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. A write that a document's extraction leaves running when it ends 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_budget_s), 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. 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: it makes the three configuration lookups the composed read makes. 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,416 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