Skip to content

feat(gate): admit quick commands and land checks ahead of load - #324

Open
kixelated wants to merge 3 commits into
mainfrom
quest/m0/land-priority
Open

kixelated wants to merge 3 commits into
mainfrom
quest/m0/land-priority

Conversation

@kixelated

@kixelated kixelated commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/land-priority.md: cheap checks wait a bounded time in quest gate, and the land daemon's check goes ahead of agent load.

Changes

  • quest gate --quick <command> waits at most QUICK_MS (60 s, the load average's lag window), then starts the command. The caller passes the flag; Quest keeps no list of command names, and the bound belongs to the gate, so callers can't pass 0.
  • QUEST_GATE_PRIORITY=1 in the environment makes a gate wait for memory but never for load. It is an environment variable, not a flag, so it reaches the nested quest gate calls in a repository's just recipes (for example moq's sh/local.sh).
  • Quick and priority admissions still go into the ledger, so other callers count them against the host's headroom. Neither is an unbounded bypass: --quick waits up to a minute, and priority still waits for memory.
  • quest agent strips QUEST_GATE_PRIORITY, as it already strips QUEST_GATE_ADMITTED, so agents launched from inside a check don't inherit priority.
  • gateBoundary now parses --quick as the gate's own option when it comes before the executable. After the executable it still belongs to the command.
  • README, quest gate --help, and tests are updated. The quest is deleted.

Where admission happens on the host (investigation)

I checked nixos read-only:

  • Each daemon runs quest land serve --sandbox <repo>-check. That command connects to /run/quest-land-<repo>-check.sock. The socket starts quest-land-<repo>-check@.service (Slice=ci.slice, CPUQuota=1600%, MemoryMax=18G, RuntimeMaxSec=60min), which boots an ephemeral systemd-nspawn container. Inside it, quest-land-check-command runs nix develop --command just ci "$BASE".

  • moq's just ci runs sh/local.sh. Outside GitHub Actions, that script calls exec quest gate bun … local.ts (the image's quest 0.1.0). So admission happens inside the container. That gate's ledger is private: /home/check/.cache/quest/admissions/qland-6 in a fresh copy of the image. But its load signal is the host's 1-minute load average, and its limit is the host's 32 CPUs. The land check therefore queues behind agent load without ever appearing in the host's ledger.

  • In the batch logs (/var/lib/quest-land-moq/moq-dev-moq/batch-*.log), 3 of 24 batches printed quest gate: waiting for the load average to fall (4 to 6 times each).

  • The 2026-10-31 05:07Z–06:45Z "idle" window was not gate starvation. The daemon was busy the whole time:

    • Batch 7344 ran 05:07Z–05:40Z and failed check gh.
    • Batch 7426 ran 05:41Z–06:21Z and failed check gh.
    • The service restarted at 06:22Z. Batch 6946 ran 06:24Z–07:10Z and failed check quest.
    • Batch 7304 landed at 07:50Z.

    check gh failed in 2 s (alert.yml's workflow list is out of sync with .github/workflows/ — stale (remove, CI-only): Pullfrog). The rest of just ci still ran for 32–40 minutes before the batch was ejected. Neither of those first two batches waited in the gate.

Host-side change (kixelated/nixos, not made here)

  • In modules/quest-land.nix, have the generated quest-land-check-command export QUEST_GATE_PRIORITY=1, next to its other exports, before exec nix develop …. The container's private ledger means a host-side reserved slot can't work, and the launcher already bounds the check: one container per repository socket, a 16-CPU quota, and an 18 GiB memory cap inside ci.slice.
  • Bump the image's quest pin to a release that contains this PR. The image ships quest 0.1.0 from the Nix store.
  • Do not use QUEST_GATE_ADMITTED=1 for this. It would also skip the memory admission that currently spaces the check's parallel Cargo suites inside its 18 GiB cap.

Choices made without asking

  • The --quick bound is a fixed 60 s owned by the gate, rather than a duration the caller declares, so it can't be turned into a zero-wait bypass.
  • Priority means "ignore load, keep memory", not a reserved slot. A slot counted in the ledger can't work while the check's gates use a ledger private to the container.
  • A --quick command still marks its descendants admitted, like any gated command. Pass the flag only for commands that start nothing expensive.
  • land-serve.ts does not set QUEST_GATE_PRIORITY on the sandbox's environment, because a parallel quest owns that file. The nspawn sandbox doesn't forward the daemon's environment anyway.
  • I deleted the quest instead of rewriting it, because the remaining work lives in kixelated/nixos and moq-dev/moq. Those items are listed as follow-ups below.

Suggested follow-ups

  • kixelated/nixos: export QUEST_GATE_PRIORITY=1 in the land check command and bump the image's quest (see above).
  • moq-dev/moq: use quest gate --quick for cheap suites such as check quest, formatters, and markdown (moq-dev/moq#7250, moq-dev/moq#7257). Also make just ci fail fast once a module fails: the 2-second check gh failure cost two 35-minute batches.
  • quest: have land-serve.ts pass QUEST_GATE_PRIORITY=1 in the sandbox environment, after the land-head-moved quest lands.

Review

  • Reviewer: Codex gpt-6.1-sol at medium effort, via quest review --base origin/main (session 01a19294-8f89-76a1-bc11-d83ddf3495e6, round 1)
  • Head reviewed: 132eeec
  • Findings: none

Local checks on this head: just check passed, and just test passed (724 passed, 2 skipped; worker suite 426 passed).

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

kixelated and others added 3 commits October 31, 2026 08:11
Quest-Claim: b30992b7dddb1fb4
… of load

quest gate --quick waits at most QUICK_MS (one load-average window), then
starts the command. QUEST_GATE_PRIORITY=1, set by the land daemon's sandbox,
makes every gate inside the check wait for memory but never for load. Both
record their admissions, so other callers still count them. quest agent drops
the priority mark as it drops an admission.

Finishes quest/m0/land-priority.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Landing and cheap checks are admitted ahead of agent load feat(gate): admit quick commands and land checks ahead of load Oct 31, 2026
@kixelated
kixelated marked this pull request as ready for review October 31, 2026 15:30
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a3f5e31-857b-4c2a-a00f-9c12ad2ffd10
Commits

Reviewing files that changed from the base of the PR and between 66a39b7 and 132eeec.

Files selected for processing: 8
  • README.md
  • quest/m0/README.md
  • quest/m0/land-priority.md
  • src/cli/agent.ts
  • src/cli/gate.ts
  • src/cli/main.ts
  • test/agent.test.ts
  • test/gate.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant