Dashboard › opencode › Distillation
e3059d63-1518-42a9-919c-1b89a4350ae9["lore_tm_v1_A48TpAHwj5KuIEJ_ConcBYCwJ2V98bccsUNPJEv0fQ8","lore_tm_v1_Lp6aaEqoNyksCUFhGOgziBbKKKpi0_E8ARHigutbq0Q","lore_tm_v1_comCbgVeXU85eMhxWrUcTjGl5AmimeE1jvm4zf1Utnk","lore_tm_v1_hVE1NqmES-RdBqqMg4dW4g21lk-j_90V8T48mh97qyk"]
/home/byk/.local/share/opencode-v2-pilot/supervisor/internal/supervisor/server_test.go (787 lines). Its sessionManager mock tracks startErr, asynchronous wait, cleanup via StopAndWait(), a stopped channel guarded by sync.Once, and ClientState() query count in identity.TestReceiveStartWithDirectoryDescriptor sends a TypeStart frame plus exactly one Unix-rights cwd descriptor; receiveStart() must return a descriptor with FD_CLOEXEC and preserve command "printf" with sole argument "ok".TestHandleCleansAmbiguousStartFailure injects errors.New("ambiguous start"); the server must send a TypeError frame containing "ambiguous start" and invoke cleanup within 1 second.Device: 1, Inode: 2); four cwd descriptors instead of one with no descriptor-count change; and control-message truncation over 20 iterations using maxStartDescriptors+16 descriptors, requiring no descriptor leak after closing the server, client, and cwd.TestReceiveStartHandlesFragmentedHeader sends the first 3 packet bytes with the cwd descriptor and the remainder separately; receiveStart() must still succeed.TestCopyInputRejectsOutputFrame requires copyInput() to reject a client-originated protocol.TypeOutput frame with payload "bad".TestExitPayloadEncodingIsBounded constructs a 9-byte header plus "success" and requires the result not to exceed protocol.MaxFrameSize.TestServeSessionStopsBeforeFinalOutputDrainAndSendsStructuredExit has cleanup write "final output" and close the unit stream. serveSession() must emit that TypeOutput before a TypeExit exactly matching encodeExit(unitResult{Result: "success", ExecMainCode: 1, ExecMainStatus: 7}).TestServeSessionDetectsDisconnectWhileInputForwardingBlocks writes up to 32 TypeInput frames, each with protocol.MaxIOPayloadSize, closes the client after 50 ms, and requires a non-nil disconnect error within 2 seconds.TestServeSessionSurfacesCleanupFailure requires serveSession() to return the injected errors.New("cleanup failed").TestServeSessionAcknowledgesStopOnlyAfterCleanup sends protocol.TypeStop; the reply must be an empty protocol.TypeStopped frame, and the cleanup marker must already be closed when that acknowledgment is observed.TestWatchDisconnectHonorsCancellation requires watchDisconnect() to return context.Canceled for an already-canceled context.TestUnauthenticatedAdmissionHasSeparateBoundedQuotaAndRate verifies exactly maxAdmissionsPerMinute ordinary admissions, rejection of the next rate-limited admission, bounded admission history of that exact size, one reserved MainPID admission despite ordinary flood, exactly maxUnauthenticated ordinary quota admissions after reset, and no more than one reserved MainPID connection.TestOnlyCachedMainPIDReceivesReservedAdmission permits the current process PID, rejects os.Getpid()+1, and requires only 1 D-Bus-equivalent identity query due to caching.TestCopyOutputPreservesDataBeforeEOF writes "last", closes the unit peer, expects io.EOF, and requires the emitted frame payload to remain "last".TestTypeScriptTransportUsesHelperAndSplitsWrites builds ./cmd/client with go build -trimpath -o <temporary-directory>/opencode-pty-client, then runs a Bun script importing openSupervisorTransport from /home/byk/.local/share/opencode-v2-pilot/config/opencode/plugins/pty-transport.ts."." as cwd and starts /bin/true with args ["arg"], runtime 60, and options { socketPath, helperPath, verifyRootHelper: false }; the server must receive those exact values.Buffer.alloc(65_536, 120), which must arrive as exactly 2 protocol.TypeInput frames, each of protocol.MaxIOPayloadSize, totaling exactly 65,536 bytes. The mock server returns output "ok" and exit { result: "success", execMainCode: 1, execMainStatus: 0 }.TestTypeScriptTransportBoundsOutputBeforeListener imports MAX_BUFFER_SIZE, sends 1_000_000 + protocol.MaxIOPayloadSize*8 bytes of ASCII z before TypeStarted, and requires the subsequently attached output listener to receive exactly MAX_BUFFER_SIZE valid z bytes plus a successful exit.TestTypeScriptTransportBoundsBackpressuredStopWrite configures { verifyRootHelper: false, helperTimeoutMs: 500, stopTimeoutMs: 100 }, launches 256 writes of 32,768 bytes, constrains the server read buffer to 1,024 bytes, and requires transport.close() to fail with "stop timed out" rather than complete. All writes are settled, and the Bun process must finish within 3 seconds.server_test.go creates Unix stream pairs with unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM|unix.SOCK_CLOEXEC, 0) and counts descriptors through /proc/self/fd./home/byk/.local/share/opencode-v2-pilot/supervisor/internal/supervisor/systemd_test.go (199 lines).TestUnitNameGrammar accepts only the lowercase service-form example opencode-pty-0123456789abcdef0123456789abcdef.service; rejected examples are opencode-pty-.service, uppercase hex, a .scope suffix, and .service/../x.TestWaitForJobResultRejectsClosedNonDoneAndTimeout rejects a closed job channel, rejects result "canceled" for a "start" job, and requires a 1 ms context timeout to produce context.DeadlineExceeded.TestUnitPropertiesAreFixed invokes unitProperties() for command "sh" with args ["-c", "echo ok"] and runtime 60. Required properties are User, Group, SupplementaryGroups, NoNewPrivileges, CapabilityBoundingSet, AmbientCapabilities, UMask, KillMode, KillSignal, FinalKillSignal, SendSIGKILL, TimeoutStopUSec, OOMPolicy, Delegate, Slice, BindsTo, After, StandardInputFileDescriptor, StandardOutputFileDescriptor, StandardErrorFileDescriptor, InaccessiblePaths, PrivateDevices, DevicePolicy, ProtectControlGroups, ProtectProc, ProcSubset, RestrictNamespaces, RestrictAddressFamilies, SystemCallArchitectures, SystemCallFilter, CPUAccounting, MemoryAccounting, TasksAccounting, IOAccounting, CPUQuotaPerSecUSec, MemoryHigh, MemoryMax, TasksMax, and RuntimeMaxUSec.User == "byk", Delegate == false, D-Bus signature "(bas)" for both RestrictAddressFamilies and SystemCallFilter, and signature "as" for SupplementaryGroups.TestDecodeUnitResult maps {"Result": "exit-code", "ExecMainCode": int32(1), "ExecMainStatus": int32(7)} to the same exact values.TestClientIdentityUsesRealSystemdInterfaces requires ActiveState, SubState, and 16-byte InvocationID from the Unit interface, while MainPID: 42 and ControlGroup: expectedClientCgroup come from the Service interface. Supplying ControlGroup through Unit must fail with an error containing "service ControlGroup".TestSystemd255IntrospectionPlacesPropertiesOnExactInterfaces checks live dbus.service introspection: Unit must expose ActiveState, SubState, and InvocationID; Service must expose MainPID and ControlGroup; Unit must not expose ControlGroup. The test skips if the system bus is unavailable.TestForgedUnitRemovedSignalCannotProveCleanup injects org.freedesktop.systemd1.Manager.UnitRemoved from sender :1.999 for opencode-pty-0123456789abcdef0123456789abcdef.service; cleanup still requires exactly 1 verification query and must not report stopped when that query returns false.TestBoundedSignalHandlerDropsFlood delivers 10,000 signals to a handler with capacity 1 and requires the queue length to remain exactly 1.TestReadinessVerifierBindsExactSourceAndCondition reads ../../verify-readiness, obtains a 64-character digest from ../../review-source-hash, and requires the verifier to contain ;pty-source:sha256:<digest>'. ../../../opencode-v2.service must contain exactly ExecCondition=/usr/local/libexec/opencode-pty-verify-readiness\n, and /bin/sh -n ../../verify-readiness must pass./home/byk/.local/share/opencode-v2-pilot/supervisor/go.mod: module opencode-pty-supervisor, Go 1.22, 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./home/byk/.local/share/opencode-v2-pilot/supervisor/go.sum (7 lines), containing checksums for github.com/coreos/go-systemd/v22 v22.5.0, github.com/godbus/dbus/v5 v5.1.0 plus the older v5.0.4/go.mod, and golang.org/x/sys v0.20.0.