Skip to content

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

Open
kitlangton wants to merge 1 commit into
v2from
latch-shell-output
Open

refactor(core): use Latch for shell output gate#43573
kitlangton wants to merge 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).

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