# Track Specification: Manual Ticket Queue Management (ticket_queue_mgmt_20260306)

## Overview
Allow user to manually reorder, prioritize, or requeue tickets in the DAG. Add drag-drop reordering, priority tags, and bulk selection for execute/skip/block operations.

## Current State Audit

### Already Implemented (DO NOT re-implement)

#### Ticket Model (src/models.py)
- **`Ticket` dataclass**: Has `status`, `depends_on`, but no `priority` field
- **`mark_blocked(reason)`**: Sets status to blocked with reason
- **`mark_complete()`**: Sets status to completed

#### DAG Engine (src/dag_engine.py)
- **`TrackDAG`**: Manages ticket dependency graph
- **`get_ready_tasks()`**: Returns tasks with satisfied dependencies
- **`update_task_status()`**: Updates ticket status
- **`has_cycle()`**: Validates DAG

### Gaps to Fill (This Track's Scope)
- No `priority` field on Ticket
- No drag-drop reordering in GUI
- No multi-select for bulk operations
- No bulk execute/skip/block actions

## Architectural Constraints

### DAG Validity
- Reordering MUST NOT violate dependencies
- Cannot move ticket before its dependencies
- `depends_on` relationships preserved

### Atomic Operations
- Bulk operations apply to all selected tickets atomically
- Partial failure rolls back all changes

## Architecture Reference

### Key Integration Points

| File | Lines | Purpose |
|------|-------|---------|
| `src/models.py` | 30-50 | `Ticket` - add priority field |
| `src/gui_2.py` | 2650-2750 | Ticket display - add drag-drop |
| `src/dag_engine.py` | 50-80 | Status updates |

### Proposed Ticket Enhancement
```python
@dataclass
class Ticket:
 # ... existing fields ...
 priority: str = "medium"  # "high" | "medium" | "low"
```

## Functional Requirements

### FR1: Priority Field
- Add `priority: str = "medium"` to Ticket dataclass
- Values: "high", "medium", "low"
- Persist in track state

### FR2: Priority UI
- Dropdown or button group per ticket
- Color-coded: high=red, medium=yellow, low=gray
- Save to state on change

### FR3: Drag-Drop Reordering
- Drag ticket to reorder in list
- Drop validates DAG (no dependency violation)
- Show error if invalid position

### FR4: Multi-Select
- Checkbox per ticket for selection
- Select all / deselect all buttons
- Track selected ticket IDs

### FR5: Bulk Actions
- Execute: Mark all selected as ready
- Skip: Mark all selected as completed
- Block: Mark all selected as blocked

## Non-Functional Requirements

| Requirement | Constraint |
|-------------|------------|
| Response Time | <100ms for drag-drop validation |
| Persistence | Priority saved to state.toml |

## Testing Requirements

### Unit Tests
- Test priority field serialization
- Test DAG validation on reorder

### Integration Tests
- Drag-drop tickets, verify order changes
- Bulk block tickets, verify all blocked

## Out of Scope
- Automatic priority assignment
- Priority-based auto-scheduling
- Cross-track ticket movement

## Acceptance Criteria
- [ ] Priority field added to Ticket
- [ ] Priority dropdown works in UI
- [ ] Drag-drop reordering functional
- [ ] DAG validity enforced on drop
- [ ] Multi-select with checkboxes
- [ ] Bulk execute/skip/block works
- [ ] 1-space indentation maintained
