authoravatarclover caruso<git@paperclover.net>2026-10-25 04:33:53-07:00
committeravatarclover caruso<git@paperclover.net>2026-11-12 16:08:55-08:00
log6544ee39cbc4b1e3af5467239fed6984f31c63e7
treeb85f2da91635b6d06ebd43b954a37019cdbc61d7
parentecf3b9eed4f36a0f45f018eff1eef6cf79646a31
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Stabilize Snow Globe networking and add the workspace SSD

Preserve the live CPU partition and published runtime launcher, protect the new server processes, include browser dependencies, and record the Mac VM code-share mount retry. Match the Ethernet adapter by MAC address so PCI renumbering does not change its configured interface name. Import the work pool and bind it into Knife at /work on startup. Assisted-by: gpt-6.1-sol Assisted-by: gpt-6.1-terra

9 files changed, 73 insertions(+), 46 deletions(-)

guest/net.paperclover.code-share.plist created+19
......@@ -0,0 +1,19 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>Label</key>
6 <string>net.paperclover.code-share</string>
7 <key>ProgramArguments</key>
8 <array>
9 <string>/bin/sh</string>
10 <string>-c</string>
11 <string>/sbin/mount | /usr/bin/grep -Fq ' on /Volumes/Code (' &amp;&amp; exit 0
12/bin/mkdir -p /Volumes/Code &amp;&amp; /sbin/mount /Volumes/Code</string>
13 </array>
14 <key>RunAtLoad</key>
15 <true/>
16 <key>StartInterval</key>
17 <integer>30</integer>
18</dict>
19</plist>
nixos/knife-linux.Containerfile+1-1
......@@ -7,7 +7,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \
77 openssh-clients openssl-devel patch procps-ng python3 ripgrep rsync rust tar time tree unzip \
88 which xz zip zlib-ng-compat-devel zsh \
99 chromium fontconfig google-noto-sans-fonts google-noto-sans-mono-fonts google-noto-serif-fonts \
10 liberation-mono-fonts liberation-sans-fonts liberation-serif-fonts mesa-dri-drivers \
10 liberation-mono-fonts liberation-sans-fonts liberation-serif-fonts mesa-dri-drivers mesa-libGLES dbus-daemon \
1111 xorg-x11-server-Xvfb \
1212 && dnf clean all
1313
nixos/knife-linux.nix+12-7
......@@ -15,7 +15,10 @@ let
1515 exec ${pkgs.podman}/bin/podman --root=${root}/containers/storage --runroot=/run/knife-linux/containers "$@"
1616 '';
1717 run = "${podman}/bin/knife-linux-podman";
18 ccd = "8-15,24-31";
18 cpus = "3-15,19-31";
19 checkWork = pkgs.writeShellScript "check-knife-work" ''
20 test "$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE --mountpoint /srv/work)" = work
21 '';
1922in
2023{
2124 environment.systemPackages = [ podman ];
......@@ -24,8 +27,8 @@ in
2427 description = "The Knife Linux agent container";
2528 wantedBy = [ "multi-user.target" ];
2629 wants = [ "network-online.target" ];
27 after = [ "network-online.target" "mac-studio-sandbox.service" ];
28 requires = [ "mac-studio-sandbox.service" ];
30 after = [ "network-online.target" "mac-studio-sandbox.service" "zfs-import-work.service" "zfs-mount.service" ];
31 requires = [ "mac-studio-sandbox.service" "zfs-import-work.service" ];
2932 # Restarting stops every running agent, so changes wait for a manual restart.
3033 restartIfChanged = false;
3134 serviceConfig = {
......@@ -33,6 +36,7 @@ in
3336 NotifyAccess = "all";
3437 ExecStartPre = [
3538 "${pkgs.util-linux}/bin/mountpoint -q ${root}"
39 checkWork
3640 "${run} build --quiet --build-arg=UID=${uid} --build-arg=GID=${gid} --tag=localhost/knife-linux --file=${./knife-linux.Containerfile} /var/empty"
3741 ];
3842 ExecStart = lib.concatStringsSep " " [
......@@ -42,18 +46,19 @@ in
4246 "--memory=96g --pids-limit=32768 --shm-size=2g --network=podman"
4347 "--volume=${root}/home:/home/clo"
4448 "--volume=${sandbox}:/Volumes/Code"
49 "--volume=/srv/work:/work"
4550 "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro"
4651 "--device=/dev/kvm"
4752 "localhost/knife-linux"
4853 ];
49 # Agents get the second CCD to themselves and the host keeps the first. A partition
54 # Agents get 13 cores to themselves and the host keeps three. A partition
5055 # rather than a CPU quota: an exhausted quota freezes the Knife server with the builds.
5156 ExecStartPost = "-" + pkgs.writeShellScript "knife-linux-cpus" ''
5257 set -e
5358 scope=/sys/fs/cgroup$(${run} inspect --format '{{.State.CgroupPath}}' knife-linux)
54 echo ${ccd} > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive
55 echo ${ccd} > $scope/cpuset.cpus.exclusive
56 echo ${ccd} > $scope/cpuset.cpus
59 echo ${cpus} > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive
60 echo ${cpus} > $scope/cpuset.cpus.exclusive
61 echo ${cpus} > $scope/cpuset.cpus
5762 echo root > $scope/cpuset.cpus.partition
5863 '';
5964 ExecStop = "${run} stop --ignore --time=90 knife-linux";
nixos/snowglobe-network.nix+8
......@@ -1,4 +1,12 @@
11{
2 systemd.network.links."10-snowglobe-ethernet" = {
3 matchConfig.MACAddress = "04:42:1a:0d:e9:b3";
4 linkConfig = {
5 NamePolicy = "";
6 Name = "enp4s0";
7 };
8 };
9
210 networking.useDHCP = false;
311 networking.interfaces.enp4s0.useDHCP = false;
412 networking.interfaces.enp4s0.ipv4.addresses = [
nixos/snowglobe.nix+1-1
......@@ -52,7 +52,7 @@ in
5252 boot.loader.systemd-boot.enable = true;
5353 boot.loader.efi.canTouchEfiVariables = true;
5454 boot.zfs.forceImportRoot = false;
55 boot.zfs.extraPools = [ pool ];
55 boot.zfs.extraPools = [ pool "work" ];
5656 boot.zfs.requestEncryptionCredentials = false;
5757 security.tpm2.enable = true;
5858
tools/knife-linux-oom.py+7-2
......@@ -13,6 +13,7 @@ HARNESS = re.compile(
1313 r"|/home/clo/\.knife/tools/(claude/[^/]+/claude|codex/[^/]+/bin/codex)"
1414)
1515SERVER = re.compile(r"/home/clo/\.local/share/knife-server/[^/]+/apps/server/dist/bin\.mjs")
16RUNTIME = re.compile(r"/home/clo/\.knife/runtime/versions/[^/]+/t3")
1617PROTECTED, WORK = -1000, 800
1718NETLINK_CONNECTOR, CN_IDX_PROC, PROC_CN_MCAST_LISTEN, PROC_EVENT_EXEC = 11, 1, 1, 2
1819
......@@ -25,7 +26,11 @@ def adjust(pid, scope):
2526 names = [os.readlink(f"/proc/{pid}/exe"), *(a.decode(errors="replace") for a in argv[1:2])]
2627 path = f"/proc/{pid}/oom_score_adj"
2728 current = int(open(path).read())
28 protected = any(HARNESS.fullmatch(name) for name in names)
29 server = any(SERVER.fullmatch(name) for name in names) or (
30 argv[1:2] in ([b"serve"], [b"__service-launcher"])
31 and any(RUNTIME.fullmatch(name) for name in names)
32 )
33 protected = server or any(HARNESS.fullmatch(name) for name in names)
2934 if protected:
3035 wanted = PROTECTED
3136 elif current < 0:
......@@ -34,7 +39,7 @@ def adjust(pid, scope):
3439 wanted = current
3540 if current != wanted:
3641 open(path, "w").write(str(wanted))
37 nice = -20 if any(SERVER.fullmatch(name) for name in names) else 0 if protected else 19
42 nice = -20 if server else 0 if protected else 19
3843 # Niceness belongs to each thread; renicing the leader leaves workers unchanged.
3944 for tid in os.listdir(f"/proc/{pid}/task"):
4045 try:
tools/knife-linux.md+8-29
......@@ -4,7 +4,7 @@
44agents directly beside ZFS. [knife-linux.nix](../nixos/knife-linux.nix) builds it
55from [knife-linux.Containerfile](../nixos/knife-linux.Containerfile) on each start
66and runs it as the `knife-linux` system service: uid 3000 (`clo`), no
7capabilities, the 16 threads of the second CCD to itself, a 96 GiB memory limit, `/dev/kvm`, and Podman's NAT network.
7capabilities, 13 cores (26 threads) to itself, a 96 GiB memory limit, `/dev/kvm`, and Podman's NAT network.
88Knife listens on container loopback port 3773; devices reach it through the mesh
99as `snowglobe` (device `4b85ee48…`). User namespaces work inside, but Podman's
1010seccomp filter blocks the `chroot` Chromium-based sandboxes need, so Chromium,
......@@ -24,6 +24,7 @@ added to the running container.
2424| Container path | Host source |
2525| --- | --- |
2626| `/Volumes/Code` | the Mac VM's NFS export, `/srv/mac-studio-vm/sandbox` |
27| `/work` | the unencrypted, uncompressed `work` SSD pool, `/srv/work` |
2728| `/home/clo` | `/srv/knife-linux/home` on `globe/clover/knife-linux` |
2829| `/usr/local/bin/jj` | the storage host's `jj-real`, read-only |
2930
......@@ -63,34 +64,12 @@ store in `~/.git-credentials`.
6364
6465## Runtime and updates
6566
66The active runtime is `~/.local/share/knife-server/current`, pointing to
67`build-372d14b9d5b4-linux-tmp`. This is a pinned native build of Clover's
68`knife-merge` fork, not the older published Linux container. Source archive
69SHA256: `372d14b9d5b41eef1e8bcc856966fbc8749dd091df1ac09682c9238770f68b39`.
70Private installation archives are on ZFS in `/srv/vm/.knife-linux-deploy-20261023`.
71Apply [knife-linux-codex.patch](knife-linux-codex.patch) before building. It keeps
72Codex's `.tmp` plugin locks local to each profile so restarts can recreate drivers.
73[knife-server](knife-server) is the `~/.local/bin/knife` launcher.
74
75Build inside the container from a fresh source directory, keeping the current
76runtime available until verification succeeds:
77
78```sh
79pnpm install --frozen-lockfile
80vp run --filter t3 build
81CARGO_BUILD_JOBS=8 cargo build --locked --release \
82 --manifest-path native/knife-mesh/Cargo.toml -p knife-mesh-node \
83 --target x86_64-unknown-linux-gnu
84CARGO_BUILD_JOBS=4 cargo build --locked --release \
85 --manifest-path native/resource-monitor/Cargo.toml
86```
87
88After the server build, stage `libknife_mesh_node.so` as
89`apps/server/dist/knife-mesh/linux-x64/knife_mesh.node` and the resource monitor as
90`apps/server/dist/resource-monitor/linux-x64/t3-resource-monitor`. Stage the font
91assets in `apps/server/dist/client/fonts` and link `node` in the runtime root to
92`/opt/node/26.12.1/bin/node`. Switch `current` and restart only when agents are
93idle. Automatic fork updates are not configured for this source build.
67The published Linux runtime lives under `~/.knife/runtime/versions`, with
68`~/.knife/runtime/current` selecting the active version and `runtime/release-feed`
69selecting the Knife release feed. [knife-server](knife-server) is installed as
70`~/.local/bin/knife`; the container's `start` command runs the foreground service
71launcher in web mode, allowing remote updates to replace the server in place.
72The previous source build remains under `~/.local/share/knife-server`.
9473
9574## Agent homes
9675
tools/knife-server+13-6
......@@ -1,9 +1,16 @@
11#!/bin/sh
22set -eu
33
4runtime="$HOME/.local/share/knife-server/current"
5export T3CODE_HOME="${T3CODE_HOME:-$HOME/.knife}"
6export T3CODE_CLI_PATH="$HOME/.local/bin/knife"
7export KNIFE_MESH_ADDON="$runtime/apps/server/dist/knife-mesh/linux-x64/knife_mesh.node"
8export T3CODE_RESOURCE_MONITOR_PATH="$runtime/apps/server/dist/resource-monitor/linux-x64/t3-resource-monitor"
9exec "$runtime/node" "$runtime/apps/server/dist/bin.mjs" "$@"
4export KNIFE_HOME="$HOME/.knife"
5export T3CODE_HOME="$KNIFE_HOME"
6
7if [ "${1:-}" = start ]; then
8 shift
9 if [ "${1:-}" = --mode ] && [ "${2:-}" = desktop ]; then
10 shift 2
11 set -- --mode web "$@"
12 fi
13 export KNIFE_FOREGROUND_SUPERVISOR=1
14 exec "$KNIFE_HOME/runtime/current/t3" __service-launcher serve "$@"
15fi
16exec "$KNIFE_HOME/runtime/current/t3" "$@"
tools/mac-agent-vm.md+4
......@@ -166,6 +166,10 @@ through the guest agent into the logged-in session's pasteboard; no automatic
166166keystroke or continuous clipboard sharing is enabled. SSH resolves the current
167167VM address each time and reuses the existing pinned key configuration.
168168
169The guest mounts Snow Globe’s NFS export at `/Volumes/Code` using `/etc/fstab`.
170[net.paperclover.code-share.plist](../guest/net.paperclover.code-share.plist)
171runs as a system LaunchDaemon at boot and retries every 30 seconds if needed.
172
169173The guest's `/etc/hosts` maps `file.paperclover.net` to the NAS LAN address
170174`10.0.0.1`. Traffic uses the VM's NAT gateway `192.168.64.1`; the host's hosts
171175file is not inherited. The previous guest file is `/etc/hosts.before-code-nas`.