Skip to content

fix(worktree-audit): show behind and diverged remotes instead of ahead0 - #453

Merged
michael-denyer merged 2 commits into
michael-denyer:mainfrom
wattanartongtipsukon-create:pr/audit-remote-behind
Nov 11, 2026
Merged

michael-denyer merged 2 commits into
michael-denyer:mainfrom
wattanartongtipsukon-create:pr/audit-remote-behind

Conversation

@wattanartongtipsukon-create

Copy link
Copy Markdown
Contributor

What and why

  • The REMOTE column in worktree-audit ran only rev-list --count origin/<branch>..HEAD, so a branch that someone else had advanced printed ahead0, which reads as in sync even when the worktree is behind or diverged. It now counts both sides with --left-right and prints aheadN, behindN, or aheadN,behindN. The pushed and no-remote cases are unchanged.

Before / after, for a worktree whose pushed branch has one commit the worktree lacks, then one that has a commit each side:

before:  REMOTE  ahead0
after:   REMOTE  behind1
after:   REMOTE  ahead1,behind1

Display only: classify reads whether the remote fact is known, not its text, so no worktree changes its safe or hold verdict. Not related to #423 (trunk ancestry), #424 (prefer an open PR) or #425 (compressed Codex rollouts).

Linked issue

None.

Test run

bun install --frozen-lockfile                 # exit 0 (root and plugins/)
bun tools/generate.mjs --check                # exit 0
bun test tests/                               # Bun 1.4.4: 2019 pass, 0 fail, 179 skip
                                              # Bun 1.4.2: 2019 pass, 0 fail, 179 skip
bun tools/sync.mjs <component> <pinned sha> --dry-run   # every component, exit 0
bun tools/sync.mjs --check-rules              # exit 0
markdownlint-cli2 '**/*.md'                   # 0 errors
shellcheck, actionlint                        # exit 0

The skips are the suite's usual opt-in and platform-conditional tests; I skipped no check. I did not run the runtime-specific smoke checks, because the PR touches no Pi, hook, Copilot, Grok or MiniMax path.

On bare upstream/main (bc09365) the new test alone fails: Expected "behind1", Received "ahead0". It passes on this branch.

Checklist

  • I ran bun install --frozen-lockfile, bun tools/generate.mjs, and bun test tests/, and committed the generator's output. (The generator wrote nothing new.)
  • bun tools/generate.mjs --check exits 0.
  • I changed model defaults only in plugins/pstack/models.json, and every Pi model ID is in Pi's catalog for that provider. (No model defaults changed.)
  • If this changes skill behavior, it adds a CHANGES.md entry and bumps VERSION, or names the release PR that will. (Display string in a script only; I left CHANGES.md and VERSION alone so this does not collide with the next release PR. Happy to add the entry and bump if you prefer.)
  • If this touches plugins/pstack/pi/, pi-tools.md, plugins/pstack/hooks/, copilot-tools.md, or setup-pstack, I ran the runtime checks that CONTRIBUTING.md lists for those paths. (Not touched.)

The REMOTE column ran only `rev-list --count origin/<branch>..HEAD`, so a branch that someone else had advanced printed `ahead0`, which reads as in sync. It now counts both sides with `--left-right` and prints `aheadN`, `behindN`, or `aheadN,behindN`.

Display only: `classify` reads whether the remote fact is known, not its text, so no worktree changes its safe or hold verdict.
@wattanartongtipsukon-create wattanartongtipsukon-create changed the title https://github.com/michael-denyer/pstack-claude/compare/main...wattanartongtipsukon-create:pstack-claude:pr/audit-remote-behind?expand=1 fix(worktree-audit): show behind and diverged remotes instead of ahead0 Nov 11, 2026
Drop the ahead case, which the tag test already covers, and the pushes and fetch that leave the remote-tracking ref where a single push puts it. Drop -q from the git calls, and say in the comment what order --left-right prints the counts in.
@michael-denyer

Copy link
Copy Markdown
Owner

Thanks for this. The --left-right mapping is right, and classify reads only whether the remote fact is known, so no verdict moves. I pushed fd033a4 on top of your commit to trim the test and the comment:

  • Dropped the ahead case. The a tag named origin/<branch> test already checks ahead1.
  • Dropped the first push of each branch and the final fetch. A single push origin <branch> creates the remote branch and updates refs/remotes/origin/<branch>, as the tag test relies on.
  • Dropped -q from the git calls, since the rest of the file runs git without it.
  • Reworded the source comment to state the order --left-right prints the counts in, rather than the old ahead0 output.

The trimmed test still fails on main's script (Expected "behind1", Received "ahead0") and passes here. bun tools/generate.mjs --check and bun test tests/ pass locally.

@michael-denyer

Copy link
Copy Markdown
Owner

@wattanartongtipsukon-create, thank you for the fix. A REMOTE column that read ahead0 for a branch someone else had advanced looked in sync when it was not, and your before and after output plus the check against main made it quick to review.

I pushed fd033a4 on top of your commit with small trims to the test and the source comment, listed in my comment above. The fix itself is unchanged. Please pull before doing any more work on pr/audit-remote-behind. I'll merge once CI passes on the new head.

@michael-denyer
michael-denyer merged commit 36f4336 into michael-denyer:main Nov 11, 2026
21 checks passed
@michael-denyer

Copy link
Copy Markdown
Owner

Merged. Thanks again @wattanartongtipsukon-create. The next release's CHANGES.md entry will credit you for this fix.

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.

2 participants