Skip to content

refactor(core): use Latch for shell output gate - #43573

Merged
kitlangton merged 1 commit into
v2from
latch-shell-output
Aug 20, 2026
Merged

refactor(core): use Latch for shell output gate#43573
kitlangton merged 1 commit into
v2from
latch-shell-output

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

The shell session's outputDone signal is a pure "output pump drained" gate — a Deferred<void> succeeded on both the success and catch paths of the pump fiber and awaited once in finish. Latch expresses that open-once, never-failing intent directly.

How

packages/core/src/shell.ts:

  • outputDone is now Latch.makeUnsafe() (starts closed).
  • Both completion sites (normal drain and the catch fallback) use outputDone.open.
  • finish waits with outputDone.await.

The value/error-carrying deferreds in the same file (ready, waiter Info resolution) are correct as Deferred and unchanged. No behavior change. Found by a repo-wide audit of Deferred<void>-as-gate patterns; sibling PRs convert the other pure-gate sites.

Testing

  • packages/core: bun typecheck; bun test test/shell.test.ts test/shell-cleanup.test.ts test/tool-shell.test.ts (29 pass); full bun run test (1908 tests, 0 fail).

@kitlangton
kitlangton enabled auto-merge (squash) August 20, 2026 15:37
@kitlangton
kitlangton merged commit 6f629c2 into v2 Aug 20, 2026
10 checks passed
@kitlangton
kitlangton deleted the latch-shell-output branch August 20, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant