claude-code-session-manager 0.86.0 → 0.88.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 +26 -53
- package/dist/assets/AgentLibrary-BZ6IY2g1.js +3 -0
- package/dist/assets/{DataModel-Q4jhl24R.js → DataModel-dAoGAODX.js} +1 -1
- package/dist/assets/{History-Cj2FejEo.js → History-CF157HyX.js} +2 -2
- package/dist/assets/{Hooks-CaelQI6t.js → Hooks-CCPPipBk.js} +3 -3
- package/dist/assets/{HostBilko--v7cMR8I.js → HostBilko-Dlmz2m06.js} +1 -1
- package/dist/assets/{Library-DgI9oCCZ.js → Library-BaXcboWX.js} +1 -1
- package/dist/assets/{ListDetail-DYUZN-x-.js → ListDetail-CoUCzG5S.js} +1 -1
- package/dist/assets/MarkdownEditor-DTg3JlOT.js +1 -0
- package/dist/assets/{McpServers-ypCYURh3.js → McpServers-DdjY1sA3.js} +2 -2
- package/dist/assets/{Memory-C2qYp-3M.js → Memory-BJ3Jlw0C.js} +4 -4
- package/dist/assets/{Panel-Cj2kw-Zv.js → Panel-ygRSgc41.js} +1 -1
- package/dist/assets/Permissions-m0KAnccF.js +3 -0
- package/dist/assets/{Plugins-C1Vj8_dU.js → Plugins-CJRl6B3Q.js} +2 -2
- package/dist/assets/{ProvenanceBadge-DczPNM5U.js → ProvenanceBadge-w8cnlVvW.js} +1 -1
- package/dist/assets/{SaveBar-Cd_7U6Gb.js → SaveBar-BpyPcUIk.js} +1 -1
- package/dist/assets/Scheduler-D2ppxSfy.js +14 -0
- package/dist/assets/{ScopeSwitcher-DVSyI44-.js → ScopeSwitcher-EyuIwt-j.js} +1 -1
- package/dist/assets/Settings-BHSGGFEc.js +3 -0
- package/dist/assets/{SkillReferenceGraph-CUv1_Q2c.js → SkillReferenceGraph-BNaZ2JCF.js} +1 -1
- package/dist/assets/{Skills-C_YHkAy-.js → Skills-Dl3q75QV.js} +2 -2
- package/dist/assets/{SystemPrompt-B8R7T9xn.js → SystemPrompt-Bg6F-Cyp.js} +1 -1
- package/dist/assets/{TagLibrary-dj9YHWyy.js → TagLibrary-BSutflCy.js} +1 -1
- package/dist/assets/{TiptapBody-DnSBUjHE.js → TiptapBody-CXih4xrc.js} +1 -1
- package/dist/assets/{Toggle-CjV_BJn6.js → Toggle-2qtUHhA9.js} +1 -1
- package/dist/assets/{index-CXFQIPhO.js → index-B3emy2oI.js} +583 -583
- package/dist/assets/{index-CDo9xBR9.css → index-BHTX4OTc.css} +1 -1
- package/dist/assets/settingsSchema-CdzxaqwM.js +3 -0
- package/dist/assets/{whisperWorker-Dbia1OpC.js → whisperWorker-C7ZGQwKg.js} +7 -7
- package/dist/index.html +2 -2
- package/dist/vad/ort-wasm-simd-threaded.asyncify.mjs +106 -110
- package/dist/vad/ort-wasm-simd-threaded.asyncify.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jsep.mjs +98 -98
- package/dist/vad/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.jspi.mjs +99 -102
- package/dist/vad/ort-wasm-simd-threaded.jspi.wasm +0 -0
- package/dist/vad/ort-wasm-simd-threaded.mjs +46 -46
- package/dist/vad/ort-wasm-simd-threaded.wasm +0 -0
- package/package.json +14 -17
- package/plugins/CLAUDE.md +61 -0
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +1 -1
- package/plugins/session-manager-dev/skills/ops-sweep/SKILL.md +1 -1
- package/scripts/README.md +59 -0
- package/scripts/audit-ops-hygiene.cjs +350 -0
- package/scripts/hooks/guard-destructive-git.cjs +10 -34
- package/scripts/hooks/guard-inline-implementation.cjs +14 -8
- package/scripts/hooks/guard-prd-writes.cjs +7 -36
- package/scripts/hooks/guard-self-schedule.cjs +175 -0
- package/scripts/ops-sweep.cjs +355 -0
- package/scripts/scheduler-mcp-server.cjs +35 -71
- package/src/main/__tests__/agentModelResolve.test.cjs +100 -9
- package/src/main/__tests__/bilkoHost-integration.test.cjs +3 -3
- package/src/main/__tests__/broadcastCoalescer.test.cjs +18 -0
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +6 -9
- package/src/main/__tests__/chat-exit-close-race.test.cjs +3 -3
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +4 -5
- package/src/main/__tests__/chat-queue.test.cjs +2 -2
- package/src/main/__tests__/chat-stop-signal.test.cjs +2 -2
- package/src/main/__tests__/dep-orphan-archive-health.test.cjs +77 -0
- package/src/main/__tests__/dod-batchkey.test.cjs +2 -2
- package/src/main/__tests__/dod-drain-hook.test.cjs +2 -2
- package/src/main/__tests__/dod-report.test.cjs +2 -2
- package/src/main/__tests__/dod-reverify.test.cjs +2 -2
- package/src/main/__tests__/epicMint.test.cjs +4 -4
- package/src/main/__tests__/exchanges.test.cjs +2 -2
- package/src/main/__tests__/extractJson.test.cjs +2 -2
- package/src/main/__tests__/files-reject-credentials.test.cjs +1 -1
- package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +556 -0
- package/src/main/__tests__/health-build-freshness.test.cjs +39 -0
- package/src/main/__tests__/health-delegation-chain.test.cjs +17 -2
- package/src/main/__tests__/health-queue-dispatch.test.cjs +58 -7
- package/src/main/__tests__/health-tick-liveness.test.cjs +11 -3
- package/src/main/__tests__/health-usage-poller.test.cjs +70 -23
- package/src/main/__tests__/historyRollup.test.cjs +2 -2
- package/src/main/__tests__/kg-augment.test.cjs +2 -2
- package/src/main/__tests__/mcpStatus.test.cjs +2 -2
- package/src/main/__tests__/memoryAggregate.test.cjs +1 -1
- package/src/main/__tests__/memoryStale.test.cjs +1 -1
- package/src/main/__tests__/needsReviewLedger.test.cjs +162 -0
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +28 -4
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +48 -4
- package/src/main/__tests__/prd-group-allocator.test.cjs +2 -2
- package/src/main/__tests__/prdAdminRouteParity.test.cjs +2 -0
- package/src/main/__tests__/prdAdminRoutes.test.cjs +14 -2
- package/src/main/__tests__/prdAuthoringSeed.test.cjs +39 -0
- package/src/main/__tests__/prdCreateDisposition.test.cjs +201 -0
- package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +125 -0
- package/src/main/__tests__/prdLocations.test.cjs +100 -2
- package/src/main/__tests__/prdLocationsArchived.test.cjs +50 -1
- package/src/main/__tests__/prdSetDisposition.test.cjs +222 -0
- package/src/main/__tests__/proc-role-env.test.cjs +125 -0
- package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +304 -0
- package/src/main/__tests__/procname-sm-processes.test.cjs +127 -0
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +81 -401
- package/src/main/__tests__/projectPages.test.cjs +63 -149
- package/src/main/__tests__/queue-health-verdict.test.cjs +170 -0
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +117 -20
- package/src/main/__tests__/queue-starvation-per-project.test.cjs +14 -2
- package/src/main/__tests__/queueHistory.test.cjs +65 -2
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +38 -3
- package/src/main/__tests__/reconcileTiming.test.cjs +135 -0
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +181 -0
- package/src/main/__tests__/runVerify.test.cjs +5 -5
- package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +3 -3
- package/src/main/__tests__/scheduleJobTransitions.test.cjs +103 -3
- package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +143 -0
- package/src/main/__tests__/scheduler-autofix-select.test.cjs +2 -2
- package/src/main/__tests__/scheduler-autopromote.test.cjs +2 -2
- package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +3 -5
- package/src/main/__tests__/scheduler-boot-orphans.test.cjs +79 -98
- package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +121 -0
- package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +43 -0
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +161 -0
- package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +58 -0
- package/src/main/__tests__/scheduler-epic-digest.test.cjs +3 -5
- package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +2 -2
- package/src/main/__tests__/scheduler-gate-shadow.test.cjs +119 -0
- package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +390 -0
- package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +80 -0
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +25 -18
- package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +4 -4
- package/src/main/__tests__/scheduler-job-budget.test.cjs +172 -0
- package/src/main/__tests__/scheduler-launch-failure.test.cjs +3 -5
- package/src/main/__tests__/scheduler-looks-done.test.cjs +119 -10
- package/src/main/__tests__/scheduler-manual-pause.test.cjs +118 -0
- package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +26 -3
- package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +164 -0
- package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +17 -2
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +3 -5
- package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +41 -6
- package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +62 -6
- package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +3 -5
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +182 -3
- package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +87 -0
- package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +100 -0
- package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +3 -3
- package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +4 -4
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +110 -0
- package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +168 -0
- package/src/main/__tests__/scheduler-starve-escalation.test.cjs +18 -8
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +245 -0
- package/src/main/__tests__/scheduler-supervisor-record.test.cjs +81 -0
- package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +2 -2
- package/src/main/__tests__/scheduler-tick-wedge.test.cjs +172 -0
- package/src/main/__tests__/scheduler-transient-failure.test.cjs +2 -2
- package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +51 -11
- package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +3 -5
- package/src/main/__tests__/usageSingleFlight.test.cjs +157 -0
- package/src/main/__tests__/workTypeLibrary.test.cjs +1 -1
- package/src/main/bilkoHost.cjs +16 -7
- package/src/main/build-info.json +8 -0
- package/src/main/chatRunner.cjs +12 -7
- package/src/main/config.cjs +2 -3
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +268 -52
- package/src/main/heapSnapshot.cjs +2 -2
- package/src/main/historyAggregator.cjs +6 -1
- package/src/main/index.cjs +152 -50
- package/src/main/ipcSchemas.cjs +53 -17
- package/src/main/lib/__tests__/active-sessions.test.cjs +251 -0
- package/src/main/lib/__tests__/auditLog.test.cjs +38 -0
- package/src/main/lib/__tests__/bootSelfHeal.test.cjs +107 -0
- package/src/main/lib/__tests__/buildIdentity.test.cjs +121 -0
- package/src/main/lib/__tests__/cwdClassify.test.cjs +111 -0
- package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +95 -0
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +323 -44
- package/src/main/lib/__tests__/dispatchLoop.test.cjs +63 -0
- package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +239 -0
- package/src/main/lib/__tests__/gateFixtures.json +20 -0
- package/src/main/lib/__tests__/gitWorktree.test.cjs +97 -1
- package/src/main/lib/__tests__/guardShims.test.cjs +151 -0
- package/src/main/lib/__tests__/instanceLock.test.cjs +93 -7
- package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +78 -0
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +11 -0
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +1 -1
- package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +6 -1
- package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +5 -5
- package/src/main/lib/__tests__/prdDisposition.test.cjs +224 -0
- package/src/main/lib/__tests__/procIdentity.test.cjs +119 -0
- package/src/main/lib/__tests__/procName.test.cjs +92 -0
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +67 -0
- package/src/main/lib/__tests__/reaperHelpers.test.cjs +179 -1
- package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +6 -7
- package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +37 -204
- package/src/main/lib/__tests__/schedulerPaths.test.cjs +226 -0
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +94 -0
- package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +56 -0
- package/src/main/lib/__tests__/sessionSlots.test.cjs +45 -0
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +1 -1
- package/src/main/lib/__tests__/upgradeDrain.test.cjs +130 -0
- package/src/main/lib/__tests__/usageCircuit.test.cjs +285 -0
- package/src/main/lib/__tests__/watchdog-helpers.test.cjs +375 -0
- package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +266 -0
- package/src/main/lib/activeIndexRebuild.cjs +1 -3
- package/{scripts → src/main}/lib/activeSessions.cjs +67 -89
- package/src/main/lib/adoptedRunSupervisor.cjs +136 -0
- package/src/main/lib/agentModelResolve.cjs +94 -24
- package/src/main/lib/agentPersonaSchema.cjs +2 -2
- package/src/main/lib/auditLog.cjs +30 -5
- package/src/main/lib/bootSelfHeal.cjs +88 -0
- package/src/main/lib/buildIdentity.cjs +113 -0
- package/src/main/lib/classifyPromptTicket.cjs +3 -2
- package/src/main/lib/claudeBin.cjs +37 -2
- package/src/main/lib/cleanEnv.cjs +27 -1
- package/src/main/lib/credentials.cjs +4 -2
- package/src/main/lib/cwdClassify.cjs +185 -0
- package/src/main/lib/definitionOfDone.cjs +296 -52
- package/src/main/lib/delegationReadiness.cjs +290 -225
- package/src/main/lib/dispatchLoop.cjs +40 -0
- package/src/main/lib/effectiveModelInfo.cjs +332 -0
- package/src/main/lib/ephemeralCwd.cjs +7 -28
- package/src/main/lib/epicMint.cjs +3 -3
- package/src/main/lib/gitWorktree.cjs +136 -19
- package/src/main/lib/guardShims.cjs +156 -0
- package/src/main/lib/historyRollup.cjs +6 -7
- package/src/main/lib/instanceLock.cjs +32 -5
- package/src/main/lib/jobDirtFilter.cjs +7 -2
- package/src/main/lib/jobSupervisorRecord.cjs +147 -0
- package/src/main/lib/jobWorktreeBootLive.cjs +9 -5
- package/src/main/lib/launchFailure.cjs +2 -1
- package/src/main/lib/localAdminHttp.cjs +9 -27
- package/src/main/lib/mcpToolCatalog.cjs +33 -78
- package/src/main/lib/needsReviewLedger.cjs +205 -0
- package/src/main/lib/opsErrorLog.cjs +1 -1
- package/src/main/lib/opsOwnership.cjs +27 -19
- package/src/main/lib/prdAuthoringSeed.cjs +36 -0
- package/src/main/lib/prdCreate.cjs +56 -1
- package/src/main/lib/prdDisposition.cjs +199 -0
- package/src/main/lib/prdFrontmatter.cjs +8 -2
- package/src/main/lib/prdLocations.cjs +214 -45
- package/src/main/lib/procIdentity.cjs +126 -0
- package/src/main/lib/procName.cjs +98 -0
- package/src/main/lib/projectHomeAdminRoutes.cjs +56 -327
- package/src/main/lib/projectRootResolve.cjs +1 -1
- package/src/main/lib/queueHistory.cjs +27 -8
- package/src/main/lib/queueStore.cjs +63 -38
- package/src/main/lib/quietMachineLease.cjs +19 -2
- package/src/main/lib/reaperHelpers.cjs +181 -15
- package/src/main/lib/reservationExpiry.cjs +30 -0
- package/src/main/lib/runClaudeP.cjs +4 -2
- package/src/main/lib/runLogRetention.cjs +3 -2
- package/src/main/lib/scheduleJobSchema.cjs +10 -2
- package/src/main/lib/scheduleJobTransitions.cjs +60 -0
- package/src/main/lib/schedulerBatch.cjs +27 -2
- package/src/main/lib/schedulerConfig.cjs +24 -0
- package/src/main/lib/schedulerPaths.cjs +175 -0
- package/src/main/lib/schedulerRuntimeState.cjs +59 -0
- package/src/main/lib/sessionSlots.cjs +47 -9
- package/src/main/lib/smProcNames.cjs +51 -0
- package/src/main/lib/upgradeDrain.cjs +188 -0
- package/src/main/lib/usageCircuit.cjs +206 -0
- package/{scripts → src/main}/lib/watchdogHelpers.cjs +71 -38
- package/src/main/lib/withTimeout.cjs +33 -0
- package/src/main/mcpStatus.cjs +4 -2
- package/src/main/pluginInstall.cjs +6 -2
- package/src/main/projectPages.cjs +41 -145
- package/src/main/pty.cjs +8 -1
- package/src/main/queueOps.cjs +10 -10
- package/src/main/runVerify.cjs +69 -3
- package/src/main/scheduler/prdParser.cjs +13 -0
- package/src/main/scheduler.cjs +2841 -482
- package/src/main/seedAgentPersonas.cjs +1 -1
- package/src/main/seedDevPlugin.cjs +1 -1
- package/src/main/seedSchedulerMcp.cjs +7 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/supervisor.cjs +5 -3
- package/src/main/templates/PRD_AUTHORING.md +50 -0
- package/src/main/usage.cjs +140 -58
- package/src/preload/api.d.ts +110 -65
- package/src/preload/index.cjs +12 -4
- package/src/seed/agents/project-home-builder.md +31 -48
- package/dist/assets/AgentLibrary-DTFL7y8G.js +0 -3
- package/dist/assets/MarkdownEditor-DCIubYWf.js +0 -1
- package/dist/assets/Permissions-BiYZNGYW.js +0 -3
- package/dist/assets/Scheduler-DcLBiJBq.js +0 -14
- package/dist/assets/Settings-Cv-pRyms.js +0 -3
- package/dist/assets/settingsSchema-BJVciriw.js +0 -3
- package/screenshots/.gitkeep +0 -0
- package/screenshots/README-screenshots.md +0 -13
- package/scripts/project-pages-logic/dist/logic.cjs +0 -4709
- package/scripts/render-project-pages/dist/renderer.cjs +0 -18900
- package/scripts/render-project-pages.cjs +0 -70
- package/scripts/validate-project-pages-summary.cjs +0 -62
- package/src/main/lib/projectPageSummarySchema.cjs +0 -181
- package/src/main/teams.cjs +0 -95
- package/src/main/templates/project-pages-catalog.json +0 -741
- package/src/main/templates/project-pages-default-home.html +0 -123
- package/src/main/templates/project-pages-pipeline.md +0 -417
- package/src/seed/prompts/code-review/ac-coverage-check.md +0 -8
- package/src/seed/prompts/code-review/correctness-only.md +0 -8
- package/src/seed/prompts/code-review/full-spectrum-high.md +0 -8
- package/src/seed/prompts/code-review/hallucination-check.md +0 -8
- package/src/seed/prompts/code-review/public-api-compat.md +0 -8
- package/src/seed/prompts/code-review/readability-naming.md +0 -8
- package/src/seed/prompts/debugging/bug-as-failing-test.md +0 -8
- package/src/seed/prompts/debugging/git-bisect-regression.md +0 -8
- package/src/seed/prompts/debugging/instrument-intermittent-bug.md +0 -8
- package/src/seed/prompts/debugging/localize-pipeline-failure.md +0 -8
- package/src/seed/prompts/debugging/reproduce-then-diagnose.md +0 -8
- package/src/seed/prompts/documentation/adr-from-change.md +0 -8
- package/src/seed/prompts/documentation/module-readme.md +0 -8
- package/src/seed/prompts/documentation/onboarding-plan.md +0 -8
- package/src/seed/prompts/documentation/refresh-claude-md.md +0 -8
- package/src/seed/prompts/documentation/tsdoc-public-exports.md +0 -8
- package/src/seed/prompts/git-pr/conventional-commit.md +0 -8
- package/src/seed/prompts/git-pr/draft-pr-title-body.md +0 -8
- package/src/seed/prompts/git-pr/pre-commit-safety-sweep.md +0 -8
- package/src/seed/prompts/git-pr/release-notes-block.md +0 -8
- package/src/seed/prompts/git-pr/split-large-pr.md +0 -8
- package/src/seed/prompts/performance/bundle-startup-audit.md +0 -8
- package/src/seed/prompts/performance/complexity-audit.md +0 -8
- package/src/seed/prompts/performance/cpu-profile-hot-path.md +0 -8
- package/src/seed/prompts/performance/db-query-plan-review.md +0 -8
- package/src/seed/prompts/performance/memory-leak-hunt.md +0 -8
- package/src/seed/prompts/qa/api-contract-tests.md +0 -8
- package/src/seed/prompts/qa/e2e-critical-path.md +0 -8
- package/src/seed/prompts/qa/failing-test-for-bug.md +0 -8
- package/src/seed/prompts/qa/find-missing-test-coverage.md +0 -8
- package/src/seed/prompts/qa/stabilize-flaky-test.md +0 -8
- package/src/seed/prompts/qa/tdd-red-first.md +0 -8
- package/src/seed/prompts/qa/visual-regression-review.md +0 -8
- package/src/seed/prompts/qa/wcag-axe-scan.md +0 -8
- package/src/seed/prompts/refactoring/dead-code-sweep.md +0 -8
- package/src/seed/prompts/refactoring/extract-duplicated-pattern.md +0 -8
- package/src/seed/prompts/refactoring/modernize-legacy-file.md +0 -8
- package/src/seed/prompts/refactoring/reduce-cyclomatic-complexity.md +0 -8
- package/src/seed/prompts/refactoring/tighten-module-boundaries.md +0 -8
- package/src/seed/prompts/security/authz-audit.md +0 -8
- package/src/seed/prompts/security/crypto-correctness.md +0 -8
- package/src/seed/prompts/security/cwe-top-25-hunt.md +0 -8
- package/src/seed/prompts/security/dependency-audit.md +0 -8
- package/src/seed/prompts/security/ipc-boundary-hardening.md +0 -8
- package/src/seed/prompts/security/owasp-top-10-staged-diff.md +0 -8
- package/src/seed/prompts/security/secret-credential-scan.md +0 -8
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scheduler-guard-verdict-autoresolve.test.cjs — needs_review ladder gap
|
|
3
|
+
* (2026-09-12, PRD 1181 shape).
|
|
4
|
+
*
|
|
5
|
+
* Auto-fix investigations only ever launch for FAILING runs — a job that
|
|
6
|
+
* exits 0 and gets parked by a post-run GUARD verdict (commit-guard
|
|
7
|
+
* 'silent_no_op', shared-tree-guard 'shared_tree_reverted') never has
|
|
8
|
+
* job.autoFixAttempted set, so isExhaustedAutoFix(job) is false forever and
|
|
9
|
+
* the row is invisible to the existing needs_review auto-resolve ladder —
|
|
10
|
+
* it sits in needs_review permanently, blocking every dependsOn row behind
|
|
11
|
+
* it, until a human clears it by hand. PRD 1181 proved it: exit 0, commit
|
|
12
|
+
* aff5607 landed, parked on a guard verdict, needed a human.
|
|
13
|
+
*
|
|
14
|
+
* This file covers the widened entry gate (isGuardParkedWithoutAutoFix /
|
|
15
|
+
* isEligibleForNeedsReviewAutoResolve) that admits these rows to the SAME
|
|
16
|
+
* ladder (selectExhaustedNeedsReviewTargets / applyNeedsReviewAutoResolve)
|
|
17
|
+
* the exhausted-auto-fix path already uses, keyed on landedCommit +
|
|
18
|
+
* looksDone evidence instead of a spent auto-fix attempt — and the closed
|
|
19
|
+
* set of verdicts eligible for this (GUARD_VERDICT_EVIDENCE_ELIGIBLE)
|
|
20
|
+
* excludes 'worktree_integration_failed', whose damage IS a commit (one
|
|
21
|
+
* stranded on an unmerged branch), so a landedCommit there is not evidence
|
|
22
|
+
* against the verdict.
|
|
23
|
+
*
|
|
24
|
+
* scheduler-needs-review-autoresolve.test.cjs's own suite covers the
|
|
25
|
+
* pre-existing exhausted-auto-fix ladder and must keep passing UNCHANGED —
|
|
26
|
+
* this file only adds new coverage for the second door into the same ladder.
|
|
27
|
+
*
|
|
28
|
+
* HOME is overridden to a tmp dir BEFORE requiring scheduler.cjs — same
|
|
29
|
+
* reason as scheduler-needs-review-autoresolve.test.cjs (appendAuditEvent
|
|
30
|
+
* writes under $HOME/.claude/session-manager/audit-log.jsonl).
|
|
31
|
+
*
|
|
32
|
+
* Run: timeout 120 npx vitest run src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
'use strict';
|
|
36
|
+
|
|
37
|
+
const assert = require('node:assert/strict');
|
|
38
|
+
const fs = require('node:fs');
|
|
39
|
+
const os = require('node:os');
|
|
40
|
+
const path = require('node:path');
|
|
41
|
+
|
|
42
|
+
const tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'guard-verdict-autoresolve-test-'));
|
|
43
|
+
process.env.HOME = tmpHome;
|
|
44
|
+
|
|
45
|
+
const { execFileSync } = require('node:child_process');
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
selectExhaustedNeedsReviewTargets,
|
|
49
|
+
applyNeedsReviewAutoResolve,
|
|
50
|
+
NEEDS_REVIEW_RESOLVE_CAP,
|
|
51
|
+
GUARD_VERDICT_EVIDENCE_ELIGIBLE,
|
|
52
|
+
isGuardParkedWithoutAutoFix,
|
|
53
|
+
isEligibleForNeedsReviewAutoResolve,
|
|
54
|
+
isExhaustedAutoFix,
|
|
55
|
+
reverifyNeedsReview,
|
|
56
|
+
} = require('../scheduler.cjs');
|
|
57
|
+
|
|
58
|
+
const { pickForProject } = require('../lib/schedulerBatch.cjs');
|
|
59
|
+
const { resolvePrdWriteDir } = require('../lib/prdLocations.cjs');
|
|
60
|
+
const { bustCwdCache } = require('../lib/queueStore.cjs');
|
|
61
|
+
|
|
62
|
+
const MIN_MS = 60_000;
|
|
63
|
+
const THRESHOLD_MS = 30 * MIN_MS;
|
|
64
|
+
|
|
65
|
+
function guardParkedJob(overrides = {}) {
|
|
66
|
+
return {
|
|
67
|
+
slug: '1181-guard-parked-row',
|
|
68
|
+
cwd: '/home/user/project',
|
|
69
|
+
status: 'needs_review',
|
|
70
|
+
exitCode: 0,
|
|
71
|
+
verifierVerdict: 'silent_no_op',
|
|
72
|
+
landedCommit: 'aff5607abc123',
|
|
73
|
+
statusHistory: [{ to: 'needs_review', at: new Date(Date.now() - 45 * MIN_MS).toISOString() }],
|
|
74
|
+
...overrides,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// --- enumeration: which guard verdicts are eligible ---
|
|
79
|
+
|
|
80
|
+
test('GUARD_VERDICT_EVIDENCE_ELIGIBLE contains exactly the benign guard verdicts, never worktree_integration_failed', () => {
|
|
81
|
+
assert.ok(GUARD_VERDICT_EVIDENCE_ELIGIBLE.has('silent_no_op'));
|
|
82
|
+
assert.ok(GUARD_VERDICT_EVIDENCE_ELIGIBLE.has('shared_tree_reverted'));
|
|
83
|
+
assert.equal(GUARD_VERDICT_EVIDENCE_ELIGIBLE.has('worktree_integration_failed'), false);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// reaperHelpers.resolvePidlessFailureOverride parks a pidless reap on this
|
|
87
|
+
// exact verdict when the row already carries a landedCommit — same shape as
|
|
88
|
+
// silent_no_op/shared_tree_reverted (exit never observed, no autoFixAttempted,
|
|
89
|
+
// real commit evidence), so it must share this ladder too, or a pidless-reap
|
|
90
|
+
// row stalls in needs_review with nothing to spend and nothing to exhaust —
|
|
91
|
+
// the same bug this file's other tests exist to prevent for the other two
|
|
92
|
+
// verdicts.
|
|
93
|
+
test('GUARD_VERDICT_EVIDENCE_ELIGIBLE also contains pidless_reap_with_landed_commit', () => {
|
|
94
|
+
assert.ok(GUARD_VERDICT_EVIDENCE_ELIGIBLE.has('pidless_reap_with_landed_commit'));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// --- isGuardParkedWithoutAutoFix / isEligibleForNeedsReviewAutoResolve ---
|
|
98
|
+
|
|
99
|
+
test('a guard-verdict park with no auto-fix history is guard-parked-without-autofix', () => {
|
|
100
|
+
const job = guardParkedJob();
|
|
101
|
+
assert.equal(isGuardParkedWithoutAutoFix(job), true);
|
|
102
|
+
assert.equal(isExhaustedAutoFix(job), false, 'never went through auto-fix — must not double-count as exhausted');
|
|
103
|
+
assert.equal(isEligibleForNeedsReviewAutoResolve(job), true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('a row that DID get an auto-fix investigation is left to the exhausted-auto-fix door, not this one', () => {
|
|
107
|
+
const job = guardParkedJob({ autoFixAttempted: true, autoFixOutcome: 'no-plan', autoFixRetries: 1 });
|
|
108
|
+
assert.equal(isGuardParkedWithoutAutoFix(job), false);
|
|
109
|
+
assert.equal(isExhaustedAutoFix(job), true);
|
|
110
|
+
assert.equal(isEligibleForNeedsReviewAutoResolve(job), true, 'still eligible overall, via the OTHER door');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('(c) worktree_integration_failed is never guard-parked-without-autofix, whatever evidence it carries', () => {
|
|
114
|
+
const job = guardParkedJob({ verifierVerdict: 'worktree_integration_failed' });
|
|
115
|
+
assert.equal(isGuardParkedWithoutAutoFix(job), false);
|
|
116
|
+
assert.equal(isEligibleForNeedsReviewAutoResolve(job), false);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('a needs_review row with an unrecognized verifierVerdict and no auto-fix history is not eligible', () => {
|
|
120
|
+
const job = guardParkedJob({ verifierVerdict: 'transcript_errors' });
|
|
121
|
+
assert.equal(isGuardParkedWithoutAutoFix(job), false);
|
|
122
|
+
assert.equal(isEligibleForNeedsReviewAutoResolve(job), false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// --- selectExhaustedNeedsReviewTargets: the widened selector ---
|
|
126
|
+
|
|
127
|
+
test('a fresh guard-parked row (under threshold) is not selected', () => {
|
|
128
|
+
const job = guardParkedJob({
|
|
129
|
+
statusHistory: [{ to: 'needs_review', at: new Date(Date.now() - 2 * MIN_MS).toISOString() }],
|
|
130
|
+
});
|
|
131
|
+
assert.equal(selectExhaustedNeedsReviewTargets([job], Date.now(), THRESHOLD_MS).length, 0);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('a guard-parked row past threshold, under the cap, is selected', () => {
|
|
135
|
+
const job = guardParkedJob();
|
|
136
|
+
const found = selectExhaustedNeedsReviewTargets([job], Date.now(), THRESHOLD_MS);
|
|
137
|
+
assert.equal(found.length, 1);
|
|
138
|
+
assert.equal(found[0].slug, '1181-guard-parked-row');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('(c) worktree_integration_failed is never selected, even past threshold with a landedCommit', () => {
|
|
142
|
+
const job = guardParkedJob({ verifierVerdict: 'worktree_integration_failed' });
|
|
143
|
+
assert.equal(selectExhaustedNeedsReviewTargets([job], Date.now(), THRESHOLD_MS).length, 0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// --- applyNeedsReviewAutoResolve: the three-branch policy, entered via the guard door ---
|
|
147
|
+
|
|
148
|
+
test('(a) the 1181 shape — exit 0 + guard verdict + landedCommit + looksDone — auto-completes', () => {
|
|
149
|
+
const job = guardParkedJob({
|
|
150
|
+
looksDone: { commits: ['aff5607'], paths: ['src/main/scheduler.cjs'], detectedAt: new Date().toISOString() },
|
|
151
|
+
});
|
|
152
|
+
const outcome = applyNeedsReviewAutoResolve(job);
|
|
153
|
+
assert.equal(outcome, 'completed');
|
|
154
|
+
assert.equal(job.status, 'completed');
|
|
155
|
+
assert.match(job.statusHistory.at(-1).reason, /silent_no_op/, 'the reason must name the evidence, not just "auto-resolved"');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('(b) the same shape WITHOUT looksDone does not auto-complete on the first pass — bounded requeue instead', () => {
|
|
159
|
+
const job = guardParkedJob({ exhaustedResolveAttempts: 0 });
|
|
160
|
+
assert.equal(job.looksDone, undefined);
|
|
161
|
+
const outcome = applyNeedsReviewAutoResolve(job);
|
|
162
|
+
assert.equal(outcome, 'requeued');
|
|
163
|
+
assert.equal(job.status, 'pending');
|
|
164
|
+
assert.equal(job.exhaustedResolveAttempts, 1);
|
|
165
|
+
assert.match(job.statusHistory.at(-1).reason, /silent_no_op/);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('a guard-parked row with no evidence, cap spent, auto-skips with the guard verdict named in job.error', () => {
|
|
169
|
+
const job = guardParkedJob({ exhaustedResolveAttempts: NEEDS_REVIEW_RESOLVE_CAP });
|
|
170
|
+
const outcome = applyNeedsReviewAutoResolve(job);
|
|
171
|
+
assert.equal(outcome, 'skipped');
|
|
172
|
+
assert.equal(job.status, 'skipped');
|
|
173
|
+
assert.equal(job.needsReviewAutoResolvedSkip, true);
|
|
174
|
+
assert.match(job.error, /silent_no_op/, 'a human reading the queue must see WHY, not a generic auto-resolved label');
|
|
175
|
+
assert.doesNotMatch(job.error, /exhausted auto-fix path/, 'this row never went through auto-fix — must not claim it did');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('(c) worktree_integration_failed never auto-completes on landed-commit + looksDone evidence', () => {
|
|
179
|
+
const job = guardParkedJob({
|
|
180
|
+
verifierVerdict: 'worktree_integration_failed',
|
|
181
|
+
looksDone: { commits: ['aff5607'], paths: ['src/main/scheduler.cjs'], detectedAt: new Date().toISOString() },
|
|
182
|
+
});
|
|
183
|
+
const outcome = applyNeedsReviewAutoResolve(job);
|
|
184
|
+
assert.equal(outcome, null, 'this verdict has no door into this ladder at all');
|
|
185
|
+
assert.equal(job.status, 'needs_review', 'must stay parked — its own mechanical-recovery path owns this verdict, not this ladder');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('the pre-existing exhausted-auto-fix ladder is unaffected: same branch, same cap, same audit shape', () => {
|
|
189
|
+
const job = {
|
|
190
|
+
slug: 'exhausted-row',
|
|
191
|
+
cwd: '/home/user/project',
|
|
192
|
+
status: 'needs_review',
|
|
193
|
+
autoFixAttempted: true,
|
|
194
|
+
autoFixOutcome: 'no-plan',
|
|
195
|
+
autoFixRetries: 1,
|
|
196
|
+
exhaustedResolveAttempts: 1,
|
|
197
|
+
looksDone: { commits: ['abc1234'], paths: ['src/main/scheduler.cjs'], detectedAt: new Date().toISOString() },
|
|
198
|
+
};
|
|
199
|
+
const outcome = applyNeedsReviewAutoResolve(job);
|
|
200
|
+
assert.equal(outcome, 'completed');
|
|
201
|
+
assert.match(job.statusHistory.at(-1).reason, /verifier annotation shows work landed/);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// --- (d) chain drain: a downstream dependsOn row becomes eligible once the guard-parked blocker resolves ---
|
|
205
|
+
|
|
206
|
+
test('(d) a dependsOn chain drains once a guard-parked blocker (no auto-fix, no evidence, cap spent) auto-skips', () => {
|
|
207
|
+
const now = Date.now();
|
|
208
|
+
const rowA = { slug: 'a-first', cwd: '/home/user/project', status: 'completed' };
|
|
209
|
+
const rowB = guardParkedJob({
|
|
210
|
+
slug: 'b-middle',
|
|
211
|
+
exhaustedResolveAttempts: NEEDS_REVIEW_RESOLVE_CAP,
|
|
212
|
+
dependsOn: ['a-first'],
|
|
213
|
+
});
|
|
214
|
+
const rowC = { slug: 'c-last', cwd: '/home/user/project', status: 'pending', dependsOn: ['b-middle'] };
|
|
215
|
+
const jobs = [rowA, rowB, rowC];
|
|
216
|
+
|
|
217
|
+
const before = pickForProject(jobs, new Set(), 5);
|
|
218
|
+
assert.equal(before.batch.length, 0, 'C must not be eligible while B still sits in needs_review');
|
|
219
|
+
|
|
220
|
+
const targets = selectExhaustedNeedsReviewTargets(jobs, now, THRESHOLD_MS);
|
|
221
|
+
assert.equal(targets.length, 1);
|
|
222
|
+
assert.equal(targets[0].slug, 'b-middle');
|
|
223
|
+
const outcome = applyNeedsReviewAutoResolve(rowB);
|
|
224
|
+
assert.equal(outcome, 'skipped');
|
|
225
|
+
|
|
226
|
+
const after = pickForProject(jobs, new Set(), 5);
|
|
227
|
+
assert.ok(after.batch.some((j) => j.slug === 'c-last'), 'C must become eligible once B is auto-skipped');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// --- end-to-end: reverifyNeedsReview computes looksDone for a guard-parked row ---
|
|
231
|
+
|
|
232
|
+
function git(args, cwd) {
|
|
233
|
+
return execFileSync('git', args, { cwd, encoding: 'utf8' });
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function initRepo(dir) {
|
|
237
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
238
|
+
git(['init', '-q'], dir);
|
|
239
|
+
git(['config', 'user.email', 'test@example.com'], dir);
|
|
240
|
+
git(['config', 'user.name', 'Test'], dir);
|
|
241
|
+
fs.writeFileSync(path.join(dir, 'README.md'), 'hello\n', 'utf8');
|
|
242
|
+
git(['add', '-A'], dir);
|
|
243
|
+
git(['commit', '-q', '-m', 'initial'], dir);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function commitFile(dir, relPath, content, message) {
|
|
247
|
+
const abs = path.join(dir, relPath);
|
|
248
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
249
|
+
fs.writeFileSync(abs, content);
|
|
250
|
+
git(['add', relPath], dir);
|
|
251
|
+
git(['commit', '-q', '-m', message], dir);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function registerActiveProject(cwd, slug) {
|
|
255
|
+
const slugDir = path.join(tmpHome, '.claude', 'projects', slug);
|
|
256
|
+
fs.mkdirSync(slugDir, { recursive: true });
|
|
257
|
+
fs.writeFileSync(path.join(slugDir, 'transcript.jsonl'), JSON.stringify({ cwd }) + '\n');
|
|
258
|
+
bustCwdCache();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function writeProjectQueue(cwd, jobs) {
|
|
262
|
+
const stateDir = path.join(cwd, 'session-manager-operations', 'scheduler', 'state');
|
|
263
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
264
|
+
fs.writeFileSync(path.join(stateDir, 'queue.json'), JSON.stringify({ jobs }, null, 2));
|
|
265
|
+
return path.join(stateDir, 'queue.json');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function writePrd(cwd, slug, body) {
|
|
269
|
+
const dir = resolvePrdWriteDir(cwd);
|
|
270
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
271
|
+
const text = `---\ntitle: Test PRD\ncwd: ${cwd}\nestimateMinutes: 30\n---\n${body}\n`;
|
|
272
|
+
fs.writeFileSync(path.join(dir, `${slug}.md`), text);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function wait(ms) {
|
|
276
|
+
await new Promise((r) => setTimeout(r, ms));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
test('reverifyNeedsReview computes looksDone for a guard-parked (silent_no_op) row with no auto-fix history', async () => {
|
|
280
|
+
const projectCwd = path.join(tmpHome, 'proj-guard-parked');
|
|
281
|
+
initRepo(projectCwd);
|
|
282
|
+
registerActiveProject(projectCwd, 'proj-guard-parked-slug');
|
|
283
|
+
writePrd(projectCwd, '1181-guard-parked', [
|
|
284
|
+
'# Implementation notes',
|
|
285
|
+
'Edit `src/thing.js`.',
|
|
286
|
+
].join('\n'));
|
|
287
|
+
|
|
288
|
+
const startedAt = new Date().toISOString();
|
|
289
|
+
const queuePath = writeProjectQueue(projectCwd, [
|
|
290
|
+
{
|
|
291
|
+
slug: '1181-guard-parked',
|
|
292
|
+
status: 'needs_review',
|
|
293
|
+
cwd: projectCwd,
|
|
294
|
+
runId: 'run-1181',
|
|
295
|
+
startedAt,
|
|
296
|
+
finishedAt: new Date().toISOString(),
|
|
297
|
+
exitCode: 0,
|
|
298
|
+
verifierVerdict: 'silent_no_op',
|
|
299
|
+
landedCommit: 'deadbeef',
|
|
300
|
+
error: 'commit-guard: made no commit on an already-clean tree',
|
|
301
|
+
},
|
|
302
|
+
]);
|
|
303
|
+
|
|
304
|
+
await wait(1100); // git --since has 1s resolution
|
|
305
|
+
// Must be attributable to THIS job (see attributeLandedCommits) — path
|
|
306
|
+
// overlap alone is no longer evidence. The row's own `landedCommit`
|
|
307
|
+
// ('deadbeef') is a stale/unresolvable placeholder, so this falls to the
|
|
308
|
+
// 'slug trailer' rule by naming the job's own slug in the commit message.
|
|
309
|
+
commitFile(projectCwd, 'src/thing.js', 'hello', 'the actual fix for 1181-guard-parked landed');
|
|
310
|
+
|
|
311
|
+
await reverifyNeedsReview();
|
|
312
|
+
|
|
313
|
+
const jobs = JSON.parse(fs.readFileSync(queuePath, 'utf8')).jobs;
|
|
314
|
+
assert.equal(jobs.length, 1);
|
|
315
|
+
assert.equal(jobs[0].status, 'needs_review', 'looksDone alone never auto-completes — only applyNeedsReviewAutoResolve does');
|
|
316
|
+
assert.ok(jobs[0].looksDone, 'expected a looksDone annotation computed for this guard-parked row');
|
|
317
|
+
assert.equal(jobs[0].looksDone.commits.length, 1);
|
|
318
|
+
assert.equal(jobs[0].looksDone.rule, 'slug trailer');
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test('reverifyNeedsReview never computes looksDone for a worktree_integration_failed row', async () => {
|
|
322
|
+
const projectCwd = path.join(tmpHome, 'proj-stranded-branch');
|
|
323
|
+
initRepo(projectCwd);
|
|
324
|
+
registerActiveProject(projectCwd, 'proj-stranded-branch-slug');
|
|
325
|
+
writePrd(projectCwd, '1181-stranded', [
|
|
326
|
+
'# Implementation notes',
|
|
327
|
+
'Edit `src/thing.js`.',
|
|
328
|
+
].join('\n'));
|
|
329
|
+
|
|
330
|
+
const startedAt = new Date().toISOString();
|
|
331
|
+
const queuePath = writeProjectQueue(projectCwd, [
|
|
332
|
+
{
|
|
333
|
+
slug: '1181-stranded',
|
|
334
|
+
status: 'needs_review',
|
|
335
|
+
cwd: projectCwd,
|
|
336
|
+
runId: 'run-stranded',
|
|
337
|
+
startedAt,
|
|
338
|
+
finishedAt: new Date().toISOString(),
|
|
339
|
+
exitCode: 0,
|
|
340
|
+
verifierVerdict: 'worktree_integration_failed',
|
|
341
|
+
landedCommit: 'deadbeef',
|
|
342
|
+
error: 'worktree branch integration failed',
|
|
343
|
+
},
|
|
344
|
+
]);
|
|
345
|
+
|
|
346
|
+
await wait(1100);
|
|
347
|
+
commitFile(projectCwd, 'src/thing.js', 'hello', 'unrelated later commit');
|
|
348
|
+
|
|
349
|
+
await reverifyNeedsReview();
|
|
350
|
+
|
|
351
|
+
const jobs = JSON.parse(fs.readFileSync(queuePath, 'utf8')).jobs;
|
|
352
|
+
assert.equal(jobs.length, 1);
|
|
353
|
+
assert.equal(jobs[0].looksDone, undefined, 'a stranded-branch verdict must never be treated as evidence-gatherable');
|
|
354
|
+
assert.equal(jobs[0].status, 'needs_review');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test('reverifyNeedsReview heals a stale shared_tree_reverted row (autoFixAttempted, no outcome) whose landedCommit is still an ancestor of HEAD', async () => {
|
|
358
|
+
const projectCwd = path.join(tmpHome, 'proj-stale-shared-tree');
|
|
359
|
+
initRepo(projectCwd);
|
|
360
|
+
registerActiveProject(projectCwd, 'proj-stale-shared-tree-slug');
|
|
361
|
+
writePrd(projectCwd, '1229-stale-shared-tree', '# Implementation notes\nEdit `src/thing.js`.');
|
|
362
|
+
|
|
363
|
+
const startedAt = new Date(Date.now() - 5000).toISOString();
|
|
364
|
+
await wait(1100);
|
|
365
|
+
commitFile(projectCwd, 'src/thing.js', 'job work', 'the job own commit');
|
|
366
|
+
const landed = git(['rev-parse', 'HEAD'], projectCwd).trim();
|
|
367
|
+
commitFile(projectCwd, 'docs/unrelated.md', 'human', 'human commit after the job');
|
|
368
|
+
|
|
369
|
+
const queuePath = writeProjectQueue(projectCwd, [
|
|
370
|
+
{
|
|
371
|
+
slug: '1229-stale-shared-tree',
|
|
372
|
+
status: 'needs_review',
|
|
373
|
+
cwd: projectCwd,
|
|
374
|
+
runId: 'run-1229',
|
|
375
|
+
startedAt,
|
|
376
|
+
finishedAt: new Date().toISOString(),
|
|
377
|
+
exitCode: 0,
|
|
378
|
+
verifierVerdict: 'shared_tree_reverted',
|
|
379
|
+
landedCommit: landed,
|
|
380
|
+
autoFixAttempted: true,
|
|
381
|
+
},
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
await reverifyNeedsReview();
|
|
385
|
+
|
|
386
|
+
const jobs = JSON.parse(fs.readFileSync(queuePath, 'utf8')).jobs;
|
|
387
|
+
// Healed rows are archived out of the live queue on the same pass.
|
|
388
|
+
const row = jobs.find((j) => j.slug === '1229-stale-shared-tree');
|
|
389
|
+
assert.ok(!row || row.status === 'completed', 'row must no longer be parked in needs_review');
|
|
390
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scheduler-heartbeat-payload.test.cjs — the heartbeat line carries build
|
|
3
|
+
* identity, a subsystem throw yields a `degraded: true` line, and both
|
|
4
|
+
* watchdogHelpers.heartbeatFresh and health.readFreshHeartbeat treat a
|
|
5
|
+
* degraded line as NOT fresh.
|
|
6
|
+
*
|
|
7
|
+
* Run: timeout 120 npx vitest run src/main/__tests__/scheduler-heartbeat-payload.test.cjs
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
import { test, expect, beforeEach, vi } from 'vitest';
|
|
12
|
+
const fs = require('node:fs');
|
|
13
|
+
const schedulerPaths = require('../lib/schedulerPaths.cjs');
|
|
14
|
+
const scheduler = require('../scheduler.cjs');
|
|
15
|
+
const { heartbeatFresh } = require('../lib/watchdogHelpers.cjs');
|
|
16
|
+
const { readFreshHeartbeat } = require('../health.cjs');
|
|
17
|
+
|
|
18
|
+
const HB = () => schedulerPaths.heartbeatPath();
|
|
19
|
+
const lastLine = () => JSON.parse(fs.readFileSync(HB(), 'utf8').trim().split('\n').pop());
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
fs.mkdirSync(require('node:path').dirname(HB()), { recursive: true });
|
|
23
|
+
fs.rmSync(HB(), { force: true });
|
|
24
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('healthy tick writes build {version, codeSha, builtAt} and is fresh', () => {
|
|
28
|
+
const entry = scheduler.heartbeatTick({ readQueueSync: () => ({ jobs: [], unreadable: true, paused: null }) });
|
|
29
|
+
expect(entry.degraded).toBeUndefined();
|
|
30
|
+
const line = lastLine();
|
|
31
|
+
expect(line.build).toEqual(expect.objectContaining({ version: expect.anything() }));
|
|
32
|
+
expect(Object.keys(line.build).sort()).toEqual(['builtAt', 'codeSha', 'version']);
|
|
33
|
+
expect(line.counts).toBeDefined();
|
|
34
|
+
expect(heartbeatFresh(HB())).toBe(true);
|
|
35
|
+
expect(readFreshHeartbeat(HB())).not.toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('a throwing queue read writes a degraded line with the error, never a fresh one', () => {
|
|
39
|
+
scheduler.heartbeatTick({ readQueueSync: () => { throw new Error('boom-queue'); } });
|
|
40
|
+
const line = lastLine();
|
|
41
|
+
expect(line.degraded).toBe(true);
|
|
42
|
+
expect(line.errors[0]).toEqual({ subsystem: 'queue-read-starvation-watchdog', error: 'boom-queue' });
|
|
43
|
+
expect(line.build).toBeDefined();
|
|
44
|
+
expect(line.utilization).toBeUndefined();
|
|
45
|
+
expect(heartbeatFresh(HB())).toBe(false);
|
|
46
|
+
expect(readFreshHeartbeat(HB())).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a throw in the stall detector degrades the line too', () => {
|
|
50
|
+
scheduler.heartbeatTick({ readQueueSync: () => ({ jobs: null, unreadable: true, paused: null }) });
|
|
51
|
+
const line = lastLine();
|
|
52
|
+
expect(line.degraded).toBe(true);
|
|
53
|
+
expect(line.errors.some((e) => e.subsystem === 'stall-detector' || e.subsystem === 'heartbeat-write')).toBe(true);
|
|
54
|
+
expect(heartbeatFresh(HB())).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('watchdogHelpers treats a hand-written degraded line as stale', () => {
|
|
58
|
+
fs.writeFileSync(HB(), JSON.stringify({ ts: Date.now(), degraded: true }) + '\n');
|
|
59
|
+
expect(heartbeatFresh(HB())).toBe(false);
|
|
60
|
+
fs.writeFileSync(HB(), JSON.stringify({ ts: Date.now() }) + '\n');
|
|
61
|
+
expect(heartbeatFresh(HB())).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('healthy tick carries dispatch {..., pendingDispatchable excludes blocked chains}', () => {
|
|
65
|
+
const jobs = [
|
|
66
|
+
{ slug: '1-a', cwd: '/p', status: 'failed' },
|
|
67
|
+
{ slug: '2-b', cwd: '/p', status: 'pending', dependsOn: ['1-a'] },
|
|
68
|
+
{ slug: '3-c', cwd: '/p', status: 'pending' },
|
|
69
|
+
];
|
|
70
|
+
const entry = scheduler.heartbeatTick({
|
|
71
|
+
readQueueSync: () => ({ jobs, unreadable: true, paused: null, lastRunAt: '2026-01-01T00:00:00.000Z' }),
|
|
72
|
+
});
|
|
73
|
+
expect(entry.dispatch).toEqual(expect.objectContaining({
|
|
74
|
+
lastRunAt: '2026-01-01T00:00:00.000Z', pendingDispatchable: 1, runningCount: 0, paused: false,
|
|
75
|
+
}));
|
|
76
|
+
expect(Object.keys(entry.dispatch).sort()).toEqual(
|
|
77
|
+
['drain', 'lastDispatchAttemptAt', 'lastRunAt', 'lastTickReason', 'paused', 'pendingDispatchable', 'runningCount'],
|
|
78
|
+
);
|
|
79
|
+
expect(entry.dispatch.drain).toBeNull();
|
|
80
|
+
});
|
|
@@ -18,6 +18,7 @@ import { test, expect, beforeAll, afterAll, afterEach } from 'vitest';
|
|
|
18
18
|
const fs = require('node:fs');
|
|
19
19
|
const os = require('node:os');
|
|
20
20
|
const path = require('node:path');
|
|
21
|
+
const claudeStub = require('../../../tests/helpers/claudeStub.cjs');
|
|
21
22
|
const { execFileSync } = require('node:child_process');
|
|
22
23
|
|
|
23
24
|
let tmpHome;
|
|
@@ -52,6 +53,12 @@ function registerActiveProject(cwd) {
|
|
|
52
53
|
fs.writeFileSync(path.join(slugDir, 'transcript.jsonl'), JSON.stringify({ cwd }) + '\n');
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
// Every PRD fixture below lives Epic-scoped, not in the legacy flat prds/
|
|
57
|
+
// dir: the flat dir is retired and swept into prds-archived/ by
|
|
58
|
+
// consolidateFlatPrds the moment a job is no longer pending/running, which
|
|
59
|
+
// would strand a just-completed/failed row the instant reconcile()'s
|
|
60
|
+
// auto-archive-drop path (see scheduler-reconcile-history-backfill.test.cjs)
|
|
61
|
+
// treats the now-missing PRD as "archived on purpose" and drops it.
|
|
55
62
|
function writeProjectQueue(cwd, jobs) {
|
|
56
63
|
const stateDir = path.join(cwd, 'session-manager-operations', 'scheduler', 'state');
|
|
57
64
|
fs.mkdirSync(stateDir, { recursive: true });
|
|
@@ -68,16 +75,13 @@ function writeProjectQueue(cwd, jobs) {
|
|
|
68
75
|
// which is not the scenario under test here — this must land as a genuine
|
|
69
76
|
// non-zero exit.
|
|
70
77
|
function writeKilledClaudeStub() {
|
|
71
|
-
|
|
72
|
-
const body = `
|
|
78
|
+
return claudeStub.writeClaudeStub({ body: `
|
|
73
79
|
const fs = require('fs');
|
|
74
80
|
const path = require('path');
|
|
75
81
|
fs.writeFileSync(path.join(process.cwd(), 'README.md'), 'hello\\nedited by job\\n', 'utf8');
|
|
76
82
|
fs.writeFileSync(path.join(process.cwd(), 'job-output.txt'), 'work the job produced before dying\\n', 'utf8');
|
|
77
83
|
process.exit(137);
|
|
78
|
-
|
|
79
|
-
fs.writeFileSync(stubPath, `#!${process.execPath}\n${body}\n`, { mode: 0o755 });
|
|
80
|
-
return stubPath;
|
|
84
|
+
` });
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
beforeAll(() => {
|
|
@@ -117,7 +121,7 @@ test('an in-place job killed (exit 137) mid-run salvages a delta-scoped patch th
|
|
|
117
121
|
fs.appendFileSync(path.join(projectCwd, 'human-wip.txt'), 'more human edits\n', 'utf8');
|
|
118
122
|
|
|
119
123
|
const slug = `1098-test-inplace-killed-${process.pid}-${Math.floor(Math.random() * 1e6)}`;
|
|
120
|
-
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'prds');
|
|
124
|
+
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'epics', 'test-fixture-epic', 'prds');
|
|
121
125
|
fs.mkdirSync(prdsDir, { recursive: true });
|
|
122
126
|
fs.writeFileSync(path.join(prdsDir, `${slug}.md`), 'Do a thing that gets killed mid-run.', 'utf8');
|
|
123
127
|
|
|
@@ -192,13 +196,10 @@ test('an in-place job killed (exit 137) mid-run salvages a delta-scoped patch th
|
|
|
192
196
|
// — a job whose only working-tree dirt is pre-existing human/sibling WIP
|
|
193
197
|
// present before the run even started.
|
|
194
198
|
function writeNoopClaudeStub() {
|
|
195
|
-
|
|
196
|
-
const body = `
|
|
199
|
+
return claudeStub.writeClaudeStub({ body: `
|
|
197
200
|
process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', result: 'nothing to do', is_error: false }) + '\\n');
|
|
198
201
|
process.exit(0);
|
|
199
|
-
|
|
200
|
-
fs.writeFileSync(stubPath, `#!${process.execPath}\n${body}\n`, { mode: 0o755 });
|
|
201
|
-
return stubPath;
|
|
202
|
+
` });
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
// Stub `claude` binary that blocks until a `go` marker file appears in its
|
|
@@ -206,11 +207,19 @@ function writeNoopClaudeStub() {
|
|
|
206
207
|
// window to read the queue row's intermediate dispatchPhase before the run
|
|
207
208
|
// finalizes and deletes it.
|
|
208
209
|
function writeGatedClaudeStub() {
|
|
209
|
-
|
|
210
|
-
const body = `
|
|
210
|
+
return claudeStub.writeClaudeStub({ body: `
|
|
211
211
|
const fs = require('fs');
|
|
212
212
|
const path = require('path');
|
|
213
213
|
const { execFileSync } = require('child_process');
|
|
214
|
+
// spawnJob's dispatch path probes 'claude --version' (claudeBin.cjs)
|
|
215
|
+
// BEFORE the real dispatch — a real claude binary answers that
|
|
216
|
+
// near-instantly regardless of any in-flight work, so the stub must
|
|
217
|
+
// too, or the probe's own 8s exec timeout eats almost this whole test's
|
|
218
|
+
// poll window before the row ever advances past 'running-stamped'.
|
|
219
|
+
if (process.argv.includes('--version')) {
|
|
220
|
+
process.stdout.write('1.0.0 (stub)\\n');
|
|
221
|
+
process.exit(0);
|
|
222
|
+
}
|
|
214
223
|
const goFile = path.join(process.cwd(), 'go.marker');
|
|
215
224
|
const deadline = Date.now() + 10_000;
|
|
216
225
|
while (!fs.existsSync(goFile) && Date.now() < deadline) {
|
|
@@ -218,9 +227,7 @@ function writeGatedClaudeStub() {
|
|
|
218
227
|
}
|
|
219
228
|
process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', result: 'ok', is_error: false }) + '\\n');
|
|
220
229
|
process.exit(0);
|
|
221
|
-
|
|
222
|
-
fs.writeFileSync(stubPath, `#!${process.execPath}\n${body}\n`, { mode: 0o755 });
|
|
223
|
-
return stubPath;
|
|
230
|
+
` });
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
test('dispatchPhase breadcrumb advances to "spawned" mid-run and is gone after finalize', async () => {
|
|
@@ -229,7 +236,7 @@ test('dispatchPhase breadcrumb advances to "spawned" mid-run and is gone after f
|
|
|
229
236
|
registerActiveProject(projectCwd);
|
|
230
237
|
|
|
231
238
|
const slug = `1163-test-dispatchphase-${process.pid}-${Math.floor(Math.random() * 1e6)}`;
|
|
232
|
-
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'prds');
|
|
239
|
+
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'epics', 'test-fixture-epic', 'prds');
|
|
233
240
|
fs.mkdirSync(prdsDir, { recursive: true });
|
|
234
241
|
fs.writeFileSync(path.join(prdsDir, `${slug}.md`), 'Do a thing, gated on a marker file.', 'utf8');
|
|
235
242
|
|
|
@@ -285,7 +292,7 @@ test('a job whose tree is dirty only from pre-existing baseline WIP (human/sibli
|
|
|
285
292
|
fs.writeFileSync(path.join(projectCwd, 'human-wip.txt'), 'human work in progress\n', 'utf8');
|
|
286
293
|
|
|
287
294
|
const slug = `1098-test-inplace-noop-${process.pid}-${Math.floor(Math.random() * 1e6)}`;
|
|
288
|
-
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'prds');
|
|
295
|
+
const prdsDir = path.join(projectCwd, 'session-manager-operations', 'scheduler', 'epics', 'test-fixture-epic', 'prds');
|
|
289
296
|
fs.mkdirSync(prdsDir, { recursive: true });
|
|
290
297
|
fs.writeFileSync(path.join(prdsDir, `${slug}.md`), 'Do nothing.', 'utf8');
|
|
291
298
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* scheduler-investigation-prompt.test.cjs — unit tests for buildInvestigationPrompt.
|
|
3
3
|
*
|
|
4
|
-
* Run: timeout
|
|
4
|
+
* Run: timeout 300 npx vitest run src/main/__tests__/scheduler-investigation-prompt.test.cjs
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import { test } from 'vitest';
|
|
10
10
|
const assert = require('node:assert/strict');
|
|
11
11
|
const fs = require('node:fs');
|
|
12
12
|
const os = require('node:os');
|
|
@@ -93,7 +93,7 @@ test('prompt instructs that cwd must be the git repo root where the fix will lan
|
|
|
93
93
|
assert.match(prompt, /needs_review/);
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
test('prompt frontmatter block still declares exactly the
|
|
96
|
+
test('prompt frontmatter block still declares exactly the five expected keys', () => {
|
|
97
97
|
const prompt = buildInvestigationPrompt(makeArgs());
|
|
98
98
|
const fenceMatch = prompt.match(/```\s*\n\s*---\n([\s\S]*?)\n\s*---\n\s*```/);
|
|
99
99
|
assert.ok(fenceMatch, 'expected a fenced frontmatter block in the prompt');
|
|
@@ -101,7 +101,7 @@ test('prompt frontmatter block still declares exactly the four expected keys', (
|
|
|
101
101
|
.split('\n')
|
|
102
102
|
.filter((line) => line.trim().length > 0)
|
|
103
103
|
.map((line) => line.split(':')[0].trim());
|
|
104
|
-
assert.deepEqual(keys, ['title', 'cwd', 'parallelGroup', 'estimateMinutes']);
|
|
104
|
+
assert.deepEqual(keys, ['title', 'cwd', 'parallelGroup', 'estimateMinutes', 'isFixPlan']);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
// ─── isGitRepoSync (scheduler.cjs) ─────────────────────────────────────────────
|