state-machine
Task lifecycle state transitions with validation gates. Defines states, triggers, and required proofs.
What this skill does
plugin: autopilot
updated: 2026-01-20
# Task Lifecycle State Machine
**Version:** 0.1.0
**Purpose:** Manage task state transitions with validation gates
**Status:** Phase 1
## When to Use
Use this skill when you need to:
- Understand valid state transitions for tasks
- Implement validation gates before state changes
- Handle iteration loops (In Review -> In Progress)
- Manage escalation to blocked state
- Enforce iteration limits
## States
```
Todo ──→ In Progress ──→ In Review ──→ Done
↑ │
└───────────┘
(iteration)
In Progress ──→ Blocked (escalation)
```
## State Definitions
| State | Description | Entry Condition |
|-------|-------------|-----------------|
| Todo | Task queued for execution | Created with @autopilot label |
| In Progress | Task being executed | Passed start gate |
| In Review | Awaiting validation | Proof generated |
| Done | Task completed | Auto-approved or user approved |
| Blocked | Cannot proceed | Dependency issue or escalation |
## Transition Triggers
| From | To | Trigger | Gate |
|------|----|---------|------|
| Todo | In Progress | Label @autopilot added | Has acceptance criteria |
| In Progress | In Review | Work complete | Proof >= 80% confidence |
| In Review | Done | Confidence >= 95% | Auto-approval |
| In Review | Done | User approves | User feedback = APPROVAL |
| In Review | In Progress | Confidence < 80% | Validation failed |
| In Review | In Progress | User requests changes | Feedback = REQUESTED_CHANGES |
| In Progress | Blocked | Max iterations | Escalation |
| * | Blocked | Unresolvable blocker | Manual trigger |
## Validation Gates
### Gate 1: Start Work (Todo -> In Progress)
```typescript
async function canStartWork(issue: Issue): Promise<boolean> {
const checks = [
// Has acceptance criteria
extractAcceptanceCriteria(issue.description).length > 0,
// No blocking dependencies
(await getBlockingIssues(issue)).length === 0,
// Assigned to autopilot
issue.assignee?.id === AUTOPILOT_BOT_USER_ID,
];
return checks.every(c => c);
}
```
### Gate 2: Submit for Review (In Progress -> In Review)
```typescript
async function canSubmitForReview(proof: Proof): Promise<boolean> {
const checks = [
// All tests pass
proof.testResults.passed === proof.testResults.total,
// Build successful
proof.buildSuccessful,
// No lint errors
proof.lintErrors === 0,
// Has proof artifacts
proof.screenshots.length > 0 || proof.deploymentUrl,
];
return checks.every(c => c);
}
```
### Gate 3: Complete (In Review -> Done)
```typescript
async function canComplete(proof: Proof): Promise<{
canProceed: boolean;
autoApproved: boolean;
}> {
if (proof.confidence >= 95) {
return { canProceed: true, autoApproved: true };
}
if (proof.confidence >= 80) {
return { canProceed: false, autoApproved: false };
// Wait for user approval
}
return { canProceed: false, autoApproved: false };
// Validation failed, should iterate
}
```
## Iteration Limits
| Loop Type | Max Iterations | Escalation |
|-----------|----------------|------------|
| Execution retry | 2 | Block task |
| Feedback rounds | 5 | Manual intervention |
| Quality check fixes | 2 | Report to user |
## Implementation
```typescript
class StateMachine {
async transition(
issueId: string,
targetState: string,
proof?: Proof
): Promise<void> {
const issue = await linear.issue(issueId);
const currentState = issue.state.name;
// Validate transition
const isValid = this.validateTransition(currentState, targetState, proof);
if (!isValid) {
throw new Error(`Invalid transition: ${currentState} -> ${targetState}`);
}
// Execute transition
await linear.issueUpdate(issueId, {
stateId: await this.getStateId(issue.team.id, targetState),
});
// Log transition
await this.logTransition(issueId, currentState, targetState, proof);
}
private validateTransition(
from: string,
to: string,
proof?: Proof
): boolean {
const validTransitions: Record<string, string[]> = {
'Todo': ['In Progress', 'Blocked'],
'In Progress': ['In Review', 'Blocked'],
'In Review': ['Done', 'In Progress'],
'Blocked': ['Todo', 'In Progress'],
};
return validTransitions[from]?.includes(to) ?? false;
}
}
```
## State Transition Diagram
```
┌─────────────────────────────┐
│ │
▼ │
┌──────┐ ┌─────────────┐ ┌───────────┴───┐ ┌──────┐
│ Todo │ ────► │ In Progress │ ────► │ In Review │ ────► │ Done │
└──────┘ └─────────────┘ └───────────────┘ └──────┘
│ │ │
│ │ │
│ ▼ │
│ ┌─────────┐ │
└────────► │ Blocked │ ◄─────────────────┘
└─────────┘
```
## Examples
### Example 1: Happy Path
```typescript
// Task created
await transitionState(issueId, 'In Progress'); // Gate: Has acceptance criteria
// Work complete, proof generated
await transitionState(issueId, 'In Review'); // Gate: Proof >= 80%
// High confidence auto-approval
await transitionState(issueId, 'Done'); // Gate: Confidence >= 95%
```
### Example 2: Iteration Loop
```typescript
// First attempt
await transitionState(issueId, 'In Progress');
await transitionState(issueId, 'In Review'); // Confidence: 85%
// User requests changes
await transitionState(issueId, 'In Progress'); // Feedback: REQUESTED_CHANGES
// Second attempt
await transitionState(issueId, 'In Review'); // Confidence: 97%
await transitionState(issueId, 'Done'); // Auto-approved
```
### Example 3: Escalation
```typescript
// After 5 feedback rounds
if (iterationCount >= MAX_FEEDBACK_ROUNDS) {
await transitionState(issueId, 'Blocked');
await addComment(issueId, "Escalated: Max iterations reached");
}
```
## Best Practices
- Always validate before transitioning
- Log all transitions for audit trail
- Include proof artifacts when transitioning to In Review
- Enforce iteration limits to prevent infinite loops
- Escalate gracefully rather than failing silently
- Comment on Linear when state changes for visibility
Related in Productivity
gitea-workflow
IncludedOrchestrate agile development workflows for Gitea repositories using the tea CLI. Use when working with Gitea-hosted repos and asking to 'run the workflow', 'continue working', 'what's next', 'complete the task cycle', 'start my day', 'end the sprint', 'implement the next task', or wanting guided step-by-step development assistance. Keywords: workflow, orchestrate, agile, task cycle, sprint, daily, implement, review, PR, standup, retrospective, gitea, tea.
microsoft-graph-gateway
IncludedRoute Microsoft Graph work in this workspace. Use when users want to read or write Outlook mail, calendar events, contacts, OneDrive or SharePoint files, Teams, Planner, To Do, users, groups, directory data, or arbitrary Microsoft Graph endpoints from VS Code. Prefer WorkIQ for common read scenarios. Use Microsoft Graph for write actions and gap-read scenarios that need exact Graph properties, filters, permissions, or endpoints.
copilotkit
IncludedUse when building with CopilotKit — setup, development, integrations, debugging, upgrading, or contributing. Routes to the appropriate specialized skill based on the task.
wordly-wisdom
IncludedProvides calibrated decision analysis using Charlie Munger-style multiple mental models, inversion, incentive mapping, circle-of-competence checks, misjudgment audits, second-order effects, and forecast updates. Use when the user asks for an oracle take, a hard call, a decision memo, a premortem, an outside view, a red-team, a sanity-check, what am I missing, think this through, or wants a strategy, hire, investment, plan, product, partnership, or major life choice analysed. Avoid for simple factual lookups or time-sensitive legal, medical, or market questions without fresh evidence.
swain-session
IncludedSession management and project status dashboard. Owns the full session lifecycle (start/work/close/resume), focus lane, bookmarks, worktree detection, and tab naming. Also serves as the project status dashboard — shows active epics, progress, actionable next steps, blocked items, tasks, GitHub issues, and recommendations. Worktree creation is deferred to swain-do task dispatch (SPEC-195). Triggers on: 'session', 'status', 'what's next', 'dashboard', 'overview', 'where are we', 'what should I work on', 'show me priorities', 'bookmark', 'focus on', 'session info'.
gandi
IncludedComprehensive Gandi domain registrar integration for domain and DNS management. Register and manage domains, create/update/delete DNS records (A, AAAA, CNAME, MX, TXT, SRV, and more), configure email forwarding and aliases, check SSL certificate status, create DNS snapshots for safe rollback, bulk update zone files, and monitor domain expiration. Supports multi-domain management, zone file import/export, and automated DNS backups. Includes both read-only and destructive operations with safety controls.