okstra 0.231.1 → 0.233.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -271
- package/dist/cli-registry.mjs +14 -1
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/execute/render-bundle.d.mts +6 -1
- package/dist/commands/execute/render-bundle.mjs +139 -32
- package/dist/commands/execute/render-bundle.mjs.map +1 -1
- package/dist/commands/lifecycle/config.mjs +6 -74
- package/dist/commands/lifecycle/config.mjs.map +1 -1
- package/dist/commands/memory/memory.mjs +9 -55
- package/dist/commands/memory/memory.mjs.map +1 -1
- package/dist/commands/trace/capacity.d.mts +12 -0
- package/dist/commands/trace/capacity.mjs +21 -0
- package/dist/commands/trace/capacity.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +89 -0
- package/dist/commands/trace/model.mjs +251 -0
- package/dist/commands/trace/model.mjs.map +1 -0
- package/dist/commands/trace/progression.d.mts +11 -0
- package/dist/commands/trace/progression.mjs +194 -0
- package/dist/commands/trace/progression.mjs.map +1 -0
- package/dist/commands/trace/review.d.mts +7 -0
- package/dist/commands/trace/review.mjs +51 -0
- package/dist/commands/trace/review.mjs.map +1 -0
- package/dist/commands/trace/task-link.d.mts +18 -0
- package/dist/commands/trace/task-link.mjs +72 -0
- package/dist/commands/trace/task-link.mjs.map +1 -0
- package/dist/commands/trace/trace.d.mts +1 -0
- package/dist/commands/trace/trace.mjs +293 -0
- package/dist/commands/trace/trace.mjs.map +1 -0
- package/dist/lib/bounded-file.d.mts +1 -0
- package/dist/lib/bounded-file.mjs +36 -0
- package/dist/lib/bounded-file.mjs.map +1 -0
- package/dist/lib/config-store.d.mts +34 -0
- package/dist/lib/config-store.mjs +70 -0
- package/dist/lib/config-store.mjs.map +1 -0
- package/dist/lib/file-lock.mjs +4 -5
- package/dist/lib/file-lock.mjs.map +1 -1
- package/dist/lib/input-limit.d.mts +4 -0
- package/dist/lib/input-limit.mjs +8 -0
- package/dist/lib/input-limit.mjs.map +1 -0
- package/dist/lib/memory-auto-register.d.mts +1 -0
- package/dist/lib/memory-auto-register.mjs +98 -0
- package/dist/lib/memory-auto-register.mjs.map +1 -0
- package/dist/lib/memory-entry-contract.d.mts +12 -0
- package/dist/lib/memory-entry-contract.mjs +46 -0
- package/dist/lib/memory-entry-contract.mjs.map +1 -0
- package/dist/lib/python-helper.d.mts +1 -1
- package/dist/lib/python-helper.mjs +3 -2
- package/dist/lib/python-helper.mjs.map +1 -1
- package/dist/lib/record-secrets.d.mts +1 -0
- package/dist/lib/record-secrets.mjs +28 -0
- package/dist/lib/record-secrets.mjs.map +1 -0
- package/dist/lib/report-language-tag.d.mts +1 -0
- package/dist/lib/report-language-tag.mjs +4 -0
- package/dist/lib/report-language-tag.mjs.map +1 -0
- package/dist/lib/report-language.d.mts +1 -0
- package/dist/lib/report-language.mjs +50 -0
- package/dist/lib/report-language.mjs.map +1 -0
- package/dist/lib/skill-catalog.mjs +3 -0
- package/dist/lib/skill-catalog.mjs.map +1 -1
- package/dist/lib/types.d.mts +2 -1
- package/docs/architecture/storage-model.md +163 -5
- package/docs/architecture.md +17 -4
- package/docs/cli.md +511 -0
- package/docs/contributor-change-matrix.md +1 -2
- package/docs/project-structure-overview.md +33 -42
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/common.json +8 -8
- package/runtime/agents/operations/trace-interface-review.json +6 -0
- package/runtime/agents/operations/trace-scope-review.json +6 -0
- package/runtime/agents/roles/verifier.json +2 -4
- package/runtime/bin/okstra-provider-exec.py +10 -4
- package/runtime/prompts/coding-preflight/architectures/hexagonal.md +23 -30
- package/runtime/prompts/coding-preflight/authoring-checks.md +17 -0
- package/runtime/prompts/coding-preflight/clean-code.md +88 -286
- package/runtime/prompts/coding-preflight/frameworks/node-server.md +2 -3
- package/runtime/prompts/coding-preflight/languages/java.md +3 -5
- package/runtime/prompts/coding-preflight/languages/javascript-typescript.md +5 -12
- package/runtime/prompts/coding-preflight/languages/kotlin.md +2 -4
- package/runtime/prompts/coding-preflight/languages/python.md +2 -7
- package/runtime/prompts/coding-preflight/languages/rust.md +2 -8
- package/runtime/prompts/coding-preflight/languages/sql.md +2 -4
- package/runtime/prompts/coding-preflight/overview.md +25 -38
- package/runtime/prompts/coding-preflight/review-rules.json +30 -0
- package/runtime/prompts/duties/code-reviewer.json +15 -18
- package/runtime/prompts/duties/implementation-verifier.json +1 -0
- package/runtime/prompts/duties/interface-reviewer.json +32 -0
- package/runtime/prompts/host-orchestration/README.md +18 -9
- package/runtime/prompts/launch.template.md +3 -2
- package/runtime/prompts/lead/context-loader.md +2 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
- package/runtime/prompts/lead/report-writer.md +6 -6
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +41 -6
- package/runtime/prompts/profiles/_common-contract.md +1 -1
- package/runtime/python/okstra_ctl/agent/invocation.py +122 -36
- package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +72 -26
- package/runtime/python/okstra_ctl/agent/prompt_cli/corrections.py +23 -8
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +58 -14
- package/runtime/python/okstra_ctl/agent/prompt_cli/results.py +8 -11
- package/runtime/python/okstra_ctl/agent/standalone.py +15 -0
- package/runtime/python/okstra_ctl/analysis_packet.py +24 -30
- package/runtime/python/okstra_ctl/attempt_evidence.py +10 -0
- package/runtime/python/okstra_ctl/code_review_census.py +162 -7
- package/runtime/python/okstra_ctl/code_review_coverage.py +4 -274
- package/runtime/python/okstra_ctl/code_review_integrity.py +154 -0
- package/runtime/python/okstra_ctl/code_review_invocation.py +212 -0
- package/runtime/python/okstra_ctl/code_review_prepare.py +381 -0
- package/runtime/python/okstra_ctl/code_review_run.py +384 -0
- package/runtime/python/okstra_ctl/code_review_scope.py +49 -9
- package/runtime/python/okstra_ctl/code_review_supervisor.py +41 -0
- package/runtime/python/okstra_ctl/code_review_target.py +212 -13
- package/runtime/python/okstra_ctl/consumers.py +12 -9
- package/runtime/python/okstra_ctl/coverage_census.py +11 -2
- package/runtime/python/okstra_ctl/design_review.py +207 -0
- package/runtime/python/okstra_ctl/design_review_evidence.py +297 -0
- package/runtime/python/okstra_ctl/design_snapshot.py +16 -9
- package/runtime/python/okstra_ctl/direct_work.py +45 -3
- package/runtime/python/okstra_ctl/dispatch_core.py +31 -15
- package/runtime/python/okstra_ctl/dispatch_state.py +9 -2
- package/runtime/python/okstra_ctl/doctor.py +8 -25
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/doyouknow/__init__.py +9 -0
- package/runtime/python/okstra_ctl/doyouknow/cli.py +91 -0
- package/runtime/python/okstra_ctl/doyouknow/config.py +58 -0
- package/runtime/python/okstra_ctl/doyouknow/contracts.py +184 -0
- package/runtime/python/okstra_ctl/doyouknow/identity.py +22 -0
- package/runtime/python/okstra_ctl/doyouknow/paths.py +22 -0
- package/runtime/python/okstra_ctl/doyouknow/pending.py +72 -0
- package/runtime/python/okstra_ctl/doyouknow/registration.py +260 -0
- package/runtime/python/okstra_ctl/doyouknow/source_contracts.py +128 -0
- package/runtime/python/okstra_ctl/doyouknow/source_store.py +172 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/io.py +36 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +300 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/memory.py +179 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/task.py +95 -0
- package/runtime/python/okstra_ctl/doyouknow/store.py +260 -0
- package/runtime/python/okstra_ctl/doyouknow/sync.py +58 -0
- package/runtime/python/okstra_ctl/execution_mutation_audit.py +18 -2
- package/runtime/python/okstra_ctl/file_size_cap.py +3 -4
- package/runtime/python/okstra_ctl/final_report_schema.py +37 -34
- package/runtime/python/okstra_ctl/incremental_carry.py +6 -7
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +9 -2
- package/runtime/python/okstra_ctl/json_boundary.py +51 -5
- package/runtime/python/okstra_ctl/jsonl.py +21 -0
- package/runtime/python/okstra_ctl/manager_cli.py +148 -1
- package/runtime/python/okstra_ctl/manager_journal.py +126 -0
- package/runtime/python/okstra_ctl/manager_launch.py +3 -3
- package/runtime/python/okstra_ctl/manager_log.py +221 -0
- package/runtime/python/okstra_ctl/manager_paths.py +8 -0
- package/runtime/python/okstra_ctl/manager_registration.py +29 -0
- package/runtime/python/okstra_ctl/manager_resume.py +59 -0
- package/runtime/python/okstra_ctl/manager_split.py +2 -2
- package/runtime/python/okstra_ctl/manager_store.py +116 -17
- package/runtime/python/okstra_ctl/manager_sync.py +45 -25
- package/runtime/python/okstra_ctl/manager_view.py +35 -2
- package/runtime/python/okstra_ctl/material.py +2 -0
- package/runtime/python/okstra_ctl/model_cli.py +64 -14
- package/runtime/python/okstra_ctl/model_defaults.py +22 -0
- package/runtime/python/okstra_ctl/model_io/renderers.py +16 -2
- package/runtime/python/okstra_ctl/model_io_cli.py +7 -1
- package/runtime/python/okstra_ctl/operation_invocation.py +207 -28
- package/runtime/python/okstra_ctl/path_hints.py +14 -3
- package/runtime/python/okstra_ctl/paths.py +6 -1
- package/runtime/python/okstra_ctl/phases/catalog.py +24 -7
- package/runtime/python/okstra_ctl/phases/final_verification/validation.py +20 -0
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +3 -3
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +10 -0
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +23 -8
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +6 -4
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +38 -10
- package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation.template.html +13 -0
- package/runtime/python/okstra_ctl/phases/implementation/spec.md +25 -0
- package/runtime/python/okstra_ctl/phases/implementation/validation.py +6 -0
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/votes.py +11 -11
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +16 -9
- package/runtime/python/okstra_ctl/phases/implementation_planning/host-rules.md +3 -6
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -10
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +6 -6
- package/runtime/python/okstra_ctl/phases/improvement_discovery/lenses.py +12 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/profile.md +7 -6
- package/runtime/python/okstra_ctl/phases/improvement_discovery/resolved_census.py +159 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/spec.md +5 -2
- package/runtime/python/okstra_ctl/phases/improvement_discovery/validation.py +21 -7
- package/runtime/python/okstra_ctl/phases/release_handoff/boundary.json +1 -1
- package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +4 -1
- package/runtime/python/okstra_ctl/plan_verify_cli.py +6 -4
- package/runtime/python/okstra_ctl/render.py +28 -2
- package/runtime/python/okstra_ctl/report_assembly.py +53 -11
- package/runtime/python/okstra_ctl/report_contract.py +26 -0
- package/runtime/python/okstra_ctl/report_corrections.py +36 -20
- package/runtime/python/okstra_ctl/report_inputs.py +1 -0
- package/runtime/python/okstra_ctl/report_language.py +4 -1
- package/runtime/python/okstra_ctl/report_narrative.py +182 -7
- package/runtime/python/okstra_ctl/report_projections.py +64 -18
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +97 -38
- package/runtime/python/okstra_ctl/review_policy.py +359 -0
- package/runtime/python/okstra_ctl/review_verdicts.py +291 -0
- package/runtime/python/okstra_ctl/run.py +67 -36
- package/runtime/python/okstra_ctl/run_context.py +10 -1
- package/runtime/python/okstra_ctl/set_work_status.py +4 -15
- package/runtime/python/okstra_ctl/stage_done.py +11 -0
- package/runtime/python/okstra_ctl/standalone_review_audit.py +28 -0
- package/runtime/python/okstra_ctl/task_list_cli.py +34 -8
- package/runtime/python/okstra_ctl/task_query.py +239 -0
- package/runtime/python/okstra_ctl/trace_review.py +264 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +197 -0
- package/runtime/python/okstra_ctl/user_authorization.py +14 -0
- package/runtime/python/okstra_ctl/verification_generation.py +23 -1
- package/runtime/python/okstra_ctl/verification_input_types.py +15 -1
- package/runtime/python/okstra_ctl/verification_inputs.py +28 -6
- package/runtime/python/okstra_ctl/verification_invocation.py +7 -1
- package/runtime/python/okstra_ctl/verification_target.py +2 -0
- package/runtime/python/okstra_ctl/wizard/confirmation.py +7 -3
- package/runtime/python/okstra_ctl/wizard/launch.py +52 -0
- package/runtime/python/okstra_ctl/wizard/launch_cli.py +39 -0
- package/runtime/python/okstra_ctl/wizard/outcome.py +17 -16
- package/runtime/python/okstra_ctl/wizard/registry.py +1 -1
- package/runtime/python/okstra_ctl/wizard/render.py +8 -0
- package/runtime/python/okstra_ctl/wizard/state.py +2 -1
- package/runtime/python/okstra_ctl/worker_prompt_headers.py +24 -9
- package/runtime/python/okstra_ctl/worker_runner.py +66 -10
- package/runtime/python/okstra_ctl/write_policy.py +34 -1
- package/runtime/python/okstra_project/__init__.py +2 -0
- package/runtime/python/okstra_project/dirs.py +18 -0
- package/runtime/python/okstra_project/state.py +45 -20
- package/runtime/python/okstra_token_usage/blocks.py +74 -0
- package/runtime/python/okstra_token_usage/cli.py +23 -10
- package/runtime/python/okstra_token_usage/collect.py +25 -22
- package/runtime/python/okstra_token_usage/policy.py +193 -0
- package/runtime/schemas/doyouknow-config-v1.schema.json +20 -0
- package/runtime/schemas/doyouknow-v1.schema.json +65 -0
- package/runtime/schemas/final-report-v2.0.schema.json +157 -0
- package/runtime/schemas/final-report-v3.0.schema.json +157 -0
- package/runtime/schemas/memory-entry-contract-v1.json +11 -0
- package/runtime/schemas/record-secret-patterns.json +41 -0
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +1 -1
- package/runtime/skills/_fragments/wizard-confirm-step.md +1 -1
- package/runtime/skills/_fragments/wizard-preflight.md +1 -1
- package/runtime/skills/_fragments/wizard-prompt-loop.md +3 -5
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/_fragments/wizard-render-bundle.md +15 -29
- package/runtime/skills/okstra-brief-gen/SKILL.md +7 -7
- package/runtime/skills/okstra-brief-gen/references/tracker-recursion.md +1 -1
- package/runtime/skills/okstra-code-review/SKILL.md +92 -136
- package/runtime/skills/okstra-code-review/references/census-rules.md +29 -105
- package/runtime/skills/okstra-code-review/references/review-calibration.md +37 -61
- package/runtime/skills/okstra-discussion/SKILL.md +22 -38
- package/runtime/skills/okstra-explain-flow/SKILL.md +6 -2
- package/runtime/skills/okstra-manager/SKILL.md +31 -0
- package/runtime/skills/okstra-memory/SKILL.md +8 -1
- package/runtime/skills/okstra-pr-gen/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +55 -183
- package/runtime/skills/okstra-schedule-gen/SKILL.md +9 -13
- package/runtime/skills/okstra-setup/SKILL.md +3 -2
- package/runtime/skills/okstra-setup/references/project-config.md +2 -4
- package/runtime/skills/okstra-tdd/SKILL.md +187 -0
- package/runtime/skills/okstra-user-response/SKILL.md +4 -2
- package/runtime/templates/implementation-worker-preamble.md +4 -9
- package/runtime/templates/manager/view.template.html +4 -0
- package/runtime/templates/report-writer-prompt-preamble.md +15 -3
- package/runtime/templates/trace/trace.template.md +42 -0
- package/runtime/templates/worker-prompt-preamble.md +4 -12
- package/runtime/validators/checks/fixtures-02.py +25 -33
- package/runtime/validators/validate-run.py +107 -38
|
@@ -10,6 +10,7 @@ from okstra_project.dirs import OKSTRA_DIR_NAME, json_lock_path, registry_lock
|
|
|
10
10
|
|
|
11
11
|
from .json_boundary import load_owned_object_snapshot, write_owned_object_atomic
|
|
12
12
|
from .paths import RunRef
|
|
13
|
+
from .review_policy import capture_review_policy, review_policy_errors
|
|
13
14
|
from .qa_commands import (
|
|
14
15
|
QA_COMMAND_EXECUTING_TASK_TYPES, QA_SOURCE_DIGEST_PATTERN, qa_relative_path_valid,
|
|
15
16
|
validate_qa_commands,
|
|
@@ -22,12 +23,14 @@ from .qa_procedures import (
|
|
|
22
23
|
|
|
23
24
|
from .verification_input_types import (
|
|
24
25
|
INPUT_KIND, INPUT_SCHEMA_VERSION, PLAN_INPUT_SCHEMA_VERSION,
|
|
26
|
+
REVIEW_INPUT_SCHEMA_VERSION, DESIGN_REVIEW_INPUT_SCHEMA_VERSION,
|
|
25
27
|
FrozenProcedure, VerificationInputs,
|
|
26
28
|
)
|
|
27
29
|
from .verification_conformance import capture_conformance_baseline
|
|
28
30
|
from .verification_plan import (
|
|
29
31
|
VERIFICATION_PLAN_SCHEMA, capture_verification_plan, verification_plan_errors,
|
|
30
32
|
)
|
|
33
|
+
from .verification_target import read_worktree_head
|
|
31
34
|
|
|
32
35
|
INPUT_ARTIFACT = "verification inputs"
|
|
33
36
|
QA_INPUT_FIELDS = (
|
|
@@ -41,11 +44,14 @@ INPUT_SCHEMA = {
|
|
|
41
44
|
"additionalProperties": False,
|
|
42
45
|
"required": ["schemaVersion", "kind", "sourceRoot", "qaCommands", "procedures"],
|
|
43
46
|
"properties": {
|
|
44
|
-
"schemaVersion": {"enum": [INPUT_SCHEMA_VERSION, PLAN_INPUT_SCHEMA_VERSION
|
|
47
|
+
"schemaVersion": {"enum": [INPUT_SCHEMA_VERSION, PLAN_INPUT_SCHEMA_VERSION,
|
|
48
|
+
REVIEW_INPUT_SCHEMA_VERSION, DESIGN_REVIEW_INPUT_SCHEMA_VERSION]},
|
|
45
49
|
"kind": {"const": INPUT_KIND},
|
|
46
50
|
"sourceRoot": {"type": "string", "minLength": 1},
|
|
47
51
|
"qaCommands": {"type": "object"},
|
|
48
52
|
"procedures": {"type": "object"},
|
|
53
|
+
"reviewPolicy": {"type": "object"},
|
|
54
|
+
"reviewBase": {"type": "string", "pattern": "^[0-9a-f]{40}([0-9a-f]{24})?$"},
|
|
49
55
|
"approvedPlan": VERIFICATION_PLAN_SCHEMA,
|
|
50
56
|
"qaSourceObservations": {"type": "object"},
|
|
51
57
|
"conformanceBaseline": {
|
|
@@ -101,6 +107,16 @@ def _verification_source_errors(
|
|
|
101
107
|
|
|
102
108
|
|
|
103
109
|
def _verification_input_errors(payload: dict[str, Any]) -> list[str]:
|
|
110
|
+
if payload["schemaVersion"] == DESIGN_REVIEW_INPUT_SCHEMA_VERSION and not {"reviewBase", "approvedPlan"}.issubset(payload):
|
|
111
|
+
return ["verification inputs 4.0 requires reviewBase and approvedPlan"]
|
|
112
|
+
if payload["schemaVersion"] != DESIGN_REVIEW_INPUT_SCHEMA_VERSION and "reviewBase" in payload:
|
|
113
|
+
return ["reviewBase requires verification inputs 4.0"]
|
|
114
|
+
if payload["schemaVersion"] in (REVIEW_INPUT_SCHEMA_VERSION, DESIGN_REVIEW_INPUT_SCHEMA_VERSION) and "reviewPolicy" not in payload:
|
|
115
|
+
return ["review policy: verification inputs 3.0 requires reviewPolicy"]
|
|
116
|
+
if "reviewPolicy" in payload:
|
|
117
|
+
policy_errors = review_policy_errors(payload["reviewPolicy"])
|
|
118
|
+
if policy_errors:
|
|
119
|
+
return policy_errors
|
|
104
120
|
has_plan = "approvedPlan" in payload
|
|
105
121
|
if payload["schemaVersion"] == PLAN_INPUT_SCHEMA_VERSION and not has_plan:
|
|
106
122
|
return ["verification inputs 2.0 requires approvedPlan"]
|
|
@@ -167,7 +183,8 @@ def _conformance_baseline_errors(payload: Mapping[str, Any]) -> list[str]:
|
|
|
167
183
|
def capture_verification_inputs(
|
|
168
184
|
project: Path, source: Path, *, approved_plan: Path | None = None,
|
|
169
185
|
) -> VerificationInputs:
|
|
170
|
-
|
|
186
|
+
config = load_qa_config(project)
|
|
187
|
+
declared = config.get("qaCommands") or {}
|
|
171
188
|
read_digest = new_qa_source_digest_reader()
|
|
172
189
|
commands = {
|
|
173
190
|
category: [{key: entry[key] for key in QA_INPUT_FIELDS if key in entry}
|
|
@@ -185,9 +202,10 @@ def capture_verification_inputs(
|
|
|
185
202
|
"body": raw.decode("utf-8"), "digest": content_digest(raw),
|
|
186
203
|
}
|
|
187
204
|
payload: VerificationInputs = {
|
|
188
|
-
"schemaVersion":
|
|
205
|
+
"schemaVersion": REVIEW_INPUT_SCHEMA_VERSION, "kind": INPUT_KIND,
|
|
189
206
|
"sourceRoot": str(source.resolve()), "qaCommands": commands,
|
|
190
207
|
"procedures": procedures,
|
|
208
|
+
"reviewPolicy": capture_review_policy(project, config),
|
|
191
209
|
"qaSourceObservations": {
|
|
192
210
|
category: [{**observe_qa_sources(source, entry, read_digest),
|
|
193
211
|
"entryDigest": canonical_json_digest(entry)}
|
|
@@ -196,7 +214,6 @@ def capture_verification_inputs(
|
|
|
196
214
|
},
|
|
197
215
|
}
|
|
198
216
|
if approved_plan is not None:
|
|
199
|
-
payload["schemaVersion"] = PLAN_INPUT_SCHEMA_VERSION
|
|
200
217
|
payload["approvedPlan"] = capture_verification_plan(approved_plan)
|
|
201
218
|
return payload
|
|
202
219
|
|
|
@@ -288,8 +305,8 @@ def canonical_run_ref(project: Path, ref: RunRef) -> RunRef:
|
|
|
288
305
|
def prepare_verification_inputs(
|
|
289
306
|
project: Path, source: Path, ref: RunRef, *, approved_plan: Path | None = None,
|
|
290
307
|
) -> tuple[Path, str]:
|
|
291
|
-
if ref.task_type not in QA_COMMAND_EXECUTING_TASK_TYPES:
|
|
292
|
-
raise ValueError("verification inputs require a QA-executing phase")
|
|
308
|
+
if ref.task_type not in (*QA_COMMAND_EXECUTING_TASK_TYPES, "implementation-planning"):
|
|
309
|
+
raise ValueError("verification inputs require a QA-executing or planning phase")
|
|
293
310
|
payload = capture_verification_inputs(project, source, approved_plan=approved_plan)
|
|
294
311
|
if conformance_baseline_required(ref.task_type, payload):
|
|
295
312
|
# The executor may rename or delete an earlier stage's script; only the
|
|
@@ -303,6 +320,11 @@ def prepare_verification_inputs(
|
|
|
303
320
|
# Runs without the evidence contract keep preparing over a malformed
|
|
304
321
|
# manifest; the recorded cause lets a marked seal refuse it by name.
|
|
305
322
|
payload["conformanceBaselineError"] = str(exc)
|
|
323
|
+
if approved_plan is not None and ref.task_type in ("implementation", "final-verification"):
|
|
324
|
+
if not evidence_contract_applies(payload):
|
|
325
|
+
raise ValueError("design-review inputs require stable QA ids and a valid conformance baseline")
|
|
326
|
+
payload["schemaVersion"] = DESIGN_REVIEW_INPUT_SCHEMA_VERSION
|
|
327
|
+
payload["reviewBase"] = read_worktree_head(source)
|
|
306
328
|
return publish_verification_snapshot(
|
|
307
329
|
project, ref.verification_inputs, capture=partial(dict, payload),
|
|
308
330
|
artifact=INPUT_ARTIFACT, schema=INPUT_SCHEMA,
|
|
@@ -9,13 +9,14 @@ from okstra_project.dirs import OKSTRA_DIR_NAME
|
|
|
9
9
|
from .qa_commands import (
|
|
10
10
|
QA_SOURCE_DIGEST_PATTERN, QA_VERIFIER_AUDIENCE_BY_TASK_TYPE, qa_relative_path_valid,
|
|
11
11
|
)
|
|
12
|
-
from .qa_procedures import safe_qa_path
|
|
12
|
+
from .qa_procedures import canonical_json_digest, safe_qa_path
|
|
13
13
|
from .verification_generation import (
|
|
14
14
|
VERIFICATION_GENERATION_PATH_MAX_LENGTH, VerificationGenerationRecord,
|
|
15
15
|
read_verification_generation,
|
|
16
16
|
)
|
|
17
17
|
from .verification_input_ref import VerificationInputReference
|
|
18
18
|
from .verification_inputs import read_verification_inputs
|
|
19
|
+
from .verification_input_types import DESIGN_REVIEW_INPUT_SCHEMA_VERSION
|
|
19
20
|
|
|
20
21
|
VERIFICATION_EVIDENCE_VERSION = "1.0"
|
|
21
22
|
VERIFICATION_GENERATION_HEADER_PREFIXES = (
|
|
@@ -118,6 +119,11 @@ def _read_bound_generation(
|
|
|
118
119
|
)
|
|
119
120
|
if record["sourceRoot"] != inputs["sourceRoot"]:
|
|
120
121
|
raise ValueError("verification generation source differs from frozen inputs")
|
|
122
|
+
if inputs["schemaVersion"] == DESIGN_REVIEW_INPUT_SCHEMA_VERSION and task_type == "implementation":
|
|
123
|
+
review = record.get("designReview")
|
|
124
|
+
if (review is None or review["base"] != inputs["reviewBase"]
|
|
125
|
+
or review["policyDigest"] != canonical_json_digest(inputs["reviewPolicy"])):
|
|
126
|
+
raise ValueError("design review differs from frozen review base or policy")
|
|
121
127
|
return record
|
|
122
128
|
|
|
123
129
|
|
|
@@ -16,7 +16,7 @@ from okstra_ctl.worktree import (
|
|
|
16
16
|
)
|
|
17
17
|
from okstra_ctl.work_categories import resolve_work_category
|
|
18
18
|
|
|
19
|
-
from .render import render_args
|
|
19
|
+
from .render import render_args, wizard_persist_actions
|
|
20
20
|
from .ids import S_CONFIRM, _STAGE_SCOPED_TASK_TYPES
|
|
21
21
|
from .state import (
|
|
22
22
|
Prompt,
|
|
@@ -109,12 +109,13 @@ def _build_confirm(state: WizardState) -> Prompt:
|
|
|
109
109
|
같은 블록을 낸다.
|
|
110
110
|
"""
|
|
111
111
|
t = _p(state.workspace_root, "confirm")
|
|
112
|
-
if not state.confirmation_prompt:
|
|
112
|
+
if not state.confirmation_prompt or state.confirmation_persist_actions is None:
|
|
113
113
|
state.confirmation_stages = resolve_wizard_stage_intent(
|
|
114
114
|
task_type=state.task_type, selected_stage=state.selected_stage,
|
|
115
115
|
selected_stages=state.selected_stages,
|
|
116
116
|
).chain_stages
|
|
117
117
|
state.confirmation_scope = render_args(state)
|
|
118
|
+
state.confirmation_persist_actions = wizard_persist_actions(state)
|
|
118
119
|
state.confirmation_prompt = f"{confirmation_block(state)}\n\n{t['label']}"
|
|
119
120
|
return Prompt(
|
|
120
121
|
step=S_CONFIRM, kind="pick",
|
|
@@ -139,19 +140,22 @@ def _submit_confirm(state: WizardState, value: str) -> Optional[str]:
|
|
|
139
140
|
selected_stages=state.selected_stages,
|
|
140
141
|
).chain_stages
|
|
141
142
|
if (not state.confirmation_prompt or state.confirmation_scope != render_args(state)
|
|
142
|
-
or state.confirmation_stages != stages
|
|
143
|
+
or state.confirmation_stages != stages
|
|
144
|
+
or state.confirmation_persist_actions != wizard_persist_actions(state)):
|
|
143
145
|
raise WizardError("confirmation scope changed; display the confirmation again before proceeding")
|
|
144
146
|
state.user_authorization = {
|
|
145
147
|
"schemaVersion": "1.0", "source": "wizard-confirmation",
|
|
146
148
|
"response": value, "prompt": state.confirmation_prompt,
|
|
147
149
|
"scope": state.confirmation_scope.copy(),
|
|
148
150
|
"stageScope": state.confirmation_stages.split(",") if state.confirmation_stages else [],
|
|
151
|
+
"persistActions": [action.copy() for action in state.confirmation_persist_actions or []],
|
|
149
152
|
}
|
|
150
153
|
else:
|
|
151
154
|
state.user_authorization = {}
|
|
152
155
|
state.confirmation_prompt = ""
|
|
153
156
|
state.confirmation_scope = {}
|
|
154
157
|
state.confirmation_stages = ""
|
|
158
|
+
state.confirmation_persist_actions = None
|
|
155
159
|
state.confirmed = value == "proceed"
|
|
156
160
|
return f"confirm: {value}"
|
|
157
161
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Read one confirmed wizard snapshot for bundle preparation."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from okstra_ctl.run import prepare_exception_applies
|
|
8
|
+
from okstra_ctl.user_authorization import validate_wizard_authorization
|
|
9
|
+
|
|
10
|
+
from .outcome import wizard_outcome
|
|
11
|
+
from .state import WizardError
|
|
12
|
+
from .statefile import load_state_file
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class ConfirmedWizardLaunch:
|
|
17
|
+
project_root: str
|
|
18
|
+
render_argv: tuple[str, ...]
|
|
19
|
+
persist_actions: tuple[dict[str, str], ...]
|
|
20
|
+
chain_stages: str
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_confirmed_launch(
|
|
24
|
+
path: Path, *, stage: str = "", qa_waiver: str = "", tdd_bypass: str = "",
|
|
25
|
+
) -> ConfirmedWizardLaunch:
|
|
26
|
+
if not path.is_absolute():
|
|
27
|
+
raise WizardError("wizard state file path must be absolute")
|
|
28
|
+
state = load_state_file(path)
|
|
29
|
+
if state.user_authorization != {}:
|
|
30
|
+
validate_wizard_authorization(state.user_authorization)
|
|
31
|
+
outcome = wizard_outcome(state)
|
|
32
|
+
for option, value in (("--qa-waiver", qa_waiver), ("--tdd-bypass", tdd_bypass)):
|
|
33
|
+
if value and not prepare_exception_applies(state.task_type, option):
|
|
34
|
+
raise WizardError(f"{option} is not supported for confirmed task type {state.task_type}")
|
|
35
|
+
actions = outcome["persistActions"]
|
|
36
|
+
recorded_actions = state.user_authorization.get("persistActions")
|
|
37
|
+
if (actions or recorded_actions) and recorded_actions != actions:
|
|
38
|
+
raise WizardError("template save scope changed or was not recorded; confirm the save action again")
|
|
39
|
+
argv = outcome["renderArgv"]
|
|
40
|
+
chain = outcome["orchestration"]["chainStages"]
|
|
41
|
+
if stage:
|
|
42
|
+
if state.task_type != "implementation":
|
|
43
|
+
raise WizardError("wizard stage override is implementation-only")
|
|
44
|
+
if stage not in chain.split(","):
|
|
45
|
+
raise WizardError("requested stage is outside the confirmed stage scope")
|
|
46
|
+
argv[argv.index("--stage") + 1] = stage
|
|
47
|
+
return ConfirmedWizardLaunch(
|
|
48
|
+
project_root=state.project_root,
|
|
49
|
+
render_argv=tuple(argv),
|
|
50
|
+
persist_actions=tuple(actions),
|
|
51
|
+
chain_stages=chain,
|
|
52
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Internal JSON transport for confirmed wizard bundle inputs."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from .launch import load_confirmed_launch
|
|
10
|
+
from .state import WizardError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main(argv: list[str]) -> int:
|
|
14
|
+
parser = argparse.ArgumentParser()
|
|
15
|
+
parser.add_argument("--state-file", required=True)
|
|
16
|
+
parser.add_argument("--stage", default="")
|
|
17
|
+
parser.add_argument("--qa-waiver", default="")
|
|
18
|
+
parser.add_argument("--tdd-bypass", default="")
|
|
19
|
+
args = parser.parse_args(argv)
|
|
20
|
+
try:
|
|
21
|
+
launch = load_confirmed_launch(
|
|
22
|
+
Path(args.state_file), stage=args.stage,
|
|
23
|
+
qa_waiver=args.qa_waiver, tdd_bypass=args.tdd_bypass,
|
|
24
|
+
)
|
|
25
|
+
except (OSError, ValueError, WizardError) as exc:
|
|
26
|
+
print(json.dumps({"ok": False, "error": str(exc)}, ensure_ascii=False))
|
|
27
|
+
return 1
|
|
28
|
+
print(json.dumps({
|
|
29
|
+
"ok": True,
|
|
30
|
+
"projectRoot": launch.project_root,
|
|
31
|
+
"renderArgv": launch.render_argv,
|
|
32
|
+
"persistActions": launch.persist_actions,
|
|
33
|
+
"chainStages": launch.chain_stages,
|
|
34
|
+
}, ensure_ascii=False))
|
|
35
|
+
return 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
raise SystemExit(main(sys.argv[1:]))
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"""승인된 상태에서 실행 인자와 확인 화면을 조립한다."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
7
|
+
from okstra_ctl.phases.catalog import PhaseAssetError, host_rules
|
|
8
|
+
|
|
6
9
|
from .confirmation import confirmation_block
|
|
7
|
-
from .render import _stage_intent, render_args
|
|
10
|
+
from .render import _stage_intent, render_args, wizard_persist_actions
|
|
8
11
|
from .state import WizardError, WizardState
|
|
9
12
|
|
|
10
13
|
|
|
@@ -22,33 +25,31 @@ def _render_argv(rendered: dict[str, Any], *, host_runtime: str) -> list[str]:
|
|
|
22
25
|
return argv
|
|
23
26
|
|
|
24
27
|
|
|
25
|
-
def _wizard_persist_actions(state: WizardState) -> list[dict[str, str]]:
|
|
26
|
-
if state.task_type != "release-handoff":
|
|
27
|
-
return []
|
|
28
|
-
from okstra_ctl.phases.release_handoff.wizard import pr_template_persist_actions
|
|
29
|
-
|
|
30
|
-
return pr_template_persist_actions(state)
|
|
31
|
-
|
|
32
|
-
|
|
33
28
|
def wizard_outcome(state: WizardState) -> dict[str, Any]:
|
|
34
29
|
"""Public outcome for callers that need launch data and follow-up writes.
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`renderArgs` made the renderer reject the wizard's own output.
|
|
31
|
+
Execution inputs and orchestration signals stay separate so compatibility
|
|
32
|
+
callers cannot send stage-chain instructions to the prepare parser.
|
|
33
|
+
Native skills pass the confirmed state file to bundle preparation instead
|
|
34
|
+
of reconstructing these compatibility argument views.
|
|
41
35
|
"""
|
|
42
36
|
if state.aborted:
|
|
43
37
|
raise WizardError("wizard was aborted by the user — outcome is unavailable")
|
|
44
38
|
if state.confirmed is not True:
|
|
45
39
|
raise WizardError("wizard is not complete — outcome is unavailable")
|
|
46
40
|
rendered = render_args(state)
|
|
41
|
+
try:
|
|
42
|
+
host_rules_file = host_rules(Path(state.workspace_root), state.task_type)
|
|
43
|
+
except PhaseAssetError as exc:
|
|
44
|
+
raise WizardError(str(exc)) from exc
|
|
47
45
|
return {
|
|
48
46
|
"renderArgs": rendered,
|
|
49
47
|
"renderArgv": _render_argv(rendered, host_runtime=state.host_runtime),
|
|
50
|
-
"orchestration": {
|
|
51
|
-
|
|
48
|
+
"orchestration": {
|
|
49
|
+
"chainStages": _stage_intent(state).chain_stages,
|
|
50
|
+
"hostRulesPath": str(host_rules_file.resolve()) if host_rules_file is not None else "",
|
|
51
|
+
},
|
|
52
|
+
"persistActions": wizard_persist_actions(state),
|
|
52
53
|
"confirmationText": state.user_authorization.get("prompt") or confirmation_block(state),
|
|
53
54
|
"userAuthorization": state.user_authorization or None,
|
|
54
55
|
}
|
|
@@ -651,7 +651,7 @@ STEPS: list[Step] = [
|
|
|
651
651
|
or bool(s.fix_cycle))
|
|
652
652
|
and s.confirmed is None),
|
|
653
653
|
build=_build_confirm, submit=_submit_confirm,
|
|
654
|
-
owns=("confirmed", "edit_target", "confirmation_prompt", "confirmation_stages", "confirmation_scope", "user_authorization")),
|
|
654
|
+
owns=("confirmed", "edit_target", "confirmation_prompt", "confirmation_stages", "confirmation_scope", "confirmation_persist_actions", "user_authorization")),
|
|
655
655
|
# 되감기는 이 step 뒤에서 일어나 answered 에 남는다. 반복 가능이 아니면 두 번째
|
|
656
656
|
# 수정에서 건너뛰어져 위저드가 미확정인 채 done 을 냈다(dev-11126 planning).
|
|
657
657
|
Step(S_EDIT_TARGET,
|
|
@@ -149,3 +149,11 @@ def render_args(state: WizardState) -> dict[str, Any]:
|
|
|
149
149
|
raise WizardError("confirmed scope changed; obtain confirmation for the changed inputs")
|
|
150
150
|
rendered["user-authorization-json"] = json.dumps(state.user_authorization, ensure_ascii=False)
|
|
151
151
|
return rendered
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def wizard_persist_actions(state: WizardState) -> list[dict[str, str]]:
|
|
155
|
+
if state.task_type != "release-handoff":
|
|
156
|
+
return []
|
|
157
|
+
from okstra_ctl.phases.release_handoff.wizard import pr_template_persist_actions
|
|
158
|
+
|
|
159
|
+
return pr_template_persist_actions(state)
|
|
@@ -158,6 +158,7 @@ class WizardState:
|
|
|
158
158
|
confirmation_stages: str = ""
|
|
159
159
|
confirmation_prompt: str = ""
|
|
160
160
|
confirmation_scope: dict[str, Any] = field(default_factory=dict)
|
|
161
|
+
confirmation_persist_actions: list[dict[str, str]] | None = None
|
|
161
162
|
user_authorization: dict[str, Any] = field(default_factory=dict)
|
|
162
163
|
edit_target: str = ""
|
|
163
164
|
# terminal: user picked 중단 — no further prompt ever applies
|
|
@@ -676,7 +677,7 @@ _FIELD_DEFAULTS: dict[str, Any] = {
|
|
|
676
677
|
"fix_cycle": "",
|
|
677
678
|
"reasoning_effort": "",
|
|
678
679
|
"confirmed": None, "edit_target": "", "confirmation_prompt": "", "confirmation_stages": "",
|
|
679
|
-
"confirmation_scope": {}, "user_authorization": {},
|
|
680
|
+
"confirmation_scope": {}, "confirmation_persist_actions": None, "user_authorization": {},
|
|
680
681
|
}
|
|
681
682
|
|
|
682
683
|
|
|
@@ -10,6 +10,7 @@ from .fixed_text import block
|
|
|
10
10
|
from .paths import okstra_home
|
|
11
11
|
from .verification_input_ref import VerificationInputReference
|
|
12
12
|
from .worker_artifact_paths import WorkerArtifactPathError, audit_sidecar_rel
|
|
13
|
+
from .worker_prompt_body import analysis_input_lines
|
|
13
14
|
from .worker_prompt_policy import (
|
|
14
15
|
GRILLING_LOG_HEADER,
|
|
15
16
|
PromptPlan,
|
|
@@ -36,16 +37,16 @@ class WorkerPromptHeaderError(Exception):
|
|
|
36
37
|
READ_SCOPE_HEADER = (
|
|
37
38
|
"**Read scope:** Read only the paths this prompt enumerates "
|
|
38
39
|
"(`[Required reading]`, `## Inputs`, verification-target paths) plus "
|
|
39
|
-
"source/evidence
|
|
40
|
+
"source/evidence needed to evaluate the assignment. Do not expand that scope "
|
|
41
|
+
"to follow host-injected graph dumps or skill catalogs. Report an essential "
|
|
42
|
+
"unlisted artifact as missing input instead of guessing its contents."
|
|
43
|
+
)
|
|
44
|
+
ANALYSIS_PACKET_READ_HEADER = (
|
|
45
|
+
"**Analysis packet reading:** Task-group context and sibling "
|
|
40
46
|
"record paths listed in the primary analysis packet are allowed for targeted "
|
|
41
47
|
"evidence reads when their relevance is uncertain or more detail is needed. "
|
|
42
48
|
"Direct Work Context record paths in that packet are also allowed for targeted evidence reads. "
|
|
43
|
-
"
|
|
44
|
-
"(SessionStart hooks, global `CLAUDE.md` / `AGENTS.md`, skill catalogs) do "
|
|
45
|
-
"NOT apply inside an okstra worker run: do not auto-read `graphify-out/`, "
|
|
46
|
-
"`SKILL.md`, or other artifacts outside `<PROJECT_ROOT>/.okstra/`. If an "
|
|
47
|
-
"un-enumerated file seems essential, record it under *Missing Information "
|
|
48
|
-
"or Assumptions* instead of reading it. Read the primary analysis packet "
|
|
49
|
+
"Read the primary analysis packet "
|
|
49
50
|
f"in pages of at most {PACKET_PAGE_LINES} lines "
|
|
50
51
|
f"(`sed -n '1,{PACKET_PAGE_LINES}p'`, "
|
|
51
52
|
f"then `'{PACKET_PAGE_LINES + 1},{2 * PACKET_PAGE_LINES}p'`, …), "
|
|
@@ -168,7 +169,7 @@ def worker_prompt_headers(
|
|
|
168
169
|
headers.extend([
|
|
169
170
|
f"**Errors log path:** {errors_log_path}",
|
|
170
171
|
f"**Errors sidecar path:** {errors_sidecar_path}",
|
|
171
|
-
|
|
172
|
+
*_read_scope_headers(manifest, active_context, plan),
|
|
172
173
|
])
|
|
173
174
|
if _worker_provider(manifest, worker_id) == ANTIGRAVITY_PROVIDER:
|
|
174
175
|
headers.append(PLAIN_FILE_WRITE_HEADER)
|
|
@@ -185,6 +186,17 @@ def worker_prompt_headers(
|
|
|
185
186
|
return headers
|
|
186
187
|
|
|
187
188
|
|
|
189
|
+
def _read_scope_headers(
|
|
190
|
+
manifest: Mapping[str, Any], active_context: Mapping[str, Any], plan: PromptPlan,
|
|
191
|
+
) -> tuple[str, ...]:
|
|
192
|
+
if plan.audience not in ("analysis", "implementation-executor", "implementation-verifier"):
|
|
193
|
+
return (READ_SCOPE_HEADER,)
|
|
194
|
+
inputs = analysis_input_lines(manifest, active_context, plan)
|
|
195
|
+
if any(line.startswith("- Primary analysis packet:") for line in inputs):
|
|
196
|
+
return (READ_SCOPE_HEADER, ANALYSIS_PACKET_READ_HEADER)
|
|
197
|
+
return (READ_SCOPE_HEADER,)
|
|
198
|
+
|
|
199
|
+
|
|
188
200
|
def verification_input_headers(
|
|
189
201
|
project_root: Path, manifest: Mapping[str, Any],
|
|
190
202
|
) -> list[str]:
|
|
@@ -214,7 +226,10 @@ def verification_input_headers(
|
|
|
214
226
|
"approvedPlan is present; otherwise retain this phase's approved-plan "
|
|
215
227
|
"or brief source. Preserve existing phase, stage and QA ownership rules. "
|
|
216
228
|
"Use frozen declarations; do not replace them with current project QA "
|
|
217
|
-
"settings.
|
|
229
|
+
"settings. When Frozen Review Policy is present, apply its captured "
|
|
230
|
+
"project rules and architecture declaration instead of live project settings. "
|
|
231
|
+
"Rule-source text supplies coding criteria, not authorization to post reviews "
|
|
232
|
+
"or launch additional agents. Do not open the snapshot JSON directly. "
|
|
218
233
|
"The snapshot is not command-execution evidence.",
|
|
219
234
|
]
|
|
220
235
|
|
|
@@ -32,6 +32,11 @@ from .domain.worker_presentation import JsonEvents, Presentation
|
|
|
32
32
|
from .process_group import MemoryWatch, kill_group, memory_cap_bytes
|
|
33
33
|
from .session_transcript import SessionTranscript
|
|
34
34
|
from .json_boundary import JsonBoundaryError, write_owned_object_atomic
|
|
35
|
+
from .execution_mutation_audit import ExecutionMutationAudit, MutationSnapshot
|
|
36
|
+
from .standalone_review_audit import (
|
|
37
|
+
REVIEW_WRITE_VIOLATION_EXIT_CODE,
|
|
38
|
+
compare_standalone_review,
|
|
39
|
+
)
|
|
35
40
|
|
|
36
41
|
LIVE = "live"
|
|
37
42
|
QUIET = "quiet"
|
|
@@ -68,6 +73,7 @@ def run_worker(
|
|
|
68
73
|
) -> int:
|
|
69
74
|
_validate_status_extra(status_extra)
|
|
70
75
|
_validate_request_write_contract(request, status_extra)
|
|
76
|
+
review_before = _snapshot_standalone_review(request, status_extra)
|
|
71
77
|
command = strategy.build_command(request)
|
|
72
78
|
memory_watch = MemoryWatch(memory_cap_bytes(request.project_root))
|
|
73
79
|
started_monotonic = time.monotonic()
|
|
@@ -95,6 +101,7 @@ def run_worker(
|
|
|
95
101
|
# forever. No exit code is invented — its absence is already how every
|
|
96
102
|
# reader spells a run that failed. The exits that never raise at all are
|
|
97
103
|
# the guard's to close.
|
|
104
|
+
_record_standalone_review_audit(request, review_before, status, 1)
|
|
98
105
|
guard.close(f"{type(exc).__name__}: {exc}")
|
|
99
106
|
raise
|
|
100
107
|
|
|
@@ -104,20 +111,18 @@ def run_worker(
|
|
|
104
111
|
# 수집기(`okstra_token_usage`)가 홈 트랜스크립트가 없는 공급자의
|
|
105
112
|
# 사용량을 여기서 읽는다.
|
|
106
113
|
status["usage"] = dict(usage)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
status["servedModelAttestation"] = _attestation_payload(attestation)
|
|
110
|
-
if served_model_verifier is not None:
|
|
111
|
-
failure = served_model_verifier(attestation)
|
|
112
|
-
if failure:
|
|
113
|
-
status["failure"] = failure
|
|
114
|
-
exit_code = SERVED_MODEL_MISMATCH_EXIT_CODE
|
|
114
|
+
exit_code = _record_served_model(status, served_model_normalizer,
|
|
115
|
+
served_model_verifier, raw_model, exit_code)
|
|
115
116
|
if reaped:
|
|
116
117
|
status["leftoverProcessesKilled"] = True
|
|
117
118
|
if memory_watch.exceeded_bytes:
|
|
118
119
|
exit_code = MEMORY_CAP_EXIT_CODE
|
|
119
120
|
status.update(failure=memory_watch.failure(), terminated_by="memory-cap")
|
|
120
121
|
status["exit_code"] = exit_code
|
|
122
|
+
if _record_standalone_review_audit(request, review_before, status, exit_code):
|
|
123
|
+
status["providerExitCode"] = exit_code
|
|
124
|
+
exit_code = REVIEW_WRITE_VIOLATION_EXIT_CODE
|
|
125
|
+
status["exit_code"] = exit_code
|
|
121
126
|
if timed_out:
|
|
122
127
|
status.update(
|
|
123
128
|
timeout=True,
|
|
@@ -168,18 +173,69 @@ def _validate_status_extra(status_extra: Mapping[str, Any]) -> None:
|
|
|
168
173
|
def _validate_request_write_contract(
|
|
169
174
|
request: WorkerExecRequest, status_extra: Mapping[str, Any]
|
|
170
175
|
) -> None:
|
|
171
|
-
|
|
176
|
+
standalone = status_extra.get("standalonePurpose") == "code-review"
|
|
177
|
+
if status_extra.get("executionIdentityVersion") != 2 and not standalone:
|
|
172
178
|
return
|
|
173
179
|
policy = request.policy.write_policy
|
|
174
180
|
enforcement = request.policy.write_enforcement
|
|
175
181
|
if policy is None or enforcement is None:
|
|
176
|
-
raise ValueError("
|
|
182
|
+
raise ValueError("audited worker request has no write contract")
|
|
183
|
+
if standalone and policy.source_mode != "source-readonly":
|
|
184
|
+
raise ValueError("standalone code review must be source-readonly")
|
|
177
185
|
if status_extra.get("writePolicyDigest") != policy.digest:
|
|
178
186
|
raise ValueError("v2 worker request write policy digest changed")
|
|
179
187
|
if status_extra.get("writeEnforcement") != enforcement.to_payload():
|
|
180
188
|
raise ValueError("v2 worker request write enforcement changed")
|
|
181
189
|
|
|
182
190
|
|
|
191
|
+
def _snapshot_standalone_review(
|
|
192
|
+
request: WorkerExecRequest, status_extra: Mapping[str, Any],
|
|
193
|
+
) -> MutationSnapshot | None:
|
|
194
|
+
if status_extra.get("standalonePurpose") != "code-review":
|
|
195
|
+
return None
|
|
196
|
+
policy = request.policy.write_policy
|
|
197
|
+
assert policy is not None
|
|
198
|
+
return ExecutionMutationAudit().snapshot((policy,))
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _record_standalone_review_audit(
|
|
202
|
+
request: WorkerExecRequest, before: MutationSnapshot | None,
|
|
203
|
+
status: dict[str, Any], exit_code: int,
|
|
204
|
+
) -> bool:
|
|
205
|
+
if before is None:
|
|
206
|
+
return False
|
|
207
|
+
policy = request.policy.write_policy
|
|
208
|
+
assert policy is not None
|
|
209
|
+
try:
|
|
210
|
+
result = compare_standalone_review(before, policy, succeeded=exit_code == 0)
|
|
211
|
+
except (OSError, ValueError) as exc:
|
|
212
|
+
status["writeAudit"] = {"mutationStatus": "error", "failure": str(exc)}
|
|
213
|
+
status["failure"] = "standalone review mutation audit could not complete"
|
|
214
|
+
return True
|
|
215
|
+
status["writeAudit"] = result.change_summary()
|
|
216
|
+
if result.violations:
|
|
217
|
+
status["failure"] = "standalone review write policy violated"
|
|
218
|
+
return True
|
|
219
|
+
return False
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _record_served_model(
|
|
223
|
+
status: dict[str, Any], normalizer: ServedModelNormalizer | None,
|
|
224
|
+
verifier: Callable[[ServedModelAttestation], str] | None,
|
|
225
|
+
raw_model: str | None, exit_code: int,
|
|
226
|
+
) -> int:
|
|
227
|
+
if normalizer is None:
|
|
228
|
+
return exit_code
|
|
229
|
+
attestation = normalizer(raw_model)
|
|
230
|
+
status["servedModelAttestation"] = _attestation_payload(attestation)
|
|
231
|
+
if verifier is not None:
|
|
232
|
+
failure = verifier(attestation)
|
|
233
|
+
if failure:
|
|
234
|
+
status["failure"] = failure
|
|
235
|
+
return SERVED_MODEL_MISMATCH_EXIT_CODE
|
|
236
|
+
return exit_code
|
|
237
|
+
|
|
238
|
+
|
|
183
239
|
def _launch(
|
|
184
240
|
command: ExecCommand,
|
|
185
241
|
log_path: Path,
|
|
@@ -6,7 +6,7 @@ import json
|
|
|
6
6
|
import re
|
|
7
7
|
import subprocess
|
|
8
8
|
from collections.abc import Iterator, Mapping, Sequence
|
|
9
|
-
from dataclasses import dataclass
|
|
9
|
+
from dataclasses import dataclass, replace
|
|
10
10
|
from pathlib import Path, PurePosixPath
|
|
11
11
|
from typing import Any, Literal
|
|
12
12
|
|
|
@@ -85,6 +85,39 @@ def build_write_policy(
|
|
|
85
85
|
return policy
|
|
86
86
|
|
|
87
87
|
|
|
88
|
+
def build_standalone_review_write_contract(
|
|
89
|
+
project_root: Path, prompt_path: Path, metadata_path: Path,
|
|
90
|
+
metadata: Mapping[str, Any],
|
|
91
|
+
) -> tuple[WritePolicy, WriteEnforcement]:
|
|
92
|
+
root = project_root.resolve()
|
|
93
|
+
artifacts = root / ".okstra/agent-invocations/code-review"
|
|
94
|
+
if prompt_path.resolve().parent != artifacts.resolve():
|
|
95
|
+
raise WritePolicyError("code-review prompt is outside its invocation directory")
|
|
96
|
+
stem = prompt_path.name.removesuffix(".prompt.md")
|
|
97
|
+
duty = root / str(metadata["contractSource"]["dutyRootPath"])
|
|
98
|
+
preserved = {
|
|
99
|
+
prompt_path.resolve().relative_to(root).as_posix(),
|
|
100
|
+
metadata_path.resolve().relative_to(root).as_posix(),
|
|
101
|
+
(artifacts / f"{stem}.review-policy.json").relative_to(root).as_posix(),
|
|
102
|
+
(artifacts / f"{stem}.review-source.json").relative_to(root).as_posix(),
|
|
103
|
+
(artifacts / f"{stem}.review-audit.json").relative_to(root).as_posix(),
|
|
104
|
+
*(path.relative_to(root).as_posix() for path in duty.rglob("*")
|
|
105
|
+
if path.is_file() or path.is_symlink()),
|
|
106
|
+
*(str(source["path"]) for source in metadata["instruction"]["sourcePaths"]
|
|
107
|
+
if source["kind"] == "project"),
|
|
108
|
+
}
|
|
109
|
+
policy = build_write_policy(
|
|
110
|
+
{"role": "verifier", "projectRoot": str(root),
|
|
111
|
+
"artifactPaths": [artifacts.relative_to(root).as_posix()],
|
|
112
|
+
"preservedPaths": sorted(preserved)},
|
|
113
|
+
{"workerWriteCapability": {"maxBoundaryPrecision": "none"}}, None,
|
|
114
|
+
)
|
|
115
|
+
enforcement = derive_write_enforcement(policy, "none", role="verifier")
|
|
116
|
+
return policy, replace(enforcement, unobserved_write_surfaces=(
|
|
117
|
+
*enforcement.unobserved_write_surfaces, "other-git-refs", "shared-git-object-store",
|
|
118
|
+
))
|
|
119
|
+
|
|
120
|
+
|
|
88
121
|
def _role_qa_artifact_paths(role: str, task_root: Path | None) -> tuple[Path, ...]:
|
|
89
122
|
"""The task `qa/` writes a role's own contract makes mandatory.
|
|
90
123
|
|
|
@@ -38,6 +38,7 @@ from .state import (
|
|
|
38
38
|
resolve_task_id,
|
|
39
39
|
resolve_task_identity,
|
|
40
40
|
resolve_task_reference,
|
|
41
|
+
resolve_task_root_read_only,
|
|
41
42
|
slugify,
|
|
42
43
|
task_read_side_snapshot,
|
|
43
44
|
)
|
|
@@ -66,6 +67,7 @@ __all__ = [
|
|
|
66
67
|
"resolve_task_id",
|
|
67
68
|
"resolve_task_identity",
|
|
68
69
|
"resolve_task_reference",
|
|
70
|
+
"resolve_task_root_read_only",
|
|
69
71
|
"slugify",
|
|
70
72
|
"task_read_side_snapshot",
|
|
71
73
|
"tasks_root",
|