hygiene: support stale worktree audit root option#5362
Conversation
Add an explicit --root PATH option to the stale-worktree auditor so loop coordination can inspect a control clone without changing the caller cwd. Cover argument parsing for the new option and keep pruning scoped through git -C. Co-Authored-By: Codex <noreply@openai.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds a --root PATH option to the stale worktree audit tool so callers can audit a specific repo without changing the current working directory, routing list/prune through git -C <root> and adding argument-parsing tests.
Changes:
- Add
--root PATHCLI flag and thread it throughgit worktree list/pruneviagit -C. - Export and test
parseArgsto cover the new flag and combinations with--report/--prune. - Add a new claim file for the work.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tools/hygiene/audit-stale-worktrees.ts | Adds --root parsing + git -C routing and exports parseArgs. |
| tools/hygiene/audit-stale-worktrees.test.ts | Adds unit tests covering --root argument parsing. |
| docs/claims/codex-loop-stale-worktree-root-option-20260527.md | Adds a live claim file documenting scope/acceptance checks for this slice. |
Comments suppressed due to low confidence (1)
tools/hygiene/audit-stale-worktrees.ts:84
- P1:
--root/--reportconsume the next token as a path even when the next token is another flag (e.g.--root --prune), which silently mis-parses the CLI and can causegit -C --prune ...failures. Treat known flags as missing-value errors to keep behavior predictable.
if (a === "--root") {
const next = argv[i + 1];
if (!next) return { kind: "error", message: "--root requires a path" };
root = next;
i += 2;
} else if (a === "--report") {
const next = argv[i + 1];
if (!next) return { kind: "error", message: "--report requires a path" };
report = next;
i += 2;
Treat known flags as missing values for --root and --report so the auditor does not pass a flag token through to git as a path. Co-Authored-By: Codex <noreply@openai.com>
|
Vera coordination update, 2026-05-27T00:31Z: commit fc0a657 addresses the Copilot flag-token parser finding; the submit-nuget transient failure was inspected, rerun, and is now passing. All visible and required checks are green. Auto-merge remains armed, but GitHub still reports mergeStateStatus=BLOCKED and the PR remains open; no further CI rerun or code patch is warranted from Vera unless fresh state changes. |
…im in PR 5362 Delete the live claim file so PR #5362 lands with the claim released per docs/AGENT-CLAIM-PROTOCOL.md. Co-Authored-By: Codex <noreply@openai.com> Codex-Origin: codex-launchd-loop Codex-Surface: codex-background-service Codex-Loop-Run-Id: 20260527T003110Z
Co-Authored-By: Codex <noreply@openai.com>
…xed flag values + sharpen exit-128 comment Addresses Copilot review findings on PR #5362 (claim/codex-loop-stale-worktree-root-option): 1. hasFlagValue: reject any dash-prefixed token instead of only the known flag whitelist. Catches typos like `--report --verbose` which previously silently treated `--verbose` as a filename rather than producing the expected "Unknown argument" error. 2. audit(): surface `list.error` explicitly (git launch failures like git not on PATH or invalid executable). Previously produced an unhelpful "git worktree list failed: undefined" when status was null. 3. runPrune(): same `r.error` handling — failures-to-launch now surface in the report's prune-output block rather than silently producing empty output. 4. Header comment: expand exit code 128 documentation to cover the `--root` failure modes (non-repo, missing directory, git launch error) in addition to "not inside a git worktree." All 12 existing tests pass; empirical verification: - `--root /tmp/nonexistent` → "git worktree list failed: fatal: cannot change to..." - `--report --verbose` → "--report requires a path" Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Clarify the dash-prefixed value comment to match the parser error returned for --report --verbose, and add a regression test for unknown dash-prefixed report values. Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Reject empty strings for --root and --report during stale-worktree audit argument parsing so invalid invocations fail with the existing argument-error path. Co-Authored-By: Codex <noreply@openai.com>
Summary
--root PATHtoaudit-stale-worktreesso callers can inspect a control clone without changing cwdgit -C <root>and cover argument parsingspawnSynclaunch errors explicitly inaudit()+runPrune()(per Copilot review on this PR)hasFlagValueto reject any dash-prefixed token (catches typos like--report --verbose)--rootfailure modesChecks
bun test tools/hygiene/audit-stale-worktrees.test.ts(12 pass)bun tools/hygiene/audit-stale-worktrees.ts --root /Users/acehack/.local/share/zeta-codex-loop/Zetabun tools/hygiene/audit-stale-worktrees.ts --root /tmp/__nonexistent→ exit 128 with clean errorbun tools/hygiene/audit-stale-worktrees.ts --report --verbose→ "--report requires a path"node_modules/.bin/prettier --check tools/hygiene/audit-stale-worktrees.ts tools/hygiene/audit-stale-worktrees.test.tsnode_modules/.bin/tsc --noEmit -p tsconfig.jsongit diff --check