arreio 1.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +81 -0
  2. package/package.json +42 -0
  3. package/scripts/postinstall.js +50 -0
  4. package/skills/arreio-init/SKILL.md +214 -0
  5. package/skills/arreio-init/references/architecture-template.md +85 -0
  6. package/skills/arreio-init/references/learn-index-template.md +15 -0
  7. package/skills/arreio-init/references/plan-index-template.md +29 -0
  8. package/skills/arreio-init/references/tasks-index-template.md +15 -0
  9. package/skills/learn/SKILL.md +151 -0
  10. package/skills/learn/modules/capture.md +108 -0
  11. package/skills/learn/modules/index.md +94 -0
  12. package/skills/learn/modules/maintain.md +116 -0
  13. package/skills/learn/modules/refine.md +104 -0
  14. package/skills/learn/references/dedup-rules.md +129 -0
  15. package/skills/learn/references/entry-schema.md +152 -0
  16. package/skills/learn/references/error-handling.md +178 -0
  17. package/skills/learn/references/id-generation.md +114 -0
  18. package/skills/learn/references/index-format.md +140 -0
  19. package/skills/learn/references/interaction-mode-propagation.md +89 -0
  20. package/skills/learn/references/migration-bootstrap.md +142 -0
  21. package/skills/learn/references/templates/artifacts/captured-entry.md +172 -0
  22. package/skills/learn/references/templates/artifacts/index-update.md +135 -0
  23. package/skills/learn/references/templates/artifacts/learn-input.md +100 -0
  24. package/skills/learn/references/templates/artifacts/maintain-log.md +142 -0
  25. package/skills/learn/references/templates/artifacts/refined-entry.md +168 -0
  26. package/skills/plan/SKILL.md +129 -0
  27. package/skills/plan/modules/design.md +140 -0
  28. package/skills/plan/modules/generate.md +156 -0
  29. package/skills/plan/modules/research.md +122 -0
  30. package/skills/plan/modules/scope.md +121 -0
  31. package/skills/plan/modules/tasks.md +190 -0
  32. package/skills/plan/references/design-complexity-assessment.md +118 -0
  33. package/skills/plan/references/error-handling.md +155 -0
  34. package/skills/plan/references/external-research-guidance.md +61 -0
  35. package/skills/plan/references/high-risk-detection.md +111 -0
  36. package/skills/plan/references/id-generation.md +55 -0
  37. package/skills/plan/references/interaction-mode-propagation.md +75 -0
  38. package/skills/plan/references/learnings-gate-logic.md +93 -0
  39. package/skills/plan/references/plan-tier-selection.md +174 -0
  40. package/skills/plan/references/task-slicing-rules.md +220 -0
  41. package/skills/plan/references/templates/artifacts/design.md +134 -0
  42. package/skills/plan/references/templates/artifacts/final-plan.md +265 -0
  43. package/skills/plan/references/templates/artifacts/research-findings.md +50 -0
  44. package/skills/plan/references/templates/artifacts/scoped-context.md +53 -0
  45. package/skills/plan/references/templates/artifacts/task.md +192 -0
  46. package/skills/plan/references/templates/artifacts/user-input.md +112 -0
  47. package/skills/review/SKILL.md +163 -0
  48. package/skills/review/modules/analyze.md +104 -0
  49. package/skills/review/modules/prepare.md +103 -0
  50. package/skills/review/modules/report.md +109 -0
  51. package/skills/review/modules/scope.md +126 -0
  52. package/skills/review/references/approval-criteria.md +101 -0
  53. package/skills/review/references/change-set-resolution.md +126 -0
  54. package/skills/review/references/error-handling.md +172 -0
  55. package/skills/review/references/id-generation.md +80 -0
  56. package/skills/review/references/interaction-mode-propagation.md +80 -0
  57. package/skills/review/references/review-categories.md +124 -0
  58. package/skills/review/references/scope-creep-detection.md +120 -0
  59. package/skills/review/references/severity-rubric.md +107 -0
  60. package/skills/review/references/templates/artifacts/findings.md +161 -0
  61. package/skills/review/references/templates/artifacts/review-input.md +116 -0
  62. package/skills/review/references/templates/artifacts/review-kit.md +135 -0
  63. package/skills/review/references/templates/artifacts/review-report.md +175 -0
  64. package/skills/review/references/templates/artifacts/review-scope.md +146 -0
  65. package/skills/work/SKILL.md +163 -0
  66. package/skills/work/modules/execute.md +109 -0
  67. package/skills/work/modules/prepare.md +140 -0
  68. package/skills/work/modules/review.md +164 -0
  69. package/skills/work/modules/triage.md +181 -0
  70. package/skills/work/references/ad-hoc-input-resolution.md +122 -0
  71. package/skills/work/references/error-handling.md +183 -0
  72. package/skills/work/references/execution-mode-selection.md +95 -0
  73. package/skills/work/references/id-generation.md +85 -0
  74. package/skills/work/references/interaction-mode-propagation.md +80 -0
  75. package/skills/work/references/review-checklist.md +94 -0
  76. package/skills/work/references/task-execution-rules.md +116 -0
  77. package/skills/work/references/templates/artifacts/execution-log.md +123 -0
  78. package/skills/work/references/templates/artifacts/execution-plan.md +111 -0
  79. package/skills/work/references/templates/artifacts/work-input.md +78 -0
  80. package/skills/work/references/templates/artifacts/work-manifest.md +119 -0
  81. package/skills/work/references/templates/artifacts/work-report.md +143 -0
@@ -0,0 +1,140 @@
1
+ ---
2
+ title: Prepare
3
+ description: Set up the execution environment, assemble the ordered execution list from the Work Manifest, select an execution mode (inline/serial/parallel), select the per-task gates from task-execution-rules, and return an Execution Plan for the Execute phase.
4
+ type: module
5
+ version: 1.0
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 2 - Prepare
10
+
11
+ **Purpose:** Second step in the Work workflow. Reads the [Work Manifest](../references/templates/artifacts/work-manifest.md) from Triage, verifies the test execution environment and establishes a green baseline, assembles the ordered execution list from the manifest's `ready-tasks`, selects an execution mode, and selects the per-task quality gates (Red → Green → Refactor) and resume/blocked/skip policy from their authoritative references — without re-encoding them. Returns an [Execution Plan](../references/templates/artifacts/execution-plan.md) that the Execute phase consumes.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 2 pipeline for the Work Skill. It orchestrates the following steps:
16
+
17
+ ### Step 0: Verification
18
+
19
+ Run the **[Step 0 verification](../references/error-handling.md)**. Required input: a valid **Work Manifest** from Triage. Specifically verify:
20
+
21
+ 1. The Work Manifest carries `triage-id`, `work-id`, `input-shape`, `interactionMode`, the resolved task list, and `ready-tasks`.
22
+ 2. Every manifest task preserves the `/plan` invariants (one Acceptance Criterion → one `files.test` → Red → Green → Refactor steps).
23
+ 3. `interactionMode` is present and valid (default to `smart` if missing; log warning).
24
+ 4. Cross-phase consistency: `work-id` matches the Triage output; `interactionMode` is identical across artifacts.
25
+
26
+ If the manifest reports `work-state: nothing-ready` (no runnable task), do **not** abort — Prepare still runs Steps 1–4 to produce an Execution Plan that records the empty run; the Review phase handles the outcome.
27
+
28
+ ### Step 1: Verify the Test Execution Environment
29
+
30
+ 1. **Detect the test runner** from config files in repository root:
31
+
32
+ | Tech Stack | Config File(s) | Test Command (capability) |
33
+ | ---------- | ------------------------------------- | ----------------------------------- |
34
+ | Node.js (npm) | `package.json` + `package-lock.json`; `scripts.test`, or `jest`/`vitest`/`mocha` in deps | `npm test` / `npx jest` / `npx vitest` |
35
+ | Node.js (pnpm) | `package.json` + `pnpm-lock.yaml`; `scripts.test`, or `jest`/`vitest`/`mocha` in deps | `pnpm test` / `pnpm exec jest` / `pnpm exec vitest` |
36
+ | Python | `pyproject.toml` / `pytest.ini` / `setup.cfg` | `pytest` |
37
+ | Go | `go.mod` + `*_test.go` | `go test ./...` |
38
+ | Rust | `Cargo.toml` | `cargo test` |
39
+ | Ruby | `Gemfile` (rspec/minitest) | `bundle exec rspec` |
40
+ | PHP | `composer.json` (phpunit) | `vendor/bin/phpunit` |
41
+ | Java/Kotlin | `pom.xml` / `build.gradle` | `mvn test` / `gradle test` |
42
+
43
+ **Node.js package manager detection:** read lockfiles to pick npm vs pnpm — `package-lock.json` → npm; `pnpm-lock.yaml` → pnpm. If both lockfiles exist, prefer the one that matches `package.json`'s `packageManager` field; if that is also unset, ask the user which to use. Record `packageManager: npm | pnpm` for Execute so every test/install command uses it consistently.
44
+
45
+ If NO config files match, record `runner: unknown` and ask the user for the project's test command before proceeding.
46
+
47
+ 2. **Establish a green baseline.** Run the existing test suite (or the targeted test path covering the tasks in scope) to confirm the suite runs and is green. Record `baseline: green` (exit clean) or `baseline: red` (pre-existing failures).
48
+ - **If `baseline: red`:** do not proceed silently. This is a Smart pause trigger — ask the user one question:
49
+ ```
50
+ The existing test suite is currently red (<N> failures), so later regressions cannot be detected reliably.
51
+ What would you like to do?
52
+ - Fix baseline first: Resolve the pre-existing failures before running Work
53
+ - Snapshot & continue: Record the currently-failing tests as the known-baseline; Execute only flags *new* regressions
54
+ - Abort: Stop and return to the Orchestrator
55
+ ```
56
+ - On **Snapshot & continue**, record the set of known-failing tests in the Execution Plan so Execute's regression gate ignores them (per the `snapshot & continue` policy in [task-execution-rules.md](../references/task-execution-rules.md)).
57
+
58
+ 3. **Verify each `files.test` path resolves** against the working directory (or will be created by Red — a not-yet-existing test path is valid for a Red step). Only surface a problem if the *directory* the test should live in doesn't exist and can't be created. Do not create files here; Execute writes tests.
59
+
60
+ ### Step 2: Assemble the Ordered Execution List
61
+
62
+ 1. **Take `ready-tasks`** from the Work Manifest (already dependency-filtered in Triage Step 4). Preserve the manifest's dependency order — do not re-sort.
63
+ 2. **Group into execution waves** (used only if Step 3 selects `parallel`):
64
+ - **Wave 0** — tasks with all dependencies already `completed` (the manifest's `ready-tasks` with satisfied deps).
65
+ - **Wave N** — tasks all of whose dependencies are in Waves `< N`; each wave is independent internally and can run concurrently.
66
+ - Within a wave, order by original unit number for stable output.
67
+ 3. Record the ordered list (flat for `inline`/`serial`; wave-grouped for `parallel`) as `execution-list`. If `input-shape: task-file` with the user having chosen **Proceed anyway**, the list is still the single task — record `upstream-skipped: true`.
68
+
69
+ ### Step 3: Select Execution Mode
70
+
71
+ Select how `execution-list` is run. The three modes are defined canonically in **[execution-mode-selection.md](../references/execution-mode-selection.md)** — this step looks them up, it does not re-derive them:
72
+
73
+ | Mode | Behavior | Default when |
74
+ | ---------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
75
+ | `inline` | One task at a time; pause between tasks; re-confirm the user before each destructive step. | `interactionMode: detailed`, **or** any `P0`/HIGH-risk task is in the list |
76
+ | `serial` | Run the ordered list sequentially; no per-task pause (still stops on a blocked task). | Default fallback — most task lists |
77
+ | `parallel` | Run each wave's independent tasks concurrently (waves run in order). | `execution-list` has 2+ independent waves **and** none is HIGH-risk |
78
+
79
+ 1. **Compute the default** from the table above, reading each task's `priority` and any HIGH-risk flag carried from the manifest.
80
+ 2. **Apply the risk floor (authoritative in [execution-mode-selection.md](../references/execution-mode-selection.md)):** any HIGH-risk task forces `inline` for that task; the user may not downgrade a HIGH-risk task below `inline`.
81
+ 3. **Determine user preference:**
82
+ - **Detailed:** ask the user which mode to run, presenting the recommendation.
83
+ - **Smart:** auto-select, unless a pause trigger fires (Step 7).
84
+ - **Autopilot:** auto-select; never ask.
85
+ 4. **Honor user preference** unless it violates the risk floor; on violation, ask the user to accept `inline` instead.
86
+ 5. Record `executionMode: inline | serial | parallel` and the per-mode flow (`single-task-pause: true` for inline; `waves: [...]` for parallel).
87
+
88
+ ### Step 4: Select Per-Task Gates and Resume Policy
89
+
90
+ Select the gates and transitions Execute will enforce. Their definitions are authoritative in **[task-execution-rules.md](../references/task-execution-rules.md)** — this step records which gates apply and the thresholds, it does not re-encode the rules:
91
+
92
+ 1. **Per-task gates** (record the applicable set):
93
+ - **Red** — the new test in `files.test` exists and **fails for the right reason** (not a setup/import/compile error).
94
+ - **Green** — the task's single Acceptance-Criterion test now passes, with no new regression beyond the Step 1 baseline.
95
+ - **Refactor** — the test stays green after cleanup, with no regression.
96
+ - **Complete transition** — frontmatter `status → completed`; the task file's `## Acceptance Criteria` checkbox flips to `- [x]`; the index checklist ticks forward (`- [ ]` → `- [x]`).
97
+ 2. **Resume policy (authoritative in [task-execution-rules.md](../references/task-execution-rules.md)):**
98
+ - Re-entry reads each task file's `status`; a `completed` task is skipped (never re-opened, checkboxes never reset).
99
+ - `blocked` and `skipped` tasks are carried with their recorded reasons; they are not auto-retried.
100
+ 3. **Blocked transition (record the thresholds; definitions in [task-execution-rules.md](../references/task-execution-rules.md)):** if the Green gate isn't reached within the documented retry limit, the task → `blocked` with a recorded reason and a per-task snapshot of the failing assertion. Execute pauses (per mode) before the next task.
101
+ 4. **Skip transition:** skipping a task requires explicit user confirmation (never auto-skip); the index checkbox stays `- [ ]` and the reason is recorded.
102
+
103
+ Record the selected `applicable-gates` and thresholds (retry-limit, regression policy from Step 1) in the Execution Plan so Execute enforces them read-only.
104
+
105
+ ### Step 5: Generate the Execution Plan Artifact
106
+
107
+ 1. **Assign a `prepare-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-prepare`, saved to `docs/plans/.work/.prepare/`). Reuse it if the user later picks **Edit & Retry**.
108
+
109
+ 2. Produce an **Execution Plan** block (as markdown) following the schema in [execution-plan.md](../references/templates/artifacts/execution-plan.md). Include:
110
+ - `prepare-id`, inherited `triage-id` and `work-id`, `input-shape`
111
+ - `interactionMode` and `executionMode`
112
+ - the `execution-list` (flat or wave-grouped)
113
+ - `runner` + test command, `baseline` (`green` | `red` | `snapshot-and-continue`), and any known-failing test snapshot
114
+ - `applicable-gates`, retry-limit, and resume/blocked/skip policy (read from [task-execution-rules.md](../references/task-execution-rules.md))
115
+ - `work-state` (echo `nothing-ready` if the manifest carried it)
116
+
117
+ ### Step 6: Present, Confirm, and Save
118
+
119
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these prepare-specific **Smart pause triggers**:
120
+
121
+ - `baseline: red` and the user has not yet chosen a baseline policy (Step 1), or
122
+ - `executionMode: parallel` on an execution list of > 5 tasks (concurrency risk), or
123
+ - A HIGH-risk task is present but the selected `executionMode` would not give it `inline` treatment (risk-floor conflict pre-override).
124
+
125
+ - **Detailed:** present the Execution Plan and ask one question with options *(1) Proceed to Execute, (2) Edit & Retry, (3) Abort*. On **Edit & Retry**, loop back through Steps 1–5 reusing the `prepare-id`. On **Abort**, stop and inform the Orchestrator.
126
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
127
+ - **Autopilot:** auto-proceed (no confirmation).
128
+
129
+ Then save the artifact to `docs/plans/.work/.prepare/<prepare-id>.md` (ensure `interactionMode` and `executionMode` are included) and return it, with both mode values, to the Orchestrator for the transition to Phase 3 (Execute).
130
+
131
+ ## Output: Execution Plan Artifact
132
+
133
+ - Verify that the Execution Plan is complete and valid: `prepare-id`, `triage-id`, `work-id`, `input-shape`, `interactionMode`, `executionMode`, `execution-list`, `runner`, `baseline`, `applicable-gates`, and resume/blocked/skip policy.
134
+ - Verify that `executionMode` is consistent with the interaction mode and the risk floor in [execution-mode-selection.md](../references/execution-mode-selection.md) (HIGH-risk → `inline`).
135
+ - Verify that the gate/policy details were **read from** [task-execution-rules.md](../references/task-execution-rules.md) rather than re-encoded inline (no second formula contradicting the authoritative reference).
136
+ - Verify that `execution-list` preserves the manifest's dependency order (no task before its dependencies) and that wave-grouping (if `parallel`) respects dependency layers.
137
+ - Verify that the `baseline` policy is recorded (a red baseline was surfaced, not hidden).
138
+ - Verify that the artifact is saved to `docs/plans/.work/.prepare/<prepare-id>.md`.
139
+
140
+ > Pass the Execution Plan to `execute` (Phase 3) for the test-first execution run.
@@ -0,0 +1,164 @@
1
+ ---
2
+ title: Review
3
+ description: Close the Work workflow by reviewing the Execution Log run simplification/consolidation (definitions authoritative in review-checklist), running a whole-work-id regression check, detecting scope creep against the Work Manifest, surfacing learnings for /learn, and gating task status to for-review (if regressions/creep detected) or completed (if clean). Updates task file frontmatter status and appends the closing Work Report status block to the task index.
4
+ type: module
5
+ version: 1.0
6
+ timestamp: "2026-08-12"
7
+ ---
8
+
9
+ # Phase 4 - Review
10
+
11
+ **Purpose:** Fourth and final step in the Work workflow. Reads the [Execution Log](../references/templates/artifacts/execution-log.md) from Execute, reviews the executed code for simplification and consolidation, runs a whole-`work-id` test-regression check, detects any scope creep against the Work Manifest, and surfaces new learnings for the Learn skill (`/learn`) to persist. Appends the closing `## Work Report — <review-id>` status block to `docs/tasks/<work-id>/index.md`. Returns a [Work Report](../references/templates/artifacts/work-report.md) as the Work skill's final deliverable.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 4 pipeline for the Work Skill. It orchestrates the following steps:
16
+
17
+ ### Step 0: Verification
18
+
19
+ Run the **[Step 0 verification](../references/error-handling.md)**. Required input: a valid **Execution Log** from Execute. Specifically verify:
20
+
21
+ 1. The Execution Log carries `execute-id`, `prepare-id`, `triage-id`, `work-id`, `input-shape`, `interactionMode`, `executionMode`, the per-task result table, and the aggregator counts.
22
+ 2. **Task-status coherence** (the orchestrator's quality gate #4): every task ended `completed`, `blocked` (with a recorded reason), or `skipped` (with a recorded reason) — none left `in-progress` — and `docs/tasks/<work-id>/index.md` checklist state matches the task files' frontmatter `status`. Execute is responsible for leaving this coherent; Review re-verifies and refuses to proceed (Category 2 recovery) if not.
23
+ 3. `interactionMode` is present and valid (default to `smart` if missing; log warning).
24
+ 4. Cross-phase consistency: `work-id`, `triage-id`, `prepare-id`, `execute-id` match the upstream artifacts.
25
+
26
+ If the run was empty (`work-state: nothing-ready` was carried through), Review still produces a Work Report recording that no task was runnable — do not abort.
27
+
28
+ ### Step 1: Simplify and Consolidate
29
+
30
+ Review the code touched by the `completed` tasks for simplification and consolidation. The definitions and the per-check criteria are authoritative in **[review-checklist.md](../references/review-checklist.md)** — Review applies the checklist, it does not re-encode it. Run its checks across the changed files (those listed in the completed tasks' `files.create` / `files.modify`):
31
+
32
+ - **Dead code / duplication** — remove code made unreachable or duplicated by the run; honor DRY by extracting shared logic.
33
+ - **Naming and structure** — tighten intention-revealing names; collapse overlarge functions/classes to single responsibility; no speculative generality.
34
+ - **Boundary isolation** — keep side effects at the boundaries; prefer pure functions where the changes permit it.
35
+
36
+ Apply each change as a **refactor** — the relevant tasks' AC tests must stay green; if any targeted check would change behavior, treat it as scope creep (Step 3) rather than a refactor, and do not apply it here.
37
+
38
+ Record `simplification-summary` (what was simplified/clipped) and `consolidations` (any merged logic / extracted abstractions) in the Work Report.
39
+
40
+ ### Step 2: Whole-Work-Id Regression Check
41
+
42
+ 1. Run the full test suite for the `work-id`'s affected scope (the union of the `completed` tasks' test paths, plus any files they modified that are covered elsewhere) using the Execute-resolved test command (`runner` + `packageManager`).
43
+ 2. **Compare against the Prepare baseline** recorded in the Execution Plan:
44
+ - `baseline: green` — the suite must still be green; **any failure is a regression** (binary threshold: one failure = gate fails).
45
+ - `baseline: snapshot-and-continue` — failures must be a subset of the recorded known-failing snapshot; any **new** failure is a regression.
46
+ 3. Record `regression-check: clean | regressions-found` with the failing-test list if any. A regression found here is a gate trigger: if regressions exist, task status enters `for-review` (Step 4a).
47
+
48
+ ### Step 3: Scope-Creep Detection
49
+
50
+ Compare the executed work against the Work Manifest's resolved task list and each task's single Acceptance Criterion:
51
+
52
+ 1. **Per-task scope** — for each `completed` task, confirm the change in `files.create` / `files.modify` is bounded by **that task's single AC**. Edits beyond the AC (extra files touched, behavior not asserted by `files.test`) are scope creep.
53
+ 2. **Manifest scope** — confirm no task was added, removed, or silently expanded beyond what Triage resolved. (A `dependency-warning: expanded-to-upstream` from the task-file shape is expected, not creep.)
54
+ 3. Record `scope-creep` findings per task (file path + why it exceeds the AC), or `scope-creep: none`. Surface any creep to the user — never fold it silently into a task.
55
+
56
+ ### Step 4: Scope-Creep Detection (Detailed)
57
+
58
+ Compare the executed work against the Work Manifest's resolved task list and each task's single Acceptance Criterion:
59
+
60
+ 1. **Per-task scope** — for each `completed` task, confirm the change in `files.create` / `files.modify` is bounded by **that task's single AC**. Edits beyond the AC (extra files touched, behavior not asserted by `files.test`) are scope creep.
61
+ 2. **Manifest scope** — confirm no task was added, removed, or silently expanded beyond what Triage resolved. (A `dependency-warning: expanded-to-upstream` from the task-file shape is expected, not creep.)
62
+ 3. Record `scope-creep` findings per task (file path + why it exceeds the AC), or `scope-creep: none`. Surface any creep to the user — never fold it silently into a task. Scope-creep findings are a gate trigger (Step 4a).
63
+
64
+ ### Step 4a: Gate Decision — For-Review vs. Completed
65
+
66
+ **Binary gate:** Decide task status based on the outcomes of Steps 2–3.
67
+
68
+ If **any** of the following conditions is true, set `task-status-target: for-review` (tasks will enter `status: for-review` in Step 6):
69
+
70
+ - `regression-check: regressions-found` (any test failure)
71
+ - `scope-creep` findings exist (any file/behavior exceeds AC)
72
+
73
+ Otherwise, set `task-status-target: completed` (tasks will move to `status: completed`).
74
+
75
+ Record this decision with a brief summary: e.g., "Gate passed: clean regression check, no scope creep" or "Gate blocked: regressions-found (3 new failures) + scope creep in 2 files".
76
+
77
+ ### Step 5: Learnings Capture
78
+
79
+ Surface new learnings discovered during execution for the Learn skill to persist (Work does not write `docs/learn/` directly):
80
+
81
+ 1. For each notable finding — a confirmed pattern, a refuted assumption, a gotcha hit, or a decision forced by the run — record a learning candidate with: a working title, the domain, the source (task-id + gate where found), and a 1–2 sentence summary.
82
+ 2. Carry the Work Manifest's `Learning Gaps` forward; add any gaps the run revealed (e.g., a missing test pattern that forced a workaround).
83
+ 3. Record `learnings-to-capture` (candidates) and `learning-gaps` in the Work Report. The user is prompted (per interaction mode) to run `/learn` to persist them (orthogonal to approval gates).
84
+
85
+ ### Step 6: Generate the Work Report Artifact
86
+
87
+ 1. **Assign a `review-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-review`, saved to `docs/plans/.work/.review/`). Reuse it if the user later picks **Edit & Retry**.
88
+
89
+ 2. Produce a **Work Report** block (as markdown) following the schema in [work-report.md](../references/templates/artifacts/work-report.md). Include:
90
+ - `review-id`, inherited `execute-id`, `prepare-id`, `triage-id`, `work-id`, `input-shape`
91
+ - `interactionMode` and `executionMode` (both carried)
92
+ - the final task-outcome rollup (echo Execute's aggregator counts: `completed` / `blocked` / `skipped`)
93
+ - `simplification-summary` and `consolidations`
94
+ - `regression-check` (`clean` | `regressions-found` + failing list)
95
+ - `scope-creep` findings (or `none`)
96
+ - `learnings-to-capture` and `learning-gaps`
97
+ - a final `work-state`:
98
+ - `for-review`: tasks gated to `status: for-review` (regressions or scope-creep detected; pending Standalone Review approval)
99
+ - `complete`: all tasks `completed` and regression-clean (gate passed)
100
+ - `partial`: some tasks `blocked`/`skipped` but progress made (all non-blocked tasks passed gate)
101
+ - `nothing-done`: empty run or all blocked early
102
+
103
+ ### Step 7: Update Task File Frontmatter and Register the Work Report
104
+
105
+ **Update task file status:**
106
+ For each task affected by the Work run (based on `task-status-target` from Step 4a):
107
+
108
+ 1. Open `docs/tasks/<work-id>/T<NN>-<name>.md`
109
+ 2. Update the frontmatter `status:` field:
110
+ - If `task-status-target: for-review` → set `status: for-review`
111
+ - If `task-status-target: completed` → set `status: completed` (as before)
112
+ 3. Idempotent: re-running Review with the same `review-id` overwrites the status (never duplicates).
113
+
114
+ **Append status block to task index:**
115
+ Append the closing status block to `docs/tasks/<work-id>/index.md` (the task index Triage created / Execute updated). The block records the final state next to the checklist, so a future glance shows how the run ended:
116
+
117
+ ```markdown
118
+ ## Work Report — <review-id>
119
+
120
+ - **Status:** complete | partial | for-review | nothing-done
121
+ - **Tasks:** <completed>/<total> completed, <for-review> for-review, <blocked> blocked, <skipped> skipped
122
+ - **Regression check:** clean | regressions-found (<N>)
123
+ - **Scope creep:** none | <count> finding(s)
124
+ - **Learnings to capture:** <count> (run `/learn` to persist)
125
+ - **Work Report:** docs/plans/.work/.review/<review-id>.md
126
+ ```
127
+
128
+ If the index does not exist (ad-hoc input that somehow lost its index), create it with the checklist before appending the block. The block is **append-only** and idempotent on `review-id` (a re-run overwrites the block with the same `review-id`, never duplicates).
129
+
130
+ ### Step 8: Present, Confirm, and Save
131
+
132
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these review-specific **Smart pause triggers**:
133
+
134
+ - `task-status-target: for-review` (gate blocked; tasks will enter for-review), or
135
+ - `regression-check: regressions-found` (any test failures detected), or
136
+ - `scope-creep` findings exist (confirm the creep is intentional or roll it back), or
137
+ - `learnings-to-capture` is non-empty and the user may want to capture them now via `/learn` before closing.
138
+
139
+ - **Detailed:** present the Work Report and ask one question with options _(1) Finalize Work, (2) Edit & Retry, (3) Abort_. On **Edit & Retry**, loop back through Steps 1–7 reusing the `review-id` (the index block is overwritten, not duplicated, because it keys on `review-id`). On **Abort**, stop and inform the Orchestrator.
140
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
141
+ - **Autopilot:** auto-proceed (no confirmation).
142
+
143
+ Then save the artifact to `docs/plans/.work/.review/<review-id>.md` (ensure `interactionMode` and `executionMode` are included).
144
+
145
+ ### Step 9: Return to Orchestrator
146
+
147
+ Return the Work Report to the Orchestrator — `path`, `review-id`, `work-id`, `work-state`, `task-status-target`, `interactionMode`, `executionMode`, and `learnings-to-capture` count. The Orchestrator marks the Work workflow complete.
148
+
149
+ **Next steps (user-facing):**
150
+
151
+ - If `work-state: for-review`, inform the user: "Tasks have entered `for-review` status. Run `/review <work-id>` to audit them before final approval."
152
+ - Optionally chain to the Learn skill (`/learn <work-id>` or `/learn <candidate-ref>`) when `learnings-to-capture` is non-empty; otherwise the session ends.
153
+
154
+ ## Output: Work Report Artifact
155
+
156
+ - Verify that the Work Report is complete and valid: `review-id`, `execute-id`, `prepare-id`, `triage-id`, `work-id`, `input-shape`, `interactionMode`, `executionMode`, the task-outcome rollup, `simplification-summary`, `consolidations`, `regression-check`, `scope-creep`, `learnings-to-capture`, and `learning-gaps`.
157
+ - Verify that **task-status coherence** held: the Execution Log's outcomes match `docs/tasks/<work-id>/index.md` and the task files' frontmatter (re-verified in Step 0).
158
+ - Verify that task files' frontmatter `status:` fields were updated to `for-review | completed` per the gate decision (Step 4a).
159
+ - Verify that the `## Work Report — <review-id>` block was appended to `docs/tasks/<work-id>/index.md` and is idempotent on `review-id` (no duplicate blocks).
160
+ - Verify that the simplification/consolidation/scope-creep/learnings rules were **applied from** [review-checklist.md](../references/review-checklist.md) rather than re-encoded inline.
161
+ - Verify that `work-state` reflects the gate outcome: `for-review | complete | partial | nothing-done`.
162
+ - Verify that the artifact is saved to `docs/plans/.work/.review/<review-id>.md`.
163
+
164
+ > The Work Report is the primary deliverable of the Work Skill. Tasks entering `for-review` status signal that Standalone Review approval is required before moving to `completed`. The Orchestrator marks the workflow complete; user runs `/review <work-id>` next if tasks are in `for-review`; optionally chains to `/learn` when learnings were surfaced (orthogonal to approval gates).
@@ -0,0 +1,181 @@
1
+ ---
2
+ title: Triage
3
+ description: Classify work input (plan-id, task file, or ad-hoc description), resolve it into a unified, dependency-ordered Work Manifest carrying one Acceptance Criterion per task with a Red-first test, and return it for the Prepare phase.
4
+ type: module
5
+ version: 1.0
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 1 - Triage & Work Input Resolution
10
+
11
+ **Purpose:** Entry point to the Work workflow. Classifies the incoming work input (a plan-id, a single task file, or an ad-hoc description), resolves it into a unified, dependency-ordered **Work Manifest** — one task per Acceptance Criterion, each carrying its own Red → Green → Refactor test — establishes the git work branch (`work/<short-description>`) for the run, and returns it for the Prepare phase to sequence and select an execution mode.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 1 pipeline for the Work Skill. It orchestrates the following steps:
16
+
17
+ ### Step 0: Verification
18
+
19
+ Run the **[Step 0 verification](../references/error-handling.md)**. Required input: a valid **Work Input Artifact** (see [work-input.md](../references/templates/artifacts/work-input.md)) from the Orchestrator. Specifically verify:
20
+
21
+ 1. The Work Input Artifact carries exactly one of: a `plan-id`, a `task-file path` (or task-id), or an `ad-hoc` description.
22
+ 2. `interactionMode` is present and valid (default to `smart` if missing; log warning).
23
+ 3. The required folders already exist (the Orchestrator's Pre-Flight Check is responsible for creation); do not re-create them here.
24
+
25
+ If the input is empty or ambiguous between shapes, ask the user one question: "What would you like to work on? Provide a plan-id, a task file, or describe the task."
26
+
27
+ ### Step 1: Classify Input Shape
28
+
29
+ Determine which of the three input shapes applies, by precedence:
30
+
31
+ 1. **Plan-based** — the input matches an existing `docs/tasks/<plan-id>/index.md` (the value is a `YYYY-MM-DD-NNN` plan-id, or a path resolving to a `docs/tasks/<id>/index.md`).
32
+ 2. **Task-file** — the input is, or resolves to, a path matching `docs/tasks/<plan-id>/T<NN>-<name>.md`, or a task-id matching `<plan-id>-T<NN>`.
33
+ 3. **Ad-hoc** — the input is a free-text description that matches neither of the above.
34
+
35
+ Record `input-shape: plan-based | task-file | ad-hoc`. If classification is ambiguous (e.g., a string that could be a plan-id or a description), ask the user one question with the candidate shapes as options.
36
+
37
+ ### Step 2: Resolve to Work Manifest (by Shape)
38
+
39
+ Resolve the classified input into a unified **Work Manifest** — a single task list where each entry is keyed by `task-id` and carries `unit`, `acceptance-criterion`, `files`, `dependencies`, `priority`, and current `status`. Each task preserves the `/plan` invariant: exactly one Acceptance Criterion, exactly one `files.test`, Red → Green → Refactor steps.
40
+
41
+ #### 2a. Plan-based
42
+
43
+ 1. Read `docs/tasks/<plan-id>/index.md` and parse the task checklist into an ordered list of task file paths.
44
+ 2. Set `work-id = plan-id` (inherited — never allocate a new id).
45
+ 3. For each task file, parse its frontmatter (`id`, `title`, `plan-id`, `unit`, `status`, `priority`, `dependencies`, `files`, `estimated-effort`) and body sections.
46
+ 4. Build the manifest in **dependency order** using the same topological ordering as the `/plan` Tasks phase (a task never appears before its dependencies). On a cycle, surface the involved tasks and ask the user whether to break the cycle (remove a dependency) or abort.
47
+ 5. Record the full task list. Do **not** filter by status here — resume filtering happens in Step 4.
48
+
49
+ #### 2b. Task-file
50
+
51
+ 1. Locate the single task file. If given a task-id (`<plan-id>-T<NN>`), resolve it to the unique `docs/tasks/<plan-id>/T<NN>-*.md` match (exactly one expected; if multiple match, ask the user to disambiguate).
52
+ 2. Set `work-id = plan-id` inferred from the file's folder.
53
+ 3. Parse the task file into a one-entry manifest.
54
+ 4. Read the task's `dependencies`; for each referenced `task-id`, read that upstream task file's `status`:
55
+ - If **all** upstream tasks are `completed`: no warning; proceed.
56
+ - If **any** upstream task is not `completed`: this is a Smart pause trigger. Ask the user one question:
57
+ ```
58
+ Task <id> depends on <upstream-ids> which are not yet completed.
59
+ What would you like to do?
60
+ - Proceed anyway: Run this task's Red→Green→Refactor cycle now
61
+ - Run upstream first: Execute the missing upstream task(s) before this one
62
+ - Abort: Stop and return to the Orchestrator
63
+ ```
64
+ - **Proceed anyway:** keep the single-task manifest; record `dependency-warning: proceeded-without-upstream`.
65
+ - **Run upstream first:** switch to the plan-based path (Step 2a) scoped to the unmet upstream tasks **plus** this task, in dependency order; record `dependency-warning: expanded-to-upstream`.
66
+ - **Abort:** stop and inform the Orchestrator.
67
+ 5. The manifest contains **only this one task** (plus any upstream tasks the user chose to add). It **never** includes downstream dependents of this task.
68
+
69
+ #### 2c. Ad-hoc
70
+
71
+ 1. Allocate a fresh `work-id` of the form `YYYY-MM-DD-NNN`, counting existing `docs/tasks/YYYY-MM-DD-NNN/` folders for today (per [id-generation.md](../references/id-generation.md)).
72
+
73
+ 2. Resolve the raw description into task-shaped work — **one Acceptance Criterion per task, one test per task, Red-first**. For the resolution rules (problem-frame/intended-behavior collection, AC extraction, test-file assignment, sizing, dependency ordering, priority assignment), see **[ad-hoc-input-resolution.md](../references/ad-hoc-input-resolution.md)**. Minimally:
74
+ - Identify the problem frame and intended behavior from the description; if either is missing or vague, ask the user one question at a time to collect them.
75
+ - Derive 1–3 Acceptance Criteria, **one AC per task**. If a criterion would need > 5 files or > 1 day of effort, split it into finer sub-criteria (mirror the `/plan` task-slicing rules — one test per AC).
76
+ - For each task: assign a dedicated test file, populate `files.create`/`files.modify` from the description, and draft Red → Green → Refactor steps.
77
+ - Order tasks by dependency; assign priorities (`P0` / `P1` / `P2`).
78
+
79
+ Do **not** write any files in this step — task-file materialization is deferred to Step 2e, so the work branch exists before anything is written (Step 2d).
80
+
81
+ #### 2d. Work Branch Creation
82
+
83
+ Every new feature or plan runs on its own git branch. This step runs for all input shapes, after the shape-specific resolution (2a/2b/2c) and **before any file is written** (the dirty-tree check must see the pre-work state).
84
+
85
+ 1. **Verify git repository:** confirm the working directory is inside a git repository (e.g., `git rev-parse --is-inside-work-tree`). If not, record `work-branch: null` with `work-branch-state: not-a-git-repo`, log one explicit warning, and skip the remaining sub-steps — the pipeline continues without a branch.
86
+
87
+ 2. **Derive the branch slug** for `work/<slug>`:
88
+ - plan-based / task-file: from the plan's kebab-case name suffix — `docs/plans/<plan-id>-<slug>.md` or the plan title registered in `docs/plans/index.md`.
89
+ - ad-hoc: from the resolved description — a 2–5 word kebab-case slug naming the work's subject (e.g., "fix login timeout" → `work/fix-login-timeout`).
90
+ - Sanitize: lowercase; replace every character outside `[a-z0-9]` with `-`; collapse repeated `-`; trim leading/trailing `-`; cap at 50 characters. If the result is empty, fall back to the `work-id`.
91
+ - If no slug can be confidently derived (vague ad-hoc description), ask the user one question: "What short name should the work branch use?" (accept the raw text and sanitize it). This is a Smart pause trigger.
92
+
93
+ 3. **Dirty working tree check:** the tree must be clean (`git status --porcelain` empty). If there are uncommitted changes, **fail branch creation with an explicit error** (Category 7 in [error-handling.md](../references/error-handling.md)) and ask the user one question: (a) I've committed/stashed — retry, (b) proceed without a work branch (`work-branch-state: skipped-by-user`), or (c) abort. Never stash, commit, or carry changes silently.
94
+
95
+ 4. **Determine the base branch:** detect the repository's default branch (e.g., resolve `origin/HEAD` → `main`); fall back to an existing `main`, then `master`, then the current HEAD.
96
+
97
+ 5. **Select or create the branch** (idempotent — resume-safe):
98
+ - Already on `work/<slug>` → no-op; `work-branch-state: already-on`.
99
+ - `work/<slug>` exists but is not checked out → check it out; `work-branch-state: checked-out`.
100
+ - Otherwise create it from the base branch (`git checkout -b work/<slug> <base>`); `work-branch-state: created`.
101
+ - When creating and the current HEAD is not the default branch: Smart pause trigger — ask one question: (a) create from the default branch, (b) create from the current HEAD, (c) abort. Autopilot: create from the default branch and log a warning.
102
+
103
+ 6. **Record** `work-branch` (branch name or `null`), `work-branch-base` (base used, or `null`), and `work-branch-state` (`created` | `checked-out` | `already-on` | `skipped-by-user` | `not-a-git-repo`) in the manifest (Step 6).
104
+
105
+ #### 2e. Materialize Ad-Hoc Task Files
106
+
107
+ Ad-hoc shape only (for plan-based/task-file, task files already exist — no-op):
108
+
109
+ 1. Materialize the resolved tasks as task files under `docs/tasks/<work-id>/`:
110
+ - Filename: `T<NN>-<kebab-case-name>.md` (`<NN>` zero-padded, matching dependency order).
111
+ - Schema: the [Task Artifact template](../../plan/references/templates/artifacts/task.md) — set `plan-id` to `work-id`, `status: not-started`; infer `tier` from task count per the `/plan` Fast/Standard/Deep sizing (Fast ≤ 3; Standard 4–8; Deep 8–15), defaulting to `fast`.
112
+ - Create `docs/tasks/<work-id>/index.md` with the `- [ ]` checklist for all tasks (same format as the `/plan` Tasks phase index).
113
+
114
+ 2. Build the manifest by reading the newly created task files back (confirming shape parity with plan-based tasks).
115
+
116
+ ### Step 3: Task Artifact Validation
117
+
118
+ For every task in the resolved manifest, validate it preserves the `/plan` invariants:
119
+
120
+ 1. **One Acceptance Criterion per task** — the task carries exactly one `## Acceptance Criterion` and exactly one `files.test` entry.
121
+ 2. **Red-first steps** — `## Steps` are ordered Red → Green → Refactor, with the failing test written and confirmed before implementation.
122
+ 3. **Repository-relative paths** — all `files` entries are repo-relative and backtick-formatted; `files.test` holds exactly one path.
123
+ 4. **Dependency integrity** — every `dependencies` entry references a `task-id` that exists (in the manifest for plan-based/ad-hoc, or in the parent plan's index for task-file input).
124
+
125
+ On any failure: never silently drop the task. Surface the specific failure and apply the recovery workflow in [error-handling.md](../references/error-handling.md) (Category 2 — Malformed Artifact): for plan-based/task-file, ask the user to fix the task or re-run the relevant `/plan` phase; for ad-hoc, regenerate the offending task from Step 2c.
126
+
127
+ ### Step 4: Dependency & Resume Check
128
+
129
+ 1. Read each manifest task's current `status` from its task file frontmatter.
130
+ 2. **Resume-safe filtering:** a task is `ready` only if all its dependencies are `completed`. Tasks already `completed` are skipped (never re-opened — index checkboxes are ticked forward only). Tasks `blocked` or `skipped` are carried as-is with their recorded reasons.
131
+ 3. Record the manifest's `ready-tasks` (to run this session) and `already-complete-tasks` (carried for the Work Report).
132
+ 4. If **no** task is `ready` (all blocked or already complete), record `work-state: nothing-ready` and proceed to Step 6 — the Work Report will surface that no work was runnable. Do **not** abort; the Review phase handles the empty outcome.
133
+
134
+ ### Step 5: Learnings Index Gate
135
+
136
+ Search `docs/learn/index.md` for entries relevant to the task domains in the manifest. For the matching logic (keyword extraction, exact + fuzzy match, HIGH/MEDIUM/LOW relevance scoring, gap identification, and inclusion), defer to the Plan skill's **[learnings-gate-logic.md](../../plan/references/learnings-gate-logic.md)**.
137
+
138
+ - Add HIGH and MEDIUM relevance learnings to the manifest's `Related Learnings`, scoped **per task** (a learning applies to a task, not the whole manifest — mirror the `/plan` Tasks phase, which embeds learnings in each task's `## Notes`).
139
+ - Identify and document any `Learning Gaps`.
140
+
141
+ > This gate reuses the Plan skill's learnings-matching algorithm; it does not duplicate it. If `docs/learn/index.md` does not exist (arreio-init not yet run), set `Related Learnings` to empty and continue — do not block the work pipeline on a missing learnings index. But log a single explicit warning so the absence is visible rather than silently no-op'd.
142
+
143
+ ### Step 6: Generate the Work Manifest Artifact
144
+
145
+ 1. **Assign a `triage-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-triage`, saved to `docs/plans/.work/.triage/`). Reuse it if the user later picks **Edit & Retry**.
146
+
147
+ 2. Produce a **Work Manifest Artifact** block (as markdown) following the schema in [work-manifest.md](../references/templates/artifacts/work-manifest.md). Include:
148
+ - `triage-id`, `work-id`, `input-shape`, `interactionMode`, `work-branch` (plus `work-branch-base` and `work-branch-state` from Step 2d)
149
+ - the resolved task list (one row per task: `task-id`, `title`, `unit`, `acceptance-criterion`, `priority`, `dependencies`, `status`, `ready?`)
150
+ - `ready-tasks` and `already-complete-tasks`
151
+ - `Related Learnings` (per task) and `Learning Gaps`
152
+ - any `dependency-warning` (task-file shape only)
153
+ - `work-state` (`nothing-ready`, if applicable)
154
+
155
+ ### Step 7: Present, Confirm, and Save
156
+
157
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these triage-specific **Smart pause triggers**:
158
+
159
+ - `input-shape` is `ad-hoc` (the resolved task list was **inferred**, not user-authored — confirm it matches intent), or
160
+ - Task-file input has an unmet upstream dependency (Step 2b warning case), or
161
+ - One or more task artifacts failed validation (Step 3) and required recovery, or
162
+ - The work branch slug could not be derived automatically and was supplied by the user (Step 2d.2), or
163
+ - The current HEAD was not the default branch when the work branch was created (Step 2d.5).
164
+
165
+ - **Detailed:** present the Work Manifest Artifact and ask one question with options *(1) Proceed to Prepare, (2) Edit & Retry, (3) Abort*. On **Edit & Retry**, loop back through Steps 1–6 reusing the `triage-id`. On **Abort**, stop and inform the Orchestrator.
166
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
167
+ - **Autopilot:** auto-proceed (no confirmation).
168
+
169
+ Then save the artifact to `docs/plans/.work/.triage/<triage-id>.md` (ensure `interactionMode` and `input-shape` are included) and return it, with the `interactionMode` value, to the Orchestrator for the transition to Phase 2 (Prepare).
170
+
171
+ ## Output: Work Manifest Artifact
172
+
173
+ - Verify that the Work Manifest Artifact is complete and valid: `triage-id`, `work-id`, `input-shape`, `interactionMode`, the resolved task list, `ready-tasks`, `Related Learnings`, and any `dependency-warning`.
174
+ - Verify that every task in the manifest carries **exactly one Acceptance Criterion**, **exactly one `files.test`**, and **Red → Green → Refactor** steps (Step 3 passed).
175
+ - Verify that the manifest is in **dependency order** — no task appears before its dependencies.
176
+ - Verify that `work-id` is correct for the shape (inherited `plan-id` for plan-based/task-file; freshly allocated for ad-hoc).
177
+ - Verify that `work-branch` is recorded in the manifest and, unless `null`, the repository is checked out on that branch.
178
+ - Verify that for `ad-hoc` input, the task files and `docs/tasks/<work-id>/index.md` were created.
179
+ - Verify that the artifact is saved to `docs/plans/.work/.triage/<triage-id>.md`.
180
+
181
+ > Pass the Work Manifest to `prepare` (Phase 2) for execution-mode selection and sequencing.
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: Ad-Hoc Input Resolution
3
+ description: Authoritative reference for the Triage phase. Defines how a raw work description is resolved into task-shaped work (one Acceptance Criterion per task, one test per task, Red-first), including problem-frame collection, AC extraction, sizing, dependency ordering, and priority assignment.
4
+ type: reference
5
+ version: 1.0
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Ad-Hoc Input Resolution
10
+
11
+ Authoritative reference for the **Triage** phase (Step 2c). Defines how a raw work description (bug, feature, change) is resolved into the same task-shaped work the `/plan` Tasks phase produces — **one Acceptance Criterion per task, one test per task, Red → Green → Refactor** — so ad-hoc work is fully interchangeable with plan-based work downstream.
12
+
13
+ ## Core Rule (mirrors `/plan`)
14
+
15
+ - **One Acceptance Criterion per task.** Each derived task carries exactly one `## Acceptance Criterion` and exactly one `files.test` entry (its own test asserting that criterion).
16
+ - **One test per task.** Never one test asserting multiple criteria. Never one task bundling multiple criteria.
17
+ - **Red-first.** Each task's `## Steps` are ordered Red → Green → Refactor, with the failing test written and confirmed before implementation.
18
+
19
+ ## Resolution Steps
20
+
21
+ ### 1. Collect the Problem Frame and Intended Behavior
22
+
23
+ If the description is missing or vague on either, ask the user one question at a time:
24
+
25
+ 1. **Problem Frame:** "What problem are you trying to solve? Describe it in 1–2 sentences." (maps to the task's `## Goal`)
26
+ 2. **Intended Behavior:** "What should happen after this is implemented? Describe the desired outcome." (maps to the observable outcome)
27
+ 3. **Success Criteria:** "How will we know this is complete? What specific outcomes define success?" Collect 1–3 criteria.
28
+
29
+ If both are present and concrete from the description, extract them and skip the prompts.
30
+
31
+ ### 2. Extract Acceptance Criteria
32
+
33
+ Derive 1–3 Acceptance Criteria from the success criteria — **one AC per task**. Phrase each as a single, verifiable outcome (not a bundle). If a criterion would need > 5 files or > 1 day of effort, **split it into finer sub-criteria** (each its own task) rather than slicing a task partway through a criterion (mirror the `/plan` task-slicing Rule 2). Sub-IDs use letters: `U1` → `T01a`, `T01b` (never extra digits).
34
+
35
+ ### 3. Assign Files Per Task
36
+
37
+ For each task, populate from the description and a read of the codebase:
38
+
39
+ - `files.create` — new files the implementation needs.
40
+ - `files.modify` — existing files touched.
41
+ - `files.test` — **exactly one** dedicated test file for this task's single AC; resolved repo-relative.
42
+
43
+ At least one of `create`, `modify`, or `test` must be non-empty. All paths repository-relative, backtick-formatted in the task file.
44
+
45
+ ### 4. Draft Steps (Red → Green → Refactor)
46
+
47
+ For each task, draft the three steps:
48
+
49
+ 1. **Red** — write the failing test in `files.test[0]` asserting this AC; confirm it fails for the right reason.
50
+ 2. **Green** — implement the minimum code in `files.create`/`files.modify` to make the test pass.
51
+ 3. **Refactor** — clean up naming, duplication, and structure while keeping the test green.
52
+
53
+ ### 5. Order by Dependencies
54
+
55
+ Order tasks so each task's dependencies are satisfied by earlier tasks (topological order, stable by original unit number):
56
+
57
+ ```
58
+ 1. Start with all tasks as "remaining".
59
+ 2. Find tasks whose dependencies are all already ordered -> "ready".
60
+ 3. If none ready: a cycle exists -> surface to the user (break or abort).
61
+ 4. Sort ready tasks by original unit number; append to "ordered".
62
+ 5. Repeat until all tasks are ordered.
63
+ ```
64
+
65
+ ### 6. Assign Priorities
66
+
67
+ | Priority | Criteria |
68
+ | -------- | -------------------------------------------------- |
69
+ | P0 | Blocks all other tasks (foundation, infra, schema) |
70
+ | P1 | On the critical path but not blocking |
71
+ | P2 | Can be deferred or parallelized |
72
+
73
+ ### 7. Infer Tier (for task frontmatter)
74
+
75
+ Infer the `/plan` tier from the derived task count:
76
+
77
+ | Tier | Task count | Max files/task | Max effort/task |
78
+ | -------- | ---------- | -------------- | --------------- |
79
+ | fast | 1–3 | 3 | Half day |
80
+ | standard | 4–8 | 5 | 1 day |
81
+ | deep | 8–15 | 5 | 1 day |
82
+
83
+ Default to `fast` when task count ≤ 3. The tier is recorded in each task's frontmatter (`tier` field) for traceability with `/plan` task files; it does not change Work's behavior (Work runs tasks identically regardless of tier).
84
+
85
+ ## Materialization
86
+
87
+ After resolution, materialize the tasks as files (Triage Step 2c.3):
88
+
89
+ - **Filename:** `docs/tasks/<work-id>/T<NN>-<kebab-case-name>.md` (`<NN>` zero-padded 2 digits matching dependency order).
90
+ - **Schema:** the `/plan` [Task Artifact template](../../plan/references/templates/artifacts/task.md) — set `plan-id` to `work-id`, `status: not-started`, the inferred `tier`.
91
+ - **Index:** create `docs/tasks/<work-id>/index.md` with the `- [ ]` checklist for all tasks (same format as the `/plan` Tasks phase index).
92
+
93
+ Then build the manifest by reading the created files back (confirming shape parity with plan-based tasks).
94
+
95
+ ## Validation (Triage Step 3 re-checks)
96
+
97
+ Each derived task must pass before the manifest is accepted:
98
+
99
+ - exactly one `## Acceptance Criterion` and exactly one `files.test`
100
+ - Red → Green → Refactor step ordering, test written and confirmed first
101
+ - repository-relative, backtick-formatted paths
102
+ - dependencies reference task-ids that exist in the manifest
103
+
104
+ On any failure, regenerate the offending task from Step 2 onward (Category 2 recovery per [error-handling.md](error-handling.md)).
105
+
106
+ ## Smart Pause Triggers
107
+
108
+ Triage pauses in Smart mode when the input shape is `ad-hoc` (the resolved task list was **inferred**, not user-authored — confirm it matches intent). This is the ad-hoc-specific trigger; see Triage Step 7 for the full list.
109
+
110
+ ## Error Handling
111
+
112
+ | Scenario | Recovery |
113
+ | ------------------------------------------ | ----------------------------------------------------- |
114
+ | Description empty or unobservable | Ask the user the problem-frame/intended-behavior prompts |
115
+ | A criterion needs > 5 files / > 1 day | Split into finer sub-criteria (Step 2) |
116
+ | Dependency cycle among derived tasks | Surface to the user; ask to break or abort |
117
+ | `docs/tasks/<work-id>/` write fails | Category 4 recovery per [error-handling.md](error-handling.md) |
118
+
119
+ ## Notes
120
+
121
+ - This reference reuses the `/plan` task-slicing heuristics (one AC per task, sub-ID letters, topological order, P0/P1/P2) so ad-hoc tasks are indistinguishable from `/plan`-produced tasks.
122
+ - The resolved tasks inherit the same Task Artifact schema as `/plan`, so Execute and Review treat them identically to plan-based tasks.