okstra 0.234.1 → 0.236.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/dist/cli-registry.mjs +7 -0
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/implementation-report/implementation-report.d.mts +1 -0
- package/dist/commands/implementation-report/implementation-report.mjs +73 -0
- package/dist/commands/implementation-report/implementation-report.mjs.map +1 -0
- package/dist/commands/trace/comparison.d.mts +39 -0
- package/dist/commands/trace/comparison.mjs +138 -0
- package/dist/commands/trace/comparison.mjs.map +1 -0
- package/dist/commands/trace/document.d.mts +8 -0
- package/dist/commands/trace/document.mjs +37 -0
- package/dist/commands/trace/document.mjs.map +1 -0
- package/dist/commands/trace/line-counts.d.mts +15 -0
- package/dist/commands/trace/line-counts.mjs +107 -0
- package/dist/commands/trace/line-counts.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +2 -1
- package/dist/commands/trace/model.mjs +13 -1
- package/dist/commands/trace/model.mjs.map +1 -1
- package/dist/commands/trace/progression.mjs +7 -3
- package/dist/commands/trace/progression.mjs.map +1 -1
- package/dist/commands/trace/task-link.d.mts +3 -0
- package/dist/commands/trace/task-link.mjs.map +1 -1
- package/dist/commands/trace/trace.mjs +64 -44
- package/dist/commands/trace/trace.mjs.map +1 -1
- package/dist/lib/host-registry-client.d.mts +9 -2
- package/dist/lib/host-registry-client.mjs +29 -3
- package/dist/lib/host-registry-client.mjs.map +1 -1
- package/dist/lib/python-helper.d.mts +1 -1
- package/dist/lib/python-helper.mjs +11 -5
- package/dist/lib/python-helper.mjs.map +1 -1
- package/dist/lib/runtime-payload.mjs +1 -0
- package/dist/lib/runtime-payload.mjs.map +1 -1
- package/dist/lib/types.d.mts +1 -0
- package/docs/architecture/storage-model.md +50 -0
- package/docs/architecture.md +1 -1
- package/docs/cli.md +37 -15
- package/docs/project-structure-overview.md +6 -1
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/operations/trace-tests-review.json +6 -0
- package/runtime/bin/lib/okstra/usage.sh +8 -8
- package/runtime/bin/okstra-qwen-exec.sh +5 -0
- package/runtime/prompts/duties/test-reviewer.json +32 -0
- package/runtime/prompts/lead/convergence.md +4 -1
- package/runtime/prompts/lead/okstra-lead-contract.md +3 -3
- package/runtime/prompts/lead/report-writer.md +13 -1
- package/runtime/prompts/profiles/_common-contract.md +10 -1
- package/runtime/prompts/wizard/prompts.ko.json +16 -4
- package/runtime/python/okstra_ctl/adapters/providers/antigravity/adapter.py +10 -2
- package/runtime/python/okstra_ctl/adapters/providers/claude/adapter.py +16 -1
- package/runtime/python/okstra_ctl/adapters/providers/codex/adapter.py +20 -5
- package/runtime/python/okstra_ctl/adapters/providers/kimi/adapter.py +17 -9
- package/runtime/python/okstra_ctl/adapters/providers/qwen/adapter.py +88 -0
- package/runtime/python/okstra_ctl/adapters/providers/qwen/manifest.json +1 -0
- package/runtime/python/okstra_ctl/adapters/providers/qwen/settings.json +12 -0
- package/runtime/python/okstra_ctl/adapters/providers/zai/adapter.py +8 -2
- package/runtime/python/okstra_ctl/agent/invocation.py +109 -56
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +17 -0
- package/runtime/python/okstra_ctl/attempt_evidence.py +5 -2
- package/runtime/python/okstra_ctl/business_flow/contracts.py +11 -0
- package/runtime/python/okstra_ctl/business_flow/engine.py +90 -32
- package/runtime/python/okstra_ctl/business_flow/hooks.py +4 -2
- package/runtime/python/okstra_ctl/business_flow/source.py +39 -7
- package/runtime/python/okstra_ctl/business_flow/store.py +94 -28
- package/runtime/python/okstra_ctl/code_review_census.py +38 -0
- package/runtime/python/okstra_ctl/code_review_coverage.py +15 -4
- package/runtime/python/okstra_ctl/code_review_prepare.py +15 -3
- package/runtime/python/okstra_ctl/code_review_scope.py +3 -2
- package/runtime/python/okstra_ctl/code_review_target.py +16 -6
- package/runtime/python/okstra_ctl/conformance_evidence.py +44 -21
- package/runtime/python/okstra_ctl/consumers.py +6 -1
- package/runtime/python/okstra_ctl/convergence.py +95 -5
- package/runtime/python/okstra_ctl/convergence_critic_verify_prompt.py +11 -10
- package/runtime/python/okstra_ctl/convergence_engine.py +30 -15
- package/runtime/python/okstra_ctl/convergence_reverify_prompt.py +9 -2
- package/runtime/python/okstra_ctl/coverage_census.py +75 -12
- package/runtime/python/okstra_ctl/design_review.py +6 -26
- package/runtime/python/okstra_ctl/design_review_evidence.py +6 -26
- package/runtime/python/okstra_ctl/dispatch_core.py +9 -2
- package/runtime/python/okstra_ctl/dispatch_state.py +5 -0
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/entrypoints/hosts.py +1 -1
- package/runtime/python/okstra_ctl/execution_manifest.py +8 -0
- package/runtime/python/okstra_ctl/implementation_comparison/__init__.py +12 -0
- package/runtime/python/okstra_ctl/implementation_comparison/__main__.py +129 -0
- package/runtime/python/okstra_ctl/implementation_comparison/assembly.py +340 -0
- package/runtime/python/okstra_ctl/implementation_comparison/baseline.py +254 -0
- package/runtime/python/okstra_ctl/implementation_comparison/business_reuse.py +118 -0
- package/runtime/python/okstra_ctl/implementation_comparison/commit_source.py +113 -0
- package/runtime/python/okstra_ctl/implementation_comparison/html.py +49 -0
- package/runtime/python/okstra_ctl/implementation_comparison/inputs.py +348 -0
- package/runtime/python/okstra_ctl/implementation_comparison/model.py +47 -0
- package/runtime/python/okstra_ctl/implementation_comparison/preparation.py +195 -0
- package/runtime/python/okstra_ctl/implementation_comparison/publication.py +317 -0
- package/runtime/python/okstra_ctl/implementation_comparison/run_evidence.py +208 -0
- package/runtime/python/okstra_ctl/implementation_comparison/run_integration.py +198 -0
- package/runtime/python/okstra_ctl/implementation_comparison/source.py +342 -0
- package/runtime/python/okstra_ctl/implementation_comparison/target.py +144 -0
- package/runtime/python/okstra_ctl/implementation_comparison/task_assembly.py +333 -0
- package/runtime/python/okstra_ctl/implementation_comparison/task_selection.py +309 -0
- package/runtime/python/okstra_ctl/implementation_generation_evidence.py +134 -0
- package/runtime/python/okstra_ctl/implementation_outcome.py +2 -2
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +1 -0
- package/runtime/python/okstra_ctl/json_boundary.py +28 -8
- package/runtime/python/okstra_ctl/lead_progress.py +1 -1
- package/runtime/python/okstra_ctl/model_discovery.py +1 -1
- package/runtime/python/okstra_ctl/models.py +2 -2
- package/runtime/python/okstra_ctl/paths.py +7 -4
- package/runtime/python/okstra_ctl/phases/discussion/profile.md +2 -2
- package/runtime/python/okstra_ctl/phases/error_analysis/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +2 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +3 -3
- package/runtime/python/okstra_ctl/phases/requirements_discovery/profile.md +5 -5
- package/runtime/python/okstra_ctl/plan_run_root.py +8 -4
- package/runtime/python/okstra_ctl/qa_procedures.py +33 -2
- package/runtime/python/okstra_ctl/registry/provider_registry.py +1 -1
- package/runtime/python/okstra_ctl/render.py +4 -0
- package/runtime/python/okstra_ctl/render_final_report.py +1 -1
- package/runtime/python/okstra_ctl/report_execution_evidence.py +88 -15
- package/runtime/python/okstra_ctl/report_finalize.py +18 -4
- package/runtime/python/okstra_ctl/report_html/render.py +46 -7
- package/runtime/python/okstra_ctl/report_html/validation.py +32 -0
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +37 -3
- package/runtime/python/okstra_ctl/report_view_artifacts.py +12 -0
- package/runtime/python/okstra_ctl/review_verdicts.py +9 -0
- package/runtime/python/okstra_ctl/run.py +17 -1
- package/runtime/python/okstra_ctl/run_context.py +18 -3
- package/runtime/python/okstra_ctl/schema_excerpt.py +14 -9
- package/runtime/python/okstra_ctl/stage_done.py +11 -3
- package/runtime/python/okstra_ctl/stage_ledger.py +2 -2
- package/runtime/python/okstra_ctl/stage_map.py +3 -3
- package/runtime/python/okstra_ctl/trace_review.py +1 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +22 -7
- package/runtime/python/okstra_ctl/verdict_blocks.py +7 -2
- package/runtime/python/okstra_ctl/verification_dispatch.py +32 -0
- package/runtime/python/okstra_ctl/verification_evidence.py +23 -3
- package/runtime/python/okstra_ctl/verification_generation.py +3 -2
- package/runtime/python/okstra_ctl/verification_inputs.py +3 -2
- package/runtime/python/okstra_ctl/verification_invocation.py +7 -3
- package/runtime/python/okstra_ctl/wizard/engine.py +28 -1
- package/runtime/python/okstra_ctl/wizard/ids.py +8 -0
- package/runtime/python/okstra_ctl/wizard/picker_navigation.py +64 -2
- package/runtime/python/okstra_ctl/wizard/roles.py +194 -45
- package/runtime/python/okstra_ctl/wizard/sources.py +10 -1
- package/runtime/python/okstra_ctl/wizard/state.py +67 -20
- package/runtime/python/okstra_ctl/wizard/steps_roles.py +6 -3
- package/runtime/python/okstra_ctl/wizard/worker_settings.py +129 -25
- package/runtime/python/okstra_ctl/worker_audit_ledger.py +44 -8
- package/runtime/python/okstra_ctl/worker_prompt_body.py +26 -2
- package/runtime/python/okstra_ctl/worker_prompt_headers.py +12 -9
- package/runtime/python/okstra_token_usage/claude.py +5 -1
- package/runtime/python/okstra_token_usage/collect.py +3 -3
- package/runtime/python/okstra_token_usage/pricing.py +1 -0
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +17 -0
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/okstra-code-review/SKILL.md +1 -1
- package/runtime/skills/okstra-code-review/references/census-rules.md +1 -1
- package/runtime/skills/okstra-code-review/references/review-calibration.md +1 -1
- package/runtime/skills/okstra-discussion/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +33 -2
- package/runtime/skills/okstra-tdd/SKILL.md +74 -13
- package/runtime/templates/reports/html/assets/implementation-comparison.css +39 -0
- package/runtime/templates/reports/html/assets/implementation-comparison.js +55 -0
- package/runtime/templates/reports/html/i18n/en.json +113 -0
- package/runtime/templates/reports/html/i18n/ko.json +113 -0
- package/runtime/templates/reports/html/implementation-comparison.template.html +77 -0
- package/runtime/templates/reports/implementation-comparison-notes.md +72 -0
- package/runtime/templates/trace/trace.template.md +2 -0
- package/runtime/templates/worker-prompt-preamble.md +12 -2
- package/runtime/validators/validate-report-views.py +4 -36
|
@@ -62,7 +62,7 @@ def build_stage_ledger(task_root: Path) -> dict[str, Any] | None:
|
|
|
62
62
|
records = lifecycle.ledger_records()
|
|
63
63
|
|
|
64
64
|
built_from, divergence = _built_from(task_root, latest)
|
|
65
|
-
divergence +=
|
|
65
|
+
divergence += renumbering_divergence(
|
|
66
66
|
latest, built_from, state.done_stages
|
|
67
67
|
)
|
|
68
68
|
ledger: dict[str, Any] = {
|
|
@@ -112,7 +112,7 @@ def _built_from(task_root: Path, latest: Any):
|
|
|
112
112
|
]
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
def
|
|
115
|
+
def renumbering_divergence(
|
|
116
116
|
latest: Any,
|
|
117
117
|
built_from: Any,
|
|
118
118
|
done_stages: set[int],
|
|
@@ -378,8 +378,8 @@ def stage_row_is_cancelled(
|
|
|
378
378
|
return status == "cancelled"
|
|
379
379
|
|
|
380
380
|
|
|
381
|
-
def
|
|
382
|
-
data: dict[str, Any], source_plan_path: str,
|
|
381
|
+
def parse_stage_map_data(
|
|
382
|
+
data: dict[str, Any], *, source_plan_path: str = "",
|
|
383
383
|
) -> list[StageMapStage]:
|
|
384
384
|
planning = data.get("implementationPlanning")
|
|
385
385
|
stage_map = planning.get("stageMap") if isinstance(planning, dict) else None
|
|
@@ -416,7 +416,7 @@ def parse_stage_map_file(plan_path: Path) -> list[StageMapStage]:
|
|
|
416
416
|
raise StageMapError(
|
|
417
417
|
"stage_map", "structured report must be an object", str(resolved)
|
|
418
418
|
)
|
|
419
|
-
return
|
|
419
|
+
return parse_stage_map_data(data, source_plan_path=str(resolved))
|
|
420
420
|
return _parse_stage_map_markdown(resolved)
|
|
421
421
|
|
|
422
422
|
|
|
@@ -34,6 +34,7 @@ STEP_OPERATIONS = {
|
|
|
34
34
|
"analysis-review": "trace-scope-review",
|
|
35
35
|
"spec-review": "trace-scope-review",
|
|
36
36
|
"interface-review": "trace-interface-review",
|
|
37
|
+
"tests-review": "trace-tests-review",
|
|
37
38
|
}
|
|
38
39
|
_DIGEST_RE = re.compile(r"^sha256:[0-9a-f]{64}$")
|
|
39
40
|
_VERDICT_RE = re.compile(r"^Trace review verdict: (pass|fail)[ \t]*$", re.MULTILINE)
|
|
@@ -6,6 +6,7 @@ import hashlib
|
|
|
6
6
|
import json
|
|
7
7
|
import math
|
|
8
8
|
import re
|
|
9
|
+
from collections.abc import Mapping
|
|
9
10
|
from dataclasses import dataclass
|
|
10
11
|
from datetime import datetime, timezone
|
|
11
12
|
from pathlib import Path
|
|
@@ -30,7 +31,7 @@ class TraceSource:
|
|
|
30
31
|
digest: str
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def
|
|
34
|
+
def read_trace_source(project_root: Path, trace_path: str, *, budget: ReadBudget | None = None) -> TraceSource:
|
|
34
35
|
root = project_root.resolve()
|
|
35
36
|
relative = Path(trace_path)
|
|
36
37
|
if relative.is_absolute() or len(relative.parts) != 4 or relative.parts[:2] != (*OKSTRA_RELATIVE.parts, "traces"):
|
|
@@ -38,14 +39,31 @@ def read_task_trace(project_root: Path, trace_path: str, task_key: str, *, budge
|
|
|
38
39
|
if trace_path != relative.as_posix() or contained_relative_path(trace_path, root) != trace_path or relative.suffix != ".md":
|
|
39
40
|
raise ValueError("Trace path is not canonical or contained")
|
|
40
41
|
content = read_bounded_bytes(root / relative, max_bytes=TASK_MANIFEST_MAX_BYTES, artifact="implementation trace", budget=budget)
|
|
42
|
+
return parse_trace_source(content)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def parse_trace_source(content: bytes) -> TraceSource:
|
|
41
46
|
text = content.decode("utf-8")
|
|
42
47
|
match = re.match(r"^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)", text)
|
|
43
48
|
header = json.loads(match[1]) if match else None
|
|
44
|
-
if not isinstance(header, dict)
|
|
45
|
-
raise ValueError("Trace
|
|
49
|
+
if not isinstance(header, dict):
|
|
50
|
+
raise ValueError("Trace frontmatter must be a JSON object")
|
|
46
51
|
return TraceSource(header, text, hashlib.sha256(content).hexdigest())
|
|
47
52
|
|
|
48
53
|
|
|
54
|
+
def read_task_trace(project_root: Path, trace_path: str, task_key: str, *, budget: ReadBudget | None = None) -> TraceSource:
|
|
55
|
+
source = read_trace_source(project_root, trace_path, budget=budget)
|
|
56
|
+
if not isinstance(source.frontmatter.get("task"), dict) or source.frontmatter["task"].get("key") != task_key:
|
|
57
|
+
raise ValueError("Trace owner does not match the task")
|
|
58
|
+
return source
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def trace_integration_completed(frontmatter: Mapping[str, object]) -> bool:
|
|
62
|
+
steps = frontmatter.get("steps", {})
|
|
63
|
+
integration = steps.get("integration", {}) if isinstance(steps, dict) else {}
|
|
64
|
+
return isinstance(integration, dict) and integration.get("status") == "done"
|
|
65
|
+
|
|
66
|
+
|
|
49
67
|
def _validate_request(project_root: Path, request: dict) -> dict:
|
|
50
68
|
if not isinstance(request, dict) or len(json.dumps(request, ensure_ascii=False).encode()) > TRACE_REQUEST_MAX_BYTES:
|
|
51
69
|
raise ValueError("Trace request exceeds its input limit")
|
|
@@ -71,10 +89,7 @@ def _validate_request(project_root: Path, request: dict) -> dict:
|
|
|
71
89
|
raise ValueError("Trace creation timestamp does not match its source")
|
|
72
90
|
if source.digest != request.get("digest") or source.frontmatter.get("currentStep") != request["currentStep"]:
|
|
73
91
|
raise ValueError("Trace projection does not match its saved source")
|
|
74
|
-
|
|
75
|
-
integration = steps.get("integration", {}) if isinstance(steps, dict) else {}
|
|
76
|
-
completed = isinstance(integration, dict) and integration.get("status") == "done"
|
|
77
|
-
if request["completed"] != completed:
|
|
92
|
+
if request["completed"] != trace_integration_completed(source.frontmatter):
|
|
78
93
|
raise ValueError("Trace completion projection does not match its source")
|
|
79
94
|
task = source.frontmatter["task"]
|
|
80
95
|
if set(task) != {"key", *TRACE_METADATA_LIST_LIMITS, *TRACE_METADATA_TEXT_LIMITS}:
|
|
@@ -65,7 +65,7 @@ _ITEM_RE = re.compile(r"^###[ \t]+(?P<id>[^\s:]+)[ \t]*:?.*$", re.MULTILINE)
|
|
|
65
65
|
# `_field_match` enforces that an opening `**` is closed exactly once and that
|
|
66
66
|
# a label without bold carries a bullet.
|
|
67
67
|
_FIELD_KEYS = ("Verdict", "Fixability", "Note", "Explanation", "Prior dissent",
|
|
68
|
-
"Basis", "Your evidence", "Dependencies")
|
|
68
|
+
"Basis", "Your evidence", "Dependencies", "Opened")
|
|
69
69
|
_CANONICAL_KEYS = {key.lower(): key for key in _FIELD_KEYS}
|
|
70
70
|
_FIELD_RE = re.compile(
|
|
71
71
|
r"^(?P<bullet>[-*+][ \t]+)?(?P<open>\*\*)?"
|
|
@@ -105,6 +105,7 @@ class FindingVote:
|
|
|
105
105
|
verdict: str
|
|
106
106
|
disagree_basis: str | None
|
|
107
107
|
explanation: str
|
|
108
|
+
opened: tuple[str, ...] = ()
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
def _scan_blocks(text: str) -> dict[str, dict[str, str]]:
|
|
@@ -221,7 +222,11 @@ def _finding_vote(
|
|
|
221
222
|
f"finding `{finding_id}` has basis `{basis}` — expected one of "
|
|
222
223
|
f"{sorted(DISAGREE_BASES)}"
|
|
223
224
|
)
|
|
224
|
-
|
|
225
|
+
from .worker_audit_ledger import named_files
|
|
226
|
+
|
|
227
|
+
return FindingVote(
|
|
228
|
+
finding_id, verdict, basis, explanation, named_files(fields.get("Opened", "")),
|
|
229
|
+
)
|
|
225
230
|
|
|
226
231
|
|
|
227
232
|
@dataclass(frozen=True)
|
|
@@ -6,6 +6,9 @@ from typing import Any, Mapping
|
|
|
6
6
|
|
|
7
7
|
from .correction_round import completed_round_attempts, correction_round
|
|
8
8
|
from .execution_manifest import read_execution_manifest
|
|
9
|
+
from .execution_identity import ExecutionManifest, build_dispatch_id
|
|
10
|
+
from .attempt_evidence import AttemptEvidenceSeal, read_sealed_artifact
|
|
11
|
+
from .json_boundary import ArtifactByteReader
|
|
9
12
|
from .paths import RunRef
|
|
10
13
|
from .qa_procedures import safe_qa_path
|
|
11
14
|
from .verification_generation import prepare_verification_generation
|
|
@@ -60,6 +63,35 @@ def generation_sealed_after_round(round_number: int) -> int:
|
|
|
60
63
|
return 1 + round_number
|
|
61
64
|
|
|
62
65
|
|
|
66
|
+
def implementation_generation_frontier(execution: ExecutionManifest) -> int | None:
|
|
67
|
+
return max((verification_generation_number(row.dispatch_kind)
|
|
68
|
+
for row in execution.invocations
|
|
69
|
+
if row.duty_id in ("implementation-executor", "implementation-verifier")), default=None)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def read_completed_attempt_result(
|
|
73
|
+
project: Path, execution: ExecutionManifest, invocation_ref: str, attempt: int,
|
|
74
|
+
*, reader: ArtifactByteReader | None = None,
|
|
75
|
+
) -> tuple[Path, bytes]:
|
|
76
|
+
row = next((row for row in execution.attempts if (row.invocation_ref, row.attempt)
|
|
77
|
+
== (invocation_ref, attempt)), None)
|
|
78
|
+
if row is None or row.status != "ok" or row.finished_at is None or not row.result_path:
|
|
79
|
+
raise ValueError("result requires the current completed ok attempt")
|
|
80
|
+
attempt_ref = build_dispatch_id(invocation_ref, attempt)
|
|
81
|
+
seals = [seal for seal in execution.attempt_evidence_seals
|
|
82
|
+
if seal.get("sealRef") == row.evidence_seal_ref and seal.get("attemptRef") == attempt_ref]
|
|
83
|
+
if len(seals) != 1:
|
|
84
|
+
raise ValueError("result requires its attempt evidence seal")
|
|
85
|
+
path = Path(row.result_path)
|
|
86
|
+
relative = path.relative_to(project).as_posix() if path.is_absolute() else path.as_posix()
|
|
87
|
+
if not relative.startswith(".okstra/"):
|
|
88
|
+
raise ValueError("result must remain in project artifacts")
|
|
89
|
+
path = safe_qa_path(project, relative)
|
|
90
|
+
seal = AttemptEvidenceSeal.from_payload(seals[0])
|
|
91
|
+
raw = read_sealed_artifact(seal, path) if reader is None else read_sealed_artifact(seal, path, reader=reader)
|
|
92
|
+
return path, raw
|
|
93
|
+
|
|
94
|
+
|
|
63
95
|
def _seal(
|
|
64
96
|
project: Path, manifest_path: Path, manifest: Mapping[str, Any],
|
|
65
97
|
active_context: Mapping[str, Any], *, audience: str, dispatch_kind: str,
|
|
@@ -23,6 +23,7 @@ from .execution_mutation_audit import (
|
|
|
23
23
|
compare_verification_sources,
|
|
24
24
|
)
|
|
25
25
|
from .json_boundary import (
|
|
26
|
+
ArtifactByteReader, OwnedJsonSnapshot, ReadBudget,
|
|
26
27
|
JsonBoundaryError, load_owned_object, load_owned_object_snapshot,
|
|
27
28
|
write_owned_object_atomic,
|
|
28
29
|
)
|
|
@@ -308,6 +309,17 @@ def roster_verifier_role_execution_ref(
|
|
|
308
309
|
return None
|
|
309
310
|
|
|
310
311
|
|
|
312
|
+
def implementation_verifier_roster(manifest: Mapping[str, Any]) -> list[str]:
|
|
313
|
+
assignments = manifest.get("workerAssignments", [])
|
|
314
|
+
if not isinstance(assignments, list) or any(not isinstance(row, Mapping) for row in assignments):
|
|
315
|
+
raise ValueError("implementation verifier roster is malformed")
|
|
316
|
+
roster = [row.get("workerId") for row in assignments
|
|
317
|
+
if row.get("role") == "verifier"]
|
|
318
|
+
if not roster or any(not isinstance(worker, str) or not worker for worker in roster) or len(set(roster)) != len(roster):
|
|
319
|
+
raise ValueError("implementation requires a distinct verifier roster")
|
|
320
|
+
return roster
|
|
321
|
+
|
|
322
|
+
|
|
311
323
|
def _sealed_conformance_entry(
|
|
312
324
|
project: Path, ref: RunRef, generation: VerificationGenerationRecord,
|
|
313
325
|
check_ref: str, stage_key: str,
|
|
@@ -647,10 +659,18 @@ def _publish(check_run_dir: Path, record: VerificationExecutionRecord) -> None:
|
|
|
647
659
|
|
|
648
660
|
|
|
649
661
|
def read_verification_execution_record(path: Path) -> VerificationExecutionRecord:
|
|
650
|
-
return cast(VerificationExecutionRecord,
|
|
662
|
+
return cast(VerificationExecutionRecord, read_verification_execution_snapshot(path).value)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def read_verification_execution_snapshot(
|
|
666
|
+
path: Path, *, reader: ArtifactByteReader | None = None,
|
|
667
|
+
max_bytes: int | None = None, budget: ReadBudget | None = None,
|
|
668
|
+
) -> OwnedJsonSnapshot:
|
|
669
|
+
return load_owned_object_snapshot(
|
|
651
670
|
path, artifact="verification execution record", schema=_RECORD_SCHEMA,
|
|
652
|
-
validate_cross_fields=_record_errors,
|
|
653
|
-
|
|
671
|
+
validate_cross_fields=_record_errors, reader=reader,
|
|
672
|
+
max_bytes=max_bytes, budget=budget,
|
|
673
|
+
)
|
|
654
674
|
|
|
655
675
|
|
|
656
676
|
def _record_errors(record: dict[str, Any]) -> list[str]:
|
|
@@ -12,7 +12,7 @@ from .execution_mutation_audit import (
|
|
|
12
12
|
VerificationSourceSnapshot, capture_verification_source,
|
|
13
13
|
is_generated_verification_path,
|
|
14
14
|
)
|
|
15
|
-
from .json_boundary import load_owned_object_snapshot
|
|
15
|
+
from .json_boundary import ArtifactByteReader, load_owned_object_snapshot
|
|
16
16
|
from .paths import RunRef
|
|
17
17
|
from .qa_commands import (
|
|
18
18
|
QA_COMMAND_EXECUTING_TASK_TYPES, QA_SOURCE_DIGEST_PATTERN, qa_relative_path_valid,
|
|
@@ -267,11 +267,12 @@ def sealed_source_snapshot(
|
|
|
267
267
|
|
|
268
268
|
|
|
269
269
|
def read_verification_generation(
|
|
270
|
-
path: Path, expected_digest: str,
|
|
270
|
+
path: Path, expected_digest: str, *, reader: ArtifactByteReader | None = None,
|
|
271
271
|
) -> VerificationGenerationRecord:
|
|
272
272
|
stored = load_owned_object_snapshot(
|
|
273
273
|
path, artifact=_ARTIFACT, schema=_SCHEMA,
|
|
274
274
|
validate_cross_fields=_generation_errors,
|
|
275
|
+
reader=reader,
|
|
275
276
|
)
|
|
276
277
|
if content_digest(stored.raw_bytes) != expected_digest:
|
|
277
278
|
raise ValueError("verification generation digest mismatch")
|
|
@@ -8,7 +8,7 @@ from typing import Any, Callable, Mapping, cast
|
|
|
8
8
|
|
|
9
9
|
from okstra_project.dirs import OKSTRA_DIR_NAME, json_lock_path, registry_lock
|
|
10
10
|
|
|
11
|
-
from .json_boundary import load_owned_object_snapshot, write_owned_object_atomic
|
|
11
|
+
from .json_boundary import ArtifactByteReader, load_owned_object_snapshot, write_owned_object_atomic
|
|
12
12
|
from .paths import RunRef
|
|
13
13
|
from .review_policy import capture_review_policy, review_policy_errors
|
|
14
14
|
from .qa_commands import (
|
|
@@ -218,10 +218,11 @@ def capture_verification_inputs(
|
|
|
218
218
|
return payload
|
|
219
219
|
|
|
220
220
|
|
|
221
|
-
def read_verification_inputs(path: Path, expected_digest: str) -> VerificationInputs:
|
|
221
|
+
def read_verification_inputs(path: Path, expected_digest: str, *, reader: ArtifactByteReader | None = None) -> VerificationInputs:
|
|
222
222
|
snapshot = load_owned_object_snapshot(
|
|
223
223
|
path, artifact=INPUT_ARTIFACT, schema=INPUT_SCHEMA,
|
|
224
224
|
validate_cross_fields=_verification_input_errors,
|
|
225
|
+
reader=reader,
|
|
225
226
|
)
|
|
226
227
|
if content_digest(snapshot.raw_bytes) != expected_digest:
|
|
227
228
|
raise ValueError("verification input digest mismatch")
|
|
@@ -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
|
from .verification_input_types import DESIGN_REVIEW_INPUT_SCHEMA_VERSION
|
|
20
|
+
from .json_boundary import ArtifactByteReader
|
|
20
21
|
|
|
21
22
|
VERIFICATION_EVIDENCE_VERSION = "1.0"
|
|
22
23
|
VERIFICATION_GENERATION_HEADER_PREFIXES = (
|
|
@@ -63,13 +64,14 @@ def _has_c0_control_characters(value: str) -> bool:
|
|
|
63
64
|
|
|
64
65
|
def read_invocation_generation(
|
|
65
66
|
project: Path, manifest_path: Path | None, manifest: Mapping[str, Any],
|
|
66
|
-
reference: VerificationGenerationReference | None, audience: str,
|
|
67
|
+
reference: VerificationGenerationReference | None, audience: str, *,
|
|
68
|
+
reader: ArtifactByteReader | None = None,
|
|
67
69
|
) -> VerificationGenerationRecord | None:
|
|
68
70
|
if not _generation_required(manifest, reference, audience):
|
|
69
71
|
return None
|
|
70
72
|
if reference is None or manifest_path is None:
|
|
71
73
|
raise ValueError("verifier invocation requires a verification generation")
|
|
72
|
-
return _read_bound_generation(project, manifest_path, manifest, reference)
|
|
74
|
+
return _read_bound_generation(project, manifest_path, manifest, reference, reader=reader)
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
def verification_generation_required(
|
|
@@ -102,11 +104,12 @@ def _generation_required(
|
|
|
102
104
|
def _read_bound_generation(
|
|
103
105
|
project: Path, manifest_path: Path, manifest: Mapping[str, Any],
|
|
104
106
|
reference: VerificationGenerationReference,
|
|
107
|
+
*, reader: ArtifactByteReader | None = None,
|
|
105
108
|
) -> VerificationGenerationRecord:
|
|
106
109
|
task_type = manifest["taskType"]
|
|
107
110
|
project = project.resolve()
|
|
108
111
|
path = safe_qa_path(project, reference.path)
|
|
109
|
-
record = read_verification_generation(path, reference.digest)
|
|
112
|
+
record = read_verification_generation(path, reference.digest, **({"reader": reader} if reader is not None else {}))
|
|
110
113
|
relative_manifest = manifest_path.resolve().relative_to(project).as_posix()
|
|
111
114
|
if (record["runManifestPath"] != relative_manifest
|
|
112
115
|
or record["taskType"] != task_type):
|
|
@@ -116,6 +119,7 @@ def _read_bound_generation(
|
|
|
116
119
|
raise ValueError("verification generation input reference differs from run")
|
|
117
120
|
inputs = read_verification_inputs(
|
|
118
121
|
safe_qa_path(project, expected.relative_path), expected.digest,
|
|
122
|
+
**({"reader": reader} if reader is not None else {}),
|
|
119
123
|
)
|
|
120
124
|
if record["sourceRoot"] != inputs["sourceRoot"]:
|
|
121
125
|
raise ValueError("verification generation source differs from frozen inputs")
|
|
@@ -37,11 +37,12 @@ from .ids import (
|
|
|
37
37
|
_STEP_TO_GROUP,
|
|
38
38
|
)
|
|
39
39
|
from .state import Prompt, WizardError, WizardState, _is_role_selection_step
|
|
40
|
-
from .prompts import _domain_prompt
|
|
40
|
+
from .prompts import _domain_prompt, _msg
|
|
41
41
|
from .picker_navigation import (
|
|
42
42
|
is_split_picker,
|
|
43
43
|
merge_split_picker_answer,
|
|
44
44
|
present_picker,
|
|
45
|
+
split_by_vendor,
|
|
45
46
|
split_picker,
|
|
46
47
|
)
|
|
47
48
|
from .roles import _step_role, _submit_role_prompt, next_role_prompt
|
|
@@ -184,9 +185,19 @@ def next_prompt(state: WizardState) -> Prompt:
|
|
|
184
185
|
state.__dict__.update(attempt.__dict__)
|
|
185
186
|
|
|
186
187
|
|
|
188
|
+
def _is_model_pick(prompt: Prompt) -> bool:
|
|
189
|
+
return prompt.kind == "pick" and (
|
|
190
|
+
prompt.step.startswith(("role-models:", "role-model:"))
|
|
191
|
+
or prompt.step == "worker_settings_models"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
187
195
|
def _native_picker_screen(state: WizardState, prompt: Prompt) -> Prompt:
|
|
188
196
|
"""호스트 네이티브 선택기 한도에 맞춘 화면.
|
|
189
197
|
|
|
198
|
+
모델 선택 화면은 후보 수와 상관없이 벤더별 탭으로 나눈다(`split_by_vendor`).
|
|
199
|
+
그 묶음이 호스트에 실리지 않을 때만 아래 규칙을 쓴다.
|
|
200
|
+
|
|
190
201
|
한도를 넘는 픽은 체크박스든 단일 선택이든 네이티브 질문 묶음에 실리는
|
|
191
202
|
크기(claude-code 4×4=16)까지 같은 화면의 체크박스 질문 여러 개로 자른다
|
|
192
203
|
(`split_picker`) — 사용자는 탭을 옮겨 다니며 한 번에 답한다. 단일 선택을
|
|
@@ -204,6 +215,16 @@ def _native_picker_screen(state: WizardState, prompt: Prompt) -> Prompt:
|
|
|
204
215
|
return prompt
|
|
205
216
|
prompt = prompt.questions[0]
|
|
206
217
|
port = default_host_registry().resolve(state.host_runtime).interaction()
|
|
218
|
+
if _is_model_pick(prompt):
|
|
219
|
+
by_vendor = split_by_vendor(
|
|
220
|
+
prompt,
|
|
221
|
+
max_options=port.native_option_limit,
|
|
222
|
+
max_questions=port.native_question_limit,
|
|
223
|
+
free_input_label=_msg(state.workspace_root, "model_tabs", "free_input", vendors="{vendors}"),
|
|
224
|
+
mixed_label=_msg(state.workspace_root, "model_tabs", "mixed", vendors="{vendors}"),
|
|
225
|
+
)
|
|
226
|
+
if by_vendor is not prompt and _interaction_plan(state, by_vendor).kind == "native-group":
|
|
227
|
+
return by_vendor
|
|
207
228
|
split = split_picker(
|
|
208
229
|
prompt,
|
|
209
230
|
max_options=port.native_option_limit,
|
|
@@ -276,6 +297,12 @@ def _sim_advance(state: WizardState, prompt: Prompt) -> None:
|
|
|
276
297
|
prompt = _next_prompt_screen(state)
|
|
277
298
|
try:
|
|
278
299
|
if _is_role_selection_step(prompt.step):
|
|
300
|
+
# A pending typed-model step has no default answer: count it and
|
|
301
|
+
# settle the role from its model screen's recommended set.
|
|
302
|
+
if prompt.kind == "text":
|
|
303
|
+
state.role_model_drafts.pop(_step_role(prompt.step), None)
|
|
304
|
+
state.answered.append(prompt.step)
|
|
305
|
+
prompt = next_role_prompt(state) or prompt
|
|
279
306
|
# 화면은 호스트 한도에 맞춰 쪽으로 잘린 사본일 수 있다 — 기본답은
|
|
280
307
|
# 잘리지 않은 원본(추천 집합)에서 낸다.
|
|
281
308
|
original = next_role_prompt(state) or prompt
|
|
@@ -348,8 +348,16 @@ _REUSE_FILLED_STEPS = (
|
|
|
348
348
|
S_CLARIFICATION_PICK, S_CLARIFICATION)
|
|
349
349
|
|
|
350
350
|
|
|
351
|
+
_INPUT_PREFIX = "role-model-input:"
|
|
351
352
|
_MODELS_PREFIX = "role-models:"
|
|
352
353
|
_SINGLE_PREFIX = "role-model:"
|
|
354
|
+
_ROLE_SELECTION_PREFIXES = (_INPUT_PREFIX, _MODELS_PREFIX, _SINGLE_PREFIX)
|
|
355
|
+
# A vendor tab's "type a model" row: the prefix plus the tab's providers joined by "+".
|
|
356
|
+
MODEL_FREE_INPUT_PREFIX = "__free_input__:"
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def _role_model_input_prompt_id(role: str) -> str:
|
|
360
|
+
return f"{_INPUT_PREFIX}{role}"
|
|
353
361
|
|
|
354
362
|
|
|
355
363
|
def _role_models_prompt_id(role: str) -> str:
|
|
@@ -13,8 +13,8 @@ import json
|
|
|
13
13
|
import math
|
|
14
14
|
from dataclasses import replace
|
|
15
15
|
|
|
16
|
-
from .ids import PICK_TYPE_CUSTOM
|
|
17
|
-
from .state import Prompt, WizardError
|
|
16
|
+
from .ids import MODEL_FREE_INPUT_PREFIX, PICK_TYPE_CUSTOM
|
|
17
|
+
from .state import Option, Prompt, WizardError
|
|
18
18
|
|
|
19
19
|
_SPLIT_SEPARATOR = "#"
|
|
20
20
|
|
|
@@ -69,6 +69,68 @@ def split_picker(
|
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
def split_by_vendor(
|
|
73
|
+
prompt: Prompt,
|
|
74
|
+
*,
|
|
75
|
+
max_options: int,
|
|
76
|
+
max_questions: int,
|
|
77
|
+
free_input_label: str,
|
|
78
|
+
mixed_label: str,
|
|
79
|
+
) -> Prompt:
|
|
80
|
+
"""Show a model pick as one checkbox tab per vendor on one screen.
|
|
81
|
+
|
|
82
|
+
Each tab lists up to `max_options - 1` of a vendor's models, keeping the
|
|
83
|
+
recommended ones, and ends with a "type a model" row whose value names the tab's
|
|
84
|
+
providers. A vendor with that many models gets its own tab; the others
|
|
85
|
+
share one mixed tab. When the own tabs and the mixed tab exceed
|
|
86
|
+
`max_questions`, the last own tabs join the mixed one. Rows that are not
|
|
87
|
+
`provider/model` refs (a skip row) are left out: an empty answer means
|
|
88
|
+
nothing picked. Returns the prompt unchanged when it holds no model.
|
|
89
|
+
"""
|
|
90
|
+
models = [option for option in prompt.options if "/" in option.value]
|
|
91
|
+
if prompt.kind != "pick" or not models or max_options < 2:
|
|
92
|
+
return prompt
|
|
93
|
+
shown = max_options - 1
|
|
94
|
+
vendors: dict[str, list[Option]] = {}
|
|
95
|
+
for option in models:
|
|
96
|
+
vendors.setdefault(option.value.split("/", 1)[0], []).append(option)
|
|
97
|
+
own = [vendor for vendor, rows in vendors.items() if len(rows) >= shown]
|
|
98
|
+
mixed = [vendor for vendor in vendors if vendor not in own]
|
|
99
|
+
if len(own) + (1 if mixed else 0) > max_questions:
|
|
100
|
+
keep = max_questions - 1
|
|
101
|
+
mixed = [vendor for vendor in vendors if vendor in own[keep:] or vendor in mixed]
|
|
102
|
+
own = own[:keep]
|
|
103
|
+
groups = [[vendor] for vendor in own] + ([mixed] if mixed else [])
|
|
104
|
+
questions: list[Prompt] = []
|
|
105
|
+
for index, group in enumerate(groups, start=1):
|
|
106
|
+
rows = [option for vendor in group for option in vendors[vendor]]
|
|
107
|
+
picked = sorted(rows, key=lambda option: not option.recommended)[:shown]
|
|
108
|
+
rows = [option for option in rows if option in picked]
|
|
109
|
+
name = group[0] if len(group) == 1 else mixed_label.format(vendors="·".join(group))
|
|
110
|
+
questions.append(replace(
|
|
111
|
+
prompt,
|
|
112
|
+
step=f"{prompt.step}{_SPLIT_SEPARATOR}{index}",
|
|
113
|
+
label=f"{prompt.label} [{name}]",
|
|
114
|
+
options=[
|
|
115
|
+
*rows,
|
|
116
|
+
Option(
|
|
117
|
+
f"{MODEL_FREE_INPUT_PREFIX}{'+'.join(group)}",
|
|
118
|
+
free_input_label.format(vendors=name),
|
|
119
|
+
),
|
|
120
|
+
],
|
|
121
|
+
multi=True,
|
|
122
|
+
))
|
|
123
|
+
return Prompt(
|
|
124
|
+
step=prompt.step,
|
|
125
|
+
kind="pick_group",
|
|
126
|
+
label=prompt.label,
|
|
127
|
+
help=prompt.help,
|
|
128
|
+
echo_template=prompt.echo_template,
|
|
129
|
+
multi=prompt.multi,
|
|
130
|
+
questions=questions,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
72
134
|
def is_split_picker(prompt: Prompt) -> bool:
|
|
73
135
|
return prompt.kind == "pick_group" and bool(prompt.questions) and all(
|
|
74
136
|
question.multi
|