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,257 +0,0 @@
1
- """Tests for daemon edge cases, status scripts, stuck detection, and status_common parity."""
2
-
3
- from __future__ import annotations
4
-
5
- import importlib.util
6
- import json
7
- import os
8
- import subprocess
9
- import sys
10
- from datetime import datetime, timedelta, timezone
11
- from pathlib import Path
12
-
13
- import pytest
14
-
15
- from _helpers import PIPELINE_ROOT, PYTHON_310_PLUS, make_runtime_paths
16
-
17
-
18
- def _load_script(name: str, filename: str):
19
- path = PIPELINE_ROOT / "scripts" / filename
20
- spec = importlib.util.spec_from_file_location(name, path)
21
- module = importlib.util.module_from_spec(spec)
22
- assert spec.loader is not None
23
- spec.loader.exec_module(module)
24
- return module
25
-
26
-
27
- def _write_minimal_feature_plan(plan_path: Path) -> None:
28
- plan_path.write_text(
29
- json.dumps(
30
- {
31
- "$schema": "dev-pipeline-feature-list-v1",
32
- "project_name": "Demo",
33
- "features": [
34
- {
35
- "id": "F-001",
36
- "title": "Sample",
37
- "description": "Sample",
38
- "priority": "high",
39
- "dependencies": [],
40
- "acceptance_criteria": ["ok"],
41
- "status": "pending",
42
- }
43
- ],
44
- }
45
- ),
46
- encoding="utf-8",
47
- )
48
-
49
-
50
- def test_daemon_start_lock_fast_exit_crash_tail_and_invalid_env(monkeypatch, tmp_path):
51
- from prizmkit_runtime import daemon
52
- from prizmkit_runtime.runner_models import family_for
53
-
54
- paths = make_runtime_paths(tmp_path)
55
- _write_minimal_feature_plan(paths.feature_plan)
56
- family = family_for("feature", paths)
57
- daemon_paths = daemon._daemon_paths(family)
58
-
59
- # 1. Start lock contention
60
- daemon_paths.start_lock.mkdir(parents=True, exist_ok=True)
61
- (daemon_paths.start_lock / "owner.json").write_text(f'{{"pid": {os.getpid()}}}\n', encoding="utf-8")
62
- locked = daemon.run_daemon_command("feature", "start", (str(paths.feature_plan),), paths)
63
- assert locked.exit_code == 1
64
- assert "already in progress" in locked.stderr
65
- (daemon_paths.start_lock / "owner.json").unlink()
66
- daemon_paths.start_lock.rmdir()
67
-
68
- # 2. Invalid --env key rejection
69
- with pytest.raises(ValueError, match="Invalid --env variable name"):
70
- daemon._parse_start_args(family, (str(paths.feature_plan), "--env", "BAD-KEY=1"))
71
-
72
- # 3. Fast exit code 0 within startup window
73
- monkeypatch.setattr(daemon, "_start_verify_seconds", lambda: 0.4)
74
- monkeypatch.setattr(
75
- daemon,
76
- "_payload_command",
77
- lambda *_args: [sys.executable, "-c", "print('quick completion')"],
78
- )
79
- fast = daemon.run_daemon_command("feature", "start", (str(paths.feature_plan),), paths)
80
- assert fast.exit_code == 0
81
- fast_payload = json.loads(fast.stdout)
82
- assert fast_payload["completed"] is True
83
- assert fast_payload["exit_code"] == 0
84
- assert not daemon_paths.pid_file.exists()
85
-
86
- # 4. Immediate crash includes log tail in stderr
87
- monkeypatch.setattr(
88
- daemon,
89
- "_payload_command",
90
- lambda *_args: [sys.executable, "-c", "import sys; print('fatal crash marker'); sys.exit(1)"],
91
- )
92
- crashed = daemon.run_daemon_command("feature", "start", (str(paths.feature_plan),), paths)
93
- assert crashed.exit_code == 1
94
- assert "died immediately after launch" in crashed.stderr
95
- assert "--- Last log lines ---" in crashed.stderr
96
- assert "fatal crash marker" in crashed.stderr
97
- assert not daemon_paths.pid_file.exists()
98
-
99
-
100
- def test_check_session_status_accepts_canonical_and_legacy_schemas(tmp_path):
101
- mod = _load_script("check_session_status_mod", "check-session-status.py")
102
-
103
- canonical_statuses = (
104
- "success",
105
- "failed",
106
- "crashed",
107
- "timed_out",
108
- "infra_error",
109
- "commit_missing",
110
- "docs_missing",
111
- "merge_conflict",
112
- "context_overflow",
113
- "stalled_context_continuation",
114
- "workflow_blocked",
115
- "workflow_skipped",
116
- )
117
- for status in canonical_statuses:
118
- payload = {
119
- "session_id": "F-001-sess-1",
120
- "task_id": "F-001",
121
- "task_type": "feature",
122
- "status": status,
123
- "checkpoint_state": {"current_stage": "prizmkit-test", "stage_result": "TEST_PASS"},
124
- }
125
- assert mod.validate_required_fields(payload) == []
126
- assert mod.determine_status(payload) == status
127
- report = mod.build_detail_report(payload, status)
128
- assert report["task_id"] == "F-001"
129
- assert report["task_type"] == "feature"
130
- assert report["checkpoint_state"] == payload["checkpoint_state"]
131
-
132
- # Legacy format still requires timestamp, while missing task_id|feature_id|bug_id is diagnosed
133
- assert mod.validate_required_fields(
134
- {"session_id": "s1", "feature_id": "F-001", "status": "success", "timestamp": "2026-01-01T00:00:00Z"}
135
- ) == []
136
- assert "timestamp" in mod.validate_required_fields(
137
- {"session_id": "s1", "feature_id": "F-001", "status": "success"}
138
- )
139
- assert "task_id|feature_id|bug_id" in mod.validate_required_fields(
140
- {"session_id": "s1", "status": "success"}
141
- )
142
-
143
- status_file = tmp_path / "session-status.json"
144
- status_file.write_text(
145
- json.dumps(
146
- {
147
- "session_id": "B-001-sess-1",
148
- "task_id": "B-001",
149
- "task_type": "bugfix",
150
- "status": "workflow_blocked",
151
- }
152
- ),
153
- encoding="utf-8",
154
- )
155
- proc = subprocess.run(
156
- [PYTHON_310_PLUS, str(PIPELINE_ROOT / "scripts" / "check-session-status.py"), "--status-file", str(status_file)],
157
- text=True,
158
- stdout=subprocess.PIPE,
159
- stderr=subprocess.PIPE,
160
- check=False,
161
- )
162
- assert proc.returncode == 0
163
- assert proc.stdout.strip() == "workflow_blocked"
164
- detail = json.loads(proc.stderr)
165
- assert detail["task_id"] == "B-001"
166
- assert detail["task_type"] == "bugfix"
167
-
168
-
169
- def test_detect_stuck_handles_canonical_checkpoint_state_and_heartbeat_fields(tmp_path):
170
- mod = _load_script("detect_stuck_mod", "detect-stuck.py")
171
-
172
- item_dir = tmp_path / "state" / "features" / "F-001"
173
- for idx in (1, 2, 3):
174
- session_dir = item_dir / "sessions" / f"F-001-session-{idx}"
175
- session_dir.mkdir(parents=True)
176
- (session_dir / "session-status.json").write_text(
177
- json.dumps(
178
- {
179
- "session_id": f"F-001-session-{idx}",
180
- "task_id": "F-001",
181
- "task_type": "feature",
182
- "status": "failed",
183
- "checkpoint_state": {
184
- "current_stage": "prizmkit-implement",
185
- "stage_result": "IMPLEMENT_REPAIR",
186
- },
187
- }
188
- ),
189
- encoding="utf-8",
190
- )
191
-
192
- stuck = mod.check_stuck_checkpoint(item_dir)
193
- assert stuck is not None
194
- assert stuck["reason"] == "stuck_at_checkpoint"
195
- assert "prizmkit-implement:IMPLEMENT_REPAIR" in stuck["details"]
196
-
197
- # Heartbeat supporting last_heartbeat_at and updated_at
198
- hb_path = item_dir / "sessions" / "F-001-session-3" / "heartbeat.json"
199
- now = datetime.now(timezone.utc)
200
- fresh = (now - timedelta(seconds=10)).strftime("%Y-%m-%dT%H:%M:%SZ")
201
- stale = (now - timedelta(seconds=600)).strftime("%Y-%m-%dT%H:%M:%SZ")
202
- item_status = {"last_session_id": "F-001-session-3"}
203
-
204
- hb_path.write_text(json.dumps({"last_heartbeat_at": fresh}), encoding="utf-8")
205
- assert mod.check_stale_heartbeat("F-001", item_status, tmp_path / "state", "features", 120, "in_progress") is None
206
-
207
- hb_path.write_text(json.dumps({"updated_at": stale}), encoding="utf-8")
208
- stale_report = mod.check_stale_heartbeat("F-001", item_status, tmp_path / "state", "features", 120, "in_progress")
209
- assert stale_report is not None
210
- assert stale_report["reason"] == "stale_heartbeat"
211
-
212
-
213
- def test_status_common_parity_across_feature_and_bugfix_updaters(tmp_path):
214
- feat_mod = _load_script("update_feature_status_parity", "update-feature-status.py")
215
- bug_mod = _load_script("update_bug_status_parity", "update-bug-status.py")
216
-
217
- feat_plan = tmp_path / "feature-list.json"
218
- feat_state = tmp_path / "feat-state"
219
- feat_state.mkdir()
220
- feat_plan.write_text(
221
- json.dumps(
222
- {
223
- "features": [
224
- {"id": "F-001", "title": "Root", "status": "failed", "dependencies": []},
225
- {"id": "F-002", "title": "Child", "status": "pending", "dependencies": ["F-001"]},
226
- ]
227
- }
228
- ),
229
- encoding="utf-8",
230
- )
231
- skipped_f = feat_mod.auto_skip_blocked_features(str(feat_plan), str(feat_state), "F-001")
232
- assert [entry["feature_id"] for entry in skipped_f] == ["F-002"]
233
- assert feat_mod.get_feature_status_from_list(str(feat_plan), "F-002") == "auto_skipped"
234
- feat_mod.update_feature_in_list(str(feat_plan), "F-001", "pending")
235
- assert feat_mod.reconcile_orphaned_auto_skipped_features(str(feat_plan), str(feat_state)) == ["F-002"]
236
- assert feat_mod.get_feature_status_from_list(str(feat_plan), "F-002") == "pending"
237
-
238
- bug_plan = tmp_path / "bug-fix-list.json"
239
- bug_state = tmp_path / "bug-state"
240
- bug_state.mkdir()
241
- bug_plan.write_text(
242
- json.dumps(
243
- {
244
- "bugs": [
245
- {"id": "B-001", "title": "Root", "status": "needs_info", "dependencies": []},
246
- {"id": "B-002", "title": "Child", "status": "pending", "dependencies": ["B-001"]},
247
- ]
248
- }
249
- ),
250
- encoding="utf-8",
251
- )
252
- skipped_b = bug_mod.auto_skip_blocked_bugs(str(bug_plan), str(bug_state), "B-001")
253
- assert [entry["bug_id"] for entry in skipped_b] == ["B-002"]
254
- assert bug_mod.get_bug_status_from_list(str(bug_plan), "B-002") == "auto_skipped"
255
- bug_mod.update_bug_in_list(str(bug_plan), "B-001", "pending")
256
- assert bug_mod.reconcile_orphaned_auto_skipped_bugs(str(bug_plan), str(bug_state)) == ["B-002"]
257
- assert bug_mod.get_bug_status_from_list(str(bug_plan), "B-002") == "pending"