fix(#3995): derive the review diff base from the phase directory (#4181)

* test(#3995): diff base keys on the phase directory, not commit subjects

All three derivation sites (Tier 3, spawn_reviewer, fallow pre-pass)
must anchor on the phase directory's first commit; the milestone-blind
repro (an archived milestone's same-numbered phase commit capturing
the base) is the failing-first row. #3191/#3503 rows reworked to the
directory-anchor contract; T6 docs-parity forbids any remaining
phase-scope message-grep site.

* fix(#3995): derive the review diff base from the phase directory

A phase number is unique within a milestone, not a repository; the
message grep had no milestone bound and tail -1 deliberately selected
the oldest same-numbered subject, dragging archived milestones phases
into the scope (7 files to 3388 plus the >50 depth downgrade). All
three lockstep sites now anchor on the first commit that added anything
under the phase own directory — the same anchor class
git-base-branch phaseStartCommit uses. ShellCheck baseline gains the
escaped fragment shifted parse signature.

Emitted-Drift-Ack-Growth: code-review.md — phase-directory anchor replaces the message-grep derivation at both sites (#3995)

* chore(#3995): backfill changeset pr number

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-02 06:03:17 -04:00
committed by GitHub
parent 647365faf1
commit 5c7243e54b
5 changed files with 189 additions and 195 deletions

View File

@@ -27,21 +27,19 @@ FALLOW_STDERR_TMP=$(mktemp)
# Phase scope uses fallow's native changed-files scoping (--changed-since <base>).
# Derive the phase base commit; if none is found, fall back to repo scope (fallow
# auto-detects the base branch). #3191/#3503: the grep is the SAME anchored,
# POSIX-portable conventional-commit-scope derivation the workflow's Tier-3
# scope step uses (subject-line `type((phase-)?N(-plan)?):`, padded or unpadded
# phase spelling). Free prose in commit bodies — "deferred to Phase N per
# D-09", "### Phase N" format examples — never captures the base, and a bare
# digit substring matches version strings, dates, and other phases; the oldest
# such false match would silently widen --changed-since far past the phase.
# Phase-directory-anchor derivation, lockstep with the workflow's Tier-3
# scope step (#3191/#3995): base = the parent of the first commit that added
# anything under the phase's own directory. Commit subjects carry no milestone
# bound — a same-numbered phase in a previous milestone used to win the grep.
FALLOW_SCOPE_ARGS=()
if [ \"$FALLOW_SCOPE\" = \"phase\" ]; then
PHASE_SCOPE_NUM=\"${PADDED_PHASE}\"
case \"$PADDED_PHASE\" in
0[0-9]*) PHASE_SCOPE_NUM=\"${PADDED_PHASE#0}|${PADDED_PHASE}\" ;;
esac
FALLOW_PHASE_COMMITS=$(git log --oneline --all --extended-regexp --grep=\"^[[:alpha:]]+!?\((phase-)?(${PHASE_SCOPE_NUM})(-[0-9]+)?\)!?:\" --format=\"%H\" 2>/dev/null)
if [ -n \"$FALLOW_PHASE_COMMITS\" ]; then
FALLOW_BASE=$(echo \"$FALLOW_PHASE_COMMITS\" | tail -1)^
# #3995: phase-directory anchor — same derivation as the Tier-3 scope step
# (lockstep per #3191). A phase number is unique within a milestone, not a
# repository; the former message grep matched previous milestones'
# same-numbered phases and tail -1 selected the oldest.
FALLOW_PHASE_START=$(git log --format=\"%H\" --diff-filter=A -- \"${PHASE_DIR}\" 2>/dev/null | tail -1)
if [ -n \"$FALLOW_PHASE_START\" ]; then
FALLOW_BASE=\"${FALLOW_PHASE_START}^\"
FALLOW_SCOPE_ARGS=(--changed-since \"$FALLOW_BASE\")
fi
fi