okstra 0.230.0 → 0.231.1
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 +3 -3
- package/docs/architecture/storage-model.md +67 -6
- package/docs/architecture.md +6 -2
- package/docs/coding-rules.md +15 -0
- package/docs/project-structure-overview.md +2 -1
- package/package.json +2 -2
- package/runtime/BUILD.json +2 -2
- package/runtime/prompts/coding-preflight/clean-code.md +8 -0
- package/runtime/prompts/coding-preflight/overview.md +1 -0
- package/runtime/prompts/launch.template.md +2 -0
- package/runtime/prompts/lead/convergence.md +3 -3
- package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
- package/runtime/prompts/lead/report-writer.md +1 -1
- package/runtime/prompts/lead/team-contract.md +1 -1
- package/runtime/prompts/profiles/_clarification-recommendation.md +3 -2
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +2 -0
- package/runtime/python/okstra_ctl/agent/invocation.py +48 -4
- package/runtime/python/okstra_ctl/approval_decisions.py +16 -0
- package/runtime/python/okstra_ctl/blocking_checks.py +10 -0
- package/runtime/python/okstra_ctl/business_flow/invocation.py +35 -3
- package/runtime/python/okstra_ctl/conformance_evidence.py +148 -67
- package/runtime/python/okstra_ctl/convergence.py +112 -20
- package/runtime/python/okstra_ctl/convergence_engine.py +1 -0
- package/runtime/python/okstra_ctl/convergence_provenance.py +27 -11
- package/runtime/python/okstra_ctl/correction_round.py +6 -1
- package/runtime/python/okstra_ctl/dispatch_checkpoints.py +28 -5
- package/runtime/python/okstra_ctl/dispatch_core.py +3 -11
- package/runtime/python/okstra_ctl/execution_mutation_audit.py +13 -1
- package/runtime/python/okstra_ctl/incremental_carry.py +7 -4
- package/runtime/python/okstra_ctl/paths.py +19 -4
- package/runtime/python/okstra_ctl/phases/final_verification/profile.md +1 -0
- package/runtime/python/okstra_ctl/phases/final_verification/report_assets/final-verification.template.html +8 -0
- package/runtime/python/okstra_ctl/phases/final_verification/spec.md +1 -0
- package/runtime/python/okstra_ctl/phases/final_verification/validation.py +53 -0
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +5 -1
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +3 -1
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +20 -4
- package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation.template.html +1 -1
- package/runtime/python/okstra_ctl/phases/implementation/spec.md +2 -0
- package/runtime/python/okstra_ctl/phases/implementation/validation.py +230 -30
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +16 -22
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +2 -2
- package/runtime/python/okstra_ctl/phases/implementation_planning/wizard.py +11 -4
- package/runtime/python/okstra_ctl/phases/release_handoff/operations.py +4 -5
- package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +1 -1
- package/runtime/python/okstra_ctl/plan_items.py +28 -0
- package/runtime/python/okstra_ctl/render.py +15 -0
- package/runtime/python/okstra_ctl/report_assembly.py +102 -1
- package/runtime/python/okstra_ctl/report_execution_evidence.py +220 -0
- package/runtime/python/okstra_ctl/report_inputs.py +28 -0
- package/runtime/python/okstra_ctl/report_narrative.py +12 -3
- package/runtime/python/okstra_ctl/report_prose_keys.py +7 -0
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +8 -0
- package/runtime/python/okstra_ctl/run.py +16 -0
- package/runtime/python/okstra_ctl/stage_close.py +52 -6
- package/runtime/python/okstra_ctl/stage_fix_carry.py +21 -1
- package/runtime/python/okstra_ctl/stage_integrate.py +90 -25
- package/runtime/python/okstra_ctl/team.py +3 -1
- package/runtime/python/okstra_ctl/verification_dispatch.py +8 -2
- package/runtime/python/okstra_ctl/verification_evidence.py +26 -7
- package/runtime/python/okstra_ctl/verification_generation.py +12 -4
- package/runtime/python/okstra_ctl/verification_inputs.py +10 -0
- package/runtime/python/okstra_ctl/verification_invocation.py +2 -1
- package/runtime/python/okstra_ctl/wizard/engine.py +23 -0
- package/runtime/python/okstra_ctl/wizard/steps_plan.py +6 -2
- package/runtime/python/okstra_ctl/worker_dispatch.py +3 -1
- package/runtime/python/okstra_ctl/worktree/git_ops.py +8 -1
- package/runtime/python/okstra_ctl/worktree/rebase.py +5 -2
- package/runtime/python/okstra_ctl/wrapper_status.py +16 -0
- package/runtime/schemas/final-report-v3.0.schema.json +184 -1
- package/runtime/skills/okstra-run/SKILL.md +5 -1
- package/runtime/templates/reports/html/i18n/en.json +7 -0
- package/runtime/templates/reports/html/i18n/ko.json +7 -0
- package/runtime/validators/validate-run.py +27 -11
- package/runtime/validators/validate-workflow.sh +1 -1
|
@@ -18,6 +18,7 @@ from pathlib import Path
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from .worktree import _git
|
|
21
|
+
from .worktree.git_ops import WITHOUT_HOOKS
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class IntegrateError(Exception):
|
|
@@ -45,13 +46,14 @@ class StageMergeBranch:
|
|
|
45
46
|
class MergeBranchConflict(IntegrateError):
|
|
46
47
|
"""선행 stage 들끼리 내용이 충돌해 공통 바닥을 만들 수 없다."""
|
|
47
48
|
|
|
48
|
-
def __init__(self, stage: int, branch: str, paths: list[str]
|
|
49
|
+
def __init__(self, stage: int, branch: str, paths: list[str],
|
|
50
|
+
recovery: str):
|
|
49
51
|
self.stage = stage
|
|
50
52
|
self.branch = branch
|
|
51
53
|
self.paths = paths
|
|
52
54
|
super().__init__(
|
|
53
55
|
f"merge conflict while merging stage {stage} ({branch}): "
|
|
54
|
-
f"{', '.join(paths)}")
|
|
56
|
+
f"{', '.join(paths)}. {recovery}")
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
def ensure_stage_merge_branch(
|
|
@@ -78,8 +80,7 @@ def ensure_stage_merge_branch(
|
|
|
78
80
|
재진입이 안 되므로 여기서 다시 잡으면 이미 락을 쥔 implementation 경로가
|
|
79
81
|
교착한다 — `_resolve_and_integrate_whole_task_unlocked` 와 같은 분리다.
|
|
80
82
|
"""
|
|
81
|
-
from .worktree import
|
|
82
|
-
is_ancestor, remove_worktree_force, stage_group_id)
|
|
83
|
+
from .worktree import compute_branch_name, stage_group_id
|
|
83
84
|
|
|
84
85
|
if not heads:
|
|
85
86
|
raise IntegrateError("ensure_stage_merge_branch requires at least one stage")
|
|
@@ -88,42 +89,82 @@ def ensure_stage_merge_branch(
|
|
|
88
89
|
task_id_segment=task_id,
|
|
89
90
|
group_id=stage_group_id(stages))
|
|
90
91
|
root = Path(project_root)
|
|
92
|
+
if not anchor_base:
|
|
93
|
+
raise IntegrateError(
|
|
94
|
+
f"cannot create or reuse {branch}: the implementation base commit "
|
|
95
|
+
"is not recorded in the worktree registry — run at least one "
|
|
96
|
+
"implementation stage first")
|
|
91
97
|
if _branch_exists(root, branch):
|
|
92
|
-
|
|
93
|
-
missing = [n for n in stages if not is_ancestor(root, heads[n], tip)]
|
|
98
|
+
missing = _heads_missing_from(root, branch, heads, anchor_base)
|
|
94
99
|
if not missing:
|
|
95
|
-
return StageMergeBranch(branch=branch, commit=
|
|
96
|
-
stages=stages,
|
|
100
|
+
return StageMergeBranch(branch=branch, commit=_rev_parse(root, branch),
|
|
101
|
+
created=False, stages=stages,
|
|
102
|
+
merge_commits=[])
|
|
97
103
|
if not advance_existing:
|
|
98
104
|
raise IntegrateError(
|
|
99
|
-
f"merge-base branch {branch} exists but stage(s)
|
|
100
|
-
"are not merged into it — delete the
|
|
101
|
-
"okstra can rebuild it")
|
|
105
|
+
f"merge-base branch {branch} exists but stage(s) "
|
|
106
|
+
f"{sorted(missing)} are not merged into it — delete the "
|
|
107
|
+
"branch and retry so okstra can rebuild it")
|
|
102
108
|
# 기존 브랜치를 그대로 체크아웃해 빠진 commit 만 얹는다.
|
|
103
|
-
creating, start = False, branch
|
|
104
|
-
to_merge = {n: heads[n] for n in missing}
|
|
109
|
+
creating, start, to_merge = False, branch, missing
|
|
105
110
|
else:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
creating, start, to_merge = True, anchor_base, dict(heads)
|
|
112
|
+
return _build_merge_branch(
|
|
113
|
+
root, branch=branch, stages=stages, creating=creating, start=start,
|
|
114
|
+
anchor_base=anchor_base, to_merge=to_merge, project_id=project_id,
|
|
115
|
+
task_group=task_group, task_id=task_id, work_category=work_category)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _heads_missing_from(root: Path, branch: str, heads: dict[int, str],
|
|
119
|
+
anchor_base: str) -> dict[int, str]:
|
|
120
|
+
"""Validate an existing merge-base branch and return the heads it lacks."""
|
|
121
|
+
from .worktree import is_ancestor
|
|
122
|
+
|
|
123
|
+
tip = _rev_parse(root, branch)
|
|
124
|
+
if not is_ancestor(root, anchor_base, tip):
|
|
125
|
+
raise IntegrateError(
|
|
126
|
+
f"merge-base branch {branch} does not contain the anchor "
|
|
127
|
+
f"{anchor_base} — it was not built from the implementation "
|
|
128
|
+
"base; delete the branch and retry so okstra can rebuild it")
|
|
129
|
+
# Merge commits are okstra's own merges or a person's conflict resolution;
|
|
130
|
+
# any other commit came from outside the anchor and the predecessors.
|
|
131
|
+
foreign = _git(root, "rev-list", "--no-merges", tip, f"^{anchor_base}",
|
|
132
|
+
*(f"^{head}" for head in heads.values())).stdout.split()
|
|
133
|
+
if foreign:
|
|
134
|
+
raise IntegrateError(
|
|
135
|
+
f"merge-base branch {branch} carries {len(foreign)} commit(s) that "
|
|
136
|
+
f"are in neither the anchor nor a predecessor stage, such as "
|
|
137
|
+
f"{foreign[0]} — delete the branch and retry so okstra can "
|
|
138
|
+
"rebuild it")
|
|
139
|
+
return {n: heads[n] for n in sorted(heads)
|
|
140
|
+
if not is_ancestor(root, heads[n], tip)}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _build_merge_branch(
|
|
144
|
+
root: Path, *, branch: str, stages: list[int], creating: bool, start: str,
|
|
145
|
+
anchor_base: str, to_merge: dict[int, str], project_id: str,
|
|
146
|
+
task_group: str, task_id: str, work_category: str,
|
|
147
|
+
) -> StageMergeBranch:
|
|
148
|
+
"""Merge `to_merge` onto `start` in a scratch worktree that is removed
|
|
149
|
+
afterwards; a branch this call created is deleted again on failure."""
|
|
150
|
+
from .worktree import (compute_worktree_path, remove_worktree_force,
|
|
151
|
+
stage_group_id)
|
|
113
152
|
|
|
114
153
|
wt_path = compute_worktree_path(
|
|
115
154
|
project_id=project_id, task_group_segment=task_group,
|
|
116
155
|
task_id_segment=task_id, group_id=stage_group_id(stages))
|
|
117
156
|
wt_path.parent.mkdir(parents=True, exist_ok=True)
|
|
118
|
-
add = _git(root, "worktree", "add",
|
|
157
|
+
add = _git(root, *WITHOUT_HOOKS, "worktree", "add",
|
|
119
158
|
*(["-b", branch] if creating else []), str(wt_path), start)
|
|
120
159
|
if add.returncode != 0:
|
|
121
160
|
raise IntegrateError(
|
|
122
161
|
f"git worktree add for {branch} failed: "
|
|
123
162
|
f"{(add.stderr or add.stdout).strip()}")
|
|
124
163
|
try:
|
|
125
|
-
merge_commits = _merge_heads_into(
|
|
126
|
-
|
|
164
|
+
merge_commits = _merge_heads_into(
|
|
165
|
+
wt_path, to_merge, work_category, task_id,
|
|
166
|
+
recovery=_conflict_recovery(branch, creating, start, anchor_base,
|
|
167
|
+
to_merge))
|
|
127
168
|
commit = _rev_parse(wt_path, "HEAD")
|
|
128
169
|
except Exception:
|
|
129
170
|
remove_worktree_force(root, wt_path)
|
|
@@ -135,8 +176,32 @@ def ensure_stage_merge_branch(
|
|
|
135
176
|
stages=stages, merge_commits=merge_commits)
|
|
136
177
|
|
|
137
178
|
|
|
179
|
+
def _conflict_recovery(branch: str, creating: bool, start: str, anchor: str,
|
|
180
|
+
heads: dict[int, str]) -> str:
|
|
181
|
+
"""The manual build of `branch` that a retry accepts: the same start, merge
|
|
182
|
+
order and disabled hooks okstra uses, with the conflict resolved by a
|
|
183
|
+
person, whose resolving commit still runs the repository's hooks."""
|
|
184
|
+
no_hooks = " ".join(WITHOUT_HOOKS)
|
|
185
|
+
if creating:
|
|
186
|
+
intro = f"To recover, build {branch} by hand from the anchor"
|
|
187
|
+
checkout = f"git {no_hooks} worktree add -b {branch} <dir> {start}"
|
|
188
|
+
else:
|
|
189
|
+
intro = (f"{branch} was left at its previous tip. To recover, finish it "
|
|
190
|
+
"by hand")
|
|
191
|
+
checkout = f"git {no_hooks} worktree add <dir> {branch}"
|
|
192
|
+
merges = "; ".join(
|
|
193
|
+
f"`git -C <dir> {no_hooks} merge --no-ff --no-edit {heads[n]}` "
|
|
194
|
+
f"(stage {n})" for n in sorted(heads))
|
|
195
|
+
return (
|
|
196
|
+
f"{intro}: `{checkout}`, then {merges}, in that order. Resolve each "
|
|
197
|
+
"conflict, run the project's checks and commit the merge, then "
|
|
198
|
+
"`git worktree remove <dir>` and retry the same command. okstra reuses "
|
|
199
|
+
f"{branch} only when it contains the anchor {anchor} and every "
|
|
200
|
+
"predecessor commit, and no other non-merge commit")
|
|
201
|
+
|
|
202
|
+
|
|
138
203
|
def _merge_heads_into(wt_path, heads: dict[int, str], work_category: str,
|
|
139
|
-
task_id: str) -> list[str]:
|
|
204
|
+
task_id: str, *, recovery: str) -> list[str]:
|
|
140
205
|
"""stage 번호 순서로 done commit 을 `--no-ff` 머지한다. 이미 담긴 commit 은
|
|
141
206
|
git 이 `Already up to date` 로 지나가므로 빈 머지 커밋이 생기지 않는다."""
|
|
142
207
|
from .worktree import MergeError, compute_branch_name, merge_branch
|
|
@@ -154,7 +219,7 @@ def _merge_heads_into(wt_path, heads: dict[int, str], work_category: str,
|
|
|
154
219
|
) from exc
|
|
155
220
|
if conflicts is not None:
|
|
156
221
|
raise MergeBranchConflict(stage=n, branch=stage_branch,
|
|
157
|
-
paths=conflicts)
|
|
222
|
+
paths=conflicts, recovery=recovery)
|
|
158
223
|
merge_commits.append(_rev_parse(wt_path, "HEAD"))
|
|
159
224
|
return merge_commits
|
|
160
225
|
|
|
@@ -101,7 +101,9 @@ wrapper subprocess holding no pane, so there is nothing to close.
|
|
|
101
101
|
that never reached a terminal status.
|
|
102
102
|
|
|
103
103
|
On a cmux-pane run, dispatch records `phase-3-team-create` when it writes the
|
|
104
|
-
implicit-team marker, `phase-4-dispatch` for each `initial` job and
|
|
104
|
+
implicit-team marker, `phase-4-dispatch` for each `initial` job and each
|
|
105
|
+
job of an implementation correction round (`correction-r<N>`, and a
|
|
106
|
+
`reverify-r<k>` whose invocation id carries `-correction-r<N>-`), and
|
|
105
107
|
`phase-6-synthesis` on the first report-writer dispatch; await records
|
|
106
108
|
`phase-5-poll` on entry and again when the counts changed, and
|
|
107
109
|
`phase-5-collect` for each `initial` dispatch it settled. The lead does not
|
|
@@ -50,8 +50,14 @@ def seal_dispatch_generation(
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def verification_generation_number(dispatch_kind: str) -> int:
|
|
53
|
-
"""
|
|
54
|
-
|
|
53
|
+
"""The generation a dispatch seals; every dispatch outside a correction
|
|
54
|
+
round seals 1."""
|
|
55
|
+
return generation_sealed_after_round(correction_round(dispatch_kind) or 0)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def generation_sealed_after_round(round_number: int) -> int:
|
|
59
|
+
"""Correction round N seals generation N + 1."""
|
|
60
|
+
return 1 + round_number
|
|
55
61
|
|
|
56
62
|
|
|
57
63
|
def _seal(
|
|
@@ -268,12 +268,20 @@ def conformance_check_owner_ref(manifest: Mapping[str, Any]) -> str | None:
|
|
|
268
268
|
|
|
269
269
|
|
|
270
270
|
def _stage_qa_owner_role_execution_ref(manifest: Mapping[str, Any]) -> str:
|
|
271
|
-
"""The role execution of the stage QA owner, resolved the way initial
|
|
272
|
-
materialization binds a roster worker to its role execution."""
|
|
273
271
|
owner = stage_qa_owner(manifest)
|
|
274
272
|
if not owner:
|
|
275
273
|
raise EvidenceRefused("the run roster has no stage QA owner")
|
|
276
|
-
|
|
274
|
+
role_execution_ref = worker_role_execution_ref(manifest, owner)
|
|
275
|
+
if role_execution_ref is None:
|
|
276
|
+
raise EvidenceRefused("the stage QA owner has no v2 role execution")
|
|
277
|
+
return role_execution_ref
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def worker_role_execution_ref(manifest: Mapping[str, Any], worker_id: str) -> str | None:
|
|
281
|
+
"""The role execution of a roster verifier, resolved the way initial
|
|
282
|
+
materialization binds a roster worker to its role execution; None for a
|
|
283
|
+
v1 run."""
|
|
284
|
+
assignment_ref = f"initial/{worker_id}"
|
|
277
285
|
assignments = manifest.get("invocationAssignments")
|
|
278
286
|
identity = invocation_execution_identity_from_manifest(
|
|
279
287
|
manifest,
|
|
@@ -282,11 +290,22 @@ def _stage_qa_owner_role_execution_ref(manifest: Mapping[str, Any]) -> str:
|
|
|
282
290
|
else None
|
|
283
291
|
),
|
|
284
292
|
assignment_ref=assignment_ref,
|
|
285
|
-
duty_id=QA_VERIFIER_AUDIENCE_BY_TASK_TYPE["
|
|
293
|
+
duty_id=QA_VERIFIER_AUDIENCE_BY_TASK_TYPE[str(manifest.get("taskType"))],
|
|
286
294
|
)
|
|
287
|
-
if identity is None
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
return None if identity is None else identity.role_execution_ref
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def roster_verifier_role_execution_ref(
|
|
299
|
+
manifest: Mapping[str, Any], name: object,
|
|
300
|
+
) -> str | None:
|
|
301
|
+
"""The role execution a report's `verifier` name binds; None for a name the
|
|
302
|
+
roster does not bind to one. Report assembly attaches records by this
|
|
303
|
+
reading and the validator checks them by it, so both must share it."""
|
|
304
|
+
try:
|
|
305
|
+
return worker_role_execution_ref(manifest, str(name))
|
|
306
|
+
except (AgentInvocationError, ValueError):
|
|
307
|
+
# expected-miss: the caller reports the unbound name.
|
|
308
|
+
return None
|
|
290
309
|
|
|
291
310
|
|
|
292
311
|
def _sealed_conformance_entry(
|
|
@@ -26,7 +26,11 @@ from .verification_inputs import (
|
|
|
26
26
|
from .verification_target import read_verification_head
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
class
|
|
29
|
+
class _OptionalFrozenVerificationSource(TypedDict, total=False):
|
|
30
|
+
ignoredRoots: list[str]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class FrozenVerificationSource(_OptionalFrozenVerificationSource):
|
|
30
34
|
trackedPaths: list[str]
|
|
31
35
|
generatedRoots: list[str]
|
|
32
36
|
inputPaths: list[str]
|
|
@@ -64,7 +68,7 @@ _SOURCE = {
|
|
|
64
68
|
"protectedFiles", "generatedFiles"],
|
|
65
69
|
"properties": {
|
|
66
70
|
"trackedPaths": _PATHS, "generatedRoots": _PATHS, "inputPaths": _PATHS,
|
|
67
|
-
"protectedFiles": _FILES, "generatedFiles": _FILES,
|
|
71
|
+
"protectedFiles": _FILES, "generatedFiles": _FILES, "ignoredRoots": _PATHS,
|
|
68
72
|
},
|
|
69
73
|
}
|
|
70
74
|
_SCHEMA = {
|
|
@@ -102,7 +106,8 @@ def _generation_errors(payload: dict[str, Any]) -> list[str]:
|
|
|
102
106
|
if PurePosixPath(payload[field]).parts[0] != OKSTRA_DIR_NAME:
|
|
103
107
|
return ["generation references must remain in project artifacts"]
|
|
104
108
|
protected, generated = source["protectedFiles"], source["generatedFiles"]
|
|
105
|
-
|
|
109
|
+
ignored = source.get("ignoredRoots", [])
|
|
110
|
+
paths = {*source["trackedPaths"], *protected, *generated, *declarations, *ignored}
|
|
106
111
|
for relative in paths:
|
|
107
112
|
if len(relative) > VERIFICATION_GENERATION_PATH_MAX_LENGTH:
|
|
108
113
|
return ["generation source path is too long"]
|
|
@@ -112,7 +117,7 @@ def _generation_errors(payload: dict[str, Any]) -> list[str]:
|
|
|
112
117
|
return ["generation source paths must be canonical and relative"]
|
|
113
118
|
if not set(source["inputPaths"]).issubset(protected):
|
|
114
119
|
return ["generation declared inputs must remain protected"]
|
|
115
|
-
roots = frozenset(source["generatedRoots"])
|
|
120
|
+
roots = frozenset(source["generatedRoots"]) | frozenset(ignored)
|
|
116
121
|
required = frozenset(source["trackedPaths"]) | frozenset(source["inputPaths"])
|
|
117
122
|
if any(is_generated_verification_path(path, roots, required) for path in protected):
|
|
118
123
|
return ["generation protected path conflicts with classification"]
|
|
@@ -184,6 +189,8 @@ def _capture_generation(
|
|
|
184
189
|
"inputPaths": sorted(snapshot.input_paths),
|
|
185
190
|
"protectedFiles": dict(snapshot.protected_files),
|
|
186
191
|
"generatedFiles": dict(snapshot.generated_files),
|
|
192
|
+
**({"ignoredRoots": sorted(snapshot.ignored_roots)}
|
|
193
|
+
if snapshot.ignored_roots else {}),
|
|
187
194
|
},
|
|
188
195
|
"artifactInputs": artifacts,
|
|
189
196
|
**({"conformanceStages": list(conformance.stages)}
|
|
@@ -233,6 +240,7 @@ def sealed_source_snapshot(
|
|
|
233
240
|
input_paths=frozenset(source["inputPaths"]),
|
|
234
241
|
protected_files=source["protectedFiles"],
|
|
235
242
|
generated_files=source["generatedFiles"],
|
|
243
|
+
ignored_roots=frozenset(source.get("ignoredRoots", ())),
|
|
236
244
|
)
|
|
237
245
|
|
|
238
246
|
|
|
@@ -248,6 +248,16 @@ def conformance_baseline_required(
|
|
|
248
248
|
return task_type == "implementation" and "approvedPlan" in inputs
|
|
249
249
|
|
|
250
250
|
|
|
251
|
+
def evidence_contract_applies(inputs: Mapping[str, Any]) -> bool:
|
|
252
|
+
"""Whether a new run with these frozen inputs can satisfy the verification
|
|
253
|
+
evidence contract: a generation seals conformance stages only from an
|
|
254
|
+
approved plan with a captured baseline, and an evidence check selects a
|
|
255
|
+
qaCommands entry by its id (`verification_evidence.resolve_evidence_check`)."""
|
|
256
|
+
return ("approvedPlan" in inputs and "conformanceBaselineError" not in inputs
|
|
257
|
+
and all(entry.get("id") is not None
|
|
258
|
+
for entries in inputs["qaCommands"].values() for entry in entries))
|
|
259
|
+
|
|
260
|
+
|
|
251
261
|
def frozen_conformance_baseline(
|
|
252
262
|
inputs: VerificationInputs, task_type: str,
|
|
253
263
|
) -> dict[int, str]:
|
|
@@ -17,6 +17,7 @@ from .verification_generation import (
|
|
|
17
17
|
from .verification_input_ref import VerificationInputReference
|
|
18
18
|
from .verification_inputs import read_verification_inputs
|
|
19
19
|
|
|
20
|
+
VERIFICATION_EVIDENCE_VERSION = "1.0"
|
|
20
21
|
VERIFICATION_GENERATION_HEADER_PREFIXES = (
|
|
21
22
|
"**Verification generation path:**", "**Verification generation digest:**",
|
|
22
23
|
)
|
|
@@ -84,7 +85,7 @@ def _generation_required(
|
|
|
84
85
|
if reference is not None:
|
|
85
86
|
raise ValueError("verification generation requires evidence contract 1.0")
|
|
86
87
|
return False
|
|
87
|
-
if manifest["verificationEvidenceVersion"] !=
|
|
88
|
+
if manifest["verificationEvidenceVersion"] != VERIFICATION_EVIDENCE_VERSION:
|
|
88
89
|
raise ValueError("unsupported verification evidence version")
|
|
89
90
|
task_type = manifest.get("taskType")
|
|
90
91
|
if (not isinstance(task_type, str)
|
|
@@ -13,6 +13,10 @@ from okstra_ctl.domain.wizard.interaction import (
|
|
|
13
13
|
WizardAnswerError,
|
|
14
14
|
normalize_planned_answer,
|
|
15
15
|
)
|
|
16
|
+
from okstra_ctl.phases.implementation_planning.wizard import (
|
|
17
|
+
_DIRECTION_SEPARATOR,
|
|
18
|
+
_settle_selected_direction,
|
|
19
|
+
)
|
|
16
20
|
from okstra_ctl.registry.host_registry import default_host_registry
|
|
17
21
|
from okstra_ctl.run import PrepareError
|
|
18
22
|
|
|
@@ -22,11 +26,13 @@ from .ids import (
|
|
|
22
26
|
PROMPT_GROUPS,
|
|
23
27
|
REQUESTABLE_TASK_TYPES,
|
|
24
28
|
S_ABORTED,
|
|
29
|
+
S_APPROVE_PLAN_CONFIRM,
|
|
25
30
|
S_CONFIRM,
|
|
26
31
|
S_DESIGN_PREP_CONFIRM,
|
|
27
32
|
S_DESIGN_PREP_OVERRIDES,
|
|
28
33
|
S_DONE,
|
|
29
34
|
S_REPORT_LANGUAGE,
|
|
35
|
+
S_SELECTED_DIRECTION_PICK,
|
|
30
36
|
_ABORT_OPTION,
|
|
31
37
|
_STEP_TO_GROUP,
|
|
32
38
|
)
|
|
@@ -40,6 +46,7 @@ from .picker_navigation import (
|
|
|
40
46
|
)
|
|
41
47
|
from .roles import _step_role, _submit_role_prompt, next_role_prompt
|
|
42
48
|
from .steps_analysis import _advance_design_prep_item
|
|
49
|
+
from .steps_plan import _settle_approved_plan
|
|
43
50
|
from .registry import STEPS, STEP_BY_ID, _ROLE_SELECTION_BOUNDARY
|
|
44
51
|
from .worker_settings import (
|
|
45
52
|
next_worker_settings_prompt,
|
|
@@ -285,6 +292,22 @@ def _sim_advance(state: WizardState, prompt: Prompt) -> None:
|
|
|
285
292
|
if q.step not in state.answered:
|
|
286
293
|
state.answered.append(q.step)
|
|
287
294
|
return
|
|
295
|
+
if prompt.step == S_APPROVE_PLAN_CONFIRM:
|
|
296
|
+
# The real submit writes `approved: true` into the plan's data.json
|
|
297
|
+
# and re-renders the report. The deepcopy in `_remaining_screens`
|
|
298
|
+
# does not cover files, so counting screens would approve the plan.
|
|
299
|
+
_settle_approved_plan(state, state.approve_plan_candidate)
|
|
300
|
+
if prompt.step not in state.answered:
|
|
301
|
+
state.answered.append(prompt.step)
|
|
302
|
+
return
|
|
303
|
+
if prompt.step == S_SELECTED_DIRECTION_PICK:
|
|
304
|
+
# The real submit records the picked direction in the report's
|
|
305
|
+
# user-response sidecar; counting screens must not answer for the user.
|
|
306
|
+
path, _, _ = _sim_answer(prompt).partition(_DIRECTION_SEPARATOR)
|
|
307
|
+
_settle_selected_direction(state, path)
|
|
308
|
+
if prompt.step not in state.answered:
|
|
309
|
+
state.answered.append(prompt.step)
|
|
310
|
+
return
|
|
288
311
|
if prompt.step == S_DESIGN_PREP_CONFIRM:
|
|
289
312
|
_advance_design_prep_item(state)
|
|
290
313
|
if prompt.step not in state.answered:
|
|
@@ -403,11 +403,15 @@ def _submit_approve_plan_confirm(state: WizardState, value: str) -> Optional[str
|
|
|
403
403
|
path=resolved, option=state.html_approval_option)
|
|
404
404
|
except PrepareError as exc:
|
|
405
405
|
raise WizardError(str(exc)) from exc
|
|
406
|
-
state
|
|
406
|
+
_settle_approved_plan(state, str(resolved))
|
|
407
|
+
return echo
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def _settle_approved_plan(state: WizardState, path_str: str) -> None:
|
|
411
|
+
state.approved_plan_path = path_str
|
|
407
412
|
state.approve_plan_candidate = ""
|
|
408
413
|
state.html_approval_sidecar = ""
|
|
409
414
|
state.html_approval_option = ""
|
|
410
|
-
return echo
|
|
411
415
|
|
|
412
416
|
|
|
413
417
|
def _build_stage_pick(state: WizardState) -> Prompt:
|
|
@@ -120,7 +120,9 @@ Native-session assignments remain owned by the active host session.
|
|
|
120
120
|
|
|
121
121
|
It records the lead checkpoints it owns and prints them as `progressLines`:
|
|
122
122
|
`phase-3-team-create` when it writes the implicit-team marker,
|
|
123
|
-
`phase-4-dispatch` for each `initial` job
|
|
123
|
+
`phase-4-dispatch` for each `initial` job and each job of an implementation
|
|
124
|
+
correction round (`correction-r<N>`, and a `reverify-r<k>` whose invocation id
|
|
125
|
+
carries `-correction-r<N>-`), `phase-6-synthesis` on the first
|
|
124
126
|
report-writer dispatch, and `phase-5-collect` for each `initial` dispatch it
|
|
125
127
|
settled. The lead emits those lines instead of calling
|
|
126
128
|
`okstra lead-progress append` for them.
|
|
@@ -7,9 +7,16 @@ okstra 의 규칙을 하나도 모른다 — 브랜치가 존재하는지, HEAD
|
|
|
7
7
|
"""
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import os
|
|
10
11
|
import subprocess
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
|
|
14
|
+
# Prefix for git commands that create commits or checkouts nobody asked the
|
|
15
|
+
# repository's hooks about: okstra's merge commits, rebases and scratch
|
|
16
|
+
# worktrees. A hooks path such as husky's `.husky` expects files a fresh
|
|
17
|
+
# worktree does not have, and `--no-verify` still runs `prepare-commit-msg`.
|
|
18
|
+
WITHOUT_HOOKS = ("-c", f"core.hooksPath={os.devnull}")
|
|
19
|
+
|
|
13
20
|
|
|
14
21
|
def _git(cwd: Path, *args: str) -> subprocess.CompletedProcess:
|
|
15
22
|
return subprocess.run(
|
|
@@ -145,7 +152,7 @@ def merge_branch(cwd, branch: str, *, no_ff: bool) -> list[str] | None:
|
|
|
145
152
|
충돌감지·abort 시퀀스의 단일 지점."""
|
|
146
153
|
args = ["merge", "--no-ff", "--no-edit", branch] if no_ff \
|
|
147
154
|
else ["merge", "--no-edit", branch]
|
|
148
|
-
res = _git(Path(cwd), *args)
|
|
155
|
+
res = _git(Path(cwd), *WITHOUT_HOOKS, *args)
|
|
149
156
|
if res.returncode == 0:
|
|
150
157
|
return None
|
|
151
158
|
conflicts = _git(Path(cwd), "diff", "--name-only",
|
|
@@ -10,7 +10,7 @@ from contextlib import contextmanager
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
12
|
from .cleanliness import is_dirty_excluding_okstra
|
|
13
|
-
from .git_ops import _git, is_ancestor
|
|
13
|
+
from .git_ops import WITHOUT_HOOKS, _git, is_ancestor
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def _checked_git(root: Path, *args: str) -> str:
|
|
@@ -38,7 +38,9 @@ def _stage_worktree(project_root: Path, branch: str) -> Iterator[Path]:
|
|
|
38
38
|
if temporary:
|
|
39
39
|
holder = Path(tempfile.mkdtemp(prefix="okstra-rebase-"))
|
|
40
40
|
holder.rmdir()
|
|
41
|
-
_checked_git(
|
|
41
|
+
_checked_git(
|
|
42
|
+
project_root, *WITHOUT_HOOKS, "worktree", "add", str(holder), branch
|
|
43
|
+
)
|
|
42
44
|
try:
|
|
43
45
|
yield holder
|
|
44
46
|
finally:
|
|
@@ -93,6 +95,7 @@ def rebase_stage_branch(
|
|
|
93
95
|
def _apply_rebase(holder: Path, branch: str, old: str, new: str) -> str:
|
|
94
96
|
result = _git(
|
|
95
97
|
holder,
|
|
98
|
+
*WITHOUT_HOOKS,
|
|
96
99
|
"rebase",
|
|
97
100
|
"--no-autostash",
|
|
98
101
|
"--no-autosquash",
|
|
@@ -20,6 +20,7 @@ class WrapperStatus:
|
|
|
20
20
|
# wrapper 가 init 에 기록한 자기 pid (`okstra-wrapper-status.py init`). 상태
|
|
21
21
|
# 파일을 못 쓰고 죽은 프로세스를 await 가 알아보는 유일한 단서다.
|
|
22
22
|
pid: int | None = None
|
|
23
|
+
failure: str = ""
|
|
23
24
|
|
|
24
25
|
@property
|
|
25
26
|
def is_terminal(self) -> bool:
|
|
@@ -45,6 +46,20 @@ def log_path_for_prompt(prompt_path: Path) -> Path:
|
|
|
45
46
|
return Path(f"{prompt_path}.log")
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
def read_log_tail(log_path: Path, max_bytes: int) -> str | None:
|
|
50
|
+
"""The last ``max_bytes`` of a worker log, decoded, or None when the log
|
|
51
|
+
is unreadable or blank. A CLI's own failure text usually sits there and
|
|
52
|
+
nowhere else."""
|
|
53
|
+
try:
|
|
54
|
+
with log_path.open("rb") as handle:
|
|
55
|
+
handle.seek(0, 2)
|
|
56
|
+
handle.seek(max(0, handle.tell() - max_bytes))
|
|
57
|
+
tail = handle.read()
|
|
58
|
+
except OSError:
|
|
59
|
+
return None
|
|
60
|
+
return tail.decode("utf-8", errors="replace").strip() or None
|
|
61
|
+
|
|
62
|
+
|
|
48
63
|
def mutation_snapshot_path_for_prompt(prompt_path: Path) -> Path:
|
|
49
64
|
"""Where okstra writes this prompt's pre-dispatch mutation snapshot."""
|
|
50
65
|
return prompt_path.with_suffix(prompt_path.suffix + ".mutation-audit.json")
|
|
@@ -86,6 +101,7 @@ def read_wrapper_status(path: Path) -> WrapperStatus | None:
|
|
|
86
101
|
log_path=_optional_path(raw.get("log_path")),
|
|
87
102
|
raw=raw,
|
|
88
103
|
pid=_optional_int(raw.get("pid")),
|
|
104
|
+
failure=raw["failure"].strip() if isinstance(raw.get("failure"), str) else "",
|
|
89
105
|
)
|
|
90
106
|
|
|
91
107
|
|