Previous contents of src/ AGENTS.md files, as they were on 2026-11-13 before the refactor (source: this repository, HEAD 15260ce07 plus working tree).
Rules are kept in the shortened files; the dated narratives, measurements and status notes are kept here verbatim.

======== src/AGENTS.md
# src/ -- Makronix's NetBSD tree

NetBSD 11.99.9, forked from commit `e523df740` (`src/BASE`) and tracked in the
repository root since 2026-11-09.  There is no `.git` here and no patch stack:
this tree **is** the source.  `refs/netbsd/src` is upstream trunk, shallow and
read-only, for comparison.  This directory is what `build.sh` builds; its
state is the build.

## Read first

- `BUILDING` -- the manual of `build.sh` (operations such as `distribution`,
  `release`, `iso-image`, `sourcesets`).  `UPDATING` -- incompatible changes.
  `README.md` -- the short version.
- `share/misc/style` -- the code style.  `doc/` -- documentation about the tree.
- Each top-level directory has an `AGENTS.md` saying what it is for (taken from
  hier(7), section `/usr/src/`, and the READMEs) and what Makronix changes
  there.

## What may be changed, and how

- Edit it here.  A change is a commit in the parent repository, not a patch and
  not an overlay; `patches/src/` and `overlay/` are gone (their content is in
  this tree).  `refs/netbsd/src` is upstream trunk: read it, diff against it,
  never build from it.
- The `AGENTS.md` files (this one and the 21 top-level ones) are part of the
  tree and tracked; they are not upstream and not a patch.
- Do not rewrite history that contains this tree, and do not `git reset
  --hard` / `git clean -fdx` at the repository root: uncommitted work here is
  real work.
- Build only through the targets of the root `Makefile` (`make release
  ARCH=amd64`, then `make iso`).  Do not run `build.sh` by hand.
- NetBSD first: the documentation in the tree, then the pattern that already
  exists (`git grep`), then the building block that exists, then new code.  The
  comment says which NetBSD pattern the change follows.

======== src/usr.sbin/sysinst/AGENTS.md
# usr.sbin/sysinst/ -- the installer (Makronix fork)

NetBSD's `sysinst(8)`, kept as an overlay unit (`overlay/AGENTS.md`).  Edit it
in `overlay/usr.sbin/sysinst/`; the copy in `src/` is overwritten by the sync.
Based on the import at `overlay/BASE`; `tools/overlay.sh diff` shows our
changes.

## Goal of the fork (`GOAL.md`)

1. CDE default palette for the colours.
2. Simple installation: choose the target disk, the rest is automatic; manual
   partitioning stays available.
3. Optional encryption of the target disk (cgd), bootable.

What the code already does about each, with file and line:
`docs/reference/sysinst-survey.txt` (read it before designing a change).

## The simple installation mode (done, measured 2026-11-06)

`do_install()` (`install.c`) first asks "Select the installation mode":
Simple, Advanced, Abandon.  `simple_install` (`defs.h`, set in `install.c`,
reset by the `do_install` wrapper so that an upgrade in the same session does
not inherit it) is checked at these places; each skips a question that only
exists to shape the layout or the sets, and keeps the default the question
would have offered:

- `part_edit.c`: `select_part_scheme` takes GPT where it can be booted;
  `edit_outer_parts` uses the whole disk.
- `bsddisklabel.c`: `make_bsd_partitions` takes the default layout
  (`LY_USEDEFAULT`) instead of `ask_layout`.
- `label.c`: `edit_and_check_label` does not show the partition editor; if
  `verify_parts` rejects the layout, it is shown after all.
- `arch/i386/md.c` (used by amd64): `md_get_info` drops the partitioning that
  is on the disk; `get_bios_info` does not ask when exactly one BIOS disk
  matches; `md_post_newfs_bios` keeps the console the installer runs on for
  the boot blocks.
- `util.c`: `get_and_unpack_sets` tries `get_via_cdrom()` before it shows the
  "Install from" menu.
- `install.c`: all sets (`init_set_status(0)`), no set menu.

Kept on purpose (they protect data or secrets): "Shall we continue?", the disk,
the last chance, the warning when other partitions would be overwritten, the
root password, the entropy menu when the kernel asks for it, the config menu,
the notice that an optional set is not on the medium.

Test: `tools/install-simple.sh` (about 25 keys with the last step, then `login:`, the `makronix` set,
CDE and the GPT are checked).  Known limits: the simple mode without encryption was run on BIOS only; the
messages exist in five languages but only English was seen; on a disk with a
second system that system is erased without being offered as a choice.

## Encrypted installation (done, measured 2026-11-06, BIOS and UEFI, amd64)

In the simple mode sysinst asks "Encrypt the disk?" (`cgdroot.c`, built only
where the port defines `-DCGDROOT`, today `arch/amd64/Makefile`).  Design and
sources: `docs/reference/cgdroot-design.txt`.  Test: `tools/install-cgd.sh`
(passphrase typed at the install and at boot, then `login:`, `makronix` set,
CDE, root on `/dev/cgd0a`, and no root file name readable in the raw disk
image; logs `build/logs/install-cgd-{bios,uefi}-*-2026-11-06.log`; `-f uefi`
for UEFI).  UEFI layout: ESP (loader, copy of boot.cfg), `cgd.conf` (FFS:
kernel, module, boot.cfg, cgd.conf, parameters; the EFI loader takes the first
FFS partition as its default device), `cgdroot`.  Limits: simple mode only, wrong
passphrase and kernel update (copy to `/cgdboot`) not tested, only English
seen.  `cgd` is in `is_bootable_device()`'s list (`disks.c`) so cgd0 is handled
like raid.

## Colours (2026-11-06)

The default pair is black on white (`main.c`).  `do_coloring()` (`util.c`)
sets three pairs: 1 text on the window colour, 2 the selected menu line, 3 the
menu box.  Where `can_change_color()` the colours are those of the CDE default
palette: window colour = slot 5 (proven on a running CDE,
`docs/reference/cde-colours.txt`), selection and box = slot 4 (a design choice,
not proven), selected text white; on a fixed 8-colour console: white on blue.
With no colours at all (vt220 over serial) nothing changes.  Pairs 2 and 3 are
drawn by `menuc`, which needs `patches/src/0009-menuc-colour-pairs.patch`.

## What is here

- `main.c`, `util.c`, `run.c`, `install.c`, `upgrade.c`, `target.c`,
  `configmenu.c`, `net.c` -- the flow, the target, configuration, utilities.
- `disks.c`, `part_edit.c`, `partitions.[ch]`, `gpt.c`, `mbr.c`, `label.c`,
  `disklabel.c`, `bsddisklabel.c`, `geom.c` -- disks and partition schemes.
- `partman.c`, `menus.pm`, `msg.pm.*` -- the extended partition manager (RAID,
  LVM, cgd, vnd).
- `menus.mi`, `menus.entropy`, `msg.*.{de,en,es,fr,pl}` -- menus and messages
  in five languages.
- `arch/<port>/` -- machine-dependent code: `md.c`, `md.h`, `Makefile`, and
  for some ports `msg.md.*`.  `arch/amd64` has only `md.c`, `md.h` and
  `Makefile`.  `Makefile` builds `arch/${MACHINE}` (or `arch/dummy`).
- `sysinst.8` -- the manual page; `TODO`, `README.md_defs` -- notes.
- `Makefile`, `Makefile.inc` -- the build; sysinst is also built into the
  install ramdisks of the ports (`distrib/*/ramdisks`, `list.sysinst`).

## Rules for this directory

- **Every port uses this code.**  Machine-independent files must stay portable
  and must not assume amd64 or UEFI; what only amd64 needs goes into
  `arch/amd64/`.  A change that cannot be portable is a finding for the
  report.
- A new or changed message exists in **every** language of `LANGUAGES`
  (`Makefile.inc`: `de en es fr pl pt`), in each `msg.*.<lang>` file.
  `msg_xlat.sh` reports a missing translation as an error (`-i` would ignore
  it; do not).  Change the manual page `sysinst.8` with the behaviour.
- `menu_defs.c` and `msg_defs.c` are generated from `menus.*` and `msg.*`
  (`Makefile.inc`, `SRCS`); edit the sources, never generated files.
- NetBSD style: `src/share/misc/style`.  Reuse the existing helpers
  (`run_program`, `add_rc_conf`, the partitioning-scheme interface in
  `partitions.h`) instead of new mechanisms.
- Test through a built medium, one change at a time, with the log kept in
  `build/logs/`.  A change is done when an installation from the medium
  reaches `login:` (`GOAL.md`).

## Two CDs, the welcome screen and the last step (measured 2026-11-07)

- **Welcome** (`main.c`, `MENU_welcome`): after the language menu, "Welcome to
  Makronix <release>", a short description, OK.
- **Two CDs** (`util.c`, `extract_file_to`): the first CD boots the GENERIC
  kernel and loads `miniroot.kmod`, so the installer runs from RAM
  (`root_is_ramdisk()`).  When a set is not on the CD in the drive, the CD is
  unmounted, `MENU_nextcd` asks for the next one (continue / skip this set),
  and `cd_has_sets()` is retried silently for 16 s because the drive needs
  time after a medium change.  In `dist_list` the `makronix` set is the last
  entry on purpose: the sets are extracted in list order, so there is one
  change of CD, not one per set after it.  The DVD needs none of this.
- **The last step of the simple mode** (`setup.c`, `makronix_setup()`, called
  from `install.c` instead of `do_configmenu()`): hostname, network through the
  configuration-menu form while the target is mounted (`configmenu.c`,
  `makronix_config_network()` -> `set_network()`; if the network is not up,
  `dhcpcd=YES`), time zone (`set_timezone()`), root password
  (`root_pw_setup()`), a user through the configuration-menu form
  (`makronix_config_user()` -> `add_new_user()`), then the created non-system
  users (uid 1000..59999) are added to the groups wheel, operator, staff, users,
  dialer, games, wsrc with `usermod(8)` in the chroot.  `ntpdate`/`ntpd`,
  `sshd`, mDNS, npf, pkg defaults and `dtlogin` in place of `xdm` (rc.d script
  and PAM file copied from the pkgsrc examples) follow.  `target.c`'s
  `dup_file_into_target()` copies `/etc/wpa_supplicant.conf` and
  `/etc/resolv.conf` only when the source exists.  Passwords go to the chroot in
  an environment variable, never on a command line.  The advanced mode keeps the
  configuration menu.
- Tests (all on the serial console, `build/logs/*-cd13-2026-11-07.log`,
  `install-cgd-uefi-cd2-2026-11-07.log`): `tools/install-simple.sh` (CD 1, CD
  2), `install-cgd.sh -f bios|uefi`, `install-simple.sh -S` (DVD with sources).
  Checked after the boot: login as root with the typed password, `id` of the
  user, host name, `rc.conf`, `/etc/localtime`, `dtlogin` running.
  Not measured: that the CDE login screen is drawn (only that the process
  runs); a wrong passphrase; the other languages.

## The extra programs and CD 3 (written 2026-11-07, test pending)

`extras.c`, `makronix_extras()`, called from `install.c` in the simple mode
after the sets (and after `cgdroot_finish()`, which needs CD 2 in the drive).
It asks nothing since 2026-11-09 (the extra programs are part of the userland:
Firefox, Thunderbird, QEMU, about 2.6 GB, measured as the sum of `SIZE_PKG` of the
112 packages), looks for
`<medium>/<machine>/packages/All/pkg_summary.gz`, asks for the next CD when
the installer runs from RAM and the medium in the drive has none (the same
Next-CD menu, its own message), copies the packages (about 480 MB) into
`/var/tmp/makronix-pkgs` of the target and runs the target's own
`/usr/sbin/pkg_add` in the chroot with `PKG_PATH` pointing there and the names of
`<machine>/packages/top.list`, then removes the copy.  A second mount of the
medium inside the target does not work: the device is mounted already and
cd9660 refuses (EBUSY); the first try did that and said "Installing the extra
programs failed" with no pkg_add output (`install-simple-cd20-2026-11-07.log`).  The DVD carries the directory (`build/cd3` through `CDBUILDEXTRA`, patch 0008, see
`tools/cd3.sh`), CD 3 is made by it.  Nothing here is needed for a working
system: "no", or a medium without the directory, leaves it out.

Measured on the build VM (not yet through sysinst), `pkg_add -P` into a copy of
the sysroot's `/usr/pkg` with the files of the set already in place:
`pkg_add firefox thunderbird qemu` exit 0, 116 packages registered in
`/usr/pkg/pkgdb`, no conflict with the unregistered files of the set (only
xmlcatmgr says its catalogs "already exist"), `qemu-system-aarch64 --version`
prints 11.1.1 on NetBSD 11.99.9, 29 `qemu-system-*` targets.  pkg_add warns
"was built for a different platform: NetBSD 11.0 vs 11.99.9" for every package
and goes on.

## The desktop services and four CDs (2026-11-07, test pending)

Decided by the owner of the project, 2026-11-07: remote login on by default,
root allowed with the password ("I do not care"), mDNS and the like on by
default, PulseAudio as the sound daemon, and a four-CD install set is fine.
So the question about ssh that was written first (`MENU_sshmode`) is gone.

- `setup.c`: `set_ssh()` -- `sshd=YES`, a line `PermitRootLogin yes` at the end
  of `/etc/ssh/sshd_config` (password login is the default; the shipped file
  has `PermitRootLogin` at `prohibit-password` in a comment), `/etc/npf.conf`
  and `npf=YES`; `set_mdns()` -- `mdnsd=YES` and `hosts: files mdnsd dns` in
  `/etc/nsswitch.conf` (mDNSResponder and its NSS module are in the base
  system: `usr.sbin/mdnsd`, `lib nss_mdnsd.so.0`, `rc.d/mdnsd`; the module
  answers only `.local`); `set_pkg_defaults()` -- `PKG_PATH`,
  `CHECK_OS_VERSION=no`, `fetch_pkg_vulnerabilities=YES` (`docs/UPDATING.md`).
  The firewall opens ssh and UDP 5353 and nothing else
  (`docs/reference/npf-default.conf`, validated with `npfctl validate`).
- `extras.c`: the packages come from CD 3 and, if they need more, CD 4, ...
  (`tools/cd3.sh` splits them first-fit to 700 MB per CD; each CD has
  `packages/disc` "N M").  All CDs are copied into the target, then `pkg_add`
  runs once; `dbus` and `cupsd` are enabled from the examples the packages bring
  (`share/examples/rc.d`).  PulseAudio needs no rc script: the clients start it.
  The set today: Firefox, Thunderbird, QEMU, PulseAudio with `pavucontrol`, CUPS
  with `cups-filters`; 164 packages, 569 MB, so **one** CD for amd64 -- CD 4
  appears when the packages pass 700 MB.  The multi-CD code is tested by
  building the CDs with `CDPKG_LIMIT=300000000`.
- `msg.mi.{de,es,fr,pl}`: **an error found on 2026-11-07**: the messages I had
  appended with `printf '\0344'` in zsh had control characters where the umlauts
  and accents belong (zsh reads `\0NNN` as three digits including the 0), in
  four languages, from the setup step on; they were repaired byte by byte
  (`b*8+c`), the files now show the right letters.  The languages were never
  looked at on a screen: only English has been run.

## Portuguese (Brazil), 2026-11-07, not built yet

`msg.mi.pt`, `msg.pm.pt`, `msg.mbr.pt`, `msg.entropy.pt` and `arch/i386/msg.md.pt`
(ISO-8859-1, `pt` in `LANGUAGES`, locale `pt_BR.ISO8859-1`), plus patch `0013`
for the two lists that name a catalog (`list.sysinst`, `lists/base/md.amd64`).
The text was translated in five parts by parallel helpers from the English
files with one fixed rule set (structure, `printf` conversions, glossary,
80 columns); the main file is the four parts put together.  Checked by me with a
script: all 496 + 114 + 29 + 26 + 37 message names in the same order, the same
`%` conversions and `@@...@@` in every message, and every file encodable in
ISO-8859-1.  **Not checked:** that `msgc`/`msg_xlat.sh` accept it (that is the
build), how it looks on the screen (line widths of menus), and the quality of
the Portuguese by a native speaker.  The Polish texts written for the Makronix
messages have no diacritics (ASCII) -- the same kind of gap.

## The install image on a USB stick (2026-11-08)

`disks.c`, `is_root_wedge_parent()`: the root of the install image is a wedge
(`dk1`) of the stick (`sd0`); `is_active_rootpart()` compares names only and did
not exclude the stick, so the disk list offered the stick first (measured with
`tools/install-simple.sh -U`: `a: sd0 (3.0G)`).  The disk whose wedge is the
root is no longer listed.

## Makronix, not NetBSD, in the messages (2026-11-08)

The texts say Makronix; `@@MXVERSION@@` (from `src/sys/conf/makronix-release`,
`MAKRONIXVER` in `Makefile.inc`) is the product version, `@@VERSION@@` stays the
NetBSD version.  Kept as NetBSD on purpose: the CDN and the entropy-file
messages (they name NetBSD infrastructure), the partition type name in `mbr.c`,
the `EFI/NetBSD` directory of the ESP (efiboot reads `esp:/EFI/NetBSD/boot.cfg`),
the message identifiers and the RCS ids.  Patch `0015-makronix-identity` does the
same for the kernel banner, the boot loaders and the media names.

## The theme of the release (2026-11-08)

`palette.dp` is a copy of the CDE palette the release is named after
(`/usr/pkg/dt/share/palettes/Camouflage.dp`); `Makefile.inc` turns its slots 5
(window colour) and 4 (selected line, box) into `palette.h`, which `util.c`
includes for `do_coloring()`.  A release changes its installer colours by
replacing `palette.dp` (or `make PALETTE_DP=...`), not the C code.  Checked: the
default palette gives the old constants, 776/698/659 and 408/435/510.  Seen only
where the terminal can redefine colours (`can_change_color()`); on a fixed
8-colour console the installer is white on blue as before.  The welcome screen
shows the release name (`@@MXNAME@@` from `sys/conf/makronix-codename`).

## Why a command failed (2026-11-08)

`run.c`: upstream's `run_program()` says only "Command failed" for a command that
printed nothing on the screen (`RUN_SILENT`), and the output of such a command is
thrown away.  A MacBook Pro 2011 failed to create the partitions and the screen
said nothing else.  Now every command's output is kept (the last 512 bytes) and the
status line says `Command failed (<exit status>): <last line it printed>`; the log
(`Logging functions`) has the command and its whole tail, and silent commands'
output goes to the log.  `install.c`: before the partitions are written, the
simple mode clears the first and the last 4 MB of the disk (`wipe_disk_ends()`):
old partition maps, a GPT and its backup copy, LVM/LUKS headers.  Not done for
the encrypted install (`cgdroot`), which partitions in its own way.  Not yet
measured on a disk that failed: the QEMU tests only show that an installation
still works.

## No X sets without X in the base (2026-11-10)

Since X comes from pkgsrc (`X11_TYPE=modular`, in the `makronix` set) the
release has no `xbase`, `xcomp`, `xetc`, `xfont`, `xserver`, `xdebug` or
`xsrc`.  `Makefile.inc` defines `NO_X11_SETS` when `MKX11` is `no` (the
default, `share/mk/bsd.own.mk`); `defsizes.h` then selects and offers no X
set and `defs.h` leaves `xsrc`/`xdebug` out of the source and debug groups.
Without it both installation tests stopped at "Release set xbase does not
exist" (`build/logs/test-install-dvd-2026-11-10.log`).

======== src/usr.sbin/AGENTS.md
# usr.sbin/

Source for the utilities and files in `/usr/sbin` (hier(7)).  The important
one for Makronix is `sysinst/`, the installer: it is this tree's own version,
not upstream and not an overlay any more.  It teaches the
`makronix` set (`SET_MAKRONIX` in `defs.h`, a row in `dist_list` in `util.c`,
a message in every `msg.mi.*`).  The sysinst fork -- CDE palette, simple
install, optional encryption (`../../GOAL.md`) -- is built on it.  Read
`sysinst/` and sysinst(8) before changing it.  Changes are commits in the root
repository; see `../AGENTS.md`.

======== src/lib/AGENTS.md
# lib/

Source for the libraries in `/usr/lib` (hier(7)).  Makronix may change anything.  Changes are commits in the root repository; see `../AGENTS.md`.

`libmxlinux/` is Makronix's own and is built only for a Linux target
(Makronix/Linux, `mobile/conf/mk.conf`): what NetBSD's headers and libc have
and glibc lacks.  NetBSD's own sources are reached over with `.PATH`, never
copied; code of ours (`mx_*.c`) only where Linux's kernel or glibc must be
asked; a NetBSD header glibc has no counterpart for is reached over in
`libmxlinux/include/`.  Every declaration in `mxlinux.h` names the NetBSD
header line it stands in for.  Hazard: a macro of NetBSD's cdefs that is
also a member name in a glibc header changes that structure's layout
(`__used` in `<regex.h>`, 2026-11-12) -- such a header is included in
`mxlinux.h` before `mx_cdefs.h`.

======== src/distrib/AGENTS.md
# distrib/

Tools and data files for making releases and distributions (hier(7)).  This is
where the install media and the sets are made, so most Makronix changes live
here.

- `sets/` -- the set lists (`lists/<set>/`), `checkflist`, `sets.subr`,
  `makesrctars` (the source sets).  The list carries the `makronix` set.
  Deleting a list to make `checkflist` pass is forbidden.
- `amd64/` -- the amd64 media: `cdroms/installcd`, `cdroms/installdvd`,
  `ramdisks/`, `instkernel/`, `kmod/`.  `make release` builds the INSTALL
  kernel and ramdisks here (`distrib/amd64/Makefile`, `TARGETS+= release`);
  `iso-image` only packages them.  The media carry Makronix's changes: the CD
  size limit, the `boot.cfg` timeout, the serial console.
- `common/Makefile.bootcd` -- how a bootable CD is assembled.
- `notes/` -- the installation notes.

Read the Makefile of a medium before changing it.  Changes are commits in the
root repository; see `../AGENTS.md`.

======== src/etc/AGENTS.md
# etc/

Source, usually example files, for the files in `/etc` (hier(7)).
`etc.amd64/boot.cfg` is the `boot.cfg` the install medium ends up with: the
etc set is unpacked into the medium after the generated one
(`../../docs/reference/boot-cfg-timeout.txt`).  Makronix may change anything
yet.  Changes are commits in the root repository; see `../AGENTS.md`.
