Skip to content

Unify the backend connect signature on one host-injected shape - #38

Merged
aron-cf merged 2 commits into
stack/3-process-shimfrom
stack/4-unify-connect-host
Aug 3, 2026
Merged

aron-cf merged 2 commits into
stack/3-process-shimfrom
stack/4-unify-connect-host

Conversation

@aron-cf

@aron-cf aron-cf commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

The two backend interfaces took different connect signatures. The shell and container kind took a bare connect() and reached the host through a transport it captured when it was built. The JavaScript kind took a connect(host) that received the storage-layer handles the Workspace owns. The split was historical rather than necessary: the host bag exists only because the Workspace builds its database and filesystem handles after the caller has already constructed the backends and passed them in, so a backend cannot capture them at its own construction time.

This change gives every backend the same connect(host) signature and has the Workspace pass its host bag on every connect. Shell and container backends accept the bag and ignore it, reaching the host through their own transport as before; the JavaScript backend uses it as before. Because method parameters are compatible when an implementation ignores arguments the interface declares, the existing zero-argument implementations satisfy the wider signature without edits. The duplicate host type collapses onto one canonical definition.

This is internal plumbing. connect is called only by the Workspace itself, never by an example or other consumer, so there is no public-API impact. No behavior changes.

Verify with npm test --workspace @cloudflare/computer and npm run typecheck.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/computer/@cloudflare/computer@38

commit: 741f0c9

@aron-cf
aron-cf force-pushed the stack/4-unify-connect-host branch from 741f0c9 to 0653c4e Compare August 1, 2026 17:32
@aron-cf
aron-cf force-pushed the stack/4-unify-connect-host branch from 0653c4e to 27e1a4d Compare August 3, 2026 10:18
@aron-cf
aron-cf force-pushed the stack/4-unify-connect-host branch from 27e1a4d to f8a8e78 Compare August 3, 2026 10:39
aron-cf added 2 commits August 3, 2026 11:49
The shell and module backend interfaces took different connect
signatures: the shell kind a bare connect(), the module kind a
connect(host) receiving the storage-layer handles the Workspace owns.
The split was historical, not necessary; the host bag exists only
because the Workspace builds db and fs after the caller constructs the
backends.

Give WorkspaceBackend.connect the same host parameter and pass the bag
on every connect. Shell and container backends ignore it and reach the
host through their own transport; the module backend uses it as before.
Method-parameter bivariance lets the existing zero-argument
implementations satisfy the wider signature unchanged. Collapse the
duplicate WorkspaceModuleBackendHost onto the canonical
WorkspaceBackendHost so there is one definition.
The connect host bag reaches git through this.git, which throws once git
is opt-in and no factory was configured. The module path already routed
through the configured-or-disabled guard; the shell and container path,
which never used git before the connect unification, did not. Route it
through the same guard so a workspace without git keeps running commands.
@aron-cf
aron-cf force-pushed the stack/4-unify-connect-host branch from f8a8e78 to 392ae8c Compare August 3, 2026 11:53
@aron-cf
aron-cf merged commit 8746912 into main Aug 3, 2026
9 of 10 checks passed
@aron-cf
aron-cf deleted the stack/4-unify-connect-host branch August 3, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant