Skip to main content

Module busy

Module busy 

Source
Expand description

Busy detection: determine whether a worktree is currently in use.

Two signals are combined:

  1. Session lockfile (explicit — gw shell/gw start write one)
  2. Process cwd scan (implicit — catches external cd + tool usage)

The current process and its ancestor chain are excluded so that Claude Code or a parent shell invoking gw delete on its own worktree does not self-detect as busy.

Structs§

BusyInfo
Information about a single process holding a worktree busy.

Enums§

BusySource
Signal source that flagged a process as busy.
BusyTier
Tier of a busy signal — controls refusal strength in gw delete. Hard signals (active Claude session, explicit lockfile) refuse with a strong message. Soft signals (process cwd scan) refuse with a warning. Both tiers are overridable by the same --force flag.

Functions§

detect_busy
Detect busy processes for a given worktree path.
detect_busy_lockfile_only
Fast busy detection using only the session lockfile.
detect_busy_tiered
Tiered busy detection: returns (hard, soft) separately so the caller can render distinct refusal messages.
self_process_tree
Returns the current process + all ancestor PIDs (via getppid chain). Memoized for the lifetime of the process — the ancestry does not change during a single gw invocation.
self_siblings
Returns the memoized sibling set (see compute_self_siblings).