prizmkit 1.1.191 → 1.1.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/antigravity/skill-adapter.js +13 -4
- package/bundled/adapters/codex/skill-adapter.js +28 -8
- package/bundled/adapters/cursor/skill-adapter.js +13 -4
- package/bundled/adapters/pi/skill-adapter.js +28 -7
- package/bundled/dev-pipeline/.env.example +4 -12
- package/bundled/dev-pipeline/README.md +5 -10
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -6
- package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -76
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +125 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +77 -430
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +93 -49
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +36 -14
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +206 -151
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +2 -23
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +15 -134
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +68 -83
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -29
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +276 -217
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +124 -122
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +183 -130
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2780 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -101
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +43 -19
- package/bundled/dev-pipeline/scripts/continuation.py +6 -4
- package/bundled/dev-pipeline/scripts/detect-stuck.py +28 -28
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +7 -2
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -2
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +8 -2
- package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
- package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
- package/bundled/dev-pipeline/scripts/prompt_framework.py +56 -9
- package/bundled/dev-pipeline/scripts/status_common.py +591 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +227 -65
- package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
- package/bundled/dev-pipeline/scripts/utils.py +5 -12
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +4 -4
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
- package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
- package/bundled/dev-pipeline/tests/_helpers.py +418 -0
- package/bundled/dev-pipeline/tests/conftest.py +45 -1
- package/bundled/dev-pipeline/tests/test_auto_skip.py +4 -69
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +126 -1
- package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +257 -0
- package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +500 -0
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +59 -117
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +12 -10
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +431 -3099
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +7 -8
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -1
- package/bundled/dev-pipeline/tests/test_reset_modes.py +15 -27
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +54 -139
- package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +766 -0
- package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +1257 -0
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +97 -20
- package/bundled/dev-pipeline/tests/test_session_launch.py +1101 -0
- package/bundled/dev-pipeline/tests/test_stream_progress.py +585 -0
- package/bundled/dev-pipeline/tests/test_unified_cli.py +155 -2034
- package/bundled/dev-pipeline/tests/test_utils.py +3 -3
- package/bundled/skills/_metadata.json +9 -63
- package/bundled/skills/app-planner/SKILL.md +32 -303
- package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
- package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
- package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
- package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
- package/bundled/skills/bug-planner/SKILL.md +54 -435
- package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/bug-planner/references/input-formats.md +32 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-planner/SKILL.md +60 -439
- package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
- package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
- package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
- package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
- package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
- package/bundled/skills/feature-workflow/SKILL.md +1 -2
- package/bundled/skills/prizmkit/SKILL.md +7 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +24 -127
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
- package/bundled/skills/prizmkit-test/SKILL.md +25 -133
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
- package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
- package/bundled/skills/recovery-workflow/SKILL.md +7 -7
- package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
- package/bundled/skills/recovery-workflow/references/detection.md +1 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
- package/bundled/templates/project-memory-template.md +1 -2
- package/package.json +1 -1
- package/src/scaffold.js +28 -7
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
- package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
- package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
- package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
- package/bundled/skills/refactor-planner/SKILL.md +0 -467
- package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
- package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
- package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
- package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
- package/bundled/skills/refactor-workflow/SKILL.md +0 -205
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
"""Durable task checkout identity for pipeline branch
|
|
1
|
+
"""Durable task checkout identity for pipeline branch reuse."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
-
import shutil
|
|
8
|
-
import tempfile
|
|
9
|
-
import time
|
|
10
7
|
from contextlib import contextmanager
|
|
11
8
|
from dataclasses import asdict, dataclass
|
|
12
9
|
from pathlib import Path
|
|
13
10
|
from typing import Iterator
|
|
14
11
|
|
|
12
|
+
from .atomic_io import write_json_atomic
|
|
13
|
+
from .processes import PidLockError, exclusive_pid_lock
|
|
14
|
+
|
|
15
15
|
|
|
16
16
|
CHECKOUT_STATE_ACTIVE = "active"
|
|
17
17
|
CHECKOUT_STATE_COMPLETED = "completed"
|
|
18
18
|
CHECKOUT_STATE_RESET = "reset"
|
|
19
19
|
CHECKOUT_MODE_BRANCH = "branch"
|
|
20
|
-
CHECKOUT_MODE_WORKTREE = "worktree"
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
class TaskCheckoutError(RuntimeError):
|
|
@@ -34,7 +33,6 @@ class TaskCheckout:
|
|
|
34
33
|
active_dev_branch: str = ""
|
|
35
34
|
base_branch: str = ""
|
|
36
35
|
checkout_mode: str = CHECKOUT_MODE_BRANCH
|
|
37
|
-
worktree_path: str = ""
|
|
38
36
|
|
|
39
37
|
@classmethod
|
|
40
38
|
def active(
|
|
@@ -45,21 +43,15 @@ class TaskCheckout:
|
|
|
45
43
|
base_branch: str,
|
|
46
44
|
*,
|
|
47
45
|
checkout_mode: str = CHECKOUT_MODE_BRANCH,
|
|
48
|
-
worktree_path: str = "",
|
|
49
46
|
) -> "TaskCheckout":
|
|
50
47
|
branch = active_dev_branch.strip()
|
|
51
48
|
base = base_branch.strip()
|
|
52
49
|
mode = checkout_mode.strip()
|
|
53
|
-
path = worktree_path.strip()
|
|
54
50
|
if not branch or not base:
|
|
55
51
|
raise TaskCheckoutError("Active task checkout requires development and base branches")
|
|
56
|
-
if mode
|
|
52
|
+
if mode != CHECKOUT_MODE_BRANCH:
|
|
57
53
|
raise TaskCheckoutError(f"Unsupported task checkout mode: {mode or '(empty)'}")
|
|
58
|
-
|
|
59
|
-
raise TaskCheckoutError("Worktree task checkout requires a canonical worktree path")
|
|
60
|
-
if mode == CHECKOUT_MODE_BRANCH:
|
|
61
|
-
path = ""
|
|
62
|
-
return cls(task_type, task_id, CHECKOUT_STATE_ACTIVE, branch, base, mode, path)
|
|
54
|
+
return cls(task_type, task_id, CHECKOUT_STATE_ACTIVE, branch, base, mode)
|
|
63
55
|
|
|
64
56
|
@classmethod
|
|
65
57
|
def reset(cls, task_type: str, task_id: str) -> "TaskCheckout":
|
|
@@ -75,7 +67,6 @@ class TaskCheckout:
|
|
|
75
67
|
active_dev_branch=self.active_dev_branch,
|
|
76
68
|
base_branch=self.base_branch,
|
|
77
69
|
checkout_mode=self.checkout_mode,
|
|
78
|
-
worktree_path=self.worktree_path,
|
|
79
70
|
)
|
|
80
71
|
|
|
81
72
|
@property
|
|
@@ -90,10 +81,6 @@ class TaskCheckout:
|
|
|
90
81
|
def is_reset(self) -> bool:
|
|
91
82
|
return self.state == CHECKOUT_STATE_RESET
|
|
92
83
|
|
|
93
|
-
@property
|
|
94
|
-
def uses_worktree(self) -> bool:
|
|
95
|
-
return self.checkout_mode == CHECKOUT_MODE_WORKTREE
|
|
96
|
-
|
|
97
84
|
|
|
98
85
|
def task_checkout_path(state_dir: Path | str, task_id: str) -> Path:
|
|
99
86
|
"""Return the canonical checkout identity path for one task."""
|
|
@@ -117,116 +104,56 @@ def load_task_checkout(state_dir: Path | str, task_type: str, task_id: str) -> T
|
|
|
117
104
|
if not isinstance(data, dict):
|
|
118
105
|
raise TaskCheckoutError(f"Invalid task checkout identity {path}: expected a JSON object")
|
|
119
106
|
|
|
107
|
+
raw_mode = str(data.get("checkout_mode") or CHECKOUT_MODE_BRANCH).strip()
|
|
108
|
+
if raw_mode == "worktree":
|
|
109
|
+
raw_worktree = str(data.get("worktree_path") or "").strip()
|
|
110
|
+
location = f" ({raw_worktree})" if raw_worktree else ""
|
|
111
|
+
raise TaskCheckoutError(
|
|
112
|
+
f"Task {task_id} uses retired worktree checkout mode{location}; "
|
|
113
|
+
"remove any leftover linked worktree manually and reset/clean the task before rerunning."
|
|
114
|
+
)
|
|
115
|
+
if raw_mode != CHECKOUT_MODE_BRANCH:
|
|
116
|
+
raise TaskCheckoutError(f"Invalid task checkout mode in {path}: {raw_mode or '(empty)'}")
|
|
117
|
+
|
|
120
118
|
checkout = TaskCheckout(
|
|
121
119
|
task_type=str(data.get("task_type") or ""),
|
|
122
120
|
task_id=str(data.get("task_id") or ""),
|
|
123
121
|
state=str(data.get("state") or ""),
|
|
124
122
|
active_dev_branch=str(data.get("active_dev_branch") or ""),
|
|
125
123
|
base_branch=str(data.get("base_branch") or ""),
|
|
126
|
-
checkout_mode=
|
|
127
|
-
worktree_path=str(data.get("worktree_path") or ""),
|
|
124
|
+
checkout_mode=raw_mode,
|
|
128
125
|
)
|
|
129
126
|
if checkout.task_type != task_type or checkout.task_id != task_id:
|
|
130
127
|
raise TaskCheckoutError(f"Task checkout identity mismatch in {path}")
|
|
131
128
|
if checkout.state not in {CHECKOUT_STATE_ACTIVE, CHECKOUT_STATE_COMPLETED, CHECKOUT_STATE_RESET}:
|
|
132
129
|
raise TaskCheckoutError(f"Invalid task checkout state in {path}: {checkout.state or '(empty)'}")
|
|
133
|
-
if checkout.checkout_mode not in {CHECKOUT_MODE_BRANCH, CHECKOUT_MODE_WORKTREE}:
|
|
134
|
-
raise TaskCheckoutError(f"Invalid task checkout mode in {path}: {checkout.checkout_mode or '(empty)'}")
|
|
135
130
|
if checkout.is_active or checkout.is_completed:
|
|
136
131
|
if not checkout.active_dev_branch.strip() or not checkout.base_branch.strip():
|
|
137
132
|
raise TaskCheckoutError(f"Incomplete task checkout identity in {path}")
|
|
138
|
-
if checkout.uses_worktree and not checkout.worktree_path.strip():
|
|
139
|
-
raise TaskCheckoutError(f"Missing worktree path in task checkout identity {path}")
|
|
140
133
|
return checkout
|
|
141
134
|
|
|
142
135
|
|
|
143
|
-
def _process_is_running(pid: int) -> bool:
|
|
144
|
-
if pid <= 0:
|
|
145
|
-
return False
|
|
146
|
-
try:
|
|
147
|
-
os.kill(pid, 0)
|
|
148
|
-
except ProcessLookupError:
|
|
149
|
-
return False
|
|
150
|
-
except PermissionError:
|
|
151
|
-
return True
|
|
152
|
-
except OSError:
|
|
153
|
-
return False
|
|
154
|
-
return True
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def _lock_owner_pid(lock_path: Path) -> int:
|
|
158
|
-
for _attempt in range(5):
|
|
159
|
-
try:
|
|
160
|
-
data = json.loads((lock_path / "owner.json").read_text(encoding="utf-8"))
|
|
161
|
-
return int(data.get("pid") or 0) if isinstance(data, dict) else 0
|
|
162
|
-
except FileNotFoundError:
|
|
163
|
-
time.sleep(0.01)
|
|
164
|
-
except (OSError, ValueError, json.JSONDecodeError):
|
|
165
|
-
return 0
|
|
166
|
-
return 0
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
def _remove_stale_lock(lock_path: Path) -> None:
|
|
170
|
-
stale_path = lock_path.with_name(f"{lock_path.name}.stale-{os.getpid()}-{os.urandom(6).hex()}")
|
|
171
|
-
try:
|
|
172
|
-
os.rename(lock_path, stale_path)
|
|
173
|
-
except FileNotFoundError:
|
|
174
|
-
return
|
|
175
|
-
except OSError as exc:
|
|
176
|
-
raise TaskCheckoutError(f"Cannot claim stale task checkout lock {lock_path}: {exc}") from exc
|
|
177
|
-
shutil.rmtree(stale_path, ignore_errors=True)
|
|
178
|
-
|
|
179
|
-
|
|
180
136
|
@contextmanager
|
|
181
137
|
def task_checkout_guard(state_dir: Path | str, task_id: str) -> Iterator[None]:
|
|
182
138
|
"""Exclusively guard one task lifecycle, reclaiming locks from dead processes."""
|
|
183
139
|
lock_path = task_checkout_lock_path(state_dir, task_id)
|
|
184
|
-
lock_path.parent.mkdir(parents=True, exist_ok=True)
|
|
185
|
-
acquired = False
|
|
186
|
-
for _attempt in range(3):
|
|
187
|
-
try:
|
|
188
|
-
lock_path.mkdir()
|
|
189
|
-
(lock_path / "owner.json").write_text(json.dumps({"pid": os.getpid()}) + "\n", encoding="utf-8")
|
|
190
|
-
acquired = True
|
|
191
|
-
break
|
|
192
|
-
except FileExistsError:
|
|
193
|
-
owner_pid = _lock_owner_pid(lock_path)
|
|
194
|
-
if _process_is_running(owner_pid):
|
|
195
|
-
raise TaskCheckoutError(f"Task {task_id} is already running or being reset (PID {owner_pid})")
|
|
196
|
-
_remove_stale_lock(lock_path)
|
|
197
|
-
except OSError as exc:
|
|
198
|
-
raise TaskCheckoutError(f"Cannot acquire task checkout lock {lock_path}: {exc}") from exc
|
|
199
|
-
if not acquired:
|
|
200
|
-
raise TaskCheckoutError(f"Cannot acquire task checkout lock {lock_path}")
|
|
201
140
|
try:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
141
|
+
with exclusive_pid_lock(
|
|
142
|
+
lock_path,
|
|
143
|
+
busy_message=f"Task {task_id} is already running or being reset (PID {{pid}})",
|
|
144
|
+
error_label="task checkout lock",
|
|
145
|
+
):
|
|
146
|
+
yield
|
|
147
|
+
except PidLockError as exc:
|
|
148
|
+
raise TaskCheckoutError(str(exc)) from exc
|
|
205
149
|
|
|
206
150
|
|
|
207
151
|
def persist_task_checkout(state_dir: Path | str, checkout: TaskCheckout) -> Path:
|
|
208
152
|
"""Atomically persist checkout identity while the caller holds its task guard."""
|
|
209
153
|
path = task_checkout_path(state_dir, checkout.task_id)
|
|
210
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
211
|
-
descriptor = -1
|
|
212
|
-
temporary = ""
|
|
213
154
|
try:
|
|
214
|
-
|
|
215
|
-
with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
|
|
216
|
-
descriptor = -1
|
|
217
|
-
json.dump(asdict(checkout), handle, indent=2, ensure_ascii=False)
|
|
218
|
-
handle.write("\n")
|
|
219
|
-
handle.flush()
|
|
220
|
-
os.fsync(handle.fileno())
|
|
221
|
-
os.replace(temporary, path)
|
|
155
|
+
write_json_atomic(path, asdict(checkout))
|
|
222
156
|
except OSError as exc:
|
|
223
|
-
if descriptor >= 0:
|
|
224
|
-
os.close(descriptor)
|
|
225
|
-
if temporary:
|
|
226
|
-
try:
|
|
227
|
-
os.unlink(temporary)
|
|
228
|
-
except OSError:
|
|
229
|
-
pass
|
|
230
157
|
raise TaskCheckoutError(f"Cannot persist task checkout identity {path}: {exc}") from exc
|
|
231
158
|
return path
|
|
232
159
|
|
|
@@ -262,7 +189,6 @@ def replace_missing_recorded_base_locked(
|
|
|
262
189
|
existing.active_dev_branch,
|
|
263
190
|
base_branch,
|
|
264
191
|
checkout_mode=existing.checkout_mode,
|
|
265
|
-
worktree_path=existing.worktree_path,
|
|
266
192
|
)
|
|
267
193
|
current = load_task_checkout(state_dir, existing.task_type, existing.task_id)
|
|
268
194
|
if current != existing:
|
|
@@ -15,6 +15,9 @@ _RESULT_LINE_PATTERN = re.compile(
|
|
|
15
15
|
_BARE_RESULT_LINE_PATTERN = re.compile(
|
|
16
16
|
r"(?m)^(TEST_PASS|TEST_NEEDS_FIXES|TEST_BLOCKED)\s*$"
|
|
17
17
|
)
|
|
18
|
+
_PRODUCTION_CHANGED_LINE_PATTERN = re.compile(
|
|
19
|
+
r"(?im)^-\s*Production changed during test:\s*(.+?)\s*$"
|
|
20
|
+
)
|
|
18
21
|
_RESULT_KEYS = {
|
|
19
22
|
"schema_version",
|
|
20
23
|
"result",
|
|
@@ -108,21 +111,42 @@ def valid_test_artifact_pair(
|
|
|
108
111
|
result_path: str | Path,
|
|
109
112
|
*,
|
|
110
113
|
required_result: str | None = None,
|
|
114
|
+
require_no_production_change: bool | None = None,
|
|
111
115
|
) -> bool:
|
|
112
116
|
"""Validate one strict sibling report/result pair and terminal result."""
|
|
113
117
|
return _valid_test_artifact_pair(
|
|
114
118
|
report_path,
|
|
115
119
|
result_path,
|
|
116
120
|
required_result=required_result,
|
|
121
|
+
require_no_production_change=require_no_production_change,
|
|
117
122
|
)
|
|
118
123
|
|
|
119
124
|
|
|
125
|
+
def test_pass_requires_delta_review(
|
|
126
|
+
report_path: str | Path,
|
|
127
|
+
result_path: str | Path,
|
|
128
|
+
) -> bool:
|
|
129
|
+
"""Return whether valid TEST_PASS artifacts require delta Code Review."""
|
|
130
|
+
if not _valid_test_artifact_pair(
|
|
131
|
+
report_path,
|
|
132
|
+
result_path,
|
|
133
|
+
required_result="TEST_PASS",
|
|
134
|
+
require_no_production_change=False,
|
|
135
|
+
):
|
|
136
|
+
return False
|
|
137
|
+
projection = load_test_result(result_path)
|
|
138
|
+
return bool(projection and projection.get("production_changed") is True)
|
|
139
|
+
|
|
140
|
+
|
|
120
141
|
def _valid_test_artifact_pair(
|
|
121
142
|
report_path: str | Path,
|
|
122
143
|
result_path: str | Path,
|
|
123
144
|
*,
|
|
124
145
|
required_result: str | None,
|
|
146
|
+
require_no_production_change: bool | None = None,
|
|
125
147
|
) -> bool:
|
|
148
|
+
if require_no_production_change is None:
|
|
149
|
+
require_no_production_change = required_result == "TEST_PASS"
|
|
126
150
|
report = Path(report_path)
|
|
127
151
|
result = Path(result_path)
|
|
128
152
|
if not report.is_file() or not result.is_file():
|
|
@@ -134,15 +158,45 @@ def _valid_test_artifact_pair(
|
|
|
134
158
|
return False
|
|
135
159
|
if required_result is not None and projection.get("result") != required_result:
|
|
136
160
|
return False
|
|
161
|
+
if require_no_production_change and projection.get("production_changed"):
|
|
162
|
+
return False
|
|
137
163
|
try:
|
|
138
164
|
report_text = report.read_text(encoding="utf-8")
|
|
139
165
|
except OSError:
|
|
140
166
|
return False
|
|
141
167
|
final_result = _report_final_result(report_text)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
168
|
+
if not report_text.startswith("# Test Report") or final_result != projection["result"]:
|
|
169
|
+
return False
|
|
170
|
+
report_changed_valid, report_changed = _parse_report_production_changed(report_text)
|
|
171
|
+
if not report_changed_valid:
|
|
172
|
+
return False
|
|
173
|
+
if report_changed is not None and report_changed != projection["production_changed"]:
|
|
174
|
+
return False
|
|
175
|
+
return True
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _parse_report_production_changed(report: str) -> tuple[bool, bool | None]:
|
|
179
|
+
"""Parse explicit production-change flags from test-report.md."""
|
|
180
|
+
values: list[bool] = []
|
|
181
|
+
for match in _PRODUCTION_CHANGED_LINE_PATTERN.finditer(report):
|
|
182
|
+
normalized = match.group(1).strip().lower()
|
|
183
|
+
if normalized == "yes":
|
|
184
|
+
values.append(True)
|
|
185
|
+
elif normalized == "no":
|
|
186
|
+
values.append(False)
|
|
187
|
+
else:
|
|
188
|
+
return False, None
|
|
189
|
+
if not values:
|
|
190
|
+
return True, None
|
|
191
|
+
if len(set(values)) != 1:
|
|
192
|
+
return False, None
|
|
193
|
+
return True, values[0]
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _report_production_changed(report: str) -> bool | None:
|
|
197
|
+
"""Return unambiguous production-change boolean declared in test-report.md."""
|
|
198
|
+
valid, value = _parse_report_production_changed(report)
|
|
199
|
+
return value if valid else None
|
|
146
200
|
|
|
147
201
|
|
|
148
202
|
def _report_final_result(report: str) -> str | None:
|
|
@@ -18,7 +18,7 @@ from utils import setup_logging
|
|
|
18
18
|
|
|
19
19
|
REQUIRED_FIELDS = ["session_id", "status", "timestamp"]
|
|
20
20
|
# At least one of these ID fields must be present (depends on pipeline type)
|
|
21
|
-
ID_FIELDS = ["feature_id", "bug_id"
|
|
21
|
+
ID_FIELDS = ["feature_id", "bug_id"]
|
|
22
22
|
|
|
23
23
|
LOGGER = setup_logging("check-session-status")
|
|
24
24
|
|
|
@@ -124,24 +124,41 @@ def load_status_file(path):
|
|
|
124
124
|
def validate_required_fields(data):
|
|
125
125
|
"""Check that all required fields are present and non-empty.
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
Supports both canonical runtime session-status.json records
|
|
128
|
+
(``session_id``, ``status``, ``task_id``, ``task_type``; ``timestamp`` optional)
|
|
129
|
+
and legacy session-status.json records
|
|
130
|
+
(``session_id``, ``status``, ``feature_id``|``bug_id``, ``timestamp``).
|
|
130
131
|
"""
|
|
132
|
+
if not isinstance(data, dict):
|
|
133
|
+
return ["session_id", "status", "task_id|feature_id|bug_id"]
|
|
134
|
+
|
|
131
135
|
missing = []
|
|
132
|
-
for field in
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
elif not isinstance(data[field], str) or not data[field].strip():
|
|
136
|
+
for field in ("session_id", "status"):
|
|
137
|
+
value = data.get(field)
|
|
138
|
+
if not isinstance(value, str) or not value.strip():
|
|
136
139
|
missing.append(field)
|
|
137
140
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
task_id = data.get("task_id")
|
|
142
|
+
task_type = data.get("task_type")
|
|
143
|
+
has_canonical_id = (
|
|
144
|
+
isinstance(task_id, str)
|
|
145
|
+
and bool(task_id.strip())
|
|
146
|
+
and task_type in ("feature", "bugfix")
|
|
147
|
+
)
|
|
148
|
+
has_legacy_id = any(
|
|
149
|
+
isinstance(data.get(field), str) and bool(data[field].strip())
|
|
141
150
|
for field in ID_FIELDS
|
|
142
151
|
)
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
|
|
153
|
+
if not has_canonical_id and not has_legacy_id:
|
|
154
|
+
if isinstance(task_id, str) and task_id.strip():
|
|
155
|
+
missing.append("task_type")
|
|
156
|
+
else:
|
|
157
|
+
missing.append("task_id|feature_id|bug_id")
|
|
158
|
+
elif not has_canonical_id:
|
|
159
|
+
ts = data.get("timestamp")
|
|
160
|
+
if not isinstance(ts, str) or not ts.strip():
|
|
161
|
+
missing.append("timestamp")
|
|
145
162
|
|
|
146
163
|
return missing
|
|
147
164
|
|
|
@@ -202,11 +219,13 @@ def build_detail_report(data, resolved_status):
|
|
|
202
219
|
|
|
203
220
|
return {
|
|
204
221
|
"status": resolved_status,
|
|
222
|
+
"task_id": data.get("task_id"),
|
|
223
|
+
"task_type": data.get("task_type"),
|
|
205
224
|
"feature_id": data.get("feature_id"),
|
|
206
225
|
"bug_id": data.get("bug_id"),
|
|
207
|
-
"refactor_id": data.get("refactor_id"),
|
|
208
226
|
"completed_phases": data.get("completed_phases", []),
|
|
209
227
|
"checkpoint_reached": data.get("checkpoint_reached"),
|
|
228
|
+
"checkpoint_state": data.get("checkpoint_state"),
|
|
210
229
|
"tasks_completed": data.get("tasks_completed", 0),
|
|
211
230
|
"tasks_total": data.get("tasks_total", 0),
|
|
212
231
|
"error_count": error_count,
|
|
@@ -241,13 +260,18 @@ def main():
|
|
|
241
260
|
# Validate required fields
|
|
242
261
|
missing = validate_required_fields(data)
|
|
243
262
|
if missing:
|
|
263
|
+
safe_data = data if isinstance(data, dict) else {}
|
|
244
264
|
detail = {
|
|
245
265
|
"status": "crashed",
|
|
246
|
-
"
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
"
|
|
250
|
-
"
|
|
266
|
+
"task_id": safe_data.get("task_id"),
|
|
267
|
+
"task_type": safe_data.get("task_type"),
|
|
268
|
+
"feature_id": safe_data.get("feature_id"),
|
|
269
|
+
"bug_id": safe_data.get("bug_id"),
|
|
270
|
+
"completed_phases": safe_data.get("completed_phases", []),
|
|
271
|
+
"checkpoint_reached": safe_data.get("checkpoint_reached"),
|
|
272
|
+
"checkpoint_state": safe_data.get("checkpoint_state"),
|
|
273
|
+
"tasks_completed": safe_data.get("tasks_completed", 0),
|
|
274
|
+
"tasks_total": safe_data.get("tasks_total", 0),
|
|
251
275
|
"error_count": 1,
|
|
252
276
|
"can_resume": False,
|
|
253
277
|
"resume_from_phase": None,
|
|
@@ -11,7 +11,7 @@ if _PIPELINE_ROOT not in sys.path:
|
|
|
11
11
|
from prizmkit_runtime.checkpoint_state import checkpoint_cursor as shared_checkpoint_cursor # noqa: E402
|
|
12
12
|
|
|
13
13
|
SUPPORTED_CONTINUATION_MODES = {"context_overflow", "ai_error"}
|
|
14
|
-
TASK_TYPES = {"feature", "bugfix"
|
|
14
|
+
TASK_TYPES = {"feature", "bugfix"}
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def add_continuation_args(parser, default_task_type):
|
|
@@ -138,9 +138,11 @@ def continuation_summary_paths(task_type, task_id, task_slug, override_path=""):
|
|
|
138
138
|
)
|
|
139
139
|
return _dedupe([override_path, default_path])
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
if task_type != "bugfix":
|
|
142
|
+
raise ValueError(f"Unsupported task_type: {task_type}")
|
|
143
|
+
|
|
142
144
|
task_local = os.path.join(
|
|
143
|
-
".prizmkit",
|
|
145
|
+
".prizmkit", "bugfix", task_id, "continuation-summary.md",
|
|
144
146
|
)
|
|
145
147
|
specs_path = os.path.join(
|
|
146
148
|
".prizmkit", "specs", task_slug or task_id, "continuation-summary.md",
|
|
@@ -155,7 +157,7 @@ def durable_paths(task_type, task_id, task_slug):
|
|
|
155
157
|
elif task_type == "bugfix":
|
|
156
158
|
artifact_dir = os.path.join(".prizmkit", "bugfix", task_id)
|
|
157
159
|
else:
|
|
158
|
-
|
|
160
|
+
raise ValueError(f"Unsupported task_type: {task_type}")
|
|
159
161
|
|
|
160
162
|
return {
|
|
161
163
|
"artifact_dir": artifact_dir,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""Detect stuck items in the dev-pipeline (features
|
|
2
|
+
"""Detect stuck items in the dev-pipeline (features or bugs).
|
|
3
3
|
|
|
4
4
|
Checks each item for conditions that indicate it is stuck:
|
|
5
5
|
1. Max retries exceeded
|
|
@@ -43,9 +43,9 @@ def parse_args():
|
|
|
43
43
|
)
|
|
44
44
|
parser.add_argument(
|
|
45
45
|
"--pipeline-type",
|
|
46
|
-
choices=["feature", "bugfix"
|
|
46
|
+
choices=["feature", "bugfix"],
|
|
47
47
|
default=None,
|
|
48
|
-
help="Pipeline type (auto-detected from --feature-id/--bug-id
|
|
48
|
+
help="Pipeline type (auto-detected from --feature-id/--bug-id if omitted)",
|
|
49
49
|
)
|
|
50
50
|
parser.add_argument(
|
|
51
51
|
"--item-id",
|
|
@@ -63,11 +63,6 @@ def parse_args():
|
|
|
63
63
|
default=None,
|
|
64
64
|
help="Bug ID — equivalent to --pipeline-type bugfix --item-id <id>",
|
|
65
65
|
)
|
|
66
|
-
parser.add_argument(
|
|
67
|
-
"--refactor-id",
|
|
68
|
-
default=None,
|
|
69
|
-
help="Refactor ID — equivalent to --pipeline-type refactor --item-id <id>",
|
|
70
|
-
)
|
|
71
66
|
parser.add_argument(
|
|
72
67
|
"--max-retries",
|
|
73
68
|
type=int,
|
|
@@ -90,15 +85,10 @@ def parse_args():
|
|
|
90
85
|
default=None,
|
|
91
86
|
help="Path to bug-fix-list.json",
|
|
92
87
|
)
|
|
93
|
-
parser.add_argument(
|
|
94
|
-
"--refactor-list",
|
|
95
|
-
default=None,
|
|
96
|
-
help="Path to refactor-list.json",
|
|
97
|
-
)
|
|
98
88
|
parser.add_argument(
|
|
99
89
|
"--task-list",
|
|
100
90
|
default=None,
|
|
101
|
-
help="Path to the task list JSON (feature-list
|
|
91
|
+
help="Path to the task list JSON (feature-list or bug-fix-list)",
|
|
102
92
|
)
|
|
103
93
|
return parser.parse_args()
|
|
104
94
|
|
|
@@ -198,6 +188,23 @@ def check_max_retries(item_status, max_retries):
|
|
|
198
188
|
return None
|
|
199
189
|
|
|
200
190
|
|
|
191
|
+
def _session_checkpoint_marker(data):
|
|
192
|
+
"""Extract a stable checkpoint progress marker from legacy or canonical status."""
|
|
193
|
+
if not isinstance(data, dict):
|
|
194
|
+
return None
|
|
195
|
+
legacy = data.get("checkpoint_reached")
|
|
196
|
+
if legacy is not None:
|
|
197
|
+
return legacy
|
|
198
|
+
state = data.get("checkpoint_state")
|
|
199
|
+
if not isinstance(state, dict) or not state:
|
|
200
|
+
return None
|
|
201
|
+
stage = str(state.get("current_stage") or state.get("next_stage") or "").strip()
|
|
202
|
+
result = str(state.get("stage_result") or "").strip()
|
|
203
|
+
terminal = str(state.get("terminal_status") or "").strip()
|
|
204
|
+
parts = [part for part in (stage, result, terminal) if part]
|
|
205
|
+
return ":".join(parts) if parts else None
|
|
206
|
+
|
|
207
|
+
|
|
201
208
|
def check_stuck_checkpoint(item_dir):
|
|
202
209
|
"""Check 2: Is the item stuck at the same checkpoint for 3 consecutive sessions?
|
|
203
210
|
|
|
@@ -211,8 +218,7 @@ def check_stuck_checkpoint(item_dir):
|
|
|
211
218
|
last_three = session_statuses[-3:]
|
|
212
219
|
checkpoints = []
|
|
213
220
|
for _sid, data in last_three:
|
|
214
|
-
|
|
215
|
-
checkpoints.append(cp)
|
|
221
|
+
checkpoints.append(_session_checkpoint_marker(data))
|
|
216
222
|
|
|
217
223
|
# All three must be non-None and identical
|
|
218
224
|
if checkpoints[0] is not None and all(cp == checkpoints[0] for cp in checkpoints):
|
|
@@ -262,7 +268,11 @@ def check_stale_heartbeat(item_id, item_status, state_dir, items_subdir, stale_t
|
|
|
262
268
|
}
|
|
263
269
|
|
|
264
270
|
# Parse heartbeat timestamp and check staleness
|
|
265
|
-
ts_str =
|
|
271
|
+
ts_str = (
|
|
272
|
+
heartbeat.get("timestamp")
|
|
273
|
+
or heartbeat.get("last_heartbeat_at")
|
|
274
|
+
or heartbeat.get("updated_at")
|
|
275
|
+
)
|
|
266
276
|
heartbeat_time = parse_iso_timestamp(ts_str)
|
|
267
277
|
if heartbeat_time is None:
|
|
268
278
|
return {
|
|
@@ -345,7 +355,6 @@ def find_task_list(state_dir):
|
|
|
345
355
|
fl_path = (
|
|
346
356
|
pipeline.get("feature_list_path")
|
|
347
357
|
or pipeline.get("bug_list_path")
|
|
348
|
-
or pipeline.get("refactor_list_path")
|
|
349
358
|
)
|
|
350
359
|
if not fl_path:
|
|
351
360
|
return None
|
|
@@ -365,7 +374,6 @@ def find_task_list(state_dir):
|
|
|
365
374
|
PIPELINE_CONFIG = {
|
|
366
375
|
"feature": {"subdir": "", "items_key": "features", "id_label": "feature_id"},
|
|
367
376
|
"bugfix": {"subdir": "", "items_key": "bugs", "id_label": "bug_id"},
|
|
368
|
-
"refactor": {"subdir": "", "items_key": "refactors", "id_label": "refactor_id"},
|
|
369
377
|
}
|
|
370
378
|
|
|
371
379
|
|
|
@@ -426,7 +434,7 @@ def resolve_pipeline_type(args):
|
|
|
426
434
|
ptype = args.pipeline_type
|
|
427
435
|
item_id = args.item_id
|
|
428
436
|
task_list = args.task_list
|
|
429
|
-
# Legacy / shorthand: --feature-id, --bug-id
|
|
437
|
+
# Legacy / shorthand: --feature-id, --bug-id
|
|
430
438
|
elif args.feature_id:
|
|
431
439
|
ptype = "feature"
|
|
432
440
|
item_id = args.feature_id
|
|
@@ -435,10 +443,6 @@ def resolve_pipeline_type(args):
|
|
|
435
443
|
ptype = "bugfix"
|
|
436
444
|
item_id = args.bug_id
|
|
437
445
|
task_list = args.bug_list or args.task_list
|
|
438
|
-
elif args.refactor_id:
|
|
439
|
-
ptype = "refactor"
|
|
440
|
-
item_id = args.refactor_id
|
|
441
|
-
task_list = args.refactor_list or args.task_list
|
|
442
446
|
# Legacy: --feature-list without --feature-id means check all features
|
|
443
447
|
elif args.feature_list:
|
|
444
448
|
ptype = "feature"
|
|
@@ -448,10 +452,6 @@ def resolve_pipeline_type(args):
|
|
|
448
452
|
ptype = "bugfix"
|
|
449
453
|
item_id = None
|
|
450
454
|
task_list = args.bug_list
|
|
451
|
-
elif args.refactor_list:
|
|
452
|
-
ptype = "refactor"
|
|
453
|
-
item_id = None
|
|
454
|
-
task_list = args.refactor_list
|
|
455
455
|
else:
|
|
456
456
|
# Default to feature for backward compat
|
|
457
457
|
ptype = "feature"
|
|
@@ -664,9 +664,14 @@ def _resolve_artifacts(artifact_templates, slug):
|
|
|
664
664
|
return [a.replace("{slug}", slug) for a in artifact_templates]
|
|
665
665
|
|
|
666
666
|
|
|
667
|
-
def route_feature_repair(stage_result, repair_scope=None, repair_round=0):
|
|
667
|
+
def route_feature_repair(stage_result, repair_scope=None, repair_round=0, *, production_changed=False):
|
|
668
668
|
"""Map Feature review/test outcomes to the shared safe route contract."""
|
|
669
|
-
return route_pipeline_repair(
|
|
669
|
+
return route_pipeline_repair(
|
|
670
|
+
stage_result,
|
|
671
|
+
repair_scope,
|
|
672
|
+
repair_round,
|
|
673
|
+
production_changed=production_changed,
|
|
674
|
+
)
|
|
670
675
|
|
|
671
676
|
|
|
672
677
|
def feature_checkpoint_metadata(artifact_dir, stage="plan",
|
|
@@ -33,9 +33,14 @@ from utils import enrich_global_context, helper_replacements, load_json_file, re
|
|
|
33
33
|
LOGGER = setup_logging("generate-bugfix-prompt")
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def route_bugfix_repair(stage_result, repair_scope=None, repair_round=0):
|
|
36
|
+
def route_bugfix_repair(stage_result, repair_scope=None, repair_round=0, *, production_changed=False):
|
|
37
37
|
"""Map Bugfix review/test outcomes to the shared safe route contract."""
|
|
38
|
-
return route_pipeline_repair(
|
|
38
|
+
return route_pipeline_repair(
|
|
39
|
+
stage_result,
|
|
40
|
+
repair_scope,
|
|
41
|
+
repair_round,
|
|
42
|
+
production_changed=production_changed,
|
|
43
|
+
)
|
|
39
44
|
|
|
40
45
|
|
|
41
46
|
def bugfix_checkpoint_metadata(artifact_dir, stage="plan",
|
|
@@ -15,7 +15,7 @@ import re
|
|
|
15
15
|
import sys
|
|
16
16
|
from datetime import datetime, timezone
|
|
17
17
|
|
|
18
|
-
from utils import stable_topological_order
|
|
18
|
+
from utils import stable_topological_order, write_json_file
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
EXPECTED_SCHEMA = "dev-pipeline-bug-fix-list-v1"
|
|
@@ -48,6 +48,7 @@ ALLOWED_BUG_FIELDS = set(REQUIRED_BUG_FIELDS) | {
|
|
|
48
48
|
"user_context",
|
|
49
49
|
"browser_interaction",
|
|
50
50
|
"model",
|
|
51
|
+
"completion_notes",
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
VALID_SEVERITIES = ["critical", "high", "medium", "low"]
|
|
@@ -310,9 +311,9 @@ def create_state_directory(state_dir, bug_list_path, bugs):
|
|
|
310
311
|
"completed_bugs": completed_count,
|
|
311
312
|
}
|
|
312
313
|
pipeline_path = os.path.join(abs_state_dir, "pipeline.json")
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
err = write_json_file(pipeline_path, pipeline_state)
|
|
315
|
+
if err:
|
|
316
|
+
raise OSError(err)
|
|
316
317
|
|
|
317
318
|
# Write per-bug status.json and create sessions directory
|
|
318
319
|
for bug in bugs:
|
|
@@ -337,9 +338,11 @@ def create_state_directory(state_dir, bug_list_path, bugs):
|
|
|
337
338
|
"updated_at": now,
|
|
338
339
|
}
|
|
339
340
|
status_path = os.path.join(bug_dir, "status.json")
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
if os.path.exists(status_path):
|
|
342
|
+
continue
|
|
343
|
+
err = write_json_file(status_path, bug_status)
|
|
344
|
+
if err:
|
|
345
|
+
raise OSError(err)
|
|
343
346
|
|
|
344
347
|
return abs_state_dir
|
|
345
348
|
|