Repository navigation
fix: recover schema-ahead DB migration + worktree branch-resolution collision - #471
Conversation
…d DBs, warn on off-branch dev-install The live ~/.agentflare/agentflare.db was at schema version 11 (item_assignment_events, from the unpushed feat/pm-fast-follows branch) while master's binary only defined migrations 0001-0010, so every item/claim MCP call failed with an opaque rusqlite_migration 'too high' error and no way to tell why. - Forward-port migration 0011 (item_assignment_events) onto master so the current binary can open the DB again. - agentflare-db-kit::open::open_file now detects DatabaseTooFarAhead specifically and reports the recorded schema version plus remediation steps instead of the bare upstream error string, for every DB that goes through this shared opener. - dev-install now warns when installing from a non-default branch, since it replaces the one shared binary+db and any migration it carries can't be downgraded by reinstalling from master later. Agentflare-Agent: claude-code_2-1-228_agent Agentflare-Branch: fix/backend-migration-0011
… freshly recomputed slug create_worktree/push_branch called task_branch_name(item) fresh every time, which re-slugs from the item's current title. A worktree already sitting at .worktrees/task/<seq> on a different branch (a legacy bare task/<seq> branch predating the slugged naming scheme, or simply because the item was renamed since its first claim) then fails the exact-match re-claim check, so git worktree add collides with the already-occupied path instead of reusing it -- item #447's worktree (bare task/447 branch) hit this on every dispatch attempt, silently looping forever (claim succeeded but no worktree was created). resolve_worktree_branch now checks what branch a pre-existing worktree is actually on (any task/<seq> or task/<seq>-* branch) before falling back to the freshly-derived slug, so a re-claim reuses it instead of colliding. Agentflare-Agent: claude-code_2-1-228_agent Agentflare-Branch: fix/backend-migration-0011
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe backend adds an item assignment-events migration and schema-ahead detection. Git worktrees preserve legacy or renamed task branches. ChangesDatabase migration handling
Worktree branch reuse
Development installation branch warning
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/agentflare-db-kit/src/open.rs`:
- Around line 44-46: Update the user_version query in the open/schema-version
flow to propagate the SQLite error instead of using unwrap_or(-1). Ensure the
retrieved version is returned through the existing Result path so
Error::SchemaAhead always uses the actually recorded schema version.
In `@src/dev_install/mod.rs`:
- Around line 175-176: Update resolve_default_branch and the surrounding
migration check so inconclusive resolution returns an explicit unknown state
instead of the current branch; in the current != default logic, handle unknown
conservatively by emitting the migration warning. Add a regression test covering
a repository with default branch trunk and current branch feature when
origin/HEAD, main, and master are unavailable.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6427e16d-e888-4015-9bc9-cff1b9d50ebf
📒 Files selected for processing (6)
crates/agentflare-backend/src/db.rscrates/agentflare-backend/src/migrations/0011_item_assignment_events.sqlcrates/agentflare-db-kit/src/open.rscrates/flare-git-core/src/worktree.rscrates/flare-git-core/src/worktree_tests.rssrc/dev_install/mod.rs
- open.rs: propagate the PRAGMA user_version query error instead of swallowing it into a -1 sentinel, so SchemaAhead always carries the actually recorded version. - Add resolve_default_branch_known(), returning None instead of falling back to the current branch when no authoritative default (origin/HEAD, local main/master) is resolvable. dev-install's off-default-branch warning now uses it and warns conservatively on 'unknown' instead of silently matching current == fallback-to-current and never firing. Agentflare-Agent: claude-code_2-1-228_agent Agentflare-Branch: fix/backend-migration-0011
|
@coderabbitai review |
|
Summary
Two independent, verified infra fixes found and fixed while diagnosing why
mcp__flare__item/claimwere completely broken this session:1. Backend migration 0011 recovery + schema-ahead diagnostics
~/.agentflare/agentflare.dbwas at schema version 11 (from an unpushedfeat/pm-fast-followsdev-install earlier), but master's binary only defined migrations 0001-0010 — every DB open failed with an opaquerusqlite_migration"too high" error and no indication why.0011_item_assignment_events.sqlonto master so the current binary can open the DB again.agentflare-db-kit::open::open_filenow detectsDatabaseTooFarAheadspecifically and reports the actual recorded schema version plus remediation steps, for every DB that goes through this shared opener (backend, store, jobs, memory).dev-installnow warns when installing from a non-default branch, since it replaces the one shared binary+db and any migration it carries can't be downgraded by reinstalling from master later.2. Worktree branch-resolution collision (blocked all re-dispatch of items with a pre-existing worktree)
create_worktree/push_branchrecomputedtask_branch_name(item)fresh on every call — a slug derived from the item's current title. A worktree already checked out to a different branch (a legacy baretask/<seq>branch predating the slugged naming scheme, or simply because the item was renamed since its first claim) then failed the exact-match re-claim check, sogit worktree addcollided with the already-occupied path instead of reusing it — silently looping forever (claim succeeded but no worktree was created).resolve_worktree_branchnow checks what branch a pre-existing worktree is actually on (anytask/<seq>ortask/<seq>-*branch) before falling back to the freshly-derived slug, so a re-claim reuses it instead of colliding.Test plan
cargo test -p agentflare-db-kit— newa_database_migrated_by_a_newer_build_reports_schema_aheadregression test passescargo test -p agentflare-backend— migration suite passescargo test -p flare-git-core worktree— 57/57 pass, including 2 new regression tests reproducing the exact collision (legacy bare branch + renamed-item cases)cargo fmt --all --checkcleancargo clippy --locked -p agentflare-db-kit -p agentflare-backend -p flare-git-core -p agentflare --all-targets -- -D warnings -A unsafe_code -A clippy::pedanticcleandev-install, daemon self-restarted, confirmed real re-dispatch of a previously-stuck item with no errorsSummary by CodeRabbit
dev-installfrom a non-default branch.