Memory governor
The deacon’s memory governor (assessMemoryPressure in
src/lib/cloister/memory-governor.ts) watches available RAM and CPU pressure
and reports what it sees to the activity feed through the memory-pressure
patrol. Its verdict gates only automatic resumes: deacon-lite resumes a
crashed work agent (crashed-work-resume.ts), and the dashboard’s restart
recovery resumes conversations (backend-restart-recovery.ts), only while the
governor admits. The preemptive scheduler’s automatic resume
(preemption.ts:resumeYieldedAgents) and the shed() reclaim function
(stopping merged Docker stacks, pausing idle work agents) have no production
caller. CPU pressure acts at the dispatch doors instead;
see CPU pressure.
The governor never blocks conversations, pan start, or dashboard Start.
A separate, unrelated check, evaluateSpawnGuardrails in
routes/agents/shared.ts, is what actually gates POST /api/agents (the
operator’s start button, the planning auto-handoff, and its deferred retry).
Reserve defaults
Four reserves, inresources.governor_{hard,soft,watch,recovery}_reserve_gb,
each computed as min(max(pct × totalGb, floorGb), cap × totalGb): a
percentage of total RAM, with an absolute floor for small hosts and a cap so
the floor never swallows a small host whole:
At or above 40 GB the cap never binds, so these values match the defaults
before PAN-4267 added the cap, and nothing changes on large hosts. The floors
still bind above 40 GB: the 4 GB hard floor up to 50 GB, the 10 GB watch floor
up to 50 GB, the 12 GB recovery floor up to 48 GB, and the 8 GB soft floor up
to about 53 GB.
The
POST /api/agents spawn guardrail has its own pair,
resources.memory_warn_gb / resources.memory_block_gb, scaled the same way
but simpler: min(4, totalGb / 8) and min(2, totalGb / 16):
Both tables come from
src/lib/config-yaml/governor-reserves.ts
(computeGovernorReserveDefaultsGb, computeSpawnMemoryThresholdDefaultsGb).
Normalizing a user-set config
If aconfig.yaml override breaks the reserves’ ordering invariants,
normalizeGovernorReserves (same module, called from
config-yaml/merge.ts) corrects it and logs one warning naming the key it
changed:
hard >= soft→hard = soft × 0.5.recovery <= soft→recovery = soft + 1.watch <= soft→watch = soft + 1.- Any of the four at or above this host’s total RAM → all four reset to the scaled defaults above (a recovery reserve at or above total RAM can never be reached, which is what locked the governor into permanent shedding before PAN-4267).
Linux vs macOS measurement
Linux reads/proc/meminfo’s MemAvailable and /proc/pressure/memory
for PSI (pressure stall information). Low free swap sheds only when PSI shows
live stalls; where PSI is unavailable, low free swap holds, so the automatic
resumes above wait.
macOS has neither. computeDarwinAvailableMemoryBytes
(src/lib/system-health/darwin.ts) is the one available-memory calculation
shared by the header collector and the governor’s reader
(readProcMemoryDarwin in src/dashboard/server/services/proc-memory.ts):
it prefers memory_pressure -Q’s free percentage of total RAM, falling back
to the Activity Monitor vm_stat formula (total - (anonymous - purgeable + wired + compressor) × page size) when memory_pressure is unavailable.
macOS also allocates swap on demand, so a low free-swap share is not
pressure there; the governor ignores swap runway on darwin
(swapGrowsOnDemand). Its stall signal instead is the kernel’s own
kern.memorystatus_vm_pressure_level sysctl: level 4 (critical) sheds
immediately regardless of the memory reserves, and level 1 (normal) counts
as calm for the holding re-admit window, the same role Linux’s PSI plays.
Small Macs
Before PAN-4267, an 8-16 GB Mac could get a recovery reserve at or above its total RAM, so the governor never cleared HARD. The scaled defaults above fix this for a fresh install. If you still need to override the reserves by hand (e.g. on a host between the documented sizes), add to~/.overdeck/config.yaml:
pan restart. normalizeGovernorReserves will correct anything in this
override that violates the ordering invariants above and log why.
CPU pressure
On Linux the governor and the dispatch doors read CPU Pressure Stall Information (/proc/pressure/cpu, some avg60): the share of the last minute
during which a runnable task waited for a CPU. Unlike load average, it does not
count tasks blocked on IO. Where PSI is unavailable (macOS, old kernels), load
per core (governor_cpu_soft_load_per_core / governor_cpu_recovery_load_per_core)
is the fallback.
When CPU pressure is at or above the hold threshold:
pan lane startandPOST /api/lanesrefuse with HTTP 429cpu-saturated. Passpan lane start --force(or"force": true) to launch anyway.- Starting an agent from the dashboard shows an acknowledgeable
cpu_saturatedwarning. Your confirm covers it; the planning auto-handoff does not, so it waits and retries. - Flywheel-started work agents are held only if you turn on
governor_cpu_hold_dispatch.
pan start, and dashboard Start are never blocked on CPU.
Runaway processes (for example a tool call that outlived its agent) are
reported in the activity feed with the kill -TERM -<pgid> command to stop
them; Overdeck never kills them itself.
Quality gates, local Vitest runs and typecheck lanes (scripts/tsc-admitted.mjs)
share an admission queue with resources.quality_gate_slots slots (default 2),
set in ~/.overdeck/config.yaml only. A gate starts only while CPU is
unpressured; PSI counts only while CPU utilization is at least 50 %, so a
workload pinned to a few cores does not hold gates while other cores are
idle; under pressure new gates wait and running gates keep their slots.
The CPU wait is bounded: once the admission queue has waited on CPU for
resources.quality_gate_cpu_bypass_minutes, the gate at its head starts alone
as soon as no other gate holds a slot, and the gates behind it follow one at a
time without waiting the bound again, because CPU contention only slows a gate
down (PAN-5588).
A gate also waits while starting it would push MemAvailable below
resources.governor_soft_reserve_gb, counting the memory that already-admitted
gates are still expected to allocate and its own measured footprint.
Later gates may pass a head that is waiting on memory. A
gate at the head of the queue that has waited 5 minutes on memory can no
longer be passed by later gates. The slots drain and it runs alone, as long
as available memory minus its footprint stays at or above the hard reserve
(PAN-5285). When even that is impossible for
resources.quality_gate_starvation_minutes, Overdeck reports the stall once
instead of waiting on it silently (PAN-5621).
The deacon log (
~/.overdeck/logs/deacon.log) gets one cpu-pressure sample
line every 5 minutes with PSI some avg10/avg60 and load per core, so you can
calibrate the hold threshold for your host. New weights and nice levels apply
to units and agents started after the change.
Disk alert
Separate from this page’s memory and CPU guardrails: the disk alert (PAN-5093) watches free space on the filesystem holding the Overdeck home and raises a Needs-you item plus a phone push when it drops too low. It runs in the primary dashboard process (src/dashboard/server/services/disk-alert-service.ts),
polling every 30 seconds; see
Disk alert (PAN-5093) for
the full design.