@@ -529,6 +529,50 @@ def _persist_session_with_pending_verification(temp_dir: Path) -> str: |
| 529 | 529 | return snapshot.session_id |
| 530 | 530 | |
| 531 | 531 | |
| 532 | +def _persist_session_with_planned_verification(temp_dir: Path) -> str: |
| 533 | + snapshot = SessionSnapshot( |
| 534 | + session_id="20260406T160430Z-plan1234", |
| 535 | + created_at="2026-04-06T16:04:30Z", |
| 536 | + updated_at="2026-04-06T16:04:50Z", |
| 537 | + messages=[ |
| 538 | + Message(role=Role.USER, content="Keep editing the runtime"), |
| 539 | + Message(role=Role.ASSISTANT, content="Verification will run after execution."), |
| 540 | + ], |
| 541 | + current_task="Keep editing the runtime", |
| 542 | + runtime_owner_type="RuntimeHandle", |
| 543 | + runtime_owner_path="runtime-handle", |
| 544 | + workflow_mode="execute", |
| 545 | + permission_mode="workspace-write", |
| 546 | + prompt_format="native", |
| 547 | + prompt_sections=["Runtime Config", "Workflow Context", "Mode Guidance"], |
| 548 | + workflow_timeline=[ |
| 549 | + WorkflowTimelineEntry( |
| 550 | + timestamp="2026-04-06T16:04:50Z", |
| 551 | + kind="verify_observation", |
| 552 | + mode="execute", |
| 553 | + reason_code="verification_planned", |
| 554 | + summary="verify: verification is planned after new mutating work", |
| 555 | + decision_kind="forced", |
| 556 | + policy_stage="verification", |
| 557 | + policy_outcome="planned", |
| 558 | + verification_observations=[ |
| 559 | + VerificationObservation( |
| 560 | + status="planned", |
| 561 | + summary="verification planned for `uv run pytest -q`", |
| 562 | + command="uv run pytest -q", |
| 563 | + kind="runtime", |
| 564 | + detail="write changed src/loader/runtime/tool_batches.py", |
| 565 | + ) |
| 566 | + ], |
| 567 | + prompt_format="native", |
| 568 | + prompt_sections=["Runtime Config", "Workflow Context", "Mode Guidance"], |
| 569 | + ) |
| 570 | + ], |
| 571 | + ) |
| 572 | + SessionStore(temp_dir).save(snapshot) |
| 573 | + return snapshot.session_id |
| 574 | + |
| 575 | + |
| 532 | 576 | def _persist_session_with_stale_verification(temp_dir: Path) -> str: |
| 533 | 577 | snapshot = SessionSnapshot( |
| 534 | 578 | session_id="20260406T160700Z-stale1234", |
@@ -889,6 +933,30 @@ def test_collect_status_snapshot_surfaces_pending_verification( |
| 889 | 933 | ] |
| 890 | 934 | |
| 891 | 935 | |
| 936 | +def test_collect_status_snapshot_surfaces_planned_verification( |
| 937 | + temp_dir: Path, |
| 938 | +) -> None: |
| 939 | + _write_python_workspace(temp_dir) |
| 940 | + _ensure_loader_dirs(temp_dir) |
| 941 | + _persist_session_with_planned_verification(temp_dir) |
| 942 | + |
| 943 | + snapshot = collect_status_snapshot(temp_dir) |
| 944 | + |
| 945 | + assert snapshot.latest_policy_summary is not None |
| 946 | + assert "verification_planned" in snapshot.latest_policy_summary |
| 947 | + assert "policy-outcome=planned" in snapshot.latest_policy_summary |
| 948 | + assert snapshot.latest_policy_observed_verification == [ |
| 949 | + "verification planned for `uv run pytest -q` [write changed src/loader/runtime/tool_batches.py]" |
| 950 | + ] |
| 951 | + assert [item.status for item in snapshot.recent_verification] == ["planned"] |
| 952 | + assert [item.command for item in snapshot.recent_verification] == [ |
| 953 | + "uv run pytest -q" |
| 954 | + ] |
| 955 | + assert [item.detail for item in snapshot.recent_verification] == [ |
| 956 | + "write changed src/loader/runtime/tool_batches.py" |
| 957 | + ] |
| 958 | + |
| 959 | + |
| 892 | 960 | def test_collect_status_snapshot_surfaces_stale_verification( |
| 893 | 961 | temp_dir: Path, |
| 894 | 962 | ) -> None: |
@@ -1094,6 +1162,29 @@ def test_workflow_command_renders_stale_verification_context( |
| 1094 | 1162 | assert "new mutating work" in result.output |
| 1095 | 1163 | |
| 1096 | 1164 | |
| 1165 | +def test_workflow_command_renders_planned_verification_context( |
| 1166 | + temp_dir: Path, |
| 1167 | + monkeypatch: pytest.MonkeyPatch, |
| 1168 | +) -> None: |
| 1169 | + _write_python_workspace(temp_dir) |
| 1170 | + _ensure_loader_dirs(temp_dir) |
| 1171 | + session_id = _persist_session_with_planned_verification(temp_dir) |
| 1172 | + runner = CliRunner() |
| 1173 | + |
| 1174 | + monkeypatch.chdir(temp_dir) |
| 1175 | + |
| 1176 | + result = runner.invoke(cli_main_module.workflow_cli, ["show"]) |
| 1177 | + |
| 1178 | + assert result.exit_code == 0 |
| 1179 | + assert session_id in result.output |
| 1180 | + assert "Verify planned:" in result.output |
| 1181 | + assert "verification_planned" in result.output |
| 1182 | + assert "policy-outcome=planned" in result.output |
| 1183 | + assert "Observed Verification" in result.output |
| 1184 | + assert "verification planned for `uv run pytest -q`" in result.output |
| 1185 | + assert "uv run pytest -q" in result.output |
| 1186 | + |
| 1187 | + |
| 1097 | 1188 | def test_collect_workflow_timeline_can_focus_on_policy_accountability( |
| 1098 | 1189 | temp_dir: Path, |
| 1099 | 1190 | ) -> None: |