# Notes for coding agents This file is for every agent working in any OrchardLinux repository (orchard, tools, omarchy-a, linux, m1n1, mesa, packages and the rest), in any checkout anywhere, with or without a local orchard checkout. Each of those repositories' own AGENTS.md sends agents here first. Read this file at the start of every session, whatever the task. Several agents and people work on one machine at the same time, in different checkouts, sharing one Orchard cache (`~/.cache/orchard`), one Podman VM and the devices on the desk. The rules below keep that from breaking each other's work. When a rule and your task conflict, ask the person you work for. ## Everything benefits every device **Every change benefits every device it can.** A driver, device tree node, firmware recipe or desktop change is on by default for every board that has the hardware: describe it in the shared chip or model `.dtsi` with `status = "okay"`, not in one board's `.dts`. A per-board file holds only what really differs on that board, such as its wiring. **Every opt-in or opt-out needs a very good reason, written next to it:** the hardware is absent, or there is evidence that it breaks that board. **"Untested" is never a reason.** Neither is "I only have one device". The catalog marks the other boards `untested`, and their owners find out. This is about the shared, standard part, not about size: a new feature may start in one driver, through the standard interface, so other drivers can add it later. It never means every driver in one pull request. ## Short timeouts, checked results Nobody waits for something that has long failed. - Give every command a short timeout that fits what it does (`timeout -k 5 N`): seconds for a query, a few minutes for a build step. Never an open-ended wait. - Check that each command succeeded before you go on: its exit status and its output. Don't stack the next step on an unchecked one. - A background job, build or CI run: check within a minute that it is really progressing, and stop it as soon as it fails, hangs or stops moving. Read the first failure, fix the cause, then start again. - CI: watch the run's jobs, not only its end; a failed job means the run has failed, so act on it at once instead of waiting for the rest. ## Every build goes through `orchard build` Every image, payload, kernel, m1n1, initramfs, root file system and distribution is built with the orchard tool: `orchard build`, booted with `orchard run` or `orchard launch`. The tool calls orchard's producers in the right order, with the right inputs, cache and checks. - Never run a producer yourself (`producers/*.py`), never run a repository's own build or release script in place of the tool (omarchy-a's `release/package.py`, `make` in a kernel or m1n1 tree, `mkinitcpio`, a hand-written `podman run`), and never copy their commands into a shell. A result made that way is not what users get, and it is the most common mistake agents make here. - To see what a build ran, use `orchard build --explain`; don't redo it by hand. - If `orchard build` can't do what you need, fix or extend the tool or its producers in a pull request. Don't work around it. ## Tests Run the tests with `PYTHONPATH=$PWD/src python3 -m unittest discover -s tests` (Python 3.11 or newer with `jsonschema`; on the Mac `/opt/glustore/bin/python3.14`), or `bin/orchard python -m unittest discover -s tests`, which brings its own environment. The suite is green on main: a failing test is yours to fix. Don't compare against main. ## Which orchard runs - `orchard` on PATH is the Rust command line from OrchardLinux/tools. Alone it builds from the newest nightly's recipes and board data, whatever the current directory. - To run the code of a checkout or worktree, call its own launcher by path: `/path/to/checkout/bin/orchard build …`. Nothing else selects a checkout. - Build with `orchard build` and boot with `orchard run` (RAM) or `orchard launch` (installed). A project says what it builds in its `orchard.toml`; a board or platform is an argument (`--device j71b`, `--platform apple-16k`) or a line in the uncommitted `orchard.local.toml`. - `orchard build --explain` prints what a build ran as plain commands. ## Kernel and m1n1 changes - m1n1: OrchardLinux/m1n1 is the source. Work on a branch there, open the pull request there, and never add m1n1 patch files to orchard. Orchard builds the commit in `boot/m1n1/upstream.lock`; move it in the orchard pull request that needs the new m1n1 (`boot/m1n1/README.md`). - Kernel: OrchardLinux/linux is the source (`main` for arm64, `armv7` for the 32-bit boards). Work on a branch there in a worktree under `~/projects/OrchardLinux/trees/` (a case-sensitive volume), as ordinary source, and open the pull request there. Never add kernel patch files to orchard. Build a tree with `orchard build … --kernel-tree DIR`; its build output stays inside the tree, in `.orchard-out/` (git ignores it there). - Kernel work follows upstream Linux and Asahi practice: standard kernel interfaces and frameworks, upstream commit style, hardware described in the shared chip or model device-tree files. A feature may start in one driver; through the standard interface, other drivers add it later and userspace works with all of them. - Review a pull request by its own layer's upstream practice. Never ask it for work that belongs in another repository (no desktop UI from a kernel pull request). - Commits in upstream style, one topic each, with `Assisted-by: LLM`. - Every commit to linux, mesa and m1n1 (whose work can go upstream) carries its actual author's `Signed-off-by` (CONTRIBUTING.md, Sign-off); the other repositories need none. Work you write for the person you work for: they are the author (global git config), sign off with `git commit -s`. Work based on someone else's code (a contributor's port, a fork such as Project Cascadia): they are the git author, as linux#6 did, with an `[Orchard: from …]` note on what changed; a mention in the message is not enough. Such a commit carries the author's sign-off only if their original work has one or they gave it explicitly. Never add a sign-off for someone else without their approval, and never sign off someone else's work as your own. - A missing author sign-off never blocks a merge: merge, then ask the author for it and keep nudging until it is there. - Never rewrite `main` or `armv7` of OrchardLinux/linux, or `main` of OrchardLinux/m1n1: no force-push, no rebase of what is merged. The branches are protected against it. A new base under the series is added on top with `tools/kernel-tree/replay`. - Orchard builds the kernel commit its lock names. When orchard needs a merged kernel change, `tools/kernel-tree/take` moves the lock and rewrites the config copies; commit that in the orchard pull request that needs it (`kernel/README.md`). ## Distributions - A distribution's build imports none of orchard's Python: it runs orchard's producers as commands from a snapshot (`docs/distribution-contract.md`). Changing one of those commands is a contract change: update both distributions in the same push set. ## Disk: every GB counts The machine's disk is always nearly full, and a full disk breaks everyone's builds and can hang the VM. Treat space as scarce and time as scarce too: - **Clean up what you made, when you are done with it:** your worktrees, scratch and work directories, test releases and `out/` builds you no longer need, downloaded archives. Before you report a task as finished, list what you created and remove what nobody needs any more. Keep what is still in use (the last good build someone boots, a tree you keep working in). - **Don't delete what others made**, nor package caches, git mirrors, builder images, firmware or private inputs, unless the person asks you to. If something looks abandoned, list it with its size and ask. - **Check before large work:** `df -h ~` before a kernel, root or image build or a large download; below about 10 GB free, clean up first or ask. `orchard build` and `orchard run` refuse to start below 10 GB (`ORCHARD_MIN_FREE_GB` changes the limit). They also keep Orchard's own directories (the shared cache and the store) under 20 GiB by deleting the least recently used entries Orchard can make again (`ORCHARD_CACHE_BUDGET_GB`; 0 turns it off). - **Prefer reuse to copies:** a published nightly component over a local build, one worktree over several, a pointer over a duplicate. - Inside `~/.cache/orchard`, delete through `orchard cache` (or ask), never by editing its trees or bare repositories. ## Devices - One holder per device. Say when you take it ("taking the J71b for one RAM boot") and when you give it back; coordinate with the other sessions. - Never boot or flash without the person's go for that attempt (e.g. "dfu ready"), even if the device shows up in DFU. One attempt, no retry loops. - RAM boots by default; write to a device's storage only when asked. - USB serial and SSH must always come up; no change may take them away. - Bound every command you run on a device (`timeout -k 5 N …`) and read the serial log and dmesg before guessing. - **The DFU bell:** when a person has to do something physical (put a device into DFU, replug it, unlock it), ring it once with `tools/dfu-bell/dfu-bell`, say in one line what you need, then wait. ## Releasing orchard - A release is one pull request that sets `pyproject.toml`'s version and renames CHANGELOG.md's `## Unreleased` to `## [X.Y.Z] - date`; it can be the change itself. Merged and green, the build of `main` tags it, publishes `vX.Y.Z` in about 7 minutes. Don't tag or publish by hand. It starts no distribution: after an orchard release, check each distribution on it and release it by hand (`docs/ci.md`, Release behavior). ## Device specs and capabilities - Device data must always match the code. When a change affects what a board or chip is or can do (a driver, kernel config, firmware, boot method, a test result), update `devices//device.toml` and `chips/*.toml` in the same change, including a change that breaks or removes something. - Regenerate the hardware support matrix with `tools/catalog/generate matrix`; never edit `docs/compatibility.md` by hand. ## Changelog - CHANGELOG.md is curated: one entry per meaningful unit of work (a device, a hardware feature, an install or launch change, a compatibility break), not per commit, refactor or CI change. - When you finish such a unit, propose the entry under Unreleased: what changed, described by its effect. Add it only after the person explicitly approves it, and never edit the changelog without that approval.