fix(gaia-wiki): wait for merge and clean up locally when finishing the chain#514
Merged
Conversation
`gaia wiki chain finish` (and `sync land`'s protected-branch path) fired `gh pr merge --auto` then immediately checked out the base branch and returned. `--auto` only queues the merge, so the base was never pulled and the local `wiki-sync/*` branch was never deleted; the remote branch got auto-deleted on merge while the local one lingered until the janitor swept it. Finish now lands like any other PR: after enabling auto-merge it polls `gh pr view --json state` until MERGED, then cleans up locally (checkout base, pull --ff-only, delete the local branch, prune). If the merge does not land within the bounded wait, auto-merge stays queued and cleanup is deferred to the session-start janitor (unchanged fallback), so the CLI never hard-fails here. The wait+cleanup lives in a shared `finalizeMerge` helper in `util/land.ts` because the chain determinism contract forbids the router from inlining git/gh; both surfaces route through it, removing the duplicated finish tail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
code-review-audit skipped: no audit-relevant files changed in the un-audited delta (since the last clean audit); GAIA-Audit commit status stamped on HEAD so the merge gate is satisfied with no local audit run |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
code-review-audit skipped: no audit-relevant files changed in the un-audited delta (since the last clean audit); GAIA-Audit commit status stamped on HEAD so the merge gate is satisfied with no local audit run |
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.
Problem
/gaia-wiki's finish (gaia wiki chain finish, andsync land's protected-branch path) firedgh pr merge --squash --auto --delete-branchthen immediatelygit checkout mainand returned.--autoonly queues the merge, so the CLI never waited for it: localmainwas never pulled to reflect the merged content, and the localwiki-sync/*branch was never deleted. The remote branch got auto-deleted on merge later, but the local one lingered until the session-start janitor eventually swept it.Fix
Finish now lands like any other PR, following the "safe pattern" in
wiki/concepts/PR Merge Workflow.md:--autowaits for the gate to go green server-side).gh pr view <branch> --json stateuntilMERGED.git checkout main→git pull --ff-only origin main→git branch -D <branch>→git fetch --prune origin.The chain determinism contract forbids the router from inlining git/gh, so the wait+cleanup lives in a shared
finalizeMergehelper in.gaia/cli/src/wiki/util/land.ts. Bothchain finishandsync land's protected-branch landing route through it (the latter had the identical non-waiting bug), removing the duplicated finish tail.Notes
.gaia/+.claude/+ root markdown, so it's out ofcode-review-auditscope — the merge gate's out-of-scope bypass clears it with no marker..gaia/cli/gaia,gaia-maintainer) rebuilt.Testing
.gaia/clitypecheck clean; full CLI suite 1477 passed / 1 skipped.chain finishandsync land.🤖 Generated with Claude Code