Skip to content

fix(j5): Crew archive removes worktrees whose PR was squash-merged - #1133

Merged
Jacksondr5 merged 3 commits into
j5/mainfrom
fix/crew-archive-squash-merged
Nov 21, 2026
Merged

Jacksondr5 merged 3 commits into
j5/mainfrom
fix/crew-archive-squash-merged

Conversation

@Jacksondr5

Copy link
Copy Markdown
Owner

Problem

Archiving a Crew right after its PR was squash-merged kept the builder's worktree as unmerged_commits and the tester's as unverified. That filed an Owner Inbox cleanup item for work that was already merged. Fixes #1103.

The issue guessed the PR status was stale. It wasn't. mergeKeepReason recognised a squash merge only through GitManager.branchPullRequest, and that lookup returns null for J5 branches in this checkout. Upstream's GitHub repository resolution follows gh's priority (upstream, then github, then origin). With no gh repo set-default, it queries pingdotgg/t3code, which has no PR for j5code/design-*. Every stored cleanup entry in the live database has pullRequestUrl: null, including #1099, #1101 and #1112. The tester failed for a second reason: its PR lookup is for its own branch, which has no PR, and that branch doesn't hold its detached HEAD.

What changed

In CrewWorktrees.mergeKeepReason, when HEAD is not an ancestor of the fetched default branch, the check now asks git merge-tree --write-tree <default> HEAD. If merging HEAD in yields exactly the default branch's tree, the work is already there and the worktree counts as merged. The check uses git alone, so it doesn't depend on the host, and it covers a builder on the merged head and a tester detached at it. The existing pull request path stays as a fallback.

The check still keeps a worktree whenever there's doubt:

  • Uncommitted changes are checked first, as before.
  • Commits beyond the merged head change the merge result, so the worktree is kept.
  • A conflict, or a default branch that has since changed the same lines, also keeps it.

The same check feeds the archive estimate, so the archive confirmation shows the same verdicts.

The Crews definition's AC19 now says "commit or content".

Live testing

No live server run: the change is a server-only git check with no UI of its own. Runtime confirmation against real refs in this repository:

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior: a new case in CrewWorktrees.test.ts covers a squash-merged builder, a tester detached at its commit, and a seat with a commit beyond it, with no PR found. It failed on j5/main with kept unmerged_commits / kept unverified.
  • UI changes: none
  • Live testing: the section above says what ran and what did not
  • Upstream-owned files: none edited
  • Upstream product: unchanged. Upstream's repository resolution is left as it is.
  • Surfaces: the server decides. Client-runtime, web and mobile only render the reason, so nothing there changes. Open Inbox items aren't re-checked: an item is filed once per archive, and there's no later pass that could clear one cheaply.
  • Docs: docs/j5/product/features/crews.md AC19 rewritten

Claude Opus 5.5 in Claude Code (J5 Code).

🤖 Generated with Claude Code

A squash merge was recognised only through the host's pull request
lookup, which finds nothing in a fork checkout whose GitHub resolution
picks the upstream remote. The archive now also counts a worktree as
merged when merging its HEAD into the fetched default branch changes
nothing, so a builder on the merged head and a tester detached at it
both go.

Fixes #1103

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Nov 21, 2026 7:53pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 17 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 3 included reviews currently available. Your 44 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f92322e and f6a4348.

Files selected for processing: 3

  • apps/server/src/j5/a2a/CrewWorktrees.test.ts
  • apps/server/src/j5/a2a/CrewWorktrees.ts
  • docs/j5/product/features/crews.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 effective changed lines (test files excluded in mixed PRs). labels Nov 21, 2026
… branch or tag holds

A clean, no-op merge into the default branch does not prove that removing the
worktree loses nothing: a merge=ours driver, an edit and its revert, or an
empty commit all pass. The content check now removes a worktree only while a
branch or tag holds its HEAD; a detached commit nothing holds is kept as
unverified. Git's stderr is logged at debug when merge-tree or rev-parse
refuses to run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:M 30-99 effective changed lines (test files excluded in mixed PRs). and removed size:S 10-29 effective changed lines (test files excluded in mixed PRs). labels Nov 21, 2026
…ed commit

A symbolic tag can point into the worktree's own refs (refs/worktree/*),
which go with the worktree. Count only direct refs as holders, so removing
the worktree can never leave its commit unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jacksondr5

Copy link
Copy Markdown
Owner Author

Review outcome:

  • Opus 5.5: approved at 9/10.
  • Sol 6.2: found blockers over three rounds; all are resolved except one, which is declined below.
    • Round 1: a no-op merge isn't enough evidence to remove a worktree. Fixed: a content match counts only when a branch or tag still holds the commit.
    • Round 2: a symbolic tag pointing into refs/worktree/* counted as a holder. Fixed: only direct refs count. Regression seat added; it fails without the fix.
    • Round 3: a loose tag file hand-symlinked on disk to the worktree's own ref file still passes. Declined. Nothing in git, J5 or our agent workflows creates such a ref; it takes deliberate filesystem surgery inside .git. AGENTS.md: error out instead of building machinery for rare or nearly impossible cases.

Merging once CI is green.

— J5 Code Director (Claude Opus 5.5)

@Jacksondr5
Jacksondr5 enabled auto-merge (squash) November 21, 2026 20:14
@Jacksondr5
Jacksondr5 merged commit aa203ce into j5/main Nov 21, 2026
33 checks passed
@Jacksondr5
Jacksondr5 deleted the fix/crew-archive-squash-merged branch November 21, 2026 20:15

This branch was successfully deployed

1 active deployment
Preview — f6a4348e Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crew archive keeps worktrees whose PR was just squash-merged

1 participant