Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b37a163
fix(gitlab)!: post triage and prioritize results as new notes
tpouyer Nov 14, 2026
0361d25
fix(triage): answer review on the GitLab notes change
tpouyer Nov 15, 2026
87aae17
fix(triage): count a marked comment only when the triage account wrot…
tpouyer Nov 16, 2026
5101ed9
fix(triage): read GitHub comments with their authors from one listing
tpouyer Nov 16, 2026
fe731bf
fix(triage): fail closed when the account lookup fails
tpouyer Nov 16, 2026
cf269b5
fix(triage): match the exact triage App and read GitHub comments from…
tpouyer Nov 16, 2026
8fddc96
fix(github-forge): keep the REST field paths in the comment listing
tpouyer Nov 16, 2026
29a23a6
fix(triage): pick the newest analysis by creation time, not edit time
tpouyer Nov 16, 2026
0a27289
fix(triage): compare the GitHub App slug with FULLSEND_SLUG
tpouyer Nov 16, 2026
b22b9f5
fix(triage): order marked comments by creation time only
tpouyer Nov 16, 2026
a2003cf
fix(triage): date a comment by its last edit only when the triage App…
tpouyer Nov 16, 2026
4186ada
fix(triage): trust only App names the triage sandbox has, compare the…
tpouyer Nov 16, 2026
77c9466
fix(triage): a bot comment someone else last edited is a human comment
tpouyer Nov 16, 2026
3d6075f
fix(triage): leave never-edited comments trusted; say what GitLab edi…
tpouyer Nov 16, 2026
d97ea7d
fix(triage): spot a foreign edit by its recorded editor on every tracker
tpouyer Nov 16, 2026
572b075
fix(gitlab-forge): name the GraphQL project path <REPO>
tpouyer Nov 16, 2026
d09977e
fix(triage): match GitLab notes by their numeric id; page the editor …
tpouyer Nov 16, 2026
8eba4b4
fix(triage): judge a comment by its last editor; date GitLab notes th…
tpouyer Nov 16, 2026
863d3da
fix(triage): say how to compare a GitLab editor with the agent's account
tpouyer Nov 16, 2026
e58a21b
fix(triage): trust a custom App set; say when the identity lookup fails
tpouyer Nov 16, 2026
ce27860
docs(triage): link the issue that exports FULLSEND_APP_SET to triage
tpouyer Nov 16, 2026
f6c97fc
fix(triage): do not pass FULLSEND_APP_SET from the harness yet
tpouyer Nov 16, 2026
0f05e1c
fix(triage): pass FULLSEND_APP_SET through triage.env; trust the bare…
tpouyer Nov 16, 2026
e161f43
fix(triage): drop the bare App prefix from the trusted names
tpouyer Nov 16, 2026
b9fa025
fix(triage): read Previous run folds as history, not findings
tpouyer Nov 16, 2026
5d14be4
fix(triage): keep fold-only causes as unverified; name the job that l…
tpouyer Nov 16, 2026
ed2e20b
docs(triage): name the FULLSEND_APP_SET guard on the fourth trusted name
tpouyer Nov 17, 2026
354e445
docs(triage): a custom App set still matches through the harness slug
tpouyer Nov 17, 2026
f495ad9
test(triage): keep FULLSEND_APP_SET in the host file, not the harness
tpouyer Nov 17, 2026
c6e6548
fix(triage): label human hypotheses unverified; tighten the APP_SET g…
tpouyer Nov 17, 2026
81b8ef3
test(triage): check the APP_SET host file is wired and expanded
tpouyer Nov 17, 2026
16a5000
docs(triage): fullsend's triage job now exports FULLSEND_APP_SET
tpouyer Nov 17, 2026
f2a4496
Merge main into gitlab-doors-append
tpouyer Nov 17, 2026
654ead9
test(triage): the APP_SET guard comment matches fullsend#9575; name i…
tpouyer Nov 17, 2026
deb69c3
refactor(triage): narrow this change to posting GitLab results as new…
tpouyer Nov 17, 2026
192ca6d
fix(triage): read every GitLab triage note; say #9399 is still open
tpouyer Nov 17, 2026
c5b7b53
Merge remote-tracking branch 'origin/main' into gitlab-doors-append
tpouyer Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agents/triage.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ If every child is closed and every addressing PR/MR is merged, use `completed`.

### 2e. Review prior triage analysis

Check whether this issue has already been triaged. Look through the comments you fetched in Step 1 for a prior triage comment — it will contain `<!-- fullsend:triage-agent -->` or `<!-- fullsend:triage-in-progress -->` in its body, or be posted by a user whose login ends in `-triage[bot]`.
Check whether this issue has already been triaged. Look through the comments you fetched in Step 1 for a prior triage comment — it will contain `<!-- fullsend:triage-agent -->` or `<!-- fullsend:triage-in-progress -->` in its body, or be posted by a user whose login ends in `-triage[bot]`. On GitLab every triage run adds a new note, so an issue triaged more than once has several: fetch every page of notes (your forge skill lists 100 a page), treat the newest `triage-agent` note as the prior analysis, and treat each earlier one as part of it below.

If a prior triage comment exists, **accumulate — do not replace:**

Expand Down
2 changes: 1 addition & 1 deletion behaviour/features/prioritize.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Prioritize posts the RICE score on the issue
A write actor's "/fs-prioritize" comment on an issue dispatches
prioritize. The dummy agent emits RICE scores chosen so the
post-script's score, round2(R*I*C/E) = round2(2*3*0.5/2), is exactly
1.5. The post-script must post its sticky RICE comment on the issue.
1.5. The post-script must post a RICE comment on the issue.

Scenario: /fs-prioritize posts the RICE score comment
Given the enrolled test repository
Expand Down
8 changes: 4 additions & 4 deletions docs/prioritize.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Scores an issue using the RICE framework (Reach, Impact, Confidence, Effort) and produces scores with reasoning for project board ranking. Supports GitHub and GitLab forges. A Jira Cloud forge exists in the harness but is **dark**: it is not dispatched, does not change `/fs-prioritize` on GitHub or GitLab, and is used only when `FULLSEND_FORGE=jira`.

On GitHub, scores are written to Projects V2 custom fields and posted as a reasoning comment. On GitLab, scores are posted as a sticky issue comment. GitLab custom fields API integration is deferred — the Issues API silently ignores unknown keys, and the correct Custom Fields API requires Premium/Ultimate with runtime field ID resolution.
On GitHub, scores are written to Projects V2 custom fields and posted as a reasoning comment. On GitLab, scores are posted as an issue comment; each run adds a new comment rather than editing the earlier one. GitLab custom fields API integration is deferred — the Issues API silently ignores unknown keys, and the correct Custom Fields API requires Premium/Ultimate with runtime field ID resolution.

On Jira, when that forge is explicitly selected, five custom fields on the `Prioritization` tab are written, resolved by exact name: `Reach`, `Impact`, `Effort`, and `RICE Score` (number/float) and `Confidence` (a shared select list: `50% (Low)`, `75% (Medium)`, `100% (High)`). Jira admins keep Confidence as that select; it cannot become a number without breaking other projects. The agent Confidence float is used as-is in `RICE Score = (Reach × Impact × Confidence) / Effort`. The same float is mapped onto those three options only for the Confidence field (`< 0.4` → Low, `< 0.7` → Medium, otherwise High). The sticky comment still prints the unmapped floats, the formula, and reasoning. Rank, Priority, and other Jira fields are never written. GitHub and GitLab `/fs-prioritize` are unchanged. The post-script fails closed if any of the five fields is missing, duplicated, not a custom field, or the wrong schema type.

Expand Down Expand Up @@ -43,10 +43,10 @@ skill data.
The prioritize agent does not apply or consume control labels. It reads the
issue content and produces a score. On GitHub, the project board is updated
directly via Projects V2 custom fields. On GitLab, scores are posted as
a sticky comment on the issue. On Jira (opt-in forge only), the five
a new comment on the issue each run. On Jira (opt-in forge only), the five
RICE custom fields are updated (Confidence mapped onto the shared select)
and the sticky comment carries the unmapped floats; Rank and Priority
are not written.
and the sticky comment carries the unmapped floats; Rank and Priority are
not written.

## Configuration

Expand Down
25 changes: 20 additions & 5 deletions docs/triage.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,19 @@ variable, which the harness sets based on the detected CI platform (`github`,
forward-compatible override when set, but the harness itself only ever sets
`FULLSEND_FORGE`.

Re-running triage posts the result differently per tracker:

- **GitLab:** every run, a retry included, posts the `sufficient` or
`in-progress` result as a new note and never edits an earlier one.
- **GitHub and Jira:** the `sufficient` and `in-progress` results edit the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: fullsend#9399 is described as open, but it merged and shipped in v0.58.0

This PR describes fullsend-ai/fullsend#9399 as an open PR in several places:

  • docs/triage.md: the Multi-forge note here (lines 293-295) and the Retries bullet (around lines 362-368)
  • the comments in scripts/lib/gitlab-triage-ops.lib.sh and scripts/lib/gitlab-prioritize-ops.lib.sh
  • the bundled copies in post-/pre-triage.sh and post-/pre-prioritize.sh

#9399 merged on 2026-11-30 as 47d884c8, and the v0.58.0 release contains it. The GitHub and Jira doors in this repo post through fullsend post-comment and fullsend issues post-comment. So with fullsend v0.58.0 or later, three statements are wrong:

  • "GitHub and Jira: the sufficient and in-progress results edit the earlier marked comment"
  • "on Jira, comments are idempotent ... every run edits the earlier comment with that marker"
  • "a re-run of the same workflow or pipeline edits its earlier comment"

The PR body is also out of date: its Order section ("Until #9399 lands, GitHub and Jira keep editing in place") and its Not changed line ("the open fullsend-ai/fullsend#9399"). The earlier replies on the qodo thread for this file and on the #9399 wording relied on #9399 being unmerged, which is no longer true.

Suggestion: Reword the text for the released CLI: on fullsend v0.58.0 and later, every tracker posts a new comment on each run, and older pinned CLIs still edit in place on GitHub and Jira. Remove "open PR" from docs/triage.md, the two GitLab ops libs and the bundles, then run make bundle. Rewrite the Retries bullet so it no longer says Jira comments are idempotent or that a same-run retry edits its earlier comment. Update the PR body's Order and Not changed sections.

Verified: read code at head; gh pr view fullsend#9399 (MERGED 2026-11-30, 47d884c8); compare 47d884c8...v0.58.0 = ahead at c5b7b53; raised by: Claude, DeepSeek

earlier marked comment. The open PR fullsend-ai/fullsend#9399 makes them
post a new comment each run as well.

Because triage also runs when an issue is edited, an issue that is edited
often collects one triage note per run on GitLab. fullsend-ai/fullsend#9334
accepts that cost; fullsend-ai/fullsend#9335 is the follow-up that brings
each run down to one compact comment.

### Jira setup

Jira triage requires the following env vars, mirroring the shape of the
Expand Down Expand Up @@ -346,11 +359,13 @@ The run stops before any write if `FULLSEND_WORK_ITEM_KEY` does not match
that URL, or if an explicit `FULLSEND_TRACKER` or `ISSUE_URL` points
somewhere else.

- **Retries:** comments are idempotent. Sticky comments (`sufficient`,
`in-progress`) use fixed markers. Other comments use a marker scoped to the
CI run (`GITHUB_RUN_ID` or `CI_PIPELINE_ID`). A re-run of the same workflow
or pipeline edits its earlier comment, while a new triage run still posts a
new one.
- **Retries:** on Jira, comments are idempotent. Sticky comments
(`sufficient`, `in-progress`) each use their own fixed marker, so every
run edits the earlier comment with that marker. Other comments use a
marker scoped to the CI run (`GITHUB_RUN_ID` or `CI_PIPELINE_ID`): a
re-run of the same workflow or pipeline edits its earlier comment, while a
new triage run posts a new one. The open PR fullsend-ai/fullsend#9399
changes this (see [Multi-forge support](#multi-forge-support)).
- **Write failures:** a failed Jira write fails the step. This covers label
adds and removals, component updates, comments and transitions.
- **Updates that cannot be applied:** these are listed under **Not applied in
Expand Down
77 changes: 8 additions & 69 deletions scripts/lib/gitlab-prioritize-ops.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ _gitlab_api() {
"$@"
}

_GITLAB_BOT_USERNAME=""

_gitlab_bot_username() {
if [[ -z "${_GITLAB_BOT_USERNAME}" ]]; then
_GITLAB_BOT_USERNAME=$(_gitlab_api GET "/user" 2>/dev/null | jq -r '.username // empty')
if [[ -z "${_GITLAB_BOT_USERNAME}" ]]; then
echo "ERROR: failed to determine GitLab token owner via GET /user" >&2
return 1
fi
fi
echo "${_GITLAB_BOT_USERNAME}"
}

# --- URL handling ---

forge_validate_issue_url() {
Expand Down Expand Up @@ -87,64 +74,16 @@ forge_update_project_scores() {

# --- Comments ---

# Posts a new note whose first line is <marker>. Each run appends a new
# note at the end of the thread; earlier marked notes are never edited
# (fullsend-ai/fullsend#9334). The open PR fullsend-ai/fullsend#9399 makes
# the GitHub door append the same way.
forge_post_sticky_comment() {
: "${GITLAB_TOKEN:?GITLAB_TOKEN must be set}"
local body="$1"
local marker="$2"
local marked_body="${marker}
${body}"

local bot_user
bot_user=$(_gitlab_bot_username) || {
echo "::warning::Could not resolve bot username; falling back to non-sticky comment" >&2
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marked_body}" > /dev/null \
|| echo "::warning::Failed to post fallback comment" >&2
return 0
}

local notes="[]"
local page=1 max_pages=50
while [[ "${page}" -le "${max_pages}" ]]; do
local batch
batch=$(_gitlab_api GET "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes?per_page=100&sort=asc&page=${page}" 2>/dev/null) || break
local count
count=$(echo "${batch}" | jq 'length') || break
[[ "${count}" -eq 0 ]] && break
notes=$(echo "${notes}" "${batch}" | jq -s 'add')
page=$((page + 1))
done

local match
match=$(echo "${notes}" | jq --arg marker "${marker}" --arg user "${bot_user}" \
'[.[] | select(.author.username == $user and (.body | startswith($marker)))][0] // empty')

local note_id
note_id=$(echo "${match}" | jq -r '.id // empty')

if [[ -n "${note_id}" ]]; then
local old_body
old_body=$(echo "${match}" | jq -r '.body // empty')
local stripped_old
local escaped_marker
escaped_marker=$(printf '%s' "${marker}" | sed 's/[].[*^$()+?{|\\]/\\&/g; s|/|\\/|g')
stripped_old=$(echo "${old_body}" | sed "1{/^${escaped_marker}$/d;}")
if [[ -n "${stripped_old}" ]]; then
local history
history=$(printf '\n\n<details>\n<summary>Previous run</summary>\n\n%s\n\n</details>' "${stripped_old}")
local max_len=60000
if [[ ${#history} -gt ${max_len} ]]; then
history="${history:0:${max_len}}
...(truncated)"
fi
marked_body="${marked_body}${history}"
fi
_gitlab_api PUT "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes/${note_id}" \
--data-urlencode "body=${marked_body}" > /dev/null \
|| { echo "::warning::Failed to update sticky comment (note ${note_id})" >&2; return 1; }
else
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marked_body}" > /dev/null \
|| { echo "::warning::Failed to post comment" >&2; return 1; }
fi
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marker}
${body}" > /dev/null \
|| { echo "::warning::Failed to post comment" >&2; return 1; }
}
78 changes: 11 additions & 67 deletions scripts/lib/gitlab-triage-ops.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,6 @@ forge_create_label() {
tracker_create_label "$@"
}

# --- Bot identity (for sticky-comment author filtering) ---

_GITLAB_BOT_USERNAME=""

_gitlab_bot_username() {
if [[ -z "${_GITLAB_BOT_USERNAME}" ]]; then
_GITLAB_BOT_USERNAME=$(_gitlab_api GET "/user" 2>/dev/null | jq -r '.username // empty')
if [[ -z "${_GITLAB_BOT_USERNAME}" ]]; then
echo "ERROR: failed to determine GitLab token owner via GET /user" >&2
return 1
fi
fi
echo "${_GITLAB_BOT_USERNAME}"
}

# --- Comments (notes in GitLab) ---

tracker_post_comment() {
Expand All @@ -229,61 +214,20 @@ tracker_post_comment() {
--data-urlencode "body=${body}" > /dev/null
}

# Posts a new note whose first line is <marker>. Each run appends a new
# note at the end of the thread; earlier marked notes are never edited
# (fullsend-ai/fullsend#9334). The open PR fullsend-ai/fullsend#9399 makes
# the GitHub door append the same way. The Jira door (jira-triage-ops.lib.sh,
# `fullsend issues post-comment` with a fixed marker) would change with
# that PR's CLI, not here.
tracker_post_sticky_comment() {
: "${GITLAB_TOKEN:?GITLAB_TOKEN must be set}"
local body="$1"
local marker="$2"
local marked_body="${marker}
${body}"

local bot_user
bot_user=$(_gitlab_bot_username) || {
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marked_body}" > /dev/null
return
}

local notes="[]"
local page=1 max_pages=50
while [[ "${page}" -le "${max_pages}" ]]; do
local batch
batch=$(_gitlab_api GET "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes?per_page=100&sort=asc&page=${page}" 2>/dev/null) || break
local count
count=$(echo "${batch}" | jq 'length') || break
[[ "${count}" -eq 0 ]] && break
notes=$(echo "${notes}" "${batch}" | jq -s 'add')
page=$((page + 1))
done

local match
match=$(echo "${notes}" | jq --arg marker "${marker}" --arg user "${bot_user}" \
'[.[] | select(.author.username == $user and (.body | startswith($marker)))][0] // empty')

local note_id
note_id=$(echo "${match}" | jq -r '.id // empty')

if [[ -n "${note_id}" ]]; then
local old_body
old_body=$(echo "${match}" | jq -r '.body // empty')
local stripped_old
local escaped_marker
escaped_marker=$(printf '%s' "${marker}" | sed 's/[].[*^$()+?{|\\]/\\&/g; s|/|\\/|g')
stripped_old=$(echo "${old_body}" | sed "1{/^${escaped_marker}$/d;}")
if [[ -n "${stripped_old}" ]]; then
local history
history=$(printf '\n\n<details>\n<summary>Previous run</summary>\n\n%s\n\n</details>' "${stripped_old}")
local max_len=60000
if [[ ${#history} -gt ${max_len} ]]; then
history="${history:0:${max_len}}
...(truncated)"
fi
marked_body="${marked_body}${history}"
fi
_gitlab_api PUT "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes/${note_id}" \
--data-urlencode "body=${marked_body}" > /dev/null
else
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marked_body}" > /dev/null
fi
_gitlab_api POST "/projects/${REPO_ENCODED}/issues/${ISSUE_NUMBER}/notes" \
--data-urlencode "body=${marker}
${body}" > /dev/null \
|| { echo "::warning::Failed to post comment" >&2; return 1; }
}

# --- Issues ---
Expand Down
81 changes: 44 additions & 37 deletions scripts/post-prioritize-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ unset ORG
unset PROJECT_NUMBER

CURL_LOG="${TEST_TMPDIR}/curl-calls.log"
MOCK_NOTES_FILE="${TEST_TMPDIR}/mock-notes-override.json"
printf '#!/usr/bin/env bash\necho "curl $*" >> %s\nMOCK_NOTES_FILE=%s\n' "${CURL_LOG}" "${MOCK_NOTES_FILE}" > "${MOCK_BIN}/curl"
MOCK_CURL_NOTE_FAIL="${TEST_TMPDIR}/mock-curl-note-fail"
printf '#!/usr/bin/env bash\necho "curl $*" >> %s\nMOCK_CURL_NOTE_FAIL=%s\n' "${CURL_LOG}" "${MOCK_CURL_NOTE_FAIL}" > "${MOCK_BIN}/curl"
cat >> "${MOCK_BIN}/curl" <<'CURLMOCK'

# Parse the URL from args.
Expand Down Expand Up @@ -769,32 +769,27 @@ for arg in "$@"; do
esac
done

# Return bot user identity.
# Simulate a failed note POST when flagged.
if [[ "${URL}" =~ /notes$ ]] && [[ "${METHOD}" == "POST" ]] && [[ -f "${MOCK_CURL_NOTE_FAIL}" ]] && [[ -n "${HAS_FAIL}" ]]; then
echo "curl: (22) The requested URL returned error: 500" >&2
exit 22
fi

# Bot identity and a bot-authored prioritize note. Posting never reads
# these; they let the append test catch code that edits in place.
if [[ "${URL}" =~ /user$ ]] && [[ "${METHOD}" == "GET" ]]; then
echo '{"username":"fullsend-bot","id":12345,"name":"Fullsend Bot"}'
exit 0
fi

# Return notes list — check for test-specific override file (page 1 only).
if [[ "${URL}" =~ /notes\? ]] && [[ "${METHOD}" == "GET" ]]; then
if [[ "${URL}" =~ page=1 ]] || [[ ! "${URL}" =~ page=[0-9] ]]; then
if [[ -f "${MOCK_NOTES_FILE}" ]]; then
cat "${MOCK_NOTES_FILE}"
else
echo '[]'
fi
if [[ "${URL}" =~ page=1(&|$) ]] || [[ ! "${URL}" =~ page=[0-9] ]]; then
echo '[{"id":200,"body":"<!-- fullsend:prioritize-agent -->\nOld RICE scores","author":{"username":"fullsend-bot"}}]'
else
echo '[]'
fi
exit 0
fi

# PUT to notes — sticky comment update.
if [[ "${URL}" =~ /notes/[0-9]+$ ]] && [[ "${METHOD}" == "PUT" ]]; then
echo '{"id":1}'
exit 0
fi

# POST to notes — comment posting.
if [[ "${URL}" =~ /notes$ ]] && [[ "${METHOD}" == "POST" ]]; then
echo '{"id":1}'
Expand Down Expand Up @@ -963,29 +958,41 @@ export ISSUE_URL="https://evil.example/group/project/-/issues/1"
run_gitlab_test "gitlab-rejects-non-allowlisted-host" "true"
export ISSUE_URL="${SAVED_ISSUE_URL}"

# --- GitLab sticky-comment author filtering ---
# --- GitLab marked comments append (fullsend-ai/fullsend#9334) ---

# Test: the mock lists a bot-authored prioritize note, so code that edited
# it in place would PUT it. Each run must instead post one new note, marker
# first and the result below it, and never list or edit (PUT) notes.
run_gitlab_test_curl_pattern "gitlab-rerun-posts-new-note" \
"--request POST https://gitlab.com/api/v4/projects/test-group%2Ftest-project/issues/42/notes --data-urlencode body=<!-- fullsend:prioritize-agent -->"
if grep -qE -- "--request PUT [^ ]*/notes/" "${CURL_LOG}"; then
echo "FAIL: gitlab-rerun-posts-new-note — an earlier note was edited (PUT)"
FAILURES=$((FAILURES + 1))
fi
if grep -qF -- "/notes?" "${CURL_LOG}" || grep -qF -- "Previous run" "${CURL_LOG}"; then
echo "FAIL: gitlab-rerun-posts-new-note — notes were listed or history was folded in"
FAILURES=$((FAILURES + 1))
fi
POSTS=$(grep -cE -- "--request POST [^ ]*/issues/42/notes( |$)" "${CURL_LOG}" || true)
if [[ "${POSTS}" -ne 1 ]]; then
echo "FAIL: gitlab-rerun-posts-new-note — expected exactly one note POST, got ${POSTS}"
FAILURES=$((FAILURES + 1))
fi
# The same POST carries the result body, not just the marker.
if ! awk '/^curl /{p = index($0, "--request POST ") && index($0, "/notes --data-urlencode body=<!-- fullsend:")} p' "${CURL_LOG}" \
| grep -qF -- "RICE Priority Score"; then
echo "FAIL: gitlab-rerun-posts-new-note — the posted note has no result body"
FAILURES=$((FAILURES + 1))
fi

# Test: sticky comment ignores notes from other users (spoofing protection).
printf '%s' '[{"id":100,"body":"<!-- fullsend:prioritize-agent -->\nSpoofed content","author":{"username":"attacker"}}]' > "${MOCK_NOTES_FILE}"
run_gitlab_test_curl_pattern "gitlab-sticky-comment-ignores-spoofed-notes" \
"--request POST"
if grep -qF "notes/100" "${CURL_LOG}"; then
echo "FAIL: gitlab-sticky-comment-ignores-spoofed-notes — attacker note 100 was updated (PUT)"
# Test: a failed note POST warns and fails the step.
touch "${MOCK_CURL_NOTE_FAIL}"
run_gitlab_test "gitlab-post-failure-fails" "true"
if ! grep -qF -- "::warning::Failed to post comment" "${TEST_TMPDIR}/stdout-gitlab-post-failure-fails.log"; then
echo "FAIL: gitlab-post-failure-fails — no ::warning:: for the failed POST"
FAILURES=$((FAILURES + 1))
fi
rm -f "${MOCK_NOTES_FILE}"

# Test: sticky comment updates own note when bot-authored note exists.
printf '%s' '[{"id":200,"body":"<!-- fullsend:prioritize-agent -->\nOld RICE scores","author":{"username":"fullsend-bot"}}]' > "${MOCK_NOTES_FILE}"
run_gitlab_test_curl_pattern "gitlab-sticky-comment-updates-own-note" \
"notes/200"
rm -f "${MOCK_NOTES_FILE}"

# Test: sticky comment preserves history in <details> block.
printf '%s' '[{"id":300,"body":"<!-- fullsend:prioritize-agent -->\nPrevious RICE summary here","author":{"username":"fullsend-bot"}}]' > "${MOCK_NOTES_FILE}"
run_gitlab_test_curl_pattern "gitlab-sticky-comment-preserves-history" \
"Previous run"
rm -f "${MOCK_NOTES_FILE}"
rm -f "${MOCK_CURL_NOTE_FAIL}"

# --- GitLab subgroup URL parsing ---

Expand Down
Loading
Loading