@jonit-dev/night-watch-cli 1.8.4-beta.5 → 1.8.4-beta.7

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/dist/cli.js CHANGED
@@ -492,7 +492,7 @@ If no issues are warranted, output an empty array: []`;
492
492
  GLOBAL_NOTIFICATIONS_FILE_NAME = "global-notifications.json";
493
493
  MAX_HISTORY_RECORDS_PER_PRD = 10;
494
494
  DEFAULT_QUEUE_ENABLED = true;
495
- DEFAULT_QUEUE_MODE = "conservative";
495
+ DEFAULT_QUEUE_MODE = "auto";
496
496
  DEFAULT_QUEUE_MAX_CONCURRENCY = 1;
497
497
  DEFAULT_QUEUE_MAX_WAIT_TIME = 7200;
498
498
  DEFAULT_QUEUE_PRIORITY = getDefaultQueuePriority();
@@ -704,7 +704,7 @@ function normalizeConfig(rawConfig) {
704
704
  const rawQueue = readObject(rawConfig.queue);
705
705
  if (rawQueue) {
706
706
  const rawMode = readString(rawQueue.mode);
707
- const mode = rawMode === "conservative" || rawMode === "provider-aware" ? rawMode : DEFAULT_QUEUE.mode;
707
+ const mode = rawMode === "conservative" || rawMode === "provider-aware" || rawMode === "auto" ? rawMode : DEFAULT_QUEUE.mode;
708
708
  const queue = {
709
709
  enabled: readBoolean(rawQueue.enabled) ?? DEFAULT_QUEUE.enabled,
710
710
  mode,
@@ -6615,6 +6615,34 @@ function dispatchNextJob(config) {
6615
6615
  });
6616
6616
  return { ...entry, status: "dispatched", dispatchedAt: now };
6617
6617
  }
6618
+ if (mode === "auto") {
6619
+ const candidates2 = getPendingCandidates(db);
6620
+ if (candidates2.length === 0) {
6621
+ logger.debug("Dispatch skipped: no pending jobs");
6622
+ return null;
6623
+ }
6624
+ logger.debug("Auto dispatch: evaluating candidates", { candidateCount: candidates2.length });
6625
+ const inFlightByBucket2 = getInFlightCountByBucket(db);
6626
+ for (const candidate of candidates2) {
6627
+ const bucketKey = candidate.providerKey ?? "default";
6628
+ if ((inFlightByBucket2[bucketKey] ?? 0) === 0) {
6629
+ db.prepare(`UPDATE job_queue SET status = 'dispatched', dispatched_at = ? WHERE id = ?`).run(now, candidate.id);
6630
+ logger.info("Job dispatched (auto)", {
6631
+ id: candidate.id,
6632
+ jobType: candidate.jobType,
6633
+ project: candidate.projectName,
6634
+ priority: candidate.priority,
6635
+ providerKey: candidate.providerKey ?? null,
6636
+ waitSeconds: now - candidate.enqueuedAt
6637
+ });
6638
+ return { ...candidate, status: "dispatched", dispatchedAt: now };
6639
+ }
6640
+ }
6641
+ logger.info("Dispatch skipped: all candidates blocked by provider concurrency (auto)", {
6642
+ candidateCount: candidates2.length
6643
+ });
6644
+ return null;
6645
+ }
6618
6646
  const candidates = getPendingCandidates(db);
6619
6647
  if (candidates.length === 0) {
6620
6648
  logger.debug("Dispatch skipped: no pending jobs");