prizmkit 1.1.160 → 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.
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/README.md +3 -1
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -6
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +63 -4
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +268 -110
- package/bundled/dev-pipeline/scripts/update-bug-status.py +8 -4
- package/bundled/dev-pipeline/scripts/update-feature-status.py +10 -6
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +8 -4
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +2 -2
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +9 -15
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +8 -5
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +4 -2
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +4 -2
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +221 -6
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +308 -67
- package/bundled/dev-pipeline/tests/test_unified_cli.py +172 -4
- package/bundled/rules/prizm/prizm-commit-workflow.md +12 -5
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +5 -5
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +4 -5
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +4 -6
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +1 -4
- package/bundled/skills/prizmkit-committer/SKILL.md +47 -63
- package/bundled/skills/prizmkit-test/SKILL.md +2 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +1 -1
- package/bundled/skills/prizmkit-workflow/SKILL.md +4 -6
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +10 -8
- package/package.json +1 -1
|
@@ -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:
|
|
@@ -171,16 +174,15 @@ def _write_commit_ready_checkpoint(root: Path) -> tuple[Path, Path]:
|
|
|
171
174
|
return artifact_dir, checkpoint_path
|
|
172
175
|
|
|
173
176
|
|
|
174
|
-
def _write_request(root: Path, artifact_dir: Path, base_head: str
|
|
177
|
+
def _write_request(root: Path, artifact_dir: Path, base_head: str) -> Path:
|
|
175
178
|
request_path = artifact_dir / "runtime-commit-request.json"
|
|
176
179
|
request_path.write_text(
|
|
177
180
|
json.dumps(
|
|
178
181
|
{
|
|
179
|
-
"schema_version":
|
|
182
|
+
"schema_version": 2,
|
|
180
183
|
"artifact_dir": artifact_dir.relative_to(root).as_posix(),
|
|
181
184
|
"base_head": base_head,
|
|
182
185
|
"commit_message": "fix(runtime): finalize prepared task",
|
|
183
|
-
"intended_paths": paths,
|
|
184
186
|
}
|
|
185
187
|
),
|
|
186
188
|
encoding="utf-8",
|
|
@@ -188,7 +190,7 @@ def _write_request(root: Path, artifact_dir: Path, base_head: str, paths: list[s
|
|
|
188
190
|
return request_path
|
|
189
191
|
|
|
190
192
|
|
|
191
|
-
def
|
|
193
|
+
def test_runtime_commit_executes_complete_workspace_and_finalizes_only_checkpoint(tmp_path):
|
|
192
194
|
base_head = _init_repo(tmp_path)
|
|
193
195
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
194
196
|
caller_state = tmp_path / ".prizmkit" / "state" / "workflows" / "caller.json"
|
|
@@ -196,7 +198,7 @@ def test_runtime_commit_executes_exact_request_and_finalizes_only_checkpoint(tmp
|
|
|
196
198
|
caller_state.write_text('{"owner":"external-coordinator"}\n', encoding="utf-8")
|
|
197
199
|
expected_caller_state = caller_state.read_bytes()
|
|
198
200
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
199
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
201
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
200
202
|
|
|
201
203
|
result = finalize_runtime_commit(
|
|
202
204
|
tmp_path,
|
|
@@ -229,7 +231,7 @@ def test_runtime_commit_executes_exact_request_and_finalizes_only_checkpoint(tmp
|
|
|
229
231
|
".prizmkit/prizm-docs/src/counter.prizm",
|
|
230
232
|
],
|
|
231
233
|
)
|
|
232
|
-
def
|
|
234
|
+
def test_runtime_commit_includes_tracked_prizmkit_path_from_workspace(tmp_path, durable_path):
|
|
233
235
|
_init_repo(tmp_path)
|
|
234
236
|
durable = tmp_path / durable_path
|
|
235
237
|
durable.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -240,7 +242,7 @@ def test_runtime_commit_admits_tracked_prizmkit_path_in_exact_request(tmp_path,
|
|
|
240
242
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
241
243
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
242
244
|
durable.write_text("after\n", encoding="utf-8")
|
|
243
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
245
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
244
246
|
|
|
245
247
|
result = finalize_runtime_commit(
|
|
246
248
|
tmp_path,
|
|
@@ -261,7 +263,7 @@ def test_runtime_commit_admits_tracked_prizmkit_path_in_exact_request(tmp_path,
|
|
|
261
263
|
assert durable.read_text(encoding="utf-8") == "after\n"
|
|
262
264
|
|
|
263
265
|
|
|
264
|
-
def
|
|
266
|
+
def test_runtime_commit_includes_valid_host_support_paths_from_workspace(tmp_path):
|
|
265
267
|
base_head = _init_repo(tmp_path)
|
|
266
268
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
267
269
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
@@ -269,7 +271,7 @@ def test_runtime_commit_ignores_runner_support_paths_but_leaves_them_unmodified(
|
|
|
269
271
|
codex_config = tmp_path / ".codex" / "config.toml"
|
|
270
272
|
codex_config.parent.mkdir()
|
|
271
273
|
codex_config.write_text("[project]\ntrusted = true\n", encoding="utf-8")
|
|
272
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
274
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
273
275
|
|
|
274
276
|
result = finalize_runtime_commit(
|
|
275
277
|
tmp_path,
|
|
@@ -278,11 +280,11 @@ def test_runtime_commit_ignores_runner_support_paths_but_leaves_them_unmodified(
|
|
|
278
280
|
)
|
|
279
281
|
|
|
280
282
|
assert result.status == "committed"
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
assert
|
|
283
|
+
changed = set(
|
|
284
|
+
_git(tmp_path, "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD").splitlines()
|
|
285
|
+
)
|
|
286
|
+
assert changed == {"tracked.txt", "AGENTS.md", ".codex/config.toml"}
|
|
287
|
+
assert _git(tmp_path, "status", "--porcelain") == ""
|
|
286
288
|
|
|
287
289
|
|
|
288
290
|
def test_runtime_commit_allows_task_path_adjacent_to_internal_namespace(tmp_path):
|
|
@@ -291,7 +293,7 @@ def test_runtime_commit_allows_task_path_adjacent_to_internal_namespace(tmp_path
|
|
|
291
293
|
adjacent_path = tmp_path / ".prizmkitx" / "task.txt"
|
|
292
294
|
adjacent_path.parent.mkdir()
|
|
293
295
|
adjacent_path.write_text("task-owned\n", encoding="utf-8")
|
|
294
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
296
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
295
297
|
|
|
296
298
|
result = finalize_runtime_commit(
|
|
297
299
|
tmp_path,
|
|
@@ -315,7 +317,7 @@ def test_runtime_commit_ignores_project_gitignored_transient_data(tmp_path):
|
|
|
315
317
|
transient = tmp_path / "tmp" / "tool-cache.json"
|
|
316
318
|
transient.parent.mkdir()
|
|
317
319
|
transient.write_text('{"cache":true}\n', encoding="utf-8")
|
|
318
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
320
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
319
321
|
|
|
320
322
|
result = finalize_runtime_commit(
|
|
321
323
|
tmp_path,
|
|
@@ -328,12 +330,12 @@ def test_runtime_commit_ignores_project_gitignored_transient_data(tmp_path):
|
|
|
328
330
|
assert transient.read_text(encoding="utf-8") == '{"cache":true}\n'
|
|
329
331
|
|
|
330
332
|
|
|
331
|
-
def
|
|
333
|
+
def test_runtime_commit_includes_preexisting_git_visible_change_without_manifest(tmp_path):
|
|
332
334
|
base_head = _init_repo(tmp_path)
|
|
333
335
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
334
336
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
335
|
-
(tmp_path / "
|
|
336
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
337
|
+
(tmp_path / "preexisting.txt").write_text("validated existing work\n", encoding="utf-8")
|
|
338
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
337
339
|
|
|
338
340
|
result = finalize_runtime_commit(
|
|
339
341
|
tmp_path,
|
|
@@ -341,16 +343,18 @@ def test_runtime_commit_rejects_unlisted_git_visible_change(tmp_path):
|
|
|
341
343
|
checkpoint_path=checkpoint_path,
|
|
342
344
|
)
|
|
343
345
|
|
|
344
|
-
assert result.status == "
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
assert result.status == "committed"
|
|
347
|
+
changed = set(
|
|
348
|
+
_git(tmp_path, "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD").splitlines()
|
|
349
|
+
)
|
|
350
|
+
assert changed == {"tracked.txt", "preexisting.txt"}
|
|
347
351
|
|
|
348
352
|
|
|
349
353
|
def test_runtime_commit_recovers_commit_created_before_state_finalization(tmp_path):
|
|
350
354
|
base_head = _init_repo(tmp_path)
|
|
351
355
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
352
356
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
353
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
357
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
354
358
|
_git(tmp_path, "add", "tracked.txt")
|
|
355
359
|
_git(tmp_path, "commit", "-m", "fix(runtime): finalize prepared task")
|
|
356
360
|
committed_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
@@ -367,15 +371,38 @@ def test_runtime_commit_recovers_commit_created_before_state_finalization(tmp_pa
|
|
|
367
371
|
assert _git(tmp_path, "rev-list", "--count", f"{base_head}..HEAD") == "1"
|
|
368
372
|
|
|
369
373
|
|
|
374
|
+
def test_runtime_commit_rejects_recovery_commit_containing_causal_bookkeeping(tmp_path):
|
|
375
|
+
base_head = _init_repo(tmp_path)
|
|
376
|
+
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
377
|
+
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
378
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
379
|
+
_git(
|
|
380
|
+
tmp_path,
|
|
381
|
+
"add",
|
|
382
|
+
"-f",
|
|
383
|
+
"tracked.txt",
|
|
384
|
+
checkpoint_path.relative_to(tmp_path).as_posix(),
|
|
385
|
+
request_path.relative_to(tmp_path).as_posix(),
|
|
386
|
+
)
|
|
387
|
+
_git(tmp_path, "commit", "-m", "fix(runtime): finalize prepared task")
|
|
388
|
+
|
|
389
|
+
result = finalize_runtime_commit(
|
|
390
|
+
tmp_path,
|
|
391
|
+
artifact_dir=artifact_dir,
|
|
392
|
+
checkpoint_path=checkpoint_path,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
assert result.status == "failed"
|
|
396
|
+
assert result.reason == "base_head_mismatch"
|
|
397
|
+
|
|
398
|
+
|
|
370
399
|
def test_runtime_commit_recovers_after_checkpoint_finalization_failure(tmp_path, monkeypatch):
|
|
371
400
|
import prizmkit_runtime.runtime_commit as runtime_commit
|
|
372
401
|
|
|
373
402
|
base_head = _init_repo(tmp_path)
|
|
374
403
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
375
404
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
376
|
-
request_path = _write_request(
|
|
377
|
-
tmp_path, artifact_dir, base_head, ["tracked.txt"]
|
|
378
|
-
)
|
|
405
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
379
406
|
|
|
380
407
|
original_finalize = runtime_commit._finalize_checkpoint
|
|
381
408
|
monkeypatch.setattr(
|
|
@@ -412,9 +439,7 @@ def test_runtime_commit_recovers_cleanup_after_completed_checkpoint(tmp_path, mo
|
|
|
412
439
|
base_head = _init_repo(tmp_path)
|
|
413
440
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
414
441
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
415
|
-
request_path = _write_request(
|
|
416
|
-
tmp_path, artifact_dir, base_head, ["tracked.txt"]
|
|
417
|
-
)
|
|
442
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
418
443
|
|
|
419
444
|
original_unlink = Path.unlink
|
|
420
445
|
|
|
@@ -457,7 +482,7 @@ def test_runtime_commit_disables_repository_hooks(tmp_path):
|
|
|
457
482
|
)
|
|
458
483
|
hook.chmod(0o755)
|
|
459
484
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
460
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
485
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
461
486
|
|
|
462
487
|
result = finalize_runtime_commit(
|
|
463
488
|
tmp_path,
|
|
@@ -479,12 +504,7 @@ def test_runtime_commit_handles_rename_as_exact_delete_and_add(tmp_path):
|
|
|
479
504
|
base_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
480
505
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
481
506
|
old_path.rename(tmp_path / "new-name.txt")
|
|
482
|
-
_write_request(
|
|
483
|
-
tmp_path,
|
|
484
|
-
artifact_dir,
|
|
485
|
-
base_head,
|
|
486
|
-
["old-name.txt", "new-name.txt"],
|
|
487
|
-
)
|
|
507
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
488
508
|
|
|
489
509
|
result = finalize_runtime_commit(
|
|
490
510
|
tmp_path,
|
|
@@ -508,27 +528,229 @@ def test_runtime_commit_handles_rename_as_exact_delete_and_add(tmp_path):
|
|
|
508
528
|
@pytest.mark.parametrize(
|
|
509
529
|
"unsafe_path",
|
|
510
530
|
[
|
|
511
|
-
"../escape.txt",
|
|
512
|
-
".git/config",
|
|
513
531
|
".env",
|
|
514
|
-
"
|
|
515
|
-
"
|
|
516
|
-
".
|
|
517
|
-
".
|
|
518
|
-
".prizmkit/prizm-docs/.env",
|
|
519
|
-
".prizmkit/state/runtime.json",
|
|
520
|
-
".prizmkit/dev-pipeline/cli.py",
|
|
521
|
-
".prizmkit/scripts/helper.py",
|
|
522
|
-
".prizmkit/manifest.json",
|
|
523
|
-
".prizmkit/specs/001-runtime-commit/workflow-checkpoint.json",
|
|
524
|
-
".prizmkit/specs/001-runtime-commit/runtime-commit-request.json",
|
|
532
|
+
"credentials.json",
|
|
533
|
+
"secrets.json",
|
|
534
|
+
"private.pem",
|
|
535
|
+
".codex/settings.local.json",
|
|
525
536
|
],
|
|
526
537
|
)
|
|
527
|
-
def
|
|
538
|
+
def test_runtime_commit_rejects_sensitive_git_visible_workspace_path(tmp_path, unsafe_path):
|
|
539
|
+
base_head = _init_repo(tmp_path)
|
|
540
|
+
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
541
|
+
unsafe = tmp_path / unsafe_path
|
|
542
|
+
unsafe.parent.mkdir(parents=True, exist_ok=True)
|
|
543
|
+
unsafe.write_text("sensitive\n", encoding="utf-8")
|
|
544
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
545
|
+
|
|
546
|
+
result = finalize_runtime_commit(
|
|
547
|
+
tmp_path,
|
|
548
|
+
artifact_dir=artifact_dir,
|
|
549
|
+
checkpoint_path=checkpoint_path,
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
assert result.status == "failed"
|
|
553
|
+
assert result.reason == "sensitive_workspace_path"
|
|
554
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
555
|
+
|
|
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
|
+
|
|
691
|
+
def test_runtime_commit_rejects_empty_workspace(tmp_path):
|
|
692
|
+
base_head = _init_repo(tmp_path)
|
|
693
|
+
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
694
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
695
|
+
|
|
696
|
+
result = finalize_runtime_commit(
|
|
697
|
+
tmp_path,
|
|
698
|
+
artifact_dir=artifact_dir,
|
|
699
|
+
checkpoint_path=checkpoint_path,
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
assert result.status == "failed"
|
|
703
|
+
assert result.reason == "empty_workspace_change"
|
|
704
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def test_runtime_commit_rejects_unresolved_merge_state(tmp_path):
|
|
708
|
+
_init_repo(tmp_path)
|
|
709
|
+
initial_branch = _git(tmp_path, "branch", "--show-current")
|
|
710
|
+
_git(tmp_path, "checkout", "-b", "other")
|
|
711
|
+
(tmp_path / "tracked.txt").write_text("other\n", encoding="utf-8")
|
|
712
|
+
_git(tmp_path, "add", "tracked.txt")
|
|
713
|
+
_git(tmp_path, "commit", "-m", "other change")
|
|
714
|
+
_git(tmp_path, "checkout", initial_branch)
|
|
715
|
+
(tmp_path / "tracked.txt").write_text("master\n", encoding="utf-8")
|
|
716
|
+
_git(tmp_path, "add", "tracked.txt")
|
|
717
|
+
_git(tmp_path, "commit", "-m", "master change")
|
|
718
|
+
base_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
719
|
+
merged = subprocess.run(
|
|
720
|
+
["git", "merge", "other"],
|
|
721
|
+
cwd=tmp_path,
|
|
722
|
+
stdout=subprocess.PIPE,
|
|
723
|
+
stderr=subprocess.PIPE,
|
|
724
|
+
text=True,
|
|
725
|
+
check=False,
|
|
726
|
+
)
|
|
727
|
+
assert merged.returncode != 0
|
|
728
|
+
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
729
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
730
|
+
|
|
731
|
+
result = finalize_runtime_commit(
|
|
732
|
+
tmp_path,
|
|
733
|
+
artifact_dir=artifact_dir,
|
|
734
|
+
checkpoint_path=checkpoint_path,
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
assert result.status == "failed"
|
|
738
|
+
assert result.reason == "unresolved_merge_state"
|
|
739
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def test_runtime_commit_rejects_already_staged_runtime_bookkeeping(tmp_path):
|
|
528
743
|
base_head = _init_repo(tmp_path)
|
|
529
744
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
530
745
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
531
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
746
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
747
|
+
_git(
|
|
748
|
+
tmp_path,
|
|
749
|
+
"add",
|
|
750
|
+
"-f",
|
|
751
|
+
checkpoint_path.relative_to(tmp_path).as_posix(),
|
|
752
|
+
request_path.relative_to(tmp_path).as_posix(),
|
|
753
|
+
)
|
|
532
754
|
|
|
533
755
|
result = finalize_runtime_commit(
|
|
534
756
|
tmp_path,
|
|
@@ -537,11 +759,32 @@ def test_runtime_commit_rejects_unsafe_intended_paths(tmp_path, unsafe_path):
|
|
|
537
759
|
)
|
|
538
760
|
|
|
539
761
|
assert result.status == "failed"
|
|
540
|
-
assert result.reason == "
|
|
762
|
+
assert result.reason == "runtime_bookkeeping_staged"
|
|
541
763
|
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
542
764
|
|
|
543
765
|
|
|
544
|
-
def
|
|
766
|
+
def test_runtime_commit_rejects_schema_v1_path_manifest(tmp_path):
|
|
767
|
+
base_head = _init_repo(tmp_path)
|
|
768
|
+
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
769
|
+
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
770
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
771
|
+
request = json.loads(request_path.read_text(encoding="utf-8"))
|
|
772
|
+
request["schema_version"] = 1
|
|
773
|
+
request["intended_paths"] = ["tracked.txt"]
|
|
774
|
+
request_path.write_text(json.dumps(request), encoding="utf-8")
|
|
775
|
+
|
|
776
|
+
result = finalize_runtime_commit(
|
|
777
|
+
tmp_path,
|
|
778
|
+
artifact_dir=artifact_dir,
|
|
779
|
+
checkpoint_path=checkpoint_path,
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
assert result.status == "failed"
|
|
783
|
+
assert result.reason == "commit_request_invalid_schema"
|
|
784
|
+
assert _git(tmp_path, "rev-parse", "HEAD") == base_head
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
def test_runtime_commit_includes_already_staged_and_unstaged_workspace(tmp_path):
|
|
545
788
|
_init_repo(tmp_path)
|
|
546
789
|
support = tmp_path / "AGENTS.md"
|
|
547
790
|
support.write_text("before\n", encoding="utf-8")
|
|
@@ -552,7 +795,7 @@ def test_runtime_commit_verifies_staged_set_before_commit(tmp_path):
|
|
|
552
795
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
553
796
|
support.write_text("after\n", encoding="utf-8")
|
|
554
797
|
_git(tmp_path, "add", "AGENTS.md")
|
|
555
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
798
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
556
799
|
|
|
557
800
|
result = finalize_runtime_commit(
|
|
558
801
|
tmp_path,
|
|
@@ -560,9 +803,11 @@ def test_runtime_commit_verifies_staged_set_before_commit(tmp_path):
|
|
|
560
803
|
checkpoint_path=checkpoint_path,
|
|
561
804
|
)
|
|
562
805
|
|
|
563
|
-
assert result.status == "
|
|
564
|
-
|
|
565
|
-
|
|
806
|
+
assert result.status == "committed"
|
|
807
|
+
changed = set(
|
|
808
|
+
_git(tmp_path, "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD").splitlines()
|
|
809
|
+
)
|
|
810
|
+
assert changed == {"AGENTS.md", "tracked.txt"}
|
|
566
811
|
|
|
567
812
|
|
|
568
813
|
def test_runtime_commit_keeps_tracked_post_commit_bookkeeping_out_of_snapshot(tmp_path):
|
|
@@ -570,13 +815,13 @@ def test_runtime_commit_keeps_tracked_post_commit_bookkeeping_out_of_snapshot(tm
|
|
|
570
815
|
|
|
571
816
|
initial_head = _init_repo(tmp_path)
|
|
572
817
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
573
|
-
request_path = _write_request(tmp_path, artifact_dir, initial_head
|
|
818
|
+
request_path = _write_request(tmp_path, artifact_dir, initial_head)
|
|
574
819
|
checkpoint_rel = checkpoint_path.relative_to(tmp_path).as_posix()
|
|
575
820
|
request_rel = request_path.relative_to(tmp_path).as_posix()
|
|
576
821
|
_git(tmp_path, "add", "-f", checkpoint_rel, request_rel)
|
|
577
822
|
_git(tmp_path, "commit", "-m", "track runtime bookkeeping by project policy")
|
|
578
823
|
base_head = _git(tmp_path, "rev-parse", "HEAD")
|
|
579
|
-
_write_request(tmp_path, artifact_dir, base_head
|
|
824
|
+
_write_request(tmp_path, artifact_dir, base_head)
|
|
580
825
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
581
826
|
|
|
582
827
|
result = finalize_runtime_commit(
|
|
@@ -606,9 +851,7 @@ def test_runtime_commit_rejects_caller_orchestration_fields(tmp_path):
|
|
|
606
851
|
base_head = _init_repo(tmp_path)
|
|
607
852
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
608
853
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
609
|
-
request_path = _write_request(
|
|
610
|
-
tmp_path, artifact_dir, base_head, ["tracked.txt"]
|
|
611
|
-
)
|
|
854
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
612
855
|
request = json.loads(request_path.read_text(encoding="utf-8"))
|
|
613
856
|
request["caller_state_path"] = ".runtime/caller-state.json"
|
|
614
857
|
request_path.write_text(json.dumps(request), encoding="utf-8")
|
|
@@ -628,9 +871,7 @@ def test_runtime_commit_rejects_ai_supplied_premature_runtime_hash(tmp_path):
|
|
|
628
871
|
base_head = _init_repo(tmp_path)
|
|
629
872
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
630
873
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
631
|
-
request_path = _write_request(
|
|
632
|
-
tmp_path, artifact_dir, base_head, ["tracked.txt"]
|
|
633
|
-
)
|
|
874
|
+
request_path = _write_request(tmp_path, artifact_dir, base_head)
|
|
634
875
|
request = json.loads(request_path.read_text(encoding="utf-8"))
|
|
635
876
|
request["runtime_commit_hash"] = "a" * 40
|
|
636
877
|
request_path.write_text(json.dumps(request), encoding="utf-8")
|
|
@@ -650,7 +891,7 @@ def test_runtime_commit_rejects_stale_base_head(tmp_path):
|
|
|
650
891
|
base_head = _init_repo(tmp_path)
|
|
651
892
|
artifact_dir, checkpoint_path = _write_commit_ready_checkpoint(tmp_path)
|
|
652
893
|
(tmp_path / "tracked.txt").write_text("after\n", encoding="utf-8")
|
|
653
|
-
_write_request(tmp_path, artifact_dir, "a" * 40
|
|
894
|
+
_write_request(tmp_path, artifact_dir, "a" * 40)
|
|
654
895
|
|
|
655
896
|
result = finalize_runtime_commit(
|
|
656
897
|
tmp_path,
|