From e5f19bd673a5b00d100577602303fc7d884a621b Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 02:40:12 -0600 Subject: [PATCH] docs(fleet): dispatch-first guidance for remote builds and tests The remote dispatch surface (fleet queue dispatch / session, fleet shell --target actions, placement across the org and personal pools) is landed and verified, but the agent-facing docs still framed the laptop build lock as the primary route for heavy work. - Runbook: add the dispatch-first rule (push, dispatch with the ref, poll the session, read logs from the run), the fleet shell actions target, and the other dispatch routes (dispatch-test, raw workflow dispatch) with their tracking commands. - owner-preferences: CI-first and build-discipline bullets now lead with remote dispatch; the laptop build-lock discipline remains as the fallback for jobs that must run on the laptop. - AGENTS.md: short text matches (still inside the size budget; scripts/research_workflow.py check passes). Refs the sandbox-seat reachability gap recorded in #13122. --- AGENTS.md | 6 ++--- doc/agents/owner-preferences.md | 4 +-- .../fleet/doc/agents/remote-build-and-test.md | 26 +++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9ca6082d55..345b6fe37c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,9 +27,9 @@ logs — do not mention that or file rotation tasks for it. Velocity: unblock yourself, test selectively, run full suites only for very large or critical changes, and file GitHub issues for unresolved gaps instead of blocking. CI-first verification per -[`.github/ci-policy.md`](.github/ci-policy.md); heavy laptop builds go -through `~/tools/fleet-build-lock` — see the topic file for the build -discipline (target broker, narrowest Rust verification). +[`.github/ci-policy.md`](.github/ci-policy.md); builds and tests dispatch +remotely first (`fleet queue dispatch`); heavy laptop builds go through +`~/tools/fleet-build-lock` — details in the topic file. ## Testing doctrine diff --git a/doc/agents/owner-preferences.md b/doc/agents/owner-preferences.md index cc2e7260c3..671883c764 100644 --- a/doc/agents/owner-preferences.md +++ b/doc/agents/owner-preferences.md @@ -12,7 +12,7 @@ - Perform quick or selective tests during iteration. Only run full exhaustive test suites preemptively for very large changes or known critical issues. - It is acceptable to push and merge code that has been validated with targeted tests without running every single test upfront. - Run long test suites or CI in the background while progressing on other work in parallel. If background jobs or CI fail, double back and address failures while continuing forward. - - **CI-first verification:** Review the checks actually triggered on the PR and use [`.github/ci-policy.md`](../../.github/ci-policy.md) to distinguish the basic merge-gating PR tier from the full main tier; formatting is not a merge gate. Run targeted local checks on the laptop when useful; sandboxed workers use CI and must not run builds or tests in the sandbox. If a policy-listed check is missing from the PR, inspect the workflow trigger and report the coverage gap instead of assuming it ran. - - **Build discipline on the laptop (2026-11-10):** Heavy builds/tests (cargo, nix) on the laptop go through `~/tools/fleet-build-lock` (max 2 heavy builds fleet-wide; it also defaults CARGO_BUILD_JOBS to half the cores). Never set `RUSTC_WRAPPER=` empty — that bypasses the shared sccache cache every other lane benefits from. `fleet-build-lock` leases CARGO_TARGET_DIR from the cargo target broker (`~/tools/cargo-target-broker`, code#6797) for cargo builds — a bounded pool of warm per-workspace dirs under `~/build-cache/broker-pool`, held under an exclusive lease for the build and returned warm — instead of a per-worktree target dir: lanes then reuse each other's dependency builds instead of each paying a full ~17-minute compile (measured 2026-11-11 through the broker: a pkgs/id test build from a second worktree compiled 1 of 535 units, and a build returning to its own leased dir compiles none; re-measured 2026-11-11 through the lock, pkgs/atlas-search: 35s isolated target dir -> 1s shared). If the broker cannot lease a dir, the lock falls back to the pre-broker static per-package dir (`~/build-cache/`, e.g. `~/build-cache/id` for pkgs/id). Sessions launched outside the lock run cargo through `~/tools/cargo-target-broker exec --repo --profile -- cargo ...` to land on the same leased dirs. Set CARGO_TARGET_DIR yourself only to override all of that. For Rust verification, run the narrowest build that proves the change: `cargo check` for type-only changes; `cargo test --lib` without `--features web` when the change does not touch web code; named test filters always. The full `--features web` test build of a package like `pkgs/id` costs many minutes of fleet-wide compile and must be justified by the change actually touching that surface. + - **CI-first verification:** Review the checks actually triggered on the PR and use [`.github/ci-policy.md`](../../.github/ci-policy.md) to distinguish the basic merge-gating PR tier from the full main tier; formatting is not a merge gate. Builds and tests go through remote dispatch first (`fleet queue dispatch` — see the runbook, `pkgs/fleet/doc/agents/remote-build-and-test.md`); run targeted local checks on the laptop only when dispatch cannot serve the job; sandboxed workers must not run builds or tests in the sandbox. If a policy-listed check is missing from the PR, inspect the workflow trigger and report the coverage gap instead of assuming it ran. + - **Build discipline — dispatch first (2026-11-10; dispatch-first added 2026-11-23):** Heavy builds/tests (cargo, nix) are dispatched remotely by default: push the code, then `fleet queue dispatch --repo --ref --command '' --dispatch --json`, track it with `fleet queue session status/result`, and read logs from the run URL (`gh run view --log`). Placement picks the least-loaded runner pool (the developing-today org or the dezren39 account), keeps GitHub-hosted runners ahead of Blacksmith, and reuses dependency caches across dispatches. The laptop route in the rest of this bullet is the fallback for work that genuinely must run on the laptop (NixOS builds and activations, stateful or secret-bearing checks, a quick single-binary check). When a build does run on the laptop, it goes through `~/tools/fleet-build-lock` (max 2 heavy builds fleet-wide; it also defaults CARGO_BUILD_JOBS to half the cores). Never set `RUSTC_WRAPPER=` empty — that bypasses the shared sccache cache every other lane benefits from. `fleet-build-lock` leases CARGO_TARGET_DIR from the cargo target broker (`~/tools/cargo-target-broker`, code#6797) for cargo builds — a bounded pool of warm per-workspace dirs under `~/build-cache/broker-pool`, held under an exclusive lease for the build and returned warm — instead of a per-worktree target dir: lanes then reuse each other's dependency builds instead of each paying a full ~17-minute compile (measured 2026-11-11 through the broker: a pkgs/id test build from a second worktree compiled 1 of 535 units, and a build returning to its own leased dir compiles none; re-measured 2026-11-11 through the lock, pkgs/atlas-search: 35s isolated target dir -> 1s shared). If the broker cannot lease a dir, the lock falls back to the pre-broker static per-package dir (`~/build-cache/`, e.g. `~/build-cache/id` for pkgs/id). Sessions launched outside the lock run cargo through `~/tools/cargo-target-broker exec --repo --profile -- cargo ...` to land on the same leased dirs. Set CARGO_TARGET_DIR yourself only to override all of that. For Rust verification, run the narrowest build that proves the change: `cargo check` for type-only changes; `cargo test --lib` without `--features web` when the change does not touch web code; named test filters always. The full `--features web` test build of a package like `pkgs/id` costs many minutes of fleet-wide compile and must be justified by the change actually touching that surface. - **Resource defaults (provisional, 2026-11-22; evidence: [#7011](https://github.com/developing-today/code/issues/7011)):** On a sandbox exec cell, limit CPU-bound subprocess parallelism to **2 workers**. The recorded synthetic per-cell sweeps repeatedly show throughput reaching a plateau from 2 workers onward; this is not a cap on independent queue lanes. Before starting new heavy sessions on the shared sandbox VM, check `MemAvailable` and do not start below **1.5 GiB**. Use available memory as the admission gate rather than load average alone: recorded ramp windows showed memory headroom falling while load remained below the VM's vCPU count. On the laptop executor, keep CPU-bound parallelism at or below the logical-core count and reduce it under mixed load; measured results show that the unloaded peak is not stable under concurrent builds. Do not run fleet-wide concurrency sweeps as part of ordinary work. These are conservative operating defaults, not a substitute for a representative lane-level benchmark; revise them when such measurements exist. - Document unresolved ambiguities, design concerns, or known gaps by creating GitHub issues instead of blocking progress. diff --git a/pkgs/fleet/doc/agents/remote-build-and-test.md b/pkgs/fleet/doc/agents/remote-build-and-test.md index 9e9d9999e9..7508ab7d9b 100644 --- a/pkgs/fleet/doc/agents/remote-build-and-test.md +++ b/pkgs/fleet/doc/agents/remote-build-and-test.md @@ -2,6 +2,18 @@ `fleet queue dispatch` sends one command directly to the Fleet command workflow in an eligible runner repository. It does not wait for the target repository's pull-request or main-branch CI. +## The rule: dispatch first — do not compile on the sandbox or the laptop + +Builds, test suites, and other CPU-heavy work run on dispatched GitHub Actions runners, not on the machine you are sitting on. The sandbox is small and shared; the laptop is the fleet's machine of record and is already loaded. The flow is always: + +1. Push the code (branch or commit) to the target repo. +2. Dispatch the command against that ref: `fleet queue dispatch --repo --ref --command '' --dispatch --json`. +3. Track it asynchronously with `fleet queue session status ` and collect the outcome with `fleet queue session result `; the run's full log is on its Actions page (`gh run view --repo --log`). + +Placement chooses the runner pool by live load — the developing-today org (20 concurrent jobs) and the dezren39 account (40) — so the same command lands wherever there is capacity. GitHub-hosted runners are the default; Blacksmith is a budgeted fallback, never the default, and paid Blacksmith minutes require the explicit `--allow-paid-blacksmith` override. macOS is available with `--platform macos` when a job genuinely needs it. Dependency caches (Actions cache, the shared Nix cache, per-branch Rust/Go keys) are keyed so repeat dispatches of the same kind of job reuse them; `--followup` pins a repeat job to the previous run's host and outputs. + +Run locally only when the job cannot be dispatched: a NixOS build or activation, work needing laptop state or secrets, or a quick single-binary check while iterating. "The sandbox was closer" is not a reason. + ## Submit and track a command Run from the current Fleet checkout or anywhere the Fleet binary and GitHub auth are configured: @@ -65,6 +77,15 @@ fleet shell --target codespace --codespace --cwd --ref --commands ''` stores the job in the fleet-dispatch Turso store and dispatches `fleet-dispatch-test.yml` there; `status ` reads the stored result. Linux, GitHub-hosted only; use it when the job is naturally "run inside submodule X at ref Y". +- **Raw workflow dispatch** — when no current `fleet` binary is at hand, dispatch the workflows directly: `gh workflow run fleet-command.yml --repo developing-today/fleet -f repo= -f ref= -f command=''` (the same runner the placement route uses; `-f platform=macos` and `-f runner=blacksmith` exist — Blacksmith stays explicit-only), or `gh workflow run fleet-run.yml --repo dezren39/fleet -f repo= -f command=''` for the matrix-capable generic runner. Track with `gh run list` / `gh run view --log` on the hosting repo. Prefer the `fleet` verbs whenever they are available: they add placement, budgets, and session tracking.