fix(bin): keep the PR block last when registering a no-mistakes clone - #12
Merged
Merged
Conversation
register-clone appended nm_clone= after the pr= and pr_head= lines, so the merge poll's record validator rejected the task record on every cycle. Insert nm_clone= before the PR block instead.
NewAiCoder
force-pushed
the
fm/fm-meta-nm-clone-after-pr
branch
from
October 1, 2026 23:34
5d634ca to
3794160
Compare
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.
What Changed
fm-nm-watch.sh register-clonenow rewrites the task record withawkinstead of appendingnm_clone=at the end. It drops any existingnm_clone=line, writesnm_clone=before the PR block (pr=,pr_head=,x_request,x_request_ts,x_followups,x_platform,x_reply_max_chars), and keeps the PR block last. This matters becausefm_pr_metadata_identity_parserejects any other line after the firstpr=, so registering a clone after a PR existed made the merge poll treat the record as invalid.test_register_clone_keeps_pr_block_lasttotests/fm-nm-watch.test.sh. It checks that:nm_clone=is the last line when there is no PR block.nm_clone=present exactly once andpr/pr_headas the last two lines.fm_pr_metadata_identity_parsestill accepts the record afterwards.Risk Assessment
✅ Low: A small, well-bounded fix that keeps nm_clone= ahead of the PR block as fm_pr_metadata_identity_parse requires. A behavioral test covers the with-PR and no-PR cases and repeated registration; the only issue found is an edge case with backslashes in clone paths.
Testing
I ran the fm-nm-watch behavior test on the fix, and the new regression case passes. Run on the base commit, the same case fails with 'the PR block is not last', which reproduces the bug. I also drove the real register-clone script on a task record with a stale nm_clone=, an unrelated line and a full PR block with all five x_* lines. The clone path was recorded exactly once, the PR block stayed last, and the merge-poll validator accepted the record. No UI surface is involved, so there are no screenshots. The test touches only temp directories and throwaway git worktrees, which I removed.
Evidence: Base-commit repro of the bug
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-nm-watch.sh:100- awk -v clone="$path" interprets backslash escape sequences in the value. A valid absolute clone path containing a backslash (e.g. /srv/a\tb) would be written to nm_clone= altered (a tab, not the literal path). The old printf '%s' recorded it verbatim. Pass the path via the environment (FM_NM_CLONE="$path" awk ... ENVIRON["FM_NM_CLONE"]) to keep it byte-exact. Rare in practice.✅ **Test** - passed
✅ No issues found.
bash tests/fm-nm-watch.test.shon the target commit (all four cases pass, including the newtest_register_clone_keeps_pr_block_last)The same test file run against a throwaway worktree of base commit bfc1e2b: fails with 'the PR block is not last'Ad-hoc run of realbin/fm-nm-watch.sh register-cloneon a record with a stale nm_clone=, an unrelated line, pr=, pr_head= and all five x_* lines, thenfm_pr_metadata_identity_parseon the result✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.