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
@@ -0,0 +1,221 @@
1
+ """Merge manager activity files for `okstra manager log`."""
2
+ from __future__ import annotations
3
+
4
+ from collections.abc import Iterator
5
+ from dataclasses import dataclass
6
+ from datetime import datetime, timezone
7
+ from pathlib import Path
8
+ from typing import TypedDict
9
+
10
+ from .manager_journal import JOURNAL_ORIGIN, is_open_followup, open_followups_oldest_first, resolved_entry_ids
11
+ from .manager_paths import directives_jsonl_path, events_jsonl_path, journal_jsonl_path, manager_events_jsonl_path
12
+ from .manager_store import ManagerError, _read_json, _task_manifest_paths, load_manager, read_jsonl_rows, task_selection
13
+
14
+ DEFAULT_LIMIT = 50
15
+ MAX_LIMIT = 1000
16
+ MANAGER_EVENT = "manager-event"
17
+ TASK_EVENT = "task-event"
18
+ DIRECTIVE = "directive"
19
+ JOURNAL = JOURNAL_ORIGIN
20
+ _NO_TASK = ("", "")
21
+
22
+
23
+ class ActivityEntry(TypedDict):
24
+ origin: str
25
+ kind: str
26
+ createdAt: str
27
+ taskGroup: str
28
+ taskId: str
29
+ row: dict
30
+
31
+
32
+ def _since_floor(value: str) -> str:
33
+ try:
34
+ parsed = datetime.fromisoformat(value.strip().replace("Z", "+00:00"))
35
+ if parsed.tzinfo is None:
36
+ parsed = parsed.replace(tzinfo=timezone.utc)
37
+ return parsed.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
38
+ except (ValueError, OverflowError) as exc:
39
+ raise ManagerError(f"--since must be an ISO date or time: {value!r}") from exc
40
+
41
+
42
+ def _task_identities(home: Path, manager_id: str) -> list[tuple[str, str]]:
43
+ """Read (task group, task id) from manifests only, so other task files cannot stop the log."""
44
+ load_manager(home, manager_id)
45
+ identities = []
46
+ for path in _task_manifest_paths(home, manager_id):
47
+ manifest = _read_json(path)
48
+ identities.append((str(manifest.get("taskGroup") or ""), str(manifest.get("taskId") or "")))
49
+ return sorted(identities)
50
+
51
+
52
+ def _sources(home: Path, manager_id: str) -> list[tuple[str, Path, tuple[str, str]]]:
53
+ sources = [(MANAGER_EVENT, manager_events_jsonl_path(home, manager_id), _NO_TASK)]
54
+ for group, task_id in _task_identities(home, manager_id):
55
+ sources.append((TASK_EVENT, events_jsonl_path(home, manager_id, group, task_id), (group, task_id)))
56
+ sources.append((DIRECTIVE, directives_jsonl_path(home, manager_id, group, task_id), (group, task_id)))
57
+ sources.append((JOURNAL, journal_jsonl_path(home, manager_id), _NO_TASK))
58
+ return sources
59
+
60
+
61
+ def _matches_task(identity: tuple[str, str], row: dict, task: tuple[str, str] | None) -> bool:
62
+ """Whether a row belongs to the `--task-group` / `--task-id` selection.
63
+
64
+ Task files belong to their own task. Manager-level rows (manager events and journal
65
+ entries) belong to a task they name, which includes removals and unlinks recorded
66
+ after the task's own files are gone.
67
+ """
68
+ if task is None:
69
+ return True
70
+ if identity != _NO_TASK:
71
+ return identity == task
72
+ group, task_id = task
73
+ if (row.get("taskGroup"), row.get("taskId")) == task:
74
+ return True
75
+ event = row.get("event")
76
+ if event == "task-group-removed":
77
+ return row.get("taskGroup") == group and task_id in (row.get("taskIds") or [])
78
+ if event == "project-unlinked":
79
+ named = row.get("tasks") or []
80
+ return any(isinstance(item, dict) and (item.get("taskGroup"), item.get("taskId")) == task for item in named)
81
+ return False
82
+
83
+
84
+ def _reads_file(identity: tuple[str, str], task: tuple[str, str] | None) -> bool:
85
+ """Manager-level files are always read; a task's own files only for that task."""
86
+ return identity == _NO_TASK or _matches_task(identity, {}, task)
87
+
88
+
89
+ def _kind(origin: str, row: dict) -> str:
90
+ if origin == DIRECTIVE:
91
+ return DIRECTIVE
92
+ if origin == JOURNAL:
93
+ return str(row.get("kind") or "")
94
+ return str(row.get("event") or "")
95
+
96
+
97
+ def _entry(origin: str, identity: tuple[str, str], row: dict) -> ActivityEntry:
98
+ group, task_id = identity
99
+ return {
100
+ "origin": origin,
101
+ "kind": _kind(origin, row),
102
+ "createdAt": str(row.get("createdAt") or ""),
103
+ "taskGroup": group or str(row.get("taskGroup") or ""),
104
+ "taskId": task_id or str(row.get("taskId") or ""),
105
+ "row": row,
106
+ }
107
+
108
+
109
+ def _string_values(value: object) -> Iterator[str]:
110
+ if isinstance(value, str):
111
+ yield value
112
+ elif isinstance(value, dict):
113
+ for child in value.values():
114
+ yield from _string_values(child)
115
+ elif isinstance(value, list):
116
+ for child in value:
117
+ yield from _string_values(child)
118
+
119
+
120
+ def _search_text(entry: ActivityEntry) -> str:
121
+ if entry["origin"] in (DIRECTIVE, JOURNAL):
122
+ return str(entry["row"].get("body") or "")
123
+ return "\n".join(_string_values(entry["row"]))
124
+
125
+
126
+ def _matches_filters(entry: ActivityEntry, kind: str | None, since_utc: str, grep_casefolded: str) -> bool:
127
+ if kind is not None and entry["kind"] != kind:
128
+ return False
129
+ if since_utc and entry["createdAt"] < since_utc:
130
+ return False
131
+ return not grep_casefolded or grep_casefolded in _search_text(entry).casefold()
132
+
133
+
134
+ def _newest_first(entries: list[ActivityEntry]) -> list[ActivityEntry]:
135
+ """Sort by createdAt, newest first.
136
+
137
+ createdAt has one-second resolution. Entries with the same createdAt come in reverse
138
+ read order: a later line of one file comes first, and so does a file read later.
139
+ Files are read manager events first, then each task's events and directives in
140
+ (task group, task id) order, then the journal, so across files a tie does not follow
141
+ write order.
142
+ """
143
+ indexed = sorted(enumerate(entries), key=lambda item: (item[1]["createdAt"], item[0]), reverse=True)
144
+ return [entry for _, entry in indexed]
145
+
146
+
147
+ @dataclass(frozen=True)
148
+ class Activity:
149
+ entries: list[ActivityEntry]
150
+ damaged: list[dict]
151
+ resolved: set[str]
152
+
153
+ def open_followups_oldest_first(self) -> list[ActivityEntry]:
154
+ return open_followups_oldest_first(self.entries, self.resolved)
155
+
156
+
157
+ def merge_activity(
158
+ home: Path,
159
+ manager_id: str,
160
+ *,
161
+ task: tuple[str, str] | None = None,
162
+ kind: str | None = None,
163
+ since_utc: str = "",
164
+ grep_casefolded: str = "",
165
+ ) -> Activity:
166
+ """Every matching entry newest first, unpaged, with damaged lines per file and resolved journal ids.
167
+
168
+ `since_utc` must already be normalised by `_since_floor` and `grep_casefolded` must be
169
+ casefolded. `resolved` comes from the whole journal, whatever the filters keep.
170
+ """
171
+ entries: list[ActivityEntry] = []
172
+ damaged: list[dict] = []
173
+ resolved: set[str] = set()
174
+ for origin, path, identity in _sources(home, manager_id):
175
+ if not _reads_file(identity, task):
176
+ continue
177
+ rows, invalid_lines = read_jsonl_rows(path)
178
+ if invalid_lines:
179
+ damaged.append({"path": str(path), "lines": invalid_lines})
180
+ if origin == JOURNAL:
181
+ resolved = resolved_entry_ids(rows)
182
+ for row in rows:
183
+ entry = _entry(origin, identity, row)
184
+ if _matches_task(identity, row, task) and _matches_filters(entry, kind, since_utc, grep_casefolded):
185
+ entries.append(entry)
186
+ return Activity(_newest_first(entries), damaged, resolved)
187
+
188
+
189
+ def read_activity_page(
190
+ home: Path,
191
+ manager_id: str,
192
+ *,
193
+ task_group: str | None = None,
194
+ task_id: str | None = None,
195
+ kind: str | None = None,
196
+ since: str | None = None,
197
+ grep: str | None = None,
198
+ open_followups: bool = False,
199
+ limit: int = DEFAULT_LIMIT,
200
+ ) -> dict:
201
+ """One page (`limit` entries) of manager events, task events, directives and journal entries, newest first.
202
+
203
+ `open_followups` keeps only followup journal entries that no journal row resolves.
204
+
205
+ Each entry names the file it came from as `origin` and keeps the stored JSONL
206
+ object under `row`; stored directive and task-split rows have their own `source`.
207
+ """
208
+ task = task_selection(task_group, task_id)
209
+ check_limit(limit, "--limit")
210
+ activity = merge_activity(home, manager_id, task=task, kind=kind,
211
+ since_utc=_since_floor(since) if since else "", grep_casefolded=(grep or "").casefold())
212
+ entries = activity.entries
213
+ if open_followups:
214
+ entries = [entry for entry in entries if is_open_followup(entry, activity.resolved)]
215
+ return {"managerId": manager_id, "matchedCount": len(entries), "entries": entries[:limit],
216
+ "damaged": activity.damaged}
217
+
218
+
219
+ def check_limit(value: int, flag: str) -> None:
220
+ if not 1 <= value <= MAX_LIMIT:
221
+ raise ManagerError(f"{flag} must be between 1 and {MAX_LIMIT}")
@@ -79,6 +79,14 @@ def projects_json_path(home: Path, manager_id: str) -> Path:
79
79
  return manager_root(home, manager_id) / "projects.json"
80
80
 
81
81
 
82
+ def manager_events_jsonl_path(home: Path, manager_id: str) -> Path:
83
+ return manager_root(home, manager_id) / "events.jsonl"
84
+
85
+
86
+ def journal_jsonl_path(home: Path, manager_id: str) -> Path:
87
+ return manager_root(home, manager_id) / "journal.jsonl"
88
+
89
+
82
90
  def task_manifest_path(home: Path, manager_id: str, task_group: str, task_id: str) -> Path:
83
91
  return task_root(home, manager_id, task_group, task_id) / "manifest.json"
84
92
 
@@ -0,0 +1,29 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ from .manager_paths import canonical_manager_id
9
+
10
+ REGISTRATION_TIMEOUT_SECONDS = 5
11
+
12
+
13
+ def register_manager_source(home: Path, manager_id: str) -> bool:
14
+ from .doyouknow.config import load_config
15
+ from .doyouknow.pending import enqueue_source
16
+ from .doyouknow.source_contracts import SourceRef
17
+
18
+ settings = load_config(home=home)
19
+ if not settings["autoRegister"] or "manager" not in settings["sources"]:
20
+ return True
21
+ ref = SourceRef("manager", canonical_manager_id(manager_id), "$manager")
22
+ ticket = enqueue_source(ref, home=home)
23
+ result = subprocess.run(
24
+ [sys.executable, "-m", "okstra_ctl.doyouknow.cli", "register", "--ticket", ticket, "--json"],
25
+ env={**os.environ, "OKSTRA_HOME": str(home.expanduser().resolve())},
26
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
27
+ timeout=REGISTRATION_TIMEOUT_SECONDS, check=False,
28
+ )
29
+ return result.returncode == 0
@@ -0,0 +1,59 @@
1
+ """Session start summary for `okstra manager resume`."""
2
+ from __future__ import annotations
3
+
4
+ from pathlib import Path
5
+
6
+ from .manager_journal import DECISION, SESSION_SUMMARY, is_journal_kind
7
+ from .manager_log import ActivityEntry, _task_identities, check_limit, merge_activity
8
+ from .manager_store import ManagerError
9
+ from .manager_sync import status_task
10
+
11
+ DEFAULT_RECENT = 10
12
+ RECENT_DECISION_COUNT = 5
13
+
14
+
15
+ def _last_summary_index(entries: list[ActivityEntry]) -> int | None:
16
+ return next((index for index, entry in enumerate(entries) if is_journal_kind(entry, SESSION_SUMMARY)), None)
17
+
18
+
19
+ def _task_overview(home: Path, manager_id: str, task_group: str, task_id: str, now: str | None) -> dict:
20
+ """One task's sync state, or its `error` when its files cannot be read, so other tasks still report."""
21
+ try:
22
+ status = status_task(home, manager_id, task_group, task_id, now=now)
23
+ except ManagerError as exc:
24
+ return {"taskGroup": task_group, "taskId": task_id, "error": str(exc)}
25
+ overview = {
26
+ "taskGroup": task_group,
27
+ "taskId": task_id,
28
+ "syncedAt": status["syncedAt"],
29
+ "changedSinceSyncCount": status["changedSinceSyncCount"],
30
+ "unlinkedChildCount": sum(1 for child in status["children"] if not child["projectLinked"]),
31
+ }
32
+ if "syncAgeSeconds" in status:
33
+ overview["syncAgeSeconds"] = status["syncAgeSeconds"]
34
+ return overview
35
+
36
+
37
+ def resume_manager(home: Path, manager_id: str, *, recent: int = DEFAULT_RECENT, now: str | None = None) -> dict:
38
+ """What the previous sessions left: last summary, activity after it, open follow-ups and task status.
39
+
40
+ `unsummarizedCount` counts the entries listed before the last session summary in
41
+ the newest-first order of `log`, so it follows the same tie rule.
42
+ """
43
+ check_limit(recent, "--recent")
44
+ activity = merge_activity(home, manager_id)
45
+ entries = activity.entries
46
+ summary_index = _last_summary_index(entries)
47
+ summary = entries[summary_index] if summary_index is not None else None
48
+ return {
49
+ "managerId": manager_id,
50
+ "lastSummary": summary,
51
+ "unsummarizedCount": summary_index if summary_index is not None else len(entries),
52
+ "unsummarizedSince": summary["createdAt"] if summary is not None else "",
53
+ "openFollowups": activity.open_followups_oldest_first(),
54
+ "recentDecisions": [entry for entry in entries if is_journal_kind(entry, DECISION)][:RECENT_DECISION_COUNT],
55
+ "recentEntries": entries[:recent],
56
+ "tasks": [_task_overview(home, manager_id, group, task_id, now)
57
+ for group, task_id in _task_identities(home, manager_id)],
58
+ "damaged": activity.damaged,
59
+ }
@@ -19,7 +19,6 @@ from types import ModuleType
19
19
  from typing import Any, TypedDict
20
20
 
21
21
  from okstra_ctl.json_boundary import JsonBoundaryError, load_owned_object
22
- from okstra_ctl.jsonl import append_jsonl
23
22
 
24
23
  from .analysis_packet import _fence_mask, project_relative_ref
25
24
  from .brief_sources import (
@@ -35,6 +34,7 @@ from .manager_store import (
35
34
  _read_json,
36
35
  _write_json,
37
36
  create_task,
37
+ record_event,
38
38
  list_projects,
39
39
  load_manager,
40
40
  )
@@ -746,7 +746,7 @@ def split_task(
746
746
  _write_json(split_plan_path(home, manager_id, task_group, task_id), plan)
747
747
  briefs = [{"taskKey": item["taskKey"], "projectId": item["projectId"], "ticketId": item["issue"]["ticketId"],
748
748
  "briefPath": str(item["briefPath"]), "briefStatus": item["briefStatus"]} for item in items]
749
- append_jsonl(events_jsonl_path(home, manager_id, task_group, task_id),
749
+ record_event(events_jsonl_path(home, manager_id, task_group, task_id),
750
750
  {"event": "task-split", "createdAt": when, "source": source["ref"],
751
751
  "taskKeys": [brief["taskKey"] for brief in briefs]})
752
752
  return {"managerId": manager_id, "taskGroup": task_group, "taskId": task_id, "briefs": briefs}
@@ -4,12 +4,13 @@ from __future__ import annotations
4
4
  import json
5
5
  import os
6
6
  import shutil
7
+ import sys
7
8
  from datetime import datetime, timezone
8
9
  from pathlib import Path
9
10
 
10
11
  from okstra_project import project_json_path, upsert_project_json
11
12
 
12
- from okstra_ctl.jsonl import append_jsonl
13
+ from okstra_ctl.jsonl import append_jsonl, parse_jsonl_snapshot
13
14
  from okstra_ctl.json_boundary import (
14
15
  JsonBoundaryError,
15
16
  load_owned_object,
@@ -23,6 +24,7 @@ from .manager_paths import (
23
24
  children_json_path,
24
25
  directives_jsonl_path,
25
26
  events_jsonl_path,
27
+ manager_events_jsonl_path,
26
28
  manager_json_path,
27
29
  manager_root,
28
30
  projects_json_path,
@@ -46,6 +48,28 @@ def _write_json(path: Path, payload: dict) -> None:
46
48
  write_owned_object_atomic(path, payload, artifact="manager state")
47
49
 
48
50
 
51
+ def record_event(path: Path, row: dict) -> None:
52
+ """Append one activity row after the state change it describes has been saved.
53
+
54
+ An `OSError` is not raised: it becomes one stderr warning and the caller continues,
55
+ so a failed append never turns a saved state change into a failed command.
56
+ """
57
+ try:
58
+ append_jsonl(path, row)
59
+ except OSError as exc:
60
+ # The state change already succeeded. Reporting failure would make the user repeat it.
61
+ print(f"okstra manager: activity log write failed: {path}: {exc.strerror or exc}", file=sys.stderr)
62
+
63
+
64
+ def _field_changes(current: dict, requested: dict) -> dict:
65
+ """`{field: {"from", "to"}}` for each requested value that differs from the current one."""
66
+ return {
67
+ key: {"from": current.get(key), "to": value}
68
+ for key, value in requested.items()
69
+ if current.get(key) != value
70
+ }
71
+
72
+
49
73
  def _read_json(path: Path) -> dict:
50
74
  if not path.is_file():
51
75
  raise ManagerError(f"manager file not found: {path}")
@@ -58,6 +82,28 @@ def _read_json(path: Path) -> dict:
58
82
  return data
59
83
 
60
84
 
85
+ def read_jsonl_rows(path: Path) -> tuple[list[dict], list[int]]:
86
+ """Parsed rows and the line numbers of damaged lines; a missing file has neither."""
87
+ if not path.is_file():
88
+ return [], []
89
+ try:
90
+ text = path.read_text(encoding="utf-8")
91
+ except (OSError, UnicodeDecodeError) as exc:
92
+ raise ManagerError(f"failed to read {path}: {exc}") from exc
93
+ return parse_jsonl_snapshot(text)
94
+
95
+
96
+ def task_selection(task_group: str | None, task_id: str | None) -> tuple[str, str] | None:
97
+ """`--task-group` / `--task-id` as one pair, or None when neither is given."""
98
+ if (task_group is None) != (task_id is None):
99
+ raise ManagerError("--task-group and --task-id must be given together")
100
+ if task_group is None or task_id is None:
101
+ return None
102
+ if not task_group.strip() or not task_id.strip():
103
+ raise ManagerError("--task-group and --task-id must not be empty")
104
+ return task_group, task_id
105
+
106
+
61
107
  def _read_json_default(path: Path, default: dict) -> dict:
62
108
  if not path.is_file():
63
109
  return default
@@ -91,6 +137,10 @@ def init_manager(home: Path, manager_id: str, *, now: str | None = None) -> dict
91
137
  }
92
138
  root.mkdir(parents=True, exist_ok=True)
93
139
  _write_json(path, payload)
140
+ record_event(
141
+ manager_events_jsonl_path(home, canonical_id),
142
+ {"event": "manager-initialized", "createdAt": payload["createdAt"]},
143
+ )
94
144
  return payload
95
145
 
96
146
 
@@ -214,29 +264,49 @@ def link_project(
214
264
  raise ManagerError(str(exc)) from exc
215
265
  payload = _load_projects(home, manager_id)
216
266
  entry = _project_entry(payload, project_id)
267
+ when = now or _now_iso()
217
268
  next_entry = {
218
269
  "projectId": project_id,
219
270
  "projectRoot": str(root),
220
271
  "role": role,
221
272
  "tags": list(tags),
222
- "linkedAt": now or _now_iso(),
273
+ "linkedAt": when,
223
274
  }
275
+ changes = {}
224
276
  if entry is None:
225
277
  payload["projects"].append(next_entry)
226
278
  else:
279
+ changes = _field_changes(entry, {key: next_entry[key] for key in ("projectRoot", "role", "tags")})
227
280
  entry.update(next_entry)
228
281
  payload["projects"].sort(key=lambda item: item.get("projectId", ""))
229
282
  _write_json(projects_json_path(home, manager_id), payload)
283
+ if entry is None or changes:
284
+ record_event(manager_events_jsonl_path(home, manager_id), _project_linked_event(next_entry, changes))
230
285
  return payload
231
286
 
232
287
 
288
+ def _project_linked_event(linked: dict, changes: dict) -> dict:
289
+ row = {"event": "project-linked", "createdAt": linked["linkedAt"]}
290
+ row.update({key: linked[key] for key in ("projectId", "projectRoot", "role", "tags")})
291
+ if changes:
292
+ row["changes"] = changes
293
+ return row
294
+
295
+
233
296
  def _ensure_group_meta(home: Path, manager_id: str, task_group: str, when: str) -> dict:
234
297
  """그룹 폴더와 `group.json` 을 만든다. 이미 있으면 처음 기록을 그대로 둔다."""
235
298
  path = task_group_meta_path(home, manager_id, task_group)
236
299
  if path.is_file():
237
300
  return _read_json(path)
301
+ # A group directory without group.json predates group.json, so the group is not new.
302
+ group_is_new = not path.parent.is_dir()
238
303
  meta = {"taskGroup": task_group, "createdAt": when}
239
304
  _write_json(path, meta)
305
+ if group_is_new:
306
+ record_event(
307
+ manager_events_jsonl_path(home, manager_id),
308
+ {"event": "task-group-created", "createdAt": when, "taskGroup": task_group},
309
+ )
240
310
  return meta
241
311
 
242
312
 
@@ -331,7 +401,7 @@ def create_task(
331
401
  _ensure_group_meta(home, manager_id, task_group, when)
332
402
  _write_json(manifest_path, manifest)
333
403
  _write_json(children_json_path(home, manager_id, task_group, task_id), children)
334
- append_jsonl(
404
+ record_event(
335
405
  events_jsonl_path(home, manager_id, task_group, task_id),
336
406
  {
337
407
  "event": "task-children-added" if existing else "task-created",
@@ -398,14 +468,21 @@ def assign_child(
398
468
  tags: list[str],
399
469
  assignment: str,
400
470
  child_task_id: str | None = None,
471
+ now: str | None = None,
401
472
  ) -> dict:
402
473
  _read_json(task_manifest_path(home, manager_id, task_group, task_id))
403
474
  payload = _load_children(home, manager_id, task_group, task_id)
404
475
  child = _select_child_for_assignment(payload["children"], project_id, task_group, child_task_id)
405
- child["role"] = role
406
- child["tags"] = list(tags)
407
- child["assignment"] = assignment
476
+ requested = {"role": role, "tags": list(tags), "assignment": assignment}
477
+ changes = _field_changes(child, requested)
478
+ child.update(requested)
408
479
  _write_json(children_json_path(home, manager_id, task_group, task_id), payload)
480
+ if changes:
481
+ record_event(
482
+ events_jsonl_path(home, manager_id, task_group, task_id),
483
+ {"event": "task-assigned", "createdAt": now or _now_iso(),
484
+ "taskKey": str(child.get("taskKey") or ""), "changes": changes},
485
+ )
409
486
  return payload
410
487
 
411
488
 
@@ -510,10 +587,18 @@ def unlink_project(
510
587
  _write_json(projects_json_path(home, manager_id), payload)
511
588
  when = now or _now_iso()
512
589
  for manifest, keys in affected:
513
- append_jsonl(
590
+ record_event(
514
591
  events_jsonl_path(home, manager_id, str(manifest["taskGroup"]), str(manifest["taskId"])),
515
592
  {"event": "project-unlinked", "createdAt": when, "projectId": project_id, "taskKeys": keys},
516
593
  )
594
+ # Task-level rows disappear with `remove task`; this copy keeps the unlink visible afterwards.
595
+ record_event(
596
+ manager_events_jsonl_path(home, manager_id),
597
+ {"event": "project-unlinked", "createdAt": when, "projectId": project_id,
598
+ "taskKeys": result["keptChildren"],
599
+ "tasks": [{"taskGroup": str(manifest["taskGroup"]), "taskId": str(manifest["taskId"])}
600
+ for manifest, _ in affected]},
601
+ )
517
602
  return result
518
603
 
519
604
 
@@ -550,7 +635,7 @@ def remove_child(
550
635
  child_context_path(
551
636
  home, manager_id, task_group, task_id, project_id, str(child.get("taskId") or task_id)
552
637
  ).unlink(missing_ok=True)
553
- append_jsonl(
638
+ record_event(
554
639
  events_jsonl_path(home, manager_id, task_group, task_id),
555
640
  {"event": "task-child-removed", "createdAt": now or _now_iso(), "taskKey": task_key},
556
641
  )
@@ -577,16 +662,12 @@ def update_task(
577
662
  raise ManagerError("task update needs at least one of --objective, --common-brief, --progress-mode")
578
663
  if requested.get("progressMode") not in (None, "manual", "auto"):
579
664
  raise ManagerError("progress-mode must be manual or auto")
580
- changes = {
581
- key: {"from": manifest.get(key), "to": value}
582
- for key, value in requested.items()
583
- if manifest.get(key) != value
584
- }
665
+ changes = _field_changes(manifest, requested)
585
666
  for key, change in changes.items():
586
667
  manifest[key] = change["to"]
587
668
  if changes:
588
669
  _write_json(manifest_path, manifest)
589
- append_jsonl(
670
+ record_event(
590
671
  events_jsonl_path(home, manager_id, task_group, task_id),
591
672
  {"event": "task-updated", "createdAt": now or _now_iso(), "changes": changes},
592
673
  )
@@ -594,7 +675,7 @@ def update_task(
594
675
 
595
676
 
596
677
  def remove_task(
597
- home: Path, manager_id: str, task_group: str, task_id: str, *, confirm: bool
678
+ home: Path, manager_id: str, task_group: str, task_id: str, *, confirm: bool, now: str | None = None
598
679
  ) -> dict:
599
680
  """manager task 폴더를 지운다. 하위 프로젝트의 태스크와 브리프는 남는다."""
600
681
  manifest = _read_json(task_manifest_path(home, manager_id, task_group, task_id))
@@ -610,16 +691,29 @@ def remove_task(
610
691
  }
611
692
  if confirm:
612
693
  shutil.rmtree(root)
694
+ record_event(
695
+ manager_events_jsonl_path(home, manager_id),
696
+ {"event": "task-removed", "createdAt": now or _now_iso(), "taskGroup": result["taskGroup"],
697
+ "taskId": result["taskId"],
698
+ "taskKeys": [str(child.get("taskKey") or "") for child in children if isinstance(child, dict)]},
699
+ )
613
700
  return result
614
701
 
615
702
 
616
- def remove_task_group(home: Path, manager_id: str, task_group: str, *, confirm: bool) -> dict:
703
+ def remove_task_group(
704
+ home: Path, manager_id: str, task_group: str, *, confirm: bool, now: str | None = None
705
+ ) -> dict:
617
706
  """그룹 폴더와 그 안의 manager task 전부를 지운다."""
618
707
  load_manager(home, manager_id)
619
708
  root = task_group_root(home, manager_id, task_group)
620
709
  if not root.is_dir():
621
710
  raise ManagerError(f"unknown task group: {task_group}")
622
- task_ids = [str(_read_json(path).get("taskId") or path.parent.name) for path in sorted(root.glob("*/manifest.json"))]
711
+ manifests = [(path, _read_json(path)) for path in sorted(root.glob("*/manifest.json"))]
712
+ task_ids = [str(manifest.get("taskId") or path.parent.name) for path, manifest in manifests]
713
+ meta_path = root / "group.json"
714
+ stored_name = str(_read_json(meta_path).get("taskGroup") or "") if meta_path.is_file() else ""
715
+ if not stored_name and manifests:
716
+ stored_name = str(manifests[0][1].get("taskGroup") or "")
623
717
  result = {
624
718
  "managerId": manager_id,
625
719
  "taskGroup": task_group,
@@ -629,4 +723,9 @@ def remove_task_group(home: Path, manager_id: str, task_group: str, *, confirm:
629
723
  }
630
724
  if confirm:
631
725
  shutil.rmtree(root)
726
+ record_event(
727
+ manager_events_jsonl_path(home, manager_id),
728
+ {"event": "task-group-removed", "createdAt": now or _now_iso(),
729
+ "taskGroup": stored_name or task_group, "taskIds": task_ids},
730
+ )
632
731
  return result