Skip to content

Type and normalize runtime failure boundaries - #4739

Merged
max-sixty merged 10 commits into
mainfrom
codex/strict-runtime-types
Oct 30, 2026
Merged

max-sixty merged 10 commits into
mainfrom
codex/strict-runtime-types

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Sample commands that threw null, unreadable objects, or uncloneable error fields could fail while reporting the error and leave their parent request unanswered. One strict exception owner now supplies summaries, diagnostic traces, native Error values, and transport-safe records; the real sample receive callback regressions verify an answer for ordinary, cross-realm, primitive, unreadable, and uncloneable failures.

JSON requests now throw the public RequestError class, preserving HTTP refusal status/body/current snapshot and network causes. Consumers use that contract and the shared formatter, enabling useUnknownInCatchVariables throughout runtime checking and noUncheckedSideEffectImports in the browser projects. Initial producer bundles resolve authored TypeScript even when committed JavaScript is absent or stale, covered by an executable bundler regression. The shared esbuild wrapper now derives runtime emit semantics from the checker configuration, preserving value-import initialization exactly as checked; a separate regression checks and executes that case.

Validation: full pnpm run check passed (27 build, 711 runtime, 88 Worker tests); the final summary fallback passed its focused regression, all 53 integrated focused tests passed, and all pre-commit hooks passed. After the emission repair, browser build/freshness and all 28 build tests passed; vendor/initial outputs stayed unchanged. Served base/candidate startup retained 23 JavaScript / 25 code requests through presentation, adding 1,851 code bytes for reliable synchronous reporting. A served public-API probe confirmed RequestError constructor identity and the current file snapshot.

This was written by Codex on behalf of max-sixty

@max-sixty
max-sixty merged commit 81df21b into main Oct 30, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/strict-runtime-types branch October 30, 2026 07:30
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_
max-sixty added a commit that referenced this pull request Nov 15, 2026
…ctor alternates (#6013)

Max asked for a scan of the whole tree for code like the Codex adapter's
20 s bounds (#5994): mechanisms that guard a case that can't occur or is
already covered, and layers with no second user. Nine read-only agents
covered `src/leaf`, the browser runtime, the packages, the Worker, the
hooks, `build/` and `dev/`. The tree has little of that kind left: no
compatibility reads, no validation repeated after an entry point, no
deadline plumbing. What remains is mostly options no caller sets and
wrappers with one caller. This deletes the ones a reading confirmed, for
−70 production lines. Behaviour stays the same except in the dev
readers, as the last item says.

- Export's CSS traversal carried a `declarations` flag that was always
False.
- `accept_event`, `PageTransaction.owned_by` and `page_events` only
forwarded. `final_text` and `reply_so_far` were the same function.
- `createThreadLanding` built a stateless object whose members forwarded
to module functions. `landIn`, `landInThread` and `returnToThread` are
module exports now.
- `stageAuthoredStates` took an `existing` map that every caller passed
empty. `presentedControl`'s fallback was applied three times. Margin
rows typed four fields optional that their one caller always sets.
- Eleven defaults that every caller overrides, in thread code and
leaf-dev, are gone.
- The dev browser readers still matched `data-mid` and
`.lf-thread[data-id]`, which the runtime no longer emits. That made
`leaf-dev site verify` miss news on thread cards. They now read
`data-lf-event` and the runtime's thread selector, and the website
verifier tests' fixtures draw today's DOM.

The candidates left alone guard real cases. Draft validation covers
records an earlier runtime wrote to localStorage. The unreadable-service
branches cover a server started by another Leaf copy on the shared state
home. Unreadable-throw handling covers untrusted sample code (#4739).
The Worker's per-step timing logs (about 70 lines) have no reader in the
repo, but they can be queried on Cloudflare, so they stay unless Max
says otherwise.

Checks: `pnpm run test:runtime` (974 pass), the browser type check,
pre-commit, 191 focused model, process and dev tests, and 11 browser
tests over margin pins, obligation walks, replies and the website
verifier.

> _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