Repository navigation
fix: resolve the closed pr head so a clean closed worktree can prune - #31124
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix targets the real cause (a lookup that only accepted MERGED) by letting the caller choose the state, every refusal stays in place, and the removal callers keep the MERGED-only default. Notes
[DESIGN-REVIEWED] 75b01c8 Description read[DESCRIPTION-READ] 11b7057db674ad3a886004093b35cffcf6a290d007ea8e80b7612f37c27c1bb6 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This is a mechanism-level fix for #30399. The head lookup only matched MERGED, so the closed branch could never resolve an OID. The rewritten batch pin What this change shipsInventory (5 items) — 5 justifiedIntent: let an operator prune a clean worktree whose PR was closed without merging, from the existing manual Prune-merged path — FIX.
[FIRST-PRINCIPLES-REVIEWED] 75b01c8 Description read[DESCRIPTION-READ] 12fa99213bbfb0c9714d8bcd7a24b4f46f822982d8d2fc695cbb412a24c1e1ba That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
HOLD. Reviewed 57bf7ac. What would clear it:
The code as written looks sound. Every other caller keeps the MERGED default, an OPEN PR on the head is still refused, and the head-containment check still runs. All AI lanes pass on this head. The rebase needs a new review. — crew-pr-reviewer (r148) |
|
The KiroCrew conductor (largjaco's v2 drive-to-green session) now owns this PR under the 24h orphan rule; the desk session that opened it has been offline since 11-06. I'll rebase onto main, fix CI and answer review here. |
57bf7ac to
75b01c8
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving. I read the whole diff, tests included.
- The root cause is right. The closed-PR branch of
_prunablebound its verdict through_fetch_pr_head_oid, which only ever returned a MERGED head, so a clean closed worktree always readclosed_unverifiedand the manual closed-PR prune could never be reached. - The fix is narrow.
stateis keyword-only withMERGEDas the default, so every removal caller is unchanged. Anything outside{"MERGED", "CLOSED"}is refused beforeghruns, so OPEN can never be passed. - Every guard is kept: the same fresh
gh pr list --state allquery with state and OID from one row, the saturation sentinel, the refusal when any OPEN PR sits on the head, and the head-containment check after it, so a branch reused after its PR closed staysclosed_new_commits. The tests pin the OPEN-next-to-CLOSED refusal, the saturated batch, a MERGED-only head under the CLOSED gate, and OPEN asstate. - The reaper still auto-prunes only
merged. Aclosedcandidate is offered only to the manual path, with its unmerged-commits warning. - No regex.
Kiro Crew's built-in Dev Fleet moved on after this tree was cut from main at 6d07df11. An adopted host runs this tree, so each of those changes is carried here first, up to main at 46f62dea: - pod_down waits for the pod's whole stop, and the tool waits 120s (kirodotdev/KiroCrew#33272) - pod_up names a worktree hidden in a session's scratch, and its description says where to create one (kirodotdev/KiroCrew#33254) - the how-to sentence is one message per language (kirodotdev/KiroCrew#33327), rendered by i18nNodes, the bundle's stand-in for the dashboard's <Trans components> - Create worktree from latest stable, with Refresh, in a labelled More actions menu (kirodotdev/KiroCrew#33391), on the page's own MenuBtn - pod_up's test-double env override (kirodotdev/KiroCrew#35199) - provision checks the build input (kirodotdev/KiroCrew#22686), a clean closed worktree can prune (kirodotdev/KiroCrew#31124), the secret comes from the spawn environment (kirodotdev/KiroCrew#34762), every bad-body 400 carries a code (kirodotdev/KiroCrew#32503), and the demo skill's Windows tool lookup (kirodotdev/KiroCrew#33556, #33779) app.json now carries the wheel copy's agentTools block byte for byte, which an adopted record needs for its tools to stay listed (kirodotdev/KiroCrew#33141). The suite runs against Kiro Crew main at 46f62dea, the fixtures match that wheel copy, and PORTING.md records each port. Co-authored-by: Bolin Chen <bolichen@amazon.com>
Problem / Motivation
Goal: A clean worktree whose PR was closed without merging is offered under Prune merged as a
closedcandidate instead of sitting in Kept asclosed_unverifiedon every scan.In Dev Fleet, a clean worktree whose branch has a CLOSED (not merged) pull request is always kept with "PR closed but verification unavailable — retry", even when
ghanswersCLOSEDwith the matching head OID. The manual closed-PR prune path can never be used.Why it matters
The closed-PR prune path (manual, with the unmerged-commits warning) is unreachable, so every declined or superseded worktree has to be removed by hand, and the Kept list shows a misleading "retry" that never succeeds.
Not a goal
merged).What changed (motivation → approach → change)
_prunablereturnsclosed_unverifiedfor every clean closed-PR worktree.fleet_state._fetch_pr_head_oid, which only ever returns the head of a MERGED PR. For a CLOSED PR it always returnsNone, so the fail-closed guard always fires._fetch_pr_head_oidtakes a keyword-onlystate(MERGEDby default, orCLOSED; anything else is refused beforeghruns). It keeps the same freshgh pr list --state allquery, the saturation sentinel, and the refusal when any OPEN PR is on the head; only the state the returned OID must come from changes. The closed branch of_prunablepassesstate="CLOSED", then still runs the head-containment check, so a branch reused after its PR closed staysclosed_new_commits.Backwards compatibility
Compatible: the new parameter is keyword-only with a default that keeps the existing MERGED-only behavior for every current caller.
Removes nothing: the change only lets a previously unreachable
closedverdict be reached; no refusal, key, or caller is removed.Tests
test/test_dev_fleet_server_coverage_prune.py::test_prunable_closed_clean_resolves_head_through_real_lookup: with onlyghstubbed, a clean closed-PR worktree whose head matches is aclosedcandidate.test/test_dev_fleet_server_coverage_prune.py::test_prunable_closed_with_open_pr_on_head_stays_unverified: a reused head with an OPEN PR next to the CLOSED one staysclosed_unverified.test/test_dev_fleet_server_more_coverage.py::test_fetch_pr_head_oid_closed_gate_returns_closed_head:state="CLOSED"returns the CLOSED head; the default still returnsNonefor it.test/test_dev_fleet_server_more_coverage.py::test_fetch_pr_head_oid_closed_gate_keeps_refusals: OPEN-on-head, saturated batch, MERGED-only head and an OPENstateare all refused, the last without callinggh.Proof: PROVEN test/test_dev_fleet_server_coverage_prune.py::test_prunable_closed_clean_resolves_head_through_real_lookup (head 9e2eacfd4bba)
python3 scripts/local-gate.pygreen locally (backend related: 1308 passed; frontend related: 466 files / 13395 tests passed). Lint, mypy, comment-history and brand gates pass.Manual verification
N/A — unit coverage sufficient: the defect sits entirely in how the
gh pr listJSON is read, which the new tests drive with real-shaped payloads.Related Issues
Closes #30399
Sibling sweep
Swept: git grep -n "_fetch_pr_head_oid" -- src/
Sibling: src/kiro_crew/apps/builtins/dev_fleet/worktree_ops.py -- changed here
Sibling: src/kiro_crew/apps/builtins/dev_fleet/worktree_ops_removal.py -- not affected -- every call there gates a MERGED verdict and keeps the default
Sibling: src/kiro_crew/apps/builtins/dev_fleet/fleet_state.py -- changed here
Pattern harvest
Not generalizable: one lookup helper was gated to a single PR state and reused by a caller whose verdict rests on a different state.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.