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,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* telemetrySettings.test.cjs — unit tests for the telemetry consent/config store.
|
|
3
|
-
*
|
|
4
|
-
* Run: timeout 120 npx vitest run src/main/__tests__/telemetrySettings.test.cjs
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
import { test, expect, beforeEach, afterEach } from 'vitest';
|
|
9
|
-
const fs = require('node:fs');
|
|
10
|
-
const fsp = require('node:fs/promises');
|
|
11
|
-
const os = require('node:os');
|
|
12
|
-
const path = require('node:path');
|
|
13
|
-
|
|
14
|
-
const tmpDirs = [];
|
|
15
|
-
let originalHome;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
originalHome = process.env.HOME;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(async () => {
|
|
22
|
-
if (originalHome !== undefined) process.env.HOME = originalHome;
|
|
23
|
-
delete process.env.SM_TELEMETRY;
|
|
24
|
-
delete process.env.SM_TELEMETRY_ENDPOINT;
|
|
25
|
-
while (tmpDirs.length) {
|
|
26
|
-
const d = tmpDirs.pop();
|
|
27
|
-
await fsp.rm(d, { recursive: true, force: true });
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
async function freshModule(home) {
|
|
32
|
-
process.env.HOME = home;
|
|
33
|
-
const modPath = require.resolve('../lib/telemetrySettings.cjs');
|
|
34
|
-
delete require.cache[modPath];
|
|
35
|
-
delete require.cache[require.resolve('../config.cjs')];
|
|
36
|
-
return require('../lib/telemetrySettings.cjs');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function mkHome() {
|
|
40
|
-
const dir = await fsp.mkdtemp(path.join(os.tmpdir(), 'sm-telemetry-home-'));
|
|
41
|
-
tmpDirs.push(dir);
|
|
42
|
-
return dir;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
test('DEFAULTS carries no identity-shaped key', async () => {
|
|
46
|
-
const home = await mkHome();
|
|
47
|
-
const telemetrySettings = await freshModule(home);
|
|
48
|
-
const keys = Object.keys(telemetrySettings.DEFAULTS);
|
|
49
|
-
const identityLike = keys.filter((k) => /email|user|name|host|account/i.test(k));
|
|
50
|
-
expect(identityLike).toEqual([]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('isValid rejects a config carrying an unknown extra identity-shaped key', async () => {
|
|
54
|
-
const home = await mkHome();
|
|
55
|
-
const telemetrySettings = await freshModule(home);
|
|
56
|
-
const base = { ...telemetrySettings.DEFAULTS, installId: 'abc' };
|
|
57
|
-
expect(telemetrySettings.isValid(base)).toBe(true);
|
|
58
|
-
const withExtra = { ...base, identifyEmail: 'someone@example.com' };
|
|
59
|
-
expect(telemetrySettings.isValid(withExtra)).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('load() mints installId once via crypto.randomUUID and persists it', async () => {
|
|
63
|
-
const home = await mkHome();
|
|
64
|
-
const telemetrySettings = await freshModule(home);
|
|
65
|
-
|
|
66
|
-
const first = await telemetrySettings.load();
|
|
67
|
-
expect(typeof first.installId).toBe('string');
|
|
68
|
-
expect(first.installId.length).toBeGreaterThan(0);
|
|
69
|
-
|
|
70
|
-
const second = await telemetrySettings.load();
|
|
71
|
-
expect(second.installId).toBe(first.installId);
|
|
72
|
-
|
|
73
|
-
const raw = JSON.parse(fs.readFileSync(telemetrySettings.storePath(), 'utf8'));
|
|
74
|
-
expect(raw.installId).toBe(first.installId);
|
|
75
|
-
|
|
76
|
-
const freshRead = await freshModule(home);
|
|
77
|
-
const third = await freshRead.load();
|
|
78
|
-
expect(third.installId).toBe(first.installId);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('isEnabled: hard kill switch SM_TELEMETRY=0 overrides persisted enabled:true', async () => {
|
|
82
|
-
const home = await mkHome();
|
|
83
|
-
const telemetrySettings = await freshModule(home);
|
|
84
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', enabled: true };
|
|
85
|
-
process.env.SM_TELEMETRY = '0';
|
|
86
|
-
expect(telemetrySettings.isEnabled(cfg)).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('isEnabled: returns false when persisted enabled is false', async () => {
|
|
90
|
-
const home = await mkHome();
|
|
91
|
-
const telemetrySettings = await freshModule(home);
|
|
92
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', enabled: false };
|
|
93
|
-
expect(telemetrySettings.isEnabled(cfg)).toBe(false);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('isEnabled: returns true when persisted enabled is true and no kill switch', async () => {
|
|
97
|
-
const home = await mkHome();
|
|
98
|
-
const telemetrySettings = await freshModule(home);
|
|
99
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', enabled: true };
|
|
100
|
-
expect(telemetrySettings.isEnabled(cfg)).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('resolveEndpoint prefers SM_TELEMETRY_ENDPOINT over persisted endpoint', async () => {
|
|
104
|
-
const home = await mkHome();
|
|
105
|
-
const telemetrySettings = await freshModule(home);
|
|
106
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', endpoint: 'https://persisted.example' };
|
|
107
|
-
process.env.SM_TELEMETRY_ENDPOINT = 'https://env-override.example';
|
|
108
|
-
expect(telemetrySettings.resolveEndpoint(cfg)).toBe('https://env-override.example');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('resolveEndpoint falls back to persisted endpoint when no env override', async () => {
|
|
112
|
-
const home = await mkHome();
|
|
113
|
-
const telemetrySettings = await freshModule(home);
|
|
114
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', endpoint: 'https://persisted.example' };
|
|
115
|
-
expect(telemetrySettings.resolveEndpoint(cfg)).toBe('https://persisted.example');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test('isDailyFlushDue: true when lastDailyFlushAt is null', async () => {
|
|
119
|
-
const home = await mkHome();
|
|
120
|
-
const telemetrySettings = await freshModule(home);
|
|
121
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastDailyFlushAt: null };
|
|
122
|
-
expect(telemetrySettings.isDailyFlushDue(cfg, Date.now())).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('isDailyFlushDue: false when lastDailyFlushAt is 23h before now', async () => {
|
|
126
|
-
const home = await mkHome();
|
|
127
|
-
const telemetrySettings = await freshModule(home);
|
|
128
|
-
const now = Date.now();
|
|
129
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastDailyFlushAt: new Date(now - 23 * 60 * 60 * 1000).toISOString() };
|
|
130
|
-
expect(telemetrySettings.isDailyFlushDue(cfg, now)).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('isDailyFlushDue: true when lastDailyFlushAt is 25h before now', async () => {
|
|
134
|
-
const home = await mkHome();
|
|
135
|
-
const telemetrySettings = await freshModule(home);
|
|
136
|
-
const now = Date.now();
|
|
137
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastDailyFlushAt: new Date(now - 25 * 60 * 60 * 1000).toISOString() };
|
|
138
|
-
expect(telemetrySettings.isDailyFlushDue(cfg, now)).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test('isMachineReportDue: true when app version changed', async () => {
|
|
142
|
-
const home = await mkHome();
|
|
143
|
-
const telemetrySettings = await freshModule(home);
|
|
144
|
-
const now = Date.now();
|
|
145
|
-
const cfg = {
|
|
146
|
-
...telemetrySettings.DEFAULTS,
|
|
147
|
-
installId: 'x',
|
|
148
|
-
lastMachineReportVersion: '0.80.0',
|
|
149
|
-
lastMachineReportAt: new Date(now).toISOString(),
|
|
150
|
-
};
|
|
151
|
-
expect(telemetrySettings.isMachineReportDue(cfg, { now, appVersion: '0.81.0' })).toBe(true);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test('isMachineReportDue: true when lastMachineReportAt is null (same version)', async () => {
|
|
155
|
-
const home = await mkHome();
|
|
156
|
-
const telemetrySettings = await freshModule(home);
|
|
157
|
-
const now = Date.now();
|
|
158
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastMachineReportVersion: '0.81.0', lastMachineReportAt: null };
|
|
159
|
-
expect(telemetrySettings.isMachineReportDue(cfg, { now, appVersion: '0.81.0' })).toBe(true);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test('isMachineReportDue: true when lastMachineReportAt is more than 30 days before now (same version)', async () => {
|
|
163
|
-
const home = await mkHome();
|
|
164
|
-
const telemetrySettings = await freshModule(home);
|
|
165
|
-
const now = Date.now();
|
|
166
|
-
const thirtyOneDaysAgo = new Date(now - 31 * 24 * 60 * 60 * 1000).toISOString();
|
|
167
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastMachineReportVersion: '0.81.0', lastMachineReportAt: thirtyOneDaysAgo };
|
|
168
|
-
expect(telemetrySettings.isMachineReportDue(cfg, { now, appVersion: '0.81.0' })).toBe(true);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('save() merges a partial patch onto a fresh disk read — concurrent savers do not clobber each other', async () => {
|
|
172
|
-
const home = await mkHome();
|
|
173
|
-
const telemetrySettings = await freshModule(home);
|
|
174
|
-
const base = await telemetrySettings.load(); // mints + persists installId
|
|
175
|
-
expect(base.installId).not.toBe('');
|
|
176
|
-
|
|
177
|
-
// Two independent writers, each stamping a DIFFERENT field, racing each
|
|
178
|
-
// other — mirrors telemetryBoot's install-report stamp landing around the
|
|
179
|
-
// same time as telemetryClient's own daily-flush stamp. Neither holds the
|
|
180
|
-
// other's snapshot; each passes only the field it intends to change.
|
|
181
|
-
await Promise.all([
|
|
182
|
-
telemetrySettings.save({ lastMachineReportAt: '2026-01-01T00:00:00.000Z', lastMachineReportVersion: '2.0.0' }),
|
|
183
|
-
telemetrySettings.save({ lastDailyFlushAt: '2026-01-01T01:00:00.000Z' }),
|
|
184
|
-
]);
|
|
185
|
-
|
|
186
|
-
const onDisk = await telemetrySettings.load();
|
|
187
|
-
expect(onDisk.lastMachineReportAt).toBe('2026-01-01T00:00:00.000Z');
|
|
188
|
-
expect(onDisk.lastMachineReportVersion).toBe('2.0.0');
|
|
189
|
-
expect(onDisk.lastDailyFlushAt).toBe('2026-01-01T01:00:00.000Z');
|
|
190
|
-
// Neither save touched installId/enabled/endpoint — they must survive too.
|
|
191
|
-
expect(onDisk.installId).toBe(base.installId);
|
|
192
|
-
expect(onDisk.enabled).toBe(base.enabled);
|
|
193
|
-
expect(onDisk.endpoint).toBe(base.endpoint);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('save() rejects an unknown key without touching disk', async () => {
|
|
197
|
-
const home = await mkHome();
|
|
198
|
-
const telemetrySettings = await freshModule(home);
|
|
199
|
-
await telemetrySettings.load();
|
|
200
|
-
await expect(telemetrySettings.save({ notARealField: 'x' })).rejects.toThrow('Invalid telemetry config');
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test('isMachineReportDue: false when same version and reported less than 30 days ago', async () => {
|
|
204
|
-
const home = await mkHome();
|
|
205
|
-
const telemetrySettings = await freshModule(home);
|
|
206
|
-
const now = Date.now();
|
|
207
|
-
const oneDayAgo = new Date(now - 24 * 60 * 60 * 1000).toISOString();
|
|
208
|
-
const cfg = { ...telemetrySettings.DEFAULTS, installId: 'x', lastMachineReportVersion: '0.81.0', lastMachineReportAt: oneDayAgo };
|
|
209
|
-
expect(telemetrySettings.isMachineReportDue(cfg, { now, appVersion: '0.81.0' })).toBe(false);
|
|
210
|
-
});
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* transcripts-batch-flush.test.cjs — unit tests for the batched IPC flush
|
|
3
|
-
* (PRD transcript-batch-flush): transcripts.cjs's doFlush now sends the
|
|
4
|
-
* events produced by ONE flush as a SINGLE `transcript:event:<tabId>` IPC
|
|
5
|
-
* message (an array), instead of one message per event, while still
|
|
6
|
-
* recording one OTEL span per event and preserving exact event order.
|
|
7
|
-
*
|
|
8
|
-
* Run: timeout 120 npx vitest run src/main/__tests__/transcripts-batch-flush.test.cjs
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import { test, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
14
|
-
|
|
15
|
-
const fs = require('node:fs');
|
|
16
|
-
const os = require('node:os');
|
|
17
|
-
const path = require('node:path');
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
subscribe,
|
|
21
|
-
closeTab,
|
|
22
|
-
transcriptPath,
|
|
23
|
-
attachWindow,
|
|
24
|
-
__getSubForTest,
|
|
25
|
-
__doFlushForTest,
|
|
26
|
-
MAX_EVENTS_PER_BATCH,
|
|
27
|
-
} = require('../transcripts.cjs');
|
|
28
|
-
const otel = require('../otel.cjs');
|
|
29
|
-
|
|
30
|
-
let cwd;
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-batch-flush-test-'));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
fs.rmSync(cwd, { recursive: true, force: true });
|
|
38
|
-
fs.rmSync(path.dirname(transcriptPath(cwd, 'x')), { recursive: true, force: true });
|
|
39
|
-
attachWindow(null);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
function writeTranscript(cwdArg, sessionId, lines) {
|
|
43
|
-
const filePath = transcriptPath(cwdArg, sessionId);
|
|
44
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
45
|
-
fs.writeFileSync(filePath, lines.map((l) => JSON.stringify(l)).join('\n') + '\n');
|
|
46
|
-
return filePath;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function appendTranscript(filePath, lines) {
|
|
50
|
-
fs.appendFileSync(filePath, lines.map((l) => JSON.stringify(l)).join('\n') + '\n');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** A fake BrowserWindow that records every webContents.send call. */
|
|
54
|
-
function makeFakeWindow() {
|
|
55
|
-
const sent = [];
|
|
56
|
-
return {
|
|
57
|
-
sent,
|
|
58
|
-
isDestroyed: () => false,
|
|
59
|
-
webContents: {
|
|
60
|
-
isDestroyed: () => false,
|
|
61
|
-
isCrashed: () => false,
|
|
62
|
-
send: (channel, payload) => sent.push({ channel, payload }),
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function assistantLine(text, toolId) {
|
|
68
|
-
return {
|
|
69
|
-
type: 'assistant',
|
|
70
|
-
message: {
|
|
71
|
-
content: [
|
|
72
|
-
{ type: 'text', text },
|
|
73
|
-
{ type: 'tool_use', name: 'Bash', id: toolId, input: { command: 'ls' } },
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
test('one flush with several multi-event lines sends exactly ONE IPC message carrying the whole ordered batch', async () => {
|
|
80
|
-
const sessionId = 'sess-one-batch';
|
|
81
|
-
const tabId = 'tab-one-batch';
|
|
82
|
-
const filePath = writeTranscript(cwd, sessionId, []);
|
|
83
|
-
|
|
84
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
85
|
-
expect(res.ok).toBe(true);
|
|
86
|
-
|
|
87
|
-
const win = makeFakeWindow();
|
|
88
|
-
attachWindow(win);
|
|
89
|
-
|
|
90
|
-
// 5 lines * 2 events each = 10 events, well under MAX_EVENTS_PER_BATCH.
|
|
91
|
-
appendTranscript(
|
|
92
|
-
filePath,
|
|
93
|
-
Array.from({ length: 5 }, (_, i) => assistantLine(`line ${i}`, `tu-${i}`)),
|
|
94
|
-
);
|
|
95
|
-
const sub = __getSubForTest(tabId);
|
|
96
|
-
await sub.watcher?.close();
|
|
97
|
-
await __doFlushForTest(sub);
|
|
98
|
-
|
|
99
|
-
const messages = win.sent.filter((m) => m.channel === `transcript:event:${tabId}`);
|
|
100
|
-
expect(messages).toHaveLength(1);
|
|
101
|
-
expect(Array.isArray(messages[0].payload)).toBe(true);
|
|
102
|
-
expect(messages[0].payload).toHaveLength(10);
|
|
103
|
-
// Event order preserved: text/tool_use pairs in line order.
|
|
104
|
-
expect(messages[0].payload.map((e) => e.kind)).toEqual([
|
|
105
|
-
'assistant', 'tool_use', 'assistant', 'tool_use', 'assistant', 'tool_use', 'assistant', 'tool_use', 'assistant', 'tool_use',
|
|
106
|
-
]);
|
|
107
|
-
expect(messages[0].payload.map((e) => e.data?.id ?? e.data).filter(Boolean)).toEqual(
|
|
108
|
-
expect.arrayContaining(['tu-0', 'tu-1', 'tu-2', 'tu-3', 'tu-4']),
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
closeTab(tabId);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('order is preserved exactly across a multi-event flush (matches per-event order semantics)', async () => {
|
|
115
|
-
const sessionId = 'sess-order';
|
|
116
|
-
const tabId = 'tab-order';
|
|
117
|
-
const filePath = writeTranscript(cwd, sessionId, []);
|
|
118
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
119
|
-
expect(res.ok).toBe(true);
|
|
120
|
-
|
|
121
|
-
const win = makeFakeWindow();
|
|
122
|
-
attachWindow(win);
|
|
123
|
-
|
|
124
|
-
appendTranscript(filePath, [
|
|
125
|
-
{ type: 'user', message: { content: 'first' } },
|
|
126
|
-
assistantLine('second', 'tu-order-1'),
|
|
127
|
-
{ type: 'user', message: { content: 'third' } },
|
|
128
|
-
]);
|
|
129
|
-
const sub = __getSubForTest(tabId);
|
|
130
|
-
await sub.watcher?.close();
|
|
131
|
-
await __doFlushForTest(sub);
|
|
132
|
-
|
|
133
|
-
const messages = win.sent.filter((m) => m.channel === `transcript:event:${tabId}`);
|
|
134
|
-
expect(messages).toHaveLength(1);
|
|
135
|
-
const kinds = messages[0].payload.map((e) => e.kind);
|
|
136
|
-
const texts = messages[0].payload.map((e) =>
|
|
137
|
-
typeof e.data === 'string' ? e.data : e.data?.id ?? e.data?.message?.content,
|
|
138
|
-
);
|
|
139
|
-
expect(kinds).toEqual(['user', 'assistant', 'tool_use', 'user']);
|
|
140
|
-
expect(texts).toEqual(['first', 'second', 'tu-order-1', 'third']);
|
|
141
|
-
|
|
142
|
-
closeTab(tabId);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('OTEL still records ONE span per event, not one per batch', async () => {
|
|
146
|
-
const sessionId = 'sess-otel-batch';
|
|
147
|
-
const tabId = 'tab-otel-batch';
|
|
148
|
-
const filePath = writeTranscript(cwd, sessionId, []);
|
|
149
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
150
|
-
expect(res.ok).toBe(true);
|
|
151
|
-
|
|
152
|
-
const win = makeFakeWindow();
|
|
153
|
-
attachWindow(win);
|
|
154
|
-
|
|
155
|
-
const spy = vi.spyOn(otel, 'recordTranscriptEvent');
|
|
156
|
-
const before = spy.mock.calls.length;
|
|
157
|
-
|
|
158
|
-
appendTranscript(
|
|
159
|
-
filePath,
|
|
160
|
-
Array.from({ length: 6 }, (_, i) => assistantLine(`otel line ${i}`, `otel-tu-${i}`)),
|
|
161
|
-
);
|
|
162
|
-
const sub = __getSubForTest(tabId);
|
|
163
|
-
await sub.watcher?.close();
|
|
164
|
-
await __doFlushForTest(sub);
|
|
165
|
-
|
|
166
|
-
// 6 lines * 2 events = 12 spans, sent as one IPC batch.
|
|
167
|
-
expect(spy.mock.calls.length - before).toBe(12);
|
|
168
|
-
const messages = win.sent.filter((m) => m.channel === `transcript:event:${tabId}`);
|
|
169
|
-
expect(messages).toHaveLength(1);
|
|
170
|
-
expect(messages[0].payload).toHaveLength(12);
|
|
171
|
-
|
|
172
|
-
spy.mockRestore();
|
|
173
|
-
closeTab(tabId);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('backpressure: a flush producing more than MAX_EVENTS_PER_BATCH events is sent as multiple ordered, capped batches', async () => {
|
|
177
|
-
const sessionId = 'sess-backpressure';
|
|
178
|
-
const tabId = 'tab-backpressure';
|
|
179
|
-
const filePath = writeTranscript(cwd, sessionId, []);
|
|
180
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
181
|
-
expect(res.ok).toBe(true);
|
|
182
|
-
|
|
183
|
-
const win = makeFakeWindow();
|
|
184
|
-
attachWindow(win);
|
|
185
|
-
|
|
186
|
-
// Each line yields 2 events; pick a line count that produces more than
|
|
187
|
-
// 2x the cap so at least 3 batches are required.
|
|
188
|
-
const lineCount = Math.ceil((MAX_EVENTS_PER_BATCH * 2.5) / 2);
|
|
189
|
-
const totalEvents = lineCount * 2;
|
|
190
|
-
appendTranscript(
|
|
191
|
-
filePath,
|
|
192
|
-
Array.from({ length: lineCount }, (_, i) => assistantLine(`bp line ${i}`, `bp-tu-${i}`)),
|
|
193
|
-
);
|
|
194
|
-
const sub = __getSubForTest(tabId);
|
|
195
|
-
await sub.watcher?.close();
|
|
196
|
-
await __doFlushForTest(sub);
|
|
197
|
-
|
|
198
|
-
const messages = win.sent.filter((m) => m.channel === `transcript:event:${tabId}`);
|
|
199
|
-
expect(messages.length).toBeGreaterThan(1);
|
|
200
|
-
for (const m of messages) {
|
|
201
|
-
expect(m.payload.length).toBeLessThanOrEqual(MAX_EVENTS_PER_BATCH);
|
|
202
|
-
}
|
|
203
|
-
// Concatenating every batch in send order reproduces the full ordered
|
|
204
|
-
// event list — no event dropped, none duplicated, none reordered.
|
|
205
|
-
const flattened = messages.flatMap((m) => m.payload);
|
|
206
|
-
expect(flattened).toHaveLength(totalEvents);
|
|
207
|
-
const ids = flattened.map((e) => (e.kind === 'tool_use' ? e.data.id : null)).filter(Boolean);
|
|
208
|
-
expect(ids).toEqual(Array.from({ length: lineCount }, (_, i) => `bp-tu-${i}`));
|
|
209
|
-
|
|
210
|
-
closeTab(tabId);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test('benchmark: IPC message count drops from N-per-event to a small number of batches for a 20+ event flush', async () => {
|
|
214
|
-
const sessionId = 'sess-benchmark';
|
|
215
|
-
const tabId = 'tab-benchmark';
|
|
216
|
-
const filePath = writeTranscript(cwd, sessionId, []);
|
|
217
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
218
|
-
expect(res.ok).toBe(true);
|
|
219
|
-
|
|
220
|
-
const win = makeFakeWindow();
|
|
221
|
-
attachWindow(win);
|
|
222
|
-
|
|
223
|
-
// 12 lines * 2 events = 24 events — at least 20, comfortably under one cap.
|
|
224
|
-
const lineCount = 12;
|
|
225
|
-
appendTranscript(
|
|
226
|
-
filePath,
|
|
227
|
-
Array.from({ length: lineCount }, (_, i) => assistantLine(`bench line ${i}`, `bench-tu-${i}`)),
|
|
228
|
-
);
|
|
229
|
-
const sub = __getSubForTest(tabId);
|
|
230
|
-
await sub.watcher?.close();
|
|
231
|
-
await __doFlushForTest(sub);
|
|
232
|
-
|
|
233
|
-
const messages = win.sent.filter((m) => m.channel === `transcript:event:${tabId}`);
|
|
234
|
-
const totalEvents = messages.reduce((n, m) => n + m.payload.length, 0);
|
|
235
|
-
expect(totalEvents).toBeGreaterThanOrEqual(20);
|
|
236
|
-
|
|
237
|
-
// BEFORE this PRD: doFlush sent one IPC message PER EVENT, so a 24-event
|
|
238
|
-
// flush meant 24 messages and (in the renderer) 24 store commits. AFTER:
|
|
239
|
-
// one message per flush (bounded by MAX_EVENTS_PER_BATCH), so the same
|
|
240
|
-
// flush is 1 message — a >20x reduction in IPC round-trips, and the
|
|
241
|
-
// renderer's live.ts/chat.ts now fold that one message into exactly one
|
|
242
|
-
// store commit each (see live.test.ts / chatTranscriptFeed.test.ts).
|
|
243
|
-
const beforeMessageCount = totalEvents; // one send per event, historically
|
|
244
|
-
const afterMessageCount = messages.length;
|
|
245
|
-
expect(afterMessageCount).toBeLessThan(beforeMessageCount);
|
|
246
|
-
expect(afterMessageCount).toBe(1);
|
|
247
|
-
|
|
248
|
-
closeTab(tabId);
|
|
249
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* transcripts-doFlush-array.test.cjs — unit tests for transcripts.cjs's
|
|
3
|
-
* doFlush()/readDelta() handling of classifyLine's array-of-events shape.
|
|
4
|
-
*
|
|
5
|
-
* Covers: one line producing several events all land in the getBuffer()
|
|
6
|
-
* drain flattened (not nested per line), a session with far more than the
|
|
7
|
-
* old 500-entry ring cap still returns every event via the line-offset
|
|
8
|
-
* index (the cap is gone), and each event's byte `ref` correctly points
|
|
9
|
-
* back at its own line in the transcript file on disk.
|
|
10
|
-
*
|
|
11
|
-
* Run: timeout 120 npx vitest run src/main/__tests__/transcripts-doFlush-array.test.cjs
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
'use strict';
|
|
15
|
-
|
|
16
|
-
import { test, expect, beforeEach, afterEach } from 'vitest';
|
|
17
|
-
|
|
18
|
-
const fs = require('node:fs');
|
|
19
|
-
const os = require('node:os');
|
|
20
|
-
const path = require('node:path');
|
|
21
|
-
|
|
22
|
-
const { subscribe, getBuffer, closeTab, transcriptPath } = require('../transcripts.cjs');
|
|
23
|
-
|
|
24
|
-
let cwd;
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'sm-doflush-test-'));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
fs.rmSync(cwd, { recursive: true, force: true });
|
|
32
|
-
// writeTranscript mkdir -p's this run's folder under the REAL
|
|
33
|
-
// ~/.claude/projects (that's where transcriptPath resolves to), so leaving
|
|
34
|
-
// it behind accumulates one phantom project directory per test run — 1760
|
|
35
|
-
// of them had piled up before this cleanup existed, and Home counted every
|
|
36
|
-
// one as a project. Remove it with the tmp cwd it mirrors.
|
|
37
|
-
fs.rmSync(path.dirname(transcriptPath(cwd, 'x')), { recursive: true, force: true });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
function writeTranscript(cwdArg, sessionId, lines) {
|
|
41
|
-
const filePath = transcriptPath(cwdArg, sessionId);
|
|
42
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
43
|
-
fs.writeFileSync(filePath, lines.map((l) => JSON.stringify(l)).join('\n') + '\n');
|
|
44
|
-
return filePath;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
test('a single multi-block line flattens into multiple buffered events', async () => {
|
|
48
|
-
const sessionId = 'sess-multi';
|
|
49
|
-
const tabId = 'tab-multi';
|
|
50
|
-
writeTranscript(cwd, sessionId, [
|
|
51
|
-
{
|
|
52
|
-
type: 'assistant',
|
|
53
|
-
message: {
|
|
54
|
-
content: [
|
|
55
|
-
{ type: 'text', text: 'doing two things' },
|
|
56
|
-
{ type: 'tool_use', name: 'Bash', id: 'tu-1', input: { command: 'ls' } },
|
|
57
|
-
{ type: 'tool_use', name: 'Bash', id: 'tu-2', input: { command: 'pwd' } },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
62
|
-
|
|
63
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
64
|
-
expect(res.ok).toBe(true);
|
|
65
|
-
const buf = await getBuffer(tabId);
|
|
66
|
-
expect(buf).toHaveLength(3);
|
|
67
|
-
expect(buf.map((e) => e.kind)).toEqual(['assistant', 'tool_use', 'tool_use']);
|
|
68
|
-
closeTab(tabId);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('a session with far more than the old 500-entry cap still returns every event — the ring cap is gone', async () => {
|
|
72
|
-
const sessionId = 'sess-cap';
|
|
73
|
-
const tabId = 'tab-cap';
|
|
74
|
-
// 200 lines * 3 events each = 600 events > the old 500 cap.
|
|
75
|
-
const lines = Array.from({ length: 200 }, (_, i) => ({
|
|
76
|
-
type: 'assistant',
|
|
77
|
-
message: {
|
|
78
|
-
content: [
|
|
79
|
-
{ type: 'text', text: `line ${i}` },
|
|
80
|
-
{ type: 'tool_use', name: 'Bash', id: `tu-${i}-a`, input: { command: 'ls' } },
|
|
81
|
-
{ type: 'tool_use', name: 'Bash', id: `tu-${i}-b`, input: { command: 'pwd' } },
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
}));
|
|
85
|
-
writeTranscript(cwd, sessionId, lines);
|
|
86
|
-
|
|
87
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
88
|
-
expect(res.ok).toBe(true);
|
|
89
|
-
const buf = await getBuffer(tabId);
|
|
90
|
-
expect(buf).toHaveLength(600);
|
|
91
|
-
// Nothing evicted — both the genuine first and last events survive.
|
|
92
|
-
expect(buf[0].data).toBe('line 0');
|
|
93
|
-
expect(buf[buf.length - 1].data.id).toBe('tu-199-b');
|
|
94
|
-
closeTab(tabId);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('each event ref points at its own line — re-reading those bytes reproduces that exact line', async () => {
|
|
98
|
-
const sessionId = 'sess-ref';
|
|
99
|
-
const tabId = 'tab-ref';
|
|
100
|
-
const filePath = writeTranscript(cwd, sessionId, [
|
|
101
|
-
{ type: 'user', message: { content: 'first line — some unicode: héllo 🎉' } },
|
|
102
|
-
{ type: 'assistant', message: { content: 'second line' } },
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
const res = await subscribe({ tabId, cwd, sessionUuid: sessionId });
|
|
106
|
-
expect(res.ok).toBe(true);
|
|
107
|
-
const buf = await getBuffer(tabId);
|
|
108
|
-
expect(buf).toHaveLength(2);
|
|
109
|
-
|
|
110
|
-
const fd = fs.openSync(filePath, 'r');
|
|
111
|
-
try {
|
|
112
|
-
for (const ev of buf) {
|
|
113
|
-
expect(ev.ref).toBeTruthy();
|
|
114
|
-
expect(ev.ref.filePath).toBe(filePath);
|
|
115
|
-
const readBuf = Buffer.alloc(ev.ref.byteLength);
|
|
116
|
-
fs.readSync(fd, readBuf, 0, ev.ref.byteLength, ev.ref.byteOffset);
|
|
117
|
-
const parsed = JSON.parse(readBuf.toString('utf8'));
|
|
118
|
-
expect(parsed.type).toBe(ev.kind);
|
|
119
|
-
}
|
|
120
|
-
} finally {
|
|
121
|
-
fs.closeSync(fd);
|
|
122
|
-
}
|
|
123
|
-
closeTab(tabId);
|
|
124
|
-
});
|