Dashboard › opencode › Distillation
e47d1157-e99f-48dc-8199-2cb24a7ebfa9["lore_tm_v1_AsFzEOcIwyActIJMwRted9yl0WWgwWAgLB9AmEiYQiE","lore_tm_v1_AmpFElQkZKFf2DZ37etD5SQJz8j6C6ID1QJ_6lcHONQ","lore_tm_v1_jNNVWyS9DdS7FdvLqzfAJJf-QPw_43TDO_QWZHQWwNY","lore_tm_v1_NIya4aWHOTTif3AeTMZh8zymcgIgeetvnex3IGO0-3k","lore_tm_v1_cXkGyGu6fKPCa_LEaxUzAP7s0XufSy4j72vaLlYDfQw","lore_tm_v1_bVNmjZzWqYibL6sk8GMjgBQ_KZgjZILbsKhDyohAaMk","lore_tm_v1_aMOWRwk3doxsSfUqZzl8hb197HfwHqBzDAhscNQ-o6U","lore_tm_v1_2dYWwksyYQbQENbk43Mm8l02OXJnSzbpFdRfxWf2zxQ","lore_tm_v1_eEbd7XWqxEG_doi1Di_S-zU04P8oY070YxAz4fof__E","lore_tm_v1_29rkUWDEKjE5fWDKb3yuHA1Qd_MIBUnbZ-4ux1WCxmk","lore_tm_v1_3RBnFwBVRaaVS2PF6KYGAuMc3rnxMw5BeQLyGmpPtIE","lore_tm_v1_aORibp1Mvv4V6lBBYLUPlqlRuuooj-RsW3_hiOmNTwE","lore_tm_v1_wjKP8KV9EdGg5YLM_RaIAqkyqDqeR-eala5rT_56hZA","lore_tm_v1_E7GTGCsuDO_xBCvTHqGzhHim_dW2jXQzXrM0BwNjI-k"]
Date: Sep 8, 2026
/home/byk/.local/share/opencode-v2-pilot/supervisor/cmd/launcher/main_test.go contains 5 launcher behaviors under test: TestDecodeArgumentsPreservesEveryArgument decodes ["printf","%s\\n","a'b; $(id)",""]; TestDecodeArgumentsRejectsInvalidGrammar rejects "bad="; TestScriptArgumentsRequireInteractiveShellAndExitPropagation requires ["script","-q","-e","-f","-c","/bin/sh -i -c 'exec /proc/self/fd/3 --exec'","/dev/null"]; TestLauncherExecutesInDescriptorDirectory verifies /usr/bin/pwd runs in the directory supplied through stderr; and TestLauncherPropagatesExitAndSignalStatus expects exit 7 from exit 7 and exit 143 from kill -TERM $$.TestLauncherPreservesMetacharactersAndNewlinesWithoutEvaluation passes the literal value "a'b; $(id)\nsecond line" to /usr/bin/printf "%s\n" and verifies it is emitted unchanged except for the final newline. buildLauncher() runs go build -trimpath -o <temp>/opencode-pty-launcher ../home/byk/.local/share/opencode-v2-pilot/supervisor/internal/supervisor/auth_test.go defines authenticationManager and currentIdentity() with current PID, ActiveState:"active", SubState:"running", ControlGroup:expectedClientCgroup, and InvocationID:[]byte("0123456789abcdef").peer.Recheck(), reject wrong UID, wrong GID, changed PID, inactive state, substate "exited", control group "/wrong", and missing InvocationID, and reject an InvocationID changed after authentication to "fedcba9876543210"./home/byk/.local/share/opencode-v2-pilot/supervisor/internal/supervisor/systemd_test.go verifies validUnitName() accepts only a lowercase 32-hex service name such as opencode-pty-0123456789abcdef0123456789abcdef.service, rejecting an empty suffix, uppercase hex, .scope, and traversal suffix .service/../x.waitForUnitSignal() rejects a closed signal channel and honors context timeout; waitForJobResult() rejects a closed channel, non-done result "canceled", and timeout.TestUnitPropertiesAreFixed requires transient-unit properties User, Group, SupplementaryGroups, NoNewPrivileges, CapabilityBoundingSet, AmbientCapabilities, UMask, KillMode, KillSignal, FinalKillSignal, SendSIGKILL, TimeoutStopUSec, OOMPolicy, Delegate, Slice, BindsTo, After, all 3 standard file descriptors, InaccessiblePaths, PrivateDevices, DevicePolicy, ProtectControlGroups, ProtectProc, ProcSubset, RestrictNamespaces, RestrictAddressFamilies, SystemCallArchitectures, SystemCallFilter, all 4 accounting settings, CPUQuotaPerSecUSec, MemoryHigh, MemoryMax, TasksMax, and RuntimeMaxUSec; it specifically requires User="byk", Delegate=false, D-Bus signature (bas) for RestrictAddressFamilies and SystemCallFilter, and signature as for SupplementaryGroups.TestDecodeUnitResult verifies {"Result":"exit-code","ExecMainCode":int32(1),"ExecMainStatus":int32(7)} decodes without changing those exact values./home/byk/.local/share/opencode-v2-pilot/supervisor/internal/supervisor/server_test.go defines sessionManager with controllable startErr, wait, stop, and stopped; StopAndWait() closes stopped exactly once before invoking the optional stop callback.TestReceiveStartWithDirectoryDescriptor receives one cwd descriptor with FD_CLOEXEC and command printf/argument ok; TestReceiveStartRejectsMetadataMismatch rejects frame device/inode 1/2; TestReceiveStartClosesEveryExtraDescriptor rejects two descriptors without changing /proc/self/fd count; and TestReceiveStartHandlesFragmentedHeader accepts a header split after its first 3 bytes while receiving the rights descriptor with the first fragment.TestHandleCleansAmbiguousStartFailure injects errors.New("ambiguous start"), expects a TypeError frame containing that text, and requires StopAndWait() cleanup within 1 second.copyInput() rejects a client TypeOutput frame; the structured exit payload for result "success" is bounded by protocol.MaxFrameSize; and copyOutput() preserves payload "last" before returning io.EOF.TestServeSessionStopsBeforeFinalOutputDrainAndSendsStructuredExit makes cleanup write "final output" and close the unit stream, then requires a TypeOutput frame before a TypeExit encoding {Result:"success", ExecMainCode:1, ExecMainStatus:7}.TestServeSessionDetectsDisconnectWhileInputForwardingBlocks sends up to 32 maximum-size input frames, closes the client after 50 ms, and requires a disconnect error within 2 seconds rather than allowing blocked PTY input to hide disconnection.TestServeSessionSurfacesCleanupFailure requires serveSession() to return the exact errors.New("cleanup failed"); TestServeSessionAcknowledgesStopOnlyAfterCleanup requires an empty TypeStopped frame only after StopAndWait() has completed; TestWatchDisconnectHonorsCancellation requires context.Canceled.TestUnauthenticatedAdmissionHasSeparateBoundedQuotaAndRate admits exactly maxAdmissionsPerMinute sequential unauthenticated attempts before rate limiting, keeps admission history exactly that size, and separately admits exactly maxUnauthenticated concurrent connections before quota rejection.TestTypeScriptTransportUsesHelperAndSplitsWrites builds ./cmd/client as a temporary opencode-pty-client, runs Bun against /home/byk/.local/share/opencode-v2-pilot/config/opencode/plugins/pty-transport.ts, starts /bin/true with argument "arg" and runtime 60, sends a valid STARTED unit name, verifies a 65_536-byte write becomes exactly 2 TypeInput frames of protocol.MaxIOPayloadSize, and returns output "ok" plus exit {result:"success", execMainCode:1, execMainStatus:0}.opencode-pty-[0-9a-f]{32}.service.SOCK_STREAM connection, then gives the helper duplicates at fd 3 for the connected socket and fd 4 for the approved directory.started frame (type 6) after systemd accepts the transient unit./home/byk/.local/share/opencode-v2-pilot/supervisor/PROTOCOL.md specifies one Unix SOCK_STREAM connection per PTY; the supervisor authenticates immutable peer credentials against the exact opencode-v2.service MainPID, while the fixed helper sends one START frame and fd 4 and then exits, and unrelated Node children inherit neither descriptor.PROTOCOL.md specifies a 12-byte frame header: bytes 0β3 ASCII OPTY, byte 4 version 1, byte 5 type, bytes 6β7 zero, and bytes 8β11 unsigned big-endian payload length. Maximum payload is 71,680 bytes; input/output are at most 32,768 bytes; one accepted 65,536-byte plugin write becomes at most 2 input frames.1 carries exactly one SCM_RIGHTS descriptor. The supervisor uses MSG_CMSG_CLOEXEC, closes every received descriptor on every error, requires exactly one directory, and compares its st_dev and st_ino with the frame. Payload order is: 1. 8-byte st_dev, 2. 8-byte st_ino, 3. 4-byte runtime seconds where 0 selects 3,600, 4. 2-byte command length, 5. 2-byte argument count, 6. command bytes, 7. each argument as a 2-byte length followed by bytes.PROTOCOL.md: type 2 input and type 3 output are nonempty opaque data up to 32,768 bytes; type 4 exit is structured systemd completion; type 5 error is nonempty UTF-8 truncated to 32,768 bytes; type 7 stop is an empty request to stop and wait for the complete unit cgroup; type 8 stopped is an empty acknowledgement sent only after bounded cleanup and final-output drain.ExecMainCode, 4-byte unsigned big-endian ExecMainStatus, 4-byte unsigned big-endian result length, and UTF-8 systemd Service Result. CLD_EXITED maps status to exitCode; CLD_KILLED/CLD_DUMPED map it to numeric exitSignal; explicit stop maps to result "stopped", CLD_KILLED, signal 15 as a protocol completion rather than a claimed systemd ExecMain result.BindsTo enforcing shutdown cleanup.PROTOCOL.md characterizes the mechanism as an interactive PTY transport, not a general security sandbox: pilot commands retain workspace and IPv4/IPv6 network access. systemd blocks supplementary privileged groups, capabilities, devices, namespace creation, privileged syscall groups, supervisor/Docker/D-Bus sockets, and cgroup delegation; any same-UID process able to control the Node SEA MainPID or inherit its authenticated socket remains a deployment blocker./home/byk/.local/share/opencode-v2-pilot/supervisor/ROOT-ACCEPTANCE.md states the candidate must not be installed, started, enabled, or marked ready until every root-only check passes on the exact target host; source tests do not substitute for these checks.ROOT-ACCEPTANCE.md ordered acceptance checks are: 1. reproducibly rebuild all 3 binaries, record revision/Go version/dependency sums/build commands/SHA-256, and install exact hashes root-owned mode 0755 under /usr/local/libexec; 2. verify parent paths and binaries are root-owned/non-writable by byk or a group and the SEA uses an irreplaceable fixed helper path; 3. put service/slice candidates on a disposable VM mode 0644, run systemd-analyze verify, inspect every D-Bus transient property, and leave production units unchanged.ROOT-ACCEPTANCE.md checks 4β6 are: 4. prove the socket peer is the Node SEA MainPID rather than helper, with exact UID/GID/MainPID, active/running, /system.slice/opencode-v2.service, 16-byte InvocationID, mandatory SO_PEERPIDFD, and pidfd/invocation rechecks that reject replacement; 5. syscall/descriptor trace proving the helper opens no Unix socket or path, receives only stdio plus fd 3 and fd 4, sends one bounded START with one descriptor, exits, and leaks no descriptors; 6. exercise separate unauthenticated quota/rate limits, retain valid authentication after floods, and bound every handshake D-Bus operation to 5 seconds.ROOT-ACCEPTANCE.md checks 7β10 are: 7. verify one session creates only the strict unit name, runs byk:byk with no supplementary privileged groups, no capabilities/devices/cgroup delegation, restricted proc/namespaces/address families/syscalls, fixed environment and descriptor cwd, and inaccessible supervisor/Docker/system/user D-Bus sockets; 8. preserve workspace and IPv4/IPv6 access, never call it a general sandbox, and block deployment for any same-UID impersonation/inheritance/delegation path; 9. verify exact command/argument/runtime/write limits and reject malformed UTF-8, NUL, descriptor errors, MSG_CTRUNC, metadata mismatch, wrong directions/types, and oversized frames; 10. test a real PTY and /bin/sh -i for spaces, quotes, metacharacters, newlines, terminal input/modes, stdout/stderr ordering, EOF, script -e, zero/nonzero exits, signals, and argv boundaries.ROOT-ACCEPTANCE.md checks 11β15 are: 11. exercise 16 concurrent sessions/reject the 17th and test slow/disconnected readers, blocked input, backpressure, maximum output, expiry, TERM-to-KILL, protocol failure, shutdown, D-Bus closure/timeouts, cancellation, and every non-done/ambiguous start; 12. after every StartTransientUnit, ensure bounded StopUnit and full cgroup removal, surface cleanup errors, and verify orphan cleanup removes only strict-name/exact-BindsTo owned units; 13. test aggregate slice and per-session CPU/memory/tasks/I/O/runtime limits under pressure and bounded-memory cleanup; 14. run the five-tool adversarial plugin smoke 10 times, covering permissions, identity, ownership/deletion/reservations, JSON, regex/UTF-8/framing/helper/notifications/timeouts/cleanup; 15. obtain fresh independent correctness and security approvals, then create the exact four-line root-owned mode-0644 /etc/opencode/pty-supervisor-verified marker with revision and 3 sha256sum records./home/byk/.local/share/opencode-v2-pilot/supervisor/opencode-pty-supervisor.service runs /usr/local/libexec/opencode-pty-supervisor as root with group byk, empty SupplementaryGroups, runtime directory opencode-pty mode 0750, UMask=0077, control-group TERMβKILL shutdown with TimeoutStopSec=20s, OOMPolicy=kill, Delegate=no, AF_UNIX only, private temp/devices/mounts/network, strict system/home/kernel/proc/namespace protections, filtered syscalls, closed devices, and inaccessible Docker and user D-Bus socket paths.CPUAccounting=yes, MemoryAccounting=yes, TasksAccounting=yes, IOAccounting=yes, MemoryHigh=192M, MemoryMax=256M, and TasksMax=64./home/byk/.local/share/opencode-v2-pilot/supervisor/opencode-pty.slice sets all 4 accounting switches, CPUQuota=800%, IOWeight=100, MemoryHigh=1536M, MemoryMax=2G, and TasksMax=512./home/byk/.local/share/opencode-v2-pilot/opencode-v2.service requires and starts after opencode-pty-supervisor.service; runs as byk from /home/byk; loads /home/byk/.opencode/env and /home/byk/.local/share/opencode-v2-pilot/server.env; sets pilot config/database/XDG paths; and starts opencode2-node serve --hostname=0.0.0.0 --port=4096.opencode-v2.service uses an ExecCondition requiring /etc/opencode/pty-supervisor-verified to be a non-symlink regular file owned 0:0, mode 644, exactly 4 lines, with line 1 matching ^revision=[0-9a-f]{40,64}$ and lines 2β4 passing /usr/bin/sha256sum --check --strict -.opencode-v2.service runtime settings include Restart=always, RestartSec=5, Nice=-5, LimitNOFILE=65535, LimitNPROC=4096, MemoryHigh=12G, MemoryMax=13G, NoNewPrivileges=true, ProtectSystem=strict, ProtectHome=read-only, ReadWritePaths=/home/byk, PrivateTmp=yes, and empty SupplementaryGroups./home/byk/.local/share/opencode-v2-pilot/CUTOVER.md states the V2 executable serves API and web UI from one origin and nginx must not be added; cutover requires explicit approval because it stops the running service and must never occur before root acceptance, independent reviews, and the content-bound readiness marker are complete.CUTOVER.md preflight order is: 1. confirm production healthy on port 4096; 2. record candidate revision and smoke binary version; 3. health-check isolated candidate on 14102; 4. activate and confirm both local plugins; 5. create mode-0600 server.env containing OPENCODE_PASSWORD=<password>; 6. complete ROOT-ACCEPTANCE.md against the 3 freshly built root-owned helpers; 7. prove deletion, unload, expiry, kill, disconnect, and ambiguous starts remove full cgroups; 8. prove helper-only descriptor inheritance and block same-UID delegation; 9. obtain fresh independent correctness/security approval; 10. create the exact verified marker; 11. run systemd-analyze verify and confirm unit ordering without changing production.CUTOVER.md cutover order is: 1. install candidate as /etc/systemd/system/opencode-v2.service; 2. sudo systemctl daemon-reload; 3. sudo systemctl stop opencode.service; 4. sudo systemctl start opencode-v2.service; 5. verify /api/health, /, /site.webmanifest, /sw.js, and /openapi.json on 4096; 6. call POST /api/plugin/await-activation and confirm followup and local-pty via GET /api/plugin; 7. observe browser traffic and run one follow-up plus one PTY smoke; 8. enable V2 only after all checks and retain disabled legacy service for rollback.CUTOVER.md rollback order is: 1. stop opencode-v2.service; 2. start opencode.service; 3. verify legacy health and browser UI on port 4096; 4. disable V2 only after legacy health is confirmed. The isolated V2 database under /home/byk/.local/share/opencode-v2-pilot/data is never rewritten or deleted during rollback./home/byk/.local/share/opencode-v2-pilot/supervisor contains exactly 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 contains exactly 7 entries: cache/, config/, CUTOVER.md, data/, opencode-v2.service, state/, and supervisor/.