Repository navigation
code.branch.diff lists how two branches differ - #1974
KaloyanNaumov wants to merge 43 commits into
Conversation
Asking what one branch changes against another meant reading code.files on both namespaces and comparing by hand, then reading symbols path by path. Both namespaces already hold what the comparison needs: code_files carries each file's blob, code_symbols each definition's span and signature. The new viewer op compares two indexed heads tip to tip. It reads one key-prefixed code_files range per side and judges files by blob, then reads the tree-sitter definitions of the added, removed and changed paths and lists those added, removed or changed in signature or span length (a definition that only moved is counted, not listed). With overlaps it names the other readable namespaces of the repository that change the same definitions against the same base. Both namespaces are authorized before any read and an unreadable one refuses; an overlap candidate that is unreadable is skipped and disclosed. The answer pins both git_head values and states that it is not a merge-base diff. Lists are cut at limit and carry their totals; a head that moves during the read sets heads_stable to false. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The generated Python client gained `client.code.branch_diff(body, options)`, and the recorded public surface did not list it, so the surface contract test failed. The snapshot is regenerated with LOOM_UPDATE_SNAPSHOT=1. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ruff format --check .` rewraps two statements of the test; the repository's format gate passes again. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A definition counted as changed only when its signature or the length of its span differed, so a one-line fix inside a body, the commonest edit, was listed nowhere: not in `definitions` and not in `overlaps`, where two branches patching the same line of one function are the conflict the overlap read exists to show. Each side now also reads, for the differing paths, a fingerprint per definition: one hash over the content hashes of the `code_chunks` rows the chunker tagged with it, in line order. The read is a range of the chunk table's path key, one statement per 500 paths. A chunk's hash covers its text and not its position, so a definition that only moved keeps its fingerprint and is still counted in `definitions_moved`; one whose text differs is changed with the reason `body`. A definition no chunk is tagged with (one nested inside another's chunk) is compared by signature and span as before; the enclosing definition carries its edit. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able The overlap read cut the sibling list at its cap before checking readability, so a namespace the caller cannot read was named `over_cap` without being checked, and unreadable siblings took slots from readable ones that sorted later. Readability is now checked over every sibling first; the cap counts only readable ones, and an unreadable sibling is named only as `not_readable`, as in every fan-out Loom expands. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tip-to-tip comparison reports every change the trunk made after a branch forked as a removal on the branch, and nothing in the answer said whether the branch was up to date. A reader could not tell "this branch removes X" from "the trunk added X later". The answer now carries `divergence`: the heads' merge-base and `ahead` and `behind`, the commits each head has that the other lacks. It is read from the git mirror both namespaces share on the serving process, with two git reads (`merge-base` and `rev-list --left-right --count`) gathered with the manifest reads, each bounded at two seconds; the mirror is never cloned or fetched for it. Without a shared mirror on the process, with a head the mirror lacks, or when git fails or runs out of time, the divergence is `unknown` with a reason and the rest of the answer stands. The file and definition comparison stays tip to tip. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A container's skeleton chunk lists the body-less declarations inside it (the methods of a TypeScript interface or a Rust trait) after the container's own id. The fingerprint read took every tag of every chunk, so an edit to one method changed the hash of every sibling method. Each sibling came back as a `body` change and, when another branch edited a different method of the same container, as an overlap. The read now takes only the first tag of a chunk, the definition that owns it. A declaration has no chunk of its own, so it has no fingerprint and falls back to the signature and span test, which is its whole text. The container keeps its fingerprint and reports a skeleton edit as before. The integration test indexes a TypeScript interface on a trunk and two branches that each edit a different method. It failed on the earlier head, where `get` and `size` were listed beside the edited `put`, and passes now. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The two divergence reads passed the stored heads to git as they were: no check that a value is a revision and not an option, and no `--end-of-options`. The values are watermarks the indexer wrote itself, so no caller input reaches them, but every other range reader in the git module guards the same shape. The merge-base read now goes through `gitrepo.merge_base`, which takes a timeout, and the ahead and behind count through a new `gitrepo.ahead_behind`. Both refuse a value that starts with a dash before git runs and put `--end-of-options` before the revisions. A refused head answers as an unknown divergence with the rest of the call intact. A test sets a head that reads as an option and checks that neither read starts. It failed before the change, with both `merge-base` and `rev-list` run. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…hunk With SQL statement records on, the chunker packs consecutive statements into one chunk of kind `other` tagged with every statement in it. Reading only the first tag handed the whole pack's fingerprint to its first statement, so an edit to a later statement flagged the first and left the edited one unlisted. A chunk of kind `other` now counts for every statement it is tagged with, as before the first-tag rule: statements that share a chunk are listed together, never misattributed, and statements in other chunks stay unflagged. Function and container chunks keep the first-tag rule. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The generated Go models carry the registry model schema hash, which the merged change and this branch's new op both move; it is regenerated, not merged by hand. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
The comparison can report a stable pair of heads while it reads rows from a partially applied commit. The existing embedding model and overload pairing findings also apply to this head.
| heads_after = await asyncio.gather( | ||
| repo.get_state(org, ns, "git_head"), repo.get_state(org, against, "git_head") | ||
| ) | ||
| stable = tuple(heads_after) == (head_commit, base_commit) |
There was a problem hiding this comment.
P1 — A stable watermark does not pin the rows to that commit. The ingest worker can write a slice for commit B, stop, and leave git_head at A until all slices finish. Both reads here then return A even though the live manifest and definitions include B's writes. Fence the read against an in-progress publish and cover a paused ingest slice so the response cannot present those rows as a stable diff at A.
There was a problem hiding this comment.
Fixed in 7de678b and 375f0f3. The comparison reads both sides' state rows before and after the reads, and heads_stable is false while either side is publishing a commit: its commit slice cursor names a commit on top of its current git_head, or its bootstrap index cursor is set. 7de678b added the read. 375f0f3 closes the writer side. The incremental ingest saved the slice cursor only between the rounds of a commit, so a commit that fits in one round had no marker from its first row until git_head moved. Now the commit step writes the cursor before the commit's first row and moves git_head before it clears the cursor, so a reader always sees one of the two. A pass that stops before git_head moves leaves the cursor in place, and the next pass resumes the commit from it. test_a_paused_ingest_slice_is_not_presented_as_a_stable_diff (unit), test_a_paused_slice_in_the_store_makes_the_pair_unstable (ClickHouse) and test_a_one_round_commit_is_fenced_from_its_first_write_until_git_head_moves (unit, the ingest step with the fence read at its first write and at the dependents step) failed before the change.
The ingest worker can make the first rounds of a commit durable, stop, and leave `git_head` at the commit before until the last round lands. Comparing `git_head` before and after the reads then sees no move, so the answer claimed a stable pair while one side's rows already held files of the next commit. The writer marks that state: an incremental pass keeps its commit slice cursor set between rounds, and a bootstrap keeps its index cursor set between slices, and each clears its cursor only when it moves `git_head`. The comparison now reads both sides' state rows in one statement before and after the reads, and `heads_stable` is false when either cursor is set on either side at either point, as well as when a head moved. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`definition_fingerprints` read `code_chunks` without `embedding_model`. While a namespace holds live chunks of a second model, as during a re-embed, those rows carry their own content hashes and were hashed in with the served model's, so an unchanged definition read as a body edit. The missing predicate also kept the read off the (org, namespace, embedding_model, path) key range its docstring names. The read now takes the model label the indexer writes chunks under, as the other chunk reads in the module do. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a name `shared_changes` keyed the sibling's changes by path, name and kind, so overloads of one name collided: an added overload matched a different one the sibling changed, and two changed overloads both matched the sibling's last row. Both diffs pair against the same base rows, so a changed or removed definition now matches by its base row (signature, symbol id and start line), and an added one by its signature. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generated Go and Rust wire models conflicted; both are regenerated from the merged models. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The field's description now names a side partway through publishing a commit, in a sentence short enough for the generated reference to print whole. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports merge conflicts with main in the generated Go and Rust wire models. Resolve the schema changes and regenerate both models from the combined tree.
The ingest saved the slice cursor only after a round when more rounds were left. A commit that fits in one round, which is most of them, never had one: from its first durable row, through its dependents, the context pack and the review brief, until `git_head` moved, `code.branch.diff` saw no marker and could call the pair of heads stable while one side's rows held a commit its head did not name. The commit step now writes the cursor at file 0 before the commit's first row (a resumed commit keeps its count), and moves `git_head` before it clears the cursor, so a reader always sees one of the two. A pass that stops anywhere before `git_head` moves leaves the cursor naming the commit on top of the old head; the next pass reads it as a resume from that count, as it already did for a commit cut between rounds. A pass that stops between the two final writes leaves a cursor whose base is no longer `git_head`; the next commit starts from file 0, and the fence counts a slice cursor only when its base is the side's current `git_head`. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 2 Three fixes, one commit each, then a merge of main (2c7441c) that regenerates the Go and Rust wire models, c24195e, which updates the |
zlareb1
left a comment
There was a problem hiding this comment.
The new marker fences publication when both the worker and the reader use this build. The diff can still report stable heads while the previous build publishes rows during a rolling upgrade.
|
|
||
| def busy(state: IndexState) -> bool: | ||
| base, dots, _ = value(state, SLICE_KEY).partition("..") | ||
| return bool(value(state, CURSOR_KEY)) or (bool(dots) and base == value(state, "git_head")) |
There was a problem hiding this comment.
P1 — This check treats a missing cursor as a published head. The previous build can write the first slice before setting commit_slice. It also clears the cursor before advancing git_head. If a reader on this build runs in either window, both state reads can see the old head while the file rows have changed. Fence the read during mixed-version publication and cover a read paused across a previous-build write.
There was a problem hiding this comment.
Fixed in f5617fc and 09c4cd3. No state row can show that a previous-build worker is publishing. For a commit of one round it writes no cursor and no other state until git_head moves. So after the reads, the comparison now also checks each side's rows: a code_files or tree-sitter code_symbols row under the prefix, written after git_head was set, makes heads_stable false when it names a commit other than that head or is a tombstone. Every build moves git_head only after a commit's rows, so this holds whichever build is writing, a commit that only deletes files included: a tombstone keeps the commit of the row it retires, which can be the head, so the commit check alone missed it (09c4cd3).
A live row a reconcile heal rewrites at the head itself does not count. A tombstone a reconcile writes after the head does count: it cannot be told from a previous-build deletion, so an idle branch reads unstable until its next commit. I kept that, since unstable is a lower bound and a rule that skipped them could hide a real deletion. The docstrings and the PR body say so.
PreviousBuild in tests/unit/test_code_branch_diff.py replays main's write order, and its fake store now keeps a tombstone's commit as the real one does. Three cases failed before f5617fc: a one-round commit with no cursor, the cursor cleared before git_head moves, and a read paused across that build's first write while both state reads saw the old head. test_rows_of_a_commit_the_head_does_not_name_make_the_pair_unstable (ClickHouse) failed the same way. For 09c4cd3, test_a_commit_that_only_deletes_files_written_at_the_head_is_not_stable (ClickHouse, the real tombstone_file) failed before the change, and test_a_previous_build_commit_that_only_deletes_is_not_a_stable_diff and test_a_tombstone_names_the_commit_of_the_row_it_retires cover it without a store.
The code_symbols count cannot use the path prefix, because its key is (org, namespace, tier, qualified_name, symbol_id): it scans the namespace's tree-sitter rows, once per side. The code_files count is a key range. I have not measured the scan at scale; the docstring says so.
Rolling-upgrade rule 71 records the window left. The previous build flushes a round's chunk rows before its symbol and file rows, so a read that falls wholly between the two can call a body-only change stable. It closes once this build leads the workers.
There was a problem hiding this comment.
Fixed in 28eff76. rows_after_head also counts the served model's code_chunks rows under the prefix written after git_head for another commit, or as tombstones, in the same statement. The chunk count is a range of the chunk key. Rule 71 in the rolling-upgrade notes no longer lists the window. test_chunk_rows_of_a_commit_the_head_does_not_name_make_the_pair_unstable (ClickHouse) writes only a chunk row at the next commit, as the previous build does before its symbol and file rows; before the change the pair read as stable.
Known limit: a chunk that an embedding pass rewrites after the head keeps the commit it was written at, so an embed recovery of an older commit's chunk reads as unstable until the next commit, as a reconcile's tombstone already does. The docstring says so.
zlareb1
left a comment
There was a problem hiding this comment.
The analyzer job failed the mentor SQL shape assertion on the tested merge. I reproduced the same failure on that merge and its base. The focused test passes on current main with the snapshot from #1957. The related SQL masking repair is tracked in #1990.
|
|
||
| # Rows one side's manifest may hold before the call asks for a narrower `path_prefix` | ||
| # (the largest indexed repository holds about 40 thousand files). | ||
| MAX_MANIFEST_FILES = 200_000 |
There was a problem hiding this comment.
The four branch comparison limits fail the tunable constants gate. I reproduced the failure on the tested merge. The same test passes on its base. Declare the manifest, definition and namespace caps and the Git divergence timeout in server settings.
There was a problem hiding this comment.
Fixed in f55dffd. The four limits are server settings now, with the values they had: LOOM_CODE_BRANCH_DIFF_MAX_MANIFEST_FILES (200000), LOOM_CODE_BRANCH_DIFF_MAX_DEFINITION_PATHS (2000), LOOM_CODE_BRANCH_DIFF_MAX_OVERLAP_NAMESPACES (16) and LOOM_CODE_BRANCH_DIFF_DIVERGENCE_TIMEOUT_S (2.0). branch_diff.py reads them at the call, the cap tests set the settings, and the configuration reference, schema, example and defaults snapshot are regenerated. test_tunable_constants.py, test_settings_defaults.py and test_env_reads.py pass, and the settings codegen --check scripts are clean.
An ingest worker of the previous build sets no slice cursor for a commit of one round, and clears the cursor before `git_head` moves. During a rolling upgrade it can write a commit's rows while both state reads see the old head and no cursor. After its reads, the comparison now also counts each side's file and tree-sitter definition rows under the prefix that were written after its `git_head` for another commit. Every writer moves `git_head` only after a commit's rows, so such a row belongs to a commit the head does not name yet. Rows a heal rewrites at the head itself do not count. Each overlap sibling gets the same fence, and `heads_stable` covers it. Rolling-upgrade rule 69 names what is left: a read that falls between an older worker's chunk insert and its symbol insert in one flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
The manifest, definition-path and overlap-namespace caps and the git divergence timeout were module constants, which the tunable-constants test rejects. They are now settings with the values they had: LOOM_CODE_BRANCH_DIFF_MAX_MANIFEST_FILES (200000), LOOM_CODE_BRANCH_DIFF_MAX_DEFINITION_PATHS (2000), LOOM_CODE_BRANCH_DIFF_MAX_OVERLAP_NAMESPACES (16) and LOOM_CODE_BRANCH_DIFF_DIVERGENCE_TIMEOUT_S (2.0). The cap tests set the settings instead of the constants. The configuration reference, schema, example and defaults snapshot are regenerated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
Rules 69 and 70 are taken by other changes in flight, so the rule that records the window left by the branch-diff publish fence is numbered 71. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
A previous-build commit that only deletes files last written at the current head writes tombstones that copy the old row, so they keep `indexed_commit = head`. The fence compared each row's commit with the head and skipped them, and `heads_stable` stayed true over an unpublished deletion. Both counts now take any tombstone written after `git_head`, besides rows that name another commit. A live row rewritten at the head still does not count. A reconcile that tombstones rows after the head cannot be told from such a deletion, so an idle branch reads unstable until its next commit; `_settled` and `rows_after_head` say so. The `code_symbols` count cannot use the path prefix (the key is org, namespace, tier, qualified_name, symbol_id); its docstring states the cost. The unit fake's tombstones now keep the commit of the row they retire, as `tombstone_of` does, and a test pins that for the real `tombstone_file`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
`main` moved `sdk/go/wire/models.gen.go` under the branch: both sides wrote a different registry schema hash, and the same for the Rust wire models, the settings schema and the defaults snapshot. The generated files take `main`'s copy and are regenerated from the merged registry, not hand-merged; `sdk_go_gen.py --check`, `sdk_rust_gen.py --check` and `settings_schema.py` all report current. `tests/unit/snapshots/settings_defaults.json` is rewritten by `LOOM_UPDATE_SNAPSHOT=1 pytest tests/unit/test_settings_defaults.py`. Two hand conflicts: `server/code/store/index/base.py` is a union — this branch adds `set_state`'s floor, `main` adds `rewrite_state` after it; and `docs/architecture/rolling-upgrades.md` gains `main`'s held-edges rule as 70 and keeps this branch's publish-fence rule as 71. `main` renamed `pass_commit._resolve_dependents` to `resolve_dependents`; the one-round fence test now patches the new name. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
`_slice_done` answered None for a failed `get_state`, and the step read that as "start at file 0": it wrote no marker (the `:0` went only with a 0) and went on to write the commit's rows. Under a `git_head` that does not name the commit, those rows are a publish with no marker at all, and a reader takes the pair for settled. An unreadable cursor cannot fence a commit — what it names is unknown — so the step now starts nothing: no rows, no marker, `git_head` where it was, the stored cursor (if any) untouched and still fencing. The commit is left for the next pass, which reads the cursor again; the entry is not retried within this one, as a failed read is not made better by asking again at once. The pass records why. Tests: `test_a_failed_cursor_read_leaves_the_stored_cursor_alone` now asserts no row is written on the failed pass and that the next pass resumes at the durable `:N`; `test_an_unreadable_cursor_does_not_let_the_commit_land_unmarked` is the no-cursor hole. Both were red before the change (the rows landed). Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`heads_stable` counted a row as part of a publish when its version was past the `git_head` row's. That is one worker's clock read against another's: an N-1 worker whose clock trails the one that wrote the head writes its one-round commit's row below that version, and its `git_head` write loses under FINAL, so both state reads name the old head and the row is invisible to the count. The takeover test never ran that case: it wrote the slice cursor through N's `set_state`, whose floor puts the cursor past the head row, so the cursor did the fencing and the row check was never asked. The fence now also compares the rows the read saw with the head's tree, read once from the namespace's mirror (`git ls-tree -r -z`, bounded by the divergence budget): a live row whose blob is not the head's file at that path, or a tree path with no live row, is a commit the head does not name yet, whatever the clocks. Rows of older commits whose files are unchanged at the head are the head's files. A process without the mirror, or a head it cannot read, keeps the version count alone, as before; the rule says so. The integration test now runs N-1's write order: a real descendant commit, the file row and the losing `git_head` row at a clock below the head's, and no cursor. It was red before the change (the pair read stable through the row count); after N's worker moves `git_head` (its write floors past the head row) the row is the head's file and the pair is stable. A unit test replays the same shape through `_settled` with the tree stubbed; `tree_blobs` and `_holds_tree` have their own tests against a real repository. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Steady point:
795 branch/ingest unit tests pass. The integration tests are running against a real ClickHouse right now — I will not claim the fence works against a real store until that returns, and I'll post the result here either way. |
zlareb1
left a comment
There was a problem hiding this comment.
The cursor error now stops the write. The slow-clock finding still reproduces when an N−1 writer changes rows after the file manifest and before the definition reads. The response contains an unpublished definition diff and reports heads_stable: true. The two findings below cover the new Git tree check.
| if tree.get(path) != blob: | ||
| return False | ||
| if paths is None: | ||
| return set(tree) <= set(manifest) |
There was a problem hiding this comment.
P1 — A settled index may intentionally omit files outside the indexed prefixes or binary files. With a tracked binary beside an indexed source file, the exact-head handler reports heads_stable: false although no publish is in progress. Compare against the indexed path set and cover a settled partial index.
| directory). A rev the mirror does not hold is a GitError, never an empty tree.""" | ||
| if not _is_rev(rev): | ||
| raise GitError(f"not a revision: {rev[:12]!r}") | ||
| out = await _git( |
There was a problem hiding this comment.
P2 — A one-file comparison buffers the entire Git tree before applying its prefix. The same read runs for both branches and can run for each overlap sibling. Bound the Git results and apply the requested scope before collecting the output.
|
Integration against a real store, as promised. ClickHouse 26.12.1.1533, disposable instance with CI-parity config (lemmatizers, nlp flags,
And the test bites — the part that matters. On the pre-fix tree ( with the losing One clarification in case it matters to the review: this branch carries no |
zlareb1
left a comment
There was a problem hiding this comment.
The pinned Biome check finds the same unformatted dashboard assertion in this run and on clean main. The separate repair formats that assertion. Failed job · Repair #2107
`main` moved the generated artefacts under this branch: the Go wire models stamped a different registry schema hash, the Ruby and TypeScript tables a different op count, the Rust wire models renumbered every `default_N` past a field `main` added ahead of them, and `operations.md` / `status.md` a different total. All of them are regenerated from the merged registry rather than hand-merged — 385 ops (this branch's `code.branch.diff` plus `main`'s five); every `--check` reports current: sdk_py, sdk_py_client, sdk_py_admin, sdk_go, sdk_rb, sdk_ts, sdk_rust (and `--fixtures`), agent_plugin_sync, standalone_skills, served_skills, settings_reference, settings_schema, settings_example, docs_reference, op_reach_census. Two hand resolutions: - `docs/architecture/rolling-upgrades.md`: `main`'s `/help` rule and usage-label rule keep 71 and 72, because `docs/operations/upgrades.md`, `docsLinks.ts` and `help-address.spec.ts` name them; this branch's publish-fence rule becomes 73 and is appended last, as in the previous refresh. Rules read 1..73 with no gap and no duplicate. - `tests/unit/test_code_branch_diff.py`: `main`'s `readable_subset` now calls `authz.row_reach` (bool | None) instead of `row_in_scope`, and `_AS_OF_CACHE` holds `(block, failed read's text)`. The fixture patches `row_reach` and seeds the tuple; the handler is unchanged. `server/identity/domain/read_scope.py` is a union: this branch's `code.branch.diff` in `NARROW_SAFE_OPS` and `main`'s `ops.incidents` and `NARROW_REFUSED_OPS`. Verified on sonique against the merged tree: `ruff check` clean; `mypy_gate.py` 0 errors; the focused unit set (branch diff, ingest, state/fence, SDK surface, settings defaults) 366 passed, 4 skipped; `tests/integration/test_code_branch_diff.py` 9 passed on ClickHouse 26.12.1.1533; the wider integration filter over branch/diff/publish/state/fence/ingest/store 127 passed, 187 skipped (the skips are the pod's missing Postgres, S3 and reference extractor). Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
A writer on the preceding build can still change definition rows after the file manifest is captured. If that writer’s clock trails the previous head, the row-version check can miss those writes and the response can call an unpublished diff stable. The fence against intentionally unindexed files and the full-tree read also remain. Existing review
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict with main in the rolling-upgrade guide and the generated Go and Rust models. Please reconcile the guide and regenerate both models from the combined schema. This head has no matching Actions runs.
The wire models, the Ruby and TypeScript op tables and the reference pages conflicted in their generated stamps only: main and this branch each bumped an op total and a registry hash. Each took main's copy and was regenerated from the merged registry; every codegen --check is current. rolling-upgrades.md merged into a duplicate rule 73 (this branch's publish fence and main's owner-erasure rule). Main's 73-75 are kept where main has them and the branch's fence is appended as 76.
…ters' clocks A previous build's one-round apply writes a round's chunk and symbol rows before its file row, and moves git_head last. Between the file manifest and the definition reads those rows land with no file row to show them, and the row-version count misses them when the writer's clock trails the head's: the answer then carries a definition of a commit the head does not name and calls it stable. The same read called a settled partial index a publish, because it required a live row for every path of the head's tree, and a binary or a path outside the repository's prefixes has none. The fence is now what the read itself captured, in two halves because a write can land on either side of it: - the definition rows (code_symbols of the tier, code_chunks of the served model) are digested when they are read and read again after; a row that moved in between is another commit's whatever version its writer stamped (definition_capture, _settled); - every row names the commit it was written at, and each must be the head or in its history: one rev-list against the head catches a row that had already landed before the read began, which is the previous-build shape (commits_outside, _commits_outside). The file leg compares one way: every live row must be a path the head's tree holds, at the blob it holds there, so a row of another commit is caught and a path the index declines to hold is not evidence (_holds_tree). The tree is no longer read whole: tree_blobs_at asks git for the paths the manifest named, with the listing scoped to the directory they share and one entry kept per path asked (gitrepo). A one-file comparison went from 726 ms and 16.2 MB of tree to 6 ms. The version count stays as the cheap first exclusion; its docstring, the module's, the heads_stable field and rule 76 now say where the fence actually is. Co-Authored-By: Loom <loom@lumnus.net>
|
Merged A write on the preceding build after the manifest capture. The stability check now stands on two legs. The definition rows are digested as they are read and re-read to confirm they did not move, and every commit those rows name is asked of the head in one Intentionally unindexed files. The full-tree read. |
zlareb1
left a comment
There was a problem hiding this comment.
The publication fence still needs to cover deletes from the preceding build. The definition fence and tree scope threads also remain open. GitHub reports conflicts in the generated Go and Rust models. Please reconcile with main and regenerate both.
| from a tree id at all, and is left to the version count and the definition fence, | ||
| unless its path is not in the tree, which is evidence whatever the row holds. `paths` | ||
| limits the comparison (an overlap's wanted set); None is every path of the manifest.""" | ||
| for path, (blob, _hash) in manifest.items(): |
There was a problem hiding this comment.
P1 — A slower previous-build worker can delete a file before publishing its head. If the tombstone has a version below git_head, the row-version check misses it and the tree check sees no manifest entry to compare. A private ClickHouse test paused after the deletion and got an addition with heads_stable: true. Account for deleted paths while keeping intentionally unindexed files distinguishable.
There was a problem hiding this comment.
A tombstone written after the head's row now counts, whatever version its writer gave it: rows_after_head compares the tombstone's tombstoned_at with the updated_at of the head's row, for files, symbols and chunks. A file the index never held has no tombstone, so intentionally unindexed files are unaffected. test_a_previous_build_deletion_on_a_slower_clock_is_not_stable runs your shape against a ClickHouse server: the head's version is ahead, tombstone_file writes below it, and the file showed as added with heads_stable: true before and false now. A tombstone written in the head's own second is not seen, because tombstoned_at has one-second resolution; the docstring and the rule say so.
| counted = "1" | ||
| if counted.strip() == "0": | ||
| return set() | ||
| for c in present: |
There was a problem hiding this comment.
P2 — When the mirror lacks the published head, this fallback treats Git errors as proof the captured commits are outside that head. Two integration tests return heads_stable: false after publication. Even with a valid head, one unpublished commit makes the loop check all candidates separately. A 601-commit probe took 12.53 seconds with a 0.5-second Git timeout. Distinguish unavailable ancestry and use one deadline for the check.
There was a problem hiding this comment.
A git failure is unknown now. commits_outside makes one rev-list of the candidates against the head and returns the candidates it lists, so there is no call per candidate, and missing_commits and the rev-list share one deadline. When git cannot read the head it raises and _commits_outside keeps the evidence it has. The two integration tests that returned heads_stable: false after publication pass, and a unit test covers the missing head and counts one rev-list and no merge-base. I did not rerun the 601-commit probe; the loop it measured is gone.
The wire models for Go and Rust conflicted. Each took main's copy and was regenerated from the merged registry; every codegen --check is current, and the Rust diff is the mechanical default renumbering. rolling-upgrades.md merged into a duplicate rule 76 (main's session-run rule and this branch's publish fence). Main's 76 and 77 are kept where main has them and the fence is appended as 78. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Assisted-by: Claude Code:claude-sonnet-5-5
… not as proof `commits_outside` answered a failed `rev-list --count` as "one is outside" and then asked `merge-base --is-ancestor` of each candidate, where a head the mirror lacks fails too, so every commit read as outside. Two integration tests that publish a head the mirror does not hold returned `heads_stable: false` after publication. With a readable head, one unpublished commit made the check run git once per candidate, each with its own timeout. One `rev-list` of the candidates against the head now lists what the head does not contain, and the candidates among it are the answer. The call and the check for missing commits share one deadline. A git failure raises, and the caller keeps the evidence it has, as it does for a mirror it does not hold. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
`_scope_dir` took the string prefix of the directories and cut it at the last slash, so one path in `a/b` and another in `a/b/d` shared `a/b` and lost it, and the listing ran on `a`; one path in `src` and another in `src/pkg` listed the repository root. On a large tree that read could hit the divergence timeout, and the blob fence was skipped. The shared directory is now the common leading components of the directories. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
… asked about The read after the definitions compared digests only for paths that held rows when they were first captured. A path with no chunk or symbol row was left out of that comparison, so a definition a previous-build worker wrote there while the read ran stayed out of the check and `heads_stable` stayed true. The capture now carries the paths it asked about, and the later read asks about all of them. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
…ild deleted A previous-build worker whose clock trails the head's can delete a file before it publishes its head. The tombstone's version is below `git_head`, so the row-version count does not see it, and the file has no live row in the manifest, so the head's tree has nothing to be compared with. A private ClickHouse test paused after such a deletion and got the file listed as added with `heads_stable: true`. `rows_after_head` now also counts a tombstone stamped after the second the head's row was written, whatever version its writer gave it. A file the index never held has no tombstone, so intentionally unindexed files are not affected. A tombstone written in the head's own second is not seen, and one written by a reconcile after the head reads as unstable until the next commit, as before. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
Reconciled with main and regenerated the Go and Rust models; the fence is rule 78 now, after main's 76 and 77. The four threads are answered on their own. The deletion fence, the ancestry check, the definition fence and the tree scope each have a test that failed before the change. @zlareb1 re-review please. |
zlareb1
left a comment
There was a problem hiding this comment.
The latest commit catches tombstones with a later timestamp. The outstanding thread still applies when a previous build stamps a tombstone in the same second as the published head. GitHub also reports that this head conflicts with main.
Conflicts were in the generated Go and Rust models, the Ruby and TypeScript op tables, the generated operations and status pages, and docs/architecture/rolling-upgrades.md. The generated files take main's copy and are regenerated with the repo's generators. Main now holds rules 78 and 79, so this branch's publication fence is rule 80. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Assisted-by: Claude Code:claude-sonnet-5-5
…deleted files A previous-build worker whose clock trails the head's can delete a file before it publishes its head. The tombstone's version is below `git_head`, so the version count does not see it, and a deleted file has no live row for the tree check to compare. The previous commit counted a tombstone stamped after the second the head's row was written, which is a comparison of two writers' clocks: a tombstone in the head's own second, or from a writer whose clock trails, matched neither it nor the version. The tree check now takes the deleted paths too. `file_manifest(deleted=True)` reads the paths whose newest row is a tombstone, with the blob of the row each retired, under the same prefix and to the same cap as the manifest, and `_holds_tree` fails when the head's tree still holds a deleted path with that blob: the head's own file was deleted by a commit the head does not name yet. A path the tree does not hold is the head's own deletion. A tombstone that retired another blob, or one older than the blob column, is left alone, as a live row of that kind is. Past the cap the deleted paths cannot all be asked of the tree and the pair reads as unstable. With the tree check covering deletions, the timestamp predicate in `rows_after_head` is redundant and is removed, so no clock decides whether a deletion is the head's. The rolling-upgrade rule and the docstrings that described the one-second limit say so. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
…iff reports as missing The tree check read every tombstoned path under the prefix. Tombstones accumulate over a repository's whole history, so on a long-lived repo that was a large read per call, and past the cap a namespace read as unstable for good. A deletion changes the answer only where the other side's manifest holds the path and this side's lacks it (for an overlap's sibling, the wanted set its manifest lacks). `_missing` names those paths and `_tree_holds` reads the tombstones for exactly them, in batches, so the read is bounded by the manifests the call already holds. The cap branch is gone with the full read. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The last commit caught a later tombstone and left the same second, and the tombstone from a trailing clock, to a one-second limit. That is closed now, without a clock: the head's tree is asked about deleted paths as it is about live ones (thread r4808464481), and the timestamp predicate is gone. The rolling-upgrade rule and the docstrings that described the limit say so. Main is merged (one merge commit). The Go and Rust models, the Ruby and TypeScript op tables and the generated operation and status pages were regenerated with the repo's generators, not merged by hand. Main now holds rules 78 and 79, so the publication fence is rule 80. @zlareb1 re-review please. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 3180386. Configure here.
| await repo.file_manifest(org, ns, paths=sorted(missing), deleted=True) if missing else {} | ||
| ) | ||
| tree = await _head_tree(org, ns, head, sorted({*manifest, *deleted})) | ||
| return tree is None or _holds_tree(manifest, tree, None, deleted) |
There was a problem hiding this comment.
In-progress deletion looks stable
High Severity
A publish that tombstones chunks and symbols before the file row is invisible to the stability fence. definition_capture only reads live rows, so those tombstones never contribute a commit, and _tree_holds only loads tombstones for paths already missing from the live manifest. On a clock behind git_head, rows_after_head misses them too, so heads_stable stays true while definitions on that path are already gone.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3180386. Configure here.
| ) | ||
| except gitrepo.GitError as e: | ||
| logger.debug("code.branch.diff: tree of %s at %s: %s", ns, head[:12], e) | ||
| return None |
There was a problem hiding this comment.
Tree listing skips the file fence
Medium Severity
tree_blobs_at still runs git ls-tree -r for the common parent of every manifest path. For a branch diff that parent is usually the repo root, so both sides and each overlap sibling buffer a full tree under the 2s divergence budget. A timeout is a GitError, _head_tree returns None, and _tree_holds treats that as agreement, which turns the file fence off.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3180386. Configure here.
zlareb1
left a comment
There was a problem hiding this comment.
The new tombstone lookup is limited to paths missing from the file manifest. It still misses a deletion paused after symbol and chunk tombstones while the live file row remains, as described in the in-progress deletion thread. Please also address the tree listing failure. GitHub confirms a conflict with main.


Adds a read-only op,
code.branch.diff, that says how two indexed branches of a repository differ: the files added, removed and changed, then the definitions on those paths, and optionally which other branches change the same definitions. It compares the two indexed heads tip to tip, pins both commits and states their merge-base with the ahead and behind counts. Both namespaces must be readable, or the call refuses.Related: #1680
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.branch.difflists the files and the definitions that differ between two indexed branches of a repository, with the indexed commit of each side and their merge-base, and withoverlapsnames the other branches that change the same definitions.Why
"What does this branch change against main?" and "which other branches touch the same functions?" have no single answer today. A caller reads
code.fileson both namespaces and compares them by hand, then reads symbols path by path. The two namespaces already hold what is needed:code_filescarries each file's blob,code_symbolseach definition's span and signature, andcode_chunksthe content hash of each chunk with the definitions it covers. The op compares them.The answer is a comparison of two indexes, not of two histories. Each namespace is one branch's indexed head, so
code.branch.diffsays what the two heads hold differently and pins bothgit_headvalues. A change already onagainstthatnamespacelacks shows as a removal, so the answer also states the heads' merge-base and how many commits each has that the other lacks (divergence). Withbehind: 0the branch is up to date withagainstand its removals are its own; otherwise some may be additions made onagainstafter the fork.Scope and risk
What it does:
code_files(one range per side, underpath_prefix), compared byblob_sha. A row with no blob sha is judged by its content hash; a row with neither counts as changed.code_symbolson each side, paired by path, name and kind (overloads pair by signature first). A definition is changed when its signature, the length of its line span or its text differs (reasons:signature,size,body). The text is compared through a fingerprint per definition: one hash over the content hashes of thecode_chunksrows that carry its text under the embedding model the server indexes with, in line order, read as a range of the chunk table's (org, namespace, embedding_model, path) key. Rows another model left behind do not count. A function or container chunk is the definition's by its first tag. A chunk of kindotheris every tagged definition's: with SQL statement records on, the chunker packs consecutive statements into one chunk tagged with all of them, so its text cannot say which statement changed. Those statements are listed together, the edited one among them, and the statements of other chunks are not. A chunk's text includes the doc comment attached to the function, so a one-line fix inside a body, or an edit to its doc comment, is a change and takes part inoverlaps. A chunk's hash covers its text, not its position, so a definition that only moved down the file is counted indefinitions_movedand not listed. A definition no chunk carries is compared by signature and span: one nested in another's chunk, and a body-less declaration (a TypeScript interface method, a Rust trait method), which a container's skeleton chunk lists after its own id. Editing one such declaration therefore does not mark its siblings, and the container carries a skeleton edit.divergence:merge_base,aheadandbehindfrom the git mirror both namespaces share on the serving process, two git reads (merge-base,rev-list --left-right --count) gathered with the manifest reads and run through the git module's guarded helpers (a value that could pass for an option is refused before git runs, and--end-of-optionsprecedes the revisions). They are bounded together by the 2 s divergence budget, which also bounds thecat-filelookup for a head the mirror lacks; a read that runs out of it givesgit_timeout. The mirror is never cloned or fetched for this. Without a shared mirror on the process, with a head the mirror lacks, or when git fails or runs out of time, it isunknownwith areasonand the rest of the answer stands.overlaps: the other namespaces of the same repository (equalrepo_key) that Loom itself looks up. Readability is checked over all of them first; at most 16 readable ones are compared, each againstagainston the paths this diff names, and the answer lists the definitions both change. Both diffs pair against the sameagainstrows, so a changed or removed definition matches the one paired with the same base row (signature, symbol id, start line), and an added one matches an addition with the same signature: distinct overloads of one name never match. A candidate the caller cannot read takes no slot and is named inoverlaps_skippedasnot_readable, ascode.backportdoes; readable candidates past the cap are namedover_cap.namespaceandagainstare both authorized before any read, failing closed.limit(default 100, at most 500) and carries its total. There is no continuation: a large answer is narrowed withpath_prefix. A side with more than 200,000 files under the prefix refuses and asks for a narrower one. The definition read covers at most the first 2,000 differing paths, anddefinitions_completesays when more differ.heads_stableis false when either side's indexed head moved while the rows were read, or when either side was partway through publishing a commit: an incremental ingest writing a commit on top of itsgit_head(its slice cursor names that head as its base) or a bootstrap between slices (its index cursor set). Both sides' state rows are read in one statement before the reads and again after them. For this the ingest's commit step now writes the slice cursor before a commit's first row, also for a commit that fits in one round, and movesgit_headbefore it clears the cursor. A pass that stops beforegit_headmoves leaves the cursor, and the next pass resumes the commit from it as before. After the reads it also counts each side's file, tree-sitter definition and chunk rows (chunks under the served embedding model) under the prefix that were written after itsgit_head: a live row that names another commit, and every tombstone, since a deletion's tombstones keep the commit of the row they retire, which can be the head itself. A deleted file is asked of the head's tree: for the paths the diff reports as missing on a side, the tombstones are read with the blob each retired, and one the tree still holds with that blob was deleted by a commit the head does not name yet, whichever clock stamped it. That covers a previous-build worker that writes no cursor, including one whose commit only deletes files; the overlap siblings get the same fence, andheads_stablecovers them. A live row rewritten at the head (a heal) does not count. A reconcile that tombstones rows after the head cannot be told from such a deletion, so it counts too and an idle branch reads unstable until its next commit; unstable is a lower bound, never a false stable. Thecode_filesandcode_chunkscounts are ranges of their keys. Thecode_symbolscount cannot use the path prefix (its key is org, namespace, tier, qualified_name, symbol_id), so it scans the namespace's tree-sitter rows, once per side and per overlap sibling; not measured at scale.as_ofandagainst_as_ofare given only when they name the head the answer pinned, and are empty otherwise.What it leaves alone: no table and no migration; the op itself writes nothing, and four settings (
LOOM_CODE_BRANCH_DIFF_*) bound its read. The op isexperimental, viewer-only and not in the MCP listing (callable by name throughloom_op), so the default listing budget is unchanged. Two store reads are new,CodeRepo.file_manifestandCodeRepo.definition_fingerprints; the symbol read is the existinglive_symbols_for_paths, and the git reads use the existinggitreporunner andmirrors.present_dir.Risk: it is a read over two namespaces' rows, bounded by the caps above, plus two bounded git reads of a local mirror. The latency budget entry (3000 ms) is a design target that has not been measured on a large index. The cross-principal and restricted-namespace leakage suites probe every registered read op; the authorization is the same
row_in_scopegate thatcode.searchover several namespaces uses.Compatibility, rollout and rollback
code.branch.diff, with the generated SDK entries (Python, TypeScript, Ruby, Rust, Go), reference rows and the SDK public-API snapshot. No existing op or field changes. A process older than this build answerscode.branch.diffas an unknown op; nothing else is affected.<base>..<sha>:<files>format, so an older ingest worker resumes from it as before. An older worker writes no cursor for a one-round commit, which only leaves that commit unfenced until the worker is upgraded.OP_BUDGETS_P99_MS) ships with it.Tests
tests/unit/test_code_branch_diff.py(45 cases): the blob comparison and its fallback, moved versus changed definitions, a body edit with the same span and signature (changed, listed and counted inoverlaps) beside an equal text that moved (counted as moved), overload pairing, in the diff and inoverlaps(an added overload shares no change with another overload, and each changed overload pairs with the same overload on the sibling), fingerprints read under the server's embedding model, the answer's pinned heads, a head that moves during the read, a paused ingest slice, a bootstrap between slices onagainstand a slice that pauses during the read (eachheads_stable: false),path_prefix,limitand the definition-path and manifest caps,overlapson and off, a sibling that is unreadable, unindexed or over the cap, a cap that counts only readable siblings and never names an unreadable one over it, the divergence from a real repository as the mirror (merge-base, one ahead, one behind), a head the mirror lacks, a head that could pass for an option (refused before either read runs) and no mirror at all (eachunknownwhile the call answers), an unreadableagainstand an unreadablenamespace(each refuses before any read), and a side with no indexed head. A previous-build worker's write order is replayed (PreviousBuild, whose fake store keeps a tombstone's commit as the real store does): a one-round commit with no cursor, a cursor cleared beforegit_headmoves, a commit that only deletes a file written at the head, a read paused across its first write, and rows written at the head itself leaving the pair stable. A tombstone written after the head reads unstable until the next commit. A sibling that publishes a commit, or pauses across a previous-build write, makesheads_stablefalse. The path, manifest and overlap caps are set through the settings.tests/unit/test_code_tombstone_file.pypins that the realtombstone_filekeeps the retired row's commit, and the ClickHouse casetest_a_commit_that_only_deletes_files_written_at_the_head_is_not_stableruns it on a real store.tests/unit/test_code_ingest_large_commit_slices.py(three new cases): a commit that fits in one round reads as publishing from its first write through the dependents step and as settled oncegit_headnames it; a pass killed inside it leaves the cursor at file 0 under the old head, and the next pass rewrites it from its first file;git_headis written before the cursor clears, and a cursor left behind aftergit_headmoved does not fence and does not resume the next commit.tests/unit/test_model_calls_held_mid_pass.py: a held commit leaves the cursor at file 0.tests/integration/test_code_branch_diff.py: a git repository with a trunk and two branches, each indexed by a real backfill into its own namespace, then the op over the live tables: files, definitions (including one patched in place on both branches with the same span and signature), the overlap on the two shared definitions, the divergence (merge-base the trunk's commit, one ahead, none behind), the reverse direction, a prefix, a limit, and the fail-closed refusal. A second test indexes a TypeScript interface on a trunk and two branches that each edit a different method: only the edited method is listed, and no method is shared inoverlaps. A third indexes a SQL test of five statements with statement records on, where the first three pack into one chunk, and edits the second: it is listed, and the statements of the other chunk are not. A fourth sets the slice cursor on an indexed namespace, as a paused ingest leaves it, and the pair reads unstable. A fifth copies a namespace's chunks under a second embedding model with other hashes on a branch that only adds a function, and only that addition is listed. A sixth writes the chunk rows of the next commit without a file or definition row, and the pair reads unstable untilgit_headnames that commit.test_a_previous_build_deletion_is_not_stable_whatever_the_clocks_say(integration, four clock shapes),test_a_deletion_the_head_names_stays_stable(integration) andtest_a_path_with_no_rows_when_read_is_fenced_tooandtest_ancestry_git_cannot_read_is_unknown_and_one_call_decides_the_rest(unit) for the deletion fence, the definition fence and the ancestry check).test_memory_code_links(ClickHouse),test_sdk_surface_contract,test_op_budgets,test_mcp_listing_budget,test_op_reach_census,test_op_inputs_after_gate,test_transport_layering,test_hidden_op_says_whyandtest_public_copy; every generator with--check(Rust with the rustfmt of Rust 1.85.1, Go 1.27.4),ruff format --check .,ruff check, the function-length, secrets and mypy gates. The full suite and the leakage integration suites 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 Sonnet 5.5 and Claude Opus 5.5. I read the diff, ran the focused tests and the generators, and checked the comparison against a real repository indexed into three namespaces.
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. (No migration.)frontend/changed. (It did not.)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.Note
Medium Risk
New read path over two namespaces with multi-table reads and git mirror calls; ingest cursor ordering changes affect how in-progress commits are visible during rolling upgrades.
Overview
Adds
code.branch.diff, a viewer read op that compares two indexed branch namespaces tip to tip: file adds/removes/changes by blob, then tree-sitter definition diffs on those paths (signature, span length, body via chunk fingerprints), plus optionaldivergence(merge-base, ahead/behind) andoverlapsfor sibling branches touching the same definitions against the same base.heads_stableand related ingest behavior are tightened so answers are not trusted mid-publish: the ingest worker sets the slice cursor before the first row of a commit (including one-round commits), movesgit_headbefore clearing the cursor, and does not start a commit when the cursor cannot be read; stabilization also re-reads definition digests, checks commit ancestry on the mirror, and compares manifests to the head’s tree (including deletions via tombstones).New store/git helpers back the op; four
LOOM_CODE_BRANCH_DIFF_*settings cap manifest size, definition paths, overlap namespaces, and git timeouts. Wire/SDK/docs/reference are regenerated; extensive unit and integration tests cover diffs, overlaps, and publish races (including N−1 write order).Reviewed by Cursor Bugbot for commit 3180386. Bugbot is set up for automated code reviews on this repo. Configure here.