docs/task-workflow.md

Task review and selection

New tasks carry a complete track-prefixed ID and a confirmed priority:

id: "DEV-003"
title: Fix settings persistence
status: ready
kind: code
priority: high

Design uses DSGN-003 and kind: design. The suffixes may match because the counters are independent; references, reservations and locks always use the complete identity. An ID is not a priority or a timestamp. See allocation and lookup for exact matching, reservation contention, rollover and old numeric IDs.

Review before choosing

Run /factory:tasks without arguments to see a Markdown table of all tasks: ID, title, track, priority, status, and blocker/next action. A bundled script builds it from the task headers (status, depends_on, implements, reviewer, approach, approval, delivery.manual_checks, delivery.pr) and locks/, so every run gives the same table for the same catalog and PR states; delivery uses the same script to choose a task automatically. With --prs, which /factory:tasks passes, the script reads every recorded PR's state on GitHub with one gh query per repository, shows it for done tasks (done; PR #42 merged into main) and lists under To settle the code tasks whose PR was merged while they weren't done. /factory:tasks then runs the settle script, which checks each one itself (merge into the integration branch, local and remote branch, checkouts, manual checks, definition changes), marks those it safely can done and reports every reason for the rest under Needs attention. The overview script stays read-only; only the settle script writes task records. Apart from settling, no catalog initialization, writes, locks, migrations or task execution occurs. When gh is missing or can't read a PR, the overview says so in a note and settles nothing. Missing metadata is shown explicitly, not repaired. Current lock owners and inaccessible evidence are reported when known; the overview cannot promise a stable snapshot while another session writes.

The shared selection contract orders eligible ready tasks by urgent, high, normal, low, then prefix and numeric suffix. For example, eligible DEV-010 with high priority comes before normal DEV-002; an urgent task with an unresolved dependency does not bypass that dependency. Delivery selects within its own track; the overview may suggest one task across tracks. Neither substitutes priority for approval.

Use /factory:deliver DEV-010 or /factory:design deliver DSGN-003 to explicitly request a task. Selection never grants missing definition or human visual approval. Delivery re-reads the record under its normal lock; a changed status, dependency or priority may require reassessment. Existing building/reviewing work resumes from recorded branches and artifact revisions, not a newly derived prefixed path. To change a done code task, for example after PR review, ask /factory:deliver DEV-010 to reopen it: it goes back through build, the full gate, review and the STR run on the new head, and its open PR is updated. A task whose branch is already merged is not reopened; define a new task for the change instead.

During definition, confirm the priority with the task scope. When follow-ups arrive, reassess pending order with the developer without interrupting active work. A priority-only edit requires a developer decision, the existing task lock and an append-only log of old/new value and reason; it does not redefine scope or renew approvals.

Compatibility boundary

Projects with tasks from before 0.5.0 run the 0.5.0 release migration once. It renames 003 to DEV-003 or DSGN-003 by kind, keeping the suffix, records legacy_id: "003", and sets priority: normal on tasks without one. Branches, handoffs, log history, journal entries and approval evidence keep the old ID as history. Afterwards, an old numeric ID given by the developer resolves only through an exact legacy_id match. Until the migration runs, the overview shows numeric records as unmigrated, and definition, delivery and allocation stop. Missing priority on a new record stays unknown, not normal, and prevents automatic selection when it makes the ready-task ranking incomplete.

Projects with tasks from before 0.6.0 also run the 0.6.0 release migration once. It moves workflow references from body sections into the header and adds depends_on (and approach for design). Until then, the overview shows those tasks as eligibility unknown: missing … (run /factory:migrate 0.6.0) and makes no automatic recommendation that would depend on them.

Maintainer verification scenarios

Use disposable fixture catalogs, never live consumer records. Instruction-contract tests check the templates, routing and safety requirements; they do not prove runtime agent obedience. The overview script's rows of this table run automatically in tests/tasks-overview.test.mjs. For an interactive trial, provide the actual fixture checkout and invoke the skill through the selected adapter. Compare catalog contents before/after a read-only overview, and report unavailable interactive coverage rather than claiming these scenarios were executed:

Fixture / action Expected result
Fresh catalog; define one task per track Reserve DEV-001 and DSGN-001 independently; confirm priority before ready.
Highest reservation is DEV-009, including an abandoned definition Next code task is DEV-010; design counter is unaffected.
Two allocators contend for DEV-010 Only one atomic mkdir succeeds; the other advances; non-contention errors stop.
Last suffix is 999 Next ID is 1000, without lexical sorting or extra zero padding.
High DEV-010, normal DEV-002, urgent but blocked DEV-011 Suggest eligible DEV-010, not the lowest suffix or blocked urgent task.
Equal-priority DEV-999, DEV-1000, DSGN-001 Use integer suffix within each prefix; cross-track tie-break is deterministic.
Unmigrated ready task 003 without priority Show it as unmigrated with unknown priority; no global auto-recommendation, no writes.
Duplicate ID, mismatched kind/filename, unreadable or malformed record Report identity/coverage errors; do not silently select around uncertain ready work.
No catalog; request overview Report no tasks without creating directories or checkpoints.
Reviewing design; checking, waiting-for-approval or blocked code; done task; occupied task lock Show the state/owner or next human decision, not new execution.
--prs: done tasks with merged, open and closed PRs; a building task whose PR was merged, locked or with a pending check Show each PR's state; list the building task to settle with its reasons; one gh query per repository; notes, not failure, without gh.
settle.mjs: a listed task whose local or remote branch has a commit the PR didn't merge, or a dirty checkout Leave it unsettled under Needs attention; never reopen it or open another PR.
The recorded PR of a reopened task is merged during its delivery Finish doesn't set done or open another PR; the developer settles it through settle.
A reopened task's criteria changed before its old PR was merged Leave it unsettled under Needs attention (definition changed); a follow-up task carries the change.
Design-dependent code lacks exact human approval evidence Mark it ineligible even if priority is urgent.
New urgent follow-up while another task is building Reassess pending work; no interruption, status change or automatic launch.
Developer asks for 003 after migration; DEV-003 has legacy_id: "003" and a recorded branch Resolve to DEV-003 through legacy_id, name it, and resume from the recorded branch; never suffix-match.
Original Markdown, including metadata
# Task review and selection

New tasks carry a complete track-prefixed ID and a confirmed priority:

```yaml
id: "DEV-003"
title: Fix settings persistence
status: ready
kind: code
priority: high
```

Design uses `DSGN-003` and `kind: design`. The suffixes may match because the counters are independent; references, reservations and locks always use the complete identity. An ID is not a priority or a timestamp. See [allocation and lookup](../skills/task-ids.md) for exact matching, reservation contention, rollover and old numeric IDs.

## Review before choosing

Run `/factory:tasks` without arguments to see a Markdown table of all tasks: ID, title, track, priority, status, and blocker/next action. A bundled script builds it from the task headers (`status`, `depends_on`, `implements`, `reviewer`, `approach`, `approval`, `delivery.manual_checks`, `delivery.pr`) and `locks/`, so every run gives the same table for the same catalog and PR states; delivery uses the same script to choose a task automatically. With `--prs`, which `/factory:tasks` passes, the script reads every recorded PR's state on GitHub with one `gh` query per repository, shows it for `done` tasks (`done; PR #42 merged into main`) and lists under **To settle** the code tasks whose PR was merged while they weren't `done`. `/factory:tasks` then runs the [settle script](../skills/settle/settle.mjs), which checks each one itself (merge into the integration branch, local and remote branch, checkouts, manual checks, definition changes), marks those it safely can `done` and reports every reason for the rest under **Needs attention**. The overview script stays read-only; only the settle script writes task records. Apart from settling, no catalog initialization, writes, locks, migrations or task execution occurs. When `gh` is missing or can't read a PR, the overview says so in a note and settles nothing. Missing metadata is shown explicitly, not repaired. Current lock owners and inaccessible evidence are reported when known; the overview cannot promise a stable snapshot while another session writes.

The [shared selection contract](../skills/task-priorities.md) orders eligible ready tasks by `urgent`, `high`, `normal`, `low`, then prefix and numeric suffix. For example, eligible `DEV-010` with high priority comes before normal `DEV-002`; an urgent task with an unresolved dependency does not bypass that dependency. Delivery selects within its own track; the overview may suggest one task across tracks. Neither substitutes priority for approval.

Use `/factory:deliver DEV-010` or `/factory:design deliver DSGN-003` to explicitly request a task. Selection never grants missing definition or human visual approval. Delivery re-reads the record under its normal lock; a changed status, dependency or priority may require reassessment. Existing building/reviewing work resumes from recorded branches and artifact revisions, not a newly derived prefixed path. To change a `done` code task, for example after PR review, ask `/factory:deliver DEV-010` to reopen it: it goes back through build, the full gate, review and the STR run on the new head, and its open PR is updated. A task whose branch is already merged is not reopened; define a new task for the change instead.

During definition, confirm the priority with the task scope. When follow-ups arrive, reassess pending order with the developer without interrupting active work. A priority-only edit requires a developer decision, the existing task lock and an append-only log of old/new value and reason; it does not redefine scope or renew approvals.

## Compatibility boundary

Projects with tasks from before 0.5.0 run the [0.5.0 release migration](migrations/0.5.0-release.md) once. It renames `003` to `DEV-003` or `DSGN-003` by kind, keeping the suffix, records `legacy_id: "003"`, and sets `priority: normal` on tasks without one. Branches, handoffs, log history, journal entries and approval evidence keep the old ID as history. Afterwards, an old numeric ID given by the developer resolves only through an exact `legacy_id` match. Until the migration runs, the overview shows numeric records as unmigrated, and definition, delivery and allocation stop. Missing priority on a new record stays unknown, not normal, and prevents automatic selection when it makes the ready-task ranking incomplete.

Projects with tasks from before 0.6.0 also run the [0.6.0 release migration](migrations/0.6.0-release.md) once. It moves workflow references from body sections into the header and adds `depends_on` (and `approach` for design). Until then, the overview shows those tasks as `eligibility unknown: missing … (run /factory:migrate 0.6.0)` and makes no automatic recommendation that would depend on them.

## Maintainer verification scenarios

Use disposable fixture catalogs, never live consumer records. Instruction-contract tests check the templates, routing and safety requirements; they do not prove runtime agent obedience. The overview script's rows of this table run automatically in `tests/tasks-overview.test.mjs`. For an interactive trial, provide the actual fixture checkout and invoke the skill through the selected adapter. Compare catalog contents before/after a read-only overview, and report unavailable interactive coverage rather than claiming these scenarios were executed:

| Fixture / action | Expected result |
| --- | --- |
| Fresh catalog; define one task per track | Reserve `DEV-001` and `DSGN-001` independently; confirm priority before ready. |
| Highest reservation is `DEV-009`, including an abandoned definition | Next code task is `DEV-010`; design counter is unaffected. |
| Two allocators contend for `DEV-010` | Only one atomic mkdir succeeds; the other advances; non-contention errors stop. |
| Last suffix is 999 | Next ID is 1000, without lexical sorting or extra zero padding. |
| High `DEV-010`, normal `DEV-002`, urgent but blocked `DEV-011` | Suggest eligible `DEV-010`, not the lowest suffix or blocked urgent task. |
| Equal-priority `DEV-999`, `DEV-1000`, `DSGN-001` | Use integer suffix within each prefix; cross-track tie-break is deterministic. |
| Unmigrated ready task `003` without priority | Show it as unmigrated with unknown priority; no global auto-recommendation, no writes. |
| Duplicate ID, mismatched kind/filename, unreadable or malformed record | Report identity/coverage errors; do not silently select around uncertain ready work. |
| No catalog; request overview | Report no tasks without creating directories or checkpoints. |
| Reviewing design; checking, waiting-for-approval or blocked code; done task; occupied task lock | Show the state/owner or next human decision, not new execution. |
| `--prs`: done tasks with merged, open and closed PRs; a building task whose PR was merged, locked or with a pending check | Show each PR's state; list the building task to settle with its reasons; one `gh` query per repository; notes, not failure, without `gh`. |
| `settle.mjs`: a listed task whose local or remote branch has a commit the PR didn't merge, or a dirty checkout | Leave it unsettled under **Needs attention**; never reopen it or open another PR. |
| The recorded PR of a reopened task is merged during its delivery | Finish doesn't set `done` or open another PR; the developer settles it through settle. |
| A reopened task's criteria changed before its old PR was merged | Leave it unsettled under **Needs attention** (definition changed); a follow-up task carries the change. |
| Design-dependent code lacks exact human approval evidence | Mark it ineligible even if priority is urgent. |
| New urgent follow-up while another task is building | Reassess pending work; no interruption, status change or automatic launch. |
| Developer asks for `003` after migration; `DEV-003` has `legacy_id: "003"` and a recorded branch | Resolve to `DEV-003` through `legacy_id`, name it, and resume from the recorded branch; never suffix-match. |