claude-code-session-manager 0.87.0 → 0.88.1
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 +26 -53
- package/dist/assets/{AgentLibrary-DyLWzZDf.js → AgentLibrary-kQF8_wAw.js} +1 -1
- package/dist/assets/{DataModel--mISIJ6h.js → DataModel-CY_mMnsr.js} +1 -1
- package/dist/assets/{History-C2ahUXTg.js → History-Sji2brb0.js} +1 -1
- package/dist/assets/{Hooks-BiC6oyR2.js → Hooks-CtqpO-p5.js} +1 -1
- package/dist/assets/{HostBilko-BPleEOld.js → HostBilko-DN0ydOCr.js} +1 -1
- package/dist/assets/{Library-Dc8Qst1R.js → Library-CoiLZTKh.js} +1 -1
- package/dist/assets/{ListDetail-DIXh-OLX.js → ListDetail-CmqiQ_io.js} +1 -1
- package/dist/assets/{MarkdownEditor-C90bkLXK.js → MarkdownEditor-HPoNeKhT.js} +1 -1
- package/dist/assets/{McpServers-DqcbLOLZ.js → McpServers-Bj1X3_NT.js} +1 -1
- package/dist/assets/{Memory-CW62MXlh.js → Memory-1PKjsM3b.js} +1 -1
- package/dist/assets/{Panel-Bw1FhRuF.js → Panel-I1s6ghPo.js} +1 -1
- package/dist/assets/{Permissions-BcUC-5y8.js → Permissions-BhiiZjHQ.js} +1 -1
- package/dist/assets/{Plugins-BnKx9flD.js → Plugins-gv3_fkPX.js} +2 -2
- package/dist/assets/{ProvenanceBadge-Bw5vNVPT.js → ProvenanceBadge-BGcgBd8V.js} +1 -1
- package/dist/assets/{SaveBar-CWr0O_w-.js → SaveBar-BGr9eZ4g.js} +1 -1
- package/dist/assets/{Scheduler-DYdLuUqq.js → Scheduler-Bdo_awPq.js} +7 -7
- package/dist/assets/{ScopeSwitcher-CrBLbg8s.js → ScopeSwitcher-ukl0qWaA.js} +1 -1
- package/dist/assets/{Settings-DluB-vN1.js → Settings-DJkFj22G.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CHLSseay.js → SkillReferenceGraph-0t1Qblp6.js} +1 -1
- package/dist/assets/{Skills-gNdo_HNK.js → Skills-CeVdBGE-.js} +1 -1
- package/dist/assets/{SystemPrompt-Cru05-Ia.js → SystemPrompt-CfKvNHi3.js} +1 -1
- package/dist/assets/{TagLibrary-DNHY0xou.js → TagLibrary-DAzNaUPd.js} +1 -1
- package/dist/assets/{TiptapBody-I4lmbCgP.js → TiptapBody--S_rGXoA.js} +1 -1
- package/dist/assets/{Toggle-bWMHjmRh.js → Toggle-Dszm0xnp.js} +1 -1
- package/dist/assets/{index-DV3PorRY.css → index-BHTX4OTc.css} +1 -1
- package/dist/assets/{index-fc_JjdxL.js → index-Dp4Rc--q.js} +356 -356
- package/dist/assets/{settingsSchema-BfhtZnGD.js → settingsSchema-BLbssMYo.js} +1 -1
- package/dist/assets/{whisperWorker-Dbia1OpC.js → whisperWorker-C7ZGQwKg.js} +7 -7
- package/dist/index.html +2 -2
- package/dist/vad/ort-wasm-simd-threaded.asyncify.mjs +106 -110
- package/dist/vad/ort-wasm-simd-threaded.asyncify.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jsep.mjs +98 -98
- package/dist/vad/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jspi.mjs +99 -102
- package/dist/vad/ort-wasm-simd-threaded.jspi.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.mjs +46 -46
- package/dist/vad/ort-wasm-simd-threaded.wasm +0 -0
- package/package.json +10 -13
- package/scripts/README.md +59 -0
- package/scripts/audit-ops-hygiene.cjs +350 -0
- package/scripts/hooks/guard-destructive-git.cjs +10 -34
- package/scripts/hooks/guard-inline-implementation.cjs +14 -8
- package/scripts/hooks/guard-prd-writes.cjs +7 -36
- package/scripts/hooks/guard-self-schedule.cjs +175 -0
- package/scripts/ops-sweep.cjs +355 -0
- package/scripts/scheduler-mcp-server.cjs +28 -71
- package/src/main/__tests__/bilkoHost-integration.test.cjs +3 -3
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +6 -9
- package/src/main/__tests__/chat-exit-close-race.test.cjs +3 -3
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +4 -5
- package/src/main/__tests__/chat-queue.test.cjs +2 -2
- package/src/main/__tests__/chat-stop-signal.test.cjs +2 -2
- package/src/main/__tests__/dep-orphan-archive-health.test.cjs +77 -0
- package/src/main/__tests__/dod-batchkey.test.cjs +2 -2
- package/src/main/__tests__/dod-drain-hook.test.cjs +2 -2
- package/src/main/__tests__/dod-report.test.cjs +2 -2
- package/src/main/__tests__/dod-reverify.test.cjs +2 -2
- package/src/main/__tests__/epicMint.test.cjs +2 -2
- package/src/main/__tests__/exchanges.test.cjs +2 -2
- package/src/main/__tests__/extractJson.test.cjs +2 -2
- package/src/main/__tests__/files-reject-credentials.test.cjs +1 -1
- package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +556 -0
- package/src/main/__tests__/health-build-freshness.test.cjs +39 -0
- package/src/main/__tests__/health-delegation-chain.test.cjs +15 -1
- package/src/main/__tests__/health-queue-dispatch.test.cjs +58 -7
- package/src/main/__tests__/health-tick-liveness.test.cjs +27 -3
- package/src/main/__tests__/health-usage-poller.test.cjs +70 -23
- package/src/main/__tests__/historyRollup.test.cjs +2 -2
- package/src/main/__tests__/kg-augment.test.cjs +2 -2
- package/src/main/__tests__/mcpStatus.test.cjs +2 -2
- package/src/main/__tests__/memoryAggregate.test.cjs +1 -1
- package/src/main/__tests__/memoryStale.test.cjs +1 -1
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +25 -1
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +33 -3
- package/src/main/__tests__/prd-group-allocator.test.cjs +2 -2
- package/src/main/__tests__/prdAdminRouteParity.test.cjs +2 -0
- package/src/main/__tests__/prdAdminRoutes.test.cjs +14 -2
- package/src/main/__tests__/prdAuthoringSeed.test.cjs +39 -0
- package/src/main/__tests__/prdLocationsArchived.test.cjs +20 -13
- package/src/main/__tests__/proc-role-env.test.cjs +125 -0
- package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +304 -0
- package/src/main/__tests__/procname-sm-processes.test.cjs +127 -0
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +81 -401
- package/src/main/__tests__/projectPages.test.cjs +63 -149
- package/src/main/__tests__/queue-health-verdict.test.cjs +9 -9
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +117 -20
- package/src/main/__tests__/queueHistory.test.cjs +2 -2
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +38 -3
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +181 -0
- package/src/main/__tests__/runVerify.test.cjs +5 -5
- package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +3 -3
- package/src/main/__tests__/scheduleJobTransitions.test.cjs +2 -2
- package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +143 -0
- package/src/main/__tests__/scheduler-autofix-select.test.cjs +2 -2
- package/src/main/__tests__/scheduler-autopromote.test.cjs +2 -2
- package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +3 -5
- package/src/main/__tests__/scheduler-boot-orphans.test.cjs +78 -97
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +161 -0
- package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +58 -0
- package/src/main/__tests__/scheduler-epic-digest.test.cjs +3 -5
- package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +2 -2
- package/src/main/__tests__/scheduler-gate-shadow.test.cjs +119 -0
- package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +46 -0
- package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +80 -0
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +25 -18
- package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +4 -4
- package/src/main/__tests__/scheduler-launch-failure.test.cjs +3 -5
- package/src/main/__tests__/scheduler-looks-done.test.cjs +26 -7
- package/src/main/__tests__/scheduler-manual-pause.test.cjs +118 -0
- package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +26 -3
- package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +17 -2
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +3 -5
- package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +41 -6
- package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +62 -6
- package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +3 -5
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +23 -4
- package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +100 -0
- package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +3 -3
- package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +4 -4
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +110 -0
- package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +81 -1
- package/src/main/__tests__/scheduler-stall-per-project.test.cjs +14 -0
- package/src/main/__tests__/scheduler-starve-escalation.test.cjs +4 -4
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +245 -0
- package/src/main/__tests__/scheduler-supervisor-record.test.cjs +81 -0
- package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +2 -2
- package/src/main/__tests__/scheduler-tick-wedge.test.cjs +172 -0
- package/src/main/__tests__/scheduler-transient-failure.test.cjs +2 -2
- package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +37 -11
- package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +3 -5
- package/src/main/__tests__/usageSingleFlight.test.cjs +157 -0
- package/src/main/__tests__/workTypeLibrary.test.cjs +1 -1
- package/src/main/bilkoHost.cjs +16 -7
- package/src/main/build-info.json +8 -0
- package/src/main/chatRunner.cjs +4 -2
- package/src/main/config.cjs +2 -3
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +276 -52
- package/src/main/heapSnapshot.cjs +2 -2
- package/src/main/historyAggregator.cjs +1 -1
- package/src/main/index.cjs +61 -10
- package/src/main/ipcSchemas.cjs +6 -17
- package/src/main/lib/__tests__/auditLog.test.cjs +38 -0
- package/src/main/lib/__tests__/buildIdentity.test.cjs +121 -0
- package/src/main/lib/__tests__/cwdClassify.test.cjs +111 -0
- package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +95 -0
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +1 -1
- package/src/main/lib/__tests__/dispatchLoop.test.cjs +63 -0
- package/src/main/lib/__tests__/gateFixtures.json +20 -0
- package/src/main/lib/__tests__/gitWorktree.test.cjs +8 -1
- package/src/main/lib/__tests__/instanceLock.test.cjs +93 -7
- package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +78 -0
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +11 -0
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +1 -1
- package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +6 -1
- package/src/main/lib/__tests__/procIdentity.test.cjs +119 -0
- package/src/main/lib/__tests__/procName.test.cjs +92 -0
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +67 -0
- package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +6 -7
- package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +37 -204
- package/src/main/lib/__tests__/schedulerPaths.test.cjs +226 -0
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +94 -0
- package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +56 -0
- package/src/main/lib/__tests__/sessionSlots.test.cjs +45 -0
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +1 -1
- package/src/main/lib/__tests__/upgradeDrain.test.cjs +130 -0
- package/src/main/lib/__tests__/usageCircuit.test.cjs +61 -0
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +63 -0
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +73 -0
- package/src/main/lib/activeIndexRebuild.cjs +1 -3
- package/src/main/lib/activeSessions.cjs +20 -88
- package/src/main/lib/adoptedRunSupervisor.cjs +136 -0
- package/src/main/lib/agentModelResolve.cjs +33 -1
- package/src/main/lib/agentPersonaSchema.cjs +2 -2
- package/src/main/lib/auditLog.cjs +30 -5
- package/src/main/lib/buildIdentity.cjs +113 -0
- package/src/main/lib/classifyPromptTicket.cjs +3 -2
- package/src/main/lib/claudeBin.cjs +37 -2
- package/src/main/lib/cleanEnv.cjs +27 -1
- package/src/main/lib/credentials.cjs +4 -2
- package/src/main/lib/cwdClassify.cjs +185 -0
- package/src/main/lib/definitionOfDone.cjs +296 -52
- package/src/main/lib/dispatchLoop.cjs +40 -0
- package/src/main/lib/effectiveModelInfo.cjs +9 -10
- package/src/main/lib/ephemeralCwd.cjs +7 -28
- package/src/main/lib/gitWorktree.cjs +95 -8
- package/src/main/lib/guardShims.cjs +3 -3
- package/src/main/lib/historyRollup.cjs +6 -7
- package/src/main/lib/instanceLock.cjs +32 -5
- package/src/main/lib/jobSupervisorRecord.cjs +147 -0
- package/src/main/lib/jobWorktreeBootLive.cjs +9 -5
- package/src/main/lib/localAdminHttp.cjs +9 -27
- package/src/main/lib/mcpToolCatalog.cjs +29 -77
- package/src/main/lib/opsOwnership.cjs +27 -19
- package/src/main/lib/prdAuthoringSeed.cjs +36 -0
- package/src/main/lib/prdLocations.cjs +48 -1
- package/src/main/lib/procIdentity.cjs +126 -0
- package/src/main/lib/procName.cjs +98 -0
- package/src/main/lib/projectHomeAdminRoutes.cjs +56 -327
- package/src/main/lib/queueHistory.cjs +8 -7
- package/src/main/lib/queueStore.cjs +57 -37
- package/src/main/lib/quietMachineLease.cjs +19 -2
- package/src/main/lib/reservationExpiry.cjs +30 -0
- package/src/main/lib/runClaudeP.cjs +4 -2
- package/src/main/lib/runLogRetention.cjs +3 -2
- package/src/main/lib/scheduleJobSchema.cjs +2 -2
- package/src/main/lib/scheduleJobTransitions.cjs +29 -2
- package/src/main/lib/schedulerBatch.cjs +27 -2
- package/src/main/lib/schedulerPaths.cjs +175 -0
- package/src/main/lib/schedulerRuntimeState.cjs +59 -0
- package/src/main/lib/sessionSlots.cjs +47 -9
- package/src/main/lib/smProcNames.cjs +51 -0
- package/src/main/lib/upgradeDrain.cjs +188 -0
- package/src/main/lib/usageCircuit.cjs +53 -6
- package/src/main/lib/watchdogHelpers.cjs +70 -37
- package/src/main/lib/withTimeout.cjs +33 -0
- package/src/main/mcpStatus.cjs +4 -2
- package/src/main/pluginInstall.cjs +6 -2
- package/src/main/projectPages.cjs +41 -145
- package/src/main/pty.cjs +8 -1
- package/src/main/queueOps.cjs +10 -10
- package/src/main/runVerify.cjs +69 -3
- package/src/main/scheduler.cjs +1607 -383
- package/src/main/seedAgentPersonas.cjs +1 -1
- package/src/main/seedDevPlugin.cjs +1 -1
- package/src/main/seedSchedulerMcp.cjs +7 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/supervisor.cjs +5 -3
- package/src/main/usage.cjs +126 -62
- package/src/preload/api.d.ts +18 -64
- package/src/preload/index.cjs +2 -4
- package/src/seed/agents/project-home-builder.md +31 -48
- package/screenshots/.gitkeep +0 -0
- package/screenshots/README-screenshots.md +0 -13
- package/src/main/lib/projectPageSummarySchema.cjs +0 -181
- package/src/main/teams.cjs +0 -95
- package/src/main/templates/project-pages-catalog.json +0 -741
- package/src/main/templates/project-pages-default-home.html +0 -123
- package/src/main/templates/project-pages-pipeline.md +0 -417
- package/src/seed/prompts/code-review/ac-coverage-check.md +0 -8
- package/src/seed/prompts/code-review/correctness-only.md +0 -8
- package/src/seed/prompts/code-review/full-spectrum-high.md +0 -8
- package/src/seed/prompts/code-review/hallucination-check.md +0 -8
- package/src/seed/prompts/code-review/public-api-compat.md +0 -8
- package/src/seed/prompts/code-review/readability-naming.md +0 -8
- package/src/seed/prompts/debugging/bug-as-failing-test.md +0 -8
- package/src/seed/prompts/debugging/git-bisect-regression.md +0 -8
- package/src/seed/prompts/debugging/instrument-intermittent-bug.md +0 -8
- package/src/seed/prompts/debugging/localize-pipeline-failure.md +0 -8
- package/src/seed/prompts/debugging/reproduce-then-diagnose.md +0 -8
- package/src/seed/prompts/documentation/adr-from-change.md +0 -8
- package/src/seed/prompts/documentation/module-readme.md +0 -8
- package/src/seed/prompts/documentation/onboarding-plan.md +0 -8
- package/src/seed/prompts/documentation/refresh-claude-md.md +0 -8
- package/src/seed/prompts/documentation/tsdoc-public-exports.md +0 -8
- package/src/seed/prompts/git-pr/conventional-commit.md +0 -8
- package/src/seed/prompts/git-pr/draft-pr-title-body.md +0 -8
- package/src/seed/prompts/git-pr/pre-commit-safety-sweep.md +0 -8
- package/src/seed/prompts/git-pr/release-notes-block.md +0 -8
- package/src/seed/prompts/git-pr/split-large-pr.md +0 -8
- package/src/seed/prompts/performance/bundle-startup-audit.md +0 -8
- package/src/seed/prompts/performance/complexity-audit.md +0 -8
- package/src/seed/prompts/performance/cpu-profile-hot-path.md +0 -8
- package/src/seed/prompts/performance/db-query-plan-review.md +0 -8
- package/src/seed/prompts/performance/memory-leak-hunt.md +0 -8
- package/src/seed/prompts/qa/api-contract-tests.md +0 -8
- package/src/seed/prompts/qa/e2e-critical-path.md +0 -8
- package/src/seed/prompts/qa/failing-test-for-bug.md +0 -8
- package/src/seed/prompts/qa/find-missing-test-coverage.md +0 -8
- package/src/seed/prompts/qa/stabilize-flaky-test.md +0 -8
- package/src/seed/prompts/qa/tdd-red-first.md +0 -8
- package/src/seed/prompts/qa/visual-regression-review.md +0 -8
- package/src/seed/prompts/qa/wcag-axe-scan.md +0 -8
- package/src/seed/prompts/refactoring/dead-code-sweep.md +0 -8
- package/src/seed/prompts/refactoring/extract-duplicated-pattern.md +0 -8
- package/src/seed/prompts/refactoring/modernize-legacy-file.md +0 -8
- package/src/seed/prompts/refactoring/reduce-cyclomatic-complexity.md +0 -8
- package/src/seed/prompts/refactoring/tighten-module-boundaries.md +0 -8
- package/src/seed/prompts/security/authz-audit.md +0 -8
- package/src/seed/prompts/security/crypto-correctness.md +0 -8
- package/src/seed/prompts/security/cwe-top-25-hunt.md +0 -8
- package/src/seed/prompts/security/dependency-audit.md +0 -8
- package/src/seed/prompts/security/ipc-boundary-hardening.md +0 -8
- package/src/seed/prompts/security/owasp-top-10-staged-diff.md +0 -8
- package/src/seed/prompts/security/secret-credential-scan.md +0 -8
- package/web/README.md +0 -41
- package/web/project-pages/logic/dist/logic.cjs +0 -4709
- package/web/project-pages/render.cjs +0 -70
- package/web/project-pages/renderer/dist/renderer.cjs +0 -18900
- package/web/project-pages/validate-summary.cjs +0 -62
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* schedulerMcpServerProjectHome.test.cjs — the
|
|
3
|
-
*
|
|
2
|
+
* schedulerMcpServerProjectHome.test.cjs — the single project_home_write MCP
|
|
3
|
+
* tool that wraps POST /admin/project-home/write.
|
|
4
4
|
* Covers: presence in TOOLS, catalog-composed descriptions, correct
|
|
5
5
|
* route/payload dispatch via a stubbed admin HTTP server, cwd defaulting to
|
|
6
|
-
* SM_PROJECT_ROOT/process.cwd() when omitted, the app-not-running failure
|
|
7
|
-
* shape
|
|
8
|
-
* self-sufficient (mentions all 5 lens ids, no repo-relative path).
|
|
6
|
+
* SM_PROJECT_ROOT/process.cwd() when omitted, and the app-not-running failure
|
|
7
|
+
* shape.
|
|
9
8
|
*
|
|
10
9
|
* Same HOME-repointing pattern as schedulerMcpServerHelp.test.cjs — see that
|
|
11
10
|
* file's header for why.
|
|
@@ -23,7 +22,8 @@ const path = require('node:path');
|
|
|
23
22
|
const SERVER_PATH = path.join(__dirname, '../../../../scripts/scheduler-mcp-server.cjs');
|
|
24
23
|
const { MCP_TOOL_CATALOG, composeDescription } = require('../mcpToolCatalog.cjs');
|
|
25
24
|
|
|
26
|
-
const
|
|
25
|
+
const TOOL_NAME = 'project_home_write';
|
|
26
|
+
const OLD_TOOL_NAMES = [
|
|
27
27
|
'project_home_get_contract',
|
|
28
28
|
'project_home_validate_summary',
|
|
29
29
|
'project_home_render',
|
|
@@ -94,8 +94,7 @@ function requireServerWithHome(homeDir) {
|
|
|
94
94
|
process.env.HOME = homeDir;
|
|
95
95
|
delete require.cache[require.resolve(SERVER_PATH)];
|
|
96
96
|
const mod = require(SERVER_PATH);
|
|
97
|
-
|
|
98
|
-
originalHome = undefined;
|
|
97
|
+
// HOME stays redirected until afterEach: admin-token path resolves lazily.
|
|
99
98
|
return mod;
|
|
100
99
|
}
|
|
101
100
|
|
|
@@ -109,223 +108,60 @@ function callTool(handleCallTool, name, args) {
|
|
|
109
108
|
return handleCallTool({ params: { name, arguments: args } });
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
test('
|
|
111
|
+
test('project_home_write is the only project_home_* tool, with html required and cwd optional', async () => {
|
|
113
112
|
const homeDir = await mkTmp();
|
|
114
113
|
const { TOOLS } = requireServerWithHome(homeDir);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
const validate = TOOLS.find((t) => t.name === 'project_home_validate_summary');
|
|
124
|
-
expect(validate.inputSchema.required).toContain('summary');
|
|
125
|
-
const render = TOOLS.find((t) => t.name === 'project_home_render');
|
|
126
|
-
expect(render.inputSchema.required).toEqual(expect.arrayContaining(['summary', 'picks']));
|
|
114
|
+
expect(TOOLS.filter((t) => t.name.startsWith('project_home_')).map((t) => t.name)).toEqual([TOOL_NAME]);
|
|
115
|
+
for (const old of OLD_TOOL_NAMES) expect(TOOLS.find((t) => t.name === old)).toBeUndefined();
|
|
116
|
+
const tool = TOOLS.find((t) => t.name === TOOL_NAME);
|
|
117
|
+
expect(tool.inputSchema.type).toBe('object');
|
|
118
|
+
expect(tool.inputSchema.properties.cwd).toBeTruthy();
|
|
119
|
+
expect(tool.inputSchema.properties.html).toBeTruthy();
|
|
120
|
+
expect(tool.inputSchema.required).toEqual(['html']);
|
|
127
121
|
});
|
|
128
122
|
|
|
129
|
-
test
|
|
123
|
+
test('project_home_write description equals the catalog-composed string; old entries are gone', async () => {
|
|
130
124
|
const homeDir = await mkTmp();
|
|
131
125
|
const { TOOLS } = requireServerWithHome(homeDir);
|
|
132
|
-
const tool = TOOLS.find((t) => t.name ===
|
|
133
|
-
const entry = MCP_TOOL_CATALOG.find((e) => e.name ===
|
|
126
|
+
const tool = TOOLS.find((t) => t.name === TOOL_NAME);
|
|
127
|
+
const entry = MCP_TOOL_CATALOG.find((e) => e.name === TOOL_NAME);
|
|
134
128
|
expect(entry).toBeTruthy();
|
|
135
129
|
expect(entry.group).toBe('project-home');
|
|
136
130
|
expect(tool.description).toBe(composeDescription(entry));
|
|
131
|
+
for (const old of OLD_TOOL_NAMES) expect(MCP_TOOL_CATALOG.find((e) => e.name === old)).toBeUndefined();
|
|
137
132
|
});
|
|
138
133
|
|
|
139
|
-
test('
|
|
140
|
-
const homeDir = await mkTmp();
|
|
141
|
-
const token = 'test-token';
|
|
142
|
-
const { server, requests } = await startFakeAdminServer(token, {
|
|
143
|
-
ok: true,
|
|
144
|
-
protocol: ['step one'],
|
|
145
|
-
catalog: { lenses: [{ id: 'home' }, { id: 'marketing' }, { id: 'feature' }, { id: 'architecture' }, { id: 'brief' }] },
|
|
146
|
-
paths: { summaryPath: '/abs/summary.json', picksPath: '/abs/picks.json', outputDir: '/abs/output' },
|
|
147
|
-
spec: { text: 'spec text', path: '/abs/spec.md' },
|
|
148
|
-
});
|
|
149
|
-
servers.push(server);
|
|
150
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
151
|
-
|
|
152
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
153
|
-
const result = await callTool(handleCallTool, 'project_home_get_contract', { cwd: '/home/bilko/Projects/session-manager' });
|
|
154
|
-
expect(result.isError).toBeFalsy();
|
|
155
|
-
expect(requests).toHaveLength(1);
|
|
156
|
-
expect(requests[0].method).toBe('GET');
|
|
157
|
-
expect(requests[0].url).toBe('/admin/project-home/contract?cwd=%2Fhome%2Fbilko%2FProjects%2Fsession-manager');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('project_home_get_contract composed response mentions all 5 lens ids and no repo-relative path', async () => {
|
|
161
|
-
const homeDir = await mkTmp();
|
|
162
|
-
const token = 'test-token';
|
|
163
|
-
const { server } = await startFakeAdminServer(token, {
|
|
164
|
-
ok: true,
|
|
165
|
-
protocol: [
|
|
166
|
-
'Call GET /admin/project-home/status?cwd=<abs> first.',
|
|
167
|
-
'Compose a ProjectPageSummary matching summarySchema.',
|
|
168
|
-
'For each lens in catalog.lenses, pick a variant per slot.',
|
|
169
|
-
'POST /admin/project-home/validate-summary with {cwd, summary}.',
|
|
170
|
-
'POST /admin/project-home/render with {cwd, summary, picks}.',
|
|
171
|
-
],
|
|
172
|
-
summarySchema: { type: 'object' },
|
|
173
|
-
picksSchema: { type: 'object' },
|
|
174
|
-
catalog: {
|
|
175
|
-
lenses: [
|
|
176
|
-
{ id: 'home', slots: [] },
|
|
177
|
-
{ id: 'marketing', slots: [] },
|
|
178
|
-
{ id: 'feature', slots: [] },
|
|
179
|
-
{ id: 'architecture', slots: [] },
|
|
180
|
-
{ id: 'brief', slots: [] },
|
|
181
|
-
],
|
|
182
|
-
},
|
|
183
|
-
paths: { summaryPath: '/abs/project-pages/summary.json', picksPath: '/abs/project-pages/picks.json', outputDir: '/abs/project-pages/output' },
|
|
184
|
-
spec: { text: 'This project uses absolute paths only, never repo-relative ones.', path: '/abs/project-pages-pipeline.md' },
|
|
185
|
-
});
|
|
186
|
-
servers.push(server);
|
|
187
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
188
|
-
|
|
189
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
190
|
-
const result = await callTool(handleCallTool, 'project_home_get_contract', {});
|
|
191
|
-
expect(result.isError).toBeFalsy();
|
|
192
|
-
const text = result.content[0].text;
|
|
193
|
-
for (const lens of ['home', 'marketing', 'feature', 'architecture', 'brief']) {
|
|
194
|
-
expect(text).toContain(lens);
|
|
195
|
-
}
|
|
196
|
-
expect(text).not.toMatch(/session-manager-operations\/architecture\//);
|
|
197
|
-
expect(text).not.toMatch(/\.claude\/agents\//);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('project_home_validate_summary dispatches POST /admin/project-home/validate-summary with cwd+summary', async () => {
|
|
201
|
-
const homeDir = await mkTmp();
|
|
202
|
-
const token = 'test-token';
|
|
203
|
-
const { server, requests } = await startFakeAdminServer(token, { ok: true, valid: true, errors: [] });
|
|
204
|
-
servers.push(server);
|
|
205
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
206
|
-
|
|
207
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
208
|
-
const summary = { title: 'Example Project' };
|
|
209
|
-
const result = await callTool(handleCallTool, 'project_home_validate_summary', {
|
|
210
|
-
cwd: '/home/bilko/Projects/session-manager',
|
|
211
|
-
summary,
|
|
212
|
-
});
|
|
213
|
-
expect(result.isError).toBeFalsy();
|
|
214
|
-
expect(requests).toHaveLength(1);
|
|
215
|
-
expect(requests[0].method).toBe('POST');
|
|
216
|
-
expect(requests[0].url).toBe('/admin/project-home/validate-summary');
|
|
217
|
-
expect(requests[0].body).toEqual({ cwd: '/home/bilko/Projects/session-manager', summary });
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
test('project_home_validate_summary surfaces per-field errors from the route, not a generic failure', async () => {
|
|
221
|
-
const homeDir = await mkTmp();
|
|
222
|
-
const token = 'test-token';
|
|
223
|
-
const { server } = await startFakeAdminServer(token, {
|
|
224
|
-
ok: true,
|
|
225
|
-
valid: false,
|
|
226
|
-
errors: [{ field: 'quotes[0].attribution', message: 'quotes[0].attribution must not be a placeholder value' }],
|
|
227
|
-
});
|
|
228
|
-
servers.push(server);
|
|
229
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
230
|
-
|
|
231
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
232
|
-
const result = await callTool(handleCallTool, 'project_home_validate_summary', {
|
|
233
|
-
cwd: '/home/bilko/Projects/session-manager',
|
|
234
|
-
summary: { title: 'x', quotes: [{ attribution: 'TODO' }] },
|
|
235
|
-
});
|
|
236
|
-
expect(result.isError).toBeFalsy();
|
|
237
|
-
const body = JSON.parse(result.content[0].text);
|
|
238
|
-
expect(body.valid).toBe(false);
|
|
239
|
-
expect(body.errors).toEqual([
|
|
240
|
-
{ field: 'quotes[0].attribution', message: 'quotes[0].attribution must not be a placeholder value' },
|
|
241
|
-
]);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
test('project_home_validate_summary requires summary', async () => {
|
|
245
|
-
const homeDir = await mkTmp();
|
|
246
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
247
|
-
const result = await callTool(handleCallTool, 'project_home_validate_summary', { cwd: '/x' });
|
|
248
|
-
expect(result.isError).toBe(true);
|
|
249
|
-
expect(result.content[0].text).toContain('summary');
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
test('project_home_render dispatches POST /admin/project-home/render with cwd+summary+picks', async () => {
|
|
134
|
+
test('project_home_write dispatches POST /admin/project-home/write with cwd+html', async () => {
|
|
253
135
|
const homeDir = await mkTmp();
|
|
254
136
|
const token = 'test-token';
|
|
255
|
-
const { server, requests } = await startFakeAdminServer(token, {
|
|
256
|
-
ok: true,
|
|
257
|
-
filesWritten: ['/abs/summary.json'],
|
|
258
|
-
generatedAt: '2026-09-01T00:00:00.000Z',
|
|
259
|
-
});
|
|
137
|
+
const { server, requests } = await startFakeAdminServer(token, { ok: true, path: '/abs/home.html', bytes: 12 });
|
|
260
138
|
servers.push(server);
|
|
261
139
|
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
262
140
|
|
|
263
141
|
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const result = await callTool(handleCallTool, 'project_home_render', {
|
|
267
|
-
cwd: '/home/bilko/Projects/session-manager',
|
|
268
|
-
summary,
|
|
269
|
-
picks,
|
|
270
|
-
});
|
|
142
|
+
const html = '<!DOCTYPE html><html></html>';
|
|
143
|
+
const result = await callTool(handleCallTool, TOOL_NAME, { cwd: '/home/bilko/Projects/session-manager', html });
|
|
271
144
|
expect(result.isError).toBeFalsy();
|
|
272
145
|
expect(requests).toHaveLength(1);
|
|
273
146
|
expect(requests[0].method).toBe('POST');
|
|
274
|
-
expect(requests[0].url).toBe('/admin/project-home/
|
|
275
|
-
expect(requests[0].body).toEqual({ cwd: '/home/bilko/Projects/session-manager',
|
|
147
|
+
expect(requests[0].url).toBe('/admin/project-home/write');
|
|
148
|
+
expect(requests[0].body).toEqual({ cwd: '/home/bilko/Projects/session-manager', html });
|
|
276
149
|
});
|
|
277
150
|
|
|
278
|
-
test('
|
|
151
|
+
test('project_home_write requires a non-empty html', async () => {
|
|
279
152
|
const homeDir = await mkTmp();
|
|
280
153
|
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const missingPicks = await callTool(handleCallTool, 'project_home_render', { summary: {} });
|
|
287
|
-
expect(missingPicks.isError).toBe(true);
|
|
288
|
-
expect(missingPicks.content[0].text).toContain('picks');
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test('project_home_status dispatches GET /admin/project-home/status with cwd query param', async () => {
|
|
292
|
-
const homeDir = await mkTmp();
|
|
293
|
-
const token = 'test-token';
|
|
294
|
-
const { server, requests } = await startFakeAdminServer(token, {
|
|
295
|
-
ok: true,
|
|
296
|
-
summary: { exists: false, mtimeMs: null },
|
|
297
|
-
picks: { exists: false, mtimeMs: null },
|
|
298
|
-
output: {
|
|
299
|
-
home: { exists: false, mtimeMs: null },
|
|
300
|
-
marketing: { exists: false, mtimeMs: null },
|
|
301
|
-
feature: { exists: false, mtimeMs: null },
|
|
302
|
-
architecture: { exists: false, mtimeMs: null },
|
|
303
|
-
brief: { exists: false, mtimeMs: null },
|
|
304
|
-
},
|
|
305
|
-
manifest: { exists: false, generatedAt: null },
|
|
306
|
-
});
|
|
307
|
-
servers.push(server);
|
|
308
|
-
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
309
|
-
|
|
310
|
-
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
311
|
-
const result = await callTool(handleCallTool, 'project_home_status', { cwd: '/home/bilko/Projects/session-manager' });
|
|
312
|
-
expect(result.isError).toBeFalsy();
|
|
313
|
-
expect(requests).toHaveLength(1);
|
|
314
|
-
expect(requests[0].method).toBe('GET');
|
|
315
|
-
expect(requests[0].url).toBe('/admin/project-home/status?cwd=%2Fhome%2Fbilko%2FProjects%2Fsession-manager');
|
|
316
|
-
|
|
317
|
-
// Never-generated project: well-formed all-absent result, not an error.
|
|
318
|
-
const body = JSON.parse(result.content[0].text);
|
|
319
|
-
expect(body.ok).toBe(true);
|
|
320
|
-
expect(body.summary.exists).toBe(false);
|
|
321
|
-
expect(body.manifest.exists).toBe(false);
|
|
322
|
-
expect(body.output.brief.exists).toBe(false);
|
|
154
|
+
for (const args of [{ cwd: '/x' }, { cwd: '/x', html: '' }]) {
|
|
155
|
+
const result = await callTool(handleCallTool, TOOL_NAME, args);
|
|
156
|
+
expect(result.isError).toBe(true);
|
|
157
|
+
expect(result.content[0].text).toContain('html');
|
|
158
|
+
}
|
|
323
159
|
});
|
|
324
160
|
|
|
325
|
-
test
|
|
161
|
+
test('project_home_write defaults cwd to SM_PROJECT_ROOT when omitted', async () => {
|
|
326
162
|
const homeDir = await mkTmp();
|
|
327
163
|
const token = 'test-token';
|
|
328
|
-
const { server, requests } = await startFakeAdminServer(token, { ok: true
|
|
164
|
+
const { server, requests } = await startFakeAdminServer(token, { ok: true });
|
|
329
165
|
servers.push(server);
|
|
330
166
|
await writeAdminConfig(homeDir, { port: server.address().port, token });
|
|
331
167
|
|
|
@@ -333,18 +169,15 @@ test.each(PROJECT_HOME_TOOL_NAMES)('%s defaults cwd to SM_PROJECT_ROOT when omit
|
|
|
333
169
|
process.env.SM_PROJECT_ROOT = '/home/bilko/Projects/session-manager/session-manager-operations/scheduler/epics/some-epic/worktree';
|
|
334
170
|
|
|
335
171
|
const { handleCallTool } = requireServerWithHome(homeDir);
|
|
336
|
-
|
|
337
|
-
await callTool(handleCallTool, name, args);
|
|
172
|
+
await callTool(handleCallTool, TOOL_NAME, { html: '<p>x</p>' });
|
|
338
173
|
expect(requests).toHaveLength(1);
|
|
339
|
-
|
|
340
|
-
expect(encoded).toBe(process.env.SM_PROJECT_ROOT);
|
|
174
|
+
expect(requests[0].body.cwd).toBe(process.env.SM_PROJECT_ROOT);
|
|
341
175
|
});
|
|
342
176
|
|
|
343
|
-
test
|
|
177
|
+
test('project_home_write returns the app-not-running error when the admin API is unreachable', async () => {
|
|
344
178
|
const homeDir = await mkTmp();
|
|
345
179
|
const { handleCallTool, NOT_RUNNING_ERROR } = requireServerWithHome(homeDir);
|
|
346
|
-
const
|
|
347
|
-
const result = await callTool(handleCallTool, name, args);
|
|
180
|
+
const result = await callTool(handleCallTool, TOOL_NAME, { html: '<p>x</p>' });
|
|
348
181
|
expect(result.isError).toBe(true);
|
|
349
182
|
expect(result.content[0].text).toBe(NOT_RUNNING_ERROR);
|
|
350
183
|
});
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedulerPaths.test.cjs — every machine-wide scheduler root resolves lazily
|
|
3
|
+
* through lib/schedulerPaths.cjs, so SM_SCHEDULER_HOME redirects ALL of them.
|
|
4
|
+
*
|
|
5
|
+
* SM_SCHEDULER_HOME is set to a temp dir BEFORE the modules under test are
|
|
6
|
+
* required; nothing here touches ~/.claude/session-manager.
|
|
7
|
+
*
|
|
8
|
+
* Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerPaths.test.cjs
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import { test, expect, beforeAll, afterAll } from 'vitest';
|
|
14
|
+
const fs = require('node:fs');
|
|
15
|
+
const os = require('node:os');
|
|
16
|
+
const path = require('node:path');
|
|
17
|
+
|
|
18
|
+
const REPO = path.resolve(__dirname, '..', '..', '..', '..');
|
|
19
|
+
// Every module the PRD routes through the resolver — a half-redirect in any of
|
|
20
|
+
// them fails the source scan below.
|
|
21
|
+
const ROUTED_MODULES = [
|
|
22
|
+
'src/main/scheduler.cjs',
|
|
23
|
+
'src/main/queueOps.cjs',
|
|
24
|
+
'src/main/lib/queueStore.cjs',
|
|
25
|
+
'src/main/lib/sessionSlots.cjs',
|
|
26
|
+
'src/main/lib/localAdminHttp.cjs',
|
|
27
|
+
'src/main/lib/watchdogHelpers.cjs',
|
|
28
|
+
'src/main/health.cjs',
|
|
29
|
+
'scripts/scheduler-watchdog.cjs',
|
|
30
|
+
'src/main/lib/auditLog.cjs',
|
|
31
|
+
'src/main/lib/historyRollup.cjs',
|
|
32
|
+
'src/main/lib/queueHistory.cjs',
|
|
33
|
+
'src/main/lib/instanceLock.cjs',
|
|
34
|
+
'src/main/lib/procName.cjs',
|
|
35
|
+
'src/main/heapSnapshot.cjs',
|
|
36
|
+
'scripts/scheduler-mcp-server.cjs',
|
|
37
|
+
'scripts/replay-verdicts.cjs',
|
|
38
|
+
'scripts/audit-ops-hygiene.cjs',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const ENV_KEYS = ['SM_SCHEDULER_HOME', 'SM_SCHEDULER_LOG_CWD', 'SM_ADMIN_TOKEN_PATH', 'SM_DEV', 'SM_E2E'];
|
|
42
|
+
const savedEnv = {};
|
|
43
|
+
let tmpHome;
|
|
44
|
+
let sp;
|
|
45
|
+
|
|
46
|
+
beforeAll(() => {
|
|
47
|
+
for (const k of ENV_KEYS) savedEnv[k] = process.env[k];
|
|
48
|
+
for (const k of ['SM_SCHEDULER_LOG_CWD', 'SM_ADMIN_TOKEN_PATH', 'SM_DEV', 'SM_E2E']) delete process.env[k];
|
|
49
|
+
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-scheduler-home-'));
|
|
50
|
+
process.env.SM_SCHEDULER_HOME = tmpHome;
|
|
51
|
+
sp = require('../schedulerPaths.cjs');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterAll(() => {
|
|
55
|
+
for (const k of ENV_KEYS) {
|
|
56
|
+
if (savedEnv[k] === undefined) delete process.env[k]; else process.env[k] = savedEnv[k];
|
|
57
|
+
}
|
|
58
|
+
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('every resolver lands under SM_SCHEDULER_HOME', () => {
|
|
62
|
+
expect(sp.schedulerHome()).toBe(tmpHome);
|
|
63
|
+
const plans = path.join(tmpHome, 'scheduled-plans');
|
|
64
|
+
expect(sp.scheduledPlansRoot()).toBe(plans);
|
|
65
|
+
expect(sp.runsDir()).toBe(path.join(plans, 'runs'));
|
|
66
|
+
expect(sp.prdsRoot()).toBe(path.join(plans, 'prds'));
|
|
67
|
+
expect(sp.legacyQueuePath()).toBe(path.join(plans, 'queue.json'));
|
|
68
|
+
expect(sp.machineStatePath()).toBe(path.join(tmpHome, 'scheduler-machine.json'));
|
|
69
|
+
expect(sp.schedulerStatePath()).toBe(path.join(tmpHome, 'scheduler-state.json'));
|
|
70
|
+
expect(sp.heartbeatPath()).toBe(path.join(tmpHome, 'scheduler-heartbeat.log'));
|
|
71
|
+
expect(sp.sessionSlotsConfigPath()).toBe(path.join(tmpHome, 'session-slots-config.json'));
|
|
72
|
+
expect(sp.adminTokenPath()).toBe(path.join(tmpHome, 'admin-api.json'));
|
|
73
|
+
expect(sp.watchdogLogsDir()).toBe(path.join(tmpHome, 'logs'));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('resolvers are lazy: changing the env changes the result without re-requiring', () => {
|
|
77
|
+
const other = path.join(tmpHome, 'other');
|
|
78
|
+
process.env.SM_SCHEDULER_HOME = other;
|
|
79
|
+
try {
|
|
80
|
+
expect(sp.runsDir()).toBe(path.join(other, 'scheduled-plans', 'runs'));
|
|
81
|
+
} finally {
|
|
82
|
+
process.env.SM_SCHEDULER_HOME = tmpHome;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('default home is ~/.claude/session-manager', () => {
|
|
87
|
+
delete process.env.SM_SCHEDULER_HOME;
|
|
88
|
+
try {
|
|
89
|
+
expect(sp.schedulerHome()).toBe(path.join(os.homedir(), '.claude', 'session-manager'));
|
|
90
|
+
} finally {
|
|
91
|
+
process.env.SM_SCHEDULER_HOME = tmpHome;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('adminTokenPath keeps the SM_ADMIN_TOKEN_PATH > SM_DEV > SM_E2E ladder', () => {
|
|
96
|
+
try {
|
|
97
|
+
process.env.SM_E2E = '1';
|
|
98
|
+
expect(sp.adminTokenPath()).toBe(path.join(tmpHome, 'admin-api.e2e.json'));
|
|
99
|
+
process.env.SM_DEV = '1';
|
|
100
|
+
expect(sp.adminTokenPath()).toBe(path.join(tmpHome, 'admin-api.dev.json'));
|
|
101
|
+
process.env.SM_ADMIN_TOKEN_PATH = path.join(os.tmpdir(), 'explicit-token.json');
|
|
102
|
+
expect(sp.adminTokenPath()).toBe(path.join(os.tmpdir(), 'explicit-token.json'));
|
|
103
|
+
} finally {
|
|
104
|
+
delete process.env.SM_E2E; delete process.env.SM_DEV; delete process.env.SM_ADMIN_TOKEN_PATH;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('machineStateLogCwd is the literal ~/Projects/session-manager unless overridden (never process.cwd())', () => {
|
|
109
|
+
expect(sp.machineStateLogCwd()).toBe(path.join(os.homedir(), 'Projects', 'session-manager'));
|
|
110
|
+
process.env.SM_SCHEDULER_LOG_CWD = path.join(os.tmpdir(), 'log-cwd');
|
|
111
|
+
try {
|
|
112
|
+
expect(sp.machineStateLogCwd()).toBe(path.join(os.tmpdir(), 'log-cwd'));
|
|
113
|
+
} finally {
|
|
114
|
+
delete process.env.SM_SCHEDULER_LOG_CWD;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('queueStore: paths and readMergedSync resolve under the override', () => {
|
|
119
|
+
const queueStore = require('../queueStore.cjs');
|
|
120
|
+
expect(queueStore.MACHINE_STATE_PATH).toBe(sp.machineStatePath());
|
|
121
|
+
expect(queueStore.LEGACY_QUEUE_PATH).toBe(sp.legacyQueuePath());
|
|
122
|
+
fs.writeFileSync(sp.machineStatePath(), JSON.stringify({ paused: null, lastRunAt: 4242 }));
|
|
123
|
+
const merged = queueStore.readMergedSync();
|
|
124
|
+
expect(merged.unreadable).toBeUndefined();
|
|
125
|
+
expect(merged.lastRunAt).toBe(4242);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('sessionSlots: persisted cap is read from and written under the override', () => {
|
|
129
|
+
const slots = require('../sessionSlots.cjs');
|
|
130
|
+
slots.setCap(7);
|
|
131
|
+
const cfg = sp.sessionSlotsConfigPath();
|
|
132
|
+
expect(JSON.parse(fs.readFileSync(cfg, 'utf8')).cap).toBe(7);
|
|
133
|
+
expect(slots.totalSlots()).toBe(7);
|
|
134
|
+
slots.__resetForTests?.();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('localAdminHttp: TOKEN_PATH / resolveTokenPath follow the resolver', () => {
|
|
138
|
+
const admin = require('../localAdminHttp.cjs');
|
|
139
|
+
expect(admin.TOKEN_PATH).toBe(path.join(tmpHome, 'admin-api.json'));
|
|
140
|
+
expect(admin.resolveTokenPath()).toBe(admin.TOKEN_PATH);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('scheduler / queueOps / watchdogHelpers path exports follow the override', () => {
|
|
144
|
+
const scheduler = require('../../scheduler.cjs');
|
|
145
|
+
expect(scheduler.ROOT).toBe(sp.scheduledPlansRoot());
|
|
146
|
+
expect(scheduler.PRDS_DIR).toBe(sp.prdsRoot());
|
|
147
|
+
expect(scheduler.RUNS_DIR).toBe(sp.runsDir());
|
|
148
|
+
expect(scheduler.SCHEDULER_STATE_PATH).toBe(sp.schedulerStatePath());
|
|
149
|
+
const queueOps = require('../../queueOps.cjs');
|
|
150
|
+
expect(queueOps.PRDS_DIR).toBe(sp.prdsRoot());
|
|
151
|
+
expect(queueOps.PRDS_ARCHIVE_DIR).toBe(path.join(sp.scheduledPlansRoot(), 'prds-archived'));
|
|
152
|
+
const wd = require('../watchdogHelpers.cjs');
|
|
153
|
+
expect(wd.DEFAULT_HEARTBEAT_PATH).toBe(sp.heartbeatPath());
|
|
154
|
+
expect(wd.DEFAULT_LOCK_PATH).toBe(sp.historyRollupLockPath());
|
|
155
|
+
expect(wd.DEFAULT_STAMP_PATH).toBe(sp.historyRollupStampPath());
|
|
156
|
+
expect(wd.DEFAULT_RELAUNCH_STATE_PATH).toBe(sp.watchdogRelaunchStatePath());
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('auditLog, historyRollup, queueHistory, instanceLock, procName, heapSnapshot land under SM_SCHEDULER_HOME', () => {
|
|
160
|
+
const saved = {};
|
|
161
|
+
for (const k of ['SM_HISTORY_PATH_OVERRIDE', 'SM_SCHEDULER_LOCK_PATH']) { saved[k] = process.env[k]; delete process.env[k]; }
|
|
162
|
+
try {
|
|
163
|
+
const auditLog = require('../auditLog.cjs');
|
|
164
|
+
expect(auditLog.auditLogPath()).toBe(path.join(tmpHome, 'audit-log.jsonl'));
|
|
165
|
+
auditLog.appendAuditEvent('schedulerPaths_test', {});
|
|
166
|
+
expect(fs.existsSync(path.join(tmpHome, 'audit-log.jsonl'))).toBe(true);
|
|
167
|
+
expect(require('../historyRollup.cjs').historyRollupPath()).toBe(path.join(tmpHome, 'history-rollup.jsonl'));
|
|
168
|
+
expect(require('../queueHistory.cjs').historyPath()).toBe(path.join(tmpHome, 'scheduled-plans', 'history.jsonl'));
|
|
169
|
+
expect(require('../instanceLock.cjs').lockPath()).toBe(path.join(tmpHome, 'scheduler-owner.lock'));
|
|
170
|
+
expect(require('../procName.cjs').procnamesRoot()).toBe(path.join(tmpHome, 'procnames'));
|
|
171
|
+
expect(sp.heapSnapshotDir()).toBe(tmpHome);
|
|
172
|
+
} finally {
|
|
173
|
+
for (const k of Object.keys(saved)) { if (saved[k] === undefined) delete process.env[k]; else process.env[k] = saved[k]; }
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test.each(ROUTED_MODULES)('%s derives no home-rooted path from os.homedir() itself', (rel) => {
|
|
178
|
+
const src = fs.readFileSync(path.join(REPO, rel), 'utf8');
|
|
179
|
+
const offenders = src.split('\n').filter((l) => {
|
|
180
|
+
const t = l.trim();
|
|
181
|
+
if (t.startsWith('*') || t.startsWith('//')) return false;
|
|
182
|
+
return /os\.homedir\(\).*(\.claude|session-manager|scheduled-plans)/.test(l)
|
|
183
|
+
|| (/os\.homedir\(\)/.test(l) && /Projects/.test(l));
|
|
184
|
+
});
|
|
185
|
+
expect(offenders).toEqual([]);
|
|
186
|
+
expect(src).toMatch(/schedulerPaths\.cjs/);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('assertNotLiveRoot throws under vitest for a path outside the override roots and os.tmpdir(), naming resolver + path', () => {
|
|
190
|
+
const live = path.join(path.parse(os.homedir()).root, 'definitely-not-tmp', 'live-root');
|
|
191
|
+
// os.tmpdir() may itself be "/", so only assert the throw when the path is really outside it.
|
|
192
|
+
const rel = path.relative(os.tmpdir(), live);
|
|
193
|
+
if (rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
194
|
+
expect(() => sp.assertNotLiveRoot(live, 'someResolver')).toThrow(/someResolver.*live-root|live-root.*someResolver/s);
|
|
195
|
+
}
|
|
196
|
+
const ok = path.join(os.tmpdir(), 'fine');
|
|
197
|
+
expect(sp.assertNotLiveRoot(ok, 'someResolver')).toBe(ok);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('an empty SM_SCHEDULER_HOME falls through to the real ~/.claude and the guard fires', () => {
|
|
201
|
+
const { spawnSync } = require('node:child_process');
|
|
202
|
+
const r = spawnSync(process.execPath, ['-e', "require('./src/main/lib/schedulerPaths.cjs').schedulerHome()"], {
|
|
203
|
+
cwd: REPO,
|
|
204
|
+
env: { ...process.env, SM_SCHEDULER_HOME: '', VITEST: '1', HOME: '/home/definitely-live-user' },
|
|
205
|
+
encoding: 'utf8',
|
|
206
|
+
});
|
|
207
|
+
expect(r.status).not.toBe(0);
|
|
208
|
+
expect(r.stderr).toMatch(/schedulerHome\(\) resolved to live root/);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// 2026-09-18 defaultCwd leak: the guard's allow-list is env-derived, so a live SM_SCHEDULER_HOME
|
|
212
|
+
// (inherited from the app) or a mid-test HOME swap let a test write the LIVE machine file.
|
|
213
|
+
// The passwd-home anchor must refuse the live root no matter what the env says.
|
|
214
|
+
test('under VITEST the passwd-home live root is refused even when SM_SCHEDULER_HOME names it', async () => {
|
|
215
|
+
const liveHome = path.join(os.userInfo().homedir, '.claude', 'session-manager');
|
|
216
|
+
process.env.SM_SCHEDULER_HOME = liveHome;
|
|
217
|
+
try {
|
|
218
|
+
expect(() => sp.machineStatePath()).toThrow(/live root/);
|
|
219
|
+
// the path the leak wrote through: the machine-state read/write refuses instead of touching it
|
|
220
|
+
const queueStore = require('../queueStore.cjs');
|
|
221
|
+
expect(() => queueStore.MACHINE_STATE_PATH).toThrow(/live root/);
|
|
222
|
+
await expect(queueStore.writeSplit({ jobs: [], config: {} }, os.tmpdir())).rejects.toThrow(/live root/);
|
|
223
|
+
} finally {
|
|
224
|
+
process.env.SM_SCHEDULER_HOME = tmpHome;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedulerPathsWorktree.test.cjs — SM_WORKTREE_ROOT moves the job + epic
|
|
3
|
+
* worktree roots (and isEphemeralCwd) as a unit; the real os.tmpdir() roots are
|
|
4
|
+
* never touched.
|
|
5
|
+
*
|
|
6
|
+
* Run: timeout 120 npx vitest run src/main/lib/__tests__/schedulerPathsWorktree.test.cjs
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
import { test, expect, beforeEach, afterEach } from 'vitest';
|
|
12
|
+
const fs = require('node:fs');
|
|
13
|
+
const os = require('node:os');
|
|
14
|
+
const path = require('node:path');
|
|
15
|
+
const { execFileSync } = require('node:child_process');
|
|
16
|
+
const gitWorktree = require('../gitWorktree.cjs');
|
|
17
|
+
const schedulerPaths = require('../schedulerPaths.cjs');
|
|
18
|
+
const { isEphemeralCwd } = require('../ephemeralCwd.cjs');
|
|
19
|
+
|
|
20
|
+
let scratch;
|
|
21
|
+
let override;
|
|
22
|
+
let repo;
|
|
23
|
+
let prevRoot;
|
|
24
|
+
let prevDisable;
|
|
25
|
+
|
|
26
|
+
function git(args, cwd) { return execFileSync('git', args, { cwd, encoding: 'utf8' }); }
|
|
27
|
+
// Probe checkouts (keys starting wtroot-probe) found anywhere under a root. Other
|
|
28
|
+
// suites in the same worker pool share the real root, so a whole-listing
|
|
29
|
+
// comparison would be flaky; the probe key is unique to this file.
|
|
30
|
+
function probesUnder(root) {
|
|
31
|
+
const found = [];
|
|
32
|
+
let hashes = [];
|
|
33
|
+
try { hashes = fs.readdirSync(root); } catch { return found; }
|
|
34
|
+
for (const h of hashes) {
|
|
35
|
+
try {
|
|
36
|
+
for (const k of fs.readdirSync(path.join(root, h))) if (k.startsWith('wtroot-probe')) found.push(`${h}/${k}`);
|
|
37
|
+
} catch { /* not a dir */ }
|
|
38
|
+
}
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
prevRoot = process.env.SM_WORKTREE_ROOT;
|
|
44
|
+
prevDisable = process.env.SM_JOB_WORKTREE_DISABLE;
|
|
45
|
+
delete process.env.SM_JOB_WORKTREE_DISABLE;
|
|
46
|
+
scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-wtroot-test-'));
|
|
47
|
+
override = path.join(scratch, 'override');
|
|
48
|
+
repo = path.join(scratch, 'repo');
|
|
49
|
+
fs.mkdirSync(override, { recursive: true });
|
|
50
|
+
fs.mkdirSync(repo, { recursive: true });
|
|
51
|
+
git(['init', '-q'], repo);
|
|
52
|
+
git(['config', 'user.email', 't@example.com'], repo);
|
|
53
|
+
git(['config', 'user.name', 'T'], repo);
|
|
54
|
+
fs.writeFileSync(path.join(repo, 'README.md'), 'hi\n');
|
|
55
|
+
git(['add', '-A'], repo);
|
|
56
|
+
git(['commit', '-q', '-m', 'init'], repo);
|
|
57
|
+
process.env.SM_WORKTREE_ROOT = override;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
afterEach(() => {
|
|
61
|
+
if (prevRoot === undefined) delete process.env.SM_WORKTREE_ROOT; else process.env.SM_WORKTREE_ROOT = prevRoot;
|
|
62
|
+
if (prevDisable === undefined) delete process.env.SM_JOB_WORKTREE_DISABLE; else process.env.SM_JOB_WORKTREE_DISABLE = prevDisable;
|
|
63
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('resolver and KIND_CONFIG roots follow SM_WORKTREE_ROOT together', () => {
|
|
67
|
+
expect(schedulerPaths.worktreeRoot('job')).toBe(path.join(override, 'session-manager-job-worktrees'));
|
|
68
|
+
expect(schedulerPaths.worktreeRoot('epic')).toBe(path.join(override, 'session-manager-epic-worktrees'));
|
|
69
|
+
expect(gitWorktree.KIND_CONFIG.job.root).toBe(schedulerPaths.worktreeRoot('job'));
|
|
70
|
+
expect(gitWorktree.KIND_CONFIG.epic.root).toBe(schedulerPaths.worktreeRoot('epic'));
|
|
71
|
+
delete process.env.SM_WORKTREE_ROOT;
|
|
72
|
+
expect(schedulerPaths.worktreeRoot('job')).toBe(path.join(os.tmpdir(), 'session-manager-job-worktrees'));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('create / sweep / isEphemeralCwd operate under the override, never the real root', async () => {
|
|
76
|
+
const realJobRoot = path.join(os.tmpdir(), 'session-manager-job-worktrees');
|
|
77
|
+
expect(probesUnder(realJobRoot)).toEqual([]);
|
|
78
|
+
|
|
79
|
+
const res = await gitWorktree.createJobWorktree({ cwd: repo, slug: 'wtroot-probe' });
|
|
80
|
+
expect(res.ok).toBe(true);
|
|
81
|
+
expect(res.dir.startsWith(path.join(override, 'session-manager-job-worktrees') + path.sep)).toBe(true);
|
|
82
|
+
expect(isEphemeralCwd(res.dir)).toBe(true);
|
|
83
|
+
|
|
84
|
+
const sweep = await gitWorktree.sweepStaleWorktreeCheckouts('job', { staleAgeMs: 0, holders: new Set() });
|
|
85
|
+
expect(sweep.checkoutsRemoved).toBeGreaterThanOrEqual(1);
|
|
86
|
+
expect(fs.existsSync(res.dir)).toBe(false);
|
|
87
|
+
|
|
88
|
+
const again = await gitWorktree.createJobWorktree({ cwd: repo, slug: 'wtroot-probe-2' });
|
|
89
|
+
expect(again.ok).toBe(true);
|
|
90
|
+
await gitWorktree.cleanupJobWorktree({ cwd: repo, dir: again.dir, branch: again.branch });
|
|
91
|
+
expect(fs.existsSync(override)).toBe(true); // the guard never rmdir's the base
|
|
92
|
+
|
|
93
|
+
expect(probesUnder(realJobRoot)).toEqual([]);
|
|
94
|
+
});
|