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.
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/README.md +23 -34
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -0
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -2
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -40
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -1
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -22
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +11 -7
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +26 -20
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +37 -4
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +20 -41
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +74 -36
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -66
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +271 -52
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +51 -13
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +43 -15
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +27 -24
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +0 -1
- package/bundled/dev-pipeline/scripts/check-session-status.py +13 -1
- package/bundled/dev-pipeline/scripts/continuation.py +2 -3
- package/bundled/dev-pipeline/scripts/detect-stuck.py +19 -5
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -14
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +13 -8
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +17 -2
- package/bundled/dev-pipeline/scripts/prompt_framework.py +39 -21
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +27 -0
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -6
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +1 -1
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
- package/bundled/dev-pipeline/tests/_helpers.py +0 -418
- package/bundled/dev-pipeline/tests/conftest.py +0 -73
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1806
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1439
- package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +0 -257
- package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +0 -500
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1654
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -629
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -2973
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -321
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -251
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1196
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -872
- package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +0 -766
- package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +0 -1257
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -380
- package/bundled/dev-pipeline/tests/test_session_launch.py +0 -1101
- package/bundled/dev-pipeline/tests/test_stream_progress.py +0 -585
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -3625
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
|
@@ -15,7 +15,7 @@ They must agree on the testing result and unresolved items. Do not require an ev
|
|
|
15
15
|
|
|
16
16
|
Gate outcomes:
|
|
17
17
|
|
|
18
|
-
- `TEST_PASS` with consistent `production_changed=false`: mark the test checkpoint step completed and continue to retrospective.
|
|
18
|
+
- `TEST_PASS` with consistent `production_changed=false`: mark the test checkpoint step completed and continue to fix report (`fix-report.md`) before retrospective.
|
|
19
19
|
- `TEST_PASS` with consistent `production_changed=true`: do NOT mark the test step completed; within the shared 3-round outer repair budget (`repair_round < 3`), re-enter `prizmkit-code-review` (`--status in_progress --repair-scope production`), run `/prizmkit-code-review` in delta mode (`review_scope=delta`), and re-run `/prizmkit-test` before continuing (if `repair_round >= 3`, record `WORKFLOW_BLOCKED` with `repair_round_limit`).
|
|
20
20
|
- `TEST_NEEDS_FIXES`: this injected session classifies the exact unresolved correction into an allowed `repair_scope` and records both on the failed test step. If scope and outer budget permit, start `prizmkit-implement` with that explicit repair input; the helper rewinds stale downstream steps, then fresh review, configured verification, and test results are mandatory. If scope is unsafe/unknown or budget is exhausted, record terminal `WORKFLOW_BLOCKED`. Never recreate the testing-local repair loop.
|
|
21
21
|
- `TEST_BLOCKED`: preserve the report/result and blocker, then record terminal `WORKFLOW_BLOCKED`. Do not reinterpret the result as a runtime crash or make speculative production edits.
|
|
@@ -21,7 +21,7 @@ The JSON is the minimal terminal result projection and the report contains seman
|
|
|
21
21
|
|
|
22
22
|
The caller checkpoint records only the returned testing result and caller-owned routing state. It must not ask the skill to manage sessions or checkpoints.
|
|
23
23
|
|
|
24
|
-
- `TEST_PASS` with consistent `production_changed=false` across `test-report.md` and `test-result.json` → mark `prizmkit-test` completed and continue to retrospective.
|
|
24
|
+
- `TEST_PASS` with consistent `production_changed=false` across `test-report.md` and `test-result.json` → mark `prizmkit-test` completed and continue to completion summary (`completion-summary.json`) before retrospective.
|
|
25
25
|
- `TEST_PASS` with consistent `production_changed=true` across `test-report.md` and `test-result.json` → do NOT complete `prizmkit-test`; check the shared outer repair budget (`repair_round < 3`). If budget permits, re-enter `prizmkit-code-review` (`--status in_progress --repair-scope production`), run `/prizmkit-code-review` in delta mode (`review_scope=delta`), re-run configured post-review verification (if present), and run `/prizmkit-test` again until `TEST_PASS` has `production_changed=false`. If `repair_round >= 3`, record `WORKFLOW_BLOCKED` (`blocked_reason=repair_round_limit`) and stop.
|
|
26
26
|
- `TEST_NEEDS_FIXES` → this injected session classifies the exact unresolved correction into an allowed `repair_scope` and records both on the failed test step. If scope and outer budget permit, start `prizmkit-implement` with that explicit repair input; the checkpoint helper rewinds stale downstream steps, after which fresh `prizmkit-code-review`, configured verification, and `prizmkit-test` results are mandatory. If scope is unsafe/unknown or budget is exhausted, record terminal `WORKFLOW_BLOCKED`. Never recreate the testing-local repair loop.
|
|
27
27
|
- `TEST_BLOCKED` → preserve the report, result, and blocker; record terminal `WORKFLOW_BLOCKED`. Do not reinterpret it as an AI CLI crash or perform speculative production edits.
|
package/package.json
CHANGED
|
@@ -1,418 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"""Shared fixtures and import helpers for dev-pipeline tests."""
|
|
2
|
-
|
|
3
|
-
import importlib
|
|
4
|
-
import os
|
|
5
|
-
import sys
|
|
6
|
-
|
|
7
|
-
import pytest
|
|
8
|
-
|
|
9
|
-
# Add dev-pipeline/scripts to the import path so tests can import modules
|
|
10
|
-
# without requiring package installation.
|
|
11
|
-
_scripts_dir = os.path.join(os.path.dirname(__file__), "..", "scripts")
|
|
12
|
-
sys.path.insert(0, _scripts_dir)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def _load_hyphenated_module(module_name, filename):
|
|
16
|
-
"""Load a hyphenated .py file and register it as an importable module."""
|
|
17
|
-
spec = importlib.util.spec_from_file_location(
|
|
18
|
-
module_name,
|
|
19
|
-
os.path.join(_scripts_dir, filename),
|
|
20
|
-
)
|
|
21
|
-
mod = importlib.util.module_from_spec(spec)
|
|
22
|
-
sys.modules[module_name] = mod
|
|
23
|
-
spec.loader.exec_module(mod)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Register hyphenated script files so tests can import them with underscores.
|
|
27
|
-
_load_hyphenated_module("generate_bootstrap_prompt", "generate-bootstrap-prompt.py")
|
|
28
|
-
_load_hyphenated_module("generate_bugfix_prompt", "generate-bugfix-prompt.py")
|
|
29
|
-
_load_hyphenated_module("update_feature_status", "update-feature-status.py")
|
|
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)
|