Skip to content

Before 4.0.0: an exports map, pin in the oracle model, and the open review items - #216

Merged
KyleAMathews merged 2 commits into
masterfrom
release-followups
Nov 30, 2026
Merged

KyleAMathews merged 2 commits into
masterfrom
release-followups

Conversation

@KyleAMathews

Copy link
Copy Markdown
Owner

Before the 4.0.0 release, this PR closes the items that the review of #215 left open. It also adds an exports map to the package. The production code in src/ does not change.

The package now has an exports map

Bundlers get the ES module build, Node gets the CommonJS build, and TypeScript gets the types. A deep import of another path now fails:

import Headroom, { useHeadroom } from 'react-headroom' // bundler: dist/esm, Node: dist/index.js
require('react-headroom/dist/core.js')                 // ERR_PACKAGE_PATH_NOT_EXPORTED

The map has no import condition. The ES module build uses imports without file extensions, and Node cannot load them. So Node keeps the CommonJS build, as in 3.2.1. The CHANGELOG lists the refused deep imports as a breaking change.

The package oracle now uses the packed tarball by its name, from an app directory with its own package.json. A package with exports resolves its own name to itself. Without that package.json, the oracle loaded the repository's dist/ instead of the tarball. The oracle now reports any file that comes from outside the tarball. New histories check Node's native import in a child process, because Vitest resolves import() through Vite. Another history checks that a deep require fails.

Four laws now compare with a model

Four laws took their expected values from other observations. They are the callbacks law (L3), the wrapper state law (L10), the transition class law (L20) and the work law (W). Now each compares with a model. For L3, L10 and L20, the shared scroll model must predict pin. It now models the frame that pin asks for at mount, when pin changes, on a parent change and when disable turns off. It also records whether each change slides. With pin off, its predictions are the same as before.

The review of this branch found two defects in the model. The oracle showed each one failing before its fix:

  • A parent change with a frame still pending forks the model. One fork lost the change of the attach, so a header that unfixed without onUnfix passed the callbacks law. The three laws now generate parent changes with a pending frame. A calibration and a production mutant show the fix.
  • With pin and disable both on, a parent change made the model expect onPin. A disabled header does not attach, so nothing happens. A Chrome run on a random seed found this defect.

One rule stays a relation between two observations: a step that shows nothing new calls no setState.

A new clause of the speed law

With matchScrollSpeed, a slide without movement lasts 200 ms. One example is a slide that starts when pin turns on while the page does not move. Production already does this, and a slide from an instance method also lasts 200 ms. The histories of the speed law now toggle pin. A calibration and a production mutant fail the clause. Decision by Kyle Mathews (GitHub KyleAMathews), 2026-11-30.

Smaller changes

  • The CI gap-check job fails on any gap, and on any oracle file that fails before mutation. oracle-gaps exits 0 whatever it finds, so the job reads its output.
  • The syntax law parses every JavaScript file in the tarball. Before, it parsed only the files that src/ explains.
  • The text of L20 states its mount rule. The Chrome limits list what the Chrome run still stands in.
  • The package oracle reads file URLs with fileURLToPath. It judges the build of the bundler from every package file in the bundle.

Verification

  • pnpm test: the unit tests, the oracles (832 tests), the type check, lint and the format check pass.
  • pnpm test:gaps with seed 1: 342 mutants, 342 killed, 0 gaps.
  • pnpm test:oracles:chrome: 788 tests pass.

A follow-up remains: three existing calibrations have no history binding, in the overscroll and calcHeightOnResize laws. The framework warns that their search will go away.

This pull request and its description were written by Isaac.

KyleAMathews and others added 2 commits November 30, 2026 11:04
- The scroll model predicts pin (L4's frames at mount, on a toggle, on
  attach and on enabling) and whether each change slides. The callbacks
  (L3), wrapper state (L10) and transition class (L20) laws now compare
  with it instead of with other observations; the work law's bounds come
  from its model. Predictions with pin off are unchanged.
- An exports map: types, module for bundlers, default (CommonJS) for
  Node. The package oracle now uses the tarball by its name from an app
  with its own package.json (a package with exports resolves its own name
  to itself), adds Node's native import and a refused deep require, and
  reports any file loaded from outside the tarball. The type check
  imports the package by name.
- The syntax law parses every JavaScript file the tarball holds.
- L20's text states the mount rule; the Chrome limits list what is stood
  in there.
- CI's gap-check job fails on any gap or failing oracle file.

Gap check (seed 1): 342 mutants, 342 killed, 0 gaps. Chrome: 766 passed.

Co-authored-by: Isaac <no-reply@databricks.com>
Each defect was shown failing in the oracle before its fix.
- The model's fork for a frame left pending across a parent change kept
  the attach's change (state, callback, snap and slide). The callbacks,
  wrapper and transition-class laws now generate parent changes with a
  frame pending; a calibration that drops the attach's onUnfix was
  accepted before the fix and is rejected after it, and a production
  mutant that makes that unfix silent is killed.
- A parent change while disabled changes nothing in the model (it ran
  pin's frame and owed onPin); a constructed history failed before.
- New clause of the speed law (decision 2026-11-30): a slide without
  movement lasts 200ms with matchScrollSpeed. The speed law's histories
  now toggle pin; a calibration and a mutant (no zero-movement guard)
  fail it.
- The package oracle reads file URLs with fileURLToPath and judges the
  bundler's build from every package file in the bundle; L20 records
  the decision behind its mount rule; one helper runs the frame at the
  parent's position.

Gap check (seed 1): 342 mutants, 342 killed, 0 gaps. Chrome: 788 passed.

Co-authored-by: Isaac <no-reply@databricks.com>
@KyleAMathews
KyleAMathews merged commit b5384d0 into master Nov 30, 2026
6 checks passed
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.

1 participant