Skip to content

fix: orphan restart release must not delete clean worktrees - #839

Merged
getappz merged 4 commits into
masterfrom
task/322-fix-orphan-restart-release-must-not-dele
Oct 2, 2026
Merged

getappz merged 4 commits into
masterfrom
task/322-fix-orphan-restart-release-must-not-dele

Conversation

@getappz

@getappz getappz commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Using systematic-debugging and lean-ctx to fix orphan-restart deleting clean worktrees. Checking skills and locating the release/cleanup path.lean-ctx unavailable (readonly DB) — falling back to native Grep/Read.Bypassing lean-ctx shell hook (LEAN_CTX_DISABLED) so verification can run.Checking whether reclaim resumes the item branch or recreates from default — that determines what orphan cleanup actually loses.Shadow mode is blocking native Grep/Read — using shell redirects for code access.Writing the failing test first (TDD), then the minimal preserve_worktree fix.Edit tools are seeing compressed lean-ctx views — patching via shell instead.Preserve test passed. Running the remaining cleanup/orphan regression tests.Orphan test looks stuck mid-cargo — killing it and rerunning alone with a timeout.All targeted tests passed. Cleaning probe files and committing.LOC gate blocked the commit — moving the new unit test out of the oversized action_tests.rs.Status: done — 8ad435c on task/322-fix-orphan-restart-release-must-not-dele

Change: Orphan-restart now uses release_and_comment_preserving_worktree → item_release with preserve_worktree: true, so #335 cleanup still runs on normal abandon but not on daemon-restart reconcile.

Tests (all pass):

  • item_release_preserve_worktree_leaves_a_clean_worktree
  • reconcile_orphaned_jobs_preserves_a_clean_item_worktree
  • item_release_removes_its_own_clean_worktree (abandon still cleans)
  • item_release_leaves_a_dirty_worktree_in_place
  • item_done_removes_its_own_clean_worktree

Concerns: Branch is ahead 1 / behind 1 vs origin/master. No dedicated check_merge worktree test re-run (that path untouched). Other release_and_comment failure paths still clean clean trees before rediscovery — only orphan-restart preserves.Done. Fix is committed as 8ad435c on task/322-fix-orphan-restart-release-must-not-dele.

Orphan-restart release now preserves clean worktrees; normal abandon still cleans them. Targeted unit tests passed before the commit.


Opened by cursor on flared:51bb8de6c33b for item #322 via agentflare.

Summary by CodeRabbit

  • New Features
    • Work-item releases can preserve the existing worktree, including committed files.
    • During orphaned-job recovery, worktrees are retained when claims are released.
  • Bug Fixes
    • Releases that request worktree preservation no longer clean up the worktree; other releases continue to clean up as before.

Daemon restart reconcile was routing through item_release cleanup (#335),
which wiped live mid-work checkouts before rediscovery. Add preserve_worktree
for that path so abandon releases still clean and reclaim can resume.

Agentflare-Agent: cursor
Agentflare-Branch: task/322-fix-orphan-restart-release-must-not-dele
Agentflare-Item: 322
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: b3cd2ab3-4961-4af6-bea5-da34ef817e4c

📥 Commits

Reviewing files that changed from the base of the PR and between 0b9a7af and 20cb719.

📒 Files selected for processing (1)
  • src/mcp_server/item.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/mcp_server/item.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

Release requests now support preserving an item worktree. The MCP release handler skips cleanup when the flag is true. Orphan-job reconciliation uses a CLI helper that enables the flag. Tests verify that committed files remain in the worktree.

Changes

Orphan worktree preservation

Layer / File(s) Summary
Release request contract and cleanup behavior
src/mcp_server/types.rs, src/mcp_server/item.rs, src/mcp_server/tests/item_release_worktree_tests.rs, src/mcp_server/tests/mod.rs
ItemRequest adds an optional preserve_worktree flag. When it is true, item_release skips worktree cleanup. The test checks that the worktree and committed file remain.
Orphan reconciliation release path
src/cli/work.rs, src/dashboard/orphan_reconcile.rs, src/dashboard/orphan_reconcile_tests.rs
A new CLI helper requests worktree preservation. Orphan reconciliation uses the helper, and its test verifies that the worktree and committed file remain.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 20cb7

The change keeps clean item worktrees in place during daemon-restart orphan recovery, and normal abandon releases still clean them up. No actionable merge-blocking risk was identified in the supplied context.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: preventing orphan-restart releases from deleting clean worktrees.
Description check ✅ Passed The description explains the change, reports targeted tests, and notes relevant risks. It is not organized under the repository template headings and does not include the requested test-plan checkboxe…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@getappz

getappz commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

Claiming self-repair for flared:51bb8de6c33b.

@getappz

getappz commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: fmt.

Please investigate and push a fix.

job: DZNQSc9xu_k1TDTgX1fB-

Co-authored-by: Cursor <cursoragent@cursor.com>

Agentflare-Agent: cursor
Agentflare-Branch: task/322-fix-orphan-restart-release-must-not-dele
Agentflare-Item: 322
@getappz

getappz commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI green

Checks are passing again.

@getappz
getappz merged commit f56b442 into master Oct 2, 2026
18 checks passed
@getappz
getappz deleted the task/322-fix-orphan-restart-release-must-not-dele branch October 2, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant