prizmkit 1.1.192 → 1.1.193

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 (56) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/dev-pipeline/README.md +23 -34
  3. package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
  4. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -0
  5. package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -2
  6. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +2 -0
  7. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -40
  8. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -1
  9. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -22
  10. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +11 -7
  11. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +26 -20
  12. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +37 -4
  13. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +20 -41
  14. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +74 -36
  15. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -66
  16. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +271 -52
  17. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +51 -13
  18. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +43 -15
  19. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +27 -24
  20. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +0 -1
  21. package/bundled/dev-pipeline/scripts/check-session-status.py +13 -1
  22. package/bundled/dev-pipeline/scripts/continuation.py +2 -3
  23. package/bundled/dev-pipeline/scripts/detect-stuck.py +19 -5
  24. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -14
  25. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +13 -8
  26. package/bundled/dev-pipeline/scripts/init-change-artifact.py +17 -2
  27. package/bundled/dev-pipeline/scripts/prompt_framework.py +39 -21
  28. package/bundled/dev-pipeline/scripts/update-checkpoint.py +27 -0
  29. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
  30. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -6
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
  32. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +1 -1
  33. package/bundled/skills/_metadata.json +1 -1
  34. package/package.json +1 -1
  35. package/bundled/dev-pipeline/tests/_helpers.py +0 -418
  36. package/bundled/dev-pipeline/tests/conftest.py +0 -73
  37. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
  38. package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1806
  39. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1439
  40. package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +0 -257
  41. package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +0 -500
  42. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1654
  43. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -629
  44. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -2973
  45. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -321
  46. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -251
  47. package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1196
  48. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -872
  49. package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +0 -766
  50. package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +0 -1257
  51. package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
  52. package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -380
  53. package/bundled/dev-pipeline/tests/test_session_launch.py +0 -1101
  54. package/bundled/dev-pipeline/tests/test_stream_progress.py +0 -585
  55. package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -3625
  56. package/bundled/dev-pipeline/tests/test_utils.py +0 -170
@@ -1,629 +0,0 @@
1
- """Tests for generate-bugfix-prompt.py core functions."""
2
-
3
- from argparse import Namespace
4
- from pathlib import Path
5
- import json
6
- import os
7
-
8
- from generate_bugfix_prompt import (
9
- build_replacements,
10
- find_bug,
11
- format_acceptance_criteria,
12
- format_global_context,
13
- format_error_source_details,
14
- format_environment,
15
- generate_bugfix_checkpoint,
16
- bugfix_checkpoint_metadata,
17
- merge_bugfix_checkpoint_state,
18
- route_bugfix_repair,
19
- process_conditional_blocks,
20
- render_template,
21
- assemble_bugfix_sections,
22
- )
23
- from continuation import append_continuation_handoff
24
-
25
- PIPELINE_ROOT = Path(__file__).resolve().parents[1]
26
-
27
- REMOVED_MAX_LOG_ENV = "MAX_" + "LOG_SIZE"
28
- REMOVED_MAX_LOG_HUMAN = REMOVED_MAX_LOG_ENV + "_HUMAN"
29
-
30
-
31
- # ---------------------------------------------------------------------------
32
- # find_bug
33
- # ---------------------------------------------------------------------------
34
-
35
- class TestFindBug:
36
- def test_found(self):
37
- bugs = [{"id": "B-001", "title": "A"}, {"id": "B-002", "title": "B"}]
38
- assert find_bug(bugs, "B-002") == {"id": "B-002", "title": "B"}
39
-
40
- def test_not_found(self):
41
- assert find_bug([{"id": "B-001"}], "B-999") is None
42
-
43
- def test_empty_list(self):
44
- assert find_bug([], "B-001") is None
45
-
46
- def test_non_dict_items(self):
47
- assert find_bug(["garbage", 42, None, {"id": "B-001"}], "B-001") == {"id": "B-001"}
48
-
49
-
50
- # ---------------------------------------------------------------------------
51
- # format_error_source_details
52
- # ---------------------------------------------------------------------------
53
-
54
- class TestFormatErrorSourceDetails:
55
- def test_none(self):
56
- result = format_error_source_details(None)
57
- assert "no error source" in result
58
-
59
- def test_empty_dict(self):
60
- result = format_error_source_details({})
61
- assert "no error source" in result
62
-
63
- def test_stack_trace(self):
64
- source = {"type": "stack_trace", "stack_trace": "Error at line 42"}
65
- result = format_error_source_details(source)
66
- assert "Error at line 42" in result
67
- assert "Stack Trace" in result
68
-
69
- def test_error_message(self):
70
- source = {"type": "unknown", "error_message": "Something went wrong"}
71
- result = format_error_source_details(source)
72
- assert "Something went wrong" in result
73
-
74
- def test_log_pattern(self):
75
- source = {"type": "log_pattern", "log_snippet": "FATAL: connection refused"}
76
- result = format_error_source_details(source)
77
- assert "connection refused" in result
78
-
79
- def test_failed_test(self):
80
- source = {"type": "failed_test", "failed_test_path": "tests/auth.test.js"}
81
- result = format_error_source_details(source)
82
- assert "tests/auth.test.js" in result
83
-
84
- def test_user_report(self):
85
- source = {"type": "user_report", "reproduction_steps": ["Click login", "Enter bad password"]}
86
- result = format_error_source_details(source)
87
- assert "Click login" in result
88
- assert "Enter bad password" in result
89
-
90
-
91
- # ---------------------------------------------------------------------------
92
- # format_environment
93
- # ---------------------------------------------------------------------------
94
-
95
- class TestFormatEnvironment:
96
- def test_none(self):
97
- assert "not specified" in format_environment(None)
98
-
99
- def test_empty(self):
100
- assert "not specified" in format_environment({})
101
-
102
- def test_with_values(self):
103
- result = format_environment({"os": "Linux", "node": "20.1"})
104
- assert "**node**: 20.1" in result
105
- assert "**os**: Linux" in result
106
-
107
- def test_skips_empty_values(self):
108
- result = format_environment({"os": "Linux", "browser": ""})
109
- assert "**os**: Linux" in result
110
- assert "browser" not in result
111
-
112
-
113
- # ---------------------------------------------------------------------------
114
- # process_conditional_blocks
115
- # ---------------------------------------------------------------------------
116
-
117
- class TestProcessConditionalBlocks:
118
- def test_automated_removes_manual_block(self):
119
- tpl = "before\n{{IF_VERIFICATION_MANUAL_OR_HYBRID}}\nmanual content\n{{END_IF_VERIFICATION_MANUAL_OR_HYBRID}}\nafter"
120
- bug = {"verification_type": "automated"}
121
- result = process_conditional_blocks(tpl, bug)
122
- assert "manual content" not in result
123
- assert "before" in result
124
- assert "after" in result
125
-
126
- def test_manual_keeps_block(self):
127
- tpl = "before\n{{IF_VERIFICATION_MANUAL_OR_HYBRID}}\nmanual content\n{{END_IF_VERIFICATION_MANUAL_OR_HYBRID}}\nafter"
128
- bug = {"verification_type": "manual"}
129
- result = process_conditional_blocks(tpl, bug)
130
- assert "manual content" in result
131
- assert "IF_VERIFICATION" not in result
132
-
133
- def test_hybrid_keeps_block(self):
134
- tpl = "{{IF_VERIFICATION_MANUAL_OR_HYBRID}}hybrid{{END_IF_VERIFICATION_MANUAL_OR_HYBRID}}"
135
- bug = {"verification_type": "hybrid"}
136
- result = process_conditional_blocks(tpl, bug)
137
- assert "hybrid" in result
138
-
139
- def test_default_is_automated(self):
140
- tpl = "{{IF_VERIFICATION_MANUAL_OR_HYBRID}}content{{END_IF_VERIFICATION_MANUAL_OR_HYBRID}}"
141
- bug = {}
142
- result = process_conditional_blocks(tpl, bug)
143
- assert "content" not in result
144
-
145
-
146
- # ---------------------------------------------------------------------------
147
- # render_template (integration)
148
- # ---------------------------------------------------------------------------
149
-
150
- class TestRenderTemplate:
151
- def test_placeholders_replaced(self):
152
- tpl = "Bug: {{BUG_ID}} — {{BUG_TITLE}}"
153
- replacements = {"{{BUG_ID}}": "B-042", "{{BUG_TITLE}}": "Login crash"}
154
- bug = {"verification_type": "automated"}
155
- result = render_template(tpl, replacements, bug)
156
- assert result == "Bug: B-042 — Login crash"
157
-
158
- def test_conditional_and_replacement(self):
159
- tpl = (
160
- "{{IF_VERIFICATION_MANUAL_OR_HYBRID}}manual{{END_IF_VERIFICATION_MANUAL_OR_HYBRID}}"
161
- "id={{BUG_ID}}"
162
- )
163
- replacements = {"{{BUG_ID}}": "B-001"}
164
- bug = {"verification_type": "automated"}
165
- result = render_template(tpl, replacements, bug)
166
- assert "manual" not in result
167
- assert "id=B-001" in result
168
-
169
-
170
- class TestExplicitProjectRoot:
171
- def test_build_replacements_uses_cli_project_root_for_rendered_paths(self, tmp_path, monkeypatch):
172
- monkeypatch.setenv("PRIZMKIT_PLATFORM", "claude")
173
- execution_root = tmp_path / "worktree"
174
- main_checkout = tmp_path / "main"
175
- execution_root.mkdir()
176
- main_checkout.mkdir()
177
- args = Namespace(
178
- bug_list=str(main_checkout / ".prizmkit" / "plans" / "bug-fix-list.json"),
179
- bug_id="B-001",
180
- session_id="session-1",
181
- run_id="run-1",
182
- retry_count="0",
183
- resume_phase="null",
184
- state_dir=str(main_checkout / ".prizmkit" / "state" / "bugfix"),
185
- output=str(main_checkout / ".prizmkit" / "state" / "bugfix" / "B-001" / "sessions" / "session-1" / "bootstrap-prompt.md"),
186
- template=None,
187
- project_root=str(execution_root),
188
- )
189
- bug = {"id": "B-001", "title": "Worktree Bug", "description": "d"}
190
-
191
- replacements = build_replacements(
192
- args,
193
- bug,
194
- {},
195
- str(main_checkout / "dev-pipeline" / "scripts"),
196
- )
197
-
198
- assert replacements["{{PROJECT_ROOT}}"] == str(execution_root.resolve())
199
- assert "{{SESSION_STATUS_PATH}}" not in replacements
200
- assert "{{" + "DEV_" + "SUBAGENT_PATH" + "}}" not in replacements
201
- assert replacements["{{SESSION_LOG_PATH}}"].endswith(
202
- ".prizmkit/state/bugfix/B-001/sessions/session-1/logs/session.log"
203
- )
204
- assert "{{" + REMOVED_MAX_LOG_ENV + "}}" not in replacements
205
- assert "{{" + REMOVED_MAX_LOG_HUMAN + "}}" not in replacements
206
- assert "### Checkpoint Update Helper" in replacements["{{CHECKPOINT_SYSTEM}}"]
207
- assert "{{CHECKPOINT_PYTHON_CMD}}" in replacements["{{CHECKPOINT_SYSTEM}}"]
208
- assert "pipeline progress mechanism" not in replacements["{{CHECKPOINT_SYSTEM}}"]
209
- assert "prizmkit-runtime-helper.py" in replacements["{{RUNTIME_HELPER_CMD}}"]
210
-
211
-
212
- # ---------------------------------------------------------------------------
213
- # Reuse shared helpers (same as bootstrap prompt — verify they are present)
214
- # ---------------------------------------------------------------------------
215
-
216
- class TestSharedHelpers:
217
- def test_format_acceptance_criteria_items(self):
218
- result = format_acceptance_criteria(["Fix works", "No regression"])
219
- assert "- Fix works" in result
220
- assert "- No regression" in result
221
-
222
- def test_format_acceptance_criteria_empty(self):
223
- assert "none specified" in format_acceptance_criteria([])
224
-
225
- def test_format_global_context_dict(self):
226
- result = format_global_context({"lang": "Python"})
227
- assert "**lang**: Python" in result
228
-
229
-
230
- # ---------------------------------------------------------------------------
231
- # Active compaction harness rollback
232
- # ---------------------------------------------------------------------------
233
-
234
- class TestHeadlessRecoveryReframing:
235
- def test_bugfix_source_has_no_deleted_log_size_injection(self):
236
- deleted_section = "log-size-" + "awareness.md"
237
- loader = "load_" + "log_size_section"
238
- placeholder = "{{LOG_" + "SIZE_AWARENESS}}"
239
- deleted_title = "Session " + "Checkpoint Awareness"
240
- source = (PIPELINE_ROOT / "scripts" / "generate-bugfix-prompt.py").read_text(encoding="utf-8")
241
- template = (PIPELINE_ROOT / "templates" / "bugfix-bootstrap-prompt.md").read_text(encoding="utf-8")
242
-
243
- assert (PIPELINE_ROOT / "templates" / "sections" / deleted_section).exists() is False
244
- for content in (source, template):
245
- for forbidden in (deleted_section, loader, placeholder, deleted_title):
246
- assert forbidden not in content
247
-
248
- def test_bugfix_template_does_not_spawn_monitor_or_require_compact(self):
249
- content = (PIPELINE_ROOT / "templates" / "bugfix-bootstrap-prompt.md").read_text(encoding="utf-8")
250
-
251
- assert "On execution-unit timeout, preserve the active checkout and artifacts" in content
252
- assert "follow the owning contract's recovery or downgrade path" in content
253
- assert "Do not spawn persistent background subagents for headless recovery" not in content
254
- assert REMOVED_MAX_LOG_ENV not in content
255
- assert REMOVED_MAX_LOG_HUMAN not in content
256
- assert ("209" + "7152") not in content
257
- assert ("2" + "MB") not in content
258
- assert "log-size monitor" not in content
259
- assert "monitor-log" not in content
260
- assert "COMPACT_NEEDED" not in content
261
- assert "Run this command and keep it running" not in content
262
- assert "Execute `/compact`" not in content
263
- assert "run `/compact` after" not in content
264
-
265
-
266
- class TestBugfixContinuationHandoff:
267
- def test_writes_specs_and_task_local_summaries(self, tmp_path):
268
- args = Namespace(
269
- output=str(tmp_path / ".prizmkit/state/bugfix/B-007/sessions/B-007-new/bootstrap-prompt.md"),
270
- state_dir=str(tmp_path / ".prizmkit/state/bugfix"),
271
- continuation_mode="ai_error",
272
- failure_classification="ai_runtime_or_provider_error",
273
- code_retry_count="1",
274
- infra_error_count="2",
275
- max_code_retries="3",
276
- max_infra_retries="3",
277
- no_progress_count="0",
278
- progress_fingerprint=json.dumps({"git_diff_fingerprint": "diff", "head_commit": "abc", "checkpoint_cursor": "S03:pending"}),
279
- previous_session_id="B-007-old",
280
- continuation_count="1",
281
- context_overflow_count="1",
282
- active_dev_branch="bugfix/B-007",
283
- base_branch="main",
284
- continuation_summary_path=".prizmkit/specs/B-007/continuation-summary.md",
285
- )
286
- prompt = append_continuation_handoff(
287
- "BUGFIX PROMPT", args, str(tmp_path), "bugfix", "B-007", "B-007",
288
- {"steps": [{"id": "S01", "skill": "diagnose", "name": "Diagnose", "status": "pending"}]},
289
- )
290
-
291
- assert prompt.startswith("BUGFIX PROMPT")
292
- assert "This is an automatic continuation after the previous launched AI session ended with `ai_runtime_or_provider_error`." in prompt
293
- assert "Do not attempt `/compact` as the recovery mechanism." not in prompt
294
- assert ("Log " + "monitor") not in prompt
295
- assert ("log-" + "monitor") not in prompt
296
- assert (tmp_path / ".prizmkit/specs/B-007/continuation-summary.md").exists()
297
- assert (tmp_path / ".prizmkit/bugfix/B-007/continuation-summary.md").exists()
298
-
299
-
300
- HEADLESS_FORBIDDEN_PROMPT_STRINGS = [
301
- "### Interactive Claude Code Note",
302
- "### Project Conventions",
303
- "Scaffold / generated file awareness",
304
- "### Resume Behavior",
305
- "[NEEDS CLARIFICATION]",
306
- "pause for interactive input",
307
- "prizmkit-test-gate.py",
308
- "/compact",
309
- "Session " + "Checkpoint Awareness",
310
- "{{LOG_" + "SIZE_AWARENESS}}",
311
- ]
312
-
313
-
314
- def test_template_source_is_clean_for_headless_prompt_contract():
315
- content = (PIPELINE_ROOT / "templates" / "bugfix-bootstrap-prompt.md").read_text(encoding="utf-8")
316
- for forbidden in HEADLESS_FORBIDDEN_PROMPT_STRINGS:
317
- assert forbidden not in content
318
- assert "FAST_PATH=true" not in content
319
- assert "prizmkit-workflow" not in content
320
- assert "/prizmkit-test scope=this-change artifact_dir=.prizmkit/bugfix/{{BUG_ID}}/" in content
321
- assert "operation=prepare-runtime-commit" in content
322
- assert "local_commit_authorized" not in content
323
- assert "push_authorized" not in content
324
-
325
-
326
- def test_bugfix_prompt_keeps_fine_grained_phases_out_of_external_status_contract():
327
- content = (PIPELINE_ROOT / "templates" / "bugfix-bootstrap-prompt.md").read_text(encoding="utf-8")
328
- old_statuses = ["triaging", "reproducing", "fixing", "verifying"]
329
-
330
- assert "external bug-list status field" in content
331
- assert "pending`, `in_progress`, `completed`, `failed`, `skipped`, or `needs_info`" in content
332
- for status in old_statuses:
333
- assert f"status=\"{status}\"" not in content
334
- assert f"status = \"{status}\"" not in content
335
- assert f"status='{status}'" not in content
336
- assert f"status = '{status}'" not in content
337
- assert f"Set bug status to `{status}`" not in content
338
-
339
-
340
- # ---------------------------------------------------------------------------
341
- # Anti-Bash regression guardrails (F-039)
342
- # Note: grep -n, sed -n, grep -q, wc -l excluded — referenced in bugfix context
343
- # budget rules as AI tool hints, not as operational shell snippets.
344
- # | sed (trailing space) only matches pipe-to-sed operational patterns.
345
- # ---------------------------------------------------------------------------
346
-
347
- RETIRED_EXTRACTED_SNIPPETS_BUGFIX = [
348
- "find . -maxdepth",
349
- "| sed ",
350
- r"grep -c '^\- \[ \]'",
351
- "2>/dev/null",
352
- "/dev/null",
353
- "$DEV_PORT",
354
- "$!",
355
- "$HOME",
356
- "if [ ",
357
- "which playwright-cli",
358
- "which opencli",
359
- "lsof -ti",
360
- "xargs",
361
- " kill -",
362
- "kill -",
363
- "|| echo",
364
- "mkdir -p",
365
- "touch .prizmkit",
366
- ]
367
-
368
-
369
- def _render_bugfix_prompt(tmp_path, platform="claude"):
370
- """Render a complete bugfix prompt through the generator."""
371
- from generate_bugfix_prompt import main as bugfix_main
372
-
373
- project = tmp_path / "bugfix-anti-bash"
374
- project.mkdir(parents=True)
375
- (project / ".prizmkit").mkdir(exist_ok=True)
376
- (project / ".prizmkit" / "config.json").write_text(
377
- json.dumps({"platform": platform, "ai_cli": platform}), encoding="utf-8"
378
- )
379
- _ensure_skill_files(project)
380
- bug_list = project / ".prizmkit" / "plans" / "bug-fix-list.json"
381
- bug_list.parent.mkdir(parents=True)
382
- bug_list.write_text(json.dumps({
383
- "bugs": [{"id": "B-001", "title": "Broken", "description": "Fix it",
384
- "acceptance_criteria": ["Works"]}],
385
- "global_context": {"language": "Python"},
386
- }), encoding="utf-8")
387
- output = project / "bugfix-prompt.md"
388
- old_argv = os.sys.argv
389
- old_platform = os.environ.get("PRIZMKIT_PLATFORM")
390
- try:
391
- os.environ.pop("PRIZMKIT_PLATFORM", None)
392
- os.sys.argv = [
393
- "generate-bugfix-prompt.py",
394
- "--bug-list", str(bug_list),
395
- "--bug-id", "B-001",
396
- "--session-id", "session-1",
397
- "--run-id", "run-1",
398
- "--retry-count", "0",
399
- "--resume-phase", "null",
400
- "--state-dir", str(project / ".prizmkit" / "state" / "bugfix"),
401
- "--project-root", str(project),
402
- "--output", str(output),
403
- ]
404
- try:
405
- bugfix_main()
406
- except SystemExit as exc:
407
- if exc.code not in (0, None):
408
- raise
409
- finally:
410
- os.sys.argv = old_argv
411
- if old_platform is None:
412
- os.environ.pop("PRIZMKIT_PLATFORM", None)
413
- else:
414
- os.environ["PRIZMKIT_PLATFORM"] = old_platform
415
- return output.read_text(encoding="utf-8")
416
-
417
-
418
- def _ensure_skill_files(project, platforms=None):
419
- """Create minimal skill files so platform resolution succeeds."""
420
- if platforms is None:
421
- platforms = ("claude", "codex")
422
- for plat in platforms:
423
- if plat == "codex":
424
- skill_dir = project / ".agents" / "skills" / "prizmkit"
425
- skill_dir.mkdir(parents=True, exist_ok=True)
426
- (skill_dir / "SKILL.md").write_text("skill\n", encoding="utf-8")
427
- elif plat == "codebuddy":
428
- skill_dir = project / ".codebuddy" / "skills" / "prizmkit"
429
- skill_dir.mkdir(parents=True, exist_ok=True)
430
- (skill_dir / "SKILL.md").write_text("skill\n", encoding="utf-8")
431
- else:
432
- command_dir = project / ".claude" / "commands"
433
- command_dir.mkdir(parents=True, exist_ok=True)
434
- (command_dir / "prizmkit.md").write_text("skill\n", encoding="utf-8")
435
-
436
-
437
- class TestBugfixBootstrapShellExtraction:
438
- """Regression guardrails: bugfix rendered prompts and source use helper, not shell."""
439
-
440
- def test_rendered_bugfix_prompt_uses_runtime_helper_not_extracted_bash(self, tmp_path):
441
- prompt = _render_bugfix_prompt(tmp_path)
442
- for snippet in RETIRED_EXTRACTED_SNIPPETS_BUGFIX:
443
- assert snippet not in prompt, f"Retired shell snippet found in bugfix prompt: {snippet}"
444
- assert "{{RUNTIME_HELPER_CMD}}" not in prompt
445
- assert "python" in prompt.lower()
446
- assert ".prizmkit/dev-pipeline/scripts/prizmkit-runtime-helper.py" in prompt
447
- assert "artifact ensure-dir .prizmkit/bugfix/B-001" in prompt
448
- assert "text final-verdict .prizmkit/bugfix/B-001/review-report.md" in prompt
449
-
450
- def test_bugfix_template_source_is_clean_of_helper_covered_snippets(self):
451
- content = (PIPELINE_ROOT / "templates" / "bugfix-bootstrap-prompt.md").read_text(encoding="utf-8")
452
- for snippet in RETIRED_EXTRACTED_SNIPPETS_BUGFIX:
453
- assert snippet not in content, f"Shell snippet in bugfix template: {snippet}"
454
-
455
- def test_continuation_source_is_clean_of_helper_covered_snippets(self):
456
- content = (PIPELINE_ROOT / "scripts" / "continuation.py").read_text(encoding="utf-8")
457
- for snippet in RETIRED_EXTRACTED_SNIPPETS_BUGFIX:
458
- assert snippet not in content, f"Shell snippet in continuation.py: {snippet}"
459
-
460
- def test_bugfix_generator_source_is_clean_of_helper_covered_snippets(self):
461
- content = (PIPELINE_ROOT / "scripts" / "generate-bugfix-prompt.py").read_text(encoding="utf-8")
462
- for snippet in RETIRED_EXTRACTED_SNIPPETS_BUGFIX:
463
- assert snippet not in content, f"Shell snippet in generate-bugfix-prompt.py: {snippet}"
464
-
465
-
466
- class TestBugfixCheckpointGeneration:
467
- def test_checkpoint_merge_preserves_family_handoff_state(self, tmp_path):
468
- fresh = generate_bugfix_checkpoint("B-001", "new")
469
- existing = generate_bugfix_checkpoint("B-001", "old")
470
- existing["bugfix_state"] = bugfix_checkpoint_metadata(
471
- ".prizmkit/bugfix/B-001",
472
- stage="test",
473
- status="failed",
474
- stage_result="TEST_BLOCKED",
475
- repair_round=2,
476
- next_stage="prizmkit-test",
477
- resume_from="prizmkit-test",
478
- )
479
-
480
- merged = merge_bugfix_checkpoint_state(existing, fresh, str(tmp_path))
481
-
482
- assert merged["bugfix_state"]["status"] == "failed"
483
- assert merged["bugfix_state"]["stage_result"] == "TEST_BLOCKED"
484
- assert merged["bugfix_state"]["resume_from"] == "prizmkit-test"
485
-
486
- def test_default_checkpoint_has_all_atomic_gates_in_order(self):
487
- checkpoint = generate_bugfix_checkpoint("B-001", "session-1")
488
-
489
- assert [step["skill"] for step in checkpoint["steps"]] == [
490
- "prizmkit-init",
491
- "bug-diagnosis-and-plan",
492
- "prizmkit-implement",
493
- "prizmkit-code-review",
494
- "prizmkit-test",
495
- "bug-report",
496
- "prizmkit-retrospective",
497
- "prizmkit-committer",
498
- ]
499
- plan_step = checkpoint["steps"][1]
500
- review_step = checkpoint["steps"][3]
501
- test_step = checkpoint["steps"][4]
502
- assert plan_step["required_artifacts"] == [
503
- ".prizmkit/bugfix/B-001/context-snapshot.md",
504
- ".prizmkit/bugfix/B-001/spec.md",
505
- ".prizmkit/bugfix/B-001/plan.md",
506
- ]
507
- assert review_step["required_artifacts"] == [
508
- ".prizmkit/bugfix/B-001/review-report.md"
509
- ]
510
- assert test_step["depends_on"] == "S04"
511
- assert test_step["required_artifacts"] == [
512
- ".prizmkit/bugfix/B-001/test-report.md",
513
- ".prizmkit/bugfix/B-001/test-result.json",
514
- ]
515
- assert checkpoint["steps"][5]["depends_on"] == "S05"
516
-
517
- def test_bugfix_result_routing_owns_bounded_test_repair(self):
518
- review = route_bugfix_repair(
519
- "REVIEW_NEEDS_FIXES", repair_scope="production", repair_round=0,
520
- )
521
- needs_fixes = route_bugfix_repair(
522
- "TEST_NEEDS_FIXES", repair_scope="production", repair_round=1,
523
- )
524
- blocked = route_bugfix_repair("TEST_BLOCKED", repair_round=1)
525
-
526
- assert review["route"] == [
527
- "prizmkit-implement", "prizmkit-code-review", "prizmkit-test",
528
- ]
529
- assert review["repair_round"] == 1
530
- assert needs_fixes["blocked"] is False
531
- assert needs_fixes["route"] == [
532
- "prizmkit-implement", "prizmkit-code-review", "prizmkit-test",
533
- ]
534
- assert needs_fixes["repair_round"] == 2
535
- assert blocked["blocked"] is True
536
- assert blocked["resumable"] is False
537
- assert blocked["next_stage"] is None
538
- assert blocked["terminal_status"] == "WORKFLOW_BLOCKED"
539
- assert blocked["blocked_reason"] == "test_blocked"
540
- unsafe = route_bugfix_repair("REVIEW_NEEDS_FIXES", repair_round=0)
541
- assert unsafe["blocked_reason"] == "unsafe_repair_scope"
542
-
543
- def test_bugfix_checkpoint_metadata_has_no_evidence_handoff(self):
544
- metadata = bugfix_checkpoint_metadata(
545
- ".prizmkit/bugfix/B-001",
546
- stage="test",
547
- status="failed",
548
- stage_result="TEST_NEEDS_FIXES",
549
- repair_round=0,
550
- next_stage=None,
551
- resume_from=None,
552
- )
553
-
554
- assert metadata["artifact_dir"] == ".prizmkit/bugfix/B-001"
555
- assert metadata["status"] == "failed"
556
- assert metadata["stage_result"] == "TEST_NEEDS_FIXES"
557
- assert "authoritative_evidence_paths" not in metadata
558
-
559
- def test_manual_bugfix_uses_automatic_verification_and_keeps_commit_gate(self):
560
- sections = assemble_bugfix_sections(
561
- str(PIPELINE_ROOT / "templates" / "sections"), False, True,
562
- )
563
- names = [name for name, _ in sections]
564
-
565
- assert "bugfix-manual-gate" in names
566
- assert names.index("bugfix-manual-gate") < names.index("bugfix-phase-test")
567
- assert "runtime-commit-handoff" in names
568
- assert "bugfix-phase-commit-report" in names
569
- checkpoint = generate_bugfix_checkpoint(
570
- "B-001", "session", sections=sections,
571
- )
572
- skills = [step["skill"] for step in checkpoint["steps"]]
573
- assert skills.index("prizmkit-code-review") < skills.index(
574
- "manual-verification"
575
- ) < skills.index("prizmkit-test")
576
- compatibility = generate_bugfix_checkpoint(
577
- "B-001",
578
- "session",
579
- browser_enabled=True,
580
- manual_gate=True,
581
- )
582
- compatibility_skills = [step["skill"] for step in compatibility["steps"]]
583
- assert compatibility_skills.index("prizmkit-code-review") < compatibility_skills.index(
584
- "browser-verification"
585
- ) < compatibility_skills.index("manual-verification") < compatibility_skills.index(
586
- "prizmkit-test"
587
- )
588
-
589
- def test_rendered_bugfix_prompt_is_atomic_headless_and_local_commit_only(self, tmp_path):
590
- prompt = _render_bugfix_prompt(tmp_path)
591
-
592
- assert prompt.index("/prizmkit-code-review") < prompt.index(
593
- "/prizmkit-test scope=this-change artifact_dir=.prizmkit/bugfix/B-001/"
594
- ) < prompt.index("### Bug Fix Report") < prompt.index("### Retrospective") < prompt.index("### Runtime Commit Handoff")
595
- assert "FAST_PATH=true" not in prompt
596
- assert "prizmkit-workflow" not in prompt
597
- assert "local_commit_authorized" not in prompt
598
- assert "operation=prepare-runtime-commit" in prompt
599
- assert "NEVER ask for user confirmation" in prompt
600
- assert "The Python runtime, not the AI session, executes" in prompt
601
- assert "complete final Git-visible workspace" in prompt
602
- assert '"schema_version": 2' in prompt
603
- assert '"intended_paths"' not in prompt
604
- assert "Ignored paths remain local" in prompt
605
- assert "push_authorized\": true" not in prompt
606
- assert ".prizmkit/bugfix/B-001/" in prompt
607
- assert "write the session status" not in prompt.lower()
608
-
609
- def test_setup_section_skips_and_finalization_group_expands(self):
610
- checkpoint = generate_bugfix_checkpoint(
611
- "B-001",
612
- "session-1",
613
- sections=[
614
- ("bugfix-phase-init", "setup"),
615
- ("bugfix-phase-implement", "implement"),
616
- ("bugfix-phase-commit-report", "report"),
617
- ("retrospective", "retrospective"),
618
- ("runtime-commit-handoff", "commit"),
619
- ],
620
- )
621
-
622
- assert [step["skill"] for step in checkpoint["steps"]] == [
623
- "prizmkit-init",
624
- "prizmkit-implement",
625
- "bug-report",
626
- "prizmkit-retrospective",
627
- "prizmkit-committer",
628
- ]
629
- assert checkpoint["steps"][2]["depends_on"] == "S02"