okstra 0.229.0 → 0.230.0
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/README.md +1 -5
- package/dist/cli-registry.mjs +0 -18
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/lifecycle/doctor.mjs +0 -15
- package/dist/commands/lifecycle/doctor.mjs.map +1 -1
- package/dist/lib/skill-catalog.mjs +4 -4
- package/dist/lib/skill-catalog.mjs.map +1 -1
- package/docs/architecture/storage-model.md +105 -16
- package/docs/architecture.md +13 -14
- package/docs/contributor-change-matrix.md +5 -5
- package/docs/project-structure-overview.md +11 -18
- package/package.json +1 -2
- package/runtime/BUILD.json +2 -2
- package/runtime/bin/lib/okstra/interactive.sh +2 -1
- package/runtime/prompts/launch.template.md +5 -5
- package/runtime/prompts/lead/convergence.md +4 -4
- package/runtime/prompts/lead/okstra-lead-contract.md +14 -13
- package/runtime/prompts/lead/phase-routing.md +1 -1
- package/runtime/prompts/lead/report-writer.md +3 -3
- package/runtime/prompts/lead/team-contract.md +3 -3
- package/runtime/python/okstra_ctl/agent/invocation.py +142 -5
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +31 -1
- package/runtime/python/okstra_ctl/cmux.py +4 -2
- package/runtime/python/okstra_ctl/code_review_census.py +194 -0
- package/runtime/python/okstra_ctl/code_review_coverage.py +3 -1
- package/runtime/python/okstra_ctl/code_review_scope.py +9 -6
- package/runtime/python/okstra_ctl/code_review_target.py +38 -2
- package/runtime/python/okstra_ctl/conformance.py +30 -0
- package/runtime/python/okstra_ctl/conformance_evidence.py +235 -0
- package/runtime/python/okstra_ctl/correction_round.py +19 -13
- package/runtime/python/okstra_ctl/dispatch_core.py +1 -1
- package/runtime/python/okstra_ctl/dispatch_state.py +1 -0
- package/runtime/python/okstra_ctl/generated_input.py +21 -0
- package/runtime/python/okstra_ctl/ids.py +1 -41
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +30 -0
- package/runtime/python/okstra_ctl/interactive_cli.py +5 -0
- package/runtime/python/okstra_ctl/locks.py +28 -1
- package/runtime/python/okstra_ctl/model_io/renderers.py +7 -0
- package/runtime/python/okstra_ctl/paths.py +75 -33
- package/runtime/python/okstra_ctl/phases/catalog.py +3 -0
- package/runtime/python/okstra_ctl/phases/change_impact_analysis/spec.md +2 -2
- package/runtime/python/okstra_ctl/phases/discussion/spec.md +63 -63
- package/runtime/python/okstra_ctl/phases/discussion/wizard.py +2 -11
- package/runtime/python/okstra_ctl/phases/error_analysis/report_assets/error-analysis-input.template.md +1 -1
- package/runtime/python/okstra_ctl/phases/error_analysis/spec.md +2 -2
- package/runtime/python/okstra_ctl/phases/feature_analysis/spec.md +1 -1
- package/runtime/python/okstra_ctl/phases/final_verification/profile.md +4 -4
- package/runtime/python/okstra_ctl/phases/final_verification/report_assets/final-verification-input.template.md +1 -1
- package/runtime/python/okstra_ctl/phases/final_verification/spec.md +4 -4
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +2 -2
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-executor.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +4 -4
- package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation-input.template.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation/spec.md +4 -4
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/spec.md +2 -2
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +11 -11
- package/runtime/python/okstra_ctl/phases/implementation_planning/plan_body.py +14 -0
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +4 -4
- package/runtime/python/okstra_ctl/phases/implementation_planning/report_assets/implementation-planning-input.template.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/spec.md +1 -1
- package/runtime/python/okstra_ctl/phases/project_analysis/spec.md +2 -2
- package/runtime/python/okstra_ctl/phases/release_handoff/entry.py +7 -3
- package/runtime/python/okstra_ctl/phases/release_handoff/report_assets/release-handoff-input.template.md +1 -1
- package/runtime/python/okstra_ctl/phases/release_handoff/spec.md +4 -4
- package/runtime/python/okstra_ctl/phases/technical_verification/spec.md +1 -1
- package/runtime/python/okstra_ctl/process_group.py +26 -3
- package/runtime/python/okstra_ctl/qa_commands.py +5 -1
- package/runtime/python/okstra_ctl/recap.py +1 -2
- package/runtime/python/okstra_ctl/render.py +10 -2
- package/runtime/python/okstra_ctl/report_finalize.py +3 -3
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +5 -0
- package/runtime/python/okstra_ctl/run.py +24 -20
- package/runtime/python/okstra_ctl/stage_command_commits.py +143 -0
- package/runtime/python/okstra_ctl/verification_capture.py +291 -0
- package/runtime/python/okstra_ctl/verification_conformance.py +28 -9
- package/runtime/python/okstra_ctl/verification_dispatch.py +130 -0
- package/runtime/python/okstra_ctl/verification_evidence.py +652 -0
- package/runtime/python/okstra_ctl/verification_generation.py +22 -12
- package/runtime/python/okstra_ctl/verification_input_ref.py +9 -0
- package/runtime/python/okstra_ctl/verification_input_types.py +2 -0
- package/runtime/python/okstra_ctl/verification_inputs.py +73 -2
- package/runtime/python/okstra_ctl/verification_invocation.py +139 -0
- package/runtime/python/okstra_ctl/verification_target.py +10 -3
- package/runtime/python/okstra_ctl/wizard/registry.py +2 -1
- package/runtime/python/okstra_ctl/wizard/render.py +2 -1
- package/runtime/python/okstra_ctl/wizard/sources.py +14 -3
- package/runtime/python/okstra_ctl/wizard/steps_identity.py +2 -1
- package/runtime/python/okstra_ctl/worker_runner.py +1 -1
- package/runtime/python/okstra_ctl/worktree_lock_cli.py +70 -17
- package/runtime/python/okstra_ctl/worktree_registry.py +4 -0
- package/runtime/skills/okstra-code-review/SKILL.md +7 -5
- package/runtime/skills/okstra-code-review/references/census-rules.md +2 -2
- package/runtime/skills/okstra-explain-flow/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +6 -6
- package/runtime/skills/okstra-schedule-gen/SKILL.md +3 -3
- package/runtime/skills/okstra-setup/SKILL.md +2 -3
- package/runtime/validators/validate-run.py +110 -19
- package/docs/cli.md +0 -1060
- package/docs/container.md +0 -100
- package/docs/follow-ups/2026-07-10-final-report-option-3.md +0 -51
- package/docs/performance-improvement-plan-v2.md +0 -369
- package/runtime/python/okstra_ctl/container.py +0 -702
- package/runtime/python/okstra_ctl/rollup.py +0 -241
- package/runtime/python/okstra_ctl/usage_report.py +0 -362
- package/runtime/skills/okstra-container-build/SKILL.md +0 -139
- package/runtime/skills/okstra-inspect/SKILL.md +0 -100
- package/runtime/skills/okstra-inspect/facets/cost.md +0 -84
- package/runtime/skills/okstra-inspect/facets/error-zip.md +0 -41
- package/runtime/skills/okstra-inspect/facets/errors.md +0 -69
- package/runtime/skills/okstra-inspect/facets/history.md +0 -86
- package/runtime/skills/okstra-inspect/facets/logs.md +0 -89
- package/runtime/skills/okstra-inspect/facets/recap.md +0 -167
- package/runtime/skills/okstra-inspect/facets/report.md +0 -57
- package/runtime/skills/okstra-inspect/facets/run-audit.md +0 -34
- package/runtime/skills/okstra-inspect/facets/status.md +0 -163
- package/runtime/skills/okstra-inspect/facets/time.md +0 -57
- package/runtime/skills/okstra-rollup/SKILL.md +0 -75
- package/runtime/skills/okstra-usage/SKILL.md +0 -71
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Input documents that prepare writes into a run's brief slot."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from okstra_project.state import parse_task_key
|
|
7
|
+
|
|
8
|
+
from .phases.discussion.store import DiscussionStore
|
|
9
|
+
from .phases.release_handoff.entry import handoff_input_path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def names_generated_input_document(project_root: Path, task_key: str, brief: str) -> bool:
|
|
13
|
+
"""True when ``brief`` is a release-handoff or discussion input document of the task."""
|
|
14
|
+
if not brief:
|
|
15
|
+
return False
|
|
16
|
+
_, task_group, task_id = parse_task_key(task_key)
|
|
17
|
+
generated = {
|
|
18
|
+
handoff_input_path(project_root, task_group, task_id),
|
|
19
|
+
DiscussionStore(project_root, task_key).input_path,
|
|
20
|
+
}
|
|
21
|
+
return (project_root / brief).resolve() in {path.resolve() for path in generated}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Run identifier construction, parsing, and segment escaping."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
-
import hashlib as _hashlib
|
|
5
4
|
import re as _re
|
|
6
5
|
from typing import Dict
|
|
7
6
|
|
|
8
|
-
# leaf 규칙 모듈에서 바로 가져온다. state 를 거치면 okstra_ctl 패키지 __init__ 이
|
|
9
|
-
# 상태 접근자 전체를 끌어와 okstra_project ↔ okstra_ctl 순환이 된다.
|
|
10
|
-
from okstra_project.slug import slugify as _slugify
|
|
11
|
-
|
|
12
|
-
# docker compose project name 길이 상한. compose 는 [a-z0-9][a-z0-9_-]* 만 허용한다.
|
|
13
|
-
CONTAINER_PROJECT_NAME_MAX = 60
|
|
14
7
|
|
|
15
8
|
|
|
16
9
|
# runId 형식: "<project-id>/<task-group>/<task-id>/<task-type>/r<run-seq>"
|
|
@@ -78,36 +71,3 @@ def _escape_segment_for_join(segment: str) -> str:
|
|
|
78
71
|
def slugify_task_segment(value: str) -> str:
|
|
79
72
|
"""Match okstra.sh slugify_value for task directory segments."""
|
|
80
73
|
return _re.sub(r"[^a-z0-9]+", "-", value.lower()).strip("-")
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def build_container_run_trace(project_id: str, group: str, task_id: str) -> str:
|
|
84
|
-
"""container 배포의 `okstra.run-trace` 라벨값을 합친다 → 'okstra-container-<slug>'.
|
|
85
|
-
|
|
86
|
-
세그먼트는 task_dir 가 쓰는 slugify_task_segment 와 동일 규칙으로 정규화해
|
|
87
|
-
라벨 slug 가 프로젝트 디스크 경로 slug 와 분기하지 않게 한다.
|
|
88
|
-
"""
|
|
89
|
-
seg = slugify_task_segment
|
|
90
|
-
return f"okstra-container-{seg(project_id)}-{seg(group)}-{seg(task_id)}"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def compose_project_name(project_id: str, task_group: str, task_id: str) -> str:
|
|
94
|
-
"""docker compose project name 을 합친다(순수 계산).
|
|
95
|
-
|
|
96
|
-
세그먼트 정규화는 ``paths.task_dir`` 가 쓰는 slug 함수(okstra_project.state.
|
|
97
|
-
slugify)와 동일 함수를 써서 라벨(이 이름이 SSOT)↔디스크 경로의 slug 가
|
|
98
|
-
분기하지 않게 한다. 상한(``CONTAINER_PROJECT_NAME_MAX``) 초과 시 읽기 좋은
|
|
99
|
-
본문을 앞에서 자르고 끝에 전체 이름의 해시 8자리를 붙인다 — 단순 prefix-cut 은
|
|
100
|
-
task_group 만 다른 두 task-key 를 같은 이름으로 collapse 시켜(라벨 SSOT 충돌로
|
|
101
|
-
한 task 의 down 이 형제 task 컨테이너까지 회수) 위험하므로, 해시로 distinct 를
|
|
102
|
-
보장하고 상한도 항상 만족시킨다."""
|
|
103
|
-
def seg(v: str) -> str:
|
|
104
|
-
return _slugify(v) or "x" # 빈 슬러그 방지(compose 는 [a-z0-9] 시작 요구)
|
|
105
|
-
|
|
106
|
-
proj, grp, task = seg(project_id), seg(task_group), seg(task_id)
|
|
107
|
-
name = f"okstra-{proj}-{grp}-{task}"
|
|
108
|
-
if len(name) <= CONTAINER_PROJECT_NAME_MAX:
|
|
109
|
-
return name
|
|
110
|
-
digest = _hashlib.sha1(name.encode("utf-8")).hexdigest()[:8]
|
|
111
|
-
body_budget = CONTAINER_PROJECT_NAME_MAX - len("okstra-") - 1 - len(digest)
|
|
112
|
-
body = f"{proj}-{grp}-{task}"[:body_budget].rstrip("-")
|
|
113
|
-
return f"okstra-{body}-{digest}"
|
|
@@ -25,6 +25,8 @@ from .agent.invocation import (
|
|
|
25
25
|
verify_agent_invocation,
|
|
26
26
|
)
|
|
27
27
|
from .path_hints import hydrate_active_run_context
|
|
28
|
+
from .verification_dispatch import VerificationDispatchError, seal_dispatch_generation
|
|
29
|
+
from .verification_invocation import VerificationGenerationReference
|
|
28
30
|
from .report_inputs import report_narrative_path, uses_report_contract_v3
|
|
29
31
|
from .report_synthesis_packet import (
|
|
30
32
|
ReportSynthesisPacketError,
|
|
@@ -190,6 +192,7 @@ class _PromptItem:
|
|
|
190
192
|
resources: tuple["_PromptResource", ...] = ()
|
|
191
193
|
temp_path: Path | None = None
|
|
192
194
|
stage_extract: str = ""
|
|
195
|
+
verification_generation: VerificationGenerationReference | None = None
|
|
193
196
|
|
|
194
197
|
|
|
195
198
|
@dataclass(frozen=True)
|
|
@@ -496,6 +499,12 @@ def _prepare_prompt_item(
|
|
|
496
499
|
if item.existed:
|
|
497
500
|
_validate_existing_prompt(context, prepared_item)
|
|
498
501
|
return prepared_item
|
|
502
|
+
# A published prompt's metadata already names its generation and
|
|
503
|
+
# `verify_agent_invocation` checks that binding; sealing again on reuse would
|
|
504
|
+
# recapture a tree the verifier's own run may have changed.
|
|
505
|
+
prepared_item = replace(
|
|
506
|
+
prepared_item, verification_generation=_seal_generation(context, item),
|
|
507
|
+
)
|
|
499
508
|
temp_path: Path | None = None
|
|
500
509
|
try:
|
|
501
510
|
item.final_path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -540,9 +549,28 @@ def _prepare_prompt_item(
|
|
|
540
549
|
resources=resources,
|
|
541
550
|
temp_path=temp_path,
|
|
542
551
|
stage_extract=item.stage_extract,
|
|
552
|
+
verification_generation=prepared_item.verification_generation,
|
|
543
553
|
)
|
|
544
554
|
|
|
545
555
|
|
|
556
|
+
def _seal_generation(
|
|
557
|
+
context: _MaterializationContext,
|
|
558
|
+
item: _PromptItem,
|
|
559
|
+
) -> VerificationGenerationReference | None:
|
|
560
|
+
try:
|
|
561
|
+
return seal_dispatch_generation(
|
|
562
|
+
context.project_root, context.request.run_manifest_path, context.manifest,
|
|
563
|
+
context.active_context, audience=item.plan.duty_audience,
|
|
564
|
+
dispatch_kind="initial",
|
|
565
|
+
)
|
|
566
|
+
except VerificationDispatchError as exc:
|
|
567
|
+
raise InitialPromptMaterializationError(
|
|
568
|
+
"required_input_missing" if exc.missing_executor_result
|
|
569
|
+
else "validation_failed",
|
|
570
|
+
f"verification generation: {exc}",
|
|
571
|
+
) from exc
|
|
572
|
+
|
|
573
|
+
|
|
546
574
|
def _with_prompt_resources(
|
|
547
575
|
item: _PromptItem,
|
|
548
576
|
resources: tuple[_PromptResource, ...],
|
|
@@ -556,6 +584,7 @@ def _with_prompt_resources(
|
|
|
556
584
|
resources=resources,
|
|
557
585
|
temp_path=item.temp_path,
|
|
558
586
|
stage_extract=item.stage_extract,
|
|
587
|
+
verification_generation=item.verification_generation,
|
|
559
588
|
)
|
|
560
589
|
|
|
561
590
|
|
|
@@ -710,6 +739,7 @@ def _agent_invocation_request(
|
|
|
710
739
|
duty_id=identity.duty_id if identity is not None else None,
|
|
711
740
|
invocation_ref=invocation_id if identity is not None else None,
|
|
712
741
|
attempt=1,
|
|
742
|
+
verification_generation=item.verification_generation,
|
|
713
743
|
)
|
|
714
744
|
|
|
715
745
|
|
|
@@ -15,6 +15,7 @@ from pathlib import Path
|
|
|
15
15
|
|
|
16
16
|
from . import next_phase
|
|
17
17
|
from .ids import slugify_task_segment
|
|
18
|
+
from .generated_input import names_generated_input_document
|
|
18
19
|
from .implementation_outcome import reconcile_implementation_outcome
|
|
19
20
|
from .json_boundary import JsonBoundaryError, load_owned_object
|
|
20
21
|
from .paths import RunRef, task_dir
|
|
@@ -109,6 +110,8 @@ def _autofill(args: argparse.Namespace) -> int:
|
|
|
109
110
|
task_type = ""
|
|
110
111
|
if args.need_brief:
|
|
111
112
|
brief = (data.get("taskBriefPath") or "").strip()
|
|
113
|
+
if names_generated_input_document(Path(args.project_root), args.task_key, brief):
|
|
114
|
+
brief = ""
|
|
112
115
|
if args.need_type:
|
|
113
116
|
# 포인터 판정은 파이썬이 갖는다 — `ready` 가 아니면 빈 문자열이라
|
|
114
117
|
# 셸이 센티널 목록을 따로 들고 있을 이유가 없다.
|
|
@@ -195,6 +198,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
195
198
|
|
|
196
199
|
autofill = sub.add_parser("autofill")
|
|
197
200
|
autofill.add_argument("--manifest", required=True)
|
|
201
|
+
autofill.add_argument("--project-root", required=True)
|
|
202
|
+
autofill.add_argument("--task-key", required=True)
|
|
198
203
|
autofill.add_argument("--need-brief", action="store_true")
|
|
199
204
|
autofill.add_argument("--need-type", action="store_true")
|
|
200
205
|
autofill.set_defaults(handler=_autofill)
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import contextlib
|
|
5
5
|
import fcntl
|
|
6
6
|
import hashlib
|
|
7
|
+
from collections.abc import Callable, Iterator
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from .ids import _escape_segment_for_join, _safe_fs_segment
|
|
@@ -85,6 +86,32 @@ def worktree_exec_lock(home, worktree, *, on_wait=None):
|
|
|
85
86
|
잠그지 못할 때 어떻게 할지는 호출자가 정한다.
|
|
86
87
|
"""
|
|
87
88
|
lockfile = worktree_exec_lock_path(home, worktree)
|
|
89
|
+
with _exclusive_lock(lockfile, on_wait):
|
|
90
|
+
yield lockfile
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def resource_exec_lock_path(home: str | Path, resource_key: str) -> Path:
|
|
94
|
+
"""`<home>/.locks/resource-exec/<key hash>.lock`, shared by every worktree."""
|
|
95
|
+
key = hashlib.sha256(resource_key.encode("utf-8")).hexdigest()
|
|
96
|
+
return Path(home) / ".locks" / "resource-exec" / f"{key[:32]}.lock"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@contextlib.contextmanager
|
|
100
|
+
def resource_exec_lock(
|
|
101
|
+
home: str | Path, resource_key: str, *,
|
|
102
|
+
on_wait: Callable[[Path], None] | None = None,
|
|
103
|
+
) -> Iterator[Path]:
|
|
104
|
+
"""Serialize checks that use one fixed resource (a port, a test database)
|
|
105
|
+
that worktree isolation cannot separate."""
|
|
106
|
+
lockfile = resource_exec_lock_path(home, resource_key)
|
|
107
|
+
with _exclusive_lock(lockfile, on_wait):
|
|
108
|
+
yield lockfile
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@contextlib.contextmanager
|
|
112
|
+
def _exclusive_lock(
|
|
113
|
+
lockfile: Path, on_wait: Callable[[Path], None] | None,
|
|
114
|
+
) -> Iterator[None]:
|
|
88
115
|
lockfile.parent.mkdir(parents=True, exist_ok=True)
|
|
89
116
|
with lockfile.open("a") as f:
|
|
90
117
|
try:
|
|
@@ -94,6 +121,6 @@ def worktree_exec_lock(home, worktree, *, on_wait=None):
|
|
|
94
121
|
on_wait(lockfile)
|
|
95
122
|
fcntl.flock(f.fileno(), fcntl.LOCK_EX)
|
|
96
123
|
try:
|
|
97
|
-
yield
|
|
124
|
+
yield
|
|
98
125
|
finally:
|
|
99
126
|
fcntl.flock(f.fileno(), fcntl.LOCK_UN)
|
|
@@ -178,6 +178,13 @@ def render_verification_input(
|
|
|
178
178
|
"\n## Approved Plan\n\n",
|
|
179
179
|
*quoted_value_lines("Approved plan", inputs["approvedPlan"]),
|
|
180
180
|
])
|
|
181
|
+
if "conformanceBaseline" in inputs:
|
|
182
|
+
rows.extend([
|
|
183
|
+
"\n## Conformance Baseline\n\n",
|
|
184
|
+
*quoted_value_lines(
|
|
185
|
+
"Conformance baseline", inputs["conformanceBaseline"],
|
|
186
|
+
),
|
|
187
|
+
])
|
|
181
188
|
return "".join(rows)
|
|
182
189
|
|
|
183
190
|
|
|
@@ -15,10 +15,10 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
17
|
import re
|
|
18
|
-
from collections.abc import Callable, Sequence
|
|
18
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
19
19
|
from dataclasses import dataclass, replace
|
|
20
20
|
from pathlib import Path
|
|
21
|
-
from typing import Optional
|
|
21
|
+
from typing import Any, Optional
|
|
22
22
|
|
|
23
23
|
from okstra_project.dirs import (
|
|
24
24
|
DISCOVERY_RELATIVE,
|
|
@@ -42,7 +42,6 @@ __all__ = [
|
|
|
42
42
|
"resolve_under_root",
|
|
43
43
|
"task_dir",
|
|
44
44
|
"task_runs_dir",
|
|
45
|
-
"container_paths",
|
|
46
45
|
"okstra_home",
|
|
47
46
|
"find_asset_root",
|
|
48
47
|
"RUN_VALIDATOR_RELATIVE",
|
|
@@ -118,6 +117,14 @@ _REPORT_SEQ_RE = re.compile(
|
|
|
118
117
|
r"^final-report-.+-(?P<seq>\d{3,})\.(?:md|data\.json)$"
|
|
119
118
|
)
|
|
120
119
|
_TASKS_SEGMENTS = Path(TASKS_RELATIVE).parts
|
|
120
|
+
_EXECUTION_SEGMENT_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*")
|
|
121
|
+
_CHECK_RUN_RE = re.compile(r"run-([1-9][0-9]*)")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _positive_int(value: object, label: str) -> int:
|
|
125
|
+
if isinstance(value, bool) or not isinstance(value, int) or value < 1:
|
|
126
|
+
raise ValueError(f"{label} must be a positive integer")
|
|
127
|
+
return value
|
|
121
128
|
|
|
122
129
|
|
|
123
130
|
def _newest_report(reports_dir: Path) -> Optional[Path]:
|
|
@@ -228,12 +235,40 @@ class RunRef:
|
|
|
228
235
|
return self.verification_dir / f"inputs{self._suffix}.json"
|
|
229
236
|
|
|
230
237
|
def verification_generation(self, generation: int) -> Path:
|
|
231
|
-
|
|
232
|
-
or generation < 1):
|
|
233
|
-
raise ValueError("verification generation must be a positive integer")
|
|
238
|
+
_positive_int(generation, "verification generation")
|
|
234
239
|
return (self.verification_dir / f"generations{self._suffix}"
|
|
235
240
|
/ f"generation-{generation}.json")
|
|
236
241
|
|
|
242
|
+
def verification_check_dir(
|
|
243
|
+
self, invocation_ref: str, attempt: int, check_ref: str,
|
|
244
|
+
) -> Path:
|
|
245
|
+
"""The directory holding every run of `check_ref` (`kind:id`) in one attempt."""
|
|
246
|
+
segment = check_ref.replace(":", "-", 1)
|
|
247
|
+
for value in (invocation_ref, segment):
|
|
248
|
+
if not _EXECUTION_SEGMENT_RE.fullmatch(value):
|
|
249
|
+
raise ValueError(f"verification execution segment is unsafe: {value}")
|
|
250
|
+
_positive_int(attempt, "verification execution attempt")
|
|
251
|
+
return (self.verification_dir / f"executions{self._suffix}" / invocation_ref
|
|
252
|
+
/ f"attempt-{attempt}" / segment)
|
|
253
|
+
|
|
254
|
+
def verification_execution_dir(
|
|
255
|
+
self, invocation_ref: str, attempt: int, check_ref: str, check_run: int,
|
|
256
|
+
) -> Path:
|
|
257
|
+
"""One check run's directory; a check run is not a worker attempt."""
|
|
258
|
+
_positive_int(check_run, "verification execution check run")
|
|
259
|
+
return (self.verification_check_dir(invocation_ref, attempt, check_ref)
|
|
260
|
+
/ f"run-{check_run}")
|
|
261
|
+
|
|
262
|
+
def latest_verification_check_run(
|
|
263
|
+
self, invocation_ref: str, attempt: int, check_ref: str,
|
|
264
|
+
) -> int | None:
|
|
265
|
+
runs = self.verification_check_dir(invocation_ref, attempt, check_ref)
|
|
266
|
+
numbers = [int(match.group(1)) for match in (
|
|
267
|
+
_CHECK_RUN_RE.fullmatch(path.name)
|
|
268
|
+
for path in (runs.iterdir() if runs.is_dir() else ())
|
|
269
|
+
) if match]
|
|
270
|
+
return max(numbers, default=None)
|
|
271
|
+
|
|
237
272
|
@property
|
|
238
273
|
def convergence_state(self) -> Path:
|
|
239
274
|
"""이 run 의 finding convergence 상태 파일.
|
|
@@ -242,7 +277,9 @@ class RunRef:
|
|
|
242
277
|
디렉터리마다 seq 를 따로 세므로(`reports: 004` 와 `state: 005` 가 실제로
|
|
243
278
|
갈린 적이 있다), 리포트 경로에서 만든 ref 로 이 값을 계산하면 그 갈린
|
|
244
279
|
run 에서는 존재하지 않는 파일을 가리킨다. 호출자는 파일이 없는 경우를
|
|
245
|
-
정상 분기로 다뤄야 한다.
|
|
280
|
+
정상 분기로 다뤄야 한다. The per-directory count above describes runs
|
|
281
|
+
prepared before `compute_run_paths` gave every category one seq; those
|
|
282
|
+
runs stay on disk.
|
|
246
283
|
"""
|
|
247
284
|
return self.run_dir / "state" / f"convergence{self._suffix}.json"
|
|
248
285
|
|
|
@@ -303,6 +340,18 @@ class RunRef:
|
|
|
303
340
|
run_dir.parent.parent, run_dir.name, seq=seq, stage=stage
|
|
304
341
|
)
|
|
305
342
|
|
|
343
|
+
@classmethod
|
|
344
|
+
def from_manifest(
|
|
345
|
+
cls, manifest_path: Path, manifest: Mapping[str, Any],
|
|
346
|
+
) -> "RunRef":
|
|
347
|
+
ref = cls.from_run_dir(
|
|
348
|
+
manifest_path.parent.parent,
|
|
349
|
+
seq=int(manifest["runSequencesByCategory"]["manifests"]),
|
|
350
|
+
)
|
|
351
|
+
if ref.manifest.resolve() != manifest_path.resolve():
|
|
352
|
+
raise ValueError("run manifest is not at its canonical run path")
|
|
353
|
+
return ref
|
|
354
|
+
|
|
306
355
|
@classmethod
|
|
307
356
|
def from_report_path(cls, report_path: Path) -> "RunRef":
|
|
308
357
|
"""final-report 경로에서 정체를 복원한다.
|
|
@@ -428,20 +477,6 @@ def task_timeline_file(task_root: Path) -> Path:
|
|
|
428
477
|
return Path(task_root) / "history" / "timeline.json"
|
|
429
478
|
|
|
430
479
|
|
|
431
|
-
def container_paths(project_root: Path, task_group: str, task_id: str) -> dict:
|
|
432
|
-
"""container 산출물 경로 묶음(순수 계산, mkdir 금지).
|
|
433
|
-
|
|
434
|
-
task root 하위 ``container/`` 디렉터리에 deploy 산출물을 모은다. base 가
|
|
435
|
-
``task_dir`` 에서 파생되므로 라벨(compose project name)↔디스크 경로의 slug
|
|
436
|
-
규칙이 자동으로 일치한다."""
|
|
437
|
-
base = task_dir(project_root, task_group, task_id) / "container"
|
|
438
|
-
return {
|
|
439
|
-
"container_dir": base,
|
|
440
|
-
"env_override": base / "env.override",
|
|
441
|
-
"deploy_state": base / "deploy-state.json",
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
480
|
def next_run_seq(run_seq_dir: Path, task_type_segment: str) -> int:
|
|
446
481
|
"""run_seq_dir 안에서 `*-<task-type>-NNN[.<ext>]` 항목을 스캔해 다음 seq 번호를
|
|
447
482
|
돌려준다. 디렉터리 부재 시 1.
|
|
@@ -514,6 +549,11 @@ def compute_run_paths(
|
|
|
514
549
|
run_seq_override: 정수가 주어지면 7개 seq 모두 그 값으로 강제. 외부에서
|
|
515
550
|
seq 를 미리 reserve 한 경로용(현재는 테스트 hook). 미지정 시 디스크 스캔
|
|
516
551
|
결과로 결정.
|
|
552
|
+
|
|
553
|
+
Every artifact of one run takes one seq, the next one free in all seven
|
|
554
|
+
directories. A run that fails before writing a report or worker result
|
|
555
|
+
leaves those directories behind the others; counting each on its own would
|
|
556
|
+
hand the next run the failed run's report and result paths.
|
|
517
557
|
"""
|
|
518
558
|
project_root = Path(project_root)
|
|
519
559
|
workspace_root = Path(workspace_root)
|
|
@@ -578,21 +618,23 @@ def compute_run_paths(
|
|
|
578
618
|
else run_dir / "carry"
|
|
579
619
|
)
|
|
580
620
|
|
|
621
|
+
seq_dirs = {
|
|
622
|
+
"manifests": run_manifests,
|
|
623
|
+
"prompts": run_prompts,
|
|
624
|
+
"reports": run_reports,
|
|
625
|
+
"status": run_status,
|
|
626
|
+
"state": run_state,
|
|
627
|
+
"sessions": run_sessions,
|
|
628
|
+
"worker_results": worker_results,
|
|
629
|
+
}
|
|
581
630
|
if run_seq_override is not None:
|
|
582
631
|
seq_int = int(run_seq_override)
|
|
583
|
-
seqs = {k: f"{seq_int:03d}" for k in (
|
|
584
|
-
"manifests", "prompts", "reports", "status", "state",
|
|
585
|
-
"sessions", "worker_results")}
|
|
586
632
|
else:
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
"state": f"{next_run_seq(run_state, task_type_segment):03d}",
|
|
593
|
-
"sessions": f"{next_run_seq(run_sessions, task_type_segment):03d}",
|
|
594
|
-
"worker_results": f"{next_run_seq(worker_results, task_type_segment):03d}",
|
|
595
|
-
}
|
|
633
|
+
seq_int = max(
|
|
634
|
+
next_run_seq(directory, task_type_segment)
|
|
635
|
+
for directory in seq_dirs.values()
|
|
636
|
+
)
|
|
637
|
+
seqs = {k: f"{seq_int:03d}" for k in seq_dirs}
|
|
596
638
|
|
|
597
639
|
suffixes = {k: f"-{task_type_segment}-{v}" for k, v in seqs.items()}
|
|
598
640
|
run_file_suffix = suffixes["reports"]
|
|
@@ -10,6 +10,9 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
from ..asset_roots import walk_to_asset_root
|
|
12
12
|
|
|
13
|
+
# Prepare writes its own input document into the brief slot for these task types.
|
|
14
|
+
INPUT_DOCUMENT_TASK_TYPES = ("release-handoff", "discussion")
|
|
15
|
+
|
|
13
16
|
|
|
14
17
|
class PhaseAssetError(ValueError):
|
|
15
18
|
"""단계 자산을 요청한 실행 루트에서 해석할 수 없다."""
|
|
@@ -17,8 +17,8 @@ This phase maps a proposed change's preserved behavior, affected and unaffected
|
|
|
17
17
|
| ID | Guarantee | Enforcement |
|
|
18
18
|
|---|---|---|
|
|
19
19
|
| CI-1 | Planning inputs contain constraints and unknowns only. | `scripts/okstra_ctl/phases/change_impact_analysis/validation.py::validate_change_impact_semantics` |
|
|
20
|
-
| CI-2 | Impact items require current-code evidence within the included scope. | `validators/validate_analysis_report.py::_validate_all_current_code_evidence
|
|
21
|
-
| CI-3 | The wizard collects feature evidence before project evidence. |
|
|
20
|
+
| CI-2 | Impact items require current-code evidence within the included scope. | `validators/validate_analysis_report.py::_validate_all_current_code_evidence` |
|
|
21
|
+
| CI-3 | The wizard collects feature evidence before project evidence. | unenforced |
|
|
22
22
|
| CI-4 | Common validation checks the frozen analysis source, target and evidence snapshot. | `validators/validate_analysis_report.py::validate_analysis_snapshot` |
|
|
23
23
|
|
|
24
24
|
## Tests
|