Repository navigation
fix: Prevent maintenance from rejecting foreground writes - #806
Draft
buildingjoshbetter wants to merge 1 commit into
Draft
buildingjoshbetter wants to merge 1 commit into
buildingjoshbetter wants to merge 1 commit into
Conversation
This was referenced Oct 8, 2026
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.
Scope
Foreground admission prerequisite for #753, stacked on #805. Prevent background model-lock ownership from rejecting a valid foreground add after it has already acquired the SQLite writer. This PR does not activate the new scheduler or close #753.
Changes
Reproductions and review
An event-driven test executes the actual clustering snapshot and add paths: add waits without SQLite writer ownership, an independent connection can write, then source and both vectors commit after clustering releases the model lock. Other controls cover a background writer yielding model admission, same-engine add/update ordering, borrowed sentinels, stale generations and lock release after SQLite failures.
The first full suite exposed a second genuine race: connection-wide transaction state was inspected outside the engine lock. The correction serializes capture classification only. The original concurrent-add and concurrent-consolidate tests remain unchanged. Its new add/update negative control fails twice before correction and passes afterward.
Two existing publication tests now require the intentional new model-before-writer order while retaining commit, RELEASE, rollback and output assertions. The cached-model fixture now represents a loaded model. A source-position assertion for style computation was replaced by AST containment/order checks and a runtime test proving style computation occurs outside engine/model/SQLite ownership and passes the exact computed object into publication. Independent mutation controls reject style computation inside a lock and duplicate computation.
Validation
53d7e66cc34feb5f24963d8a25206e6c85d441930f5fb41debad65648d9f8883.Limits
Waiting before writer ownership is not a latency bound; cluster snapshots can still retain the model lock while scanning source data. Cached inference can still run inside a caller-owned transaction. The borrowed fence covers savepoint release, not a later caller-controlled outer commit. If SQLite rejects rollback itself, pending changes may remain; the connection owner must recover that transaction.
All test inputs are generated. No personal memories, transcripts, credentials or local identity are included. No native performance, memory-budget or MPS/thermal improvement is established. Models, rerankers, dtype, dimensions and retrieval depth are unchanged. No main merge, release or issue closure.