Repository navigation
fix(#878): resolve phase diff stats against origin/<base>, not the stale local ref - #891
Merged
admarble merged 2 commits intoAug 4, 2026
Conversation
…ale local ref Worktrees are created from origin/<base> but getGitDiffStats diffed against the local <base> ref, which nothing in the run path updates. When local main lagged the remote, every phase log was attributed a diff belonging to commits the run never made, and the bogus filesModified flowed into run-reflect, merge-check, and sequant logs. - Add resolveDiffBase: candidates are origin/<base> and the bare ref; pick the one nearest to HEAD (rev-list --count), preferring the origin-qualified form on a tie. Nearest-wins matches the worktree's creation point in both staleness directions (stale local default branch AND chain-mode local bases with unpushed commits). Falls back to the bare ref verbatim when no candidate resolves. - getGitDiffStats resolves its base through resolveDiffBase. - getCommitHash gains an optional baseRef and returns undefined when HEAD has no commits past it, so an empty branch never logs the base tip as its phase commit. Run-level start/end markers keep the bare behavior; a git error while counting fails open. - batch-executor resolves the base once and feeds both calls. - qa/SKILL.md: all 32 bare `git diff main...HEAD` -> origin/main...HEAD across all three mirrors (byte-identical); same for the 18 bare refs in the qa reference docs and the two gate scripts (semgrep-scan.ts, tautology-detector-cli.ts), which scanned merged code on the motivating run. - Real-git regression tests: worktree from origin/main with local main deliberately behind asserts zero files and no phase commit. Out of scope (follow-up): the same bare-ref pattern in qa-cache.ts, worktree-manager.ts diff summaries, and phase-executor.ts:1114. Fixes #878
… AC-3 test QA-round fixes: - semgrep-scan.ts / tautology-detector-cli.ts: array-form execFileSync instead of execSync template interpolation. Not exploitable today (the base ref is always a hardcoded candidate of "main"), but closes the latent shell surface if a future caller passes a non-literal base. - Integration test: the standalone fixture-sanity test asserted only on git state (tautology detector correctly flagged it); its precondition assertions now live inside the AC-3 regression test.
admarble
deleted the
feature/878-fix-observability-phase-diff-stats-compare-aga
branch
August 4, 2026 04:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getGitDiffStatsnow resolves its base via a newresolveDiffBase(nearest-candidate betweenorigin/<base>and the bare ref, preferring origin on a tie), so phase diff stats compare against the ref the worktree was actually created from instead of a possibly-stale local branch — no more phantomfilesModifiedfrom already-merged upstream commits.getCommitHashgains an optionalbaseRefand returnsundefinedwhen the branch never moved off its base, so an empty branch's phase log no longer records the base tip as its commit. Run-level start/end markers keep the bare behavior.git diff main...HEADinqa/SKILL.md→origin/main...HEADacross all three mirrors (byte-identical), plus — disclosed scope expansion, same root cause and same §7 gates — the 18 bare refs in qa's reference docs and the two gate scripts (semgrep-scan.ts,tautology-detector-cli.ts, now array-formexecFileSync).origin/mainwith local main deliberately behind asserts zero files and no phase commit; also covers chain-mode local-ahead bases and remote-less fallback.AC Verification
getGitDiffStatsresolves base likeresolveBaseRefsrc/lib/workflow/git-diff-utils.ts(resolveDiffBase), wired inbatch-executor.tsgetCommitHashundefined when no commits past basegit-diff-utils.ts; run-level call sites deliberately unchangedgit-diff-utils.integration.test.ts(9 tests, real repos)qa/SKILL.mdorigin-qualified, ×3 mirrorscheck-skill-sync.ts44/44 syncedMutation verification (repo testing rules): reverting
getGitDiffStatsto the bare ref fails exactly the 2 diff-stat regression tests; disabling thegetCommitHashzero-check fails exactly the AC-2 test. Both recorded in the QA comment on #878.Out of scope: remaining bare-ref consumers (
qa-cache.ts,worktree-manager.tssummaries,phase-executor.tsaider file-context, other skills' mirrors) → #890.Test plan
lint:skill-callsgreenFixes #878
🤖 Generated with Claude Code