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,439 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scheduler-autofix-select.test.cjs — unit tests for selectAutoFixTargets.
|
|
3
|
-
*
|
|
4
|
-
* Run: timeout 300 npx vitest run src/main/__tests__/scheduler-autofix-select.test.cjs
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
import { test } from 'vitest';
|
|
10
|
-
const assert = require('node:assert/strict');
|
|
11
|
-
const {
|
|
12
|
-
selectAutoFixTargets, isUnresolvableNeedsReview, isRescanCandidate,
|
|
13
|
-
healTargetForFix, isFixPlanBeyondDepthCap, MAX_INVESTIGATION_DEPTH,
|
|
14
|
-
isEligibleForImmediateAutoFix, isExhaustedAutoFix, isPlanUnqueued, fixSlugFor,
|
|
15
|
-
applyRcaClassification,
|
|
16
|
-
} = require('../scheduler.cjs');
|
|
17
|
-
|
|
18
|
-
const noSiblingOnDisk = () => false;
|
|
19
|
-
const noRunDir = () => null;
|
|
20
|
-
|
|
21
|
-
function makeJob(overrides = {}) {
|
|
22
|
-
return {
|
|
23
|
-
slug: '05-my-feature',
|
|
24
|
-
status: 'needs_review',
|
|
25
|
-
runId: '2026-06-16T10-00-00-000Z',
|
|
26
|
-
parallelGroup: 5,
|
|
27
|
-
...overrides,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
test('selects a fresh needs_review job', () => {
|
|
32
|
-
const jobs = [makeJob()];
|
|
33
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
34
|
-
assert.strictEqual(result.length, 1);
|
|
35
|
-
assert.strictEqual(result[0].slug, '05-my-feature');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('excludes job with autoFixAttempted: true whose retry is already spent', () => {
|
|
39
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixRetries: 1 })];
|
|
40
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
41
|
-
assert.strictEqual(result.length, 0);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('excludes a fix-plan slug (05-fix-foo)', () => {
|
|
45
|
-
const jobs = [makeJob({ slug: '05-fix-foo' })];
|
|
46
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
47
|
-
assert.strictEqual(result.length, 0);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('excludes a failed job', () => {
|
|
51
|
-
const jobs = [makeJob({ status: 'failed' })];
|
|
52
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
53
|
-
assert.strictEqual(result.length, 0);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('excludes a completed job', () => {
|
|
57
|
-
const jobs = [makeJob({ status: 'completed' })];
|
|
58
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
59
|
-
assert.strictEqual(result.length, 0);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('excludes a job missing runId when no run dir resolves', () => {
|
|
63
|
-
const jobs = [makeJob({ runId: null })];
|
|
64
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk, resolveJobRunId: noRunDir });
|
|
65
|
-
assert.strictEqual(result.length, 0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('selects a job missing runId when a run dir resolves (gap 1: runId backfill)', () => {
|
|
69
|
-
const jobs = [makeJob({ runId: null })];
|
|
70
|
-
const result = selectAutoFixTargets(jobs, {
|
|
71
|
-
fixSlugExists: noSiblingOnDisk,
|
|
72
|
-
resolveJobRunId: () => '2026-06-16T10-00-00-000Z',
|
|
73
|
-
});
|
|
74
|
-
assert.strictEqual(result.length, 1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('isUnresolvableNeedsReview: needs_review + no runId + no run dir → true', () => {
|
|
78
|
-
const job = makeJob({ runId: null });
|
|
79
|
-
assert.strictEqual(isUnresolvableNeedsReview(job, { hasRunDir: false }), true);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('isUnresolvableNeedsReview: needs_review + no runId + has run dir → false', () => {
|
|
83
|
-
const job = makeJob({ runId: null });
|
|
84
|
-
assert.strictEqual(isUnresolvableNeedsReview(job, { hasRunDir: true }), false);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('isUnresolvableNeedsReview: needs_review + runId present → false', () => {
|
|
88
|
-
const job = makeJob();
|
|
89
|
-
assert.strictEqual(isUnresolvableNeedsReview(job, { hasRunDir: false }), false);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('isUnresolvableNeedsReview: non needs_review status → false', () => {
|
|
93
|
-
const job = makeJob({ runId: null, status: 'failed' });
|
|
94
|
-
assert.strictEqual(isUnresolvableNeedsReview(job, { hasRunDir: false }), false);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('autoFixOutcome no-plan with retries=0 is retried', () => {
|
|
98
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan', autoFixRetries: 0 })];
|
|
99
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
100
|
-
assert.strictEqual(result.length, 1);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('autoFixOutcome no-plan with retries=1 is exhausted (not selected)', () => {
|
|
104
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan', autoFixRetries: 1 })];
|
|
105
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
106
|
-
assert.strictEqual(result.length, 0);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// ---- PRD: unstamped/error outcomes must retry once, not dead-end forever ----
|
|
110
|
-
|
|
111
|
-
test('autoFixAttempted true with NO outcome recorded (unstamped — spawn threw before onExit wired) is retry-eligible once', () => {
|
|
112
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixRetries: 0 })];
|
|
113
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
114
|
-
assert.strictEqual(result.length, 1);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('autoFixAttempted true with no outcome AND retries=1 is exhausted (not selected)', () => {
|
|
118
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixRetries: 1 })];
|
|
119
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
120
|
-
assert.strictEqual(result.length, 0);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('autoFixOutcome error with retries=0 is retry-eligible', () => {
|
|
124
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixOutcome: 'error', autoFixRetries: 0 })];
|
|
125
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
126
|
-
assert.strictEqual(result.length, 1);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('autoFixOutcome error with retries=1 is exhausted (not selected)', () => {
|
|
130
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixOutcome: 'error', autoFixRetries: 1 })];
|
|
131
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
132
|
-
assert.strictEqual(result.length, 0);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('autoFixOutcome plan is NEVER retried, regardless of autoFixRetries', () => {
|
|
136
|
-
const jobs = [makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan', autoFixRetries: 0 })];
|
|
137
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
138
|
-
assert.strictEqual(result.length, 0);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// ---- isExhaustedAutoFix / isPlanUnqueued (reverifyNeedsReview annotation) ----
|
|
142
|
-
|
|
143
|
-
test('isExhaustedAutoFix: no-plan outcome with retries spent → true', () => {
|
|
144
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan', autoFixRetries: 1 });
|
|
145
|
-
assert.strictEqual(isExhaustedAutoFix(job), true);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test('isExhaustedAutoFix: error outcome with retries spent → true', () => {
|
|
149
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'error', autoFixRetries: 1 });
|
|
150
|
-
assert.strictEqual(isExhaustedAutoFix(job), true);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('isExhaustedAutoFix: unstamped outcome with retries spent → true', () => {
|
|
154
|
-
const job = makeJob({ autoFixAttempted: true, autoFixRetries: 1 });
|
|
155
|
-
assert.strictEqual(isExhaustedAutoFix(job), true);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test('isExhaustedAutoFix: retries not yet spent → false (still eligible for its one retry)', () => {
|
|
159
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan', autoFixRetries: 0 });
|
|
160
|
-
assert.strictEqual(isExhaustedAutoFix(job), false);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test('isExhaustedAutoFix: plan outcome is never "exhausted" here — isPlanUnqueued\'s job instead', () => {
|
|
164
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan', autoFixRetries: 1 });
|
|
165
|
-
assert.strictEqual(isExhaustedAutoFix(job), false);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('isPlanUnqueued: plan outcome, fix slug absent from queue → true', () => {
|
|
169
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan' });
|
|
170
|
-
assert.strictEqual(isPlanUnqueued(job, new Set()), true);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test('isPlanUnqueued: plan outcome, fix slug present in queue → false', () => {
|
|
174
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan' });
|
|
175
|
-
assert.strictEqual(isPlanUnqueued(job, new Set([fixSlugFor(job)])), false);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
test('isPlanUnqueued: no-plan outcome is never "plan unqueued"', () => {
|
|
179
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan' });
|
|
180
|
-
assert.strictEqual(isPlanUnqueued(job, new Set()), false);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// ---- invariant: every needs_review job is either an auto-fix target, or
|
|
184
|
-
// classified by one of the annotation predicates (i.e. would receive a
|
|
185
|
-
// non-null verifierVerdict) — no job may fall through both. ----
|
|
186
|
-
|
|
187
|
-
test('invariant: attempted+no-outcome, retries spent → not a target, but IS annotatable', () => {
|
|
188
|
-
const job = makeJob({ autoFixAttempted: true, autoFixRetries: 1 });
|
|
189
|
-
const isTarget = selectAutoFixTargets([job], { fixSlugExists: noSiblingOnDisk }).length === 1;
|
|
190
|
-
const isAnnotatable = isExhaustedAutoFix(job) || isPlanUnqueued(job, new Set())
|
|
191
|
-
|| isUnresolvableNeedsReview(job, { hasRunDir: true });
|
|
192
|
-
assert.strictEqual(isTarget, false);
|
|
193
|
-
assert.strictEqual(isAnnotatable, true);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('invariant: plan outcome, no queue row → not a target, but IS annotatable (autofix_plan_unqueued)', () => {
|
|
197
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan' });
|
|
198
|
-
const isTarget = selectAutoFixTargets([job], { fixSlugExists: noSiblingOnDisk }).length === 1;
|
|
199
|
-
const isAnnotatable = isExhaustedAutoFix(job) || isPlanUnqueued(job, new Set())
|
|
200
|
-
|| isUnresolvableNeedsReview(job, { hasRunDir: true });
|
|
201
|
-
assert.strictEqual(isTarget, false);
|
|
202
|
-
assert.strictEqual(isAnnotatable, true);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test('invariant: plan outcome WITH a queue row → not a target and NOT annotated (waiting on the fix-plan job itself)', () => {
|
|
206
|
-
const job = makeJob({ autoFixAttempted: true, autoFixOutcome: 'plan' });
|
|
207
|
-
const queuedSlugs = new Set([fixSlugFor(job)]);
|
|
208
|
-
const isTarget = selectAutoFixTargets([job], { fixSlugExists: noSiblingOnDisk }).length === 1;
|
|
209
|
-
const isAnnotatable = isExhaustedAutoFix(job) || isPlanUnqueued(job, queuedSlugs)
|
|
210
|
-
|| isUnresolvableNeedsReview(job, { hasRunDir: true });
|
|
211
|
-
assert.strictEqual(isTarget, false);
|
|
212
|
-
assert.strictEqual(isAnnotatable, false);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test('excludes a job whose rcaRecoveryAction is archive (already-shipped stale re-run must never buy a fix-plan)', () => {
|
|
216
|
-
const jobs = [makeJob({ rcaRecoveryAction: 'archive', rcaFailureClass: 'already-shipped' })];
|
|
217
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
218
|
-
assert.strictEqual(result.length, 0);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test('excludes when fix sibling exists on disk', () => {
|
|
222
|
-
const jobs = [makeJob()];
|
|
223
|
-
// fixSlug = '05-fix-my-feature'
|
|
224
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: (s) => s === '05-fix-my-feature' });
|
|
225
|
-
assert.strictEqual(result.length, 0);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test('excludes when fix sibling already in the queue', () => {
|
|
229
|
-
const sibling = { slug: '05-fix-my-feature', status: 'pending', runId: null };
|
|
230
|
-
const jobs = [makeJob(), sibling];
|
|
231
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
232
|
-
assert.strictEqual(result.length, 0);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
test('fixSlug uses padded parallelGroup and strips leading digits from slug', () => {
|
|
236
|
-
const jobs = [makeJob({ slug: '07-some-task', parallelGroup: 7 })];
|
|
237
|
-
// Expected fixSlug: '07-fix-some-task'
|
|
238
|
-
const seen = [];
|
|
239
|
-
selectAutoFixTargets(jobs, {
|
|
240
|
-
fixSlugExists: (s) => { seen.push(s); return false; },
|
|
241
|
-
});
|
|
242
|
-
assert.strictEqual(seen[0], '07-fix-some-task');
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
test('defaults parallelGroup to 99 when absent', () => {
|
|
246
|
-
const jobs = [makeJob({ slug: '05-my-feature', parallelGroup: undefined })];
|
|
247
|
-
const seen = [];
|
|
248
|
-
selectAutoFixTargets(jobs, {
|
|
249
|
-
fixSlugExists: (s) => { seen.push(s); return false; },
|
|
250
|
-
});
|
|
251
|
-
assert.strictEqual(seen[0], '99-fix-my-feature');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('isRescanCandidate: needs_review + runId + no_verdict_sentinel → true (RESCANNABLE_VERDICTS includes it)', () => {
|
|
255
|
-
const job = makeJob({ verifierVerdict: 'no_verdict_sentinel' });
|
|
256
|
-
assert.strictEqual(isRescanCandidate(job), true);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
test('isRescanCandidate: needs_review + runId + uncommitted_changes → false (git commit-guard verdict stays excluded)', () => {
|
|
260
|
-
const job = makeJob({ verifierVerdict: 'uncommitted_changes' });
|
|
261
|
-
assert.strictEqual(isRescanCandidate(job), false);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
test('isRescanCandidate: needs_review + runId + pass_no_commit → true (fix-plan exemption can flip the verdict on rescan)', () => {
|
|
265
|
-
const job = makeJob({ verifierVerdict: 'pass_no_commit' });
|
|
266
|
-
assert.strictEqual(isRescanCandidate(job), true);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// ---- investigationDepth bound (fix-plan-of-a-fix-plan recursion cap) ----
|
|
270
|
-
|
|
271
|
-
test('depth-1 (ordinary, no investigationDepth field) needs_review job is eligible', () => {
|
|
272
|
-
const jobs = [makeJob({ slug: '05-my-feature' })];
|
|
273
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
274
|
-
assert.strictEqual(result.length, 1);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
test('fix-plan job with investigationDepth: 1 is still eligible (its first -fix follow-up)', () => {
|
|
278
|
-
const jobs = [makeJob({ slug: '05-fix-foo', investigationDepth: 1 })];
|
|
279
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
280
|
-
assert.strictEqual(result.length, 1);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
test('fix-plan job with investigationDepth: 2 is now NOT eligible (cap lowered to permit at most -fix-fix)', () => {
|
|
284
|
-
const jobs = [makeJob({ slug: '05-fix-foo', investigationDepth: 2 })];
|
|
285
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
286
|
-
assert.strictEqual(result.length, 0);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
test('fix-plan job with investigationDepth: 3 is NOT eligible (bound holds)', () => {
|
|
290
|
-
const jobs = [makeJob({ slug: '05-fix-foo', investigationDepth: 3 })];
|
|
291
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
292
|
-
assert.strictEqual(result.length, 0);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test('legacy fix-plan job with no investigationDepth field defaults to excluded (back-compat)', () => {
|
|
296
|
-
const jobs = [makeJob({ slug: '05-fix-foo' })];
|
|
297
|
-
const result = selectAutoFixTargets(jobs, { fixSlugExists: noSiblingOnDisk });
|
|
298
|
-
assert.strictEqual(result.length, 0);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
test('isFixPlanBeyondDepthCap: non-fix-plan slug is never capped regardless of depth', () => {
|
|
302
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-my-feature', 99), false);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test('isFixPlanBeyondDepthCap: fix-plan at depth 1 is not capped, depth 2 is', () => {
|
|
306
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', 1), false);
|
|
307
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', MAX_INVESTIGATION_DEPTH), false);
|
|
308
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', MAX_INVESTIGATION_DEPTH + 1), true);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// PRD 1131: classification is now provenance-aware (isFixPlan), not slug-only.
|
|
312
|
-
// A legacy row with no `isFixPlan` argument at all still falls back to the
|
|
313
|
-
// slug-only heuristic above (no re-classification of live history).
|
|
314
|
-
|
|
315
|
-
test('isFixPlanBeyondDepthCap: a scheduler-authored fix plan (isFixPlan:true) is still classified as one and capped at the same depth', () => {
|
|
316
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', MAX_INVESTIGATION_DEPTH, true), false);
|
|
317
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', MAX_INVESTIGATION_DEPTH + 1, true), true);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
test('isFixPlanBeyondDepthCap: a human-authored PRD (isFixPlan:false) whose slug merely matches "fix-" is never capped, even with no investigationDepth (PRD 1126 regression)', () => {
|
|
321
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('126-fix-plan-death-reopens-parent', undefined, false), false);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
test('isFixPlanBeyondDepthCap: a legacy row (isFixPlan argument omitted/undefined) with a fix- slug and no depth field is still treated as a fix plan via the slug fallback', () => {
|
|
325
|
-
assert.strictEqual(isFixPlanBeyondDepthCap('05-fix-foo', undefined, undefined), true);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
test('healTargetForFix: depth-2 fix-of-a-fix slug resolves back to the depth-1 fix job (521-fix-recorder-export-footer-redesign)', () => {
|
|
329
|
-
// Depth-1 fix job: originally authored to fix job 521, itself in needs_review.
|
|
330
|
-
const depth1FixJob = {
|
|
331
|
-
slug: '521-fix-recorder-export-footer-redesign',
|
|
332
|
-
status: 'needs_review',
|
|
333
|
-
parallelGroup: 521,
|
|
334
|
-
investigationDepth: 2,
|
|
335
|
-
};
|
|
336
|
-
const jobs = [depth1FixJob];
|
|
337
|
-
// spawnInvestigation's fix-slug formula: baseSlug strips only the leading
|
|
338
|
-
// numeric prefix (not "fix-"), so investigating this depth-1 fix job
|
|
339
|
-
// produces a depth-2 fix slug of the form "<group>-fix-fix-<rest>".
|
|
340
|
-
const baseSlug = depth1FixJob.slug.replace(/^\d+-/, '');
|
|
341
|
-
const depth2FixSlug = `${String(depth1FixJob.parallelGroup).padStart(2, '0')}-fix-${baseSlug}`;
|
|
342
|
-
assert.strictEqual(depth2FixSlug, '521-fix-fix-recorder-export-footer-redesign');
|
|
343
|
-
const resolved = healTargetForFix(depth2FixSlug, jobs);
|
|
344
|
-
assert.strictEqual(resolved, depth1FixJob);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// ---- isEligibleForImmediateAutoFix (spawnJob's same-tick auto-fix trigger,
|
|
348
|
-
// PRD 2026-07-12: needs_review jobs no longer wait up to 10 min for
|
|
349
|
-
// reverifyNeedsReview()'s periodic pass) ----
|
|
350
|
-
|
|
351
|
-
test('isEligibleForImmediateAutoFix: fresh needs_review job (fresh from spawnJob, not reverifyNeedsReview) is eligible', () => {
|
|
352
|
-
const job = makeJob();
|
|
353
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
354
|
-
assert.strictEqual(result, true);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
test('isEligibleForImmediateAutoFix: attempted job with retry already spent is excluded (prevents double-spawn with the periodic pass)', () => {
|
|
358
|
-
const job = makeJob({ autoFixAttempted: true, autoFixRetries: 1 });
|
|
359
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
360
|
-
assert.strictEqual(result, false);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test('isEligibleForImmediateAutoFix: attempted job with an unstamped outcome and its retry still unspent IS eligible (bounded once)', () => {
|
|
364
|
-
const job = makeJob({ autoFixAttempted: true, autoFixRetries: 0 });
|
|
365
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
366
|
-
assert.strictEqual(result, true);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
test('isEligibleForImmediateAutoFix: fix sibling already on disk excludes the job', () => {
|
|
370
|
-
const job = makeJob();
|
|
371
|
-
// fixSlug = '05-fix-my-feature'
|
|
372
|
-
const result = isEligibleForImmediateAutoFix(job, [job], (s) => s === '05-fix-my-feature');
|
|
373
|
-
assert.strictEqual(result, false);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
test('isEligibleForImmediateAutoFix: fix-plan job beyond the depth cap is excluded', () => {
|
|
377
|
-
const job = makeJob({ slug: '05-fix-foo', investigationDepth: 3 });
|
|
378
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
379
|
-
assert.strictEqual(result, false);
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
test('isEligibleForImmediateAutoFix: fix-plan job at investigationDepth 2 is now excluded (previously eligible under the old cap)', () => {
|
|
383
|
-
const job = makeJob({ slug: '05-fix-foo', investigationDepth: 2 });
|
|
384
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
385
|
-
assert.strictEqual(result, false);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
test('isEligibleForImmediateAutoFix: a different job in the same queue does not affect this job\'s eligibility', () => {
|
|
389
|
-
const job = makeJob();
|
|
390
|
-
const other = { slug: '05-fix-my-feature', status: 'pending', runId: null };
|
|
391
|
-
const result = isEligibleForImmediateAutoFix(job, [job, other], noSiblingOnDisk);
|
|
392
|
-
// The fix sibling is already queued, so this job is excluded too (matches
|
|
393
|
-
// selectAutoFixTargets's "no fix sibling in queue" rule).
|
|
394
|
-
assert.strictEqual(result, false);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
test('isEligibleForImmediateAutoFix: a job whose status is not needs_review (e.g. still pending) is excluded', () => {
|
|
398
|
-
const job = makeJob({ status: 'pending' });
|
|
399
|
-
const result = isEligibleForImmediateAutoFix(job, [job], noSiblingOnDisk);
|
|
400
|
-
assert.strictEqual(result, false);
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// ---- applyRcaClassification (persists writeRcaReport's verdict onto the job row) ----
|
|
404
|
-
|
|
405
|
-
test('applyRcaClassification: persists failureClass + recoveryAction onto a needs_review job', () => {
|
|
406
|
-
const job = makeJob({ status: 'needs_review' });
|
|
407
|
-
const applied = applyRcaClassification(job, { filed: true, failureClass: 'already-shipped', recoveryAction: 'archive' });
|
|
408
|
-
assert.strictEqual(applied, true);
|
|
409
|
-
assert.strictEqual(job.rcaFailureClass, 'already-shipped');
|
|
410
|
-
assert.strictEqual(job.rcaRecoveryAction, 'archive');
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
test('applyRcaClassification: no-op when the report was never filed', () => {
|
|
414
|
-
const job = makeJob({ status: 'needs_review' });
|
|
415
|
-
const applied = applyRcaClassification(job, { filed: false, reason: 'disabled' });
|
|
416
|
-
assert.strictEqual(applied, false);
|
|
417
|
-
assert.strictEqual(job.rcaFailureClass, undefined);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
test('applyRcaClassification: no-op when the job has moved off needs_review', () => {
|
|
421
|
-
const job = makeJob({ status: 'completed' });
|
|
422
|
-
const applied = applyRcaClassification(job, { filed: true, failureClass: 'unknown', recoveryAction: 'investigate' });
|
|
423
|
-
assert.strictEqual(applied, false);
|
|
424
|
-
assert.strictEqual(job.rcaFailureClass, undefined);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
test('applyRcaClassification: no-op when the job is missing (e.g. slug lookup miss)', () => {
|
|
428
|
-
const applied = applyRcaClassification(undefined, { filed: true, failureClass: 'unknown', recoveryAction: 'investigate' });
|
|
429
|
-
assert.strictEqual(applied, false);
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
test('applyRcaClassification result feeds selectAutoFixTargets: an archive-classified job is excluded', () => {
|
|
433
|
-
const job = makeJob({ status: 'needs_review' });
|
|
434
|
-
applyRcaClassification(job, { filed: true, failureClass: 'already-shipped', recoveryAction: 'archive' });
|
|
435
|
-
const result = selectAutoFixTargets([job], { fixSlugExists: noSiblingOnDisk });
|
|
436
|
-
assert.strictEqual(result.length, 0);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
console.log('scheduler-autofix-select tests: PASS');
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scheduler-autopromote.test.cjs — unit tests for isPromotableOriginal.
|
|
3
|
-
*
|
|
4
|
-
* Run: timeout 300 npx vitest run src/main/__tests__/scheduler-autopromote.test.cjs
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
import { test } from 'vitest';
|
|
10
|
-
const assert = require('node:assert/strict');
|
|
11
|
-
const { isPromotableOriginal, healTargetForFix } = require('../scheduler.cjs');
|
|
12
|
-
|
|
13
|
-
test('isPromotableOriginal: failed → true', () => {
|
|
14
|
-
assert.strictEqual(isPromotableOriginal('failed'), true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('isPromotableOriginal: needs_review → true', () => {
|
|
18
|
-
assert.strictEqual(isPromotableOriginal('needs_review'), true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('isPromotableOriginal: completed → false', () => {
|
|
22
|
-
assert.strictEqual(isPromotableOriginal('completed'), false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('isPromotableOriginal: running → false', () => {
|
|
26
|
-
assert.strictEqual(isPromotableOriginal('running'), false);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('isPromotableOriginal: pending → false', () => {
|
|
30
|
-
assert.strictEqual(isPromotableOriginal('pending'), false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('healTargetForFix: matches the specific original by full numeric-prefixed slug, not just base', () => {
|
|
34
|
-
const jobs = [
|
|
35
|
-
{ slug: '451-foo', status: 'needs_review' },
|
|
36
|
-
{ slug: '453-foo', status: 'needs_review' },
|
|
37
|
-
];
|
|
38
|
-
const target = healTargetForFix('451-fix-foo', jobs);
|
|
39
|
-
assert.strictEqual(target.slug, '451-foo');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('healTargetForFix: returns null when no promotable original matches', () => {
|
|
43
|
-
const jobs = [
|
|
44
|
-
{ slug: '451-foo', status: 'completed' },
|
|
45
|
-
{ slug: '453-foo', status: 'needs_review' },
|
|
46
|
-
];
|
|
47
|
-
const target = healTargetForFix('451-fix-foo', jobs);
|
|
48
|
-
assert.strictEqual(target, null);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
console.log('scheduler-autopromote tests: PASS');
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scheduler-bash-timeout-env.test.cjs — PRD 1097.
|
|
3
|
-
*
|
|
4
|
-
* A headless `claude -p` job inherits the harness's 120s default foreground
|
|
5
|
-
* Bash timeout. Any legit gate command (a test suite, a build) that runs
|
|
6
|
-
* long gets auto-backgrounded, and the tool result promises a notification
|
|
7
|
-
* that a single-shot headless run can never receive — the run dead-ends
|
|
8
|
-
* with no commit and no verdict. The fix is to raise
|
|
9
|
-
* BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MS on the spawned child's env.
|
|
10
|
-
*
|
|
11
|
-
* This proves:
|
|
12
|
-
* 1. executeJob's real spawned child actually receives both env vars, with
|
|
13
|
-
* the exported constant values (not just that the constants exist).
|
|
14
|
-
* 2. BASH_MAX_TIMEOUT_MS stays strictly below IDLE_OUTPUT_KILL_MS — the
|
|
15
|
-
* coupling that makes this more than a one-liner: a long foreground
|
|
16
|
-
* Bash emits no stream-json events, so the log mtime stalls and the
|
|
17
|
-
* idle-tail watchdog would SIGTERM the job mid-gate if the two ever
|
|
18
|
-
* crossed.
|
|
19
|
-
*
|
|
20
|
-
* Run: timeout 120 npx vitest run src/main/__tests__/scheduler-bash-timeout-env.test.cjs
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict';
|
|
24
|
-
|
|
25
|
-
import { test, expect, beforeAll, afterAll, afterEach } from 'vitest';
|
|
26
|
-
const fs = require('node:fs');
|
|
27
|
-
const os = require('node:os');
|
|
28
|
-
const path = require('node:path');
|
|
29
|
-
const claudeStub = require('../../../tests/helpers/claudeStub.cjs');
|
|
30
|
-
|
|
31
|
-
let tmpHome;
|
|
32
|
-
let originalHome;
|
|
33
|
-
let executeJob;
|
|
34
|
-
let BASH_DEFAULT_TIMEOUT_MS;
|
|
35
|
-
let BASH_MAX_TIMEOUT_MS;
|
|
36
|
-
let IDLE_OUTPUT_KILL_MS;
|
|
37
|
-
|
|
38
|
-
beforeAll(() => {
|
|
39
|
-
originalHome = process.env.HOME;
|
|
40
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-bash-timeout-env-'));
|
|
41
|
-
process.env.HOME = tmpHome;
|
|
42
|
-
({ executeJob, BASH_DEFAULT_TIMEOUT_MS, BASH_MAX_TIMEOUT_MS, IDLE_OUTPUT_KILL_MS } = require('../scheduler.cjs'));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
afterAll(() => {
|
|
46
|
-
process.env.HOME = originalHome;
|
|
47
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
afterEach(() => {
|
|
51
|
-
delete process.env.SM_CLAUDE_BIN;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Stub `claude` binary: dumps the two env vars it received into a marker
|
|
55
|
-
// file, then emits a stream-json success result and exits 0.
|
|
56
|
-
function writeClaudeStub() {
|
|
57
|
-
return claudeStub.writeClaudeStub({ body: `
|
|
58
|
-
const fs = require('fs');
|
|
59
|
-
const path = require('path');
|
|
60
|
-
fs.writeFileSync(path.join(process.cwd(), 'env.marker'), JSON.stringify({
|
|
61
|
-
BASH_DEFAULT_TIMEOUT_MS: process.env.BASH_DEFAULT_TIMEOUT_MS,
|
|
62
|
-
BASH_MAX_TIMEOUT_MS: process.env.BASH_MAX_TIMEOUT_MS,
|
|
63
|
-
}), 'utf8');
|
|
64
|
-
process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', result: 'ok' }) + '\\n');
|
|
65
|
-
process.exit(0);
|
|
66
|
-
` });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
test('BASH_MAX_TIMEOUT_MS stays strictly below IDLE_OUTPUT_KILL_MS with real margin', () => {
|
|
70
|
-
expect(typeof BASH_DEFAULT_TIMEOUT_MS).toBe('number');
|
|
71
|
-
expect(typeof BASH_MAX_TIMEOUT_MS).toBe('number');
|
|
72
|
-
expect(typeof IDLE_OUTPUT_KILL_MS).toBe('number');
|
|
73
|
-
expect(BASH_DEFAULT_TIMEOUT_MS).toBeLessThanOrEqual(BASH_MAX_TIMEOUT_MS);
|
|
74
|
-
expect(BASH_MAX_TIMEOUT_MS).toBeLessThan(IDLE_OUTPUT_KILL_MS);
|
|
75
|
-
// Real margin, not a razor's edge.
|
|
76
|
-
expect(IDLE_OUTPUT_KILL_MS - BASH_MAX_TIMEOUT_MS).toBeGreaterThanOrEqual(60_000);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('executeJob spawns the executor child with BASH_DEFAULT_TIMEOUT_MS and BASH_MAX_TIMEOUT_MS set', async () => {
|
|
80
|
-
const mainCwd = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-bash-timeout-main-'));
|
|
81
|
-
fs.mkdirSync(path.join(tmpHome, '.claude'), { recursive: true });
|
|
82
|
-
const runDir = fs.mkdtempSync(path.join(tmpHome, '.claude', 'sm-bash-timeout-run-'));
|
|
83
|
-
try {
|
|
84
|
-
const slug = `1097-test-${process.pid}-${Math.floor(Math.random() * 1e6)}`;
|
|
85
|
-
const prdsDir = path.join(mainCwd, 'session-manager-operations', 'scheduler', 'prds');
|
|
86
|
-
fs.mkdirSync(prdsDir, { recursive: true });
|
|
87
|
-
fs.writeFileSync(path.join(prdsDir, `${slug}.md`), 'Verify the env vars are set.', 'utf8');
|
|
88
|
-
process.env.SM_CLAUDE_BIN = writeClaudeStub();
|
|
89
|
-
|
|
90
|
-
const job = { slug, cwd: mainCwd };
|
|
91
|
-
const result = await executeJob(job, runDir, mainCwd, () => Promise.resolve());
|
|
92
|
-
|
|
93
|
-
expect(result.exitCode).toBe(0);
|
|
94
|
-
const marker = JSON.parse(fs.readFileSync(path.join(mainCwd, 'env.marker'), 'utf8'));
|
|
95
|
-
expect(marker.BASH_DEFAULT_TIMEOUT_MS).toBe(String(BASH_DEFAULT_TIMEOUT_MS));
|
|
96
|
-
expect(marker.BASH_MAX_TIMEOUT_MS).toBe(String(BASH_MAX_TIMEOUT_MS));
|
|
97
|
-
} finally {
|
|
98
|
-
fs.rmSync(mainCwd, { recursive: true, force: true });
|
|
99
|
-
fs.rmSync(runDir, { recursive: true, force: true });
|
|
100
|
-
}
|
|
101
|
-
});
|