prizmkit 1.1.130 → 1.1.134

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 (119) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/claude/command-adapter.js +0 -2
  3. package/bundled/dev-pipeline/.env.example +1 -1
  4. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +11 -6
  5. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +445 -8
  6. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +2 -9
  7. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +21 -1
  8. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +87 -66
  9. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +53 -3
  10. package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +55 -25
  11. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +4 -0
  12. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +119 -18
  13. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +3 -2
  14. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +411 -17
  15. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +57 -14
  16. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +5 -4
  17. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +55 -2
  18. package/bundled/dev-pipeline/scripts/prompt_framework.py +152 -1
  19. package/bundled/dev-pipeline/scripts/update-bug-status.py +53 -0
  20. package/bundled/dev-pipeline/scripts/update-checkpoint.py +294 -69
  21. package/bundled/dev-pipeline/scripts/update-feature-status.py +57 -0
  22. package/bundled/dev-pipeline/scripts/update-refactor-status.py +53 -0
  23. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +5 -5
  24. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +28 -22
  25. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +24 -10
  26. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +20 -2
  27. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +2 -2
  28. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +1 -1
  29. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +5 -10
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +9 -19
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +21 -0
  32. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +1 -1
  33. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +10 -10
  34. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +1 -1
  35. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +15 -0
  36. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +2 -2
  37. package/bundled/dev-pipeline/templates/sections/phase-commit.md +2 -2
  38. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +26 -23
  39. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +5 -5
  40. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +15 -11
  41. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +1 -1
  42. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +6 -6
  43. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +21 -0
  44. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +1 -1
  45. package/bundled/dev-pipeline/templates/sections/subagent-timeout-recovery.md +1 -1
  46. package/bundled/dev-pipeline/templates/sections/task-contract.md +4 -0
  47. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +362 -3
  48. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +349 -48
  49. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +129 -0
  50. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +91 -0
  51. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +567 -23
  52. package/bundled/dev-pipeline/tests/test_unified_cli.py +37 -10
  53. package/bundled/skills/_metadata.json +63 -26
  54. package/bundled/skills/app-planner/SKILL.md +4 -3
  55. package/bundled/skills/bug-fix-workflow/SKILL.md +89 -180
  56. package/bundled/skills/bug-planner/SKILL.md +12 -27
  57. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +131 -220
  58. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +36 -90
  59. package/bundled/skills/feature-pipeline-launcher/SKILL.md +129 -271
  60. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +35 -76
  61. package/bundled/skills/feature-planner/SKILL.md +27 -22
  62. package/bundled/skills/feature-planner/assets/planning-guide.md +4 -4
  63. package/bundled/skills/feature-workflow/SKILL.md +94 -121
  64. package/bundled/skills/prizmkit/SKILL.md +130 -94
  65. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +181 -0
  66. package/bundled/skills/prizmkit-code-review/SKILL.md +132 -86
  67. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +243 -0
  68. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +42 -1
  69. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +181 -0
  70. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +93 -1
  71. package/bundled/skills/prizmkit-committer/SKILL.md +125 -48
  72. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +181 -0
  73. package/bundled/skills/prizmkit-implement/SKILL.md +99 -73
  74. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +1 -1
  75. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +181 -0
  76. package/bundled/skills/prizmkit-init/SKILL.md +5 -5
  77. package/bundled/skills/prizmkit-plan/SKILL.md +146 -105
  78. package/bundled/skills/prizmkit-plan/assets/plan-template.md +18 -0
  79. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +242 -0
  80. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +4 -4
  81. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +181 -0
  82. package/bundled/skills/prizmkit-retrospective/SKILL.md +111 -53
  83. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +7 -6
  84. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +5 -4
  85. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +181 -0
  86. package/bundled/skills/prizmkit-test/SKILL.md +52 -6
  87. package/bundled/skills/prizmkit-test/assets/authoritative-records.schema.json +63 -12
  88. package/bundled/skills/prizmkit-test/assets/evidence-manifest.schema.json +1 -1
  89. package/bundled/skills/prizmkit-test/assets/evidence-package-template.json +13 -0
  90. package/bundled/skills/prizmkit-test/references/evidence-protocol.md +6 -1
  91. package/bundled/skills/prizmkit-test/references/evidence-request-protocol.md +8 -1
  92. package/bundled/skills/prizmkit-test/references/examples.md +1 -1
  93. package/bundled/skills/prizmkit-test/references/test-generation-steps.md +4 -1
  94. package/bundled/skills/prizmkit-test/references/test-report-template.md +1 -1
  95. package/bundled/skills/prizmkit-test/references/trusted-evidence-execution.md +15 -0
  96. package/bundled/skills/prizmkit-test/references/workflow-state-protocol.md +181 -0
  97. package/bundled/skills/prizmkit-test/scripts/build_test_evidence.py +744 -23
  98. package/bundled/skills/prizmkit-test/scripts/validate_test_evidence.py +194 -15
  99. package/bundled/skills/prizmkit-workflow/SKILL.md +266 -0
  100. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +181 -0
  101. package/bundled/skills/recovery-workflow/SKILL.md +62 -241
  102. package/bundled/skills/recovery-workflow/evals/evals.json +17 -33
  103. package/bundled/skills/recovery-workflow/references/detection.md +28 -52
  104. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +105 -439
  105. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +136 -275
  106. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +53 -88
  107. package/bundled/skills/refactor-planner/SKILL.md +12 -57
  108. package/bundled/skills/refactor-planner/references/behavior-preservation.md +111 -230
  109. package/bundled/skills/refactor-planner/references/error-recovery.md +37 -0
  110. package/bundled/skills/refactor-planner/references/planning-phases.md +11 -17
  111. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +1 -1
  112. package/bundled/skills/refactor-workflow/SKILL.md +98 -139
  113. package/bundled/templates/project-memory-template.md +4 -4
  114. package/package.json +1 -1
  115. package/src/index.js +4 -0
  116. package/src/prompts.js +10 -3
  117. package/src/scaffold.js +1 -1
  118. package/bundled/dev-pipeline/tests/test-deploy-safety.sh +0 -223
  119. package/bundled/skills/feature-pipeline-launcher/scripts/preflight-check.py +0 -462
@@ -0,0 +1,181 @@
1
+ # PrizmKit Workflow State Protocol
2
+
3
+ `workflow-state.json` is lifecycle runtime metadata for one formal requirement. It preserves stage handoff, repair routing, orchestrator ownership, and resume information without replacing authoritative artifacts or any host-owned execution checkpoint.
4
+
5
+ ## Location and Identity
6
+
7
+ ```text
8
+ .prizmkit/state/workflows/<requirement-slug>.json
9
+ ```
10
+
11
+ The state file is created only when a lifecycle runs. The active `artifact_dir` is the generic requirement artifact root and must be preserved exactly across every stage:
12
+
13
+ ```text
14
+ .prizmkit/specs/<requirement-slug>/
15
+ .prizmkit/bugfix/<bug-id>/
16
+ .prizmkit/refactor/<refactor-id>/
17
+ ```
18
+
19
+ Never select a different most-recent plan when resuming or handing off. Any execution checkpoint maintained by an external host remains separate from this lifecycle state. Never merge, substitute, or infer one schema from the other. The target project controls whether generated `.prizmkit/` files are committed, ignored, or shared.
20
+
21
+ ## Authority
22
+
23
+ The state file is an index, not the authority for stage completion:
24
+
25
+ | Information | Authority |
26
+ |---|---|
27
+ | Requirement goals and acceptance criteria | `{artifact_dir}/spec.md` |
28
+ | Implementation tasks and completion | `{artifact_dir}/plan.md` plus current workspace |
29
+ | Review findings and verdict | `{artifact_dir}/review-report.md` final result |
30
+ | Test execution, verdict, and repair scope | Validated evidence package and authoritative `verdict.json` |
31
+ | Test report presentation | `{artifact_dir}/test-report.md` as a derived view only |
32
+ | Retrospective completion and result | `{artifact_dir}/retrospective-result.json` |
33
+ | Durable architecture knowledge | `.prizmkit/prizm-docs/` |
34
+ | Local commit | Git history and confirmed or authorized commit identity |
35
+ | Current stage, orchestrator, and resume entry | Workflow state |
36
+ | External orchestration progress | The external host's own checkpoint, never this state |
37
+
38
+ Every consumer compares workflow state with authoritative artifacts and the current workspace. Missing or stale state is reconstructed from those sources and is never accepted as success by itself.
39
+
40
+ ## Schema
41
+
42
+ ```json
43
+ {
44
+ "schema_version": 1,
45
+ "artifact_dir": ".prizmkit/specs/example",
46
+ "orchestrator": "prizmkit-workflow",
47
+ "stage": "test",
48
+ "status": "TEST_PASS",
49
+ "stage_result": "TEST_PASS",
50
+ "completed_stages": ["plan", "implement", "code-review", "test"],
51
+ "repair_scope": null,
52
+ "repair_round": 0,
53
+ "next_stage": "retrospective",
54
+ "resume_from": "prizmkit-retrospective"
55
+ }
56
+ ```
57
+
58
+ ### Fields
59
+
60
+ | Field | Meaning |
61
+ |---|---|
62
+ | `schema_version` | State schema version. Current value is `1`. |
63
+ | `artifact_dir` | The single generic requirement artifact root reused by every stage. |
64
+ | `orchestrator` | `prizmkit-workflow`, another semantic coordinator identifier, or `null` for direct stage use. |
65
+ | `stage` | The stage that most recently wrote state. |
66
+ | `status` | Lifecycle progression status, distinct from the domain `stage_result`. |
67
+ | `stage_result` | Domain result such as `PASS`, `NEEDS_FIXES`, `TEST_*`, `DOCS_UPDATED`, or `NO_DOC_CHANGE`. |
68
+ | `completed_stages` | Ordered stages completed for this requirement. |
69
+ | `repair_scope` | `null`, `test-infrastructure`, `production`, `runtime`, `schema`, `dependency`, `public-interface`, or `unknown`. |
70
+ | `repair_round` | Outer cross-stage repair round, from `0` through `3`. |
71
+ | `next_stage` | Next semantic stage, or `null` after commit. |
72
+ | `resume_from` | Exact atomic skill that can resume, or `null` after commit. |
73
+
74
+ ## Lifecycle and Verdict Mappings
75
+
76
+ The mandatory formal lifecycle is:
77
+
78
+ ```text
79
+ PLAN_READY
80
+ → IMPLEMENTED
81
+ → REVIEW_PASS
82
+ → TEST_PASS
83
+ → RETRO_COMPLETE
84
+ → COMMIT_PENDING
85
+ → COMMITTED
86
+ ```
87
+
88
+ No formal stage is silently optional. Domain evidence maps as follows:
89
+
90
+ ```text
91
+ review-report final PASS → status=REVIEW_PASS, stage_result=PASS
92
+ review-report final NEEDS_FIXES → status=REVIEW_NEEDS_FIXES, stage_result=NEEDS_FIXES
93
+ validated verdict TEST_PASS → status=TEST_PASS, stage_result=TEST_PASS
94
+ validated verdict TEST_FAIL → status=TEST_FAIL, stage_result=TEST_FAIL
95
+ validated verdict TEST_BLOCKED → status=TEST_BLOCKED, stage_result=TEST_BLOCKED
96
+ retrospective result DOCS_UPDATED → status=RETRO_COMPLETE, stage_result=DOCS_UPDATED
97
+ retrospective result NO_DOC_CHANGE → status=RETRO_COMPLETE, stage_result=NO_DOC_CHANGE
98
+ ```
99
+
100
+ `RETRO_COMPLETE` is the stable completion status. `DOCS_UPDATED` and `NO_DOC_CHANGE` are mutually exclusive retrospective results, not substitute statuses. A derived Markdown test report never establishes a `TEST_*` status without validated authoritative evidence.
101
+
102
+ ## Repair Routing
103
+
104
+ ```text
105
+ REVIEW_NEEDS_FIXES
106
+ → implement
107
+ → code-review
108
+ → test
109
+
110
+ TEST_FAIL with repair_scope=test-infrastructure
111
+ → implement
112
+ → test
113
+
114
+ TEST_FAIL with repair_scope=production|runtime|schema|dependency|public-interface
115
+ → implement
116
+ → code-review
117
+ → test
118
+
119
+ TEST_FAIL with repair_scope=unknown
120
+ → conservative production route only when safe
121
+ → otherwise WORKFLOW_BLOCKED
122
+
123
+ TEST_BLOCKED
124
+ → never make speculative production edits
125
+ → interactive execution stops with a prizmkit-test resume entry
126
+ → a trusted headless host may perform bounded environment recovery, then records WORKFLOW_BLOCKED if unresolved
127
+
128
+ RETRO_BLOCKED
129
+ → WORKFLOW_BLOCKED
130
+ WORKFLOW_BLOCKED
131
+ → resume only after the recorded blocker is resolved
132
+ ```
133
+
134
+ The outer workflow permits at most three automatic repair rounds. These are cross-stage rounds (`repair_round` `0` through `3`). The code-review internal loop permits at most ten completed review rounds and is separate; review-internal repairs do not increment the outer counter.
135
+
136
+ ## Orchestrator Ownership and Handoff
137
+
138
+ 1. An atomic stage performs only its own stage, writes the truthful terminal result and `next_stage`, and returns control.
139
+ 2. When `orchestrator` is non-null, only that orchestrator invokes the next skill. The atomic stage must not auto-invoke it again.
140
+ 3. Direct stage use may report one deterministic next invocation but does not claim the next stage ran.
141
+ 4. Every handoff preserves the same `artifact_dir`.
142
+ 5. External automation invokes atomic stages directly and does not invoke `prizmkit-workflow` as a nested coordinator.
143
+ 6. Workflow state never replaces or absorbs an external host's checkpoint.
144
+
145
+ ## Commit Authorization
146
+
147
+ Interactive execution:
148
+
149
+ ```text
150
+ committer previews intended files and message
151
+ → waits for explicit confirmation from the current user
152
+ → creates the local commit
153
+ ```
154
+
155
+ Trusted headless execution:
156
+
157
+ ```text
158
+ a trusted host explicitly authorizes the current local task commit
159
+ → host injects mode=<host-defined-headless-mode>, owner=<trusted-host-identifier>,
160
+ local_commit_authorized=true
161
+ → committer verifies gates and commits automatically
162
+ → no question or wait is permitted
163
+ ```
164
+
165
+ A self-declared or otherwise untrusted headless context does not authorize a commit. Remote publication remains a separate host-runtime decision.
166
+
167
+ ## Recovery
168
+
169
+ When state is missing, stale, or inconsistent:
170
+
171
+ 1. Read `spec.md` and `plan.md` from `artifact_dir` only when they are not already available in current context.
172
+ 2. Inspect task markers and the current workspace.
173
+ 3. Read the latest review report and final result when needed to establish review authority.
174
+ 4. Validate authoritative test evidence and `repair_scope`.
175
+ 5. Validate `retrospective-result.json` when retrospective is claimed complete.
176
+ 6. Verify the commit when commit is claimed complete.
177
+ 7. When an external host is active, let that host validate its own checkpoint independently; never merge the schemas.
178
+ 8. Reconstruct the latest safe predecessor and report the reconstruction.
179
+ 9. Continue only from the first incomplete or invalid stage.
180
+
181
+ Stale state never bypasses review, testing, retrospective, commit authorization, or external host checkpoint enforcement.
@@ -13,8 +13,18 @@ VERDICTS = {"PASS", "NEEDS_FIXES"}
13
13
  EVENTS = {
14
14
  "main-review-round",
15
15
  "repair-verification",
16
+ "independent-review-round",
17
+ "independent-adjudication",
18
+ "independent-review-downgrade",
16
19
  "final-verification",
17
20
  }
21
+ REVIEWER_RESULTS = {
22
+ "NO_CORRECTION_NEEDED",
23
+ "CORRECTION_NEEDED",
24
+ "REVIEW_BLOCKED",
25
+ }
26
+ ADJUDICATION_DECISIONS = {"accepted", "rejected", "unresolved"}
27
+ RECHECK_STATES = {"yes", "no", "not applicable"}
18
28
  FINAL_HEADING = "## Final Result"
19
29
 
20
30
 
@@ -59,6 +69,12 @@ def _ensure_appendable(path: Path) -> None:
59
69
  raise ReportStateError("cannot append after Final Result")
60
70
 
61
71
 
72
+ def _ensure_unique_independent_response(path: Path, response: int) -> None:
73
+ heading = f"## Independent Review Round {response}"
74
+ if heading in _report_text(path):
75
+ raise ReportStateError(f"independent response {response} was already recorded")
76
+
77
+
62
78
  def _append_section(path: Path, section: str) -> None:
63
79
  with path.open("a", encoding="utf-8") as report:
64
80
  report.write(section.rstrip() + "\n\n")
@@ -111,6 +127,76 @@ def _render_event(data: dict[str, Any]) -> str:
111
127
  ]
112
128
  )
113
129
 
130
+ if event == "independent-review-round":
131
+ response = _require_count(data, "response", maximum=5)
132
+ if response < 1:
133
+ raise ReportStateError("response must be at least 1")
134
+ result = _require_text(data, "result")
135
+ if result not in REVIEWER_RESULTS:
136
+ raise ReportStateError(f"result has invalid value: {result!r}")
137
+ corrections = _require_count(data, "corrections")
138
+ accepted = _require_count(data, "accepted")
139
+ rejected = _require_count(data, "rejected")
140
+ unresolved = _require_count(data, "unresolved")
141
+ if accepted + rejected + unresolved != corrections:
142
+ raise ReportStateError(
143
+ "accepted + rejected + unresolved must equal corrections"
144
+ )
145
+ if result == "NO_CORRECTION_NEEDED" and corrections:
146
+ raise ReportStateError(
147
+ "NO_CORRECTION_NEEDED requires zero corrections"
148
+ )
149
+ if result == "CORRECTION_NEEDED" and not corrections:
150
+ raise ReportStateError(
151
+ "CORRECTION_NEEDED requires at least one correction"
152
+ )
153
+ if result == "REVIEW_BLOCKED" and not unresolved:
154
+ raise ReportStateError("REVIEW_BLOCKED requires an unresolved correction")
155
+ return "\n".join(
156
+ [
157
+ f"## Independent Review Round {response}",
158
+ "",
159
+ f"- Result: {result}",
160
+ f"- Corrections: {corrections}",
161
+ f"- Accepted: {accepted}",
162
+ f"- Rejected: {rejected}",
163
+ f"- Unresolved: {unresolved}",
164
+ f"- Next: {_require_text(data, 'next')}",
165
+ ]
166
+ )
167
+
168
+ if event == "independent-adjudication":
169
+ decision = _require_text(data, "decision")
170
+ if decision not in ADJUDICATION_DECISIONS:
171
+ raise ReportStateError(f"decision has invalid value: {decision!r}")
172
+ return "\n".join(
173
+ [
174
+ "## Independent Adjudication",
175
+ "",
176
+ f"- Correction: {_require_text(data, 'correction')}",
177
+ f"- Decision: {decision}",
178
+ f"- Evidence: {_require_text(data, 'evidence')}",
179
+ f"- Modification: {_require_text(data, 'modification')}",
180
+ ]
181
+ )
182
+
183
+ if event == "independent-review-downgrade":
184
+ rechecked = _require_text(data, "final_state_independently_rechecked")
185
+ if rechecked not in RECHECK_STATES:
186
+ raise ReportStateError(
187
+ "final_state_independently_rechecked has invalid value: "
188
+ f"{rechecked!r}"
189
+ )
190
+ return "\n".join(
191
+ [
192
+ "## Independent Review Downgrade",
193
+ "",
194
+ f"- Reason: {_require_text(data, 'reason')}",
195
+ f"- Fallback: {_require_text(data, 'fallback')}",
196
+ f"- Final State Independently Rechecked: {rechecked}",
197
+ ]
198
+ )
199
+
114
200
  status = _require_text(data, "status")
115
201
  if status not in {"COMPLETED", "FAILED"}:
116
202
  raise ReportStateError(f"status has invalid value: {status!r}")
@@ -127,7 +213,13 @@ def _render_event(data: dict[str, Any]) -> str:
127
213
  def append_event(path: Path, data: Any) -> None:
128
214
  """Append one validated progress event to an active execution."""
129
215
  _ensure_appendable(path)
130
- _append_section(path, _render_event(_require_object(data)))
216
+ valid = _require_object(data)
217
+ if valid.get("event") == "independent-review-round":
218
+ response = _require_count(valid, "response", maximum=5)
219
+ if response < 1:
220
+ raise ReportStateError("response must be at least 1")
221
+ _ensure_unique_independent_response(path, response)
222
+ _append_section(path, _render_event(valid))
131
223
 
132
224
 
133
225
  def append_final_result(path: Path, data: Any) -> None:
@@ -1,101 +1,178 @@
1
1
  ---
2
2
  name: "prizmkit-committer"
3
- description: "Pure git commit workflow with safety checks. Stages intended files safely, generates a Conventional Commit message, commits, and verifies the result. Does not modify CHANGELOG.md or .prizmkit/prizm-docs/ by default; run /prizmkit-retrospective first only when the chosen lifecycle path requires docs sync. Trigger on: 'commit', 'submit', 'finish', 'done'. If the user says only 'ship it', clarify whether they mean commit or deploy. (project)"
3
+ description: "Final commit stage for a formal PrizmKit requirement. Verifies plan, implementation, Main-Agent review, testing, and retrospective evidence; previews and confirms interactive commits; automatically creates authorized local commits in trusted headless sessions; verifies the result; and leaves remote publication to the host runtime. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Committer
7
7
 
8
- ### When to Use
9
- - User says "commit", "submit", "finish", "done with this task"
10
- - The current lifecycle path is ready to record changes in git
11
- - Required gates for the chosen path have passed or been explicitly deemed not applicable
8
+ `/prizmkit-committer` is the final stage of the formal requirement lifecycle:
12
9
 
13
- ### When NOT to Use
14
- - No uncommitted changes exist — nothing to commit
15
- - User says only "ship it" — clarify commit vs deploy first
16
- - Current path still has required unresolved gates, such as failed tests, unresolved review findings, or required retrospective work
17
- - Mid-merge conflict resolution — handle conflicts manually before committing
10
+ ```text
11
+ prizmkit-plan
12
+ → prizmkit-implement
13
+ → prizmkit-code-review
14
+ prizmkit-test
15
+ → prizmkit-retrospective
16
+ → prizmkit-committer
17
+ ```
18
+
19
+ It does not decide which formal gates can be omitted. It verifies that all five preceding stages completed for the same `artifact_dir`, then applies the commit authorization semantics for the current execution context.
20
+
21
+ ## Atomic Stage Boundary
22
+
23
+ `prizmkit-committer` owns only final gate verification, authorization-boundary handling, local staging, commit creation, and commit verification. It writes its truthful terminal result and returns control; it must not invoke deployment or any hidden seventh stage. The active orchestrator owns lifecycle completion reporting.
24
+
25
+ ## When to Use
26
+
27
+ - Workflow state reports `RETRO_COMPLETE` with a valid `retrospective-result.json` for the active formal requirement.
28
+ - An interactive user confirms they want to create the local commit.
29
+ - A trusted headless execution context authorizes an automatic local commit.
30
+ - User says "commit", "submit", "finish", or "done" after the formal gates have completed.
31
+
32
+ ## When NOT to Use
18
33
 
19
- ## Gate Policy
34
+ - The working tree is clean and there is nothing to commit.
35
+ - Any preceding formal stage is missing, failed, blocked, or associated with a different artifact directory.
36
+ - Review has `NEEDS_FIXES` or tests have `TEST_FAIL`/`TEST_BLOCKED`.
37
+ - Retrospective has not completed, including an explicit `NO_DOC_CHANGE` result.
38
+ - User says only "ship it"; clarify commit versus deployment in interactive mode.
39
+ - A merge conflict is unresolved.
40
+ - An unknown headless caller has not supplied trusted commit authorization.
20
41
 
21
- `/prizmkit-committer` does not decide the entire lifecycle. It checks that the gates required by the chosen path are satisfied:
42
+ ## Mandatory Gate Policy
22
43
 
23
- | Path | Commit gate expectation |
44
+ For a formal requirement, all gates are mandatory:
45
+
46
+ | Gate | Required evidence |
24
47
  |---|---|
25
- | Direct edit | Verify the specific edit as appropriate; no spec/review/retro artifact required. |
26
- | Fast path | Simplified plan tasks complete; run tests or retrospective only if risk/knowledge triggers apply. |
27
- | Full path | Implementation complete; review passed; retrospective completed when docs or durable knowledge changed; tests completed when risk-triggered. |
48
+ | Plan | `spec.md`, `plan.md`, and `PLAN_READY` for the same `artifact_dir` |
49
+ | Implement | All required tasks complete and `IMPLEMENTED` |
50
+ | Code review | Final `review-report.md` result `PASS` |
51
+ | Test | Final evidence result `TEST_PASS` for the final reviewed workspace |
52
+ | Retrospective | `retrospective-result.json` with `status=RETRO_COMPLETE` and `result=DOCS_UPDATED` or `result=NO_DOC_CHANGE` |
28
53
 
29
- If a gate is missing but not applicable, state why before committing. If a gate is missing and applicable, stop and run or request the missing gate.
54
+ The committer must reject a state that merely claims a gate passed when the underlying artifact or current workspace contradicts it. If workflow state is missing, reconstruct it from authoritative artifacts and report the reconstruction before asking for confirmation.
30
55
 
31
56
  ## Workflow
32
57
 
33
- Follow these steps in order. The goal is to commit exactly the intended changes and avoid staging secrets or unrelated files.
58
+ ### Step 1: Status and Gate Check
34
59
 
35
- ### Step 1: Status Check
60
+ 1. Read the workflow state and resolve the same `artifact_dir` used by all prior stages.
61
+ 2. Verify `spec.md`, `plan.md`, final `review-report.md`, validated test evidence, `retrospective-result.json`, and the current workspace.
62
+ 3. Inspect:
36
63
 
37
64
  ```bash
38
65
  git status
66
+ git diff --stat
67
+ git diff
39
68
  ```
40
69
 
41
- - If the working tree is clean, inform the user and stop.
42
- - If changes exist, inspect modified, deleted, and untracked files before staging.
43
- - Warn about sensitive-looking files: `.env*`, `*credential*`, `*secret*`, `*.pem`, `*.key`.
70
+ 4. Inspect modified, deleted, renamed, and untracked files.
71
+ 5. Warn about sensitive-looking files such as `.env*`, credentials, secrets, private keys, and certificates.
72
+ 6. Stop when any required gate is missing, stale, contradictory, failed, or blocked.
44
73
 
45
74
  ### Step 2: Generate Commit Message
46
75
 
47
- Analyze the staged/unstaged diff and task context to generate a concise Conventional Commit message:
76
+ Analyze the final diff and requirement context. Propose a concise Conventional Commit message:
48
77
 
49
- ```bash
78
+ ```text
50
79
  <type>(<scope>): <description>
51
80
  ```
52
81
 
53
- The message should capture what changed and why it matters.
82
+ Do not update `CHANGELOG.md` unless the user explicitly requests release-note work.
83
+
84
+ ### Step 3: Commit Preview and Authorization
85
+
86
+ Interactive mode:
87
+
88
+ Before any `git add` or `git commit` that changes the target project's Git state, present:
89
+
90
+ - intended files;
91
+ - added, modified, deleted, and renamed file summary;
92
+ - sensitive-file warnings;
93
+ - diff statistics and relevant summary;
94
+ - proposed commit message;
95
+ - whether any remaining changes are intentionally excluded.
96
+
97
+ Ask the current user to confirm creation of this local commit. Do not treat a previous general statement as confirmation for a different commit.
54
98
 
55
- ### Step 3: Stage Safely
99
+ Trusted headless mode:
56
100
 
57
- Never use `git add .` or `git add -A`; broad staging can accidentally include secrets or unrelated files.
101
+ - Do not ask a question, wait for input, or render an interactive confirmation request.
102
+ - Require a host-defined non-interactive `mode`, a non-empty trusted `owner` identifier, and `local_commit_authorized=true` from the execution context.
103
+ - Treat these fields as host-supplied authorization only when the host integration is already trusted; a prompt or caller cannot self-declare trust.
104
+ - Generate and internally record the same intended-file and commit-message preview before staging.
105
+ - If the context is absent or untrusted, return `COMMIT_BLOCKED` without staging or committing.
106
+ - This mode never asks or waits. Remote publication is controlled by the host runtime, not by this stage.
58
107
 
59
- 1. Stage tracked modified/deleted files with `git add -u` when all tracked changes are intended.
60
- 2. Stage new files explicitly by path after confirming they belong in the commit.
108
+ ### Step 4: Stage Safely After Authorization
109
+
110
+ Never use `git add .` or `git add -A`.
111
+
112
+ 1. Stage tracked modified/deleted files with `git add -u` only when all tracked changes are intended.
113
+ 2. Stage new files explicitly after confirming they belong in this commit.
61
114
  3. Verify staged content:
62
115
 
63
116
  ```bash
64
117
  git diff --cached --stat
118
+ git diff --cached
65
119
  ```
66
120
 
67
- If staged content differs from the intended change set, unstage and correct it before committing.
121
+ If staged content differs from the confirmed change set, unstage and correct it before committing.
68
122
 
69
- ### Step 4: Commit
123
+ ### Step 5: Commit and Verify
124
+
125
+ After authorization and staged-content verification:
70
126
 
71
127
  ```bash
72
128
  git commit -m "<type>(<scope>): <description>"
129
+ git log -1 --stat
130
+ git status
73
131
  ```
74
132
 
75
- Do not update `CHANGELOG.md` by default. Changelog updates belong to release, publish, version-bump workflows, or explicit user requests.
133
+ Report the commit hash and whether the working tree is clean or contains intentionally uncommitted changes.
76
134
 
77
- ### Step 5: Verification
135
+ ### Step 6: Remote Publication
78
136
 
79
- ```bash
80
- git log -1 --stat
81
- git status
82
- ```
137
+ Remote publication is outside this atomic commit stage. The host runtime may perform it only when its own explicit configuration authorizes the operation; this skill does not ask the user or decide whether to publish.
83
138
 
84
- Confirm the commit was recorded and report whether the working tree is clean or has remaining intentionally uncommitted changes.
139
+ ## Workflow State
85
140
 
86
- ### Step 6: Optional Push
141
+ Before reading or updating workflow state, read `${SKILL_DIR}/references/workflow-state-protocol.md`.
87
142
 
88
- Ask user: "Push to remote?"
143
+ Before the authorization preview, set or validate:
89
144
 
90
- - Yes: run `git push`
91
- - No: stop after reporting the commit hash
145
+ ```json
146
+ {
147
+ "stage": "committer",
148
+ "status": "COMMIT_PENDING",
149
+ "stage_result": "COMMIT_PENDING",
150
+ "completed_stages": ["plan", "implement", "code-review", "test", "retrospective"],
151
+ "next_stage": "committer",
152
+ "resume_from": "prizmkit-committer"
153
+ }
154
+ ```
92
155
 
93
- **Headless mode**: If invoked with `--headless`, skip the push question, do not push, and stop after Step 5 verification.
156
+ For trusted headless execution, the validated execution context additionally contains:
94
157
 
95
- ## Examples
158
+ ```json
159
+ {
160
+ "mode": "<host-defined-headless-mode>",
161
+ "owner": "<trusted-host-identifier>",
162
+ "local_commit_authorized": true
163
+ }
164
+ ```
96
165
 
97
- ```bash
98
- git commit -m "feat(avatar): add user avatar upload with S3 storage"
99
- git commit -m "fix(auth): handle null token in refresh flow"
100
- git commit -m "docs(prizm): clarify lifecycle gate policy"
166
+ After a successful local commit, update the runtime state to:
167
+
168
+ ```json
169
+ {
170
+ "stage": "committer",
171
+ "status": "COMMITTED",
172
+ "completed_stages": ["plan", "implement", "code-review", "test", "retrospective", "committer"],
173
+ "next_stage": null,
174
+ "resume_from": null
175
+ }
101
176
  ```
177
+
178
+ The state file is generated in the target project under `.prizmkit/state/workflows/`; this skill does not prescribe whether the target project commits, ignores, or shares it.