Repository navigation
fix: support GitLab work-item note verification - #7
Merged
Merged
Conversation
eyevanovich
added a commit
that referenced
this pull request
Jul 23, 2026
## 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 - Reuse exact authenticated non-system GitLab WorkItem notes without comparing their opaque `noteable_id` to the legacy issue ID, while preserving strict Issue and MergeRequest identity checks and malformed-ID rejection. - Make issue and merge-request close operations remove workflow labels, preserve unrelated metadata, and converge already-closed resources without repeating the close transition. - Expand mutation coverage for note deduplication, endpoint-scoped identity validation, field-only mismatch diagnostics, malformed note IDs, and idempotent close cleanup. ## 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. <details> <summary>Evidence: GitLab end-user flow evidence</summary> ```text 137:+ out='{"resource":"issue","note":{"id":501,"body":"Live work-item note.\nSecond line: \"quoted\" & UTF-8 café.\n","author":"mate","already":true}}' 172:+ out='{"resource":"issue","note":{"id":501,"body":"Live work-item note.\nSecond line: \"quoted\" & UTF-8 café.\n","author":"mate","already":true}}' 202:+ out='{"resource":"issue","note":{"id":551,"body":"Legacy issue note.\n","author":"mate","already":true}}' 210:+ jq -cn --argjson exact '{"id":651,"body":"Legacy MR note.\n","author":{"id":42,"username":"mate"},"system":false,"noteable_id":8005,"noteable_type":"MergeRequest","project_id":314,"noteable_iid":5}' $'[\n ($exact | .id=649 | .noteable_type="WorkItem" | .noteable_iid=null),\n ($exact | .id=650 | .noteable_iid=6),\n $exact\n ]' 227:+ out='{"resource":"mr","note":{"id":651,"body":"Legacy MR note.\n","author":"mate","already":true}}' 257:+ jq -cn --rawfile body /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/repo/malformed-existing-note.md $'\n [{id:0,body:$body,author:{id:42,username:"mate"},system:false,\n noteable_id:77146,noteable_type:"WorkItem",project_id:314,noteable_iid:null}]' 459:+ out='{"resource":"issue","note":{"id":501,"body":"Worker update.\n","author":"mate","already":true}}' 483:+ jq -e $'.issue.state == "closed" and .issue.labels == ["bug"]\n and .issue.assignees == ["mate"]' 484:++ count_log '"state_event":"close"' 485:++ local 'pattern="state_event":"close"' 486:++ grep -c -- '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 504:++ count_log '"state_event":"close"' 505:++ local 'pattern="state_event":"close"' 506:++ grep -c -- '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 525:++ jq -r .issue.state 595:+ jq -e $'.issue.state == "closed" and .issue.labels == ["bug"]\n and .issue.assignees == ["mate"]' 596:+ assert_no_grep '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 'issue close retry repeated an already-landed state transition' 597:+ grep -F -- '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 644:+ jq -e $'.mr.state == "closed" and .mr.labels == ["backend"]\n and .mr.assignees == []' 645:+ assert_no_grep '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 'merge-request close retry repeated an already-landed state transition' 646:+ grep -F -- '"state_event":"close"' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 757:++ count_log 'input={"add_labels":"docs","remove_labels":"bug"}' 758:++ local 'pattern=input={"add_labels":"docs","remove_labels":"bug"}' 759:++ grep -c -- 'input={"add_labels":"docs","remove_labels":"bug"}' /var/folders/j_/g4b3__rs5j95fq6xf9fb17sc0000gn/T//fm-forge-mutations-tests.fstRVI/glab.log 1297:+ out='{"resource":"mr","note":{"id":601,"body":"MR update.\n","author":"mate","already":true}}' 1323:+ jq -e '.mr.state == "closed" and .mr.labels == ["docs"]' 1341:++ jq -r .mr.state ``` </details> <details> <summary>Evidence: Targeted mutation-suite transcript</summary> ```text ok - issue claim sends explicit JSON media type and preserves array encoding ok - live work-item note shape verifies exact resource and suppresses duplicates ok - note list matching and read-back share strict endpoint-scoped identity ok - malformed created note IDs cannot pass read-back verification ok - malformed matching note IDs fail closed without duplicate posts ok - issue creation validates labels, optional claim, identity, and canonical read-back ok - issue claim, status, note, close, reopen, and release converge safely ok - close retries remove workflow labels without repeating landed transitions ok - already-correct issue claims, statuses, and label deltas are no-ops ok - issue release can return self-owned work to the ready queue without clobbering labels ok - issue mutations cannot steal or bypass exact ownership ok - missing, archived, and malformed label metadata blocks mutations ok - malformed targets, labels, usernames, and non-regular note files are rejected ok - issue API identity rejects foreign, mismatched, and malformed work-item URLs ok - untrusted projects and API failures never report a successful mutation ok - issue and note mutations require deterministic matching read-back ok - merge-request claim, status, labels, notes, lifecycle, and release converge safely ok - merge-request workflow labels require status and release commands ok - merge-request mutations preserve project, author, branch, head, and API guards ok - issue creation and comments surface API and verification failures ``` </details> ## Pipeline Updates from [git push no-mistakes](https://github.com/kunchenguid/no-mistakes) <details> <summary>✅ **intent** - passed</summary> ✅ No issues found. </details> <details> <summary>✅ **Rebase** - passed</summary> ✅ No issues found. </details> <details> <summary>⚠️ **Review** - 1 info</summary> - 🚨 `bin/fm-forge.sh:591` - The intent requires “never POST another duplicate” and preserving “malformed-ID rejection.” `find_matching_note` silently skips an otherwise exact authenticated non-system note whose `.id` is malformed; if no valid duplicate follows, `post_note` falls through to POST. Reject this case with an `id`-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 call `note_identity_mismatches()` directly. Remove this dead wrapper to simplify the identity helper surface. </details> <details> <summary>✅ **Test** - passed</summary> ✅ 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"` - <code>Pre-run baseline: `command -v tmux >/dev/null || { echo &kunchenguid#34;tmux is required for e2e tests&kunchenguid#34; >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo &kunchenguid#34;== $t ==&kunchenguid#34;; bash &kunchenguid#34;$t&kunchenguid#34; || rc=1; done; exit &kunchenguid#34;$rc&kunchenguid#34;`</code> - `bash tests/fm-forge-mutations.test.sh` - <code>`bash -x tests/fm-forge-mutations.test.sh` with filtered CLI-response and mutation evidence captured to `gitlab-user-flow-evidence.txt`</code> - <code>Verified the testing run left the git worktree clean with `git status --short`</code> </details> <details> <summary>✅ **Document** - passed</summary> ✅ No issues found. </details> <details> <summary>✅ **Lint** - passed</summary> ✅ No issues found. </details> <details> <summary>✅ **Push** - passed</summary> ✅ No issues found. </details> --------- Co-authored-by: Ivan Miles Piesh <[email protected]>
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
Fix the live GitLab note-verification regression blocking completion of KissCut issue 146 after the guarded GitLab workflow changes. Preserve idempotence so an existing note is reused without duplicates, and retain trusted-project, positive-resource-ID, authenticated-author, exact-body, non-system-note, regular-file, and noteable-resource guards. Use the current GitLab work-item-backed issue note response shape, audit the shared issue and merge-request note creation/list/read-back/pagination/body-encoding identity path together, and batch only directly implied note defects rather than broadening scope. Add deterministic live-shape fixture coverage and validate focused forge behavior, lint, and the portable suite. Do not mutate KissCut issue 146 from this fix task.
What Changed
Risk Assessment
✅ Low: Captain, the change is well-bounded and satisfies the authoritative note-verification intent; the only finding is a non-functional simplification opportunity.
Testing
The already-passing portable baseline was supplemented with focused GitLab forge mutation testing and an end-to-end CLI trace; work-item-shaped issue notes verify successfully, preserve exact encoded content, reuse the existing note without duplicates, and retain the shared issue/MR safety guards, with no live mutation of KissCut issue 146.
Evidence: Focused forge mutation test transcript
Evidence: End-to-end GitLab note CLI trace showing first creation, exact body preservation, reuse on retry, pagination, and a single POST
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-forge.sh:586- The existing-note selector duplicates the full trusted note-identity predicate fromnote_identity_valid(). Extract a shared jq predicate/filter so list-time idempotence matching and read-back verification cannot drift as guards evolve.✅ **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"Reviewedgit diff --unified=100 f68d7c9c455fdf15f4972efaef9f4dc242f93eec..4bab937f7fc8a820aa88e7af6000052fa5608fbeagainst the authoritative intent.Accepted the previously successful configured portable 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".Ranbash tests/fm-forge-mutations.test.shagainst the deterministic local GitLab fixture.RanPS4='+ ${LINENO}: ' bash -x tests/fm-forge-mutations.test.shto capture end-user CLI JSON and API-call evidence.Verifiedgit status --shortremained empty and no.fm-forge-body.*transient snapshots remained.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.