Repository navigation
loom code backfill keeps an owed edge pass across a resume - #1583
Open
KaloyanNaumov wants to merge 2 commits into
Open
KaloyanNaumov wants to merge 2 commits into
KaloyanNaumov wants to merge 2 commits into
Conversation
A first full backfill implies the edges-only second pass, but only while its cursor is empty. A first backfill stopped in its index phase (a held org, a SIGTERM, a crash) resumes with the cursor set, and a rerun after an interrupted edge pass finds the cursor at its end: both finish, write `git_head` and drop the pass, so the namespace's cross-file references stay unbound and nothing says so. The run now records why it owes the pass (`first-backfill`, or `requested` for `--edges-second-pass`) under `backfill_edges_owed:index<suffix>` before its first batch, and clears the record once the pass is done. A resumed run or a rerun reads the record and runs the pass; `--no-edges-second-pass` declines it and clears the record. A `--paths-file` repair records nothing, as before. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
9 tasks done
zlareb1
requested changes
Nov 26, 2026
zlareb1
left a comment
Member
There was a problem hiding this comment.
The persisted record survives cancellation. A partial pass also needs to leave work owed.
KaloyanNaumov
marked this pull request as draft
November 26, 2026 20:49
Contributor
Author
|
Thanks for the review. Converting to draft while I address it; a new head and the replies will follow, so no need to look at this head again. |
The second edge pass returns per-file write failures in its error count, yet the owed record was cleared whenever the pass returned. A file whose edge write failed then never got another pass: the record was gone and the run published its watermark. Clear the record only when the pass reports no errors; a rerun repeats it. The new test fails one file's edge write, checks the record stays owed, and shows a clean rerun running the pass again and clearing it. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
KaloyanNaumov
marked this pull request as ready for review
November 26, 2026 21:03
zlareb1
approved these changes
Nov 26, 2026
zlareb1
left a comment
Member
There was a problem hiding this comment.
An edge pass with a per-file write error leaves the owed record in place. The regression verifies that a rerun executes the pass again and clears the record after a clean result.
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.
Related: #1540, #1552
TL;DR: A first full backfill interrupted before its edge pass finishes without that pass when it is resumed, so the namespace's cross-file references stay unbound and nothing says so. The run now records that it owes the pass before its first batch and clears the record once the pass finishes without errors, so a resumed run, or a rerun after an interrupted pass or one that ended with a failed file write, runs it.
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):
A first
loom code backfillthat is interrupted (a held org, a SIGTERM, a crash) now runs its edge second pass when it is resumed, instead of finishing with its cross-file references unbound.Why
A namespace's first full backfill implies the edges-only second pass, because files are indexed in tree order: a call into a file later in the tree binds nothing until the pass re-derives it.
second_pass_wantedimplied the pass only while the cursor was empty. Two runs lost it:Both write
git_headand finish.What changes
backfill_edges_owed:index<suffix>incode_index_statebefore its first batch. The reason isfirst-backfill, orrequestedfor--edges-second-pass. The record is cleared once the pass finishes without errors; a pass that reports a failed file write leaves it owed, and the next run repeats the pass.--no-edges-second-passdeclines the pass and clears the record.--paths-filerepair records nothing, as before.second_pass_wantedbecomesedge_pass_owed, which returns the reason._record_edge_passreads and writes the record; it lives outside_backfill, which is at the function-length limit.Scope and risk
--edges-second-passsurvives an interruption.code.index_statusanswer._COUNTS_KEYS,_FINGERPRINT_KEYS). Every write of it comes before the phase's republish, so the published rows stay current.code_index.purgedeletes everycode_index_staterow of the namespace.bootstrap.CURSOR_KEY). A record a CLI run leaves is discharged by the next CLI run, which is at most one extra pass.Compatibility, rollout and rollback
Tests
tests/unit/test_cli_backfill_second_pass.pyruns_backfillover a stubbed store and checkout:test_a_first_backfill_interrupted_in_its_index_phase_gets_its_edge_pass_on_resumetest_a_rerun_after_an_interrupted_edge_pass_runs_the_passtest_declining_the_pass_clears_what_an_earlier_run_owedtest_a_resumed_run_runs_the_pass_an_earlier_run_owedtest_an_edge_pass_with_a_failed_file_write_stays_owed_until_a_rerun_finishes_cleanedge_pass_owedThe four
_backfilltests fail onmain(no pass on resume). The tests that importcode_backfill(13 files), plustest_exception_text_ratchet,test_tunable_constantsandtest_public_copy, pass in CI's environment (Python 3.12,uv sync --locked --extra dev --extra code). So doruff,mypyonserver/cli/code_backfill.py, and the function-length gate.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 wrote the diff and the tests. Checked: I reviewed the whole diff and its tests; the test and gate runs listed under Tests are the agent's.
I can explain every line of this diff and how it interacts with the rest of Loom.
How this was found
Found while reviewing
loom code backfill --workers(#1552), whose workers depend on this pass. Fixed on a fork, PR submitted.Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.main; no merged migration is edited. (No migration.)frontend/changed. (Unchanged.)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
Changes default behavior for resumed or rerun backfills (may add a full-tree edge pass) and introduces durable per-namespace state, but scope is limited to the CLI backfill index phase with no schema or wire changes.
Overview
Fixes a resume bug where a first full
loom code backfillcould finish without the edges-only second pass after an interrupt, leaving cross-file references unbound. The pass was only implied while the index cursor was still empty, so a mid-index resume (cursor set) or a rerun after a crash during the edge pass would skip it and still advancegit_head.The index phase now persists
backfill_edges_owed:index<suffix>incode_index_state:_record_edge_passwrites the reason (first-backfillorrequested) before the first batch,edge_pass_owed(replacingsecond_pass_wanted) decides whether the current run must run the pass (including honoring a storedrecordedvalue), and the key is cleared only after a successful edge pass.--no-edges-second-passdeclines and clears the record;--paths-filerepairs still record nothing. Operator docs describe the record/clear lifecycle.Unit tests expand
test_cli_backfill_second_pass.pywith stubbed_backfillruns for interrupt/resume, interrupted edge pass, declining the pass, and edge-pass errors.Reviewed by Cursor Bugbot for commit 948904c. Bugbot is set up for automated code reviews on this repo. Configure here.