okstra 0.227.0 → 0.228.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 +1 -1
- package/dist/cli-registry.mjs +6 -0
- package/dist/cli-registry.mjs.map +1 -1
- package/docs/architecture/storage-model.md +77 -0
- package/docs/cli.md +15 -3
- package/docs/project-structure-overview.md +12 -2
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/prompts/coding-preflight/clean-code.md +24 -18
- package/runtime/prompts/coding-preflight/overview.md +6 -6
- package/runtime/prompts/duties/code-reviewer.json +1 -0
- package/runtime/prompts/lead/convergence.md +5 -19
- package/runtime/prompts/lead/okstra-lead-contract.md +1 -1
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +1 -1
- package/runtime/python/okstra_ctl/adapters/verification_inputs.py +22 -0
- package/runtime/python/okstra_ctl/adapters/worker_defaults.py +2 -2
- package/runtime/python/okstra_ctl/analysis_packet.py +52 -21
- package/runtime/python/okstra_ctl/approval_decisions.py +30 -1
- package/runtime/python/okstra_ctl/approved_plan_stage_extract.py +100 -66
- package/runtime/python/okstra_ctl/brief_sources.py +162 -44
- package/runtime/python/okstra_ctl/code_review_coverage.py +11 -1
- package/runtime/python/okstra_ctl/code_review_scope.py +157 -0
- package/runtime/python/okstra_ctl/code_review_target.py +46 -10
- package/runtime/python/okstra_ctl/conformance.py +9 -3
- package/runtime/python/okstra_ctl/design_surfaces.py +51 -19
- package/runtime/python/okstra_ctl/final_report_schema.py +37 -30
- package/runtime/python/okstra_ctl/fixed_text.py +31 -9
- package/runtime/python/okstra_ctl/implementation_direction.py +18 -0
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +59 -21
- package/runtime/python/okstra_ctl/json_registry.py +3 -18
- package/runtime/python/okstra_ctl/manager_split.py +201 -84
- package/runtime/python/okstra_ctl/model_io/references.py +31 -1
- package/runtime/python/okstra_ctl/model_io/renderers.py +30 -1
- package/runtime/python/okstra_ctl/model_io_cli.py +9 -0
- package/runtime/python/okstra_ctl/path_hints.py +13 -1
- package/runtime/python/okstra_ctl/paths.py +4 -0
- package/runtime/python/okstra_ctl/phases/final_verification/prior_blockers.py +87 -45
- package/runtime/python/okstra_ctl/phases/final_verification/profile.md +2 -2
- package/runtime/python/okstra_ctl/phases/final_verification/spec.md +10 -2
- package/runtime/python/okstra_ctl/phases/final_verification/validation.py +19 -11
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-executor.md +3 -1
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +3 -1
- package/runtime/python/okstra_ctl/phases/implementation/spec.md +14 -0
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/authoring.py +2 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/validation.py +53 -37
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +1 -1
- package/runtime/python/okstra_ctl/plan_items.py +9 -11
- package/runtime/python/okstra_ctl/ports/verification_inputs.py +17 -0
- package/runtime/python/okstra_ctl/prior_planning.py +6 -17
- package/runtime/python/okstra_ctl/prior_run_summary.py +35 -0
- package/runtime/python/okstra_ctl/qa_commands.py +66 -1
- package/runtime/python/okstra_ctl/qa_commands_cli.py +67 -0
- package/runtime/python/okstra_ctl/qa_procedures.py +235 -0
- package/runtime/python/okstra_ctl/registry/verification_inputs_store.py +8 -0
- package/runtime/python/okstra_ctl/render.py +10 -0
- package/runtime/python/okstra_ctl/report_assembly.py +12 -12
- package/runtime/python/okstra_ctl/run.py +108 -5
- package/runtime/python/okstra_ctl/verification_input_ref.py +80 -0
- package/runtime/python/okstra_ctl/verification_input_types.py +32 -0
- package/runtime/python/okstra_ctl/verification_inputs.py +162 -0
- package/runtime/python/okstra_ctl/verification_plan.py +116 -0
- package/runtime/python/okstra_ctl/worker_prompt_body.py +12 -6
- package/runtime/python/okstra_ctl/worker_prompt_contract.py +5 -1
- package/runtime/python/okstra_ctl/worker_prompt_headers.py +50 -1
- package/runtime/python/okstra_project/dirs.py +22 -0
- package/runtime/python/okstra_project/resolver.py +10 -0
- package/runtime/schemas/final-report-v3.0.schema.json +5 -1
- package/runtime/skills/okstra-brief-gen/SKILL.md +10 -4
- package/runtime/skills/okstra-code-review/SKILL.md +39 -45
- package/runtime/skills/okstra-code-review/references/census-rules.md +14 -2
- package/runtime/skills/okstra-code-review/references/review-calibration.md +31 -8
- package/runtime/skills/okstra-manager/SKILL.md +2 -2
- package/runtime/skills/okstra-setup/SKILL.md +2 -0
- package/runtime/skills/okstra-setup/references/project-config.md +2 -0
- package/runtime/validators/validate-brief.py +21 -5
|
@@ -12,13 +12,21 @@ from __future__ import annotations
|
|
|
12
12
|
import importlib.util
|
|
13
13
|
import re
|
|
14
14
|
import tempfile
|
|
15
|
+
from collections.abc import Mapping, Sequence
|
|
16
|
+
from itertools import permutations
|
|
15
17
|
from pathlib import Path
|
|
16
18
|
from types import ModuleType
|
|
19
|
+
from typing import Any, TypedDict
|
|
17
20
|
|
|
18
21
|
from okstra_ctl.json_boundary import JsonBoundaryError, load_owned_object
|
|
19
22
|
from okstra_ctl.jsonl import append_jsonl
|
|
20
23
|
|
|
21
|
-
from .analysis_packet import
|
|
24
|
+
from .analysis_packet import _fence_mask, project_relative_ref
|
|
25
|
+
from .brief_sources import (
|
|
26
|
+
TOO_LARGE_REASON,
|
|
27
|
+
by_reference_source_entry,
|
|
28
|
+
too_large_to_cite,
|
|
29
|
+
)
|
|
22
30
|
from .ids import slugify_task_segment
|
|
23
31
|
from .manager_paths import children_json_path, events_jsonl_path, split_plan_path, task_manifest_path
|
|
24
32
|
from .manager_store import (
|
|
@@ -38,6 +46,7 @@ RECOMMENDED_PHASES = ("requirements-discovery", "error-analysis", "improvement-d
|
|
|
38
46
|
DEFAULT_PHASE = "requirements-discovery"
|
|
39
47
|
GENERATOR = "okstra-manager"
|
|
40
48
|
SOURCE_TYPE = "linear"
|
|
49
|
+
SPLIT_FETCHED_VIA = "okstra manager task split"
|
|
41
50
|
# 브리프 계약의 필수 서술 필드. 비어 있으면 검증기가 거절하므로 계획 단계에서 먼저 막는다.
|
|
42
51
|
_REQUIRED_TEXT_FIELDS = ("context", "problem", "desiredOutcome")
|
|
43
52
|
_LIST_FIELDS = (
|
|
@@ -59,6 +68,34 @@ _NONE = "_(none)_"
|
|
|
59
68
|
_CREATED = re.compile(r"^created: (\d{4}-\d{2}-\d{2})$", re.M)
|
|
60
69
|
# 다른 이슈나 같은 이슈의 다른 프로젝트가 늘 때 바뀌는 생성 절. 기존 브리프에서는 이 절의 바뀐 줄만 고친다.
|
|
61
70
|
_REFRESHED_SECTIONS = ("### Out of scope", "## Related Artifacts", "## Related Task Graph")
|
|
71
|
+
_OUTSIDE_REFRESHED = (
|
|
72
|
+
"this plan changes it outside the Out of scope, Related Artifacts and "
|
|
73
|
+
"Related Task Graph sections"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class _SplitInputs(TypedDict):
|
|
78
|
+
issue: dict
|
|
79
|
+
assignment: dict
|
|
80
|
+
stem: str
|
|
81
|
+
taskKey: str
|
|
82
|
+
projectId: str
|
|
83
|
+
childTaskId: str
|
|
84
|
+
projectRoot: str
|
|
85
|
+
briefPath: Path
|
|
86
|
+
localSources: list[str]
|
|
87
|
+
graph: list[tuple[str, ...]]
|
|
88
|
+
siblings: list[tuple[str, dict, Path]]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# `total=False` instead of `NotRequired`, which Python 3.10 (the package minimum) lacks.
|
|
92
|
+
class SplitItem(_SplitInputs, total=False):
|
|
93
|
+
"""One (issue, project) pair of a split plan and the brief rendered for it."""
|
|
94
|
+
|
|
95
|
+
current: str | None
|
|
96
|
+
text: str
|
|
97
|
+
base: str | None
|
|
98
|
+
briefStatus: str
|
|
62
99
|
|
|
63
100
|
|
|
64
101
|
def brief_file_title(title: str) -> str:
|
|
@@ -251,36 +288,26 @@ def _source_block(index: int, ref: str, fetched_via: str, fetched_at: str, body:
|
|
|
251
288
|
]
|
|
252
289
|
|
|
253
290
|
|
|
254
|
-
def _local_source_block(index: int, ref: str, fetched_at: str) -> list[str]:
|
|
255
|
-
return [
|
|
256
|
-
f"### Source {index} — file",
|
|
257
|
-
"",
|
|
258
|
-
f"- ref: {ref}",
|
|
259
|
-
"- fetched-via: okstra manager task split",
|
|
260
|
-
f"- fetched-at: {fetched_at}",
|
|
261
|
-
f"- format: {BY_REFERENCE_FORMAT}",
|
|
262
|
-
"",
|
|
263
|
-
"```",
|
|
264
|
-
"```",
|
|
265
|
-
"",
|
|
266
|
-
]
|
|
267
|
-
|
|
268
|
-
|
|
269
291
|
def _local_source_refs(assignment: dict, project_root: Path, where: str, errors: list[str]) -> list[str]:
|
|
270
292
|
"""계획의 `localSources` 를 프로젝트 루트 기준 상대 경로로 바꾼다. 루트 밖이나 없는 파일은 거절한다."""
|
|
271
293
|
root = project_root.resolve()
|
|
272
294
|
refs: list[str] = []
|
|
273
295
|
for index, raw in enumerate(assignment["localSources"], 1):
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
296
|
+
relative = project_relative_ref(raw, root)
|
|
297
|
+
if relative is None:
|
|
298
|
+
errors.append(
|
|
299
|
+
f"{where}.localSources[{index}] {raw!r} does not resolve under project "
|
|
300
|
+
f"root {str(root)!r}"
|
|
301
|
+
)
|
|
280
302
|
continue
|
|
281
|
-
if not
|
|
303
|
+
if not (root / relative).is_file():
|
|
282
304
|
errors.append(f"{where}.localSources[{index}] {raw!r} is not a file under {str(root)!r}")
|
|
283
305
|
continue
|
|
306
|
+
if too_large_to_cite(root, relative):
|
|
307
|
+
errors.append(
|
|
308
|
+
f"{where}.localSources[{index}] {raw!r} is {TOO_LARGE_REASON}"
|
|
309
|
+
)
|
|
310
|
+
continue
|
|
284
311
|
refs.append(relative)
|
|
285
312
|
return list(dict.fromkeys(refs))
|
|
286
313
|
|
|
@@ -365,7 +392,7 @@ def _render_brief(
|
|
|
365
392
|
first_local = 2 if _source_is_issue(source, issue) else 3
|
|
366
393
|
for index, ref in enumerate(local_sources, first_local):
|
|
367
394
|
# 같은 계획을 다시 돌려도 브리프가 같도록 날짜만 쓴다.
|
|
368
|
-
lines.extend(
|
|
395
|
+
lines.extend(by_reference_source_entry(index, ref, SPLIT_FETCHED_VIA, created))
|
|
369
396
|
lines.extend(
|
|
370
397
|
[
|
|
371
398
|
"## Context",
|
|
@@ -421,7 +448,9 @@ def _render_brief(
|
|
|
421
448
|
return "\n".join(lines)
|
|
422
449
|
|
|
423
450
|
|
|
424
|
-
def _validate_rendered(
|
|
451
|
+
def _validate_rendered(
|
|
452
|
+
items: Sequence[Mapping[str, Any]], validator: ModuleType, group_segment: str,
|
|
453
|
+
) -> list[str]:
|
|
425
454
|
errors: list[str] = []
|
|
426
455
|
with tempfile.TemporaryDirectory(prefix="okstra-split-") as scratch:
|
|
427
456
|
for index, item in enumerate(items):
|
|
@@ -440,10 +469,10 @@ def _validate_rendered(items: list[dict], validator: ModuleType, group_segment:
|
|
|
440
469
|
|
|
441
470
|
def _plan_items(
|
|
442
471
|
projects: dict, task_group: str, group_segment: str, source: dict, issues: list[dict], validator: ModuleType,
|
|
443
|
-
) -> tuple[list[
|
|
472
|
+
) -> tuple[list[SplitItem], list[str]]:
|
|
444
473
|
"""(이슈, 프로젝트) 쌍마다 렌더링 입력을 만든다. 본문은 `created` 가 정해진 뒤 `_render_item` 이 쓴다."""
|
|
445
474
|
keys: dict[tuple[str, str], str] = {}
|
|
446
|
-
items: list[
|
|
475
|
+
items: list[SplitItem] = []
|
|
447
476
|
for issue in issues:
|
|
448
477
|
ticket = issue["ticketId"]
|
|
449
478
|
stem = "-".join(part for part in (ticket, brief_file_title(issue["title"])) if part)
|
|
@@ -453,9 +482,11 @@ def _plan_items(
|
|
|
453
482
|
key = f"{project_id}:{task_group}:{child_task_id}"
|
|
454
483
|
keys[(ticket, project_id)] = key
|
|
455
484
|
root = Path(str(projects[project_id].get("projectRoot") or ""))
|
|
485
|
+
brief_dir = root / ".okstra" / "briefs" / group_segment
|
|
456
486
|
items.append({"issue": issue, "assignment": assignment, "stem": stem, "taskKey": key,
|
|
457
487
|
"projectId": project_id, "childTaskId": child_task_id, "projectRoot": str(root),
|
|
458
|
-
"briefPath":
|
|
488
|
+
"briefPath": brief_dir / f"{stem}.md",
|
|
489
|
+
"localSources": [], "graph": [], "siblings": []})
|
|
459
490
|
errors: list[str] = []
|
|
460
491
|
for item in items:
|
|
461
492
|
item["localSources"] = _local_source_refs(item["assignment"], Path(item["projectRoot"]),
|
|
@@ -468,7 +499,9 @@ def _plan_items(
|
|
|
468
499
|
return items, errors
|
|
469
500
|
|
|
470
501
|
|
|
471
|
-
def _render_item(
|
|
502
|
+
def _render_item(
|
|
503
|
+
item: SplitItem, source: dict, task_group: str, manager_task: str, created: str,
|
|
504
|
+
) -> str:
|
|
472
505
|
return _render_brief(source=source, issue=item["issue"], assignment=item["assignment"],
|
|
473
506
|
task_group=task_group, manager_task=manager_task,
|
|
474
507
|
child_task_id=item["childTaskId"], stem=item["stem"],
|
|
@@ -479,18 +512,22 @@ def _render_item(item: dict, source: dict, task_group: str, manager_task: str, c
|
|
|
479
512
|
def _previous_items(
|
|
480
513
|
home: Path, manager_id: str, task_group: str, task_id: str, projects: dict, group_segment: str,
|
|
481
514
|
validator: ModuleType,
|
|
482
|
-
) -> tuple[dict, dict]:
|
|
483
|
-
"""
|
|
515
|
+
) -> tuple[dict[Path, SplitItem], dict, str]:
|
|
516
|
+
"""The kept plan's items by brief path, its source, and why none can be compared.
|
|
517
|
+
|
|
518
|
+
The reason is empty when the kept plan exists and validates against the projects.
|
|
519
|
+
"""
|
|
484
520
|
path = split_plan_path(home, manager_id, task_group, task_id)
|
|
485
521
|
if not path.is_file():
|
|
486
|
-
return {}, {}
|
|
522
|
+
return {}, {}, "there is no kept split plan to compare it with"
|
|
487
523
|
source, issues, errors = normalize_plan(_load_plan(path), set(projects), set(validator.TASK_RELATIONS))
|
|
524
|
+
if not errors:
|
|
525
|
+
items, errors = _plan_items(
|
|
526
|
+
projects, task_group, group_segment, source, issues, validator,
|
|
527
|
+
)
|
|
488
528
|
if errors:
|
|
489
|
-
return {}, {}
|
|
490
|
-
|
|
491
|
-
if errors:
|
|
492
|
-
return {}, {}
|
|
493
|
-
return {item["briefPath"]: item for item in items}, source
|
|
529
|
+
return {}, {}, "the kept split plan no longer validates: " + "; ".join(errors)
|
|
530
|
+
return {item["briefPath"]: item for item in items}, source, ""
|
|
494
531
|
|
|
495
532
|
|
|
496
533
|
def _existing_created(text: str) -> str:
|
|
@@ -502,13 +539,26 @@ def _section_spans(lines: list[str]) -> dict[str, tuple[int, int]]:
|
|
|
502
539
|
"""펜스 밖 제목 줄마다 본문 범위 (시작, 끝). Source Material 본문 속 `#` 줄은 제목이 아니다."""
|
|
503
540
|
headings = [index for index, (line, fenced) in enumerate(zip(lines, _fence_mask(lines)))
|
|
504
541
|
if not fenced and line.startswith("#")]
|
|
542
|
+
# A hand-added subheading stays inside its section, as validate-brief reads it:
|
|
543
|
+
# a heading closes every open heading of the same or a deeper level.
|
|
544
|
+
ends: dict[int, int] = {}
|
|
545
|
+
open_headings: list[tuple[int, int]] = []
|
|
546
|
+
for start in headings:
|
|
547
|
+
level = _heading_level(lines[start])
|
|
548
|
+
while open_headings and open_headings[-1][1] >= level:
|
|
549
|
+
ends[open_headings.pop()[0]] = start
|
|
550
|
+
open_headings.append((start, level))
|
|
551
|
+
ends.update((start, len(lines)) for start, _ in open_headings)
|
|
505
552
|
spans: dict[str, tuple[int, int]] = {}
|
|
506
|
-
for
|
|
507
|
-
|
|
508
|
-
spans.setdefault(lines[start], (start + 1, end))
|
|
553
|
+
for start in headings:
|
|
554
|
+
spans.setdefault(lines[start], (start + 1, ends[start]))
|
|
509
555
|
return spans
|
|
510
556
|
|
|
511
557
|
|
|
558
|
+
def _heading_level(line: str) -> int:
|
|
559
|
+
return len(line) - len(line.lstrip("#"))
|
|
560
|
+
|
|
561
|
+
|
|
512
562
|
def _outside_refreshed(lines: list[str], spans: dict[str, tuple[int, int]]) -> list[str]:
|
|
513
563
|
kept = list(lines)
|
|
514
564
|
for start, end in sorted((spans[heading] for heading in _REFRESHED_SECTIONS), reverse=True):
|
|
@@ -519,7 +569,8 @@ def _outside_refreshed(lines: list[str], spans: dict[str, tuple[int, int]]) -> l
|
|
|
519
569
|
def _merge_section(ours: list[str], base: list[str], new: list[str]) -> list[str]:
|
|
520
570
|
"""지난 렌더링에서 이번 렌더링으로 바뀐 줄만 기존 절에 반영한다. 손으로 더한 줄은 남는다."""
|
|
521
571
|
removed = set(base) - set(new)
|
|
522
|
-
added = [line for line in new
|
|
572
|
+
added = [line for line in new
|
|
573
|
+
if line.strip() and line not in base and line not in ours]
|
|
523
574
|
merged = [line for line in ours if not (line.strip() and line in removed)]
|
|
524
575
|
if any(line != _NONE for line in added):
|
|
525
576
|
merged = [line for line in merged if line != _NONE]
|
|
@@ -532,20 +583,117 @@ def _merge_section(ours: list[str], base: list[str], new: list[str]) -> list[str
|
|
|
532
583
|
return merged
|
|
533
584
|
|
|
534
585
|
|
|
535
|
-
def
|
|
536
|
-
"""
|
|
586
|
+
def _nested_refreshed_reason(spans: dict[str, tuple[int, int]]) -> str:
|
|
587
|
+
"""Why a refreshed heading lies inside another refreshed section, or ""."""
|
|
588
|
+
# Merging an outer section would discard the merge already applied to a nested one.
|
|
589
|
+
for outer, inner in permutations(_REFRESHED_SECTIONS, 2):
|
|
590
|
+
start, end = spans[outer]
|
|
591
|
+
inner_heading_line = spans[inner][0] - 1
|
|
592
|
+
if start <= inner_heading_line < end:
|
|
593
|
+
return f"`{inner}` is inside `{outer}`"
|
|
594
|
+
return ""
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def _refresh(current: str, base: str, new: str) -> tuple[str | None, str]:
|
|
598
|
+
"""`current` with the changes from `base` to `new` applied, or None and why not.
|
|
599
|
+
|
|
600
|
+
Only a difference confined to `_REFRESHED_SECTIONS` can be applied.
|
|
601
|
+
"""
|
|
537
602
|
ours, old, fresh = current.split("\n"), base.split("\n"), new.split("\n")
|
|
538
603
|
ours_spans, old_spans, fresh_spans = _section_spans(ours), _section_spans(old), _section_spans(fresh)
|
|
539
|
-
|
|
540
|
-
|
|
604
|
+
missing = [heading for heading in _REFRESHED_SECTIONS if heading not in ours_spans]
|
|
605
|
+
if missing:
|
|
606
|
+
names = ", ".join(f"`{heading}`" for heading in missing)
|
|
607
|
+
return None, f"it has no {names} heading to refresh"
|
|
608
|
+
nested_reason = _nested_refreshed_reason(ours_spans)
|
|
609
|
+
if nested_reason:
|
|
610
|
+
return None, nested_reason
|
|
541
611
|
if _outside_refreshed(old, old_spans) != _outside_refreshed(fresh, fresh_spans):
|
|
542
|
-
return None
|
|
612
|
+
return None, _OUTSIDE_REFRESHED
|
|
543
613
|
result = list(ours)
|
|
544
614
|
for heading in sorted(_REFRESHED_SECTIONS, key=lambda heading: ours_spans[heading][0], reverse=True):
|
|
545
615
|
start, end = ours_spans[heading]
|
|
546
616
|
result[start:end] = _merge_section(ours[start:end], old[slice(*old_spans[heading])],
|
|
547
617
|
fresh[slice(*fresh_spans[heading])])
|
|
548
|
-
return "\n".join(result)
|
|
618
|
+
return "\n".join(result), ""
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def _brief_status(item: SplitItem, previous_reason: str) -> tuple[str, str, str]:
|
|
622
|
+
"""The brief status, the text to write, and why an `overwritten` one was not merged.
|
|
623
|
+
|
|
624
|
+
The text is the merged brief for `refreshed` and the new rendering otherwise.
|
|
625
|
+
"""
|
|
626
|
+
current, base, text = item["current"], item["base"], item["text"]
|
|
627
|
+
if current is None:
|
|
628
|
+
return "created", text, ""
|
|
629
|
+
if current == text or base == text:
|
|
630
|
+
return "unchanged", text, ""
|
|
631
|
+
if base is None:
|
|
632
|
+
reason = previous_reason or "the kept split plan does not list this brief"
|
|
633
|
+
return "overwritten", text, reason
|
|
634
|
+
refreshed, reason = _refresh(current, base, text)
|
|
635
|
+
if refreshed == current:
|
|
636
|
+
return "unchanged", text, ""
|
|
637
|
+
if refreshed is None:
|
|
638
|
+
return "overwritten", text, reason
|
|
639
|
+
return "refreshed", refreshed, ""
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
def _settle_statuses(
|
|
643
|
+
items: list[SplitItem],
|
|
644
|
+
previous_reason: str,
|
|
645
|
+
overwrite: bool,
|
|
646
|
+
validator: ModuleType,
|
|
647
|
+
group_segment: str,
|
|
648
|
+
) -> None:
|
|
649
|
+
"""Set each item's `briefStatus` and the `text` to write.
|
|
650
|
+
|
|
651
|
+
Raises on unresolved conflicts and on refreshed briefs that fail validation.
|
|
652
|
+
"""
|
|
653
|
+
conflicts = []
|
|
654
|
+
for item in items:
|
|
655
|
+
item["briefStatus"], item["text"], reason = _brief_status(item, previous_reason)
|
|
656
|
+
if reason:
|
|
657
|
+
conflicts.append(f"{item['briefPath']}: {reason}")
|
|
658
|
+
if conflicts and not overwrite:
|
|
659
|
+
raise ManagerError(
|
|
660
|
+
"briefs already exist with content this plan would change; "
|
|
661
|
+
"pass --overwrite to replace them:\n- " + "\n- ".join(conflicts)
|
|
662
|
+
)
|
|
663
|
+
refreshed_items = [item for item in items if item["briefStatus"] == "refreshed"]
|
|
664
|
+
errors = _validate_rendered(refreshed_items, validator, group_segment)
|
|
665
|
+
if errors:
|
|
666
|
+
raise ManagerError(
|
|
667
|
+
"refreshed briefs failed validate-brief:\n- " + "\n- ".join(errors)
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def _register_children(
|
|
672
|
+
home: Path,
|
|
673
|
+
manager_id: str,
|
|
674
|
+
task_group: str,
|
|
675
|
+
task_id: str,
|
|
676
|
+
items: list[SplitItem],
|
|
677
|
+
title: str,
|
|
678
|
+
when: str,
|
|
679
|
+
) -> None:
|
|
680
|
+
existing = task_manifest_path(home, manager_id, task_group, task_id).is_file()
|
|
681
|
+
members = [{"projectId": item["projectId"], "taskId": item["childTaskId"]}
|
|
682
|
+
for item in items]
|
|
683
|
+
create_task(home, manager_id, task_group, task_id, members,
|
|
684
|
+
objective="" if existing else title, now=when)
|
|
685
|
+
children_path = children_json_path(home, manager_id, task_group, task_id)
|
|
686
|
+
children = _read_json(children_path)
|
|
687
|
+
by_key = {child.get("taskKey"): child for child in children.get("children", [])
|
|
688
|
+
if isinstance(child, dict)}
|
|
689
|
+
for item in items:
|
|
690
|
+
by_key[item["taskKey"]].update({
|
|
691
|
+
"ticketId": item["issue"]["ticketId"],
|
|
692
|
+
"briefPath": str(item["briefPath"]),
|
|
693
|
+
"scope": list(item["assignment"]["scope"]),
|
|
694
|
+
"recommendedPhase": item["assignment"]["recommendedPhase"],
|
|
695
|
+
})
|
|
696
|
+
_write_json(children_path, children)
|
|
549
697
|
|
|
550
698
|
|
|
551
699
|
def split_task(
|
|
@@ -574,8 +722,9 @@ def split_task(
|
|
|
574
722
|
items, errors = _plan_items(projects, task_group, group_segment, source, issues, validator)
|
|
575
723
|
if errors:
|
|
576
724
|
raise ManagerError("split plan rejected:\n- " + "\n- ".join(errors))
|
|
577
|
-
previous, previous_source = _previous_items(
|
|
578
|
-
|
|
725
|
+
previous, previous_source, previous_reason = _previous_items(
|
|
726
|
+
home, manager_id, task_group, task_id, projects, group_segment, validator,
|
|
727
|
+
)
|
|
579
728
|
for item in items:
|
|
580
729
|
path = item["briefPath"]
|
|
581
730
|
item["current"] = path.read_text(encoding="utf-8") if path.is_file() else None
|
|
@@ -587,45 +736,13 @@ def split_task(
|
|
|
587
736
|
errors = _validate_rendered(items, validator, group_segment)
|
|
588
737
|
if errors:
|
|
589
738
|
raise ManagerError("rendered briefs failed validate-brief:\n- " + "\n- ".join(errors))
|
|
590
|
-
|
|
591
|
-
current, base = item["current"], item["base"]
|
|
592
|
-
refreshed = _refresh(current, base, item["text"]) if current is not None and base is not None else None
|
|
593
|
-
if current is None:
|
|
594
|
-
item["briefStatus"] = "created"
|
|
595
|
-
elif current == item["text"] or base == item["text"] or refreshed == current:
|
|
596
|
-
item["briefStatus"] = "unchanged"
|
|
597
|
-
elif refreshed is not None:
|
|
598
|
-
item["briefStatus"] = "refreshed"
|
|
599
|
-
item["text"] = refreshed
|
|
600
|
-
else:
|
|
601
|
-
item["briefStatus"] = "overwritten"
|
|
602
|
-
conflicts = [str(item["briefPath"]) for item in items if item["briefStatus"] == "overwritten"]
|
|
603
|
-
if conflicts and not overwrite:
|
|
604
|
-
raise ManagerError(
|
|
605
|
-
"briefs already exist with content this plan would change outside the Related Task Graph, "
|
|
606
|
-
"Out of scope and Related Artifacts sections; pass --overwrite to replace them:\n- "
|
|
607
|
-
+ "\n- ".join(conflicts)
|
|
608
|
-
)
|
|
609
|
-
errors = _validate_rendered([item for item in items if item["briefStatus"] == "refreshed"], validator,
|
|
610
|
-
group_segment)
|
|
611
|
-
if errors:
|
|
612
|
-
raise ManagerError("refreshed briefs failed validate-brief:\n- " + "\n- ".join(errors))
|
|
739
|
+
_settle_statuses(items, previous_reason, overwrite, validator, group_segment)
|
|
613
740
|
for item in items:
|
|
614
741
|
if item["briefStatus"] != "unchanged":
|
|
615
742
|
item["briefPath"].parent.mkdir(parents=True, exist_ok=True)
|
|
616
743
|
item["briefPath"].write_text(item["text"], encoding="utf-8")
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
[{"projectId": item["projectId"], "taskId": item["childTaskId"]} for item in items],
|
|
620
|
-
objective="" if existing else source["title"], now=when)
|
|
621
|
-
children_path = children_json_path(home, manager_id, task_group, task_id)
|
|
622
|
-
children = _read_json(children_path)
|
|
623
|
-
by_key = {child.get("taskKey"): child for child in children.get("children", []) if isinstance(child, dict)}
|
|
624
|
-
for item in items:
|
|
625
|
-
by_key[item["taskKey"]].update({"ticketId": item["issue"]["ticketId"], "briefPath": str(item["briefPath"]),
|
|
626
|
-
"scope": list(item["assignment"]["scope"]),
|
|
627
|
-
"recommendedPhase": item["assignment"]["recommendedPhase"]})
|
|
628
|
-
_write_json(children_path, children)
|
|
744
|
+
_register_children(home, manager_id, task_group, task_id, items, source["title"],
|
|
745
|
+
when)
|
|
629
746
|
_write_json(split_plan_path(home, manager_id, task_group, task_id), plan)
|
|
630
747
|
briefs = [{"taskKey": item["taskKey"], "projectId": item["projectId"], "ticketId": item["issue"]["ticketId"],
|
|
631
748
|
"briefPath": str(item["briefPath"]), "briefStatus": item["briefStatus"]} for item in items]
|
|
@@ -13,7 +13,37 @@ from typing import Any, Mapping
|
|
|
13
13
|
from okstra_project import StateError, parse_task_key, slugify
|
|
14
14
|
|
|
15
15
|
from ..json_boundary import JsonBoundaryError, load_owned_object
|
|
16
|
-
from ..
|
|
16
|
+
from ..convergence import ConvergenceContractError, validated_run_authority
|
|
17
|
+
from ..paths import RunRef, okstra_home
|
|
18
|
+
from ..ports.verification_inputs import VerificationInputStore
|
|
19
|
+
from ..verification_input_ref import VerificationInputReference
|
|
20
|
+
from ..verification_input_types import VerificationInputs
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _load_verification_input(
|
|
24
|
+
run_manifest: Path, store: VerificationInputStore,
|
|
25
|
+
) -> tuple[VerificationInputReference, VerificationInputs]:
|
|
26
|
+
try:
|
|
27
|
+
authority = validated_run_authority(run_manifest)
|
|
28
|
+
reference = VerificationInputReference.from_artifact_fields(authority.payload)
|
|
29
|
+
if reference is None:
|
|
30
|
+
raise ValueError("run has no verification input reference")
|
|
31
|
+
sequence = authority.payload["runSequencesByCategory"]["manifests"]
|
|
32
|
+
expected = RunRef.from_run_dir(
|
|
33
|
+
authority.run_dir, seq=int(sequence),
|
|
34
|
+
).verification_inputs
|
|
35
|
+
if reference.relative_path != expected.relative_to(
|
|
36
|
+
authority.project_root,
|
|
37
|
+
).as_posix():
|
|
38
|
+
raise ValueError("verification inputs do not match canonical run")
|
|
39
|
+
path = _fixed_owned_artifact_path(
|
|
40
|
+
authority.project_root,
|
|
41
|
+
expected.relative_to(authority.project_root / ".okstra"),
|
|
42
|
+
"verification inputs",
|
|
43
|
+
)
|
|
44
|
+
return reference, store.read(path, reference.digest)
|
|
45
|
+
except (ConvergenceContractError, OSError, ValueError) as exc:
|
|
46
|
+
raise JsonBoundaryError(run_manifest, "verification inputs", str(exc)) from exc
|
|
17
47
|
|
|
18
48
|
|
|
19
49
|
def _fixed_owned_artifact_path(
|
|
@@ -16,9 +16,10 @@ from ..convergence import (
|
|
|
16
16
|
validated_run_authority,
|
|
17
17
|
)
|
|
18
18
|
from ..error_zip import last_output_path
|
|
19
|
-
from ..fixed_text import line as _line, scalar as _value
|
|
19
|
+
from ..fixed_text import line as _line, scalar as _value, quoted_value_lines
|
|
20
20
|
from ..json_boundary import JsonBoundaryError, load_owned_object
|
|
21
21
|
from ..paths import find_asset_root, okstra_home
|
|
22
|
+
from ..ports.verification_inputs import VerificationInputStore
|
|
22
23
|
from ..phases.catalog import PhaseAssetError, profile_markdown
|
|
23
24
|
from ..recap import assemble_group_recap, assemble_recap
|
|
24
25
|
from ..role_requirements import RoleProfileError, load_role_profile
|
|
@@ -42,6 +43,7 @@ from .references import (
|
|
|
42
43
|
_group_segment,
|
|
43
44
|
_latest_task_pointer,
|
|
44
45
|
_load_project,
|
|
46
|
+
_load_verification_input,
|
|
45
47
|
_owned_run_manifest_path,
|
|
46
48
|
_owned_task_manifest_path,
|
|
47
49
|
_owned_tasks_root,
|
|
@@ -145,6 +147,31 @@ def render_project_context(project_root: Path, task_ref: str = "") -> str:
|
|
|
145
147
|
)
|
|
146
148
|
|
|
147
149
|
|
|
150
|
+
def render_verification_input(
|
|
151
|
+
run_manifest: Path, store: VerificationInputStore,
|
|
152
|
+
) -> str:
|
|
153
|
+
reference, inputs = _load_verification_input(run_manifest, store)
|
|
154
|
+
rows = [
|
|
155
|
+
"# Okstra Verification Input\n\n",
|
|
156
|
+
_line("Verification inputs", reference.relative_path),
|
|
157
|
+
_line("Verification inputs digest", reference.digest),
|
|
158
|
+
_line("Source root", inputs["sourceRoot"]),
|
|
159
|
+
"\nThese are frozen declarations, not command-execution evidence.\n",
|
|
160
|
+
"Scalar values below use JSON quoting; preserve escaped characters "
|
|
161
|
+
"when reading commands and procedure bodies.\n",
|
|
162
|
+
"\n## QA Commands\n\n",
|
|
163
|
+
*quoted_value_lines("QA commands", inputs["qaCommands"]),
|
|
164
|
+
"\n## Procedures\n\n",
|
|
165
|
+
*quoted_value_lines("Procedures", inputs["procedures"]),
|
|
166
|
+
]
|
|
167
|
+
if "approvedPlan" in inputs:
|
|
168
|
+
rows.extend([
|
|
169
|
+
"\n## Approved Plan\n\n",
|
|
170
|
+
*quoted_value_lines("Approved plan", inputs["approvedPlan"]),
|
|
171
|
+
])
|
|
172
|
+
return "".join(rows)
|
|
173
|
+
|
|
174
|
+
|
|
148
175
|
def render_run_input(run_manifest: Path) -> str:
|
|
149
176
|
"""런 매니페스트의 간결한 비밀 없는 실행 식별자를 렌더한다."""
|
|
150
177
|
run_manifest = _owned_run_manifest_path(run_manifest)
|
|
@@ -182,6 +209,8 @@ def render_run_input(run_manifest: Path) -> str:
|
|
|
182
209
|
+ _line("Task manifest", run.get("taskManifestPath"))
|
|
183
210
|
+ _line("Instruction set", run.get("instructionSetPath"))
|
|
184
211
|
+ _line("Reference expectations", run.get("referenceExpectationsPath"))
|
|
212
|
+
+ _line("Verification inputs", run.get("verificationInputsPath"))
|
|
213
|
+
+ _line("Verification inputs digest", run.get("verificationInputsDigest"))
|
|
185
214
|
+ _line("Report template", run.get("reportTemplatePath"))
|
|
186
215
|
)
|
|
187
216
|
|
|
@@ -10,6 +10,7 @@ import sys
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
12
|
from .json_boundary import JsonBoundaryError
|
|
13
|
+
from .registry.verification_inputs_store import default_verification_input_store
|
|
13
14
|
from .model_io.renderers import (
|
|
14
15
|
render_active_context_input,
|
|
15
16
|
render_code_review_input,
|
|
@@ -24,12 +25,14 @@ from .model_io.renderers import (
|
|
|
24
25
|
render_schedule_input,
|
|
25
26
|
render_status_input,
|
|
26
27
|
render_task_selection_input,
|
|
28
|
+
render_verification_input,
|
|
27
29
|
)
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
_CLI_EPILOG = r"""Usage:
|
|
31
33
|
okstra model-io project-context --project-root <dir> [--task-ref <task-id|task-key|task-manifest-path>]
|
|
32
34
|
okstra model-io run-input --run-manifest <path>
|
|
35
|
+
okstra model-io verification-input --run-manifest <path>
|
|
33
36
|
okstra model-io active-context-input --project-root <dir> --run-manifest <path>
|
|
34
37
|
okstra model-io schedule-input --project-root <dir> --task-group <id>
|
|
35
38
|
okstra model-io code-review-input --project-root <dir> --base <ref> --head <ref>
|
|
@@ -52,6 +55,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
52
55
|
project.add_argument("--task-ref", default="")
|
|
53
56
|
run = commands.add_parser("run-input")
|
|
54
57
|
run.add_argument("--run-manifest", required=True)
|
|
58
|
+
verification = commands.add_parser("verification-input")
|
|
59
|
+
verification.add_argument("--run-manifest", required=True)
|
|
55
60
|
active = commands.add_parser("active-context-input")
|
|
56
61
|
active.add_argument("--project-root", required=True)
|
|
57
62
|
active.add_argument("--run-manifest", required=True)
|
|
@@ -93,6 +98,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
93
98
|
text = render_project_context(Path(args.project_root), args.task_ref)
|
|
94
99
|
elif args.command == "run-input":
|
|
95
100
|
text = render_run_input(Path(args.run_manifest))
|
|
101
|
+
elif args.command == "verification-input":
|
|
102
|
+
text = render_verification_input(
|
|
103
|
+
Path(args.run_manifest), default_verification_input_store(),
|
|
104
|
+
)
|
|
96
105
|
elif args.command == "active-context-input":
|
|
97
106
|
text = render_active_context_input(
|
|
98
107
|
Path(args.project_root), Path(args.run_manifest)
|
|
@@ -19,6 +19,9 @@ from .paths import (
|
|
|
19
19
|
task_timeline_file,
|
|
20
20
|
)
|
|
21
21
|
from .worker_artifacts import worker_artifact_paths
|
|
22
|
+
from .verification_input_ref import (
|
|
23
|
+
VerificationInputReference, artifact_fields, artifact_fields_from_context,
|
|
24
|
+
)
|
|
22
25
|
|
|
23
26
|
RUN_CONTEXT_KIND = "run-context"
|
|
24
27
|
RUN_CONTEXT_SCHEMA_VERSION = "2.0"
|
|
@@ -45,6 +48,7 @@ def compact_run_context(ctx: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
45
48
|
"runTimestampIso": ctx.get("RUN_TIMESTAMP_ISO", ""),
|
|
46
49
|
"taskDate": ctx.get("TASK_DATE", ""),
|
|
47
50
|
},
|
|
51
|
+
**artifact_fields_from_context(ctx),
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
|
|
@@ -72,6 +76,7 @@ def compact_active_run_context(
|
|
|
72
76
|
"executorWorktree": dict(_mapping(payload.get("executorWorktree"))),
|
|
73
77
|
"verificationTarget": dict(_mapping(payload.get("verificationTarget"))),
|
|
74
78
|
"lazyReadPlan": dict(_mapping(payload.get("lazyReadPlan"))),
|
|
79
|
+
**artifact_fields_from_context(ctx),
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
|
|
@@ -83,7 +88,11 @@ def hydrate_run_context(payload: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
83
88
|
identity = payload.get("identity")
|
|
84
89
|
if not isinstance(hints, Mapping) or not isinstance(identity, Mapping):
|
|
85
90
|
return dict(payload)
|
|
86
|
-
|
|
91
|
+
ctx = _hydrate_from_hints(identity, hints, payload.get("timestamps", {}))
|
|
92
|
+
reference = VerificationInputReference.from_artifact_fields(payload)
|
|
93
|
+
if reference is not None:
|
|
94
|
+
ctx.update(reference.to_context(Path(str(identity.get("projectRoot", "")))))
|
|
95
|
+
return ctx
|
|
87
96
|
|
|
88
97
|
|
|
89
98
|
def hydrate_active_run_context(payload: Mapping[str, Any]) -> dict[str, Any]:
|
|
@@ -92,11 +101,13 @@ def hydrate_active_run_context(payload: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
92
101
|
return dict(payload)
|
|
93
102
|
identity = _mapping(payload.get("identity"))
|
|
94
103
|
hints = _mapping(payload.get("pathHints"))
|
|
104
|
+
reference = VerificationInputReference.from_artifact_fields(payload)
|
|
95
105
|
ctx = hydrate_run_context({
|
|
96
106
|
"kind": RUN_CONTEXT_KIND,
|
|
97
107
|
"identity": identity,
|
|
98
108
|
"pathHints": hints,
|
|
99
109
|
"timestamps": {},
|
|
110
|
+
**artifact_fields(reference),
|
|
100
111
|
})
|
|
101
112
|
return {
|
|
102
113
|
"schemaVersion": "1.0",
|
|
@@ -305,6 +316,7 @@ def _hydrate_active_source_artifacts(ctx: Mapping[str, str]) -> dict[str, str]:
|
|
|
305
316
|
"runContextPath": ctx.get("RUN_CONTEXT_RELATIVE_PATH", ""),
|
|
306
317
|
"runInputsPath": ctx.get("RUN_INPUTS_RELATIVE_PATH", ""),
|
|
307
318
|
"historyTimelinePath": ctx.get("TIMELINE_RELATIVE_PATH", ""),
|
|
319
|
+
**artifact_fields_from_context(ctx),
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
|
|
@@ -219,6 +219,10 @@ class RunRef:
|
|
|
219
219
|
def manifest(self) -> Path:
|
|
220
220
|
return self.run_dir / "manifests" / f"run-manifest{self._suffix}.json"
|
|
221
221
|
|
|
222
|
+
@property
|
|
223
|
+
def verification_inputs(self) -> Path:
|
|
224
|
+
return self.run_dir / "verification" / f"inputs{self._suffix}.json"
|
|
225
|
+
|
|
222
226
|
@property
|
|
223
227
|
def convergence_state(self) -> Path:
|
|
224
228
|
"""이 run 의 finding convergence 상태 파일.
|