claude-code-session-manager 0.140.0 → 0.142.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 +80 -70
- package/bin/cli.cjs +11 -0
- package/dist/assets/AppSettings-BcZgIvvY.js +2 -0
- package/dist/assets/{History--JwsFnbn.js → History-DpZuJXi1.js} +1 -1
- package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +3 -0
- package/dist/assets/{Panel-CALyU0pe.js → Panel-BjdJjhqt.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-sdlA-fUb.js → ProjectClaudeConfig-BTClYV6i.js} +7 -7
- package/dist/assets/Scheduler-DPobKx1Z.js +16 -0
- package/dist/assets/{SkillReferenceGraph-CxAuwhNN.js → SkillReferenceGraph-Cqyu4mef.js} +1 -1
- package/dist/assets/{Skills-DtRzghn5.js → Skills-vv0noNVI.js} +5 -5
- package/dist/assets/{TiptapBody-DApeu7x8.js → TiptapBody-CXi8Pvut.js} +1 -1
- package/dist/assets/Toggle-CiYCWLjh.js +1 -0
- package/dist/assets/{VoiceButton-DtStfv1H.js → VoiceButton-4NKKd1sC.js} +1 -1
- package/dist/assets/{historyTotals-ydfnwepc.js → historyTotals-DDunb8Ch.js} +1 -1
- package/dist/assets/index-Cn5E9958.js +3133 -0
- package/dist/assets/{index-DKXdXfka.css → index-DVHIHoJf.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +496 -484
- package/package.json +4 -2
- package/plugins/AGENTS.md +4 -3
- package/plugins/session-manager-dev/hooks/hooks.json +15 -0
- package/plugins/session-manager-dev/hooks/residue-check.cjs +241 -0
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +55 -18
- package/plugins/session-manager-dev/skills/develop/standards.md +3 -2
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +5 -1
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +158 -1
- package/scripts/scheduler-mcp-server.cjs +737 -110
- package/src/main/adminRouteRegistry.cjs +59 -0
- package/src/main/agentLibrary.cjs +72 -4
- package/src/main/agentsIpc.cjs +3 -2
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +231 -16
- package/src/main/config.cjs +30 -0
- package/src/main/docEdit.cjs +4 -2
- package/src/main/health.cjs +91 -0
- package/src/main/index.cjs +98 -48
- package/src/main/ipcSchemas.cjs +171 -8
- package/src/main/lib/AGENTS.md +1 -1
- package/src/main/lib/chatBootRecovery.cjs +2 -0
- package/src/main/lib/claude/agentModelResolve.cjs +51 -25
- package/src/main/lib/claude/agentSnapshot.cjs +186 -0
- package/src/main/lib/claude/environmentProfiles.cjs +242 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +241 -33
- package/src/main/lib/claude/personaToolScope.cjs +82 -31
- package/src/main/lib/claude/runClaudeP.cjs +4 -2
- package/src/main/lib/claude/toolRiskMarks.cjs +41 -1
- package/src/main/lib/claude/usageCircuit.cjs +49 -21
- package/src/main/lib/claude/vaultRefs.cjs +277 -0
- package/src/main/lib/demo-video-kit/capture.cjs +282 -12
- package/src/main/lib/demo-video-kit/cast.md +43 -0
- package/src/main/lib/demo-video-kit/character.cjs +722 -30
- package/src/main/lib/demo-video-kit/checks.cjs +120 -1
- package/src/main/lib/demo-video-kit/export.cjs +218 -0
- package/src/main/lib/demo-video-kit/frames.cjs +104 -9
- package/src/main/lib/demo-video-kit/kind-marketing.md +121 -0
- package/src/main/lib/demo-video-kit/kind-tiktok.md +99 -0
- package/src/main/lib/demo-video-kit/kokoroSay.cjs +205 -0
- package/src/main/lib/demo-video-kit/project-home-html.md +43 -0
- package/src/main/lib/demo-video-kit/resumableRun.cjs +298 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
- package/src/main/lib/demo-video-kit/voiceLane.cjs +233 -0
- package/src/main/lib/demo-video-kit/voiceLibrary.cjs +312 -0
- package/src/main/lib/epic/artifactAdminRoutes.cjs +211 -0
- package/src/main/lib/epic/artifactIpc.cjs +153 -0
- package/src/main/lib/epic/artifactNotice.cjs +72 -0
- package/src/main/lib/epic/artifactRetention.cjs +310 -0
- package/src/main/lib/epic/artifactStore.cjs +392 -0
- package/src/main/lib/epic/delegationReadiness.cjs +76 -2
- package/src/main/lib/epic/epicAgentRefresh.cjs +97 -0
- package/src/main/lib/epic/epicEventLog.cjs +214 -0
- package/src/main/lib/epic/epicMint.cjs +43 -1
- package/src/main/lib/epic/epicOutsideRead.cjs +1 -0
- package/src/main/lib/epic/epicOutsideState.cjs +18 -4
- package/src/main/lib/epic/epicPurge.cjs +347 -0
- package/src/main/lib/epic/epicReopen.cjs +5 -2
- package/src/main/lib/epic/epicSettle.cjs +4 -13
- package/src/main/lib/epic/epicSpawnPlan.cjs +57 -4
- package/src/main/lib/epic/epicStatusMirror.cjs +34 -1
- package/src/main/lib/epic/epicTransitions.cjs +139 -0
- package/src/main/lib/epic/epicValidationHook.cjs +81 -2
- package/src/main/lib/epic/guardSpawnSettings.cjs +3 -2
- package/src/main/lib/externalContract.cjs +37 -4
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +389 -126
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -3
- package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +11 -6
- package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +26 -1
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +5 -2
- package/src/main/lib/feedback-remote/feedbackBoxDrain.cjs +409 -0
- package/src/main/lib/feedback-remote/feedbackBoxKeys.cjs +218 -0
- package/src/main/lib/feedback-remote/feedbackEnvelope.cjs +163 -0
- package/src/main/lib/feedback-remote/feedbackRelayClient.cjs +164 -0
- package/src/main/lib/feedback-remote/feedbackReport.cjs +234 -0
- package/src/main/lib/feedback-remote/feedbackSeal.cjs +217 -0
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +108 -2
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +2 -1
- package/src/main/lib/feedback-remote/needsYouIpc.cjs +17 -0
- package/src/main/lib/feedback-remote/needsYouStore.cjs +177 -6
- package/src/main/lib/feedback-remote/pendingReplies.cjs +189 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +188 -10
- package/src/main/lib/feedback-remote/serviceClient.cjs +429 -0
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +252 -0
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +284 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +313 -0
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +290 -0
- package/src/main/lib/feedback-remote/siteFeedbackAdminRoutes.cjs +295 -0
- package/src/main/lib/feedback-remote/siteFeedbackInbox.cjs +598 -0
- package/src/main/lib/feedback-remote/siteFeedbackIpc.cjs +86 -0
- package/src/main/lib/feedback-remote/siteFeedbackService.cjs +477 -0
- package/src/main/lib/git/worktreeDeps.cjs +77 -2
- package/src/main/lib/mcpToolCatalog.cjs +315 -30
- package/src/main/lib/opsOwnership.cjs +29 -1
- package/src/main/lib/opsRetentionSettings.cjs +27 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +7 -2
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +52 -8
- package/src/main/lib/persona-macro/macroJobIpc.cjs +16 -6
- package/src/main/lib/persona-macro/macroLibrary.cjs +49 -7
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +83 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +3 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +263 -0
- package/src/main/lib/phaseProjection.cjs +103 -0
- package/src/main/lib/prd/depSlugResolve.cjs +4 -13
- package/src/main/lib/prd/prdBodyPatch.cjs +12 -17
- package/src/main/lib/prd/prdCreate.cjs +67 -5
- package/src/main/lib/prd/prdCriteria.cjs +225 -0
- package/src/main/lib/prd/prdFrontmatter.cjs +68 -3
- package/src/main/lib/prd/prdGateFiles.cjs +125 -49
- package/src/main/lib/prd/prdSizing.cjs +3 -1
- package/src/main/lib/process/cleanEnv.cjs +52 -1
- package/src/main/lib/process/leftoverRenice.cjs +178 -0
- package/src/main/lib/process/memoryScope.cjs +31 -3
- package/src/main/lib/project-pages/pagesLibrary.cjs +72 -6
- package/src/main/lib/project-pages/videoReviewIpc.cjs +3 -2
- package/src/main/lib/project-pages/voiceAdminRoutes.cjs +175 -0
- package/src/main/lib/project-pages/voicePreview.cjs +196 -0
- package/src/main/lib/project-pages/voicesIpc.cjs +186 -0
- package/src/main/lib/promptSessionSchema.cjs +6 -0
- package/src/main/lib/scheduler/cancelledRow.cjs +57 -0
- package/src/main/lib/scheduler/cpuSample.cjs +133 -42
- package/src/main/lib/scheduler/criteriaChecks.cjs +169 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +44 -5
- package/src/main/lib/scheduler/jobMemoryStats.cjs +313 -0
- package/src/main/lib/scheduler/loadGate.cjs +82 -4
- package/src/main/lib/scheduler/planRecordHarvest.cjs +32 -2
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +133 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +42 -1
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +5 -0
- package/src/main/lib/scheduler/scheduleJobTransitions.cjs +47 -0
- package/src/main/lib/scheduler/schedulerConfig.cjs +47 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +0 -3
- package/src/main/lib/scheduler/schedulerRuntimeState.cjs +50 -1
- package/src/main/lib/scheduler/sessionSlots.cjs +5 -1
- package/src/main/lib/scheduler/slotsRoute.cjs +237 -0
- package/src/main/lib/scheduler/toolClearance.cjs +258 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +140 -10
- package/src/main/lib/tasks/memoryConsolidation.cjs +300 -0
- package/src/main/lib/tasks/mitigationReview.cjs +294 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +312 -22
- package/src/main/lib/tasks/taskIpc.cjs +22 -18
- package/src/main/lib/tasks/taskLedger.cjs +147 -25
- package/src/main/lib/tasks/taskRun.cjs +186 -17
- package/src/main/lib/tasks/taskSwitch.cjs +85 -12
- package/src/main/lib/tasks/taskSwitchRoute.cjs +172 -0
- package/src/main/lib/telemetry/auditEvents.cjs +207 -6
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +198 -6
- package/src/main/lib/telemetry/webhookDelivery.cjs +205 -0
- package/src/main/lib/telemetry/webhookRegistry.cjs +281 -0
- package/src/main/lib/toolUseClassify.cjs +181 -0
- package/src/main/lib/util/smfileRange.cjs +77 -0
- package/src/main/projectPages.cjs +3 -1
- package/src/main/promptSessionEvents.cjs +5 -0
- package/src/main/pty.cjs +68 -0
- package/src/main/queueOps.cjs +32 -13
- package/src/main/runVerify.cjs +74 -9
- package/src/main/scheduler/AGENTS.md +1 -0
- package/src/main/scheduler/budget.cjs +6 -5
- package/src/main/scheduler/prdParser.cjs +62 -14
- package/src/main/scheduler/reviewLadder.cjs +45 -28
- package/src/main/scheduler/starvation.cjs +69 -0
- package/src/main/scheduler/utilizationHold.cjs +101 -0
- package/src/main/scheduler.cjs +1745 -210
- package/src/main/templates/PRD_AUTHORING.md +13 -2
- package/src/main/webRemote.cjs +463 -6
- package/src/preload/api.d.ts +529 -38
- package/src/preload/apiSurface.json +209 -7
- package/src/preload/index.cjs +46 -1
- package/src/seed/agents/architect.md +6 -1
- package/src/seed/agents/blender-artist.md +2 -1
- package/src/seed/agents/competitive-analyst.md +3 -1
- package/src/seed/agents/competitive-researcher.md +2 -1
- package/src/seed/agents/demo-video-builder.md +87 -83
- package/src/seed/agents/dev-lead.md +3 -3
- package/src/seed/agents/project-home-builder.md +9 -31
- package/src/seed/agents/validator.md +9 -10
- package/dist/assets/AppSettings-CMFEM68R.js +0 -2
- package/dist/assets/HomeClaudeConfig-ijEXs--3.js +0 -3
- package/dist/assets/Scheduler-YT3j8SUa.js +0 -16
- package/dist/assets/ViewTabs-B7qLXRAH.js +0 -1
- package/dist/assets/index-CtxruO1L.js +0 -3121
- package/src/main/lib/epic/epicStateWatcher.cjs +0 -157
|
@@ -14,6 +14,8 @@ const { COMPLETED_EQUIVALENT_VERDICTS } = require('../lib/scheduler/terminalRunO
|
|
|
14
14
|
const { resolveIsFixPlan } = require('../lib/scheduler/fixPlanSlug.cjs');
|
|
15
15
|
const { GATE_AUTHORITY_VERDICTS } = require('../lib/scheduler/gateAuthority.cjs');
|
|
16
16
|
const { DEFAULT_PROJECT_CWD } = require('../lib/scheduler/schedulerBatch.cjs');
|
|
17
|
+
// Every automated selector skips a human-cancelled row (incident 2026-10-19 git-viewer: cancelled rows re-queued and merged).
|
|
18
|
+
const { isCancelledRow } = require('../lib/scheduler/cancelledRow.cjs');
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Resume-first recovery (PRD 1111). A job parked in needs_review with verdict
|
|
@@ -217,7 +219,7 @@ function isFinishReviewKillHealEligible(job) {
|
|
|
217
219
|
if (typeof job.landedCommit !== 'string' || job.landedCommit.length === 0) return false;
|
|
218
220
|
if (job.finishReviewHealAttemptedAt) return false;
|
|
219
221
|
if (job.integrationFailureKind) return false;
|
|
220
|
-
if (
|
|
222
|
+
if (isCancelledRow(job) || isRefireCapped(job)) return false;
|
|
221
223
|
return true;
|
|
222
224
|
}
|
|
223
225
|
|
|
@@ -441,13 +443,29 @@ function isStrandedAutoFixPark(job, jobsInProject) {
|
|
|
441
443
|
return !liveOrQueuedChild;
|
|
442
444
|
}
|
|
443
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Pure predicate, no I/O: a needs_review row that is itself a fix plan
|
|
448
|
+
* (resolveIsFixPlan — persisted isFixPlan stamp, else the slug heuristic)
|
|
449
|
+
* and never went through auto-fix. selectAutoFixTargets excludes fix plans
|
|
450
|
+
* (no recursion), so autoFixAttempted is never set and none of the other
|
|
451
|
+
* doors admit it — rung 6 never runs and its dependsOn chain waits forever
|
|
452
|
+
* (starry-night-2 852-fix-ios-asc-profile, sentinel_fail, 2026-11-22).
|
|
453
|
+
* Exported for tests.
|
|
454
|
+
*/
|
|
455
|
+
function isFixPlanParkWithoutAutoFix(job) {
|
|
456
|
+
if (!job || job.status !== 'needs_review') return false;
|
|
457
|
+
if (job.autoFixAttempted === true) return false;
|
|
458
|
+
return resolveIsFixPlan(job.slug, job.isFixPlan);
|
|
459
|
+
}
|
|
460
|
+
|
|
444
461
|
/**
|
|
445
462
|
* Pure predicate, no I/O: is this needs_review row eligible for the bounded
|
|
446
463
|
* auto-resolve ladder at all — either because its auto-fix path is genuinely
|
|
447
464
|
* spent (isExhaustedAutoFix), because it was parked by a GUARD verdict that
|
|
448
465
|
* never entered auto-fix in the first place (isGuardParkedWithoutAutoFix),
|
|
449
|
-
*
|
|
450
|
-
* recording any outcome (isStrandedAutoFixPark)
|
|
466
|
+
* because its auto-fix investigation ran but was stranded before
|
|
467
|
+
* recording any outcome (isStrandedAutoFixPark), or because it is a fix plan
|
|
468
|
+
* that auto-fix never admits (isFixPlanParkWithoutAutoFix). All four classes share ONE
|
|
451
469
|
* ladder (applyNeedsReviewAutoResolve) rather than a duplicated one — the
|
|
452
470
|
* ladder itself doesn't care which door a row came through, only whether it
|
|
453
471
|
* now carries completion evidence (job.looksDone). `jobsInProject` is only
|
|
@@ -457,7 +475,10 @@ function isStrandedAutoFixPark(job, jobsInProject) {
|
|
|
457
475
|
*/
|
|
458
476
|
function isEligibleForNeedsReviewAutoResolve(job, jobsInProject = []) {
|
|
459
477
|
if (isRefireCapped(job)) return false;
|
|
460
|
-
return isExhaustedAutoFix(job)
|
|
478
|
+
return isExhaustedAutoFix(job)
|
|
479
|
+
|| isGuardParkedWithoutAutoFix(job)
|
|
480
|
+
|| isStrandedAutoFixPark(job, jobsInProject)
|
|
481
|
+
|| isFixPlanParkWithoutAutoFix(job);
|
|
461
482
|
}
|
|
462
483
|
|
|
463
484
|
/**
|
|
@@ -495,9 +516,21 @@ function isFixPlanDead(job, jobsInProject) {
|
|
|
495
516
|
const fixSlug = fixSlugFor(job);
|
|
496
517
|
const child = (jobsInProject || []).find((j) => j.slug === fixSlug);
|
|
497
518
|
if (!child) return false;
|
|
519
|
+
// A child waiting on its own red preflight is not dead: the precondition,
|
|
520
|
+
// not the plan, is the blocker — reopening it would spend a probe for nothing.
|
|
521
|
+
if (hasActivePreflightHold(child)) return false;
|
|
498
522
|
return DEAD_FIX_CHILD_STATUSES.has(child.status);
|
|
499
523
|
}
|
|
500
524
|
|
|
525
|
+
/**
|
|
526
|
+
* Pure predicate: the row is waiting on its own red `preflight` (a
|
|
527
|
+
* preflightHold is armed). Such a row spends nothing on the model ladder —
|
|
528
|
+
* no investigation probe, no dead-fix-plan reopen. Exported for tests.
|
|
529
|
+
*/
|
|
530
|
+
function hasActivePreflightHold(job) {
|
|
531
|
+
return !!(job && job.preflightHold && typeof job.preflightHold === 'object');
|
|
532
|
+
}
|
|
533
|
+
|
|
501
534
|
/**
|
|
502
535
|
* Pure predicate: is this job eligible for the boot re-verify self-heal? Only
|
|
503
536
|
* needs_review jobs with a run log (own or backfilled via resolveRunId) AND a
|
|
@@ -565,23 +598,6 @@ function healRefusalReason(job, verdict, committedDuringRun) {
|
|
|
565
598
|
* gate or a real non-zero-exit error) is excluded — that failure is
|
|
566
599
|
* evidence, not silence, and must never become a heal candidate (PRD 1102).
|
|
567
600
|
*/
|
|
568
|
-
// A human cancelled this row (scheduler_cancel_job). Incident 2026-10-19
|
|
569
|
-
// (git-viewer): cancelled jobs were parked as 'failed' (source
|
|
570
|
-
// 'remote:cancelJob'), then selectFailedAutoResetTargets re-queued them 10
|
|
571
|
-
// minutes later and they ran and merged unwanted commits. Marker is
|
|
572
|
-
// `cancelledAt`; the statusHistory source is the fallback for rows cancelled
|
|
573
|
-
// before the marker existed. Every automated selector must skip these; only a
|
|
574
|
-
// human scheduler_reset_job revives one.
|
|
575
|
-
function isCancelledJob(job) {
|
|
576
|
-
if (!job) return false;
|
|
577
|
-
if (typeof job.cancelledAt === 'string' && job.cancelledAt) return true;
|
|
578
|
-
const history = Array.isArray(job.statusHistory) ? job.statusHistory : [];
|
|
579
|
-
for (let i = history.length - 1; i >= 0; i--) {
|
|
580
|
-
if (history[i] && history[i].to === job.status) return history[i].source === 'remote:cancelJob';
|
|
581
|
-
}
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
601
|
function isFailedUnverifiedShaped(job) {
|
|
586
602
|
if (!job || job.status !== 'failed') return false;
|
|
587
603
|
if (job.verifierVerdict && RESCANNABLE_VERDICTS.has(job.verifierVerdict)) return true;
|
|
@@ -592,7 +608,7 @@ function isFailedUnverifiedShaped(job) {
|
|
|
592
608
|
}
|
|
593
609
|
|
|
594
610
|
function isRescanCandidate(job) {
|
|
595
|
-
if (!job ||
|
|
611
|
+
if (!job || isCancelledRow(job) || isRefireCapped(job)) return false;
|
|
596
612
|
// Default-ELIGIBLE: every needs_review row is a heal candidate unless its
|
|
597
613
|
// verdict is in RESCAN_EXCLUDED_VERDICTS. No runId requirement here — a row
|
|
598
614
|
// without one still gets the evidence rung and the unresolvable annotation.
|
|
@@ -624,7 +640,7 @@ function isTranscriptRescannable(job) {
|
|
|
624
640
|
function selectEvidenceScanTargets(jobs, now = Date.now()) {
|
|
625
641
|
const due = [];
|
|
626
642
|
for (const j of jobs ?? []) {
|
|
627
|
-
if (
|
|
643
|
+
if (isCancelledRow(j)) continue;
|
|
628
644
|
if (j.status !== 'needs_review' || !isRescanCandidate(j)) continue;
|
|
629
645
|
if (isTranscriptRescannable(j)) continue;
|
|
630
646
|
if (j.looksDone) continue;
|
|
@@ -754,7 +770,7 @@ function failedAutoResetDisabled() {
|
|
|
754
770
|
function selectFailedAutoResetTargets(jobs, now, thresholdMs) {
|
|
755
771
|
const targets = [];
|
|
756
772
|
for (const j of jobs ?? []) {
|
|
757
|
-
if (
|
|
773
|
+
if (isCancelledRow(j)) continue;
|
|
758
774
|
if (j.status !== 'failed') continue;
|
|
759
775
|
const attempts = j.failedAutoResetAttempts ?? 0;
|
|
760
776
|
if (attempts >= FAILED_AUTORESET_CAP) continue;
|
|
@@ -806,7 +822,7 @@ function selectFailedAutoResetTargets(jobs, now, thresholdMs) {
|
|
|
806
822
|
function findStuckFailedJobs(jobs, now, thresholdMs) {
|
|
807
823
|
const stuck = [];
|
|
808
824
|
for (const j of jobs ?? []) {
|
|
809
|
-
if (
|
|
825
|
+
if (isCancelledRow(j)) continue;
|
|
810
826
|
if (j.status !== 'failed') continue;
|
|
811
827
|
if (j.stuckFailedNotified === true) continue;
|
|
812
828
|
if (!isRescanCandidate(j)) continue;
|
|
@@ -875,7 +891,7 @@ function needsReviewAutoResolveDisabled() {
|
|
|
875
891
|
function selectExhaustedNeedsReviewTargets(jobs, now, thresholdMs) {
|
|
876
892
|
const targets = [];
|
|
877
893
|
for (const j of jobs ?? []) {
|
|
878
|
-
if (
|
|
894
|
+
if (isCancelledRow(j)) continue;
|
|
879
895
|
if (j.status !== 'needs_review') continue;
|
|
880
896
|
if (!isEligibleForNeedsReviewAutoResolve(j, jobs)) continue;
|
|
881
897
|
if ((j.exhaustedResolveAttempts ?? 0) > NEEDS_REVIEW_RESOLVE_CAP) continue;
|
|
@@ -918,7 +934,7 @@ function selectExhaustedNeedsReviewTargets(jobs, now, thresholdMs) {
|
|
|
918
934
|
function selectAutoFixTargets(jobs, { fixSlugExists, resolveJobRunId = resolveRunId }) {
|
|
919
935
|
const slugsInQueue = new Set(jobs.map((j) => j.slug));
|
|
920
936
|
return jobs.filter((job) => {
|
|
921
|
-
if (
|
|
937
|
+
if (isCancelledRow(job)) return false;
|
|
922
938
|
if (isRefireCapped(job)) return false;
|
|
923
939
|
if (job.status !== 'needs_review') return false;
|
|
924
940
|
// A job parked here because it was blocked by a sibling's foreign WIP
|
|
@@ -1086,7 +1102,6 @@ function selectResumeRecoveryBatch(jobs, { saturated = false } = {}) {
|
|
|
1086
1102
|
module.exports = {
|
|
1087
1103
|
selectResumeRecoveryBatch,
|
|
1088
1104
|
isRefireCapped,
|
|
1089
|
-
isCancelledJob,
|
|
1090
1105
|
selectResumeRecoveryTarget,
|
|
1091
1106
|
MECHANICALLY_RESOLVABLE_VERDICTS,
|
|
1092
1107
|
isMechanicalRecoveryFutile,
|
|
@@ -1107,10 +1122,12 @@ module.exports = {
|
|
|
1107
1122
|
GUARD_VERDICT_EVIDENCE_ELIGIBLE,
|
|
1108
1123
|
isGuardParkedWithoutAutoFix,
|
|
1109
1124
|
isStrandedAutoFixPark,
|
|
1125
|
+
isFixPlanParkWithoutAutoFix,
|
|
1110
1126
|
isEligibleForNeedsReviewAutoResolve,
|
|
1111
1127
|
isPlanUnqueued,
|
|
1112
1128
|
DEAD_FIX_CHILD_STATUSES,
|
|
1113
1129
|
isFixPlanDead,
|
|
1130
|
+
hasActivePreflightHold,
|
|
1114
1131
|
NO_ATTRIBUTABLE_COMMIT_VERDICTS,
|
|
1115
1132
|
healRefusalReason,
|
|
1116
1133
|
isFailedUnverifiedShaped,
|
|
@@ -155,6 +155,73 @@ function describeStarveHold({ projectRows = [], launchBlocks = {}, lastTick = nu
|
|
|
155
155
|
return lastHoldTick?.reason ?? 'dispatching-elsewhere';
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/** Max dependency links findRootBlocker follows before giving up on a chain. */
|
|
159
|
+
const ROOT_BLOCKER_MAX_DEPTH = 50;
|
|
160
|
+
|
|
161
|
+
/** Root row's human reason: heldReason, else its last statusHistory reason, else null. */
|
|
162
|
+
function rootBlockerReason(row) {
|
|
163
|
+
if (typeof row.heldReason === 'string' && row.heldReason) return row.heldReason;
|
|
164
|
+
const h = Array.isArray(row.statusHistory) ? row.statusHistory : [];
|
|
165
|
+
const last = h[h.length - 1];
|
|
166
|
+
return last && typeof last.reason === 'string' && last.reason ? last.reason : null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function rootBlockerRow(job, rows, resolver) {
|
|
170
|
+
const visited = new Set([job.slug]);
|
|
171
|
+
let cur = job;
|
|
172
|
+
for (let depth = 0; depth < ROOT_BLOCKER_MAX_DEPTH; depth++) {
|
|
173
|
+
const depSlug = findBlockingDep(cur, rows, DEP_HISTORY_FAIL_OPEN, resolver);
|
|
174
|
+
if (!depSlug) return cur === job ? null : cur;
|
|
175
|
+
const next = resolver.rowsForDep(depSlug, cur).find((r) => !isSatisfiedDepRow(r));
|
|
176
|
+
if (!next || visited.has(next.slug)) return cur === job ? null : cur; // cycle: stop at last new row
|
|
177
|
+
visited.add(next.slug);
|
|
178
|
+
cur = next;
|
|
179
|
+
}
|
|
180
|
+
return cur === job ? null : cur;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* findRootBlocker(job, rows) → null | { slug, status, reason, preflightHeld }
|
|
185
|
+
*
|
|
186
|
+
* Pure. Walks findBlockingDep (fail-open history, as describeStarveHold does)
|
|
187
|
+
* transitively to the first row that is not itself waiting on a dependency —
|
|
188
|
+
* the row a starved chain actually waits on. Cycle-safe; stops at depth 50
|
|
189
|
+
* and reports the deepest row reached. null when `job` has no blocking dep.
|
|
190
|
+
*/
|
|
191
|
+
function findRootBlocker(job, rows, resolver = null) {
|
|
192
|
+
if (!job) return null;
|
|
193
|
+
const list = (Array.isArray(rows) ? rows : []).filter(Boolean);
|
|
194
|
+
const res = resolver ?? makeDepResolver(list, new Set(), { failOpen: true });
|
|
195
|
+
const root = rootBlockerRow(job, list, res);
|
|
196
|
+
if (!root) return null;
|
|
197
|
+
return {
|
|
198
|
+
slug: root.slug,
|
|
199
|
+
status: root.status,
|
|
200
|
+
reason: rootBlockerReason(root),
|
|
201
|
+
preflightHeld: !!root.preflightHold && typeof root.preflightHold === 'object',
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* rootBlockersForProject(projectRows) → [{ slug, status, reason, preflightHeld, heldSlugs }]
|
|
207
|
+
*
|
|
208
|
+
* Pure. Distinct root blockers over every dependency-blocked pending row,
|
|
209
|
+
* in first-seen order; `heldSlugs` lists the pending rows each one holds.
|
|
210
|
+
*/
|
|
211
|
+
function rootBlockersForProject(projectRows) {
|
|
212
|
+
const rows = (Array.isArray(projectRows) ? projectRows : []).filter(Boolean);
|
|
213
|
+
const resolver = makeDepResolver(rows, new Set(), { failOpen: true });
|
|
214
|
+
const bySlug = new Map();
|
|
215
|
+
for (const j of rows) {
|
|
216
|
+
if (j.status !== 'pending') continue;
|
|
217
|
+
const root = findRootBlocker(j, rows, resolver);
|
|
218
|
+
if (!root) continue;
|
|
219
|
+
if (!bySlug.has(root.slug)) bySlug.set(root.slug, { ...root, heldSlugs: [] });
|
|
220
|
+
bySlug.get(root.slug).heldSlugs.push(j.slug);
|
|
221
|
+
}
|
|
222
|
+
return [...bySlug.values()];
|
|
223
|
+
}
|
|
224
|
+
|
|
158
225
|
/**
|
|
159
226
|
* classifyQueueStarvation({ jobs, paused, runningCount, lastRunAtMs, now, thresholdMs })
|
|
160
227
|
* → null | { kind: 'starved' | 'blocked', pending, dispatchable, blockedChains, idleMs }
|
|
@@ -407,6 +474,8 @@ module.exports = {
|
|
|
407
474
|
dispatchIdleMs,
|
|
408
475
|
launchBlockedSlugs,
|
|
409
476
|
describeStarveHold,
|
|
477
|
+
findRootBlocker,
|
|
478
|
+
rootBlockersForProject,
|
|
410
479
|
classifyQueueStarvation,
|
|
411
480
|
classifyQueueStarvationByProject,
|
|
412
481
|
classifyQueueHealth,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scheduler/utilizationHold.cjs — the one rule deciding whether an automatic
|
|
6
|
+
* (non-human) scheduler tick may dispatch. Pure: no I/O, no clock (`now` is a
|
|
7
|
+
* parameter), so every caller (when-available, job-finish, dispatch-loop,
|
|
8
|
+
* slot-release ticks) agrees.
|
|
9
|
+
*
|
|
10
|
+
* Why every window: during a meter outage the top window (a 5-hour session
|
|
11
|
+
* at 97%) can reset while weekly_all in the same payload is still at 92%
|
|
12
|
+
* until Thursday. Reading only the binding window drops the hold at the
|
|
13
|
+
* session reset and the queue dispatches into the weekly limit (Self,
|
|
14
|
+
* 2026-11-23). A window whose reset has passed is skipped — never read as
|
|
15
|
+
* "no hold" for the others.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {{ window: string | null, percent: number | null, resetsAt: string | null }} UsageWindow
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* percent: number | null,
|
|
22
|
+
* window: string | null,
|
|
23
|
+
* resetsAt: string | null,
|
|
24
|
+
* known: boolean,
|
|
25
|
+
* windows: UsageWindow[] | null,
|
|
26
|
+
* }} UtilizationReading
|
|
27
|
+
* @typedef {{
|
|
28
|
+
* reason: 'manual-fire-policy' | 'utilization-held',
|
|
29
|
+
* window: string | null,
|
|
30
|
+
* percent: number | null,
|
|
31
|
+
* threshold: number | null,
|
|
32
|
+
* resetsAt: string | null,
|
|
33
|
+
* detail: string,
|
|
34
|
+
* }} AutoDispatchHold
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Reset time as ms, or +Infinity when null/unparseable (counts as "resets last").
|
|
39
|
+
* @param {string | null | undefined} resetsAt
|
|
40
|
+
* @returns {number}
|
|
41
|
+
*/
|
|
42
|
+
function resetMs(resetsAt) {
|
|
43
|
+
const ms = typeof resetsAt === 'string' ? Date.parse(resetsAt) : NaN;
|
|
44
|
+
return Number.isFinite(ms) ? ms : Infinity;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {{
|
|
49
|
+
* firePolicy: string | null | undefined,
|
|
50
|
+
* threshold: number | null | undefined,
|
|
51
|
+
* reading: UtilizationReading | null | undefined,
|
|
52
|
+
* now: number,
|
|
53
|
+
* }} args
|
|
54
|
+
* @returns {AutoDispatchHold | null}
|
|
55
|
+
*/
|
|
56
|
+
function evaluateAutoDispatchHold({ firePolicy, threshold, reading, now }) {
|
|
57
|
+
if (firePolicy === 'manual') {
|
|
58
|
+
return {
|
|
59
|
+
reason: 'manual-fire-policy',
|
|
60
|
+
window: null,
|
|
61
|
+
percent: null,
|
|
62
|
+
threshold: null,
|
|
63
|
+
resetsAt: null,
|
|
64
|
+
detail: 'fire policy is manual: only Run now dispatches',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (reading == null || reading.known !== true) return null;
|
|
68
|
+
if (typeof threshold !== 'number' || !Number.isFinite(threshold)) return null;
|
|
69
|
+
const limit = threshold;
|
|
70
|
+
|
|
71
|
+
/** @type {UsageWindow[]} */
|
|
72
|
+
const candidates = Array.isArray(reading.windows) && reading.windows.length > 0
|
|
73
|
+
? reading.windows
|
|
74
|
+
: [{ window: reading.window, percent: reading.percent, resetsAt: reading.resetsAt }];
|
|
75
|
+
|
|
76
|
+
/** @type {{ window: string | null, percent: number, resetsAt: string | null, resetAt: number } | null} */
|
|
77
|
+
let pick = null;
|
|
78
|
+
for (const c of candidates) {
|
|
79
|
+
if (!c) continue;
|
|
80
|
+
const percent = c.percent;
|
|
81
|
+
if (typeof percent !== 'number' || !Number.isFinite(percent)) continue;
|
|
82
|
+
const resetAt = resetMs(c.resetsAt);
|
|
83
|
+
if (resetAt <= now) continue; // already reset: its old reading no longer applies
|
|
84
|
+
if (percent < limit) continue;
|
|
85
|
+
if (pick === null || resetAt > pick.resetAt || (resetAt === pick.resetAt && percent > pick.percent)) {
|
|
86
|
+
pick = { window: c.window ?? null, percent, resetsAt: c.resetsAt ?? null, resetAt };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (pick === null) return null;
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
reason: 'utilization-held',
|
|
93
|
+
window: pick.window,
|
|
94
|
+
percent: pick.percent,
|
|
95
|
+
threshold: limit,
|
|
96
|
+
resetsAt: pick.resetsAt,
|
|
97
|
+
detail: `${pick.window ?? 'binding'} window at ${String(pick.percent)}% ≥ ${String(limit)}%, resets ${pick.resetsAt ?? 'unknown'}`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = { evaluateAutoDispatchHold };
|