@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,148 @@
1
+ # Improvement Evaluation Spec
2
+
3
+ Date: 2026-03-29
4
+ Scope: system-level evaluation of whether Prodify improves a codebase
5
+
6
+ ## Comparison Method
7
+
8
+ Evaluate Prodify by comparing before-vs-after signals from the same repository across one bounded run scope.
9
+
10
+ Use these comparison stages:
11
+
12
+ 1. capture baseline conditions before the run
13
+ 2. capture artifacts and validation outcomes after the run
14
+ 3. compare baseline to post-run state
15
+ 4. classify the overall system result as pass, borderline, or fail
16
+
17
+ ## Metrics
18
+
19
+ ### Issue Count
20
+ Measure:
21
+
22
+ - number of diagnosed issues before refactor
23
+ - number of unresolved critical or high-severity issues after the validated step
24
+
25
+ Desired direction:
26
+
27
+ - unresolved issue count should decrease or become better structured and more actionable
28
+
29
+ ### Architecture Clarity
30
+ Measure:
31
+
32
+ - clarity of subsystem boundaries
33
+ - explicitness of architecture decisions
34
+ - consistency between diagnosis and architecture proposal
35
+
36
+ Evidence sources:
37
+
38
+ - `diagnostic_report.md`
39
+ - `architecture_spec.md`
40
+ - `refactor_plan.md`
41
+
42
+ Desired direction:
43
+
44
+ - architecture should be clearer after the run than before
45
+
46
+ ### Validation Score
47
+ Measure:
48
+
49
+ - final validation posture from `validation_report.md`
50
+ - category scores such as architecture, maintainability, reliability, and testability when available
51
+
52
+ Desired direction:
53
+
54
+ - no regression in validation posture
55
+ - ideally a clearer or stronger validation outcome after the change
56
+
57
+ ### Maintainability Signals
58
+ Measure:
59
+
60
+ - duplication reduced or isolated
61
+ - naming clarity improved
62
+ - step size remained controlled
63
+ - changed code stayed within declared scope
64
+
65
+ Evidence sources:
66
+
67
+ - `implementation_summary.md`
68
+ - `validation_report.md`
69
+ - `task_log.json`
70
+
71
+ Desired direction:
72
+
73
+ - the code should be easier to understand, safer to extend, or more internally consistent
74
+
75
+ ## Evaluation Criteria
76
+
77
+ ### PASS
78
+ Classify the system as PASS when all of the following hold:
79
+
80
+ - at least one meaningful issue or structural problem was addressed
81
+ - architecture clarity improved or became more explicit
82
+ - validation result is PASS or a clearly acceptable non-regressive outcome
83
+ - maintainability signals improved
84
+ - the workflow stayed within declared task boundaries
85
+
86
+ ### BORDERLINE
87
+ Classify as BORDERLINE when:
88
+
89
+ - documentation and planning improved, but code improvement is modest
90
+ - validation is inconclusive but no clear regression is present
91
+ - maintainability gains are present but weak
92
+
93
+ Borderline means the system may be promising but is not yet strongly proven.
94
+
95
+ ### FAIL
96
+ Classify as FAIL when any of the following hold:
97
+
98
+ - issue count did not improve and no meaningful structure was added
99
+ - architecture clarity became worse or stayed confused
100
+ - validation shows regressions or clear failure
101
+ - the refactor exceeded declared scope
102
+ - artifacts are too weak to prove improvement
103
+
104
+ ## Pass/Fail Criteria For Prodify Itself
105
+
106
+ Prodify as a system passes the sample evaluation when:
107
+
108
+ - it produces all required artifacts for the run scope
109
+ - it identifies real issues in the baseline codebase
110
+ - it proposes an actionable architecture and plan
111
+ - it executes at least one isolated improvement step safely
112
+ - it validates the outcome clearly enough to support a next-step decision
113
+
114
+ Prodify as a system fails when:
115
+
116
+ - the artifacts do not support deterministic continuation
117
+ - the workflow cannot distinguish success, failure, and blocked states
118
+ - the validated result does not show credible improvement or safe control
119
+
120
+ ## Reporting Format
121
+
122
+ Use this compact reporting format for the overall evaluation:
123
+
124
+ ```text
125
+ Evaluation result: <PASS|BORDERLINE|FAIL>
126
+ Issue count: <before> -> <after>
127
+ Architecture clarity: <before summary> -> <after summary>
128
+ Validation score: <before/unknown> -> <after summary>
129
+ Maintainability signals: <before summary> -> <after summary>
130
+ System verdict: <short explanation>
131
+ ```
132
+
133
+ ## Example Evaluation
134
+
135
+ ```text
136
+ Evaluation result: PASS
137
+ Issue count: 8 -> 5
138
+ Architecture clarity: implicit and inconsistent -> explicit service boundaries proposed and partially enforced
139
+ Validation score: unknown -> PASS with improved maintainability and no regression detected
140
+ Maintainability signals: duplicated logic and weak naming -> one duplicated path removed and step scope stayed isolated
141
+ System verdict: Prodify improved the codebase measurably while keeping the workflow controlled.
142
+ ```
143
+
144
+ ## Practical Notes
145
+
146
+ - Use bounded runs for comparison; do not compare unrelated repo states.
147
+ - Prefer a small number of trustworthy metrics over a long checklist.
148
+ - Treat inconclusive validation as insufficient proof of improvement unless other strong evidence compensates, in which case classify as BORDERLINE rather than PASS.
@@ -0,0 +1,570 @@
1
+ # Next Step Resolver Design
2
+
3
+ Date: 2026-03-29
4
+ Scope: `./.prodify/`
5
+
6
+ ## Purpose
7
+
8
+ Define deterministic logic for deciding what Prodify should do next without user guidance.
9
+
10
+ The resolver answers three questions on every cycle:
11
+
12
+ - what task should run next
13
+ - whether execution should stop
14
+ - whether execution should resume, retry, or block
15
+
16
+ The resolver must use verified state only. It must not infer workflow progress from memory.
17
+
18
+ ## Canonical Inputs
19
+
20
+ ### Primary Input
21
+ - `.prodify/artifacts/run_state.json`
22
+ - canonical source for:
23
+ - `current_task`
24
+ - `last_completed_task`
25
+ - `next_task`
26
+ - `selected_refactor_step`
27
+ - `completed_step_ids`
28
+ - `status`
29
+ - `notes`
30
+
31
+ ### Secondary Inputs
32
+ - `.prodify/artifacts/task_log.json`
33
+ - confirms prior execution history
34
+ - helps distinguish a true fresh start from an inconsistent partial state
35
+ - `.prodify/artifacts/validation_report.md`
36
+ - used only when validation state or validation outcome must be confirmed
37
+ - never overrides `run_state.json`
38
+
39
+ ### Supporting Design Inputs
40
+ - `./.prodify/artifacts/run-state-design.md`
41
+ - `./.prodify/artifacts/task-dispatcher-design.md`
42
+ - `./.prodify/artifacts/refactor-validate-loop-design.md`
43
+ - `./.prodify/artifacts/completed-steps-tracking.md`
44
+ - `./.prodify/artifacts/planning-alignment-report.md`
45
+
46
+ ## Canonical Resolution Model
47
+
48
+ Use this canonical loop model for next-step resolution:
49
+
50
+ - after Task `05-refactor`, the next task is always Task `06-validate`
51
+ - after Task `06-validate` PASS:
52
+ - continue to the next remaining refactor step if one exists
53
+ - otherwise stop complete
54
+ - after Task `06-validate` FAIL:
55
+ - retry or repair the same selected step
56
+ - do not auto-advance to a later step
57
+ - after inconclusive validation:
58
+ - block until validation can be rerun or repaired
59
+
60
+ This intentionally follows the newer design set rather than the outdated PASS/FAIL wording in `AGENTS.md`.
61
+
62
+ ## Resolver Outputs
63
+
64
+ The resolver returns one structured decision with:
65
+
66
+ - `decision`
67
+ - one of:
68
+ - `dispatch`
69
+ - `resume`
70
+ - `retry`
71
+ - `stop_complete`
72
+ - `stop_blocked`
73
+ - `stop_failed`
74
+ - `resolved_task`
75
+ - task ID to run next, or `null`
76
+ - `reason`
77
+ - short deterministic explanation
78
+ - `resume_condition`
79
+ - what must be true before execution may continue
80
+ - `state_requirements`
81
+ - fields or artifacts that must be corrected first, if any
82
+
83
+ ## Resolution Order
84
+
85
+ Resolve in this strict order:
86
+
87
+ 1. Validate `run_state.json` presence and required fields.
88
+ 2. Validate status-specific state invariants.
89
+ 3. If needed, corroborate fresh-start or failure context using `task_log.json`.
90
+ 4. If needed, corroborate validation outcome using `validation_report.md`.
91
+ 5. Return exactly one decision.
92
+
93
+ Higher-priority failures always win over lower-priority dispatch opportunities.
94
+
95
+ ## Schema And State Gate
96
+
97
+ ### Required Run-State Fields
98
+ The resolver requires:
99
+
100
+ - `current_task`
101
+ - `last_completed_task`
102
+ - `next_task`
103
+ - `selected_refactor_step`
104
+ - `completed_step_ids`
105
+ - `status`
106
+
107
+ If any required field is missing:
108
+
109
+ - return `decision: stop_blocked`
110
+ - return `resolved_task: null`
111
+ - reason: `run_state_schema_incomplete`
112
+
113
+ This applies to the current on-disk `run_state.json`, which still lacks `completed_step_ids`.
114
+
115
+ ### Required Status Values
116
+ Allowed `status` values:
117
+
118
+ - `ready`
119
+ - `running`
120
+ - `awaiting_validation`
121
+ - `blocked`
122
+ - `failed`
123
+ - `complete`
124
+
125
+ Unknown status resolves to:
126
+
127
+ - `decision: stop_failed`
128
+ - reason: `unsupported_status`
129
+
130
+ ## Decision Table
131
+
132
+ | Status | Additional condition | Decision | Resolved task | Resume condition |
133
+ | --- | --- | --- | --- | --- |
134
+ | `ready` | `next_task` valid and state consistent | `dispatch` | `next_task` | state already runnable |
135
+ | `ready` | `next_task` is `05-refactor` and selected step valid | `dispatch` | `05-refactor` | selected step exists and is not completed |
136
+ | `ready` | `next_task` is `05-refactor` and no step can be selected | `stop_blocked` | `null` | repair plan or state |
137
+ | `running` | `current_task` valid | `resume` | `current_task` | resume the interrupted task only |
138
+ | `awaiting_validation` | selected step present and Task `05` completed | `dispatch` | `06-validate` | validation must run now |
139
+ | `awaiting_validation` | selected step missing or Task `05` context invalid | `stop_failed` | `null` | repair invalid loop state |
140
+ | `blocked` | blocker note present and issue unresolved | `stop_blocked` | `null` | resolve blocker, then recompute |
141
+ | `failed` | retryable task and failure is understood | `retry` | `next_task` | correct failure cause first |
142
+ | `failed` | no deterministic retry target | `stop_failed` | `null` | reconcile state manually |
143
+ | `complete` | terminal state valid | `stop_complete` | `null` | none |
144
+
145
+ ## Status Resolution Rules
146
+
147
+ ### Rule 1 - `ready`
148
+
149
+ When `status` is `ready`:
150
+
151
+ - use `next_task` as the candidate task
152
+ - verify it is valid for the pipeline or refactor loop
153
+ - if `next_task` is `05-refactor`, confirm:
154
+ - `selected_refactor_step` is set or can be selected deterministically
155
+ - the step is not already in `completed_step_ids`
156
+ - the step exists in `refactor_plan.md`
157
+
158
+ If those checks pass:
159
+
160
+ - `decision: dispatch`
161
+ - `resolved_task: next_task`
162
+
163
+ If those checks fail:
164
+
165
+ - `decision: stop_blocked`
166
+ - reason: `refactor_step_unresolvable`
167
+
168
+ ### Rule 2 - `running`
169
+
170
+ When `status` is `running`:
171
+
172
+ - ignore `next_task` for dispatch purposes
173
+ - resume `current_task`
174
+ - do not advance to another task
175
+
176
+ If `current_task` is null:
177
+
178
+ - `decision: stop_failed`
179
+ - reason: `running_without_current_task`
180
+
181
+ ### Rule 3 - `awaiting_validation`
182
+
183
+ When `status` is `awaiting_validation`:
184
+
185
+ - require `next_task: "06-validate"`
186
+ - require non-null `selected_refactor_step`
187
+ - require `last_completed_task: "05-refactor"`
188
+
189
+ If all checks pass:
190
+
191
+ - `decision: dispatch`
192
+ - `resolved_task: "06-validate"`
193
+
194
+ If any check fails:
195
+
196
+ - `decision: stop_failed`
197
+ - reason: `invalid_awaiting_validation_state`
198
+
199
+ ### Rule 4 - `blocked`
200
+
201
+ When `status` is `blocked`:
202
+
203
+ - do not dispatch any task
204
+ - return the blocker reason from `notes`
205
+ - require explicit repair before recomputing the next step
206
+
207
+ Resolver output:
208
+
209
+ - `decision: stop_blocked`
210
+ - `resolved_task: null`
211
+
212
+ ### Rule 5 - `failed`
213
+
214
+ When `status` is `failed`:
215
+
216
+ - never auto-advance to a later task
217
+ - use `next_task` only as a retry target
218
+ - prefer retrying Task `05-refactor` for the same selected step after validation FAIL
219
+ - never choose a new step while failure is unresolved
220
+
221
+ If the state identifies a deterministic retry:
222
+
223
+ - `decision: retry`
224
+ - `resolved_task: next_task`
225
+
226
+ If retry target or selected-step context is inconsistent:
227
+
228
+ - `decision: stop_failed`
229
+ - reason: `retry_target_unresolvable`
230
+
231
+ ### Rule 6 - `complete`
232
+
233
+ When `status` is `complete`:
234
+
235
+ - require `current_task: null`
236
+ - require `next_task: null`
237
+
238
+ If both conditions hold:
239
+
240
+ - `decision: stop_complete`
241
+
242
+ Otherwise:
243
+
244
+ - `decision: stop_failed`
245
+ - reason: `invalid_complete_state`
246
+
247
+ ## Validation Outcome Resolution
248
+
249
+ The resolver consults `validation_report.md` only when it needs to confirm the meaning of Task `06` output.
250
+
251
+ ### PASS
252
+ Treat validation as PASS only when:
253
+
254
+ - `run_state.json` already reflects successful validation semantics, or
255
+ - `validation_report.md` explicitly records `PASS`
256
+
257
+ PASS resolves to:
258
+
259
+ - append/select behavior handled by state-update logic
260
+ - resolver chooses:
261
+ - `05-refactor` if more valid steps remain
262
+ - `stop_complete` if no valid steps remain
263
+
264
+ ### FAIL
265
+ Treat validation as FAIL only when:
266
+
267
+ - `run_state.json` is in a failed retry state, or
268
+ - `validation_report.md` explicitly records `FAIL`
269
+
270
+ FAIL resolves to:
271
+
272
+ - `decision: retry`
273
+ - `resolved_task: "05-refactor"` if the failed step is still valid
274
+
275
+ ### Inconclusive
276
+ If `validation_report.md` is missing, template-only, interrupted, or lacks a trustworthy PASS/FAIL result:
277
+
278
+ - `decision: stop_blocked`
279
+ - `reason: validation_inconclusive`
280
+
281
+ This applies to the current template-shaped `validation_report.md`.
282
+
283
+ ## Task History Resolution
284
+
285
+ Use `task_log.json` only as corroborating evidence.
286
+
287
+ ### Fresh Start Confirmation
288
+ Treat the run as a fresh start only when all of the following are true:
289
+
290
+ - `last_completed_task` is `null`
291
+ - `next_task` is `01-understand`
292
+ - `current_task` is `null` or `01-understand`
293
+ - `task_log.json` contains no executions
294
+
295
+ Then resolve:
296
+
297
+ - `decision: dispatch`
298
+ - `resolved_task: "01-understand"`
299
+
300
+ ### History Conflict
301
+ If task history contradicts state, for example:
302
+
303
+ - `task_log.json` shows later tasks but `run_state.json` looks fresh
304
+ - `run_state.json` claims completion but history stops mid-pipeline
305
+
306
+ Then:
307
+
308
+ - prefer `run_state.json` as canonical
309
+ - return `decision: stop_blocked`
310
+ - reason: `state_history_conflict`
311
+
312
+ ## Refactor Loop Resolution
313
+
314
+ ### Selecting Work After Validation PASS
315
+ If the current state reflects Task `06` PASS:
316
+
317
+ 1. confirm the completed step is present in `completed_step_ids`
318
+ 2. ask the step-selection logic for the next remaining valid step
319
+ 3. if a next step exists:
320
+ - `decision: dispatch`
321
+ - `resolved_task: "05-refactor"`
322
+ 4. if no steps remain:
323
+ - `decision: stop_complete`
324
+
325
+ ### Retrying After Validation FAIL
326
+ If Task `06` failed:
327
+
328
+ - keep the same `selected_refactor_step`
329
+ - keep `completed_step_ids` unchanged
330
+ - resolve to retry Task `05-refactor`
331
+
332
+ ### Inconclusive Validation
333
+ If Task `06` output is inconclusive:
334
+
335
+ - do not choose a new step
336
+ - do not mark the workflow complete
337
+ - return `stop_blocked`
338
+
339
+ ## Edge Cases
340
+
341
+ ### Edge Case 1 - Missing `completed_step_ids`
342
+ If `run_state.json` lacks `completed_step_ids`:
343
+
344
+ - do not assume `[]`
345
+ - return `stop_blocked`
346
+ - require schema repair
347
+
348
+ ### Edge Case 2 - Template-Only `validation_report.md`
349
+ If the validation report still contains placeholder `PASS/FAIL:` lines without a resolved outcome:
350
+
351
+ - treat validation as inconclusive
352
+ - block instead of guessing PASS or FAIL
353
+
354
+ ### Edge Case 3 - `ready` With `05-refactor` But No Selected Step
355
+ If state says `ready` and `next_task` is `05-refactor`, but no valid selected step exists:
356
+
357
+ - block on planning or selection repair
358
+
359
+ ### Edge Case 4 - Completed Step Still Selected For Retry
360
+ If `selected_refactor_step` is already present in `completed_step_ids` while state expects a retry:
361
+
362
+ - return `stop_failed`
363
+ - reason: `selected_step_already_completed`
364
+
365
+ ### Edge Case 5 - `complete` With Remaining Task
366
+ If `status` is `complete` but `next_task` is non-null:
367
+
368
+ - return `stop_failed`
369
+ - reason: `complete_state_not_terminal`
370
+
371
+ ### Edge Case 6 - Unknown Validation Outcome After Task `05`
372
+ If Task `05` completed but the system cannot prove that Task `06` ran or what it concluded:
373
+
374
+ - require `06-validate` if state is still `awaiting_validation`
375
+ - otherwise block on validation ambiguity
376
+
377
+ ### Edge Case 7 - Failed State Points To A New Step
378
+ If `status` is `failed` but `next_task` or `selected_refactor_step` points to a different untried step instead of the failed one:
379
+
380
+ - return `stop_failed`
381
+ - reason: `illegal_skip_after_failure`
382
+
383
+ ## Examples
384
+
385
+ ### Example 1 - Fresh Start
386
+ Input state:
387
+
388
+ ```json
389
+ {
390
+ "current_task": null,
391
+ "last_completed_task": null,
392
+ "next_task": "01-understand",
393
+ "selected_refactor_step": null,
394
+ "completed_step_ids": [],
395
+ "status": "ready",
396
+ "artifacts_dir": ".prodify/artifacts",
397
+ "notes": []
398
+ }
399
+ ```
400
+
401
+ Resolver output:
402
+
403
+ ```json
404
+ {
405
+ "decision": "dispatch",
406
+ "resolved_task": "01-understand",
407
+ "reason": "fresh_start_ready",
408
+ "resume_condition": "state already runnable",
409
+ "state_requirements": []
410
+ }
411
+ ```
412
+
413
+ ### Example 2 - Mid-Pipeline
414
+ Input state:
415
+
416
+ ```json
417
+ {
418
+ "current_task": null,
419
+ "last_completed_task": "03-architecture",
420
+ "next_task": "04-plan",
421
+ "selected_refactor_step": null,
422
+ "completed_step_ids": [],
423
+ "status": "ready",
424
+ "artifacts_dir": ".prodify/artifacts",
425
+ "notes": []
426
+ }
427
+ ```
428
+
429
+ Resolver output:
430
+
431
+ ```json
432
+ {
433
+ "decision": "dispatch",
434
+ "resolved_task": "04-plan",
435
+ "reason": "linear_pipeline_ready",
436
+ "resume_condition": "state already runnable",
437
+ "state_requirements": []
438
+ }
439
+ ```
440
+
441
+ ### Example 3 - Awaiting Validation
442
+ Input state:
443
+
444
+ ```json
445
+ {
446
+ "current_task": null,
447
+ "last_completed_task": "05-refactor",
448
+ "next_task": "06-validate",
449
+ "selected_refactor_step": "step-03-extract-service",
450
+ "completed_step_ids": [
451
+ "step-01-rename-module"
452
+ ],
453
+ "status": "awaiting_validation",
454
+ "artifacts_dir": ".prodify/artifacts",
455
+ "notes": []
456
+ }
457
+ ```
458
+
459
+ Resolver output:
460
+
461
+ ```json
462
+ {
463
+ "decision": "dispatch",
464
+ "resolved_task": "06-validate",
465
+ "reason": "validation_required_now",
466
+ "resume_condition": "run Task 06 before any new refactor step",
467
+ "state_requirements": []
468
+ }
469
+ ```
470
+
471
+ ### Example 4 - Validation Fail
472
+ Input state:
473
+
474
+ ```json
475
+ {
476
+ "current_task": null,
477
+ "last_completed_task": "05-refactor",
478
+ "next_task": "05-refactor",
479
+ "selected_refactor_step": "step-03-extract-service",
480
+ "completed_step_ids": [
481
+ "step-01-rename-module"
482
+ ],
483
+ "status": "failed",
484
+ "artifacts_dir": ".prodify/artifacts",
485
+ "notes": [
486
+ "Task 06 reported a regression for step-03-extract-service."
487
+ ]
488
+ }
489
+ ```
490
+
491
+ Resolver output:
492
+
493
+ ```json
494
+ {
495
+ "decision": "retry",
496
+ "resolved_task": "05-refactor",
497
+ "reason": "retry_failed_selected_step",
498
+ "resume_condition": "correct the failure cause first",
499
+ "state_requirements": [
500
+ "selected_refactor_step must remain step-03-extract-service"
501
+ ]
502
+ }
503
+ ```
504
+
505
+ ### Example 5 - Blocked Schema Drift
506
+ Input state:
507
+
508
+ ```json
509
+ {
510
+ "current_task": "01-understand",
511
+ "last_completed_task": null,
512
+ "next_task": "01-understand",
513
+ "selected_refactor_step": null,
514
+ "status": "ready",
515
+ "artifacts_dir": ".prodify/artifacts",
516
+ "notes": []
517
+ }
518
+ ```
519
+
520
+ Resolver output:
521
+
522
+ ```json
523
+ {
524
+ "decision": "stop_blocked",
525
+ "resolved_task": null,
526
+ "reason": "run_state_schema_incomplete",
527
+ "resume_condition": "add the required completed_step_ids field",
528
+ "state_requirements": [
529
+ "completed_step_ids"
530
+ ]
531
+ }
532
+ ```
533
+
534
+ ### Example 6 - Terminal Completion
535
+ Input state:
536
+
537
+ ```json
538
+ {
539
+ "current_task": null,
540
+ "last_completed_task": "06-validate",
541
+ "next_task": null,
542
+ "selected_refactor_step": null,
543
+ "completed_step_ids": [
544
+ "step-01-rename-module",
545
+ "step-02-add-guard-clause",
546
+ "step-03-extract-service"
547
+ ],
548
+ "status": "complete",
549
+ "artifacts_dir": ".prodify/artifacts",
550
+ "notes": []
551
+ }
552
+ ```
553
+
554
+ Resolver output:
555
+
556
+ ```json
557
+ {
558
+ "decision": "stop_complete",
559
+ "resolved_task": null,
560
+ "reason": "workflow_complete",
561
+ "resume_condition": "none",
562
+ "state_requirements": []
563
+ }
564
+ ```
565
+
566
+ ## Implementation Notes
567
+
568
+ - Keep `run_state.json` authoritative; use other artifacts only for confirmation or ambiguity detection.
569
+ - Prefer blocking on incomplete schema or inconclusive validation over inventing progress.
570
+ - The resolver should be pure decision logic; it does not mutate state or rewrite artifacts.