fix(bin): make fm-teardown's landed-work proof forge-agnostic - #891
Open
mattwwatson wants to merge 2 commits into
Open
fix(bin): make fm-teardown's landed-work proof forge-agnostic#891mattwwatson wants to merge 2 commits into
mattwwatson wants to merge 2 commits into
Conversation
fm-teardown.sh's landed-work test relied on GitHub-shaped refs/pull/* fetches, so on forges that do not publish those refs a landed branch could be misjudged. Add a third, forge-agnostic proof: patches_in_default walks the default branch by patch-id (bounded by FM_LANDED_PATCH_SCAN_LIMIT) so conflicted-advance cases are rescued on any forge, with revert-rollback safety so a landed-then-reverted change still refuses teardown. Accept Bitbucket /pull-requests/<n> URLs and skip refs/pull/* fetches on hosts that do not publish them.
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.
Intent
Upstream contribution from the mattwwatson/firstmate fork: make fm-teardown.sh's landed-work proof forge-agnostic by adding a default-branch patch-id proof (bounded, revert-safe), accepting Bitbucket /pull-requests/ PR URLs, and skipping GitHub-shaped refs/pull/* fetches on forges that do not publish them, so teardown refuses correctly on any forge. The new tests/fm-teardown.test.sh suite runs in the portable serial lane unless maintainers prefer shard placement; it passes isolated on the upstream base (42/42 locally).
What Changed
bin/fm-teardown.shgains a third, forge-agnostic landed-work proof:work_is_landednow falls through topatches_in_default, which checks that every unpushed commit is present by patch id in the up-to-date default branch and still rolls back out of that branch's current tree (via a throwaway index, walked newest-first), so squash-merged work on any forge is recognized while landed-then-reverted work still refuses. The default-branch scan is bounded by a newFM_LANDED_PATCH_SCAN_LIMITknob (default 1000; 0 or non-numeric means unbounded), documented indocs/configuration.md.pr_number_from_targetaccepts Bitbucket/pull-requests/<n>URLs, andensure_commit_objectskips therefs/pull/<n>/headfetch when origin is Bitbucket Cloud, which publishes no such refs (deny-list, so unrecognized hosts keep trying the fetch).tests/fm-teardown.test.shsuite (42 cases, runs in the portable-serial lane, verified 42/42 by the pipeline's Test stage with a negative control against the base commit) and pointsdocs/gitlab-merge-watch.mdat both content and patch-id fallback proofs.Risk Assessment
Testing
Ran the full 42-case fm-teardown suite isolated (all pass, exit 0) and confirmed its portable-serial lane placement; proved the new forge-agnostic cases fail on the upstream base script (so they test the fix, not vacuously pass); then demonstrated the end-user behavior with a CLI transcript of the real fm-teardown.sh on Bitbucket-shaped repos — allowing squash-merged work via the default-branch patch-id proof with no GitHub-shaped refs/pull fetches, and refusing both never-landed and landed-then-reverted work. No UI surface is involved (CLI-only change), so the transcript is the reviewer-visible artifact.
Evidence: Bitbucket end-to-end teardown CLI transcript (ALLOW + 2 REFUSE scenarios, fetch log)
Evidence: Demo script that builds the Bitbucket-shaped sandboxes and drives the real bin/fm-teardown.sh
Evidence: Base-commit negative control (new tests fail on old fm-teardown.sh)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-teardown.sh:552- work_is_landed's fall-through path fetches the default branch twice: content_in_default and patches_in_default each call default_ref_up_to_date, which re-runsgit fetch origin +refs/heads/<name>:refs/remotes/origin/<name>. On every refusal and every patch-id rescue this doubles the network round-trip and adds a second transient-failure point. The comments state the proofs are deliberately independent and additive, and both failure modes are fail-safe (refuse), so this is a deliberate tradeoff worth acknowledging rather than an issue to fix; resolving the ref once in work_is_landed and passing it down would remove the duplicate fetch if it ever matters.✅ **Test** - passed
✅ No issues found.
bash tests/fm-teardown.test.shisolated on the branch — 42/42 ok, exit 0 (matches the intent's 42/42 claim)bin/fm-test-run.sh --list --lane portable-serial— confirms tests/fm-teardown.test.sh is selected by the portable-serial lane (pr-forge family)Negative control: checked out base-commitbin/fm-teardown.sh(4497181) under the new test suite — first forge-agnostic case fails (expected exit 0, got 1), suite exit 1; restored to f7ce2c4 and re-verified suite exit 0Manual end-to-end demo (bitbucket-teardown-demo.sh) driving the realbin/fm-teardown.shagainst Bitbucket-shaped sandboxes: squash-merged+conflicting-advance → ALLOW (exit 0) via default-branch patch-id proof; never-landed → REFUSED (exit 1, worktree preserved); landed-then-reverted → REFUSED (exit 1, worktree preserved); fetch log shows no refs/pull/* fetch on a bitbucket.org origin and the /pull-requests/7 PR URL is accepted✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.