prizmkit 1.1.191 → 1.1.192

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 (169) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/antigravity/skill-adapter.js +13 -4
  3. package/bundled/adapters/codex/skill-adapter.js +28 -8
  4. package/bundled/adapters/cursor/skill-adapter.js +13 -4
  5. package/bundled/adapters/pi/skill-adapter.js +28 -7
  6. package/bundled/dev-pipeline/.env.example +4 -12
  7. package/bundled/dev-pipeline/README.md +5 -10
  8. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -6
  9. package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
  10. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
  11. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
  12. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
  13. package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -76
  14. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +125 -67
  15. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +77 -430
  16. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +93 -49
  17. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -3
  18. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
  19. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +36 -14
  20. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +206 -151
  21. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +2 -23
  22. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +15 -134
  23. package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
  24. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +68 -83
  25. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
  26. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -29
  27. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
  28. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
  29. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +276 -217
  30. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +124 -122
  31. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
  32. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +183 -130
  33. package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
  34. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2780 -0
  35. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -101
  36. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
  37. package/bundled/dev-pipeline/scripts/check-session-status.py +43 -19
  38. package/bundled/dev-pipeline/scripts/continuation.py +6 -4
  39. package/bundled/dev-pipeline/scripts/detect-stuck.py +28 -28
  40. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +7 -2
  41. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -2
  42. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
  43. package/bundled/dev-pipeline/scripts/init-change-artifact.py +8 -2
  44. package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
  45. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
  46. package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
  47. package/bundled/dev-pipeline/scripts/prompt_framework.py +56 -9
  48. package/bundled/dev-pipeline/scripts/status_common.py +591 -0
  49. package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
  50. package/bundled/dev-pipeline/scripts/update-checkpoint.py +227 -65
  51. package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
  52. package/bundled/dev-pipeline/scripts/utils.py +5 -12
  53. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +4 -4
  54. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
  55. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
  56. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
  57. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
  58. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
  59. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
  60. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
  61. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
  62. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
  63. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
  64. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
  65. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
  66. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
  67. package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
  68. package/bundled/dev-pipeline/tests/_helpers.py +418 -0
  69. package/bundled/dev-pipeline/tests/conftest.py +45 -1
  70. package/bundled/dev-pipeline/tests/test_auto_skip.py +4 -69
  71. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +126 -1
  72. package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +257 -0
  73. package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +500 -0
  74. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +59 -117
  75. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +12 -10
  76. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +431 -3099
  77. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +7 -8
  78. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -1
  79. package/bundled/dev-pipeline/tests/test_reset_modes.py +15 -27
  80. package/bundled/dev-pipeline/tests/test_reset_preserve.py +54 -139
  81. package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +766 -0
  82. package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +1257 -0
  83. package/bundled/dev-pipeline/tests/test_runtime_helper.py +97 -20
  84. package/bundled/dev-pipeline/tests/test_session_launch.py +1101 -0
  85. package/bundled/dev-pipeline/tests/test_stream_progress.py +585 -0
  86. package/bundled/dev-pipeline/tests/test_unified_cli.py +155 -2034
  87. package/bundled/dev-pipeline/tests/test_utils.py +3 -3
  88. package/bundled/skills/_metadata.json +9 -63
  89. package/bundled/skills/app-planner/SKILL.md +32 -303
  90. package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
  91. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  92. package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
  93. package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
  94. package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
  95. package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
  96. package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
  97. package/bundled/skills/bug-planner/SKILL.md +54 -435
  98. package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
  99. package/bundled/skills/bug-planner/references/input-formats.md +32 -0
  100. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
  101. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
  102. package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
  103. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
  104. package/bundled/skills/feature-planner/SKILL.md +60 -439
  105. package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
  106. package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
  107. package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
  108. package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
  109. package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
  110. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
  111. package/bundled/skills/feature-workflow/SKILL.md +1 -2
  112. package/bundled/skills/prizmkit/SKILL.md +7 -1
  113. package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
  114. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
  115. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
  116. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
  117. package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
  118. package/bundled/skills/prizmkit-init/SKILL.md +24 -127
  119. package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
  120. package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
  121. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
  122. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
  123. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
  124. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
  125. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
  126. package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
  127. package/bundled/skills/prizmkit-test/SKILL.md +25 -133
  128. package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
  129. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
  130. package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
  131. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
  132. package/bundled/skills/recovery-workflow/SKILL.md +7 -7
  133. package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
  134. package/bundled/skills/recovery-workflow/references/detection.md +1 -3
  135. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
  136. package/bundled/templates/project-memory-template.md +1 -2
  137. package/package.json +1 -1
  138. package/src/scaffold.js +28 -7
  139. package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
  140. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
  141. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
  142. package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
  143. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
  144. package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
  145. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
  146. package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
  147. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
  148. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
  149. package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
  150. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
  151. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
  152. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
  153. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
  154. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
  155. package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
  156. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
  157. package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
  158. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
  159. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
  160. package/bundled/skills/refactor-planner/SKILL.md +0 -467
  161. package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
  162. package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
  163. package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
  164. package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
  165. package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
  166. package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
  167. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
  168. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
  169. package/bundled/skills/refactor-workflow/SKILL.md +0 -205
@@ -0,0 +1,418 @@
1
+ """Shared helper utilities for dev-pipeline unit and integration tests."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+ from types import SimpleNamespace
11
+
12
+ TESTS_ROOT = Path(__file__).resolve().parent
13
+ PIPELINE_ROOT = TESTS_ROOT.parent
14
+ REPO_ROOT = PIPELINE_ROOT.parent
15
+ CLI_PATH = PIPELINE_ROOT / "cli.py"
16
+
17
+
18
+ def python_310_plus() -> str:
19
+ """Return a Python >=3.10 interpreter path for CLI subprocess tests."""
20
+ if sys.version_info >= (3, 10):
21
+ return sys.executable
22
+ for executable in ("python3.12", "python3.11", "python3.10"):
23
+ resolved = shutil.which(executable)
24
+ if resolved:
25
+ return resolved
26
+ return sys.executable
27
+
28
+
29
+ PYTHON_310_PLUS = python_310_plus()
30
+
31
+
32
+ def make_runtime_paths(tmp_path: Path, name: str = "project"):
33
+ """Create a minimal project root with .prizmkit/plans and resolve RuntimePaths."""
34
+ from prizmkit_runtime.paths import resolve_runtime_paths
35
+
36
+ project = tmp_path / name
37
+ (project / ".prizmkit" / "plans").mkdir(parents=True, exist_ok=True)
38
+ return resolve_runtime_paths(pipeline_root=PIPELINE_ROOT, project_root=project)
39
+
40
+
41
+ def init_git_repo(
42
+ root: Path,
43
+ *,
44
+ initial_branch: str = "main",
45
+ user_name: str = "Test User",
46
+ user_email: str = "test@example.invalid",
47
+ initial_files: dict[str, str] | None = None,
48
+ initial_commit_message: str = "initial",
49
+ ) -> Path:
50
+ """Initialize a self-contained Git repository without relying on ~/.gitconfig."""
51
+ root.mkdir(parents=True, exist_ok=True)
52
+ subprocess.run(["git", "init", "-b", initial_branch], cwd=root, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
53
+ subprocess.run(["git", "config", "user.name", user_name], cwd=root, check=True)
54
+ subprocess.run(["git", "config", "user.email", user_email], cwd=root, check=True)
55
+ subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=root, check=True)
56
+ files = initial_files if initial_files is not None else {"README.md": "fixture\n"}
57
+ for rel, content in files.items():
58
+ target = root / rel
59
+ target.parent.mkdir(parents=True, exist_ok=True)
60
+ target.write_text(content, encoding="utf-8")
61
+ if files:
62
+ subprocess.run(["git", "add", "."], cwd=root, check=True)
63
+ subprocess.run(["git", "commit", "-qm", initial_commit_message], cwd=root, check=True)
64
+ return root
65
+
66
+
67
+ def write_fake_cli(path: Path, body: str) -> Path:
68
+ """Write an executable Python fake CLI script for subprocess/session tests."""
69
+ path.parent.mkdir(parents=True, exist_ok=True)
70
+ if not body.startswith("#!"):
71
+ body = "#!/usr/bin/env python3\n" + body
72
+ path.write_text(body, encoding="utf-8")
73
+ path.chmod(0o755)
74
+ return path
75
+
76
+
77
+ def load_progress_parser_module():
78
+ import importlib.util
79
+
80
+ parser_path = PIPELINE_ROOT / "scripts" / "parse-stream-progress.py"
81
+ spec = importlib.util.spec_from_file_location("parse_stream_progress", parser_path)
82
+ module = importlib.util.module_from_spec(spec)
83
+ assert spec.loader is not None
84
+ spec.loader.exec_module(module)
85
+ return module
86
+
87
+
88
+ _make_paths = make_runtime_paths
89
+
90
+
91
+ def _write_feature_list(paths):
92
+ paths.feature_plan.write_text(
93
+ json.dumps(
94
+ {
95
+ "$schema": "dev-pipeline-feature-list-v1",
96
+ "project_name": "Fake",
97
+ "features": [
98
+ {"id": "F-001", "title": "Low", "status": "pending", "priority": "low", "dependencies": []},
99
+ {"id": "F-002", "title": "Critical", "status": "pending", "priority": "critical", "dependencies": []},
100
+ {"id": "F-003", "title": "Blocked", "status": "pending", "priority": "high", "dependencies": ["F-001"]},
101
+ ],
102
+ }
103
+ ),
104
+ encoding="utf-8",
105
+ )
106
+
107
+
108
+ def _write_family_plan(paths, kind, items):
109
+ plan_config = {
110
+ "feature": (paths.feature_plan, "features", "dev-pipeline-feature-list-v1"),
111
+ "bugfix": (paths.bugfix_plan, "bugs", "dev-pipeline-bug-fix-list-v1"),
112
+ }
113
+ plan_path, list_key, schema = plan_config[kind]
114
+ plan_path.write_text(
115
+ json.dumps({"$schema": schema, "project_name": "Fake", list_key: items}),
116
+ encoding="utf-8",
117
+ )
118
+ return plan_path
119
+
120
+
121
+ def _write_semantic_completion_checkpoint(project_root, artifact_dir, workflow_type="feature-pipeline"):
122
+ contracts = {
123
+ "feature-pipeline": (
124
+ "feature_state",
125
+ [
126
+ "prizmkit-implement", "prizmkit-code-review", "prizmkit-test",
127
+ "completion-summary", "prizmkit-retrospective", "prizmkit-committer",
128
+ ],
129
+ ),
130
+ "bugfix-pipeline": (
131
+ "bugfix_state",
132
+ [
133
+ "prizmkit-implement", "prizmkit-code-review", "prizmkit-test",
134
+ "bug-report", "prizmkit-retrospective", "prizmkit-committer",
135
+ ],
136
+ ),
137
+ }
138
+ state_key, skills = contracts[workflow_type]
139
+ steps = []
140
+ previous = None
141
+ for index, skill in enumerate(skills, start=1):
142
+ step = {
143
+ "id": f"S{index:02d}",
144
+ "skill": skill,
145
+ "name": skill,
146
+ "status": "completed",
147
+ "required_artifacts": [],
148
+ "depends_on": previous,
149
+ }
150
+ if skill == "prizmkit-implement":
151
+ step["stage_result"] = "IMPLEMENTED"
152
+ if skill == "prizmkit-code-review":
153
+ step["stage_result"] = "REVIEW_PASS"
154
+ if skill == "prizmkit-test":
155
+ step["stage_result"] = "TEST_PASS"
156
+ relative_artifact = artifact_dir.relative_to(project_root)
157
+ step["required_artifacts"] = [
158
+ str(relative_artifact / "test-report.md"),
159
+ str(relative_artifact / "test-result.json"),
160
+ ]
161
+ if skill == "prizmkit-retrospective":
162
+ step["stage_result"] = "RETRO_COMPLETE"
163
+ if skill == "prizmkit-committer":
164
+ step["stage_result"] = "COMMITTED"
165
+ steps.append(step)
166
+ previous = step["id"]
167
+ artifact_dir.mkdir(parents=True, exist_ok=True)
168
+ (artifact_dir / "test-report.md").write_text(
169
+ "# Test Report\n\n## Final Result\n\n- Result: TEST_PASS\n",
170
+ encoding="utf-8",
171
+ )
172
+ (artifact_dir / "test-result.json").write_text(
173
+ json.dumps({
174
+ "schema_version": 1,
175
+ "result": "TEST_PASS",
176
+ "report": "test-report.md",
177
+ "main_review_rounds": 1,
178
+ "independent_review": {
179
+ "status": "downgraded",
180
+ "responses": 0,
181
+ "downgrade_reason": "read-only continuation capability unavailable",
182
+ "final_state_rechecked": False,
183
+ },
184
+ "repair_rounds": 0,
185
+ "production_changed": False,
186
+ "unresolved_items": [],
187
+ }),
188
+ encoding="utf-8",
189
+ )
190
+ runtime_commit_hash = "b" * 40
191
+ runtime_base_head = "a" * 40
192
+ head = subprocess.run(
193
+ ["git", "rev-parse", "HEAD"],
194
+ cwd=project_root,
195
+ stdout=subprocess.PIPE,
196
+ stderr=subprocess.DEVNULL,
197
+ text=True,
198
+ check=False,
199
+ )
200
+ parent = subprocess.run(
201
+ ["git", "rev-parse", "HEAD^"],
202
+ cwd=project_root,
203
+ stdout=subprocess.PIPE,
204
+ stderr=subprocess.DEVNULL,
205
+ text=True,
206
+ check=False,
207
+ )
208
+ if head.returncode == 0 and parent.returncode == 0:
209
+ runtime_commit_hash = head.stdout.strip()
210
+ runtime_base_head = parent.stdout.strip()
211
+ checkpoint = artifact_dir / "workflow-checkpoint.json"
212
+ checkpoint.write_text(
213
+ json.dumps({
214
+ "version": 1,
215
+ "workflow_type": workflow_type,
216
+ "steps": steps,
217
+ state_key: {
218
+ "repair_round": 0,
219
+ "terminal_status": "WORKFLOW_COMPLETED",
220
+ "runtime_base_head": runtime_base_head,
221
+ "runtime_commit_hash": runtime_commit_hash,
222
+ },
223
+ }),
224
+ encoding="utf-8",
225
+ )
226
+ return checkpoint
227
+
228
+
229
+ def _install_runner_session_fakes(monkeypatch, runners, *, statuses=("success",), update_status="completed", max_retries=3):
230
+ from prizmkit_runtime.runner_models import PromptGenerationResult, SessionClassification
231
+
232
+ prompt_calls = []
233
+ launch_cwds = []
234
+ launch_configs = []
235
+ updates = []
236
+ cleanup_calls = []
237
+ merge_calls = []
238
+ wip_calls = []
239
+ restore_calls = []
240
+ events = []
241
+ status_queue = list(statuses)
242
+
243
+ monkeypatch.setattr(
244
+ runners,
245
+ "load_runtime_config",
246
+ lambda paths: SimpleNamespace(
247
+ ai_client=SimpleNamespace(command="fake-ai", platform="codebuddy"),
248
+ model="fallback-model",
249
+ effort=None,
250
+ ),
251
+ )
252
+ monkeypatch.setattr(runners, "detect_stream_json_support", lambda command, platform: SimpleNamespace(enabled=False))
253
+ monkeypatch.setattr(runners, "start_item", lambda *args, **kwargs: SimpleNamespace(ok=True, text="", data={"new_status": "in_progress"}))
254
+ monkeypatch.setattr(runners, "commit_preflight_ready_changes", lambda *args, **kwargs: SimpleNamespace(attempted=False, committed=False, ok=True, result=None))
255
+ monkeypatch.setattr(runners, "commit_pre_branch_bookkeeping", lambda *args, **kwargs: None)
256
+ monkeypatch.setattr(runners, "commit_final_bookkeeping", lambda *args, **kwargs: None)
257
+ monkeypatch.setattr(runners, "commit_task_branch_changes", lambda *args, **kwargs: None)
258
+ monkeypatch.setattr(
259
+ runners,
260
+ "finalize_accepted_workspace_commit",
261
+ lambda *args, **kwargs: SimpleNamespace(
262
+ status="not_needed",
263
+ reason="accepted_workspace_clean",
264
+ committed=False,
265
+ commit_hash="",
266
+ ),
267
+ )
268
+ monkeypatch.setattr(runners, "current_branch", lambda _root: "main")
269
+ monkeypatch.setattr(runners, "_session_id", lambda item_id: f"{item_id}-session-{len(prompt_calls) + 1}")
270
+ monkeypatch.setattr(
271
+ runners,
272
+ "run_git_command",
273
+ lambda project_root, args: SimpleNamespace(return_code=0, stdout="base-head\n", stderr="", args=tuple(args)),
274
+ )
275
+
276
+ def fake_generate_prompt(family, invocation, **kwargs):
277
+ events.append("prompt")
278
+ prompt_calls.append(kwargs)
279
+ session_paths = kwargs["session_paths"]
280
+ execution_root = kwargs.get("execution_root") or kwargs["project_root"]
281
+ return PromptGenerationResult(
282
+ output_path=session_paths.prompt_path,
283
+ model="per-item-model",
284
+ checkpoint_path=execution_root / ".prizmkit" / "specs" / "001-low" / "workflow-checkpoint.json",
285
+ artifact_path=execution_root / ".prizmkit" / "specs" / "001-low",
286
+ raw={},
287
+ )
288
+
289
+ class FakeLauncher:
290
+ def __init__(self, config):
291
+ self.config = config
292
+
293
+ def run(self):
294
+ launch_cwds.append(self.config.cwd)
295
+ launch_configs.append(self.config)
296
+ return SimpleNamespace(progress_summary=SimpleNamespace(), fatal_error_code="")
297
+
298
+ def fake_classify(*args, **kwargs):
299
+ status = status_queue.pop(0)
300
+ return SessionClassification(
301
+ status,
302
+ reason=status,
303
+ fatal_error_code="context_overflow" if status == "context_overflow" else "",
304
+ progress_fingerprint={"head_commit": status},
305
+ no_progress_count=0,
306
+ )
307
+
308
+ def fake_update(family, invocation, item_id, session_status, session_id, project_root, **metadata):
309
+ updates.append((session_status, session_id, metadata))
310
+ normal_retry_count = sum(
311
+ status in {"context_overflow", "crashed", "timed_out", "failed"}
312
+ for status, *_ in updates
313
+ )
314
+ infra_error_count = sum(status == "infra_error" for status, *_ in updates)
315
+ current_update_status = update_status
316
+ if session_status in {"context_overflow", "crashed", "timed_out", "failed"}:
317
+ if normal_retry_count >= max_retries:
318
+ current_update_status = "failed"
319
+ elif len(status_queue) > 0:
320
+ current_update_status = "in_progress"
321
+ elif session_status == "infra_error" and len(status_queue) > 0:
322
+ current_update_status = "in_progress"
323
+ return SimpleNamespace(
324
+ ok=True,
325
+ text="",
326
+ data={
327
+ "new_status": current_update_status,
328
+ "retry_count": normal_retry_count,
329
+ "infra_error_count": infra_error_count,
330
+ "continuation_count": len(updates),
331
+ "context_overflow_count": sum(status == "context_overflow" for status, *_ in updates),
332
+ },
333
+ )
334
+
335
+ def fake_restore_wip(project_root, **kwargs):
336
+ events.append("restore")
337
+ restore_calls.append((project_root, kwargs))
338
+ return SimpleNamespace(
339
+ ok=True,
340
+ restored=False,
341
+ reason="runtime_wip_not_found",
342
+ wip_head="",
343
+ restored_head="",
344
+ )
345
+
346
+ monkeypatch.setattr(runners, "generate_prompt", fake_generate_prompt)
347
+ monkeypatch.setattr(runners, "AISessionLauncher", FakeLauncher)
348
+ monkeypatch.setattr(runners, "classify_session", fake_classify)
349
+ monkeypatch.setattr(runners, "update_item", fake_update)
350
+ monkeypatch.setattr(runners, "restore_runtime_wip", fake_restore_wip, raising=False)
351
+ return SimpleNamespace(
352
+ prompt_calls=prompt_calls,
353
+ launch_cwds=launch_cwds,
354
+ launch_configs=launch_configs,
355
+ updates=updates,
356
+ cleanup_calls=cleanup_calls,
357
+ merge_calls=merge_calls,
358
+ wip_calls=wip_calls,
359
+ restore_calls=restore_calls,
360
+ events=events,
361
+ )
362
+
363
+
364
+ def _init_bookkeeping_repo(project_root, *, configure_identity=True):
365
+ subprocess.run(["git", "init", "-b", "main"], cwd=project_root, check=True, stdout=subprocess.DEVNULL)
366
+ if configure_identity:
367
+ subprocess.run(["git", "config", "user.email", "test@example.com"], cwd=project_root, check=True)
368
+ subprocess.run(["git", "config", "user.name", "Test"], cwd=project_root, check=True)
369
+ (project_root / "staged.txt").write_text("base staged\n", encoding="utf-8")
370
+ (project_root / "unstaged.txt").write_text("base unstaged\n", encoding="utf-8")
371
+ subprocess.run(["git", "add", "staged.txt", "unstaged.txt"], cwd=project_root, check=True)
372
+ subprocess.run(
373
+ [
374
+ "git",
375
+ "-c",
376
+ "user.email=test@example.com",
377
+ "-c",
378
+ "user.name=Test",
379
+ "commit",
380
+ "-m",
381
+ "base",
382
+ ],
383
+ cwd=project_root,
384
+ check=True,
385
+ stdout=subprocess.DEVNULL,
386
+ )
387
+
388
+
389
+ def _init_git_repo_for_invalid_checkpoint_test(tmp_path):
390
+ subprocess.run(["git", "init", "-b", "main"], cwd=tmp_path, check=True, stdout=subprocess.DEVNULL)
391
+ subprocess.run(["git", "config", "user.email", "test@example.com"], cwd=tmp_path, check=True)
392
+ subprocess.run(["git", "config", "user.name", "Test"], cwd=tmp_path, check=True)
393
+ (tmp_path / "base.txt").write_text("base", encoding="utf-8")
394
+ subprocess.run(["git", "add", "base.txt"], cwd=tmp_path, check=True)
395
+ subprocess.run(["git", "commit", "-m", "base"], cwd=tmp_path, check=True, stdout=subprocess.DEVNULL)
396
+ return subprocess.run(["git", "rev-parse", "HEAD"], cwd=tmp_path, check=True, stdout=subprocess.PIPE, text=True).stdout.strip()
397
+
398
+
399
+ def _terminal_success_result(tmp_path):
400
+ from prizmkit_runtime.sessions import AISessionCommand, AISessionResult
401
+ from prizmkit_runtime.status import ProgressSummary
402
+
403
+ log = tmp_path / "session.log"
404
+ log.write_text("terminal success", encoding="utf-8")
405
+ return AISessionResult(
406
+ command=AISessionCommand(("fake",), None, "claude", "stdin"),
407
+ exit_code=0,
408
+ timed_out=False,
409
+ termination_reason=None,
410
+ stale_marker=None,
411
+ fatal_error_code="",
412
+ progress_summary=ProgressSummary(result_subtype="success", terminal_result_text="Completed"),
413
+ session_log=log,
414
+ backup_log=tmp_path / "backup.log",
415
+ log_recovery=None,
416
+ started_epoch=0,
417
+ ended_epoch=1,
418
+ )
@@ -4,6 +4,8 @@ import importlib
4
4
  import os
5
5
  import sys
6
6
 
7
+ import pytest
8
+
7
9
  # Add dev-pipeline/scripts to the import path so tests can import modules
8
10
  # without requiring package installation.
9
11
  _scripts_dir = os.path.join(os.path.dirname(__file__), "..", "scripts")
@@ -24,6 +26,48 @@ def _load_hyphenated_module(module_name, filename):
24
26
  # Register hyphenated script files so tests can import them with underscores.
25
27
  _load_hyphenated_module("generate_bootstrap_prompt", "generate-bootstrap-prompt.py")
26
28
  _load_hyphenated_module("generate_bugfix_prompt", "generate-bugfix-prompt.py")
27
- _load_hyphenated_module("generate_refactor_prompt", "generate-refactor-prompt.py")
28
29
  _load_hyphenated_module("update_feature_status", "update-feature-status.py")
29
30
  _load_hyphenated_module("update_checkpoint", "update-checkpoint.py")
31
+
32
+
33
+ _ISOLATED_ENV_VARS = (
34
+ "AI_CLI",
35
+ "CODEBUDDY_CLI",
36
+ "PRIZMKIT_PLATFORM",
37
+ "PRIZMKIT_EFFORT",
38
+ "CLAUDECODE",
39
+ "CLAUDE_CODE",
40
+ "MODEL",
41
+ "USE_WORKTREE",
42
+ "DEV_BRANCH",
43
+ "STOP_ON_FAILURE",
44
+ "AUTO_PUSH",
45
+ "MAX_RETRIES",
46
+ "VERBOSE",
47
+ "HEARTBEAT_INTERVAL",
48
+ "HEARTBEAT_STALE_THRESHOLD",
49
+ "STALE_KILL_THRESHOLD",
50
+ "CLAUDE_HOME",
51
+ "CLAUDE_CONFIG_DIR",
52
+ "CLAUDE_PROJECTS_DIR",
53
+ "CODEX_HOME",
54
+ "CODEBUDDY_HOME",
55
+ "CODEBUDDY_CONFIG_DIR",
56
+ )
57
+
58
+
59
+ @pytest.fixture(autouse=True)
60
+ def _isolate_test_environment(tmp_path_factory, monkeypatch):
61
+ """Isolate HOME, provider overrides, and global Git config per test."""
62
+ isolated_root = tmp_path_factory.mktemp("isolated_env")
63
+ isolated_home = isolated_root / "_isolated_home"
64
+ isolated_home.mkdir(parents=True, exist_ok=True)
65
+ empty_gitconfig = isolated_root / "_empty.gitconfig"
66
+ empty_gitconfig.write_text("", encoding="utf-8")
67
+
68
+ monkeypatch.setenv("HOME", str(isolated_home))
69
+ monkeypatch.setenv("USERPROFILE", str(isolated_home))
70
+ monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(empty_gitconfig))
71
+ monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
72
+ for var in _ISOLATED_ENV_VARS:
73
+ monkeypatch.delenv(var, raising=False)
@@ -152,25 +152,6 @@ class TestContextOverflowRetrySemantics:
152
152
  }],
153
153
  },
154
154
  },
155
- {
156
- "script": scripts_dir / "update-refactor-status.py",
157
- "list_option": "--refactor-list",
158
- "id_option": "--refactor-id",
159
- "id": "R-001",
160
- "list_name": "refactor-list.json",
161
- "collection": "refactors",
162
- "list_payload": {
163
- "refactors": [{
164
- "id": "R-001",
165
- "title": "Context Overflow Refactor",
166
- "description": "desc",
167
- "complexity": "medium",
168
- "priority": "medium",
169
- "status": "in_progress",
170
- "dependencies": [],
171
- }],
172
- },
173
- },
174
155
  ]
175
156
 
176
157
  def _run_case_update(self, case, list_path, state_dir, session_status, session_id="sess-1", extra_args=None):
@@ -558,7 +539,7 @@ class TestContextOverflowRetrySemantics:
558
539
  elif case["id_option"] == "--bug-id":
559
540
  conventional_summary = case_dir / ".prizmkit" / "bugfix" / case["id"] / "continuation-summary.md"
560
541
  else:
561
- conventional_summary = case_dir / ".prizmkit" / "refactor" / case["id"] / "continuation-summary.md"
542
+ raise ValueError(f"Unsupported id_option: {case['id_option']}")
562
543
  conventional_summary.parent.mkdir(parents=True)
563
544
  conventional_summary.write_text("conventional", encoding="utf-8")
564
545
  continuation_files.append(conventional_summary)
@@ -630,23 +611,6 @@ class TestContextOverflowRetrySemantics:
630
611
  }],
631
612
  },
632
613
  },
633
- {
634
- "target": "refactor",
635
- "list_name": "refactor-list.json",
636
- "state_root": "refactor",
637
- "item_id": "R-001",
638
- "list_payload": {
639
- "refactors": [{
640
- "id": "R-001",
641
- "title": "Context Overflow Refactor",
642
- "description": "desc",
643
- "complexity": "medium",
644
- "priority": "medium",
645
- "status": "failed",
646
- "dependencies": [],
647
- }],
648
- },
649
- },
650
614
  ]
651
615
 
652
616
  for case in script_cases:
@@ -777,26 +741,6 @@ def _status_snapshot_cases(scripts_dir):
777
741
  }],
778
742
  },
779
743
  },
780
- {
781
- "task": "refactor",
782
- "script": scripts_dir / "update-refactor-status.py",
783
- "list_option": "--refactor-list",
784
- "id_option": "--refactor-id",
785
- "id": "R-001",
786
- "list_name": "refactor-list.json",
787
- "collection": "refactors",
788
- "list_payload": {
789
- "refactors": [{
790
- "id": "R-001",
791
- "title": "Snapshot Refactor",
792
- "description": "desc",
793
- "complexity": "medium",
794
- "priority": "medium",
795
- "status": "in_progress",
796
- "dependencies": [],
797
- }],
798
- },
799
- },
800
744
  ]
801
745
 
802
746
 
@@ -888,7 +832,7 @@ def _continuation_conventional_path(case_dir, case):
888
832
  return case_dir / ".prizmkit" / "specs" / case["feature_slug"] / "continuation-summary.md"
889
833
  if case["task"] == "bugfix":
890
834
  return case_dir / ".prizmkit" / "bugfix" / case["id"] / "continuation-summary.md"
891
- return case_dir / ".prizmkit" / "refactor" / case["id"] / "continuation-summary.md"
835
+ raise ValueError(f"Unsupported task family: {case['task']}")
892
836
 
893
837
 
894
838
  def _build_status_updater_behavior_snapshot(tmp_path):
@@ -1613,15 +1557,6 @@ FAMILY_ORPHAN_CASES = (
1613
1557
  "prefix": "B-",
1614
1558
  "blocking_status": "needs_info",
1615
1559
  },
1616
- {
1617
- "kind": "refactor",
1618
- "script": "update-refactor-status.py",
1619
- "list_option": "--refactor-list",
1620
- "id_option": "--refactor-id",
1621
- "collection": "refactors",
1622
- "prefix": "R-",
1623
- "blocking_status": "skipped",
1624
- },
1625
1560
  )
1626
1561
 
1627
1562
 
@@ -1640,7 +1575,7 @@ def _family_item(case, number, status, dependencies=None):
1640
1575
  elif case["kind"] == "bugfix":
1641
1576
  item["severity"] = "high"
1642
1577
  else:
1643
- item["complexity"] = "medium"
1578
+ raise ValueError(f"Unsupported family: {case['kind']}")
1644
1579
  return item
1645
1580
 
1646
1581
 
@@ -1770,7 +1705,7 @@ def test_get_next_recovers_legacy_orphan_before_pipeline_completion(tmp_path, ca
1770
1705
  result = _run_family_orphan_action(case, list_path, tmp_path / "state", "get_next")
1771
1706
 
1772
1707
  payload = json.loads(result.stdout)
1773
- selected_id = payload.get("feature_id") or payload.get("bug_id") or payload.get("refactor_id")
1708
+ selected_id = payload.get("feature_id") or payload.get("bug_id")
1774
1709
  assert selected_id == child_id
1775
1710
  assert child_id in result.stdout
1776
1711
  assert _family_statuses(case, list_path)[child_id] == "pending"