prizmkit 1.1.191 → 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/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 +28 -44
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -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 +48 -78
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
- 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 +540 -262
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
- package/bundled/dev-pipeline/scripts/continuation.py +8 -7
- package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
- 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 +85 -20
- 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 +254 -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 +5 -5
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
- 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/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/conftest.py +0 -29
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
- 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,1871 +0,0 @@
|
|
|
1
|
-
"""Tests for auto-skip and reset_state functionality in update-feature-status.py."""
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import os
|
|
5
|
-
import shutil
|
|
6
|
-
import subprocess
|
|
7
|
-
import sys
|
|
8
|
-
import time
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
import pytest
|
|
12
|
-
|
|
13
|
-
from update_feature_status import (
|
|
14
|
-
auto_skip_blocked_features,
|
|
15
|
-
TERMINAL_STATUSES,
|
|
16
|
-
load_feature_status,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
from utils import load_json_file, write_json_file
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ROOT = Path(__file__).resolve().parents[2]
|
|
23
|
-
UNIX_RUNTIME_SNAPSHOT = ROOT / "tests" / "fixtures" / "dev-pipeline-behavior-snapshots" / "unix-runtime.json"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _python_310_plus() -> str:
|
|
27
|
-
if sys.version_info >= (3, 10):
|
|
28
|
-
return sys.executable
|
|
29
|
-
for executable in ("python3.12", "python3.11", "python3.10"):
|
|
30
|
-
resolved = shutil.which(executable)
|
|
31
|
-
if resolved:
|
|
32
|
-
return resolved
|
|
33
|
-
return sys.executable
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
PYTHON_310_PLUS = _python_310_plus()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def _load_unix_snapshot_section(section):
|
|
40
|
-
with open(UNIX_RUNTIME_SNAPSHOT, encoding="utf-8") as fh:
|
|
41
|
-
fixture = json.load(fh)
|
|
42
|
-
required = fixture.get("requiredScenarios", {}).get(section)
|
|
43
|
-
assert required, f"{section} required scenario list must not be empty"
|
|
44
|
-
section_data = fixture.get(section)
|
|
45
|
-
assert section_data, f"{section} fixture section must not be empty"
|
|
46
|
-
for scenario_id in required:
|
|
47
|
-
assert scenario_id in section_data, f"missing {section}.{scenario_id} from fixture"
|
|
48
|
-
assert section_data[scenario_id] not in ({}, [], "", None), f"empty {section}.{scenario_id} fixture"
|
|
49
|
-
return section_data
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def _assert_matches_unix_snapshot_section(section, actual):
|
|
53
|
-
expected = _load_unix_snapshot_section(section)
|
|
54
|
-
for scenario_id in expected:
|
|
55
|
-
assert scenario_id in actual, f"missing actual {section}.{scenario_id}"
|
|
56
|
-
assert actual == expected
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# ---------------------------------------------------------------------------
|
|
60
|
-
# Helpers
|
|
61
|
-
# ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
def _make_feature(fid, title="Feature", deps=None, status="pending"):
|
|
64
|
-
return {
|
|
65
|
-
"id": fid,
|
|
66
|
-
"title": title,
|
|
67
|
-
"description": "desc",
|
|
68
|
-
"priority": "medium",
|
|
69
|
-
"dependencies": deps or [],
|
|
70
|
-
"acceptance_criteria": ["ok"],
|
|
71
|
-
"status": status,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _make_feature_list(features):
|
|
76
|
-
return {
|
|
77
|
-
"$schema": "dev-pipeline-feature-list-v1",
|
|
78
|
-
"project_name": "test-app",
|
|
79
|
-
"features": features,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _init_state(tmp_path, feature_ids):
|
|
84
|
-
"""Create state dir with status.json for each feature."""
|
|
85
|
-
state_dir = str(tmp_path / "state" / "features")
|
|
86
|
-
for fid in feature_ids:
|
|
87
|
-
feature_dir = os.path.join(state_dir, fid, "sessions")
|
|
88
|
-
os.makedirs(feature_dir, exist_ok=True)
|
|
89
|
-
status_path = os.path.join(state_dir, fid, "status.json")
|
|
90
|
-
write_json_file(status_path, {
|
|
91
|
-
"feature_id": fid,
|
|
92
|
-
"status": "pending",
|
|
93
|
-
"retry_count": 0,
|
|
94
|
-
"max_retries": 3,
|
|
95
|
-
"sessions": [],
|
|
96
|
-
"last_session_id": None,
|
|
97
|
-
"resume_from_phase": None,
|
|
98
|
-
"created_at": "2026-01-01T00:00:00Z",
|
|
99
|
-
"updated_at": "2026-01-01T00:00:00Z",
|
|
100
|
-
})
|
|
101
|
-
return state_dir
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def _write_fl(tmp_path, features):
|
|
105
|
-
"""Write feature-list.json and return its path."""
|
|
106
|
-
fl_path = str(tmp_path / "feature-list.json")
|
|
107
|
-
write_json_file(fl_path, _make_feature_list(features))
|
|
108
|
-
return fl_path
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def _read_statuses(fl_path):
|
|
112
|
-
"""Return {feature_id: status} from feature-list.json."""
|
|
113
|
-
data, _ = load_json_file(fl_path)
|
|
114
|
-
return {f["id"]: f["status"] for f in data["features"]}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# ---------------------------------------------------------------------------
|
|
120
|
-
# context_overflow retry semantics
|
|
121
|
-
# ---------------------------------------------------------------------------
|
|
122
|
-
|
|
123
|
-
class TestContextOverflowRetrySemantics:
|
|
124
|
-
def _script_cases(self, scripts_dir):
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
"script": scripts_dir / "update-feature-status.py",
|
|
128
|
-
"list_option": "--feature-list",
|
|
129
|
-
"id_option": "--feature-id",
|
|
130
|
-
"id": "F-001",
|
|
131
|
-
"list_name": "feature-list.json",
|
|
132
|
-
"collection": "features",
|
|
133
|
-
"list_payload": {
|
|
134
|
-
"features": [_make_feature("F-001", "Context Overflow", status="in_progress")],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"script": scripts_dir / "update-bug-status.py",
|
|
139
|
-
"list_option": "--bug-list",
|
|
140
|
-
"id_option": "--bug-id",
|
|
141
|
-
"id": "B-001",
|
|
142
|
-
"list_name": "bug-fix-list.json",
|
|
143
|
-
"collection": "bugs",
|
|
144
|
-
"list_payload": {
|
|
145
|
-
"bugs": [{
|
|
146
|
-
"id": "B-001",
|
|
147
|
-
"title": "Context Overflow Bug",
|
|
148
|
-
"description": "desc",
|
|
149
|
-
"severity": "medium",
|
|
150
|
-
"priority": "medium",
|
|
151
|
-
"status": "in_progress",
|
|
152
|
-
}],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
"script": scripts_dir / "update-refactor-status.py",
|
|
157
|
-
"list_option": "--refactor-list",
|
|
158
|
-
"id_option": "--refactor-id",
|
|
159
|
-
"id": "R-001",
|
|
160
|
-
"list_name": "refactor-list.json",
|
|
161
|
-
"collection": "refactors",
|
|
162
|
-
"list_payload": {
|
|
163
|
-
"refactors": [{
|
|
164
|
-
"id": "R-001",
|
|
165
|
-
"title": "Context Overflow Refactor",
|
|
166
|
-
"description": "desc",
|
|
167
|
-
"complexity": "medium",
|
|
168
|
-
"priority": "medium",
|
|
169
|
-
"status": "in_progress",
|
|
170
|
-
"dependencies": [],
|
|
171
|
-
}],
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
]
|
|
175
|
-
|
|
176
|
-
def _run_case_update(self, case, list_path, state_dir, session_status, session_id="sess-1", extra_args=None):
|
|
177
|
-
cmd = [
|
|
178
|
-
"python3",
|
|
179
|
-
str(case["script"]),
|
|
180
|
-
case["list_option"],
|
|
181
|
-
str(list_path),
|
|
182
|
-
"--state-dir",
|
|
183
|
-
str(state_dir),
|
|
184
|
-
case["id_option"],
|
|
185
|
-
case["id"],
|
|
186
|
-
"--session-id",
|
|
187
|
-
session_id,
|
|
188
|
-
"--session-status",
|
|
189
|
-
session_status,
|
|
190
|
-
"--max-retries",
|
|
191
|
-
"3",
|
|
192
|
-
"--max-infra-retries",
|
|
193
|
-
"3",
|
|
194
|
-
"--action",
|
|
195
|
-
"update",
|
|
196
|
-
]
|
|
197
|
-
if extra_args:
|
|
198
|
-
cmd.extend(extra_args)
|
|
199
|
-
result = subprocess.run(cmd, text=True, capture_output=True, check=True)
|
|
200
|
-
return json.loads(result.stdout)
|
|
201
|
-
|
|
202
|
-
def _runtime_status(self, state_dir, item_id):
|
|
203
|
-
with open(Path(state_dir) / item_id / "status.json", encoding="utf-8") as fh:
|
|
204
|
-
return json.load(fh)
|
|
205
|
-
|
|
206
|
-
def _assert_no_continuation_runtime_state(self, status):
|
|
207
|
-
for key in [
|
|
208
|
-
"active_dev_branch",
|
|
209
|
-
"base_branch",
|
|
210
|
-
"continuation_pending",
|
|
211
|
-
"continuation_reason",
|
|
212
|
-
"last_context_overflow_session_id",
|
|
213
|
-
"previous_session_id",
|
|
214
|
-
"last_fatal_error_code",
|
|
215
|
-
"continuation_summary_path",
|
|
216
|
-
"no_progress_count",
|
|
217
|
-
"last_progress_fingerprint",
|
|
218
|
-
"needs_attention",
|
|
219
|
-
"stalled_context_continuation",
|
|
220
|
-
"stalled_reason",
|
|
221
|
-
"context_overflow_count",
|
|
222
|
-
"continuation_count",
|
|
223
|
-
]:
|
|
224
|
-
assert key not in status
|
|
225
|
-
|
|
226
|
-
def test_start_and_update_persist_effective_retry_budgets_without_charging_workflow_skip(self, tmp_path):
|
|
227
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
228
|
-
|
|
229
|
-
for case in self._script_cases(scripts_dir):
|
|
230
|
-
case_dir = tmp_path / f"budgets-{case['id']}"
|
|
231
|
-
state_dir = case_dir / "state"
|
|
232
|
-
list_path = case_dir / case["list_name"]
|
|
233
|
-
payload = json.loads(json.dumps(case["list_payload"]))
|
|
234
|
-
payload[case["collection"]][0]["status"] = "pending"
|
|
235
|
-
write_json_file(str(list_path), payload)
|
|
236
|
-
|
|
237
|
-
start = subprocess.run(
|
|
238
|
-
[
|
|
239
|
-
"python3",
|
|
240
|
-
str(case["script"]),
|
|
241
|
-
case["list_option"],
|
|
242
|
-
str(list_path),
|
|
243
|
-
"--state-dir",
|
|
244
|
-
str(state_dir),
|
|
245
|
-
case["id_option"],
|
|
246
|
-
case["id"],
|
|
247
|
-
"--action",
|
|
248
|
-
"start",
|
|
249
|
-
"--max-retries",
|
|
250
|
-
"7",
|
|
251
|
-
"--max-infra-retries",
|
|
252
|
-
"4",
|
|
253
|
-
],
|
|
254
|
-
text=True,
|
|
255
|
-
capture_output=True,
|
|
256
|
-
check=True,
|
|
257
|
-
)
|
|
258
|
-
assert json.loads(start.stdout)["new_status"] == "in_progress"
|
|
259
|
-
started = self._runtime_status(state_dir, case["id"])
|
|
260
|
-
assert started["max_retries"] == 7
|
|
261
|
-
assert started["max_infra_retries"] == 4
|
|
262
|
-
|
|
263
|
-
skipped = subprocess.run(
|
|
264
|
-
[
|
|
265
|
-
"python3",
|
|
266
|
-
str(case["script"]),
|
|
267
|
-
case["list_option"],
|
|
268
|
-
str(list_path),
|
|
269
|
-
"--state-dir",
|
|
270
|
-
str(state_dir),
|
|
271
|
-
case["id_option"],
|
|
272
|
-
case["id"],
|
|
273
|
-
"--session-id",
|
|
274
|
-
"sess-skip",
|
|
275
|
-
"--session-status",
|
|
276
|
-
"workflow_skipped",
|
|
277
|
-
"--action",
|
|
278
|
-
"update",
|
|
279
|
-
"--max-retries",
|
|
280
|
-
"5",
|
|
281
|
-
"--max-infra-retries",
|
|
282
|
-
"2",
|
|
283
|
-
],
|
|
284
|
-
text=True,
|
|
285
|
-
capture_output=True,
|
|
286
|
-
check=True,
|
|
287
|
-
)
|
|
288
|
-
summary = json.loads(skipped.stdout)
|
|
289
|
-
runtime = self._runtime_status(state_dir, case["id"])
|
|
290
|
-
assert summary["new_status"] == "skipped"
|
|
291
|
-
assert runtime["max_retries"] == 5
|
|
292
|
-
assert runtime["max_infra_retries"] == 2
|
|
293
|
-
assert runtime["retry_count"] == 0
|
|
294
|
-
assert runtime["infra_error_count"] == 0
|
|
295
|
-
|
|
296
|
-
def test_context_overflow_consumes_retry_and_records_bounded_continuation_metadata(self, tmp_path):
|
|
297
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
298
|
-
|
|
299
|
-
for case in self._script_cases(scripts_dir):
|
|
300
|
-
case_dir = tmp_path / case["id"]
|
|
301
|
-
state_dir = case_dir / "state"
|
|
302
|
-
list_path = case_dir / case["list_name"]
|
|
303
|
-
session_dir = state_dir / case["id"] / "sessions" / "sess-1"
|
|
304
|
-
session_dir.mkdir(parents=True)
|
|
305
|
-
(session_dir / "session.log").write_text("context overflow diagnostics", encoding="utf-8")
|
|
306
|
-
write_json_file(str(list_path), case["list_payload"])
|
|
307
|
-
status_path = state_dir / case["id"] / "status.json"
|
|
308
|
-
write_json_file(str(status_path), {
|
|
309
|
-
"retry_count": 1,
|
|
310
|
-
"infra_error_count": 1,
|
|
311
|
-
"sessions": [],
|
|
312
|
-
"last_session_id": None,
|
|
313
|
-
"resume_from_phase": None,
|
|
314
|
-
})
|
|
315
|
-
before_mtime = list_path.stat().st_mtime_ns
|
|
316
|
-
time.sleep(0.01)
|
|
317
|
-
|
|
318
|
-
summary = self._run_case_update(
|
|
319
|
-
case,
|
|
320
|
-
list_path,
|
|
321
|
-
state_dir,
|
|
322
|
-
"context_overflow",
|
|
323
|
-
extra_args=[
|
|
324
|
-
"--active-dev-branch",
|
|
325
|
-
"dev/existing-branch",
|
|
326
|
-
"--base-branch",
|
|
327
|
-
"main",
|
|
328
|
-
"--last-fatal-error-code",
|
|
329
|
-
"context_overflow",
|
|
330
|
-
"--continuation-summary-path",
|
|
331
|
-
str(session_dir / "continuation-summary.md"),
|
|
332
|
-
],
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
assert summary["new_status"] == "in_progress"
|
|
336
|
-
assert summary["retry_count"] == 2
|
|
337
|
-
assert summary["infra_error_count"] == 1
|
|
338
|
-
assert summary["context_overflow_count"] == 1
|
|
339
|
-
assert summary["continuation_count"] == 1
|
|
340
|
-
assert summary["continuation_pending"] is True
|
|
341
|
-
assert summary["restart_policy"] == "context_overflow_continuation"
|
|
342
|
-
assert summary["artifacts_preserved"] is True
|
|
343
|
-
assert "cleanup_performed" not in summary
|
|
344
|
-
assert (session_dir / "session.log").exists()
|
|
345
|
-
assert list_path.stat().st_mtime_ns == before_mtime
|
|
346
|
-
|
|
347
|
-
list_data, _ = load_json_file(str(list_path))
|
|
348
|
-
assert list_data[case["collection"]][0]["status"] == "in_progress"
|
|
349
|
-
|
|
350
|
-
runtime = self._runtime_status(state_dir, case["id"])
|
|
351
|
-
assert runtime["retry_count"] == 2
|
|
352
|
-
assert runtime["infra_error_count"] == 1
|
|
353
|
-
assert runtime["active_dev_branch"] == "dev/existing-branch"
|
|
354
|
-
assert runtime["base_branch"] == "main"
|
|
355
|
-
assert runtime["continuation_pending"] is True
|
|
356
|
-
assert runtime["continuation_reason"] == "context_overflow"
|
|
357
|
-
assert runtime["last_context_overflow_session_id"] == "sess-1"
|
|
358
|
-
assert runtime["last_fatal_error_code"] == "context_overflow"
|
|
359
|
-
assert runtime["context_overflow_count"] == 1
|
|
360
|
-
assert runtime["continuation_count"] == 1
|
|
361
|
-
assert runtime["continuation_summary_path"].endswith("continuation-summary.md")
|
|
362
|
-
assert runtime["last_session_id"] == "sess-1"
|
|
363
|
-
assert runtime.get("last_infra_error_session_id") is None
|
|
364
|
-
|
|
365
|
-
get_next = subprocess.run(
|
|
366
|
-
[
|
|
367
|
-
"python3",
|
|
368
|
-
str(case["script"]),
|
|
369
|
-
case["list_option"],
|
|
370
|
-
str(list_path),
|
|
371
|
-
"--state-dir",
|
|
372
|
-
str(state_dir),
|
|
373
|
-
"--action",
|
|
374
|
-
"get_next",
|
|
375
|
-
],
|
|
376
|
-
text=True,
|
|
377
|
-
capture_output=True,
|
|
378
|
-
check=True,
|
|
379
|
-
)
|
|
380
|
-
selected = json.loads(get_next.stdout)
|
|
381
|
-
assert selected["active_dev_branch"] == "dev/existing-branch"
|
|
382
|
-
assert selected["base_branch"] == "main"
|
|
383
|
-
assert selected["continuation_pending"] is True
|
|
384
|
-
assert selected["continuation_reason"] == "context_overflow"
|
|
385
|
-
assert selected["last_context_overflow_session_id"] == "sess-1"
|
|
386
|
-
assert selected["last_fatal_error_code"] == "context_overflow"
|
|
387
|
-
assert selected["context_overflow_count"] == 1
|
|
388
|
-
assert selected["continuation_count"] == 1
|
|
389
|
-
assert selected["continuation_summary_path"].endswith("continuation-summary.md")
|
|
390
|
-
|
|
391
|
-
def test_context_overflow_reaching_retry_limit_stops_all_families(self, tmp_path):
|
|
392
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
393
|
-
|
|
394
|
-
for case in self._script_cases(scripts_dir):
|
|
395
|
-
case_dir = tmp_path / f"bounded-{case['id']}"
|
|
396
|
-
state_dir = case_dir / "state"
|
|
397
|
-
list_path = case_dir / case["list_name"]
|
|
398
|
-
session_dir = state_dir / case["id"] / "sessions" / "sess-limit"
|
|
399
|
-
session_dir.mkdir(parents=True)
|
|
400
|
-
(session_dir / "session.log").write_text("context overflow diagnostics", encoding="utf-8")
|
|
401
|
-
write_json_file(str(list_path), case["list_payload"])
|
|
402
|
-
status_path = state_dir / case["id"] / "status.json"
|
|
403
|
-
write_json_file(str(status_path), {
|
|
404
|
-
"retry_count": 2,
|
|
405
|
-
"infra_error_count": 1,
|
|
406
|
-
"sessions": [],
|
|
407
|
-
"last_session_id": None,
|
|
408
|
-
"resume_from_phase": None,
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
summary = self._run_case_update(
|
|
412
|
-
case,
|
|
413
|
-
list_path,
|
|
414
|
-
state_dir,
|
|
415
|
-
"context_overflow",
|
|
416
|
-
session_id="sess-limit",
|
|
417
|
-
extra_args=[
|
|
418
|
-
"--active-dev-branch",
|
|
419
|
-
"dev/existing-branch",
|
|
420
|
-
"--base-branch",
|
|
421
|
-
"main",
|
|
422
|
-
"--last-fatal-error-code",
|
|
423
|
-
"context_overflow",
|
|
424
|
-
],
|
|
425
|
-
)
|
|
426
|
-
|
|
427
|
-
assert summary["new_status"] == "failed"
|
|
428
|
-
assert summary["retry_count"] == 3
|
|
429
|
-
assert summary["infra_error_count"] == 1
|
|
430
|
-
assert summary["context_overflow_count"] == 1
|
|
431
|
-
assert summary["continuation_count"] == 1
|
|
432
|
-
assert summary["continuation_pending"] is False
|
|
433
|
-
assert summary["restart_policy"] == "needs_attention"
|
|
434
|
-
assert summary["artifacts_preserved"] is True
|
|
435
|
-
assert (session_dir / "session.log").exists()
|
|
436
|
-
|
|
437
|
-
list_data, _ = load_json_file(str(list_path))
|
|
438
|
-
assert list_data[case["collection"]][0]["status"] == "failed"
|
|
439
|
-
|
|
440
|
-
runtime = self._runtime_status(state_dir, case["id"])
|
|
441
|
-
assert runtime["retry_count"] == 3
|
|
442
|
-
assert runtime["continuation_pending"] is False
|
|
443
|
-
assert runtime["continuation_reason"] == "context_overflow"
|
|
444
|
-
assert runtime["needs_attention"] is True
|
|
445
|
-
assert runtime["last_failed_session_id"] == "sess-limit"
|
|
446
|
-
assert runtime["context_overflow_count"] == 1
|
|
447
|
-
assert runtime["continuation_count"] == 1
|
|
448
|
-
|
|
449
|
-
def test_context_overflow_from_non_started_item_marks_in_progress_once(self, tmp_path):
|
|
450
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
451
|
-
|
|
452
|
-
for case in self._script_cases(scripts_dir):
|
|
453
|
-
case_dir = tmp_path / f"pending-{case['id']}"
|
|
454
|
-
state_dir = case_dir / "state"
|
|
455
|
-
list_path = case_dir / case["list_name"]
|
|
456
|
-
payload = json.loads(json.dumps(case["list_payload"]))
|
|
457
|
-
payload[case["collection"]][0]["status"] = "pending"
|
|
458
|
-
write_json_file(str(list_path), payload)
|
|
459
|
-
|
|
460
|
-
summary = self._run_case_update(
|
|
461
|
-
case,
|
|
462
|
-
list_path,
|
|
463
|
-
state_dir,
|
|
464
|
-
"context_overflow",
|
|
465
|
-
extra_args=["--active-dev-branch", "dev/new", "--base-branch", "main"],
|
|
466
|
-
)
|
|
467
|
-
|
|
468
|
-
list_data, _ = load_json_file(str(list_path))
|
|
469
|
-
assert summary["new_status"] == "in_progress"
|
|
470
|
-
assert list_data[case["collection"]][0]["status"] == "in_progress"
|
|
471
|
-
|
|
472
|
-
def test_success_clears_pending_continuation_fields_but_preserves_counters(self, tmp_path):
|
|
473
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
474
|
-
|
|
475
|
-
for case in self._script_cases(scripts_dir):
|
|
476
|
-
case_dir = tmp_path / f"success-{case['id']}"
|
|
477
|
-
state_dir = case_dir / "state"
|
|
478
|
-
list_path = case_dir / case["list_name"]
|
|
479
|
-
write_json_file(str(list_path), case["list_payload"])
|
|
480
|
-
status_path = state_dir / case["id"] / "status.json"
|
|
481
|
-
status_path.parent.mkdir(parents=True)
|
|
482
|
-
write_json_file(str(status_path), {
|
|
483
|
-
"retry_count": 0,
|
|
484
|
-
"infra_error_count": 0,
|
|
485
|
-
"active_dev_branch": "dev/existing-branch",
|
|
486
|
-
"base_branch": "main",
|
|
487
|
-
"continuation_pending": True,
|
|
488
|
-
"continuation_reason": "context_overflow",
|
|
489
|
-
"last_context_overflow_session_id": "sess-overflow",
|
|
490
|
-
"last_fatal_error_code": "context_overflow",
|
|
491
|
-
"continuation_summary_path": "summary.md",
|
|
492
|
-
"context_overflow_count": 2,
|
|
493
|
-
"continuation_count": 2,
|
|
494
|
-
"sessions": [],
|
|
495
|
-
"last_session_id": None,
|
|
496
|
-
"resume_from_phase": None,
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
summary = self._run_case_update(case, list_path, state_dir, "success", session_id="sess-success")
|
|
500
|
-
|
|
501
|
-
assert summary["new_status"] == "completed"
|
|
502
|
-
runtime = self._runtime_status(state_dir, case["id"])
|
|
503
|
-
for key in [
|
|
504
|
-
"active_dev_branch",
|
|
505
|
-
"base_branch",
|
|
506
|
-
"continuation_pending",
|
|
507
|
-
"continuation_reason",
|
|
508
|
-
"last_context_overflow_session_id",
|
|
509
|
-
"last_fatal_error_code",
|
|
510
|
-
"continuation_summary_path",
|
|
511
|
-
]:
|
|
512
|
-
assert key not in runtime
|
|
513
|
-
assert runtime["context_overflow_count"] == 2
|
|
514
|
-
assert runtime["continuation_count"] == 2
|
|
515
|
-
|
|
516
|
-
def test_manual_reset_clean_and_reset_state_clear_all_continuation_state(self, tmp_path):
|
|
517
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
518
|
-
|
|
519
|
-
for action in ["reset", "clean", "reset_state"]:
|
|
520
|
-
for case in self._script_cases(scripts_dir):
|
|
521
|
-
case_dir = tmp_path / f"{action}-{case['id']}"
|
|
522
|
-
state_dir = case_dir / "state"
|
|
523
|
-
list_path = case_dir / case["list_name"]
|
|
524
|
-
payload = json.loads(json.dumps(case["list_payload"]))
|
|
525
|
-
payload[case["collection"]][0]["status"] = "failed"
|
|
526
|
-
write_json_file(str(list_path), payload)
|
|
527
|
-
status_path = state_dir / case["id"] / "status.json"
|
|
528
|
-
status_path.parent.mkdir(parents=True)
|
|
529
|
-
write_json_file(str(status_path), {
|
|
530
|
-
"retry_count": 3,
|
|
531
|
-
"infra_error_count": 2,
|
|
532
|
-
"active_dev_branch": "dev/existing-branch",
|
|
533
|
-
"base_branch": "main",
|
|
534
|
-
"continuation_pending": True,
|
|
535
|
-
"continuation_reason": "context_overflow",
|
|
536
|
-
"last_context_overflow_session_id": "sess-overflow",
|
|
537
|
-
"previous_session_id": "sess-overflow",
|
|
538
|
-
"last_fatal_error_code": "context_overflow",
|
|
539
|
-
"continuation_summary_path": "continuation-summary.md",
|
|
540
|
-
"no_progress_count": 1,
|
|
541
|
-
"last_progress_fingerprint": {"checkpoint": "old"},
|
|
542
|
-
"needs_attention": True,
|
|
543
|
-
"stalled_context_continuation": True,
|
|
544
|
-
"stalled_reason": "context_overflow_without_git_checkpoint_or_artifact_progress",
|
|
545
|
-
"context_overflow_count": 2,
|
|
546
|
-
"continuation_count": 2,
|
|
547
|
-
"sessions": ["old"],
|
|
548
|
-
"last_session_id": "old",
|
|
549
|
-
"resume_from_phase": 4,
|
|
550
|
-
})
|
|
551
|
-
continuation_files = []
|
|
552
|
-
if action == "clean":
|
|
553
|
-
stored_summary = case_dir / "continuation-summary.md"
|
|
554
|
-
stored_summary.write_text("stored", encoding="utf-8")
|
|
555
|
-
continuation_files.append(stored_summary)
|
|
556
|
-
if case["id_option"] == "--feature-id":
|
|
557
|
-
conventional_summary = case_dir / ".prizmkit" / "specs" / "001-context-overflow" / "continuation-summary.md"
|
|
558
|
-
elif case["id_option"] == "--bug-id":
|
|
559
|
-
conventional_summary = case_dir / ".prizmkit" / "bugfix" / case["id"] / "continuation-summary.md"
|
|
560
|
-
else:
|
|
561
|
-
conventional_summary = case_dir / ".prizmkit" / "refactor" / case["id"] / "continuation-summary.md"
|
|
562
|
-
conventional_summary.parent.mkdir(parents=True)
|
|
563
|
-
conventional_summary.write_text("conventional", encoding="utf-8")
|
|
564
|
-
continuation_files.append(conventional_summary)
|
|
565
|
-
|
|
566
|
-
cmd = [
|
|
567
|
-
"python3",
|
|
568
|
-
str(case["script"]),
|
|
569
|
-
case["list_option"],
|
|
570
|
-
str(list_path),
|
|
571
|
-
"--state-dir",
|
|
572
|
-
str(state_dir),
|
|
573
|
-
"--action",
|
|
574
|
-
action,
|
|
575
|
-
]
|
|
576
|
-
if action in ("reset", "clean"):
|
|
577
|
-
cmd.extend([case["id_option"], case["id"]])
|
|
578
|
-
elif action == "reset_state":
|
|
579
|
-
cmd.extend([case["id_option"], case["id"]])
|
|
580
|
-
if action == "clean":
|
|
581
|
-
cmd.extend(["--project-root", str(case_dir)])
|
|
582
|
-
if case["id_option"] == "--feature-id":
|
|
583
|
-
cmd.extend(["--feature-slug", "001-context-overflow"])
|
|
584
|
-
|
|
585
|
-
result = subprocess.run(cmd, text=True, capture_output=True, check=True)
|
|
586
|
-
assert result.returncode == 0
|
|
587
|
-
for continuation_file in continuation_files:
|
|
588
|
-
assert not continuation_file.exists()
|
|
589
|
-
runtime = self._runtime_status(state_dir, case["id"])
|
|
590
|
-
if action == "reset_state":
|
|
591
|
-
assert runtime["active_dev_branch"] == "dev/existing-branch"
|
|
592
|
-
assert runtime["base_branch"] == "main"
|
|
593
|
-
continuation_only = dict(runtime)
|
|
594
|
-
continuation_only.pop("active_dev_branch")
|
|
595
|
-
continuation_only.pop("base_branch")
|
|
596
|
-
self._assert_no_continuation_runtime_state(continuation_only)
|
|
597
|
-
else:
|
|
598
|
-
self._assert_no_continuation_runtime_state(runtime)
|
|
599
|
-
assert runtime["retry_count"] == 0
|
|
600
|
-
assert runtime["infra_error_count"] == 0
|
|
601
|
-
assert runtime["last_infra_error_session_id"] is None
|
|
602
|
-
list_data, _ = load_json_file(str(list_path))
|
|
603
|
-
assert list_data[case["collection"]][0]["status"] == "pending"
|
|
604
|
-
def test_python_reset_warns_before_manual_continuation_reset(self, tmp_path):
|
|
605
|
-
project_root = Path(__file__).resolve().parents[2]
|
|
606
|
-
cli_path = project_root / "dev-pipeline" / "cli.py"
|
|
607
|
-
script_cases = [
|
|
608
|
-
{
|
|
609
|
-
"target": "feature",
|
|
610
|
-
"list_name": "feature-list.json",
|
|
611
|
-
"state_root": "features",
|
|
612
|
-
"item_id": "F-001",
|
|
613
|
-
"list_payload": {
|
|
614
|
-
"features": [_make_feature("F-001", "Context Overflow", status="failed")],
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
"target": "bugfix",
|
|
619
|
-
"list_name": "bug-fix-list.json",
|
|
620
|
-
"state_root": "bugfix",
|
|
621
|
-
"item_id": "B-001",
|
|
622
|
-
"list_payload": {
|
|
623
|
-
"bugs": [{
|
|
624
|
-
"id": "B-001",
|
|
625
|
-
"title": "Context Overflow Bug",
|
|
626
|
-
"description": "desc",
|
|
627
|
-
"severity": "medium",
|
|
628
|
-
"priority": "medium",
|
|
629
|
-
"status": "failed",
|
|
630
|
-
}],
|
|
631
|
-
},
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
"target": "refactor",
|
|
635
|
-
"list_name": "refactor-list.json",
|
|
636
|
-
"state_root": "refactor",
|
|
637
|
-
"item_id": "R-001",
|
|
638
|
-
"list_payload": {
|
|
639
|
-
"refactors": [{
|
|
640
|
-
"id": "R-001",
|
|
641
|
-
"title": "Context Overflow Refactor",
|
|
642
|
-
"description": "desc",
|
|
643
|
-
"complexity": "medium",
|
|
644
|
-
"priority": "medium",
|
|
645
|
-
"status": "failed",
|
|
646
|
-
"dependencies": [],
|
|
647
|
-
}],
|
|
648
|
-
},
|
|
649
|
-
},
|
|
650
|
-
]
|
|
651
|
-
|
|
652
|
-
for case in script_cases:
|
|
653
|
-
case_dir = tmp_path / case["item_id"]
|
|
654
|
-
prizmkit_dir = case_dir / ".prizmkit"
|
|
655
|
-
state_dir = prizmkit_dir / "state" / case["state_root"]
|
|
656
|
-
item_state_dir = state_dir / case["item_id"]
|
|
657
|
-
item_state_dir.mkdir(parents=True)
|
|
658
|
-
write_json_file(str(prizmkit_dir / "plans" / case["list_name"]), case["list_payload"])
|
|
659
|
-
write_json_file(str(state_dir / "pipeline.json"), {"status": "running"})
|
|
660
|
-
write_json_file(str(item_state_dir / "status.json"), {
|
|
661
|
-
"retry_count": 1,
|
|
662
|
-
"infra_error_count": 0,
|
|
663
|
-
"continuation_pending": True,
|
|
664
|
-
"continuation_reason": "context_overflow",
|
|
665
|
-
"active_dev_branch": "dev/manual-continuation",
|
|
666
|
-
"sessions": [],
|
|
667
|
-
})
|
|
668
|
-
subprocess.run(["git", "init", "-q"], cwd=case_dir, check=True)
|
|
669
|
-
subprocess.run(["git", "config", "user.email", "test@example.com"], cwd=case_dir, check=True)
|
|
670
|
-
subprocess.run(["git", "config", "user.name", "Test User"], cwd=case_dir, check=True)
|
|
671
|
-
(case_dir / "README.md").write_text("test\n", encoding="utf-8")
|
|
672
|
-
subprocess.run(["git", "add", "README.md"], cwd=case_dir, check=True)
|
|
673
|
-
subprocess.run(["git", "commit", "-q", "-m", "init"], cwd=case_dir, check=True)
|
|
674
|
-
|
|
675
|
-
result = subprocess.run(
|
|
676
|
-
[
|
|
677
|
-
PYTHON_310_PLUS,
|
|
678
|
-
str(cli_path),
|
|
679
|
-
"--project-root",
|
|
680
|
-
str(case_dir),
|
|
681
|
-
"reset",
|
|
682
|
-
case["target"],
|
|
683
|
-
case["item_id"],
|
|
684
|
-
"--fresh-checkout",
|
|
685
|
-
str(prizmkit_dir / "plans" / case["list_name"]),
|
|
686
|
-
],
|
|
687
|
-
cwd=case_dir,
|
|
688
|
-
text=True,
|
|
689
|
-
capture_output=True,
|
|
690
|
-
)
|
|
691
|
-
|
|
692
|
-
output = result.stdout + result.stderr
|
|
693
|
-
assert "Manual reset will abandon automatic continuation progress" in output
|
|
694
|
-
assert "Pending continuation branch: dev/manual-continuation" in output
|
|
695
|
-
assert output.index("Manual reset will abandon automatic continuation progress") < output.index("Resetting")
|
|
696
|
-
assert result.returncode == 0, output
|
|
697
|
-
runtime = self._runtime_status(state_dir, case["item_id"])
|
|
698
|
-
self._assert_no_continuation_runtime_state(runtime)
|
|
699
|
-
assert runtime["retry_count"] == 0
|
|
700
|
-
assert runtime["infra_error_count"] == 0
|
|
701
|
-
assert runtime["last_infra_error_session_id"] is None
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
# ---------------------------------------------------------------------------
|
|
705
|
-
# Unix runtime snapshot oracle: status updater behavior
|
|
706
|
-
# ---------------------------------------------------------------------------
|
|
707
|
-
|
|
708
|
-
_STATUS_SUMMARY_KEYS = [
|
|
709
|
-
"new_status",
|
|
710
|
-
"retry_count",
|
|
711
|
-
"infra_error_count",
|
|
712
|
-
"max_infra_retries",
|
|
713
|
-
"restart_policy",
|
|
714
|
-
"context_overflow_count",
|
|
715
|
-
"continuation_count",
|
|
716
|
-
"continuation_pending",
|
|
717
|
-
"artifacts_preserved",
|
|
718
|
-
"needs_attention",
|
|
719
|
-
"stalled_context_continuation",
|
|
720
|
-
"stalled_reason",
|
|
721
|
-
"no_progress_count",
|
|
722
|
-
]
|
|
723
|
-
|
|
724
|
-
_RUNTIME_STATUS_KEYS = [
|
|
725
|
-
"retry_count",
|
|
726
|
-
"infra_error_count",
|
|
727
|
-
"last_infra_error_session_id",
|
|
728
|
-
"last_failed_session_id",
|
|
729
|
-
"active_dev_branch",
|
|
730
|
-
"base_branch",
|
|
731
|
-
"continuation_pending",
|
|
732
|
-
"continuation_reason",
|
|
733
|
-
"last_context_overflow_session_id",
|
|
734
|
-
"previous_session_id",
|
|
735
|
-
"last_fatal_error_code",
|
|
736
|
-
"continuation_summary_path",
|
|
737
|
-
"context_overflow_count",
|
|
738
|
-
"continuation_count",
|
|
739
|
-
"no_progress_count",
|
|
740
|
-
"last_progress_fingerprint",
|
|
741
|
-
"needs_attention",
|
|
742
|
-
"stalled_context_continuation",
|
|
743
|
-
"stalled_reason",
|
|
744
|
-
"last_session_id",
|
|
745
|
-
]
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
def _status_snapshot_cases(scripts_dir):
|
|
749
|
-
return [
|
|
750
|
-
{
|
|
751
|
-
"task": "feature",
|
|
752
|
-
"script": scripts_dir / "update-feature-status.py",
|
|
753
|
-
"list_option": "--feature-list",
|
|
754
|
-
"id_option": "--feature-id",
|
|
755
|
-
"id": "F-001",
|
|
756
|
-
"list_name": "feature-list.json",
|
|
757
|
-
"collection": "features",
|
|
758
|
-
"list_payload": {"features": [_make_feature("F-001", "Snapshot", status="in_progress")]},
|
|
759
|
-
"feature_slug": "001-snapshot",
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
"task": "bugfix",
|
|
763
|
-
"script": scripts_dir / "update-bug-status.py",
|
|
764
|
-
"list_option": "--bug-list",
|
|
765
|
-
"id_option": "--bug-id",
|
|
766
|
-
"id": "B-001",
|
|
767
|
-
"list_name": "bug-fix-list.json",
|
|
768
|
-
"collection": "bugs",
|
|
769
|
-
"list_payload": {
|
|
770
|
-
"bugs": [{
|
|
771
|
-
"id": "B-001",
|
|
772
|
-
"title": "Snapshot Bug",
|
|
773
|
-
"description": "desc",
|
|
774
|
-
"severity": "medium",
|
|
775
|
-
"priority": "medium",
|
|
776
|
-
"status": "in_progress",
|
|
777
|
-
}],
|
|
778
|
-
},
|
|
779
|
-
},
|
|
780
|
-
{
|
|
781
|
-
"task": "refactor",
|
|
782
|
-
"script": scripts_dir / "update-refactor-status.py",
|
|
783
|
-
"list_option": "--refactor-list",
|
|
784
|
-
"id_option": "--refactor-id",
|
|
785
|
-
"id": "R-001",
|
|
786
|
-
"list_name": "refactor-list.json",
|
|
787
|
-
"collection": "refactors",
|
|
788
|
-
"list_payload": {
|
|
789
|
-
"refactors": [{
|
|
790
|
-
"id": "R-001",
|
|
791
|
-
"title": "Snapshot Refactor",
|
|
792
|
-
"description": "desc",
|
|
793
|
-
"complexity": "medium",
|
|
794
|
-
"priority": "medium",
|
|
795
|
-
"status": "in_progress",
|
|
796
|
-
"dependencies": [],
|
|
797
|
-
}],
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
]
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
def _deepcopy_json(value):
|
|
804
|
-
return json.loads(json.dumps(value))
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
def _prepare_snapshot_case(base_dir, case, list_status="in_progress", runtime_status=None):
|
|
808
|
-
case_dir = base_dir / case["task"]
|
|
809
|
-
state_dir = case_dir / "state"
|
|
810
|
-
list_path = case_dir / case["list_name"]
|
|
811
|
-
list_path.parent.mkdir(parents=True, exist_ok=True)
|
|
812
|
-
payload = _deepcopy_json(case["list_payload"])
|
|
813
|
-
payload[case["collection"]][0]["status"] = list_status
|
|
814
|
-
write_json_file(str(list_path), payload)
|
|
815
|
-
|
|
816
|
-
status_path = state_dir / case["id"] / "status.json"
|
|
817
|
-
status_path.parent.mkdir(parents=True, exist_ok=True)
|
|
818
|
-
status_payload = {
|
|
819
|
-
"retry_count": 0,
|
|
820
|
-
"infra_error_count": 0,
|
|
821
|
-
"sessions": [],
|
|
822
|
-
"last_session_id": None,
|
|
823
|
-
"resume_from_phase": None,
|
|
824
|
-
}
|
|
825
|
-
if runtime_status:
|
|
826
|
-
status_payload.update(runtime_status)
|
|
827
|
-
write_json_file(str(status_path), status_payload)
|
|
828
|
-
return case_dir, list_path, state_dir
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
def _run_status_snapshot_action(case, list_path, state_dir, action, session_status=None, session_id="sess-1", extra_args=None):
|
|
832
|
-
cmd = [
|
|
833
|
-
"python3",
|
|
834
|
-
str(case["script"]),
|
|
835
|
-
case["list_option"],
|
|
836
|
-
str(list_path),
|
|
837
|
-
"--state-dir",
|
|
838
|
-
str(state_dir),
|
|
839
|
-
"--action",
|
|
840
|
-
action,
|
|
841
|
-
]
|
|
842
|
-
if action in {"update", "reset", "clean", "reset_state"}:
|
|
843
|
-
cmd.extend([case["id_option"], case["id"]])
|
|
844
|
-
if action == "update":
|
|
845
|
-
cmd.extend([
|
|
846
|
-
"--session-id",
|
|
847
|
-
session_id,
|
|
848
|
-
"--session-status",
|
|
849
|
-
session_status,
|
|
850
|
-
"--max-retries",
|
|
851
|
-
"3",
|
|
852
|
-
"--max-infra-retries",
|
|
853
|
-
"3",
|
|
854
|
-
])
|
|
855
|
-
if extra_args:
|
|
856
|
-
cmd.extend(extra_args)
|
|
857
|
-
result = subprocess.run(cmd, text=True, capture_output=True, check=True)
|
|
858
|
-
return json.loads(result.stdout) if result.stdout.strip() else {}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
def _runtime_snapshot(state_dir, case):
|
|
862
|
-
with open(state_dir / case["id"] / "status.json", encoding="utf-8") as fh:
|
|
863
|
-
return json.load(fh)
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
def _list_item_status(list_path, case):
|
|
867
|
-
data, _ = load_json_file(str(list_path))
|
|
868
|
-
return data[case["collection"]][0]["status"]
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
def _select_stable_fields(data, keys):
|
|
872
|
-
selected = {key: data[key] for key in keys if key in data}
|
|
873
|
-
if selected.get("continuation_summary_path"):
|
|
874
|
-
selected["continuation_summary_path"] = "<CONTINUATION_SUMMARY>"
|
|
875
|
-
return selected
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
def _normalize_status_update(summary, runtime, list_status):
|
|
879
|
-
return {
|
|
880
|
-
"summary": _select_stable_fields(summary, _STATUS_SUMMARY_KEYS),
|
|
881
|
-
"runtime": _select_stable_fields(runtime, _RUNTIME_STATUS_KEYS),
|
|
882
|
-
"listStatus": list_status,
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
def _continuation_conventional_path(case_dir, case):
|
|
887
|
-
if case["task"] == "feature":
|
|
888
|
-
return case_dir / ".prizmkit" / "specs" / case["feature_slug"] / "continuation-summary.md"
|
|
889
|
-
if case["task"] == "bugfix":
|
|
890
|
-
return case_dir / ".prizmkit" / "bugfix" / case["id"] / "continuation-summary.md"
|
|
891
|
-
return case_dir / ".prizmkit" / "refactor" / case["id"] / "continuation-summary.md"
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
def _build_status_updater_behavior_snapshot(tmp_path):
|
|
895
|
-
scripts_dir = Path(__file__).resolve().parents[1] / "scripts"
|
|
896
|
-
cases = _status_snapshot_cases(scripts_dir)
|
|
897
|
-
snapshot = {
|
|
898
|
-
"contextOverflowMetadata": {},
|
|
899
|
-
"infraErrorRetryBudget": {},
|
|
900
|
-
"crashFailureBudget": {},
|
|
901
|
-
"resetCleanMetadataCleanup": {},
|
|
902
|
-
"noProgressStall": {},
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
for case in cases:
|
|
906
|
-
task = case["task"]
|
|
907
|
-
case_dir, list_path, state_dir = _prepare_snapshot_case(
|
|
908
|
-
tmp_path / "context-overflow",
|
|
909
|
-
case,
|
|
910
|
-
runtime_status={"retry_count": 1, "infra_error_count": 1},
|
|
911
|
-
)
|
|
912
|
-
summary_path = case_dir / "continuation-summary.md"
|
|
913
|
-
summary = _run_status_snapshot_action(
|
|
914
|
-
case,
|
|
915
|
-
list_path,
|
|
916
|
-
state_dir,
|
|
917
|
-
"update",
|
|
918
|
-
session_status="context_overflow",
|
|
919
|
-
extra_args=[
|
|
920
|
-
"--active-dev-branch",
|
|
921
|
-
"dev/snapshot-branch",
|
|
922
|
-
"--base-branch",
|
|
923
|
-
"main",
|
|
924
|
-
"--last-fatal-error-code",
|
|
925
|
-
"context_overflow",
|
|
926
|
-
"--continuation-summary-path",
|
|
927
|
-
str(summary_path),
|
|
928
|
-
],
|
|
929
|
-
)
|
|
930
|
-
snapshot["contextOverflowMetadata"][task] = _normalize_status_update(
|
|
931
|
-
summary,
|
|
932
|
-
_runtime_snapshot(state_dir, case),
|
|
933
|
-
_list_item_status(list_path, case),
|
|
934
|
-
)
|
|
935
|
-
|
|
936
|
-
case_dir, list_path, state_dir = _prepare_snapshot_case(
|
|
937
|
-
tmp_path / "infra-error",
|
|
938
|
-
case,
|
|
939
|
-
runtime_status={"retry_count": 2, "infra_error_count": 0},
|
|
940
|
-
)
|
|
941
|
-
summary = _run_status_snapshot_action(
|
|
942
|
-
case,
|
|
943
|
-
list_path,
|
|
944
|
-
state_dir,
|
|
945
|
-
"update",
|
|
946
|
-
session_status="infra_error",
|
|
947
|
-
session_id="sess-infra",
|
|
948
|
-
)
|
|
949
|
-
snapshot["infraErrorRetryBudget"][task] = _normalize_status_update(
|
|
950
|
-
summary,
|
|
951
|
-
_runtime_snapshot(state_dir, case),
|
|
952
|
-
_list_item_status(list_path, case),
|
|
953
|
-
)
|
|
954
|
-
|
|
955
|
-
case_dir, list_path, state_dir = _prepare_snapshot_case(tmp_path / "crash-failure", case)
|
|
956
|
-
summary = _run_status_snapshot_action(
|
|
957
|
-
case,
|
|
958
|
-
list_path,
|
|
959
|
-
state_dir,
|
|
960
|
-
"update",
|
|
961
|
-
session_status="failed",
|
|
962
|
-
session_id="sess-failed",
|
|
963
|
-
)
|
|
964
|
-
snapshot["crashFailureBudget"][task] = _normalize_status_update(
|
|
965
|
-
summary,
|
|
966
|
-
_runtime_snapshot(state_dir, case),
|
|
967
|
-
_list_item_status(list_path, case),
|
|
968
|
-
)
|
|
969
|
-
|
|
970
|
-
snapshot["resetCleanMetadataCleanup"][task] = {}
|
|
971
|
-
for action in ["reset", "clean"]:
|
|
972
|
-
cleanup_root = tmp_path / f"{action}-cleanup"
|
|
973
|
-
cleanup_case_dir = cleanup_root / case["task"]
|
|
974
|
-
case_dir, list_path, state_dir = _prepare_snapshot_case(
|
|
975
|
-
cleanup_root,
|
|
976
|
-
case,
|
|
977
|
-
list_status="failed",
|
|
978
|
-
runtime_status={
|
|
979
|
-
"retry_count": 3,
|
|
980
|
-
"infra_error_count": 2,
|
|
981
|
-
"last_infra_error_session_id": "sess-infra",
|
|
982
|
-
"active_dev_branch": "dev/snapshot-branch",
|
|
983
|
-
"base_branch": "main",
|
|
984
|
-
"continuation_pending": True,
|
|
985
|
-
"continuation_reason": "context_overflow",
|
|
986
|
-
"last_context_overflow_session_id": "sess-overflow",
|
|
987
|
-
"previous_session_id": "sess-overflow",
|
|
988
|
-
"last_fatal_error_code": "context_overflow",
|
|
989
|
-
"continuation_summary_path": str(cleanup_case_dir / "continuation-summary.md"),
|
|
990
|
-
"no_progress_count": 1,
|
|
991
|
-
"last_progress_fingerprint": {"head_commit": "abc123"},
|
|
992
|
-
"needs_attention": True,
|
|
993
|
-
"stalled_context_continuation": True,
|
|
994
|
-
"stalled_reason": "context_overflow_without_git_checkpoint_or_artifact_progress",
|
|
995
|
-
"context_overflow_count": 2,
|
|
996
|
-
"continuation_count": 2,
|
|
997
|
-
"sessions": ["old"],
|
|
998
|
-
"last_session_id": "old",
|
|
999
|
-
"resume_from_phase": 4,
|
|
1000
|
-
},
|
|
1001
|
-
)
|
|
1002
|
-
continuation_files = []
|
|
1003
|
-
extra_args = []
|
|
1004
|
-
if action == "clean":
|
|
1005
|
-
stored_summary = case_dir / "continuation-summary.md"
|
|
1006
|
-
stored_summary.write_text("stored", encoding="utf-8")
|
|
1007
|
-
conventional_summary = _continuation_conventional_path(case_dir, case)
|
|
1008
|
-
conventional_summary.parent.mkdir(parents=True)
|
|
1009
|
-
conventional_summary.write_text("conventional", encoding="utf-8")
|
|
1010
|
-
continuation_files = [stored_summary, conventional_summary]
|
|
1011
|
-
extra_args = ["--project-root", str(case_dir)]
|
|
1012
|
-
if case["task"] == "feature":
|
|
1013
|
-
extra_args.extend(["--feature-slug", case["feature_slug"]])
|
|
1014
|
-
_run_status_snapshot_action(case, list_path, state_dir, action, extra_args=extra_args)
|
|
1015
|
-
runtime = _runtime_snapshot(state_dir, case)
|
|
1016
|
-
snapshot["resetCleanMetadataCleanup"][task][action] = {
|
|
1017
|
-
"runtime": _select_stable_fields(runtime, _RUNTIME_STATUS_KEYS),
|
|
1018
|
-
"listStatus": _list_item_status(list_path, case),
|
|
1019
|
-
"continuationFilesDeleted": all(not path.exists() for path in continuation_files),
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
case_dir, list_path, state_dir = _prepare_snapshot_case(tmp_path / "no-progress", case)
|
|
1023
|
-
fingerprint = json.dumps({
|
|
1024
|
-
"git_diff_fingerprint": "same",
|
|
1025
|
-
"checkpoint_cursor": "S02:pending",
|
|
1026
|
-
"artifact_fingerprint": "artifact",
|
|
1027
|
-
"head_commit": "abc123",
|
|
1028
|
-
})
|
|
1029
|
-
first_summary = _run_status_snapshot_action(
|
|
1030
|
-
case,
|
|
1031
|
-
list_path,
|
|
1032
|
-
state_dir,
|
|
1033
|
-
"update",
|
|
1034
|
-
session_status="context_overflow",
|
|
1035
|
-
session_id="sess-1",
|
|
1036
|
-
extra_args=[
|
|
1037
|
-
"--active-dev-branch",
|
|
1038
|
-
"dev/snapshot-branch",
|
|
1039
|
-
"--base-branch",
|
|
1040
|
-
"main",
|
|
1041
|
-
"--no-progress-count",
|
|
1042
|
-
"1",
|
|
1043
|
-
"--progress-fingerprint",
|
|
1044
|
-
fingerprint,
|
|
1045
|
-
],
|
|
1046
|
-
)
|
|
1047
|
-
second_summary = _run_status_snapshot_action(
|
|
1048
|
-
case,
|
|
1049
|
-
list_path,
|
|
1050
|
-
state_dir,
|
|
1051
|
-
"update",
|
|
1052
|
-
session_status="stalled_context_continuation",
|
|
1053
|
-
session_id="sess-2",
|
|
1054
|
-
extra_args=[
|
|
1055
|
-
"--active-dev-branch",
|
|
1056
|
-
"dev/snapshot-branch",
|
|
1057
|
-
"--base-branch",
|
|
1058
|
-
"main",
|
|
1059
|
-
"--no-progress-count",
|
|
1060
|
-
"2",
|
|
1061
|
-
"--progress-fingerprint",
|
|
1062
|
-
fingerprint,
|
|
1063
|
-
],
|
|
1064
|
-
)
|
|
1065
|
-
snapshot["noProgressStall"][task] = {
|
|
1066
|
-
"first": _normalize_status_update(
|
|
1067
|
-
first_summary,
|
|
1068
|
-
_runtime_snapshot(state_dir, case),
|
|
1069
|
-
_list_item_status(list_path, case),
|
|
1070
|
-
)["summary"],
|
|
1071
|
-
"second": _normalize_status_update(
|
|
1072
|
-
second_summary,
|
|
1073
|
-
_runtime_snapshot(state_dir, case),
|
|
1074
|
-
_list_item_status(list_path, case),
|
|
1075
|
-
),
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
return snapshot
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
def test_status_updater_behavior_matches_unix_runtime_snapshot(tmp_path):
|
|
1082
|
-
actual = _build_status_updater_behavior_snapshot(tmp_path)
|
|
1083
|
-
_assert_matches_unix_snapshot_section("statusUpdaterBehavior", actual)
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
# ---------------------------------------------------------------------------
|
|
1087
|
-
# TERMINAL_STATUSES
|
|
1088
|
-
# ---------------------------------------------------------------------------
|
|
1089
|
-
|
|
1090
|
-
class TestTerminalStatuses:
|
|
1091
|
-
def test_auto_skipped_is_terminal(self):
|
|
1092
|
-
assert "auto_skipped" in TERMINAL_STATUSES
|
|
1093
|
-
|
|
1094
|
-
def test_split_is_terminal(self):
|
|
1095
|
-
assert "split" in TERMINAL_STATUSES
|
|
1096
|
-
|
|
1097
|
-
def test_all_expected_statuses(self):
|
|
1098
|
-
assert TERMINAL_STATUSES == {"completed", "failed", "skipped", "auto_skipped", "split"}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
# ---------------------------------------------------------------------------
|
|
1102
|
-
# auto_skip_blocked_features — linear chain
|
|
1103
|
-
# ---------------------------------------------------------------------------
|
|
1104
|
-
|
|
1105
|
-
class TestAutoSkipLinearChain:
|
|
1106
|
-
"""F-001 → F-002 → F-003 linear dependency chain."""
|
|
1107
|
-
|
|
1108
|
-
def test_failing_root_skips_all_downstream(self, tmp_path):
|
|
1109
|
-
features = [
|
|
1110
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1111
|
-
_make_feature("F-002", "Mid", deps=["F-001"]),
|
|
1112
|
-
_make_feature("F-003", "Leaf", deps=["F-002"]),
|
|
1113
|
-
]
|
|
1114
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1115
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1116
|
-
|
|
1117
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1118
|
-
|
|
1119
|
-
assert len(result) == 2
|
|
1120
|
-
skipped_ids = {r["feature_id"] for r in result}
|
|
1121
|
-
assert skipped_ids == {"F-002", "F-003"}
|
|
1122
|
-
|
|
1123
|
-
statuses = _read_statuses(fl_path)
|
|
1124
|
-
assert statuses["F-001"] == "failed"
|
|
1125
|
-
assert statuses["F-002"] == "auto_skipped"
|
|
1126
|
-
assert statuses["F-003"] == "auto_skipped"
|
|
1127
|
-
|
|
1128
|
-
def test_status_json_also_updated(self, tmp_path):
|
|
1129
|
-
features = [
|
|
1130
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1131
|
-
_make_feature("F-002", "Mid", deps=["F-001"]),
|
|
1132
|
-
]
|
|
1133
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1134
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1135
|
-
|
|
1136
|
-
auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1137
|
-
|
|
1138
|
-
# status lives in feature-list.json, not status.json
|
|
1139
|
-
statuses = _read_statuses(fl_path)
|
|
1140
|
-
assert statuses["F-002"] == "auto_skipped"
|
|
1141
|
-
# status.json should have updated_at but no status field
|
|
1142
|
-
fs = load_feature_status(state_dir, "F-002")
|
|
1143
|
-
assert "status" not in fs
|
|
1144
|
-
assert "updated_at" in fs
|
|
1145
|
-
|
|
1146
|
-
def test_failing_mid_skips_only_downstream(self, tmp_path):
|
|
1147
|
-
features = [
|
|
1148
|
-
_make_feature("F-001", "Root", status="completed"),
|
|
1149
|
-
_make_feature("F-002", "Mid", deps=["F-001"], status="failed"),
|
|
1150
|
-
_make_feature("F-003", "Leaf", deps=["F-002"]),
|
|
1151
|
-
]
|
|
1152
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1153
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1154
|
-
|
|
1155
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-002")
|
|
1156
|
-
|
|
1157
|
-
assert len(result) == 1
|
|
1158
|
-
assert result[0]["feature_id"] == "F-003"
|
|
1159
|
-
|
|
1160
|
-
statuses = _read_statuses(fl_path)
|
|
1161
|
-
assert statuses["F-001"] == "completed"
|
|
1162
|
-
assert statuses["F-003"] == "auto_skipped"
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
# ---------------------------------------------------------------------------
|
|
1166
|
-
# auto_skip_blocked_features — diamond dependency
|
|
1167
|
-
# ---------------------------------------------------------------------------
|
|
1168
|
-
|
|
1169
|
-
class TestAutoSkipDiamond:
|
|
1170
|
-
"""A → C, B → C diamond where only A fails."""
|
|
1171
|
-
|
|
1172
|
-
def test_diamond_skips_downstream(self, tmp_path):
|
|
1173
|
-
features = [
|
|
1174
|
-
_make_feature("F-001", "A", status="failed"),
|
|
1175
|
-
_make_feature("F-002", "B", status="completed"),
|
|
1176
|
-
_make_feature("F-003", "C", deps=["F-001", "F-002"]),
|
|
1177
|
-
]
|
|
1178
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1179
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1180
|
-
|
|
1181
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1182
|
-
|
|
1183
|
-
assert len(result) == 1
|
|
1184
|
-
assert result[0]["feature_id"] == "F-003"
|
|
1185
|
-
|
|
1186
|
-
def test_no_skip_when_all_deps_ok(self, tmp_path):
|
|
1187
|
-
features = [
|
|
1188
|
-
_make_feature("F-001", "A", status="completed"),
|
|
1189
|
-
_make_feature("F-002", "B", status="completed"),
|
|
1190
|
-
_make_feature("F-003", "C", deps=["F-001", "F-002"]),
|
|
1191
|
-
]
|
|
1192
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1193
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1194
|
-
|
|
1195
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1196
|
-
|
|
1197
|
-
assert len(result) == 0
|
|
1198
|
-
assert _read_statuses(fl_path)["F-003"] == "pending"
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
# ---------------------------------------------------------------------------
|
|
1202
|
-
# auto_skip_blocked_features — edge cases
|
|
1203
|
-
# ---------------------------------------------------------------------------
|
|
1204
|
-
|
|
1205
|
-
class TestAutoSkipEdgeCases:
|
|
1206
|
-
def test_no_dependencies_no_skip(self, tmp_path):
|
|
1207
|
-
features = [
|
|
1208
|
-
_make_feature("F-001", "A", status="failed"),
|
|
1209
|
-
_make_feature("F-002", "B"), # independent
|
|
1210
|
-
]
|
|
1211
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1212
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1213
|
-
|
|
1214
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1215
|
-
|
|
1216
|
-
assert len(result) == 0
|
|
1217
|
-
assert _read_statuses(fl_path)["F-002"] == "pending"
|
|
1218
|
-
|
|
1219
|
-
def test_already_completed_not_skipped(self, tmp_path):
|
|
1220
|
-
features = [
|
|
1221
|
-
_make_feature("F-001", "A", status="failed"),
|
|
1222
|
-
_make_feature("F-002", "B", deps=["F-001"], status="completed"),
|
|
1223
|
-
]
|
|
1224
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1225
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1226
|
-
|
|
1227
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1228
|
-
|
|
1229
|
-
assert len(result) == 0
|
|
1230
|
-
assert _read_statuses(fl_path)["F-002"] == "completed"
|
|
1231
|
-
|
|
1232
|
-
def test_already_auto_skipped_dep_propagates(self, tmp_path):
|
|
1233
|
-
"""If a dep is already auto_skipped (from a previous failure),
|
|
1234
|
-
new downstream features depending on it should also be skipped."""
|
|
1235
|
-
features = [
|
|
1236
|
-
_make_feature("F-001", "A", status="failed"),
|
|
1237
|
-
_make_feature("F-002", "B", deps=["F-001"], status="auto_skipped"),
|
|
1238
|
-
_make_feature("F-003", "C", deps=["F-002"]), # pending
|
|
1239
|
-
]
|
|
1240
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1241
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1242
|
-
|
|
1243
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1244
|
-
|
|
1245
|
-
# F-002 is already terminal (auto_skipped), so not re-processed
|
|
1246
|
-
# F-003 should be auto_skipped because its dep F-002 is auto_skipped
|
|
1247
|
-
skipped_ids = {r["feature_id"] for r in result}
|
|
1248
|
-
assert "F-003" in skipped_ids
|
|
1249
|
-
assert _read_statuses(fl_path)["F-003"] == "auto_skipped"
|
|
1250
|
-
|
|
1251
|
-
def test_split_feature_not_skipped(self, tmp_path):
|
|
1252
|
-
features = [
|
|
1253
|
-
_make_feature("F-001", "A", status="failed"),
|
|
1254
|
-
_make_feature("F-002", "B", deps=["F-001"], status="split"),
|
|
1255
|
-
]
|
|
1256
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1257
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1258
|
-
|
|
1259
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1260
|
-
|
|
1261
|
-
assert len(result) == 0
|
|
1262
|
-
assert _read_statuses(fl_path)["F-002"] == "split"
|
|
1263
|
-
|
|
1264
|
-
def test_skipped_dep_triggers_auto_skip(self, tmp_path):
|
|
1265
|
-
"""When a dependency is manually skipped, downstream should be auto_skipped."""
|
|
1266
|
-
features = [
|
|
1267
|
-
_make_feature("F-001", "A", status="skipped"),
|
|
1268
|
-
_make_feature("F-002", "B", deps=["F-001"]),
|
|
1269
|
-
_make_feature("F-003", "C", deps=["F-002"]),
|
|
1270
|
-
]
|
|
1271
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1272
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1273
|
-
|
|
1274
|
-
result = auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1275
|
-
|
|
1276
|
-
assert len(result) == 2
|
|
1277
|
-
statuses = _read_statuses(fl_path)
|
|
1278
|
-
assert statuses["F-001"] == "skipped"
|
|
1279
|
-
assert statuses["F-002"] == "auto_skipped"
|
|
1280
|
-
assert statuses["F-003"] == "auto_skipped"
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
# ---------------------------------------------------------------------------
|
|
1284
|
-
# action_reset_state — via subprocess (tests the full CLI interface)
|
|
1285
|
-
# ---------------------------------------------------------------------------
|
|
1286
|
-
|
|
1287
|
-
import subprocess
|
|
1288
|
-
|
|
1289
|
-
_SCRIPT = os.path.join(
|
|
1290
|
-
os.path.dirname(__file__), "..", "scripts", "update-feature-status.py"
|
|
1291
|
-
)
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
def _run_reset_state(fl_path, state_dir, feature_id=None):
|
|
1295
|
-
cmd = [
|
|
1296
|
-
"python3", _SCRIPT,
|
|
1297
|
-
"--feature-list", fl_path,
|
|
1298
|
-
"--state-dir", state_dir,
|
|
1299
|
-
"--action", "reset_state",
|
|
1300
|
-
]
|
|
1301
|
-
if feature_id:
|
|
1302
|
-
cmd += ["--feature-id", feature_id]
|
|
1303
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
1304
|
-
assert result.returncode == 0, result.stderr
|
|
1305
|
-
return json.loads(result.stdout)
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
def _run_get_next(fl_path, state_dir):
|
|
1309
|
-
cmd = [
|
|
1310
|
-
"python3", _SCRIPT,
|
|
1311
|
-
"--feature-list", fl_path,
|
|
1312
|
-
"--state-dir", state_dir,
|
|
1313
|
-
"--action", "get_next",
|
|
1314
|
-
]
|
|
1315
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
1316
|
-
return result.stdout.strip()
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
def _run_update(fl_path, state_dir, feature_id, session_status, session_id="session-1", max_retries=3, max_infra_retries=3):
|
|
1320
|
-
cmd = [
|
|
1321
|
-
"python3", _SCRIPT,
|
|
1322
|
-
"--feature-list", fl_path,
|
|
1323
|
-
"--state-dir", state_dir,
|
|
1324
|
-
"--feature-id", feature_id,
|
|
1325
|
-
"--session-status", session_status,
|
|
1326
|
-
"--session-id", session_id,
|
|
1327
|
-
"--max-retries", str(max_retries),
|
|
1328
|
-
"--max-infra-retries", str(max_infra_retries),
|
|
1329
|
-
"--action", "update",
|
|
1330
|
-
]
|
|
1331
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
1332
|
-
assert result.returncode == 0, result.stderr
|
|
1333
|
-
return json.loads(result.stdout)
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
class TestInfraErrorUpdate:
|
|
1337
|
-
def test_infra_error_below_budget_keeps_in_progress_without_consuming_retry(self, tmp_path):
|
|
1338
|
-
features = [_make_feature("F-001", "Root", status="in_progress")]
|
|
1339
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1340
|
-
state_dir = _init_state(tmp_path, ["F-001"])
|
|
1341
|
-
status_path = os.path.join(state_dir, "F-001", "status.json")
|
|
1342
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1343
|
-
fs["retry_count"] = 2
|
|
1344
|
-
write_json_file(status_path, fs)
|
|
1345
|
-
|
|
1346
|
-
result = _run_update(
|
|
1347
|
-
fl_path,
|
|
1348
|
-
state_dir,
|
|
1349
|
-
"F-001",
|
|
1350
|
-
"infra_error",
|
|
1351
|
-
"session-infra",
|
|
1352
|
-
max_retries=3,
|
|
1353
|
-
max_infra_retries=3,
|
|
1354
|
-
)
|
|
1355
|
-
|
|
1356
|
-
assert result["new_status"] == "in_progress"
|
|
1357
|
-
assert result["retry_count"] == 2
|
|
1358
|
-
assert result["infra_error_count"] == 1
|
|
1359
|
-
assert result["max_infra_retries"] == 3
|
|
1360
|
-
assert result["restart_policy"] == "in_process_ai_error_continuation"
|
|
1361
|
-
assert _read_statuses(fl_path)["F-001"] == "in_progress"
|
|
1362
|
-
|
|
1363
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1364
|
-
assert fs["retry_count"] == 2
|
|
1365
|
-
assert fs["infra_error_count"] == 1
|
|
1366
|
-
assert fs["last_infra_error_session_id"] == "session-infra"
|
|
1367
|
-
assert fs["max_infra_retries"] == 3
|
|
1368
|
-
|
|
1369
|
-
def test_infra_error_at_budget_marks_failed_without_consuming_code_retry(self, tmp_path):
|
|
1370
|
-
features = [_make_feature("F-001", "Root", status="in_progress")]
|
|
1371
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1372
|
-
state_dir = _init_state(tmp_path, ["F-001"])
|
|
1373
|
-
status_path = os.path.join(state_dir, "F-001", "status.json")
|
|
1374
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1375
|
-
fs["retry_count"] = 1
|
|
1376
|
-
fs["infra_error_count"] = 2
|
|
1377
|
-
write_json_file(status_path, fs)
|
|
1378
|
-
|
|
1379
|
-
result = _run_update(
|
|
1380
|
-
fl_path,
|
|
1381
|
-
state_dir,
|
|
1382
|
-
"F-001",
|
|
1383
|
-
"infra_error",
|
|
1384
|
-
"session-infra-final",
|
|
1385
|
-
max_retries=3,
|
|
1386
|
-
max_infra_retries=3,
|
|
1387
|
-
)
|
|
1388
|
-
|
|
1389
|
-
assert result["new_status"] == "failed"
|
|
1390
|
-
assert result["retry_count"] == 1
|
|
1391
|
-
assert result["infra_error_count"] == 3
|
|
1392
|
-
assert result["restart_policy"] == "needs_attention"
|
|
1393
|
-
assert _read_statuses(fl_path)["F-001"] == "failed"
|
|
1394
|
-
|
|
1395
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1396
|
-
assert fs["retry_count"] == 1
|
|
1397
|
-
assert fs["infra_error_count"] == 3
|
|
1398
|
-
assert fs["last_infra_error_session_id"] == "session-infra-final"
|
|
1399
|
-
assert fs["last_failed_session_id"] == "session-infra-final"
|
|
1400
|
-
|
|
1401
|
-
def test_reset_clears_infra_retry_counters(self, tmp_path):
|
|
1402
|
-
features = [_make_feature("F-001", "Root", status="failed")]
|
|
1403
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1404
|
-
state_dir = _init_state(tmp_path, ["F-001"])
|
|
1405
|
-
status_path = os.path.join(state_dir, "F-001", "status.json")
|
|
1406
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1407
|
-
fs["retry_count"] = 3
|
|
1408
|
-
fs["infra_error_count"] = 3
|
|
1409
|
-
fs["last_infra_error_session_id"] = "session-infra-final"
|
|
1410
|
-
write_json_file(status_path, fs)
|
|
1411
|
-
|
|
1412
|
-
cmd = [
|
|
1413
|
-
"python3", _SCRIPT,
|
|
1414
|
-
"--feature-list", fl_path,
|
|
1415
|
-
"--state-dir", state_dir,
|
|
1416
|
-
"--feature-id", "F-001",
|
|
1417
|
-
"--action", "reset",
|
|
1418
|
-
]
|
|
1419
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
1420
|
-
assert result.returncode == 0, result.stderr
|
|
1421
|
-
|
|
1422
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1423
|
-
assert fs["retry_count"] == 0
|
|
1424
|
-
assert fs["infra_error_count"] == 0
|
|
1425
|
-
assert fs["last_infra_error_session_id"] is None
|
|
1426
|
-
assert _read_statuses(fl_path)["F-001"] == "pending"
|
|
1427
|
-
|
|
1428
|
-
def test_reset_state_clears_infra_retry_counters(self, tmp_path):
|
|
1429
|
-
features = [_make_feature("F-001", "Root", status="failed")]
|
|
1430
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1431
|
-
state_dir = _init_state(tmp_path, ["F-001"])
|
|
1432
|
-
status_path = os.path.join(state_dir, "F-001", "status.json")
|
|
1433
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1434
|
-
fs["retry_count"] = 3
|
|
1435
|
-
fs["infra_error_count"] = 3
|
|
1436
|
-
fs["last_infra_error_session_id"] = "session-infra-final"
|
|
1437
|
-
write_json_file(status_path, fs)
|
|
1438
|
-
|
|
1439
|
-
_run_reset_state(fl_path, state_dir, "F-001")
|
|
1440
|
-
|
|
1441
|
-
fs = load_feature_status(state_dir, "F-001")
|
|
1442
|
-
assert fs["retry_count"] == 0
|
|
1443
|
-
assert fs["infra_error_count"] == 0
|
|
1444
|
-
assert fs["last_infra_error_session_id"] is None
|
|
1445
|
-
assert _read_statuses(fl_path)["F-001"] == "pending"
|
|
1446
|
-
|
|
1447
|
-
class TestResetStateByFeatureId:
|
|
1448
|
-
"""ResetState with --feature-id targets a specific failed feature + downstream."""
|
|
1449
|
-
|
|
1450
|
-
def test_reset_state_failed_root_resets_all(self, tmp_path):
|
|
1451
|
-
features = [
|
|
1452
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1453
|
-
_make_feature("F-002", "Mid", deps=["F-001"], status="auto_skipped"),
|
|
1454
|
-
_make_feature("F-003", "Leaf", deps=["F-002"], status="auto_skipped"),
|
|
1455
|
-
]
|
|
1456
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1457
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1458
|
-
|
|
1459
|
-
result = _run_reset_state(fl_path, state_dir, "F-001")
|
|
1460
|
-
|
|
1461
|
-
assert result["reset_count"] == 3
|
|
1462
|
-
statuses = _read_statuses(fl_path)
|
|
1463
|
-
assert all(s == "pending" for s in statuses.values())
|
|
1464
|
-
|
|
1465
|
-
def test_reset_state_auto_skipped_leaf_resets_upstream(self, tmp_path):
|
|
1466
|
-
"""C2 fix: reset_state F-003 must also find and reset F-001 (failed root)."""
|
|
1467
|
-
features = [
|
|
1468
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1469
|
-
_make_feature("F-002", "Mid", deps=["F-001"], status="auto_skipped"),
|
|
1470
|
-
_make_feature("F-003", "Leaf", deps=["F-002"], status="auto_skipped"),
|
|
1471
|
-
]
|
|
1472
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1473
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1474
|
-
|
|
1475
|
-
result = _run_reset_state(fl_path, state_dir, "F-003")
|
|
1476
|
-
|
|
1477
|
-
assert result["reset_count"] == 3
|
|
1478
|
-
reset_ids = {f["feature_id"] for f in result["features"]}
|
|
1479
|
-
assert "F-001" in reset_ids # transitive upstream reset
|
|
1480
|
-
assert all(s == "pending" for s in _read_statuses(fl_path).values())
|
|
1481
|
-
|
|
1482
|
-
def test_reset_state_preserves_completed_features(self, tmp_path):
|
|
1483
|
-
features = [
|
|
1484
|
-
_make_feature("F-001", "Done", status="completed"),
|
|
1485
|
-
_make_feature("F-002", "Failed", deps=["F-001"], status="failed"),
|
|
1486
|
-
_make_feature("F-003", "Skipped", deps=["F-002"], status="auto_skipped"),
|
|
1487
|
-
]
|
|
1488
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1489
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003"])
|
|
1490
|
-
|
|
1491
|
-
result = _run_reset_state(fl_path, state_dir, "F-002")
|
|
1492
|
-
|
|
1493
|
-
assert result["reset_count"] == 2
|
|
1494
|
-
statuses = _read_statuses(fl_path)
|
|
1495
|
-
assert statuses["F-001"] == "completed" # not touched
|
|
1496
|
-
assert statuses["F-002"] == "pending"
|
|
1497
|
-
assert statuses["F-003"] == "pending"
|
|
1498
|
-
|
|
1499
|
-
def test_reset_state_skipped_feature_resets_downstream(self, tmp_path):
|
|
1500
|
-
"""ResetState a manually-skipped feature should also reset its auto_skipped downstream."""
|
|
1501
|
-
features = [
|
|
1502
|
-
_make_feature("F-001", "Skipped", status="skipped"),
|
|
1503
|
-
_make_feature("F-002", "Child", deps=["F-001"], status="auto_skipped"),
|
|
1504
|
-
]
|
|
1505
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1506
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1507
|
-
|
|
1508
|
-
result = _run_reset_state(fl_path, state_dir, "F-001")
|
|
1509
|
-
|
|
1510
|
-
assert result["reset_count"] == 2
|
|
1511
|
-
statuses = _read_statuses(fl_path)
|
|
1512
|
-
assert statuses["F-001"] == "pending"
|
|
1513
|
-
assert statuses["F-002"] == "pending"
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
class TestResetStateAll:
|
|
1517
|
-
"""ResetState without --feature-id resets all failed + auto_skipped."""
|
|
1518
|
-
|
|
1519
|
-
def test_resets_all_failed_and_auto_skipped(self, tmp_path):
|
|
1520
|
-
features = [
|
|
1521
|
-
_make_feature("F-001", "OK", status="completed"),
|
|
1522
|
-
_make_feature("F-002", "Failed", status="failed"),
|
|
1523
|
-
_make_feature("F-003", "Skipped", deps=["F-002"], status="auto_skipped"),
|
|
1524
|
-
_make_feature("F-004", "Pending", status="pending"),
|
|
1525
|
-
]
|
|
1526
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1527
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002", "F-003", "F-004"])
|
|
1528
|
-
|
|
1529
|
-
result = _run_reset_state(fl_path, state_dir)
|
|
1530
|
-
|
|
1531
|
-
assert result["reset_count"] == 2
|
|
1532
|
-
statuses = _read_statuses(fl_path)
|
|
1533
|
-
assert statuses["F-001"] == "completed"
|
|
1534
|
-
assert statuses["F-002"] == "pending"
|
|
1535
|
-
assert statuses["F-003"] == "pending"
|
|
1536
|
-
assert statuses["F-004"] == "pending"
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
# ---------------------------------------------------------------------------
|
|
1540
|
-
# Integration: auto-skip → get_next → reset_state → get_next
|
|
1541
|
-
# ---------------------------------------------------------------------------
|
|
1542
|
-
|
|
1543
|
-
class TestAutoSkipIntegration:
|
|
1544
|
-
"""Full lifecycle: fail → auto-skip → pipeline complete → reset_state → resume."""
|
|
1545
|
-
|
|
1546
|
-
def test_full_lifecycle(self, tmp_path):
|
|
1547
|
-
features = [
|
|
1548
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1549
|
-
_make_feature("F-002", "Child", deps=["F-001"]),
|
|
1550
|
-
]
|
|
1551
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1552
|
-
state_dir = _init_state(tmp_path, ["F-001", "F-002"])
|
|
1553
|
-
|
|
1554
|
-
# 1. Auto-skip cascades
|
|
1555
|
-
auto_skip_blocked_features(fl_path, state_dir, "F-001")
|
|
1556
|
-
assert _read_statuses(fl_path)["F-002"] == "auto_skipped"
|
|
1557
|
-
|
|
1558
|
-
# 2. get_next should return PIPELINE_COMPLETE
|
|
1559
|
-
assert _run_get_next(fl_path, state_dir) == "PIPELINE_COMPLETE"
|
|
1560
|
-
|
|
1561
|
-
# 3. ResetState recovers everything
|
|
1562
|
-
_run_reset_state(fl_path, state_dir, "F-001")
|
|
1563
|
-
statuses = _read_statuses(fl_path)
|
|
1564
|
-
assert statuses["F-001"] == "pending"
|
|
1565
|
-
assert statuses["F-002"] == "pending"
|
|
1566
|
-
|
|
1567
|
-
# 4. get_next should now return F-001
|
|
1568
|
-
output = _run_get_next(fl_path, state_dir)
|
|
1569
|
-
data = json.loads(output)
|
|
1570
|
-
assert data["feature_id"] == "F-001"
|
|
1571
|
-
|
|
1572
|
-
def test_retry_count_reset_after_reset_state(self, tmp_path):
|
|
1573
|
-
features = [
|
|
1574
|
-
_make_feature("F-001", "Root", status="failed"),
|
|
1575
|
-
]
|
|
1576
|
-
fl_path = _write_fl(tmp_path, features)
|
|
1577
|
-
state_dir = _init_state(tmp_path, ["F-001"])
|
|
1578
|
-
# Simulate retry_count = 3
|
|
1579
|
-
fs_path = os.path.join(state_dir, "F-001", "status.json")
|
|
1580
|
-
with open(fs_path) as f:
|
|
1581
|
-
fs = json.load(f)
|
|
1582
|
-
fs["retry_count"] = 3
|
|
1583
|
-
with open(fs_path, "w") as f:
|
|
1584
|
-
json.dump(fs, f)
|
|
1585
|
-
|
|
1586
|
-
_run_reset_state(fl_path, state_dir, "F-001")
|
|
1587
|
-
|
|
1588
|
-
with open(fs_path) as f:
|
|
1589
|
-
fs = json.load(f)
|
|
1590
|
-
assert fs["retry_count"] == 0
|
|
1591
|
-
# status lives in feature-list.json, not status.json
|
|
1592
|
-
assert "status" not in fs
|
|
1593
|
-
statuses = _read_statuses(fl_path)
|
|
1594
|
-
assert statuses["F-001"] == "pending"
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
FAMILY_ORPHAN_CASES = (
|
|
1598
|
-
{
|
|
1599
|
-
"kind": "feature",
|
|
1600
|
-
"script": "update-feature-status.py",
|
|
1601
|
-
"list_option": "--feature-list",
|
|
1602
|
-
"id_option": "--feature-id",
|
|
1603
|
-
"collection": "features",
|
|
1604
|
-
"prefix": "F-",
|
|
1605
|
-
"blocking_status": "failed",
|
|
1606
|
-
},
|
|
1607
|
-
{
|
|
1608
|
-
"kind": "bugfix",
|
|
1609
|
-
"script": "update-bug-status.py",
|
|
1610
|
-
"list_option": "--bug-list",
|
|
1611
|
-
"id_option": "--bug-id",
|
|
1612
|
-
"collection": "bugs",
|
|
1613
|
-
"prefix": "B-",
|
|
1614
|
-
"blocking_status": "needs_info",
|
|
1615
|
-
},
|
|
1616
|
-
{
|
|
1617
|
-
"kind": "refactor",
|
|
1618
|
-
"script": "update-refactor-status.py",
|
|
1619
|
-
"list_option": "--refactor-list",
|
|
1620
|
-
"id_option": "--refactor-id",
|
|
1621
|
-
"collection": "refactors",
|
|
1622
|
-
"prefix": "R-",
|
|
1623
|
-
"blocking_status": "skipped",
|
|
1624
|
-
},
|
|
1625
|
-
)
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
def _family_item(case, number, status, dependencies=None):
|
|
1629
|
-
item_id = f"{case['prefix']}{number:03d}"
|
|
1630
|
-
item = {
|
|
1631
|
-
"id": item_id,
|
|
1632
|
-
"title": item_id,
|
|
1633
|
-
"description": "orphan convergence test",
|
|
1634
|
-
"priority": "medium",
|
|
1635
|
-
"dependencies": list(dependencies or []),
|
|
1636
|
-
"status": status,
|
|
1637
|
-
}
|
|
1638
|
-
if case["kind"] == "feature":
|
|
1639
|
-
item["acceptance_criteria"] = ["converges"]
|
|
1640
|
-
elif case["kind"] == "bugfix":
|
|
1641
|
-
item["severity"] = "high"
|
|
1642
|
-
else:
|
|
1643
|
-
item["complexity"] = "medium"
|
|
1644
|
-
return item
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
def _write_family_orphan_list(tmp_path, case, items):
|
|
1648
|
-
list_path = tmp_path / f"{case['kind']}-list.json"
|
|
1649
|
-
write_json_file(str(list_path), {
|
|
1650
|
-
"project_name": "orphan convergence",
|
|
1651
|
-
case["collection"]: items,
|
|
1652
|
-
})
|
|
1653
|
-
return list_path
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
def _run_family_orphan_action(
|
|
1657
|
-
case,
|
|
1658
|
-
list_path,
|
|
1659
|
-
state_dir,
|
|
1660
|
-
action,
|
|
1661
|
-
item_id=None,
|
|
1662
|
-
session_status=None,
|
|
1663
|
-
extra_args=None,
|
|
1664
|
-
):
|
|
1665
|
-
script = ROOT / "dev-pipeline" / "scripts" / case["script"]
|
|
1666
|
-
command = [
|
|
1667
|
-
"python3",
|
|
1668
|
-
str(script),
|
|
1669
|
-
case["list_option"],
|
|
1670
|
-
str(list_path),
|
|
1671
|
-
"--state-dir",
|
|
1672
|
-
str(state_dir),
|
|
1673
|
-
"--action",
|
|
1674
|
-
action,
|
|
1675
|
-
]
|
|
1676
|
-
if item_id:
|
|
1677
|
-
command.extend([case["id_option"], item_id])
|
|
1678
|
-
if session_status:
|
|
1679
|
-
command.extend(["--session-status", session_status, "--session-id", "orphan-session"])
|
|
1680
|
-
command.extend(extra_args or [])
|
|
1681
|
-
return subprocess.run(command, capture_output=True, text=True, check=True)
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
def _family_statuses(case, list_path):
|
|
1685
|
-
data, error = load_json_file(str(list_path))
|
|
1686
|
-
assert error is None
|
|
1687
|
-
return {item["id"]: item["status"] for item in data[case["collection"]]}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
@pytest.mark.parametrize("case", FAMILY_ORPHAN_CASES, ids=lambda case: case["kind"])
|
|
1691
|
-
def test_start_reconciles_rootless_auto_skipped_descendants_without_deleting_sessions(tmp_path, case):
|
|
1692
|
-
root_id = f"{case['prefix']}001"
|
|
1693
|
-
child_id = f"{case['prefix']}002"
|
|
1694
|
-
leaf_id = f"{case['prefix']}003"
|
|
1695
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1696
|
-
_family_item(case, 1, case["blocking_status"]),
|
|
1697
|
-
_family_item(case, 2, "auto_skipped", [root_id]),
|
|
1698
|
-
_family_item(case, 3, "auto_skipped", [child_id]),
|
|
1699
|
-
])
|
|
1700
|
-
state_dir = tmp_path / "state"
|
|
1701
|
-
session_marker = state_dir / child_id / "sessions" / "existing" / "session.log"
|
|
1702
|
-
session_marker.parent.mkdir(parents=True)
|
|
1703
|
-
session_marker.write_text("preserved\n", encoding="utf-8")
|
|
1704
|
-
|
|
1705
|
-
result = _run_family_orphan_action(case, list_path, state_dir, "start", root_id)
|
|
1706
|
-
|
|
1707
|
-
summary = json.loads(result.stdout)
|
|
1708
|
-
assert summary["recovered_auto_skipped"] == [child_id, leaf_id]
|
|
1709
|
-
assert _family_statuses(case, list_path) == {
|
|
1710
|
-
root_id: "in_progress",
|
|
1711
|
-
child_id: "pending",
|
|
1712
|
-
leaf_id: "pending",
|
|
1713
|
-
}
|
|
1714
|
-
assert session_marker.read_text(encoding="utf-8") == "preserved\n"
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
@pytest.mark.parametrize("case", FAMILY_ORPHAN_CASES, ids=lambda case: case["kind"])
|
|
1718
|
-
def test_start_keeps_shared_descendant_skipped_while_another_root_blocks(tmp_path, case):
|
|
1719
|
-
first_id = f"{case['prefix']}001"
|
|
1720
|
-
second_id = f"{case['prefix']}002"
|
|
1721
|
-
child_id = f"{case['prefix']}003"
|
|
1722
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1723
|
-
_family_item(case, 1, case["blocking_status"]),
|
|
1724
|
-
_family_item(case, 2, case["blocking_status"]),
|
|
1725
|
-
_family_item(case, 3, "auto_skipped", [first_id, second_id]),
|
|
1726
|
-
])
|
|
1727
|
-
|
|
1728
|
-
result = _run_family_orphan_action(case, list_path, tmp_path / "state", "start", first_id)
|
|
1729
|
-
|
|
1730
|
-
summary = json.loads(result.stdout)
|
|
1731
|
-
assert "recovered_auto_skipped" not in summary
|
|
1732
|
-
assert _family_statuses(case, list_path)[child_id] == "auto_skipped"
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
@pytest.mark.parametrize("case", FAMILY_ORPHAN_CASES, ids=lambda case: case["kind"])
|
|
1736
|
-
def test_success_without_start_reconciles_auto_skipped_descendants(tmp_path, case):
|
|
1737
|
-
root_id = f"{case['prefix']}001"
|
|
1738
|
-
child_id = f"{case['prefix']}002"
|
|
1739
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1740
|
-
_family_item(case, 1, case["blocking_status"]),
|
|
1741
|
-
_family_item(case, 2, "auto_skipped", [root_id]),
|
|
1742
|
-
])
|
|
1743
|
-
|
|
1744
|
-
result = _run_family_orphan_action(
|
|
1745
|
-
case,
|
|
1746
|
-
list_path,
|
|
1747
|
-
tmp_path / "state",
|
|
1748
|
-
"update",
|
|
1749
|
-
root_id,
|
|
1750
|
-
session_status="success",
|
|
1751
|
-
)
|
|
1752
|
-
|
|
1753
|
-
summary = json.loads(result.stdout)
|
|
1754
|
-
assert summary["recovered_auto_skipped"] == [child_id]
|
|
1755
|
-
assert _family_statuses(case, list_path) == {
|
|
1756
|
-
root_id: "completed",
|
|
1757
|
-
child_id: "pending",
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
@pytest.mark.parametrize("case", FAMILY_ORPHAN_CASES, ids=lambda case: case["kind"])
|
|
1762
|
-
def test_get_next_recovers_legacy_orphan_before_pipeline_completion(tmp_path, case):
|
|
1763
|
-
root_id = f"{case['prefix']}001"
|
|
1764
|
-
child_id = f"{case['prefix']}002"
|
|
1765
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1766
|
-
_family_item(case, 1, "completed"),
|
|
1767
|
-
_family_item(case, 2, "auto_skipped", [root_id]),
|
|
1768
|
-
])
|
|
1769
|
-
|
|
1770
|
-
result = _run_family_orphan_action(case, list_path, tmp_path / "state", "get_next")
|
|
1771
|
-
|
|
1772
|
-
payload = json.loads(result.stdout)
|
|
1773
|
-
selected_id = payload.get("feature_id") or payload.get("bug_id") or payload.get("refactor_id")
|
|
1774
|
-
assert selected_id == child_id
|
|
1775
|
-
assert child_id in result.stdout
|
|
1776
|
-
assert _family_statuses(case, list_path)[child_id] == "pending"
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
@pytest.mark.parametrize("case", FAMILY_ORPHAN_CASES, ids=lambda case: case["kind"])
|
|
1780
|
-
def test_status_labels_rootless_auto_skipped_as_orphan_without_mutation(tmp_path, case):
|
|
1781
|
-
root_id = f"{case['prefix']}001"
|
|
1782
|
-
child_id = f"{case['prefix']}002"
|
|
1783
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1784
|
-
_family_item(case, 1, "completed"),
|
|
1785
|
-
_family_item(case, 2, "auto_skipped", [root_id]),
|
|
1786
|
-
])
|
|
1787
|
-
|
|
1788
|
-
result = _run_family_orphan_action(case, list_path, tmp_path / "state", "status")
|
|
1789
|
-
|
|
1790
|
-
assert "orphaned: no blocking dependency" in result.stdout
|
|
1791
|
-
assert _family_statuses(case, list_path)[child_id] == "auto_skipped"
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
def test_feature_status_filter_uses_complete_graph_for_orphan_label(tmp_path):
|
|
1795
|
-
case = FAMILY_ORPHAN_CASES[0]
|
|
1796
|
-
root_id = "F-001"
|
|
1797
|
-
child_id = "F-002"
|
|
1798
|
-
list_path = _write_family_orphan_list(tmp_path, case, [
|
|
1799
|
-
_family_item(case, 1, "completed"),
|
|
1800
|
-
_family_item(case, 2, "auto_skipped", [root_id]),
|
|
1801
|
-
])
|
|
1802
|
-
|
|
1803
|
-
result = _run_family_orphan_action(
|
|
1804
|
-
case,
|
|
1805
|
-
list_path,
|
|
1806
|
-
tmp_path / "state",
|
|
1807
|
-
"status",
|
|
1808
|
-
extra_args=["--features", child_id],
|
|
1809
|
-
)
|
|
1810
|
-
|
|
1811
|
-
assert "orphaned: no blocking dependency" in result.stdout
|
|
1812
|
-
assert root_id not in result.stdout
|
|
1813
|
-
assert child_id in result.stdout
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
def test_context_overflow_records_no_progress_fingerprint_and_stall(tmp_path):
|
|
1817
|
-
scripts_dir = Path(__file__).resolve().parents[1] / 'scripts'
|
|
1818
|
-
feature_list = tmp_path / 'feature-list.json'
|
|
1819
|
-
state_dir = tmp_path / 'state'
|
|
1820
|
-
write_json_file(str(feature_list), _make_feature_list([
|
|
1821
|
-
_make_feature('F-001', 'Context Continuation', status='in_progress')
|
|
1822
|
-
]))
|
|
1823
|
-
fingerprint = json.dumps({
|
|
1824
|
-
'git_diff_fingerprint': 'same',
|
|
1825
|
-
'checkpoint_cursor': 'S02:pending',
|
|
1826
|
-
'artifact_fingerprint': 'artifact',
|
|
1827
|
-
'head_commit': 'abc123',
|
|
1828
|
-
})
|
|
1829
|
-
|
|
1830
|
-
first = subprocess.run([
|
|
1831
|
-
'python3', str(scripts_dir / 'update-feature-status.py'),
|
|
1832
|
-
'--feature-list', str(feature_list),
|
|
1833
|
-
'--state-dir', str(state_dir),
|
|
1834
|
-
'--feature-id', 'F-001',
|
|
1835
|
-
'--session-id', 's1',
|
|
1836
|
-
'--session-status', 'context_overflow',
|
|
1837
|
-
'--active-dev-branch', 'dev/F-001',
|
|
1838
|
-
'--base-branch', 'main',
|
|
1839
|
-
'--no-progress-count', '1',
|
|
1840
|
-
'--progress-fingerprint', fingerprint,
|
|
1841
|
-
'--action', 'update',
|
|
1842
|
-
], text=True, capture_output=True, check=True)
|
|
1843
|
-
first_summary = json.loads(first.stdout)
|
|
1844
|
-
assert first_summary['new_status'] == 'in_progress'
|
|
1845
|
-
assert first_summary['retry_count'] == 1
|
|
1846
|
-
assert first_summary['infra_error_count'] == 0
|
|
1847
|
-
assert first_summary['no_progress_count'] == 1
|
|
1848
|
-
|
|
1849
|
-
second = subprocess.run([
|
|
1850
|
-
'python3', str(scripts_dir / 'update-feature-status.py'),
|
|
1851
|
-
'--feature-list', str(feature_list),
|
|
1852
|
-
'--state-dir', str(state_dir),
|
|
1853
|
-
'--feature-id', 'F-001',
|
|
1854
|
-
'--session-id', 's2',
|
|
1855
|
-
'--session-status', 'stalled_context_continuation',
|
|
1856
|
-
'--active-dev-branch', 'dev/F-001',
|
|
1857
|
-
'--base-branch', 'main',
|
|
1858
|
-
'--no-progress-count', '2',
|
|
1859
|
-
'--progress-fingerprint', fingerprint,
|
|
1860
|
-
'--action', 'update',
|
|
1861
|
-
], text=True, capture_output=True, check=True)
|
|
1862
|
-
second_summary = json.loads(second.stdout)
|
|
1863
|
-
status = load_feature_status(str(state_dir), 'F-001')
|
|
1864
|
-
assert second_summary['new_status'] == 'failed'
|
|
1865
|
-
assert second_summary['retry_count'] == 1
|
|
1866
|
-
assert second_summary['infra_error_count'] == 0
|
|
1867
|
-
assert second_summary['needs_attention'] is True
|
|
1868
|
-
assert second_summary['stalled_context_continuation'] is True
|
|
1869
|
-
assert second_summary['stalled_reason'] == 'context_overflow_without_git_checkpoint_or_artifact_progress'
|
|
1870
|
-
assert status['no_progress_count'] == 2
|
|
1871
|
-
assert status['last_progress_fingerprint']['head_commit'] == 'abc123'
|