Skip to content

Check developer browser probes and add focused correctness lints - #4743

Merged
max-sixty merged 2 commits into
mainfrom
codex/js-correctness
Oct 30, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex/js-correctness

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The browser compiler now checks all four developer init scripts used by startup probes, site verification and latency benchmarks. Known selectors retain their element types and nullable results; navigation timing and the presentation promise use native types. The main-thread probe exposes the same object and property descriptor, with its Window type derived from the producer rather than a separate API mirror. Both browser programs include the sources so the strict program owns declaration errors and the relaxed program owns the JavaScript checks.

Enable five additional ESLint correctness guards: callback returns (allowing explicit bare-return skips), constructor returns, boxed primitives, unreachable loops and negation before ordering comparisons. These add no dependency or source suppressions.

Validation: full-tree ESLint and five deliberate rejection probes; browser compiler/checksum; Node tooling compiler; applicable pre-commit checks; actual Chrome init-script injection across fresh documents with API read/reset and descriptor checks. Type-negative probes reject a missing probe method, a DOM property typo and a malformed producer declaration.

Coverage remains deliberate: the installed DOM library does not type native long-animation-frame payloads, so those records retain their existing inferred boundary. An audit of atomic-update, promise-executor-return and optional-arithmetic reports found intentional patterns rather than defects; a blanket runtime-test check produced 447 mostly fixture/DOM diagnostics and is excluded.

This was written by Codex on behalf of max-sixty

@max-sixty
max-sixty merged commit 39bc7be into main Oct 30, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/js-correctness branch October 30, 2026 08:09
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_
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.

2 participants