@urielsh/prodify 0.1.0

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 (273) hide show
  1. package/.prodify/AGENTS.md +56 -0
  2. package/.prodify/README.md +10 -0
  3. package/.prodify/artifacts/01-understand.md +28 -0
  4. package/.prodify/artifacts/02-diagnose.md +26 -0
  5. package/.prodify/artifacts/03-architecture.md +30 -0
  6. package/.prodify/artifacts/04-plan.md +35 -0
  7. package/.prodify/artifacts/05-refactor.md +24 -0
  8. package/.prodify/artifacts/06-validate.md +17 -0
  9. package/.prodify/artifacts/README.md +6 -0
  10. package/.prodify/artifacts/architecture_spec.md +29 -0
  11. package/.prodify/artifacts/artifact-validation-design.md +276 -0
  12. package/.prodify/artifacts/cli-command-design.md +299 -0
  13. package/.prodify/artifacts/completed-steps-tracking.md +201 -0
  14. package/.prodify/artifacts/diagnostic_report.md +45 -0
  15. package/.prodify/artifacts/hardening-patch-summary.md +57 -0
  16. package/.prodify/artifacts/hardening-verification-report.md +48 -0
  17. package/.prodify/artifacts/implementation_summary.md +19 -0
  18. package/.prodify/artifacts/improvement-evaluation-spec.md +148 -0
  19. package/.prodify/artifacts/next-step-resolver-design.md +570 -0
  20. package/.prodify/artifacts/orientation_map.md +32 -0
  21. package/.prodify/artifacts/persona-removal-audit.md +106 -0
  22. package/.prodify/artifacts/planning-alignment-report.md +189 -0
  23. package/.prodify/artifacts/refactor-plan-template-hardening.md +83 -0
  24. package/.prodify/artifacts/refactor-validate-loop-design.md +231 -0
  25. package/.prodify/artifacts/refactor_plan.md +21 -0
  26. package/.prodify/artifacts/refactor_plan.strict-example.md +31 -0
  27. package/.prodify/artifacts/run-state-design.md +292 -0
  28. package/.prodify/artifacts/run-summary-spec.md +149 -0
  29. package/.prodify/artifacts/run_state.json +14 -0
  30. package/.prodify/artifacts/sample-repo-test-plan.md +129 -0
  31. package/.prodify/artifacts/status-output-spec.md +349 -0
  32. package/.prodify/artifacts/step-selection-design.md +251 -0
  33. package/.prodify/artifacts/task-dispatcher-design.md +266 -0
  34. package/.prodify/artifacts/task-header-audit.md +42 -0
  35. package/.prodify/artifacts/task-log-enhancement-spec.md +264 -0
  36. package/.prodify/artifacts/task-protocol-hardening-plan.md +68 -0
  37. package/.prodify/artifacts/task-self-validation-spec.md +171 -0
  38. package/.prodify/artifacts/task_log.json +160 -0
  39. package/.prodify/artifacts/template-usage-audit.md +20 -0
  40. package/.prodify/artifacts/validation_report.md +22 -0
  41. package/.prodify/contracts/README.md +3 -0
  42. package/.prodify/contracts/architecture.contract.json +42 -0
  43. package/.prodify/contracts/diagnose.contract.json +42 -0
  44. package/.prodify/contracts/plan.contract.json +42 -0
  45. package/.prodify/contracts/refactor.contract.json +45 -0
  46. package/.prodify/contracts/understand.contract.json +42 -0
  47. package/.prodify/contracts/validate.contract.json +52 -0
  48. package/.prodify/contracts-src/README.md +4 -0
  49. package/.prodify/contracts-src/architecture.contract.md +29 -0
  50. package/.prodify/contracts-src/diagnose.contract.md +29 -0
  51. package/.prodify/contracts-src/plan.contract.md +29 -0
  52. package/.prodify/contracts-src/refactor.contract.md +32 -0
  53. package/.prodify/contracts-src/understand.contract.md +29 -0
  54. package/.prodify/contracts-src/validate.contract.md +35 -0
  55. package/.prodify/metrics/README.md +4 -0
  56. package/.prodify/planning.md +13 -0
  57. package/.prodify/project.md +15 -0
  58. package/.prodify/rules/01-global-operating-rules.md +21 -0
  59. package/.prodify/rules/02-analysis-discipline.md +17 -0
  60. package/.prodify/rules/03-diagnosis-severity-rules.md +42 -0
  61. package/.prodify/rules/04-architecture-rules.md +27 -0
  62. package/.prodify/rules/05-planning-rules.md +23 -0
  63. package/.prodify/rules/06-refactor-rules.md +20 -0
  64. package/.prodify/rules/07-validation-rules.md +25 -0
  65. package/.prodify/rules/08-output-format-rules.md +20 -0
  66. package/.prodify/rules/09-template-usage-rules.md +11 -0
  67. package/.prodify/rules/10-artifact-flow-and-orchestration-rules.md +40 -0
  68. package/.prodify/rules/README.md +3 -0
  69. package/.prodify/rules/example-rule.md +4 -0
  70. package/.prodify/runtime-commands.md +57 -0
  71. package/.prodify/skills/README.md +8 -0
  72. package/.prodify/skills/domain/react-frontend.skill.json +34 -0
  73. package/.prodify/skills/domain/typescript-backend.skill.json +34 -0
  74. package/.prodify/skills/quality-policy/maintainability-review.skill.json +25 -0
  75. package/.prodify/skills/quality-policy/security-hardening.skill.json +32 -0
  76. package/.prodify/skills/quality-policy/test-hardening.skill.json +23 -0
  77. package/.prodify/skills/registry.json +16 -0
  78. package/.prodify/skills/stage-method/architecture-method.skill.json +22 -0
  79. package/.prodify/skills/stage-method/codebase-scanning.skill.json +22 -0
  80. package/.prodify/skills/stage-method/diagnosis-method.skill.json +22 -0
  81. package/.prodify/skills/stage-method/planning-method.skill.json +22 -0
  82. package/.prodify/skills/stage-method/refactoring-method.skill.json +22 -0
  83. package/.prodify/skills/stage-method/validation-method.skill.json +22 -0
  84. package/.prodify/state.json +30 -0
  85. package/.prodify/tasks/01-understand.md +83 -0
  86. package/.prodify/tasks/02-diagnose.md +67 -0
  87. package/.prodify/tasks/03-architecture.md +70 -0
  88. package/.prodify/tasks/04-plan.md +71 -0
  89. package/.prodify/tasks/05-refactor.md +61 -0
  90. package/.prodify/tasks/06-validate.md +69 -0
  91. package/.prodify/tasks/README.md +3 -0
  92. package/.prodify/tasks/example-task.md +13 -0
  93. package/.prodify/templates/01-understand.template.md +18 -0
  94. package/.prodify/templates/02-diagnose.template.md +18 -0
  95. package/.prodify/templates/03-architecture.template.md +18 -0
  96. package/.prodify/templates/04-plan.template.md +22 -0
  97. package/.prodify/templates/05-refactor.template.md +19 -0
  98. package/.prodify/templates/06-validate.template.md +16 -0
  99. package/.prodify/templates/README.md +3 -0
  100. package/.prodify/templates/architecture_spec.template.md +29 -0
  101. package/.prodify/templates/diagnostic_report.template.md +45 -0
  102. package/.prodify/templates/example.template.md +5 -0
  103. package/.prodify/templates/implementation_summary.template.md +19 -0
  104. package/.prodify/templates/orientation_map.template.md +32 -0
  105. package/.prodify/templates/refactor_plan.template.md +24 -0
  106. package/.prodify/templates/validation_report.template.md +22 -0
  107. package/.prodify/version.json +5 -0
  108. package/AGENTS.md +305 -0
  109. package/LICENSE +201 -0
  110. package/README.md +118 -0
  111. package/assets/presets/default/canonical/AGENTS.md +54 -0
  112. package/assets/presets/default/canonical/artifacts/README.md +6 -0
  113. package/assets/presets/default/canonical/contracts-src/README.md +4 -0
  114. package/assets/presets/default/canonical/contracts-src/architecture.contract.md +56 -0
  115. package/assets/presets/default/canonical/contracts-src/diagnose.contract.md +49 -0
  116. package/assets/presets/default/canonical/contracts-src/plan.contract.md +42 -0
  117. package/assets/presets/default/canonical/contracts-src/refactor.contract.md +54 -0
  118. package/assets/presets/default/canonical/contracts-src/understand.contract.md +56 -0
  119. package/assets/presets/default/canonical/contracts-src/validate.contract.md +64 -0
  120. package/assets/presets/default/canonical/metrics/README.md +4 -0
  121. package/assets/presets/default/canonical/planning.md +13 -0
  122. package/assets/presets/default/canonical/project.md +15 -0
  123. package/assets/presets/default/canonical/rules/README.md +3 -0
  124. package/assets/presets/default/canonical/rules/example-rule.md +4 -0
  125. package/assets/presets/default/canonical/runtime-commands.md +57 -0
  126. package/assets/presets/default/canonical/skills/README.md +8 -0
  127. package/assets/presets/default/canonical/skills/domain/react-frontend.skill.json +34 -0
  128. package/assets/presets/default/canonical/skills/domain/typescript-backend.skill.json +34 -0
  129. package/assets/presets/default/canonical/skills/quality-policy/maintainability-review.skill.json +25 -0
  130. package/assets/presets/default/canonical/skills/quality-policy/security-hardening.skill.json +32 -0
  131. package/assets/presets/default/canonical/skills/quality-policy/test-hardening.skill.json +23 -0
  132. package/assets/presets/default/canonical/skills/registry.json +16 -0
  133. package/assets/presets/default/canonical/skills/stage-method/architecture-method.skill.json +22 -0
  134. package/assets/presets/default/canonical/skills/stage-method/codebase-scanning.skill.json +22 -0
  135. package/assets/presets/default/canonical/skills/stage-method/diagnosis-method.skill.json +22 -0
  136. package/assets/presets/default/canonical/skills/stage-method/planning-method.skill.json +22 -0
  137. package/assets/presets/default/canonical/skills/stage-method/refactoring-method.skill.json +22 -0
  138. package/assets/presets/default/canonical/skills/stage-method/validation-method.skill.json +22 -0
  139. package/assets/presets/default/canonical/state.json +30 -0
  140. package/assets/presets/default/canonical/tasks/README.md +3 -0
  141. package/assets/presets/default/canonical/tasks/example-task.md +13 -0
  142. package/assets/presets/default/canonical/templates/README.md +3 -0
  143. package/assets/presets/default/canonical/templates/example.template.md +5 -0
  144. package/assets/presets/default/preset.json +5 -0
  145. package/dist/cli.js +53 -0
  146. package/dist/commands/doctor.js +16 -0
  147. package/dist/commands/init.js +30 -0
  148. package/dist/commands/install.js +27 -0
  149. package/dist/commands/setup-agent.js +23 -0
  150. package/dist/commands/status.js +28 -0
  151. package/dist/commands/sync.js +29 -0
  152. package/dist/commands/update.js +18 -0
  153. package/dist/contracts/compiled-schema.js +37 -0
  154. package/dist/contracts/compiler.js +83 -0
  155. package/dist/contracts/freshness.js +52 -0
  156. package/dist/contracts/index.js +5 -0
  157. package/dist/contracts/parser.js +201 -0
  158. package/dist/contracts/schema.js +138 -0
  159. package/dist/contracts/source-schema.js +111 -0
  160. package/dist/core/agent-runtime.js +36 -0
  161. package/dist/core/agent-setup.js +111 -0
  162. package/dist/core/doctor.js +155 -0
  163. package/dist/core/errors.js +19 -0
  164. package/dist/core/flow-state.js +262 -0
  165. package/dist/core/fs.js +50 -0
  166. package/dist/core/install.js +44 -0
  167. package/dist/core/managed-files.js +106 -0
  168. package/dist/core/paths.js +56 -0
  169. package/dist/core/preset-validation.js +43 -0
  170. package/dist/core/prompt-builder.js +63 -0
  171. package/dist/core/repo-context.js +77 -0
  172. package/dist/core/repo-root.js +55 -0
  173. package/dist/core/skill-resolution.js +123 -0
  174. package/dist/core/state.js +220 -0
  175. package/dist/core/status.js +293 -0
  176. package/dist/core/sync.js +63 -0
  177. package/dist/core/targets.js +48 -0
  178. package/dist/core/upgrade.js +57 -0
  179. package/dist/core/validation.js +138 -0
  180. package/dist/core/version-checks.js +35 -0
  181. package/dist/generators/claude.js +14 -0
  182. package/dist/generators/codex.js +14 -0
  183. package/dist/generators/copilot.js +29 -0
  184. package/dist/generators/header.js +13 -0
  185. package/dist/generators/opencode.js +14 -0
  186. package/dist/generators/shared.js +37 -0
  187. package/dist/index.js +9 -0
  188. package/dist/legacy/targets.js +55 -0
  189. package/dist/presets/default.js +3 -0
  190. package/dist/presets/loader.js +34 -0
  191. package/dist/presets/version.js +18 -0
  192. package/dist/scoring/model.js +262 -0
  193. package/dist/skills/loader.js +40 -0
  194. package/dist/skills/schema.js +159 -0
  195. package/dist/types.js +1 -0
  196. package/docs/canonical-prodify-layout.md +87 -0
  197. package/docs/claude-support.md +22 -0
  198. package/docs/cli-doctor-spec.md +52 -0
  199. package/docs/cli-init-spec.md +70 -0
  200. package/docs/cli-install-agent-spec.md +48 -0
  201. package/docs/cli-sync-spec.md +40 -0
  202. package/docs/codex-support.md +24 -0
  203. package/docs/compatibility-targets.md +59 -0
  204. package/docs/copilot-support.md +30 -0
  205. package/docs/default-preset.md +47 -0
  206. package/docs/generated-file-headers.md +45 -0
  207. package/docs/generation-rules.md +94 -0
  208. package/docs/idempotency-guarantees.md +31 -0
  209. package/docs/managed-file-detection.md +45 -0
  210. package/docs/manual-edit-conflicts.md +37 -0
  211. package/docs/opencode-support.md +27 -0
  212. package/docs/ownership-rules.md +39 -0
  213. package/docs/path-resolution-rules.md +40 -0
  214. package/docs/preset-structure.md +49 -0
  215. package/docs/skill-system.md +67 -0
  216. package/docs/versioning-and-upgrade-strategy.md +40 -0
  217. package/package.json +22 -0
  218. package/src/README.md +11 -0
  219. package/src/cli.ts +61 -0
  220. package/src/commands/doctor.ts +20 -0
  221. package/src/commands/init.ts +37 -0
  222. package/src/commands/setup-agent.ts +28 -0
  223. package/src/commands/status.ts +34 -0
  224. package/src/commands/update.ts +23 -0
  225. package/src/contracts/README.md +10 -0
  226. package/src/contracts/compiled-schema.ts +42 -0
  227. package/src/contracts/compiler.ts +111 -0
  228. package/src/contracts/freshness.ts +58 -0
  229. package/src/contracts/index.ts +11 -0
  230. package/src/contracts/parser.ts +253 -0
  231. package/src/contracts/source-schema.ts +141 -0
  232. package/src/core/agent-runtime.ts +53 -0
  233. package/src/core/agent-setup.ts +147 -0
  234. package/src/core/doctor.ts +171 -0
  235. package/src/core/errors.ts +28 -0
  236. package/src/core/flow-state.ts +333 -0
  237. package/src/core/fs.ts +59 -0
  238. package/src/core/paths.ts +63 -0
  239. package/src/core/preset-validation.ts +47 -0
  240. package/src/core/prompt-builder.ts +73 -0
  241. package/src/core/repo-context.ts +93 -0
  242. package/src/core/repo-root.ts +74 -0
  243. package/src/core/skill-resolution.ts +151 -0
  244. package/src/core/state.ts +264 -0
  245. package/src/core/status.ts +372 -0
  246. package/src/core/targets.ts +53 -0
  247. package/src/core/upgrade.ts +66 -0
  248. package/src/core/validation.ts +233 -0
  249. package/src/core/version-checks.ts +40 -0
  250. package/src/index.ts +13 -0
  251. package/src/presets/default.ts +7 -0
  252. package/src/presets/loader.ts +46 -0
  253. package/src/presets/version.ts +31 -0
  254. package/src/scoring/model.ts +332 -0
  255. package/src/skills/loader.ts +58 -0
  256. package/src/skills/schema.ts +197 -0
  257. package/src/types.ts +329 -0
  258. package/tests/integration/cli-flows.test.js +347 -0
  259. package/tests/unit/agent-setup.test.js +81 -0
  260. package/tests/unit/cli.test.js +28 -0
  261. package/tests/unit/contracts.test.js +61 -0
  262. package/tests/unit/helpers.js +28 -0
  263. package/tests/unit/paths.test.js +52 -0
  264. package/tests/unit/preset-loader.test.js +37 -0
  265. package/tests/unit/scoring.test.js +65 -0
  266. package/tests/unit/self-hosted-workspace.test.js +22 -0
  267. package/tests/unit/skills.test.js +115 -0
  268. package/tests/unit/state-and-flow.test.js +120 -0
  269. package/tests/unit/targets.test.js +13 -0
  270. package/tests/unit/validation.test.js +73 -0
  271. package/tests/unit/version.test.js +24 -0
  272. package/tsconfig.json +23 -0
  273. package/urielsh-prodify-0.1.0.tgz +0 -0
@@ -0,0 +1,266 @@
1
+ # Task Dispatcher Design
2
+
3
+ Date: 2026-03-28
4
+ Scope: `./.prodify/`
5
+
6
+ ## Purpose
7
+ Define how the system selects, prepares, and hands off the correct task using workflow state from `run_state.json`.
8
+
9
+ The dispatcher is responsible for choosing the next executable task and assembling the verified execution context for that task. It is not responsible for:
10
+ - performing the task itself
11
+ - validating output artifacts after execution
12
+ - mutating workflow state beyond the dispatcher's own error reporting
13
+
14
+ ## Required Inputs
15
+ - `.prodify/artifacts/run_state.json`
16
+ - source of truth for `current_task`, `last_completed_task`, `next_task`, `selected_refactor_step`, `completed_step_ids`, and `status`
17
+ - `.prodify/tasks/*.md`
18
+ - source of task metadata and task ordering via frontmatter
19
+ - `.prodify/artifacts/`
20
+ - source of declared input artifacts referenced in task frontmatter
21
+ - `.prodify/templates/`
22
+ - source of task output templates referenced in the selected task's output specification
23
+ - `.prodify/artifacts/task-self-validation-spec.md`
24
+ - source of pre-run validation requirements and task-specific checks
25
+ - `.prodify/artifacts/run-state-design.md`
26
+ - source of status handling, transition expectations, and resume rules
27
+ - `.prodify/artifacts/task_log.json`
28
+ - append-only execution history sink after task completion or failure
29
+
30
+ ## Dispatcher Responsibilities
31
+ - read and validate workflow state before dispatch
32
+ - resolve the single task that is allowed to run next
33
+ - locate the matching task file
34
+ - load task frontmatter and execution metadata
35
+ - derive required inputs and expected primary output
36
+ - prepare the execution payload for the selected task
37
+ - stop and surface deterministic failure reasons when dispatch cannot continue
38
+
39
+ ## Dispatch Algorithm
40
+
41
+ ### Step 1 - Load State
42
+ 1. Read `.prodify/artifacts/run_state.json`.
43
+ 2. Confirm the required state fields exist:
44
+ - `current_task`
45
+ - `last_completed_task`
46
+ - `next_task`
47
+ - `selected_refactor_step`
48
+ - `completed_step_ids`
49
+ - `status`
50
+ 3. If required fields are missing or malformed, stop with dispatcher failure.
51
+
52
+ ### Step 2 - Resolve Dispatch Mode From Status
53
+ Dispatch behavior depends on `status`:
54
+ - `ready`
55
+ - dispatch `next_task`
56
+ - `running`
57
+ - resume `current_task`
58
+ - `awaiting_validation`
59
+ - dispatch `06-validate`
60
+ - `blocked`
61
+ - do not dispatch; surface the blocker from `notes`
62
+ - `failed`
63
+ - do not auto-advance; dispatch only the retry task identified by `next_task` after operator or system recovery logic resets state to runnable
64
+ - `complete`
65
+ - do not dispatch; workflow is terminal
66
+
67
+ ### Step 3 - Resolve Target Task ID
68
+ Determine the single target task ID:
69
+ - for `ready`, use `next_task`
70
+ - for `running`, use `current_task`
71
+ - for `awaiting_validation`, use `06-validate`
72
+
73
+ If the resolved target task ID is `null`, missing, or not one of:
74
+ - `01-understand`
75
+ - `02-diagnose`
76
+ - `03-architecture`
77
+ - `04-plan`
78
+ - `05-refactor`
79
+ - `06-validate`
80
+
81
+ stop with dispatcher failure.
82
+
83
+ ### Step 4 - Resolve Task File
84
+ Map the task ID to its file in `.prodify/tasks/`:
85
+ - `01-understand` -> `.prodify/tasks/01-understand.md`
86
+ - `02-diagnose` -> `.prodify/tasks/02-diagnose.md`
87
+ - `03-architecture` -> `.prodify/tasks/03-architecture.md`
88
+ - `04-plan` -> `.prodify/tasks/04-plan.md`
89
+ - `05-refactor` -> `.prodify/tasks/05-refactor.md`
90
+ - `06-validate` -> `.prodify/tasks/06-validate.md`
91
+
92
+ If the mapped file does not exist, stop with dispatcher failure.
93
+
94
+ ### Step 5 - Load Task Metadata
95
+ Read the task file frontmatter and extract:
96
+ - `task_id`
97
+ - `reads`
98
+ - `writes`
99
+ - `next_task`
100
+ - `mode`
101
+
102
+ Reject dispatch if:
103
+ - frontmatter is missing
104
+ - the frontmatter `task_id` does not match the resolved target task ID
105
+ - more than one primary output is declared in `writes`
106
+ - the `next_task` value conflicts with the expected pipeline or loop behavior
107
+
108
+ ### Step 6 - Derive Required Inputs
109
+ From task metadata and current state, compute the execution inputs:
110
+ - `task_file`
111
+ - `task_id`
112
+ - `mode`
113
+ - `declared_inputs` from `reads`
114
+ - `expected_output` from the single `writes` entry
115
+ - `declared_next_task` from task frontmatter
116
+ - `selected_refactor_step` from `run_state.json` when dispatching Tasks `05` or `06`
117
+ - `completed_step_ids` from `run_state.json` when dispatching Tasks `05` or `06`
118
+
119
+ For Task `05-refactor`, require:
120
+ - `selected_refactor_step` to be non-null
121
+ - the step to exist in `refactor_plan.md`
122
+
123
+ For Task `06-validate`, require:
124
+ - `selected_refactor_step` to be non-null
125
+ - `last_completed_task` to be `05-refactor` or `status` to be `awaiting_validation`
126
+
127
+ ### Step 7 - Run Pre-Run Validation Hook
128
+ Call the self-validation layer using `task-self-validation-spec.md`:
129
+ - verify task file and frontmatter shape
130
+ - verify declared input artifacts exist
131
+ - verify the task's exact template exists
132
+ - verify expected output path consistency
133
+
134
+ If pre-run validation fails:
135
+ - do not dispatch execution
136
+ - return a structured failure
137
+ - leave branching to the run-state failure/update logic
138
+
139
+ ### Step 8 - Emit Execution Payload
140
+ If all checks pass, emit a dispatcher result containing:
141
+ - `task_id`
142
+ - `task_file`
143
+ - `mode`
144
+ - `inputs`
145
+ - `expected_output`
146
+ - `selected_refactor_step`
147
+ - `code_modified`
148
+ - expected `no` for Tasks `01` through `04` and `06`
149
+ - expected `yes` only for Task `05`
150
+ - `candidate_next_task`
151
+ - derived from frontmatter for Tasks `01` through `04`
152
+ - forced to `06-validate` after Task `05`
153
+ - resolved by validation result after Task `06`
154
+
155
+ ## Success And Failure Branching
156
+
157
+ ### Success Branching Before Execution
158
+ - If dispatch succeeds, control passes to task execution.
159
+ - The dispatcher does not advance run state on its own; the execution layer and state-update layer do that after task success or failure.
160
+
161
+ ### Success Branching After Execution
162
+ The dispatcher consumes updated state on the next cycle:
163
+ - after Tasks `01` through `04`, the next dispatch should use the next linear task
164
+ - after Task `05`, the next dispatch should use `06-validate`
165
+ - after Task `06` PASS, the next dispatch should either:
166
+ - loop to `05-refactor` for another step
167
+ - stop if the workflow is complete
168
+ - after Task `06` FAIL, the next dispatch should not occur until state is recovered to a runnable form
169
+
170
+ ## Failure Paths
171
+
172
+ ### State Failures
173
+ - `run_state.json` missing
174
+ - required state fields missing
175
+ - unsupported `status`
176
+ - contradictory `current_task` and `next_task`
177
+ - `next_task` not allowed by the pipeline
178
+
179
+ Dispatcher action:
180
+ - stop
181
+ - report the invalid state condition
182
+ - recommend setting workflow state to `blocked` or `failed`
183
+
184
+ ### Task Resolution Failures
185
+ - target task file missing
186
+ - frontmatter missing or malformed
187
+ - resolved `task_id` and frontmatter `task_id` do not match
188
+ - task declares zero or multiple primary outputs
189
+
190
+ Dispatcher action:
191
+ - stop
192
+ - report the exact task metadata problem
193
+
194
+ ### Input Resolution Failures
195
+ - declared input artifact missing
196
+ - required template missing
197
+ - Task `05` or `06` missing `selected_refactor_step`
198
+ - `selected_refactor_step` not found in `refactor_plan.md`
199
+
200
+ Dispatcher action:
201
+ - stop
202
+ - report the exact missing path or invalid step reference
203
+
204
+ ### Loop Control Failures
205
+ - Task `06` selected when Task `05` did not complete for the current step
206
+ - Task `05` selected while `status` is `awaiting_validation`
207
+ - Task ordering attempts to skip `06-validate` after Task `05`
208
+
209
+ Dispatcher action:
210
+ - stop
211
+ - report the illegal branch condition
212
+
213
+ ## Integration Points
214
+
215
+ ### Integration With Run-State Logic
216
+ - The dispatcher reads, but does not authoritatively define, status semantics from `run-state-design.md`.
217
+ - It must obey:
218
+ - `ready`
219
+ - `running`
220
+ - `awaiting_validation`
221
+ - `blocked`
222
+ - `failed`
223
+ - `complete`
224
+ - It must use `selected_refactor_step` and `completed_step_ids` only as inputs, not as inferred values.
225
+
226
+ ### Integration With Self-Validation
227
+ - The dispatcher invokes the pre-run checks from `task-self-validation-spec.md` before handing a task off for execution.
228
+ - It does not perform post-run artifact validation; that belongs to the validation layer after execution.
229
+
230
+ ### Integration With Task Execution
231
+ - The dispatcher provides the execution layer with one fully resolved task payload.
232
+ - The execution layer is responsible for:
233
+ - loading task instructions
234
+ - performing the task
235
+ - writing the primary artifact
236
+ - calling post-run validation
237
+
238
+ ### Integration With Task Logging
239
+ - After execution concludes, append one record to `.prodify/artifacts/task_log.json` including:
240
+ - dispatched task ID
241
+ - selected refactor step if any
242
+ - execution outcome
243
+ - output artifact path
244
+ - next state summary
245
+
246
+ ## Minimal Execution Payload Shape
247
+ ```json
248
+ {
249
+ "task_id": "02-diagnose",
250
+ "task_file": ".prodify/tasks/02-diagnose.md",
251
+ "mode": "analysis",
252
+ "inputs": [
253
+ ".prodify/artifacts/orientation_map.md"
254
+ ],
255
+ "expected_output": ".prodify/artifacts/diagnostic_report.md",
256
+ "selected_refactor_step": null,
257
+ "code_modified": "no",
258
+ "candidate_next_task": "03-architecture"
259
+ }
260
+ ```
261
+
262
+ ## Implementation Notes
263
+ - Keep task ID to file-path mapping explicit and deterministic.
264
+ - Prefer failing fast over trying to repair state implicitly.
265
+ - Use relative paths only.
266
+ - Keep dispatcher logic separate from artifact validation and state mutation so each layer remains testable and predictable.
@@ -0,0 +1,42 @@
1
+ # Task Header Audit
2
+
3
+ Date: 2026-03-28
4
+ Scope: `./.prodify/tasks/*.md`
5
+
6
+ ## Files Checked
7
+ - `./.prodify/tasks/01-understand.md`
8
+ - `./.prodify/tasks/02-diagnose.md`
9
+ - `./.prodify/tasks/03-architecture.md`
10
+ - `./.prodify/tasks/04-plan.md`
11
+ - `./.prodify/tasks/05-refactor.md`
12
+ - `./.prodify/tasks/06-validate.md`
13
+
14
+ ## Required Header Fields
15
+ Expected frontmatter keys, in order:
16
+ 1. `task_id`
17
+ 2. `reads`
18
+ 3. `writes`
19
+ 4. `next_task`
20
+ 5. `mode`
21
+
22
+ ## Findings
23
+ - All 6 task files include the required header keys.
24
+ - All 6 task files already use the expected key order.
25
+ - 5 of 6 task files already used valid list formatting for `reads` and `writes`.
26
+ - `./.prodify/tasks/01-understand.md` used `reads:` with no value, which parsed as `null` rather than an empty list.
27
+
28
+ ## Missing Fields
29
+ - None.
30
+
31
+ ## Normalization Changes Needed
32
+ - `./.prodify/tasks/01-understand.md`
33
+ Changed `reads:` to `reads: []` so the field is explicitly an empty list and matches the intended metadata contract.
34
+
35
+ ## Recommended Fixes
36
+ - Keep `reads` and `writes` typed as lists in every task file, including explicit empty lists where applicable.
37
+ - Preserve the existing key order: `task_id`, `reads`, `writes`, `next_task`, `mode`.
38
+ - If future task files are added, validate frontmatter shape before committing them so `null` values do not slip in for list fields.
39
+
40
+ ## Result
41
+ - Task headers are now standardized across the audited task set.
42
+ - No additional header fixes are currently needed in `./.prodify/tasks/`.
@@ -0,0 +1,264 @@
1
+ # Task Log Enhancement Spec
2
+
3
+ Date: 2026-03-29
4
+ Scope: `./.prodify/artifacts/task_log.json`
5
+
6
+ ## Purpose
7
+
8
+ Define a richer append-only execution log format for Prodify.
9
+
10
+ The enhanced log should:
11
+
12
+ - remain easy to inspect manually
13
+ - provide enough detail for status and summary features
14
+ - preserve deterministic append-only behavior
15
+
16
+ ## Updated Log Shape
17
+
18
+ Keep the top-level container as:
19
+
20
+ ```json
21
+ {
22
+ "executions": []
23
+ }
24
+ ```
25
+
26
+ Each entry in `executions` should use this shape:
27
+
28
+ ```json
29
+ {
30
+ "timestamp": "2026-03-29T10:15:00Z",
31
+ "task": "02-diagnose",
32
+ "result": "success",
33
+ "artifacts_touched": [
34
+ ".prodify/artifacts/diagnostic_report.md"
35
+ ],
36
+ "notes": [
37
+ "Validated declared inputs before execution.",
38
+ "Wrote the diagnostic report template output."
39
+ ]
40
+ }
41
+ ```
42
+
43
+ ## Entry Fields
44
+
45
+ ### `timestamp`
46
+ Type:
47
+ - string
48
+
49
+ Format:
50
+ - ISO 8601 UTC timestamp
51
+
52
+ Purpose:
53
+ - records when the execution result was appended
54
+
55
+ Example:
56
+ - `2026-03-29T10:15:00Z`
57
+
58
+ ### `task`
59
+ Type:
60
+ - string
61
+
62
+ Purpose:
63
+ - records the runtime task ID that was executed or attempted
64
+
65
+ Allowed examples:
66
+ - `01-understand`
67
+ - `02-diagnose`
68
+ - `03-architecture`
69
+ - `04-plan`
70
+ - `05-refactor`
71
+ - `06-validate`
72
+
73
+ ### `result`
74
+ Type:
75
+ - string
76
+
77
+ Allowed values:
78
+ - `success`
79
+ - `blocked`
80
+ - `failed`
81
+
82
+ Purpose:
83
+ - captures the final outcome of that execution attempt
84
+
85
+ Rules:
86
+ - use `success` only when the task completed and its primary artifact passed required validation
87
+ - use `blocked` when execution could not continue because inputs, state, or templates were incomplete
88
+ - use `failed` when the task ran or attempted to run but ended in a failure condition
89
+
90
+ ### `artifacts_touched`
91
+ Type:
92
+ - array of strings
93
+
94
+ Purpose:
95
+ - records the runtime artifact paths written or materially updated during the task attempt
96
+
97
+ Rules:
98
+ - use relative paths only
99
+ - keep the list limited to artifacts materially touched by that execution result
100
+ - for blocked outcomes with no writes, this may be `[]`
101
+
102
+ Examples:
103
+ - `.prodify/artifacts/orientation_map.md`
104
+ - `.prodify/artifacts/validation_report.md`
105
+ - `.prodify/artifacts/run_state.json`
106
+
107
+ ### `notes`
108
+ Type:
109
+ - array of strings
110
+
111
+ Purpose:
112
+ - captures short high-signal details about what happened
113
+
114
+ Rules:
115
+ - keep entries concise
116
+ - prefer factual statements over narrative prose
117
+ - include failure or blocker reason when relevant
118
+ - avoid duplicating full artifact contents
119
+
120
+ ## Append Rules
121
+
122
+ ### Rule 1 - Append Only
123
+ Never rewrite or delete earlier execution entries during normal operation.
124
+
125
+ Allowed action:
126
+ - append exactly one new entry for each completed execution attempt
127
+
128
+ ### Rule 2 - One Entry Per Attempt
129
+ Each task attempt should produce at most one appended log entry.
130
+
131
+ This includes:
132
+ - successful task completion
133
+ - blocked attempt
134
+ - failed attempt
135
+
136
+ ### Rule 3 - Append After Outcome Is Known
137
+ Append only after the task outcome is determined.
138
+
139
+ That means:
140
+ - after artifact validation for success
141
+ - after blocker detection for blocked outcomes
142
+ - after failure handling decides the attempt failed
143
+
144
+ ### Rule 4 - Keep Order Chronological
145
+ New entries must be appended at the end of the `executions` array in actual execution order.
146
+
147
+ ### Rule 5 - Preserve Prior Entries
148
+ State repair, retries, and later successful executions must not erase earlier blocked or failed entries.
149
+
150
+ ### Rule 6 - Relative Paths Only
151
+ Artifact paths in `artifacts_touched` must remain relative to the runtime root.
152
+
153
+ ## Result-Specific Rules
154
+
155
+ ### Success Entry
156
+ A success entry should:
157
+
158
+ - include the executed task
159
+ - include the primary artifact written
160
+ - include relevant state or summary artifacts if they were updated as part of the same execution cycle
161
+ - include a short note confirming successful completion
162
+
163
+ ### Blocked Entry
164
+ A blocked entry should:
165
+
166
+ - include the task that could not proceed
167
+ - include `artifacts_touched: []` when nothing was written
168
+ - include a note naming the blocker
169
+
170
+ ### Failed Entry
171
+ A failed entry should:
172
+
173
+ - include the task that failed
174
+ - include any artifact written before failure if it materially exists
175
+ - include a short failure reason in `notes`
176
+
177
+ ## Sample Entries
178
+
179
+ ### Sample 1 - Success
180
+
181
+ ```json
182
+ {
183
+ "timestamp": "2026-03-29T10:15:00Z",
184
+ "task": "03-architecture",
185
+ "result": "success",
186
+ "artifacts_touched": [
187
+ ".prodify/artifacts/architecture_spec.md",
188
+ ".prodify/artifacts/run_state.json"
189
+ ],
190
+ "notes": [
191
+ "Architecture spec written and validated.",
192
+ "Run state advanced to 04-plan."
193
+ ]
194
+ }
195
+ ```
196
+
197
+ ### Sample 2 - Blocked
198
+
199
+ ```json
200
+ {
201
+ "timestamp": "2026-03-29T10:22:00Z",
202
+ "task": "05-refactor",
203
+ "result": "blocked",
204
+ "artifacts_touched": [],
205
+ "notes": [
206
+ "selected_refactor_step could not be resolved from refactor_plan.md."
207
+ ]
208
+ }
209
+ ```
210
+
211
+ ### Sample 3 - Failed
212
+
213
+ ```json
214
+ {
215
+ "timestamp": "2026-03-29T10:28:00Z",
216
+ "task": "06-validate",
217
+ "result": "failed",
218
+ "artifacts_touched": [
219
+ ".prodify/artifacts/validation_report.md",
220
+ ".prodify/artifacts/run_state.json"
221
+ ],
222
+ "notes": [
223
+ "Validation reported a regression for step-03-extract-service.",
224
+ "Retry of 05-refactor is required."
225
+ ]
226
+ }
227
+ ```
228
+
229
+ ## Inspection Guidelines
230
+
231
+ The log should stay easy to inspect by humans.
232
+
233
+ Guidelines:
234
+
235
+ - keep field names stable
236
+ - keep entries shallow
237
+ - avoid nested diagnostic blobs
238
+ - store only short note strings
239
+ - prefer explicit results over inferred meaning
240
+
241
+ ## Integration Notes
242
+
243
+ ### Integration With Run State
244
+ - `task_log.json` is not the control plane.
245
+ - `run_state.json` remains the canonical source of workflow state.
246
+ - the log exists to record execution history, not to replace state
247
+
248
+ ### Integration With Status Output
249
+ - status views may use the latest execution entry to enrich human summaries
250
+ - status must still prefer current state over stale history
251
+
252
+ ### Integration With Run Summary
253
+ - Task `62-add-summary-output` should be able to read the latest log entry directly
254
+ - the fields in this spec are intentionally chosen to support:
255
+ - task executed
256
+ - result
257
+ - artifact written or touched
258
+ - notes
259
+
260
+ ## Implementation Notes
261
+
262
+ - Keep the existing top-level `executions` array for compatibility.
263
+ - Prefer a small stable schema over a verbose event stream.
264
+ - If no artifact was touched, use an empty array rather than inventing a placeholder path.
@@ -0,0 +1,68 @@
1
+ # Task Protocol Hardening Plan
2
+
3
+ Date: 2026-03-29
4
+ Task: `82-tighten-task-protocols`
5
+
6
+ ## Plan
7
+
8
+ | Task file | Missing protocol elements | Exact wording to add or tighten | Severity |
9
+ | --- | --- | --- | --- |
10
+ | `01-understand.md` | explicit required inputs section, explicit no-code-modification rule, explicit failure conditions | Add `## Inputs` for repository root; add `MUST NOT modify source code`; add stop conditions for missing repository access, missing output-template compliance, or unsupported scan evidence. | High |
11
+ | `02-diagnose.md` | explicit failure conditions, explicit no-code-modification rule, explicit stop conditions | Add `MUST NOT modify source code`; add stop conditions for missing `orientation_map.md`, missing required context, or inability to produce the declared template output. | High |
12
+ | `03-architecture.md` | explicit failure conditions, explicit no-code-modification rule, explicit stop conditions | Add `MUST NOT modify source code`; add stop conditions for missing `orientation_map.md` or `diagnostic_report.md`, or inability to ground recommendations in evidence. | High |
13
+ | `04-plan.md` | explicit failure conditions, explicit no-code-modification rule, explicit stop conditions, stronger plan-step structure requirement | Add `MUST NOT modify source code`; add stop conditions for missing required artifacts, ambiguous step structure, or output not matching the template; require fixed step blocks with stable IDs. | High |
14
+ | `05-refactor.md` | explicit forbidden behavior section, explicit stop conditions, explicit ambiguity handling | Add `MUST execute exactly one selected step`; add `MUST NOT modify unrelated files`; add `MUST STOP if selected step is ambiguous, missing, or not isolated enough to execute safely`. | Critical |
15
+ | `06-validate.md` | explicit no-code-modification rule, explicit required ordering, explicit PASS/FAIL requirement, explicit failure conditions | Add `MUST NOT modify source code`; add `MUST run only after Task 05`; add `MUST explicitly report PASS or FAIL`; add stop conditions for missing context or inability to produce a verdict. | Critical |
16
+
17
+ ## Protocol Additions By Task
18
+
19
+ ### Tasks 01 Through 04
20
+ Add these protocol rules explicitly:
21
+
22
+ - `MUST NOT modify source code.`
23
+ - `MUST STOP if any required input artifact is missing.`
24
+ - `MUST STOP if the declared output cannot be produced in the required template structure.`
25
+
26
+ ### Task 05
27
+ Add these protocol rules explicitly:
28
+
29
+ - `MUST execute exactly one selected refactor step.`
30
+ - `MUST NOT modify unrelated files.`
31
+ - `MUST STOP if the selected step is ambiguous, missing, or combines unrelated concerns.`
32
+
33
+ ### Task 06
34
+ Add these protocol rules explicitly:
35
+
36
+ - `MUST run after Task 05 for the same selected step.`
37
+ - `MUST NOT modify source code.`
38
+ - `MUST STOP if required context is missing.`
39
+ - `MUST explicitly report PASS or FAIL.`
40
+
41
+ ## File-Specific Hardening Notes
42
+
43
+ ### `01-understand.md`
44
+ - Convert narrative framing into explicit scope and input language.
45
+ - Make conservative evidence gathering a stop rule, not just a style preference.
46
+
47
+ ### `02-diagnose.md`
48
+ - Tighten the task so it clearly fails when the orientation artifact is absent or insufficient.
49
+
50
+ ### `03-architecture.md`
51
+ - Tighten the task so architectural recommendations cannot proceed without evidence from Tasks `01` and `02`.
52
+
53
+ ### `04-plan.md`
54
+ - Require fixed refactor-step structure aligned with the hardened template.
55
+ - Tighten step atomicity into a stop condition, not just guidance.
56
+
57
+ ### `05-refactor.md`
58
+ - Make one-step discipline and unrelated-file prohibition unambiguous.
59
+ - Add explicit stop behavior for ambiguous or unsafe steps.
60
+
61
+ ### `06-validate.md`
62
+ - Make explicit verdict reporting mandatory.
63
+ - Add stop behavior for missing implementation context or missing plan context.
64
+
65
+ ## Result
66
+ - Every core task now has a concrete hardening recommendation.
67
+ - Missing fail and stop conditions are documented.
68
+ - A deterministic upgrade path exists for the full `01` through `06` suite.