Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions doc/agents/owner-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<pkg>`, e.g. `~/build-cache/id` for pkgs/id). Sessions launched outside the lock run cargo through `~/tools/cargo-target-broker exec --repo <repo> --profile <test|dev|release> -- 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 <owner/name> --ref <ref> --command '<cmd>' --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/<pkg>`, e.g. `~/build-cache/id` for pkgs/id). Sessions launched outside the lock run cargo through `~/tools/cargo-target-broker exec --repo <repo> --profile <test|dev|release> -- 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.
26 changes: 26 additions & 0 deletions pkgs/fleet/doc/agents/remote-build-and-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <owner/name> --ref <ref> --command '<cmd>' --dispatch --json`.
3. Track it asynchronously with `fleet queue session status <HANDLE>` and collect the outcome with `fleet queue session result <HANDLE>`; the run's full log is on its Actions page (`gh run view <RUN_ID> --repo <RUNNER_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:
Expand Down Expand Up @@ -65,10 +77,24 @@ fleet shell --target codespace --codespace <CODESPACE_NAME> --cwd <CODESPACE_REP
fleet shell --target local --cwd "$PWD" -- cargo test -p fleet-queue --lib
```

The `actions` target is the same dispatch through the shell verb — it dispatches the command through placement and waits for the session result (add `--detach` to get the session handle and return immediately):

```sh
fleet shell --target actions --repo developing-today/code -- cargo test -p fleet-queue --lib
fleet shell --target actions --detach --repo developing-today/code -- cargo test -p fleet-queue --lib
```

`auto` never picks `actions`; name it explicitly when a build or test should leave the local machines.

`auto` honors `FLEET_SHELL_TARGET`; otherwise it prefers this seat if it is the laptop, then a reachable laptop, a Codespace, and finally the local environment. An explicit target does not fall back. `--build` takes a laptop `fleet-build-lock` slot and allows a longer build timeout.

For a detached laptop command, add `--detach` and track the returned job ID with `fleet laptop-agent poll JOB --wait SECONDS`; use `fleet laptop-agent fetch REMOTE_PATH LOCAL_PATH` to retrieve an output file. This is separate from GitHub Actions dispatch. `fleet queue dispatch --surface laptop` currently creates a handoff record; it does not execute arbitrary commands on the laptop. `fleet dispatch launch` submits an agent session to pm-dispatch.

## Portable run IDs

Random `fp_...` handles and their records remain in `~/.local/state/fleet-place/sessions.json`. They work where that local store is available. For a follow-up from another agent or workspace, use the portable `OWNER/REPO#RUN_ID` identifier; Fleet resolves it through GitHub without the local session record. If dispatch has not correlated a run ID yet, keep using the local handle.

## Other dispatch routes

- **`fleet dispatch-test scan|submit|status`** — the explicit-dispatch route for work inside a fleet-umbrella submodule. `scan` lists the execution homes (dezren39/fleet and its fork network) with their live Actions load and picks the first with free capacity; `submit --submodule <name> --ref <ref> --commands '<cmds>'` stores the job in the fleet-dispatch Turso store and dispatches `fleet-dispatch-test.yml` there; `status <job-id>` 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=<owner/name> -f ref=<ref> -f command='<cmd>'` (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=<owner/name> -f command='<cmd>'` 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.