Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

fix(core): backport transport and process-exit cleanup - #410

Merged
brentyates-swx merged 36 commits into
swxtchfrom
fm/oc-transport-exit-393
Nov 6, 2026
Merged

brentyates-swx merged 36 commits into
swxtchfrom
fm/oc-transport-exit-393

Conversation

@brentyates-swx

@brentyates-swx brentyates-swx commented Nov 4, 2026 •

Copy link
Copy Markdown

Closes https://github.com/swxtchio/swx-opencode/issues/393.

Backport the assigned transport and process-lifecycle behavior in the fork's existing owners. Preserve request options, caller cancellation, configured deadlines, fork #303's generation-progress watchdog, fork #380 cancellation cleanup, and intentional descendant release.

Donor coverage

  • anomalyco/opencode#55149 (52a10f573f1da5103c85990da9341e3645a39365), local cherry-pick ca3abb1290: the assigned TUI/run/mini fetch override is complete through packages/core/src/no-timeout-fetch.ts, packages/tui/src/context/sdk.tsx, and packages/opencode/src/cli/cmd/run.ts. The donor's existing-session shell-failure UI recovery is unassigned and excluded; payload status is partial.
  • anomalyco/opencode#55007 (460c626acd9e3de8fdffc27bde99bb5f070bb70f), local cherry-pick 379832391b: the native override is wired at packages/core/src/effect/app-node-platform.ts's actual RequestExecutor composition; payload status is complete.
  • anomalyco/opencode#59411 (e2bc79dc0bae112b79ab780f7c1a63db8a7f7dae), local cherry-pick 31ccedc31b: detached POSIX groups are synchronously terminated while cleanup remains owed. packages/tui/src/app.tsx routes terminal SIGHUP through renderer shutdown; packages/tui/src/terminal-signal.ts preserves nohup's ignore without a TTY. The upstream CLI shutdown-deadline module is absent and not imported; payload status is partial, assigned behavior complete.

Bun 1.4.4 and install

The official bun-linux-aarch64.zip SHA-256 baa6bb36f51d6e58561e02bbea825038a9df454f673d6d776e8bbf86f8c7850e matched the committed Nix SRI sha256-uqa7NvUdblhWHgK76oJQOKnfRU9nPW13bou/hvjHhQ4=. The extracted binary reported Bun 1.4.4, revision 1.4.4+38afee6c8. bun install --frozen-lockfile passed with the verified binary and reported no lockfile changes (2,444 installs checked across 2,843 packages).

Core, OpenCode, and TUI package-local bun typecheck each passed in bounded, memory-capped background scopes. OpenCode typecheck was repeated after the test-only server-readiness bound adjustment and passed.

Round-one review coverage

  1. CrossSpawnSpawner sends acknowledged process-group acquisition/release events to the TUI server Worker. Worker shutdown kills and confirms its remaining groups before replying; TuiThreadCommand keeps the recorded PGID ledger for bounded timeout, Worker-error and owner-exit backstops. The focused integration test drives the real packages/opencode/src/cli/tui/worker.ts RPC path for both shutdown acknowledgement and a blocked-shutdown parent backstop.
  2. TUI SDK/SSE and Mini attach tests hold real requests while a default fetch control expires under a child Bun 1.4.4 process configured with BUN_CONFIG_HTTP_IDLE_TIMEOUT=2; they then release the real event or session response. The attached-run acceptance uses the same short child-process timeout and confirms persisted session output.
  3. SIGHUP fixtures now report only observed behavior: the real terminal TUI fixture verifies lifecycle cleanup, the nohup fixture proves ignored-SIGHUP survival, and a non-TTY non-nohup fixture proves the OS default action without asserting graceful cleanup.
  4. The default unit suite no longer waits multiple minutes: held-request witnesses use bounded child Bun processes and short release windows. Before that change, unmodified-default runs had already observed native and attached-run completion after 374.96s and 418.23s respectively.
  5. CHANGESET.md now records the replace-not-merge native request policy, high-level option preservation, acknowledged Worker group ownership, SIGHUP distinctions, and test coverage.

Focused validation (verified Bun 1.4.4)

  • Core native idle witness: 1 pass, 12.18s; CrossSpawnSpawner ownership/scope-release slice: 5 pass, 17.92s.
  • Mini attach witness: 1 pass, 21.13s; attached-run witness: 1 pass, 22.19s.
  • TUI SDK/SSE witness: 1 pass, 15.31s; terminal/nohup/default SIGHUP fixtures: 3 pass, 7.90s.
  • Real TUI Server Worker process-group shutdown/backstop test: 1 pass, 22 assertions.
  • Core, OpenCode, and TUI package typechecks passed in bounded scopes; the normal pre-push Turbo typecheck also passed 30/30 with concurrency limited to one.

Focused preservation and removal proofs

  • Under Bun 1.4.4, the core fetch-helper tests, Mini attach construction, TUI SDK event client, TUI terminal/nohup SIGHUP cases, Core native caller-expiry case, abrupt-owner-exit group cases, and the fix(core): reap shell process groups on cancellation #380 scope-release descendant-reaping case passed.
  • The fix(opencode): bound stalled provider streams and interrupts #303 Foundry stall case passed with the generation-progress timeout restored; the slow-reasoning and Chat Completions/tool-argument progress cases passed. An earlier slow-reasoning run hit the fixture's 2-second progress deadline; the final isolated uninstrumented run passed.
  • Replacing noTimeoutFetch with fetch(request, init) made the Mini and TUI SDK regressions fail at timeoutDisabled (false, expected true). The attached-run regression also failed under a red-only BUN_CONFIG_HTTP_IDLE_TIMEOUT=2 run with the helper removed; its green acceptance used the unmodified default.
  • Removing Layer.provide(withoutBunTimeout) made the native composition regression observe timeout: 1 instead of false. Removing the spawner's exit hook made live and cleanup-owed group cases fail with recorded members still alive. Removing the TUI non-terminal guard made the nohup case fail; removing terminal handler registration made the PTY case fail. Disabling the fix(opencode): bound stalled provider streams and interrupts #303 progress timer made the stalled-Foundry case fail inside its bound. Each behavior was restored and its focused positive case passed.

Round-one changed tests: packages/core/test/effect/app-node-platform.test.ts, packages/core/test/effect/cross-spawn-spawner.test.ts, packages/opencode/test/cli/run/mini-attach.test.ts, packages/opencode/test/cli/run/run-process.test.ts, packages/opencode/test/cli/tui/worker-process-group.test.ts, packages/tui/test/cli/tui/sdk-transport.test.tsx, and packages/tui/test/app-lifecycle.test.tsx. Supporting process fixtures are packages/opencode/test/cli/run/mini-attach-worker.ts, packages/opencode/test/cli/tui/worker-process-group-worker.ts, packages/tui/test/fixture/sighup-ignore-worker.ts, and packages/tui/test/fixture/sighup-terminal-worker.ts.

Handoff

Current pushed head: b05423513beb168f45c29cb11e3aaf5cdc7c631f, on fm/oc-transport-exit-393, based on the no-rebase merge of origin/swxtch through 02013d1c77 (#407). PR #410 remains draft. The commit-identity gate passed on the merged base range. This repository has no bin/fm-lint.sh. Do not merge the PR or mark it ready; Firstmate owns review and final-suite admission.

Implement the assigned transport and lifecycle behavior in existing fork owners.

- Pick each donor in its own -x commit; omit shell-failure UI and absent CLI/MCP payload.
- Disable Bun’s independent fetch deadline only for long network clients and native provider requests; preserve caller signals, domain deadlines, and the #303 watchdog.
- Track detached POSIX groups only while cleanup is owed, preserving #380 escalation and release of intentional descendants; route terminal SIGHUP through the TUI lifecycle.
- Add real-server and child-process regressions with removal proofs, then record donor coverage and focused checks in CHANGESET.md.
@brentyates-swx

Copy link
Copy Markdown
Author

Session ID: unknown
Working repo: /home/byates/fm-worktrees/fm-llmrouter/oc-transport-exit-393/swx-opencode

Finn763 and others added 14 commits November 4, 2026 17:43
…lyco#55149)

Give the TUI client timeout: false, share the no-timeout fetch helper across run, mini and the TUI via @opencode/util/no-timeout-fetch, and surface existing-session shell failures with a toast and composer restore.

Closes anomalyco#54974

Co-authored-by: Finn763 <[email protected]>
(cherry picked from commit 52a10f5)
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5

# Conflicts:
#	CHANGESET.md
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Run the native and attached held-response witnesses in bounded Bun 1.4.4 child processes with BUN_CONFIG_HTTP_IDLE_TIMEOUT=2 so they stay out of the multi-minute range.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Exercise SDKProvider's external SDK and SSE paths with a held event stream, a real timeout control, and a completed event after the injected short idle expiry.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Hold the real mini attach session response in a Bun 1.4.4 child process, observe an unmodified control fetch time out first, then release the expected 404 response.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Keep the nohup fixture scoped to listener policy and process survival, and add a non-TTY non-nohup default-disposition witness while retaining lifecycle assertions only from the real TUI producer.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Acknowledge Worker group ownership and release events, kill and await remaining groups before the shutdown reply, and use the recorded PGID ledger as the bounded TUI-owner backstop when shutdown is unconfirmed.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
Record the acknowledged TUI Worker group lifecycle, truthful SIGHUP behavior, and short Bun 1.4.4 behavioral witnesses in the backport ledger.

Claude-Session: c368ed23-1e31-4f2c-b305-b84f21d79cc5
1. Make worker and parent ownership ledgers converge on each local acquire, release, and cleanup decision even when acknowledgement is rejected or delayed; validate recorded identities before parent-side signalling.
2. Add rejected/delayed acknowledgement regressions for acquire, release, cleanup announcement, and release/reacquire identity fallback.
3. Harden fixture cleanup and deadlines; add Linux-only guards; correct CHANGESET ownership and SIGHUP claims; remove only test hooks no longer needed.
4. Verify focused changed cases and then each importing test file once under checksum-verified Bun 1.4.4; commit without pushing.
Reconcile Worker and parent ownership ledgers on local acquire, release, and cleanup facts, independent of rejected or delayed acknowledgements. Validate recorded member identities before signalling and preserve released member identities across reacquisition.

Bound identity-owned process fixture cleanup, gate procfs child fixtures to Linux, retain portable SDK cancellation coverage, and correct the #410 SIGHUP and ownership ledger.

Claude-Session: unknown
Wait for the process spawn acknowledgement before the ShellTool first-output deadline and reap the child on readiness failure. Tighten process-group fixture types for package typecheck.

Claude-Session: unknown
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
Claude-Session: unavailable (OpenCode session)
@brentyates-swx
brentyates-swx marked this pull request as ready for review November 6, 2026 18:00
@brentyates-swx
brentyates-swx merged commit 5d878c1 into swxtch Nov 6, 2026
5 of 7 checks passed
@brentyates-swx
brentyates-swx deleted the fm/oc-transport-exit-393 branch November 6, 2026 18:11
brentyates-swx added a commit that referenced this pull request Nov 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backport upstream long-call fetch-timeout override and hard-exit process-group cleanup

3 participants