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.
Files changed (265) hide show
  1. package/README.md +19 -271
  2. package/dist/cli-registry.mjs +14 -1
  3. package/dist/cli-registry.mjs.map +1 -1
  4. package/dist/commands/execute/render-bundle.d.mts +6 -1
  5. package/dist/commands/execute/render-bundle.mjs +139 -32
  6. package/dist/commands/execute/render-bundle.mjs.map +1 -1
  7. package/dist/commands/lifecycle/config.mjs +6 -74
  8. package/dist/commands/lifecycle/config.mjs.map +1 -1
  9. package/dist/commands/memory/memory.mjs +9 -55
  10. package/dist/commands/memory/memory.mjs.map +1 -1
  11. package/dist/commands/trace/capacity.d.mts +12 -0
  12. package/dist/commands/trace/capacity.mjs +21 -0
  13. package/dist/commands/trace/capacity.mjs.map +1 -0
  14. package/dist/commands/trace/model.d.mts +89 -0
  15. package/dist/commands/trace/model.mjs +251 -0
  16. package/dist/commands/trace/model.mjs.map +1 -0
  17. package/dist/commands/trace/progression.d.mts +11 -0
  18. package/dist/commands/trace/progression.mjs +194 -0
  19. package/dist/commands/trace/progression.mjs.map +1 -0
  20. package/dist/commands/trace/review.d.mts +7 -0
  21. package/dist/commands/trace/review.mjs +51 -0
  22. package/dist/commands/trace/review.mjs.map +1 -0
  23. package/dist/commands/trace/task-link.d.mts +18 -0
  24. package/dist/commands/trace/task-link.mjs +72 -0
  25. package/dist/commands/trace/task-link.mjs.map +1 -0
  26. package/dist/commands/trace/trace.d.mts +1 -0
  27. package/dist/commands/trace/trace.mjs +293 -0
  28. package/dist/commands/trace/trace.mjs.map +1 -0
  29. package/dist/lib/bounded-file.d.mts +1 -0
  30. package/dist/lib/bounded-file.mjs +36 -0
  31. package/dist/lib/bounded-file.mjs.map +1 -0
  32. package/dist/lib/config-store.d.mts +34 -0
  33. package/dist/lib/config-store.mjs +70 -0
  34. package/dist/lib/config-store.mjs.map +1 -0
  35. package/dist/lib/file-lock.mjs +4 -5
  36. package/dist/lib/file-lock.mjs.map +1 -1
  37. package/dist/lib/input-limit.d.mts +4 -0
  38. package/dist/lib/input-limit.mjs +8 -0
  39. package/dist/lib/input-limit.mjs.map +1 -0
  40. package/dist/lib/memory-auto-register.d.mts +1 -0
  41. package/dist/lib/memory-auto-register.mjs +98 -0
  42. package/dist/lib/memory-auto-register.mjs.map +1 -0
  43. package/dist/lib/memory-entry-contract.d.mts +12 -0
  44. package/dist/lib/memory-entry-contract.mjs +46 -0
  45. package/dist/lib/memory-entry-contract.mjs.map +1 -0
  46. package/dist/lib/python-helper.d.mts +1 -1
  47. package/dist/lib/python-helper.mjs +3 -2
  48. package/dist/lib/python-helper.mjs.map +1 -1
  49. package/dist/lib/record-secrets.d.mts +1 -0
  50. package/dist/lib/record-secrets.mjs +28 -0
  51. package/dist/lib/record-secrets.mjs.map +1 -0
  52. package/dist/lib/report-language-tag.d.mts +1 -0
  53. package/dist/lib/report-language-tag.mjs +4 -0
  54. package/dist/lib/report-language-tag.mjs.map +1 -0
  55. package/dist/lib/report-language.d.mts +1 -0
  56. package/dist/lib/report-language.mjs +50 -0
  57. package/dist/lib/report-language.mjs.map +1 -0
  58. package/dist/lib/skill-catalog.mjs +3 -0
  59. package/dist/lib/skill-catalog.mjs.map +1 -1
  60. package/dist/lib/types.d.mts +2 -1
  61. package/docs/architecture/storage-model.md +163 -5
  62. package/docs/architecture.md +17 -4
  63. package/docs/cli.md +511 -0
  64. package/docs/contributor-change-matrix.md +1 -2
  65. package/docs/project-structure-overview.md +33 -42
  66. package/package.json +1 -1
  67. package/runtime/BUILD.json +2 -2
  68. package/runtime/agents/common.json +8 -8
  69. package/runtime/agents/operations/trace-interface-review.json +6 -0
  70. package/runtime/agents/operations/trace-scope-review.json +6 -0
  71. package/runtime/agents/roles/verifier.json +2 -4
  72. package/runtime/bin/okstra-provider-exec.py +10 -4
  73. package/runtime/prompts/coding-preflight/architectures/hexagonal.md +23 -30
  74. package/runtime/prompts/coding-preflight/authoring-checks.md +17 -0
  75. package/runtime/prompts/coding-preflight/clean-code.md +88 -286
  76. package/runtime/prompts/coding-preflight/frameworks/node-server.md +2 -3
  77. package/runtime/prompts/coding-preflight/languages/java.md +3 -5
  78. package/runtime/prompts/coding-preflight/languages/javascript-typescript.md +5 -12
  79. package/runtime/prompts/coding-preflight/languages/kotlin.md +2 -4
  80. package/runtime/prompts/coding-preflight/languages/python.md +2 -7
  81. package/runtime/prompts/coding-preflight/languages/rust.md +2 -8
  82. package/runtime/prompts/coding-preflight/languages/sql.md +2 -4
  83. package/runtime/prompts/coding-preflight/overview.md +25 -38
  84. package/runtime/prompts/coding-preflight/review-rules.json +30 -0
  85. package/runtime/prompts/duties/code-reviewer.json +15 -18
  86. package/runtime/prompts/duties/implementation-verifier.json +1 -0
  87. package/runtime/prompts/duties/interface-reviewer.json +32 -0
  88. package/runtime/prompts/host-orchestration/README.md +18 -9
  89. package/runtime/prompts/launch.template.md +3 -2
  90. package/runtime/prompts/lead/context-loader.md +2 -0
  91. package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
  92. package/runtime/prompts/lead/report-writer.md +6 -6
  93. package/runtime/prompts/profiles/_coding-conventions-preflight.md +41 -6
  94. package/runtime/prompts/profiles/_common-contract.md +1 -1
  95. package/runtime/python/okstra_ctl/agent/invocation.py +122 -36
  96. package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +72 -26
  97. package/runtime/python/okstra_ctl/agent/prompt_cli/corrections.py +23 -8
  98. package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +58 -14
  99. package/runtime/python/okstra_ctl/agent/prompt_cli/results.py +8 -11
  100. package/runtime/python/okstra_ctl/agent/standalone.py +15 -0
  101. package/runtime/python/okstra_ctl/analysis_packet.py +24 -30
  102. package/runtime/python/okstra_ctl/attempt_evidence.py +10 -0
  103. package/runtime/python/okstra_ctl/code_review_census.py +162 -7
  104. package/runtime/python/okstra_ctl/code_review_coverage.py +4 -274
  105. package/runtime/python/okstra_ctl/code_review_integrity.py +154 -0
  106. package/runtime/python/okstra_ctl/code_review_invocation.py +212 -0
  107. package/runtime/python/okstra_ctl/code_review_prepare.py +381 -0
  108. package/runtime/python/okstra_ctl/code_review_run.py +384 -0
  109. package/runtime/python/okstra_ctl/code_review_scope.py +49 -9
  110. package/runtime/python/okstra_ctl/code_review_supervisor.py +41 -0
  111. package/runtime/python/okstra_ctl/code_review_target.py +212 -13
  112. package/runtime/python/okstra_ctl/consumers.py +12 -9
  113. package/runtime/python/okstra_ctl/coverage_census.py +11 -2
  114. package/runtime/python/okstra_ctl/design_review.py +207 -0
  115. package/runtime/python/okstra_ctl/design_review_evidence.py +297 -0
  116. package/runtime/python/okstra_ctl/design_snapshot.py +16 -9
  117. package/runtime/python/okstra_ctl/direct_work.py +45 -3
  118. package/runtime/python/okstra_ctl/dispatch_core.py +31 -15
  119. package/runtime/python/okstra_ctl/dispatch_state.py +9 -2
  120. package/runtime/python/okstra_ctl/doctor.py +8 -25
  121. package/runtime/python/okstra_ctl/domain/role.py +1 -0
  122. package/runtime/python/okstra_ctl/doyouknow/__init__.py +9 -0
  123. package/runtime/python/okstra_ctl/doyouknow/cli.py +91 -0
  124. package/runtime/python/okstra_ctl/doyouknow/config.py +58 -0
  125. package/runtime/python/okstra_ctl/doyouknow/contracts.py +184 -0
  126. package/runtime/python/okstra_ctl/doyouknow/identity.py +22 -0
  127. package/runtime/python/okstra_ctl/doyouknow/paths.py +22 -0
  128. package/runtime/python/okstra_ctl/doyouknow/pending.py +72 -0
  129. package/runtime/python/okstra_ctl/doyouknow/registration.py +260 -0
  130. package/runtime/python/okstra_ctl/doyouknow/source_contracts.py +128 -0
  131. package/runtime/python/okstra_ctl/doyouknow/source_store.py +172 -0
  132. package/runtime/python/okstra_ctl/doyouknow/sources/io.py +36 -0
  133. package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +300 -0
  134. package/runtime/python/okstra_ctl/doyouknow/sources/memory.py +179 -0
  135. package/runtime/python/okstra_ctl/doyouknow/sources/task.py +95 -0
  136. package/runtime/python/okstra_ctl/doyouknow/store.py +260 -0
  137. package/runtime/python/okstra_ctl/doyouknow/sync.py +58 -0
  138. package/runtime/python/okstra_ctl/execution_mutation_audit.py +18 -2
  139. package/runtime/python/okstra_ctl/file_size_cap.py +3 -4
  140. package/runtime/python/okstra_ctl/final_report_schema.py +37 -34
  141. package/runtime/python/okstra_ctl/incremental_carry.py +6 -7
  142. package/runtime/python/okstra_ctl/initial_prompt_materialization.py +9 -2
  143. package/runtime/python/okstra_ctl/json_boundary.py +51 -5
  144. package/runtime/python/okstra_ctl/jsonl.py +21 -0
  145. package/runtime/python/okstra_ctl/manager_cli.py +148 -1
  146. package/runtime/python/okstra_ctl/manager_journal.py +126 -0
  147. package/runtime/python/okstra_ctl/manager_launch.py +3 -3
  148. package/runtime/python/okstra_ctl/manager_log.py +221 -0
  149. package/runtime/python/okstra_ctl/manager_paths.py +8 -0
  150. package/runtime/python/okstra_ctl/manager_registration.py +29 -0
  151. package/runtime/python/okstra_ctl/manager_resume.py +59 -0
  152. package/runtime/python/okstra_ctl/manager_split.py +2 -2
  153. package/runtime/python/okstra_ctl/manager_store.py +116 -17
  154. package/runtime/python/okstra_ctl/manager_sync.py +45 -25
  155. package/runtime/python/okstra_ctl/manager_view.py +35 -2
  156. package/runtime/python/okstra_ctl/material.py +2 -0
  157. package/runtime/python/okstra_ctl/model_cli.py +64 -14
  158. package/runtime/python/okstra_ctl/model_defaults.py +22 -0
  159. package/runtime/python/okstra_ctl/model_io/renderers.py +16 -2
  160. package/runtime/python/okstra_ctl/model_io_cli.py +7 -1
  161. package/runtime/python/okstra_ctl/operation_invocation.py +207 -28
  162. package/runtime/python/okstra_ctl/path_hints.py +14 -3
  163. package/runtime/python/okstra_ctl/paths.py +6 -1
  164. package/runtime/python/okstra_ctl/phases/catalog.py +24 -7
  165. package/runtime/python/okstra_ctl/phases/final_verification/validation.py +20 -0
  166. package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +3 -3
  167. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +10 -0
  168. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +23 -8
  169. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +6 -4
  170. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +38 -10
  171. package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation.template.html +13 -0
  172. package/runtime/python/okstra_ctl/phases/implementation/spec.md +25 -0
  173. package/runtime/python/okstra_ctl/phases/implementation/validation.py +6 -0
  174. package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
  175. package/runtime/python/okstra_ctl/phases/implementation_option_selection/votes.py +11 -11
  176. package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +16 -9
  177. package/runtime/python/okstra_ctl/phases/implementation_planning/host-rules.md +3 -6
  178. package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -10
  179. package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +6 -6
  180. package/runtime/python/okstra_ctl/phases/improvement_discovery/lenses.py +12 -0
  181. package/runtime/python/okstra_ctl/phases/improvement_discovery/profile.md +7 -6
  182. package/runtime/python/okstra_ctl/phases/improvement_discovery/resolved_census.py +159 -0
  183. package/runtime/python/okstra_ctl/phases/improvement_discovery/spec.md +5 -2
  184. package/runtime/python/okstra_ctl/phases/improvement_discovery/validation.py +21 -7
  185. package/runtime/python/okstra_ctl/phases/release_handoff/boundary.json +1 -1
  186. package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +4 -1
  187. package/runtime/python/okstra_ctl/plan_verify_cli.py +6 -4
  188. package/runtime/python/okstra_ctl/render.py +28 -2
  189. package/runtime/python/okstra_ctl/report_assembly.py +53 -11
  190. package/runtime/python/okstra_ctl/report_contract.py +26 -0
  191. package/runtime/python/okstra_ctl/report_corrections.py +36 -20
  192. package/runtime/python/okstra_ctl/report_inputs.py +1 -0
  193. package/runtime/python/okstra_ctl/report_language.py +4 -1
  194. package/runtime/python/okstra_ctl/report_narrative.py +182 -7
  195. package/runtime/python/okstra_ctl/report_projections.py +64 -18
  196. package/runtime/python/okstra_ctl/report_synthesis_packet.py +97 -38
  197. package/runtime/python/okstra_ctl/review_policy.py +359 -0
  198. package/runtime/python/okstra_ctl/review_verdicts.py +291 -0
  199. package/runtime/python/okstra_ctl/run.py +67 -36
  200. package/runtime/python/okstra_ctl/run_context.py +10 -1
  201. package/runtime/python/okstra_ctl/set_work_status.py +4 -15
  202. package/runtime/python/okstra_ctl/stage_done.py +11 -0
  203. package/runtime/python/okstra_ctl/standalone_review_audit.py +28 -0
  204. package/runtime/python/okstra_ctl/task_list_cli.py +34 -8
  205. package/runtime/python/okstra_ctl/task_query.py +239 -0
  206. package/runtime/python/okstra_ctl/trace_review.py +264 -0
  207. package/runtime/python/okstra_ctl/trace_tasks.py +197 -0
  208. package/runtime/python/okstra_ctl/user_authorization.py +14 -0
  209. package/runtime/python/okstra_ctl/verification_generation.py +23 -1
  210. package/runtime/python/okstra_ctl/verification_input_types.py +15 -1
  211. package/runtime/python/okstra_ctl/verification_inputs.py +28 -6
  212. package/runtime/python/okstra_ctl/verification_invocation.py +7 -1
  213. package/runtime/python/okstra_ctl/verification_target.py +2 -0
  214. package/runtime/python/okstra_ctl/wizard/confirmation.py +7 -3
  215. package/runtime/python/okstra_ctl/wizard/launch.py +52 -0
  216. package/runtime/python/okstra_ctl/wizard/launch_cli.py +39 -0
  217. package/runtime/python/okstra_ctl/wizard/outcome.py +17 -16
  218. package/runtime/python/okstra_ctl/wizard/registry.py +1 -1
  219. package/runtime/python/okstra_ctl/wizard/render.py +8 -0
  220. package/runtime/python/okstra_ctl/wizard/state.py +2 -1
  221. package/runtime/python/okstra_ctl/worker_prompt_headers.py +24 -9
  222. package/runtime/python/okstra_ctl/worker_runner.py +66 -10
  223. package/runtime/python/okstra_ctl/write_policy.py +34 -1
  224. package/runtime/python/okstra_project/__init__.py +2 -0
  225. package/runtime/python/okstra_project/dirs.py +18 -0
  226. package/runtime/python/okstra_project/state.py +45 -20
  227. package/runtime/python/okstra_token_usage/blocks.py +74 -0
  228. package/runtime/python/okstra_token_usage/cli.py +23 -10
  229. package/runtime/python/okstra_token_usage/collect.py +25 -22
  230. package/runtime/python/okstra_token_usage/policy.py +193 -0
  231. package/runtime/schemas/doyouknow-config-v1.schema.json +20 -0
  232. package/runtime/schemas/doyouknow-v1.schema.json +65 -0
  233. package/runtime/schemas/final-report-v2.0.schema.json +157 -0
  234. package/runtime/schemas/final-report-v3.0.schema.json +157 -0
  235. package/runtime/schemas/memory-entry-contract-v1.json +11 -0
  236. package/runtime/schemas/record-secret-patterns.json +41 -0
  237. package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +1 -1
  238. package/runtime/skills/_fragments/wizard-confirm-step.md +1 -1
  239. package/runtime/skills/_fragments/wizard-preflight.md +1 -1
  240. package/runtime/skills/_fragments/wizard-prompt-loop.md +3 -5
  241. package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
  242. package/runtime/skills/_fragments/wizard-render-bundle.md +15 -29
  243. package/runtime/skills/okstra-brief-gen/SKILL.md +7 -7
  244. package/runtime/skills/okstra-brief-gen/references/tracker-recursion.md +1 -1
  245. package/runtime/skills/okstra-code-review/SKILL.md +92 -136
  246. package/runtime/skills/okstra-code-review/references/census-rules.md +29 -105
  247. package/runtime/skills/okstra-code-review/references/review-calibration.md +37 -61
  248. package/runtime/skills/okstra-discussion/SKILL.md +22 -38
  249. package/runtime/skills/okstra-explain-flow/SKILL.md +6 -2
  250. package/runtime/skills/okstra-manager/SKILL.md +31 -0
  251. package/runtime/skills/okstra-memory/SKILL.md +8 -1
  252. package/runtime/skills/okstra-pr-gen/SKILL.md +1 -1
  253. package/runtime/skills/okstra-run/SKILL.md +55 -183
  254. package/runtime/skills/okstra-schedule-gen/SKILL.md +9 -13
  255. package/runtime/skills/okstra-setup/SKILL.md +3 -2
  256. package/runtime/skills/okstra-setup/references/project-config.md +2 -4
  257. package/runtime/skills/okstra-tdd/SKILL.md +187 -0
  258. package/runtime/skills/okstra-user-response/SKILL.md +4 -2
  259. package/runtime/templates/implementation-worker-preamble.md +4 -9
  260. package/runtime/templates/manager/view.template.html +4 -0
  261. package/runtime/templates/report-writer-prompt-preamble.md +15 -3
  262. package/runtime/templates/trace/trace.template.md +42 -0
  263. package/runtime/templates/worker-prompt-preamble.md +4 -12
  264. package/runtime/validators/checks/fixtures-02.py +25 -33
  265. package/runtime/validators/validate-run.py +107 -38
@@ -1,18 +1,25 @@
1
1
  """Read project-local okstra state into manager-owned snapshots."""
2
2
  from __future__ import annotations
3
3
 
4
+ import sys
4
5
  from datetime import datetime
5
6
  from pathlib import Path
6
7
 
7
- from okstra_project import TASKS_RELATIVE, StateError, parse_task_key, read_task_catalog, read_task_manifest, slugify
8
+ from okstra_project import StateError, read_task_manifest, resolve_task_root_read_only
8
9
  from okstra_project.dirs import TASK_MANIFEST_FILENAME
9
10
 
10
11
  from . import next_phase
11
12
  from .next_phase import STATUS_BLOCKED, STATUS_TERMINAL
12
13
  from .phases.discussion.overview import discussion_overview
13
14
  from .phases.discussion.store import DiscussionStore
14
- from .manager_paths import children_json_path, projects_json_path, snapshots_json_path, task_manifest_path
15
- from .manager_store import _now_iso, _read_json, _read_json_default, _write_json
15
+ from .manager_paths import (
16
+ children_json_path,
17
+ events_jsonl_path,
18
+ projects_json_path,
19
+ snapshots_json_path,
20
+ task_manifest_path,
21
+ )
22
+ from .manager_store import ManagerError, _now_iso, _read_json, _read_json_default, _write_json, record_event
16
23
 
17
24
 
18
25
  def _project_map(home: Path, manager_id: str) -> dict[str, dict]:
@@ -39,25 +46,6 @@ def _list_field(payload: dict, field: str) -> list:
39
46
  return list(value) if isinstance(value, list) else []
40
47
 
41
48
 
42
- def _resolve_task_root_read_only(project_root: Path, task_key: str) -> Path | None:
43
- _, task_group, task_id = parse_task_key(task_key)
44
- requested_key = task_key.lower()
45
- for entry in read_task_catalog(project_root):
46
- entry_key = entry.get("taskKey") or ""
47
- if not isinstance(entry_key, str) or entry_key.lower() != requested_key:
48
- continue
49
- relative_path = entry.get("taskRootPath") or entry.get("taskRoot") or ""
50
- if not isinstance(relative_path, str) or not relative_path:
51
- continue
52
- candidate = project_root / relative_path if not Path(relative_path).is_absolute() else Path(relative_path)
53
- if candidate.is_dir():
54
- return candidate
55
- slug_path = project_root / TASKS_RELATIVE / slugify(task_group) / slugify(task_id)
56
- if slug_path.is_dir():
57
- return slug_path
58
- return None
59
-
60
-
61
49
  DISCUSSION_TASK_TYPE = "discussion"
62
50
 
63
51
 
@@ -77,7 +65,7 @@ def _snapshot_child(project_root: Path, child: dict) -> dict:
77
65
  base = _base_child_snapshot(child)
78
66
  task_key = base["taskKey"]
79
67
  try:
80
- task_dir = _resolve_task_root_read_only(project_root, task_key)
68
+ task_dir = resolve_task_root_read_only(project_root, task_key)
81
69
  if task_dir is None:
82
70
  return base
83
71
  manifest = read_task_manifest(task_dir) or {}
@@ -111,8 +99,34 @@ def _snapshot_child(project_root: Path, child: dict) -> dict:
111
99
  }
112
100
 
113
101
 
102
+ def _previous_buckets(path: Path) -> dict[str, str]:
103
+ try:
104
+ previous = _read_json_default(path, {})
105
+ except ManagerError:
106
+ print(f"okstra manager: previous snapshot is damaged; this sync replaces it and reports its "
107
+ f"children with from=null: {path}", file=sys.stderr)
108
+ previous = {}
109
+ return {
110
+ str(row.get("taskKey") or ""): summary_bucket(row)
111
+ for row in _list_field(previous, "children")
112
+ if isinstance(row, dict)
113
+ }
114
+
115
+
116
+ def _bucket_transitions(before: dict[str, str], rows: list[dict]) -> list[dict]:
117
+ transitions = []
118
+ for row in rows:
119
+ task_key = str(row.get("taskKey") or "")
120
+ bucket = summary_bucket(row)
121
+ if before.get(task_key) != bucket:
122
+ transitions.append({"taskKey": task_key, "from": before.get(task_key), "to": bucket})
123
+ return transitions
124
+
125
+
114
126
  def sync_task(home: Path, manager_id: str, task_group: str, task_id: str, *, now: str | None = None) -> dict:
115
127
  _read_json(task_manifest_path(home, manager_id, task_group, task_id))
128
+ snapshot_path = snapshots_json_path(home, manager_id, task_group, task_id)
129
+ before = _previous_buckets(snapshot_path)
116
130
  children = _read_json_default(children_json_path(home, manager_id, task_group, task_id), {"children": []})
117
131
  projects = _project_map(home, manager_id)
118
132
  rows = []
@@ -135,7 +149,13 @@ def sync_task(home: Path, manager_id: str, task_group: str, task_id: str, *, now
135
149
  "syncedAt": now or _now_iso(),
136
150
  "children": rows,
137
151
  }
138
- _write_json(snapshots_json_path(home, manager_id, task_group, task_id), payload)
152
+ _write_json(snapshot_path, payload)
153
+ transitions = _bucket_transitions(before, rows)
154
+ if transitions:
155
+ record_event(
156
+ events_jsonl_path(home, manager_id, task_group, task_id),
157
+ {"event": "task-synced", "createdAt": payload["syncedAt"], "transitions": transitions},
158
+ )
139
159
  return payload
140
160
 
141
161
 
@@ -183,7 +203,7 @@ def _manifest_changed_since(project: dict | None, task_key: str, synced: int | N
183
203
  root = Path(str(project.get("projectRoot") or ""))
184
204
  if not root.is_dir():
185
205
  return False
186
- task_dir = _resolve_task_root_read_only(root, task_key)
206
+ task_dir = resolve_task_root_read_only(root, task_key)
187
207
  manifest_path = task_dir / TASK_MANIFEST_FILENAME if task_dir is not None else None
188
208
  if manifest_path is None or not manifest_path.is_file():
189
209
  return False
@@ -1,7 +1,7 @@
1
1
  """manager 상태를 한 장짜리 HTML 로 그린다.
2
2
 
3
3
  manager 가 이미 저장한 파일(projects / task manifest / children / snapshots /
4
- directives / events)만 읽는다. 하위 프로젝트는 읽지 않는다 — 최신 상태가 필요하면
4
+ directives / events / journal)만 읽는다. 하위 프로젝트는 읽지 않는다 — 최신 상태가 필요하면
5
5
  먼저 `okstra manager task sync` 를 돌리고, 페이지는 각 task 의 마지막 sync 시각을
6
6
  보여 준다.
7
7
  """
@@ -15,6 +15,7 @@ from pathlib import Path
15
15
 
16
16
  from okstra_ctl.jsonl import read_jsonl
17
17
 
18
+ from .manager_log import MANAGER_EVENT, merge_activity
18
19
  from .manager_paths import directives_jsonl_path, events_jsonl_path, view_html_path
19
20
  from .manager_store import ManagerError, list_projects, list_tasks, load_manager
20
21
  from .manager_sync import status_task
@@ -192,17 +193,48 @@ def _directive_list(directives: list[dict]) -> str:
192
193
  return f'<ul class="plain">{items}</ul>'
193
194
 
194
195
 
196
+ def _event_detail(row: dict) -> str:
197
+ if row.get("event") == "task-synced":
198
+ return f" · child tasks changed: {len(row.get('transitions') or [])}"
199
+ if row.get("event") == "task-assigned":
200
+ return " · changed: " + _e(", ".join(sorted(row.get("changes") or {})))
201
+ return ""
202
+
203
+
195
204
  def _event_list(events: list[dict]) -> str:
196
205
  if not events:
197
206
  return '<p class="empty">No events.</p>'
198
207
  items = "".join(
199
208
  f"<li><code>{_e(row.get('createdAt'))}</code> {_e(row.get('event'))}"
200
- f"{' · ' + _e(row.get('taskKey')) if row.get('taskKey') else ''}</li>"
209
+ f"{' · ' + _e(row.get('taskKey')) if row.get('taskKey') else ''}{_event_detail(row)}</li>"
201
210
  for row in events
202
211
  )
203
212
  return f'<ul class="plain">{items}</ul>'
204
213
 
205
214
 
215
+ def _followup_list(entries: list[dict]) -> str:
216
+ if not entries:
217
+ return '<p class="empty">No open follow-ups.</p>'
218
+ items = "".join(
219
+ f"<li><code>{_e(entry['createdAt'])}</code> {_e(entry['row'].get('body'))}"
220
+ f"{' · ' + _e(entry['taskGroup'] + ' / ' + entry['taskId']) if entry['taskId'] else ''}"
221
+ f" <span class=\"meta\">{_e(entry['row'].get('id'))}</span></li>"
222
+ for entry in entries
223
+ )
224
+ return f'<ul class="plain">{items}</ul>'
225
+
226
+
227
+ def _activity_section(home: Path, manager_id: str) -> str:
228
+ """Open follow-ups oldest first, then manager-level events newest first."""
229
+ activity = merge_activity(home, manager_id)
230
+ followups = activity.open_followups_oldest_first()
231
+ events = [entry["row"] for entry in activity.entries if entry["origin"] == MANAGER_EVENT]
232
+ return (
233
+ f"<h3>Open follow-ups ({len(followups)})</h3>{_followup_list(followups)}"
234
+ f"<details><summary>Manager events ({len(events)})</summary>{_event_list(events)}</details>"
235
+ )
236
+
237
+
206
238
  def _task_panel(home: Path, manager_id: str, task: dict, status: dict, roots: dict[str, str]) -> str:
207
239
  group, task_id = task["taskGroup"], task["taskId"]
208
240
  synced_at = status["lastSnapshot"].get("syncedAt") or ""
@@ -265,6 +297,7 @@ def render_view(home: Path, manager_id: str, *, now: str | None = None) -> str:
265
297
  "TITLE": _e(f"Okstra manager · {manager.get('managerId') or manager_id}"),
266
298
  "META": meta,
267
299
  "SUMMARY": _summary_tiles(totals),
300
+ "ACTIVITY": _activity_section(home, manager_id),
268
301
  "PROJECTS": _projects_table(projects),
269
302
  "TASKS": "".join(panels) or '<p class="empty">No manager tasks.</p>',
270
303
  }
@@ -90,6 +90,8 @@ def direct_work_context(project_root: Path, task_key: str, related: list[str]) -
90
90
  f"- Summary: {' '.join(record['summary'].split())[:400]}",
91
91
  f"- Record: `{record_path}`", "",
92
92
  ])
93
+ if record.get("implementationTracePath"):
94
+ blocks.extend([f"- Implementation trace: `{record['implementationTracePath']}`", ""])
93
95
  if not blocks:
94
96
  return ""
95
97
  return "\n".join(["## Direct Work Context", "", *blocks])
@@ -66,26 +66,56 @@ def set_model_default(
66
66
  f"model {ref!r} cannot default role {canonical}: "
67
67
  f"{availability.reason}"
68
68
  )
69
- path = _config_path(scope, cwd)
70
- payload = _read_json(path)
71
- defaults = dict(payload.get("modelDefaults") or {})
72
- defaults[canonical] = list(refs)
73
- payload["modelDefaults"] = defaults
74
- _write_json_atomic(path, payload)
69
+ _update_config_section(scope, cwd, "modelDefaults", canonical, refs)
75
70
  return 0
76
71
 
77
72
 
78
73
  def unset_model_default(*, role: str, scope: str, cwd: Path) -> int:
79
- canonical = normalize_role(role)
80
- path = _config_path(scope, cwd)
81
- payload = _read_json(path)
82
- defaults = dict(payload.get("modelDefaults") or {})
83
- defaults.pop(canonical, None)
84
- payload["modelDefaults"] = defaults
85
- _write_json_atomic(path, payload)
74
+ _update_config_section(scope, cwd, "modelDefaults", normalize_role(role), None)
75
+ return 0
76
+
77
+
78
+ def set_operation_models(*, operation: str, refs: tuple[str, ...], scope: str, cwd: Path) -> int:
79
+ from .operation_invocation import operation_contract_root, resolve_operation_models
80
+
81
+ pool, _adapter = _pool_and_host("claude-code")
82
+ resolve_operation_models(operation, refs, contract_root=operation_contract_root(), pool=pool)
83
+ _update_config_section(scope, cwd, "operationModels", operation, refs)
84
+ return 0
85
+
86
+
87
+ def unset_operation_models(*, operation: str, scope: str, cwd: Path) -> int:
88
+ _update_config_section(scope, cwd, "operationModels", operation, None)
86
89
  return 0
87
90
 
88
91
 
92
+ def _update_config_section(
93
+ scope: str, cwd: Path, key: str, name: str, refs: tuple[str, ...] | None,
94
+ ) -> None:
95
+ """Set (`refs`) or remove (`None`) one entry of a model-list section.
96
+
97
+ The whole read-modify-write holds the config file's registry lock, so two
98
+ commands changing different entries cannot drop each other's change.
99
+ """
100
+ from okstra_project.dirs import json_lock_path, registry_lock
101
+
102
+ from .model_defaults import ModelDefaultError, parse_model_lists
103
+
104
+ path = _config_path(scope, cwd)
105
+ with registry_lock(json_lock_path(path)):
106
+ payload = _read_json(path)
107
+ try:
108
+ section = {entry: list(values) for entry, values in parse_model_lists(payload, key, path).items()}
109
+ except ModelDefaultError as exc:
110
+ raise ModelCliError(str(exc)) from exc
111
+ if refs is None:
112
+ section.pop(name, None)
113
+ else:
114
+ section[name] = list(refs)
115
+ payload[key] = section
116
+ _write_json_atomic(path, payload)
117
+
118
+
89
119
  def model_diagnostics(
90
120
  *,
91
121
  host_runtime: str = "claude-code",
@@ -238,10 +268,12 @@ _CLI_EPILOG = r"""Usage:
238
268
  okstra model list [--role <role>] [--host <host>] [--json]
239
269
  okstra model default set <role> <modelRef[,modelRef...]> --scope project|global [--cwd <dir>]
240
270
  okstra model default unset <role> --scope project|global [--cwd <dir>]
271
+ okstra model operation set <operation> <modelRef[,modelRef...]> --scope project|global [--cwd <dir>]
272
+ okstra model operation unset <operation> --scope project|global [--cwd <dir>]
241
273
 
242
274
  Listing and default writes never send an inference call.
243
275
  """
244
- _CLI_DESCRIPTION = "List catalog models and manage role defaults."
276
+ _CLI_DESCRIPTION = "List catalog models and manage role and operation model defaults."
245
277
 
246
278
 
247
279
  def main(argv: list[str] | None = None) -> int:
@@ -266,12 +298,30 @@ def main(argv: list[str] | None = None) -> int:
266
298
  unsetter.add_argument("role")
267
299
  unsetter.add_argument("--scope", choices=("project", "global"), required=True)
268
300
  unsetter.add_argument("--cwd", default=".")
301
+ operation = sub.add_parser("operation")
302
+ operation_sub = operation.add_subparsers(dest="operation_command", required=True)
303
+ operation_set = operation_sub.add_parser("set")
304
+ operation_set.add_argument("operation")
305
+ operation_set.add_argument("refs")
306
+ operation_set.add_argument("--scope", choices=("project", "global"), required=True)
307
+ operation_set.add_argument("--cwd", default=".")
308
+ operation_unset = operation_sub.add_parser("unset")
309
+ operation_unset.add_argument("operation")
310
+ operation_unset.add_argument("--scope", choices=("project", "global"), required=True)
311
+ operation_unset.add_argument("--cwd", default=".")
269
312
  args = parser.parse_args(argv)
270
313
  try:
271
314
  if args.command == "list":
272
315
  return list_models(
273
316
  role=args.role, host_runtime=args.host, as_json=args.json
274
317
  )
318
+ if args.command == "operation":
319
+ if args.operation_command == "set":
320
+ refs = tuple(part for part in args.refs.split(",") if part)
321
+ return set_operation_models(
322
+ operation=args.operation, refs=refs, scope=args.scope, cwd=Path(args.cwd)
323
+ )
324
+ return unset_operation_models(operation=args.operation, scope=args.scope, cwd=Path(args.cwd))
275
325
  if args.default_command == "set":
276
326
  refs = tuple(part for part in args.refs.split(",") if part)
277
327
  return set_model_default(
@@ -44,3 +44,25 @@ def default_scope(role: str, scopes: ModelDefaultScopes) -> str | None:
44
44
  if role in values:
45
45
  return scope_name
46
46
  return None
47
+
48
+
49
+ def parse_model_lists(payload: object, key: str, source: object) -> dict[str, tuple[str, ...]]:
50
+ """Read a config section mapping names to non-empty model-ref lists.
51
+
52
+ `modelDefaults` (role → refs) and `operationModels` (operation → refs)
53
+ share this shape; `source` names the file in error messages.
54
+ """
55
+ raw = payload.get(key, {}) if isinstance(payload, Mapping) else {}
56
+ if not isinstance(raw, Mapping):
57
+ raise ModelDefaultError(f"{key} must be an object: {source}")
58
+ lists: dict[str, tuple[str, ...]] = {}
59
+ for name, refs in raw.items():
60
+ if (
61
+ not isinstance(name, str)
62
+ or not isinstance(refs, list)
63
+ or not refs
64
+ or not all(isinstance(ref, str) and ref for ref in refs)
65
+ ):
66
+ raise ModelDefaultError(f"{key} entries must be non-empty string arrays: {source}")
67
+ lists[name] = tuple(refs)
68
+ return lists
@@ -6,7 +6,7 @@
6
6
  from __future__ import annotations
7
7
 
8
8
  from pathlib import Path
9
- from typing import Any, Mapping
9
+ from typing import Any, Mapping, Sequence
10
10
 
11
11
  from okstra_project import StateError, parse_task_key, slugify
12
12
 
@@ -20,8 +20,10 @@ from ..fixed_text import line as _line, scalar as _value, quoted_value_lines
20
20
  from ..json_boundary import JsonBoundaryError, load_owned_object
21
21
  from ..paths import find_asset_root, okstra_home
22
22
  from ..ports.verification_inputs import VerificationInputStore
23
+ from ..review_policy import render_review_policy, review_policy_context
23
24
  from ..phases.catalog import PhaseAssetError, profile_markdown
24
25
  from ..recap import assemble_group_recap, assemble_recap
26
+ from ..report_contract import report_authoring_format
25
27
  from ..role_requirements import RoleProfileError, load_role_profile
26
28
  from ..timeline_runs import current_run_facts
27
29
  from .lines import (
@@ -148,7 +150,8 @@ def render_project_context(project_root: Path, task_ref: str = "") -> str:
148
150
 
149
151
 
150
152
  def render_verification_input(
151
- run_manifest: Path, store: VerificationInputStore,
153
+ run_manifest: Path, store: VerificationInputStore, *, source_paths: Sequence[str] = (),
154
+ resources: Sequence[str] = (),
152
155
  ) -> str:
153
156
  reference, inputs = _load_verification_input(run_manifest, store)
154
157
  rows = [
@@ -162,6 +165,15 @@ def render_verification_input(
162
165
  "\n## QA Commands\n\n",
163
166
  *quoted_value_lines("QA commands", inputs["qaCommands"]),
164
167
  ]
168
+ if "reviewPolicy" in inputs:
169
+ project_paths, manifests = (review_policy_context(
170
+ Path(inputs["sourceRoot"]), "HEAD", source_paths,
171
+ ) if source_paths else ((), {}))
172
+ rows.append(render_review_policy(
173
+ inputs["reviewPolicy"], source_paths, project_paths=project_paths,
174
+ manifest_contents=manifests,
175
+ resources=resources,
176
+ ))
165
177
  rows.append("\n## QA Source Observations\n\n")
166
178
  if "qaSourceObservations" in inputs:
167
179
  rows.extend(quoted_value_lines(
@@ -203,6 +215,7 @@ def render_run_input(run_manifest: Path) -> str:
203
215
  + _line("Task type", run.get("taskType"))
204
216
  + _line("Run ID", run.get("runDateTimeSegment"))
205
217
  + _line("Work category", run.get("workCategory"))
218
+ + _line("Report authoring format", report_authoring_format(run))
206
219
  + _line("Lead runtime", run.get("leadRuntime"))
207
220
  + _line("Lead adapter name", adapter.get("name"))
208
221
  + _line("Lead dispatch mode", adapter.get("dispatchMode"))
@@ -218,6 +231,7 @@ def render_run_input(run_manifest: Path) -> str:
218
231
  + _worker_prompt_lines(run)
219
232
  + _line("Worker results directory", run.get("workerResultsDirectoryPath"))
220
233
  + _line("Expected report", run.get("expectedReportRecordPath"))
234
+ + _line("Report writer input", run.get("reportNarrativePath"))
221
235
  + _line("Expected status", run.get("expectedStatusPath"))
222
236
  + _line("Validator", run.get("validatorScriptPath"))
223
237
  + _line("Resume command", run.get("resumeCommandPath"))
@@ -32,7 +32,7 @@ from .model_io.renderers import (
32
32
  _CLI_EPILOG = r"""Usage:
33
33
  okstra model-io project-context --project-root <dir> [--task-ref <task-id|task-key|task-manifest-path>]
34
34
  okstra model-io run-input --run-manifest <path>
35
- okstra model-io verification-input --run-manifest <path>
35
+ okstra model-io verification-input --run-manifest <path> [--source-path <relative-file> ...] [--resource <pack-relative-resource> ...]
36
36
  okstra model-io active-context-input --project-root <dir> --run-manifest <path>
37
37
  okstra model-io schedule-input --project-root <dir> --task-group <id>
38
38
  okstra model-io code-review-input --project-root <dir> --base <ref> --head <ref>
@@ -57,6 +57,10 @@ def build_parser() -> argparse.ArgumentParser:
57
57
  run.add_argument("--run-manifest", required=True)
58
58
  verification = commands.add_parser("verification-input")
59
59
  verification.add_argument("--run-manifest", required=True)
60
+ verification.add_argument("--source-path", action="append", default=[],
61
+ help="load frozen rules applicable to this repository-relative source")
62
+ verification.add_argument("--resource", action="append", default=[],
63
+ help="load an additional captured pack-relative rule resource")
60
64
  active = commands.add_parser("active-context-input")
61
65
  active.add_argument("--project-root", required=True)
62
66
  active.add_argument("--run-manifest", required=True)
@@ -101,6 +105,8 @@ def main(argv: list[str] | None = None) -> int:
101
105
  elif args.command == "verification-input":
102
106
  text = render_verification_input(
103
107
  Path(args.run_manifest), default_verification_input_store(),
108
+ source_paths=args.source_path,
109
+ resources=args.resource,
104
110
  )
105
111
  elif args.command == "active-context-input":
106
112
  text = render_active_context_input(