prizmkit 1.1.192 → 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/dev-pipeline/README.md +23 -34
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -0
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -2
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -40
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -1
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -22
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +11 -7
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +26 -20
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +37 -4
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +20 -41
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +74 -36
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -66
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +271 -52
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +51 -13
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +43 -15
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +27 -24
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +0 -1
- package/bundled/dev-pipeline/scripts/check-session-status.py +13 -1
- package/bundled/dev-pipeline/scripts/continuation.py +2 -3
- package/bundled/dev-pipeline/scripts/detect-stuck.py +19 -5
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -14
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +13 -8
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +17 -2
- package/bundled/dev-pipeline/scripts/prompt_framework.py +39 -21
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +27 -0
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -6
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +1 -1
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
- package/bundled/dev-pipeline/tests/_helpers.py +0 -418
- package/bundled/dev-pipeline/tests/conftest.py +0 -73
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1806
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1439
- package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +0 -257
- package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +0 -500
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1654
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -629
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -2973
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -321
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -251
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1196
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -872
- package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +0 -766
- package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +0 -1257
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -380
- package/bundled/dev-pipeline/tests/test_session_launch.py +0 -1101
- package/bundled/dev-pipeline/tests/test_stream_progress.py +0 -585
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -3625
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
|
@@ -7,18 +7,19 @@ import re
|
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
9
|
from collections.abc import Sequence
|
|
10
|
+
from contextlib import ExitStack
|
|
10
11
|
from dataclasses import dataclass
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
|
|
13
14
|
from .gitops import (
|
|
14
15
|
default_branch,
|
|
15
16
|
list_reset_branches,
|
|
17
|
+
local_branch_exists,
|
|
16
18
|
reset_cleanup_branch,
|
|
17
19
|
)
|
|
18
20
|
from .results import CommandResult
|
|
19
21
|
from .runner_models import RunnerFamily, family_for
|
|
20
22
|
from .task_checkout import (
|
|
21
|
-
TaskCheckout,
|
|
22
23
|
load_task_checkout,
|
|
23
24
|
mark_task_checkout_reset_locked,
|
|
24
25
|
task_checkout_guard,
|
|
@@ -138,7 +139,28 @@ def run_reset_command(kind: str, legacy_args: tuple[str, ...], paths) -> Command
|
|
|
138
139
|
stdout=text,
|
|
139
140
|
)
|
|
140
141
|
if options.state_only:
|
|
141
|
-
|
|
142
|
+
guard_ids: list[str] = []
|
|
143
|
+
if options.item_id:
|
|
144
|
+
guard_ids.append(options.item_id)
|
|
145
|
+
elif family.state_dir.is_dir():
|
|
146
|
+
guard_ids.extend(
|
|
147
|
+
sorted(
|
|
148
|
+
entry.name
|
|
149
|
+
for entry in family.state_dir.iterdir()
|
|
150
|
+
if entry.is_dir() and not entry.name.startswith(".")
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
try:
|
|
154
|
+
with ExitStack() as stack:
|
|
155
|
+
for gid in guard_ids:
|
|
156
|
+
stack.enter_context(task_checkout_guard(family.state_dir, gid))
|
|
157
|
+
state_result = _run_state_only_updater(family, options, paths.project_root)
|
|
158
|
+
except RuntimeError as exc:
|
|
159
|
+
return CommandResult(
|
|
160
|
+
1,
|
|
161
|
+
f"Python {kind} reset --state-only",
|
|
162
|
+
f"ERROR: Reset could not acquire checkout lifecycle: {exc}",
|
|
163
|
+
)
|
|
142
164
|
text = state_result.stdout.strip() or state_result.stderr.strip() or "State-only reset failed"
|
|
143
165
|
ok = state_result.returncode == 0 and _json_without_error(state_result.stdout)
|
|
144
166
|
return CommandResult(
|
|
@@ -364,13 +386,20 @@ def _reset_one(family: RunnerFamily, item: ResetItem, options: ResetOptions, pro
|
|
|
364
386
|
lines.append(f"Current status: {item.status} (no runtime state file)")
|
|
365
387
|
|
|
366
388
|
checkout = load_task_checkout(family.state_dir, family.task_type, item.item_id)
|
|
389
|
+
effective_return_branch = return_branch
|
|
390
|
+
if (
|
|
391
|
+
checkout is not None
|
|
392
|
+
and checkout.base_branch
|
|
393
|
+
and local_branch_exists(project_root, checkout.base_branch)
|
|
394
|
+
):
|
|
395
|
+
effective_return_branch = checkout.base_branch
|
|
367
396
|
branches = list(list_reset_branches(project_root, BRANCH_PREFIX_BY_KIND[family.kind], item.item_id))
|
|
368
397
|
if checkout is not None and (checkout.is_active or checkout.is_completed):
|
|
369
398
|
if checkout.active_dev_branch not in branches:
|
|
370
399
|
branches.insert(0, checkout.active_dev_branch)
|
|
371
400
|
|
|
372
401
|
for branch in branches:
|
|
373
|
-
cleanup = reset_cleanup_branch(project_root, branch, return_branch=
|
|
402
|
+
cleanup = reset_cleanup_branch(project_root, branch, return_branch=effective_return_branch, delete=options.clean)
|
|
374
403
|
if getattr(cleanup, "checkout_discarded", False):
|
|
375
404
|
lines.append(f"Discarded uncommitted changes on current dev branch: {cleanup.branch}")
|
|
376
405
|
elif getattr(cleanup, "branch_preserved", False):
|
|
@@ -503,7 +532,11 @@ def _slug_for_item(family: RunnerFamily, item_id: str, title: str) -> str:
|
|
|
503
532
|
|
|
504
533
|
|
|
505
534
|
def _looks_like_item_id(value: str, prefix: str) -> bool:
|
|
506
|
-
return
|
|
535
|
+
return (
|
|
536
|
+
":" not in value
|
|
537
|
+
and value.upper().startswith(prefix.upper())
|
|
538
|
+
and bool(re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]*", value[len(prefix) :]))
|
|
539
|
+
)
|
|
507
540
|
|
|
508
541
|
|
|
509
542
|
def _looks_like_range(value: str, prefix: str) -> bool:
|
|
@@ -6,13 +6,13 @@ import copy
|
|
|
6
6
|
import json
|
|
7
7
|
import os
|
|
8
8
|
import shlex
|
|
9
|
-
import tempfile
|
|
10
9
|
import time
|
|
11
10
|
from contextlib import ExitStack
|
|
12
11
|
from dataclasses import dataclass
|
|
13
12
|
from pathlib import Path
|
|
14
13
|
from typing import Any
|
|
15
14
|
|
|
15
|
+
from .atomic_io import write_json_atomic
|
|
16
16
|
from .checkpoint_state import (
|
|
17
17
|
load_checkpoint_state,
|
|
18
18
|
rewind_checkpoint_for_implementation,
|
|
@@ -21,6 +21,7 @@ from .gitops import (
|
|
|
21
21
|
create_branch_from_base,
|
|
22
22
|
local_branch_exists,
|
|
23
23
|
registered_worktrees,
|
|
24
|
+
safe_task_branch_prefix,
|
|
24
25
|
)
|
|
25
26
|
from .runner_models import RunnerFamily
|
|
26
27
|
from .task_checkout import (
|
|
@@ -455,7 +456,6 @@ def _preflight_root(
|
|
|
455
456
|
family,
|
|
456
457
|
item,
|
|
457
458
|
project_root,
|
|
458
|
-
project_root,
|
|
459
459
|
)
|
|
460
460
|
|
|
461
461
|
source_checkpoint = (
|
|
@@ -503,9 +503,10 @@ def _replacement_identity(
|
|
|
503
503
|
) -> str:
|
|
504
504
|
stamp = time.strftime("%Y%m%d%H%M%S", time.gmtime())
|
|
505
505
|
registered_branches = {registration.branch for registration in registrations}
|
|
506
|
+
branch_prefix = safe_task_branch_prefix(project_root, family.branch_prefix)
|
|
506
507
|
for suffix in range(1000):
|
|
507
508
|
ending = "" if suffix == 0 else f"-{suffix}"
|
|
508
|
-
branch = f"{
|
|
509
|
+
branch = f"{branch_prefix}/{item.item_id}-resume-{stamp}{ending}"
|
|
509
510
|
if local_branch_exists(project_root, branch) or branch in registered_branches:
|
|
510
511
|
continue
|
|
511
512
|
return branch
|
|
@@ -520,7 +521,8 @@ def _checkpoint_candidates(
|
|
|
520
521
|
) -> tuple[tuple[Path, Path], ...]:
|
|
521
522
|
candidates: list[tuple[Path, Path]] = []
|
|
522
523
|
seen: set[Path] = set()
|
|
523
|
-
|
|
524
|
+
roots = (execution_root,) if execution_root.resolve() == project_root.resolve() else (execution_root, project_root)
|
|
525
|
+
for root in roots:
|
|
524
526
|
checkpoint = _artifact_path(family, item, root) / "workflow-checkpoint.json"
|
|
525
527
|
resolved = checkpoint.resolve()
|
|
526
528
|
if resolved in seen or not checkpoint.is_file():
|
|
@@ -533,14 +535,10 @@ def _checkpoint_candidates(
|
|
|
533
535
|
def _existing_artifact_source(
|
|
534
536
|
family: RunnerFamily,
|
|
535
537
|
item: PreservePlanItem,
|
|
536
|
-
primary_root: Path,
|
|
537
538
|
project_root: Path,
|
|
538
539
|
) -> Path | None:
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
if candidate.is_dir():
|
|
542
|
-
return candidate
|
|
543
|
-
return None
|
|
540
|
+
candidate = _artifact_path(family, item, project_root)
|
|
541
|
+
return candidate if candidate.is_dir() else None
|
|
544
542
|
|
|
545
543
|
|
|
546
544
|
def _artifact_path(
|
|
@@ -614,7 +612,7 @@ def _apply_recovery(
|
|
|
614
612
|
|
|
615
613
|
for recovery in recoveries:
|
|
616
614
|
if recovery.checkpoint_target is not None and recovery.checkpoint_data is not None:
|
|
617
|
-
|
|
615
|
+
write_json_atomic(recovery.checkpoint_target, recovery.checkpoint_data)
|
|
618
616
|
|
|
619
617
|
for recovery in recoveries:
|
|
620
618
|
if recovery.replacement_checkout is not None:
|
|
@@ -628,13 +626,22 @@ def _apply_recovery(
|
|
|
628
626
|
status_data = copy.deepcopy(recovery.status_data)
|
|
629
627
|
status_data["retry_count"] = 0
|
|
630
628
|
status_data["infra_error_count"] = 0
|
|
629
|
+
status_data["no_progress_count"] = 0
|
|
631
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)
|
|
632
639
|
if recovery.replacement_checkout is not None:
|
|
633
640
|
status_data["active_dev_branch"] = (
|
|
634
641
|
recovery.replacement_checkout.active_dev_branch
|
|
635
642
|
)
|
|
636
643
|
status_data["base_branch"] = recovery.replacement_checkout.base_branch
|
|
637
|
-
|
|
644
|
+
write_json_atomic(recovery.status_path, status_data)
|
|
638
645
|
|
|
639
646
|
plan_data = copy.deepcopy(snapshot.data)
|
|
640
647
|
raw_items = plan_data.get(family.list_key)
|
|
@@ -650,35 +657,7 @@ def _apply_recovery(
|
|
|
650
657
|
item_id = _normalize_item_id(str(raw_item.get("id") or ""), family.id_prefix)
|
|
651
658
|
if item_id in restored_ids:
|
|
652
659
|
raw_item["status"] = "pending"
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
def _atomic_write_json(path: Path, data: Any) -> None:
|
|
657
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
658
|
-
descriptor = -1
|
|
659
|
-
temporary = ""
|
|
660
|
-
try:
|
|
661
|
-
descriptor, temporary = tempfile.mkstemp(
|
|
662
|
-
prefix=f".{path.name}.",
|
|
663
|
-
suffix=".tmp",
|
|
664
|
-
dir=path.parent,
|
|
665
|
-
)
|
|
666
|
-
with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
|
|
667
|
-
descriptor = -1
|
|
668
|
-
json.dump(data, handle, indent=2, ensure_ascii=False)
|
|
669
|
-
handle.write("\n")
|
|
670
|
-
handle.flush()
|
|
671
|
-
os.fsync(handle.fileno())
|
|
672
|
-
os.replace(temporary, path)
|
|
673
|
-
except OSError:
|
|
674
|
-
if descriptor >= 0:
|
|
675
|
-
os.close(descriptor)
|
|
676
|
-
if temporary:
|
|
677
|
-
try:
|
|
678
|
-
os.unlink(temporary)
|
|
679
|
-
except OSError:
|
|
680
|
-
pass
|
|
681
|
-
raise
|
|
660
|
+
write_json_atomic(list_path, plan_data)
|
|
682
661
|
|
|
683
662
|
|
|
684
663
|
def _normalize_item_id(value: str, prefix: str) -> str:
|
|
@@ -62,9 +62,16 @@ class BookkeepingResult:
|
|
|
62
62
|
return self.result is None or self.result.return_code == 0
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def _bookkeeping_paths(
|
|
65
|
+
def _bookkeeping_paths(
|
|
66
|
+
project_root: Path,
|
|
67
|
+
family: RunnerFamily,
|
|
68
|
+
item_id: str,
|
|
69
|
+
*,
|
|
70
|
+
list_path: Path | None = None,
|
|
71
|
+
) -> tuple[str, ...]:
|
|
72
|
+
target_list = list_path if list_path is not None else family.plan_path
|
|
66
73
|
return (
|
|
67
|
-
_repo_path(project_root,
|
|
74
|
+
_repo_path(project_root, target_list),
|
|
68
75
|
_repo_path(project_root, family.state_dir / item_id / "status.json"),
|
|
69
76
|
)
|
|
70
77
|
|
|
@@ -163,27 +170,16 @@ def _remaining_preflight_changes(project_root: Path) -> GitCommandResult:
|
|
|
163
170
|
)
|
|
164
171
|
|
|
165
172
|
|
|
166
|
-
def _paths_from_status(stdout: str) -> tuple[str, ...]:
|
|
167
|
-
changed: list[str] = []
|
|
168
|
-
seen: set[str] = set()
|
|
169
|
-
for line in stdout.splitlines():
|
|
170
|
-
if len(line) < 4:
|
|
171
|
-
continue
|
|
172
|
-
path = line[3:].strip()
|
|
173
|
-
paths = path.split(" -> ", 1) if " -> " in path else [path]
|
|
174
|
-
for candidate in paths:
|
|
175
|
-
candidate = candidate.strip()
|
|
176
|
-
if candidate and candidate not in seen:
|
|
177
|
-
changed.append(candidate)
|
|
178
|
-
seen.add(candidate)
|
|
179
|
-
return tuple(changed)
|
|
180
|
-
|
|
181
|
-
|
|
182
173
|
def _changed_paths_in(project_root: Path, paths: Sequence[str]) -> tuple[str, ...]:
|
|
183
|
-
|
|
174
|
+
if not paths:
|
|
175
|
+
return ()
|
|
176
|
+
result = run_git_command(
|
|
177
|
+
project_root,
|
|
178
|
+
("status", "--porcelain=v1", "-z", "--", *literal_pathspecs(paths)),
|
|
179
|
+
)
|
|
184
180
|
if result.return_code != 0:
|
|
185
181
|
return ()
|
|
186
|
-
return
|
|
182
|
+
return parse_status_record_paths(result.stdout)
|
|
187
183
|
|
|
188
184
|
|
|
189
185
|
def commit_bookkeeping_changes(
|
|
@@ -191,13 +187,21 @@ def commit_bookkeeping_changes(
|
|
|
191
187
|
family: RunnerFamily,
|
|
192
188
|
item_id: str,
|
|
193
189
|
message: str,
|
|
190
|
+
*,
|
|
191
|
+
list_path: Path | None = None,
|
|
194
192
|
) -> BookkeepingResult:
|
|
195
193
|
"""Stage and commit only runner-owned bookkeeping paths when present."""
|
|
196
|
-
paths = _changed_paths_in(
|
|
194
|
+
paths = _changed_paths_in(
|
|
195
|
+
project_root,
|
|
196
|
+
_bookkeeping_paths(project_root, family, item_id, list_path=list_path),
|
|
197
|
+
)
|
|
197
198
|
if not paths:
|
|
198
199
|
return BookkeepingResult(attempted=False, committed=False)
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
pathspecs = literal_pathspecs(paths)
|
|
201
|
+
add = run_git_command(project_root, ("add", "-A", "--", *pathspecs))
|
|
202
|
+
if add.return_code != 0:
|
|
203
|
+
return BookkeepingResult(attempted=True, committed=False, result=add)
|
|
204
|
+
result = run_git_command(project_root, ("commit", "--no-verify", "-m", message, "--", *pathspecs))
|
|
201
205
|
return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
|
|
202
206
|
|
|
203
207
|
|
|
@@ -292,14 +296,46 @@ def commit_wip_changes(
|
|
|
292
296
|
)
|
|
293
297
|
|
|
294
298
|
|
|
295
|
-
def commit_pre_branch_bookkeeping(
|
|
299
|
+
def commit_pre_branch_bookkeeping(
|
|
300
|
+
project_root: Path,
|
|
301
|
+
family: RunnerFamily,
|
|
302
|
+
item_id: str,
|
|
303
|
+
*,
|
|
304
|
+
list_path: Path | None = None,
|
|
305
|
+
) -> BookkeepingResult:
|
|
296
306
|
"""Commit in-progress status on the current task branch."""
|
|
297
|
-
return commit_bookkeeping_changes(
|
|
307
|
+
return commit_bookkeeping_changes(
|
|
308
|
+
project_root,
|
|
309
|
+
family,
|
|
310
|
+
item_id,
|
|
311
|
+
f"chore({item_id}): mark in_progress",
|
|
312
|
+
list_path=list_path,
|
|
313
|
+
)
|
|
298
314
|
|
|
299
315
|
|
|
300
|
-
def commit_final_bookkeeping(
|
|
316
|
+
def commit_final_bookkeeping(
|
|
317
|
+
project_root: Path,
|
|
318
|
+
family: RunnerFamily,
|
|
319
|
+
item_id: str,
|
|
320
|
+
status: str,
|
|
321
|
+
*,
|
|
322
|
+
list_path: Path | None = None,
|
|
323
|
+
) -> BookkeepingResult:
|
|
301
324
|
"""Commit final runner-owned status changes on the current task branch."""
|
|
302
|
-
return commit_bookkeeping_changes(
|
|
325
|
+
return commit_bookkeeping_changes(
|
|
326
|
+
project_root,
|
|
327
|
+
family,
|
|
328
|
+
item_id,
|
|
329
|
+
f"chore({item_id}): update {family.kind} status {status}",
|
|
330
|
+
list_path=list_path,
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def _is_runtime_state_relpath(rel_path: str) -> bool:
|
|
335
|
+
normalized = rel_path.replace("\\", "/")
|
|
336
|
+
while normalized.startswith(("./", "/")):
|
|
337
|
+
normalized = normalized[2:] if normalized.startswith("./") else normalized[1:]
|
|
338
|
+
return normalized == ".prizmkit/state" or normalized.startswith(".prizmkit/state/")
|
|
303
339
|
|
|
304
340
|
|
|
305
341
|
def sync_terminal_failure_bookkeeping_to_base(
|
|
@@ -309,27 +345,29 @@ def sync_terminal_failure_bookkeeping_to_base(
|
|
|
309
345
|
status: str,
|
|
310
346
|
snapshots: Mapping[Path, str],
|
|
311
347
|
) -> BookkeepingResult:
|
|
312
|
-
"""Persist
|
|
348
|
+
"""Persist terminal failure bookkeeping on base_branch without tracking runtime state."""
|
|
313
349
|
if not snapshots:
|
|
314
350
|
return BookkeepingResult(attempted=False, committed=False)
|
|
315
351
|
resolved_root = project_root.resolve()
|
|
316
|
-
|
|
352
|
+
git_candidates: list[str] = []
|
|
317
353
|
for path, text in snapshots.items():
|
|
354
|
+
needs_write = True
|
|
318
355
|
if path.is_file():
|
|
319
356
|
try:
|
|
320
|
-
|
|
321
|
-
continue
|
|
357
|
+
needs_write = path.read_text(encoding="utf-8") != text
|
|
322
358
|
except OSError:
|
|
323
|
-
|
|
324
|
-
|
|
359
|
+
needs_write = True
|
|
360
|
+
if needs_write:
|
|
361
|
+
write_text_atomic(path, text)
|
|
325
362
|
try:
|
|
326
363
|
rel = path.resolve().relative_to(resolved_root).as_posix()
|
|
327
364
|
except ValueError:
|
|
328
365
|
continue
|
|
329
|
-
|
|
330
|
-
|
|
366
|
+
if not _is_runtime_state_relpath(rel):
|
|
367
|
+
git_candidates.append(rel)
|
|
368
|
+
if not git_candidates:
|
|
331
369
|
return BookkeepingResult(attempted=False, committed=False)
|
|
332
|
-
changed = _changed_paths_in(project_root,
|
|
370
|
+
changed = _changed_paths_in(project_root, git_candidates)
|
|
333
371
|
if not changed:
|
|
334
372
|
return BookkeepingResult(attempted=False, committed=False)
|
|
335
373
|
pathspecs = literal_pathspecs(changed)
|
|
@@ -120,65 +120,6 @@ class SessionPaths:
|
|
|
120
120
|
)
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
@dataclass(frozen=True)
|
|
124
|
-
class SemanticCheckpointState:
|
|
125
|
-
"""Cohesive provider-neutral checkpoint metadata persisted by L4."""
|
|
126
|
-
|
|
127
|
-
current_stage: str | None = None
|
|
128
|
-
next_stage: str | None = None
|
|
129
|
-
stage_result: str | None = None
|
|
130
|
-
repair_scope: str | None = None
|
|
131
|
-
repair_round: int = 0
|
|
132
|
-
blocked_reason: str | None = None
|
|
133
|
-
terminal_status: str | None = None
|
|
134
|
-
|
|
135
|
-
@classmethod
|
|
136
|
-
def from_mapping(cls, value: Mapping[str, object] | None) -> "SemanticCheckpointState":
|
|
137
|
-
data = value or {}
|
|
138
|
-
return cls(
|
|
139
|
-
current_stage=_optional_text(data.get("current_stage")),
|
|
140
|
-
next_stage=_optional_text(data.get("next_stage")),
|
|
141
|
-
stage_result=_optional_text(data.get("stage_result")),
|
|
142
|
-
repair_scope=_optional_text(data.get("repair_scope")),
|
|
143
|
-
repair_round=max(0, _safe_int(data.get("repair_round"), 0)),
|
|
144
|
-
blocked_reason=_optional_text(data.get("blocked_reason")),
|
|
145
|
-
terminal_status=_optional_text(data.get("terminal_status")),
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
def as_dict(self) -> dict[str, object]:
|
|
149
|
-
return {
|
|
150
|
-
"current_stage": self.current_stage,
|
|
151
|
-
"next_stage": self.next_stage,
|
|
152
|
-
"stage_result": self.stage_result,
|
|
153
|
-
"repair_scope": self.repair_scope,
|
|
154
|
-
"repair_round": self.repair_round,
|
|
155
|
-
"blocked_reason": self.blocked_reason,
|
|
156
|
-
"terminal_status": self.terminal_status,
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
@dataclass(frozen=True)
|
|
161
|
-
class ContinuationState:
|
|
162
|
-
"""Provider-neutral durable handoff inputs for the next AI session."""
|
|
163
|
-
|
|
164
|
-
active: bool = False
|
|
165
|
-
previous_session_id: str = ""
|
|
166
|
-
failure_classification: str = ""
|
|
167
|
-
continuation_count: int = 0
|
|
168
|
-
context_overflow_count: int = 0
|
|
169
|
-
retry_count: int = 0
|
|
170
|
-
infra_error_count: int = 0
|
|
171
|
-
max_retries: int = 0
|
|
172
|
-
max_infra_retries: int = 0
|
|
173
|
-
no_progress_count: int = 0
|
|
174
|
-
progress_fingerprint: Mapping[str, object] = field(default_factory=dict)
|
|
175
|
-
summary_path: Path | None = None
|
|
176
|
-
active_dev_branch: str = ""
|
|
177
|
-
base_branch: str = ""
|
|
178
|
-
fatal_error_code: str = ""
|
|
179
|
-
checkpoint_state: SemanticCheckpointState = field(default_factory=SemanticCheckpointState)
|
|
180
|
-
|
|
181
|
-
|
|
182
123
|
@dataclass(frozen=True)
|
|
183
124
|
class SessionClassification:
|
|
184
125
|
"""Final runner-owned session outcome before status updater mutation."""
|
|
@@ -335,13 +276,6 @@ def _falsey(value: str | None) -> bool:
|
|
|
335
276
|
return str(value or "").strip().lower() in {"0", "false", "no", "off"}
|
|
336
277
|
|
|
337
278
|
|
|
338
|
-
def _optional_text(value: object) -> str | None:
|
|
339
|
-
if value is None:
|
|
340
|
-
return None
|
|
341
|
-
text = str(value).strip()
|
|
342
|
-
return text or None
|
|
343
|
-
|
|
344
|
-
|
|
345
279
|
def _safe_int(value: object, default: int) -> int:
|
|
346
280
|
try:
|
|
347
281
|
return int(str(value))
|