# internal/core/lifecycle

Package lifecycle defines allowed task state transitions.

## TerminalEvidenceTimeout

```go
const TerminalEvidenceTimeout = 30 * time.Second
```

TerminalEvidenceTimeout bounds best-effort repair writes after an external provider returns or the caller context is already canceled.

## Draft

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Approved

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Active

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Blocked

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Review

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Completed

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Failed

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## Cancelled

```go
const (
	// Draft is the editable pre-approval state.
	Draft State = "draft"
	// Approved is the state after approval but before execution.
	Approved State = "approved"
	// Active is the execution state.
	Active State = "active"
	// Blocked is the state after execution or review finds blocking work.
	Blocked State = "blocked"
	// Review is the adversarial review gate state.
	Review State = "review"
	// Completed is the terminal successful state.
	Completed State = "completed"
	// Failed is the terminal unsuccessful state.
	Failed State = "failed"
	// Cancelled is the terminal abandoned state.
	Cancelled State = "cancelled"
)
```

## CanTransition

```go
func CanTransition(from State, to State) bool
```

CanTransition reports whether the lifecycle transition is allowed.

## TerminalEvidenceContext

```go
func TerminalEvidenceContext(parent context.Context) (context.Context, context.CancelFunc)
```

TerminalEvidenceContext returns a short-lived context for recording terminal gate evidence. It intentionally detaches from caller cancellation so a timed out provider attempt does not strand the task in an in-progress state.

## State

```go
type State string
```

State names a lifecycle state in the task workflow.
