Merge pull request #4092 from proffesor-for-testing/fix/console-worktree-remove-fsmonitor

fix(console): worktree removal runs no fsmonitor or hooks and keeps untracked files
This commit is contained in:
rUv authored and GitHub committed 2026-10-12 11:49:30 -07:00
commit eaa2ebf2bd
18 files changed
+546 -38

No files matched your search

@@ -1,7 +1,7 @@
{
"name": "ruflo-console",
"description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",
"version": "0.43.1",
"version": "0.43.2",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
+4
View File
@@ -2,6 +2,10 @@
Newest first. One `## <version> — <date>` heading per version, then `feat:`, `fix:`, `breaking:` and `chore:` bullets (ADR-478). Built from git history; older versions: `git log -- plugins/ruflo-console`.
## 0.43.2 — 2026-10-12
- fix: removing a worktree no longer runs the repository's own programs, and no longer deletes unsaved files: `git worktree remove` runs its own status, which ran `core.fsmonitor` and the `post-index-change` hook, and with `status.showUntrackedFiles=no` it read a worktree holding new files as clean and deleted them. The removal, the worktree status probe, the changed-files read and `describe --dirty` now switch the fsmonitor (and for removal and describe, hooks) off, and list untracked files whatever the setting says (#4090, thanks @proffesor-for-testing, #4092)
- fix: a `filter.<name>.clean`, `.smudge` or `.process` command in a repository's config no longer runs when the console compares a worktree with HEAD: before the removal, the worktree status and the diff drill-down, it lists the configured drivers (a config read) and blanks each one on the command line; a driver name it cannot blank exactly refuses the probe instead of running it
## 0.43.1 — 2026-10-12
- fix: `ruflo tui` marks the page on screen in the page bar: on the AI page it kept the previous page lit (`5 Missions`, or `1 Overview` after a number key) because the bar was painted from the console view the session last showed and the AI page is not one; it is now drawn from the page itself, through Tab, Shift-Tab, letters, digits and resize
- fix: `ruflo tui --help` and the console README list the page keys as `1-6` and `o c s e m a` (they said `1-5`); a test holds the help text
+1 -1
View File
@@ -107,7 +107,7 @@ export async function syncAdrDigest(state: State, host: Host): Promise<void> {
/** Files changed in the project: uncommitted work, and commits since the mission began. Read-only git. */
export async function changedFiles(host: Pick<Host, 'run'>, cwd: string, sinceMs: number): Promise<string[]> {
const out = new Set<string>()
const status = await host.run(['git', '-C', cwd, 'status', '--porcelain'], 15_000).catch(() => null)
const status = await host.run(['git', '-C', cwd, '--no-optional-locks', '-c', 'core.fsmonitor=false', 'status', '--porcelain'], 15_000).catch(() => null)
for (const line of (status?.stdout ?? '').split('\n')) {
const path = line.slice(3).split(' -> ').pop()?.trim().replace(/^"|"$/g, '')
@@ -0,0 +1,52 @@
/**
* Filter drivers named by a repository's own config (filter.<name>.clean, .smudge, .process) are programs git runs while it compares a work tree
* with HEAD: status, diff and `worktree remove` all do. The console reads and removes worktrees of projects it did not make, so before such a
* command it lists the configured drivers (a config read; nothing runs) and blanks each one on the command line, where it outranks the
* repository's config. A driver name it cannot blank exactly stops the command (null) rather than letting the driver run.
*/
export type GitRun = (argv: readonly string[], timeoutMs: number) => Promise<{ stdout: string; exitCode?: number | null }>
/** The listing. `git config --get-regexp` exits 1 when nothing matches, which is the usual case and not a failure. */
export const FILTER_KEYS_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, '--no-optional-locks', 'config', '--name-only', '--get-regexp', '^filter\\..*\\.(clean|smudge|process)$']
/** Letters, digits, dot, underscore and dash only: anything else (an equals sign, a space, a control character) cannot be written as one exact -c key. */
const KEY = /^filter\.([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*)\.(clean|smudge|process)$/
/** The -c overrides that blank every listed driver, or null when a listed key is not one it can blank exactly. */
export function filterOverrides(listing: string): string[] | null {
const out: string[] = []
const seen = new Set<string>()
for (const line of listing.split('\n')) {
const key = line.trim()
if (key === '') continue
if (!KEY.test(key)) return null
if (seen.has(key)) continue
seen.add(key)
out.push('-c', `${key}=`)
}
return out
}
/**
* `argv` with the overrides right after `git`, or null: the argv does not start with git, the listing failed or threw, or a driver name cannot be
* blanked exactly. Callers treat null as "this probe is refused", the same as any other probe that could not be made safe.
*/
export async function filterGuarded(run: GitRun, dir: string, argv: readonly string[]): Promise<string[] | null> {
if (argv[0] !== 'git') return null
const listed = await run(FILTER_KEYS_ARGV(dir), 15_000).catch(() => null)
if (listed === null) return null
if (listed.exitCode !== 0 && !(listed.exitCode === 1 && listed.stdout.trim() === '')) return null
const overrides = filterOverrides(listed.stdout)
return overrides === null ? null : ['git', ...overrides, ...argv.slice(1)]
}
@@ -11,6 +11,7 @@
* A refusal, a missing file or a file too large is a stated reason, never an empty success.
*/
import { readBounded, type ReadCache } from './files'
import { filterGuarded } from './git-filters'
import { cleanLine, cleanPath, journalResult, type Capped, type Parsed } from './wf-activity'
import { activityOf, parsedStats, PARSED_BUDGET_CHARS, resetStore } from './wf-incr-store'
import { TAIL_BYTES, TRANSCRIPT_CAP, type WorkflowFs } from './workflows-read'
@@ -253,8 +254,8 @@ export const diffOf = (agent: WfAgent): { files: Diff; extra: number } | undefin
/**
* The fixed argv of the one process this module runs: no shell, the path is its own argument after `-C`, no external diff driver, no text
* conversion, no fsmonitor hook and no optional lock. A `filter.*.clean` command in the worktree's own config can still run when git compares
* the working tree with HEAD; that is why only a worktree inside this project's folder is read.
* conversion, no fsmonitor hook and no optional lock. A `filter.*.clean` command in the worktree's own config would run when git compares the
* working tree with HEAD, so loadDiff blanks every configured driver first (git-filters.ts); and only a worktree inside this project's folder is read.
*/
export const diffArgv = (worktree: string): string[] => ['git', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-C', worktree, 'diff', '--numstat', '--no-renames', '--no-color', '--no-ext-diff', '--no-textconv', 'HEAD', '--']
@@ -279,7 +280,8 @@ export async function loadDiff(agent: WfAgent): Promise<void> {
if (stat === undefined) notes.set(path, { phase: 'none', why: 'the worktree folder no longer exists' })
else {
const result = await b.host.run(diffArgv(path), 8000)
const guarded = await filterGuarded(b.host.run, path, diffArgv(path))
const result = guarded === null ? { stdout: '', stderr: "a filter driver in the repository's config could not be switched off", exitCode: 1 } : await b.host.run(guarded, 8000)
if (result.exitCode !== 0) notes.set(path, { phase: 'failed', why: cleanLine(result.stderr ?? `git exited ${result.exitCode}`, 100) || `git exited ${result.exitCode}` })
else {
@@ -12,6 +12,7 @@
* find /proc ... -printf '%p\t%l\n' what every process has as cwd, exe and open fd (own processes only)
* The one write, `git -C <main> worktree remove <path>` with no --force, lives in views/wf-worktrees.ts behind the confirm card.
*/
import { filterGuarded } from './git-filters'
import { plain } from './parse'
import { cleanText } from './wf-clean'
import type { WfRun } from './workflows'
@@ -46,13 +47,18 @@ export const REMOVABLE_DIRS = ['.claude/worktrees', '.git-worktrees'] as const
export const LIST_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, 'worktree', 'list', '--porcelain']
// status is the one probe that can run a program from the repository's config (core.fsmonitor) and that refreshes the index (a write, and a lock another
// session's git may want): both are switched off, after '-C <dir>' so the directory stays the third word.
export const STATUS_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, '--no-optional-locks', '-c', 'core.fsmonitor=false', 'status', '--porcelain=v1']
// session's git may want): both are switched off, after '-C <dir>' so the directory stays the third word. Untracked files are listed whatever
// status.showUntrackedFiles says: with it at 'no' a worktree holding new, unsaved files would read clean, and removal deletes them.
export const STATUS_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, '--no-optional-locks', '-c', 'core.fsmonitor=false', 'status', '--porcelain=v1', '--untracked-files=normal']
/** Ignored files and folders (a folder is one entry): 'git worktree remove' deletes these too, and they are where a .env or a key lives. */
export const IGNORED_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, '--no-optional-locks', '-c', 'core.fsmonitor=false', 'ls-files', '--others', '--ignored', '--exclude-standard', '--directory']
export const AHEAD_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, 'rev-list', '--left-right', '--count', 'origin/main...HEAD']
export const REF_ARGV = (dir: string): readonly string[] => ['git', '-C', dir, 'log', '-1', '--format=%ct', 'origin/main']
export const REMOVE_ARGV = (main: string, path: string): readonly string[] => ['git', '-C', main, 'worktree', 'remove', path]
// Removal runs its own `git status` on the worktree first. That runs core.fsmonitor and fires post-index-change from the repository (its
// config or .git/hooks), so both are switched off. It also skips untracked files when status.showUntrackedFiles is 'no', and then deletes
// them without --force, so the setting is pinned to git's default. Still possible: a filter.<driver>.clean or .process command (see diffArgv
// in wf-drill-io.ts), and changes hidden by index flags (assume-unchanged, skip-worktree, core.ignoreStat), which git's check does not see.
export const REMOVE_ARGV = (main: string, path: string): readonly string[] => ['git', '-C', main, '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null', '-c', 'status.showUntrackedFiles=normal', 'worktree', 'remove', path]
export const PROCS_ARGV: readonly string[] = ['/usr/bin/find', '/proc', '-maxdepth', '3', '-regextype', 'posix-extended', '-regex', '/proc/[0-9]+/(cwd|exe|fd/[0-9]+)', '-lname', '/*', '-printf', '%p\\t%l\\n']
// eslint-disable-next-line no-control-regex
@@ -178,12 +184,19 @@ const oneLine = async (io: WtIo, argv: readonly string[], timeoutMs: number): Pr
/** Whether `cwd` is this worktree or inside it: the one a session is working in. */
export const isCurrentDir = (cwd: string, path: string): boolean => cwd === path || cwd.startsWith(`${path}/`)
/** A probe that compares the work tree with HEAD can run a filter driver from the repository's config (git-filters.ts): it runs with them blanked, or is an unknown. */
const guardedLine = async (io: WtIo, dir: string, argv: readonly string[], timeoutMs: number): Promise<string | null> => {
const guarded = await filterGuarded(io.run, dir, argv)
return guarded === null ? null : oneLine(io, guarded, timeoutMs)
}
async function probeOne(io: WtIo, entry: WtEntry, cwd: string, runs: readonly WfRun[]): Promise<WtRow> {
const base: WtRow = { ...entry, dirty: null, ignoredSecrets: null, ahead: null, behind: null, createdMs: null, maker: makerOf(entry, runs), isCurrent: isCurrentDir(cwd, entry.path) }
if (!entry.isSafe || entry.isBare || entry.isPrunable) return base
const [status, counts, ignored, link] = await Promise.all([oneLine(io, STATUS_ARGV(entry.path), 30_000), oneLine(io, AHEAD_ARGV(entry.path), 15_000), oneLine(io, IGNORED_ARGV(entry.path), 30_000), io.stat(`${entry.path}/.git`).catch(() => undefined)])
const [status, counts, ignored, link] = await Promise.all([guardedLine(io, entry.path, STATUS_ARGV(entry.path), 30_000), oneLine(io, AHEAD_ARGV(entry.path), 15_000), oneLine(io, IGNORED_ARGV(entry.path), 30_000), io.stat(`${entry.path}/.git`).catch(() => undefined)])
const pair = counts === null ? null : /^(\d+)\s+(\d+)\s*$/.exec(counts)
return {
+1 -1
View File
@@ -183,7 +183,7 @@ export const register: Register = (on, raw: PluginOptions) => {
const built = here
.run(['git', '-C', root, 'rev-parse', '--show-prefix'], 3_000)
.then(prefix => (prefix.exitCode === 0 && isOurCheckout(prefix.stdout) ? here.run(['git', '-C', root, 'describe', '--always', '--dirty', '--abbrev=7'], 3_000) : null))
.then(prefix => (prefix.exitCode === 0 && isOurCheckout(prefix.stdout) ? here.run(['git', '-C', root, '--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null', 'describe', '--always', '--dirty', '--abbrev=7'], 3_000) : null))
.then(described => {
setBuild(described !== null && described.exitCode === 0 ? buildOf(described.stdout) : '')
here.invalidate()
+1 -1
View File
@@ -2,4 +2,4 @@
* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest
* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.
*/
export const CONSOLE_VERSION = '0.43.1'
export const CONSOLE_VERSION = '0.43.2'
@@ -12,6 +12,7 @@
import type { RenderElement } from 'claude-code'
import type { ActionSpec } from '../actions'
import { filterGuarded } from '../data/git-filters'
import { plain } from '../data/parse'
import { cleanText } from '../data/wf-clean'
import { checkProcs, failureOf, inUseOf, planRemoval, readSummary, readWorktrees, REMOVE_ARGV, REMOVE_MAX, whyKept, type ProcCheck, type WtIo, type WtRead, type WtRow } from '../data/wf-worktrees'
@@ -180,7 +181,15 @@ export function removalSpec(env: SlotEnv): ActionSpec | null {
continue
}
const result = await host.run(REMOVE_ARGV(root, path), 60_000)
// git worktree remove runs its own status on the worktree, which can run a filter driver from the repository's config: blank them first
const guarded = await filterGuarded(host.run, path, REMOVE_ARGV(root, path))
if (guarded === null) {
skipped.push(`${label}: could not make git safe to run here (a filter driver in the repository's config could not be switched off)`)
continue
}
const result = await host.run(guarded, 60_000)
if (result.exitCode === 0) gone.push(label)
else skipped.push(`${label}: git said ${cleanText(plain(result.stderr || result.stdout, 100)) || `exit ${result.exitCode}`}`)
+2 -2
View File
@@ -11,9 +11,9 @@ step() { printf "→ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
step "1. plugin.json declares ruflo-console 0.43.1"
step "1. plugin.json declares ruflo-console 0.43.2"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
&& grep -q '"version": "0.43.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
&& grep -q '"version": "0.43.2"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
step "2. hooks.json names exactly one module and no classic hook commands"
grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \
+6 -3
View File
@@ -1,7 +1,8 @@
/**
* A stand-in for git and /proc for the worktree specs: a fixed list, per-path dirty and ahead counts, ages and a process listing.
*/
import { AHEAD_ARGV, IGNORED_ARGV, LIST_ARGV, parseProcs, PROCS_ARGV, REF_ARGV, STATUS_ARGV, type WtIo, type WtRead, type WtRow } from '../../hooks/data/wf-worktrees'
import { FILTER_KEYS_ARGV } from '../../hooks/data/git-filters'
import { AHEAD_ARGV, IGNORED_ARGV, LIST_ARGV, parseProcs, PROCS_ARGV, REF_ARGV, REMOVE_ARGV, STATUS_ARGV, type WtIo, type WtRead, type WtRow } from '../../hooks/data/wf-worktrees'
import type { Kit } from '../../hooks/views/common'
export const NOW = Date.parse('2026-10-06T12:00:00.000Z')
@@ -63,14 +64,16 @@ export function ioOf(w: World): WtIo {
const dir = argv[2] ?? ''
const key = argv.join(' ')
// the filter-driver listing (git config --get-regexp): a repository with none exits 1 and prints nothing
if (key === FILTER_KEYS_ARGV(dir).join(' ')) return { stdout: '', stderr: '', exitCode: 1 }
if (key === PROCS_ARGV.join(' ')) return { stdout: w.procs, stderr: 'find: Permission denied', exitCode: 1 }
if (key === LIST_ARGV(dir).join(' ')) return { stdout: w.list, stderr: '', exitCode: 0 }
if (key === REF_ARGV(dir).join(' ')) return w.hasRef ? { stdout: `${Math.floor((NOW - 2 * 3_600_000) / 1000)}\n`, stderr: '', exitCode: 0 } : { stdout: '', stderr: 'unknown revision', exitCode: 128 }
if (key === STATUS_ARGV(dir).join(' ')) return { stdout: Array.from({ length: w.dirty[dir] ?? 0 }, (_, i) => ` M f${i}`).join('\n'), stderr: '', exitCode: 0 }
if (key === IGNORED_ARGV(dir).join(' ')) return { stdout: w.ignored[dir] ?? '', stderr: '', exitCode: 0 }
if (key === AHEAD_ARGV(dir).join(' ')) return w.ahead[dir] === null ? { stdout: '', stderr: 'bad', exitCode: 128 } : { stdout: `0\t${w.ahead[dir] ?? 0}\n`, stderr: '', exitCode: 0 }
if (key.startsWith(`git -C ${ROOT} worktree remove `)) {
const path = argv[5] ?? ''
if (key === REMOVE_ARGV(ROOT, argv.at(-1) ?? '').join(' ')) {
const path = argv.at(-1) ?? ''
if (w.failRemove.has(path)) return { stdout: '', stderr: 'fatal: contains modified or untracked files', exitCode: 128 }
@@ -0,0 +1,216 @@
/**
* A repository's own config and .git/hooks can name programs git runs: core.fsmonitor when a command compares the work tree with the index,
* and post-index-change when one rewrites the index. The console runs git in worktrees and projects it did not make, so its fixed probes switch
* the fsmonitor off, and removal and describe (which can rewrite the index) also turn hooks off. Removal also lists untracked files whatever
* status.showUntrackedFiles says, so a worktree holding new files is never read as clean and deleted. Each real-git case has a positive control:
* the same config does its harm under the plain command, so a marker that stays absent means the guard held, not that the probe could not see it.
*
* Filter drivers are covered in git-filter-guard.spec.ts. Not covered here: lazy fetches in a partial clone, changes hidden by index flags (assume-unchanged,
* skip-worktree, core.ignoreStat), and commands the person configures themselves (mission gates).
*/
import { execFile, spawn } from 'node:child_process'
import { chmod, mkdtemp, readdir, readFile, rm, stat as statOf, utimes, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { promisify } from 'node:util'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { changedFiles } from '../hooks/adr-mission'
import { diffArgv } from '../hooks/data/wf-drill-io'
import { IGNORED_ARGV, REMOVE_ARGV, STATUS_ARGV } from '../hooks/data/wf-worktrees'
const sh = promisify(execFile)
const PLUGIN = join(__dirname, '..')
const isWin = process.platform === 'win32'
const exists = async (path: string): Promise<boolean> => (await statOf(path).catch(() => null)) !== null
/** Subcommands that compare the work tree with the index, so a repository's core.fsmonitor runs under them. */
const FSMONITOR = /'(status|describe|diff|diff-files|diff-index|ls-files|add|update-index)'|'worktree','remove'/
/** Of those, the ones that can write the index and so fire post-index-change even with --no-optional-locks. */
const WRITES_INDEX = /'describe'|'worktree','remove'/
async function sourceFiles(dir: string): Promise<string[]> {
const entries = await readdir(dir, { withFileTypes: true }).catch(() => [])
const nested = await Promise.all(entries.map(entry => (entry.isDirectory() ? sourceFiles(join(dir, entry.name)) : Promise.resolve(/\.(m?ts|m?js)$/.test(entry.name) ? [join(dir, entry.name)] : []))))
return nested.flat()
}
/** Every array literal in the plugin's runtime code that starts with git, quotes normalised to ' and whitespace removed. */
async function gitLiterals(): Promise<{ where: string; literal: string }[]> {
const out: { where: string; literal: string }[] = []
for (const dir of ['hooks', 'tui']) {
for (const file of await sourceFiles(join(PLUGIN, dir))) {
const text = await readFile(file, 'utf8')
for (const match of text.matchAll(/\[\s*["'`]git["'`]\s*,[^\]]*\]/g)) out.push({ where: file.slice(PLUGIN.length + 1), literal: match[0].replace(/["`]/g, "'").replace(/\s+/g, '') })
}
}
return out
}
describe('the fixed git argv the console builds', () => {
it('the builders for status, ignored files, diff and removal carry core.fsmonitor=false; removal also turns hooks off and lists untracked files', () => {
for (const argv of [STATUS_ARGV('/x'), IGNORED_ARGV('/x'), diffArgv('/x'), REMOVE_ARGV('/main', '/main/.claude/worktrees/x')]) {
expect(argv.join(' '), argv.join(' ')).toContain('-c core.fsmonitor=false')
}
expect(REMOVE_ARGV('/main', '/p').join(' ')).toContain('-c core.hooksPath=/dev/null -c status.showUntrackedFiles=normal worktree remove')
expect(REMOVE_ARGV('/main', '/p').at(-1)).toBe('/p')
expect(STATUS_ARGV('/x')).toContain('--untracked-files=normal')
})
it('no git array literal in hooks/ or tui/ reaches an fsmonitor or index-writing subcommand without its guard, and none sets the fsmonitor back', async () => {
const literals = await gitLiterals()
const unguarded = literals.filter(({ literal }) => FSMONITOR.test(literal) && !literal.includes("'-c','core.fsmonitor=false'"))
const hooksOn = literals.filter(({ literal }) => WRITES_INDEX.test(literal) && !literal.includes("'-c','core.hooksPath=/dev/null'"))
const overridden = literals.filter(({ literal }) => (literal.match(/core\.fsmonitor=/g) ?? []).length > 1)
expect(literals.length).toBeGreaterThan(5) // the scan sees the probes it is meant to check
expect(unguarded.map(({ where, literal }) => `${where}: ${literal}`)).toEqual([])
expect(hooksOn.map(({ where, literal }) => `${where}: ${literal}`)).toEqual([])
expect(overridden).toEqual([])
})
})
describe.skipIf(isWin)('against real git', () => {
let base: string
let main: string
const fsmonitorMarker = (): string => join(base, 'fsmonitor-ran')
const hookMarker = (): string => join(base, 'hook-ran')
const git = async (cwd: string, ...args: string[]): Promise<string> => (await sh('git', ['-C', cwd, '-c', 'user.name=t', '-c', 'user.email=t@t', '-c', 'commit.gpgsign=false', ...args])).stdout
const runArgv = (argv: readonly string[]): Promise<number> =>
new Promise(resolve => {
const child = spawn(argv[0] as string, argv.slice(1), { stdio: 'ignore' })
child.on('close', code => resolve(code ?? -1))
child.on('error', () => resolve(127))
})
const hostile = async (): Promise<void> => {
await rm(fsmonitorMarker(), { force: true })
await rm(hookMarker(), { force: true })
await git(main, 'config', 'core.fsmonitor', `touch ${fsmonitorMarker()}; false`)
}
// A new mtime with the same content: the index entry goes stale, so a command that refreshes the index rewrites it.
let tick = 1
const restat = async (): Promise<void> => {
const when = new Date(Date.UTC(2020, 0, tick++))
await utimes(join(main, 'a.txt'), when, when)
}
beforeAll(async () => {
base = await mkdtemp(join(tmpdir(), 'git-config-exec-'))
main = join(base, 'main')
await sh('git', ['init', '-b', 'main', main])
await writeFile(join(main, 'a.txt'), 'one\n')
await git(main, 'add', '.')
await git(main, 'commit', '-m', 'init')
const hook = join(main, '.git', 'hooks', 'post-index-change')
await writeFile(hook, `#!/bin/sh\ntouch '${hookMarker()}'\n`)
await chmod(hook, 0o755)
}, 30_000)
afterAll(async () => {
await rm(base, { recursive: true, force: true })
})
it('control: the plain removal runs the hostile fsmonitor and the post-index-change hook', async () => {
const path = join(base, 'wt-control')
await git(main, 'worktree', 'add', '-b', 'b-control', path)
await hostile()
expect(await runArgv(['git', '-C', main, 'worktree', 'remove', path])).toBe(0)
expect(await exists(path)).toBe(false)
expect(await exists(fsmonitorMarker())).toBe(true)
expect(await exists(hookMarker())).toBe(true)
}, 30_000)
it('REMOVE_ARGV removes the worktree and runs neither', async () => {
const path = join(base, 'wt-guarded')
await git(main, 'worktree', 'add', '-b', 'b-guarded', path)
await hostile()
expect(await runArgv(REMOVE_ARGV(main, path))).toBe(0)
expect(await exists(path)).toBe(false)
expect(await exists(fsmonitorMarker())).toBe(false)
expect(await exists(hookMarker())).toBe(false)
}, 30_000)
it('with status.showUntrackedFiles=no, the probe still sees a new file and REMOVE_ARGV refuses; the plain removal deletes it (control)', async () => {
await git(main, 'config', '--unset', 'core.fsmonitor').catch(() => '')
await git(main, 'config', 'status.showUntrackedFiles', 'no')
try {
const control = join(base, 'wt-untracked-control')
const guarded = join(base, 'wt-untracked')
for (const [path, branch] of [[control, 'b-untracked-control'], [guarded, 'b-untracked']] as const) {
await git(main, 'worktree', 'add', '-b', branch, path)
await writeFile(join(path, 'unsaved.txt'), 'new work\n')
}
expect(await runArgv(['git', '-C', main, 'worktree', 'remove', control])).toBe(0)
expect(await exists(join(control, 'unsaved.txt'))).toBe(false)
expect((await sh(STATUS_ARGV(guarded)[0] as string, STATUS_ARGV(guarded).slice(1) as string[])).stdout).toContain('?? unsaved.txt')
expect(await runArgv(REMOVE_ARGV(main, guarded))).not.toBe(0)
expect(await readFile(join(guarded, 'unsaved.txt'), 'utf8')).toBe('new work\n')
} finally {
await git(main, 'config', '--unset', 'status.showUntrackedFiles')
}
}, 30_000)
it("register.ts's describe argv, run as written, runs neither (control: plain describe --dirty fires the hook)", async () => {
const source = await readFile(join(PLUGIN, 'hooks', 'register.ts'), 'utf8')
const literal = source.match(/\[\s*'git'[^\]]*'describe'[^\]]*\]/)?.[0]
expect(literal).toBeDefined()
// Its elements are quoted words and the identifier `root`; run it with root set to the hostile repository.
const argv = [...(literal as string).matchAll(/'([^']*)'|([A-Za-z_]\w*)/g)].map(([, word, name]) => (word !== undefined ? word : name === 'root' ? main : `?${name}`))
expect(argv.some(word => word.startsWith('?'))).toBe(false)
await hostile()
await restat()
expect(await runArgv(['git', '-C', main, 'describe', '--always', '--dirty'])).toBe(0)
expect(await exists(hookMarker())).toBe(true)
await hostile()
await restat()
expect(await runArgv(argv)).toBe(0)
expect(await exists(fsmonitorMarker())).toBe(false)
expect(await exists(hookMarker())).toBe(false)
}, 30_000)
it('the mission scope check reads changed files without running the hostile fsmonitor (control: plain status runs it)', async () => {
await writeFile(join(main, 'a.txt'), 'changed\n')
await hostile()
expect(await runArgv(['git', '-C', main, 'status', '--porcelain'])).toBe(0)
expect(await exists(fsmonitorMarker())).toBe(true)
await hostile()
const host = {
run: async (argv: readonly string[]) => {
try {
const { stdout, stderr } = await sh(argv[0] as string, argv.slice(1) as string[])
return { exitCode: 0, stdout, stderr }
} catch (error) {
return { exitCode: 1, stdout: '', stderr: String(error) }
}
},
}
expect(await changedFiles(host, main, Date.now())).toContain('a.txt')
expect(await exists(fsmonitorMarker())).toBe(false)
await git(main, 'checkout', '--', 'a.txt')
}, 30_000)
})
@@ -0,0 +1,190 @@
/**
* #4090 follow-up: a repository's own config can name a filter driver (filter.<name>.clean, .smudge, .process) that git runs while it compares
* a work tree with HEAD, so status, diff and `worktree remove` execute it. The console reads and removes worktrees of projects it did not make,
* so it lists the configured drivers (a config read, nothing runs) and blanks each one on the command line before the git command that would
* run it. Every real-git case has a positive control: the same config runs the program under the plain command.
*/
import { execFile } from 'node:child_process'
import { chmod, mkdtemp, rm, utimes, writeFile, readFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { promisify } from 'node:util'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { diffArgv } from '../hooks/data/wf-drill-io'
import { FILTER_KEYS_ARGV, filterGuarded, filterOverrides } from '../hooks/data/git-filters'
import { REMOVE_ARGV, STATUS_ARGV } from '../hooks/data/wf-worktrees'
const sh = promisify(execFile)
const isWin = process.platform === 'win32'
const ENV = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' }
const run = async (argv: readonly string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> => {
try {
const out = await sh(argv[0] as string, argv.slice(1) as string[], { env: ENV, timeout: 20_000 })
return { stdout: out.stdout, stderr: out.stderr, exitCode: 0 }
} catch (error) {
const e = error as { stdout?: string; stderr?: string; code?: number }
return { stdout: e.stdout ?? '', stderr: e.stderr ?? '', exitCode: typeof e.code === 'number' ? e.code : 1 }
}
}
describe('filterOverrides: the drivers git lists become empty command-line overrides', () => {
it('blanks clean, smudge and process for every driver, dotted names included, once each', () => {
const overrides = filterOverrides('filter.evil.clean\nfilter.evil.smudge\nfilter.a.b.process\nfilter.evil.process\n')
expect(overrides).toEqual(['-c', 'filter.evil.clean=', '-c', 'filter.evil.smudge=', '-c', 'filter.a.b.process=', '-c', 'filter.evil.process='])
})
it('is empty when no driver is configured', () => {
expect(filterOverrides('')).toEqual([])
expect(filterOverrides('\n')).toEqual([])
})
it('fails closed (null) on a name it cannot override exactly: an equals sign, a space, a control character or an odd key', () => {
for (const text of ['filter.a=b.clean\n', 'filter.a b.clean\n', 'filter.a\u0001.clean\n', 'filter..clean\n', 'filter.x.clean.extra\n', 'other.x.clean\n']) {
expect(filterOverrides(text), JSON.stringify(text)).toBeNull()
}
})
it('the listing is a config read with a fixed argv', () => {
const argv = FILTER_KEYS_ARGV('/x')
expect(argv.slice(0, 3)).toEqual(['git', '-C', '/x'])
expect(argv).toContain('config')
expect(argv).toContain('--get-regexp')
expect(argv.join(' ')).not.toMatch(/\s(-c|status|diff|remove)\s/)
})
})
describe('filterGuarded: the argv gains the overrides, or the command is refused', () => {
const ok = (stdout: string, exitCode = 0) => async () => ({ stdout, stderr: '', exitCode })
it('puts the overrides right after git and leaves every other word in place', async () => {
const argv = await filterGuarded(ok('filter.evil.clean\n'), '/wt', ['git', '-C', '/wt', 'status'])
expect(argv).toEqual(['git', '-c', 'filter.evil.clean=', '-C', '/wt', 'status'])
})
it('returns the argv unchanged when git finds no driver (exit 1, nothing printed)', async () => {
const argv = await filterGuarded(ok('', 1), '/wt', ['git', '-C', '/wt', 'status'])
expect(argv).toEqual(['git', '-C', '/wt', 'status'])
})
it('refuses (null) when the listing fails, throws, or names something it cannot blank', async () => {
expect(await filterGuarded(ok('', 128), '/wt', ['git', 'status'])).toBeNull()
expect(await filterGuarded(async () => { throw new Error('boom') }, '/wt', ['git', 'status'])).toBeNull()
expect(await filterGuarded(ok('filter.a b.clean\n'), '/wt', ['git', 'status'])).toBeNull()
})
it('refuses an argv that does not start with git', async () => {
expect(await filterGuarded(ok(''), '/wt', ['rm', '-rf', '/'])).toBeNull()
})
})
describe.skipIf(isWin)('real git: a configured filter driver does not run', () => {
let dir = ''
let mark = ''
const setup = async (name: string, kind: 'clean' | 'process' | 'smudge', driver: string): Promise<{ main: string; wt: string }> => {
const main = join(dir, name)
await sh('git', ['init', '-q', main], { env: ENV })
await sh('git', ['-C', main, 'config', 'user.email', 'a@b.c'], { env: ENV })
await sh('git', ['-C', main, 'config', 'user.name', 't'], { env: ENV })
await writeFile(join(main, 'a'), 'a\n')
await writeFile(join(main, 'f.txt'), 'hi\n')
await writeFile(join(main, '.gitattributes'), `*.txt filter=${driver}\n`)
await sh('git', ['-C', main, 'add', '.'], { env: ENV })
await sh('git', ['-C', main, 'commit', '-qm', 'c'], { env: ENV })
await sh('git', ['-C', main, 'worktree', 'add', '-q', join(main, '.git-worktrees', 'w1'), '-b', 'w1'], { env: ENV })
const script = join(dir, `${name}.sh`)
await writeFile(script, `#!/bin/sh\necho ran >> ${mark}\ncat\n`)
await chmod(script, 0o755)
await sh('git', ['-C', main, 'config', `filter.${driver}.${kind}`, script], { env: ENV })
const wt = join(main, '.git-worktrees', 'w1')
// a stale mtime makes git compare content, which is when it runs the clean filter
await utimes(join(wt, 'f.txt'), new Date('2001-01-01'), new Date('2001-01-01'))
return { main, wt }
}
const ran = async (): Promise<boolean> => (await readFile(mark, 'utf8').catch(() => '')).includes('ran')
const reset = async (): Promise<void> => { await rm(mark, { force: true }) }
beforeAll(async () => {
dir = await mkdtemp(join(tmpdir(), 'rfc-filter-'))
mark = join(dir, 'MARK')
})
afterAll(async () => {
await rm(dir, { recursive: true, force: true })
})
it('status: the plain probe runs the driver (control), the guarded one does not', async () => {
const { wt } = await setup('s', 'clean', 'evil')
await reset()
await run(STATUS_ARGV(wt))
expect(await ran(), 'positive control: the unguarded probe runs the driver').toBe(true)
await reset()
const guarded = await filterGuarded(run, wt, STATUS_ARGV(wt))
expect(guarded).not.toBeNull()
await run(guarded as string[])
expect(await ran()).toBe(false)
})
it('diff: the guarded numstat does not run a clean driver', async () => {
const { wt } = await setup('d', 'clean', 'evil')
await reset()
await run(diffArgv(wt))
expect(await ran(), 'positive control').toBe(true)
await reset()
await run((await filterGuarded(run, wt, diffArgv(wt))) as string[])
expect(await ran()).toBe(false)
})
it('removal: the guarded git worktree remove does not run the driver and still removes a clean worktree', async () => {
const { main, wt } = await setup('r', 'clean', 'evil')
await reset()
const guarded = await filterGuarded(run, wt, REMOVE_ARGV(main, wt))
expect(guarded).not.toBeNull()
await run(guarded as string[])
expect(await ran()).toBe(false)
expect((await run(['git', '-C', main, 'worktree', 'list', '--porcelain'])).stdout).not.toContain('.git-worktrees/w1')
})
it('a dotted driver name and a process driver are blanked too', async () => {
const { wt } = await setup('p', 'process', 'evil.dotted')
await reset()
await run(STATUS_ARGV(wt))
expect(await ran(), 'positive control: process drivers run under status').toBe(true)
await reset()
await run((await filterGuarded(run, wt, STATUS_ARGV(wt))) as string[])
expect(await ran()).toBe(false)
})
it('a driver name the console cannot blank exactly stops the probe (null) instead of running it', async () => {
const { wt } = await setup('x', 'clean', 'with space')
await reset()
expect(await filterGuarded(run, wt, STATUS_ARGV(wt))).toBeNull()
expect(await ran()).toBe(false)
})
})
@@ -51,24 +51,27 @@ describe('the pinned Codex', () => {
expect(await resolveCodex(root, newer)).toMatchObject({ ok: false, why: expect.stringMatching(/pinned Codex 0\.162\.0 is not installed/) })
})
// Each release case has a home of its own: the next one writes the pinned release, and in a shuffled run it could go first.
it('finds the release directory named for the pinned version, never current and never PATH', async () => {
const releases = join(root, '.codex', 'packages', 'standalone', 'releases')
const home = mkdtempSync(join(root, 'home-'))
const releases = join(home, '.codex', 'packages', 'standalone', 'releases')
mkdirSync(join(releases, '0.162.1-x86_64-unknown-linux-musl', 'bin'), { recursive: true })
mkdirSync(join(root, '.codex', 'packages', 'standalone', 'current'), { recursive: true })
mkdirSync(join(home, '.codex', 'packages', 'standalone', 'current'), { recursive: true })
// Another version on disk, and a codex on PATH that claims the pinned version: neither is used.
writeFileSync(join(releases, '0.162.1-x86_64-unknown-linux-musl', 'bin', 'codex'), '#!/bin/sh\necho "codex-cli 0.162.0"\n')
chmodSync(join(releases, '0.162.1-x86_64-unknown-linux-musl', 'bin', 'codex'), 0o755)
expect(await resolveCodex(root)).toMatchObject({ ok: false, why: expect.stringMatching(/never uses current or PATH/) })
expect(await resolveCodex(home)).toMatchObject({ ok: false, why: expect.stringMatching(/never uses current or PATH/) })
})
it.skipIf(isWin)('finds the exact release when it is there', async () => {
const dir = join(root, '.codex', 'packages', 'standalone', 'releases', '0.162.0-x86_64-unknown-linux-musl', 'bin')
const home = mkdtempSync(join(root, 'home-'))
const dir = join(home, '.codex', 'packages', 'standalone', 'releases', '0.162.0-x86_64-unknown-linux-musl', 'bin')
mkdirSync(dir, { recursive: true })
writeFileSync(join(dir, 'codex'), readFileSync(FAKE))
chmodSync(join(dir, 'codex'), 0o755)
expect(await resolveCodex(root)).toEqual({ ok: true, bin: join(dir, 'codex') })
expect(await resolveCodex(home)).toEqual({ ok: true, bin: join(dir, 'codex') })
})
it('spawn refuses anything but a read-only codex exec, before a process starts, and with no AI options at all', () => {
@@ -5,7 +5,11 @@
*/
import { describe, expect, it } from 'vitest'
import { FILTER_KEYS_ARGV } from '../hooks/data/git-filters'
import { diffArgv, isProjectDir, isRunFile, parseNumstat } from '../hooks/data/wf-drill-io'
/** The repository lists no filter driver: git config --get-regexp exits 1 and prints nothing. */
const NO_FILTERS = { exitCode: 1, stdout: '' }
import { bindWorkflowDrill } from '../hooks/wf-drill'
import { drillOf } from '../hooks/views/wf-detail'
import { back, line, sample, SECRET, use } from './fixtures/wf-drill'
@@ -30,15 +34,16 @@ describe('Files and Result', () => {
})
it('reads the worktree diff stat through one fixed argv when bound, and joins it to the named files', async () => {
const world = await worldOf(liveFiles(), {}, async () => ({ exitCode: 0, stdout: '3\t1\ta.ts\n-\t-\timg.png\nnot a numstat line\n' }))
const world = await worldOf(liveFiles(), {}, async argv => (argv.includes('--get-regexp') ? NO_FILTERS : { exitCode: 0, stdout: '3\t1\ta.ts\n-\t-\timg.png\nnot a numstat line\n' }))
bindWorkflowDrill(world.state, world.host as never)
toAgent(world)
click(frame(world).tree, 'wf-sub-files')
await flush()
expect(world.spied.runs).toEqual([diffArgv(WT)])
expect(world.spied.runs[0]).toEqual(['git', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-C', WT, 'diff', '--numstat', '--no-renames', '--no-color', '--no-ext-diff', '--no-textconv', 'HEAD', '--'])
expect(world.spied.runs).toEqual([[...FILTER_KEYS_ARGV(WT)], diffArgv(WT)])
expect(world.spied.runs[1]).toEqual(['git', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-C', WT, 'diff', '--numstat', '--no-renames', '--no-color', '--no-ext-diff', '--no-textconv', 'HEAD', '--'])
const text = screen(world)
@@ -52,7 +57,7 @@ describe('Files and Result', () => {
const hash = 'a'.repeat(40)
const path = `${WT}/node_modules/.pnpm/pkg@1.2.3_${hash}/index.ts`
const text = [line('assistant', 1, [use('t1', 'Edit', { file_path: path, old_string: 'a', new_string: 'b' })]), line('user', 2, [back('t1', 'ok')])].join('\n')
const world = await worldOf(liveFiles({ [`${RUN}/agent-a1.jsonl`]: text }), {}, async () => ({ exitCode: 0, stdout: `5\t2\tnode_modules/.pnpm/pkg@1.2.3_${hash}/index.ts\n` }))
const world = await worldOf(liveFiles({ [`${RUN}/agent-a1.jsonl`]: text }), {}, async argv => (argv.includes('--get-regexp') ? NO_FILTERS : { exitCode: 0, stdout: `5\t2\tnode_modules/.pnpm/pkg@1.2.3_${hash}/index.ts\n` }))
bindWorkflowDrill(world.state, world.host as never)
toAgent(world)
@@ -110,7 +110,11 @@ const rowOf = (name: string): WtRow => storeFor(state).read?.rows.find(entry =>
// neither of, so on another kernel they measure the test machine, not the guard. CI runs them on Linux.
const onLinux = process.platform === 'linux'
describe('the removal guard against a real repository', () => {
// One repository, in steps: the first case reads it, the second removes from it and the third adds to it. The order is the test, so it is fixed
// (a shuffled run reorders them), and each real-git case gets the minute the header asks for rather than vitest's 5 s.
const GIT_MS = 60_000
describe('the removal guard against a real repository', { shuffle: false }, () => {
it.skipIf(!onLinux)('offers exactly the merged, clean, idle, old, not-current worktrees, and keeps everything else with the right reason', async () => {
await refreshWorktrees(state, host, true)
@@ -135,7 +139,7 @@ describe('the removal guard against a real repository', () => {
expect(why[join(base, 'outside-wt')]).toMatch(/outside/)
expect(why[main]).toBe('the main worktree')
expect(rowOf('old').createdMs).toBeLessThan(Date.now() - MIN_AGE_MS)
})
}, GIT_MS)
it.skipIf(!onLinux)('removes only those, one at a time, never a branch, and a path that reads like a command line is one argv element', async () => {
const spec = removalSpec(envOf())
@@ -154,7 +158,7 @@ describe('the removal guard against a real repository', () => {
expect(await git(main, 'branch', '--list', 'b-old', 'b-old2', 'b-rfforcexy')).toMatch(/b-old/)
expect(state.outcome?.detail).toBe('3 removed, 0 kept')
expect(state.outcome?.verified).toBe('yes')
})
}, GIT_MS)
it.skipIf(!onLinux)('re-checks each worktree at the moment of removal: one made dirty, in use or unmerged after the confirm is kept', async () => {
for (const name of ['race-dirty', 'race-busy', 'race-ahead', 'race-ok']) {
@@ -182,7 +186,7 @@ describe('the removal guard against a real repository', () => {
expect(await exists(wtPath('race-ok'))).toBe(false)
expect(state.outcome?.lines?.join('\n')).toMatch(/kept \S*race-dirty: 1 changed/)
expect(await exists(join(wtPath('race-dirty'), 'a.txt'))).toBe(true)
})
}, GIT_MS)
it('every probe that can consult the repository config switches fsmonitor off and takes no optional lock', () => {
const argv = STATUS_ARGV('/x').join(' ')
@@ -200,5 +204,5 @@ describe('the removal guard against a real repository', () => {
await refreshWorktrees(state, host, false)
await git(main, 'config', '--unset', 'core.fsmonitor')
expect(await exists(marker)).toBe(false)
})
}, GIT_MS)
})
@@ -64,12 +64,17 @@ describe('the stub endpoint receives exactly what the card showed', () => {
expect(card.ok).toBe(true)
// Counted from here: the other cases share this server, and a shuffled run can send first.
const before = seen.length
const answered = await sendTo(d, target, 'compare raft and paxos')
expect(seen).toHaveLength(1)
expect(seen[0]).toMatchObject({ method: 'POST', url: '/v1/chat/completions', contentType: 'application/json', authorization: `Bearer ${KEY}` })
expect(seen[0]?.body).toBe(chatBody({ name: 'stub', baseUrl: base, keyEnv: 'STUB_MODEL_KEY', model: 'stub-model' }, 'compare raft and paxos'))
expect(card.ok && card.payload.shows).toContain(seen[0]?.body)
expect(seen).toHaveLength(before + 1)
const sent = seen[before]
expect(sent).toMatchObject({ method: 'POST', url: '/v1/chat/completions', contentType: 'application/json', authorization: `Bearer ${KEY}` })
expect(sent?.body).toBe(chatBody({ name: 'stub', baseUrl: base, keyEnv: 'STUB_MODEL_KEY', model: 'stub-model' }, 'compare raft and paxos'))
expect(card.ok && card.payload.shows).toContain(sent?.body)
expect(card.ok && card.payload.shows).toContain('Authorization: Bearer ‹from $STUB_MODEL_KEY›')
expect(card.ok && card.payload.shows).not.toContain(KEY)
expect(answered).toMatchObject({ ok: true, state: 'reply', tokensIn: 7, tokensOut: 5, costUsd: 0.00012, model: 'stub-model' })
@@ -87,9 +92,11 @@ describe('the stub endpoint receives exactly what the card showed', () => {
it('with NONE as the key name no Authorization header is sent', async () => {
const d = depsOf(`endpoint:open=${base}|NONE|stub-model`)
const before = seen.length
await sendTo(d, targetOf(d, 'open'), 'hi')
expect(seen.at(-1)?.authorization).toBeUndefined()
expect(seen).toHaveLength(before + 1)
expect(seen[before]?.authorization).toBeUndefined()
})
})
@@ -88,11 +88,11 @@ describe('the board and the confirm-gated removal', () => {
const spec = removalSpec(envOf())
expect(spec).not.toBeNull()
expect(spec?.shows).toBe(`git -C ${ROOT} worktree remove ${wt('old')}`)
expect(spec?.shows).toBe(`git -C ${ROOT} -c core.fsmonitor=false -c core.hooksPath=/dev/null -c status.showUntrackedFiles=normal worktree remove ${wt('old')}`)
expect(spec?.shows).not.toContain('--force')
expect(spec).toMatchObject({ declared: 'delete', args: [], label: 'remove 1 merged, clean worktree' })
expect(spec?.note).toMatch(/branches stay/)
expect(REMOVE_ARGV(ROOT, wt('old'))).toEqual(['git', '-C', ROOT, 'worktree', 'remove', wt('old')])
expect(REMOVE_ARGV(ROOT, wt('old'))).toEqual(['git', '-C', ROOT, '-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null', '-c', 'status.showUntrackedFiles=normal', 'worktree', 'remove', wt('old')])
})
it('offers nothing before the live processes were checked (the timer read never checks them)', async () => {