[codex] Recover live graph refresh after DB contention#40
Merged
Conversation
Treat Ladybug lock conflicts as expected refresh contention instead of fatal watcher failures. The graph access path now shares transient-error classification, bounded retry, and a repo-local write-intent marker. Incremental writes delete incoming row IDs before COPY so retries and manifest/DB drift do not trip duplicate primary keys. Constraint: Ladybug enforces its own DB lock and can reject concurrent readers or writers during refresh Rejected: Add an external file-lock dependency | stdlib write-intent marker and Ladybug retry handling are sufficient for this recovery path Confidence: high Scope-risk: moderate Directive: Keep MCP refresh loops supervising after recoverable write failures; do not reintroduce fatal propagation from refresh_batch Tested: cargo fmt -- --check; cargo clippy --all-targets -- -D warnings; cargo test; targeted cargo test watch/mcp/graph/db_writer filters; target debug check-health Not-tested: Live restarted MCP daemon under an externally held Ladybug lock
Windows cargo test fell back to building Ladybug from source after the upstream prebuilt Windows archive returned 404, and the debug C++ build exceeds MSVC library/object limits before Rust tests can run. Keep Linux and macOS on the normal debug cargo test path, but run the Windows test leg in release profile, matching the already-passing Windows package build path while still executing the Rust test suite. Constraint: Upstream Ladybug 0.17.1 Windows static archive URL currently returns 404 in CI Rejected: Disable Windows tests | would remove platform coverage instead of preserving the test suite Rejected: Add a new file-lock or build dependency | unnecessary for a CI-only upstream C++ debug-link limit Confidence: medium Scope-risk: narrow Directive: Revisit this once upstream publishes a usable Windows prebuilt lbug archive or the source build no longer exceeds MSVC debug-link limits Tested: cargo run -p xtask -- release-gate Tested: cargo fmt -- --check Tested: cargo test --workspace --locked --release
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.
Summary
Make live graph refresh resilient when Ladybug DB contention or partial writes occur. DB lock conflicts are now treated as recoverable refresh contention instead of fatal watcher failures.
Root Cause
The MCP refresh loop and standalone
codebase-graph watchpropagated refresh write failures out of their watcher loops. A transient Ladybug lock conflict could therefore terminate live refresh, leaving the MCP session stale until the server was restarted.Changes
.codebaseGraph/.last_error_countandlast_retry_unix_msfields.codebase-graph watchretry behavior with MCP refresh and kept--max-iterationstied to successful refreshes.Validation
cargo fmt -- --checkcargo clippy --all-targets -- -D warningscargo test./target/debug/codebase-graph check-health --repo-root .cargo build --releasecodebase-graph reinstall --repo-root . --mode full --mcp-client codex --instructions-target skip --jsonlast_rebuilt=1and thenlast_deleted=1, and verified exact deleted path query returned0.