claude-code-session-manager 0.97.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.
- package/README.md +3 -3
- package/bin/cli.cjs +16 -4
- package/bin/node-floor.cjs +41 -0
- package/dist/assets/{DataModel-D93FoaOm.js → DataModel-HdR0AxFq.js} +1 -1
- package/dist/assets/{History-CXxxqNP1.js → History-Dr4Jr_5z.js} +2 -2
- package/dist/assets/{Hooks-CzeYFQjq.js → Hooks-NhrvH3JP.js} +3 -3
- package/dist/assets/{Library-D2zPkwOC.js → Library-Dv_EtIMr.js} +1 -1
- package/dist/assets/{MarkdownEditor-DbinP78A.js → MarkdownEditor-DTKDWV_n.js} +1 -1
- package/dist/assets/{McpServers-Bu_sVGLr.js → McpServers-M034G9B3.js} +2 -2
- package/dist/assets/{Memory-BgiI6LZ_.js → Memory-DzF1B4gx.js} +6 -6
- package/dist/assets/{Permissions-C1MMzZRm.js → Permissions-DrgbSGWl.js} +3 -3
- package/dist/assets/{Plugins-Dhu6wAZi.js → Plugins-Bd3ef35w.js} +2 -2
- package/dist/assets/{ProvenanceBadge-C3AcWKMG.js → ProvenanceBadge-DcBHT1Iy.js} +1 -1
- package/dist/assets/{SaveBar-plwYm0iO.js → SaveBar-rimJem-Y.js} +1 -1
- package/dist/assets/Scheduler-DjgFJl2w.js +16 -0
- package/dist/assets/{ScopeSwitcher-DFy0vv_o.js → ScopeSwitcher-CnAzTBrl.js} +1 -1
- package/dist/assets/Settings-Dc1F_sSg.js +3 -0
- package/dist/assets/{SkillReferenceGraph-DsI7hRPB.js → SkillReferenceGraph-B9aZDecM.js} +1 -1
- package/dist/assets/{Skills-3E748UfB.js → Skills-DRXd18gu.js} +2 -2
- package/dist/assets/{SystemPrompt-BqmfUJOd.js → SystemPrompt-ahy5-Fwe.js} +1 -1
- package/dist/assets/{TagLibrary-CPz6fO8Q.js → TagLibrary-C_tToDeL.js} +1 -1
- package/dist/assets/{TiptapBody-D9EoBQ1P.js → TiptapBody-DvdefS6K.js} +1 -1
- package/dist/assets/{Toggle-BHAmZNDn.js → Toggle-6Jl5Njc6.js} +1 -1
- package/dist/assets/{index-CKH5Uxik.css → index-Bta-hwud.css} +1 -1
- package/dist/assets/{index-tn5JIVPj.js → index-vx8O73l8.js} +497 -502
- package/dist/assets/{settingsSchema-Crqy_aNz.js → settingsSchema-D6iRguNV.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +26 -29
- package/plugins/CLAUDE.md +6 -6
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +23 -19
- package/plugins/session-manager-dev/skills/builder/SKILL.md +3 -3
- package/plugins/session-manager-dev/skills/develop/SKILL.md +254 -510
- package/plugins/session-manager-dev/skills/develop/standards.md +17 -22
- package/scripts/README.md +3 -11
- package/scripts/audit-ops-hygiene.cjs +3 -3
- package/scripts/hooks/lib/guard-prd-writes-policy.cjs +1 -1
- package/scripts/hooks/lib/guard-self-schedule-policy.cjs +1 -1
- package/scripts/mint-epic.cjs +2 -3
- package/scripts/scheduler-mcp-server.cjs +36 -7
- package/src/main/agentLibrary.cjs +22 -2
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +41 -38
- package/src/main/docEdit.cjs +4 -1
- package/src/main/files.cjs +2 -5
- package/src/main/health.cjs +1 -1
- package/src/main/index.cjs +23 -10
- package/src/main/ipcSchemas.cjs +28 -35
- package/src/main/lib/agentPersonaSchema.cjs +13 -2
- package/src/main/lib/atomicFs.cjs +116 -0
- package/src/main/lib/branchSweep.cjs +13 -12
- package/src/main/lib/buildTarget.cjs +3 -3
- package/src/main/lib/claudeCliCaps.cjs +129 -0
- package/src/main/lib/credentials.cjs +2 -4
- package/src/main/lib/crossProjectFeedback.cjs +3 -3
- package/src/main/lib/cwdClassify.cjs +15 -3
- package/src/main/lib/definitionOfDone.cjs +207 -125
- package/src/main/lib/dodDrainHook.cjs +11 -5
- package/src/main/lib/epicMint.cjs +2 -4
- package/src/main/lib/epicStatusMirror.cjs +8 -10
- package/src/main/lib/epicWorktreeProjectConfig.cjs +2 -4
- package/src/main/lib/gateAuthority.cjs +96 -0
- package/src/main/lib/gitExec.cjs +69 -0
- package/src/main/lib/gitWorktree.cjs +656 -92
- package/src/main/lib/instanceLock.cjs +5 -8
- package/src/main/lib/launchFailure.cjs +2 -3
- package/src/main/lib/macroLibrary.cjs +386 -0
- package/src/main/lib/mcpToolCatalog.cjs +26 -17
- package/src/main/lib/needsReviewLedger.cjs +1 -1
- package/src/main/lib/opsErrorLog.cjs +11 -1
- package/src/main/lib/opsOwnership.cjs +0 -5
- package/src/main/lib/pidAlive.cjs +32 -0
- package/src/main/lib/prdCreate.cjs +153 -19
- package/src/main/lib/prdDisposition.cjs +2 -2
- package/src/main/lib/prdGateFiles.cjs +284 -0
- package/src/main/lib/prdLocations.cjs +61 -0
- package/src/main/lib/prdMigration.cjs +2 -3
- package/src/main/lib/prdSizing.cjs +2 -1
- package/src/main/lib/promptSessionSchema.cjs +10 -2
- package/src/main/lib/rcaReport.cjs +4 -6
- package/src/main/lib/reaperHelpers.cjs +8 -1
- package/src/main/lib/reservationExpiry.cjs +6 -1
- package/src/main/lib/reviewNotice.cjs +263 -0
- package/src/main/lib/runClaudeP.cjs +4 -1
- package/src/main/lib/schedulerPaths.cjs +22 -2
- package/src/main/lib/sessionSlots.cjs +2 -4
- package/src/main/lib/shippedPersonaSeeds.cjs +179 -0
- package/src/main/lib/timeoutShim.cjs +123 -0
- package/src/main/lib/timeoutShimScript.cjs +275 -0
- package/src/main/lib/upgradeDrain.cjs +4 -10
- package/src/main/lib/watchdogHelpers.cjs +33 -30
- package/src/main/lib/workTypeLibrary.cjs +7 -1
- package/src/main/promptSessionEvents.cjs +37 -13
- package/src/main/queueOps.cjs +17 -6
- package/src/main/scheduler.cjs +975 -203
- package/src/main/seedAgentPersonas.cjs +278 -23
- package/src/main/supervisor.cjs +4 -1
- package/src/main/templates/PRD_AUTHORING.md +126 -406
- package/src/preload/__tests__/preload-surface.test.cjs +68 -0
- package/src/preload/api.d.ts +41 -94
- package/src/preload/index.cjs +14 -9
- package/src/seed/agents/architect.md +1 -0
- package/src/seed/agents/dev-lead.md +17 -18
- package/src/seed/agents/project-home-builder.md +1 -0
- package/src/seed/agents/validator.md +10 -4
- package/dist/assets/HostBilko-nESrTRIg.js +0 -1
- package/dist/assets/Scheduler-BVYTeh39.js +0 -16
- package/dist/assets/Settings-DIhGgdfs.js +0 -3
- package/src/main/__tests__/activeIndexMerge.test.cjs +0 -235
- package/src/main/__tests__/agentEffortResolve.test.cjs +0 -117
- package/src/main/__tests__/agentLibrary.test.cjs +0 -276
- package/src/main/__tests__/agentModelResolve.test.cjs +0 -311
- package/src/main/__tests__/agentOverlayWrite.test.cjs +0 -95
- package/src/main/__tests__/bilkoHost-deriveSlug.test.cjs +0 -26
- package/src/main/__tests__/bilkoHost-integration.test.cjs +0 -118
- package/src/main/__tests__/bilkoHostCore.test.cjs +0 -72
- package/src/main/__tests__/broadcastCoalescer.test.cjs +0 -122
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +0 -120
- package/src/main/__tests__/chat-dead-channels.test.cjs +0 -63
- package/src/main/__tests__/chat-exit-close-race.test.cjs +0 -146
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +0 -139
- package/src/main/__tests__/chat-preamble-anchors.test.cjs +0 -100
- package/src/main/__tests__/chat-queue.test.cjs +0 -97
- package/src/main/__tests__/chat-stop-signal.test.cjs +0 -89
- package/src/main/__tests__/chatRunner-epic-worktree-execcwd.test.cjs +0 -125
- package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +0 -252
- package/src/main/__tests__/classifyPromptTicket.test.cjs +0 -101
- package/src/main/__tests__/classifyTranscriptLine.test.cjs +0 -201
- package/src/main/__tests__/computeDepHistorySatisfaction.test.cjs +0 -66
- package/src/main/__tests__/config-readText-bounded.test.cjs +0 -84
- package/src/main/__tests__/configWriteBoundaryOwners.test.cjs +0 -59
- package/src/main/__tests__/crossProjectFeedback.test.cjs +0 -334
- package/src/main/__tests__/crossProjectFeedbackRoutes.test.cjs +0 -161
- package/src/main/__tests__/dep-orphan-archive-health.test.cjs +0 -77
- package/src/main/__tests__/develop-skill-failure-modes.test.cjs +0 -70
- package/src/main/__tests__/docEdit.test.cjs +0 -244
- package/src/main/__tests__/dod-batchkey.test.cjs +0 -183
- package/src/main/__tests__/dod-drain-hook.test.cjs +0 -302
- package/src/main/__tests__/dod-report.test.cjs +0 -304
- package/src/main/__tests__/dod-reverify.test.cjs +0 -285
- package/src/main/__tests__/epicContextDigest.test.cjs +0 -174
- package/src/main/__tests__/epicMint.test.cjs +0 -332
- package/src/main/__tests__/epicMintTelemetryTap.test.cjs +0 -64
- package/src/main/__tests__/epicStatusMirror.test.cjs +0 -110
- package/src/main/__tests__/epicValidationHook.test.cjs +0 -291
- package/src/main/__tests__/exchanges.test.cjs +0 -122
- package/src/main/__tests__/exchangesPromptId.test.cjs +0 -61
- package/src/main/__tests__/extractJson.test.cjs +0 -51
- package/src/main/__tests__/files-reject-credentials.test.cjs +0 -40
- package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +0 -556
- package/src/main/__tests__/flatPrdTickSweep.test.cjs +0 -110
- package/src/main/__tests__/health-build-freshness.test.cjs +0 -39
- package/src/main/__tests__/health-claude-md-budget.test.cjs +0 -57
- package/src/main/__tests__/health-credentials.test.cjs +0 -81
- package/src/main/__tests__/health-delegation-chain.test.cjs +0 -124
- package/src/main/__tests__/health-per-project-stall.test.cjs +0 -84
- package/src/main/__tests__/health-prd-migration.test.cjs +0 -37
- package/src/main/__tests__/health-queue-dispatch.test.cjs +0 -135
- package/src/main/__tests__/health-starve-escalation.test.cjs +0 -94
- package/src/main/__tests__/health-tick-liveness.test.cjs +0 -179
- package/src/main/__tests__/health-usage-poller.test.cjs +0 -144
- package/src/main/__tests__/health-worktree-cap-blocked.test.cjs +0 -65
- package/src/main/__tests__/heapSnapshot.test.cjs +0 -121
- package/src/main/__tests__/historyAggregatorIntraday.test.cjs +0 -313
- package/src/main/__tests__/historyDashboard.test.cjs +0 -163
- package/src/main/__tests__/historyRollup.test.cjs +0 -333
- package/src/main/__tests__/intradayRefresh.test.cjs +0 -39
- package/src/main/__tests__/ipcSchemas-dependsOn.test.cjs +0 -39
- package/src/main/__tests__/kg-augment.test.cjs +0 -195
- package/src/main/__tests__/loadGateDetailTick.test.cjs +0 -31
- package/src/main/__tests__/machineProfile.test.cjs +0 -152
- package/src/main/__tests__/mcpStatus.test.cjs +0 -61
- package/src/main/__tests__/memoryAggregate.test.cjs +0 -109
- package/src/main/__tests__/memoryStale.test.cjs +0 -88
- package/src/main/__tests__/needsReviewLedger.test.cjs +0 -162
- package/src/main/__tests__/openExternalApp-spawn-error.test.cjs +0 -25
- package/src/main/__tests__/opsErrorLog.test.cjs +0 -109
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +0 -173
- package/src/main/__tests__/personaMerge.test.cjs +0 -169
- package/src/main/__tests__/planValidator.test.cjs +0 -125
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +0 -176
- package/src/main/__tests__/prd-group-allocator.test.cjs +0 -119
- package/src/main/__tests__/prdAdminRouteParity.test.cjs +0 -70
- package/src/main/__tests__/prdAdminRoutes.test.cjs +0 -718
- package/src/main/__tests__/prdAgentType.test.cjs +0 -103
- package/src/main/__tests__/prdAuthoringSeed.test.cjs +0 -39
- package/src/main/__tests__/prdCreate.test.cjs +0 -979
- package/src/main/__tests__/prdCreateDisposition.test.cjs +0 -201
- package/src/main/__tests__/prdCreatePlanId.test.cjs +0 -132
- package/src/main/__tests__/prdFrontmatterAgentType.test.cjs +0 -117
- package/src/main/__tests__/prdFrontmatterDependsOn.test.cjs +0 -136
- package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +0 -125
- package/src/main/__tests__/prdFrontmatterQuietMachine.test.cjs +0 -108
- package/src/main/__tests__/prdLocations.test.cjs +0 -195
- package/src/main/__tests__/prdLocationsArchived.test.cjs +0 -201
- package/src/main/__tests__/prdMigration.test.cjs +0 -349
- package/src/main/__tests__/prdMigrationLegacyAdopt.test.cjs +0 -91
- package/src/main/__tests__/prdParserHighWater.test.cjs +0 -74
- package/src/main/__tests__/prdParserSourcePromptId.test.cjs +0 -65
- package/src/main/__tests__/prdSetDisposition.test.cjs +0 -222
- package/src/main/__tests__/prdSizing.test.cjs +0 -106
- package/src/main/__tests__/prdSourcePromptIdBackfill.test.cjs +0 -118
- package/src/main/__tests__/prdUpdateDependsOn.test.cjs +0 -160
- package/src/main/__tests__/proc-role-env.test.cjs +0 -125
- package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +0 -304
- package/src/main/__tests__/procname-sm-processes.test.cjs +0 -127
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +0 -177
- package/src/main/__tests__/projectPages.test.cjs +0 -137
- package/src/main/__tests__/promptSessionEvents.test.cjs +0 -234
- package/src/main/__tests__/promptSessionSchema.test.cjs +0 -101
- package/src/main/__tests__/promptSessionTranscript.test.cjs +0 -0
- package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +0 -159
- package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +0 -282
- package/src/main/__tests__/pty-session-open-telemetry.test.cjs +0 -96
- package/src/main/__tests__/pty-write-result.test.cjs +0 -46
- package/src/main/__tests__/queue-health-verdict.test.cjs +0 -170
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +0 -286
- package/src/main/__tests__/queue-starvation-per-project.test.cjs +0 -147
- package/src/main/__tests__/queueHistory.test.cjs +0 -355
- package/src/main/__tests__/queueOps-interactive-ac-lint.test.cjs +0 -65
- package/src/main/__tests__/queueOpsArchiveDestination.test.cjs +0 -65
- package/src/main/__tests__/queueOpsAutoArchive.test.cjs +0 -154
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +0 -128
- package/src/main/__tests__/rcaReport.test.cjs +0 -266
- package/src/main/__tests__/reconcileFlatPrdSweep.test.cjs +0 -119
- package/src/main/__tests__/reconcileTiming.test.cjs +0 -135
- package/src/main/__tests__/runLogRetention.test.cjs +0 -489
- package/src/main/__tests__/runVerify-atomic-verdicts.test.cjs +0 -26
- package/src/main/__tests__/runVerify-blocked-by-foreign-wip.test.cjs +0 -58
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +0 -191
- package/src/main/__tests__/runVerify-policy-denial.test.cjs +0 -89
- package/src/main/__tests__/runVerify-transcript-commit-evidence.test.cjs +0 -225
- package/src/main/__tests__/runVerify.test.cjs +0 -1784
- package/src/main/__tests__/scheduleJobSchema.test.cjs +0 -127
- package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +0 -65
- package/src/main/__tests__/scheduleJobTransitions.test.cjs +0 -277
- package/src/main/__tests__/scheduleJobTransitionsGrep.test.cjs +0 -59
- package/src/main/__tests__/scheduleJobTransitionsTelemetryTap.test.cjs +0 -72
- package/src/main/__tests__/scheduler-admin-routes.test.cjs +0 -199
- package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +0 -143
- package/src/main/__tests__/scheduler-already-satisfied-on-main.test.cjs +0 -105
- package/src/main/__tests__/scheduler-archive-completed-prd.test.cjs +0 -102
- package/src/main/__tests__/scheduler-archived-twin-guard.test.cjs +0 -155
- package/src/main/__tests__/scheduler-autofix-outcome.test.cjs +0 -188
- package/src/main/__tests__/scheduler-autofix-select.test.cjs +0 -439
- package/src/main/__tests__/scheduler-autopromote.test.cjs +0 -51
- package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +0 -101
- package/src/main/__tests__/scheduler-blocked-by-foreign-wip.test.cjs +0 -107
- package/src/main/__tests__/scheduler-boot-orphans.test.cjs +0 -153
- package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +0 -121
- package/src/main/__tests__/scheduler-clear-queue-history.test.cjs +0 -134
- package/src/main/__tests__/scheduler-commit-guard-noop.test.cjs +0 -244
- package/src/main/__tests__/scheduler-committed-in-window.test.cjs +0 -182
- package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +0 -43
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +0 -168
- package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +0 -58
- package/src/main/__tests__/scheduler-effective-concurrency.test.cjs +0 -81
- package/src/main/__tests__/scheduler-epic-digest.test.cjs +0 -227
- package/src/main/__tests__/scheduler-failed-autoreset.test.cjs +0 -121
- package/src/main/__tests__/scheduler-finalize-dispatch-guards.test.cjs +0 -229
- package/src/main/__tests__/scheduler-find-prd-dir.test.cjs +0 -75
- package/src/main/__tests__/scheduler-fix-plan-path.test.cjs +0 -119
- package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +0 -46
- package/src/main/__tests__/scheduler-foreign-wip-manifest.test.cjs +0 -78
- package/src/main/__tests__/scheduler-gate-shadow.test.cjs +0 -119
- package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +0 -390
- package/src/main/__tests__/scheduler-heal-refusal.test.cjs +0 -61
- package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +0 -80
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +0 -323
- package/src/main/__tests__/scheduler-integration-failure-stamp.test.cjs +0 -41
- package/src/main/__tests__/scheduler-investigation-clean-skip.test.cjs +0 -63
- package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +0 -123
- package/src/main/__tests__/scheduler-job-budget.test.cjs +0 -172
- package/src/main/__tests__/scheduler-job-overrun.test.cjs +0 -175
- package/src/main/__tests__/scheduler-launch-failure.test.cjs +0 -199
- package/src/main/__tests__/scheduler-leftover-fields.test.cjs +0 -52
- package/src/main/__tests__/scheduler-leftover-quarantine.test.cjs +0 -199
- package/src/main/__tests__/scheduler-looks-done.test.cjs +0 -537
- package/src/main/__tests__/scheduler-manual-pause.test.cjs +0 -118
- package/src/main/__tests__/scheduler-mechanical-recovery.test.cjs +0 -245
- package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +0 -46
- package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +0 -197
- package/src/main/__tests__/scheduler-never-stop.test.cjs +0 -157
- package/src/main/__tests__/scheduler-no-dead-end-status.test.cjs +0 -152
- package/src/main/__tests__/scheduler-no-orphan-run-dir.test.cjs +0 -81
- package/src/main/__tests__/scheduler-notify-originating-tab-transcript.test.cjs +0 -87
- package/src/main/__tests__/scheduler-notify-originating-tab.test.cjs +0 -343
- package/src/main/__tests__/scheduler-periodic-reverify-guard.test.cjs +0 -217
- package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +0 -164
- package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +0 -161
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +0 -178
- package/src/main/__tests__/scheduler-quarantine-autoresolve.test.cjs +0 -165
- package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +0 -257
- package/src/main/__tests__/scheduler-rate-limit-cooldown-freshness.test.cjs +0 -123
- package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +0 -152
- package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +0 -156
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +0 -754
- package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +0 -87
- package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +0 -100
- package/src/main/__tests__/scheduler-reconcile-history-backfill.test.cjs +0 -105
- package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +0 -203
- package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +0 -247
- package/src/main/__tests__/scheduler-reset-job-fields-guard.test.cjs +0 -77
- package/src/main/__tests__/scheduler-resume-recovery.test.cjs +0 -254
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +0 -115
- package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +0 -380
- package/src/main/__tests__/scheduler-sigterm-commit.test.cjs +0 -43
- package/src/main/__tests__/scheduler-stall-per-project.test.cjs +0 -126
- package/src/main/__tests__/scheduler-starve-escalation.test.cjs +0 -154
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +0 -252
- package/src/main/__tests__/scheduler-stranded-investigation.test.cjs +0 -185
- package/src/main/__tests__/scheduler-stuck-failed-escalation.test.cjs +0 -136
- package/src/main/__tests__/scheduler-supervisor-record.test.cjs +0 -81
- package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +0 -54
- package/src/main/__tests__/scheduler-tick-wedge.test.cjs +0 -172
- package/src/main/__tests__/scheduler-transient-failure.test.cjs +0 -141
- package/src/main/__tests__/scheduler-unreadable-queue-guard.test.cjs +0 -62
- package/src/main/__tests__/scheduler-utilization-hold.test.cjs +0 -89
- package/src/main/__tests__/scheduler-verify-prd-path.test.cjs +0 -109
- package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +0 -234
- package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +0 -120
- package/src/main/__tests__/scheduler-writeprd-epic-rollback.test.cjs +0 -105
- package/src/main/__tests__/schedulerBatchRootBlocker.test.cjs +0 -117
- package/src/main/__tests__/schedulerStateSidecarRestore.test.cjs +0 -110
- package/src/main/__tests__/seedAgentPersonas.test.cjs +0 -184
- package/src/main/__tests__/seedSchedulerMcp.test.cjs +0 -211
- package/src/main/__tests__/seedStatus.test.cjs +0 -100
- package/src/main/__tests__/seedValidatorPersona.test.cjs +0 -116
- package/src/main/__tests__/stop-signal-anchor.test.cjs +0 -75
- package/src/main/__tests__/telemetryClient.test.cjs +0 -1055
- package/src/main/__tests__/telemetryContract.test.cjs +0 -930
- package/src/main/__tests__/telemetrySettings.test.cjs +0 -210
- package/src/main/__tests__/transcripts-batch-flush.test.cjs +0 -249
- package/src/main/__tests__/transcripts-doFlush-array.test.cjs +0 -124
- package/src/main/__tests__/transcripts-paged-reads.test.cjs +0 -241
- package/src/main/__tests__/transcripts-worktree-epic-path.test.cjs +0 -154
- package/src/main/__tests__/transcriptsUsageFor.test.cjs +0 -206
- package/src/main/__tests__/uniquePrdNumbers.test.cjs +0 -153
- package/src/main/__tests__/usageSingleFlight.test.cjs +0 -169
- package/src/main/__tests__/validationSentinels.test.cjs +0 -84
- package/src/main/__tests__/workTypeLibrary.test.cjs +0 -89
- package/src/main/bilkoHost.cjs +0 -314
- package/src/main/bilkoHostCore.cjs +0 -89
- package/src/main/lib/__tests__/active-sessions.test.cjs +0 -251
- package/src/main/lib/__tests__/activeIndexRebuild.test.cjs +0 -179
- package/src/main/lib/__tests__/agentPersonaSchema.test.cjs +0 -67
- package/src/main/lib/__tests__/auditLog.test.cjs +0 -38
- package/src/main/lib/__tests__/bootSelfHeal.test.cjs +0 -107
- package/src/main/lib/__tests__/branchSweep.test.cjs +0 -164
- package/src/main/lib/__tests__/buildIdentity.test.cjs +0 -121
- package/src/main/lib/__tests__/buildTarget.test.cjs +0 -52
- package/src/main/lib/__tests__/childWithLog.test.cjs +0 -321
- package/src/main/lib/__tests__/coldBootPromptSessionsWrite.test.cjs +0 -87
- package/src/main/lib/__tests__/crashTelemetry.test.cjs +0 -103
- package/src/main/lib/__tests__/credentials-futile-refresh.test.cjs +0 -115
- package/src/main/lib/__tests__/cwdClassify.test.cjs +0 -111
- package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +0 -95
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +0 -1175
- package/src/main/lib/__tests__/dispatchLoop.test.cjs +0 -63
- package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +0 -244
- package/src/main/lib/__tests__/ephemeralCwd.test.cjs +0 -91
- package/src/main/lib/__tests__/epicDelegationStats.test.cjs +0 -137
- package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +0 -283
- package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +0 -196
- package/src/main/lib/__tests__/epicTranscriptPath.test.cjs +0 -163
- package/src/main/lib/__tests__/epicWorktreeBoot.test.cjs +0 -136
- package/src/main/lib/__tests__/epicWorktreeMerge.test.cjs +0 -130
- package/src/main/lib/__tests__/epicWorktreeMint.test.cjs +0 -117
- package/src/main/lib/__tests__/epicWorktreeProjectConfig.test.cjs +0 -137
- package/src/main/lib/__tests__/fixChainDepth.test.cjs +0 -40
- package/src/main/lib/__tests__/fixtures/204-mercury-steam-horse.log.txt +0 -13
- package/src/main/lib/__tests__/fixtures/scheduler-machine.json.corrupt-1789147548 +0 -34
- package/src/main/lib/__tests__/gateFixtures.json +0 -20
- package/src/main/lib/__tests__/gitCacheBound.test.cjs +0 -69
- package/src/main/lib/__tests__/gitWorktree.test.cjs +0 -1478
- package/src/main/lib/__tests__/gitWorktreeSalvage.test.cjs +0 -107
- package/src/main/lib/__tests__/gitWorktreeSalvageDelta.test.cjs +0 -153
- package/src/main/lib/__tests__/guardShims.test.cjs +0 -158
- package/src/main/lib/__tests__/importReferences.spec.cjs +0 -56
- package/src/main/lib/__tests__/instanceLock.test.cjs +0 -173
- package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +0 -78
- package/src/main/lib/__tests__/jobWorktree.test.cjs +0 -199
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +0 -82
- package/src/main/lib/__tests__/landedSinceRun.test.cjs +0 -133
- package/src/main/lib/__tests__/launchFailure.test.cjs +0 -220
- package/src/main/lib/__tests__/loadGate.test.cjs +0 -303
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +0 -214
- package/src/main/lib/__tests__/loopDelay.test.cjs +0 -68
- package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +0 -107
- package/src/main/lib/__tests__/modelCatalog.test.cjs +0 -202
- package/src/main/lib/__tests__/opsOwnership.test.cjs +0 -113
- package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +0 -328
- package/src/main/lib/__tests__/opsRootNestedWrite.test.cjs +0 -51
- package/src/main/lib/__tests__/opsRootResolve.test.cjs +0 -149
- package/src/main/lib/__tests__/prdDeclaredPaths.test.cjs +0 -82
- package/src/main/lib/__tests__/prdDisposition.test.cjs +0 -224
- package/src/main/lib/__tests__/procIdentity.test.cjs +0 -119
- package/src/main/lib/__tests__/procName.test.cjs +0 -92
- package/src/main/lib/__tests__/projectBriefCore.test.cjs +0 -216
- package/src/main/lib/__tests__/projectRootResolve.test.cjs +0 -148
- package/src/main/lib/__tests__/queueHealth.test.cjs +0 -58
- package/src/main/lib/__tests__/queueStoreAtomicWrite.test.cjs +0 -88
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +0 -190
- package/src/main/lib/__tests__/quietMachineLease.test.cjs +0 -39
- package/src/main/lib/__tests__/rateLimitWindow.test.cjs +0 -88
- package/src/main/lib/__tests__/reaperHelpers.test.cjs +0 -577
- package/src/main/lib/__tests__/schedulerBatchDepends.test.cjs +0 -312
- package/src/main/lib/__tests__/schedulerBatchFairness.test.cjs +0 -213
- package/src/main/lib/__tests__/schedulerBatchLaunchHold.test.cjs +0 -125
- package/src/main/lib/__tests__/schedulerBatchProjectCap.test.cjs +0 -127
- package/src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs +0 -109
- package/src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs +0 -71
- package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +0 -216
- package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +0 -183
- package/src/main/lib/__tests__/schedulerPaths.test.cjs +0 -226
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +0 -133
- package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +0 -56
- package/src/main/lib/__tests__/sessionSlots.test.cjs +0 -144
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +0 -626
- package/src/main/lib/__tests__/telemetryBoot.test.cjs +0 -134
- package/src/main/lib/__tests__/telemetryConsent.test.cjs +0 -136
- package/src/main/lib/__tests__/telemetryCounters.test.cjs +0 -57
- package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +0 -98
- package/src/main/lib/__tests__/terminalRunOutcome.test.cjs +0 -200
- package/src/main/lib/__tests__/toolUseClassify.test.cjs +0 -53
- package/src/main/lib/__tests__/updateCheck.test.cjs +0 -63
- package/src/main/lib/__tests__/upgradeDrain.test.cjs +0 -130
- package/src/main/lib/__tests__/usageCircuit.test.cjs +0 -354
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +0 -375
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +0 -266
- package/src/main/lib/kgExchangePairing.cjs +0 -75
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerBatchProjectCap.test.cjs
|
|
4
|
-
//
|
|
5
|
-
// Regression coverage for the per-project job cap (PRD 1066): the global
|
|
6
|
-
// sessionSlots pool is machine-wide and project-blind, so all of it can land
|
|
7
|
-
// on one project — measured 2026-08-31 as 4 concurrent executors on one
|
|
8
|
-
// project, loadavg 25.89/14 cores, silently converting that project's
|
|
9
|
-
// timing-sensitive test gate into a no-op. These tests pin the fix: an INNER
|
|
10
|
-
// per-cwd cap inside pickNextBatch/pickForProject, layered under the existing
|
|
11
|
-
// global pool (never a replacement for it).
|
|
12
|
-
|
|
13
|
-
const assert = require('node:assert/strict');
|
|
14
|
-
const { pickNextBatch, pickForProject } = require('../schedulerBatch.cjs');
|
|
15
|
-
|
|
16
|
-
const CWD_A = '/home/user/Projects/project-a';
|
|
17
|
-
const CWD_B = '/home/user/Projects/project-b';
|
|
18
|
-
|
|
19
|
-
function job(slug, status, cwd, extra = {}) {
|
|
20
|
-
return {
|
|
21
|
-
slug,
|
|
22
|
-
status,
|
|
23
|
-
cwd,
|
|
24
|
-
parallelGroup: Number(String(slug).match(/^(\d+)-/)?.[1] ?? 99),
|
|
25
|
-
dependsOn: [],
|
|
26
|
-
...extra,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const ORIGINAL_CAP_ENV = process.env.SM_PROJECT_JOB_CAP;
|
|
31
|
-
afterEach(() => {
|
|
32
|
-
if (ORIGINAL_CAP_ENV === undefined) delete process.env.SM_PROJECT_JOB_CAP;
|
|
33
|
-
else process.env.SM_PROJECT_JOB_CAP = ORIGINAL_CAP_ENV;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('three eligible jobs in one project, default cap 2 -> exactly 2 selected', () => {
|
|
37
|
-
delete process.env.SM_PROJECT_JOB_CAP;
|
|
38
|
-
const jobs = [
|
|
39
|
-
job('101-a', 'pending', CWD_A),
|
|
40
|
-
job('102-b', 'pending', CWD_A),
|
|
41
|
-
job('103-c', 'pending', CWD_A),
|
|
42
|
-
];
|
|
43
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5);
|
|
44
|
-
assert.deepEqual(batch.map((j) => j.slug), ['101-a', '102-b']);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('cap is per-project: two projects with 2 eligible jobs each (cap 2) both fire in full', () => {
|
|
48
|
-
delete process.env.SM_PROJECT_JOB_CAP;
|
|
49
|
-
const jobs = [
|
|
50
|
-
job('101-a', 'pending', CWD_A),
|
|
51
|
-
job('102-b', 'pending', CWD_A),
|
|
52
|
-
job('201-a', 'pending', CWD_B),
|
|
53
|
-
job('202-b', 'pending', CWD_B),
|
|
54
|
-
];
|
|
55
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5);
|
|
56
|
-
// A global cap of 2 would only ever admit 2 total; the per-project cap
|
|
57
|
-
// admits up to 2 PER cwd, so all 4 fire here against a 5-slot pool.
|
|
58
|
-
assert.deepEqual(
|
|
59
|
-
batch.map((j) => j.slug).sort(),
|
|
60
|
-
['101-a', '102-b', '201-a', '202-b'],
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('SM_PROJECT_JOB_CAP=1 -> exactly 1 selected', () => {
|
|
65
|
-
process.env.SM_PROJECT_JOB_CAP = '1';
|
|
66
|
-
const jobs = [
|
|
67
|
-
job('101-a', 'pending', CWD_A),
|
|
68
|
-
job('102-b', 'pending', CWD_A),
|
|
69
|
-
job('103-c', 'pending', CWD_A),
|
|
70
|
-
];
|
|
71
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5);
|
|
72
|
-
assert.deepEqual(batch.map((j) => j.slug), ['101-a']);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('a job deferred by the project cap stays eligible and fires once a sibling finishes', () => {
|
|
76
|
-
delete process.env.SM_PROJECT_JOB_CAP;
|
|
77
|
-
const jobs = [
|
|
78
|
-
job('101-a', 'running', CWD_A),
|
|
79
|
-
job('102-b', 'running', CWD_A),
|
|
80
|
-
job('103-c', 'pending', CWD_A),
|
|
81
|
-
];
|
|
82
|
-
// Tick 1: both slots for this project are already running (cap 2) -> 103-c
|
|
83
|
-
// is held, NOT failed/skipped, and remains 'pending' in the queue.
|
|
84
|
-
const running1 = new Set(['101-a', '102-b']);
|
|
85
|
-
const tick1 = pickNextBatch(jobs, running1, 5);
|
|
86
|
-
assert.deepEqual(tick1.batch, []);
|
|
87
|
-
assert.match(tick1.reason, /project-cap/);
|
|
88
|
-
assert.equal(jobs.find((j) => j.slug === '103-c').status, 'pending');
|
|
89
|
-
|
|
90
|
-
// Tick 2: 101-a finished (removed from running, its row now 'completed');
|
|
91
|
-
// 103-c is still eligible and fires on this later tick.
|
|
92
|
-
const jobsTick2 = [
|
|
93
|
-
job('101-a', 'completed', CWD_A),
|
|
94
|
-
job('102-b', 'running', CWD_A),
|
|
95
|
-
job('103-c', 'pending', CWD_A),
|
|
96
|
-
];
|
|
97
|
-
const running2 = new Set(['102-b']);
|
|
98
|
-
const tick2 = pickNextBatch(jobsTick2, running2, 5);
|
|
99
|
-
assert.deepEqual(tick2.batch.map((j) => j.slug), ['103-c']);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('cap counts an untracked running row (boot-orphan grace window), not just the tracked running Set', () => {
|
|
103
|
-
delete process.env.SM_PROJECT_JOB_CAP;
|
|
104
|
-
const jobs = [
|
|
105
|
-
// status:running but its slug is absent from the caller's `running` Set —
|
|
106
|
-
// e.g. still alive during BOOT_ORPHAN_KILL_GRACE_MS before reconciliation
|
|
107
|
-
// catches up. Must still count against the cap.
|
|
108
|
-
job('101-a', 'running', CWD_A),
|
|
109
|
-
job('102-b', 'running', CWD_A),
|
|
110
|
-
job('103-c', 'pending', CWD_A),
|
|
111
|
-
];
|
|
112
|
-
const { batch, reason } = pickNextBatch(jobs, new Set(), 5);
|
|
113
|
-
assert.deepEqual(batch, []);
|
|
114
|
-
assert.match(reason, /project-cap/);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('pickForProject: cap counts jobs already running in that project', () => {
|
|
118
|
-
delete process.env.SM_PROJECT_JOB_CAP;
|
|
119
|
-
const jobs = [
|
|
120
|
-
job('101-a', 'running', CWD_A),
|
|
121
|
-
job('102-b', 'running', CWD_A),
|
|
122
|
-
job('103-c', 'pending', CWD_A),
|
|
123
|
-
];
|
|
124
|
-
const { batch, reason } = pickForProject(jobs, new Set(['101-a', '102-b']), 5);
|
|
125
|
-
assert.deepEqual(batch, []);
|
|
126
|
-
assert.match(reason, /project-cap/);
|
|
127
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs
|
|
4
|
-
//
|
|
5
|
-
// Pure-logic coverage for the `quietMachine: true` exclusive lease (PRD
|
|
6
|
-
// 1107): dispatched only when zero other jobs are running machine-wide,
|
|
7
|
-
// blocks every other dispatch while its lease is held, degrades (dispatches
|
|
8
|
-
// anyway) once it has waited past the configurable interval, and never
|
|
9
|
-
// touches the ordinary dispatch path for a PRD that doesn't opt in.
|
|
10
|
-
|
|
11
|
-
const assert = require('node:assert/strict');
|
|
12
|
-
const { pickNextBatch } = require('../schedulerBatch.cjs');
|
|
13
|
-
|
|
14
|
-
const CWD_A = '/home/user/Projects/project-a';
|
|
15
|
-
const CWD_B = '/home/user/Projects/project-b';
|
|
16
|
-
|
|
17
|
-
function job(slug, status, cwd, extra = {}) {
|
|
18
|
-
return {
|
|
19
|
-
slug,
|
|
20
|
-
status,
|
|
21
|
-
cwd,
|
|
22
|
-
parallelGroup: Number(String(slug).match(/^(\d+)-/)?.[1] ?? 99),
|
|
23
|
-
dependsOn: [],
|
|
24
|
-
...extra,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const ORIGINAL_WAIT_ENV = process.env.SM_QUIET_MACHINE_WAIT_MINUTES;
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
if (ORIGINAL_WAIT_ENV === undefined) delete process.env.SM_QUIET_MACHINE_WAIT_MINUTES;
|
|
31
|
-
else process.env.SM_QUIET_MACHINE_WAIT_MINUTES = ORIGINAL_WAIT_ENV;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('a quietMachine job dispatches alone when the machine is idle, even with ordinary work also pending', () => {
|
|
35
|
-
const jobs = [
|
|
36
|
-
job('101-quiet', 'pending', CWD_A, { quietMachine: true, createdAt: new Date().toISOString() }),
|
|
37
|
-
job('102-ordinary', 'pending', CWD_A, { createdAt: new Date().toISOString() }),
|
|
38
|
-
job('201-other', 'pending', CWD_B, { createdAt: new Date().toISOString() }),
|
|
39
|
-
];
|
|
40
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5, { leaseHeld: false, machineInUse: 0, now: Date.now() });
|
|
41
|
-
assert.deepEqual(batch.map((j) => j.slug), ['101-quiet']);
|
|
42
|
-
assert.equal(batch[0].quietLeaseDegraded, false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('a quietMachine job does NOT dispatch while another job is running machine-wide, and ordinary jobs dispatch unaffected', () => {
|
|
46
|
-
const jobs = [
|
|
47
|
-
job('101-quiet', 'pending', CWD_A, { quietMachine: true, createdAt: new Date().toISOString() }),
|
|
48
|
-
job('201-other', 'pending', CWD_B, { createdAt: new Date().toISOString() }),
|
|
49
|
-
];
|
|
50
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5, { leaseHeld: false, machineInUse: 1, now: Date.now() });
|
|
51
|
-
assert.deepEqual(batch.map((j) => j.slug), ['201-other']);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('leaseHeld blocks EVERY project from dispatching, not just the quiet job\'s own project', () => {
|
|
55
|
-
const jobs = [
|
|
56
|
-
job('101-quiet', 'running', CWD_A, { quietMachine: true }),
|
|
57
|
-
job('201-other', 'pending', CWD_B, { createdAt: new Date().toISOString() }),
|
|
58
|
-
];
|
|
59
|
-
const { batch, reason } = pickNextBatch(jobs, new Set(['101-quiet']), 5, { leaseHeld: true, machineInUse: 1, now: Date.now() });
|
|
60
|
-
assert.deepEqual(batch, []);
|
|
61
|
-
assert.match(reason, /quiet-machine/);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('a quietMachine job blocked by dependsOn is skipped even when the machine is idle', () => {
|
|
65
|
-
const jobs = [
|
|
66
|
-
job('100-dep', 'pending', CWD_A, { createdAt: new Date().toISOString() }),
|
|
67
|
-
job('101-quiet', 'pending', CWD_A, { quietMachine: true, dependsOn: ['100-dep'], createdAt: new Date().toISOString() }),
|
|
68
|
-
];
|
|
69
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5, { leaseHeld: false, machineInUse: 0, now: Date.now() });
|
|
70
|
-
// The quiet job is blocked by its dep; the dep itself is an ordinary job
|
|
71
|
-
// and dispatches normally.
|
|
72
|
-
assert.deepEqual(batch.map((j) => j.slug), ['100-dep']);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('a quietMachine job waiting under the configured interval stays held while the machine is busy', () => {
|
|
76
|
-
process.env.SM_QUIET_MACHINE_WAIT_MINUTES = '30';
|
|
77
|
-
const now = Date.now();
|
|
78
|
-
const queuedAt = new Date(now - 10 * 60_000).toISOString(); // waited 10m
|
|
79
|
-
const jobs = [
|
|
80
|
-
job('101-quiet', 'pending', CWD_A, { quietMachine: true, createdAt: queuedAt }),
|
|
81
|
-
];
|
|
82
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5, { leaseHeld: false, machineInUse: 1, now });
|
|
83
|
-
assert.deepEqual(batch, []);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('a quietMachine job past the configured wait interval dispatches anyway, marked degraded', () => {
|
|
87
|
-
process.env.SM_QUIET_MACHINE_WAIT_MINUTES = '30';
|
|
88
|
-
const now = Date.now();
|
|
89
|
-
const queuedAt = new Date(now - 31 * 60_000).toISOString(); // waited 31m
|
|
90
|
-
const jobs = [
|
|
91
|
-
job('101-quiet', 'pending', CWD_A, { quietMachine: true, createdAt: queuedAt }),
|
|
92
|
-
];
|
|
93
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5, { leaseHeld: false, machineInUse: 1, now });
|
|
94
|
-
assert.deepEqual(batch.map((j) => j.slug), ['101-quiet']);
|
|
95
|
-
assert.equal(batch[0].quietLeaseDegraded, true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('ordinary dispatch path is unchanged when no quietMachine job is present (no quietOpts passed at all)', () => {
|
|
99
|
-
const jobs = [
|
|
100
|
-
job('101-a', 'pending', CWD_A),
|
|
101
|
-
job('102-b', 'pending', CWD_A),
|
|
102
|
-
job('201-a', 'pending', CWD_B),
|
|
103
|
-
];
|
|
104
|
-
const { batch } = pickNextBatch(jobs, new Set(), 5);
|
|
105
|
-
assert.deepEqual(
|
|
106
|
-
batch.map((j) => j.slug).sort(),
|
|
107
|
-
['101-a', '102-b', '201-a'],
|
|
108
|
-
);
|
|
109
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* schedulerMcpServerHeadlessRefusal.test.cjs — scheduler_create_prd is
|
|
3
|
-
* refused at the authoring boundary when called from inside a headless
|
|
4
|
-
* scheduled job (issue #11 list C1: PRD 460 called /develop from inside its
|
|
5
|
-
* own run, spawned a duplicate PRD, and exited 0 having done nothing).
|
|
6
|
-
* scheduler.cjs stamps SM_SCHEDULER_JOB_SLUG on every job spawn and
|
|
7
|
-
* SM_SCHEDULER_JOB_MAY_QUEUE=1 only for decomposition personas.
|
|
8
|
-
*
|
|
9
|
-
* Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
import { test, expect, afterEach } from 'vitest';
|
|
15
|
-
const fsp = require('node:fs/promises');
|
|
16
|
-
const os = require('node:os');
|
|
17
|
-
const path = require('node:path');
|
|
18
|
-
|
|
19
|
-
const SERVER_PATH = path.join(__dirname, '../../../../scripts/scheduler-mcp-server.cjs');
|
|
20
|
-
|
|
21
|
-
const tmpDirs = [];
|
|
22
|
-
const savedEnv = {};
|
|
23
|
-
for (const k of ['SM_SCHEDULER_JOB_SLUG', 'SM_SCHEDULER_JOB_MAY_QUEUE', 'HOME']) savedEnv[k] = process.env[k];
|
|
24
|
-
|
|
25
|
-
afterEach(async () => {
|
|
26
|
-
for (const [k, v] of Object.entries(savedEnv)) {
|
|
27
|
-
if (v === undefined) delete process.env[k]; else process.env[k] = v;
|
|
28
|
-
}
|
|
29
|
-
delete require.cache[require.resolve(SERVER_PATH)];
|
|
30
|
-
while (tmpDirs.length) await fsp.rm(tmpDirs.pop(), { recursive: true, force: true });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
async function freshServer() {
|
|
34
|
-
const homeDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-mcp-headless-'));
|
|
35
|
-
tmpDirs.push(homeDir);
|
|
36
|
-
process.env.HOME = homeDir;
|
|
37
|
-
delete require.cache[require.resolve(SERVER_PATH)];
|
|
38
|
-
return require(SERVER_PATH);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const PRD_ARGS = { title: 'x', goal: 'y', acceptanceCriteria: ['z'] };
|
|
42
|
-
|
|
43
|
-
test('scheduler_create_prd inside a headless job is refused before any admin request', async () => {
|
|
44
|
-
process.env.SM_SCHEDULER_JOB_SLUG = '460-some-prd';
|
|
45
|
-
delete process.env.SM_SCHEDULER_JOB_MAY_QUEUE;
|
|
46
|
-
const { handleCallTool } = await freshServer();
|
|
47
|
-
const result = await handleCallTool({ params: { name: 'scheduler_create_prd', arguments: PRD_ARGS } });
|
|
48
|
-
expect(result.isError).toBe(true);
|
|
49
|
-
const text = result.content[0].text;
|
|
50
|
-
expect(text).toMatch(/refused/);
|
|
51
|
-
expect(text).toMatch(/460-some-prd/);
|
|
52
|
-
expect(text).toMatch(/never queues follow-on work/);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('scheduler_create_prd inside a headless job with SM_SCHEDULER_JOB_MAY_QUEUE=1 is not refused by the gate', async () => {
|
|
56
|
-
process.env.SM_SCHEDULER_JOB_SLUG = '461-architect-plan';
|
|
57
|
-
process.env.SM_SCHEDULER_JOB_MAY_QUEUE = '1';
|
|
58
|
-
const { handleCallTool } = await freshServer();
|
|
59
|
-
const result = await handleCallTool({ params: { name: 'scheduler_create_prd', arguments: PRD_ARGS } });
|
|
60
|
-
// No admin API is configured in this tmp HOME, so the call fails LATER at
|
|
61
|
-
// the admin request — the point is that it was not the headless refusal.
|
|
62
|
-
const text = result.content[0].text;
|
|
63
|
-
expect(text).not.toMatch(/never queues follow-on work/);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('scheduler_create_prd outside a headless job is not refused by the gate', async () => {
|
|
67
|
-
delete process.env.SM_SCHEDULER_JOB_SLUG;
|
|
68
|
-
const { handleCallTool } = await freshServer();
|
|
69
|
-
const result = await handleCallTool({ params: { name: 'scheduler_create_prd', arguments: PRD_ARGS } });
|
|
70
|
-
expect(result.content[0].text).not.toMatch(/never queues follow-on work/);
|
|
71
|
-
});
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* schedulerMcpServerHelp.test.cjs — session_manager_help argument handling
|
|
3
|
-
* (none/tool/topic/unknown/both) and the pointer-suffix contract every
|
|
4
|
-
* isError return in scheduler-mcp-server.cjs now carries. Also covers the
|
|
5
|
-
* "app not running" degradation: the static catalog must still answer even
|
|
6
|
-
* when the admin API is unreachable — only the readiness section may report
|
|
7
|
-
* unavailable.
|
|
8
|
-
*
|
|
9
|
-
* The admin token path (schedulerPaths.adminTokenPath) resolves lazily from
|
|
10
|
-
* os.homedir(). Since os.homedir() reads process.env.HOME on POSIX, each test
|
|
11
|
-
* repoints HOME at a fresh tmp dir for its duration (restored in afterEach)
|
|
12
|
-
* so the token path resolves under that tmp dir, never the real
|
|
13
|
-
* ~/.claude/session-manager/admin-api.json.
|
|
14
|
-
*
|
|
15
|
-
* Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs
|
|
16
|
-
*/
|
|
17
|
-
'use strict';
|
|
18
|
-
|
|
19
|
-
import { test, expect, afterEach } from 'vitest';
|
|
20
|
-
const fsp = require('node:fs/promises');
|
|
21
|
-
const http = require('node:http');
|
|
22
|
-
const os = require('node:os');
|
|
23
|
-
const path = require('node:path');
|
|
24
|
-
|
|
25
|
-
const SERVER_PATH = path.join(__dirname, '../../../../scripts/scheduler-mcp-server.cjs');
|
|
26
|
-
|
|
27
|
-
const tmpDirs = [];
|
|
28
|
-
const servers = [];
|
|
29
|
-
let originalHome;
|
|
30
|
-
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
if (originalHome !== undefined) {
|
|
33
|
-
process.env.HOME = originalHome;
|
|
34
|
-
originalHome = undefined;
|
|
35
|
-
}
|
|
36
|
-
delete require.cache[require.resolve(SERVER_PATH)];
|
|
37
|
-
while (servers.length) {
|
|
38
|
-
const s = servers.pop();
|
|
39
|
-
await new Promise((resolve) => s.close(resolve));
|
|
40
|
-
}
|
|
41
|
-
while (tmpDirs.length) {
|
|
42
|
-
const d = tmpDirs.pop();
|
|
43
|
-
await fsp.rm(d, { recursive: true, force: true });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
async function mkTmp() {
|
|
48
|
-
const d = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-mcp-help-'));
|
|
49
|
-
tmpDirs.push(d);
|
|
50
|
-
return d;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Starts a fake admin HTTP server answering GET /admin/mcp/readiness. */
|
|
54
|
-
function startFakeAdminServer(token, readinessBody) {
|
|
55
|
-
return new Promise((resolve) => {
|
|
56
|
-
const server = http.createServer((req, res) => {
|
|
57
|
-
if (req.headers.authorization !== `Bearer ${token}`) {
|
|
58
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
59
|
-
res.end(JSON.stringify({ ok: false, error: 'bad token' }));
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
63
|
-
res.end(JSON.stringify(readinessBody));
|
|
64
|
-
});
|
|
65
|
-
server.listen(0, '127.0.0.1', () => resolve(server));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Requires a fresh scheduler-mcp-server.cjs with TOKEN_PATH under `homeDir`. */
|
|
70
|
-
function requireServerWithHome(homeDir) {
|
|
71
|
-
originalHome = process.env.HOME;
|
|
72
|
-
process.env.HOME = homeDir;
|
|
73
|
-
delete require.cache[require.resolve(SERVER_PATH)];
|
|
74
|
-
const mod = require(SERVER_PATH);
|
|
75
|
-
// HOME stays redirected until afterEach: admin-token path resolves lazily.
|
|
76
|
-
return mod;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function writeAdminConfig(homeDir, { port, token }) {
|
|
80
|
-
const tokenPath = path.join(homeDir, '.claude', 'session-manager', 'admin-api.json');
|
|
81
|
-
await fsp.mkdir(path.dirname(tokenPath), { recursive: true });
|
|
82
|
-
await fsp.writeFile(tokenPath, JSON.stringify({ port, token }), 'utf8');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function callTool(handleCallTool, name, args) {
|
|
86
|
-
return handleCallTool({ params: { name, arguments: args } });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
test('session_manager_help with no arguments returns grouped tool list + recipe titles + readiness', async () => {
|
|
90
|
-
const homeDir = await mkTmp();
|
|
91
|
-
const token = 'test-token';
|
|
92
|
-
const server = await startFakeAdminServer(token, { ok: true, ready: true, checks: [{ id: 'scheduler-mcp', ok: true }] });
|
|
93
|
-
servers.push(server);
|
|
94
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
95
|
-
|
|
96
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
97
|
-
const result = await callTool(handleCallTool, 'session_manager_help', {});
|
|
98
|
-
expect(result.isError).toBeFalsy();
|
|
99
|
-
const body = JSON.parse(result.content[0].text);
|
|
100
|
-
expect(Array.isArray(body.tools)).toBe(true);
|
|
101
|
-
expect(body.tools.some((t) => t.name === 'session_manager_help')).toBe(true);
|
|
102
|
-
expect(Array.isArray(body.recipes)).toBe(true);
|
|
103
|
-
expect(body.recipes.some((r) => r.id === 'queue-work-via-develop')).toBe(true);
|
|
104
|
-
expect(body.tool).toBeUndefined();
|
|
105
|
-
expect(body.recipe).toBeUndefined();
|
|
106
|
-
expect(body.readiness.available).toBe(true);
|
|
107
|
-
expect(body.readiness.ok).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('session_manager_help with a valid tool returns that entry including exampleArgs', async () => {
|
|
111
|
-
const homeDir = await mkTmp();
|
|
112
|
-
const token = 'test-token';
|
|
113
|
-
const server = await startFakeAdminServer(token, { ok: true, ready: true, checks: [] });
|
|
114
|
-
servers.push(server);
|
|
115
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
116
|
-
|
|
117
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
118
|
-
const result = await callTool(handleCallTool, 'session_manager_help', { tool: 'scheduler_create_prd' });
|
|
119
|
-
expect(result.isError).toBeFalsy();
|
|
120
|
-
const body = JSON.parse(result.content[0].text);
|
|
121
|
-
expect(body.tool.name).toBe('scheduler_create_prd');
|
|
122
|
-
expect(body.tool.exampleArgs).toBeTruthy();
|
|
123
|
-
expect(body.tools).toBeUndefined();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test('session_manager_help with a valid topic returns that recipe\'s steps', async () => {
|
|
127
|
-
const homeDir = await mkTmp();
|
|
128
|
-
const token = 'test-token';
|
|
129
|
-
const server = await startFakeAdminServer(token, { ok: true, ready: true, checks: [] });
|
|
130
|
-
servers.push(server);
|
|
131
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
132
|
-
|
|
133
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
134
|
-
const result = await callTool(handleCallTool, 'session_manager_help', { topic: 'unstick-needs-review-job' });
|
|
135
|
-
expect(result.isError).toBeFalsy();
|
|
136
|
-
const body = JSON.parse(result.content[0].text);
|
|
137
|
-
expect(body.recipe.id).toBe('unstick-needs-review-job');
|
|
138
|
-
expect(Array.isArray(body.recipe.steps)).toBe(true);
|
|
139
|
-
expect(body.recipe.steps.length).toBeGreaterThan(0);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('session_manager_help accepts both tool and topic together, returning both sections', async () => {
|
|
143
|
-
const homeDir = await mkTmp();
|
|
144
|
-
const token = 'test-token';
|
|
145
|
-
const server = await startFakeAdminServer(token, { ok: true, ready: true, checks: [] });
|
|
146
|
-
servers.push(server);
|
|
147
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
148
|
-
|
|
149
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
150
|
-
const result = await callTool(handleCallTool, 'session_manager_help', {
|
|
151
|
-
tool: 'scheduler_list_jobs',
|
|
152
|
-
topic: 'queue-work-via-develop',
|
|
153
|
-
});
|
|
154
|
-
expect(result.isError).toBeFalsy();
|
|
155
|
-
const body = JSON.parse(result.content[0].text);
|
|
156
|
-
expect(body.tool.name).toBe('scheduler_list_jobs');
|
|
157
|
-
expect(body.recipe.id).toBe('queue-work-via-develop');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('session_manager_help with an unknown tool returns a helpful error listing valid names', async () => {
|
|
161
|
-
const homeDir = await mkTmp();
|
|
162
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
163
|
-
const result = await callTool(handleCallTool, 'session_manager_help', { tool: 'not_a_real_tool' });
|
|
164
|
-
expect(result.isError).toBe(true);
|
|
165
|
-
expect(result.content[0].text).toContain('not_a_real_tool');
|
|
166
|
-
expect(result.content[0].text).toContain('scheduler_create_prd');
|
|
167
|
-
expect(result.content[0].text).toContain('call session_manager_help for the correct usage');
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test('session_manager_help with an unknown topic returns a helpful error listing valid ids', async () => {
|
|
171
|
-
const homeDir = await mkTmp();
|
|
172
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
173
|
-
const result = await callTool(handleCallTool, 'session_manager_help', { topic: 'not-a-real-recipe' });
|
|
174
|
-
expect(result.isError).toBe(true);
|
|
175
|
-
expect(result.content[0].text).toContain('not-a-real-recipe');
|
|
176
|
-
expect(result.content[0].text).toContain('queue-work-via-develop');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('session_manager_help still returns the static catalog when the app is not running, with readiness unavailable', async () => {
|
|
180
|
-
// No admin-api.json written under this tmp HOME at all — simulates the app
|
|
181
|
-
// being down. The catalog is bundled in-process, so this must NOT fail
|
|
182
|
-
// wholesale; only the readiness half degrades.
|
|
183
|
-
const homeDir = await mkTmp();
|
|
184
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
185
|
-
const result = await callTool(handleCallTool, 'session_manager_help', {});
|
|
186
|
-
expect(result.isError).toBeFalsy();
|
|
187
|
-
const body = JSON.parse(result.content[0].text);
|
|
188
|
-
expect(Array.isArray(body.tools)).toBe(true);
|
|
189
|
-
expect(body.tools.length).toBeGreaterThan(0);
|
|
190
|
-
expect(body.readiness.available).toBe(false);
|
|
191
|
-
expect(typeof body.readiness.reason).toBe('string');
|
|
192
|
-
expect(body.readiness.reason.length).toBeGreaterThan(0);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test('every isError return from the tool handler carries the session_manager_help pointer', async () => {
|
|
196
|
-
const homeDir = await mkTmp();
|
|
197
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
198
|
-
|
|
199
|
-
const missingSlug = await callTool(handleCallTool, 'scheduler_reset_job', {});
|
|
200
|
-
expect(missingSlug.isError).toBe(true);
|
|
201
|
-
expect(missingSlug.content[0].text).toContain('call session_manager_help for the correct usage');
|
|
202
|
-
|
|
203
|
-
const unknownTool = await callTool(handleCallTool, 'not_a_tool_at_all', {});
|
|
204
|
-
expect(unknownTool.isError).toBe(true);
|
|
205
|
-
expect(unknownTool.content[0].text).toContain('call session_manager_help for the correct usage');
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
test('NOT_RUNNING_ERROR (app not running) carries the pointer and is surfaced via isError', async () => {
|
|
209
|
-
const homeDir = await mkTmp();
|
|
210
|
-
const { handleCallTool, NOT_RUNNING_ERROR } = requireServerWithHome(homeDir);
|
|
211
|
-
expect(NOT_RUNNING_ERROR).toContain('call session_manager_help for the correct usage');
|
|
212
|
-
|
|
213
|
-
const result = await callTool(handleCallTool, 'scheduler_list_jobs', {});
|
|
214
|
-
expect(result.isError).toBe(true);
|
|
215
|
-
expect(result.content[0].text).toBe(NOT_RUNNING_ERROR);
|
|
216
|
-
});
|