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,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* launchFailure.test.cjs — the non-run classifier + launch circuit breaker
|
|
3
|
-
* behind GitHub issue #11 (macOS, 2026-09-02): an outdated Claude CLI sent
|
|
4
|
-
* `thinking.type.enabled`, the API answered HTTP 400 on the first request,
|
|
5
|
-
* and 12 of 41 runs in one project were recorded as `failed` with
|
|
6
|
-
* `error: null` and then investigated by a probe that died the same way.
|
|
7
|
-
*
|
|
8
|
-
* Run: timeout 120 npx vitest run src/main/lib/__tests__/launchFailure.test.cjs
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import { test, expect } from 'vitest';
|
|
14
|
-
const fs = require('node:fs');
|
|
15
|
-
const os = require('node:os');
|
|
16
|
-
const path = require('node:path');
|
|
17
|
-
const lf = require('../launchFailure.cjs');
|
|
18
|
-
|
|
19
|
-
// Verbatim shape from the issue-#11 transcript (2c3cd24f-…ccf0eb290fff.jsonl):
|
|
20
|
-
// a single assistant entry that IS the raw API error, then the result event.
|
|
21
|
-
const THINKING_400_RESULT = {
|
|
22
|
-
type: 'result', subtype: 'error', is_error: true, api_error_status: 400, num_turns: 1,
|
|
23
|
-
duration_ms: 23811, total_cost_usd: 0,
|
|
24
|
-
usage: { input_tokens: 0, output_tokens: 0 },
|
|
25
|
-
result: 'API Error: 400 {"detail":{"error":"{\\"message\\":\\"\\\\\\"thinking.type.enabled\\\\\\" is not supported for this model. Use \\\\\\"thinking.type.adaptive\\\\\\" and \\\\\\"output_config.effort\\\\\\" to control thinking behavior.\\"}"}}',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const REAL_WORK_FAILURE = {
|
|
29
|
-
type: 'result', subtype: 'error', is_error: true, num_turns: 19,
|
|
30
|
-
usage: { input_tokens: 4000, output_tokens: 2200 },
|
|
31
|
-
result: 'Error: expected 2 but got 3\n at test/foo.test.ts:12:5', terminal_reason: 'error_max_turns',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function tmpLog(lines) {
|
|
35
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-launch-'));
|
|
36
|
-
const p = path.join(dir, 'run.log');
|
|
37
|
-
fs.writeFileSync(p, lines.map((l) => (typeof l === 'string' ? l : JSON.stringify(l))).join('\n') + '\n');
|
|
38
|
-
return p;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
test('parseResultEvent: flattens the last result event with turns/tokens/status', () => {
|
|
42
|
-
const r = lf.parseResultEvent([
|
|
43
|
-
'[scheduler] starting foo',
|
|
44
|
-
JSON.stringify({ type: 'assistant', message: { content: [{ type: 'text', text: 'API Error: 400 …' }] } }),
|
|
45
|
-
JSON.stringify(THINKING_400_RESULT),
|
|
46
|
-
].join('\n'));
|
|
47
|
-
expect(r).toMatchObject({ subtype: 'error', isError: true, numTurns: 1, outputTokens: 0, apiErrorStatus: 400 });
|
|
48
|
-
expect(r.resultText).toMatch(/thinking\.type\.enabled/);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('parseResultEvent: null when no result event exists (process died first)', () => {
|
|
52
|
-
expect(lf.parseResultEvent('[scheduler] starting\n{"type":"system","subtype":"init"}\n')).toBeNull();
|
|
53
|
-
expect(lf.parseResultEvent('')).toBeNull();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('classifyLaunchFailure: the issue-#11 thinking 400 → model_config_rejected with the API message', () => {
|
|
57
|
-
const c = lf.classifyLaunchFailure(lf.parseResultEvent(JSON.stringify(THINKING_400_RESULT)));
|
|
58
|
-
expect(c).not.toBeNull();
|
|
59
|
-
expect(c.kind).toBe('model_config_rejected');
|
|
60
|
-
expect(c.httpStatus).toBe(400);
|
|
61
|
-
expect(c.message).toMatch(/thinking\.type\.enabled.*not supported for this model/);
|
|
62
|
-
expect(c.message).not.toMatch(/^API Error/);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('classifyLaunchFailure: a run that took real turns is NEVER a launch failure, even with API Error text', () => {
|
|
66
|
-
expect(lf.classifyLaunchFailure(lf.parseResultEvent(JSON.stringify(REAL_WORK_FAILURE)))).toBeNull();
|
|
67
|
-
const lateApiError = { ...THINKING_400_RESULT, num_turns: 7, usage: { output_tokens: 900 } };
|
|
68
|
-
expect(lf.classifyLaunchFailure(lf.parseResultEvent(JSON.stringify(lateApiError)))).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('classifyLaunchFailure: zero-turn failure WITHOUT the API Error marker is not classified (someone else owns it)', () => {
|
|
72
|
-
const r = lf.parseResultEvent(JSON.stringify({ type: 'result', subtype: 'error', is_error: true, num_turns: 1, usage: { output_tokens: 0 }, result: 'Invalid prompt' }));
|
|
73
|
-
expect(lf.classifyLaunchFailure(r)).toBeNull();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('classifyLaunchFailure: 429 is left to the rate-limit path', () => {
|
|
77
|
-
const r = lf.parseResultEvent(JSON.stringify({ type: 'result', subtype: 'error', is_error: true, api_error_status: 429, num_turns: 1, usage: { output_tokens: 0 }, result: 'API Error: 429 {"error":{"message":"rate limited"}}' }));
|
|
78
|
-
expect(lf.classifyLaunchFailure(r)).toBeNull();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('classifyLaunchFailure: status → kind mapping', () => {
|
|
82
|
-
const mk = (status, text) => lf.classifyLaunchFailure(lf.parseResultEvent(JSON.stringify({
|
|
83
|
-
type: 'result', subtype: 'error', is_error: true, num_turns: 1, usage: { output_tokens: 0 }, result: `API Error: ${status} ${text}`,
|
|
84
|
-
})));
|
|
85
|
-
expect(mk(401, '{"error":{"message":"invalid x-api-key"}}').kind).toBe('auth_failed');
|
|
86
|
-
expect(mk(403, '{"error":{"message":"forbidden"}}').kind).toBe('auth_failed');
|
|
87
|
-
expect(mk(404, '{"error":{"message":"model: claude-x not found"}}').kind).toBe('model_not_found');
|
|
88
|
-
expect(mk(400, '{"error":{"message":"max_tokens must be > 0"}}').kind).toBe('bad_request');
|
|
89
|
-
expect(mk(529, '{"error":{"type":"overloaded_error","message":"Overloaded"}}').kind).toBe('api_overloaded');
|
|
90
|
-
expect(mk(500, '{"error":{"message":"internal"}}').kind).toBe('api_overloaded');
|
|
91
|
-
expect(mk(418, 'teapot').kind).toBe('api_error');
|
|
92
|
-
expect(mk(401, '{"error":{"message":"invalid x-api-key"}}').message).toBe('invalid x-api-key');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('readResultEvent + classify on a real log tail (scheduler log lines interleaved)', () => {
|
|
96
|
-
const p = tmpLog([
|
|
97
|
-
'[scheduler] starting 04-fix-cdp at 2026-09-02T17:54:14.770Z',
|
|
98
|
-
{ type: 'system', subtype: 'init', session_id: 'x' },
|
|
99
|
-
{ type: 'user', message: { content: [{ type: 'text', text: 'PRD body' }] } },
|
|
100
|
-
{ type: 'assistant', message: { content: [{ type: 'text', text: 'API Error: 400 …' }] } },
|
|
101
|
-
THINKING_400_RESULT,
|
|
102
|
-
'[scheduler] exit code=1 (raw code=1 signal=null) duration=25s',
|
|
103
|
-
]);
|
|
104
|
-
try {
|
|
105
|
-
const r = lf.readResultEvent(p);
|
|
106
|
-
expect(lf.classifyLaunchFailure(r)?.kind).toBe('model_config_rejected');
|
|
107
|
-
expect(lf.resultShowsRealTurn(r)).toBe(false);
|
|
108
|
-
} finally {
|
|
109
|
-
fs.rmSync(path.dirname(p), { recursive: true, force: true });
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('resultShowsRealTurn: true once a turn or any output token happened', () => {
|
|
114
|
-
expect(lf.resultShowsRealTurn({ numTurns: 1, outputTokens: 0 })).toBe(false);
|
|
115
|
-
expect(lf.resultShowsRealTurn({ numTurns: 2, outputTokens: 0 })).toBe(true);
|
|
116
|
-
expect(lf.resultShowsRealTurn({ numTurns: 1, outputTokens: 12 })).toBe(true);
|
|
117
|
-
expect(lf.resultShowsRealTurn(null)).toBe(false);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// ─── circuit breaker ────────────────────────────────────────────────────────
|
|
121
|
-
|
|
122
|
-
const T0 = Date.parse('2026-09-02T18:00:00Z');
|
|
123
|
-
|
|
124
|
-
test('armLaunchBlock: first failure opens with the kind backoff, a mitigation env, and an operator hint', () => {
|
|
125
|
-
const b = lf.armLaunchBlock(null, { kind: 'model_config_rejected', httpStatus: 400, message: 'm', now: T0, claudeVersion: '1.0.90', slug: 'a', runId: 'r1' });
|
|
126
|
-
expect(b.attempts).toBe(1);
|
|
127
|
-
expect(b.exhausted).toBe(false);
|
|
128
|
-
expect(Date.parse(b.until) - T0).toBe(lf.backoffMsFor('model_config_rejected', 1));
|
|
129
|
-
expect(b.mitigationEnv).toEqual({ MAX_THINKING_TOKENS: '0' });
|
|
130
|
-
expect(b.hint).toMatch(/claude update/);
|
|
131
|
-
expect(b.claudeVersion).toBe('1.0.90');
|
|
132
|
-
expect(b.probing).toBeNull();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('armLaunchBlock: repeated same-kind failures escalate, cap at 60 min, then exhaust (until=null)', () => {
|
|
136
|
-
let b = null;
|
|
137
|
-
const seen = [];
|
|
138
|
-
for (let i = 0; i < lf.LAUNCH_BLOCK_MAX_ATTEMPTS; i++) {
|
|
139
|
-
b = lf.armLaunchBlock(b, { kind: 'api_error', message: 'x', now: T0 + i * 1000 });
|
|
140
|
-
seen.push(b.until ? Date.parse(b.until) - (T0 + i * 1000) : null);
|
|
141
|
-
}
|
|
142
|
-
expect(b.attempts).toBe(lf.LAUNCH_BLOCK_MAX_ATTEMPTS);
|
|
143
|
-
expect(b.exhausted).toBe(true);
|
|
144
|
-
expect(b.until).toBeNull();
|
|
145
|
-
const finite = seen.filter((x) => x !== null);
|
|
146
|
-
for (let i = 1; i < finite.length; i++) expect(finite[i]).toBeGreaterThanOrEqual(finite[i - 1]);
|
|
147
|
-
expect(Math.max(...finite)).toBeLessThanOrEqual(60 * 60_000);
|
|
148
|
-
expect(b.since).toBe(new Date(T0).toISOString()); // first-failure time survives re-arming
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('armLaunchBlock: a different kind restarts the attempt count', () => {
|
|
152
|
-
const a = lf.armLaunchBlock(null, { kind: 'api_overloaded', message: 'x', now: T0 });
|
|
153
|
-
const b = lf.armLaunchBlock(a, { kind: 'api_overloaded', message: 'x', now: T0 + 1 });
|
|
154
|
-
const c = lf.armLaunchBlock(b, { kind: 'auth_failed', message: 'y', now: T0 + 2 });
|
|
155
|
-
expect(b.attempts).toBe(2);
|
|
156
|
-
expect(c.attempts).toBe(1);
|
|
157
|
-
expect(c.mitigationEnv).toBeNull();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('evaluateLaunchGate: open → blocked during backoff → probe after → blocked while a probe is in flight', () => {
|
|
161
|
-
expect(lf.evaluateLaunchGate(null, { now: T0 }).state).toBe('open');
|
|
162
|
-
const b = lf.armLaunchBlock(null, { kind: 'model_config_rejected', message: 'm', now: T0, claudeVersion: '1.0.90' });
|
|
163
|
-
expect(lf.evaluateLaunchGate(b, { now: T0 + 1000, claudeVersion: '1.0.90' }).state).toBe('blocked');
|
|
164
|
-
expect(lf.evaluateLaunchGate(b, { now: T0 + 1000 }).reason).toMatch(/re-probe in \d+ min/);
|
|
165
|
-
const afterBackoff = Date.parse(b.until) + 1;
|
|
166
|
-
expect(lf.evaluateLaunchGate(b, { now: afterBackoff, claudeVersion: '1.0.90' }).state).toBe('probe');
|
|
167
|
-
const probing = { ...b, probing: { slug: 'p', at: new Date(afterBackoff).toISOString() } };
|
|
168
|
-
const g = lf.evaluateLaunchGate(probing, { now: afterBackoff + 60_000, claudeVersion: '1.0.90' });
|
|
169
|
-
expect(g.state).toBe('blocked');
|
|
170
|
-
expect(g.reason).toMatch(/probe p in flight/);
|
|
171
|
-
// a probe that never reported back goes stale and the gate re-opens to a new probe
|
|
172
|
-
expect(lf.evaluateLaunchGate(probing, { now: afterBackoff + lf.LAUNCH_PROBE_STALE_MS + 1, claudeVersion: '1.0.90' }).state).toBe('probe');
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test('evaluateLaunchGate: a CLI version change short-circuits the backoff (the real fix for issue #11)', () => {
|
|
176
|
-
const b = lf.armLaunchBlock(null, { kind: 'model_config_rejected', message: 'm', now: T0, claudeVersion: '1.0.90' });
|
|
177
|
-
const g = lf.evaluateLaunchGate(b, { now: T0 + 1000, claudeVersion: '1.0.128' });
|
|
178
|
-
expect(g.state).toBe('open');
|
|
179
|
-
expect(g.reason).toMatch(/cli-version-changed/);
|
|
180
|
-
// unknown current version (probe failed) → no shortcut, backoff still holds
|
|
181
|
-
expect(lf.evaluateLaunchGate(b, { now: T0 + 1000, claudeVersion: null }).state).toBe('blocked');
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('evaluateLaunchGate: an exhausted block stays blocked until version change', () => {
|
|
185
|
-
let b = null;
|
|
186
|
-
for (let i = 0; i < lf.LAUNCH_BLOCK_MAX_ATTEMPTS; i++) b = lf.armLaunchBlock(b, { kind: 'auth_failed', message: 'x', now: T0, claudeVersion: 'v1' });
|
|
187
|
-
expect(lf.evaluateLaunchGate(b, { now: T0 + 365 * 24 * 3600_000, claudeVersion: 'v1' }).state).toBe('blocked');
|
|
188
|
-
expect(lf.evaluateLaunchGate(b, { now: T0 + 1, claudeVersion: 'v2' }).state).toBe('open');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('launchBlockKeyFor: persona is the key, default when absent', () => {
|
|
192
|
-
expect(lf.launchBlockKeyFor({ agentType: 'dev-lead' })).toBe('dev-lead');
|
|
193
|
-
expect(lf.launchBlockKeyFor({})).toBe('default');
|
|
194
|
-
expect(lf.launchBlockKeyFor(null)).toBe('default');
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test('deriveTerminalReason: closed-set taxonomy', () => {
|
|
198
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'completed', exitCode: 0 })).toBe('completed');
|
|
199
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'failed', exitCode: 1 })).toBe('impl_failed:exit_1');
|
|
200
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'failed', exitCode: 143 })).toBe('signal_kill');
|
|
201
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'needs_review', exitCode: 143, sigtermOverride: { status: 'needs_review' } })).toBe('signal_kill_with_commit');
|
|
202
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'needs_review', exitCode: 0, verifyResult: { verdict: 'silent_no_op' } })).toBe('verifier:silent_no_op');
|
|
203
|
-
expect(lf.deriveTerminalReason({ effectiveStatus: 'needs_review', exitCode: 0, worktreeIntegrationFailure: 'conflict' })).toBe('worktree_integration_failed');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('writeOutcomeSidecar: writes <slug>.outcome.json atomically and never throws on a bad dir', () => {
|
|
207
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-outcome-'));
|
|
208
|
-
try {
|
|
209
|
-
const p = lf.writeOutcomeSidecar(dir, '12-foo', { numTurns: 1, outputTokens: 0, terminalReason: 'launch_failure:model_config_rejected' });
|
|
210
|
-
expect(p).toBe(path.join(dir, '12-foo.outcome.json'));
|
|
211
|
-
const parsed = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
212
|
-
expect(parsed).toMatchObject({ slug: '12-foo', numTurns: 1, outputTokens: 0, terminalReason: 'launch_failure:model_config_rejected' });
|
|
213
|
-
expect(parsed.writtenAt).toMatch(/^\d{4}-/);
|
|
214
|
-
expect(fs.existsSync(`${p}.tmp`)).toBe(false);
|
|
215
|
-
} finally {
|
|
216
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
217
|
-
}
|
|
218
|
-
expect(lf.writeOutcomeSidecar('/nonexistent/dir/for/sure', 'x', {})).toBeNull();
|
|
219
|
-
expect(lf.writeOutcomeSidecar(null, 'x', {})).toBeNull();
|
|
220
|
-
});
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// Run: timeout 120 npx vitest run src/main/lib/__tests__/loadGate.test.cjs
|
|
3
|
-
//
|
|
4
|
-
// PRD 1085 — CPU-load launch gate. The static per-project cap
|
|
5
|
-
// (schedulerBatchProjectCap.test.cjs) cannot see the feedback loop observed
|
|
6
|
-
// 2026-09-01 on starry-night-ships: 4 Godot test batteries under Xvfb,
|
|
7
|
-
// loadavg 12.95 / 14 cores = 0.93, every battery stretching past its
|
|
8
|
-
// executor's timeout and spawning fix-chain reruns that launch more
|
|
9
|
-
// batteries. These tests pin the pure decision, the audit rate-limit and the
|
|
10
|
-
// escalation, with loadavg/cores/clock all injected.
|
|
11
|
-
const assert = require('node:assert/strict');
|
|
12
|
-
const { isLoadGated, createLoadGate, topCpuConsumers, AUDIT_INTERVAL_MS } = require('../loadGate.cjs');
|
|
13
|
-
const { loadGateThreshold, LOAD_GATE_PER_CORE } = require('../schedulerConfig.cjs');
|
|
14
|
-
|
|
15
|
-
const ORIGINAL_ENV = process.env.SM_LOAD_GATE_PER_CORE;
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
if (ORIGINAL_ENV === undefined) delete process.env.SM_LOAD_GATE_PER_CORE;
|
|
18
|
-
else process.env.SM_LOAD_GATE_PER_CORE = ORIGINAL_ENV;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// ─── isLoadGated ────────────────────────────────────────────────────────────
|
|
22
|
-
|
|
23
|
-
test('the live incident shape gates: 12.95 / 14 cores = 0.93 > 0.85', () => {
|
|
24
|
-
assert.equal(isLoadGated(12.95, 14, 0.85), true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('below threshold does not gate', () => {
|
|
28
|
-
assert.equal(isLoadGated(5, 14, 0.85), false);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('exactly AT threshold does not gate (strictly greater)', () => {
|
|
32
|
-
assert.equal(isLoadGated(0.85 * 14, 14, 0.85), false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('zero cores never gates (unknown topology must not wedge the queue)', () => {
|
|
36
|
-
assert.equal(isLoadGated(100, 0, 0.85), false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('loadavg [0,0,0] (Windows / unsupported) never gates', () => {
|
|
40
|
-
assert.equal(isLoadGated(0, 14, 0.85), false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('a disabled threshold (0) never gates regardless of load', () => {
|
|
44
|
-
assert.equal(isLoadGated(1000, 1, 0), false);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// ─── loadGateThreshold (env) ────────────────────────────────────────────────
|
|
48
|
-
|
|
49
|
-
test('default threshold is the documented 0.85', () => {
|
|
50
|
-
delete process.env.SM_LOAD_GATE_PER_CORE;
|
|
51
|
-
assert.equal(LOAD_GATE_PER_CORE, 0.85);
|
|
52
|
-
assert.equal(loadGateThreshold(), 0.85);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('SM_LOAD_GATE_PER_CORE is honored and clamped to [0.25, 4]; 0 disables; garbage falls back', () => {
|
|
56
|
-
process.env.SM_LOAD_GATE_PER_CORE = '1.5';
|
|
57
|
-
assert.equal(loadGateThreshold(), 1.5);
|
|
58
|
-
process.env.SM_LOAD_GATE_PER_CORE = '0.01';
|
|
59
|
-
assert.equal(loadGateThreshold(), 0.25);
|
|
60
|
-
process.env.SM_LOAD_GATE_PER_CORE = '99';
|
|
61
|
-
assert.equal(loadGateThreshold(), 4);
|
|
62
|
-
process.env.SM_LOAD_GATE_PER_CORE = '0';
|
|
63
|
-
assert.equal(loadGateThreshold(), 0);
|
|
64
|
-
process.env.SM_LOAD_GATE_PER_CORE = 'banana';
|
|
65
|
-
assert.equal(loadGateThreshold(), 0.85);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// ─── topCpuConsumers: platform-correct ps invocation ───────────────────────
|
|
69
|
-
//
|
|
70
|
-
// The audit line the scheduler warn-logs when the load gate escalates. Purely
|
|
71
|
-
// diagnostic (nothing branches on it) but it was blank on macOS: the code only
|
|
72
|
-
// ran the GNU `ps --sort` form, which BSD ps rejects with "illegal option",
|
|
73
|
-
// so every Mac logged `top CPU: n/a` exactly when the operator needed to know
|
|
74
|
-
// what was saturating the box.
|
|
75
|
-
|
|
76
|
-
test('Linux uses the GNU ps form (-eo … --sort=-pcpu) and skips the header row', () => {
|
|
77
|
-
const calls = [];
|
|
78
|
-
const fakeExec = (bin, args) => {
|
|
79
|
-
calls.push({ bin, args });
|
|
80
|
-
return 'PID %CPU COMMAND\n 1 90.0 node\n 2 10.0 tsc\n';
|
|
81
|
-
};
|
|
82
|
-
const rows = topCpuConsumers(2, { execImpl: fakeExec, platform: 'linux' });
|
|
83
|
-
assert.deepEqual(calls[0], { bin: 'ps', args: ['-eo', 'pid,pcpu,comm', '--sort=-pcpu'] });
|
|
84
|
-
assert.deepEqual(rows, ['1 90.0 node', '2 10.0 tsc']);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('macOS uses the BSD ps form (-Aco … -r), NOT the GNU --sort that BSD ps rejects', () => {
|
|
88
|
-
const calls = [];
|
|
89
|
-
const fakeExec = (bin, args) => {
|
|
90
|
-
calls.push({ bin, args });
|
|
91
|
-
return ' PID %CPU COMM\n 847 94.4 suggestd\n 443 15.1 WindowServer\n';
|
|
92
|
-
};
|
|
93
|
-
const rows = topCpuConsumers(3, { execImpl: fakeExec, platform: 'darwin' });
|
|
94
|
-
assert.deepEqual(calls[0].args, ['-Aco', 'pid,pcpu,comm', '-r']);
|
|
95
|
-
assert.ok(!calls[0].args.some((a) => String(a).includes('--sort')), 'must not pass the GNU --sort to BSD ps');
|
|
96
|
-
assert.deepEqual(rows, ['847 94.4 suggestd', '443 15.1 WindowServer']);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('an unsupported platform returns [] without ever spawning ps', () => {
|
|
100
|
-
let spawned = false;
|
|
101
|
-
const rows = topCpuConsumers(3, { execImpl: () => { spawned = true; return ''; }, platform: 'win32' });
|
|
102
|
-
assert.deepEqual(rows, []);
|
|
103
|
-
assert.equal(spawned, false);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('a ps failure (throw) degrades to [] rather than propagating — the audit line is best-effort', () => {
|
|
107
|
-
const rows = topCpuConsumers(3, { execImpl: () => { throw new Error('boom'); }, platform: 'darwin' });
|
|
108
|
-
assert.deepEqual(rows, []);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// ─── createLoadGate: decision, 1-minute-only, bypass ───────────────────────
|
|
112
|
-
|
|
113
|
-
function gateWith({ l1 = 12.95, l5 = 0, l15 = 0, cores = 14, threshold = 0.85, clock }) {
|
|
114
|
-
let t = clock ?? 0;
|
|
115
|
-
const g = createLoadGate({
|
|
116
|
-
loadavg: () => [l1, l5, l15],
|
|
117
|
-
cores: () => cores,
|
|
118
|
-
now: () => t,
|
|
119
|
-
threshold,
|
|
120
|
-
});
|
|
121
|
-
return { g, tick: (ms) => { t += ms; } };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
test('evaluate() gates on the incident shape and reports ratio/threshold', () => {
|
|
125
|
-
const { g } = gateWith({});
|
|
126
|
-
const r = g.evaluate();
|
|
127
|
-
assert.equal(r.gated, true);
|
|
128
|
-
assert.equal(r.bypassed, false);
|
|
129
|
-
assert.equal(r.ratio, 0.925);
|
|
130
|
-
assert.equal(r.threshold, 0.85);
|
|
131
|
-
assert.equal(r.loadavg1, 12.95);
|
|
132
|
-
assert.equal(r.cores, 14);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('only the 1-minute average is consulted — a saturated 5/15-minute history with a quiet last minute launches', () => {
|
|
136
|
-
const { g } = gateWith({ l1: 2, l5: 13, l15: 13 });
|
|
137
|
-
assert.equal(g.evaluate().gated, false);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test('an explicit Run now bypasses the gate but records that it did', () => {
|
|
141
|
-
const { g } = gateWith({});
|
|
142
|
-
const r = g.evaluate({ bypass: true });
|
|
143
|
-
assert.equal(r.gated, false);
|
|
144
|
-
assert.equal(r.bypassed, true);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('bypass on an UNgated tick is not reported as a bypass', () => {
|
|
148
|
-
const { g } = gateWith({ l1: 1 });
|
|
149
|
-
const r = g.evaluate({ bypass: true });
|
|
150
|
-
assert.deepEqual([r.gated, r.bypassed], [false, false]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// ─── audit rate limit + escalation (fake clock) ─────────────────────────────
|
|
154
|
-
|
|
155
|
-
test('audits once, then not again until AUDIT_INTERVAL_MS has elapsed', () => {
|
|
156
|
-
const { g, tick } = gateWith({});
|
|
157
|
-
assert.equal(g.evaluate().shouldAudit, true, 'first gated tick audits');
|
|
158
|
-
tick(60_000);
|
|
159
|
-
assert.equal(g.evaluate().shouldAudit, false, '1 min later: silent');
|
|
160
|
-
tick(AUDIT_INTERVAL_MS - 60_000 - 1);
|
|
161
|
-
assert.equal(g.evaluate().shouldAudit, false, 'just under the interval: silent');
|
|
162
|
-
tick(1);
|
|
163
|
-
assert.equal(g.evaluate().shouldAudit, true, 'at the interval: audits again');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('an ungated tick never audits', () => {
|
|
167
|
-
const { g } = gateWith({ l1: 1 });
|
|
168
|
-
assert.equal(g.evaluate().shouldAudit, false);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('escalates once the gated stretch exceeds the escalation window, and the stretch only resets once load has stayed sub-threshold past the release window', () => {
|
|
172
|
-
let l1 = 12.95;
|
|
173
|
-
let t = 0;
|
|
174
|
-
const g = createLoadGate({
|
|
175
|
-
loadavg: () => [l1, 0, 0],
|
|
176
|
-
cores: () => 14,
|
|
177
|
-
now: () => t,
|
|
178
|
-
threshold: 0.85,
|
|
179
|
-
escalateAfterMs: 45 * 60_000,
|
|
180
|
-
releaseWindowMs: 2 * 60_000,
|
|
181
|
-
});
|
|
182
|
-
assert.equal(g.evaluate().escalate, false);
|
|
183
|
-
t += 44 * 60_000;
|
|
184
|
-
assert.equal(g.evaluate().escalate, false, 'under 45m: no escalation');
|
|
185
|
-
t += 60_000;
|
|
186
|
-
const r = g.evaluate();
|
|
187
|
-
assert.equal(r.escalate, true, 'at 45m: escalates');
|
|
188
|
-
assert.equal(r.gatedSinceMs, 45 * 60_000);
|
|
189
|
-
// A single sub-threshold sample must NOT reset the stretch (the boundary-
|
|
190
|
-
// hovering bug this PRD fixes) — gatedSinceMs keeps growing.
|
|
191
|
-
l1 = 1; t += 60_000;
|
|
192
|
-
const oneMinBelow = g.evaluate();
|
|
193
|
-
assert.equal(oneMinBelow.gated, false, 'gate decision is immediate');
|
|
194
|
-
assert.equal(oneMinBelow.gatedSinceMs, 46 * 60_000, 'stretch not yet released');
|
|
195
|
-
// Load climbs back above threshold before the release window elapses: the
|
|
196
|
-
// stretch was never actually cleared, so it just keeps accumulating.
|
|
197
|
-
l1 = 12.95; t += 30_000;
|
|
198
|
-
assert.equal(g.evaluate().gatedSinceMs, 46 * 60_000 + 30_000, 'stretch survived the brief dip');
|
|
199
|
-
// Now hold sub-threshold continuously past the release window (the window
|
|
200
|
-
// is measured from the first sub-threshold sample of this sustained drop,
|
|
201
|
-
// so it takes a tick to mark that start, then another once the window has
|
|
202
|
-
// actually elapsed).
|
|
203
|
-
l1 = 1; t += 1;
|
|
204
|
-
g.evaluate();
|
|
205
|
-
t += 2 * 60_000;
|
|
206
|
-
assert.equal(g.evaluate().gatedSinceMs, 0, 'sustained sub-threshold load past the release window clears the stretch');
|
|
207
|
-
l1 = 12.95; t += 60_000;
|
|
208
|
-
assert.equal(g.evaluate().gatedSinceMs, 0, 'a fresh stretch starts from zero');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
test('the gate decision itself is unaffected by hysteresis: a sub-threshold tick is never gated, even mid-stretch', () => {
|
|
212
|
-
let l1 = 12.95;
|
|
213
|
-
let t = 0;
|
|
214
|
-
const g = createLoadGate({
|
|
215
|
-
loadavg: () => [l1, 0, 0],
|
|
216
|
-
cores: () => 14,
|
|
217
|
-
now: () => t,
|
|
218
|
-
threshold: 0.85,
|
|
219
|
-
releaseWindowMs: 5 * 60_000,
|
|
220
|
-
});
|
|
221
|
-
assert.equal(g.evaluate().gated, true);
|
|
222
|
-
l1 = 1; t += 60_000;
|
|
223
|
-
assert.equal(g.evaluate().gated, false, 'below threshold: gated:false immediately, hysteresis notwithstanding');
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
test('snapshot() reflects the last evaluation and is null before any', () => {
|
|
227
|
-
const { g } = gateWith({});
|
|
228
|
-
assert.equal(g.snapshot(), null);
|
|
229
|
-
g.evaluate();
|
|
230
|
-
const s = g.snapshot();
|
|
231
|
-
assert.equal(s.gated, true);
|
|
232
|
-
assert.equal(typeof s.at, 'string');
|
|
233
|
-
assert.equal('shouldAudit' in s, false, 'per-tick flags are not part of the persisted snapshot');
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('snapshot() exposes gated, ratio, threshold, loadavg1, cores and gatedSinceMs (what buildScheduleStatePayload surfaces as loadGate)', () => {
|
|
237
|
-
const { g } = gateWith({});
|
|
238
|
-
g.evaluate();
|
|
239
|
-
const s = g.snapshot();
|
|
240
|
-
assert.equal(typeof s.gated, 'boolean');
|
|
241
|
-
assert.equal(typeof s.ratio, 'number');
|
|
242
|
-
assert.equal(typeof s.threshold, 'number');
|
|
243
|
-
assert.equal(typeof s.loadavg1, 'number');
|
|
244
|
-
assert.equal(typeof s.cores, 'number');
|
|
245
|
-
assert.equal(typeof s.gatedSinceMs, 'number');
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// ─── hysteresis: the real observed boundary-hovering sequence ──────────────
|
|
249
|
-
|
|
250
|
-
test('a boundary-hovering box (real observed sequence, alternating above/below threshold) grows gatedSinceMs monotonically across 50 simulated minutes and eventually escalates', () => {
|
|
251
|
-
// 14 cores, 0.85/core = 11.9 threshold; loadavg1 observed 2026-09-12
|
|
252
|
-
// oscillating 11.07 - 13.31, straddling the threshold every tick. Before
|
|
253
|
-
// this PRD, the immediate reset on ANY sub-threshold sample meant every
|
|
254
|
-
// one of these ticks reset gatedSince to null and escalate never fired.
|
|
255
|
-
const CORES = 14;
|
|
256
|
-
const THRESHOLD = 0.85;
|
|
257
|
-
const SEQUENCE = [11.07, 13.31, 11.51, 12.8];
|
|
258
|
-
let l1 = SEQUENCE[0];
|
|
259
|
-
let t = 0;
|
|
260
|
-
const g = createLoadGate({
|
|
261
|
-
loadavg: () => [l1, 0, 0],
|
|
262
|
-
cores: () => CORES,
|
|
263
|
-
now: () => t,
|
|
264
|
-
threshold: THRESHOLD,
|
|
265
|
-
escalateAfterMs: 20 * 60_000, // shorter than the 45m default so 50 sim-minutes crosses it
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
const TICK_MS = 60_000;
|
|
269
|
-
const TOTAL_MS = 50 * 60_000;
|
|
270
|
-
let prevGatedSinceMs = -1;
|
|
271
|
-
let sawEscalate = false;
|
|
272
|
-
let i = 0;
|
|
273
|
-
for (let elapsed = 0; elapsed < TOTAL_MS; elapsed += TICK_MS) {
|
|
274
|
-
l1 = SEQUENCE[i % SEQUENCE.length];
|
|
275
|
-
i += 1;
|
|
276
|
-
const r = g.evaluate();
|
|
277
|
-
assert.ok(r.gatedSinceMs >= prevGatedSinceMs, `gatedSinceMs must not shrink (was ${prevGatedSinceMs}, now ${r.gatedSinceMs})`);
|
|
278
|
-
prevGatedSinceMs = r.gatedSinceMs;
|
|
279
|
-
if (r.escalate) sawEscalate = true;
|
|
280
|
-
t += TICK_MS;
|
|
281
|
-
}
|
|
282
|
-
assert.equal(sawEscalate, true, 'escalate must fire once the (never-reset) stretch exceeds escalateAfterMs');
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
test('the release window actually releases: sustained sub-threshold load past the window reports gated:false and gatedSinceMs:0 on the next tick', () => {
|
|
286
|
-
let l1 = 13.31;
|
|
287
|
-
let t = 0;
|
|
288
|
-
const g = createLoadGate({
|
|
289
|
-
loadavg: () => [l1, 0, 0],
|
|
290
|
-
cores: () => 14,
|
|
291
|
-
now: () => t,
|
|
292
|
-
threshold: 0.85,
|
|
293
|
-
releaseWindowMs: 2 * 60_000,
|
|
294
|
-
});
|
|
295
|
-
assert.equal(g.evaluate().gated, true);
|
|
296
|
-
l1 = 5;
|
|
297
|
-
t += 1;
|
|
298
|
-
g.evaluate(); // marks the start of the sustained sub-threshold run
|
|
299
|
-
t += 2 * 60_000;
|
|
300
|
-
const r = g.evaluate();
|
|
301
|
-
assert.equal(r.gated, false);
|
|
302
|
-
assert.equal(r.gatedSinceMs, 0);
|
|
303
|
-
});
|