prizmkit 1.1.161 → 1.1.162

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "frameworkVersion": "1.1.161",
3
- "bundledAt": "2026-07-29T09:12:57.978Z",
4
- "bundledFrom": "5ba2929"
2
+ "frameworkVersion": "1.1.162",
3
+ "bundledAt": "2026-07-30T07:26:25.484Z",
4
+ "bundledFrom": "43cdcc8"
5
5
  }
@@ -372,6 +372,8 @@ python3 scripts/update-feature-status.py \
372
372
  **Session status values (for `--session-status`):**
373
373
  `success`, `partial_resumable`, `partial_not_resumable`, `failed`, `crashed`, `timed_out`, `infra_error`, `context_overflow`, `stalled_context_continuation`, `workflow_blocked`, `workflow_skipped`, `commit_missing`, `docs_missing`, `merge_conflict`
374
374
 
375
+ `workflow_skipped` remains the raw session diagnostic for a terminally successful AI process whose authoritative workflow evidence is missing, incompatible, or incomplete. After safely finalizing the complete workspace, the foreground Runner passes ordinary `success` only to the family updater so the task becomes external `completed`, spends no retry budget, and leaves dependent items runnable. The raw session record remains unchanged, and the Runner emits one non-persistent manual-review warning only after successful task finalization and merge. Failed safety checks, commit finalization, or merge remain hard outcomes and do not emit the accepted-success warning. No compatibility flag, persistent warning metadata, or new plan/session status enum is introduced.
376
+
375
377
  **Output (JSON to stdout):**
376
378
 
377
379
  ```json
@@ -411,7 +413,7 @@ python3 scripts/check-session-status.py --status-file <path>
411
413
  ```
412
414
 
413
415
  **Output (single line to stdout):**
414
- `success` | `partial_resumable` | `partial_not_resumable` | `failed` | `crashed` | `commit_missing` | `docs_missing` | `merge_conflict`
416
+ `success` | `partial_resumable` | `partial_not_resumable` | `failed` | `crashed` | `timed_out` | `infra_error` | `context_overflow` | `stalled_context_continuation` | `workflow_blocked` | `workflow_skipped` | `commit_missing` | `docs_missing` | `merge_conflict`
415
417
 
416
418
  **Detail report (JSON to stderr):**
417
419
 
@@ -53,7 +53,12 @@ from .runner_models import (
53
53
  parse_invocation,
54
54
  )
55
55
  from .runner_prompts import PromptGenerationResult, generate_prompt
56
- from .runtime_commit import REQUEST_FILENAME, RuntimeCommitResult, finalize_runtime_commit
56
+ from .runtime_commit import (
57
+ REQUEST_FILENAME,
58
+ RuntimeCommitResult,
59
+ finalize_accepted_workspace_commit,
60
+ finalize_runtime_commit,
61
+ )
57
62
  from .runner_status import get_next, start_item, status_text, update_item
58
63
  from .sessions import AISessionConfig, AISessionLauncher, detect_stream_json_support
59
64
  from .task_checkout import (
@@ -766,6 +771,21 @@ def _process_item_locked(
766
771
  progress_fingerprint=classification.progress_fingerprint,
767
772
  checkpoint_state=classification.checkpoint_state,
768
773
  )
774
+ elif classification.session_status == "workflow_skipped":
775
+ accepted_commit = _finalize_accepted_workflow_skip(
776
+ execution_root,
777
+ family,
778
+ item_id,
779
+ prompt,
780
+ base_head,
781
+ )
782
+ if accepted_commit.status not in {"committed", "not_needed"}:
783
+ classification = SessionClassification(
784
+ "commit_missing",
785
+ reason=accepted_commit.reason,
786
+ progress_fingerprint=classification.progress_fingerprint,
787
+ checkpoint_state=classification.checkpoint_state,
788
+ )
769
789
  _emit_session_summary(session_result, session_paths, classification)
770
790
  final_session_status = classification.session_status
771
791
  summary_path = _continuation_summary_path(execution_root, family, item_id, prompt)
@@ -784,11 +804,15 @@ def _process_item_locked(
784
804
  checkpoint_state=classification.checkpoint_state,
785
805
  )
786
806
 
807
+ accepted_with_warning = final_session_status == "workflow_skipped"
808
+ updater_session_status = (
809
+ "success" if accepted_with_warning else final_session_status
810
+ )
787
811
  update = update_item(
788
812
  status_family,
789
813
  status_invocation,
790
814
  item_id,
791
- final_session_status,
815
+ updater_session_status,
792
816
  session_id,
793
817
  status_root,
794
818
  active_dev_branch=branch_name,
@@ -819,7 +843,8 @@ def _process_item_locked(
819
843
  time.sleep(5)
820
844
  continue
821
845
 
822
- if final_session_status != "success":
846
+ accepted_with_warning = accepted_with_warning and new_status == "completed"
847
+ if final_session_status != "success" and not accepted_with_warning:
823
848
  commit_final_bookkeeping(status_root, status_family, item_id, new_status)
824
849
  wip = _save_failure_wip(execution_root, family, item_id, new_status, worktree_runtime)
825
850
  if not getattr(wip, "ok", True):
@@ -831,7 +856,7 @@ def _process_item_locked(
831
856
  _emit_warning(f"Could not safely return to {base_branch}; leaving {branch_name} active")
832
857
  return new_status
833
858
 
834
- return _complete_success_merge(
859
+ completed_status = _complete_success_merge(
835
860
  family,
836
861
  item_id,
837
862
  new_status,
@@ -848,6 +873,14 @@ def _process_item_locked(
848
873
  worktree_runtime,
849
874
  classification_fatal_error_code=classification.fatal_error_code,
850
875
  )
876
+ if accepted_with_warning and completed_status == "completed":
877
+ reason = classification.reason or "no_semantic_completion"
878
+ _emit_warning(
879
+ f"{item_id} was accepted with incomplete workflow evidence. "
880
+ f"Reason: {reason}. The task was finalized and merged; "
881
+ "manual review is recommended."
882
+ )
883
+ return completed_status
851
884
  except KeyboardInterrupt as interruption:
852
885
  try:
853
886
  _emit_task_interruption_diagnostics(
@@ -1017,6 +1050,32 @@ def _finalize_prepared_runtime_commit(
1017
1050
  return result
1018
1051
 
1019
1052
 
1053
+ def _finalize_accepted_workflow_skip(
1054
+ execution_root: Path,
1055
+ family: RunnerFamily,
1056
+ item_id: str,
1057
+ prompt: PromptGenerationResult,
1058
+ base_head: str,
1059
+ ) -> RuntimeCommitResult:
1060
+ """Commit accepted task output safely while retaining incomplete evidence."""
1061
+ if prompt.checkpoint_path is None or prompt.artifact_path is None:
1062
+ return RuntimeCommitResult("failed", "accepted_commit_handoff_unavailable")
1063
+ result = finalize_accepted_workspace_commit(
1064
+ execution_root,
1065
+ artifact_dir=prompt.artifact_path,
1066
+ checkpoint_path=prompt.checkpoint_path,
1067
+ base_head=base_head,
1068
+ commit_message=f"chore({item_id}): accept {family.kind} task with workflow warning",
1069
+ )
1070
+ if result.committed:
1071
+ _emit_success(f"Runtime committed accepted task output: {result.commit_hash}")
1072
+ elif result.status == "not_needed":
1073
+ _emit_info(f"Accepted task output required no additional Runtime commit ({result.reason})")
1074
+ else:
1075
+ _emit_warning(f"Accepted task output failed Runtime safety checks: {result.reason}")
1076
+ return result
1077
+
1078
+
1020
1079
  def _is_retryable_ai_outcome(session_status: str, new_status: str) -> bool:
1021
1080
  """Return whether a persisted post-launch outcome should continue in-process."""
1022
1081
  if session_status in {
@@ -214,6 +214,129 @@ def finalize_runtime_commit(
214
214
  return RuntimeCommitResult("committed", "runtime_commit_completed", head, recovered)
215
215
 
216
216
 
217
+ def finalize_accepted_workspace_commit(
218
+ project_root: Path,
219
+ *,
220
+ artifact_dir: Path,
221
+ checkpoint_path: Path,
222
+ base_head: str,
223
+ commit_message: str,
224
+ ) -> RuntimeCommitResult:
225
+ """Safely commit complete task output accepted without semantic completion.
226
+
227
+ The raw checkpoint remains incomplete diagnostic evidence. Only its exact
228
+ causal checkpoint/request paths are excluded from the accepted snapshot.
229
+ Any post-base commit is rejected so the Python Runtime remains the sole
230
+ automated commit owner for this degraded path.
231
+ """
232
+ try:
233
+ root = project_root.resolve()
234
+ artifact = artifact_dir.resolve()
235
+ checkpoint = checkpoint_path.resolve()
236
+ except (OSError, RuntimeError):
237
+ return RuntimeCommitResult("failed", "unsafe_artifact_identity")
238
+ if not _within(artifact, root) or not _within(checkpoint, artifact):
239
+ return RuntimeCommitResult("failed", "unsafe_artifact_identity")
240
+
241
+ request_path = artifact / REQUEST_FILENAME
242
+ current_head = _git(root, "rev-parse", "HEAD")
243
+ base = _git(root, "rev-parse", base_head)
244
+ if current_head.return_code != 0 or base.return_code != 0:
245
+ return RuntimeCommitResult("failed", "git_head_unavailable")
246
+ head = current_head.stdout.strip()
247
+ resolved_base = base.stdout.strip()
248
+ # The Python Runtime remains the sole automated commit owner. A HEAD change
249
+ # after the session base could hide sensitive content in intermediate commit
250
+ # history even when the final tree diff looks safe, so fail closed instead of
251
+ # adopting or merging provider-created commits on this degraded path.
252
+ if head != resolved_base:
253
+ return RuntimeCommitResult("failed", "unexpected_existing_commit")
254
+
255
+ unmerged = _git(root, "ls-files", "-u")
256
+ if unmerged.return_code != 0:
257
+ return RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
258
+ if unmerged.stdout.strip():
259
+ return RuntimeCommitResult("failed", "unresolved_merge_state")
260
+
261
+ changed, status_error = _workspace_changed_paths(
262
+ root,
263
+ checkpoint_path=checkpoint,
264
+ request_path=request_path,
265
+ )
266
+ if status_error:
267
+ return RuntimeCommitResult("failed", status_error)
268
+ if any(_sensitive_commit_path(path) for path in changed):
269
+ return RuntimeCommitResult("failed", "sensitive_workspace_path")
270
+ bookkeeping_staged = _staged_bookkeeping_paths(
271
+ root,
272
+ checkpoint_path=checkpoint,
273
+ request_path=request_path,
274
+ )
275
+ if bookkeeping_staged is None:
276
+ return RuntimeCommitResult("failed", "git_staged_set_unavailable")
277
+ if bookkeeping_staged:
278
+ return RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
279
+ if not changed:
280
+ return RuntimeCommitResult(
281
+ "not_needed",
282
+ "accepted_workspace_clean",
283
+ head,
284
+ )
285
+
286
+ staged = _stage_workspace(
287
+ root,
288
+ checkpoint_path=checkpoint,
289
+ request_path=request_path,
290
+ )
291
+ if staged.return_code != 0:
292
+ return RuntimeCommitResult("failed", "git_stage_failed")
293
+ staged_paths = _git(
294
+ root, "diff", "--cached", "--name-only", "--no-renames", "-z",
295
+ )
296
+ if staged_paths.return_code != 0:
297
+ return RuntimeCommitResult("failed", "git_staged_set_unavailable")
298
+ staged_set = {path for path in staged_paths.stdout.split("\0") if path}
299
+ if staged_set != set(changed):
300
+ return RuntimeCommitResult("failed", "staged_workspace_mismatch")
301
+ unstaged_candidates = _workspace_has_unstaged_candidates(
302
+ root,
303
+ checkpoint_path=checkpoint,
304
+ request_path=request_path,
305
+ )
306
+ if unstaged_candidates is None:
307
+ return RuntimeCommitResult("failed", "git_workspace_verification_failed")
308
+ if unstaged_candidates:
309
+ return RuntimeCommitResult("failed", "workspace_changed_during_staging")
310
+
311
+ committed = _git(
312
+ root,
313
+ "-c", "core.hooksPath=/dev/null",
314
+ "-c", "commit.gpgSign=false",
315
+ "commit", "-m", commit_message,
316
+ )
317
+ if committed.return_code != 0:
318
+ return RuntimeCommitResult("failed", "git_commit_failed")
319
+ new_head_result = _git(root, "rev-parse", "HEAD")
320
+ if new_head_result.return_code != 0:
321
+ return RuntimeCommitResult("failed", "commit_identity_unavailable")
322
+ new_head = new_head_result.stdout.strip()
323
+ parents = _git(root, "show", "-s", "--format=%P", new_head)
324
+ subject = _git(root, "show", "-s", "--format=%s", new_head)
325
+ committed_paths = _git(
326
+ root,
327
+ "diff-tree", "--no-commit-id", "--name-only", "--no-renames", "-r", "-z", new_head,
328
+ )
329
+ if any(result.return_code != 0 for result in (parents, subject, committed_paths)):
330
+ return RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
331
+ if not (
332
+ parents.stdout.strip().split() == [head]
333
+ and subject.stdout.strip() == commit_message
334
+ and {path for path in committed_paths.stdout.split("\0") if path} == staged_set
335
+ ):
336
+ return RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
337
+ return RuntimeCommitResult("committed", "accepted_workspace_committed", new_head)
338
+
339
+
217
340
  def _load_request(
218
341
  request_path: Path,
219
342
  project_root: Path,
@@ -770,10 +770,14 @@ def action_update(args, bug_list_path, state_dir):
770
770
  bs["last_session_id"] = session_id
771
771
 
772
772
  bs["updated_at"] = now_iso()
773
- # Sync resume_from_phase from checkpoint (single source of truth)
774
- _sync_checkpoint_phase(
775
- args.project_root or _default_project_root(), bug_id, bs,
776
- )
773
+ # Completed tasks are terminal even when their accepted checkpoint evidence
774
+ # remains incomplete; only non-completed outcomes expose a resume cursor.
775
+ if new_status == "completed":
776
+ bs["resume_from_phase"] = None
777
+ else:
778
+ _sync_checkpoint_phase(
779
+ args.project_root or _default_project_root(), bug_id, bs,
780
+ )
777
781
 
778
782
  err = save_bug_status(state_dir, bug_id, bs)
779
783
  if err:
@@ -1102,12 +1102,16 @@ def action_update(args, feature_list_path, state_dir):
1102
1102
  fs["last_session_id"] = session_id
1103
1103
 
1104
1104
  fs["updated_at"] = now_iso()
1105
- # Sync resume_from_phase from checkpoint (single source of truth)
1106
- _sync_checkpoint_phase(
1107
- args.project_root or _default_project_root(),
1108
- _get_feature_slug(feature_list_path, feature_id) or feature_id,
1109
- fs,
1110
- )
1105
+ # Completed tasks are terminal even when their accepted checkpoint evidence
1106
+ # remains incomplete; only non-completed outcomes expose a resume cursor.
1107
+ if new_status == "completed":
1108
+ fs["resume_from_phase"] = None
1109
+ else:
1110
+ _sync_checkpoint_phase(
1111
+ args.project_root or _default_project_root(),
1112
+ _get_feature_slug(feature_list_path, feature_id) or feature_id,
1113
+ fs,
1114
+ )
1111
1115
 
1112
1116
  err = save_feature_status(state_dir, feature_id, fs)
1113
1117
  if err:
@@ -675,10 +675,14 @@ def action_update(args, refactor_list_path, state_dir):
675
675
  rs["last_session_id"] = session_id
676
676
 
677
677
  rs["updated_at"] = now_iso()
678
- # Sync resume_from_phase from checkpoint (single source of truth)
679
- _sync_checkpoint_phase(
680
- args.project_root or _default_project_root(), refactor_id, rs,
681
- )
678
+ # Completed tasks are terminal even when their accepted checkpoint evidence
679
+ # remains incomplete; only non-completed outcomes expose a resume cursor.
680
+ if new_status == "completed":
681
+ rs["resume_from_phase"] = None
682
+ else:
683
+ _sync_checkpoint_phase(
684
+ args.project_root or _default_project_root(), refactor_id, rs,
685
+ )
682
686
 
683
687
  err = save_refactor_status(state_dir, refactor_id, rs)
684
688
  if err:
@@ -1301,6 +1301,16 @@ def _install_runner_session_fakes(monkeypatch, runners, *, statuses=("success",)
1301
1301
  monkeypatch.setattr(runners, "commit_pre_branch_bookkeeping", lambda *args, **kwargs: None)
1302
1302
  monkeypatch.setattr(runners, "commit_final_bookkeeping", lambda *args, **kwargs: None)
1303
1303
  monkeypatch.setattr(runners, "commit_task_branch_changes", lambda *args, **kwargs: None)
1304
+ monkeypatch.setattr(
1305
+ runners,
1306
+ "finalize_accepted_workspace_commit",
1307
+ lambda *args, **kwargs: SimpleNamespace(
1308
+ status="not_needed",
1309
+ reason="accepted_workspace_clean",
1310
+ committed=False,
1311
+ commit_hash="",
1312
+ ),
1313
+ )
1304
1314
  monkeypatch.setattr(runners, "current_branch", lambda _root: "main")
1305
1315
  monkeypatch.setattr(runners, "_session_id", lambda item_id: f"{item_id}-session-{len(prompt_calls) + 1}")
1306
1316
  monkeypatch.setattr(
@@ -1398,6 +1408,169 @@ def _install_runner_session_fakes(monkeypatch, runners, *, statuses=("success",)
1398
1408
 
1399
1409
 
1400
1410
 
1411
+ def test_workflow_skipped_is_finalized_as_completed_with_one_warning(monkeypatch, tmp_path, capsys):
1412
+ from prizmkit_runtime import runners
1413
+ from prizmkit_runtime.runner_models import family_for, parse_invocation
1414
+
1415
+ paths = _make_paths(tmp_path / "accepted-workflow-skip")
1416
+ family = family_for("refactor", paths)
1417
+ invocation = parse_invocation(family, "run", ())
1418
+ invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.refactor_plan})
1419
+ observed = _install_runner_session_fakes(
1420
+ monkeypatch,
1421
+ runners,
1422
+ statuses=("workflow_skipped",),
1423
+ update_status="completed",
1424
+ )
1425
+ plans = []
1426
+ wip_calls = []
1427
+ accepted_commit_calls = []
1428
+
1429
+ def fake_accepted_commit(project_root, **kwargs):
1430
+ accepted_commit_calls.append((project_root, kwargs))
1431
+ return SimpleNamespace(
1432
+ status="not_needed",
1433
+ reason="accepted_workspace_clean",
1434
+ committed=False,
1435
+ commit_hash="",
1436
+ )
1437
+
1438
+ def fake_run_git_plan(_project_root, plan):
1439
+ plans.append(plan.name)
1440
+ return SimpleNamespace(ok=True, reason="", results=())
1441
+
1442
+ monkeypatch.setattr(runners, "run_git_plan", fake_run_git_plan)
1443
+ monkeypatch.setattr(runners, "finalize_accepted_workspace_commit", fake_accepted_commit)
1444
+ monkeypatch.setattr(
1445
+ runners,
1446
+ "commit_wip_changes",
1447
+ lambda *args, **kwargs: (wip_calls.append((args, kwargs)) or SimpleNamespace(ok=True)),
1448
+ )
1449
+
1450
+ status = runners._process_item(family, invocation, "R-001", paths, initial_metadata={})
1451
+ captured = capsys.readouterr()
1452
+
1453
+ assert status == "completed"
1454
+ assert plans == ["branch_create", "branch_merge"]
1455
+ assert wip_calls == []
1456
+ assert len(accepted_commit_calls) == 1
1457
+ accepted_root, accepted_kwargs = accepted_commit_calls[0]
1458
+ assert accepted_root == paths.project_root
1459
+ assert accepted_kwargs["base_head"] == "base-head"
1460
+ assert accepted_kwargs["artifact_dir"] == paths.project_root / ".prizmkit" / "specs" / "001-low"
1461
+ assert accepted_kwargs["checkpoint_path"] == accepted_kwargs["artifact_dir"] / "workflow-checkpoint.json"
1462
+ assert "R-001" in accepted_kwargs["commit_message"]
1463
+ assert observed.updates[0][0] == "success"
1464
+ assert "classification_reason" not in observed.updates[0][2]
1465
+ assert "accept_workflow_skipped" not in observed.updates[0][2]
1466
+ session_status = json.loads(
1467
+ (
1468
+ paths.refactor_state_dir
1469
+ / "R-001"
1470
+ / "sessions"
1471
+ / "R-001-session-1"
1472
+ / "session-status.json"
1473
+ ).read_text(encoding="utf-8")
1474
+ )
1475
+ assert session_status["status"] == "workflow_skipped"
1476
+ assert session_status["reason"] == "workflow_skipped"
1477
+ assert captured.err.count("[WARN]") == 1
1478
+ assert captured.err.count("accepted with incomplete workflow evidence") == 1
1479
+ assert "Reason: workflow_skipped" in captured.err
1480
+
1481
+
1482
+ def test_workflow_skipped_uses_successful_worktree_merge_path(monkeypatch, tmp_path, capsys):
1483
+ from prizmkit_runtime import runners
1484
+ from prizmkit_runtime.runner_models import family_for, parse_invocation
1485
+
1486
+ monkeypatch.setenv("USE_WORKTREE", "1")
1487
+ monkeypatch.setenv("DEV_BRANCH", "dev/F-001-accepted")
1488
+ paths = _make_paths(tmp_path / "accepted-worktree-skip")
1489
+ family = family_for("feature", paths)
1490
+ invocation = parse_invocation(family, "run", ())
1491
+ invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.feature_plan})
1492
+ observed = _install_runner_session_fakes(
1493
+ monkeypatch,
1494
+ runners,
1495
+ statuses=("workflow_skipped",),
1496
+ update_status="completed",
1497
+ )
1498
+
1499
+ def fake_setup(runtime):
1500
+ runtime.worktree_path.mkdir(parents=True, exist_ok=True)
1501
+ return SimpleNamespace(ok=True, runtime=runtime, reason="")
1502
+
1503
+ monkeypatch.setattr(runners, "ensure_linked_worktree", fake_setup)
1504
+ monkeypatch.setattr(
1505
+ runners,
1506
+ "materialize_worktree_support_assets",
1507
+ lambda *args, **kwargs: SimpleNamespace(ok=True, reason=""),
1508
+ )
1509
+
1510
+ status = runners._process_item(family, invocation, "F-001", paths, initial_metadata={})
1511
+ captured = capsys.readouterr()
1512
+
1513
+ assert status == "completed"
1514
+ assert observed.updates[0][0] == "success"
1515
+ assert len(observed.merge_calls) == 1
1516
+ assert observed.wip_calls == []
1517
+ assert captured.err.count("[WARN]") == 1
1518
+ assert captured.err.count("accepted with incomplete workflow evidence") == 1
1519
+
1520
+
1521
+ def test_workflow_skipped_safety_failure_stays_hard_without_acceptance_warning(monkeypatch, tmp_path, capsys):
1522
+ from prizmkit_runtime import runners
1523
+ from prizmkit_runtime.runner_models import family_for, parse_invocation
1524
+
1525
+ paths = _make_paths(tmp_path / "rejected-workflow-skip")
1526
+ family = family_for("refactor", paths)
1527
+ invocation = parse_invocation(family, "run", ())
1528
+ invocation = invocation.__class__(**{**invocation.__dict__, "list_path": paths.refactor_plan})
1529
+ observed = _install_runner_session_fakes(
1530
+ monkeypatch,
1531
+ runners,
1532
+ statuses=("workflow_skipped",),
1533
+ update_status="pending",
1534
+ )
1535
+ plans = []
1536
+ wip_calls = []
1537
+
1538
+ monkeypatch.setattr(
1539
+ runners,
1540
+ "finalize_accepted_workspace_commit",
1541
+ lambda *args, **kwargs: SimpleNamespace(
1542
+ status="not_ready",
1543
+ reason="accepted_workspace_not_finalized",
1544
+ committed=False,
1545
+ commit_hash="",
1546
+ ),
1547
+ )
1548
+ monkeypatch.setattr(
1549
+ runners,
1550
+ "run_git_plan",
1551
+ lambda _root, plan: (plans.append(plan.name) or SimpleNamespace(ok=True, reason="", results=())),
1552
+ )
1553
+ monkeypatch.setattr(
1554
+ runners,
1555
+ "commit_wip_changes",
1556
+ lambda *args, **kwargs: (wip_calls.append((args, kwargs)) or SimpleNamespace(ok=True)),
1557
+ )
1558
+ monkeypatch.setattr(
1559
+ runners,
1560
+ "branch_ensure_return",
1561
+ lambda *args, **kwargs: SimpleNamespace(ok=True),
1562
+ )
1563
+
1564
+ status = runners._process_item(family, invocation, "R-001", paths, initial_metadata={})
1565
+ captured = capsys.readouterr()
1566
+
1567
+ assert status == "pending"
1568
+ assert plans == ["branch_create"]
1569
+ assert len(wip_calls) == 1
1570
+ assert observed.updates[0][0] == "commit_missing"
1571
+ assert "accepted with incomplete workflow evidence" not in captured.err
1572
+
1573
+
1401
1574
  def test_runner_launch_config_preserves_artifact_paths_live_output_and_split_thresholds(monkeypatch, tmp_path):
1402
1575
  from prizmkit_runtime import runners
1403
1576
  from prizmkit_runtime.runner_models import family_for, parse_invocation
@@ -4231,7 +4404,7 @@ def test_terminal_success_text_does_not_hide_provider_failure(tmp_path):
4231
4404
  ("kind", "item_id"),
4232
4405
  [("feature", "F-001"), ("bugfix", "B-001"), ("refactor", "R-001")],
4233
4406
  )
4234
- def test_family_status_skips_semantic_completion_failure_without_retry_spend(
4407
+ def test_family_success_completion_is_terminal_without_warning_metadata(
4235
4408
  tmp_path, kind, item_id
4236
4409
  ):
4237
4410
  from prizmkit_runtime.runner_models import family_for, parse_invocation
@@ -4259,7 +4432,7 @@ def test_family_status_skips_semantic_completion_failure_without_retry_spend(
4259
4432
  family,
4260
4433
  invocation,
4261
4434
  item_id,
4262
- "workflow_skipped",
4435
+ "success",
4263
4436
  "session-1",
4264
4437
  paths.project_root,
4265
4438
  checkpoint_state={},
@@ -4267,12 +4440,54 @@ def test_family_status_skips_semantic_completion_failure_without_retry_spend(
4267
4440
  status = json.loads((family.state_dir / item_id / "status.json").read_text(encoding="utf-8"))
4268
4441
 
4269
4442
  assert result.ok is True
4270
- assert result.data["new_status"] == "skipped"
4271
- assert result.data["restart_policy"] == "terminal_skipped"
4443
+ assert result.data["new_status"] == "completed"
4272
4444
  assert status["retry_count"] == 0
4273
4445
  assert status["infra_error_count"] == 0
4274
- assert status["needs_attention"] is True
4275
- assert status["skipped_reason"] == "workflow_completion_evidence_invalid"
4446
+ assert "completion_warning" not in status
4447
+ assert "completion_warning_reason" not in status
4448
+ assert status["resume_from_phase"] is None
4449
+
4450
+
4451
+ @pytest.mark.parametrize(
4452
+ ("kind", "item_id"),
4453
+ [("feature", "F-001"), ("bugfix", "B-001"), ("refactor", "R-001")],
4454
+ )
4455
+ def test_family_status_preserves_direct_raw_workflow_skip(
4456
+ tmp_path, kind, item_id
4457
+ ):
4458
+ from prizmkit_runtime.runner_models import family_for, parse_invocation
4459
+ from prizmkit_runtime.runner_status import start_item, update_item
4460
+
4461
+ paths = _make_paths(tmp_path / f"historical-{kind}")
4462
+ item = {
4463
+ "id": item_id,
4464
+ "title": "Historical workflow skip",
4465
+ "status": "pending",
4466
+ "priority": "high",
4467
+ "dependencies": [],
4468
+ }
4469
+ if kind == "bugfix":
4470
+ item.update(severity="high", description="invalid evidence", reproduction_steps=["run"])
4471
+ elif kind == "refactor":
4472
+ item.update(description="invalid evidence", targets=["src"], goals=["preserve"])
4473
+ _write_family_plan(paths, kind, [item])
4474
+ family = family_for(kind, paths)
4475
+ invocation = parse_invocation(family, "run", ())
4476
+ invocation = invocation.__class__(**{**invocation.__dict__, "list_path": family.plan_path})
4477
+ assert start_item(family, invocation, item_id, paths.project_root).ok is True
4478
+
4479
+ result = update_item(
4480
+ family,
4481
+ invocation,
4482
+ item_id,
4483
+ "workflow_skipped",
4484
+ "historical-session",
4485
+ paths.project_root,
4486
+ )
4487
+
4488
+ assert result.ok is True
4489
+ assert result.data["new_status"] == "skipped"
4490
+ assert result.data["restart_policy"] == "terminal_skipped"
4276
4491
 
4277
4492
 
4278
4493
  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 finalize_runtime_commit
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)
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.161",
2
+ "version": "1.1.162",
3
3
  "skills": {
4
4
  "prizmkit": {
5
5
  "description": "Framework introduction and navigation for the formal single-requirement lifecycle, project initialization, Prizm docs, and independent deployment.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizmkit",
3
- "version": "1.1.161",
3
+ "version": "1.1.162",
4
4
  "description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
5
5
  "type": "module",
6
6
  "bin": {