SchOS/.claude/memory/schunix-network-stack-choice.md
Nexoniarz 57aff40228 docs: four directories, and a rule for when a thing leaves the roadmap
docs/ was ten files where a plan, a description, a guide and a bug report all
sat next to each other. It is now architecture/ (what SchOS is), plan/ (what it
will be), guides/ (how to work on it) and history/ (why it is like this), with
an index that states the one rule holding it together: when something is
finished it moves from plan/ to architecture/ and is rewritten as a description
of the thing rather than a record of building it.

A ticked checkbox says the work happened. It does not say what the work
*produced*, and six months later the checkbox is all that is left. The network
stack proved the point: finished, verified end to end, and for a month the only
description of it anywhere was a checkbox four levels of indentation deep.

So roadmap.md went from 534 lines to 181 -- nothing deleted, the done work
graduated. Seven subsystems that were finished and undescribed now have
descriptions: boot, kernel, syscalls, filesystem, networking, graphics, usb,
init. Every one ends with "What it does not do", which is the section that pays;
a document listing only strengths is marketing, and the reader who needs it most
is the one about to trip over a limitation nobody wrote down.

schfs.md still opened with "phases 1 through 3 1/2 are done, phase 4 is next"
long after all five had landed. It is a description now, with the phase record
and the hard-won bugs moved to history/.

Three corrections found on the way, all load-bearing:

  * projects/schcom/README.md claimed SCM_RIGHTS was done. There is no
    sendmsg/recvmsg in the kernel at all, and an entire GUI plan rested on it.
  * The root README said "No TCP/IP" months after the stack landed.
  * history/kernel.md sec.7 was marked "in progress" on a problem that process
    groups solved.

Also adds plan/1.0.md, which draws a finish line so the open list stops being
infinite, and marks schwm/ and schde/ superseded: in Wayland the compositor is
the window manager, so that split dissolves rather than being abandoned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
2026-09-12 17:13:35 +02:00

61 lines
2.9 KiB
Markdown

---
name: schunix-network-stack-choice
description: "Don't write TCP from scratch — and don't take NetBSD's either; the licence and porting evidence for lwIP vs FreeBSD."
metadata:
node_type: memory
type: project
originSessionId: 9d8a2aef-bcf0-47a0-96c6-f706efab4a95
modified: 2026-08-08T20:25:37.412Z
---
Decided 2026-08-08. Nexoniarz: "we should take FreeBSD or NetBSD and their
Network stuff because it's going to be hell making own TCP/IP." **Agreed on the
premise** — TCP is the one part of a network stack where writing it yourself is
a bad trade. It is not the packet format that is hard; it is congestion control,
retransmission, window management and twenty years of corner cases that only
appear against a real peer.
**But the source matters, and NetBSD is the wrong one.**
## The licence evidence (all verified, not assumed)
| | advertising clause? |
|---|---|
| NetBSD `sys/netinet/tcp_input.c`, `tcp_output.c` | **Yes** — the WIDE Project's 4-clause |
| FreeBSD `sys/netinet/tcp_input.c` | **No** — UC, Swinburne, FreeBSD Foundation, Juniper |
| lwIP | **No** — BSD-3, Swedish Institute of Computer Science |
The NetBSD clause belongs to **WIDE**, not Berkeley, so the 1999 rescission does
not reach it. Checked FreeBSD's file directly from `raw.githubusercontent.com`;
zero matches for "All advertising materials". Checked lwIP's `COPYING`; likewise
zero. This **reverses** the older assumption in `docs/plan/roadmap.md` that NetBSD
was the intended starting point.
## The porting evidence, which matters more
FreeBSD's `sys/netinet` is not a library. `tcp_input.c` alone is 122 KB and
reaches into mbufs, `epoch(9)`, netisr, VNET, `uma(9)`, sockbufs, inpcb hash
tables and FreeBSD's locking. Taking it means porting FreeBSD's kernel
infrastructure first and finding the TCP underneath — the same conclusion
`docs/plan/roadmap.md` §1 already reached about `sys/dev/usb`.
**lwIP was written for the situation Schunix is actually in:** a small OS with a
raw Ethernet driver and no infrastructure. Port layer is a handful of files, no
dependency on the host allocator or locking, and it brings ARP, IPv4, ICMP, UDP,
TCP, DHCP and DNS.
**Recommendation: lwIP first, FreeBSD as the reference to check against.**
## Practical notes
- Nexoniarz deleted the NetBSD checkout (`src-trunk/`) for space and said it can
be re-fetched. **Do not clone a whole BSD tree** — a sparse checkout of
`sys/net` and `sys/netinet` is all that has ever been needed, and the space
complaint was legitimate.
- One-file fetches from `raw.githubusercontent.com` are enough for a licence
check and cost nothing. That is how both findings above were made.
- Shell trap hit while doing this: `grep -c` **exits 1 when it finds zero
matches**, so `cmd && grep -c ... || echo "failed"` prints the failure message
on a perfectly successful run. Nearly reported "no network access" when the
fetch had worked.
- Whichever is chosen, it needs a `NOTICE` entry — see [[schunix-licensing]].