prizmkit 1.1.161 → 1.1.164
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/bin/create-prizmkit.js +4 -4
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +65 -0
- package/bundled/adapters/cursor/hooks-adapter.js +139 -0
- package/bundled/adapters/cursor/paths.js +11 -0
- package/bundled/adapters/cursor/rules-adapter.js +49 -0
- package/bundled/adapters/cursor/skill-adapter.js +27 -0
- package/bundled/dev-pipeline/README.md +21 -6
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +3 -25
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +71 -14
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +28 -4
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +5 -2
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +21 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +82 -9
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +123 -0
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +123 -28
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +1 -42
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +43 -6
- package/bundled/dev-pipeline/scripts/init-pipeline.py +46 -8
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +41 -6
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +143 -27
- package/bundled/dev-pipeline/scripts/update-bug-status.py +8 -4
- package/bundled/dev-pipeline/scripts/update-feature-status.py +12 -8
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +8 -4
- package/bundled/dev-pipeline/scripts/utils.py +3 -12
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/feature-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +4 -2
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +2 -1
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +5 -23
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +2 -2
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +452 -6
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +138 -1
- package/bundled/dev-pipeline/tests/test_unified_cli.py +406 -30
- package/bundled/dev-pipeline/tests/test_utils.py +23 -0
- package/bundled/rules/USAGE.md +3 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/bug-planner/SKILL.md +0 -1
- package/bundled/skills/bug-planner/references/verification.md +0 -2
- package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
- package/bundled/skills/feature-planner/SKILL.md +5 -8
- package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
- package/bundled/skills/prizmkit-init/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +2 -3
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
- package/bundled/skills/refactor-planner/SKILL.md +1 -3
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
- package/package.json +4 -2
- package/src/ai-cli-launch.js +9 -2
- package/src/clean.js +42 -6
- package/src/config.js +51 -10
- package/src/detect-platform.js +30 -8
- package/src/external-skills.js +33 -99
- package/src/index.js +5 -0
- package/src/manifest.js +30 -4
- package/src/platforms.js +11 -4
- package/src/prompts.js +12 -4
- package/src/scaffold.js +75 -4
- package/src/upgrade.js +15 -14
|
@@ -463,6 +463,30 @@ def test_python_env_resolution_scenarios_match_snapshot_contracts(tmp_path):
|
|
|
463
463
|
assert codex_support.enabled is True
|
|
464
464
|
assert codex_support.format == "codex-json"
|
|
465
465
|
|
|
466
|
+
cursor = build_ai_session_command(
|
|
467
|
+
AISessionConfig(
|
|
468
|
+
cli_command="agent",
|
|
469
|
+
platform="cursor",
|
|
470
|
+
model="cursor-model",
|
|
471
|
+
prompt_path=prompt,
|
|
472
|
+
cwd=tmp_path,
|
|
473
|
+
use_stream_json=True,
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
assert cursor.argv == (
|
|
477
|
+
"agent", "--print", "--force", "--trust", "--output-format", "stream-json",
|
|
478
|
+
"--model", "cursor-model",
|
|
479
|
+
)
|
|
480
|
+
assert cursor.stdin_text == "hello"
|
|
481
|
+
assert "hello" not in cursor.argv
|
|
482
|
+
cursor_support = detect_stream_json_support(
|
|
483
|
+
"agent",
|
|
484
|
+
"cursor",
|
|
485
|
+
lambda command: "Cursor Agent --print --force --trust --output-format stream-json",
|
|
486
|
+
)
|
|
487
|
+
assert cursor_support.enabled is True
|
|
488
|
+
assert cursor_support.format == "cursor-stream-json"
|
|
489
|
+
|
|
466
490
|
|
|
467
491
|
def test_windows_structural_paths_use_installed_python_runtime_layout(tmp_path):
|
|
468
492
|
from prizmkit_runtime.paths import resolve_runtime_paths
|
|
@@ -720,6 +744,163 @@ def test_init_scripts_reject_missing_self_and_cycle_dependencies(tmp_path):
|
|
|
720
744
|
assert any(expected_fragments[scenario] in error for error in payload["errors"])
|
|
721
745
|
|
|
722
746
|
|
|
747
|
+
def test_init_scripts_reject_unknown_item_fields(tmp_path):
|
|
748
|
+
script_config = {
|
|
749
|
+
"feature": ("init-pipeline.py", "--feature-list", "F-"),
|
|
750
|
+
"bugfix": ("init-bugfix-pipeline.py", "--bug-list", "B-"),
|
|
751
|
+
"refactor": ("init-refactor-pipeline.py", "--refactor-list", "R-"),
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
for kind, (script_name, list_arg, prefix) in script_config.items():
|
|
755
|
+
paths = _make_paths(tmp_path / f"init-{kind}-unknown-field")
|
|
756
|
+
items = _family_items(kind, [(f"{prefix}001", [], "pending")])
|
|
757
|
+
items[0]["unexpected_field"] = True
|
|
758
|
+
plan_path = _write_family_plan(paths, kind, items)
|
|
759
|
+
result = subprocess.run(
|
|
760
|
+
[
|
|
761
|
+
PYTHON_310_PLUS,
|
|
762
|
+
str(PIPELINE_ROOT / "scripts" / script_name),
|
|
763
|
+
list_arg,
|
|
764
|
+
str(plan_path),
|
|
765
|
+
"--state-dir",
|
|
766
|
+
str(paths.project_root / ".prizmkit" / "state" / f"init-{kind}-unknown-field"),
|
|
767
|
+
],
|
|
768
|
+
cwd=REPO_ROOT,
|
|
769
|
+
stdout=subprocess.PIPE,
|
|
770
|
+
stderr=subprocess.PIPE,
|
|
771
|
+
text=True,
|
|
772
|
+
check=False,
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
assert result.returncode == 1, (kind, result.stdout, result.stderr)
|
|
776
|
+
payload = json.loads(result.stdout)
|
|
777
|
+
assert any("unknown fields: unexpected_field" in error for error in payload["errors"])
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
@pytest.mark.parametrize("location", ("root", "global_context"))
|
|
781
|
+
def test_init_scripts_reject_unknown_list_fields(tmp_path, location):
|
|
782
|
+
script_config = {
|
|
783
|
+
"feature": ("init-pipeline.py", "--feature-list", "F-"),
|
|
784
|
+
"bugfix": ("init-bugfix-pipeline.py", "--bug-list", "B-"),
|
|
785
|
+
"refactor": ("init-refactor-pipeline.py", "--refactor-list", "R-"),
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
for kind, (script_name, list_arg, prefix) in script_config.items():
|
|
789
|
+
paths = _make_paths(tmp_path / f"init-{kind}-unknown-{location}")
|
|
790
|
+
items = _family_items(kind, [(f"{prefix}001", [], "pending")])
|
|
791
|
+
plan_path = _write_family_plan(paths, kind, items)
|
|
792
|
+
payload = json.loads(plan_path.read_text(encoding="utf-8"))
|
|
793
|
+
if location == "root":
|
|
794
|
+
payload["unexpected_field"] = True
|
|
795
|
+
else:
|
|
796
|
+
payload["global_context"] = {"unexpected_field": True}
|
|
797
|
+
plan_path.write_text(json.dumps(payload), encoding="utf-8")
|
|
798
|
+
|
|
799
|
+
result = subprocess.run(
|
|
800
|
+
[
|
|
801
|
+
PYTHON_310_PLUS,
|
|
802
|
+
str(PIPELINE_ROOT / "scripts" / script_name),
|
|
803
|
+
list_arg,
|
|
804
|
+
str(plan_path),
|
|
805
|
+
"--state-dir",
|
|
806
|
+
str(paths.project_root / ".prizmkit" / "state" / f"init-{kind}-unknown-{location}"),
|
|
807
|
+
],
|
|
808
|
+
cwd=REPO_ROOT,
|
|
809
|
+
stdout=subprocess.PIPE,
|
|
810
|
+
stderr=subprocess.PIPE,
|
|
811
|
+
text=True,
|
|
812
|
+
check=False,
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
assert result.returncode == 1, (kind, location, result.stdout, result.stderr)
|
|
816
|
+
output = json.loads(result.stdout)
|
|
817
|
+
assert any("unknown fields: unexpected_field" in error for error in output["errors"])
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
def test_planner_validators_reject_unknown_item_fields():
|
|
821
|
+
from importlib.util import module_from_spec, spec_from_file_location
|
|
822
|
+
|
|
823
|
+
planner_config = {
|
|
824
|
+
"feature": (
|
|
825
|
+
"core/skills/orchestration-skill/pipelines/feature-planner/scripts/validate-and-generate.py",
|
|
826
|
+
"validate_feature_list",
|
|
827
|
+
"features",
|
|
828
|
+
"dev-pipeline-feature-list-v1",
|
|
829
|
+
"F-",
|
|
830
|
+
),
|
|
831
|
+
"bugfix": (
|
|
832
|
+
"core/skills/orchestration-skill/pipelines/bug-planner/scripts/validate-bug-list.py",
|
|
833
|
+
"validate",
|
|
834
|
+
"bugs",
|
|
835
|
+
"dev-pipeline-bug-fix-list-v1",
|
|
836
|
+
"B-",
|
|
837
|
+
),
|
|
838
|
+
"refactor": (
|
|
839
|
+
"core/skills/orchestration-skill/pipelines/refactor-planner/scripts/validate-and-generate-refactor.py",
|
|
840
|
+
"validate_refactor_list",
|
|
841
|
+
"refactors",
|
|
842
|
+
"dev-pipeline-refactor-list-v1",
|
|
843
|
+
"R-",
|
|
844
|
+
),
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
for kind, (relative_path, function_name, list_key, schema, prefix) in planner_config.items():
|
|
848
|
+
script_path = REPO_ROOT / relative_path
|
|
849
|
+
spec = spec_from_file_location(f"{kind}_planner_unknown_field", script_path)
|
|
850
|
+
module = module_from_spec(spec)
|
|
851
|
+
spec.loader.exec_module(module)
|
|
852
|
+
items = _family_items(kind, [(f"{prefix}001", [], "pending")])
|
|
853
|
+
items[0]["unexpected_field"] = True
|
|
854
|
+
result = getattr(module, function_name)({
|
|
855
|
+
"$schema": schema,
|
|
856
|
+
"project_name": "Fake",
|
|
857
|
+
list_key: items,
|
|
858
|
+
})
|
|
859
|
+
|
|
860
|
+
assert result["valid"] is False
|
|
861
|
+
assert any("unknown fields: unexpected_field" in error for error in result["errors"])
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
@pytest.mark.parametrize("location", ("root", "global_context"))
|
|
865
|
+
def test_planner_validators_reject_unknown_list_fields(location):
|
|
866
|
+
from importlib.util import module_from_spec, spec_from_file_location
|
|
867
|
+
|
|
868
|
+
planner_config = {
|
|
869
|
+
"feature": (
|
|
870
|
+
"core/skills/orchestration-skill/pipelines/feature-planner/scripts/validate-and-generate.py",
|
|
871
|
+
"validate_feature_list", "features", "dev-pipeline-feature-list-v1", "F-",
|
|
872
|
+
),
|
|
873
|
+
"bugfix": (
|
|
874
|
+
"core/skills/orchestration-skill/pipelines/bug-planner/scripts/validate-bug-list.py",
|
|
875
|
+
"validate", "bugs", "dev-pipeline-bug-fix-list-v1", "B-",
|
|
876
|
+
),
|
|
877
|
+
"refactor": (
|
|
878
|
+
"core/skills/orchestration-skill/pipelines/refactor-planner/scripts/validate-and-generate-refactor.py",
|
|
879
|
+
"validate_refactor_list", "refactors", "dev-pipeline-refactor-list-v1", "R-",
|
|
880
|
+
),
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
for kind, (relative_path, function_name, list_key, schema, prefix) in planner_config.items():
|
|
884
|
+
script_path = REPO_ROOT / relative_path
|
|
885
|
+
spec = spec_from_file_location(f"{kind}_planner_unknown_{location}", script_path)
|
|
886
|
+
module = module_from_spec(spec)
|
|
887
|
+
spec.loader.exec_module(module)
|
|
888
|
+
payload = {
|
|
889
|
+
"$schema": schema,
|
|
890
|
+
"project_name": "Fake",
|
|
891
|
+
list_key: _family_items(kind, [(f"{prefix}001", [], "pending")]),
|
|
892
|
+
}
|
|
893
|
+
if location == "root":
|
|
894
|
+
payload["unexpected_field"] = True
|
|
895
|
+
else:
|
|
896
|
+
payload["global_context"] = {"unexpected_field": True}
|
|
897
|
+
|
|
898
|
+
result = getattr(module, function_name)(payload)
|
|
899
|
+
|
|
900
|
+
assert result["valid"] is False
|
|
901
|
+
assert any("unknown fields: unexpected_field" in error for error in result["errors"])
|
|
902
|
+
|
|
903
|
+
|
|
723
904
|
def test_bug_planner_validator_rejects_dependency_cycles():
|
|
724
905
|
from importlib.util import module_from_spec, spec_from_file_location
|
|
725
906
|
|
|
@@ -1301,6 +1482,16 @@ def _install_runner_session_fakes(monkeypatch, runners, *, statuses=("success",)
|
|
|
1301
1482
|
monkeypatch.setattr(runners, "commit_pre_branch_bookkeeping", lambda *args, **kwargs: None)
|
|
1302
1483
|
monkeypatch.setattr(runners, "commit_final_bookkeeping", lambda *args, **kwargs: None)
|
|
1303
1484
|
monkeypatch.setattr(runners, "commit_task_branch_changes", lambda *args, **kwargs: None)
|
|
1485
|
+
monkeypatch.setattr(
|
|
1486
|
+
runners,
|
|
1487
|
+
"finalize_accepted_workspace_commit",
|
|
1488
|
+
lambda *args, **kwargs: SimpleNamespace(
|
|
1489
|
+
status="not_needed",
|
|
1490
|
+
reason="accepted_workspace_clean",
|
|
1491
|
+
committed=False,
|
|
1492
|
+
commit_hash="",
|
|
1493
|
+
),
|
|
1494
|
+
)
|
|
1304
1495
|
monkeypatch.setattr(runners, "current_branch", lambda _root: "main")
|
|
1305
1496
|
monkeypatch.setattr(runners, "_session_id", lambda item_id: f"{item_id}-session-{len(prompt_calls) + 1}")
|
|
1306
1497
|
monkeypatch.setattr(
|
|
@@ -1398,6 +1589,219 @@ def _install_runner_session_fakes(monkeypatch, runners, *, statuses=("success",)
|
|
|
1398
1589
|
|
|
1399
1590
|
|
|
1400
1591
|
|
|
1592
|
+
def test_outer_runner_routes_cursor_through_native_preflight_and_session_config(monkeypatch, tmp_path):
|
|
1593
|
+
from prizmkit_runtime import runners
|
|
1594
|
+
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
1595
|
+
|
|
1596
|
+
paths = _make_paths(tmp_path / "cursor-outer-runtime")
|
|
1597
|
+
family = family_for("feature", paths)
|
|
1598
|
+
invocation = parse_invocation(family, "run", ())
|
|
1599
|
+
invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.feature_plan})
|
|
1600
|
+
observed = _install_runner_session_fakes(
|
|
1601
|
+
monkeypatch,
|
|
1602
|
+
runners,
|
|
1603
|
+
statuses=("workflow_skipped",),
|
|
1604
|
+
update_status="completed",
|
|
1605
|
+
)
|
|
1606
|
+
monkeypatch.setattr(
|
|
1607
|
+
runners,
|
|
1608
|
+
"load_runtime_config",
|
|
1609
|
+
lambda _paths: SimpleNamespace(
|
|
1610
|
+
ai_client=SimpleNamespace(command="agent", platform="cursor", launch_profile=None),
|
|
1611
|
+
model="cursor-model",
|
|
1612
|
+
effort=None,
|
|
1613
|
+
effort_validation=SimpleNamespace(valid=True, message=""),
|
|
1614
|
+
),
|
|
1615
|
+
)
|
|
1616
|
+
probes = []
|
|
1617
|
+
|
|
1618
|
+
def cursor_preflight(command, platform):
|
|
1619
|
+
probes.append((command, platform))
|
|
1620
|
+
return SimpleNamespace(enabled=True, notes=())
|
|
1621
|
+
|
|
1622
|
+
monkeypatch.setattr(runners, "detect_stream_json_support", cursor_preflight)
|
|
1623
|
+
monkeypatch.setattr(
|
|
1624
|
+
runners,
|
|
1625
|
+
"run_git_plan",
|
|
1626
|
+
lambda *args, **kwargs: SimpleNamespace(ok=True, reason="", results=()),
|
|
1627
|
+
)
|
|
1628
|
+
|
|
1629
|
+
status = runners._process_item(family, invocation, "F-001", paths, initial_metadata={})
|
|
1630
|
+
|
|
1631
|
+
assert status == "completed"
|
|
1632
|
+
assert probes == [("agent", "cursor")]
|
|
1633
|
+
assert len(observed.launch_configs) == 1
|
|
1634
|
+
launch = observed.launch_configs[0]
|
|
1635
|
+
assert launch.platform == "cursor"
|
|
1636
|
+
assert launch.cli_command == "agent"
|
|
1637
|
+
assert launch.use_stream_json is True
|
|
1638
|
+
assert launch.model == "per-item-model"
|
|
1639
|
+
assert launch.cwd == paths.project_root
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
def test_workflow_skipped_is_finalized_as_completed_with_one_warning(monkeypatch, tmp_path, capsys):
|
|
1643
|
+
from prizmkit_runtime import runners
|
|
1644
|
+
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
1645
|
+
|
|
1646
|
+
paths = _make_paths(tmp_path / "accepted-workflow-skip")
|
|
1647
|
+
family = family_for("refactor", paths)
|
|
1648
|
+
invocation = parse_invocation(family, "run", ())
|
|
1649
|
+
invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.refactor_plan})
|
|
1650
|
+
observed = _install_runner_session_fakes(
|
|
1651
|
+
monkeypatch,
|
|
1652
|
+
runners,
|
|
1653
|
+
statuses=("workflow_skipped",),
|
|
1654
|
+
update_status="completed",
|
|
1655
|
+
)
|
|
1656
|
+
plans = []
|
|
1657
|
+
wip_calls = []
|
|
1658
|
+
accepted_commit_calls = []
|
|
1659
|
+
|
|
1660
|
+
def fake_accepted_commit(project_root, **kwargs):
|
|
1661
|
+
accepted_commit_calls.append((project_root, kwargs))
|
|
1662
|
+
return SimpleNamespace(
|
|
1663
|
+
status="not_needed",
|
|
1664
|
+
reason="accepted_workspace_clean",
|
|
1665
|
+
committed=False,
|
|
1666
|
+
commit_hash="",
|
|
1667
|
+
)
|
|
1668
|
+
|
|
1669
|
+
def fake_run_git_plan(_project_root, plan):
|
|
1670
|
+
plans.append(plan.name)
|
|
1671
|
+
return SimpleNamespace(ok=True, reason="", results=())
|
|
1672
|
+
|
|
1673
|
+
monkeypatch.setattr(runners, "run_git_plan", fake_run_git_plan)
|
|
1674
|
+
monkeypatch.setattr(runners, "finalize_accepted_workspace_commit", fake_accepted_commit)
|
|
1675
|
+
monkeypatch.setattr(
|
|
1676
|
+
runners,
|
|
1677
|
+
"commit_wip_changes",
|
|
1678
|
+
lambda *args, **kwargs: (wip_calls.append((args, kwargs)) or SimpleNamespace(ok=True)),
|
|
1679
|
+
)
|
|
1680
|
+
|
|
1681
|
+
status = runners._process_item(family, invocation, "R-001", paths, initial_metadata={})
|
|
1682
|
+
captured = capsys.readouterr()
|
|
1683
|
+
|
|
1684
|
+
assert status == "completed"
|
|
1685
|
+
assert plans == ["branch_create", "branch_merge"]
|
|
1686
|
+
assert wip_calls == []
|
|
1687
|
+
assert len(accepted_commit_calls) == 1
|
|
1688
|
+
accepted_root, accepted_kwargs = accepted_commit_calls[0]
|
|
1689
|
+
assert accepted_root == paths.project_root
|
|
1690
|
+
assert accepted_kwargs["base_head"] == "base-head"
|
|
1691
|
+
assert accepted_kwargs["artifact_dir"] == paths.project_root / ".prizmkit" / "specs" / "001-low"
|
|
1692
|
+
assert accepted_kwargs["checkpoint_path"] == accepted_kwargs["artifact_dir"] / "workflow-checkpoint.json"
|
|
1693
|
+
assert "R-001" in accepted_kwargs["commit_message"]
|
|
1694
|
+
assert observed.updates[0][0] == "success"
|
|
1695
|
+
assert "classification_reason" not in observed.updates[0][2]
|
|
1696
|
+
assert "accept_workflow_skipped" not in observed.updates[0][2]
|
|
1697
|
+
session_status = json.loads(
|
|
1698
|
+
(
|
|
1699
|
+
paths.refactor_state_dir
|
|
1700
|
+
/ "R-001"
|
|
1701
|
+
/ "sessions"
|
|
1702
|
+
/ "R-001-session-1"
|
|
1703
|
+
/ "session-status.json"
|
|
1704
|
+
).read_text(encoding="utf-8")
|
|
1705
|
+
)
|
|
1706
|
+
assert session_status["status"] == "workflow_skipped"
|
|
1707
|
+
assert session_status["reason"] == "workflow_skipped"
|
|
1708
|
+
assert captured.err.count("[WARN]") == 1
|
|
1709
|
+
assert captured.err.count("accepted with incomplete workflow evidence") == 1
|
|
1710
|
+
assert "Reason: workflow_skipped" in captured.err
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
def test_workflow_skipped_uses_successful_worktree_merge_path(monkeypatch, tmp_path, capsys):
|
|
1714
|
+
from prizmkit_runtime import runners
|
|
1715
|
+
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
1716
|
+
|
|
1717
|
+
monkeypatch.setenv("USE_WORKTREE", "1")
|
|
1718
|
+
monkeypatch.setenv("DEV_BRANCH", "dev/F-001-accepted")
|
|
1719
|
+
paths = _make_paths(tmp_path / "accepted-worktree-skip")
|
|
1720
|
+
family = family_for("feature", paths)
|
|
1721
|
+
invocation = parse_invocation(family, "run", ())
|
|
1722
|
+
invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.feature_plan})
|
|
1723
|
+
observed = _install_runner_session_fakes(
|
|
1724
|
+
monkeypatch,
|
|
1725
|
+
runners,
|
|
1726
|
+
statuses=("workflow_skipped",),
|
|
1727
|
+
update_status="completed",
|
|
1728
|
+
)
|
|
1729
|
+
|
|
1730
|
+
def fake_setup(runtime):
|
|
1731
|
+
runtime.worktree_path.mkdir(parents=True, exist_ok=True)
|
|
1732
|
+
return SimpleNamespace(ok=True, runtime=runtime, reason="")
|
|
1733
|
+
|
|
1734
|
+
monkeypatch.setattr(runners, "ensure_linked_worktree", fake_setup)
|
|
1735
|
+
monkeypatch.setattr(
|
|
1736
|
+
runners,
|
|
1737
|
+
"materialize_worktree_support_assets",
|
|
1738
|
+
lambda *args, **kwargs: SimpleNamespace(ok=True, reason=""),
|
|
1739
|
+
)
|
|
1740
|
+
|
|
1741
|
+
status = runners._process_item(family, invocation, "F-001", paths, initial_metadata={})
|
|
1742
|
+
captured = capsys.readouterr()
|
|
1743
|
+
|
|
1744
|
+
assert status == "completed"
|
|
1745
|
+
assert observed.updates[0][0] == "success"
|
|
1746
|
+
assert len(observed.merge_calls) == 1
|
|
1747
|
+
assert observed.wip_calls == []
|
|
1748
|
+
assert captured.err.count("[WARN]") == 1
|
|
1749
|
+
assert captured.err.count("accepted with incomplete workflow evidence") == 1
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
def test_workflow_skipped_safety_failure_stays_hard_without_acceptance_warning(monkeypatch, tmp_path, capsys):
|
|
1753
|
+
from prizmkit_runtime import runners
|
|
1754
|
+
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
1755
|
+
|
|
1756
|
+
paths = _make_paths(tmp_path / "rejected-workflow-skip")
|
|
1757
|
+
family = family_for("refactor", paths)
|
|
1758
|
+
invocation = parse_invocation(family, "run", ())
|
|
1759
|
+
invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.refactor_plan})
|
|
1760
|
+
observed = _install_runner_session_fakes(
|
|
1761
|
+
monkeypatch,
|
|
1762
|
+
runners,
|
|
1763
|
+
statuses=("workflow_skipped",),
|
|
1764
|
+
update_status="pending",
|
|
1765
|
+
)
|
|
1766
|
+
plans = []
|
|
1767
|
+
wip_calls = []
|
|
1768
|
+
|
|
1769
|
+
monkeypatch.setattr(
|
|
1770
|
+
runners,
|
|
1771
|
+
"finalize_accepted_workspace_commit",
|
|
1772
|
+
lambda *args, **kwargs: SimpleNamespace(
|
|
1773
|
+
status="not_ready",
|
|
1774
|
+
reason="accepted_workspace_not_finalized",
|
|
1775
|
+
committed=False,
|
|
1776
|
+
commit_hash="",
|
|
1777
|
+
),
|
|
1778
|
+
)
|
|
1779
|
+
monkeypatch.setattr(
|
|
1780
|
+
runners,
|
|
1781
|
+
"run_git_plan",
|
|
1782
|
+
lambda _root, plan: (plans.append(plan.name) or SimpleNamespace(ok=True, reason="", results=())),
|
|
1783
|
+
)
|
|
1784
|
+
monkeypatch.setattr(
|
|
1785
|
+
runners,
|
|
1786
|
+
"commit_wip_changes",
|
|
1787
|
+
lambda *args, **kwargs: (wip_calls.append((args, kwargs)) or SimpleNamespace(ok=True)),
|
|
1788
|
+
)
|
|
1789
|
+
monkeypatch.setattr(
|
|
1790
|
+
runners,
|
|
1791
|
+
"branch_ensure_return",
|
|
1792
|
+
lambda *args, **kwargs: SimpleNamespace(ok=True),
|
|
1793
|
+
)
|
|
1794
|
+
|
|
1795
|
+
status = runners._process_item(family, invocation, "R-001", paths, initial_metadata={})
|
|
1796
|
+
captured = capsys.readouterr()
|
|
1797
|
+
|
|
1798
|
+
assert status == "pending"
|
|
1799
|
+
assert plans == ["branch_create"]
|
|
1800
|
+
assert len(wip_calls) == 1
|
|
1801
|
+
assert observed.updates[0][0] == "commit_missing"
|
|
1802
|
+
assert "accepted with incomplete workflow evidence" not in captured.err
|
|
1803
|
+
|
|
1804
|
+
|
|
1401
1805
|
def test_runner_launch_config_preserves_artifact_paths_live_output_and_split_thresholds(monkeypatch, tmp_path):
|
|
1402
1806
|
from prizmkit_runtime import runners
|
|
1403
1807
|
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
@@ -4231,7 +4635,7 @@ def test_terminal_success_text_does_not_hide_provider_failure(tmp_path):
|
|
|
4231
4635
|
("kind", "item_id"),
|
|
4232
4636
|
[("feature", "F-001"), ("bugfix", "B-001"), ("refactor", "R-001")],
|
|
4233
4637
|
)
|
|
4234
|
-
def
|
|
4638
|
+
def test_family_success_completion_is_terminal_without_warning_metadata(
|
|
4235
4639
|
tmp_path, kind, item_id
|
|
4236
4640
|
):
|
|
4237
4641
|
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
@@ -4259,7 +4663,7 @@ def test_family_status_skips_semantic_completion_failure_without_retry_spend(
|
|
|
4259
4663
|
family,
|
|
4260
4664
|
invocation,
|
|
4261
4665
|
item_id,
|
|
4262
|
-
"
|
|
4666
|
+
"success",
|
|
4263
4667
|
"session-1",
|
|
4264
4668
|
paths.project_root,
|
|
4265
4669
|
checkpoint_state={},
|
|
@@ -4267,12 +4671,54 @@ def test_family_status_skips_semantic_completion_failure_without_retry_spend(
|
|
|
4267
4671
|
status = json.loads((family.state_dir / item_id / "status.json").read_text(encoding="utf-8"))
|
|
4268
4672
|
|
|
4269
4673
|
assert result.ok is True
|
|
4270
|
-
assert result.data["new_status"] == "
|
|
4271
|
-
assert result.data["restart_policy"] == "terminal_skipped"
|
|
4674
|
+
assert result.data["new_status"] == "completed"
|
|
4272
4675
|
assert status["retry_count"] == 0
|
|
4273
4676
|
assert status["infra_error_count"] == 0
|
|
4274
|
-
assert
|
|
4275
|
-
assert
|
|
4677
|
+
assert "completion_warning" not in status
|
|
4678
|
+
assert "completion_warning_reason" not in status
|
|
4679
|
+
assert status["resume_from_phase"] is None
|
|
4680
|
+
|
|
4681
|
+
|
|
4682
|
+
@pytest.mark.parametrize(
|
|
4683
|
+
("kind", "item_id"),
|
|
4684
|
+
[("feature", "F-001"), ("bugfix", "B-001"), ("refactor", "R-001")],
|
|
4685
|
+
)
|
|
4686
|
+
def test_family_status_preserves_direct_raw_workflow_skip(
|
|
4687
|
+
tmp_path, kind, item_id
|
|
4688
|
+
):
|
|
4689
|
+
from prizmkit_runtime.runner_models import family_for, parse_invocation
|
|
4690
|
+
from prizmkit_runtime.runner_status import start_item, update_item
|
|
4691
|
+
|
|
4692
|
+
paths = _make_paths(tmp_path / f"historical-{kind}")
|
|
4693
|
+
item = {
|
|
4694
|
+
"id": item_id,
|
|
4695
|
+
"title": "Historical workflow skip",
|
|
4696
|
+
"status": "pending",
|
|
4697
|
+
"priority": "high",
|
|
4698
|
+
"dependencies": [],
|
|
4699
|
+
}
|
|
4700
|
+
if kind == "bugfix":
|
|
4701
|
+
item.update(severity="high", description="invalid evidence", reproduction_steps=["run"])
|
|
4702
|
+
elif kind == "refactor":
|
|
4703
|
+
item.update(description="invalid evidence", targets=["src"], goals=["preserve"])
|
|
4704
|
+
_write_family_plan(paths, kind, [item])
|
|
4705
|
+
family = family_for(kind, paths)
|
|
4706
|
+
invocation = parse_invocation(family, "run", ())
|
|
4707
|
+
invocation = invocation.__class__(**{**invocation.__dict__, "list_path": family.plan_path})
|
|
4708
|
+
assert start_item(family, invocation, item_id, paths.project_root).ok is True
|
|
4709
|
+
|
|
4710
|
+
result = update_item(
|
|
4711
|
+
family,
|
|
4712
|
+
invocation,
|
|
4713
|
+
item_id,
|
|
4714
|
+
"workflow_skipped",
|
|
4715
|
+
"historical-session",
|
|
4716
|
+
paths.project_root,
|
|
4717
|
+
)
|
|
4718
|
+
|
|
4719
|
+
assert result.ok is True
|
|
4720
|
+
assert result.data["new_status"] == "skipped"
|
|
4721
|
+
assert result.data["restart_policy"] == "terminal_skipped"
|
|
4276
4722
|
|
|
4277
4723
|
|
|
4278
4724
|
def test_invalid_existing_checkpoint_skips_terminal_success_with_completion_summary(tmp_path):
|
|
@@ -9,7 +9,10 @@ from pathlib import Path
|
|
|
9
9
|
import pytest
|
|
10
10
|
|
|
11
11
|
from prizmkit_runtime.checkpoint_state import load_checkpoint_state
|
|
12
|
-
from prizmkit_runtime.runtime_commit import
|
|
12
|
+
from prizmkit_runtime.runtime_commit import (
|
|
13
|
+
finalize_accepted_workspace_commit,
|
|
14
|
+
finalize_runtime_commit,
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
def _git(root: Path, *args: str) -> str:
|
|
@@ -551,6 +554,140 @@ def test_runtime_commit_rejects_sensitive_git_visible_workspace_path(tmp_path, u
|
|
|
551
554
|
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
552
555
|
|
|
553
556
|
|
|
557
|
+
def test_accepted_workspace_commit_stages_safe_complete_workspace(tmp_path):
|
|
558
|
+
base_head = _init_repo(tmp_path)
|
|
559
|
+
artifact_dir = tmp_path / ".prizmkit" / "specs" / "001-accepted"
|
|
560
|
+
artifact_dir.mkdir(parents=True)
|
|
561
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
562
|
+
checkpoint_path.write_text('{"steps": []}\n', encoding="utf-8")
|
|
563
|
+
(tmp_path / "tracked.txt").write_text("accepted\n", encoding="utf-8")
|
|
564
|
+
(tmp_path / "new.txt").write_text("new\n", encoding="utf-8")
|
|
565
|
+
|
|
566
|
+
result = finalize_accepted_workspace_commit(
|
|
567
|
+
tmp_path,
|
|
568
|
+
artifact_dir=artifact_dir,
|
|
569
|
+
checkpoint_path=checkpoint_path,
|
|
570
|
+
base_head=base_head,
|
|
571
|
+
commit_message="chore: accept incomplete workflow output",
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
assert result.status == "committed"
|
|
575
|
+
assert _git(tmp_path, "show", "-s", "--format=%s", "HEAD") == "chore: accept incomplete workflow output"
|
|
576
|
+
assert set(_git(tmp_path, "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD").splitlines()) == {"new.txt", "tracked.txt"}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def test_accepted_workspace_commit_excludes_exact_causal_checkpoint(tmp_path):
|
|
580
|
+
_init_repo(tmp_path)
|
|
581
|
+
(tmp_path / ".gitignore").write_text("", encoding="utf-8")
|
|
582
|
+
artifact_dir = tmp_path / ".prizmkit" / "specs" / "001-accepted"
|
|
583
|
+
artifact_dir.mkdir(parents=True)
|
|
584
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
585
|
+
checkpoint_path.write_text('{"steps": []}\n', encoding="utf-8")
|
|
586
|
+
_git(tmp_path, "add", ".gitignore", checkpoint_path.relative_to(tmp_path).as_posix())
|
|
587
|
+
_git(tmp_path, "commit", "-m", "track causal checkpoint")
|
|
588
|
+
base_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
589
|
+
checkpoint_path.write_text('{"steps": [{"status": "in_progress"}]}\n', encoding="utf-8")
|
|
590
|
+
(tmp_path / "tracked.txt").write_text("accepted\n", encoding="utf-8")
|
|
591
|
+
|
|
592
|
+
result = finalize_accepted_workspace_commit(
|
|
593
|
+
tmp_path,
|
|
594
|
+
artifact_dir=artifact_dir,
|
|
595
|
+
checkpoint_path=checkpoint_path,
|
|
596
|
+
base_head=base_head,
|
|
597
|
+
commit_message="chore: accept incomplete workflow output",
|
|
598
|
+
)
|
|
599
|
+
|
|
600
|
+
assert result.status == "committed"
|
|
601
|
+
assert _git(tmp_path, "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD") == "tracked.txt"
|
|
602
|
+
assert checkpoint_path.relative_to(tmp_path).as_posix() in _git(tmp_path, "status", "--short")
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
@pytest.mark.parametrize("unsafe_path", [".env", "credentials.json", "private.pem"])
|
|
606
|
+
def test_accepted_workspace_commit_rejects_sensitive_paths(tmp_path, unsafe_path):
|
|
607
|
+
base_head = _init_repo(tmp_path)
|
|
608
|
+
artifact_dir = tmp_path / ".prizmkit" / "specs" / "001-accepted"
|
|
609
|
+
artifact_dir.mkdir(parents=True)
|
|
610
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
611
|
+
checkpoint_path.write_text('{"steps": []}\n', encoding="utf-8")
|
|
612
|
+
unsafe = tmp_path / unsafe_path
|
|
613
|
+
unsafe.parent.mkdir(parents=True, exist_ok=True)
|
|
614
|
+
unsafe.write_text("sensitive\n", encoding="utf-8")
|
|
615
|
+
|
|
616
|
+
result = finalize_accepted_workspace_commit(
|
|
617
|
+
tmp_path,
|
|
618
|
+
artifact_dir=artifact_dir,
|
|
619
|
+
checkpoint_path=checkpoint_path,
|
|
620
|
+
base_head=base_head,
|
|
621
|
+
commit_message="chore: accept incomplete workflow output",
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
assert result.status == "failed"
|
|
625
|
+
assert result.reason == "sensitive_workspace_path"
|
|
626
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
def test_accepted_workspace_commit_rejects_any_post_base_commit(tmp_path):
|
|
630
|
+
base_head = _init_repo(tmp_path)
|
|
631
|
+
unsafe = tmp_path / "credentials.json"
|
|
632
|
+
unsafe.write_text("sensitive\n", encoding="utf-8")
|
|
633
|
+
_git(tmp_path, "add", "credentials.json")
|
|
634
|
+
_git(tmp_path, "commit", "-m", "unsafe task commit")
|
|
635
|
+
artifact_dir = tmp_path / ".prizmkit" / "specs" / "001-accepted"
|
|
636
|
+
artifact_dir.mkdir(parents=True)
|
|
637
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
638
|
+
checkpoint_path.write_text('{"steps": []}\n', encoding="utf-8")
|
|
639
|
+
|
|
640
|
+
result = finalize_accepted_workspace_commit(
|
|
641
|
+
tmp_path,
|
|
642
|
+
artifact_dir=artifact_dir,
|
|
643
|
+
checkpoint_path=checkpoint_path,
|
|
644
|
+
base_head=base_head,
|
|
645
|
+
commit_message="chore: accept incomplete workflow output",
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
assert result.status == "failed"
|
|
649
|
+
assert result.reason == "unexpected_existing_commit"
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
def test_accepted_workspace_commit_rejects_unresolved_merge_state(tmp_path):
|
|
653
|
+
_init_repo(tmp_path)
|
|
654
|
+
initial_branch = _git(tmp_path, "branch", "--show-current")
|
|
655
|
+
_git(tmp_path, "checkout", "-b", "other")
|
|
656
|
+
(tmp_path / "tracked.txt").write_text("other\n", encoding="utf-8")
|
|
657
|
+
_git(tmp_path, "add", "tracked.txt")
|
|
658
|
+
_git(tmp_path, "commit", "-m", "other change")
|
|
659
|
+
_git(tmp_path, "checkout", initial_branch)
|
|
660
|
+
(tmp_path / "tracked.txt").write_text("main\n", encoding="utf-8")
|
|
661
|
+
_git(tmp_path, "add", "tracked.txt")
|
|
662
|
+
_git(tmp_path, "commit", "-m", "main change")
|
|
663
|
+
base_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
664
|
+
merged = subprocess.run(
|
|
665
|
+
["git", "merge", "other"],
|
|
666
|
+
cwd=tmp_path,
|
|
667
|
+
stdout=subprocess.PIPE,
|
|
668
|
+
stderr=subprocess.PIPE,
|
|
669
|
+
text=True,
|
|
670
|
+
check=False,
|
|
671
|
+
)
|
|
672
|
+
assert merged.returncode != 0
|
|
673
|
+
artifact_dir = tmp_path / ".prizmkit" / "specs" / "001-accepted"
|
|
674
|
+
artifact_dir.mkdir(parents=True)
|
|
675
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
676
|
+
checkpoint_path.write_text('{"steps": []}\n', encoding="utf-8")
|
|
677
|
+
|
|
678
|
+
result = finalize_accepted_workspace_commit(
|
|
679
|
+
tmp_path,
|
|
680
|
+
artifact_dir=artifact_dir,
|
|
681
|
+
checkpoint_path=checkpoint_path,
|
|
682
|
+
base_head=base_head,
|
|
683
|
+
commit_message="chore: accept incomplete workflow output",
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
assert result.status == "failed"
|
|
687
|
+
assert result.reason == "unresolved_merge_state"
|
|
688
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
689
|
+
|
|
690
|
+
|
|
554
691
|
def test_runtime_commit_rejects_empty_workspace(tmp_path):
|
|
555
692
|
base_head = _init_repo(tmp_path)
|
|
556
693
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|