prizmkit 1.1.167 → 1.1.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +1 -1
- package/bundled/dev-pipeline/scripts/update-bug-status.py +88 -9
- package/bundled/dev-pipeline/scripts/update-feature-status.py +135 -26
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +102 -4
- package/bundled/dev-pipeline/scripts/utils.py +105 -46
- package/bundled/dev-pipeline/tests/test_auto_skip.py +221 -0
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +3 -3
- package/bundled/dev-pipeline/tests/test_reset_modes.py +142 -6
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/prizmkit-deploy/SKILL.md +3 -3
- package/bundled/skills/prizmkit-deploy/references/legacy-migration.md +1 -1
- package/bundled/skills/prizmkit-deploy/scripts/validate-deploy-artifact.py +372 -8
- package/package.json +1 -1
package/bundled/VERSION.json
CHANGED
|
@@ -228,7 +228,7 @@ def _run_pipeline(family: RunnerFamily, invocation: RunnerInvocation, paths) ->
|
|
|
228
228
|
return PipelineRunResult(False, processed, "item_failed", final_status, details)
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
_COMPLETION_COMPATIBLE_STATUSES = {"completed"
|
|
231
|
+
_COMPLETION_COMPATIBLE_STATUSES = {"completed"}
|
|
232
232
|
|
|
233
233
|
|
|
234
234
|
def _completion_compatible_statuses(family: RunnerFamily) -> set[str]:
|
|
@@ -35,6 +35,7 @@ from utils import (
|
|
|
35
35
|
read_checkpoint_cursor,
|
|
36
36
|
dependency_rank_map,
|
|
37
37
|
causal_reset_selection,
|
|
38
|
+
orphaned_auto_skipped_ids,
|
|
38
39
|
)
|
|
39
40
|
|
|
40
41
|
|
|
@@ -475,6 +476,44 @@ def auto_skip_blocked_bugs(bug_list_path, state_dir, blocking_bug_id=None):
|
|
|
475
476
|
return skipped_info
|
|
476
477
|
|
|
477
478
|
|
|
479
|
+
def reconcile_orphaned_auto_skipped_bugs(bug_list_path, state_dir):
|
|
480
|
+
"""Restore auto-skipped bugs that have no current blocking root."""
|
|
481
|
+
data, err = load_json_file(bug_list_path)
|
|
482
|
+
if err:
|
|
483
|
+
raise RuntimeError("Cannot load bug fix list for orphan recovery: {}".format(err))
|
|
484
|
+
bugs = data.get("bugs", [])
|
|
485
|
+
orphan_ids = orphaned_auto_skipped_ids(
|
|
486
|
+
bugs,
|
|
487
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
488
|
+
item_label="Bug",
|
|
489
|
+
)
|
|
490
|
+
if not orphan_ids:
|
|
491
|
+
return []
|
|
492
|
+
|
|
493
|
+
orphan_set = set(orphan_ids)
|
|
494
|
+
for bug in bugs:
|
|
495
|
+
if isinstance(bug, dict) and bug.get("id") in orphan_set:
|
|
496
|
+
bug["status"] = "pending"
|
|
497
|
+
err = write_json_file(bug_list_path, data)
|
|
498
|
+
if err:
|
|
499
|
+
raise RuntimeError("Failed to recover orphaned bugs: {}".format(err))
|
|
500
|
+
|
|
501
|
+
for bug_id in orphan_ids:
|
|
502
|
+
bs = load_bug_status(state_dir, bug_id)
|
|
503
|
+
bs["updated_at"] = now_iso()
|
|
504
|
+
err = save_bug_status(state_dir, bug_id, bs)
|
|
505
|
+
if err:
|
|
506
|
+
raise RuntimeError("Failed to save recovered bug status: {}".format(err))
|
|
507
|
+
|
|
508
|
+
print(
|
|
509
|
+
"[auto-skip] recovered {} orphaned bug(s): {}".format(
|
|
510
|
+
len(orphan_ids), ", ".join(orphan_ids)
|
|
511
|
+
),
|
|
512
|
+
file=sys.stderr,
|
|
513
|
+
)
|
|
514
|
+
return list(orphan_ids)
|
|
515
|
+
|
|
516
|
+
|
|
478
517
|
# ---------------------------------------------------------------------------
|
|
479
518
|
# Action: get_next
|
|
480
519
|
# ---------------------------------------------------------------------------
|
|
@@ -491,6 +530,14 @@ def action_get_next(bug_list_data, state_dir, project_root=None, bug_list_path=N
|
|
|
491
530
|
"""
|
|
492
531
|
if bug_list_path:
|
|
493
532
|
auto_skip_blocked_bugs(bug_list_path, state_dir)
|
|
533
|
+
try:
|
|
534
|
+
reconcile_orphaned_auto_skipped_bugs(bug_list_path, state_dir)
|
|
535
|
+
except ValueError:
|
|
536
|
+
print("PIPELINE_BLOCKED")
|
|
537
|
+
return
|
|
538
|
+
except RuntimeError as exc:
|
|
539
|
+
error_out(str(exc))
|
|
540
|
+
return
|
|
494
541
|
refreshed, refresh_error = load_json_file(bug_list_path)
|
|
495
542
|
if refresh_error:
|
|
496
543
|
error_out("Cannot reload bug fix list after auto-skip: {}".format(refresh_error))
|
|
@@ -785,10 +832,19 @@ def action_update(args, bug_list_path, state_dir):
|
|
|
785
832
|
return
|
|
786
833
|
|
|
787
834
|
auto_skipped_bugs = []
|
|
835
|
+
recovered_auto_skipped = []
|
|
788
836
|
if new_status in RESET_BLOCKING_ROOT_STATUSES:
|
|
789
837
|
auto_skipped_bugs = auto_skip_blocked_bugs(
|
|
790
838
|
bug_list_path, state_dir, bug_id
|
|
791
839
|
)
|
|
840
|
+
else:
|
|
841
|
+
try:
|
|
842
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_bugs(
|
|
843
|
+
bug_list_path, state_dir
|
|
844
|
+
)
|
|
845
|
+
except (ValueError, RuntimeError) as exc:
|
|
846
|
+
error_out(str(exc))
|
|
847
|
+
return
|
|
792
848
|
|
|
793
849
|
summary = {
|
|
794
850
|
"action": "update",
|
|
@@ -804,6 +860,8 @@ def action_update(args, bug_list_path, state_dir):
|
|
|
804
860
|
}
|
|
805
861
|
if auto_skipped_bugs:
|
|
806
862
|
summary["auto_skipped"] = [info["bug_id"] for info in auto_skipped_bugs]
|
|
863
|
+
if recovered_auto_skipped:
|
|
864
|
+
summary["recovered_auto_skipped"] = recovered_auto_skipped
|
|
807
865
|
if session_status in ("commit_missing", "docs_missing", "merge_conflict"):
|
|
808
866
|
summary["degraded_reason"] = session_status
|
|
809
867
|
summary["restart_policy"] = "finalization_retry"
|
|
@@ -992,6 +1050,14 @@ def action_status(bug_list_data, state_dir, project_root=None):
|
|
|
992
1050
|
for bug in bugs
|
|
993
1051
|
if isinstance(bug, dict) and bug.get("id")
|
|
994
1052
|
}
|
|
1053
|
+
try:
|
|
1054
|
+
orphaned_ids = set(orphaned_auto_skipped_ids(
|
|
1055
|
+
bugs,
|
|
1056
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
1057
|
+
item_label="Bug",
|
|
1058
|
+
))
|
|
1059
|
+
except ValueError:
|
|
1060
|
+
orphaned_ids = set()
|
|
995
1061
|
bug_lines = []
|
|
996
1062
|
|
|
997
1063
|
for bug in bugs:
|
|
@@ -1049,15 +1115,18 @@ def action_status(bug_list_data, state_dir, project_root=None):
|
|
|
1049
1115
|
elif bstatus == "needs_info":
|
|
1050
1116
|
detail = " (needs more info)"
|
|
1051
1117
|
elif bstatus == "auto_skipped":
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1118
|
+
if bid in orphaned_ids:
|
|
1119
|
+
detail = " (orphaned: no blocking dependency)"
|
|
1120
|
+
else:
|
|
1121
|
+
blockers = [
|
|
1122
|
+
dependency_id
|
|
1123
|
+
for dependency_id in bug.get("dependencies", [])
|
|
1124
|
+
if status_map.get(dependency_id, "pending")
|
|
1125
|
+
in RESET_BLOCKING_ROOT_STATUSES | {"auto_skipped"}
|
|
1126
|
+
]
|
|
1127
|
+
detail = " (blocked by {})".format(
|
|
1128
|
+
", ".join(blockers) if blockers else "dependency chain"
|
|
1129
|
+
)
|
|
1061
1130
|
|
|
1062
1131
|
# Colorize
|
|
1063
1132
|
if bstatus == "completed":
|
|
@@ -1302,6 +1371,14 @@ def action_start(args, bug_list_path, state_dir):
|
|
|
1302
1371
|
error_out("Failed to update .prizmkit/plans/bug-fix-list.json: {}".format(err))
|
|
1303
1372
|
return
|
|
1304
1373
|
|
|
1374
|
+
try:
|
|
1375
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_bugs(
|
|
1376
|
+
bug_list_path, state_dir
|
|
1377
|
+
)
|
|
1378
|
+
except (ValueError, RuntimeError) as exc:
|
|
1379
|
+
error_out(str(exc))
|
|
1380
|
+
return
|
|
1381
|
+
|
|
1305
1382
|
result = {
|
|
1306
1383
|
"action": "start",
|
|
1307
1384
|
"bug_id": bug_id,
|
|
@@ -1311,6 +1388,8 @@ def action_start(args, bug_list_path, state_dir):
|
|
|
1311
1388
|
"infra_error_count": bs.get("infra_error_count", 0),
|
|
1312
1389
|
"updated_at": bs["updated_at"],
|
|
1313
1390
|
}
|
|
1391
|
+
if recovered_auto_skipped:
|
|
1392
|
+
result["recovered_auto_skipped"] = recovered_auto_skipped
|
|
1314
1393
|
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
1315
1394
|
|
|
1316
1395
|
|
|
@@ -38,6 +38,7 @@ from utils import (
|
|
|
38
38
|
read_checkpoint_cursor,
|
|
39
39
|
dependency_rank_map,
|
|
40
40
|
causal_reset_selection,
|
|
41
|
+
orphaned_auto_skipped_ids,
|
|
41
42
|
)
|
|
42
43
|
|
|
43
44
|
|
|
@@ -747,11 +748,55 @@ def auto_skip_blocked_features(feature_list_path, state_dir, failed_feature_id):
|
|
|
747
748
|
return skipped_info
|
|
748
749
|
|
|
749
750
|
|
|
751
|
+
def reconcile_orphaned_auto_skipped_features(feature_list_path, state_dir):
|
|
752
|
+
"""Restore auto-skipped features that have no current blocking root."""
|
|
753
|
+
data, err = load_json_file(feature_list_path)
|
|
754
|
+
if err:
|
|
755
|
+
raise RuntimeError("Cannot load feature list for orphan recovery: {}".format(err))
|
|
756
|
+
features = data.get("features", [])
|
|
757
|
+
orphan_ids = orphaned_auto_skipped_ids(
|
|
758
|
+
features,
|
|
759
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
760
|
+
item_label="Feature",
|
|
761
|
+
)
|
|
762
|
+
if not orphan_ids:
|
|
763
|
+
return []
|
|
764
|
+
|
|
765
|
+
orphan_set = set(orphan_ids)
|
|
766
|
+
for feature in features:
|
|
767
|
+
if isinstance(feature, dict) and feature.get("id") in orphan_set:
|
|
768
|
+
feature["status"] = "pending"
|
|
769
|
+
err = write_json_file(feature_list_path, data)
|
|
770
|
+
if err:
|
|
771
|
+
raise RuntimeError("Failed to recover orphaned features: {}".format(err))
|
|
772
|
+
|
|
773
|
+
for feature_id in orphan_ids:
|
|
774
|
+
fs = load_feature_status(state_dir, feature_id)
|
|
775
|
+
fs["updated_at"] = now_iso()
|
|
776
|
+
err = save_feature_status(state_dir, feature_id, fs)
|
|
777
|
+
if err:
|
|
778
|
+
raise RuntimeError("Failed to save recovered feature status: {}".format(err))
|
|
779
|
+
|
|
780
|
+
print(
|
|
781
|
+
"[auto-skip] recovered {} orphaned feature(s): {}".format(
|
|
782
|
+
len(orphan_ids), ", ".join(orphan_ids)
|
|
783
|
+
),
|
|
784
|
+
file=sys.stderr,
|
|
785
|
+
)
|
|
786
|
+
return list(orphan_ids)
|
|
787
|
+
|
|
788
|
+
|
|
750
789
|
# ---------------------------------------------------------------------------
|
|
751
790
|
# Action: get_next
|
|
752
791
|
# ---------------------------------------------------------------------------
|
|
753
792
|
|
|
754
|
-
def action_get_next(
|
|
793
|
+
def action_get_next(
|
|
794
|
+
feature_list_data,
|
|
795
|
+
state_dir,
|
|
796
|
+
feature_filter=None,
|
|
797
|
+
project_root=None,
|
|
798
|
+
feature_list_path=None,
|
|
799
|
+
):
|
|
755
800
|
"""Find the next feature to process.
|
|
756
801
|
|
|
757
802
|
Priority logic:
|
|
@@ -761,6 +806,23 @@ def action_get_next(feature_list_data, state_dir, feature_filter=None, project_r
|
|
|
761
806
|
4. Prefer in_progress features over pending ones (interrupted session resume)
|
|
762
807
|
5. Among eligible features, pick highest priority (high > medium > low)
|
|
763
808
|
"""
|
|
809
|
+
if feature_list_path:
|
|
810
|
+
try:
|
|
811
|
+
recovered = reconcile_orphaned_auto_skipped_features(
|
|
812
|
+
feature_list_path, state_dir
|
|
813
|
+
)
|
|
814
|
+
except ValueError:
|
|
815
|
+
print("PIPELINE_BLOCKED")
|
|
816
|
+
return
|
|
817
|
+
except RuntimeError as exc:
|
|
818
|
+
error_out(str(exc))
|
|
819
|
+
return
|
|
820
|
+
if recovered:
|
|
821
|
+
feature_list_data, err = load_json_file(feature_list_path)
|
|
822
|
+
if err:
|
|
823
|
+
error_out("Cannot reload feature list after orphan recovery: {}".format(err))
|
|
824
|
+
return
|
|
825
|
+
|
|
764
826
|
features = feature_list_data.get("features", [])
|
|
765
827
|
if not features:
|
|
766
828
|
print("PIPELINE_COMPLETE")
|
|
@@ -945,6 +1007,13 @@ def action_update(args, feature_list_path, state_dir):
|
|
|
945
1007
|
and fs.get("last_session_id") == session_id
|
|
946
1008
|
)
|
|
947
1009
|
if already_completed and not pending_continuation_metadata and (same_session_already_recorded or not session_id):
|
|
1010
|
+
try:
|
|
1011
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_features(
|
|
1012
|
+
feature_list_path, state_dir
|
|
1013
|
+
)
|
|
1014
|
+
except (ValueError, RuntimeError) as exc:
|
|
1015
|
+
error_out(str(exc))
|
|
1016
|
+
return
|
|
948
1017
|
summary = {
|
|
949
1018
|
"action": "update",
|
|
950
1019
|
"feature_id": feature_id,
|
|
@@ -957,6 +1026,8 @@ def action_update(args, feature_list_path, state_dir):
|
|
|
957
1026
|
"updated_at": fs.get("updated_at"),
|
|
958
1027
|
"no_op": True,
|
|
959
1028
|
}
|
|
1029
|
+
if recovered_auto_skipped:
|
|
1030
|
+
summary["recovered_auto_skipped"] = recovered_auto_skipped
|
|
960
1031
|
print(json.dumps(summary, indent=2, ensure_ascii=False))
|
|
961
1032
|
return
|
|
962
1033
|
|
|
@@ -1118,12 +1189,22 @@ def action_update(args, feature_list_path, state_dir):
|
|
|
1118
1189
|
error_out("Failed to save feature status: {}".format(err))
|
|
1119
1190
|
return
|
|
1120
1191
|
|
|
1121
|
-
# Auto-skip downstream features
|
|
1192
|
+
# Auto-skip downstream features for current blockers; otherwise converge
|
|
1193
|
+
# descendants whose complete transitive blocker set is now empty.
|
|
1122
1194
|
auto_skipped_features = []
|
|
1123
|
-
|
|
1195
|
+
recovered_auto_skipped = []
|
|
1196
|
+
if new_status in RESET_BLOCKING_ROOT_STATUSES:
|
|
1124
1197
|
auto_skipped_features = auto_skip_blocked_features(
|
|
1125
1198
|
feature_list_path, state_dir, feature_id
|
|
1126
1199
|
)
|
|
1200
|
+
else:
|
|
1201
|
+
try:
|
|
1202
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_features(
|
|
1203
|
+
feature_list_path, state_dir
|
|
1204
|
+
)
|
|
1205
|
+
except (ValueError, RuntimeError) as exc:
|
|
1206
|
+
error_out(str(exc))
|
|
1207
|
+
return
|
|
1127
1208
|
|
|
1128
1209
|
summary = {
|
|
1129
1210
|
"action": "update",
|
|
@@ -1139,6 +1220,8 @@ def action_update(args, feature_list_path, state_dir):
|
|
|
1139
1220
|
}
|
|
1140
1221
|
if auto_skipped_features:
|
|
1141
1222
|
summary["auto_skipped"] = [info["feature_id"] for info in auto_skipped_features]
|
|
1223
|
+
if recovered_auto_skipped:
|
|
1224
|
+
summary["recovered_auto_skipped"] = recovered_auto_skipped
|
|
1142
1225
|
if session_status in ("commit_missing", "docs_missing", "merge_conflict"):
|
|
1143
1226
|
summary["degraded_reason"] = session_status
|
|
1144
1227
|
summary["restart_policy"] = "finalization_retry"
|
|
@@ -1346,18 +1429,35 @@ def action_status(feature_list_data, state_dir, feature_filter=None, project_roo
|
|
|
1346
1429
|
as ETA, degraded reasons, and live checkpoint phase is read from status.json
|
|
1347
1430
|
and workflow-checkpoint.json.
|
|
1348
1431
|
"""
|
|
1349
|
-
|
|
1432
|
+
all_features = feature_list_data.get("features", [])
|
|
1350
1433
|
project_name = feature_list_data.get("project_name", "Unknown")
|
|
1351
1434
|
project_root = os.path.abspath(project_root) if project_root else _default_project_root()
|
|
1352
1435
|
|
|
1353
|
-
#
|
|
1436
|
+
# Dependency truth always comes from the complete plan, even when rendering
|
|
1437
|
+
# only a filtered subset.
|
|
1438
|
+
status_map = {
|
|
1439
|
+
feature["id"]: feature.get("status", "pending")
|
|
1440
|
+
for feature in all_features
|
|
1441
|
+
if isinstance(feature, dict) and feature.get("id")
|
|
1442
|
+
}
|
|
1443
|
+
try:
|
|
1444
|
+
orphaned_ids = set(orphaned_auto_skipped_ids(
|
|
1445
|
+
all_features,
|
|
1446
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
1447
|
+
item_label="Feature",
|
|
1448
|
+
))
|
|
1449
|
+
except ValueError:
|
|
1450
|
+
orphaned_ids = set()
|
|
1451
|
+
|
|
1452
|
+
features = all_features
|
|
1354
1453
|
if feature_filter is not None:
|
|
1355
1454
|
features = [
|
|
1356
|
-
|
|
1357
|
-
|
|
1455
|
+
feature
|
|
1456
|
+
for feature in features
|
|
1457
|
+
if isinstance(feature, dict) and feature.get("id") in feature_filter
|
|
1358
1458
|
]
|
|
1359
1459
|
|
|
1360
|
-
# Gather status info
|
|
1460
|
+
# Gather status info for the rendered subset.
|
|
1361
1461
|
counts = {
|
|
1362
1462
|
"completed": 0,
|
|
1363
1463
|
"in_progress": 0,
|
|
@@ -1368,16 +1468,6 @@ def action_status(feature_list_data, state_dir, feature_filter=None, project_roo
|
|
|
1368
1468
|
}
|
|
1369
1469
|
feature_lines = []
|
|
1370
1470
|
|
|
1371
|
-
# Build status map from .prizmkit/plans/feature-list.json only
|
|
1372
|
-
status_map = {}
|
|
1373
|
-
for feature in features:
|
|
1374
|
-
if not isinstance(feature, dict):
|
|
1375
|
-
continue
|
|
1376
|
-
fid = feature.get("id")
|
|
1377
|
-
if not fid:
|
|
1378
|
-
continue
|
|
1379
|
-
status_map[fid] = feature.get("status", "pending")
|
|
1380
|
-
|
|
1381
1471
|
# Build degraded_reason map from status.json (internal pipeline state)
|
|
1382
1472
|
degraded_reason_map = {}
|
|
1383
1473
|
for feature in features:
|
|
@@ -1457,13 +1547,16 @@ def action_status(feature_list_data, state_dir, feature_filter=None, project_roo
|
|
|
1457
1547
|
elif fstatus == "in_progress" and resume_phase is not None:
|
|
1458
1548
|
detail = " (CP-F-{})".format(resume_phase)
|
|
1459
1549
|
elif fstatus == "auto_skipped":
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1550
|
+
if fid in orphaned_ids:
|
|
1551
|
+
detail = " (orphaned: no blocking dependency)"
|
|
1552
|
+
else:
|
|
1553
|
+
deps = feature.get("dependencies", [])
|
|
1554
|
+
blockers = [
|
|
1555
|
+
d for d in deps
|
|
1556
|
+
if status_map.get(d, "pending") in ("failed", "skipped", "auto_skipped")
|
|
1557
|
+
]
|
|
1558
|
+
if blockers:
|
|
1559
|
+
detail = " (auto-skipped: blocked by {})".format(", ".join(blockers))
|
|
1467
1560
|
elif fstatus == "failed" and degraded_reason:
|
|
1468
1561
|
detail = " (last failure: {})".format(degraded_reason)
|
|
1469
1562
|
|
|
@@ -1588,6 +1681,14 @@ def action_start(args, feature_list_path, state_dir):
|
|
|
1588
1681
|
error_out("Failed to update .prizmkit/plans/feature-list.json: {}".format(err))
|
|
1589
1682
|
return
|
|
1590
1683
|
|
|
1684
|
+
try:
|
|
1685
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_features(
|
|
1686
|
+
feature_list_path, state_dir
|
|
1687
|
+
)
|
|
1688
|
+
except (ValueError, RuntimeError) as exc:
|
|
1689
|
+
error_out(str(exc))
|
|
1690
|
+
return
|
|
1691
|
+
|
|
1591
1692
|
result = {
|
|
1592
1693
|
"action": "start",
|
|
1593
1694
|
"feature_id": feature_id,
|
|
@@ -1597,6 +1698,8 @@ def action_start(args, feature_list_path, state_dir):
|
|
|
1597
1698
|
"infra_error_count": fs.get("infra_error_count", 0),
|
|
1598
1699
|
"updated_at": fs["updated_at"],
|
|
1599
1700
|
}
|
|
1701
|
+
if recovered_auto_skipped:
|
|
1702
|
+
result["recovered_auto_skipped"] = recovered_auto_skipped
|
|
1600
1703
|
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
1601
1704
|
|
|
1602
1705
|
|
|
@@ -1896,7 +1999,13 @@ def main():
|
|
|
1896
1999
|
|
|
1897
2000
|
# Dispatch action
|
|
1898
2001
|
if args.action == "get_next":
|
|
1899
|
-
action_get_next(
|
|
2002
|
+
action_get_next(
|
|
2003
|
+
feature_list_data,
|
|
2004
|
+
args.state_dir,
|
|
2005
|
+
feature_filter,
|
|
2006
|
+
args.project_root,
|
|
2007
|
+
args.feature_list,
|
|
2008
|
+
)
|
|
1900
2009
|
elif args.action == "start":
|
|
1901
2010
|
action_start(args, args.feature_list, args.state_dir)
|
|
1902
2011
|
elif args.action == "update":
|
|
@@ -35,6 +35,7 @@ from utils import (
|
|
|
35
35
|
read_checkpoint_cursor,
|
|
36
36
|
dependency_rank_map,
|
|
37
37
|
causal_reset_selection,
|
|
38
|
+
orphaned_auto_skipped_ids,
|
|
38
39
|
)
|
|
39
40
|
|
|
40
41
|
|
|
@@ -397,7 +398,12 @@ def _dependencies_met(refactor, completed_set):
|
|
|
397
398
|
return all(dep in completed_set for dep in deps)
|
|
398
399
|
|
|
399
400
|
|
|
400
|
-
def action_get_next(
|
|
401
|
+
def action_get_next(
|
|
402
|
+
refactor_list_data,
|
|
403
|
+
state_dir,
|
|
404
|
+
project_root=None,
|
|
405
|
+
refactor_list_path=None,
|
|
406
|
+
):
|
|
401
407
|
"""Find the next refactor to process.
|
|
402
408
|
|
|
403
409
|
Priority logic:
|
|
@@ -406,6 +412,23 @@ def action_get_next(refactor_list_data, state_dir, project_root=None):
|
|
|
406
412
|
3. Prefer in_progress refactors (interrupted session resume) over pending
|
|
407
413
|
4. Within each status class, use stable topological list order
|
|
408
414
|
"""
|
|
415
|
+
if refactor_list_path:
|
|
416
|
+
try:
|
|
417
|
+
recovered = reconcile_orphaned_auto_skipped_refactors(
|
|
418
|
+
refactor_list_path, state_dir
|
|
419
|
+
)
|
|
420
|
+
except ValueError:
|
|
421
|
+
print("PIPELINE_BLOCKED")
|
|
422
|
+
return
|
|
423
|
+
except RuntimeError as exc:
|
|
424
|
+
error_out(str(exc))
|
|
425
|
+
return
|
|
426
|
+
if recovered:
|
|
427
|
+
refactor_list_data, err = load_json_file(refactor_list_path)
|
|
428
|
+
if err:
|
|
429
|
+
error_out("Cannot reload refactor list after orphan recovery: {}".format(err))
|
|
430
|
+
return
|
|
431
|
+
|
|
409
432
|
refactors = refactor_list_data.get("refactors", [])
|
|
410
433
|
if not refactors:
|
|
411
434
|
print("PIPELINE_COMPLETE")
|
|
@@ -689,12 +712,22 @@ def action_update(args, refactor_list_path, state_dir):
|
|
|
689
712
|
error_out("Failed to save refactor status: {}".format(err))
|
|
690
713
|
return
|
|
691
714
|
|
|
692
|
-
# Auto-skip downstream refactors
|
|
715
|
+
# Auto-skip downstream refactors for current blockers; otherwise converge
|
|
716
|
+
# descendants whose complete transitive blocker set is now empty.
|
|
693
717
|
auto_skipped_refactors = []
|
|
694
|
-
|
|
718
|
+
recovered_auto_skipped = []
|
|
719
|
+
if new_status in RESET_BLOCKING_ROOT_STATUSES:
|
|
695
720
|
auto_skipped_refactors = auto_skip_blocked_refactors(
|
|
696
721
|
refactor_list_path, state_dir, refactor_id
|
|
697
722
|
)
|
|
723
|
+
else:
|
|
724
|
+
try:
|
|
725
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_refactors(
|
|
726
|
+
refactor_list_path, state_dir
|
|
727
|
+
)
|
|
728
|
+
except (ValueError, RuntimeError) as exc:
|
|
729
|
+
error_out(str(exc))
|
|
730
|
+
return
|
|
698
731
|
|
|
699
732
|
summary = {
|
|
700
733
|
"action": "update",
|
|
@@ -710,6 +743,8 @@ def action_update(args, refactor_list_path, state_dir):
|
|
|
710
743
|
}
|
|
711
744
|
if auto_skipped_refactors:
|
|
712
745
|
summary["auto_skipped"] = [info["refactor_id"] for info in auto_skipped_refactors]
|
|
746
|
+
if recovered_auto_skipped:
|
|
747
|
+
summary["recovered_auto_skipped"] = recovered_auto_skipped
|
|
713
748
|
if session_status in ("commit_missing", "docs_missing", "merge_conflict"):
|
|
714
749
|
summary["degraded_reason"] = session_status
|
|
715
750
|
summary["restart_policy"] = "finalization_retry"
|
|
@@ -961,6 +996,44 @@ def auto_skip_blocked_refactors(refactor_list_path, state_dir, failed_refactor_i
|
|
|
961
996
|
return skipped_info
|
|
962
997
|
|
|
963
998
|
|
|
999
|
+
def reconcile_orphaned_auto_skipped_refactors(refactor_list_path, state_dir):
|
|
1000
|
+
"""Restore auto-skipped refactors that have no current blocking root."""
|
|
1001
|
+
data, err = load_json_file(refactor_list_path)
|
|
1002
|
+
if err:
|
|
1003
|
+
raise RuntimeError("Cannot load refactor list for orphan recovery: {}".format(err))
|
|
1004
|
+
refactors = data.get("refactors", [])
|
|
1005
|
+
orphan_ids = orphaned_auto_skipped_ids(
|
|
1006
|
+
refactors,
|
|
1007
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
1008
|
+
item_label="Refactor",
|
|
1009
|
+
)
|
|
1010
|
+
if not orphan_ids:
|
|
1011
|
+
return []
|
|
1012
|
+
|
|
1013
|
+
orphan_set = set(orphan_ids)
|
|
1014
|
+
for refactor in refactors:
|
|
1015
|
+
if isinstance(refactor, dict) and refactor.get("id") in orphan_set:
|
|
1016
|
+
refactor["status"] = "pending"
|
|
1017
|
+
err = write_json_file(refactor_list_path, data)
|
|
1018
|
+
if err:
|
|
1019
|
+
raise RuntimeError("Failed to recover orphaned refactors: {}".format(err))
|
|
1020
|
+
|
|
1021
|
+
for refactor_id in orphan_ids:
|
|
1022
|
+
rs = load_refactor_status(state_dir, refactor_id)
|
|
1023
|
+
rs["updated_at"] = now_iso()
|
|
1024
|
+
err = save_refactor_status(state_dir, refactor_id, rs)
|
|
1025
|
+
if err:
|
|
1026
|
+
raise RuntimeError("Failed to save recovered refactor status: {}".format(err))
|
|
1027
|
+
|
|
1028
|
+
print(
|
|
1029
|
+
"[auto-skip] recovered {} orphaned refactor(s): {}".format(
|
|
1030
|
+
len(orphan_ids), ", ".join(orphan_ids)
|
|
1031
|
+
),
|
|
1032
|
+
file=sys.stderr,
|
|
1033
|
+
)
|
|
1034
|
+
return list(orphan_ids)
|
|
1035
|
+
|
|
1036
|
+
|
|
964
1037
|
# ---------------------------------------------------------------------------
|
|
965
1038
|
# Action: status
|
|
966
1039
|
# ---------------------------------------------------------------------------
|
|
@@ -998,6 +1071,14 @@ def action_status(refactor_list_data, state_dir, project_root=None):
|
|
|
998
1071
|
project_root = os.path.abspath(project_root) if project_root else _default_project_root()
|
|
999
1072
|
|
|
1000
1073
|
counts = {"completed": 0, "in_progress": 0, "failed": 0, "pending": 0, "skipped": 0, "auto_skipped": 0}
|
|
1074
|
+
try:
|
|
1075
|
+
orphaned_ids = set(orphaned_auto_skipped_ids(
|
|
1076
|
+
refactors,
|
|
1077
|
+
blocking_root_statuses=RESET_BLOCKING_ROOT_STATUSES,
|
|
1078
|
+
item_label="Refactor",
|
|
1079
|
+
))
|
|
1080
|
+
except ValueError:
|
|
1081
|
+
orphaned_ids = set()
|
|
1001
1082
|
refactor_lines = []
|
|
1002
1083
|
|
|
1003
1084
|
for r in refactors:
|
|
@@ -1055,6 +1136,8 @@ def action_status(refactor_list_data, state_dir, project_root=None):
|
|
|
1055
1136
|
detail = " ({})".format(", ".join(parts))
|
|
1056
1137
|
elif rstatus == "failed":
|
|
1057
1138
|
detail = " (failed after {} retries)".format(retry_count)
|
|
1139
|
+
elif rstatus == "auto_skipped" and rid in orphaned_ids:
|
|
1140
|
+
detail = " (orphaned: no blocking dependency)"
|
|
1058
1141
|
|
|
1059
1142
|
# Colorize title based on status
|
|
1060
1143
|
if rstatus == "completed":
|
|
@@ -1283,6 +1366,14 @@ def action_start(args, refactor_list_path, state_dir):
|
|
|
1283
1366
|
error_out("Failed to update .prizmkit/plans/refactor-list.json: {}".format(err))
|
|
1284
1367
|
return
|
|
1285
1368
|
|
|
1369
|
+
try:
|
|
1370
|
+
recovered_auto_skipped = reconcile_orphaned_auto_skipped_refactors(
|
|
1371
|
+
refactor_list_path, state_dir
|
|
1372
|
+
)
|
|
1373
|
+
except (ValueError, RuntimeError) as exc:
|
|
1374
|
+
error_out(str(exc))
|
|
1375
|
+
return
|
|
1376
|
+
|
|
1286
1377
|
result = {
|
|
1287
1378
|
"action": "start",
|
|
1288
1379
|
"refactor_id": refactor_id,
|
|
@@ -1292,6 +1383,8 @@ def action_start(args, refactor_list_path, state_dir):
|
|
|
1292
1383
|
"infra_error_count": rs.get("infra_error_count", 0),
|
|
1293
1384
|
"updated_at": rs["updated_at"],
|
|
1294
1385
|
}
|
|
1386
|
+
if recovered_auto_skipped:
|
|
1387
|
+
result["recovered_auto_skipped"] = recovered_auto_skipped
|
|
1295
1388
|
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
1296
1389
|
|
|
1297
1390
|
|
|
@@ -1389,7 +1482,12 @@ def main():
|
|
|
1389
1482
|
error_out("Cannot load refactor list: {}".format(err))
|
|
1390
1483
|
|
|
1391
1484
|
if args.action == "get_next":
|
|
1392
|
-
action_get_next(
|
|
1485
|
+
action_get_next(
|
|
1486
|
+
refactor_list_data,
|
|
1487
|
+
args.state_dir,
|
|
1488
|
+
args.project_root,
|
|
1489
|
+
args.refactor_list,
|
|
1490
|
+
)
|
|
1393
1491
|
elif args.action == "update":
|
|
1394
1492
|
action_update(args, args.refactor_list, args.state_dir)
|
|
1395
1493
|
elif args.action == "status":
|