fix(bin): close Gerrit-landed backlog items with the change URL as a note - #6140
Conversation
Teardown's backlog_done_args hands every ship's recorded pr= URL to fm_backlog_done as --pr, and tasks-axi refuses any --pr that is not a canonical GitHub or Forgejo pull request. A Gerrit change URL therefore left the item In flight after cleanup, and the pending backlog-close record replayed into the same refusal at every session start. fm_backlog_done now rewrites a --pr whose value fm_pr_url_parse reads as a Gerrit change into --note "Gerrit change <url>". The mapping sits at the tasks-axi call rather than in the pending-close record, so records already written with --pr replay to a close unchanged. The captain-held retain path records the URL in its deliverable line and skips the update --pr it cannot make.
|
|
Speaking as Kun's firstmate: this is merged. Thank you @slnkjthien — really appreciate you taking the time on this. VISION.md per-rule
contract-class: restore — unconfigured GitHub teardown unchanged; forge=gerrit landing was already supposed to close the backlog item and was broken by tasks-axi refusing Gerrit URLs as Merged squash as |
Conflict in bin/fm-backlog-transition-lib.sh: upstream's Gerrit close-note rewrite (kunchenguid#6140) and the fleet's Gitea close-note rewrite do the same job, so they are unified in fm_backlog_pr_link_note, which records a Gerrit change as 'Gerrit change <url>' and a Gitea/Forgejo pull request as 'PR <url>' on direct close, retained close, and captain-hold answer. Upstream's eager fm-pr-lib.sh source supersedes the fleet's lazy fm_backlog_pr_lib_helpers loader.
Intent
Fixes #6138.
On a project registered with
forge=gerrit, cleanup of a landed task leaves its backlog item In flight.bin/fm-teardown.shrecords the close astasks-axi done <id> --pr <gerrit change url>, and tasks-axi (0.2.6) refuses the URL: "Task pr link must be a canonical pull request URL". The endpoint and worktree are cleaned up, but the item stays In flight, and thestate/<id>.backlog-closerecord left behind fails the same way on every session-start replay, so the only way out is closing the item by hand. Everyforge=gerritlanding hits this; it was first seen on the first production Gerrit landing after #5427 merged.The item should close as Done with the Gerrit change URL still recorded on it, and a pending close record should replay to success. GitHub PR URLs keep closing with
--prexactly as today.Related and not addressed: #5936, the same rejection for GitHub Enterprise PR URLs, which also cannot be registered or merge-polled.
What Changed
fm_backlog_done(bin/fm-backlog-transition-lib.sh) now rewrites--pr <gerrit change url>to--note "Gerrit change <url>"before it callstasks-axi done. tasks-axi rejects that URL as a--prlink, so before this change teardown and replays ofstate/<id>.backlog-closeboth failed and left the item In flight. It now closes as Done, and the newfm_backlog_pr_is_gerrit_changeusesfm_pr_url_parseto decide which URLs are Gerrit changes. GitHub PR URLs still go through--pras before.fm_backlog_retain), a Gerrit change URL goes only into the deliverable line and is no longer copied into the row's--prfield.bin/fm-captain-hold.shanswerpasses a retained Gerrit URL as aGerrit change <url>note on thedonecall instead of runningupdate --pr.docs/captain-hold-lifecycle.mddocuments both behaviours.fm-backlog-atomicity, Gerrit teardown close and replay infm-teardown, and retain/answer with a Gerrit URL infm-captain-hold-lifecycle.🤖 Generated with Claude Code
Risk Assessment
✅ Low: Gerrit change URLs are now rewritten to
--noteat the sharedfm_backlog_doneandfm_backlog_row_artifact_supportedboundaries, which cover teardown close, replay of pending close records (fm_backlog_close_transition), retain mode and an early captain answer. GitHub--prhandling is unchanged, and no other code sends--prto tasks-axi.Testing
I ran the real teardown and session-start scripts in disposable homes from bin/fm-lab-home.sh, against the real tasks-axi 0.2.6, which refuses Gerrit --pr links. On this change a Gerrit landing closes as Done with the change URL kept as a note, a GitHub landing still closes with its pr link, and a stuck close record written by the base code replays to success. On the base commit the same Gerrit teardown and replay reproduce the issue. I did not drive the captain-held answer path live. It is covered by its new regression test, which passes along with the other two test files that carry the new Gerrit cases. The temp labs and the base archive were removed and the worktree is clean.
Evidence: Live teardown of a Gerrit landing (fixed): item Done, change URL recorded as a note
Source: Live teardown of a Gerrit landing (fixed): item Done, change URL recorded as a note
Evidence: Live teardown of a Gerrit landing on base 65c75b0: bug reproduced (item stays In flight, record stuck)
Source: Live teardown of a Gerrit landing on base 65c75b0: bug reproduced (item stays In flight, record stuck)
Evidence: Live teardown of a GitHub landing: still closes with a pr link
Source: Live teardown of a GitHub landing: still closes with a pr link
Evidence: Session-start replay of a stuck Gerrit close record: base fails, fix succeeds
Source: Session-start replay of a stuck Gerrit close record: base fails, fix succeeds
Evidence: Driver script for the live teardown runs
Source: Driver script for the live teardown runs
Evidence: Captain-hold lifecycle test log
Source: Captain-hold lifecycle test log
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
/tmp/fm-live-teardown.sh https://gerrit.example.com/c/project/+/12345runs the real bin/fm-teardown.sh in a disposable home from bin/fm-lab-home.sh, using the real tasks-axi 0.2.6. Only treehouse is stubbed. Result: exit 0, state done, body "Gerrit change <url>", no close record left behind.The same driver on agit archive 65c75b0copy (the base) reproduces the bug: exit 1, state in_flight, tasks-axi refuses with "Task pr link must be a canonical pull request URL", and the close record stays./tmp/fm-live-teardown.sh https://github.com/example/repo/pull/7 task-h1checks the GitHub case: state done, links pr:https://github.com/example/repo/pull/7, no note added.FM_HOME=<lab> FM_BOOTSTRAP_NETWORK=skip bin/fm-bootstrap.shwas run against the stuck record the base teardown left. The base bootstrap fails the replay with the same refusal; the fixed bootstrap closes the item as Done with the Gerrit note and removes the record.bash tests/fm-captain-hold-lifecycle.test.sh: includes test_answer_before_cleanup_replay_notes_a_retained_gerrit_change and test_teardown_retains_a_gerrit_captain_call_with_its_change_url.bash tests/fm-teardown.test.shandbash tests/fm-backlog-atomicity.test.sh: include the new Gerrit teardown and Gerrit replay regression tests.✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.