Repository navigation
featherduster - #1685
featherduster#1685
Conversation
060798f to
776daf2
Compare
|
@pullfrog review this |
There was a problem hiding this comment.
Important
Two reproducible crashes in the new copy-on-write helper copyOf (ark/schema/shared/transform.ts): it throws for every RegExp, and for any array carrying an own slice property. Both are reachable through the public API and contradict the "never writes to the input" contract this PR introduces. Details inline.
Reviewed changes
ArkErrorsno longer extendsArray— errors now live in a plainissuesarray with lazily builtbyPath/byAncestorPathcaches; iteration,length,summaryand Standard Schema support are preserved, and the new merge/countlogic tracks 2.2.7's traversal-stop semantics.- Copy-on-write
Transformreplacesclone— newcopyOf/mergeTransformedhelpers plusTransformErrorsinark/schema/shared/transform.ts; this is the source of both findings below. - New
arksetspackage — the set algebra is extracted from@ark/schemainto a separately installed engine (setEngine). Without it,@ark/schemaparses unreduced nodes and throwsmissingSetEngineMessageon relations/JSON Schema;arktypeimports it. I traced the extracted intersection loop (intersectConstraints) against its prior form and found no dropped-constraint or non-termination defect. - Public API/behavior updates —
configure()must now run before any package import;"+": "delete"removes undeclared symbol keys; root-morph failures throw from.assert; dates describe in UTC.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| Error: () => new Error(), | ||
| Headers: (data: Headers) => new Headers(data), | ||
| Map: (data: Map<unknown, unknown>) => new Map(data), | ||
| RegExp: (data: RegExp) => new RegExp(data), |
There was a problem hiding this comment.
copyContentsOf.RegExp builds its copy with new RegExp(data), which always owns a non-configurable lastIndex. The descriptor overlay at lines 82-88 then redefines that property with configurable = true and throws TypeError: Cannot redefine property: lastIndex for every RegExp. This is reachable through the public API — e.g. type({ x: "string.trim" })(regexpWithOwnProp) (a RegExp with any own structure-transformed prop) routes through StructureNode.copy → copyOf.
Technical details
# copyOf throws on every RegExp
## Affected sites
- `ark/schema/shared/transform.ts:127` — `copyContentsOf.RegExp` produces a copy that already owns non-configurable `lastIndex` (and does not carry the source's `lastIndex`).
- `ark/schema/shared/transform.ts:82-88` — the overlay copies `Object.getOwnPropertyDescriptors(data)` (including `lastIndex`) onto the copy after forcing `configurable = true`; redefining the copy's non-configurable `lastIndex` throws.
## Evidence
`copyOf(/a/g)` throws `Cannot redefine property: lastIndex`; `type({ x: "string.trim" })` invoked on a RegExp with an own prop throws the same.
## Required outcome
Copying a RegExp must not throw and must preserve `lastIndex` plus any own enumerable props. Assigning `copy.lastIndex = data.lastIndex` (the property is writable) or otherwise avoiding the non-configurable descriptor collision would satisfy this. Typed arrays already short-circuit at line 80 for the same class of reason; RegExp needs equivalent handling.
## Open questions
- Are there other `copyContentsOf` kinds whose copy owns a non-configurable property the overlay would redefine? `lastIndex` appears unique to RegExp.| } | ||
| let copy: unknown[] | ||
| // slice builds its copy from data.constructor, which a named key can shadow | ||
| if (data.constructor === Array) copy = (data as unknown[]).slice() |
There was a problem hiding this comment.
This branch deliberately supports arrays with named keys (they are copied at lines 63-64), but it calls data.slice() through the instance, so an array that owns a slice property throws TypeError: data.slice is not a function. Reachable via e.g. type(["string.trim"])(arr) where arr.slice is set, since StructureNode.copy/SequenceNode call copyOf on the array.
The constructor shadowing is guarded on this very line; the call should use Array.prototype.slice.call(data) for the same reason.
| if (data.constructor === Array) copy = (data as unknown[]).slice() | |
| if (data.constructor === Array) copy = Array.prototype.slice.call(data) |
Two crashes in copyOf, both reported on #1685 and reproduced through the public API: - A RegExp's copy is `new RegExp(data)`, which already owns a non-configurable `lastIndex`. The descriptor overlay forced every descriptor to `configurable: true`, so redefining `lastIndex` threw "Cannot redefine property: lastIndex" for any RegExp with a transformed prop. A descriptor now stays non-configurable where the copy already owns that key non-configurably; `lastIndex` is writable, so the redefine succeeds and carries the input's value. - An array copied with `data.slice()` threw when the array owned a `slice` key. It now calls `Array.prototype.slice` directly, as the `constructor` guard beside it already anticipates a shadowing key. Both tests fail without the fix, jit and jitless. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
e4b54ea to
8599524
Compare
… it with claims The announcement, README and homepage buried the answer to the question a Zod user asks first: what does switching cost me, and what do I get. They now open with it. - README: the first screen is the scoreboard card, "Using Zod? Switch with one prompt" and an example with real 3.0 output, then a before/after, what carries over (names, messages, Standard Schema integrations), what changes, and a collapsed API table. It states no number in text; numbers stay in claims.ts and reach the README through the site's generated card. - Announcement: a TL;DR under the headline and a "Switching from Zod" section second, where "Migrating from Zod" was near the end. A custom message now shows as written everywhere, forms included, which is how a Zod message behaves and was the largest papercut a production migration hit. "The plugin can wait" says what an app gets before it precompiles. - Homepage: the hero's second button is "Migrate from Zod", the migrate section carries a custom message through its before/after and lists what you keep and what it costs, and five error outputs that still printed "(was ...)" match what 3.0 writes. - The social card printed "startup: 2nd of 23" under "Pick 3" while the board beside it said 1st: it read the raw index where the board applies the tie band (zod-compiler 1.0000, ArkType 1.0009). It now reads the board's place. New claims, each recomputed from the stored results and citable from prose: - dynamicAppSpeed / dynamicZodSpec: without the plugin, ArkType validated faster than Zod 4 on all 11 apps bundled with esbuild, by 1.65x on ntwine's packages/shared and 8.38x to 15.31x on the 10 generated, 9 of 9 paired runs each (sign test p 0.0039). Against z.compile, faster on 10 of 11 at p < 0.05 and tied on 1. - dynamicZodStartup: without the plugin ArkType ran 1.50x to 2.19x the instructions Zod 4 did from import through first validation, 9 of 9 on every app. Unflattering, and stated. - dynamicZodSize: without the plugin ArkType's bundle is 3.59x Zod 4's on valibot.dev's login form, 89,751 B against 25,058 B gzipped. Also stated. - zodStartup: precompiled, fewer instructions than Zod 4 on each of the 4 startup apps by 10.34x to 54.39x, 20 of 20 paired runs on Node 24. - zodSize: precompiled, 1,007 B gzipped on the login form against Zod 4's 25,058 B and Zod Mini's 5,127 B. - dynamicZodSpeed is pending and cited nowhere: the homepage benchmark's medians have the dynamic arm ahead of Zod 4 in 32 of 32 scenarios, but its paired verdicts were stored only for the precompiled arms. bench.ts reads an optional `arktypeVs` so the next release run can back it. appSpeed printed "p <= 0.039" for p = 0.0390625; p values now round up. Not changed, and for a decision: "smallest" holds only as a best average (second on each of the three independent size results, and it fails leave-one-out), and "quickest to start" holds in instructions, not wall clock. Also: READMEs for @ark/util and @ark/fs, and the extension's and @ark/aot's READMEs carry the current tagline and the skill command.
An error had two texts: `problem`, without its path, and `message`, with it.
A custom message could go in either, and the one people reach for, `message`,
was the one a form library never showed: a Standard Schema issue read
`problem`, so `.configure({ message })` and `ctx.reject({ message })` gave a
form ArkType's default text. Migrating a 171-file production monorepo to 3.0
took rewriting 143 such sites to `problem` before its forms said what they
had on 2.x. Zod has one message, and it shows as written everywhere.
There is now one slot. `message` never holds the error's own path, and
`problem` is gone from config, meta, `ctx.reject`, errors and locales. There
are two ways to say what's wrong, and they don't mix:
- Templated: configure `expected` (or `.describe()`), and ArkType writes
`must be ${expected}`, composes it into unions and intersections, and a
summary puts the path before it: `age must be an adult's age`.
- Custom: configure `message`, or pass one to `ctx.reject`, and that one
sentence shows verbatim on a direct call, in a Standard Schema issue and
under `flatMessagesByPath`. A summary sets it apart from its path:
`email: Enter a valid email`.
What follows from it:
- `summary`, `toString`, the thrown TraversalError and `toLocaleString` write
each error's line. A type no longer places its own path; a locale composes
the line through `Locale.line`, which en writes as above and de writes with
its subject and label.
- A Standard Schema issue IS the error, not a copy with another message.
- A union that lists its branches' errors still names each one's whole path
in a summary, and from its own path in its `message`.
- A union or intersection whose errors all share one custom message takes it.
- A pipe's configured `message` is its output's errors' too, as #1479 had it.
- A missing key shows its value's custom message, where it said
`must be a string (was missing)` whatever was configured: a message written
out for a value says what's wrong with it however it fails.
- A union's configured `expected` is templated like any other. It was written
bare, with no `must be` and no path.
- `flatProblemsByPath` is `flatMessagesByPath`.
- `problem` is a type error where it was accepted, and where a cast or
JavaScript passes it, `.configure()`, `configure()`, a scope's config and
`ctx.reject` throw `problem was removed in 3.0; write message`.
- Another library's Standard Schema issue embedded in a Type keeps its
message as written, as custom text; an ArkType Type's own, from this copy,
another copy or a precompiled validator, stays templated.
The lean issues `arktype/runtime` and precompiled validators write follow the
same rules, and the standalone compiler's sites carry whether a site's text
is custom. `ark/aot`'s half of this is in the next commit to that package.
Review of this change found, and this commit fixes: a union's message writer
ran a second time at an empty path; `summary` copied each error per line
(1145 ns for ten written errors, now 460 to 500; it was 65 before lines were
composed, and what remains is deciding custom-ness per line).
Riding along, from an audit of the release:
- perf(types): completing a string definition takes 15 to 21 ms on
TypeScript 6 and 3 to 6 ms on TypeScript 7's server, where this branch took
602 to 746 ms and 208 to 233 ms, and 2.1.22 took 89 to 154 ms and 39 to
68 ms. To complete a string argument TypeScript resolves the call with
inference from it blocked, by inferring the parameter's type to itself, and
wherever that met one alias on both sides it measured the alias's variance:
a structural comparison of everything validation reaches. `type("s")` spent
741 ms there. The parameters now go through `DefinitionArgument` and
`ValidatedArgs`, interfaces that declare `in out`, so nothing is measured,
with inference sites left in a dead branch so a lambda in a tuple
expression is still typed (declaring variance alone, or `NoInfer`, made it
`any`). One completion request instantiates 4,028 types, from 946,162.
`pnpm bench` totals +0.82%; a later call of a spread-argument form costs
+5% to +13%, its first far less. completions.test.ts bounds the request.
- An issue's hover is `ArkError<ArkErrorCode>`, not a 700-character union.
- fix: two lookbehind regex literals made `import "arktype"` a SyntaxError on
Safari before 16.4, which 2.x loaded on. testBuild fails on one.
- `console.log(out)` prints `ArkErrors { summary, issues }`, where it printed
a bare array though errors are no longer one.
- An unresolvable name suggests what to write: `'int' is unresolvable. Did
you mean 'number.integer'?`, for 54 names from Zod, TypeScript and JSON
Schema at both the type level and runtime (0 instantiations added), and for
typos at runtime.
- `configure()` rejects an option it lacks, in types and at runtime.
- A class as a definition is a type error and a ParseError saying what to
write. `type(Map)` threw `Constructor Map requires 'new'`.
- The German locale leaves the value out of its messages, as English does.
- The built `@ark/aot` resolved `arktype/internal/runtimeExports.ts` to the
full internal entry rather than the runtime's, so its checks of what the
runtime exports were wrong once packed, though right in every test, which
read source. `arktype` exports those three internal modules explicitly and
testBuild checks what each deep path resolves to.
- ci: the site no longer deploys when the publish fails.
- CHANGELOG: a summary of 3.0 at the top of Unreleased.
Deleted: `ark/repo/cyclicScaling.md`, an experiment that concluded in
d7f9e92 (`scope(cyclic100).export()` took 79.6 to 85.3 s on 2.2.8 and 210 s
on this branch before it, 406 to 702 ms after); the `publishExtension` script
for a package that no longer exists; `buildCjs`, `tsconfig.cjs.json` and
build.ts's `--cjs` branch, which nothing ran.
Known and not fixed here: `union.test.ts` "a discriminant doesn't skip a
predicate an earlier key tests" passes only after other files have run, on
this branch before this commit too.
`arktype-precompile --check` on a production Next 16 app (3,556 files, pages
router, webpack, workspace packages built to CommonJS) accepted 208 of 228
sites and reported 10 errors outside one. It now accepts 234 of 234 with no
change to the app's source, `next build --webpack` passes with only the
plugin and `transpilePackages` added to next.config.js, and what its forms
display is identical to the unprecompiled build on all 1,251 rows of a
harness that runs every exported schema.
What the build reads that it refused:
- A static helper's body may return from `if`s before its final `return`. A
narrow like `if (!exists(data)) return ctx.reject(...); return true` failed
every definition that passed it to a union with a unit branch, since
arktype calls a narrow on a unit while defining the Type.
- A narrow a union's unit calls and its other branches keep.
- What tsc writes for a CommonJS module: `exports.x = ...`, a
`defineProperty` getter, `__exportStar(require(...))` and `__importStar`.
A workspace package built to CommonJS was reported as
"<path> has no export <name>", which it had. A value read this way is
passed to the validator by its export's name.
- A helper holding a Type parameter is folded at each call, where the build
told its author to inline it.
- A call whose dynamic argument only a closure the call creates reads. This
precompiles a schema factory called per render with saved values its
narrows compare against.
- Composing a call's result, `helper().or(...)`, is a site.
- `typeof X.infer.a.b` types data, not a Type: an array typed from a Type's
`infer` was flagged for `.map`. Reading `.infer` or `.t` as a value, as
`withForm({ defaultValues: X.infer })` does for its type, isn't flagged.
- A tsconfig's `paths` apply to files under it that its `include` leaves out.
- An interface with a computed key threw while scanning, which silently
turned pruning off.
What it says where it still can't:
- One cause, one report. A Type chained from a definition that failed said
"X.array reads array, which a standalone validator lacks"; it now says
"X.array composes `X`, which can't be precompiled" and points at that
definition's own report.
- A value from a React hook says it's known only as a component renders,
where the build told the author to rewrite the hook as one expression.
- A definition that composes precompiled Types is no longer told to use a
`// @ark-runtime` island, which can't define it alone.
- The barrel warning names Next's `optimizePackageImports`, the packages and
the two ways out, where it said "built <path> from two codes".
- `--baked-limit` takes a number, as its option does; its usage said a path.
This commit also holds this package's half of the single error `message`
(1c12336): validators write `message` without a path and mark a site's
text custom, and the tests compare them against arktype's.
Measured on that app, total client JS against the unprecompiled 3.0 build:
+0.65% raw (+228 KiB), +0.41% gzip, with the options its config can safely
set; +2.94% raw with none. Pruning is what makes a precompiled bundle
smaller, and here it's off: `optimizePackageImports` builds a workspace
barrel once per set of names imported from it, and with the packages taken
out of that option the build refuses four sites whose enum a tsc-built module
loads with `require()`. The code of 234 validators costs about what the
parser did. `optimize: "size"` brings it to +0.11% raw and -0.23% brotli, not
adopted: it overflows the stack on cyclic data like
`type({ foo: { bar: "this" } })`, as it did before this commit.
Docs: a "Next.js with webpack in a monorepo" section in Setup, and
Troubleshooting entries for each message above.
…t following them broke
The guides were tested the way their readers use them: an agent holding only
the skill and its references migrated realistic modules from Zod 4, 3 and
Mini, Valibot, TypeBox, Yup, Joi, Effect and JSON Schema, with about twenty
integrations around them, and upgraded three ArkType 2.x modules holding only
the upgrade guide. Each result was type-checked and run against source, and
its output compared with the original library's. 43 rounds found 86 places
the migration guide was missing, wrong or made its reader guess, and 9 in the
upgrade guide. Each is fixed in the page that caused it.
- migrating.mdx is rebuilt around a nine-step workflow, the two config
options that match Zod's defaults, a table per library whose every row
type-checks, issue codes, and the semantics that differ: `.optional()` and
`.default()` against `undefined`, key stripping, unions under that config,
where a message must be written for an optional enum or a parse keyword to
say it, narrows that `.merge()` and `.pick()` drop, async pipes, and
definitions built at runtime.
- upgrading.mdx opens with a table of every breaking change and what to
write, and lists the adapters that still peer on `arktype@^2` and read
errors as an array (`@hono/arktype-validator`, `@hookform/resolvers` before
5, `sveltekit-superforms`, `@arkenv/core`, `@typeschema/arktype`), each with
the Standard Schema entry point that works today.
- SKILL.md gains the migration steps, a table of signatures for a function
that takes a Type, a decision table for error text (a Zod message is
`message`; `ctx.reject("x")` and `ctx.mustBe("x")` mean `must be x`;
`.describe()` or `expected` for text that composes), and a table from each
error an agent will hit to its fix, each gotcha stated once.
- errors, configuration, expressions, traversal, objects, scopes,
integrations (OpenAI and Anthropic SDKs), FAQ and packages pages: what the
dogfooding showed was missing from each.
Checked: 405 `ts` blocks type-check against source, 118 documented outputs
match what runs, and the docs build and `pnpm testSkill` pass.
Two pages broke the build through inline code holding a backtick: an escaped
backtick doesn't escape inside a code span, so the braces after it parsed as
an MDX expression. They use a double-backtick span.
testBuild expected a development build to log errors as a bare array, which
1c12336 changed to `ArkErrors { summary, issues }`.
Regenerated: the skill's migrating reference, llms.txt and llms-full.txt.
testBuild writes a barrel that re-exports `match` without using it, to check what the built Node driver keeps of it. It's a fixture the test leaves behind, like those under ark/aot/__tests__/temp, and failed `pnpm lint` on an unused import after any run of `pnpm testBuild`.
…Schema()
toJsonSchema() copies a node's meta into the schema it writes, so that an
annotation like `title` or `examples` survives. It skipped a function, which
JSON can't hold, but copied a string: `.configure({ message: "Enter an email" })`
wrote `"message": "Enter an email"` beside `"type": "string"`, and `expected`
and `actual` did the same.
Those three word arktype's own errors. No JSON Schema reader has a use for
them, a validator in strict mode rejects a keyword it doesn't know, and 3.0
makes `message` the slot people reach for first, so far more schemas would
have carried one than carried `problem` on 2.x.
Found while following the migration guide against Slash's forms, where every
field has a message.
271fb16 added six claims against Zod 4 (dynamicAppSpeed, dynamicZodSpec, dynamicZodStartup, dynamicZodSize, zodStartup, zodSize), a pending seventh, a rounding change to every printed p value, an `arktypeVs` reader in bench.ts and a change to the place the social card prints. The claims had already been honed to be accurate and compelling without overreaching, and none of that was asked for. claims.ts, bench/bench.ts and writeOgImages.ts are back to what they were before that commit, byte for byte. What cited the new claims goes with them: the announcement's "The plugin can wait" section and its two bullets under "The numbers", the homepage migrate section's "no plugin yet?" note and its "no build step" cost row, and the README's bundle-size bullet, which linked to the removed section. The announcement's existing "Without the plugin" line (dynamicSize) still discloses the dynamic bundle. Kept from 271fb16: the structure (switching from Zod first), the before/after examples and the five homepage outputs that printed "(was ...)", which 3.0 doesn't write.
…a stops at the alias depth
`optimize: "size"` writes a node as a call to a runtime checker unless it's
in a cycle, since a checker's Allows passes no alias depth on: the traversal
reading it drops the depth, and a compiled node below starts again from 0.
`isInCycle` decided that by comparing an alias's resolution with the node by
identity. `this` resolves to a node equal to the root it's written in, with
the same id, but not that object, so the root of `{ foo: { bar: "this" } }`
was judged outside its own cycle and written as `runtime.sited(...)`.
Checking data that is itself cyclic then never reached the 64-deep bound,
and the 1000-visit bound came after the stack ran out: a RangeError where
arktype returns "must be acyclic". The comparison is by id now.
It reproduces through `precompileStandalone`, so through the Node and Bun
drivers, `--emit` and the differential harness. The bundler plugin's own
path already compiled that root, which is why web-app2's builds with
`optimize: "size"` never hit it.
…ageImports
A production webpack or Rspack build reads the program it built to prune.
Next's `experimental.optimizePackageImports` builds a listed package's
entry as a module of its own for each set of names imported from it
(`__barrel_optimize__?names=a,b!=!<entry>`), each holding some of the
file's re-exports and nothing else. The read saw one file as several
modules of different code, gave up ("from two codes"), and the build fell
back to building each module on its own with every member kept, behind a
warning telling the app to take the package out of the list.
On Slash's web-app2, which lists 14 workspace packages there, that fallback
is what made a precompiled build larger than one shipping arktype: 831 units
of 557 KB against the 304 KB of arktype they replaced.
Such a module is now read as its file, whose text names every re-export:
- `builtEntriesOf` takes its source from the file rather than the module,
counts it as transformed without the plugin's loader having run on it,
and resolves each import it was built with by what the file names.
- an importer's request for it is read by the specifier its text names
(`named` on `BuiltImport`), and resolves under the request too, which is
what the module as the later loaders built it names.
- where the entry is no barrel, Next builds it as `export * from` the file
itself, an import of its own id, which is dropped.
- the loader records nothing for it, since nothing is written to it.
So the package stays in the list and the bundle is read whole. The warning
that named the list is gone with what it warned about.
…ollow may write
A pruned build refused a definition reading a holder whose module
something loads in a way the build doesn't follow: a `require()` or
`import()` of it, a dependency importing it, a namespace re-exporting it
("... so code the build doesn't follow may write it"). tsc's CommonJS
writes every import as `require()`, so every const object a workspace
package built to CommonJS shares between its modules counted, like each
enum of Slash's `@slashfi/models`: four of web-app2's sites were refused
by a pruned build that a build reading one module at a time accepted.
The refusal bought nothing. A site's factory checks each value it read as
it creates the validator, in every build, pruned or not: the
`checkInput(p0["limit"], 3, ...)` is in the pruned bundle too, and that
check is all a `prune: false` build ever relied on. So only a write the
build sees still refuses the site. A value written where the build can't
see is caught where it always was, as the validator is created:
"`H.limit` is 4, but was precompiled as 3".
`findElsewhere` no longer answers for a loose exporter or a module loaded
whole, `ProgramView` no longer carries which modules are loose, and the
hint for the refusal's message goes with it.
…roduction build A site's factory checks each value its definition read as it creates the validator. For an object or array read whole, like `type.enumerated(...Object.values(Plan.Enum))`, that was a `checkFacts` of its shape, naming every key, and a `checkInput` for each key with its value and label: 22 KB minified for one of web-app2's sites, reading an enum of 118 members, and 8 KB for another reading 182 currency codes. Together the creation checks were 46 KB of that bundle. Where a build checks no Types (`creationChecks: "none"`, a production build's default), a plain object or array of four or more primitives is now one `runtime.checkDigest(value, "<digest>", "`label`")`: a 53-bit digest over what kind it is and each own key, the type of its value and the value, with -0 apart from 0. The build computes it from the value it read, and the runtime from the value it's handed, so a key added, removed or changed fails as before, by a message naming the value rather than the key: "`currencies` holds other keys or values than it was precompiled with". A build that checks Types keeps each key's check and its message.
…y load a validator
A pruned build leaves out of its validators each member no read needs,
which it decides by following every read in the program. At the first
`import()` or `require()` of a computed specifier it gave up on the whole
program and kept every member, as such a call may load a module it never
followed. One icon loader, `import(`./icons/${name}`)`, did that to all of
web-app2's validators.
A bundler has no such doubt: webpack and Rspack build a module for each
file the specifier can name, and reach them through a module of their own
with no file, so `programAsBuilt` already marks each of them exposed, read
as code outside the bundle may read it. `ScannedProgram.exposesLoaded` says
so, and the scan then goes on past the call. Members are kept only where
one of the modules it may load exports a validator, by the same warning an
entry's export gets.
Members are still pruned for the program rather than per validator, so one
validator a computed specifier may load keeps `assert`, `meta`, `~standard`
and `methods` on every validator. A build that didn't come from a bundler
reads a computed specifier as before.
… SWC declare in CommonJS A validator stored at an object's key is followed to each read of that key by name, and to each read that may read any key, like `o[k]` or `Object.getOwnPropertyDescriptor(o, k)`, where the build loses track of it: it bakes each introspection member into it and keeps every member a production build would prune. A compiler emitting CommonJS declares helpers that copy one module's exports to another's, and each holds such a read. tsc declares `__createBinding` in every module with an `export *`, and SWC `_interop_require_wildcard` in every one with an `import * as`. A workspace package built by either is the program's own code, so one such module anywhere lost every validator stored at a key anywhere in the program, with a warning naming the helper: on web-app2, "because ../../be-libs/backend-env/lib/index.js:4:16 reads its descriptors", then "../../common-libs/slash-common/lib/services/__exports/index.js:165:48". Those helpers read a module's exports by key and nothing else, and what a module exports is followed by what each module imports. So no read in one is a read of a key a program stores a validator at, and the index of such reads skips their bodies: tsc's `__createBinding`, `__setModuleDefault`, `__importStar`, `__exportStar` and `__importDefault`, declared as tsc declares them (`var x = (this && this.x) || ...`), and in a CommonJS module the functions SWC and Babel name `_export`, `_export_star`, `_interop_require_default`, `_interop_require_wildcard`, `_interopRequireDefault`, `_interopRequireWildcard` and `_getRequireWildcardCache`. A function written by hand that reads descriptors by a key it's passed still loses it. This removes two causes, not the loss on web-app2: with both skipped, the same 82 of its 231 validators, each stored at a key of what a form library is passed, are lost at a descriptor read the app itself wrote, `Object.getOwnPropertyDescriptors(tvInstance)` in a design-system package. Following a stored validator to every read of any key can't hold track of one in a program of ten thousand modules, where some module always has such a read. The docs say so, and to set `members` there. Not recognized: tslib's copies of the helpers, which a package built with `importHelpers` imports, Babel's inlined `export *`, and esbuild's `__copyProps`.
…arge program whole
A production build that reads its program whole plans every module, then
follows each validator through it, twice: once for the members to prune and
once for those to bake. Each step resolves the same imports again and
again, as a guard's test or a binding's value is read for each validator
reaching it, and `createNodeHost`'s resolve ran the resolver and a
`realpath` for every call.
On web-app2's client program (10,408 modules, 231 validators), with
nothing else running:
before after
planProgram 153.9 s 17.2 s
usedIn 102.1 s 75.7 s
readingsIn 100.3 s 73.6 s
A profile of the three had 41% of its time in `realpath` and 48% under the
host's resolve. Next runs a scan in each of its compilers, which is where a
build reading this app whole went from 3 to 5 minutes to 22 to 28.
The host now keeps each answer by importer and specifier. That makes
nothing staler than it was: the resolver already keeps what it found of a
file, there or not, for as long as it lives. A file created after a miss
stays unresolved, and one removed after a hit stays resolved, with or
without this.
What's left is the following itself: each validator stored at a key is
sent to every read of any key in the program, so `usedIn` and `readingsIn`
are each about 75 s here.
…igh arktype
The default build compiles each validator to the code that checks its Type
fastest, and that code grows with every Type, where arktype doesn't. Past
some number of Types a precompiled bundle is larger than one that ships
arktype and creates them as it runs, and nothing said so.
That is web-app2 with everything else working. Read whole, pruned, 231
validators: 394 KB of units (one copy of each, 446 KB as its chunks place
them) and 23 KB of runtime against the 304 KB of arktype they replace, the
bundle 103.5 KiB larger than on arktype. With `preset: "smallest"` the same
build is 65.3 KiB smaller than on arktype.
So a production build reading its program whole, with `optimize` unset,
sizes what it wrote against arktype and warns where that's larger, naming
both ways out: `preset: "smallest"`, or `optimize: "speed"` to keep the
validators compiled and say no more.
The size is an estimate (`validatorsToArktypeOf`): what the sites reach of
the modules written and of the runtime, over what `type` reaches of
arktype, each declaration's length with names shortened and strings kept
(`minifiedLengthKeepingStrings`). `minifiedLengthOf`, which shortens the
words in a string too, read web-app2's validators, a message on each
field, as 0.95 of arktype when they are 1.37. arktype's own source
shortens further than written code, whose names are short already, by a
factor measured on real bundles:
program estimate measured
400 number ranges 0.27 0.26
576 0.38 0.38
900 0.58 0.57
1600 1.02 0.99
web-app2, default build 1.24 1.37
(esbuild bundles for the ranges, Next's webpack build for web-app2.)
Sizing a flat bundle also found a declaration that destructures, `const
[a, b, ...] = (() => { ... })()`, counted once for each name it declares:
it's counted once.
A build reading one module at a time has no bundle to size, so it doesn't
warn.
…dator For the changes since 4289102, which wrote this setup as one that builds each module on its own: - Setup, Next.js with webpack in a monorepo: a package stays in `optimizePackageImports`; a const object a package built to CommonJS shares between its modules is precompiled, its validator checking the value as it's created; a computed `import()` doesn't stop pruning. Leave `prune` unset, and build with `preset: "smallest"` where size matters. - Options: a production build checks a list or enum read whole by a digest; what `prune` reads of Next's barrel modules and of a computed specifier; the warning where compiled validators outweigh arktype, under "Choosing smallest"; and under `members`, that the helpers tsc and SWC declare in CommonJS aren't followed, but any other read of a key the code doesn't name loses each validator stored at one, so a large app sets `members`. - Troubleshooting: the refusal for a value "code the build doesn't follow may write" is replaced by the mismatch a validator throws as it's created; Next's barrel entry folds into "from two codes"; the new warning has an entry. - The changelog's paragraphs on webpack builds, size builds and baked members say the same, and llms.txt is rebuilt from the pages.
…ck of it A validator the build loses track of keeps every member whatever else reads it: `reading()` bakes each introspection member and keeps each pruned one as soon as `lost` holds one entry, and only the first entry is ever reported. `Follow` went on regardless, and a validator stored at a key is sent to every read of any key in the program, so each lost one still walked every such read and all that flows from it. Now nothing is pushed or read once a validator is lost, and the loop sending it to each read of any key stops there too. A loss past a dependency's read (`quietlyLost`) doesn't stop it, as a later loss in the program's own code is the one a warning names. On web-app2's client program (10,408 modules, 231 validators, 97 of them lost: 82 stored at a key of what TanStack Form is passed), scanned alone: usedIn 75.7 s -> 6.3 s readingsIn 73.6 s -> 4.7 s with the same 97 lost and the same first reason for each. `next build --webpack` of that app compiled in 16.3 min before and 4.7 min with this and the two changes after it, which weren't timed apart in a build. No test: nothing observable changes but time. The suite's readings are unchanged.
…what it checks, saying it
A size build writes each node it can as a call to a runtime checker, and
compiles the rest. A checker reports a code and a description, so a node
whose site says a configured message had to be compiled, and with it every
root above: a required key whose missing site says its value's message kept
its whole object compiled.
That is how an app writes a form. web-app2's fields are
`type("string > 0").configure({ message: "Name is required." })`, one
message a field, so under `preset: "smallest"` only 127 of its 200 site
roots were checkers, 179 of 621 written modules still declared a compiled
traversal (317 KB of 702 KB of source), and each field was a unit of its
own with two or three sites holding the same sentence.
Now:
- A root no structure hangs off, each of whose references says the message
configured for it (`.configure()` reaches them all), is
`saying(<checker>, message)`: the checker of the same root without the
message, written in place, and its message once. `saying` passes its
checker a ctx whose `_at` adds the message to each site, restored when it
returns, so `string > 0` is the one checker every such field shares and
only the sentence is the field's.
- A key's checker holds the message its missing key says, so `props`
reports it: a field's own where it is `saying`, else
`sayingMissing(checker, message)`. A required key with a message of its
own no longer compiles its object.
- A basis or refinement saying a message under any other root, like an
array with a minimum length, an object, or a number narrowed after it was
configured, is `saying(<check>, message)`, as a check is its own site.
The shapes (`stringRange`, `arrayOf`, the object basis `props` checks)
are left to roots without one.
A message a function writes, one configured for a code rather than a Type,
a union listing its branches' issues and a narrow or morph reading its ctx
are compiled as before. A unit saying a message sets the build's
`writesText`, as a compiled site's did by its ref.
On web-app2's client program, what its sites import bundled and minified
with the runtime (esbuild), `preset: "smallest"`:
validators 184,389 -> 103,656 B
runtime 22,371 -> 22,956 B
together 206,760 -> 126,612 B raw, 46,914 -> 34,231 B gzip
181 of 200 site roots are checkers after the first step, and 14 of 517
modules still declare a compiled traversal (29 KB of 473 KB of source):
four forms holding a morph whose callback reads its ctx.
Tests: checkers.test.ts, "a message configured for a Type": each issue's
code, expected and message and the summary as arktype prints them, for a
field missing, invalid and valid, under a union, and for an array, an
object and a narrowed number, in the default build and the size build, and
what the size build wrote. Slash's parity harness shows the same text as
arktype on all 1,251 rows with these checkers.
…mpiled, would outweigh arktype An unconfigured production build compiled every validator for speed and, since e3e2a02, warned where that came to more than the arktype it replaced. The warning named the fix and left the bundle larger than one not precompiled at all: web-app2's 231 validators were 416 KB with their runtime against arktype's 304 KB, so the default made the app 103.5 KiB larger. A default that makes a bundle larger is the bug, not the missing setting. Now the precompiler reports the estimate (`timesArktype`, where `optimize` is unset and it exceeds 1) and the bundler plugin acts on it by what loads the bundle: - a browser (esbuild's `platform`, a webpack or Rspack compiler's `target`, Bun's `target`, a Vite client build): the worker restarts with `optimize: "size"` and reads the bundle again, and the build warns that it did, naming the settings that build so without the second read. `optimizeErrors` stays `"speed"` unless set, so the full error runtime ships and a runtime island still works, and `lazy` is left alone, since when a Type is created is the program's to decide: `preset: "smallest"` is smaller still (5.8 KB on web-app2). - a server (target node): left compiled, silently. Nothing downloads it. - unknown (Rollup, Rolldown, a Vite build of several environments, and Turbopack, whose one read holds the server's modules with the browser's): the warning as before. An explicit `optimize: "speed"` or `"size"` is never estimated, so it is honoured without a word. The estimate also stopped counting a flat bundle's replaced unit modules, which the written program still lists: an esbuild bundle of 48 ranges read 3.4 times arktype in the plugin and 1.5 through the precompiler. In `next build --webpack` of web-app2 with no `preset` or `optimize`, the client compiler printed "…would be about 1.2 times the size of arktype…so the build wrote them as calls to checkers they share" and the server compiler nothing about size. With the message checkers of the commit before, by source map over every client chunk: validators, one copy 393,603 -> 145,098 B (178,861 as placed) runtime 22,764 -> 26,912 B together 416,367 -> 172,010 B arktype: 303,611 whole client JS vs the app on arktype: +103.5 KiB -> -149.1 KiB raw, +17.4 -> -33.6 KiB gzip Slash's parity harness shows the same text as arktype on all 1,251 rows with the options this chooses. Tests, prune.test.ts "validators larger than arktype": the estimate for 48 ranges, none under `smallest` or `optimize: "speed"`; an esbuild browser bundle identical to one built `optimize: "size"`, with the warning; a node bundle left compiled, silently; webpack and Rspack by `target`.
…, in a size build
A factory declares a node its own traversals read before them, as an empty
object, and fills it once they exist. Each wrote the fill out whole:
runtime.freeze(runtime.assign(shape0, {
allowsCtx: true, checksCtx: true,
tAllows: traversals4[0], tApply: traversals4[1],
allows: data => runtime.allowsUntracked(shape0, data) ??
runtime.allowsInContext(shape0, data, runtime.runtimeConfig),
$: runtime.runtimeScope
}))
`runtime.ctxNode` already builds exactly that node for a unit declared at
module level, so the members and the function answering `allows` were in
the bundle once for those and once more in every factory. It now takes the
declared object as a fifth argument and fills it, and a size build that
details errors writes
runtime.ctxNode({ checksCtx: true }, traversals4[0], traversals4[1], void 0, shape0)
A build for speed, and one whose errors don't detail, write the fill as
before: the first inlines what it can, and the second's `tApply` isn't a
traversal `ctxNode` is passed.
web-app2 has 33 such shapes (forms built by a helper that holds a narrow or
pipe reading its ctx). Offline, client program, `preset: "smallest"` with
`members.expression: false`: validators 76,538 -> 74,579 B, runtime
22,877 -> 22,900 B; 99,415 -> 97,479 B together (-1,936), gzip
29,485 -> 28,976 (-509).
Test, checkers.test.ts "has the runtime fill a node its own traversals
read, where a callback reads its ctx": a root narrowed by a callback
reading its ctx, above a helper's narrow that reads its own, prints
arktype's issues compiled and as checkers, through the root, `allows` and
an array of it; the two `ctxNode(…, shape0)` calls are exact and no shape
writes `allowsUntracked` itself.
… its imports through a Set Profiling the scan of web-app2's client program (10,408 modules, 128 of them writing validators) after 8bd9e3e: 37.7 s, of which 13.7 s was `isOnCycle` and 3.5 s the dependency list of each module written. `isOnCycle(module)` reads every module the module's text imports reach, from disk, to see whether one imports it back. `isBindingSetBefore` asks it for each input of each site, so a module read everything it reaches again for every imported helper its definitions call: a quarter of the whole scan was `readFileSync` (9.7 s). The answer is now kept by the module's id and source, and dropped with the import components (`componentsById`, the same graph) when `forget` hears a file changed. `textClosureOf` and `ModuleGraph.dependenciesOf` collected what they reached in an array and asked `includes` of it before each push, quadratic in a closure that is thousands of modules for an app read whole. Both collect in a Set, which iterates what is added as it goes in the order added, so the lists come out as before. Same program, nothing else running: 37.7 -> 24.9 s with the first change, -> 19.2 s with both. What it writes is identical, module for module (446 written modules compared as JSON). What is left is spread: planning (the kind solver under `analysisOf`) 9.1 s, following validators 5.8 s, and no function above 2 s of its own. Test, drivers.test.ts "answers anew once another module's change closes an import cycle through it": a watch build's worker answers for an unchanged main.ts before and after app.ts comes to import it; the second answer refuses the input that cycle could run early and equals a fresh worker's. It fails with the kept answer not dropped in `forget`.
`pnpm buildDocs` writes the precompile docs' llms.txt from the pages. It now holds what 37efdf8 and 9cc2140 added to options.mdx and troubleshooting.mdx: a Type configured with a message written as a checker saying it, a browser's bundle written for size where its validators compiled would outweigh arktype, and the two messages that choice prints.
leaderboard.ts reads ArkType's rows from a list of files, "a later file's measures replacing an earlier one's where it remeasures them", but dated every suite by the last file's commit and named the whole list as the source of the homepage apps' sizes. With one file the two were the same. A later file holding only some measures, like sizes measured again without the instruction counts, would have said the counts were its commit's too. Each suite's `measured.arkType` is now the commit of the last file holding that suite's rows, and the homepage apps' source names the last file holding their sizes. With the one file there is, leaderboard.json is written as it was, byte for byte.
The published size rows were 2071002's, from before failures passed as literals, errors read whole as one class, an assert throwing no class where none is named, and the errors that wait to be read being the class a build writes. The board showed the login form at 1,026 B and the download at 1,771. Measured at ba691ac with `pnpm benchExternal size` (the form, and the download and bundle rows of schemabenchmarks.dev and Sury, each suite at the commit and the installs its rows were counted on) and `pnpm benchSize` (the homepage's apps). Only ArkType's rows are stored: bytes of its bundles don't depend on what a rival is installed at, and every rival's row stays the one its last run measured (results/newest/, 2026-11-06), so `run.json` keeps each suite's date and takes the commit. The homepage apps' sizes are a new file of ArkType's rows, results/arktype-ba691ac56.json, holding them alone, which leaderboard.ts lists after 2071002's; the instruction counts stay that file's, and each suite's `measured` says so. min / gzip (B), 2071002 -> ba691ac: login form, default build 2,142 / 1,026 -> 1,871 / 917 login form, "smallest" 1,968 / 996 -> 1,699 / 878 login form, dynamic 271,827 / 89,767 -> 294,833 / 97,987 download, precompiled 6,281 / 1,771 -> 5,568 / 1,547 download, dynamic 271,482 / 87,359 -> 293,567 / 95,309 Sury schema, production 2,763 / 1,040 -> 2,369 / 908 Sury check, production 570 / 270 -> 570 / 270 apps, default build (gzip) login 1,517 -> 1,140, moltar 1,595 -> 1,188, shop 5,692 -> 5,074, saas 10,519 -> 9,592 apps, "smallest" (gzip, first stored here; benchData.json's are 642b451's 1,228 / 1,254 / 3,522 / 5,090) login 998, moltar 1,132, shop 3,420, saas 5,318 forms-behavior.json takes the three ArkType builds' text at this commit too: a summary's line names its path (`email: Please enter your email.`), a missing key says `(was missing)`, and dynamic ArkType's reads as the builds' do. What the site computes from leaderboard.json (claims.ts, units.ts), before -> after: size, other projects' results (the form and the download): 1st at 1.35 kB -> 1st at 1.19 kB, to Typia's 1.52 kB sizeAverage: "1.35 kB gzipped against Typia's 1.52 kB, 11.3% lower" -> "1.19 kB gzipped against Typia's 1.52 kB, 21.7% lower" leaveOneOut: "The bundle size lead doesn't survive leaving out schemabenchmarks.dev's download." -> "The validation speed and bundle size leads hold with any one benchmark left out." loginSize: "1.03 kB gzipped against 1.56 kB" -> "0.92 kB gzipped against 1.56 kB" our apps, bundle (login, moltar, shop): 3rd at 2.40 kB -> 2nd at 1.90 kB, past Valibot's 2.07 kB; ajv 1.61 kB the size chart's dynamic bar: 89.8 kB -> 98.0 kB No other claim's text changes, and none throws. Not measured here. Speed and startup rows count instructions with Linux perf and stay as stored, at 2071002. One of them is known to be out of date: schemabenchmarks.dev's "parsing invalid" (144 instructions, a failing call whose errors nothing reads) was last counted before the deferral rework (3e27c4e), which measured about 5% more per such call on the moltar app (205.7 instructions against 195.3). The checked-in text the docs build writes from these numbers (llms.txt and its like) is not written again in this commit.
The repo's tsconfig has no lib for Array.prototype.findLast, so bbe9eb0 failed typecheckRepo. leaderboard.json is written as it was.
…ts nothing benchSizeScale rerun on the merge of featherduster 0031c27, which has the colocated-Type binding fix (0849485) and the smaller default error path. The two ends of the layout now agree: between every handler apart and every handler with its schema, "smallest" moves by at most 0.28% of any gzipped bundle from 10 Types (it was up to 15% raw), Valibot by at most 0.41%. "smallest" against Valibot at the app's mix (26% of modules colocated), gzip, each seed's own, with the same tree's exported-schemas control: Types forms, app forms, exported models, app 1 -28.2 / -36.2 / -15.1 -23.6 / -31.6 / -10.6 -28.2 / -36.2 / -46.3 10 -5.3 / -4.6 / -3.7 -2.8 / -2.4 / -1.4 -11.7 / -10.8 / -9.9 50 +0.4 / +0.7 / -0.6 +1.6 / +1.9 / +1.0 -4.6 / -4.6 / -6.3 100 +0.0 / +0.5 / +0.1 +1.7 / +2.2 / +1.5 -4.0 / -4.2 / -4.8 250 -0.2 / -0.3 / -0.8 +0.4 / +0.6 / +0.3 -4.8 / -5.1 / -5.3 500 -3.4 / -3.6 / -3.4 -2.4 / -2.7 / -2.5 -7.4 / -7.1 / -7.0 1,000 -4.3 / -4.7 / -5.1 -3.0 / -3.8 / -3.7 -7.8 / -8.4 / -8.8 2,500 -7.0 / -7.2 / -7.4 -10.5 / -10.6 / -10.8 5,000 -8.7 / -8.9 / -8.9 -6.6 / -7.0 / -6.8 -11.9 / -12.0 / -12.3 On forms "smallest" is still over Valibot at 100 Types on every seed, by 4, 50 and 5 bytes of about 10 KB, and at 50 on two seeds of three, by at most 0.7%; it's under at 10 and from 250 up on every seed. On models it's under at every count. In raw bytes it's 17% to 29% smaller on forms and 26% to 37% on models from 10 Types. The default build is 1.9 to 3.4 times Valibot's gzip from 50 Types, and crosses dynamic arktype near 990 Types of models and 670 of forms (870 and 600 before the smaller error path). The run took 50 minutes beside the control's 30.
llms text regenerated from the new sizeScale.json. The page's layout sentence now reads that which module a handler is in moves no build's gzipped bundle by more than 0.5%, the branch it takes when the two ends agree, and "smallest" against Valibot on forms reads: smaller at 10 Types, within 0.8% either way at 50, larger at 100 by 0.1% to 0.6%, smaller from 250. The build also rewrote llms-full.txt and a line of the precompile text for pages the merge brought in (custom messages that read on from a path, optimizeErrors) whose generated text hadn't been rebuilt. benchSizeScale's header says what's true after 0849485: a colocated Type used to cost "smallest" 20 B, the two ends stay in each row so that coming back shows, the exported entry costs it 0.6% to 2.8% of a bundle against Valibot, and the run takes about 50 minutes.
…ad of publishing `any`
A docs build was seen writing hovers as `any` (every `Regex<...>` among them)
and dropping "// TypeScript:" error lines from the checked-in llms text. It
was put down to the dependency upgrade. It isn't: at the same commit and
dependencies, a build over freshly built packages writes every hover and
error as before.
The cause is that twoslash reads each package's built declarations
(ark/<package>/out/*.d.ts), not its source, since it ignores the "ark-ts"
condition. When a package's out/ is half there, which is the state
`pnpm build` leaves it in while it runs (build.ts deletes out/ first) and
after it fails, TypeScript resolves what it can't find to `any` and reports
nothing. Reproduced by hiding ark/regex/out/regex.d.ts alone: the snippet
`const R = regex("^a(\\d+)$")` queries as `const R: any` in a production
build that exits 0, where the full declarations give
`Regex<\`a${string}\`, { captures: [string] }>`. With arktype's missing, a
snippet's documented error never occurs, and twoslash only objects to errors
it didn't expect, never to expected ones that are absent.
So the build now checks every twoslash result, fresh or cached, and throws
with what to run:
- a query or hover of a declaration whose whole type is `any` (`...` as
lib/shiki.ts writes it on hovers);
- an `// @errors:` code that didn't occur.
A degraded result is never cached. Snippets marked `// @noErrors` are left
alone: they import packages the docs don't install (Fastify, tRPC), whose
types are `any` by design, which is the one place the check found a hover of
`any` in today's docs. Every other snippet passes it.
Checked against 5d73f2b: no checked-in llms file gained an `any` hover or
lost an error line since (each file's counts of both, and of `Regex<`, are
unchanged), so nothing degraded was committed.
…beside it does The claim said "Dynamic ArkType is 89.8 kB gzipped" from a typed number while the size chart's dynamic bar, drawn from leaderboard.json, moved to 97,987 B when ArkType's size rows were measured again at ba691ac. The page stated two sizes for the same build. The sentence now reads the bar's own number, the login form built with plain type() (leaderboard.json's form `builds.dynamic`), so they can't disagree: - Dynamic ArkType is 89.8 kB gzipped, minified with esbuild, up from 47.8 kB in 2.2.9, so precompile to ship less. + Dynamic ArkType is 98.0 kB gzipped, minified with esbuild, up from 47.8 kB in 2.2.9, so precompile to ship less. The 2.2.9 half stays typed. It is `import { type } from "arktype"` alone from npm by bundle.ts's method (47,797 B), and no result file stores it; it is a published release, so it doesn't move. Reading it too needs forms/size.ts to size the form on [email protected] as an arm of its own and leaderboard.ts to keep that beside `builds`. The two halves differ in what is bundled by the form itself, which was 16 B at 2071002. Comments that cited 2071002's sizes as the current ones (the header, the size chart, the headline, loginSize) now cite ba691ac's: the form at 917 B, the board's size mean 1.19 kB, the smallest on each of its two rows. The instruction counts are still 2071002's and keep that commit.
"Current standings" and "Objections" quoted 2071002's sizes, which 3acc6ae replaced with ba691ac's: the size mean is 1,191 B to Typia's 1,520 (21.7% lower, was 1,348 and 11.3%), the default build has the smallest bundle on both averaged rows (by 18 and 21 bytes; it was 2nd on both), the size lead holds with any one suite left out (it didn't survive leaving out the download), all three size rows average to 726 B (789), and on the homepage's apps the default build is 2nd of 8 at 1.90 kB (3rd at 2.40). "Size isn't close" keeps saying how close: the per-row margins and what it was before the default build was shrunk. The login record at 2071002 is worded as the record it is, with a paragraph on which rows were measured again at ba691ac and which weren't.
… not October's login app "Against dynamic ArkType" on the Benchmarks page printed 1.7 kB precompiled against 82.1 kB dynamic for our login form app. Both came from benchData.json's size block, measured at 642b451, and nothing has re-measured them since: three paragraphs further down, the table of our own apps gives the same precompiled login app as 1.14 kB (re-measured at ba691ac), and the claim under it gives dynamic ArkType as 98.0 kB. One page, two sizes for one bundle. The size row now reads the pair leaderboard.json stores at one commit: valibot.dev's login form as the default precompiled build (the row the size graph averages) and as dynamic ArkType (the form suite's `builds.dynamic`). Those are the same two numbers the size chart draws and claims.loginSize and claims.dynamicSize state, so the page can't disagree with itself about them again, and a rerun of the form suite moves all of them together. Our own login app has no dynamic bundle stored after 642b451, so the row changes app rather than pairing a re-measured precompiled size with a stale dynamic one; each row's label now names its app, and the note says where and at which commit each was measured. The cold-start row is unchanged: 3.34 ms and 31.7 ms are still the only stored measurement of it, and agree with the startup table above. The note also stops being the last of benchNotes(), where it rendered a second time under the speed chart, which shows neither cold start nor size. benchFacts() loses sizeStandalone and sizeJit, which nothing else read.
The checked-in llms text still carried the size rows from before ba691ac: 1.03 kB for valibot.dev's login form, 1.35 kB for the size graph's average, 89,767 B for dynamic ArkType, our own apps with ArkType third. This is `pnpm buildDocs` at 1ede969 with every package's declarations built, so it reads what the pages now render: 0.92 kB, 1.19 kB (21.7% under Typia's 1.52), 97,987 B, and ArkType second on our own apps (1.90 kB to ajv's 1.61). It also picks up the Standard Schema page's `{ issues, message }` and the dynamic comparison's new size row, and drops the cold-start note that used to print a second time under the speed chart. Hover types checked against 5d73f2b file by file: the number of `any` hovers and of "// TypeScript:" lines is unchanged in every llms file, so no commit between there and here published degraded snippets. In Chrome on the built site, none of the 1,420 hover popups across the docs pages reads `any`, and all 61 `Regex<...>` hovers carry their inferred pattern and captures.
…graph
MDX reads a line that holds nothing but components as blocks: it gives them
no paragraph and drops the whitespace between them. For a component that
renders text, that showed on the pages in two ways.
Two claims side by side in a `<p>` ran together. On the Benchmarks page,
"...against 1.56 kB.Dynamic ArkType is 98.0 kB..." and "...by a median of
5.3×.It isn't the fastest at everything", and the second one again in the
3.0 post. Writing `{" "}` between them isn't a fix that lasts: Prettier
formats it back to a plain space, which is the form that loses it.
A claim alone on its line rendered as bare text in the article. `<Claim
id="appSize" />` on the Benchmarks page and `<Claim id="buildTimeMedium" />`
on the Precompile page ran wider than the prose around them, with no gap
before the paragraph that follows.
keepComponentsInline is a remark step for rendered pages that puts both
back. In a `<p>`, where the source had whitespace between two components, it
keeps one space: a `<p>` holds inline content only, so that whitespace was a
space. At the top level of a page, a Claim, Headline or StandingsAsOf with no
children becomes a paragraph. Anything else MDX reads as a block stays one,
and components side by side outside a `<p>` are untouched, since a text node
between two blocks is not always harmless.
The pages' Markdown form already wrote each claim as its own paragraph, so
the generated text doesn't change.
…r it counts A dispatch with suites: all failed on ubuntu-24.04 in its first minute because the check ran perf before anything had installed it: hosted images ship without linux-tools and with perf_event_paranoid above what an unprivileged process may count under. The step now installs perf for the running kernel and lowers the sysctl when perf can't already count, so a self-hosted runner that does is left alone. Whether a hosted runner counts at all turns out to depend on the host it is given, not on the label. A probe on 2026-11-19 ran perf stat -e instructions on four labels: ubuntu-24.04 on an Intel Xeon 6975P-C under KVM and ubuntu-24.04-arm on a Neoverse-N2 counted; ubuntu-latest on an EPYC 9V74 and ubuntu-22.04 on an EPYC 7763, both under Hyper-V, reported the event as not supported. So the check now requires a counted instructions:u line rather than perf's exit code, prints the host's CPU, and its error says to dispatch again for another host. The header no longer says hosted runners can't count.
…when building on Windows testBuild failed on Windows alone: "arktype/runtime's ArkErrors bundles to 3139 B from the build and 2109 B from source". The check was right. The packages built on Windows differed from those built anywhere else, in two ways, both in bundle.ts, and both older than the check: 1. issueFeatures.js was bundled into the chunks. It was named to esbuild's `external` by its absolute path, which esbuild matches to an import once it's resolved only if the path starts with `/`, `./` or `../`. Anything else, `D:\a\...\out\shared\issueFeatures.js` included, it reads as a package's name to match against imports as they're written, which no import is. So each chunk held the module's constants as `var`s of its own, and no bundler folds a `var`: a program importing ArkErrors kept every class and branch `readsErrors` and `findsOnRead` choose between. The job was green until 3e27c4e and a74a4d4 made the errors class itself one of those choices, which took what a missed fold costs past the check's allowance. It's now named by the two specifiers the modules of out/ import it by, `./issueFeatures.js` and `./shared/issueFeatures.js`, which esbuild compares to each import's text, the same on every platform. An import matched that way keeps its text, which importingIssueFeatures already wrote from beside shared/. The build now throws, naming the output, if any holds issueFeatures.js, so a module importing it by a third specifier fails where it's built and not as a size somewhere else. 2. Every output was parsed lazily, the runtime's chunks among them. An output's inputs were looked up in the metafile by `relative()`, which separates by `\` on Windows, where the metafile's keys use `/`. The lookup missed, `?? {}` read that as no inputs, and so no output was one a precompiled program loads. The path is normalised and a missing output throws. Simulated on macOS by breaking each lookup the same way: the external alone bundles ArkErrors to 3106 B, the metafile key alone to 2142 B (33 over), and both to 3139 B, the byte count Windows reported. No Windows run confirms the fix itself. Built here, util, schema and type are byte-identical before and after but for the hashes in chunk names.
…ed runner The `leaderboard` workflow dispatched with `suites: all` got past its counters check for the first time (an Intel Xeon host under KVM) and failed in moltar's `npm ci`. Running every later step on a Mac, with stand-ins for perf and taskset, found three more things that would have failed it or left its results wrong. No stored measurement changes. @ts-runtypes can't be installed. Every @ts-runtypes package (core, bin, devtools and bin's binaries) was removed from npm on or before 2026-11-19: `npm view` 404s on each, and so does `npm ci` on the devtools tarball moltar's lockfile names. Moltar's newest commit (cc99777) still depends on them at 0.10.0, so no later pin installs either, and the pin stays 499f3fb, which every other library was counted on. reproduce.ts now takes the library out of the clone as it's checked out, at the pinned, 2026-10-24 and newest versions alike: its three dependencies and their entries in package-lock.json, its compile script, its case directory and the two lines that import it. It's gone from the suite's releases and compiled cases, and no `<case> @ts-runtypes` arm is counted. The lockfile is edited as JSON rather than through npm, which would ask the registry about a tree it can no longer resolve. arms.ts keeps the library, since its wall arms are the plan H1 and H2 were fixed on. The leaderboard still has @ts-runtypes' four moltar rows: it reads each rival's best count across the committed runs and the newest, and the committed ones (0.10.0 in counts-a306152ce.json, 0.12.2 in counts-latest-2026-10-24.json) hold it. It is under the site's 100k downloads a week, so no claim names it, and moltar's rows aren't in the 22 results the speed graph averages, so no standing counts it. The one place the site shows it is the precompile page's hand-written chart (claims.ts's speedChart, 209 beside ArkType's 185), which no rerun rewrites. Whether a library nobody can install stays there is a call for whoever reviews the run. Pinning. count.ts and startup.ts pin to cores 10-15, which the i7 the published rows were counted on has and a hosted runner's 4 vCPUs don't, so taskset failed every arm. count.ts logs an arm's failure and moves on, so the run would have passed having counted nothing. The workflow's check now sets COUNT_CORES and STARTUP_CORES to the runner's own cores unless it names its own, and count.ts throws where none of its arms was counted. Dates. leaderboard.ts dated a suite by its --newest run only for the size suites, the only ones a newest run had ever written. Moltar's and ata's rows would have been published as measured on 2026-10-24 at 2071002 whatever the run counted. Each kind of result now names its run. Startup. `all --newest` left startup.ts out, because it has no rivals to update: it bundles the repo's own dependencies. That left ArkType's startup rows at 2071002 while every other row moved to the commit measured, and the pull request told the reader to count it by hand and edit leaderboard.ts to publish it. `--newest` now counts it too, into results/newest/startup.json, which leaderboard.ts reads in place of the committed run rather than beside it, since its wins pair every arm by round. run.json records its commit and day. The pull request says its rivals are at the lockfile's versions, not their newest. The dry run built all five suites at today's releases with nothing held back (typia 15.4.1 on ttsc 0.37.2, ata-validator 1.65.0, effect 4.1.4) and ran each of their 722 arms once for real: none failed to load. schemabenchmarks.dev installs ata-validator 1.64.0, not 1.65.0, because its pnpm 11 holds back a release under a day old. `pnpm benchScale` took 71 seconds and 3.4 GB there, and monthly.ts's baseline and report wrote a 22 kB body, past the cut that leaves the raw tables to the artifact.
… failure shares ba691ac gave a failure its errors' summary as `message`, written as `get message()` in the failure's literal so that a consumer reading issues alone writes no summary. That getter is a function of its own for each failure, and V8 kept every failure built that way in dictionary mode: none shared a shape. Building the result then cost more than finding the issues. On schemabenchmarks.dev's invalid product (`~standard.validate`, the result unread; instructions per call on an Apple M5, one case a process as the suite's harness counts them): 2071002, before the message 29,613 854c05a 61,394 here 29,541 with no message at all 25,716 The hosted run behind #1731 counted the same doubling on x86 (29,186 to 61,814), which took the row from 2nd of 17 to 7th. A failure is now `{ issues }` with two properties defined on it: `_s`, a function writing its errors' summary, and `message`, an accessor whose getter is one function for every failure and calls `_s`. It is still the failure's own, enumerable and unwritten until read: Object.keys, a spread and JSON.stringify see it as before, and none of them sees `_s`, which isn't enumerable. `message` is no longer configurable. What it is not, and why: - Not written from `this.issues`. Each errors class writes its own summary, and arktype's writes it in the locale its errors were read in, which the issues don't hold. A summary written from issues alone would be the precompiled runtime's English lines for a Type that traverses under another locale. - Not the errors themselves in `_s`. A failure kept in a reactive store is read through a proxy that wraps each object it returns, and arktype's errors can't tell their own errors through one ("Only errors validation returned can be written again"). A function is returned as it is. For the same proxies `_s` is writable: one may not return another value for a property that is neither writable nor configurable. - Not a WeakMap from the failure or its issues to the errors: 45,900 and 62,800 instructions. - Not one define. Each Object.defineProperty is about 1,900 instructions. A symbol-keyed `_s` in the literal needs only `message` defined and counts 27,200, but the key is enumerable, so it is printed, copied and compared with the failure, and it is 10 bytes more gzipped. Object.defineProperties with both is 31,500. The precompiled runtime builds a failure in arktype/runtime's standardResultOf and arktype in @ark/schema's standardFailureOf, the same eight lines twice. arktype/runtime can't import @ark/schema's without costing bundles that hold neither: esbuild's minifier numbers a bundle's names past each name a live import statement lists, used or not, and one more moved the Valibot login form's export from `lo` to `co`, 917 to 918 bytes gzipped, though the form holds no `~standard`. Written in place the form is byte for byte what it was. Bytes, min / gzip. Unchanged: the Valibot login form 1,871 / 917 (smallest 1,699 / 878) and schemabenchmarks.dev's download 5,568 / 1,547, neither of which holds `~standard`. The homepage's apps, which do: default login 2,333 / 1,140 -> 2,442 / 1,177 moltar 3,003 / 1,188 -> 3,112 / 1,228 shop 20,764 / 5,074 -> 20,873 / 5,115 smallest login 1,934 / 998 -> 2,043 / 1,038 moltar 2,212 / 1,132 -> 2,321 / 1,171 shop 7,774 / 3,420 -> 7,883 / 3,464 Tests: the message isn't written until it's read and every failure's getter is the same function; a failure read through a wrapping proxy writes its message; testV8 holds failures to fast properties and one map, which 854c05a's fail.
…ithout a Map 3e27c4e made errors that wait to be read the class a build writes (findsOnRead), and left every other runtime, a dev server's, an unpruned build's or a library another build precompiled, waiting as before: through a class beside the errors', built at a class's first failure. Before it that class was a module variable for ArkErrors. After it every class's was looked up in a Map on each failing call, and the lookup was nearly half of what a call that leaves its errors unread costs. ArkErrors' class is a module variable again, and the Map holds only the others'. On schemabenchmarks.dev's invalid product (`schema(data)`, the result unread; instructions per call on an Apple M5, one case a process), in the unpruned build the suite's counted arm was: 2071002 132.7 854c05a 254.7 here 138.9 That arm is what the hosted run behind #1731 counted at 261.3 where 2071002's was 144.2, losing the row to zod-compiler's 250.3. A pruned build never ran this code: it folds findsOnRead and holds no class beside its errors', so the Valibot login form (917 B gzipped) and schemabenchmarks.dev's download (1,547) are byte for byte what they were.
…s download arm is The suite has two ArkType arms built apart: the download test's bundle, which reproduce.ts builds with ARK_OPTIONS, and the module every speed row runs, which sb/precompiled/generate.ts builds with tsdown. A tsdown build can't tell the plugin it's a production build, so generate.ts spells out what one defaults to. It listed @ark/aot's productionDefaults and not prune, which a production build also has unless it's set false and which the download arm passes. So the speed rows were counted on a build nobody ships by default: its runtime was arktype's as written, not as a build writes it for what the module reads. Until 3e27c4e the two ran the same code on a failing call. Since it, only a pruned build's errors find their own issues when read, and the unpruned arm paid a lookup per failure (the commit before this one). With prune the arm's "parsing invalid" row counts, on an Apple M5, one case a process: 2071002 132.7 854c05a, unpruned 254.7 here, pruned 145.5 13 instructions over 2071002, about what the deferral's rework was measured to add (11, from 195 to 206 on the moltar app), where the unpruned arm added 122 here and 117 in the hosted run behind #1731. Every other row of the arm is within 0.1% of what it was, and each of its 19 cases still returns what allChild.ts's check expects. Every other counted arm already builds for production, and so prunes: moltar/build.ts, ata/build.ts, sury/bundle.ts, sb/bundle.ts, startup.ts and forms/size.ts all bundle with esbuild's "production" condition, which the plugin reads. None of them changed.
… result The hosted run behind #1731 took 62 minutes to count every library, and what it found wrong was ArkType's: two rows, both fixed in the three commits before this one. Measuring that fix shouldn't mean measuring 668 rival arms again. A rival's count changes with its release, not with the run: that run's host, an Intel Xeon under KVM, counted 0.973 to 1.002 of what the stored i7 did on the 10 schemabenchmarks.dev arms on the same suite commit and release, and 0.999 to 1.001 on the 17 of ArkType's own rows its code hadn't changed. `pnpm benchExternal <suite> --newest --arktype-only`: - installs each suite from its own lockfile, with no rival moved to a newer release, and for moltar's compiles none of the rivals' cases, which ArkType's arms don't load - counts only the arms whose label names ArkType (54 of 722: moltar's 4, schemabenchmarks.dev's 38, Sury's 4, ata's 8). count.ts resumes from its out file, so that file starts as the rivals' stored counts - runs the size scripts as they are, since each measures every library in one pass, and takes only ArkType's entries from what they write (newest.ts's carriedWith, by a label at any depth or an element's libraryName) - counts startup.ts whole: it installs nothing, and its wins pair every arm by round - keeps each suite's day and installs in run.json, which are its rivals', and records ArkType's commit and `arkTypeDate`. The leaderboard's "measured" is unchanged in meaning: the rivals' day and ArkType's commit It throws where results/newest has no run to keep, rather than counting ArkType against nothing. The workflow takes `arktype_only`. The rivals' results it keeps are the last run's, and while that run's pull request is open they are on its branch, not the one measured. So the run reads results/newest from `bench/monthly-standings[-<branch>]` into the working tree, leaving the index at the branch's head: monthly.ts then reports every change from the branch, the rivals' as that run found them and ArkType's as this one did, and publishes all of it to the same branch, so the open pull request is rewritten whole. Where no such branch exists the results are the ones checked in. The pull request says first that only ArkType was measured again, at which commit, and which day's run every rival's result is carried from. run.json's commit is nine digits again. `git rev-parse --short` picks a length by how many objects the clone holds, and the runner's shallow one wrote seven. Dry run on a Mac, with stand-ins for taskset and perf (the stand-in counts the child's retired instructions with proc_pid_rusage) and results/newest read from #1731's branch: 4 minutes 40 seconds against 17 for every library there. Every rival's leaf in every stored file was unchanged but startup.json's, every ArkType count was replaced, no install of a newer release ran, and monthly.ts wrote the body with the carry stated first.
Written by .github/workflows/leaderboard.yml's rerun of the benchmarks a hosted runner measures, with each rival at its newest release: https://github.com/arktypeio/arktype/actions/runs/44620007851. Its pull request says what changed.
…erduster bench: monthly standings
…stalled any more speedChart's bars are typed by hand from moltar's parseSafe counts, and its third bar was @ts-runtypes at 209. Every @ts-runtypes package was removed from npm by 2026-11-19, so the suite no longer builds or counts it (reproduce.ts takes it out of the clone at checkout) and a reader can't install what the chart compares against. The bar is gone and the next rival by count, @sx3/gate at 233, takes the fifth place; the stored counts from 2026-10-24 stay in the result files and in leaderboard.json's tables. ArkType's precompiled bar reads 184, not 185: the recount at 591cc38 has parseSafe at 184.4 (184.6 at 2071002). Typia (213) and ata-validator's AOT build (220) are unchanged as each rival's best stored count. The dynamic bar stays 2071002's 199.6, which the rerun doesn't measure. The header comment said ArkType's instruction counts were 2071002's; since the merge of the rerun they and the size rows are 591cc38's. The regenerated text also regains the '// TypeScript:' error lines in llms-full.txt that the rerun's runner had dropped, having built the docs over package output it hadn't built.
… does, or not at all The run behind #1731 committed an llms-full.txt without eleven lines twoslash adds: ten "// TypeScript: ..." errors and one hover. `pnpm buildDocs` on the same tree put them back (6dc5793). The benchmarks in between had nothing to do with it: at a clean, fully built checkout, with no benchmark run, node -e 'import("./ark/docs/lib/writeMarkdown.ts").then(m => m.writeMarkdown())' from the repo root, which is what monthly.ts ran, drops the same eleven lines in about a second, and from ark/docs it changes nothing. Two things had to line up. twoslash resolves a snippet's imports from its vfsRoot, which defaults to process.cwd(). arktype and its companions are installed under ark/docs/node_modules and not at the repo root, so from the root none of them resolved and every snippet's types were `any`. `next build` starts in the docs, so the docs build never saw it. The twoslasher now names the docs as its root, whatever directory the process started in. The guard from 0c6d0c9 did catch it: it threw "const User: ..." has no type for the first snippet. But codeForMarkdown only rethrows in a production build, so that a broken snippet doesn't take down `next dev`, and otherwise writes the snippet with its twoslash directives stripped. monthly.ts never set NODE_ENV, so every snippet with `// @errors` or `// ^?` was quietly written without what twoslash adds. The baseline step wrote the same degraded text, so the files the numbers didn't touch (docs/regex/llms.txt, which loses its hovers the same way) compared as unmoved and were restored, and only llms-full.txt, which the numbers did change, was committed with the loss. monthly.ts now writes the text as next.config.ts has it written: in ark/docs and with NODE_ENV=production. A snippet whose types don't resolve, or a page tree with errors, fails writeMarkdown there, and the pull request's body says the text was "Not written again" and that the run's log has why, as it already did for a writeMarkdown that failed. Checked by running the steps in a temp dir with twoslash's cache cleared: - `monthly.ts baseline` keeps nothing, where before it kept llms-full.txt and docs/regex/llms.txt - `monthly.ts report` after changing one number in presetScale.json writes no checked-in text differently - the same with ark/type/out/index.d.ts hidden leaves the text as checked in and the body reads "Not written again" The new test in markdown.test.ts is the first snippet that lost its error. Mocha starts at the repo root, so without the vfsRoot it fails on a cold cache, as CI's is. A warm one (ark/docs/node_modules/.cache/ark-docs/twoslash) hides it, since a result's key doesn't have the directory in it and a degraded result is never cached.

Based on 2.2.7 (1ee4923): 565 commits, 189 files. A draft for review by area; the history gets rewritten into reviewable ranges after review.
Suggested reading order (each a
git diff 1ee4923b..featherduster -- <paths>):ark/util,ark/regexarksetspackage:ark/sets,ark/schema/shared/{intersections,sets}.ts(git diff 3166b30ab featherduster -- ark/setsshows what changed after the verbatim move)@ark/schemacore and perf, excluding cycles and Transformclone:ark/schema/shared/transform.tsark/type(public API, lazy keywords,ArkErrorsno longer extends Array, CHANGELOG)ark/repo/{bundle,build,testBuild,publish}.ts, per-packageinternal.tsark/schema/roots/alias.ts,ark/schema/generic.ts,ark/schema/shared/utils.ts,ark/type/__tests__/cyclic*(a rewrite follows as its own PR)ark/docsKnown before review:
allowsthrows a RangeError on valid rings from 38 members (12 jitless).Issues this closes
Each was verified against this branch by a test or probe.
Closes #1121
Closes #1473
Closes #1306
Closes #1470
Closes #1529
Closes #1555
Closes #1548
Closes #1530
Closes #1577
Closes #1430
Closes #1600
Closes #1676
Closes #1445
Closes #1160
Closes #1023
Closes #579
Closes #928
Closes #930
Closes #944
Closes #1026
Closes #1630
Closes #1237
Closes #1082
Closes #1476
Closes #1486
Closes #1587
Closes #1437
Closes #1457
Closes #961
Closes #1380
Closes #1543
Closes #1568
Closes #1598
Closes #1370
Closes #1403
Closes #909
Closes #1485
Closes #810
Closes #1498
Closes #1243
Closes #1273
Closes #1481
Closes #1412
Closes #1532
Closes #1490
Closes #1390
Closes #1575
Closes #1492
Closes #1479
Closes #1337
Closes #1310
Closes #1663
Closes #1525
Closes #1448
Closes #1435
Closes #1491
Closes #1287
Closes #963
Closes #1524
Closes #1571
Closes #1475
Closes #1554
Closes #925
Closes #751
Closes #1707
Closes #1720
Closes #1719
Closes #1724
Closes #1469
Refs #1462
Thanks to @RaphaelFakhri (#1721), @louisss1016 (#1722), @RClaudiuM (#1725), @SynthLuvr (#1715), @lprnmns (#1705) and @ybai08 (#1695), whose PRs these fixes started from.