@yemi33/minions 0.1.2448 → 0.1.2449

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 (315) hide show
  1. package/bin/cli-api-client.js +1 -1
  2. package/bin/install-internal-minions.js +1382 -44
  3. package/bin/install-layout.js +150 -0
  4. package/bin/minions.js +460 -167
  5. package/dashboard/docs/typography.md +65 -12
  6. package/dashboard/js/command-center.js +58 -4
  7. package/dashboard/js/detail-panel.js +36 -0
  8. package/dashboard/js/memory-panel.js +59 -12
  9. package/dashboard/js/qa.js +179 -20
  10. package/dashboard/js/refresh.js +148 -12
  11. package/dashboard/js/render-dispatch.js +3 -4
  12. package/dashboard/js/render-inbox.js +2 -2
  13. package/dashboard/js/render-other.js +3 -3
  14. package/dashboard/js/render-pipelines.js +14 -0
  15. package/dashboard/js/render-plans.js +57 -9
  16. package/dashboard/js/render-prd.js +132 -23
  17. package/dashboard/js/render-prs.js +195 -166
  18. package/dashboard/js/render-schedules.js +63 -3
  19. package/dashboard/js/render-utils.js +3 -3
  20. package/dashboard/js/render-watches.js +19 -3
  21. package/dashboard/js/render-work-items.js +238 -30
  22. package/dashboard/js/settings.js +205 -54
  23. package/dashboard/js/utils.js +51 -1
  24. package/dashboard/pages/home.html +1 -1
  25. package/dashboard/pages/qa.html +1 -16
  26. package/dashboard/pages/work.html +40 -0
  27. package/dashboard/shared/cc-limits.js +79 -0
  28. package/dashboard/shared/pr-filters.js +21 -38
  29. package/dashboard/shared/project-git-summary.js +1 -1
  30. package/dashboard/shared/record-filters.js +169 -0
  31. package/dashboard/shared/watches-source.js +1 -1
  32. package/dashboard/shared/welcome-popup.js +1 -1
  33. package/dashboard/shared/wi-filters.js +302 -0
  34. package/dashboard/slim/body.html +1 -0
  35. package/dashboard/slim/js/command-send.js +26 -0
  36. package/dashboard/slim/js/modals-tiles.js +380 -39
  37. package/dashboard/slim/js/status.js +13 -21
  38. package/dashboard/slim/layout.html +1 -0
  39. package/dashboard/slim/panel-bootstrap.js +6 -2
  40. package/dashboard/slim/styles.css +38 -0
  41. package/dashboard/styles.css +159 -55
  42. package/dashboard-build.js +13 -2
  43. package/dashboard.js +956 -423
  44. package/docs/README.md +11 -6
  45. package/docs/api-errors.md +2 -2
  46. package/docs/architecture-review-2026-07-09.md +1 -1
  47. package/docs/architecture.excalidraw +2 -2
  48. package/docs/auto-discovery.md +18 -9
  49. package/docs/branch-derivation.md +4 -4
  50. package/docs/capture-demos.js +39 -2
  51. package/docs/ci-runner-canary.md +123 -0
  52. package/docs/claude-md-propagation.md +2 -2
  53. package/docs/cloud-agent-dispatch.md +204 -0
  54. package/docs/command-center.md +7 -7
  55. package/docs/completion-reports.md +43 -20
  56. package/docs/constants.md +10 -3
  57. package/docs/constellation-bridge.md +134 -6
  58. package/docs/constellation-style-telemetry.md +4 -4
  59. package/docs/contracts/capability-protocol.v1.json +165 -0
  60. package/docs/cooldown-merge-semantics.md +12 -12
  61. package/docs/copilot-cli-schema.md +7 -7
  62. package/docs/cross-repo-plans.md +10 -10
  63. package/docs/dead-code-audit-retractions.md +5 -5
  64. package/docs/default-branch-ci.md +173 -0
  65. package/docs/deprecated.json +31 -31
  66. package/docs/design-inbox-entries-schema.md +3 -3
  67. package/docs/design-language.md +1051 -0
  68. package/docs/design-state-storage.md +11 -11
  69. package/docs/diagnostics-crash-reports.md +9 -9
  70. package/docs/diagnostics-memory.md +5 -5
  71. package/docs/documentation-audit-2026-07-09.md +7 -7
  72. package/docs/engine-restart.md +90 -5
  73. package/docs/harness-mode.md +1 -1
  74. package/docs/internal-install.md +338 -39
  75. package/docs/kb-dedup-duplicate-pair-investigation.md +5 -5
  76. package/docs/kb-pr3223-cascade-archiving.md +1 -1
  77. package/docs/kb-pr696-merge-conflict-docs.md +6 -6
  78. package/docs/kb-sweep.md +35 -35
  79. package/docs/keep-processes.md +1 -1
  80. package/docs/live-checkout-mode.md +30 -30
  81. package/docs/managed-spawn.md +18 -14
  82. package/docs/named-agents.md +7 -7
  83. package/docs/plan-lifecycle.md +69 -2
  84. package/docs/pr-author-identity.md +114 -0
  85. package/docs/pr-auto-fix-dispatch.md +19 -4
  86. package/docs/pr-comment-followup.md +6 -6
  87. package/docs/pr-review-fix-loop.md +59 -10
  88. package/docs/process-termination.md +40 -0
  89. package/docs/proposals/repo-pool-for-live-checkout.md +13 -13
  90. package/docs/qa-runbook-lifecycle.md +367 -17
  91. package/docs/qa-runbooks.md +3 -3
  92. package/docs/rfc-completion-json.md +18 -18
  93. package/docs/runtime-adapters.md +26 -21
  94. package/docs/security.md +6 -6
  95. package/docs/self-improvement.md +4 -4
  96. package/docs/shared-lifecycle-module-map.md +473 -472
  97. package/docs/skills.md +52 -3
  98. package/docs/slim-ux/concepts.md +121 -116
  99. package/docs/specs/agent-configurability.md +18 -18
  100. package/docs/specs/agent-rename.md +18 -18
  101. package/docs/team-memory.md +38 -21
  102. package/docs/timeouts-and-liveness.md +118 -10
  103. package/docs/tutorials/01-install-and-connect.md +1 -1
  104. package/docs/watches.md +40 -39
  105. package/docs/workspace-manifests.md +4 -4
  106. package/docs/worktree-lifecycle.md +293 -14
  107. package/engine/README.md +46 -0
  108. package/engine/{ado-comment.js → ado/comment.js} +8 -8
  109. package/engine/{ado-git-auth.js → ado/git-auth.js} +4 -4
  110. package/engine/{ado.js → ado/index.js} +417 -63
  111. package/engine/{ado-status.js → ado/status.js} +6 -8
  112. package/engine/{ado-token.js → ado/token.js} +1 -1
  113. package/engine/{acp-transport.js → agents/acp-transport.js} +62 -22
  114. package/engine/{agent-worker-pool.js → agents/agent-worker-pool.js} +17 -8
  115. package/engine/{cc-worker-pool.js → agents/cc-worker-pool.js} +16 -6
  116. package/engine/{claude-md-context.js → agents/claude-md-context.js} +5 -5
  117. package/engine/{harness-context.js → agents/harness-context.js} +5 -5
  118. package/engine/{harness.js → agents/harness.js} +3 -3
  119. package/engine/{llm.js → agents/llm.js} +18 -14
  120. package/engine/{model-discovery.js → agents/model-discovery.js} +2 -2
  121. package/engine/{playbook.js → agents/playbook.js} +155 -22
  122. package/engine/{pooled-agent-process.js → agents/pooled-agent-process.js} +14 -12
  123. package/engine/{preflight.js → agents/preflight.js} +29 -10
  124. package/engine/{spawn-agent.js → agents/spawn-agent.js} +25 -14
  125. package/engine/{spawn-phase-watchdog.js → agents/spawn-phase-watchdog.js} +16 -7
  126. package/engine/{steering.js → agents/steering.js} +5 -5
  127. package/engine/{tools-inventory.js → agents/tools-inventory.js} +2 -2
  128. package/engine/{agent-api-validation.js → api/agent-api-validation.js} +2 -2
  129. package/engine/{api-validation.js → api/api-validation.js} +1 -1
  130. package/engine/api/bridge.js +787 -0
  131. package/engine/{cc-api-validation.js → api/cc-api-validation.js} +1 -1
  132. package/engine/api/companion.js +560 -0
  133. package/engine/{content-api-validation.js → api/content-api-validation.js} +2 -2
  134. package/engine/{pr-issue-validation.js → api/pr-issue-validation.js} +33 -6
  135. package/engine/{settings-validation.js → api/settings-validation.js} +32 -4
  136. package/engine/api-contracts/agent-content.js +4 -4
  137. package/engine/api-contracts/capability-manifest.js +236 -0
  138. package/engine/api-contracts/capability-protocol.js +333 -0
  139. package/engine/api-contracts/cc-ops.js +1 -1
  140. package/engine/api-contracts/config-runtime.js +5 -0
  141. package/engine/api-contracts/core.js +28 -1
  142. package/engine/api-contracts/index.js +100 -0
  143. package/engine/api-contracts/orchestration.js +18 -5
  144. package/engine/api-contracts/pull-requests.js +37 -6
  145. package/engine/api-contracts/qa-process.js +29 -6
  146. package/engine/api-contracts/work-plan-prd.js +21 -1
  147. package/engine/cloud/contract.js +212 -0
  148. package/engine/cloud/index.js +159 -0
  149. package/engine/{execution-model.js → core/execution-model.js} +1 -1
  150. package/engine/{features.js → core/features.js} +4 -4
  151. package/engine/{operator-identity.js → core/operator-identity.js} +1 -1
  152. package/engine/{queries.js → core/queries.js} +201 -36
  153. package/engine/{safe-expr.js → core/safe-expr.js} +1 -1
  154. package/engine/{shared.js → core/shared.js} +1637 -175
  155. package/engine/{stdio-timestamps.js → core/stdio-timestamps.js} +1 -1
  156. package/engine/{untrusted-fence.js → core/untrusted-fence.js} +3 -3
  157. package/engine/db/index.js +11 -2
  158. package/engine/db/migrations/002-dispatches.js +3 -3
  159. package/engine/db/migrations/003-work-items.js +1 -1
  160. package/engine/db/migrations/004-pull-requests.js +1 -1
  161. package/engine/db/migrations/006-metrics.js +1 -1
  162. package/engine/db/migrations/007-watches.js +2 -2
  163. package/engine/db/migrations/008-small-state.js +1 -1
  164. package/engine/db/migrations/009-qa.js +1 -1
  165. package/engine/db/migrations/010-pr-links.js +1 -1
  166. package/engine/db/migrations/011-remaining-state.js +1 -1
  167. package/engine/db/migrations/012-steering-deliveries.js +2 -2
  168. package/engine/db/migrations/013-backfill-broken-note-links.js +1 -1
  169. package/engine/db/migrations/014-pr-fix-target-prefs.js +2 -2
  170. package/engine/db/migrations/015-plans-prds.js +0 -0
  171. package/engine/db/migrations/018-sql-only-cutover.js +2 -2
  172. package/engine/db/migrations/021-archived-work-items.js +1 -1
  173. package/engine/db/migrations/022-global-cc-session.js +1 -1
  174. package/engine/db/migrations/023-engine-state.js +1 -1
  175. package/engine/db/migrations/025-malformed-work-item-phantoms.js +1 -1
  176. package/engine/db/migrations/027-review-learning-lifecycle.js +1 -1
  177. package/engine/db/migrations/029-repair-reused-versions.js +20 -0
  178. package/engine/db/migrations/031-pr-author-identity.js +137 -0
  179. package/engine/{consolidation.js → memory/consolidation.js} +6 -6
  180. package/engine/{kb-sweep-runner.js → memory/kb-sweep-runner.js} +2 -2
  181. package/engine/{kb-sweep.js → memory/kb-sweep.js} +9 -7
  182. package/engine/{memory-retrieval.js → memory/memory-retrieval.js} +46 -4
  183. package/engine/{memory-store.js → memory/memory-store.js} +3 -3
  184. package/engine/{promotion.js → memory/promotion.js} +3 -3
  185. package/engine/{review-learning-backfill.js → memory/review-learning-backfill.js} +6 -6
  186. package/engine/{review-learning.js → memory/review-learning.js} +10 -5
  187. package/engine/{diagnostics-memory.js → observability/diagnostics-memory.js} +1 -1
  188. package/engine/{logs-store.js → observability/logs-store.js} +5 -5
  189. package/engine/{metrics-store.js → observability/metrics-store.js} +4 -4
  190. package/engine/{check-status.js → operations/check-status.js} +3 -3
  191. package/engine/{cli.js → operations/cli.js} +271 -113
  192. package/engine/{distribution.js → operations/distribution.js} +5 -6
  193. package/engine/{cleanup.js → orchestration/cleanup.js} +72 -45
  194. package/engine/{cooldown.js → orchestration/cooldown.js} +5 -5
  195. package/engine/{dispatch-events.js → orchestration/dispatch-events.js} +2 -2
  196. package/engine/{dispatch.js → orchestration/dispatch.js} +129 -36
  197. package/engine/orchestration/failed-scheduled-cleanup.js +274 -0
  198. package/engine/{lifecycle.js → orchestration/lifecycle.js} +198 -90
  199. package/engine/{meeting.js → orchestration/meeting.js} +6 -16
  200. package/engine/{pipeline.js → orchestration/pipeline.js} +12 -12
  201. package/engine/{pre-dispatch-eval.js → orchestration/pre-dispatch-eval.js} +10 -9
  202. package/engine/{routing.js → orchestration/routing.js} +3 -3
  203. package/engine/{schedule-bootstrap.js → orchestration/schedule-bootstrap.js} +4 -4
  204. package/engine/{scheduler.js → orchestration/scheduler.js} +38 -8
  205. package/engine/{timeout.js → orchestration/timeout.js} +158 -109
  206. package/engine/{db-events.js → persistence/db-events.js} +2 -2
  207. package/engine/{dispatch-store.js → persistence/dispatch-store.js} +7 -7
  208. package/engine/{inbox-store.js → persistence/inbox-store.js} +2 -2
  209. package/engine/{note-link-backfill.js → persistence/note-link-backfill.js} +4 -4
  210. package/engine/{pr-fix-target-store.js → persistence/pr-fix-target-store.js} +8 -8
  211. package/engine/{pull-requests-store.js → persistence/pull-requests-store.js} +21 -7
  212. package/engine/{small-state-store.js → persistence/small-state-store.js} +31 -31
  213. package/engine/persistence/state-operations.js +350 -0
  214. package/engine/{steering-store.js → persistence/steering-store.js} +6 -6
  215. package/engine/{issues.js → planning/issues.js} +2 -2
  216. package/engine/{plan-prd-validation.js → planning/plan-prd-validation.js} +8 -2
  217. package/engine/planning/prd-result-sidecar.js +190 -0
  218. package/engine/{prd-store.js → planning/prd-store.js} +17 -17
  219. package/engine/{project-discovery.js → planning/project-discovery.js} +5 -5
  220. package/engine/{projects.js → planning/projects.js} +10 -10
  221. package/engine/{resolve-area.js → planning/resolve-area.js} +1 -1
  222. package/engine/{work-item-validation.js → planning/work-item-validation.js} +39 -3
  223. package/engine/{work-items-store.js → planning/work-items-store.js} +29 -21
  224. package/engine/{keep-process-sweep.js → processes/keep-process-sweep.js} +57 -17
  225. package/engine/{managed-spawn-launcher.js → processes/managed-spawn-launcher.js} +3 -3
  226. package/engine/{managed-spawn.js → processes/managed-spawn.js} +97 -46
  227. package/engine/{process-utils.js → processes/process-utils.js} +599 -55
  228. package/engine/{abandoned-pr-reconciliation.js → providers/abandoned-pr-reconciliation.js} +17 -7
  229. package/engine/{comment-classifier.js → providers/comment-classifier.js} +85 -17
  230. package/engine/{comment-format.js → providers/comment-format.js} +5 -5
  231. package/engine/{gh-comment.js → providers/gh-comment.js} +15 -15
  232. package/engine/{gh-token.js → providers/gh-token.js} +4 -4
  233. package/engine/{github.js → providers/github.js} +131 -54
  234. package/engine/{pr-action.js → providers/pr-action.js} +13 -12
  235. package/engine/{pr-clone-keep.js → providers/pr-clone-keep.js} +7 -7
  236. package/engine/{pr-devbox.js → providers/pr-devbox.js} +6 -6
  237. package/engine/{pr-fix-target.js → providers/pr-fix-target.js} +13 -13
  238. package/engine/{pr-remote-patch.js → providers/pr-remote-patch.js} +4 -4
  239. package/engine/{pr-resolve.js → providers/pr-resolve.js} +7 -7
  240. package/engine/{pr-temp-clone.js → providers/pr-temp-clone.js} +5 -5
  241. package/engine/{pr-track.js → providers/pr-track.js} +11 -13
  242. package/engine/{shared-branch-pr-reconcile.js → providers/shared-branch-pr-reconcile.js} +4 -4
  243. package/engine/qa/auto-prd-qa.js +313 -0
  244. package/engine/{qa-from-prd.js → qa/from-prd.js} +42 -12
  245. package/engine/qa/prd-session.js +240 -0
  246. package/engine/{qa-process-validation.js → qa/process-validation.js} +14 -9
  247. package/engine/{qa-runbooks.js → qa/runbooks.js} +1 -1
  248. package/engine/{qa-runs.js → qa/runs.js} +286 -15
  249. package/engine/{qa-sessions.js → qa/sessions.js} +595 -49
  250. package/engine/qa/visual-journey.js +654 -0
  251. package/engine/{qa-runners.js → qa-runners/index.js} +7 -7
  252. package/engine/qa-runners/maestro.js +3 -3
  253. package/engine/qa-runners/playwright.js +2 -2
  254. package/engine/{restart-health.js → recovery/restart-health.js} +48 -4
  255. package/engine/recovery/stop-stack.js +607 -0
  256. package/engine/{supervisor.js → recovery/supervisor.js} +105 -175
  257. package/engine/{watchdog.js → recovery/watchdog.js} +136 -13
  258. package/engine/runtimes/claude.js +14 -12
  259. package/engine/runtimes/codex.js +8 -6
  260. package/engine/runtimes/copilot.js +17 -16
  261. package/engine/{watch-actions.js → watches/actions.js} +13 -13
  262. package/engine/{watches.js → watches/index.js} +43 -32
  263. package/engine/{watches-store.js → watches/store.js} +4 -4
  264. package/engine/{create-pr-worktree.js → worktrees/create-pr.js} +1 -1
  265. package/engine/{worktree-gc.js → worktrees/gc.js} +70 -22
  266. package/engine/worktrees/inventory.js +671 -0
  267. package/engine/{live-checkout.js → worktrees/live-checkout.js} +4 -4
  268. package/engine/{worktree-pool.js → worktrees/pool.js} +2 -2
  269. package/engine/{worktree-preflight.js → worktrees/preflight.js} +1 -0
  270. package/engine/worktrees/quarantine-refs.js +173 -0
  271. package/engine.js +1137 -208
  272. package/minions.js +147 -77
  273. package/package.json +10 -6
  274. package/playbooks/_pr-description-audit.md +110 -78
  275. package/playbooks/build-fix-complex.md +2 -0
  276. package/playbooks/fix.md +16 -12
  277. package/playbooks/implement-shared.md +2 -0
  278. package/playbooks/implement.md +19 -20
  279. package/playbooks/plan-to-prd.md +18 -3
  280. package/playbooks/qa-session-draft.md +136 -1
  281. package/playbooks/qa-session-execute.md +80 -2
  282. package/playbooks/qa-session-setup.md +17 -1
  283. package/playbooks/qa-validate.md +1 -1
  284. package/playbooks/setup.md +2 -0
  285. package/playbooks/shared-rules.md +25 -32
  286. package/playbooks/templates/followup-dispatch.md +4 -3
  287. package/playbooks/verify.md +1 -1
  288. package/prompts/cc-system.md +19 -27
  289. package/watch-plugins/README.md +92 -0
  290. package/watch-plugins/ado-author-prs.js +336 -0
  291. package/watch-plugins/gh-author-prs.js +375 -0
  292. package/watch-plugins/http.js +474 -0
  293. package/watch-plugins/teams-channel.js +869 -0
  294. package/docs/dev-composite-workflow.md +0 -101
  295. package/docs/pr-screenshots/pr-886/after-single-header.png +0 -0
  296. package/docs/pr-screenshots/pr-886/before-duplicate-header.png +0 -0
  297. package/docs/pr-screenshots/pr-895/01-cancellation-reason-detail.png +0 -0
  298. package/docs/pr-screenshots/pr-899/worker-pool-worktrees-AFTER.png +0 -0
  299. package/docs/pr-screenshots/pr-899/worker-pool-worktrees-BEFORE.png +0 -0
  300. package/docs/pr-screenshots/pr-901/projects-tab-default.png +0 -0
  301. package/docs/pr-screenshots/pr-901/projects-tab-fmf-selected.png +0 -0
  302. package/docs/pr-screenshots/pr-916/model-picker-AFTER-crop.png +0 -0
  303. package/docs/pr-screenshots/pr-916/model-picker-AFTER.png +0 -0
  304. package/docs/pr-screenshots/pr-916/model-picker-BEFORE-crop.png +0 -0
  305. package/docs/pr-screenshots/pr-916/model-picker-BEFORE.png +0 -0
  306. package/docs/pr-screenshots/pr-916/model-picker-dropdown-AFTER.png +0 -0
  307. package/docs/pr-screenshots/pr-979/auto-fix-pane-AFTER.png +0 -0
  308. package/docs/pr-screenshots/pr-979/auto-fix-pane-BEFORE.png +0 -0
  309. package/docs/pr-screenshots/pr-985/pr-column-em-dash-AFTER.png +0 -0
  310. package/docs/pr-screenshots/pr-985/pr-column-em-dash-BEFORE.png +0 -0
  311. package/docs/visual-evidence-ci.md +0 -103
  312. package/engine/bridge.js +0 -379
  313. package/engine/quarantine-refs.js +0 -103
  314. package/engine/state-operations.js +0 -178
  315. /package/engine/{steering-constraints.js → agents/steering-constraints.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * engine/stdio-timestamps.js — Prefix every console.log/warn/error/info line
2
+ * engine/core/stdio-timestamps.js — Prefix every console.log/warn/error/info line
3
3
  * with an ISO-8601 timestamp so dashboard-stdio.log and engine-stdio.log
4
4
  * become diagnosable to the second.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * engine/untrusted-fence.js — F5 (W-mpeklod3000we69c).
2
+ * engine/core/untrusted-fence.js — F5 (W-mpeklod3000we69c).
3
3
  *
4
4
  * Wraps human-authored / external content in
5
5
  * <UNTRUSTED-INPUT source="…">…</UNTRUSTED-INPUT>
@@ -7,7 +7,7 @@
7
7
  * `playbooks/shared-rules.md` and `prompts/cc-system.md` that teaches agents
8
8
  * to treat fenced content as data, not instructions.
9
9
  *
10
- * Zero dependencies beyond `engine/shared` (for the ENGINE_DEFAULTS byte cap).
10
+ * Zero dependencies beyond `engine/core/shared` (for the ENGINE_DEFAULTS byte cap).
11
11
  * Pure helpers — safe to call from poll-time, render-time, and consolidation
12
12
  * paths. Source attributes are sanitized so attacker-influenced parts
13
13
  * (PR comment author, file paths) cannot break out of the fence header.
@@ -33,7 +33,7 @@ const INNER_CLOSE_RE = /<\/UNTRUSTED-INPUT(?:\s[^>]*)?>/gi;
33
33
 
34
34
  function _shared() {
35
35
  // Late require — keep this module loadable in isolated test contexts that
36
- // bust `engine/shared` from require.cache between runs.
36
+ // bust `engine/core/shared` from require.cache between runs.
37
37
  return require('./shared');
38
38
  }
39
39
 
@@ -94,7 +94,7 @@ function _resolveDbPath() {
94
94
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
95
95
  let minionsDir = envHome;
96
96
  if (!minionsDir) {
97
- try { minionsDir = require('../shared').MINIONS_DIR; } catch { /* shared not loaded */ }
97
+ try { minionsDir = require('../core/shared').MINIONS_DIR; } catch { /* shared not loaded */ }
98
98
  }
99
99
  if (!minionsDir) throw new Error('engine/db: MINIONS_DIR not resolvable');
100
100
  const engineDir = path.join(minionsDir, 'engine');
@@ -263,4 +263,13 @@ function prepareCached(db, sql) {
263
263
  return stmt;
264
264
  }
265
265
 
266
- module.exports = { getDb, closeDb, withTransaction, prepareCached, cleanupRetiredJsonFiles };
266
+ module.exports = {
267
+ getDb,
268
+ closeDb,
269
+ withTransaction,
270
+ prepareCached,
271
+ cleanupRetiredJsonFiles,
272
+ // Standalone read-only connections (backup verification) need the same
273
+ // ExperimentalWarning suppression that getDb() installs.
274
+ installSqliteWarningFilter: _installExperimentalWarningFilter,
275
+ };
@@ -26,7 +26,7 @@ const fs = require('fs');
26
26
  function _resolveMinionsDir() {
27
27
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
28
28
  if (envHome) return envHome;
29
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
29
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
30
30
  }
31
31
 
32
32
  function _toMs(v) {
@@ -102,8 +102,8 @@ module.exports = {
102
102
  // dispatch.json stays on disk as a dual-write mirror — every successful
103
103
  // mutateDispatch refreshes it from SQL via dispatch-store._mirrorJsonFromSql.
104
104
  // SQL is the source of truth; the file is a read-only derivative kept
105
- // for backward compatibility with legacy direct-readers (engine/routing.js,
106
- // engine/queries.js fallback, test infrastructure). Rollback path: if a
105
+ // for backward compatibility with legacy direct-readers (engine/orchestration/routing.js,
106
+ // engine/core/queries.js fallback, test infrastructure). Rollback path: if a
107
107
  // user pins back to a pre-Phase-1 release, dispatch.json already contains
108
108
  // the latest committed state (last mirror write), and the SQL table can
109
109
  // be discarded.
@@ -22,7 +22,7 @@ const fs = require('fs');
22
22
  function _resolveMinionsDir() {
23
23
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
24
24
  if (envHome) return envHome;
25
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
25
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
26
26
  }
27
27
 
28
28
  function _toMs(v) {
@@ -23,7 +23,7 @@ const fs = require('fs');
23
23
  function _resolveMinionsDir() {
24
24
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
25
25
  if (envHome) return envHome;
26
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
26
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
27
27
  }
28
28
 
29
29
  function _toMs(v) {
@@ -37,7 +37,7 @@ function _resolveMinionsDir() {
37
37
  // backfill its tables from MINIONS_HOME — cross-directory corruption.
38
38
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
39
39
  if (envHome) return envHome;
40
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
40
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
41
41
  }
42
42
 
43
43
  const RESERVED_KEYS = new Map([
@@ -1,6 +1,6 @@
1
1
  // engine/db/migrations/007-watches.js
2
2
  //
3
- // Phase 6: move engine/watches.json into a `watches` table.
3
+ // Phase 6: move engine/watches/index.json into a `watches` table.
4
4
  //
5
5
  // watches.json is an array of watch jobs polled every 3 ticks. Most
6
6
  // installs carry only a handful (operator-defined notifications, plan-
@@ -21,7 +21,7 @@ function _resolveMinionsDir() {
21
21
  // backfill its tables from MINIONS_HOME — cross-directory corruption.
22
22
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
23
23
  if (envHome) return envHome;
24
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
24
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
25
25
  }
26
26
 
27
27
  function _toMs(v) {
@@ -20,7 +20,7 @@ function _resolveMinionsDir() {
20
20
  // backfill its tables from MINIONS_HOME — cross-directory corruption.
21
21
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
22
22
  if (envHome) return envHome;
23
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
23
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
24
24
  }
25
25
 
26
26
  function _toMs(v) {
@@ -15,7 +15,7 @@ const fs = require('fs');
15
15
  function _resolveMinionsDir() {
16
16
  const envHome = process.env.MINIONS_HOME || process.env.MINIONS_TEST_DIR;
17
17
  if (envHome) return envHome;
18
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
18
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
19
19
  }
20
20
 
21
21
  function _toMs(v) {
@@ -17,7 +17,7 @@ const fs = require('fs');
17
17
  function _resolveMinionsDir() {
18
18
  const envHome = process.env.MINIONS_HOME || process.env.MINIONS_TEST_DIR;
19
19
  if (envHome) return envHome;
20
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
20
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
21
21
  }
22
22
 
23
23
  function _readJsonOr(filePath, fallback) {
@@ -15,7 +15,7 @@ const fs = require('fs');
15
15
  function _resolveMinionsDir() {
16
16
  const envHome = process.env.MINIONS_HOME || process.env.MINIONS_TEST_DIR;
17
17
  if (envHome) return envHome;
18
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
18
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
19
19
  }
20
20
 
21
21
  function _readJsonOr(filePath, fallback) {
@@ -7,12 +7,12 @@
7
7
  // well-defined state machine (queued → live_kill | deferred →
8
8
  // re_spawning → delivered → acknowledged) instead of relying on the
9
9
  // stdout-timestamp heuristic alone for visibility. The legacy
10
- // heuristic ack (engine/steering.js#ackProcessedSteeringMessages) is
10
+ // heuristic ack (engine/agents/steering.js#ackProcessedSteeringMessages) is
11
11
  // kept as a back-compat path for inbox files that predate this
12
12
  // migration (no `steerId:` in frontmatter, no row in this table).
13
13
  //
14
14
  // SQL-first per CLAUDE.md "New state goes into SQL first" — no JSON
15
- // sidecar; reads/writes go through engine/steering-store.js.
15
+ // sidecar; reads/writes go through engine/persistence/steering-store.js.
16
16
 
17
17
  module.exports = {
18
18
  version: 12,
@@ -1,7 +1,7 @@
1
1
  // engine/db/migrations/013-backfill-broken-note-links.js
2
2
  //
3
3
  // No-op marker. The one-time repair of broken inbox note links was moved to an
4
- // idempotent engine-boot sweep (engine/cli.js → note-link-backfill.runNoteLink
4
+ // idempotent engine-boot sweep (engine/operations/cli.js → note-link-backfill.runNoteLink
5
5
  // Backfill) because it must go through shared.mutateWorkItems to keep the SQL
6
6
  // store and its JSON mirror consistent — a raw in-migration UPDATE left the
7
7
  // mirror diverged and could be reverted by the store's resync. This migration
@@ -4,7 +4,7 @@
4
4
  // execution-target choice per repo (optional)".
5
5
  //
6
6
  // Adds the `pr_fix_target_prefs` table — one row per repo scope — so the
7
- // execution-target choice surface (engine/pr-fix-target.js) can OPTIONALLY
7
+ // execution-target choice surface (engine/providers/pr-fix-target.js) can OPTIONALLY
8
8
  // remember the user's pick (clone-keep | temp-clone | remote-patch) keyed by
9
9
  // canonical PR scope (github:owner/repo / ado:org/proj/repo). When a remembered
10
10
  // choice exists, a repeat fix on that repo routes straight to the executor
@@ -12,7 +12,7 @@
12
12
  // never clone silently). The choice is clearable/overridable.
13
13
  //
14
14
  // SQL-first per CLAUDE.md "New state goes into SQL first" — no JSON sidecar;
15
- // reads/writes go through engine/pr-fix-target-store.js.
15
+ // reads/writes go through engine/persistence/pr-fix-target-store.js.
16
16
 
17
17
  module.exports = {
18
18
  version: 14,
@@ -6,12 +6,12 @@ module.exports = {
6
6
  let legacyPrdCount = 0;
7
7
  let importedPrdCount = 0;
8
8
  const minionsDir = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME
9
- || (() => { try { return require('../../shared').MINIONS_DIR; } catch { return null; } })();
9
+ || (() => { try { return require('../../core/shared').MINIONS_DIR; } catch { return null; } })();
10
10
  if (minionsDir) {
11
11
  const importDir = (dir, archived) => {
12
12
  let files = [];
13
13
  try { files = fs.readdirSync(dir).filter(f => f.endsWith('.json')); } catch { return; }
14
- const { _upsertPrd } = require('../../prd-store');
14
+ const { _upsertPrd } = require('../../planning/prd-store');
15
15
  for (const filename of files) {
16
16
  legacyPrdCount++;
17
17
  const filePath = path.join(dir, filename);
@@ -4,7 +4,7 @@ const fs = require('fs');
4
4
  function _resolveMinionsDir() {
5
5
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
6
6
  if (envHome) return envHome;
7
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
7
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
8
8
  }
9
9
 
10
10
  function _toMs(value) {
@@ -6,7 +6,7 @@ const CC_GLOBAL_SESSION_ID = '__global__';
6
6
  function _resolveMinionsDir() {
7
7
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
8
8
  if (envHome) return envHome;
9
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
9
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
10
10
  }
11
11
 
12
12
  module.exports = {
@@ -6,7 +6,7 @@ const ENGINE_STATE_MARKER = 'engine_state';
6
6
  function _resolveMinionsDir() {
7
7
  const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
8
8
  if (envHome) return envHome;
9
- try { return require('../../shared').MINIONS_DIR; } catch { return null; }
9
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
10
10
  }
11
11
 
12
12
  module.exports = {
@@ -1,4 +1,4 @@
1
- const { isMalformedPhantomWorkItem } = require('../../work-item-validation');
1
+ const { isMalformedPhantomWorkItem } = require('../../planning/work-item-validation');
2
2
 
3
3
  module.exports = {
4
4
  version: 25,
@@ -20,7 +20,7 @@ function _parseObject(value) {
20
20
  }
21
21
  }
22
22
 
23
- // Mirror engine/review-learning.js#normalizeCanonicalPrId's space-compatible
23
+ // Mirror engine/memory/review-learning.js#normalizeCanonicalPrId's space-compatible
24
24
  // contract so the quarantine accepts valid canonical IDs whose ADO
25
25
  // org/project/repo segments contain spaces (or %20) — createReviewFeedbackForAuthor
26
26
  // writes the raw canonical `pr.id`, and valid ADO scopes may contain spaces.
@@ -0,0 +1,20 @@
1
+ // Versions 27 and 28 were previously used by retired mirror-hash migrations.
2
+ // Existing databases therefore skipped the current review-learning and
3
+ // cc-queued-message migrations even though fresh databases applied them.
4
+
5
+ function _hasTable(db, table) {
6
+ return !!db.prepare(`
7
+ SELECT 1 FROM sqlite_master WHERE type='table' AND name=?
8
+ `).get(table);
9
+ }
10
+
11
+ module.exports = {
12
+ version: 29,
13
+ description: 'repair reused migration versions 27/28',
14
+ up(db) {
15
+ require('./027-review-learning-lifecycle').up(db);
16
+ if (!_hasTable(db, 'cc_queued_messages')) {
17
+ require('./028-cc-queued-messages').up(db);
18
+ }
19
+ },
20
+ };
@@ -0,0 +1,137 @@
1
+ // engine/db/migrations/031-pr-author-identity.js
2
+ //
3
+ // W-mscibegy005e8b74: separate PR author identity from Minions agent attribution.
4
+ //
5
+ // Historically `pr.agent` was overloaded: GitHub/ADO provider sync overwrote it
6
+ // with the platform author login (`agent === 'human'` → login/displayName),
7
+ // while orchestration and routing use `pr.agent` as the *Minions* agent that
8
+ // created/owns the automated work. That conflated two distinct identities.
9
+ //
10
+ // This migration:
11
+ // 1. Adds an `author` projection column (typed label; canonical structured
12
+ // identity lives in the `data` JSON under `author`).
13
+ // 2. Backfills, FAIL-CLOSED, by un-overloading historical rows: a row whose
14
+ // `agent` is a human login (i.e. not the 'human' sentinel, not a configured
15
+ // Minions agent id, not a temp-* ephemeral, not 'unknown'/'unassigned') has
16
+ // that login moved into `author` and `agent` reset to 'human'. When the set
17
+ // of configured agent ids cannot be resolved, the destructive move is
18
+ // SKIPPED entirely so a real agent row (e.g. 'dallas') is never mistaken for
19
+ // a human login. Rows that already carry a structured `data.author` just get
20
+ // the label projected into the new column.
21
+ //
22
+ // Rows whose identity cannot be established are left untouched: `author` stays
23
+ // NULL and renders as "Unknown" rather than silently falling back to the agent.
24
+
25
+ const path = require('path');
26
+ const fs = require('fs');
27
+
28
+ function _resolveMinionsDir() {
29
+ const envHome = process.env.MINIONS_TEST_DIR || process.env.MINIONS_HOME;
30
+ if (envHome) return envHome;
31
+ try { return require('../../core/shared').MINIONS_DIR; } catch { return null; }
32
+ }
33
+
34
+ // Resolve the set of configured Minions agent ids from config.json. Returns null
35
+ // (not an empty set) when the config is unavailable/unreadable so the caller can
36
+ // distinguish "no agents configured" from "cannot tell" and fail closed.
37
+ function _resolveConfiguredAgentIds(minionsDir) {
38
+ if (!minionsDir) return null;
39
+ try {
40
+ const raw = fs.readFileSync(path.join(minionsDir, 'config.json'), 'utf8');
41
+ const cfg = JSON.parse(raw);
42
+ if (!cfg || typeof cfg !== 'object' || !cfg.agents || typeof cfg.agents !== 'object') {
43
+ return new Set();
44
+ }
45
+ const ids = new Set();
46
+ for (const key of Object.keys(cfg.agents)) {
47
+ if (key) ids.add(String(key).toLowerCase());
48
+ }
49
+ return ids;
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+
55
+ const _NON_HUMAN_AGENTS = new Set(['human', 'unknown', 'unassigned', '', 'none', 'null']);
56
+
57
+ // Does this legacy `agent` value look like a human login wrongly stored in agent?
58
+ function _looksLikeHumanLogin(agent, configuredAgentIds) {
59
+ if (!agent || typeof agent !== 'string') return false;
60
+ const norm = agent.trim().toLowerCase();
61
+ if (_NON_HUMAN_AGENTS.has(norm)) return false;
62
+ if (norm.startsWith('temp-')) return false; // ephemeral Minions agent
63
+ if (configuredAgentIds && configuredAgentIds.has(norm)) return false; // real agent
64
+ return true;
65
+ }
66
+
67
+ function _authorLabel(author) {
68
+ if (!author || typeof author !== 'object') return null;
69
+ const label = author.displayName || author.login || author.id || '';
70
+ const s = String(label).trim();
71
+ return s ? s.slice(0, 200) : null;
72
+ }
73
+
74
+ function _hasTable(db, table) {
75
+ return !!db.prepare(`
76
+ SELECT 1 FROM sqlite_master WHERE type='table' AND name=?
77
+ `).get(table);
78
+ }
79
+
80
+ module.exports = {
81
+ version: 31,
82
+ description: 'pull_requests.author — separate PR author identity from pr.agent (W-mscibegy005e8b74)',
83
+ up(db) {
84
+ // The pull_requests table is created by migration 004, so a real database
85
+ // always has it by the time this runs. Synthetic databases (e.g. hand-built
86
+ // version-26 fixtures that only create the tables under test) may not — a DB
87
+ // with no pull_requests table has no PR identities to migrate, so skip.
88
+ if (!_hasTable(db, 'pull_requests')) return;
89
+
90
+ db.exec(`
91
+ ALTER TABLE pull_requests ADD COLUMN author TEXT;
92
+ CREATE INDEX IF NOT EXISTS idx_pr_author ON pull_requests(author);
93
+ `);
94
+
95
+ const minionsDir = _resolveMinionsDir();
96
+ const configuredAgentIds = _resolveConfiguredAgentIds(minionsDir);
97
+ // FAIL-CLOSED: if we cannot resolve configured agent ids, do not perform the
98
+ // destructive agent→author move (real agent rows would be corrupted). We can
99
+ // still safely project already-structured authors into the column below.
100
+ const canUnoverload = configuredAgentIds != null;
101
+
102
+ const rows = db.prepare('SELECT scope, id, agent, data FROM pull_requests').all();
103
+ const update = db.prepare('UPDATE pull_requests SET agent = ?, author = ?, data = ? WHERE scope = ? AND id = ?');
104
+
105
+ let unoverloaded = 0;
106
+ let projected = 0;
107
+
108
+ for (const row of rows) {
109
+ let record;
110
+ try { record = JSON.parse(row.data); }
111
+ catch { continue; }
112
+ if (!record || typeof record !== 'object') continue;
113
+
114
+ // Case 1: already-structured author on the record — project label only.
115
+ if (record.author && typeof record.author === 'object') {
116
+ const label = _authorLabel(record.author);
117
+ if (label) {
118
+ update.run(record.agent || row.agent || null, label, JSON.stringify(record), row.scope, row.id);
119
+ projected += 1;
120
+ }
121
+ continue;
122
+ }
123
+
124
+ // Case 2: legacy overloaded agent — un-overload into author.
125
+ if (canUnoverload && _looksLikeHumanLogin(row.agent, configuredAgentIds)) {
126
+ const login = String(row.agent).trim().slice(0, 200);
127
+ record.author = { login };
128
+ record.agent = 'human';
129
+ update.run('human', login, JSON.stringify(record), row.scope, row.id);
130
+ unoverloaded += 1;
131
+ }
132
+ }
133
+
134
+ // eslint-disable-next-line no-console
135
+ console.log(`[db-migrate] v31: author column added; un-overloaded ${unoverloaded} legacy agent→author row(s), projected ${projected} structured author(s)${canUnoverload ? '' : ' (agent→author move SKIPPED: configured agent ids unavailable)'}`);
136
+ },
137
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * engine/consolidation.js — Inbox note consolidation for Minions engine.
2
+ * engine/memory/consolidation.js — Inbox note consolidation for Minions engine.
3
3
  * Extracted from engine.js: LLM-powered and regex fallback consolidation,
4
4
  * knowledge base classification, inbox archival.
5
5
  */
@@ -7,14 +7,14 @@
7
7
  const fs = require('fs');
8
8
  const path = require('path');
9
9
  const crypto = require('crypto');
10
- const shared = require('./shared');
10
+ const shared = require('../core/shared');
11
11
  const { safeRead, safeWrite,
12
12
  classifyInboxItem, KB_CATEGORIES, log, ts, dateStamp } = shared;
13
- const { callLLM, trackEngineUsage } = require('./llm');
14
- const queries = require('./queries');
13
+ const { callLLM, trackEngineUsage } = require('../agents/llm');
14
+ const queries = require('../core/queries');
15
15
  const { getInboxFiles, getNotes, INBOX_DIR, ENGINE_DIR,
16
16
  NOTES_PATH, KNOWLEDGE_DIR, ARCHIVE_DIR } = queries;
17
- const { wrapUntrusted, buildSource } = require('./untrusted-fence');
17
+ const { wrapUntrusted, buildSource } = require('../core/untrusted-fence');
18
18
  const reviewLearning = require('./review-learning');
19
19
  const memoryStore = require('./memory-store');
20
20
 
@@ -141,7 +141,7 @@ const AGENT_MEMORY_RECONCILE_MIN_RETAIN_RATIO = 0.30;
141
141
  const AGENT_MEMORY_RECONCILE_SIGNAL_RE = /\b(invalid|rejected|rejection|incorrect|wrong|does not exist|never existed|stale|superseded?|_failureClass|invalid_managed_spawn)\b|(^|\n)\s*(\*\*)?reason:/i;
142
142
 
143
143
  // W-mq07b8do000nc86a — Sliding-window persistent memory defaults. These
144
- // mirror the engine.agentMemory* tunables in ENGINE_DEFAULTS (engine/shared.js)
144
+ // mirror the engine.agentMemory* tunables in ENGINE_DEFAULTS (engine/core/shared.js)
145
145
  // and are exported so callers that synthesize a one-off prune (tests,
146
146
  // migrations) can opt into the same shape without re-importing shared.
147
147
  const AGENT_MEMORY_MAX_ENTRIES_DEFAULT = 300;
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * engine/kb-sweep-runner.js — Detached entrypoint for the KB sweep.
3
+ * engine/memory/kb-sweep-runner.js — Detached entrypoint for the KB sweep.
4
4
  *
5
5
  * Spawned by dashboard.js `handleKnowledgeSweep` with `{ detached: true,
6
6
  * stdio: ['ignore', logFd, logFd] }` so the sweep survives dashboard /
@@ -48,7 +48,7 @@ const dryRun = cliDryRun || body.dryRun === true;
48
48
 
49
49
  // Lazy-require AFTER args are parsed so a malformed body-file doesn't drag in
50
50
  // the whole sweep stack before we've reported the failure.
51
- const queries = require('./queries');
51
+ const queries = require('../core/queries');
52
52
  const { runKbSweep } = require('./kb-sweep');
53
53
 
54
54
  function cleanupBodyFile() {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * engine/kb-sweep.js — Knowledge base sweep: dedup, compress, normalize.
2
+ * engine/memory/kb-sweep.js — Knowledge base sweep: dedup, compress, normalize.
3
3
  *
4
4
  * Replaces the inline sweep that lived in dashboard.js. Three passes:
5
5
  * 1. Hash-based dedup — cheap, catches cross-batch duplicates
@@ -12,8 +12,8 @@
12
12
  const fs = require('fs');
13
13
  const path = require('path');
14
14
  const crypto = require('crypto');
15
- const shared = require('./shared');
16
- const queries = require('./queries');
15
+ const shared = require('../core/shared');
16
+ const queries = require('../core/queries');
17
17
  const { safeRead, safeReadOrNull, safeWrite, safeJson, safeUnlink, log, ts } = shared;
18
18
  const { MINIONS_DIR, ENGINE_DIR } = queries;
19
19
 
@@ -533,6 +533,7 @@ If nothing to do: { "duplicates": [], "reclassify": [], "remove": [] }`;
533
533
  try {
534
534
  result = await callLLM(prompt, 'Output only JSON.', {
535
535
  timeout: 120000, label: 'kb-sweep', model: 'haiku', maxTurns: 1, direct: true,
536
+ disableTools: true,
536
537
  engineConfig: opts.engineConfig,
537
538
  });
538
539
  trackEngineUsage('kb-sweep', result.usage);
@@ -650,6 +651,7 @@ ${body}`;
650
651
  try {
651
652
  const result = await callLLM(REWRITE_PROMPT(c.entry, c.body), 'Output ONLY the template body.', {
652
653
  timeout: 120000, label: 'kb-rewrite', model: 'haiku', maxTurns: 1, direct: true,
654
+ disableTools: true,
653
655
  engineConfig: opts.engineConfig,
654
656
  });
655
657
  trackEngineUsage('kb-rewrite', result.usage);
@@ -814,7 +816,7 @@ function readSweepLiveness(opts = {}) {
814
816
  /**
815
817
  * One-shot boot-time reconciliation for `engine/kb-sweep-state.json`.
816
818
  *
817
- * Mirrors the worktree-pool / keep-process boot reconcilers in `engine/cli.js`:
819
+ * Mirrors the worktree-pool / keep-process boot reconcilers in `engine/operations/cli.js`:
818
820
  * after an engine restart we may inherit a stale `in-flight`/`starting` record
819
821
  * whose runner has long since died (or — for legacy state files — never
820
822
  * recorded a pid). Without proactive cleanup the record sits there clogging
@@ -952,7 +954,7 @@ async function runKbSweep(opts = {}) {
952
954
  }
953
955
 
954
956
  async function _runKbSweepImpl(opts = {}) {
955
- const { callLLM, trackEngineUsage } = require('./llm');
957
+ const { callLLM, trackEngineUsage } = require('../agents/llm');
956
958
  const summary = {
957
959
  ok: true,
958
960
  entriesBefore: 0,
@@ -1104,7 +1106,7 @@ async function _runKbSweepImpl(opts = {}) {
1104
1106
  }
1105
1107
 
1106
1108
  /**
1107
- * Spawn the KB sweep runner (`engine/kb-sweep-runner.js`) as a detached child.
1109
+ * Spawn the KB sweep runner (`engine/memory/kb-sweep-runner.js`) as a detached child.
1108
1110
  * Shared between dashboard's POST /api/knowledge/sweep handler and the engine
1109
1111
  * tick's auto-sweep phase. Performs the same synchronous "starting" → "in-flight"
1110
1112
  * CAS dance the dashboard handler used to do inline.
@@ -1152,7 +1154,7 @@ function spawnSweepRunnerDetached(opts = {}) {
1152
1154
  const logFn = typeof opts.log === 'function'
1153
1155
  ? opts.log
1154
1156
  : (level, msg) => { (level === 'error' ? console.error : console.log)(`[kb-sweep] ${msg}`); };
1155
- const cwd = opts.cwd || require('./queries').MINIONS_DIR;
1157
+ const cwd = opts.cwd || require('../core/queries').MINIONS_DIR;
1156
1158
  const startedAt = Date.now();
1157
1159
  const sweepToken = `${startedAt}-${Math.random().toString(36).slice(2, 8)}`;
1158
1160
  const observed = readSweepLiveness({ now: startedAt });