# Task Resolution

After project detection builds a [`ProjectProfile`](/xtarterize/contributing/core/detect/), xtarterize resolves which tasks are relevant and what their current status is.

## Resolution Pipeline

```
ProjectProfile → resolveTasks() → applicable tasks → resolveTaskStatuses() → status map
```

### `resolveTasks(profile, allTasks)`

Filters the full task registry to only those where `task.applicable(profile)` returns `true`. This is a pure synchronous filter — no I/O, no side effects.

```typescript
import { resolveTasks } from '@xtarterize/core'

const applicable = resolveTasks(profile, getAllTasks())
// → only tasks whose conditions are met
```

### `resolveTaskStatuses(tasks, cwd, profile)`

Runs `task.check()` for each applicable task in parallel and returns a `Map<taskId, TaskStatus>`. Each task determines its own status by inspecting the filesystem.

```typescript
import { resolveTaskStatuses } from '@xtarterize/core'

const statuses = await resolveTaskStatuses(applicable, cwd, profile)
// → Map<string, 'new' | 'patch' | 'skip' | 'conflict'>
```

The four statuses drive which tasks appear as actionable:

| Status | Meaning | Actionable for `init` | Actionable for `sync` |
|--------|---------|----------------------|----------------------|
| `new` | Config doesn't exist yet | Yes | No |
| `patch` | Config exists, can be updated | Yes | Yes |
| `skip` | Already conformant | No | No |
| `conflict` | Incompatible changes needed | Only if explicitly selected | Only if explicitly selected |

## Task Gating Logic

Each task's `applicable()` method checks `ProjectProfile` properties:

```typescript
// TypeScript tasks: only if project uses TS
applicable: (profile) => profile.typescript

// Vite plugin tasks: only if bundler is Vite
applicable: (profile) => profile.bundler === 'vite'

// CI tasks: only if GitHub detected
applicable: (profile) => profile.hasGitHub

// Turbo task: only if monorepo uses Turborepo
applicable: (profile) => profile.monorepoTool === 'turbo'
```

Task statuses are evaluated in parallel via `Effect.all`, making resolution efficient even with many tasks.

## References

- [Task interface](/xtarterize/contributing/tasks/overview/)
- [Project detection](/xtarterize/contributing/core/detect/)
- [Task factory](/xtarterize/contributing/tasks/overview/#task-factory)