Skip to content

fix(builder): serialize concurrent index builds - #36

Draft
JohnXu22786 wants to merge 4 commits into
mainfrom
fix/serialize-concurrent-index-builds
Draft

JohnXu22786 wants to merge 4 commits into
mainfrom
fix/serialize-concurrent-index-builds

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

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 --db pointed 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.

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
JohnXu22786 force-pushed the fix/serialize-concurrent-index-builds branch from 9ba43c3 to 22e3e9b Compare September 12, 2026 23:51
@JohnXu22786 JohnXu22786 reopened this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant