Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2da62d4
feat: extend filesystem and codec compatibility profiles
rdlabo Oct 23, 2026
409417a
feat: align virtual filesystem and stream contracts with Workers
rdlabo Oct 23, 2026
622394f
feat: align digest and key derivation contracts with Workers
rdlabo Oct 23, 2026
561f97d
feat: implement Workers cipher contracts with BoringSSL
rdlabo Oct 23, 2026
c72a9d3
feat: align key generation and scrypt limits with Workers
rdlabo Oct 23, 2026
2b14cc4
feat: align random byte and fill APIs with Workers
rdlabo Oct 23, 2026
a35a343
feat: implement Workers Diffie-Hellman and request-scoped generation
rdlabo Oct 23, 2026
9aab117
fix: align signature WebCrypto and custom stream contracts
rdlabo Oct 23, 2026
c3bb1ca
fix: align FileHandle identity lifecycle and descriptor ownership
rdlabo Oct 23, 2026
7b92331
fix: align Workers key parsing and metadata contracts
rdlabo Oct 23, 2026
3488c83
fix: validate intrinsic codec buffers before native access
rdlabo Oct 23, 2026
c168259
fix: align crypto buffer boundaries and RSA digest registry
rdlabo Oct 23, 2026
fe4773d
fix: use Workers key export conversions and BoringSSL encodings
rdlabo Oct 23, 2026
89dd9de
fix: implement Workers subtle digest registry and input contracts
rdlabo Oct 23, 2026
bd2d5b2
fix: align crypto exports and key inspection contracts
rdlabo Oct 23, 2026
d938518
fix: preserve KDF frontend input lifetimes and native buffer brands
rdlabo Oct 23, 2026
5e030fa
fix: align HTTP options and preserve response cookies
rdlabo Oct 23, 2026
321df9c
fix: retain standard Fetch types at the HTTP bridge boundary
rdlabo Oct 23, 2026
16d7f45
fix: align codec option lifetimes and Zstd frame errors
rdlabo Oct 23, 2026
75cf1c6
fix(fs): type promise consumers and preserve Workers write results
rdlabo Oct 23, 2026
4912ee4
fix(zlib): publish precise codec options and result types
rdlabo Oct 23, 2026
5a4d35c
fix(compat): correct RSA errors and filesystem/network lifecycles
rdlabo Oct 23, 2026
f040eea
fix: resolve process base declarations in demo typechecks
rdlabo Oct 23, 2026
22557d5
fix: preserve stream declarations and Fetch identity in dev builds
rdlabo Oct 24, 2026
e1b6cbd
Implement native WebSocket compatibility and align TLS lifecycle
rdlabo Oct 26, 2026
6440c6f
Preserve Android TLS data before EOF and fix clean CI validation
rdlabo Oct 26, 2026
ab3d4bb
Stabilize build deadlines and isolated Workers oracle connections
rdlabo Oct 26, 2026
d8a2036
Serialize full-build acceptance on constrained CI runners
rdlabo Oct 26, 2026
7d205dd
Embed Wasm assets in the source-level Fetch policy fixture
rdlabo Oct 26, 2026
29d9639
docs: define scoped release acceptance for existing implementation
rdlabo Oct 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/native-embedding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "package.json"
- "src/**"
- "demo/tests/native-embedding/**"
- "demo/tests/native/android-socket-eof/**"
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -74,6 +75,8 @@ jobs:
node --test scripts/android-release/publish.test.mjs
python3 scripts/android-release/verify.py
demo/android/gradlew -p demo/tests/native-embedding/android -PsdkRepository="$GITHUB_WORKSPACE/scripts/android-release/build/repository" :app:assembleDebug --console=plain
- name: Verify TLS inbound EOF ordering
run: python3 demo/tests/native/android-socket-eof/run.py
- name: Enable emulator acceleration
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand Down
53 changes: 50 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Run `npm run format` from the repository root before submitting changes. `npm ru

## Complete compatibility units only

New compatibility implementations must be completed before merge or release. A useful subset, a working framework demo, or passing tests for selected methods is not enough. The release exceptions cover existing implementations in [0.1.0 Preview and its explicitly authorized 0.1.1, 0.1.2, 0.1.3 and 0.1.4 follow-ups](#010-preview-exception).
New compatibility implementations must be completed before merge or release unless an explicitly authorized release exception applies. A useful subset, a working framework demo, or passing tests for selected methods does not establish whole-module completion. Release exceptions cover [the current PR #72 candidate](#pr-72-scoped-release-exception) and existing implementations in [0.1.0 Preview and its explicitly authorized 0.1.1, 0.1.2, 0.1.3 and 0.1.4 follow-ups](#010-preview-exception).

For Node.js compatibility, the acceptance unit is a module, including its Workers
exports, subpaths and observable behavior. For a binding or Web API, define the
named API unit before implementation. Do not redefine the unit around the methods
that happen to work. Large units may be developed in several commits or draft PRs,
but incomplete implementation PRs must not be merged into main.
but incomplete implementation PRs must not be merged into main unless covered by
an explicitly authorized release exception.

The target is Cloudflare Workers, not every API available in a Node.js process.
Pin the workerd version, compatibility date and flags. An operation unsupported
Expand Down Expand Up @@ -63,12 +64,58 @@ Only then may the inventory say **Complete**. Until then, use **In progress**,

## Work in progress

Keep incomplete compatibility work on a development branch or draft PR. Do not
Except for an explicitly authorized release exception, keep incomplete compatibility work on a development branch or draft PR. Do not
activate it in a merged build alias, public export or default runtime path, and do
not ship it behind an experimental flag as a substitute for finishing it. Design
notes and reproducible experiments can be reviewed independently without adding
unfinished production behavior.

### PR #72 scoped release exception

The maintainer explicitly authorized preparing one release of the existing
implementation in PR #72 while retaining incomplete compatibility as **In progress**.
This exception is scoped to the implementation at
`7d205ddd0714787b057c715cca1b421ec81a305a`, its release documentation, and fixes for
regressions found while validating that same scope. It does not authorize adding
new API scope or apply automatically to later releases.

For this candidate, unresolved implementation and operation-coverage items do not
by themselves prevent release readiness. They must remain visible in the
[compatibility guide](docs/compatibility.md) and release notes. Missing APIs,
unverified operations and known engine/host differences remain distinct; none is
promoted to **Complete** or described as technically impossible merely to release.
The whole-module acceptance gate above remains the criterion for **Complete**.

Release readiness under this exception requires passing the existing required
contracts, public imports/types, independent package acceptance and applicable
iOS/Android page and Dedicated Worker scenarios. Verify that the evidence matches
the candidate's implementation; do not reuse evidence across runtime changes.
Known failures in those required scenarios must be fixed, not relabeled as
unfinished work or skipped. Preserve failed CI attempts and disclose unresolved
test infrastructure instability even when an unchanged rerun passes.
Manager and independent acceptance review must assess this scoped readiness and
the accuracy of the limitations. Store results in the PR and generated artifacts.

This is an exception to the completeness gate, not a publication action. Version
selection, PR publication/status changes, merge, tag push and package publication
still follow the maintainer's explicit authorization and the CI release workflow.

### Explicit WebSocket attachment representation boundary

The WebView WebSocket attachment implementation may use a documented canonical
serialization representation for its 16,384-byte limit. This is an explicitly
authorized boundary: V8 can serialize arrays with identical observable values
and properties to different lengths depending on its private packed/holey storage
representation, which JavaScriptCore cannot inspect or reproduce.

This exception covers only limit decisions and reported byte lengths that depend
on engine-private representation. It does not waive snapshot isolation, cyclic
references, supported value types, validation, ordinary size-limit enforcement,
or any other WebSocket API, network behavior, or native acceptance requirement.
See the [scope and reproducible boundary probe](src/browser/websocket/README.md).
The canonical representation must be documented and verified before acceptance;
this exception does not itself certify the current implementation.

### Explicit WebView events profile

The approved events work targets the current WebView architecture with documented
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Install the package in your web project, then follow the
[complete mobile setup](docs/integration.md#workflow):

```sh
npm install --save-exact cf-workers-native@0.1.4
npm install --save-exact cf-workers-native@0.1.5
```

Installation alone does not generate a mobile project. The guide covers adding
Expand All @@ -84,7 +84,7 @@ Open your application repository and give your assistant this prompt:

```text
Read https://github.com/rdlabo-dev/cf-workers-native/blob/main/docs/integration.md.
Add an iOS and Android version of this Workers web app using cf-workers-native@0.1.4
Add an iOS and Android version of this Workers web app using cf-workers-native@0.1.5
and Capacitor. Preserve the existing pages, backend and Cloudflare deployment configuration.
Use an existing test Worker for cloud-backed requests; ask before any cloud deployment.
Start by verifying one page, navigation and a form or data action on a simulator/emulator.
Expand Down
5 changes: 3 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@capacitor/core": "^8.5.3",
"cf-workers-native": "file:..",
"express": "^5.3.0",
"hono": "^4.13.13"
"hono": "4.13.13"
},
"devDependencies": {
"@capacitor/android": "^8.5.3",
Expand All @@ -75,6 +75,7 @@
"typescript": "^7.0.2",
"vite": "^7.3.7",
"vitest": "^5.0.5",
"wrangler": "^4.151.0"
"wrangler": "^4.151.0",
"ws": "8.21.0"
}
}
6 changes: 3 additions & 3 deletions demo/tests/build/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ it("watches Worker dependencies and emits a new asset without writing output", a
try {
await build.watch();
await expect
.poll(() => results.length, { timeout: 5000 })
.poll(() => results.length, { timeout: 30000 })
.toBeGreaterThan(0);
const asset = (result: BuildResult) =>
result.outputFiles?.find((file) => !file.path.endsWith("/main.js"));
expect(results[0].errors).toEqual([]);
expect(asset(results[0])?.text).toContain("before-change");
await writeFile(resolve(dir, "value.js"), 'export default "after-change";');
await expect
.poll(() => asset(results.at(-1)!)?.text, { timeout: 5000 })
.poll(() => asset(results.at(-1)!)?.text, { timeout: 30000 })
.toContain("after-change");
expect(asset(results.at(-1)!)?.path).not.toBe(asset(results[0])?.path);
} finally {
await build.dispose();
await rm(dir, { recursive: true, force: true });
}
}, 15000);
}, 90000);

it.each([true, false])(
"preserves an explicit JSX loader (async=%s)",
Expand Down
2 changes: 1 addition & 1 deletion demo/tests/build/isolation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ for (const tool of ["vite", "esbuild"] as const) {
} finally {
await rm(root, { recursive: true, force: true });
}
});
}, 30000);
it(`${tool}: adding a mobile build preserves original server inputs and deployment bytes`, async () => {
const root = await fixture();
const out = await mkdtemp(resolve(tmpdir(), "mobile-output-"));
Expand Down
51 changes: 51 additions & 0 deletions demo/tests/experiments/node-compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Pinned Node compatibility experiments

`exports.json` pins the workerd package and compatibility date. The public
expansion probe runs shared operation contracts through both build plugins,
Chromium/WebKit, page and Dedicated Worker. Surface inventory results are separate
from behavioral acceptance.

From the repository root:

```sh
node --test demo/tests/experiments/node-compat/expansion-contracts.probe.mjs
node demo/tests/experiments/node-compat/prepare-events-consumer.mjs
CONSUMER_PACKAGE=/absolute/path/to/prepared.tgz npm run test:package
node demo/tests/experiments/node-compat/expansion-native.mjs ios <simulator-udid>
node demo/tests/experiments/node-compat/expansion-native.mjs android <emulator-id>
```

Run the native commands sequentially: they share the independent installed
consumer. Set the Android SDK and `adb` PATH as described in the native test
procedure. Preparation writes the exact tarball path and SHA-256 to
`demo/artifacts/node-inventory/events-consumer.json`; the native runner checks that
hash before compiling the consumer. Do not rebuild repository `dist` while a
public browser probe reads it.

Native networking needs OpenSSL and Python3. Local HTTP/HTTPS, TLS, STARTTLS and
WebSocket peers use ephemeral loopback ports. The Python TLS peer explicitly calls
`unwrap()` to send close_notify; separate peers end or reset the TCP connection
without that TLS notification. The generated test CA is confined to the debug
consumer/simulator trust configuration. Workerd uses the same CA and fixture
ports. FS lifetime probes use two real workerd requests and distinct native
request scopes.

Page cases run in independent iframe realms and remove each frame on completion.
Dedicated Workers terminate after each case. This permits cold Wasm measurements
without retaining a module instance for every case in one page. Progress and
failure records identify the active case. The overall native deadline is separate
from individual case and socket deadlines.

`NODE_COMPAT_CASES=name,otherName` filters shared cases for diagnosis. It does not
filter native network rows, and a filtered run is not full acceptance. Native
`stage:complete` means all observations were collected; exact assertions run
subsequently and may still fail. Current TLS and WebSocket implementation gaps
remain failures, not skipped or accepted differences. The reports, generated
harness, compiled hash and workerd baseline live under
`demo/artifacts/node-inventory/native-expansion/<platform>/`.

The narrowly approved attachment size-accounting boundary is documented in the
[WebSocket candidate notes](../../../../src/browser/websocket/README.md). Run
`node --test demo/tests/experiments/node-compat/websocket-attachment-boundary.probe.mjs`
to reproduce its pinned Workers observations. This reference probe does not
certify the candidate or exempt network failures from acceptance.
8 changes: 4 additions & 4 deletions demo/tests/experiments/node-compat/completion-report.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const assessments = [
modules: ["crypto", "zlib"],
priority: 2,
category: "implementation-gap",
next: "Inventory algorithms, key/codec classes, synchronous and streaming behavior. Evaluate JS/Wasm implementations against all pinned operations; random/hash/HKDF/scrypt, owned secret/asymmetric keys, RSA/EC/Ed25519 signatures, prime generation/checking X509Certificate parsing/fields/name checks/signature checks and Brotli/Zstd profiles now supplement dependency polyfills. Pinned Workers X509 key-check restrictions are documented. Additional key-generation options, remaining algorithms and complete codec contracts remain open. No technical-impossibility claim has been established.",
next: "Inventory algorithms, key/codec classes, synchronous and streaming behavior. Evaluate JS/Wasm implementations against all pinned operations; random/Hash/HMAC/PBKDF2/HKDF/scrypt, owned secret/asymmetric keys, RSA/EC/Ed25519 signatures, prime generation/checking X509Certificate parsing/fields/name checks/signature checks and cipher metadata lookup now supplement dependency polyfills. Gzip/deflate now use zlib Wasm; all codec streams use the pinned Workers lifecycle, with option, reset, close, callback and output-limit contracts. Pinned Workers X509 key-check restrictions are documented. The pinned 17 digest names, copying, finalization and KDF length limits have shared contracts; Float16Array input-brand coverage depends on engine availability recorded in native measurements. Additional key-generation options, remaining algorithms and complete codec contracts remain open. No technical-impossibility claim has been established.",
evidence: [
"surface-gaps.json",
"expansion-contracts.probe.mjs",
Expand All @@ -35,7 +35,7 @@ const assessments = [
modules: ["fs", "fs/promises"],
priority: 2,
category: "implementation-gap",
next: "Compare the Workers virtual filesystem, descriptors, FileHandle, writes, permissions and watch behavior. Request-local memory-backed /tmp now supports writes, descriptors and FileHandle; permission no-ops, statfs and embedded-file copying are tested; compare remaining cross-volume operations, descriptors and stream semantics.",
next: "Compare the Workers virtual filesystem, descriptors, FileHandle, writes, permissions and watch behavior. Request-local memory-backed /tmp now supports writes, descriptors and FileHandle; permission no-ops, statfs and embedded-file copying are tested; embedded descriptors/FileHandles, links, immutable copies, cp options, millisecond timestamps and readonly metadata are also compared. Devices, directory iteration, glob, stream fd/custom-fs options, byte streams, URL normalization, FD reuse and request-local cwd now have upstream and comparative coverage. Complete the remaining per-operation/option inventory and all-platform acceptance; these cases do not certify the whole module.",
evidence: [
"../../../../src/compat/fs/index.ts",
"../../../../src/compat/fs/promises/index.ts",
Expand All @@ -45,7 +45,7 @@ const assessments = [
modules: ["process", "console"],
priority: 2,
category: "implementation-and-host-integration",
next: "Classify each export as functional or a pinned Workers stub; verify scheduling, streams, events and host-specific introspection independently. Do not substitute standalone Node behavior.",
next: "Configuration, environment-file loading and standard stream input now have shared behavioral contracts. abort, reallyExit and getBuiltinModule remain unimplemented; termination and builtin lookup require host integration. Audit the remaining process/console operations independently; selected cases do not certify the modules.",
evidence: ["surface-gaps.json"],
},
{
Expand Down Expand Up @@ -104,7 +104,7 @@ const assessments = [
],
priority: 2,
category: "implementation-and-native-transport",
next: "Direct TLS and same-connection STARTTLS exchange/hostname rejection are tested in page and Dedicated Worker on both OSes. TLS 1.2/1.3 and repeated write-half-close are covered on both OSes; custom Duplex wrapping remains unsupported. Audit remaining class/prototype/state/event contracts; these scenarios do not certify the whole TLS/server API.",
next: "Direct TLS and same-connection STARTTLS exchange/hostname rejection are tested in page and Dedicated Worker on both OSes. TLS 1.2/1.3 and repeated write-half-close are covered on both OSes. Custom Duplex wrapping follows the Workers byte-stream behavior and does not itself encrypt bytes. Native WS/WSS, compression/context takeover, pair and attachment contracts are included, with only the documented engine-private attachment-size boundary. Audit remaining class/prototype/state/event contracts; these scenarios do not certify the whole TLS/server/WebSocket API.",
evidence: ["surface-gaps.json", "../../../../docs/compatibility.md"],
},
{
Expand Down
Loading
Loading