Files
lotherk 6199effa3c $Makronix$ in libmxlinux, the rule in AGENTS.md, and build/logs for a clone
Three gaps, all found by running `make release' on a fresh clone instead of
trusting the tree that had been built in for weeks.

1. tools/userland.sh: fetch_binaries redirects into build/logs/, but nothing
   created that directory: a clone has no build/ below AGENTS.md, so step 2/7
   died with "Error code 1" from the shell, before pkg-binaries.sh ran, and
   the log it points at was never written.  mkdir -p first.  The other two
   redirects into build/logs (pkg-add, pkg-delete) come after it.

2. src/lib/libmxlinux: four files had no header at all (mx_termios.h,
   mxlinux.h, mx_locale.c, mx_fgetwln.c).  They now carry `/*\t$Makronix$\t*/'
   like the other 61 there, and all 71 files of the directory have one.
   Checked with gcc -fsyntax-only on each of the four.

3. AGENTS.md says the header rule once, in "Licence": `#\t$Makronix$' in a
   file Makronix wrote, `$NetBSD: <file>,v <rev> ... Exp $' in one taken from
   pkgsrc, never the unfilled template -- the detail is in ext/AGENTS.md
   ("Header").

Tested: tools/test-tools.sh 42 ok, 0 bad.  gcc -fsyntax-only clean on the four
files.  The directory builds through `make userland' (mobile/userland/mk/
mx.prog.mk: mx-lib), not standalone: a plain `bmake' in src/lib/libmxlinux has
no NETBSDSRCDIR (getopt.c comes through .PATH) -- not caused by this change,
the same command failed the same way before it.
2026-11-24 03:33:56 +00:00

197 lines
11 KiB
Markdown

# AGENTS.md -- how work happens in this tree
Makronix is a NetBSD, built and shaped on purpose. Read this before changing
anything; the rules are few and they are binding.
Read in this order, every time: `GOAL.md` (what Makronix is and when a part is
done), this file, `docs/BUILD-CONTRACT.md` (the one way to build). Every
directory below the root carries its own `AGENTS.md`: what lives there, what
may be changed, what may not. Read the one in the directory you work in
before you touch it.
Where this file and a measurement disagree, the measurement wins and this file
is wrong: fix the file, name the log line that settled it. The old measurements
and narratives (media sizes, the CDE/MCDE build-host story, what was measured
when) are in `docs/reference/agents-history-2026-11-13.txt`; they are history,
not rules.
## The rule before all others
**Read the documentation first, every time, and save what you read.** In this
order: the docs in the tree (`AGENTS.md`, `src/BUILDING`, man pages, the comment
at the top of the file), then the project's own upstream documentation. Keep a
copy under `docs/reference/<topic>.txt` with source and date so the next session
does not start over. Quote the sentence that settles a question -- with its
location -- before acting on it. "The docs say" without having opened them is
the failure this rule exists to prevent; it has cost this project days.
## The one rule
**NetBSD first, in this order:** read the documentation in the tree (`AGENTS.md`,
`src/BUILDING`, `src/share/misc/style`, `src/distrib/sets/README`,
`src/etc/rc.subr`); look for the pattern already in the tree with `git grep`;
use the building block that exists. Only then write code -- and the comment
says which NetBSD pattern it follows.
A patch that breaks a NetBSD convention is a finding for the report, never a
quiet change in the tree.
## Licence
What Makronix wrote itself is under the CNCL (Could Not Care Less License 1.0,
`LICENSE` at the root; files carry the line `License: CNCL 1.0 ...`). What
comes from elsewhere keeps its own licence: `src/` (NetBSD, BSD), `xsrc/`,
`pkgsrc/`, `refs/*`, the imported trees under `ext/` (MCDE is CDE: LGPL 2.0
or later) and their changes to files that already had a licence. A new file
in a fork gets the CNCL line; a changed upstream file keeps the notice it has.
The header line says where a file came from: `#\t$Makronix$` (or
`/*\t$Makronix$\t*/` in C) in a file Makronix wrote, `$NetBSD: <file>,v <rev>
... Exp $` in a file taken from pkgsrc. The unfilled `$NetBSD$` is pkgsrc's
recipe template before the revision is set and belongs to neither -- a recipe
written here takes `$Makronix$`, also when it is modelled on a pkgsrc recipe
(`ext/AGENTS.md`, "Header"; `tools/test-tools.sh` fails if one comes back).
## What belongs where
- `src/` is **Makronix's NetBSD tree**, tracked here. It began as the upstream
commit in `src/BASE` and is edited directly: no patches, no overlay.
`refs/netbsd/src` is upstream trunk, shallow and read-only -- look there,
never build from it.
- `xsrc/` is **Makronix's X tree** (since 2026-11-13 again), tracked the same
way: the upstream commit in `xsrc/BASE`, built by `build.sh -x -X xsrc` into
the X sets; pkgsrc uses it (`X11_TYPE=native`).
- `mobile/` is the Linux tree for the phones: kernel from `refs/linux/7.0.14`,
our changes as `mobile/kernel/patches/`. The imported tree is read-only.
- `ext/` holds third-party sources Makronix ships and changes (MCDE, afpfs-ng,
...): `ext/src/<name>/` the tree, `.../pkgsrc/` its recipe, `IMPORT` where it
came from. First commit of a tree is the upstream archive unchanged; every
change after it is a visible diff (`ext/AGENTS.md`).
- `pkgsrc/` and `refs/*` are their own repositories, pinned. Moving a pin is a
decision; editing inside them is not allowed.
- `distfiles/` is part of the repository (Konrad, 2026-11-19: everything the
build needs lives in the repository -- today the source archives and the
binary packages, later the sources of what now comes as a binary).
## Building
Everything builds from the root `Makefile`. It is NetBSD make (Konrad,
2026-11-19): `make` on Makronix, `bmake` on a Linux host; GNU make does not
read it. The interface is meant to stay this small -- **do not add targets**:
make the build (sets)
make release the release: sets, kernels, ramdisks, media
make install over a running Makronix, idempotent, incremental
make mobile the phones (wanted; not there yet -- mobile/Makefile
has its own targets, mobile/AGENTS.md)
The other targets that exist (`iso`, `usb`, `compress`, `sourcesets`, `isosrc`,
`userland`, `binaries`, `test`, `cdtest`) package or check what `release`
built; `docs/BUILD-CONTRACT.md` says in which order.
**Cross and native are one build** (decided 2026-11-13). The build host may be
NetBSD (native) or anything else (cross); the build detects which at the start
and sets the toolchain up once. A package that builds only on one of them is
broken, and the fix is in our recipe (`ext/`), in `tools/pkgsrc-cross.mk.conf`
(host tools such as `CC_FOR_BUILD`), or in the source -- never "build it in a
VM". `pkgsrc/` itself is not patched.
**The VM is for testing only**: installations from the media, upgrades,
smoke tests. Nothing is built in it.
Rules for a build:
- `make release` is the whole release: sets, kernels, the signed source set,
the ISO and the USB image, in one lock (since 2026-11-18). `make iso` and
`make usb` alone only repackage what the last release built: they check the
stamp (`build-stamp.sh -c`) and stop without removing anything.
- Long builds: start the one named target in the background with its output in
`build/logs/<target>-<date>.log` and end the turn. The status is the last
line, `make <target> exit=N`, not the wrapper's. No transient units.
- One build at a time in one tree: the root Makefile takes
`tools/build-lock.sh`; a second build is refused with the holder's pid
(t0286, `METALOG.sanitised` and the CD staging). The lock is re-entrant
(`BUILD_LOCK_HELD`), so `make cdtest` holds it across release, iso and the
VM test; `make mcde-linux` and `make mcde-host` take it too. Tools that
write `build/obj` or `releasedir` (`build-stamp.sh`, `cd2.sh`, `cd3.sh`,
`cd-source.sh`, `images.sh`, `srctree-stage.sh`, `userland.sh`,
`mcde-linux.sh`, `mcde-host.sh`, `mcde-debian.sh`) refuse to run outside it;
start them through make or `tools/build-lock.sh '...'`. The tests
(`test.sh`, `mediacheck.sh`, `install-simple.sh`, `install-cgd.sh`,
`mcde-tests.sh`) call `build-lock.sh --check` and refuse to start beside a
build; `make test` and `make cdtest` hold the lock while they run.
- The gate on a build is `checkflist`, run the way NetBSD runs it (`cd
src/distrib/sets && DESTDIR=build/obj/destdir.amd64 MACHINE=amd64
MACHINE_ARCH=x86_64 build/obj/tooldir.*/bin/nbmake-amd64 checkflist`). Extra
or missing files fail the build. Do not hand-roll its environment.
- A boot message `WARNING: 1 module failed to load` for `cd9660` is not a
defect (the INSTALL kernel has it built in).
## Third-party packages (pkgsrc)
pkgsrc builds FOR the target with this tree's toolchain
(`tools/pkgsrc-cross.mk.conf` is the whole configuration, `--prefer-native=yes`
is not optional). Packages are installed into the sysroot's `/usr/pkg` and
belong to one set, `makronix`, which is **generated**: `tools/makronix-set.sh`
reads the installed tree back and writes `src/distrib/sets/lists/makronix/mi`
and the METALOG records; since 2026-11-15 `packages.list` also knows the
art `bin` (vim, git-base, sysupgrade, flex, ksh93, tcl; commit 51c89ff23a),
so `makronix-set.sh` starts from `set`+`bin` and removes every other registered
package from the sysroot with pkg_delete (x11-links, osabi stay; commit
909271b3d7). sysinst installs it (`SET_MAKRONIX` in `defs.h`,
`util.c`, every `msg.mi.*`). Removing a package means removing its list
entries and marking them `obsolete`.
The target's `pkg_install` comes from the distribution, not from pkgsrc. A fork
from `ext/` builds from its own source tree: the recipe sets `DISTFILES= # empty`
and its `do-extract` copies `ext/src/<name>` into `WRKSRC`, so there is no
archive, no `distinfo` and nothing to regenerate after a commit.
`tools/ext-sync.sh` makes the recipe visible inside pkgsrc (a mirror of symlinks
to `ext/src/<name>/pkgsrc`).
Where pkgsrc's cross mode stops on a Linux host (`awk:run`, xbase looked up on
the host, host-only tools) is a finding for the report and a setting in our
configuration; see the history file for the details measured so far.
## Definition of done
A change is done when its test is green and it is committed. A build is done
when `checkflist` reports no missing and no extra files. A medium is done when
an install from it reaches a login prompt and shuts down cleanly -- with the
log kept in the tree.
No claim without a measurement: file and line, exit code, log excerpt.
## Forbidden
Enforced by the build gate `tools/claude-build-gate.sh` where a harness hook can
see it, binding everywhere else:
- building through `systemd-run` or any transient unit; `make -C build`,
`cd build && make`, hand-chained `build.sh` operations.
- writing, moving or deleting anything under `build/obj/releasedir/**` by hand.
(The hook is textual: a command that names `releasedir` and contains `rm `,
`mv `, `cp `, `touch `, `chmod `, `sed -i` or `>` is refused, a `2>&1`
included. Read without redirections, or in a script under `tools/`.)
- `git reset --hard`, `git checkout -- .`, `git clean -fdx` in the root. Undo
with `git restore <file>` after looking at what it is.
- deleting `src/distrib/sets/lists/**` to make `checkflist` pass.
- unattended loops: cron jobs, timers, "tick" scripts that start builds or
tests or hand work to an agent.
## How to work
- Plan before acting on anything non-trivial: say which command you will run
and what you expect, run it, compare.
- Every claim carries `file:line` or a log line. A sentence without one is a
guess.
- Do not trust a status document, a commit message or an old log over a
measurement you can repeat. Repeat it.
- `tools/` is POSIX `sh`: no Python, no bashisms (`dash -n`, `checkbashisms`).
- Commit with explicit paths in one command (`git commit -m ... -- <paths>`);
a second agent works in `mobile/` in the same repository.
- Each directory has its own `AGENTS.md` (what it is for, what is in it, what
may change, what must not be touched); when a directory gains a purpose, a
rule or a hazard, its file changes in the same commit. Not below the
top-level directories of `src/`, `pkgsrc/` or the reference trees.