Repository navigation
fix(bin): converge GitLab notes and close state - #9
Merged
Merged
Conversation
added 3 commits
July 22, 2026 19:41
WorkItem note IDs are opaque and can differ from the legacy issue API ID. Match exact authenticated notes by their trusted issue endpoint fields so retries reuse existing notes instead of posting duplicates. Closing issues and merge requests now also clears workflow labels, including recovery from a state transition that landed before label cleanup.
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
Autofix the remaining live GitLab WorkItem completion bug after PR #7. Issue 146 is a trusted self-owned WorkItem whose exact authenticated completion note appears three times because WorkItem noteable_id is a separate opaque positive identity from the legacy Issues API .id. Through the trusted issue-notes endpoint, reuse any existing exact authenticated non-system WorkItem note without comparing its opaque noteable_id to the issue API ID and never POST another duplicate; preserve strict comparable identity checks for legacy Issue and MergeRequest notes, exact body and author matching, pagination, malformed-ID rejection, and field-name-only mismatch diagnostics. Also make issue-close converge both new and already-closed self-owned issues to closed with all execution/workflow labels removed while preserving unrelated labels and ownership, without repeating an already-landed state transition; enforce the directly equivalent MR close invariant. Keep all fixes and tests within WorkItem note identity/deduplication and issue/MR close-state convergence, and do not broaden the public API.
What Changed
noteable_idto the legacy issue ID, while preserving strict Issue and MergeRequest identity checks and malformed-ID rejection.Risk Assessment
✅ Low: Captain, the prior correctness findings are resolved and the only remaining issue is an unused private helper.
Testing
The previously completed full baseline passed, the focused GitLab mutation suite passed twice, and its captured CLI/API trace directly demonstrates WorkItem note reuse, strict legacy identity handling, malformed-ID rejection, and idempotent issue/MR close-state convergence; no UI surface was changed, so visual evidence was not applicable.
Evidence: GitLab end-user flow evidence
Evidence: Targeted mutation-suite transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-forge.sh:591- The intent requires “never POST another duplicate” and preserving “malformed-ID rejection.”find_matching_notesilently skips an otherwise exact authenticated non-system note whose.idis malformed; if no valid duplicate follows,post_notefalls through to POST. Reject this case with anid-only diagnostic instead of posting.bin/fm-forge.sh:1117- The close path now changes workflow labels, but the script header still states that workflow labels are changed only by claim, status, and release commands. Update that safety contract to include close cleanup.bin/fm-forge.sh:1117- Issue and MR close duplicate workflow-label removal, expected-label calculation, idempotence, and payload construction. Extract the shared close-state calculation so these directly equivalent invariants cannot drift.🔧 Fix: Fix note deduplication and close-state convergence
1 info still open:
bin/fm-forge.sh:575-note_identity_valid()is now unused; matching and required verification both callnote_identity_mismatches()directly. Remove this dead wrapper to simplify the identity helper surface.✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"Pre-run baseline:command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-forge-mutations.test.shbash -x tests/fm-forge-mutations.test.shwith filtered CLI-response and mutation evidence captured togitlab-user-flow-evidence.txtVerified the testing run left the git worktree clean withgit status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.