@yemi33/minions 0.1.2447 → 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 +66 -7
  7. package/dashboard/js/detail-panel.js +36 -0
  8. package/dashboard/js/memory-panel.js +59 -12
  9. package/dashboard/js/qa.js +186 -45
  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 +52 -6
  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
@@ -19,7 +19,7 @@ This closes a class of spoofable-stdout attacks where agent output (or content q
19
19
 
20
20
  ## 1. Problem
21
21
 
22
- The engine reconstructs control-plane state from the unstructured stdout of `claude` CLI subprocesses. Eight call sites in `engine/lifecycle.js` and one in `engine/timeout.js` regex-match the agent's output stream:
22
+ The engine reconstructs control-plane state from the unstructured stdout of `claude` CLI subprocesses. Eight call sites in `engine/orchestration/lifecycle.js` and one in `engine/orchestration/timeout.js` regex-match the agent's output stream:
23
23
 
24
24
  | # | Site | What it scrapes | Spoof surface |
25
25
  |---|------|-----------------|---------------|
@@ -31,7 +31,7 @@ The engine reconstructs control-plane state from the unstructured stdout of `cla
31
31
  | 6 | `parseStructuredCompletion` (`lifecycle.js:1494`) | Last ` ```completion ` fenced block, parsed as `key: value` | An agent that includes a ` ```completion ` block in a quoted file (e.g. another playbook) overrides its own real status |
32
32
  | 7 | `classifyFailure` (`lifecycle.js:2096`) | Failure-class regexes on combined stdout/stderr (`max_turns`, `permission denied`, `merge conflict`, …) | An agent that quotes one error class while genuinely failing on another gets the wrong recovery recipe |
33
33
  | 8 | `checkForLearnings` (`lifecycle.js:1266`) | Filesystem scan for `notes/inbox/*<agentId>*<date>*` | Not stdout-based, but date-collisions cause cross-task attribution |
34
- | 9 | `checkTimeouts` (`engine/timeout.js:189-219`) | Tail of `live-output.log` for `[process-exit]` markers — completion-via-output detection after process tracking is lost | Lower-risk: this is engine/CLI output, not agent-authored content |
34
+ | 9 | `checkTimeouts` (`engine/orchestration/timeout.js:189-219`) | Tail of `live-output.log` for `[process-exit]` markers — completion-via-output detection after process tracking is lost | Lower-risk: this is engine/CLI output, not agent-authored content |
35
35
 
36
36
  Sites 1–8 are agent-spoofable (intentionally or accidentally). Site 9 is claude-CLI-emitted and stays on stdout — see §6.
37
37
 
@@ -89,7 +89,7 @@ The agent must not write the file in pieces. Empty, truncated, or malformed JSON
89
89
 
90
90
  ### 3.4 Cleanup
91
91
 
92
- `engine/cleanup.js` (every 10 ticks) gains a sweep over `engine/tmp/completion-*.json` older than 24h. The `runPostCompletionHooks` flow already removes the worktree but leaves `engine/tmp/` files for diagnostics — completion files are tiny (<10 KB typical) so a 24h window is generous and matches the existing temp-prompt retention.
92
+ `engine/orchestration/cleanup.js` (every 10 ticks) gains a sweep over `engine/tmp/completion-*.json` older than 24h. The `runPostCompletionHooks` flow already removes the worktree but leaves `engine/tmp/` files for diagnostics — completion files are tiny (<10 KB typical) so a 24h window is generous and matches the existing temp-prompt retention.
93
93
 
94
94
  ## 4. Schema
95
95
 
@@ -207,14 +207,14 @@ The agent must not write the file in pieces. Empty, truncated, or malformed JSON
207
207
  | `plan-to-prd` | `status`, `summary` (PRD file existence is checked separately, see lifecycle.js:1721) | `review`, `decomposition`, `meeting` |
208
208
  | `explore`, `ask`, `test`, `docs` | `status`, `summary` | `prs`, `review`, `decomposition`, `meeting` |
209
209
 
210
- Validation lives in a new `validateCompletion(obj, taskType)` in `engine/shared.js` and runs in `runPostCompletionHooks` *before* any field is consumed.
210
+ Validation lives in a new `validateCompletion(obj, taskType)` in `engine/core/shared.js` and runs in `runPostCompletionHooks` *before* any field is consumed.
211
211
 
212
212
  ## 5. Engine Read Path & Migration
213
213
 
214
214
  ### 5.1 New Helper
215
215
 
216
216
  ```js
217
- // engine/lifecycle.js (new — replaces parseStructuredCompletion as primary)
217
+ // engine/orchestration/lifecycle.js (new — replaces parseStructuredCompletion as primary)
218
218
  function readCompletionFile(dispatchItem) {
219
219
  const p = path.join(ENGINE_DIR, 'tmp', `completion-${dispatchItem.id}.json`);
220
220
  if (!fs.existsSync(p)) return null;
@@ -272,7 +272,7 @@ The flag name `engine.requireCompletionFile` mirrors existing engine flags (`aut
272
272
 
273
273
  These paths stay on stdout / live-output.log:
274
274
 
275
- 1. **`engine/timeout.js` completion-via-output detection** (`timeout.js:189-219`). The signal is the engine-written `[process-exit]` sentinel, emitted even if the agent crashed before writing completion.json. Removing it would mean orphans that finished during process-handle loss are never reconciled.
275
+ 1. **`engine/orchestration/timeout.js` completion-via-output detection** (`timeout.js:189-219`). The signal is the engine-written `[process-exit]` sentinel, emitted even if the agent crashed before writing completion.json. Removing it would mean orphans that finished during process-handle loss are never reconciled.
276
276
  2. **Stale-orphan cleanup via `live-output.log` mtime** (`timeout.js:178`). Completion.json is written once at exit, so `live-output.log` remains the best indirect signal after the engine loses process tracking.
277
277
  3. **`parseStreamJsonOutput` for `resultSummary`** in `parseAgentOutput` (`lifecycle.js:1483`). This extracts the human-readable summary from the CLI's stream-json. Even after the flip, `completion.summary` is *also* extracted, but the stream-json text remains the canonical "what did the agent say last" — used in dashboards, agent history, and external notifications. The two coexist: `completion.summary` is for routing decisions, the stream-json text is for display.
278
278
  4. **Inbox-file skill scan** (`lifecycle.js:2013-2024`). Some agents write skills into their inbox findings file (a deliberate human-discoverable artifact). The completion file deprecates inline ` ```skill ` blocks in stdout, but the inbox file scan is opt-in and stays — it's a different surface (a real file the agent intentionally wrote, not regex-scraped from stdout).
@@ -290,9 +290,9 @@ These paths stay on stdout / live-output.log:
290
290
  "deprecated": "Day 10",
291
291
  "reason": "Spoofable surface — agents that quote PR URLs created phantom PR records.",
292
292
  "locations": [
293
- "engine/lifecycle.js:704 syncPrsFromOutput",
294
- "engine/lifecycle.js:734 createdPattern, createdIdPattern",
295
- "engine/lifecycle.js:748 prHeaderPattern (inbox scan)"
293
+ "engine/orchestration/lifecycle.js:704 syncPrsFromOutput",
294
+ "engine/orchestration/lifecycle.js:734 createdPattern, createdIdPattern",
295
+ "engine/orchestration/lifecycle.js:748 prHeaderPattern (inbox scan)"
296
296
  ],
297
297
  "cleanup": "Delete syncPrsFromOutput; keep syncPrsFromCompletion."
298
298
  }
@@ -320,7 +320,7 @@ The key shift: **the agent's intent is now in a place no quoted text can reach.*
320
320
 
321
321
  ### 7.1 Centralized Instruction in `shared-rules.md`
322
322
 
323
- `playbooks/shared-rules.md` is auto-injected into every playbook (per `engine/playbook.js`). The completion-write block lives there once, so per-playbook diffs are minimal.
323
+ `playbooks/shared-rules.md` is auto-injected into every playbook (per `engine/agents/playbook.js`). The completion-write block lives there once, so per-playbook diffs are minimal.
324
324
 
325
325
  ```markdown
326
326
  ## Completion Protocol — Required Before Exit
@@ -400,9 +400,9 @@ The implementation PR ships:
400
400
 
401
401
  When this RFC is approved and the follow-up plan is drafted, the implementation must satisfy:
402
402
 
403
- 1. `MINIONS_COMPLETION_PATH` is set on every spawned agent process (`engine.js` and `engine/spawn-agent.js`).
404
- 2. `engine/shared.js` exports `validateCompletion(obj, taskType)`.
405
- 3. `engine/lifecycle.js` adds `readCompletionFile(dispatchItem)` and threads its return value through `runPostCompletionHooks`.
403
+ 1. `MINIONS_COMPLETION_PATH` is set on every spawned agent process (`engine.js` and `engine/agents/spawn-agent.js`).
404
+ 2. `engine/core/shared.js` exports `validateCompletion(obj, taskType)`.
405
+ 3. `engine/orchestration/lifecycle.js` adds `readCompletionFile(dispatchItem)` and threads its return value through `runPostCompletionHooks`.
406
406
  4. Every regex-based site listed in §1 has a completion-aware path with stdout fallback (Phase 0–2) or no fallback (Phase 4).
407
407
  5. `playbooks/shared-rules.md` carries the §7.1 instruction; `fix.md` / `implement-shared.md` drop their inline ` ```completion ` block.
408
408
  6. `engine.requireCompletionFile` is added to `ENGINE_DEFAULTS` (`shared.js`) defaulting to `false`.
@@ -412,12 +412,12 @@ When this RFC is approved and the follow-up plan is drafted, the implementation
412
412
 
413
413
  ## 11. References
414
414
 
415
- - `engine/lifecycle.js:1494` — current `parseStructuredCompletion` (legacy ` ```completion ` block reader, half-step toward this design).
416
- - `engine/lifecycle.js:704` — `syncPrsFromOutput` (Site 1, primary attack surface).
417
- - `engine/lifecycle.js:1278` — `extractSkillsFromOutput` (Site 5, highest-value attack surface).
418
- - `engine/timeout.js:189` — completion-via-output detection (stays on stdout per §6).
415
+ - `engine/orchestration/lifecycle.js:1494` — current `parseStructuredCompletion` (legacy ` ```completion ` block reader, half-step toward this design).
416
+ - `engine/orchestration/lifecycle.js:704` — `syncPrsFromOutput` (Site 1, primary attack surface).
417
+ - `engine/orchestration/lifecycle.js:1278` — `extractSkillsFromOutput` (Site 5, highest-value attack surface).
418
+ - `engine/orchestration/timeout.js:189` — completion-via-output detection (stays on stdout per §6).
419
419
  - `engine.js:865` — existing env-var injection pattern (`MINIONS_ADO_TOKEN`).
420
- - `engine/cleanup.js` — temp-file sweep (extended in implementation PR).
420
+ - `engine/orchestration/cleanup.js` — temp-file sweep (extended in implementation PR).
421
421
  - `playbooks/shared-rules.md` — auto-injected into every playbook.
422
422
  - `docs/deprecated.json` — deprecation tracker driving `/cleanup-deprecated`.
423
423
  - `docs/design-state-storage.md` — precedent for design-doc-in-`docs/` rather than `plans/`.
@@ -36,10 +36,10 @@ methods that genuinely differ.
36
36
  | `capabilities` | flag object (see below) | Behavioral and declarative flags (see below). |
37
37
  | `resolveBinary({ env, config? })` | `{ bin, native, leadingArgs }` or null | Probe PATH, npm-globals, package overrides; cached to `engine/<name>-caps.json`. `leadingArgs` is `[]` for direct binaries and `['copilot']` for the `gh copilot` subcommand fallback. |
38
38
  | `capsFile` | absolute path | Cache file for `resolveBinary()` results. |
39
- | `installHint` | string | Surfaced when `resolveBinary()` returns null. Consumed by `engine/preflight.js` and `engine/spawn-agent.js`. |
39
+ | `installHint` | string | Surfaced when `resolveBinary()` returns null. Consumed by `engine/agents/preflight.js` and `engine/agents/spawn-agent.js`. |
40
40
  | `listModels()` | `Promise<{id,name,provider}[] | null>` | Model catalog or null when discovery isn't supported. |
41
41
  | `modelsCache` | absolute path | Cache file for `listModels()` results. |
42
- | `spawnScript` | absolute path | Path to the runtime-agnostic spawn wrapper (currently `engine/spawn-agent.js` for all bundled runtimes). |
42
+ | `spawnScript` | absolute path | Path to the runtime-agnostic spawn wrapper (currently `engine/agents/spawn-agent.js` for all bundled runtimes). |
43
43
  | `buildArgs(opts)` | `string[]` | CLI args excluding the binary itself. |
44
44
  | `resolveInvocationOptions({ options, engineConfig, config, failureClass })` | object | Optional; maps harness-specific config and retry policy into semantic invocation options. Core code never reads harness-specific invocation keys. |
45
45
  | `buildSpawnFlags(opts)` | `string[]` | Optional compatibility flags for older spawn wrappers. New fields travel in the opaque `--runtime-options` bag automatically. |
@@ -54,7 +54,7 @@ methods that genuinely differ.
54
54
  | `parseOutput(raw)` | `{ text, usage, sessionId, model }` | Final-event parser. |
55
55
  | `parseStreamChunk(line)` | event object or null | Single JSONL line → typed event. |
56
56
  | `parseError(rawOutput)` | `{ message, code, retriable }` | Codes: `auth-failure`, `context-limit`, `budget-exceeded`, `model-unavailable` (retriable=true for upstream overload/503; retriable=false for invalid/typo'd model id — Copilot enriches the message via `_warmModelCache()` so it lists the available models), `crash`, null. |
57
- | `createStreamConsumer(ctx)` | consumer object | Stream accumulator used by `engine/llm.js`. |
57
+ | `createStreamConsumer(ctx)` | consumer object | Stream accumulator used by `engine/agents/llm.js`. |
58
58
  | `prepareWorkspace(ctx)` | result object | Optional synchronous hook for harness-owned workspace state, such as trust configuration. |
59
59
  | `isSpawnStartupEvent(event)` | boolean | Optional startup-event classifier used by the spawn-phase watchdog. |
60
60
  | `shouldSuppressPostMutationError(ctx)` | boolean | Optional harness quirk policy for an error received after a confirmed mutation. |
@@ -79,11 +79,16 @@ does not construct harness CLI argv. The selected adapter:
79
79
 
80
80
  Legacy named wrapper flags remain for backward compatibility, but they are no
81
81
  longer the extension point. A new harness option can be added entirely inside
82
- its adapter without teaching `engine.js`, `engine/llm.js`, or
83
- `engine/spawn-agent.js` another CLI flag. Large image payloads are written to a
82
+ its adapter without teaching `engine.js`, `engine/agents/llm.js`, or
83
+ `engine/agents/spawn-agent.js` another CLI flag. Large image payloads are written to a
84
84
  protected per-call sidecar; only its path enters the options argument, and the
85
85
  wrapper hydrates then deletes it before invoking the adapter.
86
86
 
87
+ `disableTools: true` is the semantic boundary for text-only internal calls such
88
+ as KB sweep/rewrite. Claude receives an empty `--tools` set, Copilot receives an
89
+ empty `--available-tools` set without autopilot, and Codex is forced into its
90
+ read-only sandbox. Core callers never branch on runtime names.
91
+
87
92
  Retirement gates for the temporary compatibility surfaces are tracked in
88
93
  `docs/deprecated.json`: `legacy-runtime-named-spawn-flags`,
89
94
  `versionless-runtime-adapter-compat`, and
@@ -128,10 +133,10 @@ to act on that behavioral split.
128
133
  | `sessionPersistenceControl` | ✓ | ✗ | ✗ | Engine writes `session.json`; Copilot and Codex own their runtime stores, while Minions records IDs only for safe resume. |
129
134
  | `resumePromptCarryover` | ✗ | ✓ | ✓ | CC resume turns prepend recent visible Q&A in stdin when the runtime session store is opaque to Minions. |
130
135
  | `resumeBookkeepingTurn` | ✓ | — | — | Claude CLI injects a synthetic "Continue from where you left off." meta turn on `--resume`; CC prompts must tell the model not to treat it as user intent. |
131
- | `streamConsumer` | ✓ | ✓ | ✓ | Adapter implements `createStreamConsumer(ctx)` — required by `engine/llm.js` accumulator. |
136
+ | `streamConsumer` | ✓ | ✓ | ✓ | Adapter implements `createStreamConsumer(ctx)` — required by `engine/agents/llm.js` accumulator. |
132
137
  | `imageInput` | ✓ | ✓ | ✓ | Runtime accepts `images: [{mimeType, dataBase64}]` and delivers them to the CLI using adapter-owned transport. When false, `_resolveImageOpts` returns a typed `model-unavailable` error. |
133
138
  | `skillDiscovery` | ✓ | — | — | Currently set only by Claude to declare native `.claude/skills` discovery. It is metadata-only today; core orchestration has no consumer yet. |
134
- | `acpWorkerPool` | ✗ | ✓ | ✗ | Runtime supports `<bin> --acp` (Agent Client Protocol), so it can be routed through a persistent worker pool instead of cold-spawning a fresh CLI process per turn/dispatch. Two independent consumers gate on this flag: `engine/cc-worker-pool.js` (CC/doc-chat tabs, `resolveCcUseWorkerPool`) and `engine/agent-worker-pool.js` (fleet agent dispatch, `resolveAgentUseWorkerPool`). Both resolvers hard-return `false` whenever this flag isn't `true` on the resolved runtime, regardless of any operator override, so a future non-ACP runtime can never be silently pooled. See [ACP Worker Pool](#acp-worker-pool-fleet-agent-dispatch) below. |
139
+ | `acpWorkerPool` | ✗ | ✓ | ✗ | Runtime supports `<bin> --acp` (Agent Client Protocol), so it can be routed through a persistent worker pool instead of cold-spawning a fresh CLI process per turn/dispatch. Two independent consumers gate on this flag: `engine/agents/cc-worker-pool.js` (CC/doc-chat tabs, `resolveCcUseWorkerPool`) and `engine/agents/agent-worker-pool.js` (fleet agent dispatch, `resolveAgentUseWorkerPool`). Both resolvers hard-return `false` whenever this flag isn't `true` on the resolved runtime, regardless of any operator override, so a future non-ACP runtime can never be silently pooled. See [ACP Worker Pool](#acp-worker-pool-fleet-agent-dispatch) below. |
135
140
 
136
141
  When a behavior is genuinely uniform across all current adapters, it still gets
137
142
  a flag if a future runtime might disagree — flags are cheap.
@@ -140,13 +145,13 @@ a flag if a future runtime might disagree — flags are cheap.
140
145
 
141
146
  The `acpWorkerPool` capability backs **two** independent pools that avoid a
142
147
  cold harness spawn for every turn/dispatch. Both share the runtime-neutral
143
- JSON-RPC transport (`engine/acp-transport.js`); the adapter owns worker argv and
148
+ JSON-RPC transport (`engine/agents/acp-transport.js`); the adapter owns worker argv and
144
149
  pooled-output encoding.
145
150
 
146
151
  | Pool | Module | Ownership model | Config | Default |
147
152
  |------|--------|------------------|--------|---------|
148
- | CC / doc-chat | `engine/cc-worker-pool.js` | 1 worker permanently owned per CC tab, kept warm for the tab's lifetime | `engine.ccUseWorkerPool` | `true` (Copilot CC) — see [docs/command-center.md](./command-center.md) |
149
- | Fleet agent dispatch | `engine/agent-worker-pool.js` | 1 worker leased to exactly one **active** dispatch at a time, returned to a shared free set on release — not owned for the dispatch's whole life | `engine.agentUseWorkerPool` + `engine.agentAcpPoolSize` | `false` (opt-in) |
153
+ | CC / doc-chat | `engine/agents/cc-worker-pool.js` | 1 worker permanently owned per CC tab, kept warm for the tab's lifetime | `engine.ccUseWorkerPool` | `true` (Copilot CC) — see [docs/command-center.md](./command-center.md) |
154
+ | Fleet agent dispatch | `engine/agents/agent-worker-pool.js` | 1 worker leased to exactly one **active** dispatch at a time, returned to a shared free set on release — not owned for the dispatch's whole life | `engine.agentUseWorkerPool` + `engine.agentAcpPoolSize` | `false` (opt-in) |
150
155
 
151
156
  This section covers the fleet agent pool (P-9b3d5f61 / P-1d8f0b93 / P-4c6e8a72).
152
157
 
@@ -171,8 +176,8 @@ concurrent dispatches than the fleet would have run anyway — it only changes
171
176
  ### How dispatches route through the pool
172
177
 
173
178
  When `resolveAgentUseWorkerPool` resolves `true`, `engine.js#spawnAgent` skips
174
- `node engine/spawn-agent.js` and instead calls `engine/agent-worker-pool.js#acquireWorker`,
175
- wrapping the lease in `engine/pooled-agent-process.js#PooledAgentProcess` — a
179
+ `node engine/agents/spawn-agent.js` and instead calls `engine/agents/agent-worker-pool.js#acquireWorker`,
180
+ wrapping the lease in `engine/agents/pooled-agent-process.js#PooledAgentProcess` — a
176
181
  child_process-shaped facade (`.pid`, `.stdout`/`.stderr`, `.kill()`,
177
182
  `'close'`/`'error'`) so the rest of `spawnAgent`'s downstream code (stdout/stderr
178
183
  handlers, PID-file writing, live-output.log, timeout/steering cancel-vs-kill,
@@ -216,7 +221,7 @@ its process cwd.
216
221
  Dispatch records persist `item.pooled = true` in SQLite, not
217
222
  just the in-memory `activeProcesses._pooled` flag (which is wiped on engine
218
223
  restart) — the on-disk flag is what tells the restart-reattach path
219
- (`engine/cli.js`) that a live worker PID is a pooled lease, not a resumable
224
+ (`engine/operations/cli.js`) that a live worker PID is a pooled lease, not a resumable
220
225
  cold-spawned child process.
221
226
  If checkpoint steering hands a pooled dispatch to a detached cold resume,
222
227
  the engine clears `pooled` first and replaces the canonical dispatch PID file,
@@ -265,8 +270,8 @@ pool size trades some isolation for parallelism and fewer respawns.
265
270
 
266
271
  ### See Also (ACP pool)
267
272
 
268
- - `engine/agent-worker-pool.js` — pool mechanics, assignment strategy, JSDoc header.
269
- - `engine/pooled-agent-process.js` — the child_process-shaped facade and its
273
+ - `engine/agents/agent-worker-pool.js` — pool mechanics, assignment strategy, JSDoc header.
274
+ - `engine/agents/pooled-agent-process.js` — the child_process-shaped facade and its
270
275
  documented output-translation scope limits (no tool-call/model-announcement
271
276
  event synthesis — a deliberate parity gap, not an oversight).
272
277
  - `test/unit/agent-worker-pool.test.js`, `test/integration/agent-pool-dispatch.test.js`,
@@ -282,7 +287,7 @@ agent fleet to Copilot, and vice versa. Both paths fall through to
282
287
  `engine.defaultCli` (the fleet-wide default), but they never see each other's
283
288
  overrides.
284
289
 
285
- The helpers in `engine/shared.js` are the single source of truth for
290
+ The helpers in `engine/core/shared.js` are the single source of truth for
286
291
  runtime/model and cross-runtime policy resolution. Engine code MUST go through
287
292
  them instead of reading config keys directly.
288
293
 
@@ -303,10 +308,10 @@ Agent dispatch resolves the runtime once at spawn time:
303
308
  const runtime = resolveRuntime(shared.resolveAgentCli(agentConfig, engineConfig));
304
309
  ```
305
310
 
306
- CC / doc-chat resolves the runtime via `engine/llm.js` `_resolveRuntimeFor()`:
311
+ CC / doc-chat resolves the runtime via `engine/agents/llm.js` `_resolveRuntimeFor()`:
307
312
 
308
313
  ```js
309
- // engine/llm.js (~line 247)
314
+ // engine/agents/llm.js (~line 247)
310
315
  if (!runtimeName && callOpts.engineConfig) runtimeName = resolveCcCli(callOpts.engineConfig);
311
316
  ```
312
317
 
@@ -337,7 +342,7 @@ files.
337
342
  ## `--cli` / `--model` / `--effort` Knobs
338
343
 
339
344
  Three CLI flags switch the fleet without dashboard interaction. They are parsed
340
- by `engine/cli.js` `_parseRuntimeFlags()` and persist into `config.json`.
345
+ by `engine/operations/cli.js` `_parseRuntimeFlags()` and persist into `config.json`.
341
346
 
342
347
  | Flag | Persists to | Notes |
343
348
  |------|-------------|-------|
@@ -419,7 +424,7 @@ runtime-name branches, and harness-specific invocation config in core paths.
419
424
  3. Add unit coverage modeled on `test/unit/runtime-adapters.test.js`.
420
425
 
421
426
  Once registered, the dashboard `/api/runtimes` endpoint, the `--cli` flag
422
- validator, the agent CLI dropdown, the `engine/preflight.js` per-runtime binary
427
+ validator, the agent CLI dropdown, the `engine/agents/preflight.js` per-runtime binary
423
428
  check, and the model discovery cache all light up automatically. Use capability
424
429
  flags — never special-case in engine code.
425
430
 
@@ -431,5 +436,5 @@ flags — never special-case in engine code.
431
436
  the spike that produced the Copilot adapter; cite it when changing
432
437
  Copilot-specific capability flags.
433
438
  - `engine/runtimes/contract.js` — authoritative adapter contract and facade.
434
- - `engine/shared.js` `resolveAgentCli` / `resolveCcCli` etc. — the only
439
+ - `engine/core/shared.js` `resolveAgentCli` / `resolveCcCli` etc. — the only
435
440
  supported way to read runtime / model selection from config.
package/docs/security.md CHANGED
@@ -63,7 +63,7 @@ system. Its threat model:
63
63
  and CORS preflights — see `dashboard.js:6007–6091` (and additional
64
64
  `isAllowedOrigin` enforcement points in the SSE/CC handlers) and
65
65
  `shared.isAllowedOrigin` / `shared.buildSecurityHeaders` in
66
- [`engine/shared.js`](../engine/shared.js). Requests whose `Origin` (or
66
+ [`engine/core/shared.js`](../engine/core/shared.js). Requests whose `Origin` (or
67
67
  `Referer`, if `Origin` is absent) is not in the local allowlist are
68
68
  rejected with HTTP 403. Callers without an `Origin` header at all
69
69
  (Node `http.request`, `curl` without `-H Origin`, CLI tooling) are
@@ -93,7 +93,7 @@ system. Its threat model:
93
93
  Entries are matched verbatim against the request `Origin` header
94
94
  (scheme + host + port; no path, no wildcards). See
95
95
  `shared.isAllowedDashboardOrigin()` in
96
- [`engine/shared.js`](../engine/shared.js).
96
+ [`engine/core/shared.js`](../engine/core/shared.js).
97
97
 
98
98
  ### Residual risks tracked elsewhere
99
99
 
@@ -145,10 +145,10 @@ Structured review learning (see
145
145
  [team-memory.md](team-memory.md#security-and-trust-boundaries)) introduces a new
146
146
  memory-derived prompt layer, so it observes the same "memory is evidence, not an
147
147
  instruction channel" boundary as the rest of retrieval, plus review-specific
148
- defenses enforced at the persistence boundary in `engine/review-learning.js`:
148
+ defenses enforced at the persistence boundary in `engine/memory/review-learning.js`:
149
149
 
150
150
  - **Fenced, bounded injection.** Recalled lessons are wrapped with
151
- `engine/untrusted-fence.js` and capped at 4 records / 4 KiB, independent of the
151
+ `engine/core/untrusted-fence.js` and capped at 4 records / 4 KiB, independent of the
152
152
  generic memory budget. They carry provenance and instruct the agent to verify
153
153
  against live code.
154
154
  - **No raw reviewer prose is ever stored.** Candidate/lesson bodies are engine-
@@ -178,7 +178,7 @@ defenses enforced at the persistence boundary in `engine/review-learning.js`:
178
178
  PR metadata, or any other on-disk JSON Minions owns.
179
179
  - **Tokens are never intentionally logged.** Engine code that shells out to
180
180
  `gh` or the ADO CLI threads the token via per-call `GH_TOKEN=...`
181
- environment injection (see `engine/gh-token.js`), so the value never
181
+ environment injection (see `engine/providers/gh-token.js`), so the value never
182
182
  appears on a command line or in `live-output.log`.
183
183
  - **The log redactor is best-effort, not authoritative.** A best-effort
184
184
  redactor scrubs token-shaped strings from logs and agent output, but its
@@ -203,7 +203,7 @@ break operator workflows we want to preserve.
203
203
  content (pinned notes, `notes/inbox/*`, PR comment bodies,
204
204
  `humanFeedback.feedbackContent`, agent-memory, dashboard doc-chat document/selection
205
205
  blocks) inside `<UNTRUSTED-INPUT source="…">…</UNTRUSTED-INPUT>` fences via
206
- the helpers in `engine/untrusted-fence.js`. The sysprompt directive in
206
+ the helpers in `engine/core/untrusted-fence.js`. The sysprompt directive in
207
207
  `playbooks/shared-rules.md` (and `prompts/cc-system.md` for CC/doc-chat)
208
208
  teaches agents to treat fenced content as a quoted artifact and raise
209
209
  `securityFlags.injectionAttempt: true` in the completion report when they
@@ -88,11 +88,11 @@ Fallback entries are labeled `**By:** Engine (regex fallback)` so you can tell w
88
88
 
89
89
  ### Auto-Pruning
90
90
 
91
- When `notes.md` exceeds 50KB, the engine trims it to the cap (keeping the header and last 8 consolidations) but **does not silently discard** the older sections — every dropped section is appended to `notes/archive/notes-overflow.md` so nothing is lost (data-loss guard `_capNotesPreservingOverflow` in `engine/consolidation.js`, #218). This keeps the live file bounded while retaining recent institutional knowledge and preserving the rest in the archive.
91
+ When `notes.md` exceeds 50KB, the engine trims it to the cap (keeping the header and last 8 consolidations) but **does not silently discard** the older sections — every dropped section is appended to `notes/archive/notes-overflow.md` so nothing is lost (data-loss guard `_capNotesPreservingOverflow` in `engine/memory/consolidation.js`, #218). This keeps the live file bounded while retaining recent institutional knowledge and preserving the rest in the archive.
92
92
 
93
93
  ## 2. Per-Agent History
94
94
 
95
- Each agent's `history.md` retains its last 20 tasks. To bound prompt size, `engine/playbook.js` injects only the five most recent retained entries into the next dispatch.
95
+ Each agent's `history.md` retains its last 20 tasks. To bound prompt size, `engine/agents/playbook.js` injects only the five most recent retained entries into the next dispatch.
96
96
 
97
97
  ### Flow
98
98
 
@@ -200,7 +200,7 @@ deterministically. It is fully specified in
200
200
 
201
201
  Humans can leave actionable comments on ADO or GitHub PRs to trigger fix tasks;
202
202
  no `@minions` mention is required. The engine polls PR threads every ~12
203
- minutes (see `prPollCommentsEvery` in `engine/shared.js`) and dispatches fixes
203
+ minutes (see `prPollCommentsEvery` in `engine/core/shared.js`) and dispatches fixes
204
204
  to the PR's author agent.
205
205
 
206
206
  ### Flow
@@ -218,7 +218,7 @@ Human comments on PR with "fix the error handling here"
218
218
  ### How it works
219
219
 
220
220
  - **Trigger:** Any human comment newer than the per-PR cutoff that survives `_isNonActionableComment()` (preview/CI/Minions-author filter) flips `pr.humanFeedback.pendingFix = true` and queues a fix. There is no "@minions keyword required" gate — `@minions` mentions are merely stripped from `feedbackContent` before it is handed to the fix agent.
221
- - **Agent detection:** Comments are filtered via `_isNonActionableComment()` in `engine/github.js` / `engine/ado.js`, which composes the body-only predicates from `engine/comment-classifier.js` (`isPreviewStatusBody`, `hasMinionsMarker`) with an identity gate (`viewerDidAuthor === true` on GitHub, `config.engine.minionsAdoIdentities` author match on ADO). Marker presence alone never classifies a comment as agent-authored on either platform.
221
+ - **Agent detection:** Comments are filtered via `_isNonActionableComment()` in `engine/providers/github.js` / `engine/ado/index.js`, which composes the body-only predicates from `engine/providers/comment-classifier.js` (`isPreviewStatusBody`, `hasMinionsMarker`) with an identity gate through the shared `classifyMarkerAuthorship()` seam (`viewerDidAuthor` on GitHub, `config.engine.minionsAdoIdentities` author match on ADO). Marker presence plus an identity *mismatch* never classifies a comment as agent-authored; marker presence with *no usable identity signal* fails safe and does (W-msbf1kf6033f46cb).
222
222
  - **Dedup:** Only comments newer than `pr.humanFeedback.lastProcessedCommentDate` are processed
223
223
  - **Multiple comments:** All new actionable comments since the cutoff are concatenated chronologically into a single fix task (each body individually fenced in `<UNTRUSTED-INPUT>` per F5 / W-mpeklod3000we69c)
224
224
  - **After fix:** `pendingFix` is cleared; PR re-enters normal review cycle