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
|
@@ -228,24 +228,19 @@ def dependency_rank_map(items, id_key="id", dependencies_key="dependencies", ite
|
|
|
228
228
|
return {item[id_key]: index for index, item in enumerate(ordered) if id_key in item}, errors
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
def
|
|
231
|
+
def _causal_blocker_analysis(
|
|
232
232
|
items,
|
|
233
|
-
|
|
234
|
-
blocking_root_statuses=None,
|
|
233
|
+
blocking_root_statuses,
|
|
235
234
|
id_key="id",
|
|
236
235
|
dependencies_key="dependencies",
|
|
237
236
|
status_key="status",
|
|
238
237
|
auto_skipped_status="auto_skipped",
|
|
239
238
|
item_label="Item",
|
|
240
239
|
):
|
|
241
|
-
"""
|
|
240
|
+
"""Validate a dependency graph and derive current transitive blockers.
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
Selecting an ``auto_skipped`` item first expands the selection to every
|
|
246
|
-
blocking root required by that item. ``selected_id=None`` means recover all
|
|
247
|
-
supported blocking roots. Invalid graph or target state raises ``ValueError``
|
|
248
|
-
before callers perform any mutation.
|
|
242
|
+
The second result tracks rootless ``auto_skipped`` ancestors separately so
|
|
243
|
+
a selected recovery never crosses another orphan branch by accident.
|
|
249
244
|
"""
|
|
250
245
|
if not isinstance(items, list):
|
|
251
246
|
raise ValueError("{} list must be an array".format(item_label))
|
|
@@ -255,7 +250,6 @@ def causal_reset_selection(
|
|
|
255
250
|
raise ValueError("Blocking root statuses must not be empty")
|
|
256
251
|
|
|
257
252
|
item_by_id = {}
|
|
258
|
-
ordered_ids = []
|
|
259
253
|
for index, item in enumerate(items):
|
|
260
254
|
if not isinstance(item, dict):
|
|
261
255
|
raise ValueError("{} at index {} is not an object".format(item_label, index))
|
|
@@ -265,9 +259,8 @@ def causal_reset_selection(
|
|
|
265
259
|
if item_id in item_by_id:
|
|
266
260
|
raise ValueError("Duplicate {} id: {}".format(item_label.lower(), item_id))
|
|
267
261
|
item_by_id[item_id] = item
|
|
268
|
-
ordered_ids.append(item_id)
|
|
269
262
|
|
|
270
|
-
|
|
263
|
+
ordered_items, graph_errors = stable_topological_order(
|
|
271
264
|
items,
|
|
272
265
|
id_key=id_key,
|
|
273
266
|
dependencies_key=dependencies_key,
|
|
@@ -276,27 +269,93 @@ def causal_reset_selection(
|
|
|
276
269
|
if graph_errors:
|
|
277
270
|
raise ValueError(graph_errors[0])
|
|
278
271
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if cached is not None:
|
|
284
|
-
cached_roots, cached_unresolved = cached
|
|
285
|
-
return set(cached_roots), set(cached_unresolved)
|
|
272
|
+
ordered_ids = tuple(item[id_key] for item in ordered_items)
|
|
273
|
+
roots_by_id = {}
|
|
274
|
+
orphan_ancestors_by_id = {}
|
|
275
|
+
for item_id in ordered_ids:
|
|
286
276
|
item = item_by_id[item_id]
|
|
287
277
|
roots = set()
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if item_status in roots_statuses:
|
|
278
|
+
orphan_ancestors = set()
|
|
279
|
+
if item.get(status_key, "pending") in roots_statuses:
|
|
291
280
|
roots.add(item_id)
|
|
292
281
|
for dependency_id in item.get(dependencies_key, []) or []:
|
|
293
|
-
dependency_roots
|
|
282
|
+
dependency_roots = roots_by_id[dependency_id]
|
|
294
283
|
roots.update(dependency_roots)
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
284
|
+
orphan_ancestors.update(orphan_ancestors_by_id[dependency_id])
|
|
285
|
+
dependency = item_by_id[dependency_id]
|
|
286
|
+
if (
|
|
287
|
+
dependency.get(status_key, "pending") == auto_skipped_status
|
|
288
|
+
and not dependency_roots
|
|
289
|
+
):
|
|
290
|
+
orphan_ancestors.add(dependency_id)
|
|
291
|
+
roots_by_id[item_id] = frozenset(roots)
|
|
292
|
+
orphan_ancestors_by_id[item_id] = frozenset(orphan_ancestors)
|
|
293
|
+
|
|
294
|
+
return ordered_ids, item_by_id, roots_by_id, orphan_ancestors_by_id
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def orphaned_auto_skipped_ids(
|
|
298
|
+
items,
|
|
299
|
+
blocking_root_statuses,
|
|
300
|
+
id_key="id",
|
|
301
|
+
dependencies_key="dependencies",
|
|
302
|
+
status_key="status",
|
|
303
|
+
auto_skipped_status="auto_skipped",
|
|
304
|
+
item_label="Item",
|
|
305
|
+
):
|
|
306
|
+
"""Return auto-skipped IDs with no current transitive blocking root."""
|
|
307
|
+
ordered_ids, item_by_id, roots_by_id, _orphan_ancestors = _causal_blocker_analysis(
|
|
308
|
+
items,
|
|
309
|
+
blocking_root_statuses,
|
|
310
|
+
id_key=id_key,
|
|
311
|
+
dependencies_key=dependencies_key,
|
|
312
|
+
status_key=status_key,
|
|
313
|
+
auto_skipped_status=auto_skipped_status,
|
|
314
|
+
item_label=item_label,
|
|
315
|
+
)
|
|
316
|
+
return tuple(
|
|
317
|
+
item_id
|
|
318
|
+
for item_id in ordered_ids
|
|
319
|
+
if item_by_id[item_id].get(status_key, "pending") == auto_skipped_status
|
|
320
|
+
and not roots_by_id[item_id]
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def causal_reset_selection(
|
|
325
|
+
items,
|
|
326
|
+
selected_id=None,
|
|
327
|
+
blocking_root_statuses=None,
|
|
328
|
+
id_key="id",
|
|
329
|
+
dependencies_key="dependencies",
|
|
330
|
+
status_key="status",
|
|
331
|
+
auto_skipped_status="auto_skipped",
|
|
332
|
+
item_label="Item",
|
|
333
|
+
):
|
|
334
|
+
"""Return the exact state-only recovery closure for one dependency graph.
|
|
335
|
+
|
|
336
|
+
A selected terminal root recovers itself and only ``auto_skipped`` items
|
|
337
|
+
whose complete transitive blocking-root set is contained by that selection.
|
|
338
|
+
Selecting an ``auto_skipped`` item expands the selection to every blocking
|
|
339
|
+
root and rootless auto-skipped ancestor required by that item. Selecting all
|
|
340
|
+
recovers every supported root and every orphan. Invalid graph or target
|
|
341
|
+
state raises ``ValueError`` before callers perform any mutation.
|
|
342
|
+
"""
|
|
343
|
+
roots_statuses = set(blocking_root_statuses or ())
|
|
344
|
+
ordered_ids, item_by_id, roots_by_id, orphan_ancestors_by_id = _causal_blocker_analysis(
|
|
345
|
+
items,
|
|
346
|
+
roots_statuses,
|
|
347
|
+
id_key=id_key,
|
|
348
|
+
dependencies_key=dependencies_key,
|
|
349
|
+
status_key=status_key,
|
|
350
|
+
auto_skipped_status=auto_skipped_status,
|
|
351
|
+
item_label=item_label,
|
|
352
|
+
)
|
|
353
|
+
orphan_ids = {
|
|
354
|
+
item_id
|
|
355
|
+
for item_id in ordered_ids
|
|
356
|
+
if item_by_id[item_id].get(status_key, "pending") == auto_skipped_status
|
|
357
|
+
and not roots_by_id[item_id]
|
|
358
|
+
}
|
|
300
359
|
|
|
301
360
|
if selected_id is None:
|
|
302
361
|
selected_roots = {
|
|
@@ -304,29 +363,22 @@ def causal_reset_selection(
|
|
|
304
363
|
for item_id in ordered_ids
|
|
305
364
|
if item_by_id[item_id].get(status_key, "pending") in roots_statuses
|
|
306
365
|
}
|
|
307
|
-
|
|
366
|
+
selected_orphans = set(orphan_ids)
|
|
367
|
+
if not selected_roots and not selected_orphans:
|
|
308
368
|
raise ValueError("No recoverable blocking roots found")
|
|
309
369
|
else:
|
|
310
370
|
target = item_by_id.get(selected_id)
|
|
311
371
|
if target is None:
|
|
312
372
|
raise ValueError("{} '{}' not found".format(item_label, selected_id))
|
|
313
373
|
target_status = target.get(status_key, "pending")
|
|
374
|
+
selected_orphans = set()
|
|
314
375
|
if target_status in roots_statuses:
|
|
315
376
|
selected_roots = {selected_id}
|
|
316
377
|
elif target_status == auto_skipped_status:
|
|
317
|
-
selected_roots
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
item_label, selected_id, ", ".join(sorted(unresolved))
|
|
322
|
-
)
|
|
323
|
-
)
|
|
324
|
-
if not selected_roots:
|
|
325
|
-
raise ValueError(
|
|
326
|
-
"{} '{}' is auto_skipped but has no transitive blocking root".format(
|
|
327
|
-
item_label, selected_id
|
|
328
|
-
)
|
|
329
|
-
)
|
|
378
|
+
selected_roots = set(roots_by_id[selected_id])
|
|
379
|
+
selected_orphans.update(orphan_ancestors_by_id[selected_id])
|
|
380
|
+
if selected_id in orphan_ids:
|
|
381
|
+
selected_orphans.add(selected_id)
|
|
330
382
|
else:
|
|
331
383
|
supported = sorted(roots_statuses | {auto_skipped_status})
|
|
332
384
|
raise ValueError(
|
|
@@ -335,14 +387,21 @@ def causal_reset_selection(
|
|
|
335
387
|
)
|
|
336
388
|
)
|
|
337
389
|
|
|
338
|
-
selected = set(selected_roots)
|
|
390
|
+
selected = set(selected_roots) | set(selected_orphans)
|
|
339
391
|
for item_id in ordered_ids:
|
|
340
392
|
item = item_by_id[item_id]
|
|
341
393
|
if item.get(status_key, "pending") != auto_skipped_status:
|
|
342
394
|
continue
|
|
343
|
-
blockers
|
|
344
|
-
|
|
395
|
+
blockers = roots_by_id[item_id]
|
|
396
|
+
required_orphans = orphan_ancestors_by_id[item_id]
|
|
397
|
+
if not blockers.issubset(selected_roots):
|
|
398
|
+
continue
|
|
399
|
+
if not required_orphans.issubset(selected_orphans):
|
|
400
|
+
continue
|
|
401
|
+
if blockers or required_orphans or item_id in selected_orphans:
|
|
345
402
|
selected.add(item_id)
|
|
403
|
+
if not blockers:
|
|
404
|
+
selected_orphans.add(item_id)
|
|
346
405
|
|
|
347
406
|
return tuple(item_id for item_id in ordered_ids if item_id in selected)
|
|
348
407
|
|
|
@@ -8,6 +8,8 @@ import sys
|
|
|
8
8
|
import time
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
11
13
|
from update_feature_status import (
|
|
12
14
|
auto_skip_blocked_features,
|
|
13
15
|
TERMINAL_STATUSES,
|
|
@@ -1592,6 +1594,225 @@ class TestAutoSkipIntegration:
|
|
|
1592
1594
|
assert statuses["F-001"] == "pending"
|
|
1593
1595
|
|
|
1594
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
|
+
|
|
1595
1816
|
def test_context_overflow_records_no_progress_fingerprint_and_stall(tmp_path):
|
|
1596
1817
|
scripts_dir = Path(__file__).resolve().parents[1] / 'scripts'
|
|
1597
1818
|
feature_list = tmp_path / 'feature-list.json'
|
|
@@ -1187,15 +1187,15 @@ def test_pipeline_aggregate_empty_authoritative_completion(monkeypatch, tmp_path
|
|
|
1187
1187
|
(
|
|
1188
1188
|
("feature", "completed", True),
|
|
1189
1189
|
("feature", "skipped", False),
|
|
1190
|
-
("feature", "auto_skipped",
|
|
1190
|
+
("feature", "auto_skipped", False),
|
|
1191
1191
|
("feature", "split", True),
|
|
1192
1192
|
("bugfix", "completed", True),
|
|
1193
1193
|
("bugfix", "skipped", False),
|
|
1194
|
-
("bugfix", "auto_skipped",
|
|
1194
|
+
("bugfix", "auto_skipped", False),
|
|
1195
1195
|
("bugfix", "split", False),
|
|
1196
1196
|
("refactor", "completed", True),
|
|
1197
1197
|
("refactor", "skipped", False),
|
|
1198
|
-
("refactor", "auto_skipped",
|
|
1198
|
+
("refactor", "auto_skipped", False),
|
|
1199
1199
|
("refactor", "split", False),
|
|
1200
1200
|
),
|
|
1201
1201
|
)
|
|
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
11
|
|
|
12
|
-
from utils import causal_reset_selection
|
|
12
|
+
from utils import causal_reset_selection, orphaned_auto_skipped_ids
|
|
13
13
|
|
|
14
14
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
15
15
|
PIPELINE_ROOT = REPO_ROOT / "dev-pipeline"
|
|
@@ -145,7 +145,7 @@ def test_causal_selection_all_recovers_every_supported_chain(prefix, root_status
|
|
|
145
145
|
assert selected == (f"{prefix}001", f"{prefix}002", f"{prefix}003")
|
|
146
146
|
|
|
147
147
|
|
|
148
|
-
def
|
|
148
|
+
def test_causal_selection_rejects_missing_and_invalid_targets():
|
|
149
149
|
items = [
|
|
150
150
|
_item("F-001", "failed"),
|
|
151
151
|
_item("F-002", "pending"),
|
|
@@ -156,8 +156,66 @@ def test_causal_selection_rejects_missing_invalid_and_orphan_targets():
|
|
|
156
156
|
causal_reset_selection(items, selected_id="F-999", blocking_root_statuses={"failed", "skipped"})
|
|
157
157
|
with pytest.raises(ValueError, match="not recoverable"):
|
|
158
158
|
causal_reset_selection(items, selected_id="F-002", blocking_root_statuses={"failed", "skipped"})
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
@pytest.mark.parametrize("prefix", ("F-", "B-", "R-"))
|
|
162
|
+
def test_causal_selection_recovers_selected_orphan_and_eligible_descendants(prefix):
|
|
163
|
+
root_statuses = {"failed", "skipped", "needs_info"} if prefix == "B-" else {"failed", "skipped"}
|
|
164
|
+
items = [
|
|
165
|
+
_item(f"{prefix}001", "completed"),
|
|
166
|
+
_item(f"{prefix}002", "auto_skipped", [f"{prefix}001"]),
|
|
167
|
+
_item(f"{prefix}003", "auto_skipped", [f"{prefix}002"]),
|
|
168
|
+
_item(f"{prefix}004", "auto_skipped", [f"{prefix}001"]),
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
selected = causal_reset_selection(
|
|
172
|
+
items,
|
|
173
|
+
selected_id=f"{prefix}002",
|
|
174
|
+
blocking_root_statuses=root_statuses,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
assert selected == (f"{prefix}002", f"{prefix}003")
|
|
178
|
+
assert orphaned_auto_skipped_ids(
|
|
179
|
+
items,
|
|
180
|
+
blocking_root_statuses=root_statuses,
|
|
181
|
+
) == (f"{prefix}002", f"{prefix}003", f"{prefix}004")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@pytest.mark.parametrize("prefix", ("F-", "B-", "R-"))
|
|
185
|
+
def test_causal_selection_all_recovers_orphans_when_no_blocking_root_remains(prefix):
|
|
186
|
+
root_statuses = {"failed", "skipped", "needs_info"} if prefix == "B-" else {"failed", "skipped"}
|
|
187
|
+
items = [
|
|
188
|
+
_item(f"{prefix}001", "completed"),
|
|
189
|
+
_item(f"{prefix}002", "auto_skipped", [f"{prefix}001"]),
|
|
190
|
+
_item(f"{prefix}003", "auto_skipped", [f"{prefix}002"]),
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
selected = causal_reset_selection(
|
|
194
|
+
items,
|
|
195
|
+
selected_id=None,
|
|
196
|
+
blocking_root_statuses=root_statuses,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
assert selected == (f"{prefix}002", f"{prefix}003")
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def test_orphan_analysis_keeps_multi_root_item_blocked_until_every_root_resolves():
|
|
203
|
+
items = [
|
|
204
|
+
_item("F-001", "completed"),
|
|
205
|
+
_item("F-002", "failed"),
|
|
206
|
+
_item("F-003", "auto_skipped", ["F-001", "F-002"]),
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
assert orphaned_auto_skipped_ids(
|
|
210
|
+
items,
|
|
211
|
+
blocking_root_statuses={"failed", "skipped"},
|
|
212
|
+
) == ()
|
|
213
|
+
|
|
214
|
+
items[1]["status"] = "in_progress"
|
|
215
|
+
assert orphaned_auto_skipped_ids(
|
|
216
|
+
items,
|
|
217
|
+
blocking_root_statuses={"failed", "skipped"},
|
|
218
|
+
) == ("F-003",)
|
|
161
219
|
|
|
162
220
|
|
|
163
221
|
def test_causal_selection_rejects_invalid_dependency_graph_before_selection():
|
|
@@ -484,6 +542,85 @@ def test_state_only_all_recovers_all_supported_chains_without_pipeline_state(tmp
|
|
|
484
542
|
assert not (family.state_dir / "pipeline.json").exists()
|
|
485
543
|
|
|
486
544
|
|
|
545
|
+
@pytest.mark.parametrize("kind", ("feature", "bugfix", "refactor"))
|
|
546
|
+
def test_state_only_all_recovers_rootless_auto_skipped_chain(tmp_path, kind):
|
|
547
|
+
from prizmkit_runtime.reset import run_reset_command
|
|
548
|
+
|
|
549
|
+
paths = _make_paths(tmp_path / kind)
|
|
550
|
+
contract = FAMILY_CONTRACTS[kind]
|
|
551
|
+
prefix = contract["prefix"]
|
|
552
|
+
root_id = f"{prefix}001"
|
|
553
|
+
child_id = f"{prefix}002"
|
|
554
|
+
leaf_id = f"{prefix}003"
|
|
555
|
+
family, plan_path = _family_and_plan(
|
|
556
|
+
paths,
|
|
557
|
+
kind,
|
|
558
|
+
[
|
|
559
|
+
_item(root_id, "completed"),
|
|
560
|
+
_item(child_id, "auto_skipped", [root_id]),
|
|
561
|
+
_item(leaf_id, "auto_skipped", [child_id]),
|
|
562
|
+
],
|
|
563
|
+
)
|
|
564
|
+
child_status_path, _ = _write_runtime_status(family, child_id)
|
|
565
|
+
session_marker = family.state_dir / child_id / "sessions" / "old-session" / "session.log"
|
|
566
|
+
session_marker.parent.mkdir(parents=True)
|
|
567
|
+
session_marker.write_text("preserve session artifact\n", encoding="utf-8")
|
|
568
|
+
|
|
569
|
+
result = run_reset_command(
|
|
570
|
+
kind,
|
|
571
|
+
("--state-only", "--all", str(plan_path)),
|
|
572
|
+
paths,
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
assert result.exit_code == 0, result.render()
|
|
576
|
+
payload = json.loads(result.render())
|
|
577
|
+
assert payload["reset_count"] == 2
|
|
578
|
+
updated = json.loads(plan_path.read_text(encoding="utf-8"))[contract["list_key"]]
|
|
579
|
+
assert [item["status"] for item in updated] == ["completed", "pending", "pending"]
|
|
580
|
+
assert session_marker.read_text(encoding="utf-8") == "preserve session artifact\n"
|
|
581
|
+
assert json.loads(child_status_path.read_text(encoding="utf-8"))["custom_diagnostic"] == {"keep": True}
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
@pytest.mark.parametrize("kind", ("feature", "bugfix", "refactor"))
|
|
585
|
+
def test_state_only_selected_orphan_recovers_only_its_causal_descendants(tmp_path, kind):
|
|
586
|
+
from prizmkit_runtime.reset import run_reset_command
|
|
587
|
+
|
|
588
|
+
paths = _make_paths(tmp_path / kind)
|
|
589
|
+
contract = FAMILY_CONTRACTS[kind]
|
|
590
|
+
prefix = contract["prefix"]
|
|
591
|
+
root_id = f"{prefix}001"
|
|
592
|
+
selected_id = f"{prefix}002"
|
|
593
|
+
leaf_id = f"{prefix}003"
|
|
594
|
+
sibling_id = f"{prefix}004"
|
|
595
|
+
family, plan_path = _family_and_plan(
|
|
596
|
+
paths,
|
|
597
|
+
kind,
|
|
598
|
+
[
|
|
599
|
+
_item(root_id, "completed"),
|
|
600
|
+
_item(selected_id, "auto_skipped", [root_id]),
|
|
601
|
+
_item(leaf_id, "auto_skipped", [selected_id]),
|
|
602
|
+
_item(sibling_id, "auto_skipped", [root_id]),
|
|
603
|
+
],
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
result = run_reset_command(
|
|
607
|
+
kind,
|
|
608
|
+
(selected_id, "--state-only", str(plan_path)),
|
|
609
|
+
paths,
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
assert result.exit_code == 0, result.render()
|
|
613
|
+
payload = json.loads(result.render())
|
|
614
|
+
assert payload["reset_count"] == 2
|
|
615
|
+
updated = json.loads(plan_path.read_text(encoding="utf-8"))[contract["list_key"]]
|
|
616
|
+
assert {item["id"]: item["status"] for item in updated} == {
|
|
617
|
+
root_id: "completed",
|
|
618
|
+
selected_id: "pending",
|
|
619
|
+
leaf_id: "pending",
|
|
620
|
+
sibling_id: "auto_skipped",
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
|
|
487
624
|
@pytest.mark.parametrize("kind", ("feature", "bugfix", "refactor"))
|
|
488
625
|
def test_reset_without_mode_fails_before_any_mutation(tmp_path, kind):
|
|
489
626
|
from prizmkit_runtime.reset import run_reset_command
|
|
@@ -585,7 +722,6 @@ def test_reset_selector_matrix_rejects_unsupported_forms_before_mutation(tmp_pat
|
|
|
585
722
|
(
|
|
586
723
|
([_item("F-001", "failed")], ("F-999", "--state-only"), "not found"),
|
|
587
724
|
([_item("F-001", "pending")], ("F-001", "--state-only"), "not recoverable"),
|
|
588
|
-
([_item("F-001", "auto_skipped")], ("F-001", "--state-only"), "unresolved auto_skipped blocker"),
|
|
589
725
|
([_item("F-001", "completed")], ("--state-only", "--all"), "No recoverable blocking roots"),
|
|
590
726
|
(
|
|
591
727
|
[_item("F-001", "failed", ["F-002"]), _item("F-002", "auto_skipped", ["F-001"])],
|
|
@@ -1028,7 +1164,7 @@ def test_bugfix_auto_skipped_schema_validators_and_aggregation_are_consistent():
|
|
|
1028
1164
|
assert "auto_skipped" in PROGRESS_COUNTS_BY_KIND["bugfix"]
|
|
1029
1165
|
paths = resolve_runtime_paths(pipeline_root=PIPELINE_ROOT, project_root=REPO_ROOT)
|
|
1030
1166
|
bug_family = family_for("bugfix", paths)
|
|
1031
|
-
assert "auto_skipped" in _completion_compatible_statuses(bug_family)
|
|
1167
|
+
assert "auto_skipped" not in _completion_compatible_statuses(bug_family)
|
|
1032
1168
|
|
|
1033
1169
|
|
|
1034
1170
|
def test_all_updaters_expose_only_reset_state_internal_recovery_action():
|