prizmkit 1.1.191 → 1.1.193
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/adapters/antigravity/skill-adapter.js +13 -4
- package/bundled/adapters/codex/skill-adapter.js +28 -8
- package/bundled/adapters/cursor/skill-adapter.js +13 -4
- package/bundled/adapters/pi/skill-adapter.js +28 -7
- package/bundled/dev-pipeline/.env.example +4 -12
- package/bundled/dev-pipeline/README.md +28 -44
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -6
- package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +48 -78
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +540 -262
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
- package/bundled/dev-pipeline/scripts/continuation.py +8 -7
- package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
- package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
- package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
- package/bundled/dev-pipeline/scripts/prompt_framework.py +85 -20
- package/bundled/dev-pipeline/scripts/status_common.py +591 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +254 -65
- package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
- package/bundled/dev-pipeline/scripts/utils.py +5 -12
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -5
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
- package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
- package/bundled/skills/_metadata.json +9 -63
- package/bundled/skills/app-planner/SKILL.md +32 -303
- package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
- package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
- package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
- package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
- package/bundled/skills/bug-planner/SKILL.md +54 -435
- package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/bug-planner/references/input-formats.md +32 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-planner/SKILL.md +60 -439
- package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
- package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
- package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
- package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
- package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
- package/bundled/skills/feature-workflow/SKILL.md +1 -2
- package/bundled/skills/prizmkit/SKILL.md +7 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +24 -127
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
- package/bundled/skills/prizmkit-test/SKILL.md +25 -133
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
- package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
- package/bundled/skills/recovery-workflow/SKILL.md +7 -7
- package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
- package/bundled/skills/recovery-workflow/references/detection.md +1 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
- package/bundled/templates/project-memory-template.md +1 -2
- package/package.json +1 -1
- package/src/scaffold.js +28 -7
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
- package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
- package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
- package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
- package/bundled/dev-pipeline/tests/conftest.py +0 -29
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
- package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
- package/bundled/skills/refactor-planner/SKILL.md +0 -467
- package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
- package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
- package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
- package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
- package/bundled/skills/refactor-workflow/SKILL.md +0 -205
|
@@ -6,32 +6,26 @@ import copy
|
|
|
6
6
|
import json
|
|
7
7
|
import os
|
|
8
8
|
import shlex
|
|
9
|
-
import shutil
|
|
10
|
-
import tempfile
|
|
11
9
|
import time
|
|
12
10
|
from contextlib import ExitStack
|
|
13
11
|
from dataclasses import dataclass
|
|
14
12
|
from pathlib import Path
|
|
15
13
|
from typing import Any
|
|
16
14
|
|
|
15
|
+
from .atomic_io import write_json_atomic
|
|
17
16
|
from .checkpoint_state import (
|
|
18
17
|
load_checkpoint_state,
|
|
19
18
|
rewind_checkpoint_for_implementation,
|
|
20
19
|
)
|
|
21
20
|
from .gitops import (
|
|
22
|
-
BranchContext,
|
|
23
|
-
WorktreePolicy,
|
|
24
|
-
WorktreeRuntimeContext,
|
|
25
21
|
create_branch_from_base,
|
|
26
|
-
ensure_linked_worktree,
|
|
27
22
|
local_branch_exists,
|
|
28
23
|
registered_worktrees,
|
|
29
|
-
|
|
24
|
+
safe_task_branch_prefix,
|
|
30
25
|
)
|
|
31
26
|
from .runner_models import RunnerFamily
|
|
32
27
|
from .task_checkout import (
|
|
33
28
|
CHECKOUT_MODE_BRANCH,
|
|
34
|
-
CHECKOUT_MODE_WORKTREE,
|
|
35
29
|
TaskCheckout,
|
|
36
30
|
TaskCheckoutError,
|
|
37
31
|
load_task_checkout,
|
|
@@ -71,7 +65,6 @@ class RootRecovery:
|
|
|
71
65
|
status_path: Path
|
|
72
66
|
status_data: dict[str, Any]
|
|
73
67
|
replacement_checkout: TaskCheckout | None = None
|
|
74
|
-
replacement_worktree: WorktreeRuntimeContext | None = None
|
|
75
68
|
source_artifact: Path | None = None
|
|
76
69
|
target_artifact: Path | None = None
|
|
77
70
|
checkpoint_target: Path | None = None
|
|
@@ -98,7 +91,7 @@ class PreserveRuntimeResetResult:
|
|
|
98
91
|
if self.no_targets:
|
|
99
92
|
return (
|
|
100
93
|
f"No failed {family.kind} tasks require preserve-runtime recovery.",
|
|
101
|
-
"No plan, status, checkout, checkpoint, branch,
|
|
94
|
+
"No plan, status, checkout, checkpoint, branch, session, or artifact state changed.",
|
|
102
95
|
)
|
|
103
96
|
if not self.ok:
|
|
104
97
|
return (
|
|
@@ -123,7 +116,7 @@ class PreserveRuntimeResetResult:
|
|
|
123
116
|
lines.append(f"Replacement checkout: {item_id}: {old_branch} -> {new_branch}")
|
|
124
117
|
lines.extend(
|
|
125
118
|
(
|
|
126
|
-
"Existing sessions, checkpoints, artifacts, branches,
|
|
119
|
+
"Existing sessions, checkpoints, artifacts, branches, and task work were not deleted.",
|
|
127
120
|
"Reset did not start a runner. Run separately:",
|
|
128
121
|
"python3 ./.prizmkit/dev-pipeline/cli.py "
|
|
129
122
|
f"run {family.kind} {shlex.quote(str(list_path))}",
|
|
@@ -400,40 +393,7 @@ def _preflight_root(
|
|
|
400
393
|
if registration.branch == checkout.active_dev_branch
|
|
401
394
|
]
|
|
402
395
|
execution_root = project_root
|
|
403
|
-
|
|
404
|
-
if checkout.checkout_mode == CHECKOUT_MODE_WORKTREE:
|
|
405
|
-
recorded_worktree = Path(checkout.worktree_path).resolve()
|
|
406
|
-
old_runtime = worktree_runtime_context(
|
|
407
|
-
BranchContext(
|
|
408
|
-
checkout.base_branch,
|
|
409
|
-
checkout.active_dev_branch,
|
|
410
|
-
project_root,
|
|
411
|
-
),
|
|
412
|
-
WorktreePolicy(True, True, True, recorded_worktree.parent),
|
|
413
|
-
)
|
|
414
|
-
if not old_runtime.is_cleanup_path_safe() or old_runtime.worktree_path != recorded_worktree:
|
|
415
|
-
blockers.append(
|
|
416
|
-
f"{item.item_id}: recorded worktree path is unsafe or inconsistent: {recorded_worktree}"
|
|
417
|
-
)
|
|
418
|
-
execution_root = recorded_worktree
|
|
419
|
-
if branch_exists:
|
|
420
|
-
if not recorded_worktree.is_dir():
|
|
421
|
-
blockers.append(
|
|
422
|
-
f"{item.item_id}: recorded worktree directory is missing: {recorded_worktree}"
|
|
423
|
-
)
|
|
424
|
-
if not any(
|
|
425
|
-
registration.path == recorded_worktree
|
|
426
|
-
and registration.branch == checkout.active_dev_branch
|
|
427
|
-
for registration in registrations
|
|
428
|
-
):
|
|
429
|
-
blockers.append(
|
|
430
|
-
f"{item.item_id}: recorded branch/worktree registration is inconsistent"
|
|
431
|
-
)
|
|
432
|
-
elif any(registration.path == recorded_worktree for registration in registrations):
|
|
433
|
-
blockers.append(
|
|
434
|
-
f"{item.item_id}: missing branch still has a conflicting registered worktree"
|
|
435
|
-
)
|
|
436
|
-
elif checkout.checkout_mode == CHECKOUT_MODE_BRANCH:
|
|
396
|
+
if checkout.checkout_mode == CHECKOUT_MODE_BRANCH:
|
|
437
397
|
if branch_exists and any(
|
|
438
398
|
registration.path != project_root.resolve()
|
|
439
399
|
for registration in active_registration
|
|
@@ -447,16 +407,13 @@ def _preflight_root(
|
|
|
447
407
|
)
|
|
448
408
|
|
|
449
409
|
replacement_checkout: TaskCheckout | None = None
|
|
450
|
-
replacement_worktree: WorktreeRuntimeContext | None = None
|
|
451
410
|
if not branch_exists and not blockers:
|
|
452
411
|
try:
|
|
453
|
-
replacement_branch
|
|
412
|
+
replacement_branch = _replacement_identity(
|
|
454
413
|
family,
|
|
455
414
|
item,
|
|
456
|
-
checkout,
|
|
457
415
|
project_root,
|
|
458
416
|
registrations,
|
|
459
|
-
old_runtime,
|
|
460
417
|
)
|
|
461
418
|
replacement_checkout = TaskCheckout.active(
|
|
462
419
|
family.task_type,
|
|
@@ -464,11 +421,6 @@ def _preflight_root(
|
|
|
464
421
|
replacement_branch,
|
|
465
422
|
checkout.base_branch,
|
|
466
423
|
checkout_mode=checkout.checkout_mode,
|
|
467
|
-
worktree_path=(
|
|
468
|
-
str(replacement_worktree.worktree_path)
|
|
469
|
-
if replacement_worktree is not None
|
|
470
|
-
else ""
|
|
471
|
-
),
|
|
472
424
|
)
|
|
473
425
|
except (TaskCheckoutError, ValueError) as exc:
|
|
474
426
|
blockers.append(str(exc))
|
|
@@ -496,37 +448,15 @@ def _preflight_root(
|
|
|
496
448
|
)
|
|
497
449
|
|
|
498
450
|
source_artifact: Path | None = None
|
|
499
|
-
target_artifact = _artifact_path(family, item,
|
|
451
|
+
target_artifact = _artifact_path(family, item, project_root)
|
|
500
452
|
checkpoint_target: Path | None = None
|
|
501
453
|
checkpoint_data: dict[str, Any] | None = None
|
|
502
454
|
if replacement_checkout is not None and not blockers:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
project_root,
|
|
509
|
-
)
|
|
510
|
-
if replacement_worktree is None:
|
|
511
|
-
blockers.append(f"{item.item_id}: replacement worktree was not resolved")
|
|
512
|
-
else:
|
|
513
|
-
target_artifact = _artifact_path(
|
|
514
|
-
family,
|
|
515
|
-
item,
|
|
516
|
-
replacement_worktree.worktree_path,
|
|
517
|
-
)
|
|
518
|
-
if target_artifact.exists():
|
|
519
|
-
blockers.append(
|
|
520
|
-
f"{item.item_id}: replacement artifact destination already exists: {target_artifact}"
|
|
521
|
-
)
|
|
522
|
-
else:
|
|
523
|
-
source_artifact = _existing_artifact_source(
|
|
524
|
-
family,
|
|
525
|
-
item,
|
|
526
|
-
project_root,
|
|
527
|
-
project_root,
|
|
528
|
-
)
|
|
529
|
-
target_artifact = _artifact_path(family, item, project_root)
|
|
455
|
+
source_artifact = _existing_artifact_source(
|
|
456
|
+
family,
|
|
457
|
+
item,
|
|
458
|
+
project_root,
|
|
459
|
+
)
|
|
530
460
|
|
|
531
461
|
source_checkpoint = (
|
|
532
462
|
source_artifact / "workflow-checkpoint.json"
|
|
@@ -540,11 +470,7 @@ def _preflight_root(
|
|
|
540
470
|
checkpoint_data = rewind_checkpoint_for_implementation(
|
|
541
471
|
source_data,
|
|
542
472
|
path=checkpoint_target,
|
|
543
|
-
project_root=
|
|
544
|
-
replacement_worktree.worktree_path
|
|
545
|
-
if replacement_worktree is not None
|
|
546
|
-
else project_root
|
|
547
|
-
),
|
|
473
|
+
project_root=project_root,
|
|
548
474
|
)
|
|
549
475
|
except (OSError, json.JSONDecodeError, ValueError) as exc:
|
|
550
476
|
blockers.append(
|
|
@@ -560,7 +486,6 @@ def _preflight_root(
|
|
|
560
486
|
status_path=status_path,
|
|
561
487
|
status_data=status_data,
|
|
562
488
|
replacement_checkout=replacement_checkout,
|
|
563
|
-
replacement_worktree=replacement_worktree,
|
|
564
489
|
source_artifact=source_artifact,
|
|
565
490
|
target_artifact=target_artifact,
|
|
566
491
|
checkpoint_target=checkpoint_target,
|
|
@@ -573,35 +498,18 @@ def _preflight_root(
|
|
|
573
498
|
def _replacement_identity(
|
|
574
499
|
family: RunnerFamily,
|
|
575
500
|
item: PreservePlanItem,
|
|
576
|
-
checkout: TaskCheckout,
|
|
577
501
|
project_root: Path,
|
|
578
502
|
registrations,
|
|
579
|
-
|
|
580
|
-
) -> tuple[str, WorktreeRuntimeContext | None]:
|
|
503
|
+
) -> str:
|
|
581
504
|
stamp = time.strftime("%Y%m%d%H%M%S", time.gmtime())
|
|
582
|
-
worktree_root = old_runtime.worktree_root if old_runtime is not None else None
|
|
583
505
|
registered_branches = {registration.branch for registration in registrations}
|
|
584
|
-
|
|
506
|
+
branch_prefix = safe_task_branch_prefix(project_root, family.branch_prefix)
|
|
585
507
|
for suffix in range(1000):
|
|
586
508
|
ending = "" if suffix == 0 else f"-{suffix}"
|
|
587
|
-
branch = f"{
|
|
509
|
+
branch = f"{branch_prefix}/{item.item_id}-resume-{stamp}{ending}"
|
|
588
510
|
if local_branch_exists(project_root, branch) or branch in registered_branches:
|
|
589
511
|
continue
|
|
590
|
-
|
|
591
|
-
if checkout.checkout_mode == CHECKOUT_MODE_WORKTREE:
|
|
592
|
-
if worktree_root is None:
|
|
593
|
-
continue
|
|
594
|
-
runtime = worktree_runtime_context(
|
|
595
|
-
BranchContext(checkout.base_branch, branch, project_root),
|
|
596
|
-
WorktreePolicy(True, True, True, worktree_root),
|
|
597
|
-
)
|
|
598
|
-
if (
|
|
599
|
-
not runtime.is_cleanup_path_safe()
|
|
600
|
-
or runtime.worktree_path.exists()
|
|
601
|
-
or runtime.worktree_path.resolve() in registered_paths
|
|
602
|
-
):
|
|
603
|
-
continue
|
|
604
|
-
return branch, runtime
|
|
512
|
+
return branch
|
|
605
513
|
raise ValueError(f"{item.item_id}: cannot allocate a collision-safe replacement checkout")
|
|
606
514
|
|
|
607
515
|
|
|
@@ -613,7 +521,8 @@ def _checkpoint_candidates(
|
|
|
613
521
|
) -> tuple[tuple[Path, Path], ...]:
|
|
614
522
|
candidates: list[tuple[Path, Path]] = []
|
|
615
523
|
seen: set[Path] = set()
|
|
616
|
-
|
|
524
|
+
roots = (execution_root,) if execution_root.resolve() == project_root.resolve() else (execution_root, project_root)
|
|
525
|
+
for root in roots:
|
|
617
526
|
checkpoint = _artifact_path(family, item, root) / "workflow-checkpoint.json"
|
|
618
527
|
resolved = checkpoint.resolve()
|
|
619
528
|
if resolved in seen or not checkpoint.is_file():
|
|
@@ -626,14 +535,10 @@ def _checkpoint_candidates(
|
|
|
626
535
|
def _existing_artifact_source(
|
|
627
536
|
family: RunnerFamily,
|
|
628
537
|
item: PreservePlanItem,
|
|
629
|
-
primary_root: Path,
|
|
630
538
|
project_root: Path,
|
|
631
539
|
) -> Path | None:
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
if candidate.is_dir():
|
|
635
|
-
return candidate
|
|
636
|
-
return None
|
|
540
|
+
candidate = _artifact_path(family, item, project_root)
|
|
541
|
+
return candidate if candidate.is_dir() else None
|
|
637
542
|
|
|
638
543
|
|
|
639
544
|
def _artifact_path(
|
|
@@ -661,20 +566,13 @@ def _writability_blockers(
|
|
|
661
566
|
f"{recovery.item.item_id} checkout identity",
|
|
662
567
|
),
|
|
663
568
|
]
|
|
664
|
-
if recovery.checkpoint_target is not None
|
|
569
|
+
if recovery.checkpoint_target is not None:
|
|
665
570
|
checks.append(
|
|
666
571
|
(
|
|
667
572
|
recovery.checkpoint_target,
|
|
668
573
|
f"{recovery.item.item_id} workflow checkpoint",
|
|
669
574
|
)
|
|
670
575
|
)
|
|
671
|
-
if recovery.replacement_worktree is not None:
|
|
672
|
-
checks.append(
|
|
673
|
-
(
|
|
674
|
-
recovery.replacement_worktree.worktree_root,
|
|
675
|
-
f"{recovery.item.item_id} replacement worktree root",
|
|
676
|
-
)
|
|
677
|
-
)
|
|
678
576
|
for path, label in checks:
|
|
679
577
|
if not _path_writable(path):
|
|
680
578
|
blockers.append(f"{label} is not writable: {path}")
|
|
@@ -711,29 +609,10 @@ def _apply_recovery(
|
|
|
711
609
|
raise RuntimeError(
|
|
712
610
|
f"{recovery.item.item_id}: replacement branch creation failed: {detail or 'unknown Git error'}"
|
|
713
611
|
)
|
|
714
|
-
if recovery.replacement_worktree is not None:
|
|
715
|
-
setup = ensure_linked_worktree(recovery.replacement_worktree)
|
|
716
|
-
if not setup.ok:
|
|
717
|
-
detail = "; ".join(
|
|
718
|
-
result.stderr.strip() or result.stdout.strip()
|
|
719
|
-
for result in setup.results
|
|
720
|
-
if result.return_code != 0
|
|
721
|
-
)
|
|
722
|
-
raise RuntimeError(
|
|
723
|
-
f"{recovery.item.item_id}: replacement worktree creation failed: "
|
|
724
|
-
f"{detail or setup.reason}"
|
|
725
|
-
)
|
|
726
|
-
if recovery.source_artifact is not None and recovery.target_artifact is not None:
|
|
727
|
-
recovery.target_artifact.parent.mkdir(parents=True, exist_ok=True)
|
|
728
|
-
shutil.copytree(
|
|
729
|
-
recovery.source_artifact,
|
|
730
|
-
recovery.target_artifact,
|
|
731
|
-
symlinks=True,
|
|
732
|
-
)
|
|
733
612
|
|
|
734
613
|
for recovery in recoveries:
|
|
735
614
|
if recovery.checkpoint_target is not None and recovery.checkpoint_data is not None:
|
|
736
|
-
|
|
615
|
+
write_json_atomic(recovery.checkpoint_target, recovery.checkpoint_data)
|
|
737
616
|
|
|
738
617
|
for recovery in recoveries:
|
|
739
618
|
if recovery.replacement_checkout is not None:
|
|
@@ -747,13 +626,22 @@ def _apply_recovery(
|
|
|
747
626
|
status_data = copy.deepcopy(recovery.status_data)
|
|
748
627
|
status_data["retry_count"] = 0
|
|
749
628
|
status_data["infra_error_count"] = 0
|
|
629
|
+
status_data["no_progress_count"] = 0
|
|
750
630
|
status_data["continuation_pending"] = True
|
|
631
|
+
for stale_key in (
|
|
632
|
+
"stalled_context_continuation",
|
|
633
|
+
"stalled_reason",
|
|
634
|
+
"needs_attention",
|
|
635
|
+
"degraded_reason",
|
|
636
|
+
"skipped_reason",
|
|
637
|
+
):
|
|
638
|
+
status_data.pop(stale_key, None)
|
|
751
639
|
if recovery.replacement_checkout is not None:
|
|
752
640
|
status_data["active_dev_branch"] = (
|
|
753
641
|
recovery.replacement_checkout.active_dev_branch
|
|
754
642
|
)
|
|
755
643
|
status_data["base_branch"] = recovery.replacement_checkout.base_branch
|
|
756
|
-
|
|
644
|
+
write_json_atomic(recovery.status_path, status_data)
|
|
757
645
|
|
|
758
646
|
plan_data = copy.deepcopy(snapshot.data)
|
|
759
647
|
raw_items = plan_data.get(family.list_key)
|
|
@@ -769,35 +657,7 @@ def _apply_recovery(
|
|
|
769
657
|
item_id = _normalize_item_id(str(raw_item.get("id") or ""), family.id_prefix)
|
|
770
658
|
if item_id in restored_ids:
|
|
771
659
|
raw_item["status"] = "pending"
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
def _atomic_write_json(path: Path, data: Any) -> None:
|
|
776
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
777
|
-
descriptor = -1
|
|
778
|
-
temporary = ""
|
|
779
|
-
try:
|
|
780
|
-
descriptor, temporary = tempfile.mkstemp(
|
|
781
|
-
prefix=f".{path.name}.",
|
|
782
|
-
suffix=".tmp",
|
|
783
|
-
dir=path.parent,
|
|
784
|
-
)
|
|
785
|
-
with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
|
|
786
|
-
descriptor = -1
|
|
787
|
-
json.dump(data, handle, indent=2, ensure_ascii=False)
|
|
788
|
-
handle.write("\n")
|
|
789
|
-
handle.flush()
|
|
790
|
-
os.fsync(handle.fileno())
|
|
791
|
-
os.replace(temporary, path)
|
|
792
|
-
except OSError:
|
|
793
|
-
if descriptor >= 0:
|
|
794
|
-
os.close(descriptor)
|
|
795
|
-
if temporary:
|
|
796
|
-
try:
|
|
797
|
-
os.unlink(temporary)
|
|
798
|
-
except OSError:
|
|
799
|
-
pass
|
|
800
|
-
raise
|
|
660
|
+
write_json_atomic(list_path, plan_data)
|
|
801
661
|
|
|
802
662
|
|
|
803
663
|
def _normalize_item_id(value: str, prefix: str) -> str:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Shared command result model for canonical runtime handlers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class CommandResult:
|
|
10
|
+
"""Result returned by runtime command handlers."""
|
|
11
|
+
|
|
12
|
+
exit_code: int
|
|
13
|
+
title: str
|
|
14
|
+
message: str
|
|
15
|
+
details: tuple[str, ...] = ()
|
|
16
|
+
stdout: str | None = None
|
|
17
|
+
stderr: str | None = None
|
|
18
|
+
|
|
19
|
+
def render(self) -> str:
|
|
20
|
+
"""Render a deterministic human-readable result."""
|
|
21
|
+
if self.stdout is not None:
|
|
22
|
+
return self.stdout
|
|
23
|
+
lines = [self.title, self.message]
|
|
24
|
+
lines.extend(self.details)
|
|
25
|
+
return "\n".join(line for line in lines if line)
|