fix(builder): serialize concurrent index builds - #36
Draft
JohnXu22786 wants to merge 4 commits into
Draft
JohnXu22786 wants to merge 4 commits into
JohnXu22786 wants to merge 4 commits into
Conversation
Prevent overlapping builds for one project root from interleaving database writes. Reject source changes before payload and final metadata commits so stale scans cannot be published.
Restore the database snapshot when a project freshness check detects a mixed source state, so earlier payload transactions cannot survive a failed build. Keep the per-root lock beside the configured database to support external indexes on read-only source trees.
Snapshot an existing database before force rebuilds so freshness failures can restore the last valid index and metadata. Add regression coverage for forced builds that observe a source change.
Skip project freshness assertions when discovery reported an error, so transient discovery gaps retain the existing index instead of being treated as a stale build.
JohnXu22786
force-pushed
the
fix/serialize-concurrent-index-builds
branch
from
September 12, 2026 23:51
9ba43c3 to
22e3e9b
Compare
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.
What this PR does
Before this PR:
Builds for the same project root could overlap and commit an older scan after a newer build, leaving stale contents in SQLite. A source edit during scanning could also be committed without detection. A late project freshness failure could leave earlier per-file transactions committed, and the lock setup required the source root to be writable even when
--dbpointed elsewhere.After this PR:
Per-root builds are serialized across threads and processes with a lock beside the configured database. Content freshness is checked before each payload transaction commits and again before final metadata commit. If a project freshness check fails after earlier writes, the pre-build SQLite snapshot is restored so stale payloads, digests, and metadata do not survive; the next run can retry safely. Focused concurrency, freshness, rollback, and external-database regression tests cover these paths.
Type of change
Bug fix
Breaking changes (if any)
None.