Repository navigation
fix(server): clean up worktrees with initialized submodules - #20368
juliusmarminge merged 10 commits into
Conversation
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — The server cleanup path now recursively inspects submodule repositories and can force-remove eligible worktrees, materially changing destructive runtime behavior. Although the change includes broad safety tests, the new recursive logic and force-removal semantics merit human review. You can add or adjust custom eligibility rules. Learn more. |
|
Warning Review limit reachedOnly developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing. Next included review available in 12 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
1b9d4ca to
cdaeeca
Compare
|
Taking over this one for batch worktree-git-11. I will reduce the real-Git regression tests, rebuild the smallest safe submodule cleanup change, and run independent adversarial reviews. No merge. |
…5-cleanup-worktrees-with-submodules
Extend the nested keep-policy regression to require surviving .env bytes after deinitialization. Expected red on the current runtime: 141 pass, one fails because cleanup removes the worktree and file. Leave the runtime fix to the separate implementation round.
Merges `pingdotgg/t3code` `main` at `e64766c56a` (367 commits from `143ab1606d`) into the fork. It branches from `main`; no other merge PR is open. ## Numbers - Landed: 2630 files from `git diff --stat HEAD^1 HEAD`, against 2629 in the upstream range. The gap: - Kept deleted: `pair.ts`, `pair.test.ts` and `useDiscoveredLocalServers.test.ts`. - Kept as fork files: `branding.test.ts` and `addBrowserSurface.test.ts`. - Extra on the merge side: four ported fork browser tests, `fork/ThreadParentLine.tsx` and `inventory.json`. - Fork delta: 812 files, down from 817. ## Conflicts (40, each by its preflight verdict) - **Upstream's test prune (pingdotgg#22557):** upstream's deletions win, fork-only tests stay, and fork adaptations of deleted upstream tests are dropped. - Upstream's deletion accepted for the `ThreadDetailsPrRows`, `PreviewEmptyState`, `previewEmptyStateLogic`, `projectScriptEditor.permissions` and `terminalSessionAvailability` tests. - Four fork browser tests are ported to the new `require-disposable-render` pattern: ThreadForkDialog, MoatlessArtifactChip, PreviewView.frame and MobileSidebarDrawer. - **`threadRoutes.ts`, `ThreadRouteView.tsx`, `ChatView.tsx`:** take upstream's `unlistedThreadDetail` (pingdotgg#19724), plus three fork changes: - An unlisted thread is "missing" once its subscription has failed. - A closed thread is not redirected by `archivedAt`, because it is absent from a Moatless listing and still opens by URL. - `onOpenRelatedThread` shows its toast only for a deleted shell. The `unlisted-thread-adoption` inventory entry now owns `threadRoutes.test.ts` and `ChatView.tsx`. - **`AGENTS.md` (`decide`):** kept the fork bullet and appended upstream's test rules and browser-test section. - **Upstream's change with the fork delta re-stated:** `BranchToolbar` (`showWorkspaceControls`), `GitActionsControl`, `ChatOverlayHosts`, `FilePreviewPanel`, `projectFilesQueryState`, `usePreviewSession` (on upstream's `inactiveAtom`) and `useThreadActions`. - **`getSidebarForkParentThreadId`:** upstream removed it, so it moves into `fork/ThreadParentLine.tsx`. - **New inventory entries:** the `branding-test` path policy and the `preview-session-use-atom-value` duplicate-add exception. - **Sweep:** 19 owned-concern hits, all upstream-owned and taken as upstream's. No new workflow. ## Feature classification ### Usable as-is - Mermaid rendering through pele (pingdotgg#21472) and project icon previews (pingdotgg#20372). - Dialog and composer polish, PR panel fixes and centred tables. - The Waiting thread state (pingdotgg#21500), which shows once the backend sends `blockedOnThreadWait`. - The even-pace tick on Limits (pingdotgg#22408). ### Unsupported in Moatless / needs implementation - `device.easAccount` and EAS Simulator device hosts (pingdotgg#21841–pingdotgg#21846). Added to the `UnsupportedMethodError` union, and the Integrations page that holds them is already flag-gated. - `projects.listIgnoredFiles` and the `ignoredFileListing` capability, which "Add project to another machine" uses (pingdotgg#22180). Added to the union. The dialog falls back to tracked files only while the capability is absent. - `pullRequests.changeBreakdown` (pingdotgg#22189, pingdotgg#22255). Its union already carries `UnsupportedMethodError`, and the tooltip drops the split when the call fails. - T3 Connect reachability (pingdotgg#22172). - Scheduled-task webhook filters and dedupe (pingdotgg#22194, pingdotgg#22234). - `lastEventLoopStall` (pingdotgg#22213) and the `previewClose` scope (pingdotgg#22156). - `compactIdleThreads` and `autoCompactThreshold` (pingdotgg#21682). - MCP diff tools (pingdotgg#15464), the install id (pingdotgg#21506) and the writing-style setting (pingdotgg#22203). ### Backend behavior to consider reproducing in Moatless - **Settlement and waits:** `blockedOnThreadWait`, orphaned follow-ups and delegated waits (pingdotgg#21499, pingdotgg#22581, pingdotgg#20037, pingdotgg#20025). - **Stop and wake:** `latestRunStopRequested` stops a stopped usage-limit thread from auto-resuming (pingdotgg#21114). A wake run settles when the provider never opens the wake turn (pingdotgg#19196). Snooze survives a run's completion (pingdotgg#22202, pingdotgg#17118). - **Runs and shells:** run failures are persisted (pingdotgg#19646), and shell updates coalesce for a slow client (pingdotgg#14859). - **VCS:** bare repositories (pingdotgg#17340, pingdotgg#16688, pingdotgg#18152, pingdotgg#20368), stack layers (pingdotgg#20415, pingdotgg#20388), VCS safety fixes (pingdotgg#15036, pingdotgg#19802) and PR provider robustness (pingdotgg#18780). - **Other:** update and restart safety (pingdotgg#22253), terminal and checkpoint performance (pingdotgg#21242, pingdotgg#21291), resource metrics (pingdotgg#22122), provider polling (pingdotgg#18851) and tool-token expiry (pingdotgg#18552, pingdotgg#19491). `docs/fork/gaps.md` is updated under *Methods the backend does not dispatch* and *Runtime fixes upstream made to its own server*. ## Verification Full `verify.mjs` run: every check except `test` passes (duplicate-adds, tripwires, resolution-check, unsupported-methods with ADD 2 / DROP 0 / KEEP 2, lockfile, fmt, lint, typecheck and build). Test failures and what was done about each: - **Machine failures seen in earlier merges:** `shared` `AgentScope`, `t3` `OrchestratorReplayFixtures` and `provider-opencode` `OpenCodeServerLedger`. The `GitVcsDriver` and `RepositoryIdentityResolver` partial-clone tests fail because of the sandbox's `insteadOf` rewrite. - **New and environmental:** `t3` `ProviderInstanceRegistry` reads the sandbox's own `ANTHROPIC_*` and `CLAUDE_CONFIG_DIR`. With those unset, all 9 of its tests pass. - **`web`:** - The fork's `AppRoot.test.tsx` broke on upstream's new `useEffect` (pingdotgg#20886). It now stubs `useEffect` and passes. - Four browser files failed to import in the parallel run and pass alone. - **Playwright:** 1.60 wants chromium build 1223, which this sandbox lacks. Browser tests ran against 1243 through a symlinked `PLAYWRIGHT_BROWSERS_PATH`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- Moatless task: https://moatless.soaplabstest.com/tasks/c3df6407-7ad0-483c-a46c-e8b603326150
Git refuses to remove eligible worktrees after their submodules have been initialized. This fixes #20355 by inspecting populated submodules and stored nested repositories, then using one
--forceonly when Git requires it. Inspection failures, unpublished live refs, and policy-protected files retain the worktree. Indexed gitlinks also expose files added after deinitialization, which Git status omits.Rebuilt from @ScottN-PV’s original contribution, preserving contributor history and merging main. Nine added cases were reduced to five in the existing suite: 146 → 142 total, with all 137 baseline cases unchanged. Four rebuilt cases fail against main. Review found and fixed file loss after deinitialization under both file-protecting policies, plus symlink-parent and index-limit false retention. Both reviewers found no confirmed code findings in round three.
Verification at bffca7f: 142/142 real-Git service tests, server typecheck, scoped lint and formatting passed on Linux/Git 2.43.0. Temporary service probes also removed clean nested worktrees through symlinked parents under both policies and with a 77,132-byte index. Nonvisual server behavior; screenshots do not apply.
Evidence: proof and limits, before-fix ignored-file loss and default-policy loss (141 passed, one failed each), final independent 142-pass run, three service probes.
Human safety approval required before merging. Inspection and forced removal are not atomic against external writers. History checks local remote-tracking refs; tag/SHA-only commits can conservatively retain clean worktrees. The default policy also conservatively retains ignored files inside deinitialized directories, apart from the existing
node_modulesdirectory exception. Bounded or unreadable metadata retains the worktree. Git 2.34.1, macOS, Windows, iOS, Android, Electron desktop and browser flows were not executed. Published-head build/typecheck, lint and all eight server shards passed. A duplicate native-fingerprint run was cancelled and superseded by a successful run; skipped jobs remain skipped. No new review findings or submitted human reviews. Human safety approval is still missing; no merge performed.Tests: GPT-6-Astra; implementation: GPT-6.1-Sol; adversarial reviews: Claude Opus 5.5 and GPT-6-Sol. Codex and Claude Code harnesses, high reasoning effort, orchestrated through T3 Code.