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
|
@@ -4,19 +4,19 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import copy
|
|
6
6
|
import json
|
|
7
|
-
import os
|
|
8
7
|
import re
|
|
9
8
|
import subprocess
|
|
10
|
-
import tempfile
|
|
11
9
|
from dataclasses import dataclass
|
|
12
10
|
from pathlib import Path, PurePosixPath
|
|
13
11
|
from typing import Mapping
|
|
14
12
|
|
|
13
|
+
from .atomic_io import write_json_atomic
|
|
15
14
|
from .checkpoint_state import (
|
|
16
15
|
load_checkpoint_state,
|
|
17
16
|
semantic_state_key,
|
|
18
17
|
validate_checkpoint_data,
|
|
19
18
|
)
|
|
19
|
+
from .gitops import commit_args_without_signing, commit_identity_global_args
|
|
20
20
|
REQUEST_FILENAME = "runtime-commit-request.json"
|
|
21
21
|
REQUEST_SCHEMA_VERSION = 2
|
|
22
22
|
_HEX_COMMIT = re.compile(r"^[0-9a-fA-F]{40,64}$")
|
|
@@ -36,6 +36,35 @@ _SENSITIVE_NAMES = {
|
|
|
36
36
|
"secrets.json",
|
|
37
37
|
}
|
|
38
38
|
_SENSITIVE_SUFFIXES = {".pem", ".p12", ".pfx"}
|
|
39
|
+
_RUNTIME_INTERNAL_PREFIXES = (
|
|
40
|
+
".prizmkit/state",
|
|
41
|
+
".prizmkit/dev-pipeline",
|
|
42
|
+
".prizmkit/scripts",
|
|
43
|
+
".prizmkit/manifest.json",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
_PIPELINE_INTERNAL_METADATA_FILES = frozenset(
|
|
48
|
+
{
|
|
49
|
+
"workflow-checkpoint.json",
|
|
50
|
+
"runtime-commit-request.json",
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
_PIPELINE_ARTIFACT_ROOTS = (".prizmkit/specs/", ".prizmkit/bugfix/")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _is_runtime_internal_path(path: str) -> bool:
|
|
57
|
+
normalized = path.replace("\\", "/")
|
|
58
|
+
while normalized.startswith(("./", "/")):
|
|
59
|
+
normalized = normalized[2:] if normalized.startswith("./") else normalized[1:]
|
|
60
|
+
if any(
|
|
61
|
+
normalized == prefix or normalized.startswith(f"{prefix}/")
|
|
62
|
+
for prefix in _RUNTIME_INTERNAL_PREFIXES
|
|
63
|
+
):
|
|
64
|
+
return True
|
|
65
|
+
return normalized.startswith(_PIPELINE_ARTIFACT_ROOTS) and (
|
|
66
|
+
normalized.rsplit("/", 1)[-1] in _PIPELINE_INTERNAL_METADATA_FILES
|
|
67
|
+
)
|
|
39
68
|
|
|
40
69
|
|
|
41
70
|
@dataclass(frozen=True)
|
|
@@ -125,76 +154,21 @@ def finalize_runtime_commit(
|
|
|
125
154
|
return RuntimeCommitResult("failed", "premature_runtime_commit_hash")
|
|
126
155
|
if state.semantic_complete:
|
|
127
156
|
return RuntimeCommitResult("failed", "completed_checkpoint_without_commit")
|
|
128
|
-
|
|
129
|
-
if unmerged.return_code != 0:
|
|
130
|
-
return RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
131
|
-
if unmerged.stdout.strip():
|
|
132
|
-
return RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
133
|
-
changed, status_error = _workspace_changed_paths(
|
|
134
|
-
root,
|
|
135
|
-
checkpoint_path=checkpoint,
|
|
136
|
-
request_path=request_path,
|
|
137
|
-
)
|
|
138
|
-
if status_error:
|
|
139
|
-
return RuntimeCommitResult("failed", status_error)
|
|
140
|
-
if not changed:
|
|
141
|
-
return RuntimeCommitResult("failed", "empty_workspace_change")
|
|
142
|
-
unsafe = next((path for path in changed if _sensitive_commit_path(path)), "")
|
|
143
|
-
if unsafe:
|
|
144
|
-
return RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
145
|
-
bookkeeping_staged = _staged_bookkeeping_paths(
|
|
146
|
-
root,
|
|
147
|
-
checkpoint_path=checkpoint,
|
|
148
|
-
request_path=request_path,
|
|
149
|
-
)
|
|
150
|
-
if bookkeeping_staged is None:
|
|
151
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
152
|
-
if bookkeeping_staged:
|
|
153
|
-
return RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
154
|
-
staged = _stage_workspace(
|
|
155
|
-
root,
|
|
156
|
-
checkpoint_path=checkpoint,
|
|
157
|
-
request_path=request_path,
|
|
158
|
-
)
|
|
159
|
-
if staged.return_code != 0:
|
|
160
|
-
return RuntimeCommitResult("failed", "git_stage_failed")
|
|
161
|
-
staged_paths = _git(
|
|
162
|
-
root, "diff", "--cached", "--name-only", "--no-renames", "-z",
|
|
163
|
-
)
|
|
164
|
-
if staged_paths.return_code != 0:
|
|
165
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
166
|
-
staged_set = {path for path in staged_paths.stdout.split("\0") if path}
|
|
167
|
-
if staged_set != set(changed):
|
|
168
|
-
return RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
169
|
-
if not staged_set:
|
|
170
|
-
return RuntimeCommitResult("failed", "empty_staged_change")
|
|
171
|
-
unstaged_candidates = _workspace_has_unstaged_candidates(
|
|
157
|
+
head, commit_failure = _stage_and_commit_workspace(
|
|
172
158
|
root,
|
|
173
159
|
checkpoint_path=checkpoint,
|
|
174
160
|
request_path=request_path,
|
|
161
|
+
commit_message=request.commit_message,
|
|
162
|
+
allow_empty_workspace=False,
|
|
175
163
|
)
|
|
176
|
-
if
|
|
177
|
-
return
|
|
178
|
-
if
|
|
179
|
-
return RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
180
|
-
committed = _git(
|
|
181
|
-
root,
|
|
182
|
-
"-c", "core.hooksPath=/dev/null",
|
|
183
|
-
"-c", "commit.gpgSign=false",
|
|
184
|
-
"commit", "-m", request.commit_message,
|
|
185
|
-
)
|
|
186
|
-
if committed.return_code != 0:
|
|
187
|
-
return RuntimeCommitResult("failed", "git_commit_failed")
|
|
188
|
-
head_result = _git(root, "rev-parse", "HEAD")
|
|
189
|
-
if head_result.return_code != 0:
|
|
190
|
-
return RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
191
|
-
head = head_result.stdout.strip()
|
|
192
|
-
if not _matches_prepared_commit(root, request, head):
|
|
164
|
+
if commit_failure is not None:
|
|
165
|
+
return commit_failure
|
|
166
|
+
if not _matches_prepared_commit(root, request, head, checkpoint_path=checkpoint):
|
|
193
167
|
return RuntimeCommitResult("failed", "git_commit_content_mismatch", head)
|
|
194
168
|
hash_error = _record_runtime_commit_hash(request_path, head)
|
|
195
169
|
if hash_error:
|
|
196
170
|
return RuntimeCommitResult("failed", hash_error, head)
|
|
197
|
-
elif _matches_prepared_commit(root, request, head):
|
|
171
|
+
elif _matches_prepared_commit(root, request, head, checkpoint_path=checkpoint):
|
|
198
172
|
if request.runtime_commit_hash and request.runtime_commit_hash.lower() != head.lower():
|
|
199
173
|
return RuntimeCommitResult("failed", "runtime_commit_hash_mismatch")
|
|
200
174
|
recovered = True
|
|
@@ -209,6 +183,7 @@ def finalize_runtime_commit(
|
|
|
209
183
|
checkpoint,
|
|
210
184
|
commit_hash=head,
|
|
211
185
|
base_head=request.base_head,
|
|
186
|
+
project_root=root,
|
|
212
187
|
)
|
|
213
188
|
if checkpoint_error:
|
|
214
189
|
return RuntimeCommitResult("failed", checkpoint_error, head, recovered)
|
|
@@ -355,61 +330,85 @@ def finalize_accepted_workspace_commit(
|
|
|
355
330
|
if head != resolved_base:
|
|
356
331
|
return RuntimeCommitResult("failed", "unexpected_existing_commit")
|
|
357
332
|
|
|
333
|
+
new_head, commit_failure = _stage_and_commit_workspace(
|
|
334
|
+
root,
|
|
335
|
+
checkpoint_path=checkpoint,
|
|
336
|
+
request_path=request_path,
|
|
337
|
+
commit_message=commit_message,
|
|
338
|
+
allow_empty_workspace=True,
|
|
339
|
+
empty_head=head,
|
|
340
|
+
expected_base_head=head,
|
|
341
|
+
)
|
|
342
|
+
if commit_failure is not None:
|
|
343
|
+
return commit_failure
|
|
344
|
+
return RuntimeCommitResult("committed", "accepted_workspace_committed", new_head)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def _stage_and_commit_workspace(
|
|
348
|
+
root: Path,
|
|
349
|
+
*,
|
|
350
|
+
checkpoint_path: Path,
|
|
351
|
+
request_path: Path,
|
|
352
|
+
commit_message: str,
|
|
353
|
+
allow_empty_workspace: bool,
|
|
354
|
+
empty_head: str = "",
|
|
355
|
+
expected_base_head: str = "",
|
|
356
|
+
) -> tuple[str, RuntimeCommitResult | None]:
|
|
358
357
|
unmerged = _git(root, "ls-files", "-u")
|
|
359
358
|
if unmerged.return_code != 0:
|
|
360
|
-
return RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
359
|
+
return "", RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
361
360
|
if unmerged.stdout.strip():
|
|
362
|
-
return RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
361
|
+
return "", RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
363
362
|
|
|
364
363
|
changed, status_error = _workspace_changed_paths(
|
|
365
364
|
root,
|
|
366
|
-
checkpoint_path=
|
|
365
|
+
checkpoint_path=checkpoint_path,
|
|
367
366
|
request_path=request_path,
|
|
368
367
|
)
|
|
369
368
|
if status_error:
|
|
370
|
-
return RuntimeCommitResult("failed", status_error)
|
|
369
|
+
return "", RuntimeCommitResult("failed", status_error)
|
|
371
370
|
if any(_sensitive_commit_path(path) for path in changed):
|
|
372
|
-
return RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
371
|
+
return "", RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
373
372
|
bookkeeping_staged = _staged_bookkeeping_paths(
|
|
374
373
|
root,
|
|
375
|
-
checkpoint_path=
|
|
374
|
+
checkpoint_path=checkpoint_path,
|
|
376
375
|
request_path=request_path,
|
|
377
376
|
)
|
|
378
377
|
if bookkeeping_staged is None:
|
|
379
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
378
|
+
return "", RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
380
379
|
if bookkeeping_staged:
|
|
381
|
-
return RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
380
|
+
return "", RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
382
381
|
if not changed:
|
|
383
|
-
|
|
384
|
-
"not_needed",
|
|
385
|
-
|
|
386
|
-
head,
|
|
387
|
-
)
|
|
382
|
+
if allow_empty_workspace:
|
|
383
|
+
return "", RuntimeCommitResult("not_needed", "accepted_workspace_clean", empty_head)
|
|
384
|
+
return "", RuntimeCommitResult("failed", "empty_workspace_change")
|
|
388
385
|
|
|
389
386
|
staged = _stage_workspace(
|
|
390
387
|
root,
|
|
391
|
-
checkpoint_path=
|
|
388
|
+
checkpoint_path=checkpoint_path,
|
|
392
389
|
request_path=request_path,
|
|
393
390
|
)
|
|
394
391
|
if staged.return_code != 0:
|
|
395
|
-
return RuntimeCommitResult("failed", "git_stage_failed")
|
|
392
|
+
return "", RuntimeCommitResult("failed", "git_stage_failed")
|
|
396
393
|
staged_paths = _git(
|
|
397
394
|
root, "diff", "--cached", "--name-only", "--no-renames", "-z",
|
|
398
395
|
)
|
|
399
396
|
if staged_paths.return_code != 0:
|
|
400
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
397
|
+
return "", RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
401
398
|
staged_set = {path for path in staged_paths.stdout.split("\0") if path}
|
|
402
399
|
if staged_set != set(changed):
|
|
403
|
-
return RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
400
|
+
return "", RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
401
|
+
if not staged_set:
|
|
402
|
+
return "", RuntimeCommitResult("failed", "empty_staged_change")
|
|
404
403
|
unstaged_candidates = _workspace_has_unstaged_candidates(
|
|
405
404
|
root,
|
|
406
|
-
checkpoint_path=
|
|
405
|
+
checkpoint_path=checkpoint_path,
|
|
407
406
|
request_path=request_path,
|
|
408
407
|
)
|
|
409
408
|
if unstaged_candidates is None:
|
|
410
|
-
return RuntimeCommitResult("failed", "git_workspace_verification_failed")
|
|
409
|
+
return "", RuntimeCommitResult("failed", "git_workspace_verification_failed")
|
|
411
410
|
if unstaged_candidates:
|
|
412
|
-
return RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
411
|
+
return "", RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
413
412
|
|
|
414
413
|
committed = _git(
|
|
415
414
|
root,
|
|
@@ -418,26 +417,27 @@ def finalize_accepted_workspace_commit(
|
|
|
418
417
|
"commit", "-m", commit_message,
|
|
419
418
|
)
|
|
420
419
|
if committed.return_code != 0:
|
|
421
|
-
return RuntimeCommitResult("failed", "git_commit_failed")
|
|
420
|
+
return "", RuntimeCommitResult("failed", "git_commit_failed")
|
|
422
421
|
new_head_result = _git(root, "rev-parse", "HEAD")
|
|
423
422
|
if new_head_result.return_code != 0:
|
|
424
|
-
return RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
423
|
+
return "", RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
425
424
|
new_head = new_head_result.stdout.strip()
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
425
|
+
if expected_base_head:
|
|
426
|
+
parents = _git(root, "show", "-s", "--format=%P", new_head)
|
|
427
|
+
subject = _git(root, "show", "-s", "--format=%s", new_head)
|
|
428
|
+
committed_paths = _git(
|
|
429
|
+
root,
|
|
430
|
+
"diff-tree", "--no-commit-id", "--name-only", "--no-renames", "-r", "-z", new_head,
|
|
431
|
+
)
|
|
432
|
+
if any(result.return_code != 0 for result in (parents, subject, committed_paths)):
|
|
433
|
+
return "", RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
|
|
434
|
+
if not (
|
|
435
|
+
parents.stdout.strip().split() == [expected_base_head]
|
|
436
|
+
and subject.stdout.strip() == commit_message
|
|
437
|
+
and {path for path in committed_paths.stdout.split("\0") if path} == staged_set
|
|
438
|
+
):
|
|
439
|
+
return "", RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
|
|
440
|
+
return new_head, None
|
|
441
441
|
|
|
442
442
|
|
|
443
443
|
def _load_request(
|
|
@@ -521,7 +521,7 @@ def _workspace_changed_paths(
|
|
|
521
521
|
)
|
|
522
522
|
visible = [
|
|
523
523
|
path for path in _status_record_paths(result.stdout)
|
|
524
|
-
if path not in local_paths
|
|
524
|
+
if path not in local_paths and not _is_runtime_internal_path(path)
|
|
525
525
|
]
|
|
526
526
|
return tuple(dict.fromkeys(visible)), ""
|
|
527
527
|
|
|
@@ -579,7 +579,7 @@ def _staged_bookkeeping_paths(
|
|
|
579
579
|
)
|
|
580
580
|
return tuple(
|
|
581
581
|
path for path in staged.stdout.split("\0")
|
|
582
|
-
if path and path in local_paths
|
|
582
|
+
if path and (path in local_paths or _is_runtime_internal_path(path))
|
|
583
583
|
)
|
|
584
584
|
|
|
585
585
|
|
|
@@ -592,16 +592,25 @@ def _stage_workspace(
|
|
|
592
592
|
staged = _git(project_root, "add", "-A", "--", ".")
|
|
593
593
|
if staged.return_code != 0:
|
|
594
594
|
return staged
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
595
|
+
local_paths = _runtime_bookkeeping_paths(
|
|
596
|
+
project_root,
|
|
597
|
+
checkpoint_path=checkpoint_path,
|
|
598
|
+
request_path=request_path,
|
|
599
|
+
)
|
|
600
|
+
cached = _git(project_root, "diff", "--cached", "--name-only", "--no-renames", "-z")
|
|
601
|
+
if cached.return_code != 0:
|
|
602
|
+
return cached
|
|
603
|
+
exclude_paths = sorted(
|
|
604
|
+
{
|
|
605
|
+
path
|
|
606
|
+
for path in cached.stdout.split("\0")
|
|
607
|
+
if path and (path in local_paths or _is_runtime_internal_path(path))
|
|
608
|
+
}
|
|
609
|
+
| set(local_paths)
|
|
610
|
+
)
|
|
611
|
+
if not exclude_paths:
|
|
612
|
+
return staged
|
|
613
|
+
local_pathspecs = [f":(top,literal){path}" for path in exclude_paths]
|
|
605
614
|
return _git(project_root, "reset", "-q", "HEAD", "--", *local_pathspecs)
|
|
606
615
|
|
|
607
616
|
|
|
@@ -632,12 +641,18 @@ def _workspace_has_unstaged_candidates(
|
|
|
632
641
|
path
|
|
633
642
|
for output in (unstaged.stdout, untracked.stdout)
|
|
634
643
|
for path in output.split("\0")
|
|
635
|
-
if path and path not in local_paths
|
|
644
|
+
if path and path not in local_paths and not _is_runtime_internal_path(path)
|
|
636
645
|
}
|
|
637
646
|
return bool(candidates)
|
|
638
647
|
|
|
639
648
|
|
|
640
|
-
def _matches_prepared_commit(
|
|
649
|
+
def _matches_prepared_commit(
|
|
650
|
+
project_root: Path,
|
|
651
|
+
request: RuntimeCommitRequest,
|
|
652
|
+
head: str,
|
|
653
|
+
*,
|
|
654
|
+
checkpoint_path: Path | None = None,
|
|
655
|
+
) -> bool:
|
|
641
656
|
parents = _git(project_root, "show", "-s", "--format=%P", head)
|
|
642
657
|
subject = _git(project_root, "show", "-s", "--format=%s", head)
|
|
643
658
|
paths = _git(
|
|
@@ -653,13 +668,28 @@ def _matches_prepared_commit(project_root: Path, request: RuntimeCommitRequest,
|
|
|
653
668
|
artifact_prefix + REQUEST_FILENAME,
|
|
654
669
|
artifact_prefix + "workflow-checkpoint.json",
|
|
655
670
|
}
|
|
656
|
-
|
|
671
|
+
if not (
|
|
657
672
|
len(parent_list) == 1
|
|
658
673
|
and parent_list[0].lower() == request.base_head.lower()
|
|
659
674
|
and subject.stdout.strip() == request.commit_message
|
|
660
675
|
and bool(changed)
|
|
661
676
|
and changed.isdisjoint(causal_bookkeeping)
|
|
662
|
-
|
|
677
|
+
and not any(_sensitive_commit_path(path) for path in changed)
|
|
678
|
+
):
|
|
679
|
+
return False
|
|
680
|
+
if checkpoint_path is not None:
|
|
681
|
+
unmerged = _git(project_root, "ls-files", "-u")
|
|
682
|
+
if unmerged.return_code != 0 or unmerged.stdout.strip():
|
|
683
|
+
return False
|
|
684
|
+
request_path = checkpoint_path.parent / REQUEST_FILENAME
|
|
685
|
+
unstaged = _workspace_has_unstaged_candidates(
|
|
686
|
+
project_root,
|
|
687
|
+
checkpoint_path=checkpoint_path,
|
|
688
|
+
request_path=request_path,
|
|
689
|
+
)
|
|
690
|
+
if unstaged is not False:
|
|
691
|
+
return False
|
|
692
|
+
return True
|
|
663
693
|
|
|
664
694
|
|
|
665
695
|
def _record_runtime_commit_hash(path: Path, commit_hash: str) -> str:
|
|
@@ -679,13 +709,24 @@ def _finalize_checkpoint(
|
|
|
679
709
|
*,
|
|
680
710
|
commit_hash: str,
|
|
681
711
|
base_head: str,
|
|
712
|
+
project_root: Path | None = None,
|
|
682
713
|
) -> str:
|
|
683
714
|
"""Finalize COMMITTED and persist the Runtime's verified commit receipt."""
|
|
684
|
-
state = load_checkpoint_state(path)
|
|
715
|
+
state = load_checkpoint_state(path, project_root=project_root)
|
|
685
716
|
if not state.valid:
|
|
686
717
|
return "checkpoint_commit_finalization_rejected"
|
|
687
718
|
if state.semantic_complete:
|
|
688
|
-
|
|
719
|
+
raw_semantic = (
|
|
720
|
+
state.raw_data.get(semantic_state_key(state.semantic.workflow_type), {})
|
|
721
|
+
if isinstance(state.raw_data, Mapping)
|
|
722
|
+
else {}
|
|
723
|
+
)
|
|
724
|
+
if isinstance(raw_semantic, Mapping):
|
|
725
|
+
existing_hash = str(raw_semantic.get("runtime_commit_hash") or "").strip().lower()
|
|
726
|
+
existing_base = str(raw_semantic.get("runtime_base_head") or "").strip().lower()
|
|
727
|
+
if existing_hash == commit_hash.lower() and existing_base == base_head.lower():
|
|
728
|
+
return ""
|
|
729
|
+
return "checkpoint_commit_receipt_mismatch"
|
|
689
730
|
if not state.semantic_commit_ready:
|
|
690
731
|
return "checkpoint_commit_finalization_rejected"
|
|
691
732
|
data = dict(state.raw_data)
|
|
@@ -722,41 +763,40 @@ def _finalize_checkpoint(
|
|
|
722
763
|
"runtime_commit_hash": commit_hash,
|
|
723
764
|
}
|
|
724
765
|
)
|
|
725
|
-
candidate = validate_checkpoint_data(
|
|
766
|
+
candidate = validate_checkpoint_data(
|
|
767
|
+
data, path=path, exists=True, project_root=project_root
|
|
768
|
+
)
|
|
726
769
|
if not candidate.valid or not candidate.semantic_complete:
|
|
727
770
|
return "checkpoint_commit_finalization_rejected"
|
|
728
771
|
if _write_json_atomic(path, data):
|
|
729
772
|
return "checkpoint_commit_finalization_failed"
|
|
730
|
-
finalized = load_checkpoint_state(path)
|
|
773
|
+
finalized = load_checkpoint_state(path, project_root=project_root)
|
|
731
774
|
return "" if finalized.semantic_complete else "checkpoint_commit_finalization_rejected"
|
|
732
775
|
|
|
733
776
|
|
|
734
777
|
def _write_json_atomic(path: Path, data: Mapping[str, object]) -> str:
|
|
735
|
-
temp_path: str | None = None
|
|
736
778
|
try:
|
|
737
|
-
path
|
|
738
|
-
fd, temp_path = tempfile.mkstemp(prefix=f".{path.name}.", suffix=".tmp", dir=path.parent)
|
|
739
|
-
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
740
|
-
json.dump(data, handle, indent=2, ensure_ascii=False)
|
|
741
|
-
handle.write("\n")
|
|
742
|
-
os.replace(temp_path, path)
|
|
779
|
+
write_json_atomic(path, data)
|
|
743
780
|
except OSError:
|
|
744
|
-
if temp_path:
|
|
745
|
-
try:
|
|
746
|
-
os.unlink(temp_path)
|
|
747
|
-
except OSError:
|
|
748
|
-
pass
|
|
749
781
|
return "atomic_json_write_failed"
|
|
750
782
|
return ""
|
|
751
783
|
|
|
752
784
|
|
|
753
785
|
def _git(project_root: Path, *args: str) -> _GitResult:
|
|
786
|
+
command_args = [str(arg) for arg in args]
|
|
787
|
+
global_args: tuple[str, ...] = ()
|
|
788
|
+
if "commit" in command_args:
|
|
789
|
+
commit_idx = command_args.index("commit")
|
|
790
|
+
global_args = commit_identity_global_args(project_root)
|
|
791
|
+
tail = commit_args_without_signing(tuple(command_args[commit_idx:]))
|
|
792
|
+
command_args = [*command_args[:commit_idx], *tail]
|
|
754
793
|
completed = subprocess.run(
|
|
755
|
-
["git", *
|
|
756
|
-
cwd=project_root,
|
|
794
|
+
["git", *global_args, "-C", str(project_root), *command_args],
|
|
757
795
|
stdout=subprocess.PIPE,
|
|
758
796
|
stderr=subprocess.PIPE,
|
|
759
797
|
text=True,
|
|
798
|
+
encoding="utf-8",
|
|
799
|
+
errors="replace",
|
|
760
800
|
check=False,
|
|
761
801
|
)
|
|
762
802
|
return _GitResult(completed.returncode, completed.stdout, completed.stderr)
|
|
@@ -54,12 +54,28 @@ SOURCE_EXTENSIONS = (
|
|
|
54
54
|
|
|
55
55
|
DEFAULT_EXCLUDES = (
|
|
56
56
|
".git",
|
|
57
|
+
".prizmkit",
|
|
58
|
+
".claude",
|
|
59
|
+
".codebuddy",
|
|
60
|
+
".agents",
|
|
61
|
+
".agent",
|
|
62
|
+
".codex",
|
|
63
|
+
".cursor",
|
|
64
|
+
".pi",
|
|
57
65
|
"node_modules",
|
|
58
66
|
"__pycache__",
|
|
59
67
|
".pytest_cache",
|
|
60
68
|
".mypy_cache",
|
|
69
|
+
".venv",
|
|
70
|
+
"venv",
|
|
61
71
|
"dist",
|
|
62
72
|
"build",
|
|
73
|
+
"target",
|
|
74
|
+
"coverage",
|
|
75
|
+
".next",
|
|
76
|
+
".nuxt",
|
|
77
|
+
".turbo",
|
|
78
|
+
".svelte-kit",
|
|
63
79
|
"vendor",
|
|
64
80
|
)
|
|
65
81
|
|
|
@@ -247,13 +263,30 @@ def _text_final_verdict(args: argparse.Namespace) -> HelperResult:
|
|
|
247
263
|
return HelperResult("REVIEW_INCOMPLETE", False, {"path": str(target), "reason": "final_result_missing"}, 1)
|
|
248
264
|
|
|
249
265
|
verdict = ""
|
|
266
|
+
accepted: int | None = None
|
|
267
|
+
fixed: int | None = None
|
|
268
|
+
unresolved: int | None = None
|
|
250
269
|
for line in lines[final_indexes[-1] + 1:]:
|
|
251
270
|
stripped = line.strip()
|
|
252
271
|
if stripped.startswith("## "):
|
|
253
272
|
break
|
|
254
|
-
if stripped.startswith("- Verdict:"):
|
|
273
|
+
if stripped.startswith("- Verdict:") and not verdict:
|
|
255
274
|
verdict = stripped[len("- Verdict:"):].strip()
|
|
256
|
-
|
|
275
|
+
elif stripped.startswith("- Accepted Findings:"):
|
|
276
|
+
try:
|
|
277
|
+
accepted = int(stripped[len("- Accepted Findings:"):].strip())
|
|
278
|
+
except ValueError:
|
|
279
|
+
pass
|
|
280
|
+
elif stripped.startswith("- Fixed Findings:"):
|
|
281
|
+
try:
|
|
282
|
+
fixed = int(stripped[len("- Fixed Findings:"):].strip())
|
|
283
|
+
except ValueError:
|
|
284
|
+
pass
|
|
285
|
+
elif stripped.startswith("- Unresolved Findings:"):
|
|
286
|
+
try:
|
|
287
|
+
unresolved = int(stripped[len("- Unresolved Findings:"):].strip())
|
|
288
|
+
except ValueError:
|
|
289
|
+
pass
|
|
257
290
|
|
|
258
291
|
markers = {
|
|
259
292
|
"PASS": "REVIEW_PASS",
|
|
@@ -262,6 +295,35 @@ def _text_final_verdict(args: argparse.Namespace) -> HelperResult:
|
|
|
262
295
|
marker = markers.get(verdict)
|
|
263
296
|
if not marker:
|
|
264
297
|
return HelperResult("REVIEW_INVALID", False, {"path": str(target), "verdict": verdict or None}, 1)
|
|
298
|
+
|
|
299
|
+
if verdict == "PASS":
|
|
300
|
+
verification_indexes = [
|
|
301
|
+
index
|
|
302
|
+
for index, line in enumerate(lines[: final_indexes[-1]])
|
|
303
|
+
if line.strip() == "## Final Verification"
|
|
304
|
+
]
|
|
305
|
+
if verification_indexes:
|
|
306
|
+
for line in lines[verification_indexes[-1] + 1 : final_indexes[-1]]:
|
|
307
|
+
stripped = line.strip()
|
|
308
|
+
if stripped.startswith("## "):
|
|
309
|
+
break
|
|
310
|
+
if stripped == "- Status: FAILED":
|
|
311
|
+
return HelperResult(
|
|
312
|
+
"REVIEW_INVALID",
|
|
313
|
+
False,
|
|
314
|
+
{"path": str(target), "verdict": verdict, "reason": "final_verification_failed"},
|
|
315
|
+
1,
|
|
316
|
+
)
|
|
317
|
+
if (unresolved is not None and unresolved > 0) or (
|
|
318
|
+
accepted is not None and fixed is not None and fixed != accepted
|
|
319
|
+
):
|
|
320
|
+
return HelperResult(
|
|
321
|
+
"REVIEW_INVALID",
|
|
322
|
+
False,
|
|
323
|
+
{"path": str(target), "verdict": verdict, "reason": "unfixed_or_unresolved_findings"},
|
|
324
|
+
1,
|
|
325
|
+
)
|
|
326
|
+
|
|
265
327
|
return HelperResult(marker, True, {"path": str(target), "verdict": verdict})
|
|
266
328
|
|
|
267
329
|
|
|
@@ -343,9 +405,20 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
343
405
|
if not command:
|
|
344
406
|
return HelperResult("PROCESS_START_FAILED", False, {"reason": "missing_command"}, 2)
|
|
345
407
|
cwd = _path(args.cwd or ".")
|
|
346
|
-
|
|
347
|
-
|
|
408
|
+
opened_handles = []
|
|
409
|
+
stdout_target = subprocess.DEVNULL
|
|
410
|
+
stderr_target = subprocess.DEVNULL
|
|
348
411
|
try:
|
|
412
|
+
if args.stdout:
|
|
413
|
+
stdout_path = _path(args.stdout)
|
|
414
|
+
stdout_path.parent.mkdir(parents=True, exist_ok=True)
|
|
415
|
+
stdout_target = open(stdout_path, "a", encoding="utf-8")
|
|
416
|
+
opened_handles.append(stdout_target)
|
|
417
|
+
if args.stderr:
|
|
418
|
+
stderr_path = _path(args.stderr)
|
|
419
|
+
stderr_path.parent.mkdir(parents=True, exist_ok=True)
|
|
420
|
+
stderr_target = open(stderr_path, "a", encoding="utf-8")
|
|
421
|
+
opened_handles.append(stderr_target)
|
|
349
422
|
process = subprocess.Popen(
|
|
350
423
|
[str(part) for part in command],
|
|
351
424
|
cwd=cwd,
|
|
@@ -358,9 +431,11 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
358
431
|
except OSError as exc:
|
|
359
432
|
return HelperResult("PROCESS_START_FAILED", False, {"reason": type(exc).__name__, "error": str(exc)}, 1)
|
|
360
433
|
finally:
|
|
361
|
-
for target in
|
|
362
|
-
|
|
434
|
+
for target in opened_handles:
|
|
435
|
+
try:
|
|
363
436
|
target.close()
|
|
437
|
+
except OSError:
|
|
438
|
+
pass
|
|
364
439
|
if args.pid_file:
|
|
365
440
|
pid_file = _path(args.pid_file)
|
|
366
441
|
pid_file.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -368,6 +443,12 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
368
443
|
return HelperResult("PROCESS_STARTED", True, {"pid": process.pid, "pid_file": str(_path(args.pid_file)) if args.pid_file else None})
|
|
369
444
|
|
|
370
445
|
|
|
446
|
+
def _status_is_ready(status: int, expected_statuses: list[int] | None) -> bool:
|
|
447
|
+
if expected_statuses:
|
|
448
|
+
return status in expected_statuses
|
|
449
|
+
return status < 500
|
|
450
|
+
|
|
451
|
+
|
|
371
452
|
def _web_wait_ready(args: argparse.Namespace) -> HelperResult:
|
|
372
453
|
deadline = time.monotonic() + float(args.timeout)
|
|
373
454
|
statuses: list[str] = []
|
|
@@ -377,11 +458,11 @@ def _web_wait_ready(args: argparse.Namespace) -> HelperResult:
|
|
|
377
458
|
with urllib.request.urlopen(request, timeout=float(args.request_timeout)) as response:
|
|
378
459
|
status = int(response.status)
|
|
379
460
|
statuses.append(str(status))
|
|
380
|
-
if status
|
|
461
|
+
if _status_is_ready(status, args.status):
|
|
381
462
|
return HelperResult("READY", True, {"url": args.url, "status": status})
|
|
382
463
|
except urllib.error.HTTPError as exc:
|
|
383
464
|
statuses.append(str(exc.code))
|
|
384
|
-
if int(exc.code)
|
|
465
|
+
if _status_is_ready(int(exc.code), args.status):
|
|
385
466
|
return HelperResult("READY", True, {"url": args.url, "status": int(exc.code)})
|
|
386
467
|
except (OSError, urllib.error.URLError, TimeoutError) as exc:
|
|
387
468
|
statuses.append(type(exc).__name__)
|
|
@@ -519,7 +600,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
519
600
|
wait_ready.add_argument("--timeout", type=float, default=30.0)
|
|
520
601
|
wait_ready.add_argument("--interval", type=float, default=2.0)
|
|
521
602
|
wait_ready.add_argument("--request-timeout", type=float, default=2.0)
|
|
522
|
-
wait_ready.add_argument("--status", action="append", type=int, default=
|
|
603
|
+
wait_ready.add_argument("--status", action="append", type=int, default=None)
|
|
523
604
|
_add_json(wait_ready)
|
|
524
605
|
wait_ready.set_defaults(func=_web_wait_ready)
|
|
525
606
|
|