Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 18.5 KB

AGENTS.md

File metadata and controls

80 lines (65 loc) · 18.5 KB

Backplane

An agentic hardware development environment: an agent harness with deterministic viewers for KiCad boards, schematics and STEP models. The hub is Rust (native/host), the desktop client is GPUI (native/gpui), the phone apps are native (mobile/). There is no JavaScript hub and no web client in this tree.

Branches

  • Work happens in your own worktree on your own branch: git worktree add .backplane/worktrees/<name> -b <name> main.
  • The source is one clone: ~/Documents/Backplane/Backplane (BackplaneWorks/Backplane). Every lane is a worktree of it under .backplane/worktrees/, and so is the main builder's checkout (.backplane/worktrees/main-build). Make no other clone or copy of the tree to work in: when ~/Documents/i2cjak/backplane-bend was deleted on 2026-11-09, every worktree of it lost its git data and the unpushed commits in them had to be rebuilt from the files.
  • FreeCAD runs headless everywhere but the person's own use: probes, conversions and test hubs use freecadcmd or the GUI with QT_QPA_PLATFORM=offscreen and no DISPLAY/WAYLAND_DISPLAY (the hub does: stepglb::headless). A test hub gets no DISPLAY from the live hub's environment; a FreeCAD that has one puts its windows (a --version box) on the person's screen.
  • Upstream main (origin/main) is the one main; always rebase on it. Start your branch from origin/main, and land with scripts/land.sh from your worktree: it fetches, rebases onto origin/main, runs the tests (scripts/dev-build.sh --gate --no-cut), pushes to origin main as a fast-forward and then fast-forwards local main. A rejected push (origin moved) fetches, rebases, tests and tries again; anything it cannot do fails loudly (land: FAILED ...) and lands nothing. Never git rebase main, never merge into local main by hand (the main hook refuses a local main that is not on origin/main), never force, never merge-commit. Landing pushes: that is the person's standing go (2026-11-10). Details: docs/git.md (Landing).
  • Every move of origin/main is built on this machine (scripts/main-build.sh builds only commits that are on origin/main, fetching every minute; started by a hook from scripts/install-hooks.sh; docs/MAIN-BUILD.md). After landing, scripts/main-build.sh status shows built: reach your tip, and ~/.backplane-gpui-dev/main-build.log says published or FAILED. A red test publishes nothing and leaves the bar red until the next merge fixes it, so land.sh runs the tests before it pushes.
  • A published build reaches the running app (the fresh hub on ~/.backplane-gpui-fresh, scripts/fresh.sh) only through its watcher, scripts/fresh-watch.sh: it shows the build bar, swaps the window at once, and offers Restart now while turns run (docs/HUB-RESILIENCE.md, docs/DEV-RELOAD.md). The watchdog timer (scripts/hub-watchdog.sh install) brings a dead watcher back. Both act on the person's live app, so the person starts them in their own terminal; an agent never does (a watcher started from an agent turn carries BACKPLANE_AGENT_OWNER and the next hub restart kills it). If ~/.backplane-gpui-dev/CURRENT names your build but the running backplane-gpui (readlink /proc/<pid>/exe) is older, the watcher is not running: tell the person, and check scripts/hub-watchdog.sh status; never relaunch the app yourself.

Layout

  • native/host/: the Rust hub (backplane-hub). HTTP + WebSocket, event store, agent processes (Claude, Codex, Grok, OpenCode, Muse, Antigravity, Pi, Oh My Pi), KiCad (in-process IPC, plots, STEP), bots and rooms, pairing, far threads, terminals. The presenter (present/, presenter.rs) is Rust only; there is no helper process and no --policy-bin. The CBOR dictionaries are in src/wire_dict.rs (append-only forever, the wire depends on the order).
  • native/voice/: the voice helper (backplane-voice), a child process of the hub: speech to text by OpenAI or locally through sherpa-onnx's C API, NDJSON on stdout (its README.md).
  • native/gpui/: the GPUI desktop client (backplane-gpui); vendor/ is vendored crates. Its colours come from assets/web/style.css, its logo from assets/web/favicon*.svg.
  • mobile/ios, mobile/android: the phone apps. They speak the hub's data/1 protocol (docs/PHONE-DATA.md).
  • native/step2glb/: the STEP mesher (backplane-step2glb), C++ on OpenCascade, a helper the hub runs from beside itself (kicad/stepglb.rs). scripts/build-step2glb.sh builds it (STATIC=1: the pinned OpenCascade from scripts/build-occt.sh, as a release does).
  • tools/: helper programs that are not Rust: browser (headless Chromium over NDJSON), cef, voice, platform. Built by scripts/build-*.sh.
  • order/: the order server (fabsrv, Python) and deploy. skills/: agent skills. deploy/kistack: KiStack's skills, pinned by deploy/kistack.lock (python3 scripts/kistack.py bump <commit>). i18n/: message catalogs. assets/: fonts, icons, web colours.
  • scripts/: dev, build, fresh/watch, side-by-side, switch and device scripts; migrate-from-bend.sh copies an old ~/.backplane-bend home into a Backplane home (the old one is only read). The hub's own import (native/host/src/import014/, docs/IMPORT-0.14.md) is what a person uses: setup and Settings offer it, and it copies into a home already in use. test/: fixtures, oracles and e2e drivers; test/tools/claude_standin.ts and perf_standin.ts: the stand-in agents.
  • docs/: how this tree works (BUILD.md, DEV-RELOAD.md, MAIN-BUILD.md, SIDE-BY-SIDE.md, COPY-GUARD.md, HUB-API.md, PHONE-DATA.md). Other docs/*.md describe features the hub keeps.

Commands

cd native/host && cargo test --offline          # hub tests
cd native/gpui && cargo test --offline          # client tests
scripts/dev-build.sh --gate --no-cut       # both crates' tests, then fast-profile builds; no publish
scripts/dev-build.sh                       # build and publish to the person's `watch` terminal via dev-cut.sh
scripts/main-build.sh --once               # build and publish the tip of main now
scripts/bp-build.sh                        # build/test on a remote builder (Boat or h@backplane), when the desktop is busy
backplane-hub --home DIR --port N --no-tailscale --foreground   # run a hub (temp home!)

dev-build.sh honours BUILD_ROOT (the checkout to build), PROFILE (default fast), HOST_TARGET/GPUI_TARGET. Tests that need agents use stand-ins only.

Builds and gates: our machines first, GitHub Actions last

Every build, test and gate runs on our own machines. GitHub Actions is the fallback only when none of them can do the job; say which job and why (today: linux-arm64 and Android release builds, and publish, which signs with repo secrets).

  • The merge gate (scripts/land.sh, run from your lane, with no bp-lock.sh wrapper): the gate runs first, outside any lock, so lanes gate side by side: scripts/land-gate.sh on a Boat box, for the crates your PR touches (cargo check --all-targets and their unit tests, no e2e); a PR touching no crate compiles nothing. Then land.sh takes the land lock itself, for seconds: it rebases onto main as it is then (no second gate), pushes and merges with --match-head-commit; a conflict there releases the lock and stops with a line (resolve, land again). No Windows, macOS, e2e, screenshot or KiCad embed suite runs at a merge: those are the release-candidate pass (docs/release-playbook.md). Main is watched instead: scripts/main-build.sh keeps building it, and when main breaks, its owner fixes forward at once or reverts. land.sh says what ran and how long it took.
  • Boat sandboxes (bp-build-N): cargo-q and dev-build.sh offload to them on their own when the local slots are full (docs/BOAT-BUILD.md). Never start one by hand for a build.
  • h@backplane: provisional builds and focused tests (scripts/bp-build.sh LANE '<cmd>'). Never a gating result.
  • hs-mac-mini: iOS and macOS builds and tests (scripts/mac-build.sh, scripts/mac-hub-build.sh), only under the mac-heavy lock.
  • bp-winbuild (Azure, 32 cores, $3.41/h): Windows builds (KiCad's runtime: scripts/winbuild-kicad.sh; it and winbuild-up.sh come with #1176) under the winbuild-vm lock. bp-win (Azure, 4 cores): Windows UI tests under bp-win-ui. Both are deallocated when idle: start with az vm start -g BP-WIN-RG -n <vm>, and az vm deallocate -g BP-WIN-RG -n <vm> when done (a stopped VM still bills). Quick Windows compile checks need no VM: scripts/windows-check.sh.
  • Releases and nightlies: release.yml's macOS, Windows and linux-x64 jobs run on our self-hosted runners (bp-mac, bp-win-nightly or bp-winbuild-release, bp-linux-release) while the RELEASE_*_RUNNER variables name them. GitHub cannot wake them, so run the release through scripts/release-dispatch.sh (dispatch or watch RUN_ID): it starts each machine under its lock and stops it after. A variable set while its runner is offline leaves the job queued for 24 h, so set the variables only for a release window (docs/release-runners.md).
  • Self-hosted runners never take pull requests. The repo is public, and each runner's guard (scripts/runner-guard.sh, .ps1) refuses every job except release.yml and nightly.yml from this repo. Pre-merge gates therefore stay as scripts you run here or over ssh, never runs-on a self-hosted label.

Rules

  • Stand-in agents only in tests: set BACKPLANE_AGENTS=<dir> (the stand-ins go first on PATH; a missing CLI is blocked, never the real one). Real model turns only on temp homes, with the person's go.
  • Testing only: a paid API key (the vault's openai-test-api-key) runs Codex only through scripts/codex-apikey.sh: it pins the cheapest model (gpt-5-nano), refuses any other, and allows one short turn per run. A hub on stand-in agents (BACKPLANE_AGENTS) keeps inherited OpenAI key variables from its Codex children. Users' own Codex auth (ChatGPT sign-in, codex login --with-api-key, OPENAI_API_KEY, custom providers and base URLs) is never touched.
  • Never write to live user data (~/.backplane*, ~/.local/share/backplane). Tests use a temp home, a port 3799+ and --no-tailscale. A hub on a copy of a real log runs with BACKPLANE_COPY=1 (docs/COPY-GUARD.md); it starts no turn the person did not send there, whatever restart.continue says (gate 5).
  • The repo is public: never put a real person's name, email, account label or home folder in code, tests, docs or fixtures, even copied from a live log. Use placeholders (person@example.com, Alex, Sam, /home/user).
  • Never run the installed backplane/backplane-hub to probe it; ask /hello.
  • Never kill processes by name or pattern; only PIDs you captured, or the process group you started (test/e2e/lib/own-group.sh: own CMD, own_stop). The guard tests fail on any pkill, killall or kill $(pgrep -f …) in scripts/, test/, deploy/ or tools/.
  • Persisted events stay decodable forever: add event variants, never change the meaning of one. CBOR dictionary entries are append-only.
  • Every feature matches everywhere it applies: GPUI client and both phone apps, driven by the hub's data.
  • The UI is dumb: decisions (order, settle state, what is visible) come from the hub or a pure function with a test.
  • No continuous repaint loops: animate only while a fade or stream is in flight.
  • Square corners on the desktop, minimal copy, no decorative headings. The phone apps are rounder (radius tokens in BackplaneTheme.kt / DataStyle.swift) and use the system font for interface text; code, paths and the small uppercase labels stay mono.
  • Build and test through scripts/cargo-q (scripts/cargo-q test --offline in native/host or native/gpui), not bare cargo: it waits for one of the machine's few build slots (two here, from cores and free memory), uses the shared sccache (compiled dependencies are shared by every worktree, so a new lane does not compile tokio, naga, zbus... from cold) and sizes -j from its slot's share of free memory, and runs the build in a scope of its own (bpbuild.slice), outside the hub's, so systemd-oomd kills a runaway build and not the hub. scripts/dev-build.sh does the same. When your branch has landed, git worktree remove it (the janitor scripts/worktree-gc.sh --apply does it for you: it removes landed, clean, idle worktrees, target/ dirs of landed branches or idle 24 h, $BP_TMP entries idle 24 h and sccache past its cap, never what a process holds; main-build.sh runs it hourly, every 5 minutes under 100 GB free, and the guard runs it before it says "Disk nearly full"; ~/.backplane-gpui-dev/janitor.log says what it freed).
  • Offload to Boat. When every local build slot is taken, scripts/cargo-q (test, build, check, clippy, doc, bench) and scripts/dev-build.sh (--gate, cuts) do not wait: they run the same command on a Boat sandbox (bp-build-N, pool of BP_BOAT_POOL=2, 8 vCPU) and behave like a local run: same output on stdout/stderr, same exit code, built programs copied back to the same target/ paths. So lanes call scripts/cargo-q, never bare cargo, and the offload happens on its own; never start a Boat for a build by hand. BP_NO_BOAT=1 forces local. How: the exact worktree (tracked and untracked files, committed or not; no .git, nothing ignored) is rsynced to the box, the same script runs there (sccache and target/ stay warm on the box between jobs), and programs come back after a sha256 check. A dev-build.sh cut made on a box is hashed here and always smoke-started here before it is published (SKIP_SMOKE is ignored for it). Nothing of the person's goes to a box: no home, no tokens, no .git; the box comes from the snapshot bp-build-base (made on a sandbox with no environment, scripts/boat-pool.sh base) and the job gets only build knobs. Idle boxes are stopped after BP_BOAT_IDLE (300 s; scripts/boat-pool.sh status|reap|stop|delete); the disk is kept, so the next job resumes warm. If Boat cannot be used (offline, no quota) the build waits for a local slot as before. Commands that need this machine (cargo run, --no-run, --target-dir, --manifest-path, absolute paths outside the worktree) stay local. iOS and macOS builds stay on the Mac mini under mac-heavy; they never go to a Boat. Details: docs/BOAT-BUILD.md.
  • /tmp is a 30 GB RAM tmpfs with an inode quota; lanes filled it twice (EDQUOT: Claude Code could not write its temp files). Lane temp space is on disk: . scripts/lib-bptmp.sh sets BP_TMP (default ~/.cache/bp-tmp), TMPDIR and CLAUDE_CODE_TMPDIR to it; cargo-q, dev-build.sh and the test runs already do. Put temp homes, logs, hub copies and scratch binaries in $BP_TMP (or mktemp -d with TMPDIR set), never under /tmp. Never set CARGO_TARGET_DIR under /tmp (cargo-q and dev-build.sh refuse); use the worktree's target/ (with a data drive, cargo-q and dev-build.sh make a new worktree's target/ a link to /data/target/<worktree>/) or, for a cross build, the shared $BP_TARGET/<target triple>; never a one-off $BP_TMP/target-* (Nov 17: three of those were 30 GB). Heavy scratch lives on the data drive: BP_DATA is /data when this machine has it (else ~/.cache), BP_TMP=$BP_DATA/bp-tmp, BP_TARGET=$BP_DATA/bp-target, sccache in $BP_DATA/sccache, KiCad test runtimes in /data/kicad-test (~/.cache/kicad-test/builds/* link there), release artifacts in /data/release. Remove your scratch when done. $BP_TMP is scratch only: the janitor (scripts/worktree-gc.sh, log ~/.backplane-gpui-dev/janitor.log) deletes any top-level entry there that nothing has written to for 24 h and no process holds, holds $BP_TMP under its cap (400 GB on /data, 60 GB on a home disk) and $BP_TARGET under 300 GB (40 GB), oldest unused first, and while the disk has under 150 GB free the oldest unused entries go too (never one written in the last 2 h, held by a process or named in a command line, or with a .bp-keep you put there; a .bp-keep git tracks does not count). Dead test runs' bp-*/bpt-* dirs go after 24 h.
  • Keep disk headroom (df -h / first; 20 GB free); delete your own build leftovers. Builds of main run in the builder's own checkout and target dirs, at low priority; a build from a worktree uses its own target dir, not another's.
  • Local automation commits as i2cjak <build@amemb.com>. Accepted authors and committers are i2cjak's build@amemb.com and 231940135+i2cjak@users.noreply.github.com, and separate contributor jlcjak's 206324213+jlcjak@users.noreply.github.com and kpatsatzakis1@gmail.com. GitHub's noreply@github.com is accepted as committer only. Everything else is refused. Preserve accepted identities and existing history. scripts/install-hooks.sh sets the repo's own automation identity and installs the shared checker and pre-commit, pre-push and reference-transaction hooks for every worktree; scripts/land.sh and CI use the same rule. Never change the global ~/.gitconfig or override automation's identity with GIT_AUTHOR_*/GIT_COMMITTER_* or git -c user.email=. A clone made elsewhere runs scripts/install-hooks.sh before its first commit.
  • Pushes go through scripts/land.sh (to main, fast-forward only). Any other push (a branch for a pull request) only when asked; before it, verify the GitHub account (i2cjak), the remote (BackplaneWorks/Backplane), and the branch.
  • Process spawning goes through native/host/src/proc.rs (its kinds decide what a copy run refuses); no other non-test Command::new under src/.
  • KiCad work commits straight to main; firmware and other software keep worktrees (docs/git.md, "Design files on main"). A hardware project's thread works in the main checkout for design files (KiCad, libraries, 3D models, mech/, mfg/, fab files: native/host/src/kicad/canonical.rs is_design), which the hub commits to main at each turn's end, and in its worktree for code. One writer per board or schematic holds its named lock (agents/design.rs). A board experiment is an explicit, labelled copy on main, never a silent switch of the canonical one.

Links

  • A link you give the person to something served on a machine (a dev server, preview, review page) must open from their other machines on the tailnet: localhost/127.0.0.1 open only on the serving machine. Your own probes stay on loopback.
  • Name the machine by its MagicDNS name <machine>.<tailnet>.ts.net (its Self.DNSName in tailscale status --json, no trailing dot), with real names filled in. Keep the server on 127.0.0.1 and share it with tailscale serve --bg --https=<free port> http://127.0.0.1:<port> after asking; turn it off when done. Leave 443 alone, never tailscale serve reset, never funnel, never bind 0.0.0.0 or drop sign-in/TLS for a link.