refactor: use defining process types and colocate host telemetry test

This commit is contained in:
Neil
2026-11-08 22:49:05 -08:00
parent 23a3698bdf
commit 5399bb3a6d
71 changed files with 287 additions and 243 deletions
+1 -30
View File
@@ -1,38 +1,28 @@
# Existing production source files importing child_process outside @orca/process-host.
# Existing production source files importing child_process at runtime outside @orca/process-host.
# Migration debt: this list may only shrink; new callers use the package public API.
src/cli/handlers/core.ts
src/cli/handlers/interactive-login-interruption.ts
src/cli/runtime/launch.ts
src/main/agent-hooks/installation/locking/managed-hook-owner-identity.ts
src/main/agent-hooks/wsl-relay/wsl-hook-relay-link.ts
src/main/agent-hooks/wsl-relay/wsl-hook-relay-manager.ts
src/main/agent-hooks/wsl-relay/wsl-hook-relay-sentinel.ts
src/main/ai-vault/scan-service/session-scanner-service-client-state.ts
src/main/ai-vault/scan-service/session-scanner-service-client.ts
src/main/ai-vault/scan-service/session-scanner-service-spawn.ts
src/main/window/desktop-integration/app-icon.ts
src/main/automations/precheck-runner.ts
src/main/browser/agent-browser/helper-process/agent-browser-bridge-execution.ts
src/main/browser/agent-browser/helper-process/agent-browser-bridge-raw-process.ts
src/main/browser/agent-browser/session-routing/agent-browser-bridge-state.ts
src/main/browser/agent-browser/session-lifecycle/agent-browser-session-state.ts
src/main/browser/network/egress/browser-route-egress-electron-launch.ts
src/main/codex-accounts/legacy-wsl-runtime-auth-drain-recovery-script-harness.ts
src/main/codex-accounts/legacy-wsl-runtime-auth-drain-script-harness.ts
src/main/codex-accounts/service.ts
src/main/codex/app-server/codex-app-server-session.ts
src/main/computer/desktop-script-provider-bridge.ts
src/main/computer/macos-computer-use-permission-status.ts
src/main/computer/macos-computer-use-permissions.ts
src/main/computer/macos-native-provider-transport.ts
src/main/computer/sidecar-client.ts
src/main/daemon/launch/daemon-launched-child.ts
src/main/daemon/endpoint/identity/daemon-process-identity-query.ts
src/main/daemon/endpoint/identity/daemon-process-inspection.ts
src/main/daemon/endpoint/identity/daemon-process-start-time.ts
src/main/emulator/android/android-avd-boot.ts
src/main/emulator/android/scrcpy-stream-session.ts
src/main/emulator/serve-sim-helper-processes.ts
src/main/emulator/serve-sim-runtime-materializer.ts
src/main/emulator/simctl-simulator-devices.ts
@@ -49,33 +39,18 @@ src/main/git/wsl-git-read-environment.ts
src/main/github/gh-utils.ts
src/main/workspace-hooks/hooks.ts
src/main/ipc/developer-permissions.ts
src/main/ipc/filesystem/filesystem-handler-context.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-cancellation-restart.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-cancellation-tracker.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-child-launch.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-child-messaging.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-child-recovery.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-child-termination.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-host-subscriptions.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-pending-cancellation.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-process-supervisor.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-supervisor-disposal.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-supervisor-message.ts
src/main/ipc/filesystem/watcher-process/parcel-watcher-supervisor-subscribe.ts
src/main/ipc/filesystem/watchers/wsl-watcher-process-exit.ts
src/main/ipc/local-network-connection-test.ts
src/main/ipc/macos-keyboard-input-source.ts
src/main/ipc/macos-keyboard-layout-snapshot.ts
src/main/ipc/notification-authorization-status.ts
src/main/ipc/preflight-command-exec.ts
src/main/ipc/repos/repo-clone-lifecycle.ts
src/main/ipc/worktree-apfs-clone.ts
src/main/local-builds/local-build-candidate.ts
src/main/macos-keychain/generic-password.ts
src/main/power/macos-system-sleep-assertion.ts
src/main/macos-permissions/macos-tcc-prompt-watch.ts
src/main/memory/collector.ts
src/main/native-chat/wsl-transcript-fs-process-slot.ts
src/main/native-chat/wsl-transcript-fs-process-spawn.ts
src/main/network/macos-system-resolver-health.ts
src/main/network/macos-tailscale-dns-diagnostic.ts
@@ -85,21 +60,17 @@ src/main/ports/port-scan-command-execution.ts
src/main/providers/macos-login-session-pty-probe.ts
src/main/providers/process-cwd.ts
src/main/pty/process-retirement/pty-descendant-fresh-table.ts
src/main/pty/environment/windows-environment-path.ts
src/main/rate-limits/providers/gemini/gemini-cli-oauth-extractor.ts
src/main/runtime/rpc/server/pairing/network/windows-default-route-interfaces.ts
src/main/runtime/rpc/server/pairing/network/windows-mobile-firewall.ts
src/main/ssh/connection/ssh-connection.ts
src/main/ssh/system-transport/ssh-proxy-command.ts
src/main/ssh/system-transport/system-ssh-command.ts
src/main/ssh/system-transport/forwarding/system-ssh-dynamic-forward-process.ts
src/main/ssh/system-transport/file-transfer/system-ssh-file-transfer.ts
src/main/ssh/system-transport/system-ssh-operation-lifecycle.ts
src/main/startup/ensure-virtual-display.ts
src/main/pty/process-retirement/windows-process-tree-kill.ts
src/main/pty/shell-startup/zsh-startup-hook-pty-harness.ts
src/shared/ephemeral-vm-recipe-process.ts
src/shared/ephemeral-vm-recipe-runner.ts
src/shared/fish-binary-requirement.ts
src/shared/process-table-ps-capture.ts
src/shared/terminal/pty/native-process/pty-slave-line-discipline-echo.ts
@@ -100,7 +100,7 @@ function collectBindings(source) {
// Resolve file-wide static import/re-export/import()/require/module.require/createRequire aliases and getBuiltinModule; literals/const strings and literal property keys only.
// No scope tracking, computed values/specifiers, imported parameters, object/argument loaders or eval/Function resolution.
export function collectModuleSpecifiers(file, contents) {
export function collectModuleSpecifiers(file, contents, { runtimeOnly = false } = {}) {
const source = ts.createSourceFile(file, contents, ts.ScriptTarget.Latest, false)
if (source.parseDiagnostics.length > 0) {
throw new Error(`Cannot parse ${file}; the process-host import check must not skip it.`)
@@ -226,6 +226,14 @@ export function collectModuleSpecifiers(file, contents) {
}
}
for (const node of modules) {
if (
runtimeOnly &&
(ts.isImportTypeNode(node) ||
node.isTypeOnly ||
(ts.isImportDeclaration(node) && node.importClause?.isTypeOnly))
) {
continue
}
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
add(node.moduleSpecifier)
} else if (
@@ -59,6 +59,7 @@ export function assessProcessHostImports(
])
for (const [file, contents] of sources) {
const ownSource = file.startsWith(PACKAGE_SOURCE)
let runtimeSpecifiers
for (const sourceSpecifier of specifiersFor(file, contents)) {
const specifier = normalized(sourceSpecifier)
const local = packageRelativeImport(file, specifier)
@@ -103,7 +104,12 @@ export function assessProcessHostImports(
!isTestOnlySourcePath(file) &&
(specifier === 'child_process' || specifier === 'node:child_process')
) {
direct.add(file)
runtimeSpecifiers ??= new Set(
collectModuleSpecifiers(file, contents, { runtimeOnly: true })
)
if (runtimeSpecifiers.has(specifier)) {
direct.add(file)
}
}
}
}
@@ -0,0 +1,48 @@
import { describe, expect, it } from 'vitest'
import { assessProcessHostImports } from './check-process-host-imports.mjs'
const file = 'src/main/process-consumer.ts'
const manifest = { exports: { '.': './dist/index.js' } }
const assess = (source) => assessProcessHostImports(new Map([[file, source]]), manifest, new Set())
describe('process-host runtime import boundary', () => {
it.each([
"import type { ChildProcess } from 'node:child_process'",
"import type * as ChildProcess from 'child_process'",
"import type ChildProcess = require('node:child_process')",
"export type { ChildProcess } from 'node:child_process'",
"type Child = import('node:child_process').ChildProcess"
])('allows erased Node type ownership: %s', (source) => {
expect(assess(source)).toMatchObject({ direct: [], added: [], violations: [] })
})
it.each([
"import { spawn } from 'node:child_process'",
"import 'child_process'",
"import { type ChildProcess } from 'node:child_process'",
"export { spawn } from 'node:child_process'",
"const child = require('node:child_process')",
"const child = import('node:child_process')",
"import type { ChildProcess } from 'node:child_process'; require('node:child_process')",
"import { createRequire } from 'node:module'; const load = createRequire(import.meta.url); load('node:child_process')",
"process.getBuiltinModule('child_process')"
])('still rejects runtime access: %s', (source) => {
expect(assess(source)).toMatchObject({ direct: [file], added: [file] })
})
it('keeps package export restrictions for type-only imports', () => {
expect(assess("import type { Private } from '@orca/process-host/private'").violations).toEqual([
`${file}: @orca/process-host/private is not a public process-host export`
])
})
it('requires the WSL allowlist only for runtime child-process imports', () => {
const wsl = "const program = 'wsl.exe'"
expect(
assess(`import type { ChildProcess } from 'node:child_process'; ${wsl}`).violations
).toEqual([])
expect(assess(`import { spawn } from 'node:child_process'; ${wsl}`).violations).toEqual([
`${file}: direct wsl.exe exec must call assertWslDistroAllowed`
])
})
})
@@ -6,11 +6,11 @@ import { PassThrough } from 'node:stream'
import { afterAll, afterEach, beforeAll, expect, it, onTestFinished, vi } from 'vitest'
import { createVitest, type PoolOptions, type Vitest } from 'vitest/node'
import * as processes from '@orca/process-host'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { nodeRuntimePool } from './vitest-node-runtime-pool'
let context: Vitest
const children: ChildProcessHandle[] = []
const children: ChildProcess[] = []
const spawn = processes.spawnProcess
beforeAll(async () => {
@@ -1,7 +1,7 @@
import { isAbsolute, resolve } from 'node:path'
import type { PoolOptions, PoolWorker, WorkerRequest } from 'vitest/node'
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
decodeNodeRuntimeMessage,
encodeNodeRuntimeMessage
@@ -10,7 +10,7 @@ import {
class NodeRuntimeWorker implements PoolWorker {
readonly name = 'node-runtime'
readonly cacheFs = true
private child: ChildProcessHandle | undefined
private child: ChildProcess | undefined
constructor(private readonly options: PoolOptions) {}
@@ -125,7 +125,7 @@ class NodeRuntimeWorker implements PoolWorker {
}
}
private get worker(): ChildProcessHandle {
private get worker(): ChildProcess {
if (!this.child) {
throw new Error('Node Vitest worker is not running')
}
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { spawnProcess } from '@orca/process-host'
import {
forceTerminateProcessTree,
@@ -212,7 +212,7 @@ async function waitForProbe(promise: Promise<void>, ms: number): Promise<boolean
]).finally(() => clearTimeout(timer))
}
function killProbeRoot(child: ChildProcessHandle, signal?: NodeJS.Signals): void {
function killProbeRoot(child: ChildProcess, signal?: NodeJS.Signals): void {
try {
child.kill(signal)
} catch {
+2 -2
View File
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { StringDecoder } from 'node:string_decoder'
import {
getEphemeralVmRecipeResultConnection,
@@ -8,7 +8,7 @@ import { RuntimeClientError } from './types'
const IGNORED_NON_RECIPE_STDOUT = '[serve] ignored non-recipe stdout'
export function waitForRecipeJson(child: ChildProcessHandle): Promise<number> {
export function waitForRecipeJson(child: ChildProcess): Promise<number> {
return new Promise((resolve, reject) => {
let output = ''
let settled = false
+5 -4
View File
@@ -1,4 +1,5 @@
import type { ChildProcessHandle, ProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { ProcessSpec } from '@orca/process-host/process-spec'
import { readFileSync } from 'node:fs'
import { readFile, rename, unlink, writeFile } from 'node:fs/promises'
import {
@@ -34,7 +35,7 @@ export const SERVE_CHILD_FORCE_KILL_GRACE_MS =
type ServeSupervisorArgs = {
/** Respawned on update; `program` is also the bundle whose installed version a handoff awaits. */
spec: ProcessSpec
spawnChild: (spec: ProcessSpec) => ChildProcessHandle
spawnChild: (spec: ProcessSpec) => ChildProcess
handoffPath: string | null
}
@@ -76,7 +77,7 @@ async function awaitInstalledHandoff(
export async function superviseForegroundServe(
args: ServeSupervisorArgs & {
child: ChildProcessHandle
child: ChildProcess
expectedHandoff: InstallRequestedHandoff | null
}
): Promise<number> {
@@ -129,7 +130,7 @@ export async function superviseForegroundServe(
}
function waitForForegroundChild(
child: ChildProcessHandle,
child: ChildProcess,
expected: { handoffPath: string; handoff: InstallRequestedHandoff } | null
): Promise<{
code: number | null
@@ -1,4 +1,4 @@
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { spawnProcess } from '@orca/process-host'
@@ -102,7 +102,7 @@ export function spawnWslRelayProcess(
distro: string,
env: NodeJS.ProcessEnv,
version: string
): PipedChildProcess {
): ChildProcessWithoutNullStreams {
// --exec bypasses login-shell rewriting and passes $HOME verbatim for guest-side expansion.
const command = `exec sh "${guestRelayDirExpr(version)}/launch.sh"`
return spawnProcess({
@@ -153,10 +153,10 @@ export async function launchWslRelayWithInstall(options: {
version: string
io: WslRelayLaunchIo
isDisposed: () => boolean
onChild: (child: PipedChildProcess) => void
onChild: (child: ChildProcessWithoutNullStreams) => void
onNoNode: () => void
onFailure: (message: string) => void
connect: (transport: MultiplexerTransport, child: PipedChildProcess) => Promise<void>
connect: (transport: MultiplexerTransport, child: ChildProcessWithoutNullStreams) => Promise<void>
}): Promise<void> {
const { distro, env, bundleJsPath, version, io } = options
let installTried = false
@@ -2,13 +2,13 @@ import { once } from 'node:events'
import { PassThrough, Writable } from 'node:stream'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { NATIVE_HOST_ERRORS } from './browser-extension-native-host-errors'
import { startNativeHost, type NativeHostConnection } from './browser-extension-native-host-process'
const owned: {
child: PipedChildProcess
child: ChildProcessWithoutNullStreams
connection: NativeHostConnection
closed: Promise<unknown>
}[] = []
@@ -23,7 +23,7 @@ async function controlledHost(script = 'setInterval(() => {}, 1000);', bufferStd
}
})
const write = vi.spyOn(stdin, 'write')
const children: PipedChildProcess[] = []
const children: ChildProcessWithoutNullStreams[] = []
const closes: string[] = []
const messages: string[] = []
let closed: Promise<unknown> = Promise.resolve()
@@ -4,7 +4,7 @@ import { join } from 'node:path'
import { once } from 'node:events'
import { build } from 'esbuild'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
import {
killAllNativeHosts,
@@ -160,7 +160,7 @@ describe('native host process', () => {
it('waits for the Windows supervisor to start the host before exposing its connection', async () => {
const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform')
Object.defineProperty(process, 'platform', { value: 'win32', configurable: true })
const children: PipedChildProcess[] = []
const children: ChildProcessWithoutNullStreams[] = []
const messages: string[] = []
let resolved = false
try {
@@ -1,6 +1,7 @@
import { dirname } from 'node:path'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess, PipedProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpec } from '@orca/process-host/process-spec'
import {
childProcessHasExited,
forceTerminateProcessTree,
@@ -38,9 +39,9 @@ export type NativeHostConnection = {
close: () => void
}
export type NativeHostSpawner = (spec: PipedProcessSpec) => PipedChildProcess
export type NativeHostSpawner = (spec: PipedProcessSpec) => ChildProcessWithoutNullStreams
const liveHosts = new Map<PipedChildProcess, () => void>()
const liveHosts = new Map<ChildProcessWithoutNullStreams, () => void>()
/** Quit: kill every host now; a pending grace timer would never fire. */
export function killAllNativeHosts(): void {
@@ -55,7 +56,7 @@ export function killAllNativeHosts(): void {
liveHosts.clear()
}
function forwardStderr(name: string, child: PipedChildProcess): void {
function forwardStderr(name: string, child: ChildProcessWithoutNullStreams): void {
let budget = STDERR_LOG_BUDGET_BYTES
child.stderr.on('data', (chunk: Buffer) => {
if (budget <= 0) {
@@ -77,7 +78,7 @@ export function startNativeHost(
spawn: NativeHostSpawner = spawnProcess
): Promise<NativeHostConnection> {
return new Promise((resolve, reject) => {
let child: PipedChildProcess
let child: ChildProcessWithoutNullStreams
const supervised = process.platform === 'win32'
try {
child = spawn(
@@ -1,5 +1,5 @@
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { WindowsHostInteractiveLoginSpawn } from '../../shared/windows-interactive-login-spawn'
import { recordSelfInitiatedTreeKill } from '../crash-reporting/self-initiated-tree-kill-log'
import { admitSelfInitiatedTreeKill } from '../pty/process-retirement/own-chromium-tree-kill-guard'
@@ -7,7 +7,7 @@ import { admitSelfInitiatedTreeKill } from '../pty/process-retirement/own-chromi
const WINDOWS_TASKKILL_TIMEOUT_MS = 5_000
export function terminateClaudeProcess(
child: ChildProcessHandle,
child: ChildProcess,
interactiveLogin: WindowsHostInteractiveLoginSpawn | null,
afterKill: () => void
): void {
@@ -1,5 +1,4 @@
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import { execFileSync } from 'node:child_process'
import { execFileSync, type ChildProcessWithoutNullStreams } from 'node:child_process'
import { describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import { proveClaudeChildExit } from './claude-agent-sdk-exit-proof'
@@ -71,7 +70,7 @@ async function proveExitWithRetries(
return proveClaudeChildExit(input)
}
function spawnScript(script: string): PipedChildProcess {
function spawnScript(script: string): ChildProcessWithoutNullStreams {
const child = spawnProcess({
program: process.execPath,
args: ['-e', script],
@@ -81,7 +80,7 @@ function spawnScript(script: string): PipedChildProcess {
return child
}
function firstStdoutLine(child: PipedChildProcess): Promise<string> {
function firstStdoutLine(child: ChildProcessWithoutNullStreams): Promise<string> {
return new Promise((resolve) => {
child.stdout.setEncoding('utf8').once('data', (chunk: string) => resolve(chunk.trim()))
})
@@ -1,4 +1,4 @@
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
terminateDescendantSnapshotWithVerdict,
type DescendantTreeVerdict
@@ -23,7 +23,7 @@ const TREE_VERDICT_TRUST: Record<DescendantTreeVerdict, number> = {
exited: 2
}
type ReapableChild = Pick<SpawnedProcess, 'pid' | 'kill'>
type ReapableChild = Pick<ChildProcess, 'pid' | 'kill'>
// A missing or exited root may have reparented descendants; its walk cannot prove an empty tree.
function admissibleTree(
@@ -1,4 +1,5 @@
import type { PipedChildProcess, PipedProcessSpawner } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpawner } from '@orca/process-host/process-spec'
import type { SpawnOptions as ClaudeAgentSdkSpawnOptions } from '@anthropic-ai/claude-agent-sdk'
import { spawnProcess } from '@orca/process-host'
import {
@@ -9,8 +10,8 @@ import { claudeChildClosePolicy, claudeChildCloseProven } from './claude-child-e
export type ClaudeCodeProcessSpawn = {
/** SDK spawn hook; Orca retains process ownership. */
spawn: (options: ClaudeAgentSdkSpawnOptions) => PipedChildProcess
readonly child: PipedChildProcess | null
spawn: (options: ClaudeAgentSdkSpawnOptions) => ChildProcessWithoutNullStreams
readonly child: ChildProcessWithoutNullStreams | null
readonly managed: ManagedProviderProcess | null
/** Supervisor pid on POSIX; lease ownership also requires start time and spawn token. */
readonly pid: number | undefined
@@ -30,7 +31,7 @@ function definedEnv(env: Record<string, string | undefined>): Record<string, str
/** Subscribes alongside the SDK's reader: an earlier listener would drain output it never sees. */
function observeStdoutWithReader(
stdout: PipedChildProcess['stdout'],
stdout: ChildProcessWithoutNullStreams['stdout'],
onStdout: (chunk: Buffer | string) => void
): void {
const onSubscribe = (event: string | symbol): void => {
@@ -2,7 +2,7 @@ import { EventEmitter } from 'node:events'
import { PassThrough } from 'node:stream'
import { describe, expect, it, vi } from 'vitest'
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { DescendantSnapshot } from '../pty/process-retirement/pty-descendant-termination'
import { createClaudeChildTreeReaper } from './claude-agent-sdk-exit-proof'
@@ -11,7 +11,7 @@ const ROOT_STARTED_AT = 'Mon Jan 1 00:00:00 2026'
const ROOT_FORK_MS = Date.parse(ROOT_STARTED_AT)
function mockChild(): EventEmitter &
Pick<SpawnedProcess, 'pid' | 'kill' | 'stdin'> & { kill: ReturnType<typeof vi.fn> } {
Pick<ChildProcess, 'pid' | 'kill' | 'stdin'> & { kill: ReturnType<typeof vi.fn> } {
return Object.assign(new EventEmitter(), {
pid: ROOT_PID,
stdin: new PassThrough(),
@@ -1,4 +1,4 @@
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import {
spawnManagedProviderProcess,
type ManagedProviderProcess
@@ -9,7 +9,7 @@ const managedChildren = new WeakMap<object, ManagedProviderProcess>()
/** `closePlatform` picks the close rules; the spawn itself always skips the POSIX supervisor. */
export function managedChild(
child: PipedChildProcess,
child: ChildProcessWithoutNullStreams,
closePlatform: NodeJS.Platform = 'linux'
): ManagedProviderProcess {
const existing = managedChildren.get(child)
@@ -1,7 +1,7 @@
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
type RootTerminationInput = {
child: Pick<SpawnedProcess, 'kill'>
child: Pick<ChildProcess, 'kill'>
exited: () => boolean
}
@@ -1,11 +1,11 @@
import { execFileSync } from 'node:child_process'
import { execFileSync, type ChildProcess } from 'node:child_process'
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { providerDiagnosticOf } from '../../shared/agent-session/failures/agent-session-failure'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { SpawnedProcess, ProcessSpec } from '@orca/process-host/process-spec'
import type { ProcessSpec } from '@orca/process-host/process-spec'
import type { query, CanUseTool } from '@anthropic-ai/claude-agent-sdk'
import {
@@ -89,7 +89,7 @@ function launchFor(
}
const spawned: ProcessSpec[] = []
const spawnedChildren: SpawnedProcess[] = []
const spawnedChildren: ChildProcess[] = []
async function open(
launch: ClaudeStreamJsonLaunch,
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { once } from 'node:events'
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
@@ -85,7 +85,7 @@ describe.skipIf(process.platform !== 'win32')('ClaudeHookService native hook ins
`${join(hooksDir, EXE).replaceAll('\\', '/')} claude`
// Holding stdin open keeps the hook image mapped to exercise locked-executable replacement.
function startHeldHook(program: string): PipedChildProcess {
function startHeldHook(program: string): ChildProcessWithoutNullStreams {
return spawnProcess({
program,
args: ['claude'],
@@ -1,4 +1,5 @@
import type { ChildProcessHandle, ProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { ProcessSpec } from '@orca/process-host/process-spec'
import { spawnProcess } from '@orca/process-host'
import '../trust/toml/config-toml-trust'
import { normalizeCodexHookTrustLookupKey as normalizeHookTrustKeyForLookup } from '../trust/identity/codex-trust-identity'
@@ -95,12 +96,11 @@ function collectHookListings(result: unknown): CodexHookListing[] {
export async function runCodexHookTrustGrantSession(
request: CodexHookTrustGrantRequest,
spawnImpl: (
program: string,
args: string[],
options: Record<string, unknown>
) => ChildProcessHandle = (program, args, options) =>
spawnProcess({ program, args, ...options } as ProcessSpec)
spawnImpl: (program: string, args: string[], options: Record<string, unknown>) => ChildProcess = (
program,
args,
options
) => spawnProcess({ program, args, ...options } as ProcessSpec)
): Promise<CodexHookTrustGrantSessionResult> {
return runCodexAppServerSession(
request.invocation,
@@ -1,5 +1,6 @@
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle, ProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { ProcessSpec } from '@orca/process-host/process-spec'
import { admitProcessTreeKill } from '@orca/process-host/process-tree-kill-gate'
/** Spawn seam for tests; production always goes through the hardened spawnProcess wrapper. */
@@ -7,13 +8,13 @@ export type CodexAppServerSpawn = (
program: string,
args: string[],
options: Record<string, unknown>
) => ChildProcessHandle
) => ChildProcess
export const spawnCodexAppServerProcess: CodexAppServerSpawn = (program, args, options) =>
spawnProcess({ program, args, ...options } as ProcessSpec)
export function killCodexAppServerProcessTree(
child: Pick<ChildProcessHandle, 'pid' | 'kill'>,
child: Pick<ChildProcess, 'pid' | 'kill'>,
options: { platform?: NodeJS.Platform; spawnImpl?: CodexAppServerSpawn } = {}
): void {
const platform = options.platform ?? process.platform
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { withCliRuntimeOnPath } from '../../../../shared/node-cli-command-resolution'
import { parseWslUncPath } from '../../../../shared/wsl-paths'
import { buildWslCodexAppServerArgs } from '../../../codex-accounts/wsl-codex-command'
@@ -18,7 +18,7 @@ const BACKFILL_RECOVERY_KILL_SITE = 'codex-state-db-backfill-recovery'
const BACKFILL_RECOVERY_CLOSE_REQUEST: ProviderCloseRequest = 'stdin-end'
export type CodexBackfillRecoveryProcess = {
child: ChildProcessHandle
child: ChildProcess
supervised: boolean
}
@@ -71,7 +71,7 @@ export function spawnCodexBackfillRecoveryProcess(
}
export async function stopCodexBackfillRecoveryProcess(
child: ChildProcessHandle,
child: ChildProcess,
supervised: boolean
): Promise<void> {
if (supervised) {
@@ -6,7 +6,7 @@ import { parseWslUncPath } from '../../../../shared/wsl-paths'
import { withManagedHookInstallLock } from '../../../agent-hooks/installation/locking/managed-hook-install-lock'
import { readManagedHookHostIdentity } from '../../../agent-hooks/installation/locking/managed-hook-owner-identity'
import { resolveCodexCommand } from '../../../codex-cli/command'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
spawnCodexAppServerProcess,
type CodexAppServerSpawn
@@ -43,7 +43,7 @@ type RecoveryDependencies = {
countSessions: (sessionsRoot: string, limit: number) => number
now: () => number
sleep: (ms: number, signal: AbortSignal) => Promise<void>
terminate: (child: ChildProcessHandle, supervised: boolean) => Promise<void>
terminate: (child: ChildProcess, supervised: boolean) => Promise<void>
}
const defaultDependencies: RecoveryDependencies = {
@@ -1,7 +1,7 @@
import { EventEmitter } from 'node:events'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { ProcessSpec } from '@orca/process-host/process-spec'
import type { RuntimeChildProcess } from './desktop-script-serve-channel'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { DesktopScriptRuntimeHost, isRuntimeHostUnavailable } from './desktop-script-runtime-host'
class FakeRuntimeChild extends EventEmitter {
@@ -96,7 +96,8 @@ function createHost(
const child = new FakeRuntimeChild()
child.deferWrites = options.deferWrites === true
children.push(child)
return child as unknown as RuntimeChildProcess
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: this fixture implements the piped streams and events used by the runtime host.
return child as unknown as ChildProcessWithoutNullStreams
}
})
return { host, children, specs, warnings }
@@ -4,11 +4,8 @@ import { reportComputerDiagnostic } from './computer-sidecar-diagnostics'
import { isReplayableTool } from './desktop-script-action'
import type { BridgeRequest, BridgeResponse } from './desktop-script-provider-types'
import { DesktopScriptRequestQueue } from './desktop-script-request-queue'
import {
startServeChannel,
type DesktopScriptServeChannel,
type RuntimeProcessSpawn
} from './desktop-script-serve-channel'
import type { PipedProcessSpawner } from '@orca/process-host/process-spec'
import { startServeChannel, type DesktopScriptServeChannel } from './desktop-script-serve-channel'
import {
MAX_START_ATTEMPTS,
RuntimeHostAvailability,
@@ -27,7 +24,7 @@ const IDLE_SHUTDOWN_MS = 120_000
export const RUNTIME_HOST_UNAVAILABLE = 'runtime_host_unavailable'
export type DesktopScriptRuntimeHostOptions = {
spawn?: RuntimeProcessSpawn
spawn?: PipedProcessSpawner
powerShellPath?: () => string
requestTimeoutMs?: number
idleShutdownMs?: number
@@ -1,6 +1,7 @@
import { EventEmitter } from 'node:events'
import { describe, expect, it, vi } from 'vitest'
import { DesktopScriptServeChannel, type RuntimeChildProcess } from './desktop-script-serve-channel'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { DesktopScriptServeChannel } from './desktop-script-serve-channel'
class FakeChild extends EventEmitter {
readonly stdout = new EventEmitter()
@@ -36,7 +37,11 @@ class FakeChild extends EventEmitter {
function createChannel() {
const child = new FakeChild()
const handlers = { onLine: vi.fn(), onGone: vi.fn(), onOverflow: vi.fn() }
const channel = new DesktopScriptServeChannel(child as unknown as RuntimeChildProcess, handlers)
const channel = new DesktopScriptServeChannel(
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: this fixture implements the piped streams and events consumed by the channel.
child as unknown as ChildProcessWithoutNullStreams,
handlers
)
return { channel, child, handlers }
}
@@ -86,11 +91,15 @@ describe('DesktopScriptServeChannel', () => {
const tails: string[] = []
const feed = (index: number): void => {
const child = new FakeChild()
const channel = new DesktopScriptServeChannel(child as unknown as RuntimeChildProcess, {
onLine: () => {},
onGone: () => {},
onOverflow: () => {}
})
const channel = new DesktopScriptServeChannel(
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: this fixture implements the piped streams and events consumed by the channel.
child as unknown as ChildProcessWithoutNullStreams,
{
onLine: () => {},
onGone: () => {},
onOverflow: () => {}
}
)
const line = String.fromCharCode(65 + (index % 26)).repeat(1024 * 1024)
child.stdout.emit('data', `${line}\n{"partial":${index}`)
tails.push((channel as unknown as { buffer: string }).buffer)
@@ -1,15 +1,8 @@
import { StringDecoder } from 'node:string_decoder'
import type {
PipedChildProcess,
PipedProcessSpawner,
PipedProcessSpec
} from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpawner, PipedProcessSpec } from '@orca/process-host/process-spec'
import { ownRetainedString } from '../../shared/own-retained-string'
export type RuntimeChildProcess = PipedChildProcess
export type RuntimeProcessSpawn = PipedProcessSpawner
/** UTF-16 units, not bytes — this bounds the buffer, it is not a payload contract. */
const MAX_RESPONSE_CHARS = 20 * 1024 * 1024
const MAX_STDERR_CHARS = 4096
@@ -30,7 +23,7 @@ export class DesktopScriptServeChannel {
private closed = false
constructor(
private readonly child: RuntimeChildProcess,
private readonly child: ChildProcessWithoutNullStreams,
private readonly handlers: ServeChannelHandlers
) {
const onStdout = (chunk: Buffer | string): void => this.readStdout(chunk)
@@ -135,7 +128,7 @@ export class DesktopScriptServeChannel {
export function startServeChannel(
spec: PipedProcessSpec,
spawn: RuntimeProcessSpawn,
spawn: PipedProcessSpawner,
handlers: ServeChannelHandlers
): DesktopScriptServeChannel {
return new DesktopScriptServeChannel(spawn(spec), handlers)
@@ -3,12 +3,12 @@ import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { afterEach, describe, expect, it } from 'vitest'
import { stopMacOSPermissionStatusHelper } from './macos-computer-use-permission-status-cleanup'
describe.skipIf(process.platform !== 'darwin')('real permission status helper cleanup', () => {
const children: ChildProcessHandle[] = []
const children: ChildProcess[] = []
const directories: string[] = []
afterEach(async () => {
@@ -27,7 +27,7 @@ describe.skipIf(process.platform !== 'darwin')('real permission status helper cl
)
})
async function startFixture(executablePath: string, args: string[]): Promise<ChildProcessHandle> {
async function startFixture(executablePath: string, args: string[]): Promise<ChildProcess> {
const child = spawnProcess({
program: process.execPath,
args: [
@@ -1,4 +1,4 @@
import type { ChildProcessHandle as ChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
export const PROVIDER_SIGKILL_GRACE_MS = 2_000
@@ -1,11 +1,11 @@
import { once } from 'node:events'
import { afterEach, describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { reapMacOSProviderProcess } from './macos-native-provider-process-reaping'
describe.skipIf(process.platform === 'win32')('real macOS provider process reaping', () => {
const children: ChildProcessHandle[] = []
const children: ChildProcess[] = []
afterEach(async () => {
await Promise.all(
@@ -1,6 +1,6 @@
import { forkProcess, type ForkSpec } from '@orca/process-host/fork-process'
import { spawnProcess } from '@orca/process-host'
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { getAppEnvironment } from '../../../shared/app-environment'
import { removeChromiumDisabledSessionBus } from '../../pty/shell-startup/chromium-session-bus-env'
import { hostMallocTunablesDaemonEnv } from '../../memory/host-malloc-tunables'
@@ -79,7 +79,7 @@ export function buildDaemonScriptArgs(
export function spawnDaemonChildProcess(
options: DaemonChildSpawnOptions,
useDurableScope: boolean
): SpawnedProcess {
): ChildProcess {
const {
forkEntryPath,
relocatedExecPath,
@@ -1,5 +1,6 @@
import { spawnProcess } from '@orca/process-host'
import type { ProcessSpec, SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { ProcessSpec } from '@orca/process-host/process-spec'
// The pipe closes even on SIGKILL; a live/reused owner PID always vetoes cleanup.
const SCOPE_DEATH_WATCH_SCRIPT = `
@@ -24,10 +25,10 @@ type ScopeDeathWatchOptions = {
/** Stopping the owned daemon scope also reaps its bound terminal slice. */
daemonScope: string | null
log: (event: string, details?: Record<string, unknown>) => void
spawn?: (spec: ProcessSpec) => SpawnedProcess
spawn?: (spec: ProcessSpec) => ChildProcess
}
export function startDaemonScopeDeathWatch(options: ScopeDeathWatchOptions): SpawnedProcess | null {
export function startDaemonScopeDeathWatch(options: ScopeDeathWatchOptions): ChildProcess | null {
const { daemonScope: unit, log } = options
if (!unit) {
return null
@@ -1,8 +1,8 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { killSpawnedRipgrepProcess } from '../../../shared/ripgrep/ripgrep-process-availability'
export type FilesystemListingProcess = {
child: ChildProcessHandle
child: ChildProcess
isDone: () => boolean
finish: (error?: Error) => void
}
@@ -1,16 +1,16 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { removeWatcherCanaryDirectory } from './parcel-watcher-canary-directory'
export class WatcherChildSlot {
child: ChildProcessHandle | null = null
terminating: ChildProcessHandle | null = null
child: ChildProcess | null = null
terminating: ChildProcess | null = null
canaryDir: string | null = null
removeCanary(): void {
this.canaryDir = removeWatcherCanaryDirectory(this.canaryDir)
}
beginTermination(proc: ChildProcessHandle): void {
beginTermination(proc: ChildProcess): void {
this.terminating = proc
this.removeCanary()
}
@@ -1,14 +1,14 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
watcherChildPhysicalExit,
requireWatcherChildTermination
} from './parcel-watcher-child-termination'
export class WatcherOwnedChildren {
private readonly children = new Set<ChildProcessHandle>()
private readonly children = new Set<ChildProcess>()
private disposal: Promise<void> | null = null
track(child: ChildProcessHandle): ChildProcessHandle {
track(child: ChildProcess): ChildProcess {
this.children.add(child)
// Reuse launch-owned physical-exit evidence, including close without exit after spawn failure.
void watcherChildPhysicalExit(child).then(() => {
@@ -1,5 +1,5 @@
/** Poll inside WSL so distro shutdown kills the watcher instead of Windows UNC polling repeatedly waking it. */
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { StringDecoder } from 'node:string_decoder'
import type { WebContents } from 'electron'
import type { Event as WatcherEvent } from '@parcel/watcher'
@@ -234,7 +234,7 @@ export async function createWslWatcher(
}
}
let child: PipedChildProcess
let child: ChildProcessWithoutNullStreams
const releaseChildReservation = watcherChildRegistry.reserveWatcherChild()
if (!releaseChildReservation) {
throw new watcherChildRegistry.WatcherChildCapacityError()
@@ -1,9 +1,12 @@
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { resolveWslInteropSpawnCwd } from '../../../wsl/execution/wsl-interop-spawn-directory'
/** Start the in-distro poll script; process-host applies the internal distro allowlist. */
export function spawnWslWatcherProcess(distro: string, linuxPath: string): PipedChildProcess {
export function spawnWslWatcherProcess(
distro: string,
linuxPath: string
): ChildProcessWithoutNullStreams {
return spawnProcess({
program: 'wsl.exe',
args: ['-d', distro, '--exec', 'sh', '-s', '--', linuxPath],
@@ -1,11 +1,10 @@
import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
import { spawnSync, type ChildProcessWithoutNullStreams } from 'node:child_process'
import { createServer, type Server, type Socket } from 'node:net'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess as Bridge } from '@orca/process-host/process-spec'
import { OrcadStdioBridgeUnavailableError } from '../../orcad/orcad-host-unavailable'
import { checkOrcadStdioBridge, type OrcadStdioBridge } from './orcad-stdio-bridge'
import { orcadBashStdioBridgeCommand } from './orcad-stdio-bridge-script'
@@ -39,7 +38,10 @@ afterAll(() => {
rmSync(scratch, { recursive: true, force: true })
})
function spawnBridge(port: number, env: Partial<NodeJS.ProcessEnv> = {}): Bridge {
function spawnBridge(
port: number,
env: Partial<NodeJS.ProcessEnv> = {}
): ChildProcessWithoutNullStreams {
return spawnProcess({
program: '/bin/sh',
args: ['-c', orcadBashStdioBridgeCommand(port)],
@@ -51,7 +53,7 @@ function realCat(): string {
return spawnSync('sh', ['-c', 'command -v cat'], { encoding: 'utf8' }).stdout.trim()
}
function exitOf(child: Bridge): Promise<number | null> {
function exitOf(child: ChildProcessWithoutNullStreams): Promise<number | null> {
return new Promise((resolve) => child.once('exit', (code) => resolve(code)))
}
@@ -1,13 +1,9 @@
import { beforeEach, expect, it, vi } from 'vitest'
import { track } from '../../telemetry/client'
import {
CALLER,
attachParams,
hostTestState
} from './host/testing/structured-agent-session-host-test-harness'
import './host/testing/structured-agent-session-create-test-fixture'
import { track } from '../../../../telemetry/client'
import { CALLER, attachParams, hostTestState } from './structured-agent-session-host-test-harness'
import './structured-agent-session-create-test-fixture'
vi.mock('../../telemetry/client', () => ({ track: vi.fn() }))
vi.mock('../../../../telemetry/client', () => ({ track: vi.fn() }))
beforeEach(() => vi.mocked(track).mockClear())
it('keeps a proved process live when telemetry capture fails', async () => {
@@ -10,7 +10,7 @@ import { withTimeout } from '../../shared/promise-timeout-fallback'
import { createOutputSink } from '@orca/process-host/bounded-output-sink'
import { readFetchResponseJsonWithinLimit } from '../../shared/fetch-response-body'
import { cancelUnreadResponseBody } from '../lib/unread-response-body'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { createProviderSpawnSpec } from '../provider-process/provider-process-supervisor'
import { stopSupervisedChildProcess } from '../provider-process/supervised-child-process-stop'
import { guardSupervisedProviderGroup } from '../provider-process/provider-group-orphan-guard'
@@ -172,7 +172,7 @@ export async function probeOpenCodeLaunchModelContext(options: {
/** Only the supervisor’s normal stop/relayed exit proves its detached server group is gone.
* Forced supervisor teardown and failed group reap (exit 1) prove nothing. */
async function stopSupervisedPreflight(
child: ChildProcessHandle,
child: ChildProcess,
closed: Promise<boolean>
): Promise<boolean> {
if (!child.pid) {
@@ -1,4 +1,5 @@
import type { PipedChildProcess, PipedProcessSpawner } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpawner } from '@orca/process-host/process-spec'
import { spawnProcess } from '@orca/process-host'
import { RetryableProcessExitProof } from '@orca/process-host/retryable-process-exit-proof'
import type { ProviderProcessLaunch } from './provider-process-launch'
@@ -53,7 +54,7 @@ type ManagedProviderProcessOptions = {
}
export type ManagedProviderProcess = {
child: PipedChildProcess
child: ChildProcessWithoutNullStreams
supervised: boolean
/** The spawn failed before a process existed: absence is proven, but no exit was observed. */
readonly processless: boolean
@@ -1,4 +1,4 @@
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { DescendantTreeVerdict } from '../pty/process-retirement/pty-descendant-exit-verification'
import { waitForProcessExitUntil } from './provider-process-exit-deadline'
import {
@@ -26,7 +26,7 @@ export type ProviderProcessClosePolicy = {
}
export type ProviderProcessCloseInput = {
child: Pick<SpawnedProcess, 'pid' | 'kill' | 'stdin'>
child: Pick<ChildProcess, 'pid' | 'kill' | 'stdin'>
exitPromise: Promise<void>
rootVerdict: () => DescendantTreeVerdict
supervised?: boolean
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
captureDescendantSnapshot,
type DescendantSnapshot
@@ -19,7 +19,7 @@ export type ProviderProcessTeardownVerdict =
const activeTeardowns = new WeakMap<object, Promise<ProviderProcessTeardownVerdict>>()
type TeardownChild = Pick<ChildProcessHandle, 'pid' | 'kill'>
type TeardownChild = Pick<ChildProcess, 'pid' | 'kill'>
export type ProviderProcessTeardownDeps = {
site: string
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
closeProviderProcess,
rootOnlyProviderClosePolicy,
@@ -8,7 +8,7 @@ import type { ProviderCloseRequest } from './provider-process-supervisor'
import { terminateProviderProcessTree } from './provider-process-teardown'
type SupervisedChild = Pick<
ChildProcessHandle,
ChildProcess,
'pid' | 'kill' | 'stdin' | 'exitCode' | 'signalCode' | 'once'
>
@@ -1,5 +1,5 @@
import { forkProcess } from '@orca/process-host/fork-process'
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
const CONPTY_PROCESS_LIST_TIMEOUT_MS = 3_000
@@ -9,7 +9,7 @@ type ForkConsoleListAgent = (
modulePath: string,
args: string[],
options: { silent: true }
) => SpawnedProcess
) => ChildProcess
const forkConsoleListAgent: ForkConsoleListAgent = (modulePath, args) =>
forkProcess({ modulePath, args, stdio: ['pipe', 'pipe', 'pipe', 'ipc'] })
@@ -33,7 +33,7 @@ export function readWindowsConsoleAttachedProcessIds(
if (!Number.isSafeInteger(rootPid) || rootPid <= 0) {
return Promise.resolve(null)
}
let child: SpawnedProcess
let child: ChildProcess
try {
child = (deps.forkProcess ?? forkConsoleListAgent)(
(deps.resolveAgentPath ?? resolveNodePtyConsoleListAgent)(),
+3 -3
View File
@@ -1,10 +1,10 @@
import { signalProcessTree } from '@orca/process-host/process-tree-termination'
import { killSpawnedRipgrepProcess } from '../../shared/ripgrep/ripgrep-process-availability'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
const stoppingChildren = new WeakSet<ChildProcessHandle>()
const stoppingChildren = new WeakSet<ChildProcess>()
export function stopBundledRipgrep(child: ChildProcessHandle, wsl = false): void {
export function stopBundledRipgrep(child: ChildProcess, wsl = false): void {
if (stoppingChildren.has(child)) {
return
}
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { SearchOptions, SearchResult } from '../../shared/file-search/code-search-types'
import { RipgrepSearchDiagnostics } from '../../shared/ripgrep/ripgrep-search-diagnostics'
import { SearchSubprocessLineAccumulator } from '../../shared/search-subprocess-lines'
@@ -45,7 +45,7 @@ export function runBundledRipgrepTextSearch({
wslDistro?: string
wslDistroForOutput?: string
signal?: AbortSignal
onSpawn: (child: ChildProcessHandle) => () => void
onSpawn: (child: ChildProcess) => () => void
}): Promise<SearchResult> {
throwIfSignalAborted(signal)
const maxResults = Math.max(
@@ -65,7 +65,7 @@ export function runBundledRipgrepTextSearch({
let resolved = false
let processErrorObserved = false
let unavailableExitObserved = false
let child: ChildProcessHandle | null = null
let child: ChildProcess | null = null
let killTimeout: ReturnType<typeof setTimeout> | undefined
let releaseChild: (() => void) | undefined
@@ -1,4 +1,4 @@
import type { ChildProcessHandle as ChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { spawnProcess } from '@orca/process-host'
import { connect } from 'node:net'
import { createSshOperationAbortError } from '../../connection/ssh-exec-options'
@@ -1,5 +1,5 @@
/** On Windows, hold a proxied ssh -N -L once; route later execs through loopback to avoid repeated proxy handshakes without ControlMaster. */
import type { ChildProcessHandle as ChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import {
childProcessHasExited,
signalProcessTree
+2 -2
View File
@@ -1,4 +1,4 @@
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { delimiter, win32 as pathWin32 } from 'node:path'
import { spawnProcess } from '@orca/process-host'
import { stripAnsiEscapeSequences } from '../../shared/ansi-escape-sequences'
@@ -154,7 +154,7 @@ function spawnShellAndReadPath(shell: string): Promise<HydrationResult> {
let stdout = ''
let timer: ReturnType<typeof setTimeout> | null = null
let child: SpawnedProcess
let child: ChildProcess
try {
child = spawnProcess({
program: shell,
+2 -2
View File
@@ -1,5 +1,5 @@
/** A detached login-shell probe gets no terminal signals, so its owner ends it: on timeout and when the owner exits. */
import type { SpawnedProcess } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import { signalProcessTree } from '@orca/process-host/process-tree-termination'
export type ShellProbeLifetime = {
@@ -10,7 +10,7 @@ export type ShellProbeLifetime = {
}
// No signal listeners: one would replace Electron's graceful signal quit, and every owner turns INT/TERM into an exit.
export function bindShellProbeLifetime(child: SpawnedProcess): ShellProbeLifetime {
export function bindShellProbeLifetime(child: ChildProcess): ShellProbeLifetime {
const kill = (): void => {
if (process.platform === 'win32') {
// Windows probes stay attached, and a tree kill would spawn taskkill from an exit hook.
@@ -1,4 +1,4 @@
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { spawnProcess } from '@orca/process-host'
import type {
WorkerThreadChildErrorPayload,
@@ -24,10 +24,13 @@ function toErrorPayload(error: unknown): WorkerThreadChildErrorPayload {
}
export function serveWorkerThreadChildProcesses(port: WorkerThreadChildPort): void {
const children = new Map<number, { child: PipedChildProcess; pendingOutputBytes: number }>()
const children = new Map<
number,
{ child: ChildProcessWithoutNullStreams; pendingOutputBytes: number }
>()
const spawnChild = ({ id, spec }: Extract<WorkerThreadChildRequest, { type: 'spawn' }>): void => {
let child: PipedChildProcess
let child: ChildProcessWithoutNullStreams
try {
child = spawnProcess({ ...spec, stdio: ['pipe', 'pipe', 'pipe'] })
} catch (error) {
@@ -1,7 +1,7 @@
import { EventEmitter } from 'node:events'
import { PassThrough } from 'node:stream'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import {
killWslChannelsInCloseGrace,
WSL_CHANNEL_CLOSE_GRACE_MS,
@@ -25,7 +25,7 @@ function fakeChild() {
child.emit('exit', code, null)
}
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the channel reads only these members.
return { child: child as unknown as PipedChildProcess, fake: child, exit }
return { child: child as unknown as ChildProcessWithoutNullStreams, fake: child, exit }
}
beforeEach(() => {
@@ -1,12 +1,12 @@
import { Duplex } from 'node:stream'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport'
/** How long a closed channel's guest gets to exit on stdin EOF before wsl.exe is killed. */
export const WSL_CHANNEL_CLOSE_GRACE_MS = 2_000
// wsl.exe children inside their close grace; quit kills them so none outlives Orca.
const closingChildren = new Set<PipedChildProcess>()
const closingChildren = new Set<ChildProcessWithoutNullStreams>()
/** App quit: no grace left, so a guest still running after close must not keep wsl.exe up. */
export function killWslChannelsInCloseGrace(): void {
@@ -19,7 +19,7 @@ export function killWslChannelsInCloseGrace(): void {
}
/** Expose wsl.exe stdio as an SSH-style channel; exit reports status and close follows stdio teardown. */
export function wrapWslCommandProcess(child: PipedChildProcess): RemoteCommandChannel {
export function wrapWslCommandProcess(child: ChildProcessWithoutNullStreams): RemoteCommandChannel {
// Only the child emits close, once after exit status, like ssh2.
const duplex = new Duplex({
emitClose: false,
@@ -1,4 +1,4 @@
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport'
import { createSshOperationAbortError } from '../../ssh/connection/ssh-exec-options'
import { startWslCommandLoop, wslCommandLoopMarker, type WslCommandLoop } from './wsl-command-loop'
@@ -11,7 +11,7 @@ export type WslCommandLoopPool = {
type WslCommandLoopPoolOptions = {
/** Starts `wsl.exe --exec sh -c <loop script> <argv0> <marker>`. */
spawnLoop: (marker: string) => PipedChildProcess
spawnLoop: (marker: string) => ChildProcessWithoutNullStreams
/** Concurrent commands beyond this run on their own wsl.exe, as before. */
maxLoops?: number
idleMs?: number
@@ -3,14 +3,14 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { execCommand } from '../../ssh/remote-exec/remote-exec-command'
import { WSL_COMMAND_LOOP_ARGV0, WSL_COMMAND_LOOP_SCRIPT } from './wsl-command-loop'
import { createWslCommandLoopPool, type WslCommandLoopPool } from './wsl-command-loop-pool'
// The guest side is plain POSIX sh, so a local sh stands in for `wsl.exe --exec sh`.
const posix = process.platform !== 'win32'
const spawned: PipedChildProcess[] = []
const spawned: ChildProcessWithoutNullStreams[] = []
const pools: WslCommandLoopPool[] = []
function pool(options: { maxLoops?: number; script?: string } = {}) {
+5 -2
View File
@@ -1,7 +1,7 @@
/** Reuse one wsl.exe for sequential stdin-free probes (~180ms startup each on win-lowspec). Isolate each sh command in its own session with /dev/null stdin; base64-frame output/status with per-loop markers. */
import { randomUUID } from 'node:crypto'
import { Duplex, PassThrough, Writable } from 'node:stream'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport'
// setsid preserves per-command process-group isolation. Fresh output files keep background writers attached to old inodes, never the next command.
@@ -53,7 +53,10 @@ export function wslCommandLoopMarker(): string {
return `__ORCA_WSL_EXEC_${randomUUID().replaceAll('-', '')}__`
}
export function startWslCommandLoop(child: PipedChildProcess, marker: string): WslCommandLoop {
export function startWslCommandLoop(
child: ChildProcessWithoutNullStreams,
marker: string
): WslCommandLoop {
let pending: PendingCommand | null = null
let alive = true
let buffered = ''
@@ -1,4 +1,4 @@
import { execFileSync } from 'node:child_process'
import { execFileSync, type ChildProcessWithoutNullStreams } from 'node:child_process'
import {
chmodSync,
existsSync,
@@ -14,7 +14,6 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import { uploadDirectoryIntoWsl } from './wsl-directory-upload'
import {
createWslOrcadHostTransport,
@@ -37,7 +36,7 @@ describe.skipIf(process.platform === 'win32' || !hasSha256sum())('uploadDirector
let dest: string
let commands: string[]
const transports: WslOrcadHostTransport[] = []
const children: PipedChildProcess[] = []
const children: ChildProcessWithoutNullStreams[] = []
const getTransport = (): WslOrcadHostTransport => {
const transport = transports.at(-1)
@@ -2,7 +2,8 @@
import { EventEmitter } from 'node:events'
import { connect } from 'node:net'
import { PassThrough } from 'node:stream'
import type { PipedChildProcess, PipedProcessSpawner } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpawner } from '@orca/process-host/process-spec'
import {
ORCAD_STDIO_BRIDGE_READY,
ORCAD_STDIO_BRIDGE_REFUSED,
@@ -78,7 +79,7 @@ export function fakeWslBridgeChildren(): FakeWslBridgeChildren {
socket.on('close', () => finish(0))
process.nextTick(() => child.emit('spawn'))
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the WSL channel reads only the streams, exit state, kill and events assigned above.
return child as unknown as PipedChildProcess
return child as unknown as ChildProcessWithoutNullStreams
}
return { spawn, commands, live: () => live, maxLive: () => maxLive }
}
@@ -1,12 +1,13 @@
import { Readable } from 'node:stream'
import { afterEach, describe, expect, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { PipedChildProcess, PipedProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpec } from '@orca/process-host/process-spec'
import { execCommand } from '../../ssh/remote-exec/remote-exec-command'
import { createWslOrcadHostTransport, type WslOrcadHostTransport } from './wsl-orcad-host-transport'
const posix = process.platform !== 'win32'
const children: PipedChildProcess[] = []
const children: ChildProcessWithoutNullStreams[] = []
const transports: WslOrcadHostTransport[] = []
/** Runs what follows `--exec` with the local sh, as wsl.exe would inside the distro. */
@@ -1,7 +1,8 @@
import { EventEmitter } from 'node:events'
import { PassThrough, Readable } from 'node:stream'
import { describe, expect, it, vi } from 'vitest'
import type { PipedChildProcess, PipedProcessSpec } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import type { PipedProcessSpec } from '@orca/process-host/process-spec'
import { execCommand } from '../../ssh/remote-exec/remote-exec-command'
import { WSL_CHANNEL_CLOSE_GRACE_MS } from '../execution/wsl-command-channel'
@@ -61,7 +62,7 @@ function transportWith(children: FakeChild[]) {
throw new Error('no fake child left')
}
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the channel reads only the streams, exit state, kill and events the fake provides.
return next as unknown as PipedChildProcess
return next as unknown as ChildProcessWithoutNullStreams
}
})
return { transport, specs }
@@ -172,7 +173,7 @@ describe('a transport with an abort signal', () => {
commandLoops: false,
signal: controller.signal,
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the channel reads only the streams, exit state, kill and events the fake provides.
spawn: () => child as unknown as PipedChildProcess
spawn: () => child as unknown as ChildProcessWithoutNullStreams
})
const channel = await transport.exec('sleep 60')
channel.on('error', () => {})
@@ -2,9 +2,9 @@
import {
fork as nodeFork,
type ForkOptions,
type SpawnOptions as NodeSpawnOptions
type SpawnOptions as NodeSpawnOptions,
type ChildProcess
} from 'node:child_process'
import type { SpawnedProcess } from './process-spec'
// Preserve fork semantics for module resolution, execPath overrides, and inherited execArgv.
export type ForkSpec = {
@@ -23,7 +23,7 @@ export type ForkSpec = {
serialization?: ForkOptions['serialization']
}
export function forkProcess(spec: ForkSpec): SpawnedProcess {
export function forkProcess(spec: ForkSpec): ChildProcess {
const options: ForkOptions = {
cwd: spec.cwd,
env: spec.env,
@@ -5,10 +5,6 @@ import type {
StdioOptions
} from 'node:child_process'
export type ChildProcessHandle = ChildProcess
export type SpawnedProcess = ChildProcess
export type ProcessSpec = {
/** Prefer an absolute Windows path; stripped Electron PATHs may not resolve bare names. */
program: string
@@ -42,13 +38,11 @@ export type ProcessSpec = {
onStderr?: (chunk: Buffer | string) => void
}
export type PipedChildProcess = ChildProcessWithoutNullStreams
export type PipedProcessSpec = Omit<ProcessSpec, 'stdio'> & {
stdio?: 'pipe' | ['pipe', 'pipe', 'pipe', ...Exclude<StdioOptions, string>]
}
export type PipedProcessSpawner = (spec: PipedProcessSpec) => PipedChildProcess
export type PipedProcessSpawner = (spec: PipedProcessSpec) => ChildProcessWithoutNullStreams
export type ProcessTerminationBarrier = {
observeStderr?: (chunk: Buffer | string) => void
+4 -8
View File
@@ -1,7 +1,8 @@
import {
spawn as nodeSpawn,
spawnSync as nodeSpawnSync,
type ChildProcess
type ChildProcess,
type ChildProcessWithoutNullStreams
} from 'node:child_process'
import { resolveSpawn, type ResolvedSpawn } from './spawn-resolution'
import { forceTerminateProcessTree, signalProcessTree } from './process-tree-termination'
@@ -13,12 +14,7 @@ import { createChildTerminationReporter } from './child-termination-reporter'
export { WindowsCmdLineBreakError } from './windows-command-line'
import type {
PipedChildProcess,
PipedProcessSpec,
ProcessSpec,
ProcessResult
} from './process-spec'
import type { PipedProcessSpec, ProcessSpec, ProcessResult } from './process-spec'
import { DEFAULT_PROCESS_TIMEOUT_MS, DEFAULT_MAX_OUTPUT_BYTES } from './process-spec'
// Bound waits for children that ignore termination and never emit close.
const PROCESS_EXIT_GRACE_MS = 2_000
@@ -26,7 +22,7 @@ const PROCESS_EXIT_GRACE_MS = 2_000
const BARRIER_UNVERIFIED_EXIT_GRACE_MS = 10_000
/** Callers own stream error handling; unhandled stream errors can crash the host process. */
export function spawnProcess(spec: PipedProcessSpec): PipedChildProcess
export function spawnProcess(spec: PipedProcessSpec): ChildProcessWithoutNullStreams
export function spawnProcess(spec: ProcessSpec): ChildProcess
export function spawnProcess(spec: ProcessSpec): ChildProcess {
const resolved = resolveSpawn(spec, process.platform)
@@ -1,9 +1,10 @@
import { once } from 'node:events'
import { describe, expect, expectTypeOf, it } from 'vitest'
import { spawnProcess } from '@orca/process-host'
import type { ChildProcessHandle, PipedChildProcess, ProcessSpec } from './process-spec'
import type { ChildProcess, ChildProcessWithoutNullStreams } from 'node:child_process'
import type { ProcessSpec } from './process-spec'
async function waitForClose(child: ChildProcessHandle): Promise<void> {
async function waitForClose(child: ChildProcess): Promise<void> {
try {
await once(child, 'close', { signal: AbortSignal.timeout(5_000) })
} finally {
@@ -18,7 +19,7 @@ async function waitForClose(child: ChildProcessHandle): Promise<void> {
describe('public spawn stream contracts', () => {
it('returns three pipes by default', async () => {
const child = spawnProcess({ program: process.execPath, args: ['-e', ''] })
expectTypeOf(child).toEqualTypeOf<PipedChildProcess>()
expectTypeOf(child).toEqualTypeOf<ChildProcessWithoutNullStreams>()
await waitForClose(child)
expect(child.stdin).not.toBeNull()
expect(child.stdout).not.toBeNull()
@@ -27,7 +28,7 @@ describe('public spawn stream contracts', () => {
it('returns three pipes for an explicit pipe mode', async () => {
const child = spawnProcess({ program: process.execPath, args: ['-e', ''], stdio: 'pipe' })
expectTypeOf(child).toEqualTypeOf<PipedChildProcess>()
expectTypeOf(child).toEqualTypeOf<ChildProcessWithoutNullStreams>()
await waitForClose(child)
expect(child.stdin).not.toBeNull()
expect(child.stdout).not.toBeNull()
@@ -40,7 +41,7 @@ describe('public spawn stream contracts', () => {
args: ['-e', ''],
stdio: ['pipe', 'pipe', 'pipe']
})
expectTypeOf(child).toEqualTypeOf<PipedChildProcess>()
expectTypeOf(child).toEqualTypeOf<ChildProcessWithoutNullStreams>()
await waitForClose(child)
expect(child.stdin).not.toBeNull()
expect(child.stdout).not.toBeNull()
@@ -53,7 +54,7 @@ describe('public spawn stream contracts', () => {
args: ['-e', 'process.disconnect()'],
stdio: ['pipe', 'pipe', 'pipe', 'ipc']
})
expectTypeOf(child).toEqualTypeOf<PipedChildProcess>()
expectTypeOf(child).toEqualTypeOf<ChildProcessWithoutNullStreams>()
await waitForClose(child)
expect(child.stdin).not.toBeNull()
expect(child.stdout).not.toBeNull()
@@ -62,7 +63,7 @@ describe('public spawn stream contracts', () => {
it.each(['ignore', 'inherit'] as const)('returns nullable streams for %s', async (stdio) => {
const child = spawnProcess({ program: process.execPath, args: ['-e', ''], stdio })
expectTypeOf(child).toEqualTypeOf<ChildProcessHandle>()
expectTypeOf(child).toEqualTypeOf<ChildProcess>()
await waitForClose(child)
expect(child.stdin).toBeNull()
expect(child.stdout).toBeNull()
@@ -75,7 +76,7 @@ describe('public spawn stream contracts', () => {
args: ['-e', ''],
stdio: ['ignore', 'pipe', 'pipe']
})
expectTypeOf(child).toEqualTypeOf<ChildProcessHandle>()
expectTypeOf(child).toEqualTypeOf<ChildProcess>()
await waitForClose(child)
expect(child.stdin).toBeNull()
expect(child.stdout).not.toBeNull()
@@ -85,7 +86,7 @@ describe('public spawn stream contracts', () => {
it('keeps the general contract when the specification does not guarantee pipes', async () => {
const spec: ProcessSpec = { program: process.execPath, args: ['-e', ''] }
const child = spawnProcess(spec)
expectTypeOf(child).toEqualTypeOf<ChildProcessHandle>()
expectTypeOf(child).toEqualTypeOf<ChildProcess>()
await waitForClose(child)
})
})
@@ -1,6 +1,6 @@
import type * as ChildProcessModule from 'node:child_process'
import { PassThrough } from 'node:stream'
import type { PipedChildProcess } from '@orca/process-host/process-spec'
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
import { vi } from 'vitest'
// Consumers may mock spawn without exporting the ChildProcess constructor.
@@ -11,7 +11,13 @@ class FakeSpawnedChild extends NodeChildProcess {
override stdin = new PassThrough()
override stdout = new PassThrough()
override stderr = new PassThrough()
override stdio: PipedChildProcess['stdio'] = [this.stdin, this.stdout, this.stderr, null, null]
override stdio: ChildProcessWithoutNullStreams['stdio'] = [
this.stdin,
this.stdout,
this.stderr,
null,
null
]
override kill = vi.fn((_signal?: NodeJS.Signals | number) => true)
override unref = vi.fn<() => void>()
@@ -1,4 +1,4 @@
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
import type { MarkdownDocument } from './file-document'
import { RipgrepFilenameDecoder } from '../ripgrep/ripgrep-filename-decoder'
import {
@@ -38,7 +38,7 @@ export const MARKDOWN_DOCUMENT_LISTING_ARGS = [
]
export function collectMarkdownDocuments(
child: ChildProcessHandle,
child: ChildProcess,
rootPath: string,
windowsOutput = false,
signal?: AbortSignal,
@@ -1,6 +1,6 @@
import { constants } from 'node:fs'
import { access, stat } from 'node:fs/promises'
import type { ChildProcessHandle } from '@orca/process-host/process-spec'
import type { ChildProcess } from 'node:child_process'
const RIPGREP_CWD_CHECK_TIMEOUT_MS = 1000
@@ -35,7 +35,7 @@ export function isTransientRipgrepSpawnError(error: unknown): boolean {
function ignoreRipgrepSpawnError(): void {}
export function killSpawnedRipgrepProcess(child: ChildProcessHandle): boolean {
export function killSpawnedRipgrepProcess(child: ChildProcess): boolean {
// Why: killing a failed-spawn handle can signal the relay's own process group.
if (Object.hasOwn(child, 'pid') && child.pid === undefined) {
return false
@@ -44,7 +44,7 @@ export function killSpawnedRipgrepProcess(child: ChildProcessHandle): boolean {
}
export function absorbPendingRipgrepSpawnError(
child: ChildProcessHandle,
child: ChildProcess,
state: { errorObserved: boolean; unavailableExitObserved: boolean }
): void {
if (
@@ -107,7 +107,7 @@ export async function classifySynchronousRipgrepSpawnFailure(
}
export function isRipgrepUnavailableExit(
child: ChildProcessHandle,
child: ChildProcess,
code: number | null,
signal: NodeJS.Signals | null,
options: { classifyNativeLauncherExit?: boolean } = {}