Skip to content

fix: refuse a top-level await in the lint, not the build - #4486

Merged
max-sixty merged 6 commits into
mainfrom
fix-await-lint
Oct 27, 2026
Merged

max-sixty merged 6 commits into
mainfrom
fix-await-lint

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#3904 made the build refuse a module that awaits at its top level, since one such await turns off rolldown's chunk optimization for the whole build. It switched the refusal off for the build script's command-line entry, saying only a comparison arm's kernel (leaf-dev probe --base, stills) goes through it. That entry's one caller, distribution.bundle_runtime, builds the kernel of every prepared installation: the suite's browser tiers, previews and the website payload as well as comparison arms. So the refusal held only in build/browser/build.mjs (the dist/kernel build pnpm run check checks) and the website's bundleRuntime.

What changed

  • A lint rule refuses a top-level await. architecture/top-level-await in eslint.config.mjs reports an AwaitExpression, a for await or an await using outside every function, over browser/**, packages/*/** and examples/**/*.page/widgets/**. Those are all the sources either build compiles: the kernel from browser/, and the website's rebundle from each published layer, which adds the packages' widgets and an example's own. The website rebundles only pages in this tree (leaf-dev site), so no compiled source falls outside the lint. CI's pre-commit run --all-files runs eslint.
  • The build no longer checks. topLevelAwait, the transform hook in moduleBoundaries, the refuseAwaits option through compile and kernelOutputs, and their test are gone. A comparison arm built from an older tree whose modules await at their top level now compiles without any flag, since nothing in the build refuses it.
  • leaf.js's comment now points at the rule.

The rule is a custom rule rather than a no-restricted-syntax selector. In flat config a file takes a rule's options from the last block that matches it, and the runtime's blocks (ownerBoundary, entryBoundary, the primitives and thread-model blocks) each set their own no-restricted-syntax. A selector would have to be copied into each of those lists, and a later block that left it out would silently drop it.

Checks

  • Scratch files, deleted afterwards: the rule flagged a top-level await, a for await and an await inside a top-level if in a browser/runtime/ module, a top-level await using in a packages/playwright/widgets/ module, and a top-level await in an examples/*.page/widgets/ module. It left alone awaits inside a function declaration, an arrow function and a class method, and examples/developer/motion.page/motion.js, a page script the builds don't compile.
  • pre-commit run eslint --all-files passes on the tree.
  • The rebuilt kernel is byte-identical apart from kernel.json, whose hash of leaf.js moved with the comment.
  • pnpm run check, and tests/model/test_distribution.py and dev/tests/model/test_distribution.py (which build through the command-line entry), pass.

This was written by Claude Code on behalf of max-sixty

#3904 made the build refuse a module that awaits at its top level, since one such await turns off rolldown's chunk optimization for the whole build. It switched the refusal off for the build script's command-line entry, saying only a comparison arm's kernel (`leaf-dev probe --base`, `stills`) goes through it. That entry's one caller, `distribution.bundle_runtime`, builds the kernel of every prepared installation: the suite's browser tiers, previews and the website payload as well as comparison arms. So the refusal held only in `build/browser/build.mjs` (the `dist/kernel` build `pnpm run check` checks) and the website's `bundleRuntime`.

## What changed

- **A lint rule refuses a top-level await.** `architecture/top-level-await` in `eslint.config.mjs` reports an `AwaitExpression`, a `for await` or an `await using` outside every function, over `browser/**`, `packages/*/**` and `examples/**/*.page/widgets/**`. Those are all the sources either build compiles: the kernel from `browser/`, and the website's rebundle from each published layer, which adds the packages' widgets and an example's own. The website rebundles only pages in this tree (`leaf-dev site`), so no compiled source falls outside the lint. CI's `pre-commit run --all-files` runs eslint.
- **The build no longer checks.** `topLevelAwait`, the `transform` hook in `moduleBoundaries`, the `refuseAwaits` option through `compile` and `kernelOutputs`, and their test are gone. A comparison arm built from an older tree whose modules await at their top level now compiles without any flag, since nothing in the build refuses it.
- `leaf.js`'s comment now points at the rule.

The rule is a custom rule rather than a `no-restricted-syntax` selector. In flat config a file takes a rule's options from the last block that matches it, and the runtime's blocks (`ownerBoundary`, `entryBoundary`, the primitives and thread-model blocks) each set their own `no-restricted-syntax`. A selector would have to be copied into each of those lists, and a later block that left it out would silently drop it.

## Checks

- Scratch files, deleted afterwards: the rule flagged a top-level `await`, a `for await` and an `await` inside a top-level `if` in a `browser/runtime/` module, a top-level `await using` in a `packages/playwright/widgets/` module, and a top-level `await` in an `examples/*.page/widgets/` module. It left alone awaits inside a function declaration, an arrow function and a class method, and `examples/developer/motion.page/motion.js`, a page script the builds don't compile.
- `pre-commit run eslint --all-files` passes on the tree.
- The rebuilt kernel is byte-identical apart from `kernel.json`, whose hash of `leaf.js` moved with the comment.
- `pnpm run check`, and `tests/model/test_distribution.py` and `dev/tests/model/test_distribution.py` (which build through the command-line entry), pass.
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
@max-sixty
max-sixty merged commit 5627c7e into main Oct 27, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix-await-lint branch October 27, 2026 18:38
max-sixty added a commit that referenced this pull request Oct 27, 2026
…ir reviews pass (#4511)

Renames `/grinding-backlog` to `/fan-out-backlog` and revises it with
what the first campaign's later stages showed: its drafts going stale
while they waited, the user's reversals, and Tend's review findings.

- **When to run one.** The maintainer isn't sure a backlog campaign
beats doing work as it comes up, and prefers that by default. So the
skill says to run one only when there are many spare tokens, not on a
schedule or from Tend.
- **Land as you go.** Once a PR's review and the reviews of its fixes
pass, the campaign marks it ready, and Tend reviews and lands it under
`running-tend`'s **Landing**. In the first campaign, drafts held for the
user waited 50 hours at the median while main took 297 commits. Other
sessions fixed 6 of the 47 first, and the user then landed the rest with
one choice.
- **Additions wait for the user.** A PR stays a draft, with its decision
on the user's page, when it leaves the user a call or adds something
beyond the repair and its test: a new mechanism, gate, public option,
dependency or protocol bump. The author's report lists these under a new
`adds` field, and the reviewer checks the list. Each PR the user
rejected or cut was an addition of this kind (#3876, #3896, #3854,
#3962).
- **Review weighs additions and every fix.** Reviewers weigh what a
change adds (`/developing-leaf`, "Weigh what a change adds") and review
every fix again. One unreviewed fix in the first campaign moved #3904's
check into the build and broke the eval comparison arms, until #4486
moved it back.
- **Counts come from GitHub**, since an orchestrating session that
compacts several times loses its counts. Ready PRs go a few at a time,
since six parallel landing agents once used up Tend's GitHub API quota.

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