fix(source-control): emit worktree_lock state when arming liveness guard - #2399
fix(source-control): emit worktree_lock state when arming liveness guard#2399kyle-sexton wants to merge 1 commit into
Conversation
Lock failures still warn and exit 0, but stderr now carries worktree_lock=armed|unarmed for orchestrators. Fixes #2389 Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 42s —— View job Security Review
Scope: Findings: none. The functional change is minimal and low-risk:
No CRITICAL / IMPORTANT / SUGGESTION items to report. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7c14a1438
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - **`fetch_pull_request_commits` fails closed when the pull-commits walk is shorter than the PR's | ||
| `commits` count (#2387).** GitHub caps that endpoint at 250 commits regardless of pagination; the | ||
| helper now compares against the PR metadata and raises instead of returning a silently truncated | ||
| list. |
There was a problem hiding this comment.
Ship the implementation claimed by the 0.53.3 entry
The 0.53.4 artifact now advertises the #2387 fail-closed behavior, but skills/babysit-prs/scripts/babysit_gh.py::fetch_pull_request_commits still only returns the paginated /pulls/{number}/commits rows and never reads or compares the PR's commits metadata. Consequently a PR with more than GitHub's 250-commit endpoint cap is still silently truncated, so evaluate_required_signatures can omit unverified commits while users of this released version are told that case is held closed.
Useful? React with 👍 / 👎.
| fi | ||
|
|
||
| printf '%s: created worktree on branch %q (base %s)\n' "$PROG" "$name" "$base_ref" >&2 | ||
| printf '%s: worktree_lock=%s\n' "$PROG" "$worktree_lock_state" >&2 |
There was a problem hiding this comment.
Emit the lock state before later copy failures can exit
When a matched .worktreeinclude file cannot be copied, the helper exits 4 at the copy-failure branch after the worktree and lock attempt have already occurred, so this final marker is never emitted. That leaves an orchestrator without the new worktree_lock state precisely when a partially provisioned worktree remains on disk; emit the state immediately after the lock attempt rather than only on the all-copies-succeeded path.
Useful? React with 👍 / 👎.
|
Claude finished @kyle-sexton's task in 3m 43s —— View job Code Review: worktree_lock signal on stderrReviewed the 4 changed files against Findings (posted inline on the relevant lines):
Everything else — the core change (a two-line stderr addition gated on the existing lock-attempt result), the I did not run the test suite myself; the PR description's |
| ## [0.53.3] | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **`fetch_pull_request_commits` fails closed when the pull-commits walk is shorter than the PR's | ||
| `commits` count (#2387).** GitHub caps that endpoint at 250 commits regardless of pagination; the | ||
| helper now compares against the PR metadata and raises instead of returning a silently truncated | ||
| list. |
There was a problem hiding this comment.
🔴 Important: This [0.53.3] entry describes a fix to fetch_pull_request_commits ("raises instead of returning a silently truncated list", #2387) that isn't in this diff and doesn't exist anywhere in this branch's history — fetch_pull_request_commits in plugins/source-control/skills/babysit-prs/scripts/babysit_gh.py (lines 476-502) still just returns out with no comparison against the PR's commits metadata and no raise. No commit in this repo's history mentions #2387 or fetch_pull_request_commits.
This entry is unrelated to the PR's stated purpose (issue #2389, worktree lock signal) and appears to be an erroneous/orphaned addition — possibly a rebase or merge artifact. It also explains why plugin.json jumps straight from 0.53.2 to 0.53.4, skipping 0.53.3 as an actual shipped version.
Either drop this block (if it doesn't belong in this PR) or, if the #2387 fix genuinely needs to land, implement it in babysit_gh.py as described. Shipping a changelog entry for a fix that was never made is misleading to anyone reading the changelog as a source of truth.
| fi | ||
|
|
||
| printf '%s: created worktree on branch %q (base %s)\n' "$PROG" "$name" "$base_ref" >&2 | ||
| printf '%s: worktree_lock=%s\n' "$PROG" "$worktree_lock_state" >&2 |
There was a problem hiding this comment.
🟡 Nit: The worktree_lock= signal is only emitted on the final success path. If the .worktreeinclude copy step fails (line 699-702, exit 4), the script exits before reaching this printf — so the exact case where an orchestrator most needs to know the lock state (the worktree already exists on disk, and the script is exiting non-zero) never gets it.
worktree_lock_state is already known right after the lock attempt (line 668-672). Emitting it there — or at every exit point once the worktree exists — would make the signal reliable regardless of which later step fails, rather than only on the happy path.
| out=$(bash "$HELPER" --name feat/liveness --root-file "$root_file" --repo-dir "$repo" 2>/dev/null) | ||
| out=$(bash "$HELPER" --name feat/liveness --root-file "$root_file" --repo-dir "$repo" 2>"$TEST_TMPDIR/wt-lock-stderr") | ||
| assert_exit "lock case: creation succeeds (exit 0)" 0 "$?" | ||
| assert_contains "lock state is machine-readable on stderr" "$(cat "$TEST_TMPDIR/wt-lock-stderr")" "worktree_lock=armed" |
There was a problem hiding this comment.
🟡 Nit: This test only covers the armed happy path for the new machine-readable signal. There's no test asserting worktree_lock=unarmed is emitted when git worktree lock fails (the actual case this PR's stated purpose — "no longer silent to machines" — is about, since the armed case was already visible via worktree list --porcelain). Consider adding a fixture that forces the lock to fail (e.g. pre-locking the path, or another mechanism already used elsewhere in this suite) and asserting on the unarmed stderr line and the existing warning message together.
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
Fixes #2389.
Emits
worktree_lock=armed|unarmedon stderr after the lock attempt. Lock failure remains best-effort (warn + exit 0) but is no longer silent to machines.Tests:
worktree-create.test.sh.Related