Skip to content

GC: collect worktree safety facts without blocking #3804

Closed

Description

@janicduplessis

Problem

GC still blocks while collecting the Git facts that decide whether a linked worktree must be kept. Status, dirty paths, HEAD, unpushed commits, submodule inventory and activity lookup run synchronous children, preventing a responsive in-process report.

Evidence

On origin/main e43aa3d, commands/gc/worktrees.ts collectWorktreeSweep invokes synchronous worktreeActivityOf, hasUncommittedWork, resolveFullRef, porcelainOf/dirtyPaths, unpushedCommits and hasPopulatedSubmodules. workspace/worktree.ts removalCheck has a 60-second budget and preserves unknown/timeout distinctions; HEAD and activity use the existing 10-second Git read budget. PR #3802 separately moves inventory discovery to async reads.

Cause

These fact readers also support destructive worktree revalidation and were built as synchronous CLI helpers. The report currently uses the same blocking entry points even though its aggregator is asynchronous.

Fix idea

Add asynchronous report reads using the same arguments, parsers, protection rules and budgets, and await them during collection. Preserve unknown/timeout refusal, full HEAD identity, detached-head and unpushed-commit protection, and populated-submodule checks. Keep synchronous revalidation at the locked destructive boundary. Verify delayed real-child liveness at each phase and timed-out status refusal, plus existing worktree loss guards. Merge-state/network policy, device reads and whole-report context/cancellation remain under #3546/#3783.

Activity

  1. janicduplessis commented on Oct 14, 2026

    @janicduplessis
    CollaboratorAuthor

    Claimed: perf/3804-async-gc-worktree-facts

  2. added
    type: featureAdds or changes behavior, including performance and polish
    priority: P2Normal; default when unsure
    area: clipackages/stim-cli, including its README and guide
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clipackages/stim-cli, including its README and guidepriority: P2Normal; default when unsuretype: featureAdds or changes behavior, including performance and polish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions