---
description: Autonomous per-ticket pipeline that chains ticket-work, local-review, PR creation, test-iterate loop, CI watching, PR review loop, integration verification gate, and auto-merge into a single unattended workflow with Slack notifications and policy guardrails
mode: full
version: 6.0.0
level: intermediate
debug: false
category: workflow
tags:
  - pipeline
  - automation
  - linear
  - tickets
  - review
  - pr
  - slack
  - ci
  - merge
  - cross-repo
author: OmniClaude Team
args:
  - name: ticket_id
    description: Linear ticket ID (e.g., OMN-1804)
    required: true
  - name: --skip-to
    description: Resume from specified phase (pre_flight|generate_contract|implement|enrich_contract|local_review|dod_verify|test_coverage_gate|create_pr|test_iterate|ci_watch|pr_review_loop|review_gate|integration_verification_gate|auto_merge|worktree_cleanup)
    required: false
  - name: --dry-run
    description: Execute phase logic and log decisions without side effects
    required: false
  - name: --skip-test-iterate
    description: Skip the test-iterate phase entirely
    required: false
  - name: --auto-merge
    description: Force auto_merge=true
    required: false
  - name: --docs-only
    description: Assert all changes are documentation-only; skips integration verification
    required: false
---

# Ticket Pipeline

## Tools Required (OMN-8708)

Workers running `ticket-pipeline` run in fresh sessions where dispatch tools are **deferred**.
If a `ticket-pipeline` worker needs to spawn sub-agents (e.g. a verifier agent), it must
fetch the schema at session start:

```
ToolSearch(query="select:Agent,SendMessage,TaskCreate,TaskUpdate,TaskGet", max_results=5)
```

Dispatch prompts from `epic-team` include this step automatically. Standalone invocations
from headless or cron contexts must include it explicitly.

**Announce at start:** "I'm using the ticket-pipeline skill."

## Usage

```
/ticket-pipeline OMN-1234
/ticket-pipeline OMN-1234 --dry-run
/ticket-pipeline OMN-1234 --skip-to ci_watch
/ticket-pipeline OMN-1234 --skip-test-iterate
/ticket-pipeline OMN-1234 --require-gate
/ticket-pipeline OMN-1234 --docs-only
```

## Execution

### Step 1 — Parse arguments

- `ticket_id` → Linear ticket ID (required)
- `--skip-to` → resume from phase (auto-detected from state file if omitted)
- `--dry-run` → no commits, pushes, or PRs
- `--skip-test-iterate` → skip test-fix loop (for infra-dependent tests)
- `--auto-merge` / `--require-gate` → merge policy override

### Step 2 — Initialize FSM

Primary path (bus-driven):

```bash
onex run-node node_ticket_pipeline \
  --input '{"ticket_id": "<ticket_id>", "skip_to": null, "skip_test_iterate": false, "dry_run": false}' \
  --timeout 300
```

Fallback path (local/offline):

```bash
onex node node_ticket_pipeline --input <json_file>
```

Where `<json_file>` contains `ModelPipelineStartCommand` JSON matching the payload fields above.

On non-zero exit, a `SkillRoutingError` JSON envelope is returned — surface it directly, do not produce prose. Outputs `ModelPipelineState` JSON with initial phase.

### Step 3 — Execute phases

Run each phase in sequence, advancing the FSM via `handler.advance()`. For each phase:

1. **PRE_FLIGHT**: Load ticket contract from Linear, validate repo target, check environment
2. **IMPLEMENT**: Execute ticket work (delegates to ticket-work skill)
3. **LOCAL_REVIEW**: Run local-review loop until N consecutive clean passes
4. **CREATE_PR**: Create PR via `gh pr create`, enable auto-merge
5. **TEST_ITERATE**: Fix failing tests up to `--max-test-iterations` cycles
6. **CI_WATCH**: Poll CI until green or timeout; auto-fix failures
7. **PR_REVIEW**: Address CodeRabbit + human review comments
8. **AUTO_MERGE**: Wait for merge queue; verify merged
9. **WORKTREE_CLEANUP**: Verify and remove safe per-ticket worktrees before Done

Circuit breaker halts after 3 consecutive phase failures → FAILED state.

### Step 4 — Report

Display final pipeline state: phase reached, PR URL, any errors, cycle counts.

## Phases

| Phase | FSM State | Description |
|-------|-----------|-------------|
| PRE_FLIGHT | → IMPLEMENT | Load contract, validate env |
| IMPLEMENT | → LOCAL_REVIEW | Execute ticket work |
| LOCAL_REVIEW | → CREATE_PR | Clean review passes |
| CREATE_PR | → TEST_ITERATE | Open PR |
| TEST_ITERATE | → CI_WATCH | Fix test failures |
| CI_WATCH | → PR_REVIEW | Wait for green CI |
| PR_REVIEW | → AUTO_MERGE | Address comments |
| AUTO_MERGE | → WORKTREE_CLEANUP | Merge queue |
| WORKTREE_CLEANUP | → DONE | Remove safe ticket worktrees or block with Linear note |

## Architecture

```
SKILL.md   -> thin shell (this file)
node       -> omnimarket/src/omnimarket/nodes/node_ticket_pipeline/ (FSM logic)
contract   -> node_ticket_pipeline/contract.yaml
```
