Appendix A - 11. Resource-pressure gating (admit before, shed during)

The Structure of Resource-pressure gating (admit before, shed during) — its shape at a glance:

One pressure signal has three readers: an admission gate left of dispatch that refuses doomed work before a worktree exists, an execution shed at compute that stops a job pressure has overtaken, and an advisory callable for operator judgment.

flowchart LR
  Monitor[(Pressure signal<br/>GREEN/YELLOW/RED)] --> Admit{Admission gate}
  Monitor --> Shed{Execution shed}
  Monitor --> Advise([Advisory read])
  Admit -->|RED| Defer([Refuse / defer dispatch])
  Shed -->|RED| Stop([Shed running job])

Accessible description: one host-pressure signal feeds three readers — an admission gate that refuses or defers a heavy dispatch under RED before a worktree exists, an execution shed that stops a running heavy job under RED, and an advisory callable the operator consults — so heavy work is neither started into nor left running on an overloaded host.

Projected from the catalogue entry mediators-and-resource-locks / Resource-pressure gating (admit before, shed during).

On this page: Intent · Motivation · Applicability · Structure · Sample Code · Consequences · Example use within DocAble · Related Patterns

Intent

Intent — Govern a saturable host resource with a live pressure signal read at two layers: an admission gate that refuses or defers heavy work before it is dispatched, and an execution shed that stops heavy work already running when pressure spikes, both driven by one signal that is also callable for the operator's own judgment. Heavy work is then neither started into an overloaded host nor left running on one (our instance: a GREEN/YELLOW/RED host-load monitor that gates agent dispatch and sheds heavy compute at the mediators).

Motivation

A cardinality cap (N-at-a-time) bounds how many heavy jobs run, not whether the host can bear them right now. Two failures follow. Dispatch into overload: the orchestrator admits a heavy agent onto an already-saturated machine because the only pre-dispatch check guards a different resource (free disk, say); the agent starts, reaches the compute mediators, and is refused, so it polls and sheds, burning wall-clock (a heavy agent has burned ~10 minutes polling) on work that never had headroom. Run into overload: pressure rises after a job was admitted, and nothing stops the now-too-heavy job mid-flight. Cardinality caps and single-resource admission checks miss both. The missing ingredient is a live pressure reading consulted at the two moments work is admitted and executed.

Applicability

Structure

The Structure diagram appears at the top of this page.

Sample Code

The two layers are not redundant: admission prevents the startup cost of doomed work; execution shedding catches pressure that rose after admission. One shared signal drives both, or they disagree and reintroduce the admit-then-shed churn.

def read_pressure() -> str:
    """One coarse level over the saturable resource — cheap enough for every dispatch and compute entry."""
    ...  # returns "GREEN" | "YELLOW" | "RED"

def admit_dispatch(is_heavy: bool) -> str:
    if is_heavy and read_pressure() == "RED":          # gate LEFT of dispatch — never start doomed work
        return "defer"                                  # defer with a wake condition, never silently drop
    return "admit"

def compute_shed(is_heavy: bool) -> str:
    if is_heavy and read_pressure() == "RED":          # catches pressure that rose AFTER admission
        return "shed"
    return "run"

Consequences

Example use within DocAble

Contents
© James C. Davis, 2026–present