Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To update an installed binary later, run [`fullsend self-update`](self-update.md
| [`fullsend self-update`](self-update.md) | Update the local `fullsend` binary to the latest release, or to `--version`, after verifying the release's Sigstore signature and checksum. |
| `fullsend eval-measure` | Score wild-run traces into `eval-measurements.jsonl`. See [Eval measurements](../guides/infrastructure/eval-measurements.md). |
| `fullsend prepare-artifacts` | Build, in `--artifact-dir`, the filtered copy of a run's `--output-dir` that CI uploads as the run artifact. The level (`all`, `metadata` or `none`) comes from `config.yaml`'s [`artifacts`](../reference/config-reference.md#artifacts) setting and the run's source; a run whose source is unknown gets the strictest configured level. Prints the level on stdout and the rule it applied on stderr. If the level cannot be resolved, it leaves `--artifact-dir` empty and exits non-zero. `action.yml` and the GitLab agent job run it after `eval-measure`. See [Run artifacts and private data](../guides/user/run-artifacts-and-private-data.md). |
| `fullsend issues transition` | Transition an issue: exactly one of `--state closed`, `--transition NAME` (Jira), or `--status NAME` (Jira). Accepts `--resolution ID_OR_NAME` (Jira) and `--comment TEXT`, plus the existing `--tracker`, `--project`, `--number`, `--fullsend-dir`, and `--token` flags. See [Issue transitions](../guides/user/issues-commands.md#fullsend-issues-transition) for permissions, ambiguity handling, and partial failures. |
| `fullsend issues transition` | Transition an issue: exactly one of `--state closed`, `--state started` (Jira), `--transition NAME` (Jira), or `--status NAME` (Jira). Jira `--state` selects by status category and prints a skip listing the candidates and exits with code 11 when no single transition fits. Accepts `--resolution ID_OR_NAME` (Jira) and `--comment TEXT`, plus the existing `--tracker`, `--project`, `--number`, `--fullsend-dir`, and `--token` flags. See [Issue transitions](../guides/user/issues-commands.md#fullsend-issues-transition) for permissions, ambiguity handling, and partial failures. |

## Global flags

Expand Down
3 changes: 2 additions & 1 deletion docs/guides/dev/cli-internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ fullsend
│ ├── --tracker <tracker> # Tracker backend: github, gitlab, or jira
│ ├── --project <project> # owner/repo or an allowed Jira project key
│ ├── --number <int> # Issue number
│ ├── --state closed # Portable closure; one selector required
│ ├── --state started # Jira only: move to an in-progress status; one selector required
│ ├── --state closed # Portable closure on all trackers; one selector required
│ ├── --transition <name> # Exact Jira transition name
│ ├── --status <name> # Exact Jira destination status
│ ├── --resolution <id-or-name> # Jira resolution allowed by the transition
Expand Down
49 changes: 41 additions & 8 deletions docs/guides/user/issues-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,16 @@ created in the type's outward direction: the example above records that

## `fullsend issues transition`

Close an issue through its tracker, or execute a named Jira workflow action:
Close an issue through its tracker, start a Jira issue, or execute a named Jira
workflow action:

```bash
fullsend issues transition --tracker github --project owner/repo \
--number 42 --state closed --comment "Triage complete."

fullsend issues transition --fullsend-dir .fullsend --tracker jira \
--project PROJ --number 42 --state started

fullsend issues transition --fullsend-dir .fullsend --tracker jira \
--project PROJ --number 42 --transition "Review"

Expand All @@ -341,10 +345,11 @@ Exactly one of `--state`, `--transition`, or `--status` is required:

| Flag | Meaning |
|------|---------|
| `--state closed` | Portable closure on GitHub, GitLab, and Jira. Jira selects a unique available transition whose destination has status category `done`. |
| `--state closed` | Portable closure on GitHub, GitLab, and Jira. Jira selects the available transition whose destination has status category `done`. |
| `--state started` | Jira only. Selects the available transition whose destination has status category `indeterminate` (in progress). Leaves the status unchanged when the issue is already in progress or done, and still posts a requested comment. GitHub and GitLab return a not-supported error. |
| `--transition NAME` | Exact, case-sensitive Jira transition name, such as `Review`. This names an action, not its destination status. |
| `--status NAME` | Exact Jira destination status name. Requires one available transition to that status. |
| `--resolution ID_OR_NAME` | Jira resolution selected from the transition's allowed values. Required when the transition requires a resolution without a default and does not offer exactly one valid allowed value. |
| `--resolution ID_OR_NAME` | Jira resolution selected from the transition's allowed values. Required when the transition requires a resolution without a default and does not offer exactly one valid allowed value (or, for `--state closed`, does not allow the site default resolution). Not accepted with `--state started`. |
| `--comment TEXT` | Optional Markdown explanation. Jira sends it in the same request as the transition; GitHub/GitLab post it after closing. |

`--tracker`, `--project`, `--number`, `--fullsend-dir`, and `--token`
Expand All @@ -356,20 +361,48 @@ its connection settings in the configuration directory. The target project must
other projects are rejected before a client is built.

The command prints JSON with `changed`, and, where available, `transition` and
`status`. Portable closure of an already closed issue returns `changed: false`,
but still posts a requested comment. For Jira, supplying `--resolution` on an
`status`. For Jira `--state`, it also prints `issue_type` and `hierarchy_level`
(`-1` sub-task, `0` standard work, `1` epic, higher above epics) when Jira
reports them. They report the kind of issue the command acted on. A run that
moves the issue builds them after the transition, so they cannot keep an epic
from moving, and the command has no filter or dry run to check the level
beforehand.
Portable closure of an already closed issue returns `changed: false`,
but still posts a requested comment. `--state started` on an issue already in
progress or done also returns `changed: false` and posts a requested comment; a
start never reopens a closed issue. For Jira, supplying `--resolution` on an
already closed issue instead returns an error before posting a comment: no
transition would run to apply that resolution. Explicit named transitions always execute,
including self-transitions. The command does not infer that an unavailable action
means the issue is already at the desired destination.

Jira controls allowed source states and account permissions. The account needs
issue visibility and Transition Issues permission (and permission to add a comment
when one is requested). Zero or multiple matching actions fail without a write.
when one is requested). Zero matching actions fail without a write. Multiple
actions matching `--transition` or `--status` also fail without a write.

`--state` selects by Jira status category, so no status names are configured.
When more than one available action reaches the category, the command prefers
Jira's default status names: `In Progress` for a start, and `Done`, `Closed`,
then `Resolved` for a close. If that does not leave exactly one action (none of
the names is available, or several actions reach the same name), nothing is
written, not even the comment. The command prints a skip that lists the
candidates on stdout, then exits with code 11 so that a script checking only the
exit code sees the issue was not moved. Choose one candidate with `--transition`
or `--status`. Exit code 1 still means any other error, including zero matching
transitions, and a failure to write the JSON takes precedence over code 11. A
successful transition and an already-satisfied state still exit 0. Example skip
output:

```json
{"changed":false,"skipped":true,"reason":"2 Jira transitions on \"PROJ-42\" fit lifecycle state \"started\" ...","candidates":[{"transition":"Review","status":"Review"},{"transition":"Code","status":"Coding"}],"issue_type":"Bug","hierarchy_level":0}
```

When Jira requires a resolution without a default, the command selects it
automatically only if the allowed-values list contains exactly one valid ID.
Otherwise, supply `--resolution`; the command never chooses among different
resolution meanings. A supplied `--comment` satisfies a required comment on the
For `--state closed`, it otherwise sends the site default resolution when the
transition allows it. Otherwise, supply `--resolution`; the command never
chooses among different resolution meanings. A supplied `--comment` satisfies a required comment on the
transition screen. Jira validates other required fields against the existing
issue values. If a required field is missing, Jira rejects the transition and
the command reports the API error. Complete those fields in Jira before retrying.
Expand Down
88 changes: 73 additions & 15 deletions internal/cli/issues_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,45 @@ type issuesTransitionConfig struct {

// issueTransitionResult is the CLI JSON representation of a tracker result.
type issueTransitionResult struct {
Changed bool `json:"changed"`
Transition string `json:"transition,omitempty"`
Status string `json:"status,omitempty"`
Changed bool `json:"changed"`
Transition string `json:"transition,omitempty"`
Status string `json:"status,omitempty"`
Skipped bool `json:"skipped,omitempty"`
Reason string `json:"reason,omitempty"`
Candidates []issueTransitionCandidate `json:"candidates,omitempty"`
IssueType string `json:"issue_type,omitempty"`
HierarchyLevel *int `json:"hierarchy_level,omitempty"`
}

// issueTransitionCandidate is one Jira transition listed in a skipped result.
type issueTransitionCandidate struct {
Transition string `json:"transition"`
Status string `json:"status"`
}

func newIssuesTransitionCmd() *cobra.Command {
var cfg issuesTransitionConfig
cmd := &cobra.Command{
Use: "transition",
Short: "Transition an issue through its tracker workflow",
Long: `Close an issue with --state closed, or select an exact Jira transition
name with --transition or target status with --status. Exactly one selector
is required. Jira resolves a unique available action and accepts --resolution
when the workflow requires it. A required resolution is selected automatically
only when Jira offers exactly one valid allowed value and no default. No arbitrary
workflow action or resolution is chosen.
Long: `Close an issue with --state closed, start a Jira issue with --state started,
or select an exact Jira transition name with --transition or target status with
--status. Exactly one selector is required. Jira resolves a unique available
action and accepts --resolution when the workflow requires it.

On Jira, --state picks the available transition whose target status category is
"indeterminate" (started) or "done" (closed), so no status names are configured.
--state started leaves the status unchanged on an issue already in progress or
done, and still posts a requested comment. When several transitions fit, the
Jira default status name wins: In Progress for a start, then Done, Closed,
Resolved for a close. If that still leaves more than one, nothing is written,
the JSON result with "skipped": true lists the candidates on stdout, and the
command exits with code 11. Zero matching transitions is an ordinary error.

A required resolution is selected automatically only when Jira offers exactly
one valid allowed value and no default, or, for --state closed, when the site
default resolution is among the allowed values. No arbitrary workflow action or
resolution is chosen.

An optional --comment is sent in the same request as the Jira transition, or after closing
on GitHub/GitLab. A comment failure on a forge leaves the issue closed and
Expand All @@ -59,7 +82,7 @@ returns an error. Inspect the issue after an uncertain failure before retrying.`
cmd.Flags().IntVar(&cfg.number, "number", 0, "issue number (required)")
cmd.Flags().StringVar(&cfg.fullsendDir, "fullsend-dir", "", fullsendDirFlagUsage)
cmd.Flags().StringVar(&cfg.token, "token", "", tokenFlagUsage)
cmd.Flags().StringVar(&cfg.opts.State, "state", "", "semantic lifecycle state: closed")
cmd.Flags().StringVar(&cfg.opts.State, "state", "", "semantic lifecycle state: started (Jira only) or closed")
cmd.Flags().StringVar(&cfg.opts.Name, "transition", "", "exact Jira transition name")
cmd.Flags().StringVar(&cfg.opts.Status, "status", "", "exact Jira target status name")
cmd.Flags().StringVar(&cfg.opts.Resolution, "resolution", "", "Jira resolution ID or name allowed by the transition")
Expand Down Expand Up @@ -110,9 +133,44 @@ func runIssuesTransition(ctx context.Context, cfg *issuesTransitionConfig) error
if out == nil {
out = os.Stdout
}
return json.NewEncoder(out).Encode(issueTransitionResult{
Changed: result.Changed,
Transition: result.Transition,
Status: result.Status,
})
var candidates []issueTransitionCandidate
Comment thread
fullsend-ai-coder[bot] marked this conversation as resolved.
Resolved
for _, c := range result.Candidates {
candidates = append(candidates, issueTransitionCandidate{Transition: c.Transition, Status: c.Status})
}
if err := json.NewEncoder(out).Encode(issueTransitionResult{
Changed: result.Changed,
Transition: result.Transition,
Status: result.Status,
Skipped: result.Skipped,
Reason: result.Reason,
Candidates: candidates,
IssueType: result.IssueType,
HierarchyLevel: result.HierarchyLevel,
}); err != nil {
return err
}
// The skip JSON is printed first so a caller can read the candidates. An
// ambiguous skip then fails with its own exit code, because the command could
// not choose and the issue was not moved. Other skips stay successful.
if result.Ambiguous {
return &transitionAmbiguousError{reason: result.Reason}
}
return nil
}

// TransitionAmbiguousExitCode is the process exit code used when --state matches
// several Jira transitions and none is singled out by a default status name. The
// skip JSON is still printed on stdout. It differs from 1 (any other error) and
// StaleHeadExitCode so a script can handle the ambiguity on its own.
const TransitionAmbiguousExitCode = 11

// transitionAmbiguousError reports an ambiguous --state skip. It carries
// TransitionAmbiguousExitCode through the ExitCode() hook in main.go.
type transitionAmbiguousError struct{ reason string }

func (e *transitionAmbiguousError) Error() string {
return "issue not transitioned: " + e.reason
}

// ExitCode returns TransitionAmbiguousExitCode.
func (e *transitionAmbiguousError) ExitCode() int { return TransitionAmbiguousExitCode }
Loading
Loading