Repository navigation
[Experimental] Prototype browser/WASM validation in isolated workers - #538
Merged
Merged
Conversation
Preserve the opt-in investigation for #536 before reviewing the shared refactor and expanding worker/browser coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add an application-owned worker example, Chromium/Firefox/WebKit coverage, explicit cancellation and cleanup checks, and broader performance and process-memory measurements for #536. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Retain the opt-in live-test work while keeping this browser prototype isolated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the 424 passing ordinary tests, disabled live suite, and both browser memory ceilings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eliminate the closed-validator compiled-module retaining path. Add independent stability and Unicode regressions, confirm the Unicode failure on pristine main, and document the verified retail Firefox dedicated-worker comparison. Keep the two upstream conformance failures explicit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep hosting application-owned. Verify CSP, compressed immutable artifacts, encoding negotiation, conditional requests, and worker loading errors across the browser matrix. Preserve the separate Unicode conformance gates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge approved main through #545 and share scoped compiler-rendered enum queries across native and WASM adapters. Preserve the original schema, error precedence, and schema-first/legacy message behavior. Keep independent Unicode assertions unchanged and expand the browser corpus to 88 outcomes. Verified build-all and 492 ordinary tests, plus all 36 experimental/browser checks with zero failures and skips. The pinned experimental compiler and WASM artifact are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tokenize coding and quality fields before simple bounded syntax checks. Preserve negotiation behavior and cover large whitespace, malformed qualities, and extra parameters. All seven HTTP and hosted-browser checks pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge main at 35d9150 without conflict resolutions or runtime workarounds. Record 596 passing ordinary tests and 36 passing experimental/browser tests with zero skips, fresh payload/timing/memory measurements, and explicit GO for continued isolated evaluation / NO-GO for supported mainline release. Keep the investigation draft and retain all upstream and deployment gates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a prominent source-only opt-in warning and distinguish an owner-reviewed experimental repository merge from publishing supported browser functionality. Keep package isolation, measured limitations, and supported-release gates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
robgruen
marked this pull request as ready for review
November 30, 2026 18:39
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The unstable upstream WASM dependency and shared native-validator changes require human owner review of experimental maintenance ownership and browser/runtime limits, especially since the supplied runtime checks were not independently rerun.
No open issues 🎉
1 file not reviewed
typescript/experimental/browser/package-lock.json: Generated file
What changed in this PR
Adds a private, source-only browser/WASM prototype for #536, investigating #534 while keeping the native Node backend as the default. This remains an opt-in experiment, not a published or supported browser release.
Changes:
- Extracts shared validation, enum handling, diagnostics, and model types for separately typed native and WASM adapters.
- Adds verified WASM loading and an application-owned worker example with cancellation, disposal, and explicit hosting policies.
- Adds backend parity, browser, lifecycle, and hosting tests, plus documented measurements and supported-release limitations.
| File | Description |
|---|---|
typescript/test/compiler.test.ts |
Tests shared compiler lifecycle and failure handling. |
typescript/src/typechat.ts |
Imports browser-safe model protocol types. |
typescript/src/ts/validation.ts |
Extracts compiler-independent validator logic. |
typescript/src/ts/validate.ts |
Adapts the native compiler to shared validation. |
typescript/src/ts/compiler.ts |
Defines shared compiler operations and diagnostics. |
typescript/src/modelTypes.ts |
Separates model and prompt type definitions. |
typescript/src/model.ts |
Re-exports extracted types without changing HTTP behavior. |
typescript/README.md |
Links the isolated experiment and clarifies its scope. |
typescript/experimental/browser/tsconfig.json |
Configures prototype compilation and declarations. |
typescript/experimental/browser/tests/types.ts |
Checks validator and prompt-layout types. |
typescript/experimental/browser/tests/stability.test.mjs |
Tests recovery, cancellation, isolation, and resource retention. |
typescript/experimental/browser/tests/repro-unicode-enum.mjs |
Provides a standalone Unicode enum regression probe. |
typescript/experimental/browser/tests/parity.test.mjs |
Compares native and WASM outcomes and diagnostics. |
typescript/experimental/browser/tests/native-preview.mjs |
Supplies the matching-version native test adapter. |
typescript/experimental/browser/tests/loader.test.mjs |
Tests artifact verification and validator ownership. |
typescript/experimental/browser/tests/hosting.test.mjs |
Tests HTTP caching, compression, and error responses. |
typescript/experimental/browser/tests/corpus.mjs |
Defines shared validation and translation cases. |
typescript/experimental/browser/tests/browser/worker-entry.mjs |
Exercises worker lifecycle and responsiveness. |
typescript/experimental/browser/tests/browser/version-mismatch.mjs |
Checks version rejection before fetching WASM. |
typescript/experimental/browser/tests/browser/process-memory.mjs |
Samples Windows browser-process memory. |
typescript/experimental/browser/tests/browser/hosting.test.mjs |
Checks hosted-page security policy and asset delivery. |
typescript/experimental/browser/tests/browser/entry.mjs |
Runs browser validation and initialization probes. |
typescript/experimental/browser/tests/browser/browser.test.mjs |
Runs the browser matrix and resource measurements. |
typescript/experimental/browser/src/versions.ts |
Pins compiler version, artifact length, and hash. |
typescript/experimental/browser/src/project.ts |
Adapts experimental compiler projects to shared logic. |
typescript/experimental/browser/src/index.ts |
Exposes the limited experimental browser API. |
typescript/experimental/browser/src/compiler.ts |
Implements verified loading and disposable validators. |
typescript/experimental/browser/README.md |
Documents setup, design, evidence, and limitations. |
typescript/experimental/browser/package.json |
Defines private dependencies and opt-in commands. |
typescript/experimental/browser/package-lock.json |
Locks the isolated experiment’s dependencies. |
typescript/experimental/browser/examples/worker/validator.worker.ts |
Validates one batch and closes owned resources. |
typescript/experimental/browser/examples/worker/tsconfig.json |
Type-checks worker code with worker-specific globals. |
typescript/experimental/browser/examples/worker/style.css |
Styles the runnable example. |
typescript/experimental/browser/examples/worker/serve.mjs |
Serves the example on loopback. |
typescript/experimental/browser/examples/worker/main.mjs |
Connects validation, cancellation, and UI status. |
typescript/experimental/browser/examples/worker/index.html |
Provides the offline validation interface. |
typescript/experimental/browser/examples/worker/host.mjs |
Serves verified assets with security and cache headers. |
typescript/experimental/browser/examples/worker/client.ts |
Owns each worker’s promise, cancellation, and cleanup. |
typescript/experimental/browser/examples/worker/build.mjs |
Bundles example assets and versions the WASM URL. |
Review effort: Balanced
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft investigation for #536, under #534. This is an opt-in prototype for design review, not a supported browser release or a replacement for the default native Node compiler.
7.1.0-dev.20261030.1; verify version, length, and SHA-256 before compiling. Make loading, cancellation, errors, independent validator ownership, and disposal explicit.The branch now integrates main through #535, including #551 and #545, including the approved 0.3 behavior from #540. Compiler-rendered enum literal queries are shared across separately typed native/WASM adapters. Tests preserve lexical scope, member-only namespace filtering, collisions, original-schema restoration, diagnostic precedence, and native CJS/ESM compatibility.
Verification (2026-11-30 refresh)
Refreshed in
65a9e7eby merging approved main35d9150without conflicts, extra runtime patches, dependency upgrades, relaxed assertions, or skipped checks. Windows, Node.js 24.22.1:typescript:npm run build-allpassed for the library and every example;npm testwithTYPECHAT_LIVE_TESTS=0passed 596 tests, 0 failed, 0 skipped, including native CJS/ESM package/declaration checks and the merged temperature/Zod regressions.npm run buildpassed. One combined serial runner selected all six experimental/browser test files withTYPECHAT_STABILITY_BROWSERS=1: 36 passed, 0 failed, 0 skipped, in about 174 seconds.git diff --check origin/main; incoming Python files are unchanged from approved main.Fresh instrumented worker observations (one run per engine, not production guarantees):
Process-tree figures are rounded decimal MB, include prior corpus/lifecycle probes, may double-count shared pages, and are not unique physical memory, one-job incremental cost, or precise peaks. Firefox still uses Playwright/Juggler; the historical retail probe below was not rerun. Strict CSP and versioned gzip delivery passed; two-job cache reuse was observed only in Firefox again.
All responses were synthetic. No live model calls or credentials were used. Tests closed their own browsers, workers, and loopback servers. Ordinary repository CI does not run the separately installed experimental suite. Reproducible commands, fresh costs, and historical evidence are in the updated prototype README.
Browser hosting follow-up
Follow-up validation addressed the CodeQL header-parser finding with tokenization and bounded syntax checks. Large/malformed header regressions were added, and all seven HTTP/hosted-browser checks passed after the change.
The application-owned example now uses a shared, tested static handler; no hosting API was added to the TypeChat core and nothing was deployed externally.
HTML/UI scripts/styles are external and no-store. Strict CSP permits same-origin resources and
wasm-unsafe-eval, not general JavaScript eval or inline scripts/styles. Both the document and worker receive the policy. Real-page eval blocking and explicit failure without WASM permission pass in all three engines.The compiler asset URL includes its exact version and SHA-256. Startup verifies the bytes before serving it with immutable caching, gzip/identity negotiation, representation-specific ETags,
Vary: Accept-Encoding, and correct HEAD/304/error handling.Four protocol tests verify actual bytes, MIME types, cache headers, compression, conditional responses, and encoding/method errors. Existing browser and recovery fixtures use the same hosting handler.
Automated two-job checks observed a warm cache hit in Firefox; Chromium and WebKit fetched again. Every network artifact response was gzip (13,359,431 bytes). Cache headers make reuse possible but do not guarantee storage, prevent eviction, or avoid initialization in a new worker.
Hosting remains application-owned and separate from core validation. The later #545 integration clears the Unicode gates without suppressing them; normal manifests match main and the pinned experimental compiler/artifact versions remain unchanged.
Resolved Unicode blocker and follow-up findings
20260516144017differs from Playwright's20260611193205. This does not certify WAN/mobile performance, retail memory costs, or a full retail-browser matrix.Ordinary repository CI does not run this separately installed experimental suite, so it was run explicitly with all browser recovery checks enabled: zero failures or skips. That clears the recorded Unicode gates, not the need for an upstream-support/maintenance decision or production deployment assessment. This remains a draft investigation.
Experimental limitations / not a supported release
typechat/tsentry point browser-compatible.The prototype README documents reproducible commands, measured results, provisional budgets, lifecycle trade-offs, upgrade/rollback, and outstanding merge gates:
Browser prototype README.
Keep #534 and #536 open. Any supported mainline integration still needs explicit upstream-stability/maintenance, API, performance, and compatibility decisions.
Go/no-go recommendation (2026-11-30)
Suitable for isolated experimental evaluation; not ready as a supported browser release. Current-main compatibility, recorded conformance checks, and provisional payload/linear-memory ceilings pass. An isolated experimental repository merge is a separate owner-reviewed decision, including acceptance of the upstream dependency and maintenance risks. It does not publish the private package or promise stable browser support.
Remaining supported-release gates from #536:
This is an experimental investigation, not production support or an automated approval. Approval, ready status, and any merge remain human-owner decisions. Keep #534 and #536 open for the outstanding support and deployment work.