okstra 0.229.0 → 0.231.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.
Files changed (150) hide show
  1. package/README.md +1 -5
  2. package/dist/cli-registry.mjs +0 -18
  3. package/dist/cli-registry.mjs.map +1 -1
  4. package/dist/commands/lifecycle/doctor.mjs +0 -15
  5. package/dist/commands/lifecycle/doctor.mjs.map +1 -1
  6. package/dist/lib/skill-catalog.mjs +4 -4
  7. package/dist/lib/skill-catalog.mjs.map +1 -1
  8. package/docs/architecture/storage-model.md +168 -18
  9. package/docs/architecture.md +15 -14
  10. package/docs/coding-rules.md +15 -0
  11. package/docs/contributor-change-matrix.md +5 -5
  12. package/docs/project-structure-overview.md +13 -19
  13. package/package.json +2 -3
  14. package/runtime/BUILD.json +2 -2
  15. package/runtime/bin/lib/okstra/interactive.sh +2 -1
  16. package/runtime/prompts/coding-preflight/clean-code.md +8 -0
  17. package/runtime/prompts/coding-preflight/overview.md +1 -0
  18. package/runtime/prompts/launch.template.md +7 -5
  19. package/runtime/prompts/lead/convergence.md +4 -4
  20. package/runtime/prompts/lead/okstra-lead-contract.md +19 -18
  21. package/runtime/prompts/lead/phase-routing.md +1 -1
  22. package/runtime/prompts/lead/report-writer.md +3 -3
  23. package/runtime/prompts/lead/team-contract.md +3 -3
  24. package/runtime/prompts/profiles/_coding-conventions-preflight.md +2 -0
  25. package/runtime/python/okstra_ctl/agent/invocation.py +190 -9
  26. package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +31 -1
  27. package/runtime/python/okstra_ctl/blocking_checks.py +10 -0
  28. package/runtime/python/okstra_ctl/cmux.py +4 -2
  29. package/runtime/python/okstra_ctl/code_review_census.py +194 -0
  30. package/runtime/python/okstra_ctl/code_review_coverage.py +3 -1
  31. package/runtime/python/okstra_ctl/code_review_scope.py +9 -6
  32. package/runtime/python/okstra_ctl/code_review_target.py +38 -2
  33. package/runtime/python/okstra_ctl/conformance.py +30 -0
  34. package/runtime/python/okstra_ctl/conformance_evidence.py +316 -0
  35. package/runtime/python/okstra_ctl/correction_round.py +19 -13
  36. package/runtime/python/okstra_ctl/dispatch_core.py +1 -1
  37. package/runtime/python/okstra_ctl/dispatch_state.py +1 -0
  38. package/runtime/python/okstra_ctl/execution_mutation_audit.py +13 -1
  39. package/runtime/python/okstra_ctl/generated_input.py +21 -0
  40. package/runtime/python/okstra_ctl/ids.py +1 -41
  41. package/runtime/python/okstra_ctl/incremental_carry.py +7 -4
  42. package/runtime/python/okstra_ctl/initial_prompt_materialization.py +30 -0
  43. package/runtime/python/okstra_ctl/interactive_cli.py +5 -0
  44. package/runtime/python/okstra_ctl/locks.py +28 -1
  45. package/runtime/python/okstra_ctl/model_io/renderers.py +7 -0
  46. package/runtime/python/okstra_ctl/paths.py +90 -33
  47. package/runtime/python/okstra_ctl/phases/catalog.py +3 -0
  48. package/runtime/python/okstra_ctl/phases/change_impact_analysis/spec.md +2 -2
  49. package/runtime/python/okstra_ctl/phases/discussion/spec.md +63 -63
  50. package/runtime/python/okstra_ctl/phases/discussion/wizard.py +2 -11
  51. package/runtime/python/okstra_ctl/phases/error_analysis/report_assets/error-analysis-input.template.md +1 -1
  52. package/runtime/python/okstra_ctl/phases/error_analysis/spec.md +2 -2
  53. package/runtime/python/okstra_ctl/phases/feature_analysis/spec.md +1 -1
  54. package/runtime/python/okstra_ctl/phases/final_verification/profile.md +5 -4
  55. package/runtime/python/okstra_ctl/phases/final_verification/report_assets/final-verification-input.template.md +1 -1
  56. package/runtime/python/okstra_ctl/phases/final_verification/report_assets/final-verification.template.html +8 -0
  57. package/runtime/python/okstra_ctl/phases/final_verification/spec.md +5 -4
  58. package/runtime/python/okstra_ctl/phases/final_verification/validation.py +53 -0
  59. package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +6 -2
  60. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +4 -2
  61. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-executor.md +1 -1
  62. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +23 -7
  63. package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation-input.template.md +1 -1
  64. package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation.template.html +1 -1
  65. package/runtime/python/okstra_ctl/phases/implementation/spec.md +6 -4
  66. package/runtime/python/okstra_ctl/phases/implementation/validation.py +152 -30
  67. package/runtime/python/okstra_ctl/phases/implementation_option_selection/spec.md +2 -2
  68. package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +16 -22
  69. package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -12
  70. package/runtime/python/okstra_ctl/phases/implementation_planning/plan_body.py +14 -0
  71. package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +4 -4
  72. package/runtime/python/okstra_ctl/phases/implementation_planning/report_assets/implementation-planning-input.template.md +1 -1
  73. package/runtime/python/okstra_ctl/phases/implementation_planning/spec.md +1 -1
  74. package/runtime/python/okstra_ctl/phases/implementation_planning/wizard.py +11 -4
  75. package/runtime/python/okstra_ctl/phases/project_analysis/spec.md +2 -2
  76. package/runtime/python/okstra_ctl/phases/release_handoff/entry.py +7 -3
  77. package/runtime/python/okstra_ctl/phases/release_handoff/operations.py +4 -5
  78. package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +1 -1
  79. package/runtime/python/okstra_ctl/phases/release_handoff/report_assets/release-handoff-input.template.md +1 -1
  80. package/runtime/python/okstra_ctl/phases/release_handoff/spec.md +4 -4
  81. package/runtime/python/okstra_ctl/phases/technical_verification/spec.md +1 -1
  82. package/runtime/python/okstra_ctl/plan_items.py +28 -0
  83. package/runtime/python/okstra_ctl/process_group.py +26 -3
  84. package/runtime/python/okstra_ctl/qa_commands.py +5 -1
  85. package/runtime/python/okstra_ctl/recap.py +1 -2
  86. package/runtime/python/okstra_ctl/render.py +25 -2
  87. package/runtime/python/okstra_ctl/report_assembly.py +102 -1
  88. package/runtime/python/okstra_ctl/report_execution_evidence.py +220 -0
  89. package/runtime/python/okstra_ctl/report_finalize.py +3 -3
  90. package/runtime/python/okstra_ctl/report_inputs.py +28 -0
  91. package/runtime/python/okstra_ctl/report_narrative.py +12 -3
  92. package/runtime/python/okstra_ctl/report_synthesis_packet.py +5 -0
  93. package/runtime/python/okstra_ctl/run.py +40 -20
  94. package/runtime/python/okstra_ctl/stage_close.py +52 -6
  95. package/runtime/python/okstra_ctl/stage_command_commits.py +143 -0
  96. package/runtime/python/okstra_ctl/stage_fix_carry.py +21 -1
  97. package/runtime/python/okstra_ctl/stage_integrate.py +90 -25
  98. package/runtime/python/okstra_ctl/verification_capture.py +291 -0
  99. package/runtime/python/okstra_ctl/verification_conformance.py +28 -9
  100. package/runtime/python/okstra_ctl/verification_dispatch.py +136 -0
  101. package/runtime/python/okstra_ctl/verification_evidence.py +671 -0
  102. package/runtime/python/okstra_ctl/verification_generation.py +34 -16
  103. package/runtime/python/okstra_ctl/verification_input_ref.py +9 -0
  104. package/runtime/python/okstra_ctl/verification_input_types.py +2 -0
  105. package/runtime/python/okstra_ctl/verification_inputs.py +83 -2
  106. package/runtime/python/okstra_ctl/verification_invocation.py +140 -0
  107. package/runtime/python/okstra_ctl/verification_target.py +10 -3
  108. package/runtime/python/okstra_ctl/wizard/engine.py +23 -0
  109. package/runtime/python/okstra_ctl/wizard/registry.py +2 -1
  110. package/runtime/python/okstra_ctl/wizard/render.py +2 -1
  111. package/runtime/python/okstra_ctl/wizard/sources.py +14 -3
  112. package/runtime/python/okstra_ctl/wizard/steps_identity.py +2 -1
  113. package/runtime/python/okstra_ctl/wizard/steps_plan.py +6 -2
  114. package/runtime/python/okstra_ctl/worker_runner.py +1 -1
  115. package/runtime/python/okstra_ctl/worktree/git_ops.py +8 -1
  116. package/runtime/python/okstra_ctl/worktree/rebase.py +5 -2
  117. package/runtime/python/okstra_ctl/worktree_lock_cli.py +70 -17
  118. package/runtime/python/okstra_ctl/worktree_registry.py +4 -0
  119. package/runtime/schemas/final-report-v3.0.schema.json +184 -1
  120. package/runtime/skills/okstra-code-review/SKILL.md +7 -5
  121. package/runtime/skills/okstra-code-review/references/census-rules.md +2 -2
  122. package/runtime/skills/okstra-explain-flow/SKILL.md +1 -1
  123. package/runtime/skills/okstra-run/SKILL.md +11 -7
  124. package/runtime/skills/okstra-schedule-gen/SKILL.md +3 -3
  125. package/runtime/skills/okstra-setup/SKILL.md +2 -3
  126. package/runtime/templates/reports/html/i18n/en.json +7 -0
  127. package/runtime/templates/reports/html/i18n/ko.json +7 -0
  128. package/runtime/validators/validate-run.py +130 -20
  129. package/runtime/validators/validate-workflow.sh +1 -1
  130. package/docs/cli.md +0 -1060
  131. package/docs/container.md +0 -100
  132. package/docs/follow-ups/2026-07-10-final-report-option-3.md +0 -51
  133. package/docs/performance-improvement-plan-v2.md +0 -369
  134. package/runtime/python/okstra_ctl/container.py +0 -702
  135. package/runtime/python/okstra_ctl/rollup.py +0 -241
  136. package/runtime/python/okstra_ctl/usage_report.py +0 -362
  137. package/runtime/skills/okstra-container-build/SKILL.md +0 -139
  138. package/runtime/skills/okstra-inspect/SKILL.md +0 -100
  139. package/runtime/skills/okstra-inspect/facets/cost.md +0 -84
  140. package/runtime/skills/okstra-inspect/facets/error-zip.md +0 -41
  141. package/runtime/skills/okstra-inspect/facets/errors.md +0 -69
  142. package/runtime/skills/okstra-inspect/facets/history.md +0 -86
  143. package/runtime/skills/okstra-inspect/facets/logs.md +0 -89
  144. package/runtime/skills/okstra-inspect/facets/recap.md +0 -167
  145. package/runtime/skills/okstra-inspect/facets/report.md +0 -57
  146. package/runtime/skills/okstra-inspect/facets/run-audit.md +0 -34
  147. package/runtime/skills/okstra-inspect/facets/status.md +0 -163
  148. package/runtime/skills/okstra-inspect/facets/time.md +0 -57
  149. package/runtime/skills/okstra-rollup/SKILL.md +0 -75
  150. package/runtime/skills/okstra-usage/SKILL.md +0 -71
@@ -45,17 +45,19 @@ def _project_script_path(project: Path, task_root: Path, script: str) -> str:
45
45
  return safe.relative_to(project).as_posix()
46
46
 
47
47
 
48
+ def conformance_stage(stage_key: str) -> int:
49
+ match = re.fullmatch(r".+-stage-([1-9][0-9]*)", stage_key)
50
+ if match is None:
51
+ raise ValueError("conformance stageKey must end in -stage-<positive integer>")
52
+ return int(match[1])
53
+
54
+
48
55
  def _entries_by_stage(
49
56
  manifest: Mapping[str, Any], declared_stages: set[int],
50
57
  ) -> dict[int, dict[str, Any]]:
51
58
  entries = {}
52
59
  for entry in manifest["entries"]:
53
- match = re.fullmatch(r".+-stage-([1-9][0-9]*)", entry["stageKey"])
54
- if match is None:
55
- raise ValueError(
56
- "conformance stageKey must end in -stage-<positive integer>"
57
- )
58
- stage = int(match[1])
60
+ stage = conformance_stage(entry["stageKey"])
59
61
  if stage in entries:
60
62
  raise ValueError(f"conformance stage {stage} has multiple entries")
61
63
  if stage not in declared_stages:
@@ -118,6 +120,25 @@ def _read_conformance_manifest(
118
120
  )
119
121
 
120
122
 
123
+ def conformance_manifest_path(project: Path, task_root: Path) -> str:
124
+ return (task_root / "qa/conformance-manifest.json").relative_to(
125
+ project,
126
+ ).as_posix()
127
+
128
+
129
+ def capture_conformance_baseline(
130
+ project: Path, task_root: Path, plan: FrozenVerificationPlan,
131
+ ) -> dict[str, str]:
132
+ entries, _ = _read_conformance_manifest(
133
+ project, conformance_manifest_path(project, task_root),
134
+ {row["stage"] for row in plan["conformance"]},
135
+ )
136
+ return {
137
+ str(stage): _project_script_path(project, task_root, entry["script"])
138
+ for stage, entry in sorted(entries.items())
139
+ }
140
+
141
+
121
142
  def capture_generation_conformance(
122
143
  project: Path, ref: RunRef, plan: FrozenVerificationPlan,
123
144
  changed_artifact_paths: frozenset[str], conformance_baseline: Mapping[int, str],
@@ -134,9 +155,7 @@ def capture_generation_conformance(
134
155
  stage: _project_script_path(project, ref.task_root, row["script"])
135
156
  for stage, row in declarations.items() if "script" in row
136
157
  }
137
- relative_manifest = (ref.task_root / "qa/conformance-manifest.json").relative_to(
138
- project,
139
- ).as_posix()
158
+ relative_manifest = conformance_manifest_path(project, ref.task_root)
140
159
  entries, sealed_manifest = _read_conformance_manifest(
141
160
  project, relative_manifest, set(declarations),
142
161
  )
@@ -0,0 +1,136 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ import subprocess
5
+ from typing import Any, Mapping
6
+
7
+ from .correction_round import completed_round_attempts, correction_round
8
+ from .execution_manifest import read_execution_manifest
9
+ from .paths import RunRef
10
+ from .qa_procedures import safe_qa_path
11
+ from .verification_generation import prepare_verification_generation
12
+ from .verification_input_ref import VerificationInputReference
13
+ from .verification_input_types import VerificationInputs
14
+ from .verification_inputs import (
15
+ frozen_conformance_baseline, read_verification_inputs,
16
+ )
17
+ from .verification_invocation import (
18
+ VerificationGenerationReference, verification_generation_required,
19
+ )
20
+ from .verification_target import read_worktree_head
21
+
22
+
23
+ class VerificationDispatchError(ValueError):
24
+ """A verifier dispatch whose generation cannot be sealed."""
25
+
26
+ def __init__(
27
+ self, message: str, *, missing_executor_result: bool = False,
28
+ ) -> None:
29
+ super().__init__(message)
30
+ self.missing_executor_result = missing_executor_result
31
+
32
+
33
+ def seal_dispatch_generation(
34
+ project: Path, manifest_path: Path, manifest: Mapping[str, Any],
35
+ active_context: Mapping[str, Any], *, audience: str, dispatch_kind: str,
36
+ ) -> VerificationGenerationReference | None:
37
+ try:
38
+ return _seal(
39
+ project, manifest_path, manifest, active_context,
40
+ audience=audience, dispatch_kind=dispatch_kind,
41
+ )
42
+ except VerificationDispatchError:
43
+ raise
44
+ except KeyError as exc:
45
+ raise VerificationDispatchError(
46
+ f"required field is missing: {exc.args[0]}",
47
+ ) from exc
48
+ except (OSError, ValueError, subprocess.SubprocessError) as exc:
49
+ raise VerificationDispatchError(str(exc)) from exc
50
+
51
+
52
+ def verification_generation_number(dispatch_kind: str) -> int:
53
+ """The generation a dispatch seals; every dispatch outside a correction
54
+ round seals 1."""
55
+ return generation_sealed_after_round(correction_round(dispatch_kind) or 0)
56
+
57
+
58
+ def generation_sealed_after_round(round_number: int) -> int:
59
+ """Correction round N seals generation N + 1."""
60
+ return 1 + round_number
61
+
62
+
63
+ def _seal(
64
+ project: Path, manifest_path: Path, manifest: Mapping[str, Any],
65
+ active_context: Mapping[str, Any], *, audience: str, dispatch_kind: str,
66
+ ) -> VerificationGenerationReference | None:
67
+ if not verification_generation_required(manifest, audience):
68
+ return None
69
+ project = project.resolve()
70
+ reference = VerificationInputReference.required_from_artifact_fields(manifest)
71
+ round_number = correction_round(dispatch_kind)
72
+ implementation = manifest["taskType"] == "implementation"
73
+ if implementation:
74
+ changed = _executor_changes(manifest_path, dispatch_kind, round_number)
75
+ else:
76
+ changed = _final_verification_changes(round_number)
77
+ inputs = read_verification_inputs(
78
+ safe_qa_path(project, reference.relative_path), reference.digest,
79
+ )
80
+ head = (
81
+ read_worktree_head(Path(inputs["sourceRoot"])) if implementation
82
+ else str(active_context["verificationTarget"]["headRef"])
83
+ )
84
+ path, digest = prepare_verification_generation(
85
+ project, RunRef.from_manifest(manifest_path, manifest), reference,
86
+ generation=verification_generation_number(dispatch_kind),
87
+ expected_head=head,
88
+ source_inputs=_present_declared_sources(inputs),
89
+ generated_roots=frozenset(), artifact_inputs=frozenset(),
90
+ changed_artifact_paths=changed,
91
+ conformance_baseline=frozen_conformance_baseline(
92
+ inputs, manifest["taskType"],
93
+ ),
94
+ )
95
+ return VerificationGenerationReference(
96
+ path.relative_to(project).as_posix(), digest,
97
+ )
98
+
99
+
100
+ def _present_declared_sources(inputs: VerificationInputs) -> frozenset[str]:
101
+ # A related source the executor deleted is part of the change under review;
102
+ # only the files present at the seal can be protected from the verifiers.
103
+ root = Path(inputs["sourceRoot"])
104
+ return frozenset(
105
+ relative
106
+ for entries in inputs["qaCommands"].values() for entry in entries
107
+ for relative in entry.get("sourcePaths", ())
108
+ if (root / relative).exists() or (root / relative).is_symlink()
109
+ )
110
+
111
+
112
+ def _executor_changes(
113
+ manifest_path: Path, dispatch_kind: str, round_number: int | None,
114
+ ) -> frozenset[str]:
115
+ attempts = completed_round_attempts(
116
+ read_execution_manifest(manifest_path), round_number, "implementer",
117
+ )
118
+ if not attempts:
119
+ raise VerificationDispatchError(
120
+ "the implementation executor has no ok result in dispatch "
121
+ f"{dispatch_kind}; dispatch the executor alone and await it before "
122
+ "its verifiers",
123
+ missing_executor_result=True,
124
+ )
125
+ return frozenset(
126
+ path for attempt in attempts
127
+ for path in attempt.change_summary.get("changedArtifactPaths", ())
128
+ )
129
+
130
+
131
+ def _final_verification_changes(round_number: int | None) -> frozenset[str]:
132
+ if round_number is not None:
133
+ raise ValueError(
134
+ "final-verification seals only its initial verifier dispatch"
135
+ )
136
+ return frozenset()