Skip to content

hygiene: support stale worktree audit root option#5362

Merged
AceHack merged 9 commits into
mainfrom
claim/codex-loop-stale-worktree-root-option-20260527
May 27, 2026
Merged

hygiene: support stale worktree audit root option#5362
AceHack merged 9 commits into
mainfrom
claim/codex-loop-stale-worktree-root-option-20260527

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 27, 2026

Summary

  • add --root PATH to audit-stale-worktrees so callers can inspect a control clone without changing cwd
  • route list/prune through git -C <root> and cover argument parsing
  • handle spawnSync launch errors explicitly in audit() + runPrune() (per Copilot review on this PR)
  • tighten hasFlagValue to reject any dash-prefixed token (catches typos like --report --verbose)
  • expand exit-128 header comment to cover --root failure modes
  • claim was released per AGENT-CLAIM-PROTOCOL.md §TL;DR step 5 (no claim file shipped with this PR; coordination artifact deleted on landing)

Checks

  • 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/Zeta
  • bun tools/hygiene/audit-stale-worktrees.ts --root /tmp/__nonexistent → exit 128 with clean error
  • bun 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.ts
  • node_modules/.bin/tsc --noEmit -p tsconfig.json
  • git diff --check

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>
Copilot AI review requested due to automatic review settings May 27, 2026 00:10
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PATH CLI flag and thread it through git worktree list/prune via git -C.
  • Export and test parseArgs to 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/--report consume 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 cause git -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;

Comment thread tools/hygiene/audit-stale-worktrees.ts
Comment thread tools/hygiene/audit-stale-worktrees.ts
Comment thread docs/claims/codex-loop-stale-worktree-root-option-20260527.md Outdated
@AceHack AceHack enabled auto-merge (squash) May 27, 2026 00:16
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>
@AceHack
Copy link
Copy Markdown
Member Author

AceHack commented May 27, 2026

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
Copilot AI review requested due to automatic review settings May 27, 2026 00:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread tools/hygiene/audit-stale-worktrees.ts Outdated
Comment thread tools/hygiene/audit-stale-worktrees.ts
Comment thread tools/hygiene/audit-stale-worktrees.ts
Comment thread tools/hygiene/audit-stale-worktrees.ts
Comment thread tools/hygiene/audit-stale-worktrees.ts
Lior and others added 2 commits May 26, 2026 20:41
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>
Copilot AI review requested due to automatic review settings May 27, 2026 00:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tools/hygiene/audit-stale-worktrees.ts Outdated
codex and others added 3 commits May 26, 2026 20:50
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>
Copilot AI review requested due to automatic review settings May 27, 2026 00:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tools/hygiene/audit-stale-worktrees.ts
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>
@AceHack AceHack merged commit f09c521 into main May 27, 2026
35 checks passed
@AceHack AceHack deleted the claim/codex-loop-stale-worktree-root-option-20260527 branch May 27, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants