Dashboard › opencode › Distillation
4bdaaa6f-6863-4591-bac5-66e727a333dd["lore_tm_v1_vqMwe_jNwXOaJHswnw_RIlFlqkMWnkOFvzj2AP8RQuI","lore_tm_v1_MZAqM11168Y5MIfG-hBIvLqNcOc8XsDo3Jhsnr_-xwc","lore_tm_v1_NXQ6mkZS1Bg--dDJ_X_7xF7eq7PnUZHVWrScDeYleKs","lore_tm_v1_9GlIJ1rPuUdh6VZM5UHSH5Ya6Wbc--UWh2EeN2jpW8k","lore_tm_v1_tFOtMzdl_IahpKEkyKjUuk1mZqVnH36To0tZ8q1jdR0","lore_tm_v1_EcYdUwDi9NP727cDYWvQic1l24LwofEdcS1SbF5IcMg","lore_tm_v1__PVU5GwB-V0H7LNMNTKc6ETZ9ENSzbsar5vetahTTC4","lore_tm_v1_59PRme94DGzRB-3D-I5SUAYyGQDaxsaX1mvcfLjnUpU","lore_tm_v1_xwAhuvo2EulhXD28SHuypySdB7aNbNunb26TGqFM4N4","lore_tm_v1_pr4ZQ2NogXViDZtWAZrZ1Y1m2RKwtaphPYCwmr-9CPo","lore_tm_v1_kUzPpN_HX3wVz1Jy5xCgM7ZDpFeGTul2R7E4pWnpLdw","lore_tm_v1_shN9ouDJsZZIHSRGpZ4qfrkPLcmVgtSTDNapkuCfEPg","lore_tm_v1_anbQJRGCj0RPF9Av7U1rPn78OdlzP1KisIS4UIHC3zg","lore_tm_v1_uSOxnNU36372097BMRu1qi4ypl2Uhm8vnGNyAkmU9Dc","lore_tm_v1_0GFDg9mF3D8t68ieyVcyYVYtG5XJfRxjXjjOzlMfuMQ","lore_tm_v1_i8MBgZDD6eRO_5MG-yEPm-oiMfaQLPD2WqEAHUTWh48","lore_tm_v1_aJizFMkywQDBAZvEhbcXwXAjHm5JXvZgYbOicMMLDKU","lore_tm_v1_7H5hw3ApHCYv4QZaYBmfRwvmKqK8zmFbLOc20QwJwlE","lore_tm_v1_e3MO2_gaiILytQeDpqRxi53wmqSeFpN8RHfNPCHekBI"]
Date: Sep 8, 2026
/home/byk/.local/share/opencode-v2-pilot/supervisor: ROOT-ACCEPTANCE.md, PROTOCOL.md, go.mod, go.sum, opencode-pty-supervisor.service, opencode-pty.slice, bin/opencode-pty-launcher, bin/opencode-pty-supervisor, cmd/supervisor/main.go, cmd/launcher/main.go, cmd/launcher/main_test.go, internal/protocol/frame.go, internal/protocol/frame_test.go, internal/supervisor/auth.go, internal/supervisor/auth_test.go, internal/supervisor/server.go, internal/supervisor/server_test.go, internal/supervisor/systemd.go, and internal/supervisor/systemd_test.go. Top-level directory has 9 entries: bin/, cmd/, go.mod, go.sum, internal/, opencode-pty-supervisor.service, opencode-pty.slice, PROTOCOL.md, and ROOT-ACCEPTANCE.md./home/byk/.local/share/opencode-v2-pilot/config/opencode/node_modules/effect/AGENTS.md.go.mod declares module opencode-pty-supervisor, Go 1.22, and pinned direct dependencies: github.com/coreos/go-systemd/v22 v22.5.0, github.com/godbus/dbus/v5 v5.1.0, and golang.org/x/sys v0.20.0; go.sum contains checksums for those versions plus the github.com/godbus/dbus/v5 v5.0.4/go.mod checksum.st_dev and st_ino, requires it to be a directory, and βnever resolves a client path.βPROTOCOL.md defines one Unix SOCK_STREAM connection per PTY and a 12-byte frame header: bytes 0β3=OPTY, byte 4=version 1, byte 5=type, bytes 6β7=zero, bytes 8β11=unsigned big-endian payload length capped at 65536.PROTOCOL.md defines the authenticated clientβs single start frame as type 1 with exactly one SCM_RIGHTS directory descriptor; payload fields are unsigned big-endian st_dev, st_ino, optional runtime seconds, argument count, and length-prefixed argument bytes. After admission, client input frames are type 2 and at most 32768 bytes; supervisor frames are output type 3, exit type 4, or error type 5. Exit payload is one byte ExecMainCode, four bytes ExecMainStatus, four bytes of result-string length, then structured systemd Result.PROTOCOL.md says the launcher receives the unit stream as stdin/stdout and approved cwd descriptor as stderr; it calls fchdir(2), replaces stderr with stdout, clears the environment, sets a fixed environment, accepts encoded arguments using grammar a[A-Za-z0-9_-]* with canonical URL-safe unpadded base64 suffixes, shell-quotes each argument, and executes /usr/bin/script -qefc COMMAND /dev/null.ROOT-ACCEPTANCE.md specifies 10 ordered root-only acceptance gates: 1. freshly build and install both binaries into root-controlled /usr/local/libexec with owner/group root:root and mode 0755, never executing the root supervisor or transient launcher from the user-writable source tree; 2. install reviewed service/slice files into /etc/systemd/system as root-owned mode 0644, run systemd-analyze verify, and do not yet enable/start them; 3. verify /usr/local/libexec, both binaries, and every parent directory are root-controlled and not writable by byk or any group; 4. run a disposable root-started supervisor while opencode-v2.service is inactive, require every connection to fail authentication, and require kernels lacking SO_PEERPIDFD to fail closed; 5. in a test VM, use an isolated disposable client matching production unit identity and confirm rejection of wrong PID, child PID, inactive state, wrong cgroup, PID replacement, missing/extra descriptors, non-directory descriptors, and mismatched st_dev/st_ino; 6. confirm a valid session creates only opencode-pty-[0-9a-f]{32}.service, runs as byk:byk in opencode-pty.slice, receives the fixed environment, starts in the descriptor-selected directory, and preserves spaces, quotes, shell metacharacters, and newlines without evaluation; 7. inspect transient-unit D-Bus properties and verify Docker, system D-Bus, and user D-Bus sockets are inaccessible from the command; 8. exercise 16 concurrent sessions and rejection of the 17th, plus maximum frames/arguments, slow/disconnected readers, unlimited output until backpressure, optional RuntimeMaxSec, TERM-to-KILL escalation, nonzero/signal exits, protocol failure, client disconnect, and supervisor shutdown; 9. verify the complete transient cgroup disappears and systemd emits UnitRemoved after every failure, then restart only the disposable supervisor and verify strict-name/exact-BindsTo orphan cleanup removes owned orphans but preserves lookalike/foreign units; 10. obtain an independent exact-source security review before installation or production cutover.opencode-pty-supervisor.service runs /usr/local/libexec/opencode-pty-supervisor as User=root, Group=byk, with Type=exec, After=/Requires=dbus.service, RuntimeDirectory=opencode-pty, RuntimeDirectoryMode=0750, RuntimeDirectoryPreserve=no, NoNewPrivileges=yes, UMask=0077, KillMode=control-group, KillSignal=SIGTERM, FinalKillSignal=SIGKILL, SendSIGKILL=yes, TimeoutStopSec=20s, OOMPolicy=kill, Delegate=no, RestrictAddressFamilies=AF_UNIX, PrivateTmp=yes, ProtectSystem=strict, ProtectKernelTunables=yes, ProtectKernelModules=yes, ProtectKernelLogs=yes, ProtectControlGroups=yes, ProtectClock=yes, RestrictSUIDSGID=yes, LockPersonality=yes, and MemoryDenyWriteExecute=yes; install target is multi-user.target.opencode-pty.slice enables CPU, memory, and task accounting and sets MemoryMax=2G and TasksMax=512.cmd/supervisor/main.go creates a context canceled by SIGINT or SIGTERM, calls supervisor.NewSystemdManager(ctx), defers manager.Close(), then runs supervisor.NewServer(manager).Serve(ctx); manager-construction or serve errors are printed to stderr and exit with status 1.cmd/launcher/main.go defines maxArgs=128 and maxArgSize=4096. run() first calls decodeCommand(), then syscall.Fchdir(2), syscall.Dup2(1, 2), os.Clearenv(), and installs exactly HOME=/home/byk, LANG=C.UTF-8, LOGNAME=byk, PATH=/usr/local/bin:/usr/bin:/bin, TERM=xterm-256color, and USER=byk; it finally calls syscall.Exec("/usr/bin/script", []string{"script", "-qefc", command, "/dev/null"}, os.Environ()).decodeCommand() in cmd/launcher/main.go rejects zero arguments or more than 128; each encoded argument must begin with a, fit the base64 encoding of at most 4096 decoded bytes, contain only ASCII letters/digits/-/_, decode as canonical base64.RawURLEncoding, and contain no NUL. It wraps every decoded argument in single quotes, escapes embedded ' as '\\'', and joins arguments with spaces.cmd/launcher/main_test.go tests: TestDecodeCommandQuotesEveryArgument expects encoded printf, %s\n, a'b; $(id), and an empty argument to become 'printf' '%s\n' 'a'\''b; $(id)' ''; TestDecodeCommandRejectsInvalidGrammar rejects bad=; TestLauncherExecutesInDescriptorDirectory passes a temp-directory descriptor as stderr to a helper process, runs /usr/bin/pwd, and verifies output contains that directory.internal/protocol/frame.go defines HeaderSize=12, MaxFrameSize=64*1024, MaxIOPayloadSize=32*1024, Version=1, frame types TypeStart=1, TypeInput=2, TypeOutput=3, TypeExit=4, TypeError=5, MaxArgs=128, MaxArgSize=4096, and MaxRuntimeSec=3600; framing errors are ErrInvalidFrame and ErrFrameTooLarge.internal/protocol/frame.go implements ReadFrame(), WriteFrame(), MarshalFrame(), and ParsePacket() with exact-header validation, full reads/writes, a 65536-byte payload cap, valid types 1β5, and rejection of nonzero reserved bytes. EncodeStart()/DecodeStart() encode Device uint64, Inode uint64, RuntimeSec uint32, Args []string in a 22-byte fixed prefix plus uint16-length-prefixed arguments; they require 1β128 arguments, a nonempty first argument, argument lengths at most 4096, runtime at most 3600, no decoded NUL bytes, no trailing payload, and total payload at most MaxFrameSize.internal/protocol/frame_test.go covers a start round trip with Device=12, Inode=34, RuntimeSec=60, args printf, %s, hello world; an input-frame round trip with payload hello; rejection of MaxFrameSize+1; rejection of argument a\x00b; and FuzzParsePacket seeded with a type-TypeInput frame containing seed.internal/supervisor/auth.go authenticates by obtaining both SO_PEERCRED and SO_PEERPIDFD, marking the pidfd close-on-exec, and failing if either lookup fails or the pidfd is negative. authenticate() requires peer PID >0 and equal to systemd MainPID, ActiveState=="active", and ControlGroup=="/system.slice/opencode-v2.service"; it validates liveness with unix.PidfdSendSignal(pidfd, 0, nil, 0), then re-queries systemd and rejects changed PID, inactive state, or unexpected cgroup. The pidfd is closed on return.internal/supervisor/auth_test.go tests successful authentication for the current process, rejection when MainPID=os.Getpid()+1, and rejection when ActiveState="inactive"; the test manager returns the configured PID/state/cgroup and stubs Start, StopAndWait, Wait, CleanupOrphans, and Close.internal/supervisor/systemd.go fixes identities and limits as clientService="opencode-v2.service", supervisorService="opencode-pty-supervisor.service", ptySlice="opencode-pty.slice", expectedClientCgroup="/system.slice/opencode-v2.service", launcherPath="/usr/local/libexec/opencode-pty-launcher", unitPrefix="opencode-pty-", unitSuffix=".service", and stopTimeout=15*time.Second; valid names must match ^opencode-pty-[0-9a-f]{32}\.service$.systemdManager.ClientState() reads and type-checks systemd MainPID as uint32, ActiveState as string, and ControlGroup as string. Start() calls StartTransientUnitContext(ctx, name, "fail", properties, result) and accepts only job result done. Wait() subscribes to unit signals and polls until ActiveState=="failed", SubState=="exited", or ActiveState=="inactive", then decodes Result, ExecMainCode, and ExecMainStatus.StopAndWait() rejects invalid unit names, applies a 15-second timeout, subscribes before calling StopUnitContext(..., "replace", ...), treats org.freedesktop.systemd1.NoSuchUnit as success, waits for matching UnitRemoved, and on timeout accepts a missing or inactive unit but otherwise returns await unit removal. subscribeUnitSignals() opens a private system bus, performs Auth(nil) and Hello(), calls systemd Manager Subscribe, matches unit PropertiesChanged plus Manager UnitRemoved filtered by unit name, and uses a signal channel buffered to 8.CleanupOrphans() lists opencode-pty-*.service, ignores names failing the strict regex, reads each unitβs properties, and stops only units whose BindsTo is exactly a one-element []string{"opencode-pty-supervisor.service"}.unitProperties() base64url-encodes every argument with an a prefix and fixes transient-unit properties: description OpenCode isolated PTY plus name; Type=exec; launcher ExecStart; Slice=opencode-pty.slice; BindsTo= and After=opencode-pty-supervisor.service; User=byk; Group=byk; NoNewPrivileges=true; UMask=0077; KillMode=control-group; KillSignal=15; FinalKillSignal=9; SendSIGKILL=true; TimeoutStopUSec=15,000,000; OOMPolicy=kill; Delegate=false; RemainAfterExit=true; CollectMode=inactive; stream fd as both StandardInputFileDescriptor and StandardOutputFileDescriptor; cwd fd as StandardErrorFileDescriptor; and InaccessiblePaths={"/run/dbus/system_bus_socket","/run/docker.sock","/run/user/1000/bus","/var/run/docker.sock"}. When runtimeSec>0, it adds RuntimeMaxUSec=runtimeSec*1,000,000.internal/supervisor/systemd_test.go verifies the valid name opencode-pty-0123456789abcdef0123456789abcdef.service; rejects an empty identifier, uppercase hex, .scope, and a .service/../x suffix; checks presence of User, Group, NoNewPrivileges, UMask, KillMode, KillSignal, FinalKillSignal, SendSIGKILL, TimeoutStopUSec, OOMPolicy, Delegate, Slice, BindsTo, After, all three standard-fd properties, InaccessiblePaths, and RuntimeMaxUSec; verifies User=="byk" and Delegate==false; and tests decoding Result="exit-code", ExecMainCode=1, ExecMainStatus=7.