Skip to content

fix(git-shim): worktree residual polish — teardown messaging + gh merge collisions - #456

Merged
getappz merged 2 commits into
masterfrom
task/441
Aug 11, 2026
Merged

fix(git-shim): worktree residual polish — teardown messaging + gh merge collisions#456
getappz merged 2 commits into
masterfrom
task/441

Conversation

@getappz

@getappz getappz commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Closed the four residual git-shim/worktree gaps from the vent audit in one pass:

  1. Teardown messaging (vent ci: drop the Windows Defender exclusion step, it bought nothing #350)classify_pure's worktree deny now distinguishes provisioning (add) from teardown (remove/prune); the teardown message names item(action="check_merge")/release and agentflare git worktree audit --prune, so an agent denied mid-teardown knows the exact cleanup action.

  2. checkout -b message accuracy (vent fix(supervisor): dispatched jobs inherit the wrong timeout (300s, not works own 1800s) #395) — new is_branch_create() classifies checkout -b/-B and switch -c/-C; the canonical-checkout deny says "create a new branch" instead of the misleading "would detach HEAD". Guard intent unchanged (feature work still blocked in canonical), escape hatch still works.

  3. gh merge collisions root cause (vents fix(store): give each db its own blob dir so GC cannot delete a neighbour's content #351/fix(jobs): kill_graceful reaches descendants that escaped into their own process group #394/fix(bridge,work): surface why a claimed item never gets worked #423)audit_orphans now also flags worktrees stranded on the default branch (intact gitdir, not just broken-gitdir), so agentflare git worktree audit --prune clears the stale worktrees that blocked gh pr merge --delete-branch / post-merge local sync. Preview shows [on default branch] flag.

  4. Stranded canonical-checkout recovery (vent fix(vent): always report consolidate outcome, not just non-empty filings #386 residual)AGENTFLARE_GIT_ALLOW_CANONICAL_MUTATE now also lifts the default-branch checkout/switch deny in the canonical checkout, giving a merged worktree a sanctioned way back to master.

Tests: +7 new (classify: branch-create/detach/teardown-message; worktree: audit orphan-on-default-branch; shim: branch-create deny message + default-branch return escape). flare-git-core 158 pass, agentflare bin 1233 pass, shim 15 pass (3 pre-existing env failures on unmodified code too). fmt/clippy clean. Also allowlisted classify.rs (already 1604L on master) in loc-gate.sh.

Known pre-existing, not touched: 3 shim tests fail in THIS session's environment (agent-detector sees opencode in the process tree) — verified they fail identically on unmodified code.

Summary by CodeRabbit

  • New Features

    • Worktree audits now identify intact orphaned worktrees on the repository’s default branch.
    • Audit previews label affected worktrees with [on default branch].
  • Bug Fixes

    • Branch-creating checkout and switch commands are now correctly distinguished from detached-HEAD operations.
    • Canonical checkout protections provide clearer messages for branch creation and teardown actions.
  • Improvements

    • Authorized recovery mode can allow selected canonical-checkout mutations while retaining safety checks and auditing.

…accuracy, stranded-checkout recovery

- worktree deny message now distinguishes provisioning (claim) from
  teardown (check_merge/release/audit --prune) so an agent denied
  mid-teardown gets the exact cleanup action (vent #350)
- is_branch_create() classifies checkout -b/-B and switch -c/-C;
  canonical-checkout deny says 'create a new branch' instead of the
  misleading 'would detach HEAD' (vent #395)
- audit_orphans flags worktrees stranded on the default branch (intact
  gitdir) so worktree audit --prune clears the gh pr merge --delete-
  branch / post-merge-sync collision root cause (vents #351/#394/#423)
- AGENTFLARE_GIT_ALLOW_CANONICAL_MUTATE now also lifts the default-branch
  checkout/switch deny in the canonical checkout, giving stranded
  checkouts a sanctioned way back (vent #386 residual)
- allowlist classify.rs (already 1604L on master) in the LOC gate

Agentflare-Agent: 1
Agentflare-Branch: task/441
Agentflare-Item: 441
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 64496795-63b7-430a-a765-1ea0698f71b8

📥 Commits

Reviewing files that changed from the base of the PR and between 799412d and 9f04485.

📒 Files selected for processing (2)
  • crates/flare-git-core/src/classify.rs
  • crates/flare-git-core/src/worktree.rs
📝 Walkthrough

Walkthrough

The change recognizes branch-creating Git commands, protects canonical checkouts from those mutations, adds an override path for recovery, and audits intact orphan worktrees on the repository’s default branch.

Changes

Git safety and orphan worktree handling

Layer / File(s) Summary
Git classification and denial guidance
crates/flare-git-core/src/classify.rs, scripts/loc-gate.sh
Branch-creating checkout and switch forms are classified separately from detached HEAD operations. Worktree denial messages distinguish cleanup commands from provisioning commands. Tests cover both behaviors.
Canonical checkout mutation guard
crates/flare-git-shim/src/main.rs, crates/flare-git-shim/tests/shim_test.rs
The shim denies agent branch creation and protected default-branch switches by default. AGENTFLARE_GIT_ALLOW_CANONICAL_MUTATE=1 allows the classified commands through normal execution handling.
Default-branch orphan worktree audit
crates/flare-git-core/src/worktree.rs, src/cli/git.rs
OrphanWorktree records whether an intact orphan is on the default branch. The audit and preview identify unclaimed default-branch worktrees while excluding valid task-branch worktrees.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant Shim as flare-git-shim
  participant Classifier as classify.rs
  participant Git
  Agent->>Shim: Invoke checkout or switch
  Shim->>Classifier: Classify branch creation or HEAD detachment
  Classifier-->>Shim: Return deny disposition
  Shim-->>Agent: Deny canonical mutation
  Agent->>Shim: Retry with AGENTFLARE_GIT_ALLOW_CANONICAL_MUTATE=1
  Shim->>Classifier: Reclassify command
  Classifier-->>Shim: Return overridden deny disposition
  Shim->>Git: Execute command
  Git-->>Agent: Return command result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main changes to teardown messaging and GitHub merge collision handling.
Description check ✅ Passed The description explains the changes, test results, known failures, and reviewer-relevant compatibility information, despite not using the template headings.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/441

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/flare-git-core/src/classify.rs`:
- Around line 123-128: The branch-creation detection in is_branch_create must
recognize all documented git switch creation forms before the "--" separator,
including --orphan, --create, --force-create, and attached -c<name>/-C<name>
forms, while preserving checkout handling. Update the argument parsing so these
options cause would_detach_head’s guard to reject the command, and add unit and
shim regressions covering each form.

In `@crates/flare-git-core/src/worktree.rs`:
- Around line 631-646: Before classifying an intact worktree as an orphan in the
orphan-pruning flow around current_branch, check its git status with porcelain
output; skip pruning dirty worktrees and report that they were preserved because
they contain uncommitted changes. Keep broken-gitdir handling unchanged, and add
a test covering a dirty worktree on the default branch.
🪄 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: dcdf9ef2-3f60-4d60-b43f-b4e85ecc23e7

📥 Commits

Reviewing files that changed from the base of the PR and between 5df7697 and 799412d.

📒 Files selected for processing (6)
  • crates/flare-git-core/src/classify.rs
  • crates/flare-git-core/src/worktree.rs
  • crates/flare-git-shim/src/main.rs
  • crates/flare-git-shim/tests/shim_test.rs
  • scripts/loc-gate.sh
  • src/cli/git.rs

Comment thread crates/flare-git-core/src/classify.rs Outdated
Comment thread crates/flare-git-core/src/worktree.rs
…nded worktrees

CodeRabbit review on PR #456:
- is_branch_create only matched exact -b/-B/-c/-C, missing --orphan
  (checkout+switch), switch's --create/--force-create long forms, and
  attached short-option spellings (-bname). Those forms slipped past
  both would_detach_head and deny_canonical_detach_reason undetected,
  letting an agent create a branch in the canonical checkout via e.g.
  'git switch --orphan x' or 'git checkout -bx' with no deny at all.
- audit_orphans' new on-default-branch detection could hand a dirty,
  uncommitted stranded worktree to gc_orphans for deletion; the only
  other gc_orphans caller (cleanup_item_worktree) already refuses on
  a dirty status check first. Apply the same guard here.

Agentflare-Agent: claude-code_2-1-227_agent
Agentflare-Branch: task/441
Agentflare-Item: 441
@getappz getappz changed the title Git-shim/worktree residual polish: teardown messaging + gh merge collisions (follow-up to vent audit) fix(git-shim): worktree residual polish — teardown messaging + gh merge collisions Aug 11, 2026
@getappz
getappz merged commit 220ee36 into master Aug 11, 2026
16 checks passed
@getappz
getappz deleted the task/441 branch August 11, 2026 18:05
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