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,321 +0,0 @@
1
- """Behavior tests for the canonical detector-only Recovery Workflow."""
2
-
3
- from __future__ import annotations
4
-
5
- import importlib.util
6
- import json
7
- import subprocess
8
- import sys
9
- from pathlib import Path
10
-
11
-
12
- REPO_ROOT = Path(__file__).resolve().parents[2]
13
- DETECTOR_PATH = (
14
- REPO_ROOT
15
- / "core"
16
- / "skills"
17
- / "orchestration-skill"
18
- / "workflows"
19
- / "recovery-workflow"
20
- / "scripts"
21
- / "detect-recovery-state.py"
22
- )
23
- STATE_DIRS = {
24
- "feature": "features",
25
- "bugfix": "bugfix",
26
- }
27
-
28
-
29
- def _load_detector(name: str):
30
- spec = importlib.util.spec_from_file_location(name, DETECTOR_PATH)
31
- assert spec is not None and spec.loader is not None
32
- module = importlib.util.module_from_spec(spec)
33
- spec.loader.exec_module(module)
34
- return module
35
-
36
-
37
- def _git(project: Path, *args: str) -> str:
38
- result = subprocess.run(
39
- ["git", *args],
40
- cwd=project,
41
- check=True,
42
- text=True,
43
- stdout=subprocess.PIPE,
44
- stderr=subprocess.PIPE,
45
- )
46
- return result.stdout.strip()
47
-
48
-
49
- def _init_repository(project: Path) -> None:
50
- project.mkdir()
51
- _git(project, "init", "-b", "main")
52
- _git(project, "config", "user.email", "detector@example.com")
53
- _git(project, "config", "user.name", "Detector Test")
54
- (project / "README.md").write_text("detector fixture\n", encoding="utf-8")
55
- _git(project, "add", "README.md")
56
- _git(project, "commit", "-m", "fixture")
57
-
58
-
59
- def _write_checkout(
60
- project: Path,
61
- family: str,
62
- task_id: str,
63
- branch: str,
64
- *,
65
- state: str = "active",
66
- worktree_path: str | None = None,
67
- ) -> Path:
68
- checkout = project / ".prizmkit" / "state" / STATE_DIRS[family] / task_id / "checkout.json"
69
- checkout.parent.mkdir(parents=True, exist_ok=True)
70
- checkout.write_text(
71
- json.dumps(
72
- {
73
- "task_type": family,
74
- "task_id": task_id,
75
- "state": state,
76
- "active_dev_branch": branch,
77
- "base_branch": "main",
78
- "checkout_mode": "worktree" if worktree_path else "branch",
79
- "worktree_path": worktree_path,
80
- }
81
- )
82
- + "\n",
83
- encoding="utf-8",
84
- )
85
- return checkout
86
-
87
-
88
- def _write_raw_checkout(
89
- project: Path,
90
- family: str,
91
- directory_id: str,
92
- payload: dict[str, object],
93
- ) -> Path:
94
- checkout = (
95
- project
96
- / ".prizmkit"
97
- / "state"
98
- / STATE_DIRS[family]
99
- / directory_id
100
- / "checkout.json"
101
- )
102
- checkout.parent.mkdir(parents=True, exist_ok=True)
103
- checkout.write_text(json.dumps(payload) + "\n", encoding="utf-8")
104
- return checkout
105
-
106
-
107
- def _repository_snapshot(project: Path) -> tuple[str, str, str]:
108
- return (
109
- _git(project, "branch", "--show-current"),
110
- _git(project, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads"),
111
- _git(project, "status", "--porcelain=v1", "--untracked-files=all"),
112
- )
113
-
114
-
115
- def _historical_snapshot(historical: Path) -> dict[str, bytes]:
116
- return {
117
- path.relative_to(historical).as_posix(): path.read_bytes()
118
- for path in historical.rglob("*")
119
- if path.is_file()
120
- }
121
-
122
-
123
- def test_single_active_checkout_reports_operation_first_command_without_mutation(tmp_path):
124
- project = tmp_path / "project"
125
- _init_repository(project)
126
- branch = "dev/F-061-resume"
127
- _git(project, "branch", branch)
128
- checkout = _write_checkout(project, "feature", "F-061", branch)
129
- before = _repository_snapshot(project)
130
-
131
- result = subprocess.run(
132
- [sys.executable, str(DETECTOR_PATH), "--project-root", str(project)],
133
- cwd=project,
134
- check=False,
135
- text=True,
136
- stdout=subprocess.PIPE,
137
- stderr=subprocess.PIPE,
138
- )
139
- report = json.loads(result.stdout)
140
-
141
- assert result.returncode == 0
142
- assert result.stderr == ""
143
- assert report["detected"] is True
144
- assert report["selection_required"] is False
145
- assert report["current_branch"] == "main"
146
- assert len(report["candidates"]) == 1
147
- candidate = report["candidates"][0]
148
- assert candidate["family"] == "feature"
149
- assert candidate["task_id"] == "F-061"
150
- assert candidate["branch"] == branch
151
- assert candidate["checkout_path"] == checkout.relative_to(project).as_posix()
152
- assert candidate["worktree_path"] is None
153
- assert candidate["continue_command"] == (
154
- "python3 ./.prizmkit/dev-pipeline/cli.py run feature F-061"
155
- )
156
- assert _repository_snapshot(project) == before
157
- assert not (project / ".prizmkit" / "state" / "recovery").exists()
158
-
159
-
160
- def test_multiple_candidates_remain_skill_owned_and_ignore_historical_recovery_data(tmp_path):
161
- project = tmp_path / "project"
162
- _init_repository(project)
163
- branches = {
164
- "feature": ("F-002", "dev/F-002-resume"),
165
- "bugfix": ("B-007", "fix/B-007-resume"),
166
- }
167
- for task_id, branch in branches.values():
168
- _git(project, "branch", branch)
169
- for family, (task_id, branch) in branches.items():
170
- _write_checkout(project, family, task_id, branch)
171
-
172
- historical = project / ".prizmkit" / "state" / "recovery" / "old-session"
173
- historical.mkdir(parents=True)
174
- (historical / "detection.json").write_text(
175
- '{"detected": true, "legacy": true}\n', encoding="utf-8"
176
- )
177
- history_before = _historical_snapshot(historical)
178
- repository_before = _repository_snapshot(project)
179
- detector = _load_detector("recovery_workflow_multiple")
180
-
181
- report = detector.build_report(project)
182
-
183
- assert report["detected"] is True
184
- assert report["selection_required"] is True
185
- assert [candidate["task_id"] for candidate in report["candidates"]] == ["F-002", "B-007"]
186
- assert [candidate["continue_command"] for candidate in report["candidates"]] == [
187
- "python3 ./.prizmkit/dev-pipeline/cli.py run feature F-002",
188
- "python3 ./.prizmkit/dev-pipeline/cli.py run bugfix B-007",
189
- ]
190
- assert _repository_snapshot(project) == repository_before
191
- assert _historical_snapshot(historical) == history_before
192
- assert sorted(path.name for path in historical.parent.iterdir()) == ["old-session"]
193
-
194
-
195
- def test_zero_candidates_filters_invalid_records_without_history_fallback_or_session_creation(tmp_path):
196
- project = tmp_path / "project"
197
- _init_repository(project)
198
- completed_branch = "fix/B-003-complete"
199
- wrong_family_branch = "dev/B-999-wrong-family"
200
- _git(project, "branch", completed_branch)
201
- _git(project, "branch", wrong_family_branch)
202
- _write_checkout(
203
- project,
204
- "bugfix",
205
- "B-003",
206
- completed_branch,
207
- state="completed",
208
- )
209
- _write_checkout(project, "feature", "B-999", wrong_family_branch)
210
- _write_checkout(project, "feature", "F-008", "dev/F-008-missing")
211
-
212
- historical = project / ".prizmkit" / "state" / "recovery" / "historical-only"
213
- historical.mkdir(parents=True)
214
- (historical / "bootstrap-prompt.md").write_text("do not read or delete\n", encoding="utf-8")
215
- history_before = _historical_snapshot(historical)
216
- repository_before = _repository_snapshot(project)
217
- detector = _load_detector("recovery_workflow_empty")
218
-
219
- report = detector.build_report(project)
220
-
221
- assert report == {
222
- "detected": False,
223
- "current_branch": "main",
224
- "candidates": [],
225
- "message": "No active interrupted pipeline task branch was found.",
226
- }
227
- assert _repository_snapshot(project) == repository_before
228
- assert _historical_snapshot(historical) == history_before
229
- assert sorted(path.name for path in historical.parent.iterdir()) == ["historical-only"]
230
-
231
-
232
- def test_detector_rejects_malformed_or_mismatched_checkout_identity(tmp_path):
233
- project = tmp_path / "project"
234
- _init_repository(project)
235
- invalid_records = (
236
- (
237
- "feature",
238
- "F-not-an-id",
239
- "dev/F-not-an-id",
240
- {
241
- "task_type": "feature",
242
- "task_id": "F-not-an-id",
243
- "state": "active",
244
- "active_dev_branch": "dev/F-not-an-id",
245
- "base_branch": "main",
246
- "checkout_mode": "branch",
247
- },
248
- ),
249
- (
250
- "bugfix",
251
- "B-004",
252
- "bugfix/B-004-missing-id",
253
- {
254
- "task_type": "bugfix",
255
- "state": "active",
256
- "active_dev_branch": "bugfix/B-004-missing-id",
257
- "base_branch": "main",
258
- "checkout_mode": "branch",
259
- },
260
- ),
261
- (
262
- "bugfix",
263
- "B-005",
264
- "bugfix/B-005-wrong-type",
265
- {
266
- "task_type": "feature",
267
- "task_id": "B-005",
268
- "state": "active",
269
- "active_dev_branch": "bugfix/B-005-wrong-type",
270
- "base_branch": "main",
271
- "checkout_mode": "branch",
272
- },
273
- ),
274
- (
275
- "feature",
276
- "F-006",
277
- "dev/F-006-path-mismatch",
278
- {
279
- "task_type": "feature",
280
- "task_id": "F-007",
281
- "state": "active",
282
- "active_dev_branch": "dev/F-006-path-mismatch",
283
- "base_branch": "main",
284
- "checkout_mode": "branch",
285
- },
286
- ),
287
- )
288
- for family, directory_id, branch, payload in invalid_records:
289
- _git(project, "branch", branch)
290
- _write_raw_checkout(project, family, directory_id, payload)
291
-
292
- detector = _load_detector("recovery_workflow_invalid_identity")
293
-
294
- assert detector.detect_candidates(project) == []
295
-
296
-
297
- def test_recovery_workflow_metadata_matches_detector_only_contract():
298
- metadata = json.loads((REPO_ROOT / "core" / "skills" / "_metadata.json").read_text())
299
- recovery = metadata["skills"]["recovery-workflow"]
300
- description = recovery["description"].lower()
301
-
302
- assert recovery["hasScripts"] is True
303
- assert "active feature or bugfix checkout records" in description
304
- assert "operation-first" in description
305
- assert "direct requirement" not in description
306
-
307
-
308
- def test_canonical_recovery_and_cli_guidance_has_no_retired_contracts():
309
- env_example = (REPO_ROOT / "dev-pipeline" / ".env.example").read_text(encoding="utf-8")
310
- readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
311
- readme_en = (REPO_ROOT / "README_EN.md").read_text(encoding="utf-8")
312
-
313
- assert "cli.py feature run" not in env_example
314
- assert "cli.py run feature" in env_example
315
- assert "从断点继续" not in readme
316
- assert "reset/clean/unskip/complete" not in readme
317
- assert "reset/clean/reset_state/complete" in readme
318
- assert "Auto-detect + resume from breakpoint" not in readme_en
319
- assert "interrupted at Phase 4" not in readme_en
320
- assert "Resumes from Phase 5" not in readme_en
321
- assert "Does not execute the command or infer a lifecycle phase" in readme_en
@@ -1,251 +0,0 @@
1
- """Git bootstrap for projects that have no repository or no commits yet."""
2
-
3
- import json
4
- import subprocess
5
- from pathlib import Path
6
-
7
- import pytest
8
-
9
- PIPELINE_ROOT = Path(__file__).resolve().parents[1]
10
-
11
-
12
- def _git(project, *args, check=True):
13
- return subprocess.run(
14
- ["git", "-C", str(project), *args],
15
- check=check,
16
- stdout=subprocess.PIPE,
17
- stderr=subprocess.PIPE,
18
- text=True,
19
- )
20
-
21
-
22
- def _init_unborn(project, branch):
23
- project.mkdir(parents=True, exist_ok=True)
24
- _git(project, "init", "-b", branch)
25
-
26
-
27
- def _identity(project):
28
- _git(project, "config", "user.email", "test@example.com")
29
- _git(project, "config", "user.name", "Test")
30
-
31
-
32
- def test_current_branch_reads_unborn_branch_name(tmp_path):
33
- from prizmkit_runtime.gitops import current_branch, default_branch
34
-
35
- project = tmp_path / "unborn"
36
- _init_unborn(project, "master")
37
-
38
- assert current_branch(project) == "master"
39
- assert default_branch(project) == "master"
40
-
41
-
42
- def test_current_branch_is_empty_outside_a_repository(tmp_path):
43
- from prizmkit_runtime.gitops import current_branch
44
-
45
- assert current_branch(tmp_path) == ""
46
-
47
-
48
- def test_default_branch_uses_the_checked_out_branch_when_main_also_exists(tmp_path):
49
- from prizmkit_runtime.gitops import default_branch
50
-
51
- project = tmp_path / "develop-repo"
52
- _init_unborn(project, "develop")
53
- _identity(project)
54
- _git(project, "commit", "--allow-empty", "-m", "init")
55
- _git(project, "branch", "main")
56
-
57
- assert default_branch(project) == "develop"
58
-
59
-
60
- def test_task_branch_resolves_back_to_the_primary_it_left(tmp_path):
61
- from prizmkit_runtime.gitops import (
62
- BranchContext,
63
- branch_create_plan,
64
- branch_ensure_return,
65
- current_branch,
66
- default_branch,
67
- run_git_plan,
68
- )
69
-
70
- project = tmp_path / "trunk-repo"
71
- _init_unborn(project, "trunk")
72
- _identity(project)
73
- _git(project, "commit", "--allow-empty", "-m", "init")
74
- _git(project, "branch", "main")
75
- created = run_git_plan(project, branch_create_plan(BranchContext("trunk", "dev/F-001-custom", project)))
76
- assert created.ok
77
- assert current_branch(project) == "dev/F-001-custom"
78
- assert default_branch(project) == "trunk"
79
-
80
- returned = branch_ensure_return(project, "trunk", "dev/F-001-custom")
81
- assert returned.ok
82
- assert current_branch(project) == "trunk"
83
-
84
-
85
- def test_default_branch_prefers_an_existing_main_or_master_commit(tmp_path):
86
- from prizmkit_runtime.gitops import default_branch
87
-
88
- main_repo = tmp_path / "main-repo"
89
- _init_unborn(main_repo, "main")
90
- _identity(main_repo)
91
- (main_repo / "README").write_text("main\n", encoding="utf-8")
92
- _git(main_repo, "add", "README")
93
- _git(main_repo, "commit", "-m", "init")
94
- assert default_branch(main_repo) == "main"
95
-
96
- master_repo = tmp_path / "master-repo"
97
- _init_unborn(master_repo, "master")
98
- _identity(master_repo)
99
- (master_repo / "README").write_text("master\n", encoding="utf-8")
100
- _git(master_repo, "add", "README")
101
- _git(master_repo, "commit", "-m", "init")
102
- assert default_branch(master_repo) == "master"
103
-
104
-
105
- def test_missing_repository_can_create_a_task_branch_after_preflight(tmp_path):
106
- from prizmkit_runtime.gitops import (
107
- BranchContext,
108
- branch_create_plan,
109
- current_branch,
110
- default_branch,
111
- ensure_branch_has_commit,
112
- ensure_git_repository,
113
- local_branch_exists,
114
- run_git_plan,
115
- )
116
- from prizmkit_runtime.runner_bookkeeping import commit_preflight_ready_changes
117
-
118
- project = tmp_path / "fresh"
119
- project.mkdir()
120
- (project / "README").write_text("framework\n", encoding="utf-8")
121
-
122
- created = ensure_git_repository(project)
123
- assert created.return_code == 0
124
- assert created.args[0] == "init"
125
- again = ensure_git_repository(project)
126
- assert again.args[0] == "rev-parse"
127
-
128
- base = current_branch(project)
129
- assert base
130
- assert base != "HEAD"
131
- assert default_branch(project) == base
132
-
133
- preflight = commit_preflight_ready_changes(project, "F-001")
134
- assert preflight.committed
135
- assert ensure_branch_has_commit(project).args[0] == "rev-parse"
136
- assert local_branch_exists(project, base)
137
- assert not local_branch_exists(project, "this-branch-does-not-exist")
138
-
139
- plan = run_git_plan(project, branch_create_plan(BranchContext(base, "dev/F-001-fresh", project)))
140
- assert plan.ok
141
- assert local_branch_exists(project, "dev/F-001-fresh")
142
- assert _git(project, "merge-base", "--is-ancestor", base, "dev/F-001-fresh").returncode == 0
143
-
144
-
145
- def test_unborn_master_preflight_branches_from_master_not_main(tmp_path):
146
- from prizmkit_runtime.gitops import (
147
- BranchContext,
148
- branch_create_plan,
149
- current_branch,
150
- default_branch,
151
- local_branch_exists,
152
- run_git_plan,
153
- )
154
- from prizmkit_runtime.runner_bookkeeping import commit_preflight_ready_changes
155
-
156
- project = tmp_path / "master-only"
157
- _init_unborn(project, "master")
158
- _identity(project)
159
- (project / ".gitignore").write_text(".prizmkit/*\n", encoding="utf-8")
160
-
161
- assert current_branch(project) == "master"
162
- assert default_branch(project) == "master"
163
- preflight = commit_preflight_ready_changes(project, "F-001")
164
- assert preflight.committed
165
- assert _git(project, "rev-parse", "--abbrev-ref", "HEAD").stdout.strip() == "master"
166
- assert not local_branch_exists(project, "main")
167
-
168
- plan = run_git_plan(project, branch_create_plan(BranchContext("master", "dev/F-001-master", project)))
169
- assert plan.ok
170
- assert local_branch_exists(project, "dev/F-001-master")
171
-
172
-
173
- def test_empty_repository_gets_an_initial_commit_before_branching(tmp_path):
174
- from prizmkit_runtime.gitops import (
175
- BranchContext,
176
- branch_create_plan,
177
- current_branch,
178
- ensure_branch_has_commit,
179
- ensure_git_repository,
180
- local_branch_exists,
181
- run_git_plan,
182
- )
183
-
184
- project = tmp_path / "empty"
185
- project.mkdir()
186
- assert ensure_git_repository(project).return_code == 0
187
- base = current_branch(project)
188
- born = ensure_branch_has_commit(project)
189
- assert born.return_code == 0
190
- assert born.args[0] == "commit"
191
- assert local_branch_exists(project, base)
192
- plan = run_git_plan(project, branch_create_plan(BranchContext(base, "dev/F-001-empty", project)))
193
- assert plan.ok
194
-
195
-
196
- def test_runner_uses_real_master_when_recorded_base_main_does_not_exist(monkeypatch, tmp_path):
197
- from prizmkit_runtime import runners
198
- from prizmkit_runtime.gitops import local_branch_exists
199
- from prizmkit_runtime.runner_models import family_for, parse_invocation
200
- from prizmkit_runtime.task_checkout import TaskCheckout, load_task_checkout, persist_task_checkout
201
-
202
- monkeypatch.delenv("DEV_BRANCH", raising=False)
203
- monkeypatch.setattr(
204
- runners,
205
- "load_runtime_config",
206
- lambda paths: type("Config", (), {
207
- "ai_client": type("Client", (), {"command": "fake-ai", "platform": "codebuddy", "launch_profile": None})(),
208
- "model": "",
209
- "effort": None,
210
- "effort_validation": type("Effort", (), {"valid": True, "message": ""})(),
211
- })(),
212
- )
213
-
214
- paths = tmp_path / "project"
215
- _init_unborn(paths, "master")
216
- _identity(paths)
217
- (paths / ".prizmkit" / "plans").mkdir(parents=True)
218
- (paths / "README").write_text("ready\n", encoding="utf-8")
219
- _git(paths, "add", "README")
220
- _git(paths, "commit", "-m", "chore: ready for F-001")
221
-
222
- from prizmkit_runtime.paths import resolve_runtime_paths
223
-
224
- runtime_paths = resolve_runtime_paths(
225
- pipeline_root=PIPELINE_ROOT,
226
- project_root=paths,
227
- )
228
- family = family_for("feature", runtime_paths)
229
- invocation = parse_invocation(family, "run", ())
230
- invocation = invocation.__class__(**{**invocation.__dict__, "list_path": runtime_paths.feature_plan})
231
- persist_task_checkout(
232
- family.state_dir,
233
- TaskCheckout.active("feature", "F-001", "dev/F-001-poison", "main"),
234
- )
235
-
236
- def stop_after_branch(*_args, **_kwargs):
237
- raise RuntimeError("stop-after-branch")
238
-
239
- monkeypatch.setattr(runners, "start_item", stop_after_branch)
240
-
241
- with pytest.raises(RuntimeError, match="stop-after-branch"):
242
- runners._process_item(family, invocation, "F-001", runtime_paths, initial_metadata={})
243
-
244
- checkout = load_task_checkout(family.state_dir, family.task_type, "F-001")
245
- assert checkout is not None
246
- assert checkout.base_branch == "master"
247
- assert checkout.active_dev_branch == "dev/F-001-poison"
248
- assert local_branch_exists(paths, "dev/F-001-poison")
249
- assert _git(paths, "merge-base", "--is-ancestor", "master", "dev/F-001-poison").returncode == 0
250
- stored = json.loads((family.state_dir / "F-001" / "checkout.json").read_text(encoding="utf-8"))
251
- assert stored["base_branch"] == "master"