fix(#3659): make the worktree base-check trust evidence, not baseRef (#3736)

* test(#3659): baseref-head suppress must be mode-aware regression rows

* fix(#3659): make baseref-head suppress mode-aware and thread isolation mode

* fix(#3659): review fixes - stale advice purge, message pins, mode alias

* fix(#3659): pick-interceptable emit seam, ack merge, writeSync pin

* test(#3659): rewrite set-baseref pin, fix writeSync row stub

* chore(#3659): backfill changeset pr number

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-21 04:58:33 -04:00
committed by GitHub
parent 1f76861202
commit 2b42b28687
18 changed files with 339 additions and 76 deletions

View File

@@ -24,19 +24,16 @@
# Unset per-wave manifest so wave N+1 creates a fresh one (#3384, #1369).
unset WAVE_WORKTREE_MANIFEST
# Between-wave base refresh (#1369): after wave N merges and tracking commits, HEAD has
# advanced. Re-assert worktree.baseRef:"head" (idempotent — no-op if already set) so the
# Claude Code harness re-reads the live HEAD on the next Agent(isolation="worktree") call
# rather than using a cached session-start commit as the fork base.
# Between-wave base re-check (#1369, #3659): after wave N merges and tracking commits,
# HEAD has advanced. Re-asserting worktree.baseRef:"head" is deliberately NOT done here —
# the runtime harness does not read project-settings baseRef (#48), so in
# harness-worktree mode the setting cannot influence the fork base. The safety re-check
# below compares HEAD against the REAL fork base and degrades the remaining waves
# whenever they diverge, avoiding the base-mismatch FATAL in executor agents.
if [ "$ISOLATION" = "harness-worktree" ] && [ "$USE_WORKTREES" != "false" ]; then
gsd_run query worktree.set-baseref 2>/dev/null || true
# Safety re-check: evaluate degradation AFTER the wave N commits. If HEAD has diverged
# from origin/HEAD and baseRef is NOT "head", degrade remaining waves to sequential to
# avoid the base-mismatch FATAL in executor agents.
_BETWEEN_DEGRADE=$(gsd_run query worktree.base-check --pick shouldDegrade 2>/dev/null || echo "false")
_BETWEEN_DEGRADE=$(gsd_run query worktree.base-check --mode "$ISOLATION" --pick shouldDegrade 2>/dev/null || echo "false")
if [ "$_BETWEEN_DEGRADE" = "true" ]; then
_DEGRADE_MSG=$(gsd_run query worktree.base-check --pick message 2>/dev/null || true)
_DEGRADE_MSG=$(gsd_run query worktree.base-check --mode "$ISOLATION" --pick message 2>/dev/null || true)
[ -n "$_DEGRADE_MSG" ] && printf '%s\n' "$_DEGRADE_MSG" >&2
printf 'Degrading to sequential mode for remaining waves: HEAD advanced past worktree fork base after wave %s merge (#1369).\n' "${N}" >&2
# Both must move together (#2652): dispatch keys on ISOLATION.

View File

@@ -13,9 +13,9 @@
```bash
if [ "$ISOLATION" = "harness-worktree" ] && [ "${USE_WORKTREES:-true}" != "false" ]; then
_WAVE_DEGRADE=$(gsd_run query worktree.base-check --pick shouldDegrade 2>/dev/null || true)
_WAVE_DEGRADE=$(gsd_run query worktree.base-check --mode "$ISOLATION" --pick shouldDegrade 2>/dev/null || true)
if [ "$_WAVE_DEGRADE" = "true" ]; then
_WAVE_DEGRADE_MSG=$(gsd_run query worktree.base-check --pick message 2>/dev/null || true)
_WAVE_DEGRADE_MSG=$(gsd_run query worktree.base-check --mode "$ISOLATION" --pick message 2>/dev/null || true)
[ -n "$_WAVE_DEGRADE_MSG" ] && printf '%s\n' "$_WAVE_DEGRADE_MSG" >&2
echo "⚠ [#1369] Worktree fork base diverged from orchestrator HEAD (wave merges advanced HEAD past origin/HEAD). Auto-degrading to sequential mode for this wave to avoid base-mismatch halts." >&2
# Both must move together (#2652): dispatch keys on ISOLATION.
@@ -27,11 +27,13 @@
If `shouldDegrade` is `true`, override `USE_WORKTREES=false` for **this wave only** —
all plans in this wave execute sequentially on the main working tree. Later waves re-run
this check and may re-enable worktree isolation if `origin/HEAD` is updated (e.g. via
`git fetch` or `worktree.baseRef:"head"` config).
this check and may re-enable worktree isolation once `origin/HEAD` matches HEAD again
(e.g. via `git fetch` or a push that advances it).
**To avoid this degrade across all waves:** set `worktree.baseRef:"head"` in
`.claude/settings.local.json` (or run `gsd-tools worktree set-baseref`). This tells
Claude Code to fork from the live HEAD instead of `origin/HEAD`, so each wave's new
worktrees always start from the correct post-merge base. See #683 for the base-ref
configuration detail.
**Why `worktree.baseRef:"head"` does not avoid this degrade (#48, #3659):** the runtime
harness does not read project-settings `baseRef` — an isolated dispatch always forks from
`origin/HEAD` regardless of the setting, so the check compares against the real fork base
and degrades whenever HEAD has diverged. Parallel worktrees return once HEAD is
merged/pushed so `origin/HEAD` matches it. The setting still restores parallel execution
on runtimes where GSD itself creates the worktrees (orchestrator-managed isolation:
Codex, OpenCode, Kimi, Kimi Code). See #683 for the base-ref configuration detail.