claude-code-session-manager 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/cli.cjs +16 -4
- package/bin/node-floor.cjs +41 -0
- package/dist/assets/{DataModel-DCEgMTjH.js → DataModel-HdR0AxFq.js} +1 -1
- package/dist/assets/{History-Bfdoywlh.js → History-Dr4Jr_5z.js} +2 -2
- package/dist/assets/{Hooks-CKDJjTJV.js → Hooks-NhrvH3JP.js} +3 -3
- package/dist/assets/{Library-7akfgy67.js → Library-Dv_EtIMr.js} +1 -1
- package/dist/assets/{MarkdownEditor-DDesiqet.js → MarkdownEditor-DTKDWV_n.js} +1 -1
- package/dist/assets/{McpServers-D4lZtXof.js → McpServers-M034G9B3.js} +2 -2
- package/dist/assets/{Memory-CeI8G1w5.js → Memory-DzF1B4gx.js} +6 -6
- package/dist/assets/{Permissions-BGleLja4.js → Permissions-DrgbSGWl.js} +3 -3
- package/dist/assets/{Plugins-P4eCXy_S.js → Plugins-Bd3ef35w.js} +2 -2
- package/dist/assets/{ProvenanceBadge-BFczzI1B.js → ProvenanceBadge-DcBHT1Iy.js} +1 -1
- package/dist/assets/{SaveBar-l9jnEMES.js → SaveBar-rimJem-Y.js} +1 -1
- package/dist/assets/Scheduler-DjgFJl2w.js +16 -0
- package/dist/assets/{ScopeSwitcher-CjJi8ST5.js → ScopeSwitcher-CnAzTBrl.js} +1 -1
- package/dist/assets/Settings-Dc1F_sSg.js +3 -0
- package/dist/assets/{SkillReferenceGraph-CjbO01Sg.js → SkillReferenceGraph-B9aZDecM.js} +1 -1
- package/dist/assets/{Skills-BxZ9_fCR.js → Skills-DRXd18gu.js} +2 -2
- package/dist/assets/{SystemPrompt-D8vfFb8b.js → SystemPrompt-ahy5-Fwe.js} +1 -1
- package/dist/assets/{TagLibrary-2vzUo7YL.js → TagLibrary-C_tToDeL.js} +1 -1
- package/dist/assets/{TiptapBody-B8ZfbK90.js → TiptapBody-DvdefS6K.js} +1 -1
- package/dist/assets/{Toggle-BbW4nGGf.js → Toggle-6Jl5Njc6.js} +1 -1
- package/dist/assets/{index-CKH5Uxik.css → index-Bta-hwud.css} +1 -1
- package/dist/assets/{index-Cd98Q1lD.js → index-vx8O73l8.js} +497 -502
- package/dist/assets/{settingsSchema-IhUfucCF.js → settingsSchema-D6iRguNV.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +25 -29
- package/plugins/CLAUDE.md +6 -6
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +21 -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 +121 -12
- 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 +12 -25
- package/src/main/lib/workTypeLibrary.cjs +7 -1
- package/src/main/promptSessionEvents.cjs +37 -13
- package/src/main/scheduler.cjs +910 -198
- 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-CDVHE0hT.js +0 -1
- package/dist/assets/Scheduler-C_phpeUS.js +0 -16
- package/dist/assets/Settings-BIwZ3FGQ.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__/prdCreateAdoption.test.cjs +0 -205
- 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 -211
- 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-mutate-reentrancy.test.cjs +0 -117
- 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 -441
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +0 -266
- package/src/main/lib/kgExchangePairing.cjs +0 -75
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// PRD 832 — unique per-project PRD numbers + dependsOn eligibility.
|
|
2
|
-
// User decision 2026-07-31: duplicate NN must be impossible; ordering is
|
|
3
|
-
// expressed via dependsOn frontmatter, never via shared numbers.
|
|
4
|
-
import { describe, it, expect } from 'vitest';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import os from 'node:os';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
// HOME stubbed BEFORE requiring scheduler.cjs (PRD 812 fix): the last
|
|
10
|
-
// describe block below calls scheduler.reconcile(), which internally calls
|
|
11
|
-
// ensureDirs() → fs.mkdirSync on PRDS_DIR/RUNS_DIR — paths baked from
|
|
12
|
-
// os.homedir() at require time. Without this stub that mkdirSync lands in
|
|
13
|
-
// the real `~/.claude/session-manager/scheduled-plans/` tree.
|
|
14
|
-
const tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-832-home-'));
|
|
15
|
-
process.env.HOME = tmpHome;
|
|
16
|
-
|
|
17
|
-
const prdParser = require('../scheduler/prdParser.cjs');
|
|
18
|
-
const { pickForProject } = require('../lib/schedulerBatch.cjs');
|
|
19
|
-
|
|
20
|
-
function tmpdir() {
|
|
21
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), 'sm-832-'));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const job = (slug, status, group, extra = {}) => ({
|
|
25
|
-
slug, status, parallelGroup: group, cwd: '/proj', ...extra,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('allocateParallelGroup extraFloor (PRD 832)', () => {
|
|
29
|
-
it('never allocates at or below the cross-dir max', async () => {
|
|
30
|
-
const dir = tmpdir();
|
|
31
|
-
// Bookkeeping dir itself is empty; another dir in the project already
|
|
32
|
-
// used numbers up to 830.
|
|
33
|
-
const nn = await prdParser.allocateParallelGroup(dir, { extraFloor: 830 });
|
|
34
|
-
expect(nn).toBe(831);
|
|
35
|
-
// And the high-water mark persists the raised floor for later calls.
|
|
36
|
-
const nn2 = await prdParser.allocateParallelGroup(dir);
|
|
37
|
-
expect(nn2).toBe(832);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('local scan still wins when higher than extraFloor', async () => {
|
|
41
|
-
const dir = tmpdir();
|
|
42
|
-
fs.writeFileSync(path.join(dir, '900-existing.md'), '---\ntitle: x\n---\n# Goal\n');
|
|
43
|
-
const nn = await prdParser.allocateParallelGroup(dir, { extraFloor: 10 });
|
|
44
|
-
expect(nn).toBe(901);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('parsePrdRaw dependsOn (PRD 832)', () => {
|
|
49
|
-
it('parses bracket and comma forms, rejects junk', async () => {
|
|
50
|
-
const dir = tmpdir();
|
|
51
|
-
const fp = path.join(dir, '840-x.md');
|
|
52
|
-
fs.writeFileSync(fp, '---\ntitle: x\ncwd: /proj\ndependsOn: [833-epics-review-fixes, 834-guard]\n---\n# Goal\nbody\n');
|
|
53
|
-
const p = await prdParser.parsePrdRaw(fp);
|
|
54
|
-
expect(p.dependsOn).toEqual(['833-epics-review-fixes', '834-guard']);
|
|
55
|
-
|
|
56
|
-
const fp2 = path.join(dir, '841-y.md');
|
|
57
|
-
fs.writeFileSync(fp2, '---\ntitle: y\ncwd: /proj\ndependsOn: 833-a, ../evil/path, 834-b\n---\n# Goal\nbody\n');
|
|
58
|
-
const p2 = await prdParser.parsePrdRaw(fp2);
|
|
59
|
-
expect(p2.dependsOn).toEqual(['833-a', '834-b']);
|
|
60
|
-
|
|
61
|
-
const fp3 = path.join(dir, '842-z.md');
|
|
62
|
-
fs.writeFileSync(fp3, '---\ntitle: z\ncwd: /proj\n---\n# Goal\nbody\n');
|
|
63
|
-
const p3 = await prdParser.parsePrdRaw(fp3);
|
|
64
|
-
expect(p3.dependsOn).toEqual([]);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('pickForProject dependsOn eligibility (PRD 832)', () => {
|
|
69
|
-
it('holds a job while its dep row is pending/running; releases when completed', () => {
|
|
70
|
-
const dep = job('850-base', 'running', 850);
|
|
71
|
-
const dependent = job('851-next', 'pending', 851, { dependsOn: ['850-base'] });
|
|
72
|
-
|
|
73
|
-
// Dep running (tracked in queue rows, not runningSet) — not eligible.
|
|
74
|
-
let res = pickForProject([dep, dependent], new Set(), 3);
|
|
75
|
-
expect(res.batch.map((j) => j.slug)).not.toContain('851-next');
|
|
76
|
-
|
|
77
|
-
// Dep completed — eligible.
|
|
78
|
-
res = pickForProject([{ ...dep, status: 'completed' }, dependent], new Set(), 3);
|
|
79
|
-
expect(res.batch.map((j) => j.slug)).toContain('851-next');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('a dep slug with NO queue row counts as done when found in history/archive (PRD 1122)', () => {
|
|
83
|
-
const dependent = job('853-next', 'pending', 853, { dependsOn: ['852-archived-long-ago'] });
|
|
84
|
-
// Caller (scheduler.cjs's computeDepHistorySatisfaction) precomputes this
|
|
85
|
-
// Set from history.jsonl/prds-archived — pickForProject never does I/O.
|
|
86
|
-
const satisfiedSlugs = new Set(['852-archived-long-ago']);
|
|
87
|
-
const res = pickForProject([dependent], new Set(), 3, new Map(), satisfiedSlugs);
|
|
88
|
-
expect(res.batch.map((j) => j.slug)).toContain('853-next');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('a dep slug with NO queue row and NO history/archive record HOLDS as unresolved (PRD 1122)', () => {
|
|
92
|
-
const dependent = job('853-next', 'pending', 853, { dependsOn: ['852-archived-long-ago'] });
|
|
93
|
-
const res = pickForProject([dependent], new Set(), 3);
|
|
94
|
-
expect(res.batch).toEqual([]);
|
|
95
|
-
expect(res.reason).toMatch(/unresolvable/);
|
|
96
|
-
expect(res.reason).toContain('853-next');
|
|
97
|
-
expect(res.reason).toContain('852-archived-long-ago');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('a FAILED dep holds the dependent with an explicit depends-gate reason', () => {
|
|
101
|
-
const dep = job('854-base', 'failed', 854);
|
|
102
|
-
const dependent = job('855-next', 'pending', 855, { dependsOn: ['854-base'] });
|
|
103
|
-
const res = pickForProject([dep, dependent], new Set(), 3);
|
|
104
|
-
expect(res.batch).toEqual([]);
|
|
105
|
-
expect(res.reason).toMatch(/depends-gate/);
|
|
106
|
-
expect(res.reason).toContain('855-next');
|
|
107
|
-
expect(res.reason).toContain('854-base');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Contract change: parallelGroup no longer gates batch membership at all
|
|
111
|
-
// (it was a wave number; PRD 832 made it unique per PRD, which silently
|
|
112
|
-
// reduced every batch to one job). Legacy same-NN rows are simply eligible
|
|
113
|
-
// like anything else with no blocking dependsOn — the 828 row is no longer
|
|
114
|
-
// held back merely for carrying a higher number.
|
|
115
|
-
it('legacy same-NN pending jobs are eligible alongside higher-numbered ones', () => {
|
|
116
|
-
// Predates the per-project job cap (PRD 1066, default 2); raise it so
|
|
117
|
-
// this test keeps exercising parallelGroup semantics, not the cap.
|
|
118
|
-
const prevCap = process.env.SM_PROJECT_JOB_CAP;
|
|
119
|
-
process.env.SM_PROJECT_JOB_CAP = '10';
|
|
120
|
-
try {
|
|
121
|
-
const a = job('827-one', 'pending', 827);
|
|
122
|
-
const b = job('827-two', 'pending', 827);
|
|
123
|
-
const later = job('828-three', 'pending', 828);
|
|
124
|
-
const res = pickForProject([a, b, later], new Set(), 3);
|
|
125
|
-
expect(res.batch.map((j) => j.slug).sort()).toEqual(['827-one', '827-two', '828-three']);
|
|
126
|
-
} finally {
|
|
127
|
-
if (prevCap === undefined) delete process.env.SM_PROJECT_JOB_CAP;
|
|
128
|
-
else process.env.SM_PROJECT_JOB_CAP = prevCap;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('reconcile retires archived-twin pending rows (post-832 cleanup)', () => {
|
|
134
|
-
it('drops a pending row whose PRD lives in prds-archived, keeps a normal invisible pending row', async () => {
|
|
135
|
-
const scheduler = require('../scheduler.cjs');
|
|
136
|
-
const root = tmpdir();
|
|
137
|
-
const opsDir = path.join(root, 'session-manager-operations', 'scheduler');
|
|
138
|
-
fs.mkdirSync(path.join(opsDir, 'prds'), { recursive: true });
|
|
139
|
-
fs.mkdirSync(path.join(opsDir, 'prds-archived'), { recursive: true });
|
|
140
|
-
fs.writeFileSync(path.join(opsDir, 'prds-archived', '833-landed-inline.md'), '---\ntitle: x\n---\n# Goal\n');
|
|
141
|
-
|
|
142
|
-
const state = {
|
|
143
|
-
jobs: [
|
|
144
|
-
job('833-landed-inline', 'pending', 833, { cwd: root }),
|
|
145
|
-
job('900-still-hidden', 'pending', 900, { cwd: root }),
|
|
146
|
-
],
|
|
147
|
-
};
|
|
148
|
-
await scheduler.reconcile(state);
|
|
149
|
-
const slugs = state.jobs.map((j) => j.slug);
|
|
150
|
-
expect(slugs).not.toContain('833-landed-inline');
|
|
151
|
-
expect(slugs).toContain('900-still-hidden');
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* usageSingleFlight.test.cjs — usage.cjs's fetchUsage() is the single owner
|
|
3
|
-
* of caching, single-flight de-duplication, and the shared usageCircuit for
|
|
4
|
-
* the /api/oauth/usage meter. Before this, the renderer's billing:fetch IPC
|
|
5
|
-
* handler owned the 30s OK-cache alone and the scheduler's pollLoop called
|
|
6
|
-
* fetchUsage() directly with no cache/dedup — two independent request
|
|
7
|
-
* streams against a rate-limiting endpoint, and a success on one path never
|
|
8
|
-
* reset the other's failure streak. This suite proves: (1) concurrent
|
|
9
|
-
* fetchUsage() callers coalesce into exactly one network fetch, (2) a
|
|
10
|
-
* success resets the shared circuit's streak regardless of which "caller"
|
|
11
|
-
* triggered the preceding failures, and (3) a 429's Retry-After suppresses
|
|
12
|
-
* the next request until it elapses.
|
|
13
|
-
*
|
|
14
|
-
* Never hits the live billing endpoint — global.fetch is stubbed throughout,
|
|
15
|
-
* and HOME is pointed at a scratch dir so no real credentials/cache file on
|
|
16
|
-
* this machine is ever read.
|
|
17
|
-
*
|
|
18
|
-
* usage.cjs (and config.cjs/credentials.cjs, which it requires) are loaded
|
|
19
|
-
* via Node's own require() — this is a .cjs test, not transformed ESM — so
|
|
20
|
-
* vi.mock()/vi.resetModules() do NOT intercept them the way they would for
|
|
21
|
-
* an ESM import graph; both also bake os.homedir() into module-level
|
|
22
|
-
* constants at first require (config.cjs's allowedRoots/WRITE_PREFIXES,
|
|
23
|
-
* usage.cjs's CACHE_PATH, credentials.cjs's CREDS_PATH). So this suite
|
|
24
|
-
* follows historyRollup.test.cjs's pattern instead: swap $HOME to a fresh
|
|
25
|
-
* tmp dir with a valid, far-from-expiry fake credentials file, purge
|
|
26
|
-
* Node's require.cache for every affected module, and re-require fresh
|
|
27
|
-
* each test.
|
|
28
|
-
*
|
|
29
|
-
* Run: timeout 120 npx vitest run src/main/__tests__/usageSingleFlight.test.cjs
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
'use strict';
|
|
33
|
-
|
|
34
|
-
import { test, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
35
|
-
import fs from 'node:fs';
|
|
36
|
-
import os from 'node:os';
|
|
37
|
-
import path from 'node:path';
|
|
38
|
-
|
|
39
|
-
function jsonResponse(status, body, headers = {}) {
|
|
40
|
-
return {
|
|
41
|
-
status,
|
|
42
|
-
ok: status >= 200 && status < 300,
|
|
43
|
-
text: async () => JSON.stringify(body),
|
|
44
|
-
json: async () => body,
|
|
45
|
-
headers: { get: (k) => headers[k.toLowerCase()] ?? null },
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const usagePayload = { five_hour: { utilization: 10, resets_at: null }, seven_day: { utilization: 10, resets_at: null }, seven_day_sonnet: null, seven_day_opus: null, extra_usage: null };
|
|
50
|
-
|
|
51
|
-
const MODULES_TO_RELOAD = [
|
|
52
|
-
'../usage.cjs',
|
|
53
|
-
'../config.cjs',
|
|
54
|
-
'../lib/credentials.cjs',
|
|
55
|
-
'../lib/usageCircuit.cjs',
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
function purgeRequireCache() {
|
|
59
|
-
for (const m of MODULES_TO_RELOAD) {
|
|
60
|
-
try { delete require.cache[require.resolve(m)]; } catch { /* not loaded yet */ }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let realHome;
|
|
65
|
-
let tmpHome;
|
|
66
|
-
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
realHome = process.env.HOME;
|
|
69
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'usage-single-flight-test-'));
|
|
70
|
-
process.env.HOME = tmpHome;
|
|
71
|
-
fs.mkdirSync(path.join(tmpHome, '.claude'), { recursive: true });
|
|
72
|
-
fs.writeFileSync(
|
|
73
|
-
path.join(tmpHome, '.claude', '.credentials.json'),
|
|
74
|
-
JSON.stringify({
|
|
75
|
-
claudeAiOauth: {
|
|
76
|
-
accessToken: 'test-access-token',
|
|
77
|
-
refreshToken: 'test-refresh-token',
|
|
78
|
-
expiresAt: Date.now() + 1_000 * 60 * 60 * 24, // 24h out — never "expiring soon"
|
|
79
|
-
subscriptionType: 'max',
|
|
80
|
-
rateLimitTier: 'default_claude_max_20x',
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
purgeRequireCache();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
afterEach(() => {
|
|
88
|
-
process.env.HOME = realHome;
|
|
89
|
-
vi.unstubAllGlobals();
|
|
90
|
-
vi.restoreAllMocks();
|
|
91
|
-
vi.useRealTimers();
|
|
92
|
-
purgeRequireCache();
|
|
93
|
-
// maxRetries: a fire-and-forget cache write inside usage.cjs can land in .claude/ mid-rm
|
|
94
|
-
// (ENOTEMPTY) when the machine is loaded; this is cleanup robustness, not a test retry.
|
|
95
|
-
fs.rmSync(tmpHome, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('two concurrent fetchUsage() calls produce exactly one HTTP fetch', async () => {
|
|
99
|
-
const { fetchUsage } = require('../usage.cjs');
|
|
100
|
-
let fetchCalls = 0;
|
|
101
|
-
vi.stubGlobal('fetch', vi.fn(async () => {
|
|
102
|
-
fetchCalls++;
|
|
103
|
-
// Slow enough that both callers are guaranteed to be in-flight together.
|
|
104
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
105
|
-
return jsonResponse(200, usagePayload);
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
const [a, b] = await Promise.all([fetchUsage(), fetchUsage()]);
|
|
109
|
-
|
|
110
|
-
expect(fetchCalls).toBe(1);
|
|
111
|
-
expect(a.kind).toBe('ok');
|
|
112
|
-
expect(b.kind).toBe('ok');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('an ok result resets the shared circuit streak built up by prior failures', async () => {
|
|
116
|
-
// The breaker's open->half_open transition (usageCircuit.cjs's state())
|
|
117
|
-
// compares real Date.now() against a jittered 15-30s backoff deadline. On
|
|
118
|
-
// a loaded machine, real wall-clock time can drift far enough between the
|
|
119
|
-
// 3rd failure and the assertions below for that deadline to pass, flipping
|
|
120
|
-
// 'open' to 'half_open' out from under this test. Freeze time so the
|
|
121
|
-
// open/closed assertions are decided by call sequence, not the real clock.
|
|
122
|
-
vi.useFakeTimers();
|
|
123
|
-
vi.setSystemTime(Date.now());
|
|
124
|
-
|
|
125
|
-
const usage = require('../usage.cjs');
|
|
126
|
-
const circuit = usage.__usageCircuitForTest;
|
|
127
|
-
|
|
128
|
-
let call = 0;
|
|
129
|
-
vi.stubGlobal('fetch', vi.fn(async () => {
|
|
130
|
-
call++;
|
|
131
|
-
if (call <= 3) return jsonResponse(500, { error: 'boom' });
|
|
132
|
-
return jsonResponse(200, usagePayload);
|
|
133
|
-
}));
|
|
134
|
-
|
|
135
|
-
// Three consecutive transient failures — simulating the scheduler's poller
|
|
136
|
-
// failing repeatedly — trip the circuit open.
|
|
137
|
-
await usage.fetchUsage();
|
|
138
|
-
await usage.fetchUsage();
|
|
139
|
-
await usage.fetchUsage();
|
|
140
|
-
expect(circuit.state()).toBe('open');
|
|
141
|
-
|
|
142
|
-
// A later success — as if it came from the renderer's independent
|
|
143
|
-
// billing:fetch call, but reached through the SAME shared fetchUsage() —
|
|
144
|
-
// must reset the streak the scheduler's calls built up, since both
|
|
145
|
-
// callers share one circuit instance.
|
|
146
|
-
const ok = await usage.fetchUsage();
|
|
147
|
-
expect(ok.kind).toBe('ok');
|
|
148
|
-
expect(circuit.state()).toBe('closed');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('a 429 with Retry-After suppresses the next request until it elapses', async () => {
|
|
152
|
-
const usage = require('../usage.cjs');
|
|
153
|
-
|
|
154
|
-
let fetchCalls = 0;
|
|
155
|
-
vi.stubGlobal('fetch', vi.fn(async () => {
|
|
156
|
-
fetchCalls++;
|
|
157
|
-
return jsonResponse(429, { error: { type: 'rate_limit_error' } }, { 'retry-after': '60' });
|
|
158
|
-
}));
|
|
159
|
-
|
|
160
|
-
const first = await usage.fetchUsage();
|
|
161
|
-
expect(first.kind).toBe('meter_rate_limited');
|
|
162
|
-
expect(first.retryAfterMs).toBe(60_000);
|
|
163
|
-
|
|
164
|
-
const second = await usage.fetchUsage();
|
|
165
|
-
expect(second.kind).toBe('meter_rate_limited');
|
|
166
|
-
expect(second.suppressed).toBe(true);
|
|
167
|
-
// No second network call — the suppression window hasn't elapsed.
|
|
168
|
-
expect(fetchCalls).toBe(1);
|
|
169
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* validationSentinels.test.cjs — unit tests for parseValidationSentinels
|
|
3
|
-
* (PRD 1407): a plan-level validator job ends its run with one
|
|
4
|
-
* `VALIDATION: <slug> VERIFIED` or `VALIDATION: <slug> REFUTED — <reason>`
|
|
5
|
-
* line per PRD; this module extracts those lines from the job's result text.
|
|
6
|
-
*
|
|
7
|
-
* Run: timeout 300 npx vitest run src/main/__tests__/validationSentinels.test.cjs
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
import { test, expect } from 'vitest';
|
|
13
|
-
const { parseValidationSentinels } = require('../lib/validationSentinels.cjs');
|
|
14
|
-
|
|
15
|
-
test('parses a VERIFIED line with no reason', () => {
|
|
16
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo VERIFIED')).toEqual([
|
|
17
|
-
{ slug: '123-foo', verdict: 'verified', reason: '' },
|
|
18
|
-
]);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('parses a REFUTED line with an em-dash reason', () => {
|
|
22
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo REFUTED — missing test coverage')).toEqual([
|
|
23
|
-
{ slug: '123-foo', verdict: 'refuted', reason: 'missing test coverage' },
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('parses a REFUTED line with an en-dash reason', () => {
|
|
28
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo REFUTED – bad wiring')).toEqual([
|
|
29
|
-
{ slug: '123-foo', verdict: 'refuted', reason: 'bad wiring' },
|
|
30
|
-
]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('parses a REFUTED line with a hyphen reason', () => {
|
|
34
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo REFUTED - wrong file touched')).toEqual([
|
|
35
|
-
{ slug: '123-foo', verdict: 'refuted', reason: 'wrong file touched' },
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('parses a REFUTED line with no reason', () => {
|
|
40
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo REFUTED')).toEqual([
|
|
41
|
-
{ slug: '123-foo', verdict: 'refuted', reason: '' },
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('ignores lowercase verified/refuted', () => {
|
|
46
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo verified')).toEqual([]);
|
|
47
|
-
expect(parseValidationSentinels('VALIDATION: 123-foo refuted')).toEqual([]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('ignores every other line in a multi-line transcript', () => {
|
|
51
|
-
const text = [
|
|
52
|
-
'Some preamble text',
|
|
53
|
-
'Running gate...',
|
|
54
|
-
'VALIDATION: 111-alpha VERIFIED',
|
|
55
|
-
'random noise mentioning VALIDATION: not-a-real-line',
|
|
56
|
-
'VALIDATION: 222-beta REFUTED — the fix was incomplete',
|
|
57
|
-
'trailing notes',
|
|
58
|
-
].join('\n');
|
|
59
|
-
|
|
60
|
-
expect(parseValidationSentinels(text)).toEqual([
|
|
61
|
-
{ slug: '111-alpha', verdict: 'verified', reason: '' },
|
|
62
|
-
{ slug: '222-beta', verdict: 'refuted', reason: 'the fix was incomplete' },
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('last line per slug wins, order of first appearance kept', () => {
|
|
67
|
-
const text = [
|
|
68
|
-
'VALIDATION: 111-alpha VERIFIED',
|
|
69
|
-
'VALIDATION: 222-beta REFUTED — first reason',
|
|
70
|
-
'VALIDATION: 111-alpha REFUTED — actually broken',
|
|
71
|
-
'VALIDATION: 222-beta VERIFIED',
|
|
72
|
-
].join('\n');
|
|
73
|
-
|
|
74
|
-
expect(parseValidationSentinels(text)).toEqual([
|
|
75
|
-
{ slug: '111-alpha', verdict: 'refuted', reason: 'actually broken' },
|
|
76
|
-
{ slug: '222-beta', verdict: 'verified', reason: '' },
|
|
77
|
-
]);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('returns [] for null, undefined, and empty input', () => {
|
|
81
|
-
expect(parseValidationSentinels(null)).toEqual([]);
|
|
82
|
-
expect(parseValidationSentinels(undefined)).toEqual([]);
|
|
83
|
-
expect(parseValidationSentinels('')).toEqual([]);
|
|
84
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* workTypeLibrary.test.cjs — cross-file consistency tests for the WorkType
|
|
3
|
-
* union. Epic tag and PRD tag are one concept (WorkType); this test enforces
|
|
4
|
-
* that every declaration site agrees, since the two module systems involved
|
|
5
|
-
* (renderer .ts, main .cjs, and the preload .d.ts that can import neither)
|
|
6
|
-
* can't enforce it via a shared import. Modelled on scheduleJobSchema.test.cjs's
|
|
7
|
-
* JOB_STATUSES cross-file assertions.
|
|
8
|
-
*
|
|
9
|
-
* Run: timeout 300 npx vitest run src/main/__tests__/workTypeLibrary.test.cjs
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
import { test, expect } from 'vitest';
|
|
15
|
-
const fs = require('node:fs');
|
|
16
|
-
const path = require('node:path');
|
|
17
|
-
const { WORK_TYPES, WorkTypeSchema } = require('../lib/workTypeLibrary.cjs');
|
|
18
|
-
|
|
19
|
-
const REPO_ROOT = path.resolve(__dirname, '../../..');
|
|
20
|
-
const TAG_LIBRARY_PATH = path.join(REPO_ROOT, 'src/renderer/lib/tagLibrary.ts');
|
|
21
|
-
const API_D_TS_PATH = path.join(REPO_ROOT, 'src/preload/api.d.ts');
|
|
22
|
-
const IPC_SCHEMAS_PATH = path.join(REPO_ROOT, 'src/main/ipcSchemas.cjs');
|
|
23
|
-
const SCHEDULER_MCP_SERVER_PATH = path.join(REPO_ROOT, 'scripts/scheduler-mcp-server.cjs');
|
|
24
|
-
|
|
25
|
-
test('WORK_TYPES matches the expected 6 canonical ids in order', () => {
|
|
26
|
-
expect(WORK_TYPES).toEqual([
|
|
27
|
-
'feature',
|
|
28
|
-
'bug',
|
|
29
|
-
'discussion',
|
|
30
|
-
'build',
|
|
31
|
-
'project-home-builder',
|
|
32
|
-
'bilko-host-publisher',
|
|
33
|
-
]);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('WorkTypeSchema accepts every WORK_TYPES value and rejects an unknown one', () => {
|
|
37
|
-
for (const value of WORK_TYPES) {
|
|
38
|
-
expect(WorkTypeSchema.safeParse(value).success).toBe(true);
|
|
39
|
-
}
|
|
40
|
-
expect(WorkTypeSchema.safeParse('not-a-real-tag').success).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('WORK_TYPES matches the tag ids declared in tagLibrary.ts TAG_LIBRARY, in order', () => {
|
|
44
|
-
const src = fs.readFileSync(TAG_LIBRARY_PATH, 'utf8');
|
|
45
|
-
const tagMatches = [...src.matchAll(/^\s*tag:\s*'([^']+)',/gm)].map((m) => m[1]);
|
|
46
|
-
expect(tagMatches).toEqual(WORK_TYPES);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('api.d.ts tag unions both contain exactly the same 6 values', () => {
|
|
50
|
-
const src = fs.readFileSync(API_D_TS_PATH, 'utf8');
|
|
51
|
-
const unionMatches = [...src.matchAll(/tag\?:\s*((?:'[^']+'\s*\|?\s*)+);/g)].map((m) =>
|
|
52
|
-
m[1]
|
|
53
|
-
.split('|')
|
|
54
|
-
.map((s) => s.trim().replace(/^'|'$/g, ''))
|
|
55
|
-
.filter(Boolean)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(unionMatches.length).toBeGreaterThanOrEqual(2);
|
|
59
|
-
for (const union of unionMatches) {
|
|
60
|
-
expect(union).toEqual(WORK_TYPES);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('ipcSchemas.cjs no longer hardcodes the full-taxonomy tag z.enum literal', () => {
|
|
65
|
-
const src = fs.readFileSync(IPC_SCHEMAS_PATH, 'utf8');
|
|
66
|
-
// The old scheduleRetagPrd literal was missing 'bilko-host-publisher'
|
|
67
|
-
// (5 of the 6 WORK_TYPES values) — assert that exact stale shape is gone.
|
|
68
|
-
expect(src).not.toMatch(/z\.enum\(\['feature',\s*'bug',\s*'discussion',\s*'build',\s*'project-home-builder'\]\)/);
|
|
69
|
-
// Epic tag (schedulerCreateEpic-style routes) draws on the full 6-value
|
|
70
|
-
// WorkType union via EpicTagSchema, which is itself WorkTypeSchema
|
|
71
|
-
// (promptSessionSchema.cjs). PRD tag fields (schedulerCreatePrd,
|
|
72
|
-
// adminPrdFrontmatterPatch) draw on the narrower 5-value PrdWorkTypeSchema
|
|
73
|
-
// — independent values, same shared vocabulary (PRD 1041).
|
|
74
|
-
expect(src).toMatch(/tag:\s*EpicTagSchema/);
|
|
75
|
-
const prdTagMatches = [...src.matchAll(/tag:\s*PrdWorkTypeSchema/g)];
|
|
76
|
-
expect(prdTagMatches.length).toBeGreaterThanOrEqual(2);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('scheduler-mcp-server.cjs requires PRD_WORK_TYPES rather than hardcoding a tag enum literal, and imports it exactly twice (scheduler_create_prd + scheduler_update_prd)', () => {
|
|
80
|
-
const { PRD_WORK_TYPES } = require('../lib/workTypeLibrary.cjs');
|
|
81
|
-
const src = fs.readFileSync(SCHEDULER_MCP_SERVER_PATH, 'utf8');
|
|
82
|
-
expect(src).toMatch(/require\(['"].*workTypeLibrary\.cjs['"]\)/);
|
|
83
|
-
const occurrences = [...src.matchAll(/enum:\s*PRD_WORK_TYPES/g)].length;
|
|
84
|
-
// scheduler_create_prd's inputSchema.tag.enum and scheduler_update_prd's
|
|
85
|
-
// frontmatter.tag.enum — exactly 2 sites, not the Epic-tag (6-value)
|
|
86
|
-
// enum on feedback_open_session's tag property.
|
|
87
|
-
expect(occurrences).toBe(2);
|
|
88
|
-
expect(PRD_WORK_TYPES).toEqual(['feature', 'bug', 'build', 'project-home-builder', 'bilko-host-publisher']);
|
|
89
|
-
});
|