GaleDocs

Chat

Heavy-job queue

How Gale schedules expensive local builds, test suites, and installs across parallel chats — with weighted FIFO admission, host-pressure throttling, a separate fail-fast cap for dev servers, and clean background handoffs.

What the queue controls

When several chats or subagents run in parallel, Gale shares a process-wide admission scheduler in the main process for expensive local work: verify runs (tests, typechecks, lint, builds), dependency installs, and recognized heavy bash commands — including background commands while their processes are actually running.

The queue is an admission budget, not an OS CPU/memory cap, and it is separate from Agent turn concurrency (Settings → Cost → Rounds, which controls how many chats stream model turns at once) and the Plans queue (which sequences prompts per folder). Commands spawned privately inside a tool or outside Gale are not policed.

Classification and weights

Gale parses bash commands at command position (stripping env assignments, wrappers, and sh -c shells) instead of doing raw substring matches. Fast read-only commands such as ls, rg, cat, or git status bypass the queue completely. Recognized heavy commands take either weight 1 or weight 2 against the shared budget:

  • Weight 1 (fast checks) — typechecks (tsc, pnpm/npm/yarn/bun typecheck), linters (lint, go vet, rubocop, srb), and scoped test runs (vitest or jest invoked with a specific .test.* or .spec.* file)
  • Weight 2 (heavy work) — full test suites (pnpm test, unscoped vitest/jest, playwright, pytest, rspec, cargo test, go test, bazel test, swift test), builds (xcodebuild, vite build, esbuild, cargo build, gradle, mvn, turbo, nx, cmake --build, make), package installs (install, add, ci, bundle install), and heavy git maintenance (git clone, fsck, gc, repack, submodule update)
  • Unclassified direct callers of the scheduler default to weight 2 so unknown heavy work is budgeted conservatively

Budget, ramp reservation, and host pressure

The base heavy budget scales with your Mac’s installed memory: clamp(floor(totalRAM_GB / 16) × 2, 4, 12). Machines with 16–32 GB of RAM get a base budget of 4, 64 GB machines get 8, and 96 GB+ machines get 12.

Gale uses hybrid reserve-then-measure admission so parallel spawns cannot stampede the machine before their memory and CPU ramp up, while still letting long-running work share capacity once settled:

  • 10-second ramp reservation — every newly admitted job holds its full declared weight for 10 seconds
  • Steady-state decay — after 10 seconds, while host pressure is normal and 1-minute CPU load is below 85% of logical cores, weight-2 jobs decay to effective weight 1 (never 0), freeing budget for queued work
  • Host-pressure sampling — Gale checks macOS memory pressure (kern.memorystatus_vm_pressure_level) and 1-minute CPU load on a 2-second cache
  • Warn pressure — macOS memory warn or CPU load at or above 115% of logical cores halves the effective ceiling (floored at 2)
  • Critical pressure — macOS memory critical (never triggered by CPU load alone) pauses new heavy admissions until memory pressure drops; while jobs are waiting, Gale re-samples every 2 seconds and resumes automatically

FIFO fairness, backfilling, and timeouts

Queued heavy jobs admit in FIFO request order. When the machine has no active heavy jobs, the head always admits regardless of a tight effective ceiling so a weight-2 head can never deadlock.

While a weight-2 head is waiting for 2 free budget units, up to 2 weight-1 waiters may backfill past it when 1 unit fits. That keeps fast typechecks and scoped tests moving without letting a stream of light checks starve a queued full build or test suite.

  • Live transcript status — parked tool rows update in place with their queue position, which active jobs they are waiting behind, and any host-pressure pause, then flip to running as soon as a slot is admitted
  • Immediate cancellation — stopping or aborting a turn removes its queued waiter right away
  • Bounded foreground waits — foreground tool calls time out after 5 minutes in the queue and return a structured error listing active holders and host pressure rather than hanging indefinitely; background runs (run_in_background) wait without that foreground timeout

Dev servers and watchers

Long-lived services — dev servers and file watchers such as pnpm dev, next dev, vite (without build/optimize), webpack serve, rails server, python -m http.server, tail -f, wrangler/vercel/netlify dev, and --watch test or build loops — never enter the heavy-job FIFO.

Instead, they register in a dedicated active-holder registry capped at 4 concurrent services. Because dev servers run until stopped, queueing a 5th server behind four immortal processes would only hang; Gale fails fast at the cap with a structured error listing every active service’s PID, label, working directory, and age, and highlights any server already running in the same directory so the agent can reuse or stop it. Hitting the dev-server cap never blocks verify, builds, or installs in other chats.

Background handoffs

When a background bash or verify job keeps running past a clean 10-minute (600 s) turn window, Gale hands the live tool row off cleanly instead of stamping it as interrupted. When the process later finishes, Gale updates that tool row in place with the exit result and wakes the chat to continue. Explicit aborts, the 15-minute stall watchdog, and quitting Gale still mark in-flight tools as interrupted.

Live stats in Settings → Performance

Open Settings → Performance → Live stats (or enable Live stats in toolbar for CPU readouts) to inspect the scheduler in real time. Counters show — when Diagnostics level is set to off.

  • Heavy jobs running — active heavy holders vs base budget
  • Heavy jobs queued — waiters currently in the heavy FIFO
  • Heavy limit effective — current pressure-adjusted ceiling and host pressure state (normal, warn, or critical)
  • Dev servers active — active entries in the fail-fast service registry out of 4
  • Heavy jobs admitted — cumulative heavy admissions since launch