Skip to content

pstack: worktree-audit holds untracked and ignored files (#459 on #492, with tests) - #770

Open
deanrie wants to merge 8 commits into
cursor:mainfrom
deanrie:pstack/worktree-audit-stack
Open

deanrie wants to merge 8 commits into
cursor:mainfrom
deanrie:pstack/worktree-audit-stack

Conversation

@deanrie

@deanrie deanrie commented Oct 22, 2026

Copy link
Copy Markdown

Stacks #492 (ours, #470) and #459 (@dajiaohuang, #449) into one mergeable unit and adds the tests #459 did not have. Close this and merge the originals in order (#492 then #459) if that is preferred; this PR exists because the two change the same two files and neither can be reviewed in isolation any more.

What is in here

Verification

bun test worktree-audit: 12 pass / 0 fail. generate-pstack-harness-trees.mjs --check up to date. Branch is on today's main.

Dean Rie and others added 8 commits October 22, 2026 09:21
… work as safe

Three problems in worktree-audit.sh (cursor#470):
- a PR in any non-open state satisfied `$pr != "-"`, so a CLOSED (unmerged)
  PR made the worktree `safe`;
- the computed `remote` column (ahead/no-remote/detached) was never read by
  the bucket logic, so unpushed commits could be bucketed `safe`;
- the header called the script read-only although it runs `git fetch`.

Only ancestry of origin/main or a MERGED PR now counts as proof the work
exists elsewhere. Worktrees whose HEAD is ahead of / absent from the remote
or detached and not on origin/main go to a new `hold-unpushed` bucket,
ranked right after hold-wip and hold-open-pr. A CLOSED PR falls through to
`review`. The header now states the one write the script performs, and the
playbook documents the new bucket in step 1 (steps 4-5 are left untouched to
avoid conflicting with cursor#459).

Verified on a synthetic repo with a stubbed gh: ahead1+CLOSED and detached
off-main -> hold-unpushed; pushed+MERGED, pushed+CLOSED-on-main and detached
on origin/main -> safe; pushed+CLOSED with commits not on main -> review.

Fixes cursor#470
Deletion advice must distinguish preserved work from local-only commits. Exercise the audit CLI in an isolated repository with closed PRs, squash merges, a behind branch, and a detached head.
A behind branch has no local-only commits. Deleted origin branches and fork branches can still have their exact head preserved by a PR. Compare that head rather than treating every missing remote as unpushed, while holding commits added after a merge.
…#613

main (cursor#613) normalises the PR list to {number, state, head} with a lowercase state and prefers the origin CLI over gh. The audit now carries head_oid through that list (gh provides it, origin's record leaves it empty) so heliowap's PR-head check still works, and the fixture expectations use the lowercase states the script prints.
Adds two worktrees to the audit fixture: one with a single untracked file,
one with only ignored build output (.gitignore'd build/ and run.log). With
cursor#459's change both report wip:N and land in hold-wip; a guard asserts no
row ever reports scratch:. Also restores cursor#459's opening paragraph of the
cleanup playbook, which the stack merge had dropped, and regenerates the
harness tree.
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.

3 participants