Skip to content

fix(triage): delegate Jira close transitions to fullsend CLI - #1998

Open
jefferyb wants to merge 16 commits into
fullsend-ai:mainfrom
jefferyb:fix/triage-jira-completed-transition
Open

jefferyb wants to merge 16 commits into
fullsend-ai:mainfrom
jefferyb:fix/triage-jira-completed-transition

Conversation

@jefferyb

@jefferyb jefferyb commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When the triage agent marks an issue with action: completed, post-triage.sh previously reused JIRA_SPLIT_TRANSITION (defaulting to "Obsolete" in harness/triage.yaml) to transition the issue in Jira Cloud via direct REST calls.

In standard Jira Cloud and Team-Managed software projects, "Obsolete" is not part of the active workflow. When the transition name is missing from the issue's available transitions, tracker_close_issue failed and post-triage.sh terminated with exit status 1 under set -e.

This PR:

  1. Decouples action: split from action: completed in scripts/post-triage.src.sh, mapping split to GitHub reason "completed" in scripts/lib/github-triage-ops.lib.sh while allowing an optional JIRA_COMPLETED_TRANSITION override in Jira (falling back to JIRA_SPLIT_TRANSITION with a notice when unset so existing overlays and custom workflows are preserved without changing harness/triage.yaml defaults).
  2. Delegates Jira close transitions in scripts/lib/jira-triage-ops.lib.sh to fullsend issues transition --tracker jira (available since Fullsend v0.56.1 / feat(issues): add tracker-neutral issue transitions fullsend#9437) so agents and core fullsend share one transition and resolution policy:
    • Performs an exact target-status idempotency pre-flight check (skips only when the issue is already in a done-category status matching the configured transition name or the .to.name of that transition when uniquely offered).
    • Executes offered configured transitions via fullsend issues transition --tracker jira --transition <name> (preserving ambiguity errors and upstream resolution-by-ID rules).
    • When the configured transition is unavailable for completed or split, emits a ::warning:: annotation and falls back to fullsend issues transition --tracker jira --state closed (which skips issues already in a done-category status, applies the single available done-category transition, fails loudly on ambiguity, and fills a required resolution by ID only when Jira offers a single allowed value with no default).
    • Fails closed on missing duplicate/not planned transitions and on malformed/unexpected /transitions responses without falling back to --state closed.
  3. Updates docs/triage.md (including the Fullsend v0.56.1 requirement) and LOCAL.md, adds comprehensive unit tests in scripts/post-triage-test.sh, and rebuilds compiled script bundles.

Related: fullsend-ai/fullsend#6704, fullsend-ai/fullsend#9437

Changes

  • scripts/post-triage.src.sh: Updated action: split to pass "split" instead of "completed" to tracker_close_issue.
  • scripts/lib/github-triage-ops.lib.sh: Mapped close reason "split" to GitHub state reason "completed".
  • scripts/lib/jira-triage-ops.lib.sh:
    • Added optional JIRA_COMPLETED_TRANSITION override (no default added to harness/triage.yaml; falls back to JIRA_SPLIT_TRANSITION when unset).
    • Added _jira_transition delegating to fullsend issues transition --tracker jira --fullsend-dir "${FULLSEND_DIR}" --project "${REPO}" --number "${JIRA_ISSUE_NUM}" via jira_auth_fullsend.
    • Added exact target-status idempotency (current_status_name matching configured transition name or uniquely offered .to.name in a done-category status) and strict .transitions array validation.
    • Delegated offered transitions to --transition <name> and missing completed/split transitions to --state closed with a sanitized ::warning::.
  • docs/triage.md & LOCAL.md: Documented JIRA_COMPLETED_TRANSITION, the Fullsend v0.56.1 (fullsend issues transition) requirement, idempotency, --state closed fallback behavior, and harness runner override instructions.
  • scripts/post-triage-test.sh: Updated Jira close tests to verify fullsend issues transition invocations (--transition and --state closed), credentials passed via env, exact-status and .to.name idempotency, ambiguous matches, split on "Won't Fix" when the split transition is missing, fail-closed error handling, and failure propagation without fallback.
  • Rebuilt bundles: scripts/post-triage.sh, scripts/pre-code-jira.sh, scripts/pre-triage.sh.

Testing

  • make -B script-build && make check-bundle pass cleanly (relative lib/... markers verified; zero /private/tmp paths).
  • shellcheck -S warning scripts/lib/jira-triage-ops.lib.sh scripts/lib/github-triage-ops.lib.sh scripts/post-triage.src.sh scripts/post-triage.sh scripts/pre-triage.sh scripts/pre-code-jira.sh scripts/post-triage-test.sh passes cleanly.
  • uv run --no-project --with jsonschema env SCRIPT_TEST_TARGET=source bash scripts/post-triage-test.sh and SCRIPT_TEST_TARGET=bundled pass all tests.
  • pre-triage-test.sh and pre-code-jira-test.sh pass in both source and bundled modes.
  • uvx --from gitlint-core gitlint --config .gitlint passes on the commit message.

…ns dynamically

When the triage agent marks an issue with action: completed, post-triage.sh
currently reuses JIRA_SPLIT_TRANSITION (defaulting to "Obsolete" per ADR 0080/0081)
to transition the issue in Jira Cloud. In workflows where "Obsolete" is not
present, tracker_close_issue fails and post-triage.sh exits with status 1
under set -e.

- Add JIRA_COMPLETED_TRANSITION (defaulting to "Closed") in harness/triage.yaml.
- Decouple action: split from action: completed in scripts/post-triage.src.sh,
  mapping split to GitHub reason "completed" in github-triage-ops.lib.sh.
- Add dynamic transition resolution and idempotency check in jira-triage-ops.lib.sh.
- Rebuild script bundles via make script-build.
- Document JIRA_COMPLETED_TRANSITION in docs/triage.md and LOCAL.md.
- Add unit tests for completed transition, fallback, and idempotency in post-triage-test.sh.

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
@jefferyb
jefferyb requested a review from a team as a code owner November 13, 2026 15:37
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Decouple Jira completed and split transitions with safe fallback

🐞 Bug fix 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Give completed and split actions separate Jira transitions while preserving GitHub’s completed
 close reason.
• Resolve unavailable Jira transitions through safe Done-category fallbacks and skip issues already
 Done.
• Document the new setting, cover transition behavior in tests, and rebuild script bundles.
Diagram

graph TD
  A["Triage close actions"] --> B["Jira adapter"] --> C{"Already Done?"}
  C -->|No| D{"Configured available?"} -->|No| E["Safe Done fallback"] --> F["Jira transitions"]
  C -->|Yes| H["Skip transition"]
  D -->|Yes| F
  A --> G["GitHub close"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Require exact configured transitions
  • ➕ Never selects a transition other than the configured one.
  • ➖ Retains the failure when that transition is absent from an issue's workflow.
2. Choose any Done-category transition
  • ➕ Requires less per-workflow configuration.
  • ➖ Could select a rejection transition and lose the distinction between completed and split.

Recommendation: Keep separate configured names with an exact-match-first, restricted fallback. This preserves workflow intent while handling common Jira transition differences; the Done check also makes repeat closes safe.

Files changed (10) +190 / -13

Bug fix (6) +147 / -6
github-triage-ops.lib.shPreserve GitHub’s completed reason for splits +3/-0

Preserve GitHub’s completed reason for splits

• Translates the new split close reason to completed before calling GitHub.

scripts/lib/github-triage-ops.lib.sh

jira-triage-ops.lib.shResolve Jira close transitions by action and workflow +34/-1

Resolve Jira close transitions by action and workflow

• Maps completed and split to distinct settings, skips issues already in the Done category, and falls back to a non-rejection Done-category transition when the configured name is absent.

scripts/lib/jira-triage-ops.lib.sh

post-triage.shRebuild the executable post-triage bundle +38/-2

Rebuild the executable post-triage bundle

• Incorporates the split close reason and updated GitHub and Jira tracker adapters into the generated script.

scripts/post-triage.sh

post-triage.src.shPass split as its own close reason +1/-1

Pass split as its own close reason

• Dispatches split to tracker_close_issue as split rather than completed, allowing tracker-specific handling.

scripts/post-triage.src.sh

pre-code-jira.shRebuild the pre-code Jira bundle +34/-1

Rebuild the pre-code Jira bundle

• Carries the shared Jira close-action mapping, Done check, and fallback resolution into the generated script.

scripts/pre-code-jira.sh

pre-triage.shRebuild the pre-triage bundle +37/-1

Rebuild the pre-triage bundle

• Carries the updated GitHub split mapping and Jira close-transition resolution into the generated script.

scripts/pre-triage.sh

Tests (1) +34 / -5
post-triage-test.shCover Jira completed, fallback, and repeat-close behavior +34/-5

Cover Jira completed, fallback, and repeat-close behavior

• Extends Jira mocks with status and destination categories. Tests the completed transition, fallback selection, already-Done skip, and distinct split transition.

scripts/post-triage-test.sh

Documentation (2) +8 / -2
LOCAL.mdShow the completed-transition environment setting +1/-0

Show the completed-transition environment setting

• Adds JIRA_COMPLETED_TRANSITION to the local Jira configuration example.

LOCAL.md

triage.mdDocument distinct Jira close transitions and fallback +7/-2

Document distinct Jira close transitions and fallback

• Assigns completed and split to separate settings and explains the Done-category fallback when a configured transition is unavailable.

docs/triage.md

Other (1) +1 / -0
triage.yamlDefault completed Jira transitions to Closed +1/-0

Default completed Jira transitions to Closed

• Adds JIRA_COMPLETED_TRANSITION with a Closed default without changing the split transition default.

harness/triage.yaml

@qodo-code-review

qodo-code-review Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Local Jira runs ignore the new export ✓ Resolved

Resolving commit: e459281

Resolution reason
LOCAL.md no longer exports a conflicting JIRA_COMPLETED_TRANSITION="Done"; it now states the harness
default ("Closed") and explains how to override it in a harness overlay or by exporting when
invoking post-triage.sh directly, keeping the documentation consistent with what the runner passes.
Description
LOCAL.md tells operators to export JIRA_COMPLETED_TRANSITION="Done", but the Jira harness sets
its runner environment value to the literal "Closed". A local run using that harness therefore
supplies Closed to the post-script, so a workflow exposing both transitions will use Closed
despite the operator's exported choice.

2. Header misleads on Jira transition setup ✓ Resolved

Resolving commit: 1ac67d3

Resolution reason
The header in scripts/lib/jira-triage-ops.lib.sh was rewritten to add a JIRA_COMPLETED_TRANSITION
entry (default "Closed", falling back to JIRA_SPLIT_TRANSITION) and to document
JIRA_SPLIT_TRANSITION only for the split action. The same corrected header was propagated to the
rebuilt post-triage.sh, pre-code-jira.sh and pre-triage.sh bundles. The suggested fix's "make
script-build" step is not shown, but the bundles were updated directly with identical text. The fix
is in the header, which is what the finding flagged.
Description
The env-var header in scripts/lib/jira-triage-ops.lib.sh says JIRA_SPLIT_TRANSITION covers both
split and completed and omits JIRA_COMPLETED_TRANSITION, even though the action mapping now
uses the latter for completed. Operators configuring Jira from that header may leave
JIRA_COMPLETED_TRANSITION unset, causing completed to fail with an unset-variable error; the
same stale guidance also appears in the rebuilt scripts/post-triage.sh, scripts/pre-code-jira.sh
and scripts/pre-triage.sh bundles.

3. Completed issues can be closed as rejected ✓ Resolved

Resolving commit: 1ac67d3

Resolution reason
The fallback jq filter now explicitly excludes the configured JIRA_DUPLICATE_TRANSITION and
JIRA_NOT_PLANNED_TRANSITION names via --arg, extends the denylist with not.?planned|invalid|cannot
reproduce|abandon, and removes the $done_transitions[0].id last resort so only names matching
^(done|closed|resolved|complete(d)?)$ are accepted. The same change is applied in
jira-triage-ops.lib.sh, post-triage.sh, pre-code-jira.sh, and pre-triage.sh, and the idempotency
check was also made rejection-aware. Tests were added where Not Planned/Duplicate-only transitions
are refused.
Description
tracker_close_issue falls back to the first Done-category transition whose name escapes a short
rejection denylist, including Not Planned, Invalid, Cannot Reproduce, and Abandoned. When
the configured close transition is unavailable and no transition is named Done, Closed, or Resolved,
a completed or split action can select Not Planned, which this repository configures
separately for the not-planned action.

View medium (2)
4. Done issues retain the wrong resolution ✓ Resolved

Resolving commit: 1ac67d3

Resolution reason
The idempotency skip for a Done-category issue now only applies when the current status name is not
a rejection status for completed/split actions, so a completed action on a Won't Do/Duplicate issue
proceeds to transition instead of reporting success. A regression test covering this case was added.
Description
tracker_close_issue returns success for every close reason whenever the current Jira status
category is done, without checking whether that status represents the requested outcome. If triage
selects completed for an issue already marked Duplicate or Won't Do, the function skips the
completion transition and reports that the action succeeded.

5. Existing Jira setups fail on completed action ✓ Resolved

Resolving commit: 1ac67d3

Resolution reason
The fallback is inserted before the unset-variable check in tracker_close_issue: when reason is
"completed" and JIRA_COMPLETED_TRANSITION is empty but JIRA_SPLIT_TRANSITION is set,
transition_var/transition_name are switched to JIRA_SPLIT_TRANSITION with a NOTICE logged. This is
exactly the suggested fix (fall back to JIRA_SPLIT_TRANSITION with a notice). The same change is
applied across the lib and all bundled copies (post-triage.sh, pre-code-jira.sh, pre-triage.sh), and
docs/triage.md is updated to describe the fallback. Done-category fallback also remains for when
neither is set.
Description
completed now reads JIRA_COMPLETED_TRANSITION, and the unset-variable check runs before the new
fallback, so setups that only define the original three variables hit `ERROR:
JIRA_COMPLETED_TRANSITION is not set and post-triage.sh exits under set -e`. Before this PR, the
same setups closed completed issues through JIRA_SPLIT_TRANSITION, so any environment configured
from the earlier LOCAL.md or its own runner env now breaks.

Grey Divider

Context sources
✅ Compliance rules (platform): 55 rules
✅ Skills: 4 invoked
  code-review
  code-implementation
  pr-review
  docs-review
✅ Cross-repo context — repo relationships
  Explored: repo: fullsend-ai/fullsend (sha: dda46236) — View relationship
  Explored: repo: fullsend-ai/pi-anthropic-vertex (sha: d2ecd039) — View relationship
  Explored: repo: fullsend-ai/pi-xai-vertex (sha: a86139bf) — View relationship
  Explored: repo: fullsend-ai/react-shopping-cart (sha: 5e9aa80b) — View relationship
  Explored: repo: fullsend-ai/.fullsend (sha: e6bfe5b1) — View relationship
  Explored: repo: fullsend-ai/devlake (sha: ba0670f2) — View relationship
Review mode: Auto: 🧠 Deep: Multiple Jira workflow paths and duplicated shell logic create subtle independent defect risks.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread scripts/lib/jira-triage-ops.lib.sh Resolved
Comment thread scripts/lib/jira-triage-ops.lib.sh Resolved
Comment thread LOCAL.md Resolved
Comment thread scripts/lib/jira-triage-ops.lib.sh Resolved
Comment thread scripts/lib/jira-triage-ops.lib.sh Resolved
Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 HIGH, 3 MEDIUM. Details are in the inline comments.

Comment thread harness/triage.yaml Outdated
# `fullsend issues` reads tracker.jira from this directory's config.
FULLSEND_DIR: ${FULLSEND_DIR}
JIRA_BASE_URL: ${JIRA_BASE_URL}
JIRA_COMPLETED_TRANSITION: "Closed"

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.

HIGH: Default for completed changes on upgrade, but the PR has no breaking-change marker

Before this PR, completed used JIRA_SPLIT_TRANSITION (harness default "Obsolete"). The harness now always sets JIRA_COMPLETED_TRANSITION: "Closed", so every managed Jira run picks a different transition. The documented NOTICE fallback to JIRA_SPLIT_TRANSITION (lib lines 368-381, docs/triage.md) can never fire through the shipped harness.

Two groups break on upgrade:

  • (a) Users whose overlay set only JIRA_SPLIT_TRANSITION to get their own completed transition now get "Closed" or a Done fallback instead, with no warning.
  • (b) Custom workflows that offer "Obsolete" but none of Done/Closed/Resolved/Complete used to succeed and now exit 1: the fallback regex at line 443 excludes "obsolete".

COMMITS.md:79 lists "Default values change in ways that alter existing behavior" as breaking, and COMMITS.md:115 asks reviewers to flag a missing ! as high severity. The title and all three commits are plain fix(triage): with no BREAKING CHANGE: trailer.

Suggestion: Retitle to fix(triage)!: and add a BREAKING CHANGE: trailer: completed now uses JIRA_COMPLETED_TRANSITION (harness default "Closed", with a Done-category fallback), and overlays that set only JIRA_SPLIT_TRANSITION must also set JIRA_COMPLETED_TRANSITION. Also fix docs/triage.md and the lib header so they no longer suggest the fallback to JIRA_SPLIT_TRANSITION applies under the harness. The alternative is to leave the harness value empty so the documented fallback really runs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a274b35: removed JIRA_COMPLETED_TRANSITION: "Closed" from harness/triage.yaml (and updated LOCAL.md to match) so existing overlays and custom workflows preserve the documented fallback to JIRA_SPLIT_TRANSITION unless explicitly overridden.

Comment thread scripts/post-triage-test.sh Outdated
"" true

# Jira completed action falls back to JIRA_SPLIT_TRANSITION when JIRA_COMPLETED_TRANSITION is unset.
(

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: Test jira-completed-fallback-to-split-var runs in a subshell, so its failures never reach the suite

Lines 2437-2442 call run_jira_test_stdout inside ( unset JIRA_COMPLETED_TRANSITION; ... ). The helper (line 2341) records a failure only with FAILURES=$((FAILURES + 1)) and returns 0. That increment is lost when the subshell exits, so the suite still prints All tests passed and exits 0. Changing the expected string so it cannot match confirms this: the run prints FAIL for this test and still exits 0. The JIRA_COMPLETED_TRANSITION -> JIRA_SPLIT_TRANSITION fallback therefore has no working regression test. The same file already handles env-changing cases correctly at lines 2967-2977 (JIRA_CASE_FAILURES file plus jira_case_fail).

Suggestion: Drop the subshell. Save JIRA_COMPLETED_TRANSITION, unset it, call the helper, then restore it. Or record the failure through the JIRA_CASE_FAILURES file mechanism. Then repeat the mutation check to confirm a broken expectation now fails the suite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a274b35: replaced the subshell around jira-completed-fallback-to-split-var in scripts/post-triage-test.sh with save/restore of JIRA_COMPLETED_TRANSITION in the parent shell so FAILURES increments propagate to the suite.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
local is_rejection_status=0
local dup_name="${JIRA_DUPLICATE_TRANSITION:-}"
local not_planned_name="${JIRA_NOT_PLANNED_TRANSITION:-}"
if echo "${current_status_name}" | grep -qiE "won.?t do|not.?planned|duplicate|obsolete|reject|cancel|invalid|cannot reproduce|abandon"; then

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: Re-running split on an issue already in "Obsolete" overwrites it to Done/Closed

The shipped split status is JIRA_SPLIT_TRANSITION="Obsolete", but "obsolete" is in the rejection regex in both the idempotency check (line 399) and the fallback exclusion (line 443). On a split re-run for an issue already in "Obsolete": is_rejection_status=1, so the split skip at lines 407-411 does not fire. The exact "Obsolete" transition is usually not offered from the Obsolete status, so the fallback picks Done/Closed and POSTs it. The issue moves out of its split resolution into a plain completed one. The split path has no tests for idempotency or fallback.

Suggestion: For reason=split, count the current status as handled when it matches the configured JIRA_SPLIT_TRANSITION name (case-insensitive), before the rejection regex is checked. More generally, skip when the current status matches the configured target for this reason. Add tests for split re-run on an Obsolete issue and for split when the Obsolete transition is unavailable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a274b35: tracker_close_issue in scripts/lib/jira-triage-ops.lib.sh now checks case-insensitive equality against the target transition_name before evaluating the rejection regex, so re-running split when already in "Obsolete" skips idempotently. Added jira-split-idempotent-obsolete and jira-split-fallback-done tests.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
local not_planned_name="${JIRA_NOT_PLANNED_TRANSITION:-}"
if echo "${current_status_name}" | grep -qiE "won.?t do|not.?planned|duplicate|obsolete|reject|cancel|invalid|cannot reproduce|abandon"; then
is_rejection_status=1
elif [[ -n "${dup_name}" ]] && echo "${current_status_name}" | grep -qiF "${dup_name}"; then

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: Configured transition names are matched as status substrings, which breaks the documented "set all four to the same name" setup

Lines 401-404 mark the current status as a rejection when its name contains JIRA_DUPLICATE_TRANSITION or JIRA_NOT_PLANNED_TRANSITION (grep -qiF, substring match). Those values are transition names, not status names. docs/triage.md tells users whose workflow does not tell outcomes apart to "Set all four to the same transition name", e.g. all "Done". With that setup, an issue already in status "Done" counts as a rejection, so the completed/split idempotent skip never fires. The exact "Done" transition is normally not offered from Done. The fallback (lines 438-441) then removes every transition whose name equals the duplicate/not-planned names, which is "Done" again. The run ends with ERROR: transition 'Done' ... is not available and exits 1, the failure this PR set out to remove, reached by following the docs.

Suggestion: Do not use the duplicate/not-planned names to classify status when they equal the name configured for the current reason. Better, compare the current status to the configured name for the requested reason first and skip on a match. Add a test with all four variables set to "Done" and the issue already in Done.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a274b35: dup_name and not_planned_name are now compared case-insensitively for equality only when they differ from transition_name, both in the pre-flight status check and in the fallback jq exclusion selector. Added jira-all-four-done-idempotent-completed covering all four transition vars set to "Done".

…tatus checks

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

@waynesun09 waynesun09 left a comment

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.

Review findings: 4 MEDIUM. Details are in the inline comments.

# the raw REST calls in this file and the `fullsend` shell-outs below.
#
# Optional env vars:
# JIRA_COMPLETED_TRANSITION — transition name for the "completed" action

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: Header comment and PR body still say JIRA_COMPLETED_TRANSITION defaults to "Closed"; the shipped harness has no default

Commit a274b35 removed JIRA_COMPLETED_TRANSITION: "Closed" from harness/triage.yaml, and harness/triage.yaml is no longer in the diff. This header (lines 46-48) still says (default: "Closed"; falls back to JIRA_SPLIT_TRANSITION when unset), and the rebuilt bundles carry the same text (scripts/post-triage.sh, scripts/pre-code-jira.sh, scripts/pre-triage.sh). The PR body also still says it "Adds JIRA_COMPLETED_TRANSITION (defaulting to "Closed") in harness/triage.yaml" and lists triage.yaml under Changes.

With the shipped harness, completed falls back to JIRA_SPLIT_TRANSITION="Obsolete". So completed is decoupled from split only for operators who set the variable, and the reported failure is fixed by the name fallback, not by decoupling. LOCAL.md and docs/triage.md are correct; this header, which operators read first, is wrong. (The earlier header thread asked to add a "Closed" default; that default was later removed, so this is a new mismatch.)

Suggestion: Change the header to "no default; falls back to JIRA_SPLIT_TRANSITION when unset" and run make script-build so all four copies match. Update the PR title and body to say that, by default, completed still routes through JIRA_SPLIT_TRANSITION (with the Done-name fallback) and that harness/triage.yaml is unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 20bebaa (20bebaa): updated the JIRA_COMPLETED_TRANSITION header comment in scripts/lib/jira-triage-ops.lib.sh (and rebuilt the bundles) to state (no default; falls back to JIRA_SPLIT_TRANSITION when unset), and updated the PR body to remove the stale "Closed" default / harness/triage.yaml references and note that validation used mocked workflow responses (linking fullsend-ai/fullsend#6704).

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
| not
)
] as $done_transitions
| ([$done_transitions[] | select(.name | test("(?i)^(done|closed|resolved|complete(d)?)$"))][0].id // empty)

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: Fallback matches only exact transition names, so common workflows still fail; docs describe a broader fallback

The fallback keeps a done-category transition only when its transition .name exactly matches ^(done|closed|resolved|complete(d)?)$. In Jira, the transition name and the target status (.to.name) are separate fields. Transitions named "Resolve Issue", "Close Issue", "Close", "Mark as done", "Finished", "Fixed" and so on do not match, even when they lead to a Done/Closed/Resolved status. The action then still exits 1 with "transition ... is not available" under set -e, which is the failure this PR set out to remove.

docs/triage.md (lines 292-295) promises a fallback to "an available positive Done-category transition (preferring "Done", "Closed", "Resolved", or "Complete")". That wording implies other positive Done transitions are accepted and that there is a priority order. The code accepts only those exact names and takes [0] in API order. Only mocked tests back the change.

Suggestion: Select candidates by .to.statusCategory.key == "done" and match the positive list against (.to.name // .name), keeping the rejection exclusion on both .name and .to.name. Rank matches explicitly if the docs keep the word "preferring". Otherwise narrow docs/triage.md to "the first available transition named exactly Done, Closed, Resolved, or Complete(d)". Please also state in the PR whether this was validated against a live team-managed or company-managed project.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 20bebaa (20bebaa): the fallback selector in scripts/lib/jira-triage-ops.lib.sh now matches positive Done-category names against (.to.name // .name) while keeping rejection exclusions on both .name and .to.name, and ranks tier-1 exact matches (Done, Closed, Resolved, Complete(d)) ahead of tier-2 word-boundary matches so transitions such as "Resolve Issue" -> "Resolved" work cleanly. Added jira-completed-fallback-resolve-issue coverage in scripts/post-triage-test.sh and rebuilt bundles.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
is_rejection_status=1
elif [[ -n "${not_planned_name}" && "${not_planned_name,,}" != "${transition_name,,}" && "${current_status_name,,}" == "${not_planned_name,,}" ]]; then
is_rejection_status=1
fi

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: duplicate and not planned treat any rejection status as already handled, and this path has no tests

In the idempotency pre-flight (lines 401-414), any done-category status that matches the broad rejection regex (won't do|not planned|duplicate|obsolete|reject|cancel|invalid|cannot reproduce|abandon), or that equals the dup or not-planned name, returns 0 for both duplicate and not planned. So a not planned action on an issue already in "Duplicate" (or a duplicate action on an issue in "Won't Do" or "Obsolete") reports success and keeps the wrong resolution. Before this PR, the transition was attempted and failed visibly if unavailable.

This is the same class as the earlier "wrong resolution" thread, which was fixed only for completed/split. The new (rejected); skipping transition branch has no test: MOCK_JIRA_STATUS_REJECTED is used only for the split-Obsolete case (scripts/post-triage-test.sh ~2456-2477).

Suggestion: For duplicate and not planned, skip only when the current status equals the configured transition name or its target status; otherwise attempt the transition as before. Add MOCK_JIRA_STATUS_REJECTED tests for duplicate and not planned, including one where the issue is in the other rejection status.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 20bebaa (20bebaa): removed the broad rejection-regex short-circuit for duplicate and not planned so they only skip idempotently when the current Jira status matches the configured transition name or its .to.name target status. Added jira-duplicate-on-wont-do-transitions and jira-not-planned-idempotent-wont-do (plus -no-post) tests in scripts/post-triage-test.sh.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
transition_id=$(echo "${transitions}" | jq -r --arg name "${transition_name}" \
'[.transitions[] | select(.name == $name)][0].id // empty')

# Fallback resolution when configured transition name is not directly available

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: An explicitly configured transition that does not exist is now silently replaced by the heuristic fallback

For completed and split, when the configured name is missing from the issue's transitions, the code falls back to any Done/Closed/Resolved/Complete transition. It logs only a plain stdout line and the run succeeds. A typo or stale override (for example JIRA_COMPLETED_TRANSITION="Closd", or a renamed workflow transition) used to fail the post-script. Now it quietly closes the issue through a different transition, with no CI annotation for the operator. No linked issue or ADR records this change to the operator contract; the fullsend Jira user guide points tracker-neutral transition discovery at fullsend-ai/fullsend#6704.

Suggestion: Print the fallback message as a ::warning:: annotation so operators see the substitution in the run summary, and link the PR to fullsend-ai/fullsend#6704 or to an issue that records the new behaviour.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 20bebaa (20bebaa): emitted a ::warning::Transition '...' is not available on issue ...; falling back to '...' via Done-category heuristics annotation (sanitized via _gha_sanitize) when substituting a missing transition, updated jira-completed-fallback-done to assert it, and linked fullsend-ai/fullsend#6704 in the PR description.

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
@jefferyb jefferyb changed the title fix(triage): decouple completed from split and resolve Jira transitions dynamically fix(triage): resolve Jira completion transitions dynamically with Done fallback Nov 13, 2026

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 MEDIUM. Details are in the inline comment.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
| select(
($dup != "" and ($dup | ascii_downcase) != ($target | ascii_downcase) and (($n | ascii_downcase) == ($dup | ascii_downcase) or ($to | ascii_downcase) == ($dup | ascii_downcase))) or
($not_planned != "" and ($not_planned | ascii_downcase) != ($target | ascii_downcase) and (($n | ascii_downcase) == ($not_planned | ascii_downcase) or ($to | ascii_downcase) == ($not_planned | ascii_downcase))) or
($n | test("(?i)won.?t do|not.?planned|duplicate|obsolete|reject|cancel|invalid|cannot reproduce|abandon")) or

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: The rejection denylist misses common Jira rejection names, so the completed/split fallback can close an issue as "Won't Fix"

The fallback added in 20bebaa ranks a transition as positive when its name OR its target status (.to.name) matches the tier-1 or tier-2 positive regex (lines 458-459). Rejections are excluded only by a fixed denylist: won.?t do|not.?planned|duplicate|obsolete|reject|cancel|invalid|cannot reproduce|abandon. The same list appears at line 403 (bash grep) and lines 452-453 (jq).

Common Jira rejection names are not on it: "Won't Fix", "Won't Implement", "Declined", "Deferred", "Not a Bug" and "As Designed".

  • Fallback: a transition named "Close Issue" (tier 2 matches \bclose\b on .name), or one named "Closed", whose .to.name is "Won't Fix", passes the filter and can be picked. A completed or split action then closes the issue as rejected, which docs/triage.md says is excluded.
  • Pre-flight (line 403): an issue already in "Won't Fix" or "Declined" gets is_rejection_status=0, so completed skips with "already in status ... (done)" and never moves the issue to a positive Done status.

The earlier Qodo comment covered the older last-resort [0] fallback. This one is about the tier-2 .name/.to.name matching added in 20bebaa.

Suggestion

  1. Do not accept a match on .name when .to.name is present and not itself positive. For tier 1, match only exact positive .to.name values.
  2. Add won.?t (fix|implement)|declin|defer|not a bug|as designed|out of scope to the denylist.
  3. Move the regex into one shared variable and pass it to jq with --arg, so the bash and jq copies cannot drift apart.
  4. Change jira-completed-fallback-done to assert the POST body ({"transition":{"id":"51"}}) instead of only the warning text. Add a mock with a "Close Issue" -> "Won't Fix" transition next to Done.

For a more robust check, read the resolution field (fields=status,resolution) in the pre-flight.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f7716a7b (f7716a7b5536d3b2c09b37841c1360551c9508e1):

  1. Shared rejection regex (rejection_re) & expanded terms: Extracted the rejection pattern into one shared rejection_re variable in _jira_transition_issue (used by pre-flight grep -qiE and passed to jq via --arg reject_re), adding won.?t (do|fix|implement), declin, defer, not a bug, as designed, and out of scope.
  2. Require positive .to.name when present: Updated tier-1 and tier-2 fallback selection so when .to.name is non-empty, .to.name itself must satisfy the positive pattern (falling back to .name only when .to.name is empty), preventing transitions like Close Issue -> Won't Fix from matching on .name.
  3. Bundled scripts & strengthened tests: Rebuilt all bundled scripts (make -B script-build), verified zero diff with make check-bundle, passed shellcheck -S warning, post-triage-test.sh (both source and bundled), pre-triage-test.sh, and pre-code-jira-test.sh. Updated jira-completed-fallback-done to assert the {"transition":{"id":"51"}} POST payload + warning, and added jira-completed-fallback-skips-close-issue-wont-fix.

…et status

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
fi
fi

if [[ -z "${transition_id}" ]]; then

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: The Done-category fallback POSTs a transition the operator never configured, and sends no resolution

When the configured transition is missing for completed/split, the fallback (lines 437-471) now picks a heuristic transition. One example is classic "Resolve Issue" -> "Resolved", which the jira-completed-fallback-resolve-issue test models. The code then POSTs only {transition:{id}} here. It does not check hasScreen or expand=transitions.fields, and it does not set fields.resolution.

In company-managed or classic workflows, the transition screen supplies Resolution. Through REST, such a transition either fails validation (400) or leaves the issue Done but "Unresolved". Before this PR, the code only POSTed a transition the operator had chosen. The fallback now does the same with transitions nobody vetted. fullsend-ai/fullsend#6704, which this PR links, lists supplying a resolution as part of the transition as a requirement.

The pre-flight has the same blind spot. It requests fields=status only (line 392), so a "Closed" issue with resolution "Won't Fix" still counts as already completed. An earlier comment mentioned reading the resolution field only as an optional extra. The new part here is the fallback POST.

Suggestion

  1. In the fallback, prefer candidates with hasScreen == false.
  2. Otherwise fetch ?expand=transitions.fields. If the screen has a Resolution field, set fields.resolution (for example "Done" or "Fixed"). If not, skip that candidate and fail loudly.
  3. Add a mock test for a candidate whose screen requires a resolution.
  4. Optional: request fields=status,resolution in the pre-flight and treat a rejection-class resolution like a rejection status.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 711a39e7 (fix(triage): handle screen resolution fields in Jira fallback).

Summary of changes in scripts/lib/jira-triage-ops.lib.sh:

  1. Pre-flight status & resolution guard: Now queries ?fields=status,resolution and checks .fields.resolution.name against rejection_re across the completed/split pre-flight idempotency checks so a Closed issue with a rejection resolution (e.g., Won't Fix) is not treated as already completed.
  2. Screen-aware fallback transitions: Fallback listing queries /transitions?expand=transitions.fields, prefers transitions with hasScreen == false before hasScreen == true within each tier, rejects hasScreen: true candidates with missing/empty .fields, required non-resolution fields, or required resolution lacking a positive allowedValues match (^(done|fixed|resolved|completed?)$), and populates fields.resolution.name in the transition POST body when .fields.resolution is present.
  3. Mock coverage: Updated mock /transitions endpoints to match ?expand=transitions.fields and added regression tests covering screenless preference, fields.resolution population, skipping transitions with required custom screen fields, and the Closed + Won't Fix pre-flight case.

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

# Conflicts:
#	LOCAL.md

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 MEDIUM. Details are in the inline comment.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
fi
if [[ "${current_category}" == "done" ]]; then
if [[ -n "${current_status_name}" && "${current_status_name,,}" == "${transition_name,,}" ]]; then
if [[ ( "${reason}" != "completed" && "${reason}" != "split" ) || ${is_rejection_resolution} -eq 0 ]]; then

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: A split re-run on an issue already closed as Obsolete, with resolution Obsolete, POSTs the transition again or falls back to Done

Commit 711a39e added a resolution gate, and it undoes the fix from a274b35 for the earlier "split re-run in Obsolete" thread. The harness default is JIRA_SPLIT_TRANSITION="Obsolete", and obsolete is in rejection_re. When the issue is in status Obsolete with a rejection-class resolution (Obsolete, Won't Do), is_rejection_resolution=1. That value turns off three skips for completed/split:

  • the exact-name skip (this line)
  • the generic done skip (is_rejection_status is 1 anyway, because the status name matches the regex)
  • the .to.name target-status skip (line 452)

There are two outcomes:

  1. If the workflow offers an Obsolete self-transition, the script POSTs it again. That is not idempotent and can fail.
  2. If it does not, the fallback picks a Done-category transition, emits a ::warning::, and re-closes a correctly closed split issue as Done.

The test jira-split-idempotent-obsolete mocks only resolution: null, so it misses this case.

Suggestion: When the current status equals the configured transition name or its .to.name, treat the issue as already done, whatever its resolution. Use the rejection-resolution check only for the generic "any done status" skip. Never fall back when the current status already equals the configured target. Add tests for status Obsolete with resolution Obsolete, both with and without a self-transition in the list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 32c489e9 (32c489e9ebdbf443af266acf51f0286cffa527ae), following an append-only merge of origin/main in f1af399c:

  • Exact-status & .to.name idempotency: Removed the is_rejection_resolution gate from both the exact status-name match (scripts/lib/jira-triage-ops.lib.sh) and the .to.name target-status match, so an issue already in the configured target status is skipped regardless of its resolution and never re-POSTed or fallen back to Done.
  • Generic Done-category skip preserved: Kept is_rejection_resolution strictly on the generic "any done status" skip, and updated jira-completed-preflight-done-wont-fix-not-satisfied to test a non-target Done status (Done while JIRA_COMPLETED_TRANSITION="Closed") with resolution Won't Fix.
  • Regression tests: Added jira-split-idempotent-obsolete-res-with-self-transition, jira-split-idempotent-obsolete-res-without-self-transition, and jira-split-idempotent-obsolete-to-name-with-res in scripts/post-triage-test.sh.
  • Verification: Passed make -B script-build && make check-bundle, shellcheck -S warning, and scripts/post-triage-test.sh under both SCRIPT_TEST_TARGET=source and SCRIPT_TEST_TARGET=bundled.

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

# Conflicts:
#	scripts/post-triage-test.sh
Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 HIGH, 3 MEDIUM. Details are in the inline comments.

The functional-tests-complete failure is not caused by the code. It fails only because the /ok-to-test <sha> authorization gate has not run.

Comment thread scripts/post-triage.sh Outdated
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/triage-ops.lib.sh
# BEGIN bundled: lib/triage-ops.lib.sh
# BEGIN bundled: /private/tmp/pr-audit-agents-1998/scripts/lib/triage-ops.lib.sh

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.

HIGH: Rebuilt bundles embed an absolute local build path, so the required script-test check fails

At head 32c489e, all 16 bundled scripts contain markers like # BEGIN bundled: /private/tmp/.../scripts/lib/.... This includes post-triage.sh, pre-code.sh, post-code.sh, pre-code-jira.sh and the others. On main, the marker is lib/....

The cause is scripts/bundle-sh.sh:168. rel_comment strips ${src_dir}/ from a path that realpath has canonicalized. On macOS, /tmp is a symlink to /private/tmp, so the prefix never matches and the absolute path gets written.

CI confirms it. script-test fails with Bundled script stale: scripts/pre-code.sh (run make script-build), although the PR says make check-bundle passes. The rebuild also publishes a local path and adds about 250 lines of noise to files the PR does not otherwise change.

Suggestion: Rebuild the bundles from a checkout whose path has no symlinked parent, or on Linux. Then confirm that make check-bundle passes and that bundles which don't include a changed lib (for example scripts/post-code.sh) show no diff against origin/main. Optionally, in a separate PR, canonicalize src_dir in bundle-sh.sh before the prefix strip.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in dcf84f2f (dcf84f2fe3fba3837db0a2ba3a741353cf041f85) and re-verified after the latest rebuild in f34c0392:

  • Rebuilt bundled scripts from the physical worktree path so bundle-sh.sh emits relative lib/... markers.
  • Confirmed zero /private/tmp paths remain in scripts/ and make check-bundle exits 0.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
is_rejection_resolution=1
fi
if [[ "${current_category}" == "done" ]]; then
if [[ -n "${current_status_name}" && "${current_status_name,,}" == "${transition_name,,}" ]]; then

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: A split re-run re-closes the issue as Done when the transition name differs from the status name

The idempotency skips compare the current status with only two names: the configured transition name (here) and the offered transition's .to.name (lines 452-457).

Example: JIRA_SPLIT_TRANSITION='Mark Obsolete' moves an issue to status Obsolete. On a split re-run:

  1. The issue is already in Obsolete, so the exact-name check misses.
  2. obsolete matches rejection_re, so is_rejection_status=1 and the generic done skip is turned off.
  3. Mark Obsolete is not offered from Obsolete, so transition_id is empty and the .to.name check never runs.
  4. The fallback (lines 465-536) then re-closes the already-split issue as Done and emits a warning.

The test jira-split-idempotent-obsolete-to-name-with-res covers only the case where the self-transition is still offered. The earlier thread fixed the case where the status name equals the transition name. This variant is still open.

Suggestion: Before falling back for split/completed, also treat a done-category current status as satisfied when it is the target status of the configured transition. One option is to accept a status that matches rejection_re when the reason is split. Another is to resolve the configured transition's target status some other way. Add a test with JIRA_SPLIT_TRANSITION='Mark Obsolete', status Obsolete, and no self-transition offered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f34c0392 (f34c03921f4c158bca17e5c6b47ca473403a86f6):

  • Before falling back for split, when the configured transition is not offered (transition_id is empty) and the issue is already in a done-category status that does not match JIRA_DUPLICATE_TRANSITION or JIRA_NOT_PLANNED_TRANSITION, tracker_close_issue now skips idempotently instead of re-closing as Done with a warning.
  • Added regression tests jira-split-idempotent-mark-obsolete-no-self-transition (confirming no POST /transitions and no ::warning:: with JIRA_SPLIT_TRANSITION='Mark Obsolete', status Obsolete, and only Done offered) and jira-split-on-duplicate-status-not-skipped (negative control).

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
test("^(done|fixed|resolved|completed?)$"; "i");
def positive_res_name($t):
if ($t.fields?.resolution? == null) then ""
elif (($t.fields.resolution.allowedValues // []) | length) == 0 then "Done"

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: The fallback can send a hard-coded resolution Done that the Jira instance may not have

positive_res_name returns the literal "Done" when a transition screen has a resolution field but allowedValues is empty or missing. Lines 543-546 then POST fields:{resolution:{name:"Done"}}.

Resolution names vary by instance (Fixed, Resolved, Completed). If Done does not exist, Jira returns 400 and the post-script exits 1. That is the same hard failure this PR sets out to remove.

Suggestion: When no positive allowed value can be derived, return "" so the payload carries only the transition id. Or treat the transition as ineligible when its resolution is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f34c0392 (f34c03921f4c158bca17e5c6b47ca473403a86f6):

  • positive_res_name now returns "" instead of hard-coding "Done" when fields.resolution.allowedValues is empty or missing.
  • screen_eligible now checks positive_res_name(.) != "" whenever fields.resolution.required is true, treating required-resolution screens with empty/missing allowedValues as ineligible while allowing optional-resolution screens to omit fields.resolution.
  • Added regression tests jira-completed-fallback-screen-required-res-empty-allowed-skipped, jira-completed-fallback-screen-optional-res-empty-allowed-omits-res, and jira-completed-fallback-screen-non-done-resolution.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
fi
fi

# Fallback resolution when configured transition name is not directly available

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: The Jira fallback and resolution payload were tested only against hand-written mocks

The new selection logic depends on several Jira Cloud REST behaviours:

  • expand=transitions.fields fills fields.resolution.allowedValues and required only for transitions with a screen
  • hasScreen is set on each transition
  • each transition carries to.name and to.statusCategory.key
  • POST /transitions accepts fields.resolution.name on a fallback transition

The PR body says this was not tested against a live Jira Cloud project, and some mock shapes differ from real responses. Under set -e, a mismatch makes the post-script fail hard.

Suggestion: Before merge, run post-triage completed and split against a real Jira Cloud dev project. Cover two projects: one team-managed project without Obsolete, and one company-managed project with a resolution screen on Done. Record the observed transition JSON and the outcomes in the PR, and refresh the mocks from those responses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f34c0392 (f34c03921f4c158bca17e5c6b47ca473403a86f6) and updated the PR description:

  • Verified the live Jira Cloud REST API v3 response shape via read-only GET /rest/api/3/issue/{key}/transitions?expand=transitions.fields, confirming expand: "transitions", hasScreen booleans, to.name, to.statusCategory.key, empty fields: {} on screenless transitions, and fields.resolution.{required,allowedValues} on screened transitions.
  • Fed the live response directly into the extracted jq selection filter from jira-triage-ops.lib.sh, which cleanly selected {"id":"61","name":"Closed","resolution_name":"Done"} (skipping non-tier Release Pending and non-done transitions).
  • Added jira-completed-fallback-live-cloud-shape to scripts/post-triage-test.sh reflecting the observed Jira Cloud response shape and documented the sanitized JSON excerpt in the PR body (noting transparently that live write POST /transitions testing was not executed against a production project and would require a dedicated scratch Jira Cloud dev project).

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

@waynesun09 waynesun09 left a comment

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.

Review findings: 2 MEDIUM. Details are in the inline comments.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
fi
fi

# Fallback resolution when configured transition name is not directly available

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: The fallback rebuilds Jira close logic in bash, though fullsend already has fullsend issues transition --state closed with the opposite rule

The PR links fullsend-ai/fullsend#6704. fullsend PR #9437 closed that issue: it merged 2026-11-13 and shipped in v0.56.1. It added fullsend issues transition (see internal/cli/issues_transition.go and internal/tracker/transition.go on fullsend main). With --state closed, the command does three things:

  1. It skips when statusCategory is already done.
  2. It picks the single available transition whose to.statusCategory.key == "done", and returns an "ambiguous Jira transition" error when more than one matches.
  3. It fills a required resolution only when Jira offers exactly one valid allowed value and the field has no default, and it sends that resolution by id.

Its help text says: "No arbitrary workflow action or resolution is chosen."

This PR adds about 100 lines of jq at lines 465-540 that do the opposite:

  • They rank transitions by English keywords (tier 1 Done/Closed/Resolved/Complete, tier 2 finish/fixed/...) and take the first match.
  • They pick a resolution by name with ^(done|fixed|resolved|completed?)$.
  • They exclude rejections with an English denylist (rejection_re, line 410).

The library already shells out to fullsend issues for comments (header lines 8-44). As written, agents and core fullsend close the same Jira workflow under two different policies.

Suggestion: For the completed/split fallback, call fullsend issues transition --tracker jira --number N --state closed, or try --transition "$JIRA_*_TRANSITION" first and use --state closed when that transition is missing. Raise the minimum fullsend version if needed. If keyword ranking is really wanted, agree that policy upstream first so both repos follow one rule. Otherwise, say in the PR why the CLI does not fit, and send the resolution by allowedValues id instead of by name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 8907b96d (8907b96d3fa492aec5239836b2aca5487e75c173):

  • Removed the ~100-line bash/jq keyword-ranking fallback, English rejection denylist (rejection_re), and resolution-by-name picker from scripts/lib/jira-triage-ops.lib.sh.
  • Delegated Jira close transitions to fullsend issues transition --tracker jira via _jira_transition (using jira_auth_fullsend and --fullsend-dir, matching _jira_post_comment):
    • When the configured transition is offered, invokes fullsend issues transition --transition "${transition_name}" (so fullsend enforces exact/unambiguous matching and upstream resolution-by-ID handling).
    • When the configured transition is unavailable for completed or split, emits a ::warning:: and falls back to fullsend issues transition --state closed so agents and core fullsend follow one shared close policy.
  • Updated docs/triage.md to document the Fullsend v0.56.1 (fullsend-ai/fullsend#9437) requirement and exact CLI behavior, rebuilt script bundles (make -B script-build && make check-bundle), and updated scripts/post-triage-test.sh (verified with shellcheck -S warning and both source and bundled runs of post-triage-test.sh, pre-triage-test.sh, and pre-code-jira-test.sh).

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated

# Fallback resolution when configured transition name is not directly available
local fallback_resolution_name=""
if [[ -z "${transition_id}" ]]; then

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: The split re-run skip silently accepts any done-category status, including rejections the main pre-flight refuses to skip

Commit f34c039 added a split-only block at lines 467-474. When the configured split transition is not offered and the issue is in a done-category status, the block returns 0 unless the status name exactly equals JIRA_DUPLICATE_TRANSITION or JIRA_NOT_PLANNED_TRANSITION. It does not check rejection_re or is_rejection_resolution, which the main pre-flight at lines 432-447 uses to decide not to skip.

Failure case: an issue sits in "Won't Fix", "Rejected", "Cancelled" or "Deferred", or in Closed with a rejection resolution, and its workflow does not offer "Obsolete". A split action then reports success: sub-issues are created and the parent keeps its rejection state. The completed reason on the same issue would treat that state as a rejection and transition the issue. This block was meant only to count a parent already in the split target (for example Obsolete reached via "Mark Obsolete") as already handled.

Suggestion: Narrow the exception. Skip only when the current status is the split target: it matches JIRA_SPLIT_TRANSITION, or it matches the .to.name of a transition with that name. Otherwise reuse the main pre-flight's is_rejection_status result. Add a test for split on an issue in "Won't Fix" when the split transition is not offered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 8907b96d (8907b96d3fa492aec5239836b2aca5487e75c173):

  • Removed the split-only catch-all done-status skip block (along with the bash rejection_re denylist as part of delegating close transitions to fullsend issues transition).
  • Pre-flight idempotency now skips only when the issue is already in a done-category status whose name matches the configured transition name directly, or matches .to.name when a single transition with the configured name is offered.
  • For split on an issue in "Won't Fix" when JIRA_SPLIT_TRANSITION is not offered, tracker_close_issue no longer takes an early bash skip; both split and completed now take the same path, emit the fallback warning, and delegate to fullsend issues transition --state closed.
  • Added jira-split-on-wont-fix-missing-transition-not-skipped (plus .to.name mismatch and ambiguous-transition tests) in scripts/post-triage-test.sh; verified in both source and bundled modes.

Replace the custom bash/jq keyword-ranking fallback and English
rejection denylist in tracker_close_issue with fullsend issues
transition (available since Fullsend v0.56.1 / fullsend-ai/fullsend#9437).

- Check exact target-status idempotency (status matches configured
  transition name or its .to.name when in a done-category status)
  and remove the split-only catch-all skip block.
- Delegate available configured transitions to
  fullsend issues transition --transition and completed/split fallbacks
  to fullsend issues transition --state closed so agents and core
  fullsend share one transition and resolution policy.
- Update docs/triage.md (documenting the Fullsend v0.56.1 requirement),
  rebuild script bundles, and update scripts/post-triage-test.sh
  including split on Won't Fix when the split transition is missing.

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>
@jefferyb jefferyb changed the title fix(triage): resolve Jira completion transitions dynamically with Done fallback fix(triage): delegate Jira close transitions to fullsend CLI Nov 20, 2026

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 MEDIUM. Details are in the inline comment.

Comment thread scripts/lib/jira-triage-ops.lib.sh Outdated
Comment on lines +472 to +476
if [[ "${reason}" == "completed" || "${reason}" == "split" ]]; then
echo "::warning::Transition '$(_gha_sanitize "${transition_name}")' (from ${transition_var}) is not available on issue ${ISSUE_NUMBER}; falling back to 'fullsend issues transition --state closed'"
if ! _jira_transition --state closed; then
echo "ERROR: failed to close issue ${ISSUE_NUMBER} via 'fullsend issues transition --state closed'" >&2
return 1

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: The --state closed fallback can close a completed or split issue through a rejection-type transition, even when the operator set the name

When the configured transition for completed or split is not offered, this block prints only a ::warning:: and runs fullsend issues transition --state closed. That command applies whatever single transition reaches a done-category status. This commit removed the bash rejection denylist, so nothing now stops that transition from being "Won't Do", "Duplicate" or "Cannot Reproduce".

Impact:

  • A positive triage decision can be recorded in Jira as a rejection. For split, the result also looks the same as any other close.
  • The fallback runs for names the operator set too. The test at scripts/post-triage-test.sh lines 2539-2556 (JIRA_COMPLETED_TRANSITION="NonExistent") passes and closes the issue anyway, so a typo or stale override is never a failure.
  • The harness default is JIRA_SPLIT_TRANSITION: "Obsolete" (harness/triage.yaml line 191), and completed falls back to it when unset. Standard Jira Cloud and team-managed workflows have no "Obsolete" transition, so with defaults every completed or split close takes this path and emits the warning. Operators learn to ignore that warning, and it is the only signal of the problem.
  • docs/triage.md lines 340-349 describe the fallback but do not say that the single done-category transition may mean won't-do.

Earlier threads covered the warning and the old denylist. This risk is new in this commit, because the denylist that guarded this path was removed.

Suggestion: Use the --state closed fallback only when the name came from the harness default: JIRA_SPLIT_TRANSITION is still the default "Obsolete", or completed fell back to the split variable. If the operator set a name and Jira does not offer it, fail loudly as before. Also say in docs/triage.md that the fallback may apply a done-category transition with a won't-do meaning when it is the only one offered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 55da9d7a (55da9d7afe187f29640f6a0fb99074013d14edfc):

  • ASK-1a: Restricted the fullsend issues transition --state closed fallback in tracker_close_issue strictly to the un-overridden harness default (default_split_transition="Obsolete", requiring transition_var == "JIRA_SPLIT_TRANSITION" and transition_name == "${default_split_transition}", which covers both split with default JIRA_SPLIT_TRANSITION="Obsolete" and completed when JIRA_COMPLETED_TRANSITION is unset and falls back to it; scripts/lib/jira-triage-ops.lib.sh:472-487; tests jira-completed-default-fallback-state-closed at scripts/post-triage-test.sh:2539-2565, jira-fallback-state-closed-failure-propagates at scripts/post-triage-test.sh:2708-2727, jira-split-fallback-state-closed at scripts/post-triage-test.sh:2880-2892).
  • ASK-1b: Any explicitly configured transition name that Jira does not offer — including JIRA_COMPLETED_TRANSITION="NonExistent", explicit JIRA_COMPLETED_TRANSITION="Obsolete", or an operator-overridden JIRA_SPLIT_TRANSITION="CustomSplit" for either split or completed — now fails loudly with zero CLI transition calls (scripts/lib/jira-triage-ops.lib.sh:489-490; tests jira-completed-explicit-missing-transition-fails, jira-completed-explicit-obsolete-missing-fails, jira-split-explicit-missing-transition-fails, and jira-completed-explicit-split-override-missing-fails at scripts/post-triage-test.sh:2567-2636).
  • ASK-1c: Updated docs/triage.md:339-358 to document that the --state closed fallback applies only to the un-overridden harness default ("Obsolete"), that explicit overrides fail loudly when unavailable, and that --state closed may apply a rejection/won't-do transition (e.g., "Won't Do", "Duplicate", "Cannot Reproduce") if it is the sole done-category transition offered.
  • ASK-1d: Rebuilt compiled bundles (scripts/post-triage.sh, scripts/pre-triage.sh, scripts/pre-code-jira.sh) from a symlink-free physical path with relative lib/... markers.
  • Verification: make -B script-build && make check-bundle, shellcheck -S warning, and uv run --no-project --with jsonschema env SCRIPT_TEST_TARGET={source,bundled} across post-triage-test.sh, pre-triage-test.sh, and pre-code-jira-test.sh all passed.

@waynesun09 waynesun09 left a comment

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.

Review findings: 1 MEDIUM. Details are in the inline comment.

# harness/triage.yaml, including when `completed` fell back to it because
# JIRA_COMPLETED_TRANSITION was unset). Any operator-configured transition
# name that Jira does not offer fails loudly below.
local default_split_transition="Obsolete"

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: The --state closed fallback depends on a hard-coded copy of the harness default "Obsolete", and no test ties the two together

local default_split_transition="Obsolete" duplicates JIRA_SPLIT_TRANSITION: "Obsolete" in harness/triage.yaml line 191. The fallback fires only when transition_var == JIRA_SPLIT_TRANSITION and the name equals that literal (a case-sensitive match).

Impact:

  • No test reads harness/triage.yaml and checks it against this constant. scripts/harness-jira-test.sh has no Obsolete or SPLIT_TRANSITION assertion. If the harness default changes, the fallback stops firing with no test failure, and the original exit-1 bug on workflows without "Obsolete" comes back.
  • The string comparison cannot tell the harness default apart from an operator overlay that sets JIRA_SPLIT_TRANSITION="Obsolete" on purpose. That operator still gets the silent fallback, although docs/triage.md lines 350-352 say an override fails loudly.

Suggestion: Pass the fallback signal from the harness, for example a runner env flag next to JIRA_SPLIT_TRANSITION, instead of comparing against a literal. At minimum, add a test that reads JIRA_SPLIT_TRANSITION from harness/triage.yaml and asserts it equals this constant. Reword the docs to say that an override to any name other than "Obsolete" fails loudly.

Verified: read code at head (lib.sh:472-487, harness/triage.yaml:191); grep shows harness-jira-test.sh has no Obsolete assertion at 55da9d7; raised by: Claude, DeepSeek

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d7c5c6e: Added check_runner_mapping assertions in scripts/harness-jira-test.sh for JIRA_SPLIT_TRANSITION ('Obsolete'), JIRA_DUPLICATE_TRANSITION ('Duplicate'), and JIRA_NOT_PLANNED_TRANSITION ("Won't Do") to couple harness defaults to fallback constants under test. Clarified in docs/triage.md that overrides to any name other than "Obsolete" fail loudly if unavailable.

…nc docs

Signed-off-by: Jeffery Bagirimvano <jefferyb@redhat.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants