Repository navigation
Author semantic application state in TypeScript - #4757
Merged
Merged
Conversation
leaf-agent
approved these changes
Oct 30, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 30, 2026
…pages and tests without a build (#4780) #4725 to #4757 wrote seven runtime modules in TypeScript (`semantic-state`, `rendering`, `queued-work`, `exception` and the framework's `application`, `presentation` and `snapshot`) and committed a generated `.js` beside each. Pages and runtime tests read only the generated file. The kernel's freshness check hashes `.js` files, and `tests/runtime/dom.mjs` resolves the committed `.js`. So an edit to a `.ts` changed nothing until `pnpm run build:browser` ran, and every probe and test passed on the old code. That is the failure #4112 described and #4184 fixed. The conversion bought no stricter checking, since the same strict program checks JSDoc under `// @ts-check`, and the files came out about the same length. The seven modules are authored JavaScript again. Each starts with `// @ts-check` in the strict program and keeps every flag the campaign added (`strictFunctionTypes`, `noImplicitThis`, `useUnknownInCatchVariables`). The executable code is unchanged: run through esbuild and compared as ASTs, each new module matches the generated file it replaces, and the kernel diff is only variable renames and input hashes. | After appending an export to `semantic-state` | What a page server serves | Has the edit | |---|---|---| | main, editing `semantic-state.ts` | the same kernel, still taken as fresh | no | | this branch, editing `semantic-state.js` | the source modules | yes | With the framework's `application` module made to throw as it loads, `framework-application.test.mjs` passes on main (55 of 55, since it imports the generated file) and fails on this branch. ## What it deletes - `build/runtime-sources.mjs`, the compile and orphan-cleanup logic in `build/browser/build.mjs`, and its tests. - The generated-output handling in `.github/scripts/dependency-bundles.mjs`, `.dependency-cruiser.mjs`, `tests/js_facts.mjs` and `tests/journeys/test_unused_exports.py`. - The checker-derived options #4739 gave `build/esbuild.mjs`, which only the TypeScript emission needed. It returns to `tsconfigRaw: "{}"`. The build now refuses any `.ts` other than `.d.ts` under `browser/runtime/`, naming the file and #4112. The pragma guard is back to #4184's form, covering framework modules only. `browser/AGENTS.md` again describes the runtime as JavaScript a page runs as written. ## Other changes - **Export audit.** The converted modules take their types through JSDoc `@import` tags. `tests/js_facts.mjs` now reads those as it reads `import("…").Name`; without that, the audit reported `LocalMessage` and `PendingProjection` in `domain.d.ts` as unread. `dev/tests/test_js_facts.py` replaces its tests of the output mapping with tests of the tag. - **Dev probes.** This removes #4743's type-checking of the four dev probes (`main_thread.js`, `startup.js`, `bench_latency.js`, `verify_site_browser.js`) and `dev/browser-globals.d.ts`. It found nothing, and a mistake there fails as soon as the probe runs. #4743's five ESLint rules stay. - **Spawn forwarder.** The forwarder in `dev/leaf_dev/pi_watch_observer.mjs` returns to its three-argument form. #4737's tools program rejects that form's arity against `spawn`'s overloads, so one `@type` cast wraps it in place of `Reflect.apply` and two casts. ## Tests - `pnpm run check:hooks`, `check:tools`, `check:framework` (29 build tests) and `check:browser` after merging main. - `pnpm run check`, run before these last edits: 708 runtime and 88 Worker tests. - `uv run pytest tests/model -k "kernel or runtime_selection or distribution or js_facts"` (19 passed) and `dev/tests/test_js_facts.py` (6 passed). - Pre-commit on every changed file. Build tests that changed: the test that a renamed TypeScript owner's output is refused is gone with the mechanism. New tests cover the `.ts` refusal and the framework pragma guard. `tests/journeys/test_unused_exports.py` still fails on six exports, each in a file this change doesn't touch and no removed `.ts` file read: `check-api.js` `runtimeRootState`, `content-layout.js` `readDocumentHeaders`, `framework.js` `Directive`, `widget-elements.js` `selectableOfferElement`, `toc-view.js` `outlineDocument`, and `layout.js` `containedSpace`. This PR's edit to the test makes CI run it. > _This was written by Claude Code on behalf of max-sixty_
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.
The semantic application's records and callback contracts now use native TypeScript declarations, imports, and signatures in
application.ts, replacing the JSDoc type scaffolding. The immutable semantic root and its gesture-ledger rules keep one owner; the existing public type surface and all semantic comments are preserved.Independent review checked the complete source, bidirectional compatibility of the factory API and exported types, and comment preservation. The actual generated JavaScript has the same executable AST as the original compiled as ESM. The kernel diff contains only bound-variable renames and its input hash, with no import or startup work change.
Validation: the canonical browser build passed strict checking and emission. All 712 runtime tests, every pre-commit check, and final browser freshness passed locally. Exact-head CI passed the full
pnpm run check, including all 88 Worker tests and the production runtime bundle case.