claude-code-session-manager 0.98.0 → 0.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (431) hide show
  1. package/README.md +3 -3
  2. package/bin/cli.cjs +16 -4
  3. package/bin/node-floor.cjs +41 -0
  4. package/dist/assets/{DataModel-DCEgMTjH.js → DataModel-HdR0AxFq.js} +1 -1
  5. package/dist/assets/{History-Bfdoywlh.js → History-Dr4Jr_5z.js} +2 -2
  6. package/dist/assets/{Hooks-CKDJjTJV.js → Hooks-NhrvH3JP.js} +3 -3
  7. package/dist/assets/{Library-7akfgy67.js → Library-Dv_EtIMr.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-DDesiqet.js → MarkdownEditor-DTKDWV_n.js} +1 -1
  9. package/dist/assets/{McpServers-D4lZtXof.js → McpServers-M034G9B3.js} +2 -2
  10. package/dist/assets/{Memory-CeI8G1w5.js → Memory-DzF1B4gx.js} +6 -6
  11. package/dist/assets/{Permissions-BGleLja4.js → Permissions-DrgbSGWl.js} +3 -3
  12. package/dist/assets/{Plugins-P4eCXy_S.js → Plugins-Bd3ef35w.js} +2 -2
  13. package/dist/assets/{ProvenanceBadge-BFczzI1B.js → ProvenanceBadge-DcBHT1Iy.js} +1 -1
  14. package/dist/assets/{SaveBar-l9jnEMES.js → SaveBar-rimJem-Y.js} +1 -1
  15. package/dist/assets/Scheduler-DjgFJl2w.js +16 -0
  16. package/dist/assets/{ScopeSwitcher-CjJi8ST5.js → ScopeSwitcher-CnAzTBrl.js} +1 -1
  17. package/dist/assets/Settings-Dc1F_sSg.js +3 -0
  18. package/dist/assets/{SkillReferenceGraph-CjbO01Sg.js → SkillReferenceGraph-B9aZDecM.js} +1 -1
  19. package/dist/assets/{Skills-BxZ9_fCR.js → Skills-DRXd18gu.js} +2 -2
  20. package/dist/assets/{SystemPrompt-D8vfFb8b.js → SystemPrompt-ahy5-Fwe.js} +1 -1
  21. package/dist/assets/{TagLibrary-2vzUo7YL.js → TagLibrary-C_tToDeL.js} +1 -1
  22. package/dist/assets/{TiptapBody-B8ZfbK90.js → TiptapBody-DvdefS6K.js} +1 -1
  23. package/dist/assets/{Toggle-BbW4nGGf.js → Toggle-6Jl5Njc6.js} +1 -1
  24. package/dist/assets/{index-CKH5Uxik.css → index-Bta-hwud.css} +1 -1
  25. package/dist/assets/{index-Cd98Q1lD.js → index-vx8O73l8.js} +497 -502
  26. package/dist/assets/{settingsSchema-IhUfucCF.js → settingsSchema-D6iRguNV.js} +1 -1
  27. package/dist/index.html +2 -2
  28. package/package.json +25 -29
  29. package/plugins/CLAUDE.md +6 -6
  30. package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +21 -19
  31. package/plugins/session-manager-dev/skills/builder/SKILL.md +3 -3
  32. package/plugins/session-manager-dev/skills/develop/SKILL.md +254 -510
  33. package/plugins/session-manager-dev/skills/develop/standards.md +17 -22
  34. package/scripts/README.md +3 -11
  35. package/scripts/audit-ops-hygiene.cjs +3 -3
  36. package/scripts/hooks/lib/guard-prd-writes-policy.cjs +1 -1
  37. package/scripts/hooks/lib/guard-self-schedule-policy.cjs +1 -1
  38. package/scripts/mint-epic.cjs +2 -3
  39. package/scripts/scheduler-mcp-server.cjs +36 -7
  40. package/src/main/agentLibrary.cjs +22 -2
  41. package/src/main/build-info.json +4 -4
  42. package/src/main/config.cjs +41 -38
  43. package/src/main/docEdit.cjs +4 -1
  44. package/src/main/files.cjs +2 -5
  45. package/src/main/health.cjs +1 -1
  46. package/src/main/index.cjs +23 -10
  47. package/src/main/ipcSchemas.cjs +28 -35
  48. package/src/main/lib/agentPersonaSchema.cjs +13 -2
  49. package/src/main/lib/atomicFs.cjs +116 -0
  50. package/src/main/lib/branchSweep.cjs +13 -12
  51. package/src/main/lib/buildTarget.cjs +3 -3
  52. package/src/main/lib/claudeCliCaps.cjs +129 -0
  53. package/src/main/lib/credentials.cjs +2 -4
  54. package/src/main/lib/crossProjectFeedback.cjs +3 -3
  55. package/src/main/lib/cwdClassify.cjs +15 -3
  56. package/src/main/lib/definitionOfDone.cjs +207 -125
  57. package/src/main/lib/dodDrainHook.cjs +11 -5
  58. package/src/main/lib/epicMint.cjs +2 -4
  59. package/src/main/lib/epicStatusMirror.cjs +8 -10
  60. package/src/main/lib/epicWorktreeProjectConfig.cjs +2 -4
  61. package/src/main/lib/gateAuthority.cjs +96 -0
  62. package/src/main/lib/gitExec.cjs +69 -0
  63. package/src/main/lib/gitWorktree.cjs +656 -92
  64. package/src/main/lib/instanceLock.cjs +5 -8
  65. package/src/main/lib/launchFailure.cjs +2 -3
  66. package/src/main/lib/macroLibrary.cjs +386 -0
  67. package/src/main/lib/mcpToolCatalog.cjs +26 -17
  68. package/src/main/lib/needsReviewLedger.cjs +1 -1
  69. package/src/main/lib/opsErrorLog.cjs +11 -1
  70. package/src/main/lib/opsOwnership.cjs +0 -5
  71. package/src/main/lib/pidAlive.cjs +32 -0
  72. package/src/main/lib/prdCreate.cjs +121 -12
  73. package/src/main/lib/prdDisposition.cjs +2 -2
  74. package/src/main/lib/prdGateFiles.cjs +284 -0
  75. package/src/main/lib/prdLocations.cjs +61 -0
  76. package/src/main/lib/prdMigration.cjs +2 -3
  77. package/src/main/lib/prdSizing.cjs +2 -1
  78. package/src/main/lib/promptSessionSchema.cjs +10 -2
  79. package/src/main/lib/rcaReport.cjs +4 -6
  80. package/src/main/lib/reaperHelpers.cjs +8 -1
  81. package/src/main/lib/reservationExpiry.cjs +6 -1
  82. package/src/main/lib/reviewNotice.cjs +263 -0
  83. package/src/main/lib/runClaudeP.cjs +4 -1
  84. package/src/main/lib/schedulerPaths.cjs +22 -2
  85. package/src/main/lib/sessionSlots.cjs +2 -4
  86. package/src/main/lib/shippedPersonaSeeds.cjs +179 -0
  87. package/src/main/lib/timeoutShim.cjs +123 -0
  88. package/src/main/lib/timeoutShimScript.cjs +275 -0
  89. package/src/main/lib/upgradeDrain.cjs +4 -10
  90. package/src/main/lib/watchdogHelpers.cjs +12 -25
  91. package/src/main/lib/workTypeLibrary.cjs +7 -1
  92. package/src/main/promptSessionEvents.cjs +37 -13
  93. package/src/main/scheduler.cjs +910 -198
  94. package/src/main/seedAgentPersonas.cjs +278 -23
  95. package/src/main/supervisor.cjs +4 -1
  96. package/src/main/templates/PRD_AUTHORING.md +126 -406
  97. package/src/preload/__tests__/preload-surface.test.cjs +68 -0
  98. package/src/preload/api.d.ts +41 -94
  99. package/src/preload/index.cjs +14 -9
  100. package/src/seed/agents/architect.md +1 -0
  101. package/src/seed/agents/dev-lead.md +17 -18
  102. package/src/seed/agents/project-home-builder.md +1 -0
  103. package/src/seed/agents/validator.md +10 -4
  104. package/dist/assets/HostBilko-CDVHE0hT.js +0 -1
  105. package/dist/assets/Scheduler-C_phpeUS.js +0 -16
  106. package/dist/assets/Settings-BIwZ3FGQ.js +0 -3
  107. package/src/main/__tests__/activeIndexMerge.test.cjs +0 -235
  108. package/src/main/__tests__/agentEffortResolve.test.cjs +0 -117
  109. package/src/main/__tests__/agentLibrary.test.cjs +0 -276
  110. package/src/main/__tests__/agentModelResolve.test.cjs +0 -311
  111. package/src/main/__tests__/agentOverlayWrite.test.cjs +0 -95
  112. package/src/main/__tests__/bilkoHost-deriveSlug.test.cjs +0 -26
  113. package/src/main/__tests__/bilkoHost-integration.test.cjs +0 -118
  114. package/src/main/__tests__/bilkoHostCore.test.cjs +0 -72
  115. package/src/main/__tests__/broadcastCoalescer.test.cjs +0 -122
  116. package/src/main/__tests__/chat-cancel-terminal.test.cjs +0 -120
  117. package/src/main/__tests__/chat-dead-channels.test.cjs +0 -63
  118. package/src/main/__tests__/chat-exit-close-race.test.cjs +0 -146
  119. package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +0 -139
  120. package/src/main/__tests__/chat-preamble-anchors.test.cjs +0 -100
  121. package/src/main/__tests__/chat-queue.test.cjs +0 -97
  122. package/src/main/__tests__/chat-stop-signal.test.cjs +0 -89
  123. package/src/main/__tests__/chatRunner-epic-worktree-execcwd.test.cjs +0 -125
  124. package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +0 -252
  125. package/src/main/__tests__/classifyPromptTicket.test.cjs +0 -101
  126. package/src/main/__tests__/classifyTranscriptLine.test.cjs +0 -201
  127. package/src/main/__tests__/computeDepHistorySatisfaction.test.cjs +0 -66
  128. package/src/main/__tests__/config-readText-bounded.test.cjs +0 -84
  129. package/src/main/__tests__/configWriteBoundaryOwners.test.cjs +0 -59
  130. package/src/main/__tests__/crossProjectFeedback.test.cjs +0 -334
  131. package/src/main/__tests__/crossProjectFeedbackRoutes.test.cjs +0 -161
  132. package/src/main/__tests__/dep-orphan-archive-health.test.cjs +0 -77
  133. package/src/main/__tests__/develop-skill-failure-modes.test.cjs +0 -70
  134. package/src/main/__tests__/docEdit.test.cjs +0 -244
  135. package/src/main/__tests__/dod-batchkey.test.cjs +0 -183
  136. package/src/main/__tests__/dod-drain-hook.test.cjs +0 -302
  137. package/src/main/__tests__/dod-report.test.cjs +0 -304
  138. package/src/main/__tests__/dod-reverify.test.cjs +0 -285
  139. package/src/main/__tests__/epicContextDigest.test.cjs +0 -174
  140. package/src/main/__tests__/epicMint.test.cjs +0 -332
  141. package/src/main/__tests__/epicMintTelemetryTap.test.cjs +0 -64
  142. package/src/main/__tests__/epicStatusMirror.test.cjs +0 -110
  143. package/src/main/__tests__/epicValidationHook.test.cjs +0 -291
  144. package/src/main/__tests__/exchanges.test.cjs +0 -122
  145. package/src/main/__tests__/exchangesPromptId.test.cjs +0 -61
  146. package/src/main/__tests__/extractJson.test.cjs +0 -51
  147. package/src/main/__tests__/files-reject-credentials.test.cjs +0 -40
  148. package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +0 -556
  149. package/src/main/__tests__/flatPrdTickSweep.test.cjs +0 -110
  150. package/src/main/__tests__/health-build-freshness.test.cjs +0 -39
  151. package/src/main/__tests__/health-claude-md-budget.test.cjs +0 -57
  152. package/src/main/__tests__/health-credentials.test.cjs +0 -81
  153. package/src/main/__tests__/health-delegation-chain.test.cjs +0 -124
  154. package/src/main/__tests__/health-per-project-stall.test.cjs +0 -84
  155. package/src/main/__tests__/health-prd-migration.test.cjs +0 -37
  156. package/src/main/__tests__/health-queue-dispatch.test.cjs +0 -135
  157. package/src/main/__tests__/health-starve-escalation.test.cjs +0 -94
  158. package/src/main/__tests__/health-tick-liveness.test.cjs +0 -179
  159. package/src/main/__tests__/health-usage-poller.test.cjs +0 -144
  160. package/src/main/__tests__/health-worktree-cap-blocked.test.cjs +0 -65
  161. package/src/main/__tests__/heapSnapshot.test.cjs +0 -121
  162. package/src/main/__tests__/historyAggregatorIntraday.test.cjs +0 -313
  163. package/src/main/__tests__/historyDashboard.test.cjs +0 -163
  164. package/src/main/__tests__/historyRollup.test.cjs +0 -333
  165. package/src/main/__tests__/intradayRefresh.test.cjs +0 -39
  166. package/src/main/__tests__/ipcSchemas-dependsOn.test.cjs +0 -39
  167. package/src/main/__tests__/kg-augment.test.cjs +0 -195
  168. package/src/main/__tests__/loadGateDetailTick.test.cjs +0 -31
  169. package/src/main/__tests__/machineProfile.test.cjs +0 -152
  170. package/src/main/__tests__/mcpStatus.test.cjs +0 -61
  171. package/src/main/__tests__/memoryAggregate.test.cjs +0 -109
  172. package/src/main/__tests__/memoryStale.test.cjs +0 -88
  173. package/src/main/__tests__/needsReviewLedger.test.cjs +0 -162
  174. package/src/main/__tests__/openExternalApp-spawn-error.test.cjs +0 -25
  175. package/src/main/__tests__/opsErrorLog.test.cjs +0 -109
  176. package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +0 -173
  177. package/src/main/__tests__/personaMerge.test.cjs +0 -169
  178. package/src/main/__tests__/planValidator.test.cjs +0 -125
  179. package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +0 -176
  180. package/src/main/__tests__/prd-group-allocator.test.cjs +0 -119
  181. package/src/main/__tests__/prdAdminRouteParity.test.cjs +0 -70
  182. package/src/main/__tests__/prdAdminRoutes.test.cjs +0 -718
  183. package/src/main/__tests__/prdAgentType.test.cjs +0 -103
  184. package/src/main/__tests__/prdAuthoringSeed.test.cjs +0 -39
  185. package/src/main/__tests__/prdCreate.test.cjs +0 -979
  186. package/src/main/__tests__/prdCreateAdoption.test.cjs +0 -205
  187. package/src/main/__tests__/prdCreateDisposition.test.cjs +0 -201
  188. package/src/main/__tests__/prdCreatePlanId.test.cjs +0 -132
  189. package/src/main/__tests__/prdFrontmatterAgentType.test.cjs +0 -117
  190. package/src/main/__tests__/prdFrontmatterDependsOn.test.cjs +0 -136
  191. package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +0 -125
  192. package/src/main/__tests__/prdFrontmatterQuietMachine.test.cjs +0 -108
  193. package/src/main/__tests__/prdLocations.test.cjs +0 -195
  194. package/src/main/__tests__/prdLocationsArchived.test.cjs +0 -201
  195. package/src/main/__tests__/prdMigration.test.cjs +0 -349
  196. package/src/main/__tests__/prdMigrationLegacyAdopt.test.cjs +0 -91
  197. package/src/main/__tests__/prdParserHighWater.test.cjs +0 -74
  198. package/src/main/__tests__/prdParserSourcePromptId.test.cjs +0 -65
  199. package/src/main/__tests__/prdSetDisposition.test.cjs +0 -222
  200. package/src/main/__tests__/prdSizing.test.cjs +0 -106
  201. package/src/main/__tests__/prdSourcePromptIdBackfill.test.cjs +0 -118
  202. package/src/main/__tests__/prdUpdateDependsOn.test.cjs +0 -160
  203. package/src/main/__tests__/proc-role-env.test.cjs +0 -125
  204. package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +0 -304
  205. package/src/main/__tests__/procname-sm-processes.test.cjs +0 -127
  206. package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +0 -177
  207. package/src/main/__tests__/projectPages.test.cjs +0 -137
  208. package/src/main/__tests__/promptSessionEvents.test.cjs +0 -234
  209. package/src/main/__tests__/promptSessionSchema.test.cjs +0 -101
  210. package/src/main/__tests__/promptSessionTranscript.test.cjs +0 -0
  211. package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +0 -159
  212. package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +0 -282
  213. package/src/main/__tests__/pty-session-open-telemetry.test.cjs +0 -96
  214. package/src/main/__tests__/pty-write-result.test.cjs +0 -46
  215. package/src/main/__tests__/queue-health-verdict.test.cjs +0 -170
  216. package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +0 -286
  217. package/src/main/__tests__/queue-starvation-per-project.test.cjs +0 -147
  218. package/src/main/__tests__/queueHistory.test.cjs +0 -355
  219. package/src/main/__tests__/queueOps-interactive-ac-lint.test.cjs +0 -65
  220. package/src/main/__tests__/queueOpsArchiveDestination.test.cjs +0 -65
  221. package/src/main/__tests__/queueOpsAutoArchive.test.cjs +0 -211
  222. package/src/main/__tests__/rateLimitPollerStreak.test.cjs +0 -128
  223. package/src/main/__tests__/rcaReport.test.cjs +0 -266
  224. package/src/main/__tests__/reconcileFlatPrdSweep.test.cjs +0 -119
  225. package/src/main/__tests__/reconcileTiming.test.cjs +0 -135
  226. package/src/main/__tests__/runLogRetention.test.cjs +0 -489
  227. package/src/main/__tests__/runVerify-atomic-verdicts.test.cjs +0 -26
  228. package/src/main/__tests__/runVerify-blocked-by-foreign-wip.test.cjs +0 -58
  229. package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +0 -191
  230. package/src/main/__tests__/runVerify-policy-denial.test.cjs +0 -89
  231. package/src/main/__tests__/runVerify-transcript-commit-evidence.test.cjs +0 -225
  232. package/src/main/__tests__/runVerify.test.cjs +0 -1784
  233. package/src/main/__tests__/scheduleJobSchema.test.cjs +0 -127
  234. package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +0 -65
  235. package/src/main/__tests__/scheduleJobTransitions.test.cjs +0 -277
  236. package/src/main/__tests__/scheduleJobTransitionsGrep.test.cjs +0 -59
  237. package/src/main/__tests__/scheduleJobTransitionsTelemetryTap.test.cjs +0 -72
  238. package/src/main/__tests__/scheduler-admin-routes.test.cjs +0 -199
  239. package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +0 -143
  240. package/src/main/__tests__/scheduler-already-satisfied-on-main.test.cjs +0 -105
  241. package/src/main/__tests__/scheduler-archive-completed-prd.test.cjs +0 -102
  242. package/src/main/__tests__/scheduler-archived-twin-guard.test.cjs +0 -155
  243. package/src/main/__tests__/scheduler-autofix-outcome.test.cjs +0 -188
  244. package/src/main/__tests__/scheduler-autofix-select.test.cjs +0 -439
  245. package/src/main/__tests__/scheduler-autopromote.test.cjs +0 -51
  246. package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +0 -101
  247. package/src/main/__tests__/scheduler-blocked-by-foreign-wip.test.cjs +0 -107
  248. package/src/main/__tests__/scheduler-boot-orphans.test.cjs +0 -153
  249. package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +0 -121
  250. package/src/main/__tests__/scheduler-clear-queue-history.test.cjs +0 -134
  251. package/src/main/__tests__/scheduler-commit-guard-noop.test.cjs +0 -244
  252. package/src/main/__tests__/scheduler-committed-in-window.test.cjs +0 -182
  253. package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +0 -43
  254. package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +0 -168
  255. package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +0 -58
  256. package/src/main/__tests__/scheduler-effective-concurrency.test.cjs +0 -81
  257. package/src/main/__tests__/scheduler-epic-digest.test.cjs +0 -227
  258. package/src/main/__tests__/scheduler-failed-autoreset.test.cjs +0 -121
  259. package/src/main/__tests__/scheduler-finalize-dispatch-guards.test.cjs +0 -229
  260. package/src/main/__tests__/scheduler-find-prd-dir.test.cjs +0 -75
  261. package/src/main/__tests__/scheduler-fix-plan-path.test.cjs +0 -119
  262. package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +0 -46
  263. package/src/main/__tests__/scheduler-foreign-wip-manifest.test.cjs +0 -78
  264. package/src/main/__tests__/scheduler-gate-shadow.test.cjs +0 -119
  265. package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +0 -390
  266. package/src/main/__tests__/scheduler-heal-refusal.test.cjs +0 -61
  267. package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +0 -80
  268. package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +0 -323
  269. package/src/main/__tests__/scheduler-integration-failure-stamp.test.cjs +0 -41
  270. package/src/main/__tests__/scheduler-investigation-clean-skip.test.cjs +0 -63
  271. package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +0 -123
  272. package/src/main/__tests__/scheduler-job-budget.test.cjs +0 -172
  273. package/src/main/__tests__/scheduler-job-overrun.test.cjs +0 -175
  274. package/src/main/__tests__/scheduler-launch-failure.test.cjs +0 -199
  275. package/src/main/__tests__/scheduler-leftover-fields.test.cjs +0 -52
  276. package/src/main/__tests__/scheduler-leftover-quarantine.test.cjs +0 -199
  277. package/src/main/__tests__/scheduler-looks-done.test.cjs +0 -537
  278. package/src/main/__tests__/scheduler-manual-pause.test.cjs +0 -118
  279. package/src/main/__tests__/scheduler-mechanical-recovery.test.cjs +0 -245
  280. package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +0 -46
  281. package/src/main/__tests__/scheduler-mutate-reentrancy.test.cjs +0 -117
  282. package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +0 -197
  283. package/src/main/__tests__/scheduler-never-stop.test.cjs +0 -157
  284. package/src/main/__tests__/scheduler-no-dead-end-status.test.cjs +0 -152
  285. package/src/main/__tests__/scheduler-no-orphan-run-dir.test.cjs +0 -81
  286. package/src/main/__tests__/scheduler-notify-originating-tab-transcript.test.cjs +0 -87
  287. package/src/main/__tests__/scheduler-notify-originating-tab.test.cjs +0 -343
  288. package/src/main/__tests__/scheduler-periodic-reverify-guard.test.cjs +0 -217
  289. package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +0 -164
  290. package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +0 -161
  291. package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +0 -178
  292. package/src/main/__tests__/scheduler-quarantine-autoresolve.test.cjs +0 -165
  293. package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +0 -257
  294. package/src/main/__tests__/scheduler-rate-limit-cooldown-freshness.test.cjs +0 -123
  295. package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +0 -152
  296. package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +0 -156
  297. package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +0 -754
  298. package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +0 -87
  299. package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +0 -100
  300. package/src/main/__tests__/scheduler-reconcile-history-backfill.test.cjs +0 -105
  301. package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +0 -203
  302. package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +0 -247
  303. package/src/main/__tests__/scheduler-reset-job-fields-guard.test.cjs +0 -77
  304. package/src/main/__tests__/scheduler-resume-recovery.test.cjs +0 -254
  305. package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +0 -115
  306. package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +0 -380
  307. package/src/main/__tests__/scheduler-sigterm-commit.test.cjs +0 -43
  308. package/src/main/__tests__/scheduler-stall-per-project.test.cjs +0 -126
  309. package/src/main/__tests__/scheduler-starve-escalation.test.cjs +0 -154
  310. package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +0 -252
  311. package/src/main/__tests__/scheduler-stranded-investigation.test.cjs +0 -185
  312. package/src/main/__tests__/scheduler-stuck-failed-escalation.test.cjs +0 -136
  313. package/src/main/__tests__/scheduler-supervisor-record.test.cjs +0 -81
  314. package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +0 -54
  315. package/src/main/__tests__/scheduler-tick-wedge.test.cjs +0 -172
  316. package/src/main/__tests__/scheduler-transient-failure.test.cjs +0 -141
  317. package/src/main/__tests__/scheduler-unreadable-queue-guard.test.cjs +0 -62
  318. package/src/main/__tests__/scheduler-utilization-hold.test.cjs +0 -89
  319. package/src/main/__tests__/scheduler-verify-prd-path.test.cjs +0 -109
  320. package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +0 -234
  321. package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +0 -120
  322. package/src/main/__tests__/scheduler-writeprd-epic-rollback.test.cjs +0 -105
  323. package/src/main/__tests__/schedulerBatchRootBlocker.test.cjs +0 -117
  324. package/src/main/__tests__/schedulerStateSidecarRestore.test.cjs +0 -110
  325. package/src/main/__tests__/seedAgentPersonas.test.cjs +0 -184
  326. package/src/main/__tests__/seedSchedulerMcp.test.cjs +0 -211
  327. package/src/main/__tests__/seedStatus.test.cjs +0 -100
  328. package/src/main/__tests__/seedValidatorPersona.test.cjs +0 -116
  329. package/src/main/__tests__/stop-signal-anchor.test.cjs +0 -75
  330. package/src/main/__tests__/telemetryClient.test.cjs +0 -1055
  331. package/src/main/__tests__/telemetryContract.test.cjs +0 -930
  332. package/src/main/__tests__/telemetrySettings.test.cjs +0 -210
  333. package/src/main/__tests__/transcripts-batch-flush.test.cjs +0 -249
  334. package/src/main/__tests__/transcripts-doFlush-array.test.cjs +0 -124
  335. package/src/main/__tests__/transcripts-paged-reads.test.cjs +0 -241
  336. package/src/main/__tests__/transcripts-worktree-epic-path.test.cjs +0 -154
  337. package/src/main/__tests__/transcriptsUsageFor.test.cjs +0 -206
  338. package/src/main/__tests__/uniquePrdNumbers.test.cjs +0 -153
  339. package/src/main/__tests__/usageSingleFlight.test.cjs +0 -169
  340. package/src/main/__tests__/validationSentinels.test.cjs +0 -84
  341. package/src/main/__tests__/workTypeLibrary.test.cjs +0 -89
  342. package/src/main/bilkoHost.cjs +0 -314
  343. package/src/main/bilkoHostCore.cjs +0 -89
  344. package/src/main/lib/__tests__/active-sessions.test.cjs +0 -251
  345. package/src/main/lib/__tests__/activeIndexRebuild.test.cjs +0 -179
  346. package/src/main/lib/__tests__/agentPersonaSchema.test.cjs +0 -67
  347. package/src/main/lib/__tests__/auditLog.test.cjs +0 -38
  348. package/src/main/lib/__tests__/bootSelfHeal.test.cjs +0 -107
  349. package/src/main/lib/__tests__/branchSweep.test.cjs +0 -164
  350. package/src/main/lib/__tests__/buildIdentity.test.cjs +0 -121
  351. package/src/main/lib/__tests__/buildTarget.test.cjs +0 -52
  352. package/src/main/lib/__tests__/childWithLog.test.cjs +0 -321
  353. package/src/main/lib/__tests__/coldBootPromptSessionsWrite.test.cjs +0 -87
  354. package/src/main/lib/__tests__/crashTelemetry.test.cjs +0 -103
  355. package/src/main/lib/__tests__/credentials-futile-refresh.test.cjs +0 -115
  356. package/src/main/lib/__tests__/cwdClassify.test.cjs +0 -111
  357. package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +0 -95
  358. package/src/main/lib/__tests__/delegationReadiness.test.cjs +0 -1175
  359. package/src/main/lib/__tests__/dispatchLoop.test.cjs +0 -63
  360. package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +0 -244
  361. package/src/main/lib/__tests__/ephemeralCwd.test.cjs +0 -91
  362. package/src/main/lib/__tests__/epicDelegationStats.test.cjs +0 -137
  363. package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +0 -283
  364. package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +0 -196
  365. package/src/main/lib/__tests__/epicTranscriptPath.test.cjs +0 -163
  366. package/src/main/lib/__tests__/epicWorktreeBoot.test.cjs +0 -136
  367. package/src/main/lib/__tests__/epicWorktreeMerge.test.cjs +0 -130
  368. package/src/main/lib/__tests__/epicWorktreeMint.test.cjs +0 -117
  369. package/src/main/lib/__tests__/epicWorktreeProjectConfig.test.cjs +0 -137
  370. package/src/main/lib/__tests__/fixChainDepth.test.cjs +0 -40
  371. package/src/main/lib/__tests__/fixtures/204-mercury-steam-horse.log.txt +0 -13
  372. package/src/main/lib/__tests__/fixtures/scheduler-machine.json.corrupt-1789147548 +0 -34
  373. package/src/main/lib/__tests__/gateFixtures.json +0 -20
  374. package/src/main/lib/__tests__/gitCacheBound.test.cjs +0 -69
  375. package/src/main/lib/__tests__/gitWorktree.test.cjs +0 -1478
  376. package/src/main/lib/__tests__/gitWorktreeSalvage.test.cjs +0 -107
  377. package/src/main/lib/__tests__/gitWorktreeSalvageDelta.test.cjs +0 -153
  378. package/src/main/lib/__tests__/guardShims.test.cjs +0 -158
  379. package/src/main/lib/__tests__/importReferences.spec.cjs +0 -56
  380. package/src/main/lib/__tests__/instanceLock.test.cjs +0 -173
  381. package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +0 -78
  382. package/src/main/lib/__tests__/jobWorktree.test.cjs +0 -199
  383. package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +0 -82
  384. package/src/main/lib/__tests__/landedSinceRun.test.cjs +0 -133
  385. package/src/main/lib/__tests__/launchFailure.test.cjs +0 -220
  386. package/src/main/lib/__tests__/loadGate.test.cjs +0 -303
  387. package/src/main/lib/__tests__/localAdminHttp.test.cjs +0 -214
  388. package/src/main/lib/__tests__/loopDelay.test.cjs +0 -68
  389. package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +0 -107
  390. package/src/main/lib/__tests__/modelCatalog.test.cjs +0 -202
  391. package/src/main/lib/__tests__/opsOwnership.test.cjs +0 -113
  392. package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +0 -328
  393. package/src/main/lib/__tests__/opsRootNestedWrite.test.cjs +0 -51
  394. package/src/main/lib/__tests__/opsRootResolve.test.cjs +0 -149
  395. package/src/main/lib/__tests__/prdDeclaredPaths.test.cjs +0 -82
  396. package/src/main/lib/__tests__/prdDisposition.test.cjs +0 -224
  397. package/src/main/lib/__tests__/procIdentity.test.cjs +0 -119
  398. package/src/main/lib/__tests__/procName.test.cjs +0 -92
  399. package/src/main/lib/__tests__/projectBriefCore.test.cjs +0 -216
  400. package/src/main/lib/__tests__/projectRootResolve.test.cjs +0 -148
  401. package/src/main/lib/__tests__/queueHealth.test.cjs +0 -58
  402. package/src/main/lib/__tests__/queueStoreAtomicWrite.test.cjs +0 -88
  403. package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +0 -190
  404. package/src/main/lib/__tests__/quietMachineLease.test.cjs +0 -39
  405. package/src/main/lib/__tests__/rateLimitWindow.test.cjs +0 -88
  406. package/src/main/lib/__tests__/reaperHelpers.test.cjs +0 -577
  407. package/src/main/lib/__tests__/schedulerBatchDepends.test.cjs +0 -312
  408. package/src/main/lib/__tests__/schedulerBatchFairness.test.cjs +0 -213
  409. package/src/main/lib/__tests__/schedulerBatchLaunchHold.test.cjs +0 -125
  410. package/src/main/lib/__tests__/schedulerBatchProjectCap.test.cjs +0 -127
  411. package/src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs +0 -109
  412. package/src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs +0 -71
  413. package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +0 -216
  414. package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +0 -183
  415. package/src/main/lib/__tests__/schedulerPaths.test.cjs +0 -226
  416. package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +0 -133
  417. package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +0 -56
  418. package/src/main/lib/__tests__/sessionSlots.test.cjs +0 -144
  419. package/src/main/lib/__tests__/telemetryBacklog.test.cjs +0 -626
  420. package/src/main/lib/__tests__/telemetryBoot.test.cjs +0 -134
  421. package/src/main/lib/__tests__/telemetryConsent.test.cjs +0 -136
  422. package/src/main/lib/__tests__/telemetryCounters.test.cjs +0 -57
  423. package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +0 -98
  424. package/src/main/lib/__tests__/terminalRunOutcome.test.cjs +0 -200
  425. package/src/main/lib/__tests__/toolUseClassify.test.cjs +0 -53
  426. package/src/main/lib/__tests__/updateCheck.test.cjs +0 -63
  427. package/src/main/lib/__tests__/upgradeDrain.test.cjs +0 -130
  428. package/src/main/lib/__tests__/usageCircuit.test.cjs +0 -354
  429. package/src/main/lib/__tests__/watchdog-helpers.test.cjs +0 -441
  430. package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +0 -266
  431. package/src/main/lib/kgExchangePairing.cjs +0 -75
@@ -11,6 +11,7 @@ const fs = require('node:fs');
11
11
  const path = require('node:path');
12
12
  const { readTail } = require('./fileTail.cjs');
13
13
  const { detectRateLimitInLog } = require('./rateLimitDetect.cjs');
14
+ const { pidAlive } = require('./pidAlive.cjs');
14
15
 
15
16
  /**
16
17
  * Return true if pid is alive AND its cmdline looks like a claude process.
@@ -20,12 +21,18 @@ const { detectRateLimitInLog } = require('./rateLimitDetect.cjs');
20
21
  * cmdline, so we conservatively return true — never false-reap a live PID
21
22
  * just because we can't verify its identity.
22
23
  *
24
+ * Existence check now delegates to the shared pidAlive() (pidAlive.cjs) so
25
+ * EPERM (pid exists, owned by another user) counts as alive here too — the
26
+ * previous bare `process.kill(pid, 0)` + catch-all-false treated EPERM the
27
+ * same as ESRCH (no such process), silently false-reaping a live-but-
28
+ * unsignalable pid.
29
+ *
23
30
  * Conservative by design: a false negative (live process treated as dead) is
24
31
  * far worse than a late reap.
25
32
  */
26
33
  function claudePidAlive(pid) {
27
34
  if (!pid || typeof pid !== 'number' || pid <= 1) return false;
28
- try { process.kill(pid, 0); } catch { return false; }
35
+ if (!pidAlive(pid)) return false;
29
36
  try {
30
37
  const cmd = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8').replace(/\0/g, ' ');
31
38
  return /\bclaude\b/.test(cmd);
@@ -9,10 +9,15 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ const { pidAlive } = require('./pidAlive.cjs');
13
+
12
14
  const DEFAULT_GRACE_MS = 10 * 60 * 1000;
13
15
 
16
+ // Thin alias over pidAlive.cjs's shared pidAlive() — kept as its own named
17
+ // export (rather than inlining the require at every call site) so existing
18
+ // imports of `defaultPidAlive` from this module keep working unchanged.
14
19
  function defaultPidAlive(pid) {
15
- try { process.kill(pid, 0); return true; } catch (e) { return e?.code === 'EPERM'; }
20
+ return pidAlive(pid);
16
21
  }
17
22
 
18
23
  /**
@@ -0,0 +1,263 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * reviewNotice.cjs — pure helpers behind the quiet, grouped needs_review
5
+ * notice (this PRD).
6
+ *
7
+ * Before this module, a park into `needs_review` told the authoring Epic
8
+ * immediately (scheduler.cjs's notifyNeedsReview), BEFORE the scheduler's own
9
+ * recovery ladder (mechanical re-integration, resume, quarantine, auto-fix,
10
+ * gate re-run, bounded auto-resolve) ever got a chance to run. Most parks
11
+ * heal on their own, so that immediate message was usually a false alarm.
12
+ *
13
+ * The new rule: record a notice at park time (buildReviewNotice) and send
14
+ * nothing yet. Send ONE message, grouped by (cwd, Epic, cause), only once the
15
+ * ladder gives up on a row (an auto-resolve skip) or the row has sat
16
+ * `needs_review` past a hold window (selectDueReviewNotices + holdMsFromEnv).
17
+ * scheduler.cjs's flushDueReviewNotices is the only caller that actually
18
+ * sends — this module stays fs/network-free so it is unit-testable without
19
+ * touching queue.json or the Epic event store.
20
+ *
21
+ * Each park is one episode with one hold clock. scheduler.cjs's
22
+ * resetJobFields deletes `job.reviewNotice` outright, so a human reset always
23
+ * starts the next park's clock fresh — it never inherits a stale
24
+ * `firstParkedAt` from days earlier. A rung-6 ladder requeue goes through
25
+ * `transitionJob` directly, not `resetJobFields`, so that requeue keeps the
26
+ * same clock on purpose (it is still the same unresolved episode).
27
+ *
28
+ * The sent message also says plainly whether the group still blocks other
29
+ * work: formatReviewNotice names any `pending` row whose `dependsOn` names a
30
+ * still-`needs_review` row in the group, instead of always claiming nothing
31
+ * is waiting. And a row that is not yet due on its own only joins a due
32
+ * group — "sweeps in" — once it has sat for SWEEP_MIN_AGE_MINUTES, so a row
33
+ * that parked seconds ago is never announced before the ladder's early rungs
34
+ * get a chance to run.
35
+ */
36
+
37
+ // Default hold before an un-resolved needs_review park gets its own grouped
38
+ // notice, in minutes. Overridable via SM_REVIEW_NOTICE_HOLD_MINUTES.
39
+ const DEFAULT_HOLD_MINUTES = 240;
40
+
41
+ // Same dependsOn slug-matching rule schedulerBatch.cjs's findBlockingDep uses
42
+ // at run time (exact slug first, else bare-name after stripping one leading
43
+ // `NN-`) — reused here, not reimplemented, so formatReviewNotice's "blocks"
44
+ // wording can never disagree with what actually holds a dependent `pending`
45
+ // row in the real queue.
46
+ const { bareSlug } = require('./depSlugResolve.cjs');
47
+
48
+ /**
49
+ * buildReviewNotice({ job, report, epicId, now, prior }) → ReviewNotice
50
+ *
51
+ * Stamped onto a job row (`job.reviewNotice`) the moment it parks
52
+ * `needs_review`, in the SAME mutate that classifies the RCA report
53
+ * (scheduler.cjs's park path). `report` is rcaReport.cjs's writeRcaReport()
54
+ * result — `null`, or `{ filed: false, ... }` when the report was skipped
55
+ * (SM_RCA_DISABLE, no verdict, etc.) — in which case a deterministic fallback
56
+ * summary stands in for the one the RCA report would have carried.
57
+ *
58
+ * `firstParkedAt` is the anchor selectDueReviewNotices measures the hold
59
+ * window from. It is carried forward from `prior` (the job's existing
60
+ * reviewNotice, if any) as long as that prior notice is still unsent — a
61
+ * re-park of the SAME unresolved episode (e.g. one more ladder attempt that
62
+ * also fails) must not restart the hold clock. Once a notice has been sent,
63
+ * a later park starts a fresh clock — and so does a later park after a human
64
+ * reset, because resetJobFields deletes the notice outright, so `prior` is
65
+ * `undefined` and this falls to the same `now` default.
66
+ */
67
+ function buildReviewNotice({ job, report, epicId, now, prior } = {}) {
68
+ const cause = `${job?.verifierVerdict || 'unknown'}${job?.integrationFailureKind ? `:${job.integrationFailureKind}` : ''}`;
69
+ const filed = Boolean(report && report.filed);
70
+ const summary = filed ? report.summary : `${job?.slug ?? 'unknown job'} stopped (${cause})`;
71
+ const reportPath = filed ? (report.path ?? null) : null;
72
+ const firstParkedAt = prior && !prior.sentAt && prior.firstParkedAt ? prior.firstParkedAt : now;
73
+ return {
74
+ summary,
75
+ reportPath,
76
+ cause,
77
+ epicId: epicId ?? null,
78
+ firstParkedAt,
79
+ sentAt: null,
80
+ };
81
+ }
82
+
83
+ // A not-yet-due row only joins a due group ("sweeps in") once it has sat
84
+ // `needs_review` for at least this long. Why: the self-heal ladder
85
+ // (scheduler-operations.md §4) needs about 30 minutes to work through its
86
+ // early rungs, so sweeping in a row seconds after it parked would announce
87
+ // it before the ladder ever got a chance to self-heal it. A row that is due
88
+ // ON ITS OWN (its own hold expired, or a skipped auto-resolve) is never held
89
+ // back by this rule — see isDue below.
90
+ const SWEEP_MIN_AGE_MINUTES = 30;
91
+
92
+ // Milliseconds since reviewNotice.firstParkedAt, or 0 for a missing/
93
+ // unparsable timestamp (fail young — never treat a bad timestamp as old
94
+ // enough to sweep in early).
95
+ function parkedAgeMs(j, now) {
96
+ const firstParkedAt = j.reviewNotice && j.reviewNotice.firstParkedAt;
97
+ if (!firstParkedAt) return 0;
98
+ const parkedMs = Date.parse(firstParkedAt);
99
+ return Number.isFinite(parkedMs) ? now - parkedMs : 0;
100
+ }
101
+
102
+ /**
103
+ * selectDueReviewNotices(jobs, { now, holdMs }) → [{ cwd, epicId, cause, jobs }]
104
+ *
105
+ * A row is a candidate when it carries an unsent `reviewNotice` and is
106
+ * either `skipped` with `needsReviewAutoResolvedSkip` (the ladder gave up),
107
+ * or still `needs_review` with its notice's `firstParkedAt` at least
108
+ * `holdMs` in the past. completed/pending/running rows, and rows whose
109
+ * notice is already sent, are never candidates.
110
+ *
111
+ * Grouping key is (cwd, reviewNotice.epicId, reviewNotice.cause) — one
112
+ * message per distinct cause per Epic, not one per PRD. Once any row in a
113
+ * key is due, every other unsent candidate sharing that same key is swept
114
+ * into the SAME group even if it individually hasn't reached its own due
115
+ * condition yet, so a cause that affects several PRDs is reported once —
116
+ * except a swept-in `needs_review` row must itself be at least
117
+ * SWEEP_MIN_AGE_MINUTES old (parkedAgeMs); a row due on its own skips that
118
+ * check entirely.
119
+ */
120
+ function selectDueReviewNotices(jobs = [], { now = Date.now(), holdMs = DEFAULT_HOLD_MINUTES * 60000 } = {}) {
121
+ const isCandidate = (j) => Boolean(
122
+ j
123
+ && j.reviewNotice
124
+ && !j.reviewNotice.sentAt
125
+ && (j.status === 'needs_review' || (j.status === 'skipped' && j.needsReviewAutoResolvedSkip)),
126
+ );
127
+ const isDue = (j) => {
128
+ if (j.status === 'skipped' && j.needsReviewAutoResolvedSkip) return true;
129
+ if (j.status !== 'needs_review') return false;
130
+ const firstParkedAt = j.reviewNotice.firstParkedAt;
131
+ if (!firstParkedAt) return false;
132
+ const parkedMs = Date.parse(firstParkedAt);
133
+ if (!Number.isFinite(parkedMs)) return false;
134
+ return now - parkedMs >= holdMs;
135
+ };
136
+ const keyOf = (j) => `${j.cwd ?? ''}\u0000${j.reviewNotice.epicId ?? ''}\u0000${j.reviewNotice.cause ?? ''}`;
137
+
138
+ const list = Array.isArray(jobs) ? jobs : [];
139
+ const dueKeys = new Set();
140
+ for (const j of list) {
141
+ if (isCandidate(j) && isDue(j)) dueKeys.add(keyOf(j));
142
+ }
143
+ if (dueKeys.size === 0) return [];
144
+
145
+ const sweepMinAgeMs = SWEEP_MIN_AGE_MINUTES * 60000;
146
+ const groupsByKey = new Map();
147
+ for (const j of list) {
148
+ if (!isCandidate(j)) continue;
149
+ const key = keyOf(j);
150
+ if (!dueKeys.has(key)) continue;
151
+ // Not due on its own, and too young to sweep in — leave it for a later
152
+ // pass, once either its own hold expires or it ages past the sweep gate.
153
+ if (!isDue(j) && parkedAgeMs(j, now) < sweepMinAgeMs) continue;
154
+ if (!groupsByKey.has(key)) {
155
+ groupsByKey.set(key, { cwd: j.cwd ?? null, epicId: j.reviewNotice.epicId ?? null, cause: j.reviewNotice.cause ?? null, jobs: [] });
156
+ }
157
+ groupsByKey.get(key).jobs.push(j);
158
+ }
159
+ return Array.from(groupsByKey.values());
160
+ }
161
+
162
+ // Plain-language stand-in for the raw verifier/integration cause string.
163
+ // Only causes worth explaining in human terms get an entry — formatReviewNotice
164
+ // falls back to the raw cause for anything not listed here.
165
+ const HUMAN_CAUSE = {
166
+ 'worktree_integration_failed:stray_checkout': 'the main checkout was on a different branch, so the work could not be merged',
167
+ transcript_errors: "the run's transcript showed error lines, so its pass could not be trusted",
168
+ no_verdict_sentinel: 'the run finished without leaving a clear pass or fail signal',
169
+ abandoned_background_task: 'the run started a background task and then stopped watching it',
170
+ silent_no_op: 'the run finished clean but made no changes, so there is no evidence it did the work',
171
+ pass_no_commit: 'the run reported success but did not commit anything',
172
+ };
173
+
174
+ function humanCauseFor(cause) {
175
+ return HUMAN_CAUSE[cause] ?? cause;
176
+ }
177
+
178
+ // One phrase per ladder rung, in the fixed order the ladder itself runs
179
+ // (scheduler-operations.md §4). Checked across every row in the group — the
180
+ // summary is the union of what was tried for ANY of the grouped PRDs, not
181
+ // just one.
182
+ function ladderSummaryFor(jobs) {
183
+ const some = (pred) => jobs.some(pred);
184
+ const phrases = [];
185
+ if (some((j) => j.mechanicalRecoveryAttempted)) phrases.push('re-merged the branch');
186
+ if (some((j) => j.resumeRecoveryAttempted)) phrases.push('resumed the session');
187
+ if (some((j) => (j.quarantineResolveAttempts ?? 0) > 0)) phrases.push('set aside stray files');
188
+ if (some((j) => j.autoFixAttempted)) phrases.push('ran an auto-fix job');
189
+ if (some((j) => j.gateShadow)) phrases.push('re-ran the gate');
190
+ if (some((j) => (j.exhaustedResolveAttempts ?? 0) > 0)) phrases.push('re-queued the job');
191
+ if (some((j) => j.needsReviewAutoResolvedSkip)) phrases.push('gave up and skipped the job');
192
+ return phrases.length ? phrases.join(', ') : 'nothing yet';
193
+ }
194
+
195
+ // The pending rows (from the FULL job list, not just this group) that a
196
+ // still-`needs_review` row in the group blocks. A dep slug "names" a group
197
+ // row when it matches that row's slug exactly, or by bare name (same rule as
198
+ // findBlockingDep). Only rows in the group's own cwd are considered — a
199
+ // dependsOn chain never crosses projects. Returns a sorted, de-duplicated
200
+ // list of the blocked rows' slugs.
201
+ function blockedDependents(group, jobs) {
202
+ const blockingSlugs = (group.jobs ?? [])
203
+ .filter((j) => j.status === 'needs_review')
204
+ .map((j) => j.slug)
205
+ .filter(Boolean);
206
+ if (!blockingSlugs.length) return [];
207
+ const namesABlockingSlug = (depSlug) => blockingSlugs.some(
208
+ (slug) => depSlug === slug || bareSlug(depSlug) === bareSlug(slug),
209
+ );
210
+ const blocked = new Set();
211
+ for (const p of jobs ?? []) {
212
+ if (p.status !== 'pending' || p.cwd !== group.cwd) continue;
213
+ if ((p.dependsOn ?? []).some(namesABlockingSlug)) blocked.add(p.slug);
214
+ }
215
+ return [...blocked].sort();
216
+ }
217
+
218
+ /**
219
+ * formatReviewNotice(group, { jobs }) → plain-text message body for the
220
+ * authoring Epic's event chain. `group` is one entry from
221
+ * selectDueReviewNotices(). `jobs` is the FULL live job list (every status,
222
+ * every project) — needed to find any `pending` row this group still blocks;
223
+ * omit it (or pass `[]`) to always get the "nothing is waiting" wording,
224
+ * e.g. from a caller that only has the group itself.
225
+ */
226
+ function formatReviewNotice(group, { jobs = [] } = {}) {
227
+ const groupJobs = group.jobs ?? [];
228
+ const slugs = groupJobs.map((j) => j.slug).filter(Boolean);
229
+ const reportPaths = groupJobs.map((j) => j.reviewNotice?.reportPath).filter(Boolean);
230
+ const blocked = blockedDependents(group, jobs);
231
+ const waitingLine = blocked.length
232
+ ? `These PRDs block ${blocked.length} other PRD(s) until they are fixed, reset or archived: ${blocked.join(', ')}.`
233
+ : 'The rest of the plan keeps running. Nothing is waiting on you unless you want to act.';
234
+ const lines = [
235
+ `${groupJobs.length} PRD(s) stopped for the same reason: ${humanCauseFor(group.cause)}.`,
236
+ `The scheduler already tried to fix this on its own: ${ladderSummaryFor(groupJobs)}.`,
237
+ waitingLine,
238
+ `PRDs: ${slugs.join(', ')}`,
239
+ ];
240
+ if (reportPaths.length) lines.push(`Reports: ${reportPaths.join(', ')}`);
241
+ return lines.join('\n');
242
+ }
243
+
244
+ /**
245
+ * holdMsFromEnv(env) → milliseconds a needs_review park waits, with no
246
+ * ladder resolution, before it gets a grouped notice on its own (case b in
247
+ * selectDueReviewNotices). SM_REVIEW_NOTICE_HOLD_MINUTES must be a positive
248
+ * number; anything else (unset, zero, negative, NaN) falls back to the
249
+ * DEFAULT_HOLD_MINUTES default.
250
+ */
251
+ function holdMsFromEnv(env = process.env) {
252
+ const raw = Number(env.SM_REVIEW_NOTICE_HOLD_MINUTES);
253
+ const minutes = Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_HOLD_MINUTES;
254
+ return minutes * 60000;
255
+ }
256
+
257
+ module.exports = {
258
+ DEFAULT_HOLD_MINUTES,
259
+ buildReviewNotice,
260
+ selectDueReviewNotices,
261
+ formatReviewNotice,
262
+ holdMsFromEnv,
263
+ };
@@ -16,12 +16,14 @@
16
16
 
17
17
  const { spawn } = require('node:child_process');
18
18
  const { resolveClaudeBin, claudeSpawnTarget } = require('./claudeBin.cjs');
19
+ const { headlessPermissionArgs, ensureCliCapsProbed } = require('./claudeCliCaps.cjs');
19
20
  const { withProcRole } = require('./cleanEnv.cjs');
20
21
 
21
22
  const MAX_OUT_BYTES = 8 * 1024 * 1024;
22
23
 
23
24
  /** Spawn `claude -p`, capture stdout. Resolves {ok, out, error} — never throws. */
24
- function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPrompt = null } = {}) {
25
+ async function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPrompt = null } = {}) {
26
+ await ensureCliCapsProbed();
25
27
  return new Promise((resolve) => {
26
28
  let bin;
27
29
  try { bin = resolveClaudeBin(); } catch (e) { resolve({ ok: false, error: `claude not found: ${e?.message}` }); return; }
@@ -29,6 +31,7 @@ function runClaudeP(prompt, { model = 'sonnet', timeoutMs = 180_000, systemPromp
29
31
  '-p', prompt,
30
32
  '--model', model,
31
33
  '--dangerously-skip-permissions',
34
+ ...headlessPermissionArgs(),
32
35
  '--output-format', 'text',
33
36
  ];
34
37
  if (systemPrompt) args.push('--append-system-prompt', systemPrompt);
@@ -23,8 +23,28 @@ const os = require('node:os');
23
23
  const path = require('node:path');
24
24
 
25
25
  function isUnder(child, parent) {
26
- const rel = path.relative(path.resolve(parent), path.resolve(child));
27
- return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
26
+ const within = (c, p) => {
27
+ const rel = path.relative(p, c);
28
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
29
+ };
30
+ const c = path.resolve(child);
31
+ const p = path.resolve(parent);
32
+ if (within(c, p)) return true;
33
+ // Symlinked roots (macOS os.tmpdir() /var -> /private/var): also compare canonical spellings.
34
+ return within(realpathDeepest(c), realpathDeepest(p));
35
+ }
36
+
37
+ /** realpath of the deepest existing ancestor + the not-yet-existing tail. Never throws. */
38
+ function realpathDeepest(abs) {
39
+ let head = abs;
40
+ const tail = [];
41
+ for (;;) {
42
+ try { return path.join(fs.realpathSync(head), ...tail.reverse()); } catch { /* walk up */ }
43
+ const up = path.dirname(head);
44
+ if (up === head) return abs;
45
+ tail.push(path.basename(head));
46
+ head = up;
47
+ }
28
48
  }
29
49
 
30
50
  /**
@@ -28,6 +28,7 @@ const fs = require('node:fs');
28
28
  const path = require('node:path');
29
29
  const { sessionSlotsConfigPath } = require('./schedulerPaths.cjs');
30
30
  const { appendAuditEvent } = require('./auditLog.cjs');
31
+ const atomicFs = require('./atomicFs.cjs');
31
32
  const { isProvablyDead, DEFAULT_GRACE_MS } = require('./reservationExpiry.cjs');
32
33
 
33
34
  const MIN_SLOTS = 0;
@@ -57,10 +58,7 @@ function setCap(cap) {
57
58
  throw new Error(`sessionSlots.setCap: cap must be an integer in [${MIN_SLOTS}, ${MAX_SLOTS}]`);
58
59
  }
59
60
  const configPath = sessionSlotsConfigPath();
60
- fs.mkdirSync(path.dirname(configPath), { recursive: true });
61
- const tmp = `${configPath}.${process.pid}.${Date.now()}.tmp`;
62
- fs.writeFileSync(tmp, JSON.stringify({ cap: n }, null, 2));
63
- fs.renameSync(tmp, configPath);
61
+ atomicFs.writeJsonAtomicSync(configPath, { cap: n });
64
62
  for (const fn of listeners) {
65
63
  try { fn(); } catch { /* a consumer's pump error is its own problem */ }
66
64
  }
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * SHIPPED_PERSONA_SEEDS — every distinct version this app has ever bundled
5
+ * for the four seed personas (`src/main/seedAgentPersonas.cjs`'s `PERSONAS`),
6
+ * keyed by persona name. One entry per version actually shipped in
7
+ * `src/seed/agents/<name>.md`'s git history; exact duplicates (same body
8
+ * hash and same `fm`) are dropped.
9
+ *
10
+ * `seedAgentPersonas.cjs`'s upgrade pass only replaces an installed persona
11
+ * file when its body hash matches one of the `bodySha256` values below — a
12
+ * body that never shipped from this app (hand-written, or hand-edited after
13
+ * install) is left alone, never overwritten. `fm` holds every frontmatter
14
+ * key that version had, except `name` and `seedVersion` — those two are
15
+ * never diffed against this list.
16
+ *
17
+ * When you change a bundled persona, add its new version here. The test in
18
+ * seedAgentPersonas.test.cjs prints the entry to paste.
19
+ */
20
+
21
+ function deepFreeze(value) {
22
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
23
+ Object.freeze(value);
24
+ for (const key of Object.keys(value)) deepFreeze(value[key]);
25
+ }
26
+ return value;
27
+ }
28
+
29
+ const SHIPPED_PERSONA_SEEDS = deepFreeze({
30
+ "architect": [
31
+ {
32
+ commit: "dba99697",
33
+ bodySha256: "40a4d41445e7fdb128f4f1d8d3eef88b857ca466726b3719b36cb69933f09168",
34
+ fm: {
35
+ description: "The primary Actor for an Epic's whole interactive conversation — owns overall plan and decomposition, clarifies scope, searches before building, decomposes work into scheduled PRDs via /develop, tracks them to completion, and verifies before calling anything done. Never implements a PRD itself — that's dev-lead's job, one PRD at a time, headless. Task-type framing is the Epic's Mission tag's job, not this persona's.",
36
+ model: "opus",
37
+ tags: "feature, bug, discussion",
38
+ title: "Engineering — Architect",
39
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
40
+ },
41
+ },
42
+ ],
43
+ "dev-lead": [
44
+ {
45
+ commit: "dba99697",
46
+ bodySha256: "7821f5bf3f1617fb4c9ea80c81fc37680bfc4c61346e59f58da456c69ef74a90",
47
+ fm: {
48
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. Not currently wired to run automatically; a PRD must name this persona explicitly (e.g. in its Implementation notes) for an executor to adopt it.",
49
+ model: "fable",
50
+ title: "Engineering — Software Engineer",
51
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
52
+ },
53
+ },
54
+ {
55
+ commit: "07b73fac",
56
+ bodySha256: "21284b34473fd4a9b727e8fa2a0702379751d3af0985392a9814f91a4fdc8551",
57
+ fm: {
58
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
59
+ model: "sonnet",
60
+ title: "Engineering — Software Engineer",
61
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
62
+ },
63
+ },
64
+ {
65
+ commit: "2751c9f5",
66
+ bodySha256: "375b46dd6f1edc7b7e304e0be5bf32a4e61ca4adf329bc73d65ba2224e3c7b8a",
67
+ fm: {
68
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
69
+ model: "sonnet",
70
+ title: "Engineering — Software Engineer",
71
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
72
+ },
73
+ },
74
+ {
75
+ commit: "9f8286d7",
76
+ bodySha256: "86e5d8a679c3be879b162140d403f905a1ef9edbcc54b3bf4b3a278425dea841",
77
+ fm: {
78
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
79
+ model: "sonnet",
80
+ title: "Engineering — Software Engineer",
81
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
82
+ },
83
+ },
84
+ {
85
+ commit: "ab4be752",
86
+ bodySha256: "dbd5500968b75cbbe6549e612dc3df5de8d1569fa902cac173705542ea095225",
87
+ fm: {
88
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
89
+ model: "sonnet",
90
+ title: "Engineering — Software Engineer",
91
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
92
+ },
93
+ },
94
+ {
95
+ commit: "535b04f8",
96
+ bodySha256: "91232cfd7ce5fb1dc608ff639a07dcb1c5c13c22502ae4790f51707f498ec917",
97
+ fm: {
98
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
99
+ model: "sonnet",
100
+ title: "Engineering — Software Engineer",
101
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
102
+ },
103
+ },
104
+ ],
105
+ "project-home-builder": [
106
+ {
107
+ commit: "e9f2f540",
108
+ bodySha256: "e1c80f465179f814f1e9ea95529434309e5238facdc8c6664cb8f44f8302e148",
109
+ fm: {
110
+ description: "Generates a project's 5 static Project Page HTML files (Home / Marketing Landing / Feature Description / Architecture Overview / Brief) by following the session-manager app's own MCP contract for the pipeline — portable to any machine with the app installed, no source-repo paths required.",
111
+ title: "Project Pages — Builder",
112
+ tools: "Read, Grep, Glob, Bash, Write, Edit",
113
+ },
114
+ },
115
+ {
116
+ commit: "5cc32fa4",
117
+ bodySha256: "7ad61d9b9dbe7f35727baf83f94c3c244deb25133eebb78c9295c9841237dd1c",
118
+ fm: {
119
+ description: "Reads a project and writes ONE self-contained overview page (home.html) for its Project Home tab, then saves it with a single project_home_write call.",
120
+ title: "Project Home — Builder",
121
+ tools: "Read, Grep, Glob, Bash, Write, Edit",
122
+ },
123
+ },
124
+ ],
125
+ "validator": [
126
+ {
127
+ commit: "41c28597",
128
+ bodySha256: "4791f25651b4fc3b7cfa3a26148e6dd1cceec05f057b882516fafcdcc04f71e7",
129
+ fm: {
130
+ description: "Validates a finished PLAN (the PRDs that share one planId) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD via sentinel lines. Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
131
+ model: "sonnet",
132
+ title: "Engineering — Plan Validator",
133
+ tools: "Read, Grep, Glob, Bash",
134
+ },
135
+ },
136
+ {
137
+ commit: "7ed8dd1d",
138
+ bodySha256: "80d19294bc8a0e654f242a6177ae14ebdb116c899614c6b6bed503774624a0b8",
139
+ fm: {
140
+ description: "Validates a finished PLAN (the PRDs that share one planId) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD via sentinel lines. Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
141
+ model: "sonnet",
142
+ title: "Engineering — Plan Validator",
143
+ tools: "Read, Grep, Glob, Bash",
144
+ },
145
+ },
146
+ {
147
+ commit: "9f8286d7",
148
+ bodySha256: "8e95bfe06f70e7f9ae7f22de829b6f40727714e7f66364d166756b269ad7d50f",
149
+ fm: {
150
+ description: "Validates a finished PLAN (the PRDs that share one planId) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD via sentinel lines. Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
151
+ model: "sonnet",
152
+ title: "Engineering — Plan Validator",
153
+ tools: "Read, Grep, Glob, Bash",
154
+ },
155
+ },
156
+ {
157
+ commit: "ab4be752",
158
+ bodySha256: "512ec61490f6b652268bedc2aebd07fb4aafe8df53cfed38bb728348a29f29cc",
159
+ fm: {
160
+ description: "Validates a finished PLAN (the PRDs that share one planId) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD via sentinel lines. Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
161
+ model: "sonnet",
162
+ title: "Engineering — Plan Validator",
163
+ tools: "Read, Grep, Glob, Bash",
164
+ },
165
+ },
166
+ {
167
+ commit: "535b04f8",
168
+ bodySha256: "5aeaf796a30ac98bdce440a6fcd088e1c776ae762f2778327439ab8d75a2de94",
169
+ fm: {
170
+ description: "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD via sentinel lines. Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
171
+ model: "sonnet",
172
+ title: "Engineering — Plan Validator",
173
+ tools: "Read, Grep, Glob, Bash",
174
+ },
175
+ },
176
+ ],
177
+ });
178
+
179
+ module.exports = { SHIPPED_PERSONA_SEEDS };