@orkestrel/contract 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/index.cjs +183 -27
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +107 -20
- package/dist/src/core/index.d.ts +107 -20
- package/dist/src/core/index.js +180 -28
- package/dist/src/core/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/helpers.ts","../../../src/core/JSONCloner.ts","../../../src/core/SchemaCloner.ts","../../../src/core/ShapePass.ts","../../../src/core/ShapeValidator.ts","../../../src/core/ShapeCloner.ts","../../../src/core/cloners.ts","../../../src/core/LazyGuard.ts","../../../src/core/combinators.ts","../../../src/core/parsers.ts","../../../src/core/EvaluationScope.ts","../../../src/core/RandomSource.ts","../../../src/core/seeders.ts","../../../src/core/ContractCompiler.ts","../../../src/core/compilers.ts","../../../src/core/LazyContract.ts","../../../src/core/factories.ts","../../../src/core/ValueInferer.ts","../../../src/core/SampleInferer.ts","../../../src/core/inferers.ts","../../../src/core/SchemaShaper.ts","../../../src/core/FaultShaper.ts","../../../src/core/shapers.ts"],"sourcesContent":["import type {\n\tContractCode,\n\tContractShape,\n\tFaultConstraint,\n\tFaultKind,\n\tJSONSchemaType,\n} from './types.js'\n\n/**\n * Lists the fields recognized for every contract declaration category, frozen.\n *\n * @example\n * ```ts\n * SHAPE_FIELDS.shape // ['description']\n * ```\n */\nexport const SHAPE_FIELDS: Readonly<Record<string, readonly string[]>> = Object.freeze({\n\tstring: Object.freeze(['min', 'max', 'pattern', 'description']),\n\tnumber: Object.freeze(['integer', 'min', 'max', 'description']),\n\tboolean: Object.freeze(['description']),\n\tnull: Object.freeze(['description']),\n\tliteral: Object.freeze(['values', 'description']),\n\tarray: Object.freeze(['items', 'min', 'max', 'description']),\n\tobject: Object.freeze(['properties', 'additionalProperties', 'description']),\n\tunion: Object.freeze(['variants', 'mode', 'description']),\n\toptional: Object.freeze(['inner', 'default']),\n\tnullable: Object.freeze(['inner']),\n\tjson: Object.freeze(['description']),\n\traw: Object.freeze(['schema']),\n\tshape: Object.freeze(['description']),\n} satisfies Record<ContractShape['category'], readonly string[]>)\n\n/**\n * Holds the registry-global key used to recognize {@link ContractError} values\n * across package copies.\n *\n * @remarks\n * The descriptor stores the branded value itself. Recognition compares that\n * identity, so a transparent proxy cannot forward its target's brand as its\n * own. The registry makes the key discoverable; it is a recognition mechanism,\n * not an unforgeable provenance marker.\n */\nexport const CONTRACT_ERROR_BRAND = Symbol.for('@orkestrel/contract.ContractError')\n\n// === Captured host operations\n\n/**\n * Captures every host operation this package dispatches through, while this\n * module evaluates.\n *\n * @remarks\n * THE answer to a defect class that mutated four times before anyone stated it\n * as a class. A caller can replace a global constructor, a static, a prototype\n * member, or a symbol-keyed hook, and a replacement can fail by THROWING, which\n * a boundary contains, or by LYING, which no boundary can\n * see. `Object.freeze = (value) => value` lies, and that is the\n * worse failure: every cloner succeeds, publishes a mutable graph, and the caller\n * cannot tell that the package's central guarantee evaporated.\n *\n * Containment cannot close that, because there is nothing to contain — only\n * capture can, and only capture taken while this module evaluates. A module's\n * initializers run at import, so a reference read here is whatever was\n * installed at the moment THIS module evaluated, and reading it later, at the\n * call site, is reading whatever the caller most recently installed. \"Before any\n * caller code runs\" is the tempting phrasing and it is false in exactly the case\n * the limit below names, so it is not used.\n *\n * The limit that follows, stated as a limit rather than as a guarantee: capture\n * is only as early as this package's own evaluation. A consumer module that\n * evaluates BEFORE `@orkestrel/contract` — ESM evaluates imports in source\n * order — chooses what this table captures, and no mechanism inside the package\n * can reach code that ran before the package existed. That precondition is\n * outside this package's control, and an adversary who holds it can replace the\n * package wholesale rather than bother with the table, so it is named here\n * instead of defended.\n *\n * Membership rule, stated so a reviewer can apply it and a new call site knows\n * where to go: **every host operation this package dispatches by name whose\n * result a published answer depends on.** That admits statics, constructors and\n * namespaces, and — this is the part the earlier wording got wrong by writing\n * the rule from the rows instead of the rows from the rule — it admits a\n * PROTOTYPE member on the same terms, including an ACCESSOR's getter,\n * dispatched onto the package's own receiver through {@link INTRINSICS.reflect.apply}.\n * A round that read `Object.getOwnPropertyDescriptor(RegExp.prototype, 'source')`\n * per call had captured nothing: capture is decided by WHEN the reference is\n * taken, not by which reflective spelling takes it.\n *\n * Collection membership needs a data structure rather than one operation, and\n * answering it from an exported class's `has` method reproduces the whole defect\n * one prototype higher, because every consumer can rewrite that method. The rule\n * has no exception\n * for it: `Set.prototype.has` / `.add` / `.forEach`,\n * `Map.prototype.has` / `.forEach`, and\n * `WeakSet.prototype.has` / `.add` / `.delete` are ordinary rows here, dispatched\n * onto collections this package built and no caller holds, and every membership\n * and visitation answer in the package is asked through the module-scope\n * functions {@link matchesMember} / {@link admitMember} /\n * {@link matchesVisited} / {@link admitVisited} / {@link omitVisited}. A module\n * binding is not a property, so there is no member on that path to replace.\n *\n * The walk-collection exclusion the earlier wording carried — \"a redirect\n * corrupts it inside a boundary and the door refuses, which is loud\" — was\n * false in the direction the corpus itself installs. `WeakSet.prototype.has`\n * answering `false` does not make a cyclic clone refuse; it removes the\n * termination bound, and a door that never returns is the one failure no\n * boundary can report. Visitation state is captured here for that reason.\n *\n * @example\n * ```ts\n * INTRINSICS.freeze(snapshot) // the genuine Object.freeze, whatever the caller installed\n * ```\n */\nexport const INTRINSICS = Object.freeze({\n\t/** Captures `Object.freeze` — the operation the ownership guarantee is made of. */\n\tfreeze: Object.freeze,\n\t/** Captures `Object.isFrozen` — the independent check that the guarantee actually held. */\n\tfrozen: Object.isFrozen,\n\t/** Captures `Object.keys` — the own enumerable string-key population of a snapshot. */\n\tkeys: Object.keys,\n\t/** Captures `Object.values` — the own enumerable value population of a snapshot. */\n\tvalues: Object.values,\n\t/** Captures `Object.hasOwn` — own presence, so no read leaves a container for its prototype. */\n\town: Object.hasOwn,\n\t/** Captures `Object.is` — `SameValue`, so a `NaN` or signed-zero comparison stays exact. */\n\tsame: Object.is,\n\t/** Captures `Object.create` — the null-prototype and prototype-pinned accumulators. */\n\tcreate: Object.create,\n\t/** Captures `Proxy` for non-array indexed views. */\n\tproxy: Proxy,\n\t/** Captures `Object.getOwnPropertyDescriptor` — value observation that runs no accessor. */\n\tdescribe: Object.getOwnPropertyDescriptor,\n\t/** Captures `Object.defineProperty` — exact placement of an own data property. */\n\tdefine: Object.defineProperty,\n\t/** Captures `Object.defineProperties` — sparse snapshot construction. */\n\tdefinitions: Object.defineProperties,\n\t/** Captures `Object.getPrototypeOf` — the record-brand observation. */\n\tprototype: Object.getPrototypeOf,\n\t/** Captures `Object.getOwnPropertySymbols` — the own-symbol population. */\n\tsymbols: Object.getOwnPropertySymbols,\n\t/** Captures `Object.prototype` — the realm-local plain-record prototype identity. */\n\tbase: Object.prototype,\n\t/**\n\t * Captures the proxy-visible operations, grouped because that is what separates them:\n\t * each reports the trap's exact answer where `Object`'s flat peer above\n\t * reports the target's.\n\t *\n\t * @remarks\n\t * Frozen on its own, so the sub-entity is as immutable as the table holding\n\t * it. `describe`, `define`, and `prototype` name the same operations their\n\t * flat peers name, and the group is what tells a reader which of the two a\n\t * call site asked for.\n\t */\n\treflect: Object.freeze({\n\t\t/** Captures `Reflect.get` — a proxy-visible read that reports the trap's exact answer. */\n\t\tread: Reflect.get,\n\t\t/** Captures `Reflect.set` — a proxy-visible write. */\n\t\twrite: Reflect.set,\n\t\t/** Captures `Reflect.ownKeys` — the complete own-key population, strings and symbols. */\n\t\tmembers: Reflect.ownKeys,\n\t\t/** Captures `Reflect.has` — a proxy-visible presence observation. */\n\t\tpresent: Reflect.has,\n\t\t/** Captures `Reflect.getOwnPropertyDescriptor` — the reflective descriptor observation. */\n\t\tdescribe: Reflect.getOwnPropertyDescriptor,\n\t\t/** Captures `Reflect.defineProperty` — placement that answers instead of throwing. */\n\t\tdefine: Reflect.defineProperty,\n\t\t/** Captures `Reflect.getPrototypeOf` — the reflective prototype observation. */\n\t\tprototype: Reflect.getPrototypeOf,\n\t\t/** Captures `Reflect.apply` — dispatch of a captured method onto its receiver. */\n\t\tapply: Reflect.apply,\n\t\t/** Captures `Reflect.construct` — construction with an explicit new target. */\n\t\tconstruct: Reflect.construct,\n\t}),\n\t/** Captures `Number.isFinite` — the finite-bound test every numeric shape refuses on. */\n\tfinite: Number.isFinite,\n\t/** Captures `Number.isInteger` — the integer-budget test the inference caps refuse on. */\n\tinteger: Number.isInteger,\n\t/** Captures `Number.isSafeInteger` — the safe-integer test every length bound refuses on. */\n\tsafe: Number.isSafeInteger,\n\t/** Captures `Number.isNaN` — the calendar-validity test for a parsed instant. */\n\tnan: Number.isNaN,\n\t/** Captures `Array.isArray` — array identity across realms. */\n\tarray: Array.isArray,\n\t/** Captures `JSON.stringify` — the escaping used by previews and canonical text. */\n\tstringify: JSON.stringify,\n\t/** Captures `JSON.parse` — document decoding. */\n\tdecode: JSON.parse,\n\t/** Captures `Math.floor` — index and quantity flooring. */\n\tfloor: Math.floor,\n\t/** Captures `Math.ceil` — index and quantity ceiling. */\n\tceil: Math.ceil,\n\t/** Captures `Math.max` — bound selection. */\n\tmax: Math.max,\n\t/** Captures `Math.min` — bound selection. */\n\tmin: Math.min,\n\t/** Captures `Math.imul` — the seeded generator's mixing step. */\n\timul: Math.imul,\n\t/** Captures `String` — primitive text coercion. */\n\ttext: String,\n\t/** Captures `Number` — primitive numeric coercion. */\n\tnumeric: Number,\n\t/** Captures `RegExp` — pattern construction from captured source and flags. */\n\tpattern: RegExp,\n\t/**\n\t * Captures `RegExp.prototype.exec` — THE pattern membership answer, dispatched through\n\t * `apply`.\n\t *\n\t * @remarks\n\t * `test` is deliberately absent. `RegExp.prototype.test` is spec-defined in\n\t * terms of `RegExpExec`, which re-reads `exec` OFF THE RECEIVER and calls it\n\t * when it is callable, so capturing `test` and dispatching it still asks\n\t * whatever the caller installed on `RegExp.prototype.exec`. Only\n\t * `RegExp.prototype.exec` itself is `RegExpBuiltinExec`, which reads the\n\t * pattern's internal slots and no member at all. A capture that still routes\n\t * through the replaced member is not a capture.\n\t */\n\tcaptures: RegExp.prototype.exec,\n\t/** Captures the `RegExp.prototype.source` getter — the pattern text a published schema embeds, dispatched through `apply`. */\n\texpression: Object.getOwnPropertyDescriptor(RegExp.prototype, 'source')?.get,\n\t/** Captures the `RegExp.prototype.flags` getter — the flag text an owned pattern is rebuilt from, dispatched through `apply`. */\n\tmodifiers: Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags')?.get,\n\t/** Captures `Array` — array construction. */\n\tlist: Array,\n\t/** Captures `Array.prototype.sort` — the deterministic ordering every published schema is emitted in, dispatched through `apply`. */\n\torder: Array.prototype.sort,\n\t/** Captures `Array.prototype.some` for short-circuit membership checks. */\n\tsome: Array.prototype.some,\n\t/** Captures `Array.prototype.findIndex`, including reads of sparse positions. */\n\tfind: Array.prototype.findIndex,\n\t/** Captures `Array.prototype.forEach` for indexed visits of owned arrays. */\n\teach: Array.prototype.forEach,\n\t/** Captures `Array.from` for ordered array construction. */\n\tfrom: Array.from,\n\t/** Captures `Array.prototype.reduce` for derived aggregate values. */\n\tfold: Array.prototype.reduce,\n\t/** Captures `Iterator.prototype.reduce` — ordered lazy reduction. */\n\treduce: Iterator.prototype.reduce,\n\t/** Captures `Array.prototype.filter` for derived selections. */\n\tselect: Array.prototype.filter,\n\t/** Captures `Array.prototype.map` for derived projections. */\n\tproject: Array.prototype.map,\n\t/** Captures `Array.prototype.flatMap` — ordered list expansion. */\n\texpand: Array.prototype.flatMap,\n\t/** Captures `Array.prototype.toReversed` — reverse-order derivation. */\n\tflip: Array.prototype.toReversed,\n\t/** Captures `Array.prototype.values` for owned iterable construction. */\n\titerator: Array.prototype.values,\n\t/** Captures `Array.prototype.keys` — an indexed cursor that reads length per step. */\n\tindices: Array.prototype.keys,\n\t/** Captures the native array iterator advance operation. */\n\tadvance: Object.getPrototypeOf([][Symbol.iterator]()).next,\n\t/** Captures `Array.prototype.join` — text assembly from derived parts. */\n\tjoin: Array.prototype.join,\n\t/** Captures `Function.prototype.bind` for a receiver-bound host operation. */\n\tbind: Function.prototype.bind,\n\t/** Captures `Object.fromEntries` for derived records. */\n\trecord: Object.fromEntries,\n\t/** Captures `Object.setPrototypeOf` for owned record prototypes. */\n\trebase: Object.setPrototypeOf,\n\t/** Captures `Map` — keyed working state. */\n\tmap: Map,\n\t/** Captures `Map.prototype.get` — a memo read whose answer a published graph embeds, dispatched through `apply`. */\n\tfetch: Map.prototype.get,\n\t/** Captures `Map.prototype.set` — a memo write a published graph is later assembled from, dispatched through `apply`. */\n\tstore: Map.prototype.set,\n\t/** Captures `Map.prototype.has` — a memo presence answer that decides whether a node is captured, dispatched through `apply`. */\n\tkeyed: Map.prototype.has,\n\t/** Captures `Map.prototype.forEach` — the only full view of a caller's `Map` that runs no iterator, dispatched through `apply`. */\n\tpairs: Map.prototype.forEach,\n\t/** Captures `Set` — membership working state. */\n\tset: Set,\n\t/** Captures `Set.prototype.union` — construction without a live `add` dispatch. */\n\tunion: Set.prototype.union,\n\t/** Captures `Set.prototype.has` — THE membership answer every published verdict rests on, dispatched through `apply`. */\n\tmember: Set.prototype.has,\n\t/** Captures `Set.prototype.add` — collection of one more member, dispatched through `apply`. */\n\tadmit: Set.prototype.add,\n\t/** Captures `Set.prototype.forEach` — the only full view of a caller's `Set` that runs no iterator, dispatched through `apply`. */\n\tsweep: Set.prototype.forEach,\n\t/** Captures `Set.prototype.delete` — settlement of an active operation. */\n\tremove: Set.prototype.delete,\n\t/** Captures `WeakMap` — object-keyed working state. */\n\tweakMap: WeakMap,\n\t/** Captures `WeakMap.prototype.get` — an object-keyed memo read a published graph embeds, dispatched through `apply`. */\n\trecall: WeakMap.prototype.get,\n\t/** Captures `WeakMap.prototype.set` — an object-keyed memo write, dispatched through `apply`. */\n\tretain: WeakMap.prototype.set,\n\t/** Captures `WeakSet` — object-membership working state. */\n\tweakSet: WeakSet,\n\t/** Captures `WeakSet.prototype.has` — the visitation answer every traversal's termination rests on, dispatched through `apply`. */\n\ttracked: WeakSet.prototype.has,\n\t/** Captures `WeakSet.prototype.add` — entry onto the active path, dispatched through `apply`. */\n\ttrack: WeakSet.prototype.add,\n\t/** Captures `WeakSet.prototype.delete` — exit from the active path, dispatched through `apply`. */\n\tuntrack: WeakSet.prototype.delete,\n\t/** Captures `Error` — the internal marker an engine throws into its own contained walk. */\n\terror: Error,\n\t/** Captures `Date` — calendar validation of an ISO instant. */\n\tdate: Date,\n\t/** Captures `Date.prototype.getTime` — the calendar verdict a published `format` rests on, dispatched through `apply`. */\n\tinstant: Date.prototype.getTime,\n\t/** Captures `Date.now` — the wall-clock reading a default generator seed is drawn from. */\n\tnow: Date.now,\n})\n\n// JSON-related constants. Kept as plain frozen data so the shipped combinators\n// and parsers operate on them directly — there is deliberately no bespoke\n// JSON-Schema guard (`.claude/rules/patterns.md` § Validation and contracts — the\n// deep recursive validators stay out by design).\n\n/**\n * Lists the seven standard JSON Schema `type` names, frozen.\n *\n * @remarks\n * The runtime source of truth for the {@link JSONSchemaType} vocabulary. Compose\n * it with the shipped primitives instead of reaching for a bespoke guard:\n * `literalOf(...JSON_SCHEMA_TYPES)` is the guard, and\n * `parseEnum(value, JSON_SCHEMA_TYPES)` / `parseEnumField(record, path, JSON_SCHEMA_TYPES)`\n * is the parser.\n *\n * @example\n * ```ts\n * import { JSON_SCHEMA_TYPES, literalOf, parseEnumField } from '@orkestrel/contract'\n *\n * const isSchemaType = literalOf(...JSON_SCHEMA_TYPES) // Guard<JSONSchemaType>\n * parseEnumField(schema, 'type', JSON_SCHEMA_TYPES) // JSONSchemaType | undefined\n * ```\n */\nexport const JSON_SCHEMA_TYPES: readonly JSONSchemaType[] = Object.freeze([\n\t'null',\n\t'boolean',\n\t'object',\n\t'array',\n\t'number',\n\t'integer',\n\t'string',\n])\n\n/**\n * Lists the JSON Schema keywords a strict `schemaToShape` conversion reads, frozen.\n *\n * @remarks\n * The keywords a shape can honour, plus the annotations that assert nothing and so\n * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,\n * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.\n * `pattern` and `format` are absent because no compiled shape asserts them, so a\n * schema holding one would convert to a shape wider than the schema it came from.\n *\n * @example\n * ```ts\n * STRICT_SCHEMA_KEYWORDS.includes('title') // true\n * STRICT_SCHEMA_KEYWORDS.includes('pattern') // false\n * ```\n */\nexport const STRICT_SCHEMA_KEYWORDS: readonly string[] = Object.freeze([\n\t'type',\n\t'title',\n\t'description',\n\t'$schema',\n\t'$id',\n\t'$comment',\n\t'examples',\n\t'deprecated',\n\t'readOnly',\n\t'writeOnly',\n\t'default',\n\t'enum',\n\t'minLength',\n\t'maxLength',\n\t'minimum',\n\t'maximum',\n\t'minItems',\n\t'maxItems',\n\t'items',\n\t'properties',\n\t'required',\n\t'additionalProperties',\n\t'anyOf',\n\t'oneOf',\n])\n\n/**\n * Lists every declared {@link ContractCode} refusal category, frozen.\n *\n * @remarks\n * The runtime source of truth for the {@link ContractCode} vocabulary, and the\n * one list every membership test over it reads: `readValue` decides from it\n * whether a caller-supplied code is declared, and `isContractError` decides\n * from it whether a candidate error carries a declared one. A code added to the\n * union is added here, so neither test can drift from the type or from the\n * other.\n *\n * @example\n * ```ts\n * import { CONTRACT_CODES, literalOf } from '@orkestrel/contract'\n *\n * const isContractCode = literalOf(...CONTRACT_CODES) // Guard<ContractCode>\n * ```\n */\nexport const CONTRACT_CODES: readonly ContractCode[] = Object.freeze([\n\t'bound',\n\t'range',\n\t'empty',\n\t'placement',\n\t'structure',\n\t'literal',\n\t'cycle',\n\t'pattern',\n\t'generate',\n\t'random',\n\t'clone',\n\t'depth',\n\t'expansion',\n])\n\n/**\n * Lists every {@link FaultKind}, frozen.\n *\n * @remarks\n * The runtime source of truth for the vocabulary, which {@link isFault} reads.\n *\n * @example\n * ```ts\n * FAULT_KINDS.includes('string') // true\n * ```\n */\nexport const FAULT_KINDS: readonly FaultKind[] = Object.freeze([\n\t'string',\n\t'number',\n\t'integer',\n\t'boolean',\n\t'null',\n\t'literal',\n\t'array',\n\t'object',\n\t'union',\n\t'json',\n\t'shape',\n])\n\n/**\n * Lists every {@link FaultConstraint}, frozen.\n *\n * @remarks\n * The runtime source of truth for the vocabulary, which {@link isFault} reads.\n *\n * @example\n * ```ts\n * FAULT_CONSTRAINTS.includes('min') // true\n * ```\n */\nexport const FAULT_CONSTRAINTS: readonly FaultConstraint[] = Object.freeze([\n\t'min',\n\t'max',\n\t'pattern',\n\t'integer',\n])\n\n// Reporting-surface bounds (`compileReporter` / `compileAuditor` —\n// `ContractInterface.explain` / `ContractInterface.audit`).\n\n/**\n * Caps at `64` the number of {@link Fault} / {@link AuditFault} entries a single\n * `explain` or `audit` report ever returns, frozen.\n *\n * @remarks\n * Bounds BOTH reports against adversarial input (a giant array, a wide record)\n * — `compileReporter` and `compileAuditor` each collect faults in stable\n * pre-order and stop once this cap is reached, and every recursive call slices\n * to it, so the report size (and the work to build it) stays finite and\n * deterministic at every nesting level regardless of the input's size. Size a\n * diagnostic surface off this constant and it bounds `audit` exactly as it\n * bounds `explain`.\n */\nexport const FAULT_LIMIT = 64\n\n/**\n * Caps at `64` the character length of a {@link preview}-rendered string, frozen.\n *\n * @remarks\n * A previewed string longer than this is clipped with a trailing `…` so a\n * {@link Fault}'s `received` field never embeds an unbounded amount of\n * untrusted text.\n */\nexport const PREVIEW_LIMIT = 64\n\n// Runtime recursion and generation bounds.\n\n/**\n * Caps the active recursion or JSON container depth for runtime guards, frozen.\n *\n * @remarks\n * Bounds explicitly recursive guards before the JavaScript call stack becomes\n * the limiting mechanism. It also caps array/plain-record containers on each\n * active path inspected by {@link matchesJSONDepth}: noncontainers are depth\n * zero, an empty container is depth one, 512 containers pass, and the 513th\n * fails. Active cycle edges do not add a level.\n *\n * @example\n * ```ts\n * GUARD_DEPTH_LIMIT // 512\n * ```\n */\nexport const GUARD_DEPTH_LIMIT = 512\n\n/**\n * Caps at `512` the supported nesting depth of a compiled contract shape, frozen.\n *\n * @remarks\n * {@link validateShape} rejects the next level\n * with a depth-coded {@link ContractError} before recursive artifact\n * compilation begins, so a finite but pathologically deep developer-authored\n * shape fails predictably instead of reaching the JavaScript call-stack limit.\n *\n * @example\n * ```ts\n * COMPILE_DEPTH_LIMIT // 512\n * ```\n */\nexport const COMPILE_DEPTH_LIMIT = 512\n\n/**\n * Caps at `16384` the number of nodes a compiled artifact may expand a shape into,\n * frozen.\n *\n * @remarks\n * A shape graph is a DAG; every compiled artifact is a TREE. A declaration may\n * therefore be tiny and its schema, guard, parser, reporter, auditor and\n * generated value enormous: `objectShape({ left: node, right: node })` nested\n * thirty times is thirty-one authored nodes that expand into more than a\n * billion emitted ones. Sharing one child is ordinary authoring, not an attack,\n * and the compilers cannot fold the expansion away without publishing a schema\n * whose members alias each other.\n *\n * So the cost is BOUNDED rather than paid. {@link validateShape} and\n * {@link ContractCompiler} preparation both count the nodes the declaration\n * expands into (one per node, summed over every incoming edge) and refuse past\n * this cap through {@link refuseExpansion}, with an `expansion`-coded\n * {@link ContractError}. Ownership is deliberately NOT bounded by it:\n * {@link cloneShape} and {@link ownShape} preserve shared-child identity, so\n * they answer a shared-child graph in time proportional to its authored nodes\n * and keep working above this cap.\n *\n * This cap does not bound compilation, because the compilers do not expand a\n * DAG. Every artifact family is one entry per unique node, so the boundary\n * declaration above compiles its unique nodes in about a millisecond.\n * What does expand is what a CONSUMER materializes from the artifacts: the\n * value `generate` builds, and the document a compiled schema serializes to,\n * are trees of exactly this size. The cap survives as a bound on what a caller\n * can be handed, not on what the compiler pays.\n *\n * @example\n * ```ts\n * COMPILE_NODE_LIMIT // 16384\n * ```\n */\nexport const COMPILE_NODE_LIMIT = 16_384\n\n/**\n * Caps at `31` the number of object keys one compiled presence mask carries, frozen.\n *\n * @remarks\n * A compiled object plan decides which declared keys a value carries. The keys\n * it asks about are fixed when the plan is built, so the plan assigns each one a\n * bit position once and a call ORs one bit per own key it finds and compares the\n * result against the full mask — no per-call collection, and one integer compare\n * instead of one membership dispatch per declared key.\n *\n * The bound is the width a JavaScript bitwise operand has: `1 << position`\n * evaluates on a 32-bit signed integer, so positions run `0` through `30` and a\n * mask stays positive. A declaration with more keys than this is ordinary\n * authoring rather than an attack, so it is answered rather than refused:\n * {@link ContractCompiler} builds no position record for it and its compiled\n * guard, parser, auditor, and reporter decide presence from a collected key\n * vocabulary instead. Both branches answer identically; only the cost differs.\n *\n * @example\n * ```ts\n * PRESENCE_MASK_LIMIT // 31\n * ```\n */\nexport const PRESENCE_MASK_LIMIT = 31\n\n/**\n * Caps at `262144` the number of nodes one JSON snapshot may produce, frozen.\n *\n * @remarks\n * JSON persistence is a TREE, so `cloneJSONValue` / `cloneJSONRecord`\n * deliberately duplicate a repeated noncyclic alias into distinct equal\n * branches — `clone.primary !== clone.fallback` is a documented guarantee, not\n * an accident, and a memo would silently take it away. The price of that\n * guarantee is that output size is exponential in the number of shared aliases:\n * an ordinary in-memory graph of twenty-one objects, a few hundred bytes,\n * produced two million nodes and took seconds, and thirty aliases took hours.\n * No attacker is needed — shared references are normal data.\n *\n * So the cost is BOUNDED rather than paid: the walk counts the nodes it\n * produces and refuses past this cap with the ordinary cause-free `clone`\n * refusal, which makes the door's worst case a function of this constant\n * instead of the caller's input. Size a snapshot against it: a document with\n * more than this many nodes — counting every array, record, and leaf the\n * snapshot would contain AFTER alias duplication — is refused rather than\n * cloned.\n *\n * @example\n * ```ts\n * CLONE_NODE_LIMIT // 262144\n * ```\n */\nexport const CLONE_NODE_LIMIT = 262_144\n\n/**\n * Caps at `32` the number of candidate-generation attempts for a constrained generated\n * value, frozen.\n *\n * @remarks\n * Provides one deterministic work bound for generators that must retry a\n * candidate against a contract constraint.\n *\n * @example\n * ```ts\n * GENERATION_ATTEMPT_LIMIT // 32\n * ```\n */\nexport const GENERATION_ATTEMPT_LIMIT = 32\n\n// Value-to-schema inference bounds (`valueToSchema` / `samplesToSchema`).\n\n/**\n * Caps at `32` the object/array nesting depth {@link valueToSchema} walks, frozen.\n *\n * @remarks\n * Bounds inference against adversarial or cyclic runtime input — once the\n * remaining depth budget reaches zero, inference stops descending and emits\n * the empty accept-anything schema `{}` for that branch instead of recursing\n * further. LOWERABLE per call through {@link ValueToSchemaLimits.depth}; a\n * higher value is held here.\n *\n * A ceiling rather than a default, because the walk recurses: what a deeper\n * walk spends is the JavaScript call stack rather than this budget, and that\n * stack is not a fixed quantity. The survivable depth measured on one host rose\n * across repeated calls within a single process as the engine optimized, and\n * fell to roughly this number under a reduced stack size. Any larger constant\n * therefore has a host where it fails, which is why none is published.\n */\nexport const INFER_DEPTH_LIMIT = 32\n\n/**\n * Caps by default at `256` the number of object properties / array elements {@link\n * valueToSchema} samples per container, frozen.\n *\n * @remarks\n * Bounds the work (and the emitted schema's size) against a wide record or a\n * huge array — properties/elements beyond this cap are never inspected.\n * Overridable per call through {@link ValueToSchemaLimits.properties}.\n */\nexport const INFER_BREADTH_LIMIT = 256\n\n/**\n * Caps by default at `12` the number of distinct values a multi-sample slot may hold\n * before enum inference gives up and falls back to a bare `type`, frozen.\n *\n * @remarks\n * Bounds how large an `enum` list {@link samplesToSchema} will emit — a slot with distinct-value count at or above this limit is\n * treated as unbounded (an ID column, not a category) and never gets an\n * `enum` keyword. Overridable per call through {@link ValueToSchemaOptions.enum}\n * (which gates whether enum inference runs at all).\n */\nexport const INFER_ENUM_LIMIT = 12\n\n/**\n * Caps at `128` the string length {@link stringToFormat} attempts to classify, frozen.\n *\n * @remarks\n * Bounds per-string format-detection work: a value longer than this returns\n * `undefined` immediately, before any pattern match runs. 128 sits\n * comfortably above the longest real format token — an RFC 3339 date-time\n * with fractional seconds and a UTC offset — so no legitimate classification\n * changes; only pathologically long strings (a multi-megabyte payload passed\n * as a candidate email/URI) are skipped.\n */\nexport const FORMAT_MAX_LENGTH = 128\n\n/**\n * Holds the pure-regex matchers backing {@link stringToFormat}'s pattern-only\n * formats (`uuid` / `email` / `uri`), frozen as data.\n *\n * @remarks\n * The ISO-8601 date/time formats are NOT listed here — they additionally\n * require an attempt-guarded `Date` validity check, so their pattern lives\n * inline in `stringToFormat` rather than as reusable standalone data.\n */\nexport const FORMAT_PATTERNS: Readonly<Record<'uuid' | 'email' | 'uri', RegExp>> = Object.freeze({\n\tuuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n\temail: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\n\turi: /^[a-z][a-z0-9+.-]*:\\/\\//i,\n})\n\n// Schema retention limits, declared for a package whose schema retains authored data.\n\n/**\n * Caps at `1024` the number of choices one schema field may offer, frozen.\n *\n * @remarks\n * A retention limit that a declaring package, such as a form or table schema\n * package, enforces; this package enforces none of the retention limits itself.\n *\n * @example\n * ```ts\n * CHOICE_LIMIT // 1024\n * ```\n */\nexport const CHOICE_LIMIT = 1024\n\n/**\n * Caps at `128` the length, in UTF-16 code units, of one name a schema declares, frozen:\n * a schema, group, or field name, or a column key.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * NAME_LIMIT // 128\n * ```\n */\nexport const NAME_LIMIT = 128\n\n/**\n * Caps at `65536` the length, in UTF-16 code units, of any single string one schema\n * retains, frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * STRING_LIMIT // 65536\n * ```\n */\nexport const STRING_LIMIT = 65_536\n\n/**\n * Caps at `1048576` the total length, in UTF-16 code units, of every string one schema\n * retains, frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * TEXT_LIMIT // 1048576\n * ```\n */\nexport const TEXT_LIMIT = 1_048_576\n\n/**\n * Caps at `16384` the total number of records, arrays, and leaves one schema retains,\n * frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * NODE_LIMIT // 16384\n * ```\n */\nexport const NODE_LIMIT = 16_384\n\n/** Caps a fault message at 2048 UTF-16 code units. */\nexport const FAULT_TEXT_LIMIT = 2048\n\n/** Caps the keys or literal candidates named in a fault line. */\nexport const FAULT_LIST_LIMIT = 12\n\n/** Caps a schema summary's UTF-16 code units. */\nexport const FAULT_SCHEMA_LIMIT = 160\n","import type { ContractErrorContext, ContractErrorOptions } from './types.js'\nimport { CONTRACT_CODES, CONTRACT_ERROR_BRAND, INTRINSICS } from './constants.js'\n\n/**\n * Carries a machine-readable contract category, optional context, and an exact optional\n * cause.\n *\n * @remarks\n * Omitting `cause` omits the own property; explicitly supplying `cause: undefined`\n * retains an own property with that value. Both optional options are read as OWN\n * properties, so a construction never consults the caller-writable prototype chain of\n * the container it was handed.\n *\n * @example\n * ```ts\n * const error = new ContractError('Minimum exceeds maximum', {\n * \tcode: 'range',\n * \tcontext: { path: ['properties', 'age'] },\n * })\n * ```\n */\nexport class ContractError extends Error {\n\toverride readonly name: string = 'ContractError'\n\treadonly code\n\treadonly context: ContractErrorContext | undefined\n\n\t/**\n\t * Creates a contract error.\n\t *\n\t * @param message - Human-readable error description\n\t * @param options - Machine-readable category, optional context, and optional cause\n\t */\n\tconstructor(message: string, options: ContractErrorOptions) {\n\t\tsuper(message, INTRINSICS.own(options, 'cause') ? { cause: options.cause } : undefined)\n\t\tINTRINSICS.define(this, CONTRACT_ERROR_BRAND, { value: this, configurable: true })\n\t\tthis.code = options.code\n\t\tthis.context = INTRINSICS.own(options, 'context') ? options.context : undefined\n\t}\n\n\tstatic {\n\t\t// The `pinMembers` body, inlined for the reason that helper's `@remarks`\n\t\t// records: `helpers.ts` imports this module, so calling it here would invert\n\t\t// the dependency. It stays aligned with that helper, accessor branch and\n\t\t// answering `declare` included, so this body and `pinMembers` cannot pin\n\t\t// differently.\n\t\tconst members = INTRINSICS.reflect.members(this.prototype)\n\t\tfor (const key of members) {\n\t\t\tif (key === undefined) continue\n\t\t\tconst declared = INTRINSICS.describe(this.prototype, key)\n\t\t\tconst accessor = declared !== undefined && !INTRINSICS.own(declared, 'value')\n\t\t\tINTRINSICS.reflect.define(\n\t\t\t\tthis.prototype,\n\t\t\t\tkey,\n\t\t\t\taccessor ? { configurable: false } : { writable: false, configurable: false },\n\t\t\t)\n\t\t\tconst pinned = INTRINSICS.describe(this.prototype, key)\n\t\t\tif (pinned?.configurable !== false || (!accessor && pinned.writable !== false)) {\n\t\t\t\tthrow new ContractError('ContractError: a prototype member could not be pinned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Checks whether an unknown value is a {@link ContractError}.\n *\n * @remarks\n * Recognition combines a global own-property brand with the native `Error`\n * base, a subclass prototype, an own declared contract code, and valid context.\n * Context may be a class instance or callable object; paths are checked by index.\n * Optional context fields are read only when owned; inherited fields are ignored.\n * A subclass may replace its name without changing recognition.\n * The brand stores the error itself and recognition requires that exact\n * identity. A transparent proxy is therefore refused because its forwarded\n * descriptor still stores the target, not the proxy.\n * The brand is recognized across duplicate installations and ESM/CommonJS\n * module copies at 0.0.13 or later. A copy earlier than 0.0.13 stamps no brand,\n * so an error it throws stays outside the type, and so does a plain or\n * property-only lookalike.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `ContractError` instance; false otherwise\n *\n * @example\n * ```ts\n * isContractError(new ContractError('Invalid shape', { code: 'placement' })) // true\n * isContractError(new Error('Invalid shape')) // false\n * ```\n */\nexport function isContractError(value: unknown): value is ContractError {\n\tif (typeof value !== 'object' || value === null) return false\n\ttry {\n\t\tif (\n\t\t\t!(value instanceof INTRINSICS.error) ||\n\t\t\tINTRINSICS.prototype(value) === INTRINSICS.error.prototype\n\t\t) {\n\t\t\treturn false\n\t\t}\n\t\tif (!INTRINSICS.own(value, 'code')) return false\n\t\tconst descriptor = INTRINSICS.describe(value, CONTRACT_ERROR_BRAND)\n\t\tif (descriptor?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, CONTRACT_CODES, [\n\t\t\t\t(candidate: unknown) => candidate === code,\n\t\t\t])\n\t\t) {\n\t\t\treturn false\n\t\t}\n\t\tconst context: unknown = INTRINSICS.own(value, 'context')\n\t\t\t? INTRINSICS.reflect.read(value, 'context')\n\t\t\t: undefined\n\t\tif (context === undefined) return true\n\t\tif ((typeof context !== 'object' || context === null) && typeof context !== 'function') {\n\t\t\treturn false\n\t\t}\n\t\tconst path: unknown = INTRINSICS.own(context, 'path')\n\t\t\t? INTRINSICS.reflect.read(context, 'path')\n\t\t\t: undefined\n\t\tif (path !== undefined && typeof path !== 'string') {\n\t\t\tif (!INTRINSICS.array(path)) return false\n\t\t\tif (\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, path, [\n\t\t\t\t\t(segment: unknown) => typeof segment !== 'string',\n\t\t\t\t]) !== -1\n\t\t\t) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tconst shape: unknown = INTRINSICS.own(context, 'shape')\n\t\t\t? INTRINSICS.reflect.read(context, 'shape')\n\t\t\t: undefined\n\t\tif (shape !== undefined && typeof shape !== 'string') return false\n\t\tconst limit: unknown = INTRINSICS.own(context, 'limit')\n\t\t\t? INTRINSICS.reflect.read(context, 'limit')\n\t\t\t: undefined\n\t\tif (limit !== undefined && typeof limit !== 'number' && typeof limit !== 'string') return false\n\t\tconst received: unknown = INTRINSICS.own(context, 'received')\n\t\t\t? INTRINSICS.reflect.read(context, 'received')\n\t\t\t: undefined\n\t\treturn received === undefined || typeof received === 'string'\n\t} catch {\n\t\treturn false\n\t}\n}\n","import type {\n\tAnyAsyncFunction,\n\tAnyConstructor,\n\tAnyFunction,\n\tAuditFault,\n\tFault,\n\tFieldPath,\n\tJSONPrimitive,\n\tJSONRecord,\n\tJSONValue,\n\tLiteralValue,\n\tZeroArgAsyncFunction,\n\tZeroArgFunction,\n} from './types.js'\nimport { FAULT_CONSTRAINTS, FAULT_KINDS, INTRINSICS } from './constants.js'\nimport {\n\tholds,\n\tisFailure,\n\tmatchesExactKeys,\n\tmatchesJSONDepth,\n\tmatchesJSONValue,\n\tmatchesRecordBrand,\n\treadArrayEntries,\n\treadPatternSource,\n} from './helpers.js'\n\n// `.claude/rules/patterns.md` § Validation and contracts: guards are total\n// functions — a guard NEVER throws. Adversarial\n// input (hostile getters, exotic objects, cycles) returns `false`, never an\n// error. Guards built from a single `typeof` / strict-equality test are\n// immediately total — no probe of the value's internals can throw. Every\n// OTHER guard here probes the value in some way — a property read through\n// `Reflect.get`, a structural walk (`isPromiseLike`, `isIterable`,\n// `isAsyncIterable`, `isJSONValue`, `isRecord`), an `instanceof` check (which\n// invokes the target's `[Symbol.hasInstance]` / triggers a `getPrototypeOf`\n// trap), or an own-key enumeration (`isEmptyObject` / `isNonEmptyObject`) —\n// so a hostile getter, a revoked `Proxy`, or an exotic trap can throw\n// mid-probe. Totality is NOT automatic for these: each contains its whole\n// probe/walk in `holds` (see ./helpers.js) and returns `false` on a caught\n// throw. Every `instanceof`-based guard in this file routes through the\n// shared {@link isInstance} helper, which is the one place that containment\n// lives for that family.\n\n// === Primitive guards\n\n/** Determines whether a value is `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is `null`; false otherwise\n *\n * @example\n * ```ts\n * isNull(null) // true\n * isNull(undefined) // false\n * ```\n */\nexport function isNull(value: unknown): value is null {\n\treturn value === null\n}\n\n/** Determines whether a value is `undefined`.\n *\n * @param value - The value to inspect\n * @returns True if the value is `undefined`; false otherwise\n *\n * @example\n * ```ts\n * isUndefined(undefined) // true\n * isUndefined(null) // false\n * ```\n */\nexport function isUndefined(value: unknown): value is undefined {\n\treturn value === undefined\n}\n\n/** Determines whether a value is defined (neither `null` nor `undefined`).\n *\n * @param value - The value to inspect\n * @returns True if the value is defined; false otherwise\n *\n * @example\n * ```ts\n * isDefined('hi') // true\n * isDefined(null) // false\n * isDefined(undefined) // false\n * ```\n */\nexport function isDefined<T>(value: T | null | undefined): value is T {\n\treturn value !== null && value !== undefined\n}\n\n/** Determines whether a value is a string.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string; false otherwise\n *\n * @example\n * ```ts\n * isString('hi') // true\n * isString(42) // false\n * ```\n */\nexport function isString(value: unknown): value is string {\n\treturn typeof value === 'string'\n}\n\n/**\n * Determines whether a value is a number.\n *\n * @remarks\n * Includes `NaN` and `±Infinity` — use {@link isFiniteNumber} to exclude them.\n *\n * @param value - The value to inspect\n * @returns True if the value is a number; false otherwise\n *\n * @example\n * ```ts\n * isNumber(42) // true\n * isNumber(Number.NaN) // true — NaN is still a number\n * isNumber('42') // false\n * ```\n */\nexport function isNumber(value: unknown): value is number {\n\treturn typeof value === 'number'\n}\n\n/** Determines whether a value is a finite number (excludes `NaN` and `±Infinity`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite number; false otherwise\n *\n * @example\n * ```ts\n * isFiniteNumber(42) // true\n * isFiniteNumber(Number.NaN) // false\n * isFiniteNumber(Infinity) // false\n * ```\n */\nexport function isFiniteNumber(value: unknown): value is number {\n\treturn typeof value === 'number' && INTRINSICS.finite(value)\n}\n\n/** Determines whether a value is a finite integer (excludes `NaN`, `±Infinity`, and fractional numbers).\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite integer; false otherwise\n *\n * @example\n * ```ts\n * isInteger(3) // true\n * isInteger(3.5) // false\n * ```\n */\nexport function isInteger(value: unknown): value is number {\n\treturn INTRINSICS.integer(value)\n}\n\n/**\n * Determines whether a value is a finite primitive number at or above positive zero.\n *\n * @remarks\n * Positive fractions pass. Negative zero is rejected explicitly, and no\n * coercion or property access is performed for non-number inputs.\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite primitive number greater than or equal\n * to zero, except `-0`; false otherwise\n *\n * @example\n * ```ts\n * isNonNegativeNumber(0.5) // true\n * isNonNegativeNumber(-0) // false\n * ```\n */\nexport function isNonNegativeNumber(value: unknown): value is number {\n\treturn isFiniteNumber(value) && value >= 0 && !INTRINSICS.same(value, -0)\n}\n\n/**\n * Determines whether a value is a non-negative finite primitive integer.\n *\n * @remarks\n * Composes {@link isNonNegativeNumber} with {@link isInteger}. Representable\n * unsafe integers remain integers; safe-integer policy is a separate domain.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-negative integer other than `-0`; false otherwise\n *\n * @example\n * ```ts\n * isNonNegativeInteger(3) // true\n * isNonNegativeInteger(3.5) // false\n * ```\n */\nexport function isNonNegativeInteger(value: unknown): value is number {\n\treturn isNonNegativeNumber(value) && isInteger(value)\n}\n\n/** Determines whether a value is a boolean.\n *\n * @param value - The value to inspect\n * @returns True if the value is a boolean; false otherwise\n *\n * @example\n * ```ts\n * isBoolean(true) // true\n * isBoolean(1) // false\n * ```\n */\nexport function isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean'\n}\n\n/**\n * Determines whether a value belongs to the string, number, or boolean literal domain.\n *\n * @remarks\n * Every JavaScript number belongs to this structural domain, including `NaN`,\n * `±Infinity`, and signed zero. Declaration and schema policies apply finiteness\n * separately where their contracts require it.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string, number, or boolean; false otherwise\n *\n * @example\n * ```ts\n * isLiteralValue(Number.NaN) // true\n * isLiteralValue(null) // false\n * ```\n */\nexport function isLiteralValue(value: unknown): value is LiteralValue {\n\treturn isString(value) || isNumber(value) || isBoolean(value)\n}\n\n/** Determines whether a value is exactly `true`.\n *\n * @param value - The value to inspect\n * @returns True if the value is exactly `true`; false otherwise\n *\n * @example\n * ```ts\n * isTrue(true) // true\n * isTrue(false) // false\n * ```\n */\nexport function isTrue(value: unknown): value is true {\n\treturn value === true\n}\n\n/** Determines whether a value is exactly `false`.\n *\n * @param value - The value to inspect\n * @returns True if the value is exactly `false`; false otherwise\n *\n * @example\n * ```ts\n * isFalse(false) // true\n * isFalse(true) // false\n * ```\n */\nexport function isFalse(value: unknown): value is false {\n\treturn value === false\n}\n\n/** Determines whether a value is a bigint.\n *\n * @param value - The value to inspect\n * @returns True if the value is a bigint; false otherwise\n *\n * @example\n * ```ts\n * isBigInt(1n) // true\n * isBigInt(1) // false\n * ```\n */\nexport function isBigInt(value: unknown): value is bigint {\n\treturn typeof value === 'bigint'\n}\n\n/** Determines whether a value is a symbol.\n *\n * @param value - The value to inspect\n * @returns True if the value is a symbol; false otherwise\n *\n * @example\n * ```ts\n * isSymbol(Symbol('x')) // true\n * isSymbol('x') // false\n * ```\n */\nexport function isSymbol(value: unknown): value is symbol {\n\treturn typeof value === 'symbol'\n}\n\n/** Determines whether a value is callable.\n *\n * @param value - The value to inspect\n * @returns True if the value is callable; false otherwise\n *\n * @example\n * ```ts\n * isFunction(() => {}) // true\n * isFunction({}) // false\n * ```\n */\nexport function isFunction(value: unknown): value is AnyFunction {\n\treturn typeof value === 'function'\n}\n\n/** Determines whether a value is a string or `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableString('hi') // true\n * isNullableString(null) // true\n * isNullableString(42) // false\n * ```\n */\nexport function isNullableString(value: unknown): value is string | null {\n\treturn value === null || isString(value)\n}\n\n/** Determines whether a value is a number or `null` (the number may be `NaN` / `±Infinity`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a number or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableNumber(42) // true\n * isNullableNumber(null) // true\n * isNullableNumber('hi') // false\n * ```\n */\nexport function isNullableNumber(value: unknown): value is number | null {\n\treturn value === null || isNumber(value)\n}\n\n/** Determines whether a value is a boolean or `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a boolean or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableBoolean(true) // true\n * isNullableBoolean(null) // true\n * isNullableBoolean(1) // false\n * ```\n */\nexport function isNullableBoolean(value: unknown): value is boolean | null {\n\treturn value === null || isBoolean(value)\n}\n\n// === Built-in guards\n//\n// The `instanceof`-based guard families below (Date/RegExp/Error/Promise,\n// Map/Set/WeakMap/WeakSet, the typed-array guards) are same-realm checks:\n// `instanceof` compares against the constructor's prototype in the CURRENT\n// realm, so a value built by another realm (a different `vm.Context`, iframe,\n// or worker global) fails even when it is structurally identical. This is a\n// known, accepted limitation — cross-realm identity would require duck-typing\n// every built-in, which trades soundness for portability.\n\n/**\n * Determines whether a value is an instance of a constructor, contained against\n * a throwing `instanceof` check.\n *\n * @remarks\n * The low-level total helper every `instanceof`-based guard in this file (and\n * the `instanceOf` combinator) routes through. A bare `value instanceof X` is\n * NOT total, which `.claude/rules/patterns.md` § Validation and contracts\n * requires: it invokes `getPrototypeOf` on `value` — which a\n * revoked `Proxy` or a `getPrototypeOf`-trap `Proxy` throws from — and, when\n * `X[Symbol.hasInstance]` is user-defined, can throw from arbitrary code. This\n * wraps the check in {@link holds} (see ./helpers.js) so any such throw\n * yields `false` instead of escaping.\n *\n * Narrows `value` to `InstanceType<C>`, which reads the constructor's last\n * construct signature. Accepts the same constructors as `instanceOf`: a public\n * or abstract construct signature returning an object (or `any`). A class with a\n * private or protected constructor and the bare `AnyConstructor` are refused at the call.\n * A value typed `Function` cannot be passed because the `Function` interface has\n * no construct signature. The constructor `Function` can be passed through\n * `FunctionConstructor`'s construct signature and narrows to `Function`.\n * The false branch drops each member of the declared union that is a subtype\n * of the instance type and keeps the rest, so a subclass that adds no member\n * narrows its base out as well (and a subclass that adds only an optional member\n * does not). A constructor whose instance type admits\n * primitives structurally, such as `Object`, makes the false branch unsound;\n * use `isObject` for that check.\n *\n * @param value - The value to test\n * @param ctor - The constructor to test against\n * @returns True if `value instanceof ctor`; false otherwise, including on a\n * contained throw\n *\n * @example\n * ```ts\n * isInstance(new Date(), Date) // true\n * isInstance({}, Date) // false\n * ```\n */\nexport function isInstance<C extends abstract new (...args: never) => object>(\n\tvalue: unknown,\n\tctor: C,\n): value is InstanceType<C> {\n\t// Keep the published runtime behaviour: `isFunction` makes a non-callable\n\t// right-hand side return `false` without consulting its `Symbol.hasInstance`\n\t// or causing a contained `TypeError`.\n\tconst target: unknown = ctor\n\treturn holds(() => isFunction(target) && value instanceof target)\n}\n\n/** Determines whether a value is a `Date`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Date`; false otherwise\n *\n * @example\n * ```ts\n * isDate(new Date()) // true\n * isDate('2024-01-01') // false\n * ```\n */\nexport function isDate(value: unknown): value is Date {\n\treturn isInstance(value, Date)\n}\n\n/** Determines whether a value is a `RegExp`.\n *\n * @remarks\n * A total native internal-slot brand check rather than a property read: it accepts a\n * genuine pattern from this realm and from another, and refuses a proxy or a hand-built\n * forgery without reading an advertised field.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `RegExp`; false otherwise\n *\n * @example\n * ```ts\n * isRegExp(/a/) // true\n * isRegExp('a') // false\n * ```\n */\nexport function isRegExp(value: unknown): value is RegExp {\n\t// The CAPTURED `source` getter applied to the candidate. That getter is\n\t// defined only on an object carrying the pattern's internal slots, so a\n\t// non-pattern throws and this total guard answers `false`. Re-reading the\n\t// descriptor off `RegExp.prototype` per call would observe whatever getter is\n\t// installed at that moment and check only that it returned a string — so\n\t// `Object.defineProperty(RegExp.prototype, 'source', { get: () => '.*' })`\n\t// would make this guard accept a plain string, and it gates `matchOf`,\n\t// `stringOf` and every string shape builder.\n\treturn holds(() => readPatternSource(value) !== undefined)\n}\n\n/** Determines whether a value is an `Error`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Error`; false otherwise\n *\n * @example\n * ```ts\n * isError(new Error('boom')) // true\n * isError('boom') // false\n * ```\n */\nexport function isError(value: unknown): value is Error {\n\treturn isInstance(value, Error)\n}\n\n/** Determines whether a value is a native `Promise` (use {@link isPromiseLike} for any thenable).\n *\n * @param value - The value to inspect\n * @returns True if the value is a native `Promise`; false otherwise\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve()) // true\n * isPromise({ then() {} }) // false\n * ```\n */\nexport function isPromise<T = unknown>(value: unknown): value is Promise<T> {\n\treturn isInstance(value, Promise)\n}\n\n/**\n * Determines whether a value is promise-like — an object exposing callable\n * `then`, `catch`, and `finally` methods.\n *\n * @remarks\n * Accepts any object with all three methods, not only native `Promise`\n * instances. Use {@link isPromise} when you specifically need `instanceof Promise`.\n *\n * @param value - The value to inspect\n * @returns True if the value is promise-like; false otherwise\n *\n * @example\n * ```ts\n * isPromiseLike(Promise.resolve()) // true\n * isPromiseLike({ then() {}, catch() {}, finally() {} }) // true\n * isPromiseLike({ then() {} }) // false\n * ```\n */\nexport function isPromiseLike<T = unknown>(\n\tvalue: unknown,\n): value is Promise<T> | (PromiseLike<T> & { catch: unknown; finally: unknown }) {\n\treturn holds(() => {\n\t\tif (!isObject(value)) {\n\t\t\treturn false\n\t\t}\n\t\tconst thenValue = INTRINSICS.reflect.read(value, 'then')\n\t\tconst catchValue = INTRINSICS.reflect.read(value, 'catch')\n\t\tconst finallyValue = INTRINSICS.reflect.read(value, 'finally')\n\t\treturn isFunction(thenValue) && isFunction(catchValue) && isFunction(finallyValue)\n\t})\n}\n\n/** Determines whether a value is an `ArrayBuffer`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `ArrayBuffer`; false otherwise\n *\n * @example\n * ```ts\n * isArrayBuffer(new ArrayBuffer(8)) // true\n * isArrayBuffer([]) // false\n * ```\n */\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n\treturn isInstance(value, ArrayBuffer)\n}\n\n/**\n * Determines whether a value is a `SharedArrayBuffer`.\n *\n * @remarks\n * Guards the global existence of `SharedArrayBuffer` first — safe where it is\n * absent or disabled (for example a context that is not cross-origin isolated).\n *\n * @param value - The value to inspect\n * @returns True if the value is a `SharedArrayBuffer`; false otherwise\n *\n * @example\n * ```ts\n * isSharedArrayBuffer(new SharedArrayBuffer(8)) // true\n * isSharedArrayBuffer(new ArrayBuffer(8)) // false\n * ```\n */\nexport function isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer {\n\treturn typeof SharedArrayBuffer !== 'undefined' && isInstance(value, SharedArrayBuffer)\n}\n\n// === Protocol guards\n\n/**\n * Determines whether a value implements the iterable protocol (`Symbol.iterator`).\n *\n * @remarks\n * Strings are explicitly included: a string has a callable `Symbol.iterator`\n * but is not an object, so the generic object path alone would miss it.\n *\n * @param value - The value to inspect\n * @returns True if the value implements the iterable protocol; false otherwise\n *\n * @example\n * ```ts\n * isIterable([1, 2]) // true\n * isIterable('abc') // true\n * isIterable({ a: 1 }) // false\n * ```\n */\nexport function isIterable<T = unknown>(value: unknown): value is Iterable<T> {\n\treturn holds(() => {\n\t\tif (isString(value)) {\n\t\t\treturn true\n\t\t}\n\t\treturn isObject(value) && isFunction(INTRINSICS.reflect.read(value, Symbol.iterator))\n\t})\n}\n\n/** Determines whether a value implements the async iterable protocol (`Symbol.asyncIterator`).\n *\n * @param value - The value to inspect\n * @returns True if the value implements the async iterable protocol; false otherwise\n *\n * @example\n * ```ts\n * isAsyncIterable({ [Symbol.asyncIterator]() {} }) // true\n * isAsyncIterable([1, 2]) // false\n * ```\n */\nexport function isAsyncIterable<T = unknown>(value: unknown): value is AsyncIterable<T> {\n\treturn holds(\n\t\t() => isObject(value) && isFunction(INTRINSICS.reflect.read(value, Symbol.asyncIterator)),\n\t)\n}\n\n// === Object & collection guards\n\n/**\n * Determines whether a value is a non-null object.\n *\n * @remarks\n * `true` for every non-null object, including an array, a class instance, a\n * plain object, a `Map`, and a `Set` — use\n * {@link isRecord} when you need a plain-record check.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-null object; false otherwise\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject([]) // true\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && value !== null\n}\n\n/**\n * Determines whether a value is a plain record (object literal or null-prototype),\n * not an array or class instance.\n *\n * @remarks\n * The total form of the shared {@link matchesRecordBrand} rule, and the only\n * one a guard may use: the whole brand runs inside `holds`, as\n * `.claude/rules/patterns.md` § Validation and contracts requires, so a\n * revoked `Proxy` or a hostile `getPrototypeOf` trap answers `false` instead of\n * escaping as a thrown error. Use instead of {@link isObject} to distinguish a\n * plain `{}` / `Object.create(null)` — or a plain object from another realm,\n * whose prototype is that realm's `Object.prototype` — from arrays, `Date`,\n * `Map`, and class instances, including a class whose prototype a caller\n * reparented to `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a plain record; false otherwise\n *\n * @example\n * ```ts\n * isRecord({ a: 1 }) // true\n * isRecord(Object.create(null)) // true\n * isRecord([]) // false\n * isRecord(new Date()) // false\n * ```\n */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn holds(() => matchesRecordBrand(value))\n}\n\n/**\n * Determines whether a value is the {@link FieldPath} a fault carries: a key, or a dense list of keys.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string or a dense array of strings; false otherwise\n *\n * @example\n * ```ts\n * isFaultPath(['user', 'name']) // true\n * isFaultPath([1]) // false\n * ```\n */\nexport function isFaultPath(value: unknown): value is FieldPath {\n\tif (isString(value)) return true\n\treturn holds(() => {\n\t\tif (!isArray(value)) return false\n\t\tconst snapshot = readArrayEntries(value)\n\t\tif (isFailure(snapshot) || !snapshot.value.dense) return false\n\t\treturn !INTRINSICS.reflect.apply(INTRINSICS.some, snapshot.value.entries, [\n\t\t\t(entry: unknown) => !isString(entry),\n\t\t])\n\t})\n}\n\n/**\n * Determines whether a value is exactly one {@link Fault}.\n *\n * @remarks\n * A closed reading of the union: each reason's required fields, each with its own\n * vocabulary, and no other key, so `{}` and a fault carrying a stray field both answer\n * `false`. An undeclared-key fault is an {@link AuditFault} and answers `false` here.\n *\n * @param value - The value to inspect\n * @returns True if the value is a well-formed fault; false otherwise\n *\n * @example\n * ```ts\n * isFault({ reason: 'missing', path: ['a'], expected: 'string' }) // true\n * isFault({}) // false\n * ```\n */\nexport function isFault(value: unknown): value is Fault {\n\treturn holds(() => {\n\t\tif (!isRecord(value) || !isFaultPath(value.path)) return false\n\t\tconst kind = INTRINSICS.reflect.apply(INTRINSICS.some, FAULT_KINDS, [\n\t\t\t(entry: string) => entry === value.expected,\n\t\t])\n\t\tconst named = INTRINSICS.own(value, 'key') || INTRINSICS.own(value, 'expected')\n\t\tconst list = readArrayEntries(isArray(value.expected) ? value.expected : [undefined])\n\t\tconst hinted =\n\t\t\t!named ||\n\t\t\t(isString(value.key) &&\n\t\t\t\t!isFailure(list) &&\n\t\t\t\tlist.value.dense &&\n\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, list.value.entries, [\n\t\t\t\t\t(entry: unknown) => !isLiteralValue(entry) || (isNumber(entry) && !isFiniteNumber(entry)),\n\t\t\t\t]))\n\t\tswitch (value.reason) {\n\t\t\tcase 'type':\n\t\t\t\treturn (\n\t\t\t\t\tkind &&\n\t\t\t\t\tisString(value.received) &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'expected', 'received'])\n\t\t\t\t)\n\t\t\tcase 'missing':\n\t\t\t\treturn kind && matchesExactKeys(value, ['reason', 'path', 'expected'])\n\t\t\tcase 'constraint':\n\t\t\t\treturn (\n\t\t\t\t\tkind &&\n\t\t\t\t\tisString(value.received) &&\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, FAULT_CONSTRAINTS, [\n\t\t\t\t\t\t(entry: string) => entry === value.constraint,\n\t\t\t\t\t]) &&\n\t\t\t\t\t(!INTRINSICS.own(value, 'limit') ||\n\t\t\t\t\t\tisFiniteNumber(value.limit) ||\n\t\t\t\t\t\tisString(value.limit)) &&\n\t\t\t\t\tmatchesExactKeys(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t['reason', 'path', 'expected', 'constraint', 'received'],\n\t\t\t\t\t\t['limit'],\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\tcase 'variant':\n\t\t\t\treturn (\n\t\t\t\t\tisNonNegativeInteger(value.variants) &&\n\t\t\t\t\thinted &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'variants'], named ? ['key', 'expected'] : [])\n\t\t\t\t)\n\t\t\tcase 'oneOf':\n\t\t\t\treturn (\n\t\t\t\t\tisNonNegativeInteger(value.matched) &&\n\t\t\t\t\thinted &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'matched'], named ? ['key', 'expected'] : [])\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn false\n\t\t}\n\t})\n}\n\n/**\n * Determines whether a value is exactly one {@link AuditFault}.\n *\n * @remarks\n * Every {@link Fault}, and the undeclared-key fault an audit adds.\n *\n * @param value - The value to inspect\n * @returns True if the value is a well-formed audit fault; false otherwise\n *\n * @example\n * ```ts\n * isAuditFault({ reason: 'extra', path: ['a'] }) // true\n * isAuditFault({}) // false\n * ```\n */\nexport function isAuditFault(value: unknown): value is AuditFault {\n\tif (isFault(value)) return true\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.reason === 'extra' &&\n\t\t\tisFaultPath(value.path) &&\n\t\t\tmatchesExactKeys(value, ['reason', 'path']),\n\t)\n}\n\n/** Determines whether a value is a `Map`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Map`; false otherwise\n *\n * @example\n * ```ts\n * isMap(new Map()) // true\n * isMap({}) // false\n * ```\n */\nexport function isMap<K = unknown, V = unknown>(value: unknown): value is ReadonlyMap<K, V> {\n\treturn isInstance(value, Map)\n}\n\n/** Determines whether a value is a `Set`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Set`; false otherwise\n *\n * @example\n * ```ts\n * isSet(new Set()) // true\n * isSet([]) // false\n * ```\n */\nexport function isSet<T = unknown>(value: unknown): value is ReadonlySet<T> {\n\treturn isInstance(value, Set)\n}\n\n/** Determines whether a value is a `WeakMap`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `WeakMap`; false otherwise\n *\n * @example\n * ```ts\n * isWeakMap(new WeakMap()) // true\n * isWeakMap({}) // false\n * ```\n */\nexport function isWeakMap(value: unknown): value is WeakMap<object, unknown> {\n\treturn isInstance(value, WeakMap)\n}\n\n/** Determines whether a value is a `WeakSet`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `WeakSet`; false otherwise\n *\n * @example\n * ```ts\n * isWeakSet(new WeakSet()) // true\n * isWeakSet({}) // false\n * ```\n */\nexport function isWeakSet(value: unknown): value is WeakSet<object> {\n\treturn isInstance(value, WeakSet)\n}\n\n// === Array & typed-array guards\n\n/** Determines whether a value is an array.\n *\n * @remarks\n * Checks the container alone — no element is inspected. Use {@link arrayOf} to check\n * every element against a guard.\n *\n * @param value - The value to inspect\n * @returns True if the value is an array; false otherwise\n *\n * @example\n * ```ts\n * isArray([1, 2]) // true\n * isArray('12') // false\n * ```\n */\nexport function isArray<T = unknown>(value: unknown): value is readonly T[] {\n\treturn holds(() => INTRINSICS.array(value))\n}\n\n/** Determines whether a value is a `DataView`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `DataView`; false otherwise\n *\n * @example\n * ```ts\n * isDataView(new DataView(new ArrayBuffer(8))) // true\n * isDataView(new ArrayBuffer(8)) // false\n * ```\n */\nexport function isDataView(value: unknown): value is DataView<ArrayBufferLike> {\n\treturn isInstance(value, DataView)\n}\n\n/** Determines whether a value is an `ArrayBufferView` (any typed array or `DataView`).\n *\n * @param value - The value to inspect\n * @returns True if the value is an `ArrayBufferView`; false otherwise\n *\n * @example\n * ```ts\n * isArrayBufferView(new Uint8Array(4)) // true\n * isArrayBufferView([1, 2, 3, 4]) // false\n * ```\n */\nexport function isArrayBufferView(value: unknown): value is ArrayBufferView {\n\treturn holds(() => ArrayBuffer.isView(value))\n}\n\n/** Determines whether a value is an `Int8Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int8Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt8Array(new Int8Array(2)) // true\n * isInt8Array(new Uint8Array(2)) // false\n * ```\n */\nexport function isInt8Array(value: unknown): value is Int8Array {\n\treturn isInstance(value, Int8Array)\n}\n\n/** Determines whether a value is a `Uint8Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint8Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint8Array(new Uint8Array(2)) // true\n * isUint8Array(new Int8Array(2)) // false\n * ```\n */\nexport function isUint8Array(value: unknown): value is Uint8Array {\n\treturn isInstance(value, Uint8Array)\n}\n\n/** Determines whether a value is a `Uint8ClampedArray`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint8ClampedArray`; false otherwise\n *\n * @example\n * ```ts\n * isUint8ClampedArray(new Uint8ClampedArray(2)) // true\n * isUint8ClampedArray(new Uint8Array(2)) // false\n * ```\n */\nexport function isUint8ClampedArray(value: unknown): value is Uint8ClampedArray {\n\treturn isInstance(value, Uint8ClampedArray)\n}\n\n/** Determines whether a value is an `Int16Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int16Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt16Array(new Int16Array(2)) // true\n * isInt16Array(new Int8Array(2)) // false\n * ```\n */\nexport function isInt16Array(value: unknown): value is Int16Array {\n\treturn isInstance(value, Int16Array)\n}\n\n/** Determines whether a value is a `Uint16Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint16Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint16Array(new Uint16Array(2)) // true\n * isUint16Array(new Int16Array(2)) // false\n * ```\n */\nexport function isUint16Array(value: unknown): value is Uint16Array {\n\treturn isInstance(value, Uint16Array)\n}\n\n/** Determines whether a value is an `Int32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int32Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt32Array(new Int32Array(2)) // true\n * isInt32Array(new Int16Array(2)) // false\n * ```\n */\nexport function isInt32Array(value: unknown): value is Int32Array {\n\treturn isInstance(value, Int32Array)\n}\n\n/** Determines whether a value is a `Uint32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint32Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint32Array(new Uint32Array(2)) // true\n * isUint32Array(new Int32Array(2)) // false\n * ```\n */\nexport function isUint32Array(value: unknown): value is Uint32Array {\n\treturn isInstance(value, Uint32Array)\n}\n\n/** Determines whether a value is a `Float32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Float32Array`; false otherwise\n *\n * @example\n * ```ts\n * isFloat32Array(new Float32Array(2)) // true\n * isFloat32Array(new Float64Array(2)) // false\n * ```\n */\nexport function isFloat32Array(value: unknown): value is Float32Array {\n\treturn isInstance(value, Float32Array)\n}\n\n/** Determines whether a value is a `Float64Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Float64Array`; false otherwise\n *\n * @example\n * ```ts\n * isFloat64Array(new Float64Array(2)) // true\n * isFloat64Array(new Float32Array(2)) // false\n * ```\n */\nexport function isFloat64Array(value: unknown): value is Float64Array {\n\treturn isInstance(value, Float64Array)\n}\n\n/**\n * Determines whether a value is a `BigInt64Array`.\n *\n * @remarks\n * Guards the global existence of `BigInt64Array` first — safe in environments\n * that pre-date the BigInt typed-array additions.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `BigInt64Array`; false otherwise\n *\n * @example\n * ```ts\n * isBigInt64Array(new BigInt64Array(2)) // true\n * isBigInt64Array(new Float64Array(2)) // false\n * ```\n */\nexport function isBigInt64Array(value: unknown): value is BigInt64Array {\n\treturn typeof BigInt64Array !== 'undefined' && isInstance(value, BigInt64Array)\n}\n\n/**\n * Determines whether a value is a `BigUint64Array`.\n *\n * @remarks\n * Guards the global existence of `BigUint64Array` first — safe in environments\n * that pre-date the BigInt typed-array additions.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `BigUint64Array`; false otherwise\n *\n * @example\n * ```ts\n * isBigUint64Array(new BigUint64Array(2)) // true\n * isBigUint64Array(new BigInt64Array(2)) // false\n * ```\n */\nexport function isBigUint64Array(value: unknown): value is BigUint64Array {\n\treturn typeof BigUint64Array !== 'undefined' && isInstance(value, BigUint64Array)\n}\n\n// === Emptiness guards\n\n/** Determines whether a value is the empty string `''`.\n *\n * @param value - The value to inspect\n * @returns True if the value is the empty string `''`; false otherwise\n *\n * @example\n * ```ts\n * isEmptyString('') // true\n * isEmptyString('a') // false\n * ```\n */\nexport function isEmptyString(value: unknown): value is '' {\n\treturn isString(value) && value.length === 0\n}\n\n/** Determines whether a value is an empty array.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty array; false otherwise\n *\n * @example\n * ```ts\n * isEmptyArray([]) // true\n * isEmptyArray([1]) // false\n * ```\n */\nexport function isEmptyArray(value: unknown): value is readonly [] {\n\treturn holds(() => isArray(value) && value.length === 0)\n}\n\n/** Determines whether a value is an empty plain object — no OWN keys at all, of any\n * kind: string or symbol, enumerable or not.\n *\n * @remarks\n * The own-key population is the one `recordOf` inspects (`Reflect.ownKeys`), and\n * it has to be: this guard narrows to `Record<string | symbol, never>`, so\n * counting only ENUMERABLE keys made the narrowing unsound — a record carrying\n * an own non-enumerable `hidden: 1` answered `true` here while `recordOf({})`\n * saw the key and rejected the same value, and the enumerable-symbol and\n * non-enumerable-string cases were treated differently for no stated reason.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty plain object; false otherwise\n *\n * @example\n * ```ts\n * isEmptyObject({}) // true\n * isEmptyObject({ a: 1 }) // false\n * isEmptyObject(Object.defineProperty({}, 'hidden', { value: 1 })) // false\n * ```\n */\nexport function isEmptyObject(value: unknown): value is Record<string | symbol, never> {\n\treturn holds(() => isRecord(value) && INTRINSICS.reflect.members(value).length === 0)\n}\n\n/** Determines whether a value is an empty `Map`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty `Map`; false otherwise\n *\n * @example\n * ```ts\n * isEmptyMap(new Map()) // true\n * isEmptyMap(new Map([['a', 1]])) // false\n * ```\n */\nexport function isEmptyMap(value: unknown): value is ReadonlyMap<never, never> {\n\treturn holds(() => isMap(value) && value.size === 0)\n}\n\n/** Determines whether a value is an empty `Set`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty `Set`; false otherwise\n *\n * @example\n * ```ts\n * isEmptySet(new Set()) // true\n * isEmptySet(new Set([1])) // false\n * ```\n */\nexport function isEmptySet(value: unknown): value is ReadonlySet<never> {\n\treturn holds(() => isSet(value) && value.size === 0)\n}\n\n/** Determines whether a value is a non-empty string (at least one character).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty string; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyString('a') // true\n * isNonEmptyString('') // false\n * ```\n */\nexport function isNonEmptyString(value: unknown): value is string {\n\treturn isString(value) && value.length > 0\n}\n\n/** Determines whether a value is a non-empty array (at least one element).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty array; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyArray([1]) // true\n * isNonEmptyArray([]) // false\n * ```\n */\nexport function isNonEmptyArray<T = unknown>(value: unknown): value is readonly [T, ...T[]] {\n\treturn holds(() => isArray<T>(value) && value.length > 0)\n}\n\n/** Determines whether a value is a non-empty plain object — at least one own key of\n * any kind: string or symbol, enumerable or not.\n *\n * @remarks\n * The exact negation of {@link isEmptyObject} over the same own-key population;\n * see there for why enumerability is not part of the rule.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty plain object; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyObject({ a: 1 }) // true\n * isNonEmptyObject({}) // false\n * ```\n */\nexport function isNonEmptyObject(value: unknown): value is Record<string | symbol, unknown> {\n\treturn holds(() => isRecord(value) && INTRINSICS.reflect.members(value).length > 0)\n}\n\n/** Determines whether a value is a non-empty `Map` (at least one entry).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty `Map`; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyMap(new Map([['a', 1]])) // true\n * isNonEmptyMap(new Map()) // false\n * ```\n */\nexport function isNonEmptyMap<K = unknown, V = unknown>(\n\tvalue: unknown,\n): value is ReadonlyMap<K, V> {\n\treturn holds(() => isMap<K, V>(value) && value.size > 0)\n}\n\n/** Determines whether a value is a non-empty `Set` (at least one element).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty `Set`; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptySet(new Set([1])) // true\n * isNonEmptySet(new Set()) // false\n * ```\n */\nexport function isNonEmptySet<T = unknown>(value: unknown): value is ReadonlySet<T> {\n\treturn holds(() => isSet<T>(value) && value.size > 0)\n}\n\n// === Function guards\n\n/** Determines whether a value is a function that declares zero parameters (`Function.length === 0`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a function that declares zero parameters; false otherwise\n *\n * @example\n * ```ts\n * isZeroArg(() => {}) // true\n * isZeroArg((a) => a) // false\n * ```\n */\nexport function isZeroArg(value: unknown): value is ZeroArgFunction {\n\treturn holds(() => isFunction(value) && value.length === 0)\n}\n\n/**\n * Determines whether a value is a native `async function`.\n *\n * @remarks\n * Uses `constructor.name === 'AsyncFunction'` — not `instanceof`, which is\n * unreliable across realms. The `?.` keeps the guard total, as\n * `.claude/rules/patterns.md` § Validation and contracts requires: a function\n * whose `constructor` was nulled yields `undefined`, never a thrown `null.name`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a native `async function`; false otherwise\n *\n * @example\n * ```ts\n * isAsyncFunction(async () => {}) // true\n * isAsyncFunction(() => {}) // false\n * ```\n */\nexport function isAsyncFunction(value: unknown): value is AnyAsyncFunction {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'AsyncFunction')\n}\n\n/** Determines whether a value is a generator function (`function*`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a generator function; false otherwise\n *\n * @example\n * ```ts\n * isGeneratorFunction(function* () {}) // true\n * isGeneratorFunction(() => {}) // false\n * ```\n */\nexport function isGeneratorFunction(\n\tvalue: unknown,\n): value is (...args: unknown[]) => Generator<unknown, unknown, unknown> {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'GeneratorFunction')\n}\n\n/** Determines whether a value is an async generator function (`async function*`).\n *\n * @param value - The value to inspect\n * @returns True if the value is an async generator function; false otherwise\n *\n * @example\n * ```ts\n * isAsyncGeneratorFunction(async function* () {}) // true\n * isAsyncGeneratorFunction(function* () {}) // false\n * ```\n */\nexport function isAsyncGeneratorFunction(\n\tvalue: unknown,\n): value is (...args: unknown[]) => AsyncGenerator<unknown, unknown, unknown> {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'AsyncGeneratorFunction')\n}\n\n/** Determines whether a value is a zero-argument async function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument async function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgAsync(async () => {}) // true\n * isZeroArgAsync(async (a) => a) // false\n * ```\n */\nexport function isZeroArgAsync(value: unknown): value is ZeroArgAsyncFunction {\n\treturn isZeroArg(value) && isAsyncFunction(value)\n}\n\n/** Determines whether a value is a zero-argument generator function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument generator function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgGenerator(function* () {}) // true\n * isZeroArgGenerator(function* (a) {}) // false\n * ```\n */\nexport function isZeroArgGenerator(\n\tvalue: unknown,\n): value is () => Generator<unknown, unknown, unknown> {\n\treturn isZeroArg(value) && isGeneratorFunction(value)\n}\n\n/** Determines whether a value is a zero-argument async generator function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument async generator function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgAsyncGenerator(async function* () {}) // true\n * isZeroArgAsyncGenerator(async function* (a) {}) // false\n * ```\n */\nexport function isZeroArgAsyncGenerator(\n\tvalue: unknown,\n): value is () => AsyncGenerator<unknown, unknown, unknown> {\n\treturn isZeroArg(value) && isAsyncGeneratorFunction(value)\n}\n\n/**\n * Determines whether a value can be used as a `new`-target constructor.\n *\n * @remarks\n * Probes with `Reflect.construct(String, [], value)`: a real constructor\n * succeeds, while arrow functions, plain functions, and non-functions throw\n * and yield `false`. Never throws. Backs the `instanceOf` combinator.\n *\n * @param value - The value to inspect\n * @returns True if the value can be used as a `new`-target constructor; false otherwise\n *\n * @example\n * ```ts\n * isConstructor(class X {}) // true\n * isConstructor(() => {}) // false\n * ```\n */\nexport function isConstructor(value: unknown): value is AnyConstructor<object> {\n\treturn holds(() => {\n\t\tif (!isFunction(value)) {\n\t\t\treturn false\n\t\t}\n\t\tINTRINSICS.reflect.construct(String, [], value)\n\t\treturn true\n\t})\n}\n\n// === JSON\n\n/**\n * Determines whether a value is a cycle-safe JSON value.\n *\n * @remarks\n * Total guard: never throws, returns `false` for cycles, functions, `Date`\n * instances, class instances, `NaN`, and `±Infinity`. Arrays and plain records\n * are walked with an ancestor set so recursive input fails instead of hanging.\n * The whole walk runs inside `holds`, as `.claude/rules/patterns.md`\n * § Validation and contracts requires: a hostile getter on a\n * record property, or a revoked `Proxy` anywhere in the structure, is caught\n * and yields `false` instead of escaping as a thrown error.\n *\n * @param value - The value to test\n * @returns True if the value has a JSON representation; false otherwise\n *\n * @example\n * ```ts\n * isJSONValue({ nested: [1, 'x', null] }) // true\n * isJSONValue(Number.NaN) // false\n * ```\n */\nexport function isJSONValue(value: unknown): value is JSONValue {\n\treturn holds(() => matchesJSONValue(value, new INTRINSICS.weakSet()))\n}\n\n/**\n * Determines whether a value is JSON-valid within the fixed container-depth limit.\n *\n * @remarks\n * Runs the total depth predicate before the existing JSON guard. These are\n * sequential observations of caller-owned input, not an atomic snapshot.\n *\n * @param value - The value to inspect\n * @returns True if the value is both depth-bounded and a valid {@link JSONValue}; false otherwise\n *\n * @example\n * ```ts\n * isBoundedJSONValue({ nested: [1] }) // true\n * isBoundedJSONValue(new Date()) // false\n * ```\n */\nexport function isBoundedJSONValue(value: unknown): value is JSONValue {\n\treturn matchesJSONDepth(value) && isJSONValue(value)\n}\n\n/**\n * Determines whether a value is a depth-bounded JSON record.\n *\n * @remarks\n * Requires the existing plain-record root invariant before applying\n * {@link isBoundedJSONValue}. Arrays therefore remain valid bounded JSON\n * values but never bounded JSON records.\n *\n * @param value - The value to inspect\n * @returns True if the value is a plain-record-rooted bounded JSON value; false otherwise\n *\n * @example\n * ```ts\n * isBoundedJSONRecord({ value: 1 }) // true\n * isBoundedJSONRecord([1]) // false\n * ```\n */\nexport function isBoundedJSONRecord(value: unknown): value is JSONRecord {\n\treturn isRecord(value) && isBoundedJSONValue(value)\n}\n\n/**\n * Determines whether a value is a primitive JSON value.\n *\n * @remarks\n * The flat leaf of any JSON document: `null`, a string, a **finite** number, or\n * a boolean. Uses {@link isFiniteNumber} (not {@link isNumber}) because real JSON\n * carries no `NaN` / `±Infinity` — `JSON.stringify(NaN)` is `'null'`.\n *\n * The recursive {@link isJSONValue} guard is shipped and stays total with\n * cycle-safe walking. Dedicated `isJSONObject` / `isJSONSchema` validators and\n * the broad `JSONSchemaDefinition` remain omitted; compose narrower shapes with\n * the combinators and gate untrusted strings with `parseJSON` / `parseJSONAs`.\n *\n * @param value - The value to test\n * @returns True if `value` is `null`, a string, a finite number, or a boolean; false otherwise\n *\n * @example\n * ```ts\n * isJSONPrimitive(null) // true\n * isJSONPrimitive('hi') // true\n * isJSONPrimitive(42) // true\n * isJSONPrimitive(Number.NaN) // false — not representable in JSON\n * isJSONPrimitive({}) // false\n * ```\n */\nexport function isJSONPrimitive(value: unknown): value is JSONPrimitive {\n\treturn isNull(value) || isString(value) || isFiniteNumber(value) || isBoolean(value)\n}\n","import type {\n\tArrayRead,\n\tArrayShape,\n\tAuditFault,\n\tBoundsRead,\n\tContainOptions,\n\tContractCode,\n\tContractAdmission,\n\tContractRefusal,\n\tContractInterface,\n\tFaultTextOptions,\n\tContractShape,\n\tEntryCollectorFunction,\n\tFailure,\n\tFault,\n\tFaultKind,\n\tFieldPath,\n\tGuard,\n\tGuardShapeRead,\n\tGuardsShape,\n\tJSONSchema,\n\tJSONValue,\n\tLengthReader,\n\tNumberShape,\n\tRandomFunction,\n\tReadValueOptions,\n\tResult,\n\tSampleMemo,\n\tSchemaFormat,\n\tStringShape,\n\tSuccess,\n} from './types.js'\nimport {\n\tCLONE_NODE_LIMIT,\n\tCOMPILE_NODE_LIMIT,\n\tCONTRACT_CODES,\n\tFORMAT_PATTERNS,\n\tFAULT_LIMIT,\n\tFAULT_TEXT_LIMIT,\n\tFAULT_LIST_LIMIT,\n\tFAULT_SCHEMA_LIMIT,\n\tGUARD_DEPTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tJSON_SCHEMA_TYPES,\n\tPREVIEW_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tisBigInt,\n\tisArray,\n\tisError,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisMap,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n\tisSymbol,\n\tisWeakMap,\n} from './validators.js'\n\n/**\n * Admits a stable readable value with only lossless repairs and returns the parser's value.\n *\n * @remarks\n * Reads must remain stable across artifacts. Guard-valid input skips both reports and parses\n * once. Repairs use audit, parse once, and explain only on parse failure. Unresolved unions,\n * extras, lossy repairs, and a capped audit refuse. An own optional undefined field omitted or\n * filled by its declared default is not a repair. The result preserves parser ownership, including union input identity.\n * A read failure returns its cause rather than throwing.\n * Snapshot a foreign object before admission, as Tool.execute does. A getter changing between\n * is and parse can publish a value that no recorded repair describes. A shallow snapshot only\n * stabilizes its own level; nested foreign values must also provide stable reads.\n *\n * @example\n * ```ts\n * admitValue(createContract(numberShape()), '3') // success carrying 3 and its type repair\n * ```\n */\nexport function admitValue<T>(\n\tcontract: ContractInterface<T>,\n\tvalue: unknown,\n): Result<ContractAdmission<T>, ContractRefusal> {\n\ttry {\n\t\tif (contract.is(value)) {\n\t\t\tconst parsed = contract.parse(value)\n\t\t\tif (parsed === undefined && value !== undefined) return failure({ faults: [] })\n\t\t\treturn success({ value: parsed === undefined ? value : parsed, repairs: [] })\n\t\t}\n\t\tconst audited = contract.audit(value)\n\t\tconst parsed = contract.parse(value)\n\t\tconst explained = parsed === undefined ? contract.explain(value) : []\n\t\tconst repairs = audited.filter((fault) => matchesLosslessRepair(fault, value, parsed))\n\t\tconst refused = audited.filter(\n\t\t\t(fault) => !repairs.includes(fault) && !matchesUndefinedField(fault, value, parsed),\n\t\t)\n\t\tconst merged = [...explained, ...refused]\n\t\tconst faults = [\n\t\t\t...new Map(\n\t\t\t\tmerged.map((fault) => [JSON.stringify([fault.reason, extractPath(fault)]), fault]),\n\t\t\t).values(),\n\t\t]\n\t\tconst covers = faults\n\t\t\t.filter((fault) => fault.reason === 'variant' || fault.reason === 'oneOf')\n\t\t\t.map((fault) => extractPath(fault))\n\t\tconst uncovered = faults.filter((fault) => {\n\t\t\tconst path = extractPath(fault)\n\t\t\tconst room = fault.reason === 'variant' || fault.reason === 'oneOf' ? 1 : 0\n\t\t\treturn !covers.some(\n\t\t\t\t(cover) =>\n\t\t\t\t\tcover.length + room <= path.length &&\n\t\t\t\t\tcover.every((segment, index) => segment === path[index]),\n\t\t\t)\n\t\t})\n\t\tif (uncovered.length > 0) return failure({ faults: limitEntries(uncovered, FAULT_LIMIT) })\n\t\tif (audited.length >= FAULT_LIMIT)\n\t\t\treturn failure({ faults: limitEntries(audited, FAULT_LIMIT) })\n\t\tif (parsed === undefined) return failure({ faults: limitEntries(audited, FAULT_LIMIT) })\n\t\treturn success({ value: parsed, repairs })\n\t} catch (cause) {\n\t\treturn failure({ faults: [], cause })\n\t}\n}\n\n/**\n * Checks whether a type fault describes an own undefined field omitted or defaulted by a successful parse.\n *\n * @remarks\n * Reads own members directly so absence and an unreadable member cannot stand for undefined.\n * A compiled parser fills an undefined field only through its declared default; it never coerces it.\n * Required reads propagate their cause to the admission boundary.\n *\n * @example\n * ```ts\n * matchesUndefinedField({ reason: 'type', path: ['note'], expected: 'string', received: 'undefined' }, { note: undefined }, {}) // true\n * ```\n */\nexport function matchesUndefinedField(fault: AuditFault, value: unknown, parsed: unknown): boolean {\n\tif (fault.reason !== 'type' || parsed === undefined) return false\n\tconst path = extractPath(fault)\n\tconst key = path.at(-1)\n\tif (key === undefined) return false\n\tconst parents = path\n\t\t.slice(0, -1)\n\t\t.reduce<readonly [unknown, unknown]>(\n\t\t\t([raw, result], segment) => [\n\t\t\t\tisObject(raw) && INTRINSICS.own(raw, segment)\n\t\t\t\t\t? INTRINSICS.reflect.read(raw, segment)\n\t\t\t\t\t: undefined,\n\t\t\t\tisObject(result) && INTRINSICS.own(result, segment)\n\t\t\t\t\t? INTRINSICS.reflect.read(result, segment)\n\t\t\t\t\t: undefined,\n\t\t\t],\n\t\t\t[value, parsed],\n\t\t)\n\tconst [raw, result] = parents\n\treturn (\n\t\tisObject(raw) &&\n\t\tINTRINSICS.own(raw, key) &&\n\t\tINTRINSICS.reflect.read(raw, key) === undefined &&\n\t\tisObject(result)\n\t)\n}\n\n/**\n * Truncates text to a UTF-16 budget without splitting a surrogate pair.\n *\n * @example\n * ```ts\n * truncateFaultText('abcdef', 4) // 'abc…'\n * ```\n */\nexport function truncateFaultText(text: string, limit: number): string {\n\tif (limit <= 0) return ''\n\tif (text.length <= limit) return text\n\treturn `${text.slice(0, limit - 1).replace(/[\\uD800-\\uDBFF]$/u, '')}…`\n}\n\n/**\n * Describes bounded faults with encoded values and a schema-derived correction summary.\n *\n * @remarks\n * Default: 2048 UTF-16 code units. A smaller non-negative integer limit reserves a caller's\n * heading budget. The report reserves room for omitted-fault and cap notices, and ends with a\n * send summary when a schema is supplied. Untrusted names, descriptions, and strings use preview.\n *\n * @example\n * ```ts\n * describeFaults([{ reason: 'missing', path: ['age'], expected: 'number' }])\n * // 'age: missing; expected number'\n * ```\n */\nexport function describeFaults(\n\tfaults: readonly AuditFault[],\n\tschema?: JSONSchema,\n\toptions?: FaultTextOptions,\n): string {\n\tconst requested = options?.limit ?? FAULT_TEXT_LIMIT\n\tif (!isInteger(requested) || requested < 0) {\n\t\tthrow new ContractError('Fault text limit must be a non-negative integer', { code: 'range' })\n\t}\n\tconst limit = Math.min(requested, FAULT_TEXT_LIMIT)\n\tconst send =\n\t\tschema === undefined\n\t\t\t? ''\n\t\t\t: `send ${renderForm(schema, Math.min(FAULT_SCHEMA_LIMIT, Math.floor(limit / 3)))}`\n\tconst lines = limitEntries(faults, FAULT_LIMIT).map((fault) =>\n\t\tdescribeFaultLine(fault, schema ?? {}),\n\t)\n\tconst room = Math.max(0, limit - send.length - 82)\n\tconst kept = lines.filter((_, index) => lines.slice(0, index + 1).join('\\n').length <= room)\n\tconst hidden = faults.length - kept.length\n\tconst note = [\n\t\t...(hidden > 0 ? [`and ${String(hidden)} more faults`] : []),\n\t\t...(faults.length >= FAULT_LIMIT ? [`the report stops at ${String(FAULT_LIMIT)}`] : []),\n\t].join(', ')\n\tconst text = [\n\t\t...kept,\n\t\t...(kept.length === 0 && lines.length > 0 && room > 0\n\t\t\t? [truncateFaultText(lines[0] ?? '', room)]\n\t\t\t: []),\n\t\t...(note.length === 0 ? [] : [note]),\n\t\t...(send.length === 0 ? [] : [send]),\n\t].join('\\n')\n\treturn truncateFaultText(text, limit)\n}\n\n/**\n * Iterates indices while rereading the upper bound before every step.\n *\n * @remarks\n * Uses a captured native cursor and never reads an element or a caller's\n * iterator. Fractional bounds include the last index below the bound.\n *\n * @param read - Reads the current upper bound\n * @returns The indices below each observed bound\n *\n * @example\n * ```ts\n * Array.from(iterateIndices(() => 3)) // [0, 1, 2]\n * ```\n */\nexport function* iterateIndices(read: LengthReader): Generator<number, void, unknown> {\n\tconst cursor = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.indices,\n\t\t{\n\t\t\tget length() {\n\t\t\t\tconst length = read()\n\t\t\t\treturn length > 0 ? INTRINSICS.ceil(length) : 0\n\t\t\t},\n\t\t},\n\t\t[],\n\t)\n\twhile (true) {\n\t\tconst step: IteratorResult<number> = INTRINSICS.reflect.apply(INTRINSICS.advance, cursor, [])\n\t\tif (step.done) return\n\t\tyield step.value\n\t}\n}\n\n/**\n * Exposes indexed reads through a non-array receiver without species dispatch.\n *\n * @remarks\n * Captured array methods read length, membership, and elements lazily through\n * the source receiver. The view is not an array, so native map, filter, and\n * flatMap never consult its constructor or species. Their callback's collection\n * argument is this view. No source element is observed while constructing it.\n *\n * @param values - The array whose live indexed reads and membership are forwarded\n * @returns A non-array receiver for captured array methods\n *\n * @example\n * ```ts\n * INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView([1, 2]), [\n * \t(value: number) => value * 2,\n * ]) // [2, 4]\n * ```\n */\nexport function readIndexView(values: readonly unknown[]): object {\n\treturn new INTRINSICS.proxy(\n\t\t{ __proto__: null },\n\t\t{\n\t\t\tget(_target, key) {\n\t\t\t\treturn INTRINSICS.reflect.read(values, key)\n\t\t\t},\n\t\t\thas(_target, key) {\n\t\t\t\treturn INTRINSICS.reflect.present(values, key)\n\t\t\t},\n\t\t},\n\t)\n}\n\n/**\n * Builds a diagnostic path from an existing path and further segments, without\n * dispatching through array iteration.\n *\n * @remarks\n * `[...path, key]` reads well and dispatches through\n * `Array.prototype[Symbol.iterator]`, a member every caller can write — and the\n * damaging installation is not a thrower but a LIAR. An iterator yielding one\n * extra value before the array's real contents turns a refusal this package\n * authored into `path: ['INJECTED', 'properties', 'INJECTED']`, so the caller\n * writes their own text into a diagnostic this package published. An indexed\n * walk reads only own index properties of an array this package owns, and a\n * rest parameter collects its arguments without an iterator either, so nothing\n * on the path is caller-reachable.\n *\n * @param path - The path segments accumulated so far\n * @param segments - Further segments to append in order; an absent segment is\n * omitted, so an optional level needs no branch at the call site\n * @returns A fresh path carrying every existing segment and each new one\n *\n * @example\n * ```ts\n * pathOf(['properties'], 'age') // ['properties', 'age']\n * pathOf(path) // an owned copy\n * ```\n */\nexport function pathOf(\n\tpath: readonly string[],\n\t...segments: ReadonlyArray<string | undefined>\n): readonly string[] {\n\tconst existing = INTRINSICS.from(\n\t\titerateIndices(() => path.length),\n\t\t(index) => path[index],\n\t)\n\tconst added = INTRINSICS.from(\n\t\titerateIndices(() => segments.length),\n\t\t(index) => segments[index],\n\t)\n\tconst combined = INTRINSICS.from(\n\t\titerateIndices(() => existing.length + added.length),\n\t\t(index) => (index < existing.length ? existing[index] : added[index - existing.length]),\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(combined), [\n\t\t(segment: string | undefined) => segment !== undefined,\n\t])\n}\n\n/**\n * Appends every element of one array onto another, by index.\n *\n * @remarks\n * The sibling of {@link pathOf}, for the other shape the same defect takes.\n * `target[target.length] = ...source` and `[summary, ...rest]` both dispatch through\n * `Array.prototype[Symbol.iterator]`, and a caller-installed iterator that\n * yields one extra value writes the caller's text into a diagnostic this\n * package publishes as its own. Both operands here are arrays this package\n * built, and an indexed read of an own index property dispatches through\n * nothing.\n *\n * @param target - The array to extend in place\n * @param source - The elements to append, read by index\n *\n * @example\n * ```ts\n * appendEntries(faults, compileReporter(inner, raw, pathOf(path, key)))\n * ```\n */\nexport function appendEntries<T>(target: T[], source: readonly T[]): void {\n\tfor (const index of iterateIndices(() => source.length)) {\n\t\tconst entry = source[index]\n\t\t// A hole is skipped rather than materialized as a present `undefined`: the\n\t\t// arrays this appends are dense reports this package built, so the branch\n\t\t// exists to keep the honest typing rather than to hide a case.\n\t\tif (entry === undefined) continue\n\t\ttarget[target.length] = entry\n\t}\n}\n\n/**\n * Takes at most `limit` leading elements of an array, by index.\n *\n * @remarks\n * `Array.prototype.slice` is a caller-writable member on every path that bounds\n * a published report, so a substitute decides how much of a diagnostic the\n * caller sees. Returns the input untouched when it already fits, so a bounded\n * report allocates nothing in the ordinary case.\n *\n * @param entries - The entries to bound\n * @param limit - The maximum number of leading entries to retain\n * @returns The input when it already fits, otherwise a fresh bounded copy\n *\n * @example\n * ```ts\n * limitEntries(faults, FAULT_LIMIT)\n * ```\n */\nexport function limitEntries<T>(entries: readonly T[], limit: number): readonly T[] {\n\tif (entries.length <= limit) return entries\n\tconst selected = INTRINSICS.from(\n\t\titerateIndices(() => limit),\n\t\t(index) => entries[index],\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(selected), [\n\t\t(entry: T | undefined) => entry !== undefined,\n\t])\n}\n\n/**\n * Orders two primitive keys or indices ascending.\n *\n * @remarks\n * The comparison {@link sortValues} hands to the captured sort, extracted rather\n * than written inline. `Reflect.apply` takes its arguments as a LIST, so an\n * inline comparator is a function expression inside an array literal rather than\n * one passed directly as an argument — a hidden function assignment, which this\n * repository forbids wherever it appears because a function that is not a named\n * declaration is a function no caller can reach and no test can exercise. As a\n * declaration it is both. The comparison is `<` / `>` on primitives, which\n * dispatches through nothing: no `valueOf`, no `toString`, and no member a\n * caller can replace, so the order a published schema is emitted in is decided\n * by the values and not by the environment.\n *\n * @param left - The value ordered first when it compares lower\n * @param right - The value compared against\n * @returns `-1`, `1`, or `0` as `left` sorts before, after, or with `right`\n *\n * @example\n * ```ts\n * comparePrimitives('a', 'b') // -1\n * ```\n */\nexport function comparePrimitives<T extends string | number>(left: T, right: T): number {\n\treturn left < right ? -1 : left > right ? 1 : 0\n}\n\n/**\n * Orders primitive keys or indices deterministically, on an owned copy, through\n * the captured sort.\n *\n * @remarks\n * Every schema this package emits is ordered so the same input produces the\n * same bytes, and `Array.prototype.sort` is a caller-writable member on every\n * one of those paths: a substitute that empties its receiver made\n * `valueToSchema({ b: 1, a: 2 })` publish `{\"type\":\"object\",\"additionalProperties\":false}`\n * — a successful answer with the caller's properties silently gone. The copy is\n * taken first so a caller-owned array is never reordered in place, and the order\n * is decided by {@link comparePrimitives}, whose `<` / `>` comparison dispatches\n * through nothing.\n *\n * @param values - The keys or indices to order\n * @returns A fresh array in ascending order\n *\n * @example\n * ```ts\n * sortValues(['b', 'a']) // ['a', 'b']\n * ```\n */\nexport function sortValues<T extends string | number>(values: readonly T[]): readonly T[] {\n\tconst observed = INTRINSICS.from(\n\t\titerateIndices(() => values.length),\n\t\t(index) => values[index],\n\t)\n\tconst owned: T[] = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t(value: T | undefined) => value !== undefined,\n\t])\n\tINTRINSICS.reflect.apply(INTRINSICS.order, owned, [comparePrimitives])\n\treturn owned\n}\n\n// === Captured membership, visitation, and pattern reads\n\n/**\n * Collects an array's entries into a membership collection this package owns.\n *\n * @remarks\n * THE builder behind every declared vocabulary, and the first half of the answer\n * to a defect that survived three rounds by moving rather than closing. A guard\n * deciding membership with `set.has(value)` answers whatever the caller most\n * recently installed on `Set.prototype`, and answering it instead through the\n * `has` method of an exported class only moved the writable member one prototype\n * up: `Vocabulary.prototype.has = () => true` reproduced the whole defect at\n * nineteen door groups. There is no property lookup here to redirect —\n * membership is asked of a MODULE BINDING, which the specification makes\n * immutable to every importer, over operations {@link INTRINSICS} captured while\n * it evaluated.\n *\n * Collection is by INDEX rather than from an iterable on purpose:\n * `new Set(values)` reads `Symbol.iterator` off the argument and `add` off the\n * instance, so building from an iterable would reintroduce two replaceable\n * dispatches to remove one.\n * A captured native union consumes the owned indexed snapshot through a cursor\n * whose `next` is bound to the captured array advance operation.\n *\n * @param values - The members to collect, read by index\n * @returns A collection no caller holds a reference to\n *\n * @example\n * ```ts\n * const allowed = collectMembers(['admin', 'guest'])\n * matchesMember(allowed, 'admin') // true\n * ```\n */\nexport function collectMembers(values: readonly unknown[]): Set<unknown> {\n\tconst indices = iterateIndices(() => values.length)\n\tconst entries = INTRINSICS.from(indices, (index) => values[index])\n\treturn INTRINSICS.reflect.apply(INTRINSICS.union, new INTRINSICS.set<unknown>(), [\n\t\t{\n\t\t\tsize: entries.length,\n\t\t\thas(value: unknown): boolean {\n\t\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, entries, [\n\t\t\t\t\t(entry: unknown) => entry === value || INTRINSICS.same(entry, value),\n\t\t\t\t])\n\t\t\t},\n\t\t\tkeys(): Iterator<unknown> {\n\t\t\t\tconst cursor = INTRINSICS.reflect.apply(INTRINSICS.iterator, entries, [])\n\t\t\t\treturn {\n\t\t\t\t\tnext: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.advance, [cursor]),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t])\n}\n\n/**\n * Determines whether a value is a member of a collected vocabulary, by\n * SameValueZero.\n *\n * @remarks\n * Dispatched through the captured `Set.prototype.has` onto a collection no caller\n * holds, and asked as a module binding rather than as a property: `set.has(value)` asks\n * a member every caller can rewrite, and moving that read onto an exported class's\n * `has` method reproduced the identical defect one prototype higher, because every\n * public class method is dispatched through a reachable prototype.\n *\n * @param members - The vocabulary to ask, built by {@link collectMembers}\n * @param value - The value to test for membership\n * @returns True if the value was collected; false otherwise\n *\n * @example\n * ```ts\n * matchesMember(collectMembers([Number.NaN]), Number.NaN) // true — SameValueZero\n * ```\n */\nexport function matchesMember(members: ReadonlySet<unknown>, value: unknown): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.member, members, [value]) === true\n}\n\n/**\n * Collects one more member into a vocabulary that grows as a walk proceeds.\n *\n * @remarks\n * Collects through the captured adder, for a vocabulary that grows as a walk proceeds —\n * a uniqueness gate, a de-duplicating key population.\n *\n * @param members - The vocabulary to extend\n * @param value - The value to admit\n *\n * @example\n * ```ts\n * const seen = collectMembers([])\n * admitMember(seen, 'a')\n * matchesMember(seen, 'a') // true\n * ```\n */\nexport function admitMember(members: Set<unknown>, value: unknown): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.admit, members, [value])\n}\n\n/**\n * Determines whether an object is already on a traversal's active path.\n *\n * @remarks\n * The visitation half, and the one an earlier ruling wrongly excused as safe\n * because \"a redirect corrupts it inside a boundary and the door refuses, which\n * is loud\". It is not loud in the direction that matters:\n * `WeakSet.prototype.has` answering `false` does not make a cyclic clone refuse,\n * it removes the door's termination bound, and a door that never returns is the\n * one failure a containment boundary cannot report. Every walk's termination\n * therefore rests on a captured operation rather than on a caller-writable one.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object to test\n * @returns True if the object is already on the active path; false otherwise\n *\n * @example\n * ```ts\n * const active = new WeakSet<object>()\n * admitVisited(active, node)\n * matchesVisited(active, node) // true\n * ```\n */\nexport function matchesVisited(visited: WeakSet<object>, value: object): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.tracked, visited, [value]) === true\n}\n\n/**\n * Records an object as entered on a traversal's active path.\n *\n * @remarks\n * Records through the captured `WeakSet.prototype.add`, on the same terms {@link\n * matchesVisited} states for the membership answer.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object being entered\n *\n * @example\n * ```ts\n * admitVisited(active, node)\n * ```\n */\nexport function admitVisited(visited: WeakSet<object>, value: object): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.track, visited, [value])\n}\n\n/**\n * Records an object as exited from a traversal's active path.\n *\n * @remarks\n * Records through the captured `WeakSet.prototype.delete`, on the same terms {@link\n * matchesVisited} states for the membership answer.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object being exited\n *\n * @example\n * ```ts\n * omitVisited(active, node)\n * ```\n */\nexport function omitVisited(visited: WeakSet<object>, value: object): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.untrack, visited, [value])\n}\n\n/**\n * Records one node's answer at one remaining-depth allowance in a shared memo.\n *\n * @remarks\n * A depth-bounded walk answers the same node differently depending on how much\n * allowance was left when it arrived, so each node keeps a `Map` of answers\n * inside one `WeakMap`. Written inline, the get-or-create ferried that map out\n * of the branch that built it through a `let`, three times over across the two\n * container branches of value inference and the schema-inversion walk. Written\n * once it is one statement per caller, and the captured `WeakMap`/`Map` members\n * stay the only ones all three dispatch through — a substituted `WeakMap.prototype.get` that\n * answered a decoy map would otherwise decide what a later call replays.\n *\n * @param memo - The per-node depth memo this walk owns\n * @param node - The source node the answer was computed for\n * @param depth - The remaining-depth allowance the answer was computed under\n * @param answer - The answer to record for that node at that allowance\n *\n * @example\n * ```ts\n * const memo = new WeakMap<object, Map<number, string>>()\n * retainDepth(memo, node, 8, 'answer')\n * memo.get(node)?.get(8) // 'answer'\n * ```\n */\nexport function retainDepth<T>(\n\tmemo: WeakMap<object, Map<number, T>>,\n\tnode: object,\n\tdepth: number,\n\tanswer: T,\n): void {\n\tconst known = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [node])\n\tconst depths = known || new INTRINSICS.map<number, T>()\n\tif (!known) INTRINSICS.reflect.apply(INTRINSICS.retain, memo, [node, depths])\n\tINTRINSICS.reflect.apply(INTRINSICS.store, depths, [depth, answer])\n}\n\n/**\n * Builds one empty {@link SampleMemo} node.\n *\n * @remarks\n * The root a multi-sample walk starts from and the node every further row\n * prefix is grown into, built from the CAPTURED `WeakMap` and `Map` so a\n * replaced global cannot decide what a published schema is served from. One\n * memo belongs to one walk: {@link samplesToSchema} builds one at the door and\n * grows a fresh node per row prefix inside it.\n *\n * @returns An empty memo node with no recorded rows and no recorded schemas\n *\n * @example\n * ```ts\n * buildSampleMemo() // { rows: WeakMap {}, schemas: Map {} }\n * ```\n */\nexport function buildSampleMemo(): SampleMemo {\n\treturn { rows: new INTRINSICS.weakMap<object, SampleMemo>(), schemas: new INTRINSICS.map() }\n}\n\n/**\n * Checks that a value really is a {@link SampleMemo} before a walk stores a\n * published schema in it.\n *\n * @remarks\n * The memo reaches a `WeakMap` and a `Map` the walk stored a node in, and a\n * wrong value there fails inside the traversal and is published as\n * `samples could not be read` — a true refusal naming the wrong argument. This\n * refuses under the memo's own name and its own path instead. The multi-sample\n * walk asks it of every node it reads back out of its own prefix chain.\n *\n * @param memo - The candidate memo\n * @param reader - The door name the refusal is published under\n * @returns The same memo when it carries a real `rows` `WeakMap` and `schemas` `Map`\n * @throws {ContractError} When the memo is not a `SampleMemo`\n *\n * @example\n * ```ts\n * readSampleMemo(buildSampleMemo(), 'samplesToSchema') // the same memo\n * ```\n */\nexport function readSampleMemo(memo: SampleMemo, reader: string): SampleMemo {\n\tif (!isObject(memo) || !isWeakMap(memo.rows) || !isMap(memo.schemas)) {\n\t\tthrow new ContractError(`${reader}: memo must be a sample memo`, {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: ['memo'], limit: 'SampleMemo', received: preview(memo) },\n\t\t})\n\t}\n\treturn memo\n}\n\n/**\n * Builds the collector a captured `forEach` sweep appends through.\n *\n * @remarks\n * Extracted rather than written inline for the same reason\n * {@link comparePrimitives} is: `Reflect.apply` takes its arguments as a LIST, so an\n * inline collector is a function expression inside an array literal rather than\n * one passed directly as an argument — a hidden function assignment this\n * repository forbids wherever it appears. Returned directly from a factory it is\n * both named and testable. Both sweeps hand the callback `(value, key)`; a `Set`\n * passes its entry in both positions, so one collector serves both.\n *\n * @param target - The pair list to append each swept entry onto\n * @returns The collector a captured `forEach` invokes per entry\n *\n * @example\n * ```ts\n * const collected: unknown[][] = []\n * new Set(['a']).forEach(collectEntries(collected)) // [['a', 'a']]\n * ```\n */\nexport function collectEntries(target: unknown[][]): EntryCollectorFunction {\n\treturn (value: unknown, key: unknown) => {\n\t\ttarget[target.length] = [key, value]\n\t}\n}\n\n/**\n * Snapshots the genuine contents of a caller's `Set` without running an iterator.\n *\n * @remarks\n * `Set.prototype[Symbol.iterator]` is a caller-writable member, and every other\n * view of the same collection disagrees with a replaced one: an iterator that\n * silently skips the non-string in `new Set(['a', 42])` made `setOf(isString)`\n * answer `true` while `forEach` and `size` still reported the real contents. The\n * sibling `arrayOf` already read its caller's collection through captured\n * reflection, so the exclusion was not even self-consistent within one file.\n * `forEach` is the only complete view of `[[SetData]]` that runs no iterator, so\n * it is dispatched here from the captured table.\n *\n * @param value - The set whose genuine entries to snapshot\n * @returns A frozen entry snapshot, or a failure carrying the exact thrown value\n *\n * @example\n * ```ts\n * readSetEntries(new Set(['a', 42])) // { success: true, value: ['a', 42] }\n * ```\n */\nexport function readSetEntries(value: ReadonlySet<unknown>): Result<readonly unknown[]> {\n\treturn attempt(() => {\n\t\tconst collected: unknown[][] = []\n\t\tINTRINSICS.reflect.apply(INTRINSICS.sweep, value, [collectEntries(collected)])\n\t\tconst entries: readonly unknown[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(collected),\n\t\t\t[(pair: readonly unknown[]) => pair[1]],\n\t\t)\n\t\treturn INTRINSICS.freeze(entries)\n\t})\n}\n\n/**\n * Snapshots the genuine entries of a caller's `Map` without running an iterator.\n *\n * @remarks\n * The `Map` half of {@link readSetEntries}, with one further replaceable\n * dispatch removed: destructuring `for (const [key, value] of map)` reads\n * `Map.prototype[Symbol.iterator]` AND `Array.prototype[Symbol.iterator]` for\n * every pair, so a substituting iterator could rename a key or replace a value\n * while every downstream structural check still passed. Each pair is read\n * positionally from a list this package built.\n *\n * @param value - The map whose genuine entries to snapshot\n * @returns A frozen `[key, value]` pair snapshot, or a failure carrying the exact thrown value\n *\n * @example\n * ```ts\n * readMapEntries(new Map([['a', 1]])) // { success: true, value: [['a', 1]] }\n * ```\n */\nexport function readMapEntries(\n\tvalue: ReadonlyMap<unknown, unknown>,\n): Result<ReadonlyArray<readonly unknown[]>> {\n\treturn attempt(() => {\n\t\tconst collected: unknown[][] = []\n\t\tINTRINSICS.reflect.apply(INTRINSICS.pairs, value, [collectEntries(collected)])\n\t\treturn INTRINSICS.freeze(collected)\n\t})\n}\n\n/**\n * Reads a regular expression's source text through the captured accessor.\n *\n * @remarks\n * `RegExp.prototype.source` is an ACCESSOR on a shared prototype, so replacing\n * its getter changes what every pattern in the realm reports — not only the\n * caller's own. A getter answering `'.*'` made `compileSchema` publish\n * `pattern: \".*\"` inside a frozen schema and made `isRegExp('x')` answer `true`.\n * Reading the descriptor per call, as an earlier round did, captures nothing:\n * capture is decided by WHEN the reference is taken.\n *\n * @param pattern - The candidate regular expression to read\n * @returns The pattern's source text, or `undefined` when it cannot be read as a string\n * @throws The exact value the captured accessor throws for a receiver that is not a pattern\n *\n * @example\n * ```ts\n * readPatternSource(/^a+$/) // '^a+$'\n * ```\n */\nexport function readPatternSource(pattern: unknown): string | undefined {\n\tconst read = INTRINSICS.expression\n\tif (read === undefined) return undefined\n\tconst source: unknown = INTRINSICS.reflect.apply(read, pattern, [])\n\treturn isString(source) ? source : undefined\n}\n\n/**\n * Reads a regular expression's flag text through the captured accessor.\n *\n * @remarks\n * The flags half of {@link readPatternSource}, on the same captured-accessor terms and\n * for the same reason.\n *\n * @param pattern - The candidate regular expression to read\n * @returns The pattern's flag text, or `undefined` when it cannot be read as a string\n * @throws The exact value the captured accessor throws for a receiver that is not a pattern\n *\n * @example\n * ```ts\n * readPatternFlags(/^a+$/giu) // 'giu'\n * ```\n */\nexport function readPatternFlags(pattern: unknown): string | undefined {\n\tconst read = INTRINSICS.modifiers\n\tif (read === undefined) return undefined\n\tconst flags: unknown = INTRINSICS.reflect.apply(read, pattern, [])\n\treturn isString(flags) ? flags : undefined\n}\n\n/**\n * Determines whether a string is in the language of a pattern this package owns.\n *\n * @remarks\n * The pattern-membership answer, asked exactly as {@link matchesMember} asks the\n * literal one, and asked through `exec` rather than `test` on purpose:\n * `RegExp.prototype.test` is spec-defined in terms of `RegExpExec`, which\n * re-reads `exec` off the receiver, so even a CAPTURED `test` still answers\n * whatever the caller installed. Replacing either member decided what `matchOf`,\n * `stringOf`, `contract.is`, `contract.parse`, `audit`, `explain` and the format\n * inferers published — a wrong yes for a non-member and a wrong no for a member,\n * silently.\n *\n * @param pattern - The owned pattern to apply\n * @param value - The string to test\n * @returns True if the pattern genuinely matches; false otherwise\n *\n * @example\n * ```ts\n * matchesPattern(/^[0-9a-f]+$/, '1a2f') // true\n * ```\n */\nexport function matchesPattern(pattern: RegExp, value: string): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.captures, pattern, [value]) !== null\n}\n\n/**\n * Checks whether a string's length in code points falls within optional bounds.\n *\n * @remarks\n * Counts what JSON Schema's `minLength` and `maxLength` count: a surrogate pair is\n * one, and a lone surrogate is one. A string holds at most `.length` code points and\n * at least half that, so `.length` decides every bound it can with no count. The\n * count runs only where a bound sits between those two figures, which limits its\n * work to about twice the bound rather than to the size of the string.\n *\n * @param value - The string to measure\n * @param min - The inclusive lower bound, when there is one\n * @param max - The inclusive upper bound, when there is one\n * @returns True if the code-point count is within every present bound; false otherwise\n *\n * @example\n * ```ts\n * matchesStringLength('😀😀', undefined, 2) // true\n * matchesStringLength('😀', 2, undefined) // false\n * ```\n */\nexport function matchesStringLength(\n\tvalue: string,\n\tmin: number | undefined,\n\tmax: number | undefined,\n): boolean {\n\tconst length = value.length\n\tif (min !== undefined && length < min) return false\n\tif (max !== undefined && length > 2 * max) return false\n\tif (\n\t\t(min === undefined || INTRINSICS.ceil(length / 2) >= min) &&\n\t\t(max === undefined || length <= max)\n\t) {\n\t\treturn true\n\t}\n\t// The code points are the units less the pairs. `max` holds at `length - max` pairs,\n\t// and `min` fails one past `length - min`, so the walk stops at whichever it reaches.\n\tconst pairs = computeSurrogatePairs(value, length - (min === undefined ? (max ?? 0) : min - 1))\n\tconst points = length - pairs\n\treturn (min === undefined || points >= min) && (max === undefined || points <= max)\n}\n\n/**\n * Counts the surrogate pairs in a string, stopping at a limit.\n *\n * @remarks\n * A regular-expression literal builds a fresh `RegExp` per evaluation, so this call\n * owns the `lastIndex` that is its cursor, and the captured `exec` reads the internal\n * slots and no member a caller can replace. Text with no surrogate costs one native\n * scan, and a string of pairs costs one `exec` per pair up to the limit.\n *\n * @param value - The string to scan\n * @param limit - The count to stop at\n * @returns The number of surrogate pairs, or `limit` when the string holds at least that many\n *\n * @example\n * ```ts\n * computeSurrogatePairs('😀a😀', 8) // 2\n * computeSurrogatePairs('😀😀😀', 2) // 2\n * ```\n */\nexport function computeSurrogatePairs(value: string, limit: number): number {\n\tconst pair = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g\n\tconst steps = limit > 0 ? INTRINSICS.ceil(limit) : 0\n\tfor (const step of iterateIndices(() => steps)) {\n\t\tif (INTRINSICS.reflect.apply(INTRINSICS.captures, pair, [value]) === null) return step\n\t}\n\treturn steps\n}\n\n/**\n * Refuses an options record that holds a key its builder does not read.\n *\n * @remarks\n * The door for an option that decides what a contract accepts, where a misspelled key\n * would otherwise read as an absent option and fail open. It looks at own enumerable\n * string keys, so an inherited or symbol-keyed member is not a misspelling.\n *\n * @param source - The builder options, when there are any\n * @param keys - The keys that builder reads\n * @param builder - The builder name used in the refusal\n * @param shape - The shape category used in structured error context\n * @throws {ContractError} When the record holds any other key\n *\n * @example\n * ```ts\n * refuseOptionKeys({ strict: true }, ['strict'], 'schemaToShape', 'schema') // returns\n * refuseOptionKeys({ strct: true }, ['strict'], 'schemaToShape', 'schema') // throws\n * ```\n */\nexport function refuseOptionKeys(\n\tsource: object | undefined,\n\tkeys: readonly string[],\n\tbuilder: string,\n\tshape: string,\n): void {\n\tif (source === undefined) return\n\tconst strays: readonly string[] = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.select,\n\t\treadIndexView(INTRINSICS.keys(source)),\n\t\t[\n\t\t\t(key: string) =>\n\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, keys, [(name: string) => name === key]),\n\t\t],\n\t)\n\tconst first = strays[0]\n\tif (first === undefined) return\n\tconst known: string = INTRINSICS.reflect.apply(INTRINSICS.join, keys, [', '])\n\tthrow new ContractError(\n\t\t`${builder}: unknown option ${preview(first)}; the options are ${known}`,\n\t\t{ code: 'structure', context: { path: [first], shape } },\n\t)\n}\n\n/**\n * Escapes every regular-expression metacharacter in a text, so the text\n * matches literally inside a larger `RegExp` source.\n *\n * @remarks\n * Prefixes each of `\\ ^ $ . * + ? ( ) [ ] { } |` with a backslash and leaves\n * every other character, `-` and `/` included, unchanged; the empty string\n * returns unchanged. The escape is an INDEXED character map rather than\n * `String.prototype.replace`, which dispatches through the caller-writable\n * `RegExp.prototype[Symbol.replace]` and `exec` members.\n *\n * @param value - The literal text to escape\n * @returns The text with every metacharacter backslash-escaped\n *\n * @example\n * ```ts\n * escapeRegExp('a.b*c') // 'a\\\\.b\\\\*c'\n * new RegExp(`^${escapeRegExp('a.b')}$`).test('axb') // false\n * ```\n */\nexport function escapeRegExp(value: string): string {\n\tconst metacharacters = collectMembers([\n\t\t'\\\\',\n\t\t'^',\n\t\t'$',\n\t\t'.',\n\t\t'*',\n\t\t'+',\n\t\t'?',\n\t\t'(',\n\t\t')',\n\t\t'[',\n\t\t']',\n\t\t'{',\n\t\t'}',\n\t\t'|',\n\t])\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => value.length),\n\t\t(index) => (matchesMember(metacharacters, value[index]) ? `\\\\${value[index]}` : value[index]),\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n}\n\n/**\n * Rebuilds a caller's regular expression as a stateless pattern this package\n * owns.\n *\n * @remarks\n * Strips the stateful `g` / `y` flags so repeated checks are stable and the\n * caller's `lastIndex` never moves. The strip is an INDEXED character filter\n * rather than `String.prototype.replaceAll`, which is itself a caller-writable\n * member: a substitute answering `'i'` made `matchOf(/^abc$/)` accept `'ABC'` —\n * the package building a case-insensitive pattern the developer never wrote.\n *\n * @param pattern - The caller's regular expression\n * @returns An owned, stateless equivalent\n * @throws The exact value thrown when the pattern's source or flags cannot be read\n *\n * @example\n * ```ts\n * readPattern(/^a+$/gy) // /^a+$/\n * ```\n */\nexport function readPattern(pattern: RegExp): RegExp {\n\tconst source = readPatternSource(pattern)\n\tconst flags = readPatternFlags(pattern)\n\tif (source === undefined || flags === undefined) {\n\t\tthrow new INTRINSICS.error('Pattern source and flags could not be read')\n\t}\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => flags.length),\n\t\t(index) => flags[index],\n\t)\n\tconst selected = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(characters), [\n\t\t(flag: string | undefined) => flag !== undefined && flag !== 'g' && flag !== 'y',\n\t])\n\tconst stateless: string = INTRINSICS.reflect.apply(INTRINSICS.join, selected, [''])\n\treturn new INTRINSICS.pattern(source, stateless)\n}\n\n/**\n * Rebuilds a declaration's regular expression as a stateless pattern this\n * package owns, and refuses an unreadable one under the reader's own name.\n *\n * @remarks\n * The one construction the compiled string leaves and `stringOf` share.\n * {@link readPattern} strips `g` and `y`, so the result carries no `lastIndex`\n * an answer could move and one rebuild answers every value alike — which is\n * what lets a compiled door take the read while the plan is built and hold the\n * rebuild for the plan's life, instead of minting a `RegExp` per answered\n * value. The read runs through {@link readValue}, so a source or flags that\n * cannot be read refuses with this module's uniform `pattern` diagnostic under\n * the reader that asked, rather than with the host's raw `TypeError`.\n *\n * @param pattern - The declaration's regular expression to rebuild\n * @param reader - The public reader name the diagnostic carries\n * @returns An owned, stateless equivalent of the declaration's pattern\n * @throws {ContractError} Thrown when the pattern's source or flags cannot be\n * read, coded `pattern` as `<reader>: pattern could not be read`\n *\n * @example\n * ```ts\n * ownPattern(/^a+$/gy, 'stringOf') // /^a+$/\n * ```\n */\nexport function ownPattern(pattern: RegExp, reader: string): RegExp {\n\treturn readValue(() => readPattern(pattern), reader, {\n\t\tsubject: 'pattern',\n\t\tcode: 'pattern',\n\t\tcontext: { shape: 'string' },\n\t})\n}\n\n/**\n * Pins every own member of a class prototype as a non-configurable member —\n * non-writable too when it is a data property — and verify the pin took.\n *\n * @remarks\n * The other half of the structural answer. Membership answers moved off class\n * methods entirely, but a class this package EXPORTS still has methods its own\n * modules dispatch through — `cloneShape` reaches `ShapeCloner.prototype.clone`,\n * and one assignment there made `compileSchema` publish whatever the caller\n * chose while `compileSchema` itself was never touched. That is the same defect\n * as a replaced host member with the package's own name on it, so every exported\n * class pins its prototype while it is DEFINED.\n *\n * The pin buys exactly this: no code that runs AFTER this class is defined can\n * replace a member on its prototype. It reaches no earlier, in exactly the case\n * {@link INTRINSICS} already states and does not defend — ESM evaluates imports\n * in source order, so a module that evaluates before this package has already\n * run.\n *\n * Placement goes through the captured `Reflect.defineProperty`, which ANSWERS\n * instead of throwing, and the answer is then corroborated by reading the\n * descriptor back. Installing is not reading: a pin that silently did not happen\n * is indistinguishable from one that did until something asks, so this asks. The\n * residual is named rather than denied: an adversary who also answers the\n * verifying descriptor read defeats this, and that adversary already chose what\n * {@link INTRINSICS} captured.\n *\n * {@link ContractError} is the one exempt class, and it inlines this body rather\n * than calling it: `errors.ts` sits beneath this module in the graph — this file\n * imports it — so reaching back for the helper would invert the dependency, the\n * same reason {@link isContractError} carries its own `try` / `catch`. That copy\n * is held aligned with this one, accessor branch and answering placement\n * included. Every other exported class calls this helper.\n *\n * @param prototype - The class prototype to pin\n * @param owner - The class name used in the refusal\n * @throws {ContractError} When a member cannot be pinned or the pin cannot be verified\n *\n * @example\n * ```ts\n * class Widget { static { pinMembers(Widget.prototype, 'Widget') } }\n * ```\n */\nexport function pinMembers(prototype: object, owner: string): void {\n\tconst members = INTRINSICS.reflect.members(prototype)\n\tfor (const index of iterateIndices(() => members.length)) {\n\t\tconst key = members[index]\n\t\tif (key === undefined) continue\n\t\t// An ACCESSOR is pinned by its configurability alone. `writable` belongs to\n\t\t// a data property, and asking for it on a getter REPLACES the accessor with\n\t\t// a data property holding `undefined` — a pin that silently deletes the\n\t\t// member it was protecting, which is the failure mode this whole helper\n\t\t// exists to make impossible.\n\t\tconst declared = INTRINSICS.describe(prototype, key)\n\t\tconst accessor = declared !== undefined && !INTRINSICS.own(declared, 'value')\n\t\tINTRINSICS.reflect.define(\n\t\t\tprototype,\n\t\t\tkey,\n\t\t\taccessor ? { configurable: false } : { writable: false, configurable: false },\n\t\t)\n\t\tconst pinned = INTRINSICS.describe(prototype, key)\n\t\tif (pinned?.configurable !== false || (!accessor && pinned.writable !== false)) {\n\t\t\tthrow new ContractError(`${owner}: a prototype member could not be pinned`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape: owner, received: preview(key) },\n\t\t\t})\n\t\t}\n\t}\n}\n\n// === Result helpers\n\n/**\n * Boxes a value as the {@link Success} branch of a {@link Result}.\n *\n * @param value - The value to box, retained exactly\n * @returns A fresh `{ success: true, value }` record\n *\n * @example\n * ```ts\n * success(42) // { success: true, value: 42 }\n * ```\n */\nexport function success<T>(value: T): Success<T> {\n\treturn { success: true, value }\n}\n\n/**\n * Boxes an error as the {@link Failure} branch of a {@link Result}.\n *\n * @param error - The error to box, retained exactly\n * @returns A fresh `{ success: false, error }` record\n *\n * @example\n * ```ts\n * failure('offline') // { success: false, error: 'offline' }\n * ```\n */\nexport function failure<E>(error: E): Failure<E> {\n\treturn { success: false, error }\n}\n\n/**\n * Narrows a {@link Result} to its {@link Success} branch.\n *\n * @param result - The result to narrow\n * @returns True if the result succeeded; false otherwise\n *\n * @example\n * ```ts\n * isSuccess(success(1)) // true\n * ```\n */\nexport function isSuccess<T, E>(result: Result<T, E>): result is Success<T> {\n\treturn result.success\n}\n\n/**\n * Narrows a {@link Result} to its {@link Failure} branch.\n *\n * @param result - The result to narrow\n * @returns True if the result failed; false otherwise\n *\n * @example\n * ```ts\n * isFailure(failure('offline')) // true\n * ```\n */\nexport function isFailure<T, E>(result: Result<T, E>): result is Failure<E> {\n\treturn !result.success\n}\n\n/**\n * Invokes a callback once and synchronously captures its exact outcome as a\n * {@link Result}.\n *\n * @remarks\n * The sanctioned never-throw boundary for the guards, required by\n * `.claude/rules/patterns.md` § Validation and contracts. The\n * `whereOf`, `lazyOf`, and `transformOf` combinators invoke caller-supplied\n * callbacks *inside* a guard body, yet a guard must NEVER throw — it returns a\n * `boolean`. This converts a throwing callback into a `Failure` so the\n * surrounding guard can treat it as a non-match instead of propagating the\n * exception, written once and shared rather than copy-pasted as ad-hoc\n * `try`/`catch`. The return or thrown value is retained exactly and is never\n * inspected, coerced, cloned, frozen, or mutated. A returned Promise or\n * thenable is an ordinary successful value; later settlement is outside this\n * synchronous boundary. {@link isContractError} does not use this boundary and\n * is not an exception to it: it carries its own `try`/`catch` inside the class\n * body, because `errors.ts` cannot import this module without inverting the\n * dependency. A guard whose totality rests on an\n * argument that nothing inside it can throw is one refactor away from throwing.\n *\n * @param callback - The callback to invoke with no arguments\n * @returns A `Success` carrying the exact return value, or a `Failure` carrying\n * the exact thrown value as `unknown`\n *\n * @example\n * ```ts\n * const outcome = attempt(() => predicate(value))\n * return isSuccess(outcome) && outcome.value\n * ```\n */\nexport function attempt<T>(callback: () => T): Result<T> {\n\ttry {\n\t\treturn success(callback())\n\t} catch (error) {\n\t\treturn failure(error)\n\t}\n}\n\n/**\n * Renders a thrown value as a non-empty message.\n *\n * @remarks\n * Reads an `Error`'s `message` and converts any other value with the `String`\n * function {@link INTRINSICS} captured at load, so a symbol renders as\n * `Symbol(description)` and a caller that replaces the global `String` does not\n * change the result. Returns `'unknown failure'` when\n * that read throws, as a throwing `message` getter or `toString` method does,\n * when an `Error`'s `message` is not a string, and when the rendered text is\n * empty. Never throws.\n *\n * @param error - The caught value, of any shape\n * @returns The rendered message, never empty\n *\n * @example\n * ```ts\n * errorToMessage(new Error('boom')) // 'boom'\n * errorToMessage('') // 'unknown failure'\n * ```\n */\nexport function errorToMessage(error: unknown): string {\n\tconst read = attempt(() => (isError(error) ? error.message : INTRINSICS.text(error)))\n\treturn isSuccess(read) && isString(read.value) && read.value.length > 0\n\t\t? read.value\n\t\t: 'unknown failure'\n}\n\n/**\n * Reads a value through the shared containment boundary or refuses it with the\n * contract module's uniform read diagnostic.\n *\n * @remarks\n * Unlike {@link attempt}, this is not an optional-result boundary: a caller\n * has committed to reading the supplied value, so a failed read cannot be\n * represented as absence or another permissive answer. Every reader using\n * this helper throws with the same `<reader>: <subject> could not be read`\n * message shape and retains the exact thrown value as its cause. Required\n * structural readers use the defaults; pattern readers supply `pattern` for\n * both the subject and code.\n *\n * @param callback - The read operation to perform\n * @param reader - The public reader name used in the diagnostic\n * @param options - Optional subject, code, and structured context\n * @returns The successfully read value\n * @throws {ContractError} When the read operation fails\n *\n * @example\n * ```ts\n * readValue(() => source.value, 'parseRecord')\n * ```\n */\nexport function readValue<T>(callback: () => T, reader: string, options?: ReadValueOptions): T {\n\tconst diagnostics = attempt(() => {\n\t\tconst source = options?.context\n\t\t// Every consumed field is projected through a literal that already OWNS\n\t\t// every consumed name, so an absent field resolves to that own `undefined`\n\t\t// instead of leaving the container for `Object.prototype` — which every\n\t\t// caller can write. An unqualified `source.path` on a context literal\n\t\t// carrying only `shape` is an ordinary `Get`, and it walked, so a polluted\n\t\t// prototype chose what a refusal this module authored published and\n\t\t// retained the caller's object by identity. Spread copies own enumerable\n\t\t// properties only through the spec's own copy operation, so the projection\n\t\t// stays own-only without dispatching through a replaceable global. The\n\t\t// copy stays EAGER because performing it is what refuses a hostile\n\t\t// context: a throwing getter on any own key — advertised or not — must\n\t\t// refuse this call whether or not the callback goes on to succeed.\n\t\tconst owned =\n\t\t\tsource === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tpath: undefined,\n\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\tlimit: undefined,\n\t\t\t\t\t\treceived: undefined,\n\t\t\t\t\t\t...source,\n\t\t\t\t\t}\n\t\tconst requested = options?.code\n\t\tconst subject = options?.subject\n\t\t// Membership over the one declared vocabulary, not a re-spelled chain of\n\t\t// equality tests: a copy of the union written here drifts from it silently,\n\t\t// and the copy this replaced had already lost `expansion`, so a door asking\n\t\t// for that code published `structure` instead.\n\t\tconst code: ContractCode =\n\t\t\trequested !== undefined &&\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, CONTRACT_CODES, [\n\t\t\t\t(known: ContractCode) => known === requested,\n\t\t\t])\n\t\t\t\t? requested\n\t\t\t\t: 'structure'\n\t\treturn {\n\t\t\treader: isString(reader) ? reader : 'readValue',\n\t\t\tsubject: isString(subject) ? subject : 'value',\n\t\t\tcode,\n\t\t\towned,\n\t\t}\n\t})\n\tif (isFailure(diagnostics)) {\n\t\tthrow new ContractError('readValue: options could not be read', {\n\t\t\tcode: 'structure',\n\t\t\tcause: diagnostics.error,\n\t\t})\n\t}\n\tconst outcome = attempt(callback)\n\tif (isFailure(outcome)) {\n\t\t// Only a refusal publishes a context, so the published object is assembled\n\t\t// in this branch rather than beside the copy. `owned` already holds copied\n\t\t// values, so assembling it outside the contained read cannot throw.\n\t\tconst owned = diagnostics.value.owned\n\t\tconst context =\n\t\t\towned === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\t...(owned.path === undefined ? {} : { path: owned.path }),\n\t\t\t\t\t\t...(owned.shape === undefined ? {} : { shape: owned.shape }),\n\t\t\t\t\t\t...(owned.limit === undefined ? {} : { limit: owned.limit }),\n\t\t\t\t\t\t...(owned.received === undefined ? {} : { received: owned.received }),\n\t\t\t\t\t}\n\t\tthrow new ContractError(\n\t\t\t`${diagnostics.value.reader}: ${diagnostics.value.subject} could not be read`,\n\t\t\t{\n\t\t\t\tcode: diagnostics.value.code,\n\t\t\t\t...(context === undefined ? {} : { context }),\n\t\t\t\tcause: outcome.error,\n\t\t\t},\n\t\t)\n\t}\n\treturn outcome.value\n}\n\n/**\n * Runs a public door's whole body and publishes only this package's error class.\n *\n * @remarks\n * The other half of the answer {@link INTRINSICS} gives, and the half that does\n * not depend on anyone enumerating anything. Capture removes a named dispatch;\n * this removes the CONSEQUENCE of every dispatch a door's path still makes,\n * named or not. Four consecutive rounds fixed the statements they were shown\n * and were defeated by a statement one line later, because a boundary placed\n * per statement is only ever as complete as the last sweep. A boundary at the\n * door composes: whatever the body reaches, and whatever a caller installs\n * under it, the door publishes a {@link ContractError} or the value it\n * promised.\n *\n * A {@link ContractError} reaching this boundary passes through by identity —\n * the diagnosis a door spent its whole body computing is the point of the door,\n * and rewrapping it would demote it to a cause. The mechanism is\n * {@link isContractError}, which establishes CLASS MEMBERSHIP; it does not and\n * cannot establish that this package authored the error, and the passthrough is\n * described by what it tests rather than by what it intends. Anything else is a\n * host failure the caller arranged, so it is republished under the door's own\n * name with the exact thrown value retained as `cause`.\n *\n * Its population is exactly the public doors that can refuse — every door whose\n * TSDoc carries `@throws {ContractError}`, and no door whose body cannot throw\n * at all. A wrapper around a body that only allocates a closure buys nothing\n * and misreports where the refusals are.\n *\n * Use {@link readValue} instead where a single read has its own subject and\n * deserves its own diagnostic; use this where the subject is the door.\n *\n * @param callback - The door body to run\n * @param door - The public door name used in the diagnostic\n * @param options - Optional code and structured context for the published refusal\n * @returns The body's exact return value\n * @throws {ContractError} The body's own refusal, or a coded translation of a host failure\n *\n * @example\n * ```ts\n * export function nullShape(options?: NullShapeOptions): NullShape {\n * \treturn contain(() => buildNullShape(options), 'nullShape')\n * }\n * ```\n */\nexport function contain<T>(callback: () => T, door: string, options?: ContainOptions): T {\n\tconst outcome = attempt(callback)\n\tif (isSuccess(outcome)) return outcome.value\n\tif (isContractError(outcome.error)) throw outcome.error\n\tthrow new ContractError(`${door}: a host operation this door depends on failed`, {\n\t\tcode: options?.code ?? 'structure',\n\t\t...(options?.context === undefined ? {} : { context: options.context }),\n\t\tcause: outcome.error,\n\t})\n}\n\n/**\n * Invokes a predicate through the sanctioned never-throw boundary.\n *\n * @remarks\n * Backs the `instanceof`-based validators and every container combinator's element\n * walk. The answer is `true` only for the boolean literal `true`; a throw and every\n * other return are `false`.\n *\n * @param callback - The predicate to invoke with no arguments\n * @returns True if the callback returns the boolean value `true`; false otherwise\n *\n * @example\n * ```ts\n * holds(() => value instanceof Widget) // false when inspection throws\n * ```\n */\nexport function holds(callback: () => boolean): boolean {\n\tconst outcome = attempt(callback)\n\treturn isSuccess(outcome) && outcome.value === true\n}\n\n/**\n * Determines whether a value carries the plain-record brand, raising a hostile\n * prototype observation instead of answering it.\n *\n * @remarks\n * THE single record-brand rule: a plain record is a non-array object whose\n * prototype is `null`, or is a realm's `Object.prototype`. Realm-agnosticism is\n * why the second arm cannot compare against this realm's\n * `Object.prototype` — a plain object from another `vm.Context`, iframe, or\n * worker inherits from THAT realm's `Object.prototype`, which is a different\n * object. The earlier rule accepted any prototype that itself had a `null`\n * prototype, which every realm's `Object.prototype` satisfies — and so does a\n * class prototype a caller reparented to `null`, which is how a class instance\n * laundered through every ownership door. A foreign `Object.prototype` is\n * therefore identified by the own members ECMAScript requires every realm to\n * put on it (`constructor`, `hasOwnProperty`, `isPrototypeOf`,\n * `propertyIsEnumerable`, `toLocaleString`, `toString`, `valueOf`), each read\n * through its own DESCRIPTOR so no accessor on a hostile prototype ever runs.\n * Each must be an own DATA property whose value is a FUNCTION — true of every\n * conformant realm, so the requirement costs a genuine foreign record nothing,\n * and it refuses the cheapest forgery (stamping the mandated names with\n * `undefined`) for free.\n *\n * That is a structural test, not a provenance one, and the residual is stated\n * as exactly what it is: a FUNCTION-VALUED forgery passes, and this realm's own\n * `Object.prototype` supplies those functions to stamp, so the price is a\n * few lines rather than nothing. Reparenting a class prototype to `null` and\n * stamping the mandated names with real functions passes; so does leaving the\n * class untouched and putting a `Proxy` in prototype position that reports\n * `null` as its own prototype and answers those descriptor reads with\n * functions. In both cases the value is a live class instance whose methods are\n * still reachable on it. A further own-key SUBSET rule buys even less: it\n * refuses a forgery that left methods on its prototype and accepts the same\n * class with those methods moved onto the instance, where they are\n * indistinguishable from a plain record's function\n * properties — so it raises the forgery's price and narrows the realm-agnostic\n * arm this rule exists to keep open. What the pass buys is acceptance at\n * brand-governed doors and nothing after it: every ownership engine publishes a\n * frozen plain record built only from captured data, so no class instance,\n * class behavior, or forged prototype survives into a snapshot.\n *\n * `Object.create(<null-prototype object>)` is refused, and NOT because it is\n * structurally identical to a reparented class instance — it is not, since a\n * class prototype always owns `constructor` and a bare `Object.create(null)`\n * owns nothing. It is refused as policy: no realm produces that chain for a\n * plain object, no consumer of it has been named, and a caller erases the\n * difference by deleting `constructor`.\n *\n * This is the diagnosing form, deliberately NOT total: a revoked `Proxy` or a\n * hostile `getPrototypeOf` trap throws out of it, so an ownership engine can\n * report an unreadable value as a failed read with the exact cause rather than\n * as a well-formed structural refusal. {@link isRecord} is the total form for\n * every guard consumer and contains that throw as `false`.\n *\n * @param value - The value whose record brand to inspect\n * @returns True if the value is a plain record; false otherwise\n * @throws The exact value thrown by a hostile brand observation\n *\n * @example\n * ```ts\n * matchesRecordBrand({}) // true\n * matchesRecordBrand(Object.create(null)) // true\n * matchesRecordBrand(new Date()) // false\n * ```\n */\nexport function matchesRecordBrand(value: unknown): boolean {\n\tif (!isObject(value) || INTRINSICS.array(value)) return false\n\tconst prototype = INTRINSICS.prototype(value)\n\tif (prototype === null || prototype === INTRINSICS.base) return true\n\tif (INTRINSICS.prototype(prototype) !== null) return false\n\tconst mandated = [\n\t\t'constructor',\n\t\t'hasOwnProperty',\n\t\t'isPrototypeOf',\n\t\t'propertyIsEnumerable',\n\t\t'toLocaleString',\n\t\t'toString',\n\t\t'valueOf',\n\t]\n\t// Indexed, not iterated: `for…of` over an array this module built still reads\n\t// `Array.prototype[Symbol.iterator]`, a caller-writable member, and an\n\t// iterator yielding a name this list never held decides a brand verdict.\n\tfor (const index of iterateIndices(() => mandated.length)) {\n\t\tconst member = mandated[index]\n\t\tif (member === undefined) return false\n\t\t// A descriptor read, not a value read: it answers ownership, data-ness and\n\t\t// the member's kind in one observation while running no accessor a hostile\n\t\t// prototype installed. Every realm's members are function-valued data\n\t\t// properties, so requiring that costs a genuine realm nothing and costs a\n\t\t// forger the work of finding seven functions to stamp.\n\t\tconst descriptor = INTRINSICS.describe(prototype, member)\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) return false\n\t\tif (typeof descriptor.value !== 'function') return false\n\t}\n\treturn true\n}\n\n/**\n * Snapshots an array through its reflected own-index population.\n *\n * @remarks\n * Reads `length` once and one reflected own-key population, then corroborates\n * and reads only those reflected canonical indices in ascending order. The\n * frozen native snapshot retains actual holes: reading one yields `undefined`,\n * while own membership remains absent. Its work is proportional to the\n * reflected population, so a length-driven consumer must require `dense` or\n * carry an independent bound. A population that is exactly the canonical\n * indices in ascending order followed by `length` is copied straight by index\n * under the same per-index corroboration, and answers with the same entries,\n * the same `dense` fact, and the same refusals as the walk. Caller-defined\n * iteration is ignored. A descriptor-only index omitted from reflection is\n * deliberately outside this lens and remains a hole. Failure retains the exact\n * thrown value when length, reflection, membership, or indexed value\n * observation throws; a non-native length or view disagreement is also\n * failure. `4294967295` is metadata rather than an array index.\n *\n * @param value - The array whose reflected indexed entries to read\n * @returns A successful frozen entry snapshot with its dense fact, or a\n * failure carrying the exact thrown value as `unknown`\n *\n * @example\n * ```ts\n * readArrayEntries([1, 2]) // { success: true, value: { entries: [1, 2], dense: true } }\n * ```\n */\nexport function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>> {\n\treturn attempt(() => {\n\t\tconst length = value.length\n\t\tif (!INTRINSICS.safe(length) || length < 0 || length > 2 ** 32 - 1) {\n\t\t\tthrow new INTRINSICS.error('Array length is outside the native array domain')\n\t\t}\n\t\tconst members = INTRINSICS.reflect.members(value)\n\t\t// One canonicality question, asked once: the reported population is the\n\t\t// ascending index texts and `length`, and nothing else. The scan stops at\n\t\t// the first disagreement, so a population that fails the question pays for\n\t\t// the prefix it shares with a canonical one before it walks.\n\t\tconst canonical =\n\t\t\tmembers.length === length + 1 &&\n\t\t\tmembers[length] === 'length' &&\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(key: PropertyKey, index: number) => index < length && key !== INTRINSICS.text(index),\n\t\t\t])\n\t\tif (canonical) {\n\t\t\tconst packed = INTRINSICS.from(\n\t\t\t\titerateIndices(() => length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t\t\t}\n\t\t\t\t\treturn value[index]\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn INTRINSICS.freeze({ entries: INTRINSICS.freeze(packed), dense: true })\n\t\t}\n\t\tconst selected: ReadonlyArray<{ readonly index: number; readonly key: string }> =\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t(key: PropertyKey) => {\n\t\t\t\t\tif (!isString(key)) return []\n\t\t\t\t\tconst index = INTRINSICS.numeric(key)\n\t\t\t\t\tif (\n\t\t\t\t\t\t!INTRINSICS.integer(index) ||\n\t\t\t\t\t\tindex < 0 ||\n\t\t\t\t\t\tindex >= 2 ** 32 - 1 ||\n\t\t\t\t\t\tINTRINSICS.text(index) !== key\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t\tif (index >= length) throw new INTRINSICS.error('Array index views disagree')\n\t\t\t\t\treturn [{ index, key }]\n\t\t\t\t},\n\t\t\t])\n\t\tconst collected: readonly number[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(selected),\n\t\t\t[(entry: { readonly index: number }) => entry.index],\n\t\t)\n\t\tconst keys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(selected),\n\t\t\t[(entry: { readonly key: string }) => entry.key],\n\t\t)\n\t\tconst ascending = !INTRINSICS.reflect.apply(INTRINSICS.some, collected, [\n\t\t\t(index: number, position: number) => index <= (collected[position - 1] ?? -1),\n\t\t])\n\t\t// Ordered on arrival, not by default: a caller-defined key view may deliver\n\t\t// the canonical indices in any order, so the sort answers that view alone\n\t\t// and the parallel key list carries the string already proven canonical\n\t\t// against its index, which the ordered arrival then never re-derives.\n\t\tconst indices = ascending ? collected : sortValues(collected)\n\t\tconst pairs = INTRINSICS.from(\n\t\t\titerateIndices(() => indices.length),\n\t\t\t(position) => {\n\t\t\t\tconst index = indices[position]\n\t\t\t\tconst key = ascending ? keys[position] : INTRINSICS.text(index)\n\t\t\t\tif (index === undefined || key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t\t}\n\t\t\t\treturn [key, { value: value[index], enumerable: true, configurable: true, writable: true }]\n\t\t\t},\n\t\t)\n\t\tconst descriptors = INTRINSICS.record<PropertyDescriptor>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t})\n\t\tconst entries = INTRINSICS.definitions(new INTRINSICS.list<T | undefined>(length), descriptors)\n\t\treturn INTRINSICS.freeze({\n\t\t\tentries: INTRINSICS.freeze(entries),\n\t\t\tdense: indices.length === length,\n\t\t})\n\t})\n}\n\n/**\n * Snapshots a guard shape and its optional-key mode for a shape combinator.\n *\n * @remarks\n * A null-prototype record plus its own key list is used instead of a `Map`.\n * The declared-key population decides the guard's answer, and\n * `Map.prototype.has`, `Map.prototype.get`, and map iteration are three\n * caller-writable members on that path. An own data key read by index\n * dispatches through nothing.\n *\n * @param shape - The guard shape whose own string declarations to snapshot\n * @param optional - The optional-key list, `true` for every key, or `undefined`\n * @param reader - The public combinator name used in read refusals\n * @returns The owned guards and names plus the collected optional-key membership\n * @throws {ContractError} When the shape or optional-key list cannot be read\n *\n * @example\n * ```ts\n * readGuardShape({ id: isString }, undefined, 'recordOf')\n * ```\n */\nexport function readGuardShape(\n\tshape: GuardsShape,\n\toptional: readonly string[] | true | undefined,\n\treader: string,\n): GuardShapeRead {\n\tconst declared = readValue(\n\t\t() => {\n\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[(key: PropertyKey) => isString(key)],\n\t\t\t)\n\t\t\tconst pairs = INTRINSICS.from(\n\t\t\t\titerateIndices(() => names.length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = names[index]\n\t\t\t\t\treturn [key, key === undefined ? undefined : shape[key]]\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst guards = INTRINSICS.rebase(\n\t\t\t\tINTRINSICS.record<Guard<unknown> | undefined>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t\tnull,\n\t\t\t)\n\t\t\treturn { guards, names, vocabulary: collectMembers(names) }\n\t\t},\n\t\treader,\n\t\t{ subject: 'shape' },\n\t)\n\tconst optionalKeys = readValue(\n\t\t() => {\n\t\t\tif (optional === true) return collectMembers(declared.names)\n\t\t\tif (!INTRINSICS.array(optional)) return collectMembers([])\n\t\t\tconst entries = readArrayEntries(optional)\n\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Optional key list must be dense')\n\t\t\treturn collectMembers(\n\t\t\t\tINTRINSICS.from(\n\t\t\t\t\titerateIndices(() => entries.value.entries.length),\n\t\t\t\t\t(index) => INTRINSICS.text(entries.value.entries[index]),\n\t\t\t\t),\n\t\t\t)\n\t\t},\n\t\treader,\n\t\t{ subject: 'optional' },\n\t)\n\n\treturn {\n\t\tguards: declared.guards,\n\t\tnames: declared.names,\n\t\toptional: optionalKeys,\n\t\tvocabulary: declared.vocabulary,\n\t}\n}\n\n/**\n * Snapshots an object's own enumerable string keys through a total boundary.\n *\n * @remarks\n * This is the package-wide runtime property view used by compiled object\n * guards, parsers, reporters, schema inference, and owned schema cloning. It\n * matches the object-key view serialized by `JSON.stringify`: inherited,\n * symbol, and non-enumerable properties are excluded. A hostile Proxy trap\n * returns `undefined` rather than escaping.\n *\n * @param value - The object whose keys to snapshot\n * @returns A frozen owned key list, or `undefined` when enumeration throws\n *\n * @example\n * ```ts\n * enumerableKeys({ visible: 1 }) // ['visible']\n * ```\n */\nexport function enumerableKeys(value: object): readonly string[] | undefined {\n\t// `Object.keys` already returns a fresh own array, so it is frozen directly:\n\t// the copy it replaces was an array SPREAD, which dispatches through\n\t// `Array.prototype[Symbol.iterator]` — a caller-writable member — and sat\n\t// outside the boundary, so a redirected iterator threw the caller's raw value\n\t// out of a helper documented to answer `undefined`, and out of every compiled\n\t// guard and parser layered on it.\n\tconst outcome = attempt(() => INTRINSICS.freeze(INTRINSICS.keys(value)))\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Validates and snapshots a shape-builder options record through every reflective\n * operation the builder relies on.\n *\n * @remarks\n * Primitive inputs are rejected before reflection so ordinary caller mistakes\n * retain the reader's precise plain-record diagnostic. For an object, every\n * consumed key is read exactly once, checked for presence, and inspected for an\n * own descriptor while the container is enumerated once. Every successfully\n * read non-`undefined` consumed value enters the fresh own-enumerable snapshot,\n * including an inherited or non-enumerable option. A hostile host is reported\n * uniformly as an unreadable options record, while a readable array or class\n * instance retains the plain-record diagnostic.\n *\n * @param source - The optional builder options value\n * @param keys - Every option key consumed by that builder\n * @param builder - The builder name used in diagnostics\n * @param shape - The shape category used in structured error context\n * @returns An owned options snapshot, or `undefined` when options are absent\n * @throws {ContractError} When the value is not a plain record or reflection fails\n *\n * @example\n * ```ts\n * const options = readOptions(source, ['min', 'max'], 'numberShape', 'number')\n * ```\n */\nexport function readOptions<T extends object>(\n\tsource: T | undefined,\n\tkeys: ReadonlyArray<keyof T & string>,\n\tbuilder: string,\n\tshape: string,\n): T | undefined {\n\treturn contain(() => {\n\t\tif (source === undefined) return undefined\n\t\tconst input: unknown = source\n\t\tif (!isObject(input)) {\n\t\t\tthrow new ContractError(`${builder}: options must be a plain record`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape },\n\t\t\t})\n\t\t}\n\t\tconst result = readValue(\n\t\t\t() => {\n\t\t\t\t// A null-prototype accumulator, indexed — not a `Map`. The values read\n\t\t\t\t// here become the builder's published options, and `Map.prototype.get`\n\t\t\t\t// is a caller-writable member: a substitute answering a decoy would put\n\t\t\t\t// the caller's value into a snapshot the builder swears it observed.\n\t\t\t\t// An own data key on a null-prototype object dispatches through nothing,\n\t\t\t\t// including for a key literally named '__proto__'.\n\t\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\t\tif (key === undefined) return undefined\n\t\t\t\t\t\tconst value = INTRINSICS.reflect.read(input, key)\n\t\t\t\t\t\tINTRINSICS.reflect.present(input, key)\n\t\t\t\t\t\tINTRINSICS.reflect.describe(input, key)\n\t\t\t\t\t\treturn [key, value]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t(entry: unknown) => entry !== undefined,\n\t\t\t\t])\n\t\t\t\tconst values = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tINTRINSICS.reflect.members(input)\n\t\t\t\tconst record = matchesRecordBrand(input)\n\t\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(\n\t\t\t\t\t\tINTRINSICS.from(\n\t\t\t\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t\t\t\t(index) => keys[index],\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t[(key: string | undefined) => key !== undefined && values[key] !== undefined],\n\t\t\t\t)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(names), [\n\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{ value: values[key], enumerable: true, configurable: true, writable: true },\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst snapshot: T = INTRINSICS.create(\n\t\t\t\t\tINTRINSICS.base,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn { snapshot, record }\n\t\t\t},\n\t\t\tbuilder,\n\t\t\t{ subject: 'options', context: { shape } },\n\t\t)\n\t\tif (!result.record) {\n\t\t\tthrow new ContractError(`${builder}: options must be a plain record`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape },\n\t\t\t})\n\t\t}\n\t\treturn result.snapshot\n\t}, 'readOptions')\n}\n\n/**\n * Draws and validates one generator random sample.\n *\n * @remarks\n * A broken source is the source's fault rather than the shape's, so the refusal\n * carries code `random` and never the `generate` code, and {@link compileGenerator}\n * rethrows it at whatever draw depth it happened instead of rotating to the next union\n * variant. The diagnostic names the consuming shape category, the `[0, 1)` limit, and a\n * total non-coercing {@link preview} of the offending sample (or `threw`), so a hostile\n * object runs no conversion hook while the diagnostic is built and a primitive symbol\n * renders without consulting mutable `Symbol.prototype.toString`.\n *\n * @param random - The caller-supplied random source\n * @param shape - The shape category consuming the sample\n * @returns A finite sample in `[0, 1)`\n * @throws {ContractError} When the source throws or returns outside `[0, 1)`;\n * a thrown value is retained exactly as the cause\n *\n * @example\n * ```ts\n * drawRandom(() => 0.5, 'number') // 0.5\n * ```\n */\nexport function drawRandom(random: RandomFunction, shape: string): number {\n\treturn contain(() => {\n\t\tconst outcome = attempt(random)\n\t\tif (isFailure(outcome)) {\n\t\t\tthrow new ContractError('drawRandom: the random source threw', {\n\t\t\t\tcode: 'random',\n\t\t\t\tcontext: { shape, limit: '[0, 1)', received: 'threw' },\n\t\t\t\tcause: outcome.error,\n\t\t\t})\n\t\t}\n\t\tconst sample = outcome.value\n\t\tif (!isFiniteNumber(sample) || sample < 0 || sample >= 1) {\n\t\t\tthrow new ContractError('drawRandom: the random source must return a value in [0, 1)', {\n\t\t\t\tcode: 'random',\n\t\t\t\tcontext: { shape, limit: '[0, 1)', received: preview(sample) },\n\t\t\t})\n\t\t}\n\t\treturn sample\n\t}, 'drawRandom')\n}\n\n// === Record-field access\n\n/**\n * Resolves a (possibly nested) field value from a record by a key or key path.\n *\n * @remarks\n * A single `string` is ONE key (never split on `.`, so dotted keys are safe); a\n * string array descends left-to-right through own properties of nested objects.\n * The root must satisfy {@link isRecord}; inherited properties are never fields.\n * Intermediates may be objects or arrays indexed by string. Returns `undefined`\n * the moment a segment is missing or lands on a non-object, so the lookup is\n * total — even against a hostile getter or Proxy trap that throws on read,\n * contained through {@link attempt} so the throw never escapes.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns The resolved value, or `undefined`\n *\n * @example\n * ```ts\n * resolveField({ user: { name: 'Ada' } }, ['user', 'name']) // 'Ada'\n * resolveField({ 'a.b': 1 }, 'a.b') // 1 (one key)\n * resolveField({ a: 1 }, ['a', 'b']) // undefined\n * ```\n */\nexport function resolveField(record: Readonly<Record<string, unknown>>, path: FieldPath): unknown {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(record)) return undefined\n\t\tconst keys = isString(path) ? [path] : path\n\t\tconst indices = iterateIndices(() => keys.length)\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.reduce, indices, [\n\t\t\t(current: unknown, index: number): unknown => {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined || !isObject(current) || !INTRINSICS.own(current, key)) {\n\t\t\t\t\t// Closing the cursor prevents even a later path-length observation.\n\t\t\t\t\tindices.return()\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.reflect.read(current, key)\n\t\t\t},\n\t\t\trecord,\n\t\t])\n\t})\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Determines whether an object holds exactly the named own keys.\n *\n * @remarks\n * Every required key must be own, and every own key, symbols and non-enumerable ones\n * included, must be named, so an inherited field and a stray one both answer `false`.\n *\n * @param value - The object to inspect\n * @param required - The keys it must own\n * @param optional - The keys it may own\n * @returns True if its own keys are exactly those; false otherwise\n *\n * @example\n * ```ts\n * matchesExactKeys({ a: 1 }, ['a']) // true\n * matchesExactKeys({ a: 1, b: 2 }, ['a']) // false\n * matchesExactKeys({ a: 1, b: 2 }, ['a'], ['b']) // true\n * ```\n */\nexport function matchesExactKeys(\n\tvalue: object,\n\trequired: readonly string[],\n\toptional: readonly string[] = [],\n): boolean {\n\tconst absent = INTRINSICS.reflect.apply(INTRINSICS.some, required, [\n\t\t(key: string) => !INTRINSICS.own(value, key),\n\t])\n\tif (absent) return false\n\treturn !INTRINSICS.reflect.apply(INTRINSICS.some, INTRINSICS.reflect.members(value), [\n\t\t(key: string | symbol) =>\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, required, [(name: string) => name === key]) &&\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, optional, [(name: string) => name === key]),\n\t])\n}\n\n/**\n * Determines whether a repair `parse` made kept everything the value said.\n *\n * @remarks\n * `parse`'s coercions are published and form input relies on them, but some change what\n * a value means: `1` to `true`, `'9007199254740993'` to `...992`, `'1e-400'` to `0`,\n * `'0x10'` to `16`. A door that must not guess asks this about each fault `audit` reported,\n * since `audit` already names every nested repair with its path and the kind it wanted.\n *\n * Only a `type` fault is a repair. A number needs a string whose trim is the number's own\n * text, so `'30'` and `' 30 '` pass while `'30.0'`, `'007'`, `'0x10'`, `'1e3'`, `'+5'`,\n * `'.5'`, `'-0'`, and `'9007199254740993'` do not. A boolean needs `'true'` or `'false'`,\n * a literal its trimmed text, and a string a finite number. Anything else refuses.\n *\n * @param fault - A fault `audit` reported\n * @param input - The value as it arrived\n * @param parsed - What `parse` made of it\n * @returns True if the repair loses nothing; false otherwise\n *\n * @example\n * ```ts\n * const fault = { reason: 'type', path: ['a'], expected: 'number', received: '' } as const\n * matchesLosslessRepair(fault, { a: ' 30 ' }, { a: 30 }) // true\n * matchesLosslessRepair(fault, { a: '30.0' }, { a: 30 }) // false\n * ```\n */\nexport function matchesLosslessRepair(fault: AuditFault, input: unknown, parsed: unknown): boolean {\n\tif (fault.reason !== 'type') return false\n\tconst keys = isString(fault.path) ? [fault.path] : fault.path\n\tconst route = INTRINSICS.from(\n\t\titerateIndices(() => keys.length + 1),\n\t\t(index) => (index === 0 ? 'root' : (keys[index - 1] ?? '')),\n\t)\n\tconst raw = resolveField({ root: input }, route)\n\tconst value = resolveField({ root: parsed }, route)\n\tswitch (fault.expected) {\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn isString(raw) && isNumber(value) && raw.trim() === INTRINSICS.text(value)\n\t\tcase 'literal':\n\t\t\treturn (\n\t\t\t\tisString(raw) &&\n\t\t\t\t(isString(value) || isNumber(value) || isBoolean(value)) &&\n\t\t\t\traw.trim() === INTRINSICS.text(value)\n\t\t\t)\n\t\tcase 'boolean':\n\t\t\treturn raw === 'true' || raw === 'false'\n\t\tcase 'string':\n\t\t\treturn isFiniteNumber(raw)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\n/**\n * Determines whether a readable value stays within the fixed JSON container-depth limit.\n *\n * @remarks\n * Counts array and plain-record containers on each active root-to-value path.\n * Primitive and readable non-record objects are leaves, active cycles add no\n * level, and shared aliases are answered from the shallowest depth at which\n * the alias already fit. Arrays are traversed through their reflected\n * own-index population, so sparse work is proportional to populated entries\n * rather than advertised length. Every observable operation is contained;\n * hostile or contradictory reads return `false`.\n *\n * The walk carries a settled-depth memo beside its active-path set: a\n * container that fit at depth `d` also fits at any depth `<= d`, because every\n * path below it is then shallower than the one already measured. Without it a\n * node reachable by `k` distinct paths was re-walked `k` times, so an ORDINARY\n * record graph with thirty shared aliases — thirty-one nodes — cost `2^30`\n * visits through a public guard.\n *\n * @param value - The value whose readable container depth to inspect\n * @returns True if no active path exceeds {@link GUARD_DEPTH_LIMIT}; false otherwise\n *\n * @example\n * ```ts\n * matchesJSONDepth({ nested: [1] }) // true\n * ```\n */\nexport function matchesJSONDepth(value: unknown): boolean {\n\treturn holds(() => {\n\t\tconst stack: Array<\n\t\t\t| { readonly operation: 'enter'; readonly value: unknown; readonly depth: number }\n\t\t\t| { readonly operation: 'exit'; readonly value: object; readonly depth: number }\n\t\t> = [{ operation: 'enter', value, depth: 0 }]\n\t\tconst active = new INTRINSICS.weakSet<object>()\n\t\tconst settled = new INTRINSICS.weakMap<object, number>()\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack.pop()\n\t\t\tif (frame === undefined) return false\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tomitVisited(active, frame.value)\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, settled, [frame.value, frame.depth])\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst entry = frame.value\n\t\t\tif (entry === null || typeof entry !== 'object') continue\n\t\t\tconst array = INTRINSICS.array(entry)\n\t\t\tif (!array && !matchesRecordBrand(entry)) continue\n\t\t\tif (matchesVisited(active, entry)) continue\n\n\t\t\tconst depth = frame.depth + 1\n\t\t\tif (depth > GUARD_DEPTH_LIMIT) return false\n\t\t\t// Settled at a deeper start means every path below it was measured with\n\t\t\t// LESS headroom than this one has, so it cannot exceed the limit here.\n\t\t\tconst deepest: unknown = INTRINSICS.reflect.apply(INTRINSICS.recall, settled, [entry])\n\t\t\tif (isNumber(deepest) && depth <= deepest) continue\n\t\t\tadmitVisited(active, entry)\n\t\t\tstack[stack.length] = { operation: 'exit', value: entry, depth }\n\n\t\t\tif (array) {\n\t\t\t\tconst snapshot = readArrayEntries(entry)\n\t\t\t\tif (isFailure(snapshot)) return false\n\t\t\t\tconst children = INTRINSICS.values(snapshot.value.entries)\n\t\t\t\tfor (const index of iterateIndices(() => children.length)) {\n\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: children[index], depth }\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst keys = enumerableKeys(entry)\n\t\t\tif (keys === undefined) return false\n\t\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) return false\n\t\t\t\tif (!INTRINSICS.own(entry, key)) return false\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tvalue: INTRINSICS.reflect.read(entry, key),\n\t\t\t\t\tdepth,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t})\n}\n\n/**\n * Matches an unknown value against the recursive JSON value structure.\n *\n * @remarks\n * The caller-owned ancestor set tracks only the active traversal path, so\n * cycles fail while shared references across sibling branches remain valid.\n * The set belongs to one traversal from one entry point; passing a shared or\n * pre-populated set is unsupported. Arrays descend through the shared dense\n * own-index lens and plain records descend by values; class instances and\n * non-finite numbers are rejected.\n *\n * The walk is ITERATIVE, over an explicit enter/exit stack, exactly as\n * {@link matchesJSONDepth} is. A recursive walk makes the verdict a function of\n * the REMAINING CALL STACK rather than of the value, and a cap enforced by the\n * JavaScript stack is not a cap. This walk carries no depth cap of its own —\n * `isJSONValue` is deliberately the unbounded deep gate and\n * {@link matchesJSONDepth} / `isBoundedJSONValue` are the bounded pair beside\n * it — so the answer depends only on the value, at every depth and from every\n * call site.\n *\n * Beside the ancestor set the walk keeps a walk-local PROVED set, so a node\n * whose whole subtree already matched is not re-walked when a second path\n * reaches it. A supplied capture budget instead charges each occurrence that\n * ownership would copy; exhaustion throws `structure` with a `clone` cause.\n * Removing the recursion alone left the work exponential in shared\n * aliases: thirty aliases — thirty-one ordinary records — cost `2^30` visits\n * through `isJSONValue`, `parseJSONValue`, `canonicalStringify` and every\n * `jsonShape` contract.\n *\n * @param entry - The value to inspect\n * @param ancestors - Objects on the active traversal path\n * @param budget - Remaining capture nodes; aliases are charged for each copied occurrence when supplied\n * @returns True if the value is a cycle-free JSON value; false otherwise\n *\n * @example\n * ```ts\n * matchesJSONValue({ nested: [1, 'x', null] }, new WeakSet()) // true\n * matchesJSONValue(Number.NaN, new WeakSet()) // false\n * ```\n */\nexport function matchesJSONValue(\n\tentry: unknown,\n\tancestors: WeakSet<object>,\n\tbudget?: { left: number },\n): entry is JSONValue {\n\treturn readValue(\n\t\t() => {\n\t\t\tif (budget !== undefined) {\n\t\t\t\tif (!INTRINSICS.safe(budget.left)) {\n\t\t\t\t\tthrow new ContractError('matchesJSONValue: invalid node budget', { code: 'clone' })\n\t\t\t\t}\n\t\t\t\tbudget.left = INTRINSICS.min(budget.left, CLONE_NODE_LIMIT)\n\t\t\t}\n\t\t\tconst stack: Array<\n\t\t\t\t| { readonly operation: 'enter'; readonly value: unknown }\n\t\t\t\t| { readonly operation: 'exit'; readonly value: object }\n\t\t\t> = [{ operation: 'enter', value: entry }]\n\t\t\t// Walk-local, never the caller's set: a node whose WHOLE subtree already\n\t\t\t// matched needs no second walk. Soundness — if a proved node could reach\n\t\t\t// an ancestor active on some later path, that ancestor was inside the\n\t\t\t// proved node's own subtree, so the first walk descended into it, met the\n\t\t\t// proved node again while it was still active, and refused. A proved node\n\t\t\t// therefore cannot participate in a cycle any later path could discover.\n\t\t\tconst proved = new INTRINSICS.weakSet<object>()\n\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst frame = stack.pop()\n\t\t\t\tif (frame === undefined) return false\n\t\t\t\tif (frame.operation === 'exit') {\n\t\t\t\t\tomitVisited(ancestors, frame.value)\n\t\t\t\t\tadmitVisited(proved, frame.value)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif (budget !== undefined) {\n\t\t\t\t\tbudget.left -= 1\n\t\t\t\t\tif (budget.left < 0) {\n\t\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t\t`validateShape: default exceeds the capture node limit ${CLONE_NODE_LIMIT}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'clone',\n\t\t\t\t\t\t\t\tcontext: { limit: CLONE_NODE_LIMIT },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst node = frame.value\n\t\t\t\tif (node === null || isString(node) || isBoolean(node) || isFiniteNumber(node)) continue\n\t\t\t\tif (INTRINSICS.array(node)) {\n\t\t\t\t\tif (matchesVisited(ancestors, node)) return false\n\t\t\t\t\tif (budget === undefined && matchesVisited(proved, node)) continue\n\t\t\t\t\tconst snapshot = readArrayEntries(node)\n\t\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\t\tif (!snapshot.value.dense) return false\n\t\t\t\t\tadmitVisited(ancestors, node)\n\t\t\t\t\tstack[stack.length] = { operation: 'exit', value: node }\n\t\t\t\t\t// Pushed in reverse so the LIFO stack visits siblings in source order,\n\t\t\t\t\t// which is the order the recursive walk this replaced descended in.\n\t\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\t\tfor (const offset of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\tconst index = entries.length - 1 - offset\n\t\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: entries[index] }\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (!isRecord(node)) return false\n\t\t\t\tif (matchesVisited(ancestors, node)) return false\n\t\t\t\tif (budget === undefined && matchesVisited(proved, node)) continue\n\t\t\t\tadmitVisited(ancestors, node)\n\t\t\t\tstack[stack.length] = { operation: 'exit', value: node }\n\t\t\t\tconst members = INTRINSICS.values(node)\n\t\t\t\tfor (const offset of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst index = members.length - 1 - offset\n\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: members[index] }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true\n\t\t},\n\t\t'matchesJSONValue',\n\t\t{ context: { shape: 'json' } },\n\t)\n}\n\n/**\n * Counts the enumerable own-symbol keys on a value.\n *\n * @remarks\n * String keys are ignored — only `Object.getOwnPropertySymbols` entries whose\n * descriptor is `enumerable` are counted, and each descriptor is read through\n * the captured observation so no accessor runs. It answers exactly the\n * `JSON.stringify`-invisible half of a record's own-symbol population, for a\n * consumer that needs that count directly. It does NOT back `isEmptyObject` /\n * `isNonEmptyObject` — those ask the complete own-key question `recordOf` asks,\n * because an enumerable-only count made their `never` narrowing unsound for an\n * own non-enumerable key.\n *\n * @param value - The object to inspect\n * @returns The number of enumerable own-symbol keys\n *\n * @example\n * ```ts\n * const flag = Symbol('flag')\n * enumerableSymbolCount(Object.defineProperty({}, flag, { value: 1, enumerable: true })) // 1\n * enumerableSymbolCount({}) // 0\n * ```\n */\nexport function enumerableSymbolCount(value: object): number {\n\treturn readValue(() => {\n\t\tconst symbols = INTRINSICS.symbols(value)\n\t\tconst count: number = INTRINSICS.reflect.apply(INTRINSICS.fold, symbols, [\n\t\t\t(total: number, symbol: symbol) =>\n\t\t\t\ttotal + (INTRINSICS.describe(value, symbol)?.enumerable ? 1 : 0),\n\t\t\t0,\n\t\t])\n\t\treturn count\n\t}, 'enumerableSymbolCount')\n}\n\n/**\n * Narrows a compiled {@link JSONSchema} down to the open `Readonly<Record<string, unknown>>` shape\n * tool definitions advertise as `parameters` — through the {@link isRecord} boundary guard, never\n * an assertion, as `.claude/rules/patterns.md` § Validation and contracts requires.\n *\n * @remarks\n * A `JSONSchema` is the closed contract-compiler fragment (it has no index signature), whereas a\n * tool advertises its `parameters` as an open record. The two are structurally compatible but not\n * assignable, so the schema crosses that boundary through `isRecord` — a compiled contract schema\n * is always a record, so the guard passes for one. A readable value that satisfies the all-optional\n * `JSONSchema` interface without being a plain record — a class instance, whose prototype is the\n * class rather than `Object.prototype` — fails that guard and returns `undefined`, so the\n * `undefined` branch is a real answer a direct caller reaches rather than a decorative fallback.\n * This is the single sanctioned narrowing from a compiled contract schema to the open\n * tool-parameters record, so the crossing lives once rather than being copy-pasted per call site.\n *\n * @param schema - The compiled JSON Schema (a contract's `schema`)\n * @returns The schema as the open tool-parameters record, or `undefined` when it is not a record\n * @throws {ContractError} When the schema cannot be read\n *\n * @example\n * ```ts\n * import { createContract, schemaToParameters } from '@orkestrel/contract'\n *\n * const contract = createContract(shape)\n * const parameters = schemaToParameters(contract.schema) // the open record a tool advertises\n * ```\n */\nexport function schemaToParameters(\n\tschema: JSONSchema,\n): Readonly<Record<string, unknown>> | undefined {\n\treturn contain(() => {\n\t\treadValue(() => INTRINSICS.values(schema), 'schemaToParameters')\n\t\treturn isRecord(schema) ? schema : undefined\n\t}, 'schemaToParameters')\n}\n\n/**\n * Wraps a non-object `JSONSchema` root in a single-property object schema, so\n * an inferred primitive/array/union schema can flow into {@link schemaToParameters}\n * as an MCP-compatible `inputSchema`.\n *\n * @remarks\n * Deterministic for readable input. `schema.type === 'object'` passes through\n * unchanged; every other root (a primitive/array `type`, an `anyOf`/`enum`-only\n * schema with no `type`, or the empty `{}`) is wrapped as a single required\n * `value` property: `{ type: 'object', properties: { value: schema },\n * required: ['value'], additionalProperties: false }`. Composition:\n * `schemaToParameters(schemaToObject(valueToSchema(payload)))`.\n *\n * @param schema - The schema to wrap\n * @returns `schema` unchanged when object-rooted, otherwise the wrapped object schema\n * @throws {ContractError} When the schema root cannot be read\n *\n * @example\n * ```ts\n * schemaToObject({ type: 'string' })\n * // { type: 'object', properties: { value: { type: 'string' } },\n * // required: ['value'], additionalProperties: false }\n * schemaToObject({ type: 'object', properties: {} }) // unchanged\n * ```\n */\nexport function schemaToObject(schema: JSONSchema): JSONSchema {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tINTRINSICS.values(schema)\n\t\t\t\tif (INTRINSICS.own(schema, 'type') && schema.type === 'object') return schema\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: { value: schema },\n\t\t\t\t\trequired: ['value'],\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t}\n\t\t\t},\n\t\t\t'schemaToObject',\n\t\t\t{ subject: 'schema' },\n\t\t)\n\t}, 'schemaToObject')\n}\n\n// === Canonicalization\n\n/**\n * Encodes one non-container value the way JSON encodes it, or `undefined` when\n * JSON cannot encode it at all.\n *\n * @remarks\n * The leaf half of {@link canonicalStringify}: `JSON.stringify` returns\n * `undefined` (never a string) for `undefined`, a function, and a symbol —\n * exactly the values with no JSON encoding — and THROWS on a bigint, which is\n * refused before the call rather than through it. A `Date` and any other\n * non-record object encode through the same captured `JSON.stringify`, so a\n * `toJSON` member keeps its ordinary meaning.\n *\n * @param value - The non-container value to encode\n * @returns The JSON encoding, or `undefined` when JSON cannot encode `value`\n *\n * @example\n * ```ts\n * encodeLeaf(Number.NaN) // 'null'\n * encodeLeaf(undefined) // undefined\n * ```\n */\nexport function encodeLeaf(value: unknown): string | undefined {\n\tif (typeof value === 'bigint') return undefined\n\treturn INTRINSICS.stringify(value)\n}\n\n/**\n * Renders a value as a deterministic, key-sorted JSON string — or `undefined`\n * when it has no faithful JSON encoding.\n *\n * @remarks\n * The stable-stringify backing {@link unifySchemas}'s de-duplication and\n * ordering: unlike `JSON.stringify`, object keys are sorted before encoding\n * (recursively, at every nesting level), so two structurally-equal\n * `JSONSchema` fragments built independently always canonicalize to the same\n * string. Pure host-independent ECMAScript with no environment-specific imports.\n *\n * For READABLE input it returns `undefined` — never a partial or invalid\n * encoding — for every value JSON cannot faithfully encode:\n *\n * - `undefined` itself, a function, a symbol, or an array hole (JSON encodes\n * none of them), at the top level or anywhere inside a container;\n * - a bigint (`JSON.stringify` throws on one);\n * - cyclic input, tracked with the same ancestor-{@link WeakSet} discipline\n * the container branches of value inference use, so a shared (non-cyclic)\n * reference reached twice through different paths still encodes;\n * A hostile traversal is categorically different: a throwing own-getter,\n * hostile `ownKeys` trap, or revoked `Proxy` throws a `structure`\n * {@link ContractError} through {@link readValue}. A caller can therefore\n * distinguish \"not JSON-encodable\" from \"could not be read\".\n *\n * A caller therefore treats `undefined` as \"this value has no canonical key\",\n * never as an encoding: see {@link unifySchemas} (an un-keyed member cannot\n * participate in de-duplication or ordering) and {@link inferPrimitiveEnum} (an\n * un-keyed member makes the slot enum-ineligible).\n *\n * @param value - The value to canonicalize (a `JSONSchema` fragment, or any\n * nested piece of one)\n * @returns A deterministic string encoding of `value`, or `undefined` when JSON\n * cannot encode it\n * @throws {ContractError} When the value cannot be read\n *\n * @example\n * ```ts\n * canonicalStringify({ type: 'object', properties: {} }) ===\n * \tcanonicalStringify({ properties: {}, type: 'object' }) // true\n * canonicalStringify(Number.NaN) // 'null' — JSON.stringify semantics\n * canonicalStringify(undefined) // undefined\n * canonicalStringify(cyclicValue) // undefined\n * ```\n */\nexport function canonicalStringify(value: unknown): string | undefined {\n\treturn contain(() => {\n\t\treturn readValue(() => {\n\t\t\tif (!isObject(value) || (!isArray(value) && !matchesRecordBrand(value))) {\n\t\t\t\treturn encodeLeaf(value)\n\t\t\t}\n\t\t\tconst ancestors = new INTRINSICS.weakSet<object>()\n\t\t\tconst encodings = new INTRINSICS.weakMap<object, string>()\n\t\t\tconst stack: Array<\n\t\t\t\t| { readonly operation: 'enter'; readonly value: object }\n\t\t\t\t| {\n\t\t\t\t\t\treadonly operation: 'exit'\n\t\t\t\t\t\treadonly value: object\n\t\t\t\t\t\treadonly members: readonly unknown[]\n\t\t\t\t\t\treadonly keys: readonly string[] | undefined\n\t\t\t\t }\n\t\t\t> = [{ operation: 'enter', value }]\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst frame = stack.pop()\n\t\t\t\tif (frame === undefined) return undefined\n\t\t\t\tif (frame.operation === 'exit') {\n\t\t\t\t\tconst parts = INTRINSICS.from(encodeParts(frame.members, frame.keys, encodings))\n\t\t\t\t\tif (parts.length !== frame.members.length) return undefined\n\t\t\t\t\tconst encoded: string = INTRINSICS.reflect.apply(INTRINSICS.join, parts, [','])\n\t\t\t\t\tconst text = frame.keys === undefined ? `[${encoded}]` : `{${encoded}}`\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, encodings, [frame.value, text])\n\t\t\t\t\tomitVisited(ancestors, frame.value)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst container = frame.value\n\t\t\t\tif (matchesVisited(ancestors, container)) return undefined\n\t\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [container]) !== undefined)\n\t\t\t\t\tcontinue\n\t\t\t\tconst snapshot = isArray(container) ? readArrayEntries(container) : undefined\n\t\t\t\tif (snapshot !== undefined && isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (snapshot !== undefined && !snapshot.value.dense) return undefined\n\t\t\t\tconst keys = snapshot === undefined ? sortValues(INTRINSICS.keys(container)) : undefined\n\t\t\t\tconst members =\n\t\t\t\t\tsnapshot === undefined\n\t\t\t\t\t\t? INTRINSICS.from(\n\t\t\t\t\t\t\t\titerateIndices(() => keys?.length ?? 0),\n\t\t\t\t\t\t\t\t(index) => {\n\t\t\t\t\t\t\t\t\tconst key = keys?.[index]\n\t\t\t\t\t\t\t\t\treturn key === undefined ? undefined : INTRINSICS.reflect.read(container, key)\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: snapshot.value.entries\n\t\t\t\tadmitVisited(ancestors, container)\n\t\t\t\tstack[stack.length] = { operation: 'exit', value: container, members, keys }\n\t\t\t\tfor (const offset of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst index = members.length - 1 - offset\n\t\t\t\t\tconst member = members[index]\n\t\t\t\t\tif (isObject(member) && (isArray(member) || matchesRecordBrand(member))) {\n\t\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: member }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [value])\n\t\t}, 'canonicalStringify')\n\t}, 'canonicalStringify')\n}\n\n// === Format classification\n\n/**\n * Checks whether a supported ISO-8601 date or date-time names a real instant.\n *\n * @remarks\n * Accepts exactly `YYYY-MM-DD`, or `YYYY-MM-DDTHH:MM:SS` with optional\n * fractional seconds followed by `Z` or a numeric offset. Inside the\n * {@link attempt} boundary, captured components receive explicit Gregorian\n * month/leap/day and clock validation before `Date#getTime` performs the final\n * offset/instant refusal. Backs {@link stringToFormat}'s `date`, `date-time`,\n * and prefixed `time` validation.\n *\n * @param value - The candidate ISO-8601 string\n * @returns True if `value` parses to a real instant; false otherwise\n *\n * @example\n * ```ts\n * matchesISOInstant('2024-02-29') // true\n * matchesISOInstant('2024-01-01T24:00Z') // false — incomplete normalized clock\n * ```\n */\nexport function matchesISOInstant(value: string): boolean {\n\tconst outcome = attempt(() => {\n\t\t// The CAPTURED `exec`, not the live member: `RegExp.prototype.test` is\n\t\t// spec-defined in terms of `RegExpExec`, so both spellings of a pattern\n\t\t// question answer whatever the caller most recently installed, and a decoy\n\t\t// match published a `format` for a string that never had one.\n\t\tconst match = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.captures,\n\t\t\t/^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2}))?$/,\n\t\t\t[value],\n\t\t)\n\t\tconst yearText = match?.[1]\n\t\tconst monthText = match?.[2]\n\t\tconst dayText = match?.[3]\n\t\tif (yearText === undefined || monthText === undefined || dayText === undefined) return false\n\t\tconst year = INTRINSICS.numeric(yearText)\n\t\tconst month = INTRINSICS.numeric(monthText)\n\t\tconst day = INTRINSICS.numeric(dayText)\n\t\tif (month < 1 || month > 12) return false\n\t\tconst leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\t\tconst limit =\n\t\t\tmonth === 2\n\t\t\t\t? 28 + INTRINSICS.numeric(leap)\n\t\t\t\t: 31 - INTRINSICS.numeric(month === 4 || month === 6 || month === 9 || month === 11)\n\t\tif (day < 1 || day > limit) return false\n\t\tconst hourText = match?.[4]\n\t\tconst minuteText = match?.[5]\n\t\tconst secondText = match?.[6]\n\t\tif (hourText !== undefined || minuteText !== undefined || secondText !== undefined) {\n\t\t\tif (hourText === undefined || minuteText === undefined || secondText === undefined)\n\t\t\t\treturn false\n\t\t\tconst hour = INTRINSICS.numeric(hourText)\n\t\t\tconst minute = INTRINSICS.numeric(minuteText)\n\t\t\tconst second = INTRINSICS.numeric(secondText)\n\t\t\tif (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tconst date = new INTRINSICS.date(value)\n\t\treturn !INTRINSICS.nan(INTRINSICS.reflect.apply(INTRINSICS.instant, date, []))\n\t})\n\treturn isSuccess(outcome) && outcome.value\n}\n\n/**\n * Classifies an already-bounded string against the pattern-only and\n * calendar-checked {@link SchemaFormat} vocabulary.\n *\n * @remarks\n * The pure leaf behind {@link stringToFormat}'s total boundary: it performs the\n * pattern dispatch, and the door decides what a failed dispatch answers. Order\n * is significant — `date-time` is tried before `date`, and both require the\n * calendar check, so `2020-13-45` matches the pattern and is still refused.\n *\n * @param value - The candidate string, already length-bounded\n * @returns The matched {@link SchemaFormat}, or `undefined`\n * @throws The exact value thrown by a redirected pattern dispatch\n *\n * @example\n * ```ts\n * classifyFormat('ada@example.com') // 'email'\n * ```\n */\nexport function classifyFormat(value: string): SchemaFormat | undefined {\n\tif (matchesPattern(FORMAT_PATTERNS.uuid, value)) return 'uuid'\n\tif (\n\t\tmatchesPattern(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/, value) &&\n\t\tmatchesISOInstant(value)\n\t) {\n\t\treturn 'date-time'\n\t}\n\tif (matchesPattern(/^\\d{4}-\\d{2}-\\d{2}$/, value) && matchesISOInstant(value)) {\n\t\treturn 'date'\n\t}\n\tif (\n\t\tmatchesPattern(/^\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/, value) &&\n\t\tmatchesISOInstant(`1970-01-01T${value}`)\n\t) {\n\t\treturn 'time'\n\t}\n\tif (matchesPattern(FORMAT_PATTERNS.email, value)) return 'email'\n\tif (matchesPattern(FORMAT_PATTERNS.uri, value)) return 'uri'\n\treturn undefined\n}\n\n// === Schema keyword derivation\n\n/**\n * Derives `min`/`max` shape bounds from a pair of non-negative-integer JSON\n * Schema length keywords (`minLength`/`maxLength`, `minItems`/`maxItems`).\n *\n * @remarks\n * Total and pure. Either keyword is used only when it is a non-negative\n * safe integer (`Number.isSafeInteger` + `>= 0`); a malformed value (a string,\n * a negative number, `NaN`, `Infinity`, a fraction, or an unsafe integer) is\n * dropped as if absent. When both bounds are present and `min` exceeds `max`,\n * the PAIR is dropped entirely (an unbounded shape is always a legal widening\n * of a contradictory schema).\n *\n * @param min - The raw `minLength` / `minItems` keyword value\n * @param max - The raw `maxLength` / `maxItems` keyword value\n * @returns The derived `min` / `max` pair, either possibly `undefined`\n *\n * @example\n * ```ts\n * deriveLengthBounds(1, 10) // { min: 1, max: 10 }\n * deriveLengthBounds(10, 1) // {} — contradictory, dropped\n * deriveLengthBounds(-1, 10) // { max: 10 } — negative min dropped\n * ```\n */\nexport function deriveLengthBounds(min: unknown, max: unknown): BoundsRead {\n\treturn contain(() => {\n\t\tconst lo = isInteger(min) && INTRINSICS.safe(min) && min >= 0 ? min : undefined\n\t\tconst hi = isInteger(max) && INTRINSICS.safe(max) && max >= 0 ? max : undefined\n\t\tif (lo !== undefined && hi !== undefined && lo > hi) return {}\n\t\treturn {\n\t\t\t...(lo === undefined ? {} : { min: lo }),\n\t\t\t...(hi === undefined ? {} : { max: hi }),\n\t\t}\n\t}, 'deriveLengthBounds')\n}\n\n/**\n * Derives `min`/`max` shape bounds from a pair of finite-number JSON Schema\n * range keywords (`minimum`/`maximum`).\n *\n * @remarks\n * Total and pure. Either keyword is used only when it is a finite number\n * ({@link isFiniteNumber} — rejects `NaN` / `±Infinity` / non-numbers); when\n * both bounds are present and `min` exceeds `max`, the PAIR is dropped\n * entirely, the same contradiction rule {@link deriveLengthBounds} applies.\n *\n * @param min - The raw `minimum` keyword value\n * @param max - The raw `maximum` keyword value\n * @returns The derived `min` / `max` pair, either possibly `undefined`\n *\n * @example\n * ```ts\n * deriveRangeBounds(0, 120) // { min: 0, max: 120 }\n * deriveRangeBounds(5, 1) // {} — contradictory, dropped\n * ```\n */\nexport function deriveRangeBounds(min: unknown, max: unknown): BoundsRead {\n\treturn contain(() => {\n\t\tconst lo = isFiniteNumber(min) ? min : undefined\n\t\tconst hi = isFiniteNumber(max) ? max : undefined\n\t\tif (lo !== undefined && hi !== undefined && lo > hi) return {}\n\t\treturn {\n\t\t\t...(lo === undefined ? {} : { min: lo }),\n\t\t\t...(hi === undefined ? {} : { max: hi }),\n\t\t}\n\t}, 'deriveRangeBounds')\n}\n\n// === Inference option sanitization\n\n/**\n * Sanitizes a user-supplied inference budget (`limits.depth` / `limits.properties`) to\n * a finite non-negative integer, selecting a valid fallback for anything else.\n *\n * @remarks\n * Guards {@link valueToSchema} / {@link samplesToSchema} against a hostile or\n * malformed budget: an unclamped `NaN` defeats every `depth <= 0` guard\n * (`NaN <= 0` is `false`, so recursion never halts), and a negative\n * `limits.properties` makes `slice(0, -1)` silently drop the LAST sorted key\n * instead of capping the list (a fractional value has a similarly undefined\n * `slice` bound). `Infinity` is rejected too — `Number.isInteger(Infinity)`\n * is `false` — since an unbounded budget is exactly the adversarial case the\n * caps exist to prevent. A valid candidate passes through unchanged without\n * inspecting the fallback. When the candidate is invalid, the fallback must\n * satisfy the same finite non-negative-integer contract or this boundary\n * refuses it with a coded error instead of returning an invalid budget.\n *\n * @param value - The candidate budget value\n * @param fallback - The default to select when `value` is not a finite\n * non-negative integer\n * @returns A finite non-negative integer budget\n * @throws {ContractError} When the selected fallback is not a finite\n * non-negative integer\n *\n * @example\n * ```ts\n * sanitizeBudget(Number.NaN, INFER_DEPTH_LIMIT) // INFER_DEPTH_LIMIT\n * sanitizeBudget(-1, INFER_BREADTH_LIMIT) // INFER_BREADTH_LIMIT\n * sanitizeBudget(4, INFER_DEPTH_LIMIT) // 4\n * ```\n */\nexport function sanitizeBudget(value: number | undefined, fallback: number): number {\n\treturn contain(() => {\n\t\tif (typeof value === 'number' && INTRINSICS.integer(value) && value >= 0) return value\n\t\tif (typeof fallback === 'number' && INTRINSICS.integer(fallback) && fallback >= 0)\n\t\t\treturn fallback\n\t\tthrow new ContractError('sanitizeBudget: fallback must be a finite non-negative integer', {\n\t\t\tcode: 'bound',\n\t\t\tcontext: { limit: 'finite non-negative integer', received: preview(fallback) },\n\t\t})\n\t}, 'sanitizeBudget')\n}\n\n/**\n * Resolves a caller's depth budget to one the traversal can actually survive.\n *\n * @remarks\n * {@link sanitizeBudget} decides the SHAPE of a budget and deliberately lets any\n * finite non-negative integer through, because it must never read a fallback a\n * hostile caller supplied. That left the depth axis unbounded from above, and\n * depth is the axis that recurses: `1e9` is a valid integer, so the walk descended\n * until the call STACK failed, at a depth that varied between runs, and the\n * refusal surfaced as an unreadable value rather than as the exhaustion the guard\n * promises. Breadth needs no such ceiling — its loop is already bounded by the\n * entries actually present.\n *\n * So {@link INFER_DEPTH_LIMIT} is the ceiling as well as the default, and\n * `limits.depth` narrows the walk rather than widening it. One bound, and the same\n * answer on every host.\n *\n * @param value - The candidate depth budget\n * @returns A finite non-negative integer no greater than `INFER_DEPTH_LIMIT`\n *\n * @example\n * ```ts\n * sanitizeDepth(4) // 4\n * sanitizeDepth(1e9) // 32\n * ```\n */\nexport function sanitizeDepth(value: number | undefined): number {\n\treturn INTRINSICS.min(sanitizeBudget(value, INFER_DEPTH_LIMIT), INFER_DEPTH_LIMIT)\n}\n\n// === Reporting\n\n/**\n * Renders an unknown value as a short, safe, TOTAL string for a {@link Fault}'s\n * `received` field.\n *\n * @remarks\n * A primitive renders as printable text: a string retains its quoted JSON\n * representation, while a narrowed symbol renders through intrinsic `String`\n * and receives the same escaping without outer quotes. A string of at most\n * {@link PREVIEW_LIMIT} code units takes its answer from one whole-string\n * encode when that encode fits the same limit, and the length predicate\n * deciding it is exact rather than approximate. Every other string and every\n * symbol renders through one bounded indexed encoder that appends only\n * complete escaped code-point tokens within {@link PREVIEW_LIMIT}; clipping\n * therefore never retrieves the mutable string iterator or splits an\n * escape/surrogate pair before its trailing `…`, and enormous primitive text\n * is not fully traversed. A number / boolean / bigint renders through `String`;\n * `null` and `undefined` render as their own name. An array renders as\n * `'array'`. Every other host — a plain object, a function, a class instance,\n * a `Map` — is NEVER traversed or stringified; it renders as its bare\n * `typeof` tag (`'object'` / `'function'`).\n *\n * The indexed encoder appends every token and closes with the quote exactly\n * when the escaped inner length is at most `PREVIEW_LIMIT - 2`, which is\n * character for character what one `JSON.stringify` call returns. At an inner\n * length of `PREVIEW_LIMIT - 1` the indexed encoder appends every token and\n * closes with `…` instead, while one `JSON.stringify` call over that same\n * string measures `PREVIEW_LIMIT + 1` — so the predicate refuses that string\n * and every longer one, and each of them renders through the indexed encoder.\n * Escaping never shrinks text, so the leading `source.length` gate admits\n * every string the predicate could accept while keeping enormous primitive\n * text out of the whole-string encode. A symbol renders through the indexed\n * encoder because its unquoted text is not what a `JSON.stringify` call\n * returns.\n *\n * @param value - The value to preview\n * @returns A short descriptive string, always safe to embed in a diagnostic\n *\n * @example\n * ```ts\n * preview('hi') // '\"hi\"'\n * preview(42) // '42'\n * preview(null) // 'null'\n * preview({ a: 1 }) // 'object'\n * preview([1, 2, 3]) // 'array'\n * ```\n */\nexport function preview(value: unknown): string {\n\tif (value === null) return 'null'\n\tif (value === undefined) return 'undefined'\n\tif (isString(value) || isSymbol(value)) {\n\t\tconst quoted = isString(value)\n\t\tconst source = INTRINSICS.text(value)\n\t\tif (quoted && source.length <= PREVIEW_LIMIT) {\n\t\t\tconst whole = INTRINSICS.stringify(source)\n\t\t\tif (whole.length <= PREVIEW_LIMIT) return whole\n\t\t}\n\t\tconst parts = previewParts(source, 0, PREVIEW_LIMIT - (quoted ? 1 : 0), quoted)\n\t\tconst body: string = INTRINSICS.reflect.apply(INTRINSICS.join, parts, [''])\n\t\treturn quoted ? `\"${body}` : body\n\t}\n\tif (isNumber(value) || isBoolean(value)) return INTRINSICS.text(value)\n\tif (isBigInt(value)) return `${value}n`\n\tif (isArray(value)) return 'array'\n\treturn typeof value\n}\n\n/**\n * Builds the refinement faults a string value has against a {@link StringShape}.\n *\n * @remarks\n * The single source of the string refinement report, shared by\n * `compileReporter` and `compileAuditor`. The two doors differ only in how they\n * OBTAIN the string — the reporter coerces through `parseString`, the auditor\n * demands a primitive string — and share every constraint afterwards through\n * this helper, so a constraint cannot drift between them.\n * Faults come out in declaration order — `min`, then `max`, then\n * `pattern` — because a report is read top to bottom and its order is public.\n *\n * The declaration's pattern is applied through an OWNED stateless rebuild\n * ({@link readPattern}) asked through {@link matchesPattern}, so the shape's own\n * pattern never moves a caller's `lastIndex` and no caller-writable member\n * decides whether the value matched. The rebuild is stateless precisely because\n * `g` and `y` are stripped, so one rebuilt pattern answers identically for every\n * value and every call — which is what lets a compiled door build it once\n * ({@link ownPattern}) and hand it down through `pattern` instead of rebuilding\n * it on each answer. The `limit` text is read from the applied rebuild, so it\n * names the pattern that decided the match. Left to rebuild, the helper asks\n * the shape's `pattern` accessor once for the presence test that decides\n * whether a pattern was declared at all, and once more for the rebuild that\n * decides the match and names the `limit` when one was.\n *\n * The whole body reads the caller's SHAPE, so it runs through the same\n * {@link readValue} boundary {@link shapeToKind} uses and refuses an\n * out-of-domain declaration with the same diagnostic. The compiled doors gate a\n * non-`RegExp` `pattern` and a non-finite bound long before this helper sees\n * them, so the package's own path never arrives here off-domain — but the door\n * is PUBLISHED, and a shape a `StringShape` annotation merely vouched for\n * (parsed out of a document, say) reaches it unchecked. Publishing the host's\n * own `TypeError` from such a shape would falsify the promise this module makes\n * for every one of its doors.\n *\n * @param shape - The string shape whose refinements are checked\n * @param value - The already-obtained string to check\n * @param path - The path every produced fault is rooted at\n * @param pattern - The one-time stateless rebuild that decides the pattern\n * refinement. Must be a {@link readPattern} result for this\n * shape's own pattern; supplied, it decides the match, the\n * `limit` text, and whether a pattern fault is reported at\n * all, and `shape.pattern` is not read. A pattern carrying `g`\n * or `y` moves the caller's `lastIndex` and makes repeated\n * answers for one value disagree. Default: rebuilt from\n * `shape.pattern` on every call, when the shape declares one\n * @returns A fresh array of faults, empty when the value satisfies every refinement\n * @throws {ContractError} When the shape's refinement fields cannot be read\n *\n * @example\n * ```ts\n * buildStringFaults({ category: 'string', min: 3 }, 'ab', [])\n * // [{ reason: 'constraint', path: [], expected: 'string', constraint: 'min', limit: 3, received: '\"ab\"' }]\n * ```\n */\nexport function buildStringFaults(\n\tshape: StringShape,\n\tvalue: string,\n\tpath: readonly string[],\n\tpattern?: RegExp,\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'min') &&\n\t\t\t\tshape.min !== undefined &&\n\t\t\t\t!matchesStringLength(value, shape.min, undefined)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'string',\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'max') &&\n\t\t\t\tshape.max !== undefined &&\n\t\t\t\t!matchesStringLength(value, undefined, shape.max)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'string',\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The bounds are read from the shape on every call because a number is\n\t\t\t// what the fault carries. The pattern is not: rebuilding it allocates a\n\t\t\t// `RegExp` per answer, so a caller holding the same shape for the life of\n\t\t\t// a compiled door supplies the rebuild once and this reads it instead.\n\t\t\t// Whatever arrives is what decides the match and names the fault's `limit`,\n\t\t\t// so a rebuild of this shape's own pattern reports exactly what the\n\t\t\t// shape's own read would: `readPattern` preserves `source` exactly.\n\t\t\tconst stateless =\n\t\t\t\tpattern ??\n\t\t\t\t(!INTRINSICS.own(shape, 'pattern') || shape.pattern === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: readPattern(shape.pattern))\n\t\t\tif (stateless !== undefined && !matchesPattern(stateless, value)) {\n\t\t\t\tconst limit = readPatternSource(stateless)\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'string',\n\t\t\t\t\tconstraint: 'pattern',\n\t\t\t\t\t...(limit === undefined ? {} : { limit }),\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildStringFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Builds the refinement faults a number value has against a {@link NumberShape}.\n *\n * @remarks\n * The numeric sibling of {@link buildStringFaults}, shared by the same two\n * doors for the same reason. `expected` is the shape's own kind — `'integer'`\n * when `integer: true`, otherwise `'number'` — so a caller reading the report\n * sees the declaration's vocabulary rather than the value's. Order is\n * `integer`, then `min`, then `max`. It refuses an unreadable shape through the\n * same boundary and for the same reason {@link buildStringFaults} does.\n *\n * @param shape - The number shape whose refinements are checked\n * @param value - The already-obtained number to check\n * @param path - The path every produced fault is rooted at\n * @returns A fresh array of faults, empty when the value satisfies every refinement\n * @throws {ContractError} When the shape's refinement fields cannot be read\n *\n * @example\n * ```ts\n * buildNumberFaults({ category: 'number', integer: true }, 1.5, [])\n * // [{ reason: 'constraint', path: [], expected: 'integer', constraint: 'integer', received: '1.5' }]\n * ```\n */\nexport function buildNumberFaults(\n\tshape: NumberShape,\n\tvalue: number,\n\tpath: readonly string[],\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst expected: FaultKind =\n\t\t\t\tINTRINSICS.own(shape, 'integer') && shape.integer === true ? 'integer' : 'number'\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'integer') &&\n\t\t\t\tshape.integer === true &&\n\t\t\t\t!INTRINSICS.integer(value)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'integer',\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'min') && shape.min !== undefined && value < shape.min) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'max') && shape.max !== undefined && value > shape.max) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildNumberFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Builds the length faults an array has against an {@link ArrayShape}.\n *\n * @remarks\n * Takes the LENGTH rather than the array, because both doors have already read\n * their entries through {@link readArrayEntries} and must report the length that\n * read observed rather than re-asking the caller's value for it. `received` is\n * that count rendered through the captured `String`, matching the other length\n * diagnostics in the package. Order is `min`, then `max`. It refuses an\n * unreadable shape through the same boundary and for the same reason\n * {@link buildStringFaults} does.\n *\n * @param shape - The array shape whose bounds are checked\n * @param length - The entry count the door already observed\n * @param path - The path every produced fault is rooted at\n * @returns A fresh array of faults, empty when the length satisfies both bounds\n * @throws {ContractError} When the shape's bound fields cannot be read\n *\n * @example\n * ```ts\n * buildArrayFaults({ category: 'array', items: { category: 'string' }, min: 2 }, 1, [])\n * // [{ reason: 'constraint', path: [], expected: 'array', constraint: 'min', limit: 2, received: '1' }]\n * ```\n */\nexport function buildArrayFaults(\n\tshape: ArrayShape,\n\tlength: number,\n\tpath: readonly string[],\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (INTRINSICS.own(shape, 'min') && shape.min !== undefined && length < shape.min) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'array',\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: INTRINSICS.text(length),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'max') && shape.max !== undefined && length > shape.max) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'array',\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: INTRINSICS.text(length),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildArrayFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Selects the report of the variant that came closest to matching.\n *\n * @remarks\n * The union summary both diagnostic doors append their closest variant's faults\n * to. \"Closest\" is the SHORTEST report, and an earlier variant wins a tie, so a\n * union's diagnostic follows declaration order rather than whichever variant a\n * later comparison happened to visit. The winning report is returned BY\n * IDENTITY, never copied, so the summary carries the exact fault objects the\n * variant produced. No report at all — a union whose every variant slot was\n * unreadable — yields a frozen empty collection rather than `undefined`, so the\n * caller appends nothing instead of branching.\n *\n * The scan is an indexed read of arrays this package built, so neither the\n * choice of variant nor the length comparison dispatches through a member a\n * caller can replace.\n *\n * @param reports - One report per variant, in declaration order\n * @returns The first shortest report, or a frozen empty collection when there are none\n *\n * @example\n * ```ts\n * selectClosestFaults([[fault, fault], [fault]]) // the second report\n * selectClosestFaults([]) // []\n * ```\n */\nexport function selectClosestFaults<T extends AuditFault>(\n\treports: ReadonlyArray<readonly T[]>,\n): readonly T[] {\n\tconst closest: readonly T[] | undefined = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.reduce,\n\t\titerateIndices(() => reports.length),\n\t\t[\n\t\t\t(best: readonly T[] | undefined, index: number) => {\n\t\t\t\tconst report = reports[index]\n\t\t\t\treturn report !== undefined && (best === undefined || report.length < best.length)\n\t\t\t\t\t? report\n\t\t\t\t\t: best\n\t\t\t},\n\t\t\tundefined,\n\t\t],\n\t)\n\treturn closest ?? INTRINSICS.freeze([])\n}\n\n/**\n * Projects a {@link ContractShape} to the {@link FaultKind} it describes.\n *\n * @remarks\n * A structural mapping used by {@link compileReporter} to fill a `Fault`'s\n * `expected` field and by {@link compileAuditor} to fill an `AuditFault`'s:\n * most shapes map to their own `category` (`numberShape` maps to\n * `'integer'` when `integer: true`, else `'number'`); `optionalShape` /\n * `nullableShape` project through to their inner shape's kind, and `rawShape`\n * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.\n *\n * A hand-authored node carrying an unrecognized discriminant is REFUSED rather\n * than answered out of type, which keeps the declared non-optional\n * {@link FaultKind} return type true at a public export; every other door in\n * this module refuses out-of-domain input, so this one does too.\n *\n * @param shape - The shape to project\n * @returns The shape's {@link FaultKind}\n * @throws {ContractError} When the node carries no recognized shape discriminant\n *\n * @example\n * ```ts\n * shapeToKind(stringShape()) // 'string'\n * shapeToKind(integerShape()) // 'integer'\n * shapeToKind(optionalShape(nullShape())) // 'null'\n * ```\n */\nexport function shapeToKind(shape: ContractShape): FaultKind {\n\treturn readValue(\n\t\t() => {\n\t\t\tswitch (shape.category) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn 'string'\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn INTRINSICS.own(shape, 'integer') && shape.integer === true ? 'integer' : 'number'\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn 'boolean'\n\t\t\t\tcase 'null':\n\t\t\t\t\treturn 'null'\n\t\t\t\tcase 'literal':\n\t\t\t\t\treturn 'literal'\n\t\t\t\tcase 'array':\n\t\t\t\t\treturn 'array'\n\t\t\t\tcase 'object':\n\t\t\t\t\treturn 'object'\n\t\t\t\tcase 'union':\n\t\t\t\t\treturn 'union'\n\t\t\t\tcase 'json':\n\t\t\t\t\treturn 'json'\n\t\t\t\tcase 'shape':\n\t\t\t\t\treturn 'shape'\n\t\t\t\tcase 'optional':\n\t\t\t\t\treturn shapeToKind(shape.inner)\n\t\t\t\tcase 'nullable':\n\t\t\t\t\treturn shapeToKind(shape.inner)\n\t\t\t\tcase 'raw':\n\t\t\t\t\treturn 'json'\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new INTRINSICS.error('shapeToKind: unrecognized shape discriminant')\n\t\t\t}\n\t\t},\n\t\t'shapeToKind',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Refuses a validated declaration whose compiled expansion exceeds\n * {@link COMPILE_NODE_LIMIT}.\n *\n * @remarks\n * The compilers' emitted-node bound, written once because two boundaries apply\n * it over a {@link ShapeValidatorInterface.expansion} count: the eager\n * {@link validateShape} function and the lazy {@link ContractCompiler}\n * preparation. The refusal keeps `validateShape`'s name because that gate\n * OWNS the rule and its exact diagnostic is public API — the same reason\n * `ShapeCloner` publishes the gate's depth wording rather than inventing a\n * second vocabulary for one rule. Two constructions of one refusal are two\n * messages waiting to drift apart.\n *\n * @param expansion - The node count one successful validation measured, or\n * `undefined` when no pass measured one\n * @returns Nothing when the count is within the limit\n * @throws {ContractError} When the count exceeds {@link COMPILE_NODE_LIMIT}, or when no successful pass measured one\n *\n * @example\n * ```ts\n * const validator = new ShapeValidator(shape)\n * validator.validate()\n * refuseExpansion(validator.expansion)\n * ```\n */\nexport function refuseExpansion(expansion: number | undefined): void {\n\t// An absent measurement is not a small one. Both boundaries call this\n\t// immediately after a successful pass, so `undefined` here means the pass that\n\t// was supposed to measure the graph did not — and letting that through would\n\t// publish the compilers' node bound as satisfied by a count nobody took.\n\tif (expansion === undefined) {\n\t\tthrow new ContractError('validateShape: a validated shape measured no expansion', {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: [] },\n\t\t})\n\t}\n\tif (expansion <= COMPILE_NODE_LIMIT) return\n\tthrow new ContractError('validateShape: a shape expands past the compilation node limit', {\n\t\tcode: 'expansion',\n\t\tcontext: {\n\t\t\tpath: [],\n\t\t\tlimit: COMPILE_NODE_LIMIT,\n\t\t\treceived: INTRINSICS.text(expansion),\n\t\t},\n\t})\n}\n\n/**\n * Encodes ordered members, stopping before the first unencodable member.\n *\n * @param members - The owned members in source order\n * @param keys - Object keys, or undefined for an array\n * @param encodings - Encodings already computed for child containers\n * @returns The encoded prefix\n *\n * @example\n * ```ts\n * Array.from(encodeParts([1, undefined, 2], undefined, new WeakMap())) // ['1']\n * ```\n */\nexport function* encodeParts(\n\tmembers: readonly unknown[],\n\tkeys: readonly string[] | undefined,\n\tencodings: WeakMap<object, string>,\n): Generator<string, void, unknown> {\n\tfor (const index of iterateIndices(() => members.length)) {\n\t\tconst member = members[index]\n\t\tconst part = isObject(member)\n\t\t\t? (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [member]) ?? encodeLeaf(member))\n\t\t\t: encodeLeaf(member)\n\t\tif (part === undefined) return\n\t\tconst key = keys?.[index]\n\t\tyield key === undefined ? part : `${INTRINSICS.stringify(key)}:${part}`\n\t}\n}\n\n/**\n * Builds bounded escaped preview parts without splitting a surrogate pair.\n *\n * @param source - The source text\n * @param index - The next UTF-16 offset\n * @param capacity - The unused preview width\n * @param quoted - Whether the final part closes a string quote\n * @returns The escaped parts with their closing quote or truncation mark\n *\n * @example\n * ```ts\n * previewParts('abc', 0, 2, false) // ['a', 'b', '…']\n * ```\n */\nexport function previewParts(\n\tsource: string,\n\tindex: number,\n\tcapacity: number,\n\tquoted: boolean,\n): readonly string[] {\n\tconst available = INTRINSICS.min(capacity, PREVIEW_LIMIT)\n\tconst first = source[index]\n\tif (index >= source.length || first === undefined) {\n\t\treturn quoted ? [available > 0 ? '\"' : '…'] : []\n\t}\n\tconst second = index + 1 < source.length ? source[index + 1] : undefined\n\tconst paired =\n\t\tfirst >= '\\ud800' &&\n\t\tfirst <= '\\udbff' &&\n\t\tsecond !== undefined &&\n\t\tsecond >= '\\udc00' &&\n\t\tsecond <= '\\udfff'\n\tconst character = paired ? `${first}${second}` : first\n\tconst encoded = INTRINSICS.stringify(character)\n\tconst length = encoded.length - 2\n\tif (length > available) return ['…']\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => length),\n\t\t(offset) => encoded[offset + 1],\n\t)\n\tconst token: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\tconst tail = previewParts(source, index + (paired ? 2 : 1), available - length, quoted)\n\treturn INTRINSICS.from(\n\t\titerateIndices(() => tail.length + 1),\n\t\t(offset) => (offset === 0 ? token : (tail[offset - 1] ?? '')),\n\t)\n}\n\n/**\n * Builds a null-prototype lookup from names to their last index.\n *\n * @param names - Names in declaration order\n * @returns The indexed lookup\n *\n * @example\n * ```ts\n * buildPositions(['id', '__proto__']).id // 0\n * ```\n */\nexport function buildPositions(names: readonly string[]): Readonly<Record<string, number>> {\n\tconst pairs = INTRINSICS.from(\n\t\titerateIndices(() => names.length),\n\t\t(index) => [names[index], index],\n\t)\n\treturn INTRINSICS.rebase(\n\t\tINTRINSICS.record<number>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t}),\n\t\tnull,\n\t)\n}\n\n/**\n * Derives the bit mask of names present in an indexed lookup.\n *\n * @param names - Names to observe in order\n * @param positions - The bit position of each declared name\n * @returns The combined signed 32-bit mask\n *\n * @example\n * ```ts\n * readPresence(['id'], buildPositions(['id', 'name'])) // 1\n * ```\n */\nexport function readPresence(\n\tnames: readonly string[],\n\tpositions: Readonly<Record<string, number>>,\n): number {\n\treturn INTRINSICS.reflect.apply(\n\t\tINTRINSICS.reduce,\n\t\titerateIndices(() => names.length),\n\t\t[\n\t\t\t(mask: number, index: number) => {\n\t\t\t\tconst name = names[index]\n\t\t\t\tif (name === undefined || !INTRINSICS.own(positions, name)) return mask\n\t\t\t\tconst position = positions[name]\n\t\t\t\treturn position === undefined ? mask : mask | (1 << position)\n\t\t\t},\n\t\t\t0,\n\t\t],\n\t)\n}\n\n// Pin the iterator protocol before any caller can reach these exported generators.\nfor (const generator of [iterateIndices, encodeParts]) {\n\tfor (const key of ['next', 'return', 'throw', Symbol.iterator]) {\n\t\tINTRINSICS.define(generator.prototype, key, {\n\t\t\tvalue: INTRINSICS.reflect.read(generator.prototype, key),\n\t\t})\n\t}\n\tINTRINSICS.freeze(generator.prototype)\n\tINTRINSICS.freeze(generator)\n}\n\n/**\n * Extracts a fault's path as its segments, reading a string path as one segment.\n *\n * @param fault - The fault to read\n * @returns The path's segments, empty at the root\n *\n * @example\n * ```ts\n * import { extractPath } from '@orkestrel/contract'\n *\n * extractPath({ reason: 'extra', path: ['page', 'typo'] }) // ['page', 'typo']\n * ```\n */\nexport function extractPath(fault: AuditFault): readonly string[] {\n\treturn isString(fault.path) ? [fault.path] : fault.path\n}\n\n/**\n * Extracts a schema's forms: the schema itself, then its union arms, so a read looks\n * through a nullable the same way everywhere.\n *\n * @param schema - The schema to read, or `undefined` where none was found\n * @returns The forms, empty when there is no schema\n *\n * @example\n * ```ts\n * import { extractForms } from '@orkestrel/contract'\n *\n * const object = { type: 'object' } as const\n * extractForms({ anyOf: [object] }) // [{ anyOf: [object] }, object]\n * ```\n */\nexport function extractForms(schema: JSONSchema | undefined): readonly JSONSchema[] {\n\tif (schema === undefined) return []\n\tconst anyOf = INTRINSICS.own(schema, 'anyOf') ? schema.anyOf : undefined\n\tconst oneOf = INTRINSICS.own(schema, 'oneOf') ? schema.oneOf : undefined\n\treturn [schema, ...(anyOf ?? oneOf ?? [])]\n}\n\n/**\n * Extracts the part of a schema a path reaches, through properties, array items, record values,\n * and the arms of a union.\n *\n * @remarks\n * Each path segment takes one step, so a union that nests itself cannot hold the walk. Only a\n * schema's own `properties` keys match, so `constructor` reaches nothing. The walk keeps every\n * matching union declaration until the end; differing declarations yield no schema. Independently\n * built declarations agree when their canonical JSON encodings agree.\n *\n * @param schema - The schema to walk\n * @param path - The segments to follow\n * @returns The schema at that path, or `undefined` where no declaration or no agreement exists\n *\n * @example\n * ```ts\n * import { extractSchema } from '@orkestrel/contract'\n *\n * const schema = { type: 'object', properties: { limit: { type: 'number' } } } as const\n * extractSchema(schema, ['limit']) // { type: 'number' }\n * ```\n */\nexport function extractSchema(schema: JSONSchema, path: readonly string[]): JSONSchema | undefined {\n\tconst nodes = path.reduce<readonly JSONSchema[]>(\n\t\t(parents, key) =>\n\t\t\tArray.from(\n\t\t\t\tnew Set(\n\t\t\t\t\tparents\n\t\t\t\t\t\t.flatMap((node) => extractForms(node))\n\t\t\t\t\t\t.map((form) => {\n\t\t\t\t\t\t\tconst properties = INTRINSICS.own(form, 'properties') ? form.properties : undefined\n\t\t\t\t\t\t\tconst additional = INTRINSICS.own(form, 'additionalProperties')\n\t\t\t\t\t\t\t\t? form.additionalProperties\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\treturn properties !== undefined && INTRINSICS.own(properties, key)\n\t\t\t\t\t\t\t\t? properties[key]\n\t\t\t\t\t\t\t\t: isRecord(additional)\n\t\t\t\t\t\t\t\t\t? additional\n\t\t\t\t\t\t\t\t\t: INTRINSICS.own(form, 'items')\n\t\t\t\t\t\t\t\t\t\t? form.items\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((child) => child !== undefined),\n\t\t\t\t),\n\t\t\t),\n\t\t[schema],\n\t)\n\tconst first = nodes[0]\n\tif (nodes.length < 2) return first\n\tconst encoded = canonicalStringify(first)\n\treturn encoded !== undefined && nodes.every((node) => canonicalStringify(node) === encoded)\n\t\t? first\n\t\t: undefined\n}\n\n/**\n * Renders a path as text, encoding what a caller could have sent and eliding the middle of a long\n * one.\n *\n * @remarks\n * A segment that is not a plain identifier is JSON-encoded and length-capped, because a key the\n * caller sent is untrusted text. A path of more than four segments past 120 characters keeps its\n * first segment and its last three.\n *\n * @param path - The segments to render\n * @returns The segments joined with `.`, empty at the root\n *\n * @example\n * ```ts\n * import { renderPath } from '@orkestrel/contract'\n *\n * renderPath(['rows', '0', 'a b']) // 'rows.0.\"a b\"'\n * ```\n */\nexport function renderPath(path: readonly string[]): string {\n\tconst segments = path.map((segment) =>\n\t\t/^[\\w$-]{1,64}$/u.test(segment) ? segment : preview(segment),\n\t)\n\tconst text = segments.join('.')\n\treturn segments.length <= 4 || text.length <= 120\n\t\t? text\n\t\t: [...segments.slice(0, 1), '…', ...segments.slice(-3)].join('.')\n}\n\n/**\n * Renders a list as text, naming at most `FAULT_LIST_LIMIT` of its entries and counting the rest.\n *\n * @param entries - The rendered entries\n * @returns The entries joined with `, `\n *\n * @example\n * ```ts\n * import { renderList } from '@orkestrel/contract'\n *\n * renderList(['city', 'units']) // 'city, units'\n * ```\n */\nexport function renderList(entries: readonly string[]): string {\n\tconst listed = entries.slice(0, FAULT_LIST_LIMIT).join(', ')\n\treturn entries.length > FAULT_LIST_LIMIT\n\t\t? `${listed} and ${String(entries.length - FAULT_LIST_LIMIT)} more`\n\t\t: listed\n}\n\n/**\n * Renders a schema as a short summary of what to send, such as `{\"city\": string, \"note\"?: string}`.\n *\n * @remarks\n * An object lists its required keys first and marks the rest with `?`, at most `FAULT_LIST_LIMIT`\n * of them. A leaf or array keeps its numeric bounds and pattern, a union joins its forms with ` | `,\n * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and\n * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past\n * `room` is cut and closes with `…`. A type word outside JSON Schema's vocabulary is encoded.\n *\n * @param schema - The schema to summarize\n * @param room - The characters the summary can take. Default: `FAULT_SCHEMA_LIMIT`\n * @returns The summary\n *\n * @example\n * ```ts\n * import { renderForm } from '@orkestrel/contract'\n *\n * renderForm({ type: 'object', properties: { zip: { type: 'number' } }, required: ['zip'] }) // '{\"zip\": number}'\n * ```\n */\nexport function renderForm(schema: JSONSchema, room: number = FAULT_SCHEMA_LIMIT): string {\n\tconst deep = room >= 16\n\tconst inner = Math.floor(room / 2)\n\tconst anyOf = INTRINSICS.own(schema, 'anyOf') ? schema.anyOf : undefined\n\tconst oneOf = INTRINSICS.own(schema, 'oneOf') ? schema.oneOf : undefined\n\tconst forms = anyOf ?? oneOf\n\tconst required = (INTRINSICS.own(schema, 'required') ? schema.required : undefined) ?? []\n\tconst entries = Object.entries(\n\t\t(INTRINSICS.own(schema, 'properties') ? schema.properties : undefined) ?? {},\n\t)\n\tconst type = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\tconst enumeration = INTRINSICS.own(schema, 'enum') ? schema.enum : undefined\n\tconst additional = INTRINSICS.own(schema, 'additionalProperties')\n\t\t? schema.additionalProperties\n\t\t: undefined\n\tconst listed = (deep ? entries : [])\n\t\t.toSorted(\n\t\t\t([left], [right]) => Number(required.includes(right)) - Number(required.includes(left)),\n\t\t)\n\t\t.slice(0, FAULT_LIST_LIMIT)\n\t\t.map(\n\t\t\t([key, child]) =>\n\t\t\t\t`${preview(key)}${required.includes(key) ? '' : '?'}: ${renderForm(child, inner)}`,\n\t\t)\n\tconst left = entries.length - listed.length\n\tconst child =\n\t\ttype === 'array'\n\t\t\t? INTRINSICS.own(schema, 'items')\n\t\t\t\t? schema.items\n\t\t\t\t: undefined\n\t\t\t: isRecord(additional)\n\t\t\t\t? additional\n\t\t\t\t: undefined\n\tconst bounds = Object.entries(schema)\n\t\t.filter(([key]) =>\n\t\t\t['minLength', 'maxLength', 'minimum', 'maximum', 'minItems', 'maxItems', 'pattern'].includes(\n\t\t\t\tkey,\n\t\t\t),\n\t\t)\n\t\t.map(([key, value]) => `${key} ${preview(value)}`)\n\tconst text =\n\t\tforms !== undefined\n\t\t\t? deep\n\t\t\t\t? forms.map((form) => renderForm(form, inner)).join(' | ')\n\t\t\t\t: 'any'\n\t\t\t: enumeration !== undefined\n\t\t\t\t? enumeration.map((value) => preview(value)).join(' | ')\n\t\t\t\t: listed.length > 0\n\t\t\t\t\t? `{${[...listed, ...(left > 0 ? [`and ${String(left)} more`] : [])].join(', ')}}`\n\t\t\t\t\t: [\n\t\t\t\t\t\t\ttype === undefined\n\t\t\t\t\t\t\t\t? entries.length > 0\n\t\t\t\t\t\t\t\t\t? 'object'\n\t\t\t\t\t\t\t\t\t: 'any'\n\t\t\t\t\t\t\t\t: JSON_SCHEMA_TYPES.some((name) => name === type)\n\t\t\t\t\t\t\t\t\t? type\n\t\t\t\t\t\t\t\t\t: preview(type),\n\t\t\t\t\t\t\t...(deep && child !== undefined ? [` of ${renderForm(child, inner)}`] : []),\n\t\t\t\t\t\t\t...(bounds.length > 0 ? [` (${bounds.join(', ')})`] : []),\n\t\t\t\t\t\t].join('')\n\treturn truncateFaultText(text, room)\n}\n\n/**\n * Describes one fault as the line a caller corrects from, naming what to send where the schema\n * says.\n *\n * @remarks\n * Each line opens with the fault's path (or `value` at the root) and reason. An `extra` fault lists\n * its parent's keys only when the declaring arms agree. A literal names candidates only where\n * the declarations agree; lists are deduplicated and bounded. A received preview stays as written\n * within PREVIEW_LIMIT and without control or line-separator characters; otherwise it is encoded\n * through preview. Received, constraint, and limit details read only own fields. A `variant` or\n * `oneOf` fault says that the value matches none of the declared forms, or several where one must\n * match, and summarizes each form through `renderForm`. It names no fault of any one form, because\n * none of them holds for the others. Those summaries share half of `FAULT_TEXT_LIMIT`.\n *\n * @param fault - The fault to describe\n * @param schema - The compiled schema the fault's path reads\n * @returns The line, with no line break\n *\n * @example\n * ```ts\n * import { describeFaultLine } from '@orkestrel/contract'\n *\n * describeFaultLine({ reason: 'missing', path: ['left'], expected: 'number' }, {}) // 'left: missing; expected number'\n * ```\n */\nexport function describeFaultLine(fault: AuditFault, schema: JSONSchema): string {\n\tconst path = extractPath(fault)\n\tconst head = `${renderPath(path) || 'value'}: ${fault.reason}`\n\tif (fault.reason === 'extra') {\n\t\tconst declarations = extractForms(extractSchema(schema, path.slice(0, -1)))\n\t\t\t.filter((form) => INTRINSICS.own(form, 'properties') && form.properties !== undefined)\n\t\t\t.map((form) => Object.keys(form.properties ?? {}))\n\t\tconst first = declarations[0] ?? []\n\t\tconst keys = declarations.every(\n\t\t\t(declared) =>\n\t\t\t\tdeclared.length === first.length && declared.every((key) => first.includes(key)),\n\t\t)\n\t\t\t? first\n\t\t\t: []\n\t\treturn keys.length === 0\n\t\t\t? `${head}; this key is not declared, remove it`\n\t\t\t: `${head}; this key is not declared, remove it or use a declared key: ${renderList(keys.map((key) => renderPath([key])))}`\n\t}\n\tconst node = extractSchema(schema, path)\n\tconst anyOf = node !== undefined && INTRINSICS.own(node, 'anyOf') ? node.anyOf : undefined\n\tconst oneOf = node !== undefined && INTRINSICS.own(node, 'oneOf') ? node.oneOf : undefined\n\tif (fault.reason === 'variant' || fault.reason === 'oneOf') {\n\t\tconst count = fault.reason === 'variant' ? fault.variants : oneOf?.length\n\t\tconst forms = count === undefined ? 'the declared forms' : `the ${String(count)} declared forms`\n\t\tconst claim =\n\t\t\tfault.reason === 'oneOf' && fault.matched > 0\n\t\t\t\t? `the value matches ${String(fault.matched)} of ${forms} and must match exactly one`\n\t\t\t\t: `the value matches none of ${forms}`\n\t\tconst declared = anyOf ?? oneOf ?? []\n\t\tconst shown = declared.slice(0, FAULT_LIST_LIMIT)\n\t\tconst room = Math.min(\n\t\t\tFAULT_SCHEMA_LIMIT,\n\t\t\tMath.floor(FAULT_TEXT_LIMIT / 2 / Math.max(shown.length, 1)),\n\t\t)\n\t\tconst more = declared.length - shown.length\n\t\tconst summary =\n\t\t\tshown.length === 0\n\t\t\t\t? ''\n\t\t\t\t: `, one of: ${shown.map((form) => renderForm(form, room)).join(' or ')}${more > 0 ? ` and ${String(more)} more` : ''}`\n\t\treturn `${head}; ${claim}${fault.key === undefined ? '' : `; discriminator ${preview(fault.key)} expects ${renderList((fault.expected ?? []).map((value) => preview(value)))}`}; send it exactly as the schema declares${summary}`\n\t}\n\tconst candidates =\n\t\tfault.expected === 'literal'\n\t\t\t? extractForms(node).flatMap((form) => [\n\t\t\t\t\t...((INTRINSICS.own(form, 'enum') ? form.enum : undefined) ?? []),\n\t\t\t\t\t...(INTRINSICS.own(form, 'type') && form.type === 'null' ? [null] : []),\n\t\t\t\t])\n\t\t\t: []\n\tconst description =\n\t\tnode !== undefined && INTRINSICS.own(node, 'description') ? node.description : undefined\n\tconst received =\n\t\t'received' in fault && INTRINSICS.own(fault, 'received') ? fault.received : undefined\n\tconst shown =\n\t\treceived !== undefined &&\n\t\treceived.length <= PREVIEW_LIMIT &&\n\t\t!/[\\p{Cc}\\p{Zl}\\p{Zp}]/u.test(received)\n\t\t\t? received\n\t\t\t: preview(received)\n\treturn [\n\t\thead,\n\t\t`expected ${fault.expected}`,\n\t\t...(received !== undefined ? [`received ${shown}`] : []),\n\t\t...('constraint' in fault && INTRINSICS.own(fault, 'constraint')\n\t\t\t? [`constraint ${fault.constraint}`]\n\t\t\t: []),\n\t\t...('limit' in fault && INTRINSICS.own(fault, 'limit') && fault.limit !== undefined\n\t\t\t? [`limit ${preview(fault.limit)}`]\n\t\t\t: []),\n\t\t...(description === undefined ? [] : [`description ${preview(description)}`]),\n\t\t...(candidates.length > 0\n\t\t\t? [`send one of ${renderList(Array.from(new Set(candidates), (value) => preview(value)))}`]\n\t\t\t: []),\n\t].join('; ')\n}\n","import type { JSONClonerInterface, JSONRecord, JSONValue, Result } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\titerateIndices,\n\tadmitVisited,\n\tattempt,\n\tfailure,\n\tcollectMembers,\n\tisFailure,\n\tisSuccess,\n\tmatchesMember,\n\tmatchesVisited,\n\tomitVisited,\n\tpinMembers,\n} from './helpers.js'\nimport { isObject, isRecord } from './validators.js'\n\n/**\n * Owns the state of one exact JSON snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call performs one iterative descriptor walk and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned error. Nonredirectable terminal failure releases partial\n * traversal working state while retaining the source and exact error. Reentry\n * poisons the active operation and every later call with one shared cause-free\n * error.\n *\n * @param value - The unknown value to retain for cloning\n *\n * @example\n * ```ts\n * const source = { settings: { enabled: true } }\n * const cloner = new JSONCloner(source)\n * const clone = cloner.clone()\n * source.settings.enabled = false\n * cloner.clone() === clone // true\n * ```\n */\nexport class JSONCloner implements JSONClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// The active-path set is NOT an exception to that, and the sentence that made\n\t// it one was wrong: a redirected member there does not produce an owned\n\t// refusal, it removes the cycle test, and `WeakSet.prototype.has` answering\n\t// `false` made this class grow `#pending` without bound on a cyclic source —\n\t// no refusal, no return, and no instrument in the corpus able to report it.\n\t// Both sets are read through the captured visitation operations.\n\tstatic readonly #weakSet = WeakSet\n\t// The released state, shared by every cloner this class ever builds. `#fail`\n\t// assigns it in place of the working list, so a failed clone releases its\n\t// frames to collection instead of retaining an emptied array's capacity for\n\t// the instance's life. Sharing is safe because nothing writes to a released\n\t// list: every writer runs inside the walk, and a failed clone has already set\n\t// `#terminal`, which every later call answers from. The static block at the\n\t// foot of the class freezes it, so a write that did reach it fails loudly at\n\t// its own line rather than leaking one cloner's frame into every other\n\t// cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: JSONValue[] | JSONRecord\n\t\treadonly array: boolean\n\t\tentries: ReadonlyArray<readonly [key: string, value: unknown]> | undefined\n\t\tindex: number\n\t}> = []\n\treadonly #source: unknown\n\treadonly #owned: WeakSet<object>\n\treadonly #active: WeakSet<object>\n\t#pending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: JSONValue[] | JSONRecord\n\t\treadonly array: boolean\n\t\tentries: ReadonlyArray<readonly [key: string, value: unknown]> | undefined\n\t\tindex: number\n\t}>\n\t#poison: ContractError | undefined\n\t#terminal: Result<JSONValue, ContractError> | undefined\n\n\tconstructor(value: unknown) {\n\t\tthis.#source = value\n\t\tthis.#owned = new JSONCloner.#weakSet()\n\t\tthis.#active = new JSONCloner.#weakSet()\n\t\tthis.#pending = []\n\t\tthis.#poison = undefined\n\t\tthis.#terminal = undefined\n\t}\n\n\t/**\n\t * Clones the retained source into exact, deeply frozen JSON data.\n\t *\n\t * @param budget - Remaining nodes shared with an enclosing ownership operation\n\t * @returns The settled JSON snapshot\n\t * @throws {ContractError} When the source is inexact, cyclic, unreadable, or cloning is reentered\n\t */\n\tclone(budget: { left: number } = { left: CLONE_NODE_LIMIT }): JSONValue {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined) {\n\t\t\tif (isSuccess(terminal)) return terminal.value\n\t\t\tthrow terminal.error\n\t\t}\n\n\t\tconst poison = this.#poison\n\t\tif (poison !== undefined) {\n\t\t\tthis.#terminal = failure(poison)\n\t\t\tthrow poison\n\t\t}\n\n\t\tthis.#poison = this.#create('JSONCloner.clone: JSON cloning may not be reentered')\n\t\tconst outcome = attempt(() => this.#execute(budget))\n\t\tconst interruption = this.#terminal\n\t\tif (interruption !== undefined) {\n\t\t\tif (isSuccess(interruption)) return interruption.value\n\t\t\tthis.#fail(interruption.error)\n\t\t}\n\t\tif (isSuccess(outcome)) {\n\t\t\tthis.#terminal = outcome\n\t\t\treturn outcome.value\n\t\t}\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneJSONValue: failed to create an owned JSON snapshot')\n\t\tthis.#fail(error)\n\t}\n\n\t// Assignment only: the working list takes the class's shared frozen empty peer\n\t// rather than being truncated in place, so the abandoned frames are released\n\t// instead of held by an emptied array. `length` is a caller-reachable write on\n\t// the instance's own array; an assignment reaches no member at all.\n\t#fail(error: ContractError): never {\n\t\tthis.#terminal = failure(error)\n\t\tthis.#pending = JSONCloner.#emptyPending\n\t\tthrow error\n\t}\n\n\t#execute(budget: { left: number }): JSONValue {\n\t\tif (!INTRINSICS.safe(budget.left)) this.#refuse('cloneJSONValue: invalid node budget')\n\t\tbudget.left = INTRINSICS.min(budget.left, CLONE_NODE_LIMIT)\n\t\tconst root = this.#capture(this.#source, budget)\n\t\tthis.#drain(budget)\n\t\treturn root\n\t}\n\n\t#drain(budget: { left: number }): void {\n\t\twhile (this.#pending.length > 0) {\n\t\t\tconst frame = this.#pending[this.#pending.length - 1]\n\t\t\tif (frame === undefined) continue\n\n\t\t\tif (frame.entries === undefined) {\n\t\t\t\tframe.entries = frame.array\n\t\t\t\t\t? this.#captureArray(frame.source)\n\t\t\t\t\t: this.#captureRecord(frame.source)\n\t\t\t}\n\n\t\t\tconst entry = frame.entries[frame.index]\n\t\t\tif (entry === undefined) {\n\t\t\t\tINTRINSICS.freeze(frame.clone)\n\t\t\t\tomitVisited(this.#active, frame.source)\n\t\t\t\tthis.#pending.pop()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tframe.index += 1\n\n\t\t\tconst clone = this.#capture(entry[1], budget)\n\t\t\tINTRINSICS.define(frame.clone, entry[0], {\n\t\t\t\tvalue: clone,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t})\n\t\t}\n\t}\n\n\t#capture(value: unknown, budget: { left: number }): JSONValue {\n\t\t// Counted before the value is classified, so a leaf costs a tick too: the\n\t\t// blowup is in how many nodes the OUTPUT holds, and every produced node is\n\t\t// one unit of work and one unit of retained memory.\n\t\tbudget.left -= 1\n\t\tif (budget.left < 0) {\n\t\t\tthis.#refuse(\n\t\t\t\t`cloneJSONValue: snapshot exceeds the node limit ${CLONE_NODE_LIMIT}`,\n\t\t\t\tCLONE_NODE_LIMIT,\n\t\t\t)\n\t\t}\n\t\tif (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n\t\tif (typeof value === 'number') {\n\t\t\tif (INTRINSICS.finite(value)) return value\n\t\t\tthis.#refuse('cloneJSONValue: number is not finite')\n\t\t}\n\t\tif (typeof value === 'object') return this.#captureObject(value)\n\t\tthis.#refuse(\n\t\t\tthis.#pending.length === 0\n\t\t\t\t? 'cloneJSONValue: value is not JSON data'\n\t\t\t\t: 'cloneJSONValue: property is not JSON data',\n\t\t)\n\t}\n\n\t#captureObject(source: object): JSONValue[] | JSONRecord {\n\t\tif (matchesVisited(this.#active, source)) this.#refuse('cloneJSONValue: cycle detected')\n\t\tconst arrayOutcome = attempt(() => INTRINSICS.array(source))\n\t\tif (isFailure(arrayOutcome)) this.#refuse('cloneJSONValue: value brand could not be inspected')\n\t\tif (arrayOutcome.value) return this.#schedule(source, true)\n\t\tif (isRecord(source)) return this.#schedule(source, false)\n\t\tthis.#refuse('cloneJSONValue: object is not a plain record')\n\t}\n\n\t#schedule(source: object, array: boolean): JSONValue[] | JSONRecord {\n\t\tconst clone: JSONValue[] | JSONRecord = array ? [] : INTRINSICS.create(null)\n\t\tadmitVisited(this.#active, source)\n\t\tthis.#pending[this.#pending.length] = {\n\t\t\tsource,\n\t\t\tclone,\n\t\t\tarray,\n\t\t\tentries: undefined,\n\t\t\tindex: 0,\n\t\t}\n\t\treturn clone\n\t}\n\n\t#captureArray(source: object): ReadonlyArray<readonly [key: string, value: unknown]> {\n\t\tconst keysOutcome = attempt(() => INTRINSICS.reflect.members(source))\n\t\tif (isFailure(keysOutcome)) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst lengthOutcome = attempt(() => INTRINSICS.reflect.describe(source, 'length'))\n\t\tif (isFailure(lengthOutcome))\n\t\t\tthis.#refuse('cloneJSONValue: array length could not be inspected')\n\t\tconst lengthDescriptor = lengthOutcome.value\n\t\tif (\n\t\t\tlengthDescriptor === undefined ||\n\t\t\t!('value' in lengthDescriptor) ||\n\t\t\ttypeof lengthDescriptor.value !== 'number' ||\n\t\t\t!INTRINSICS.integer(lengthDescriptor.value) ||\n\t\t\tlengthDescriptor.value < 0 ||\n\t\t\tlengthDescriptor.value > 4_294_967_295 ||\n\t\t\tlengthDescriptor.enumerable !== false ||\n\t\t\tlengthDescriptor.configurable !== false\n\t\t) {\n\t\t\tthis.#refuse('cloneJSONValue: array is not intrinsic and dense')\n\t\t}\n\n\t\t// A collected vocabulary plus an exact count, not a shrinking `Set`:\n\t\t// exactness is the verdict this door PUBLISHES about the caller's array, and\n\t\t// `Set.prototype.delete` and the `size` accessor are two more members the\n\t\t// caller can answer for. `Reflect.ownKeys` never repeats a key — a proxy\n\t\t// trap returning duplicates is rejected by the host — so \"every index plus\n\t\t// `length`, and nothing else\" is exactly \"each is present, and the count\n\t\t// matches\".\n\t\tconst owned = collectMembers(keysOutcome.value)\n\t\tif (!matchesMember(owned, 'length')) {\n\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t}\n\t\tif (keysOutcome.value.length !== lengthDescriptor.value + 1) {\n\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t}\n\t\treturn INTRINSICS.from(\n\t\t\titerateIndices(() => lengthDescriptor.value),\n\t\t\t(index): readonly [string, unknown] => {\n\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\tif (!matchesMember(owned, key)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t\t\t}\n\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array index could not be inspected')\n\t\t\t\t}\n\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\tif (\n\t\t\t\t\tdescriptor === undefined ||\n\t\t\t\t\t!('value' in descriptor) ||\n\t\t\t\t\tdescriptor.enumerable !== true\n\t\t\t\t) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array index is not enumerable data')\n\t\t\t\t}\n\t\t\t\treturn [key, descriptor.value]\n\t\t\t},\n\t\t)\n\t}\n\n\t#captureRecord(source: object): ReadonlyArray<readonly [key: string, value: unknown]> {\n\t\tconst keysOutcome = attempt(() => INTRINSICS.reflect.members(source))\n\t\tif (isFailure(keysOutcome)) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst names = keysOutcome.value\n\t\t// Indexed, not iterated: this walk decides the published record's own-key\n\t\t// population, and an iterator is a caller-writable member that can yield a\n\t\t// key the source never had.\n\t\treturn INTRINSICS.from(\n\t\t\titerateIndices(() => names.length),\n\t\t\t(index): readonly [string, unknown] => {\n\t\t\t\tconst key = names[index]\n\t\t\t\tif (typeof key !== 'string') this.#refuse('cloneJSONValue: record has a symbol property')\n\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: record property could not be inspected')\n\t\t\t\t}\n\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\tif (\n\t\t\t\t\tdescriptor === undefined ||\n\t\t\t\t\t!('value' in descriptor) ||\n\t\t\t\t\tdescriptor.enumerable !== true\n\t\t\t\t) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: record property is not enumerable data')\n\t\t\t\t}\n\t\t\t\treturn [key, descriptor.value]\n\t\t\t},\n\t\t)\n\t}\n\n\t#create(message: string, limit?: number): ContractError {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'json', ...(limit === undefined ? {} : { limit }) },\n\t\t})\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t#refuse(message: string, limit?: number): never {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined && isFailure(terminal)) throw terminal.error\n\t\tthrow this.#create(message, limit)\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peer and stop\n\t\t// it satisfying the mutable working field it is assigned to.\n\t\tINTRINSICS.freeze(JSONCloner.#emptyPending)\n\t\t// Pinned while this class is DEFINED. `cloneJSONValue` reaches this class\n\t\t// through `JSONCloner.prototype.clone`, so one assignment there decided what\n\t\t// a door the caller never touched published — the same defect as a replaced\n\t\t// host member, with this package's own name on it.\n\t\tpinMembers(JSONCloner.prototype, 'JSONCloner')\n\t}\n}\n","import type { JSONSchema, Result, SchemaClonerInterface } from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tfailure,\n\tenumerableKeys,\n\tisSuccess,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n} from './helpers.js'\nimport { isObject } from './validators.js'\n\n/**\n * Owns the state of one JSON Schema snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call performs one iterative identity-memoized walk and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned error. Nonredirectable terminal settlement releases\n * populated traversal state before publishing that result, while retaining\n * the source and exact result afterward. Reentry poisons the active operation\n * and every later call with one shared cause-free error.\n *\n * @param schema - The JSON Schema graph to retain for cloning\n *\n * @example\n * ```ts\n * const child = { type: 'string' }\n * const cloner = new SchemaCloner({ anyOf: [child, child] })\n * const clone = cloner.clone()\n * clone.anyOf?.[0] === clone.anyOf?.[1] // true\n * cloner.clone() === clone // true\n * ```\n */\nexport class SchemaCloner implements SchemaClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// CONSTRUCTOR of each collection is captured beside its members, because\n\t// construction happens first: capturing `WeakSet.prototype.has` while still\n\t// reaching `globalThis.Map` leaves the door open one call earlier than the\n\t// member rows can see, and the constructor runs outside every containment\n\t// this class has.\n\tstatic readonly #map = Map\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #hasOwn = Object.hasOwn\n\t// The released state, shared by every cloner this class ever builds. `#settle`\n\t// assigns it in place of the working list, so an instance allocates one\n\t// collection instead of two and construction carries no empty peer of its own.\n\t// Sharing is safe because nothing writes to a released list: every writer runs\n\t// inside the walk and `#settle` is the walk's last step. The static block at\n\t// the foot of the class freezes it, so a write that did reach it fails loudly\n\t// at its own line rather than leaking one cloner's frame into every other\n\t// cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: object\n\t\treadonly path: readonly string[]\n\t\treadonly depth: number\n\t}> = []\n\treadonly #source: JSONSchema\n\treadonly #owned: WeakSet<object>\n\t// The working map is the field with no shared peer: `Object.freeze` reaches an\n\t// array's writes and not a `Map`'s, so a shared empty map would be a\n\t// class-lifetime cache any write could fill with one cloner's nodes. `#settle`\n\t// drops it instead, and absence is `undefined`.\n\t#memo: Map<object, object> | undefined\n\t#pending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: object\n\t\treadonly path: readonly string[]\n\t\treadonly depth: number\n\t}>\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'settled'; readonly result: Result<JSONSchema, ContractError> }\n\n\tconstructor(schema: JSONSchema) {\n\t\tthis.#source = schema\n\t\tthis.#owned = new SchemaCloner.#weakSet()\n\t\tthis.#memo = new SchemaCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clones the retained schema into an identity-preserving frozen graph.\n\t *\n\t * @returns The settled JSON Schema snapshot\n\t * @throws {ContractError} When traversal is unreadable or cloning is reentered\n\t */\n\tclone(): JSONSchema {\n\t\tconst state = this.#state\n\t\tswitch (state.phase) {\n\t\t\tcase 'settled':\n\t\t\t\tif (isSuccess(state.result)) return state.result.value\n\t\t\t\tthrow state.result.error\n\t\t\tcase 'running':\n\t\t\tcase 'interrupted':\n\t\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\t\tthrow state.poison\n\t\t\tcase 'ready':\n\t\t\t\tbreak\n\t\t}\n\n\t\tconst poison = this.#create('SchemaCloner.clone: schema cloning may not be reentered')\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#complete(attempt(() => this.#execute()))\n\t}\n\n\t#complete(outcome: Result<JSONSchema>): JSONSchema {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') {\n\t\t\treturn this.#settle(failure(state.poison))\n\t\t}\n\t\tif (isSuccess(outcome)) return this.#settle(outcome)\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneSchema: failed to create an owned schema snapshot', {\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t})\n\t\treturn this.#settle(failure(error))\n\t}\n\n\t#execute(): JSONSchema {\n\t\t// The root is branded like every other node. `#schedule` has always branched\n\t\t// on `Array.isArray`, so a nested array kept its brand while an ARRAY ROOT\n\t\t// was silently republished as a null-prototype record — one construct, two\n\t\t// answers depending on position, from a door whose whole contract is a\n\t\t// faithful owned snapshot. A `JSONSchema` root is a record, and a snapshot\n\t\t// that cannot be faithful refuses rather than rebrands. The rule is the ROOT's\n\t\t// alone: a schema graph is otherwise deliberately unbranded, so a class\n\t\t// instance stays acceptable schema data.\n\t\tif (INTRINSICS.array(this.#source)) {\n\t\t\tthis.#refuse('cloneSchema: a schema root must be a record, not an array', 'structure', [])\n\t\t}\n\t\t// Narrowed once at the door, because the dispatch below takes its receiver\n\t\t// type from this value. The walk runs before `#settle` drops the map, so it\n\t\t// always finds the one the constructor built; this refusal is what keeps\n\t\t// that a statement the types carry rather than one a comment makes.\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst root: JSONSchema = INTRINSICS.create(null)\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [this.#source, root])\n\t\tthis.#pending[this.#pending.length] = {\n\t\t\tsource: this.#source,\n\t\t\tclone: root,\n\t\t\tpath: [],\n\t\t\tdepth: 0,\n\t\t}\n\t\tthis.#drain()\n\t\treturn root\n\t}\n\n\t#drain(): void {\n\t\twhile (this.#pending.length > 0) {\n\t\t\tconst frame = this.#pending.pop()\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.depth > COMPILE_DEPTH_LIMIT) {\n\t\t\t\t// This door carried NO depth bound at all while every other public\n\t\t\t\t// traversal carried one, and its per-key path copy makes the walk\n\t\t\t\t// quadratic, so a 16,000-level schema — a few hundred kilobytes of\n\t\t\t\t// `JSON.parse`-able text — bought tens of seconds of work. The bound is\n\t\t\t\t// the shared compilation limit, and it is unreachable from `ShapeCloner`,\n\t\t\t\t// whose raw path validates the fragment against the same limit first.\n\t\t\t\tthis.#refuse('cloneSchema: schema exceeds the compilation depth limit', 'depth', frame.path)\n\t\t\t}\n\t\t\tconst keys = enumerableKeys(frame.source)\n\t\t\tif (keys === undefined) {\n\t\t\t\tthrow this.#create('cloneSchema: property enumeration failed', { path: frame.path })\n\t\t\t}\n\n\t\t\t// Indexed, not iterated: this walk decides the cloned node's own-key\n\t\t\t// population, so a lying `Array.prototype[Symbol.iterator]` would place a\n\t\t\t// key the source never had into a snapshot documented as faithful.\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.each, keys, [\n\t\t\t\t(key: string | undefined) => {\n\t\t\t\t\tif (key === undefined) return\n\t\t\t\t\tconst path = pathOf(frame.path, key)\n\t\t\t\t\tconst source = this.#read(frame.source, key, path)\n\t\t\t\t\tconst clone = this.#capture(source, path, frame.depth + 1)\n\t\t\t\t\tINTRINSICS.define(frame.clone, key, {\n\t\t\t\t\t\tvalue: clone,\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\twritable: true,\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t])\n\n\t\t\tINTRINSICS.freeze(frame.clone)\n\t\t}\n\t}\n\n\t#capture(value: unknown, path: readonly string[], depth: number): unknown {\n\t\tif (typeof value !== 'object' || value === null) return value\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst existing = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [value])\n\t\tif (existing !== undefined) return existing\n\t\treturn this.#schedule(value, path, depth)\n\t}\n\n\t#schedule(source: object, path: readonly string[], depth: number): object {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst clone: object = INTRINSICS.array(source) ? [] : INTRINSICS.create(null)\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [source, clone])\n\t\tthis.#pending[this.#pending.length] = { source, clone, path, depth }\n\t\treturn clone\n\t}\n\n\t#read(source: object, key: string, path: readonly string[]): unknown {\n\t\tconst outcome = attempt(() => INTRINSICS.reflect.read(source, key))\n\t\tif (isSuccess(outcome)) return outcome.value\n\t\tthrow this.#create('cloneSchema: property access failed', {\n\t\t\tpath,\n\t\t\tcause: outcome.error,\n\t\t})\n\t}\n\n\t// One refusal for the dropped working map, because a settled cloner replays\n\t// from `#state` and re-enters no walk method: nothing reachable settles here,\n\t// and every guard that says so must say it the same way.\n\t#unavailable(): ContractError {\n\t\treturn this.#create('SchemaCloner.clone: the capture state is unavailable')\n\t}\n\n\t#create(\n\t\tmessage: string,\n\t\toptions?: { readonly path?: readonly string[]; readonly cause?: unknown },\n\t): ContractError {\n\t\t// Own reads only, exactly as the diagnostic's `cause` already was: the\n\t\t// translation literal below carries `cause` and no `path`, so an\n\t\t// unqualified `options.path` would leave the literal and consult\n\t\t// `Object.prototype`, which the caller being diagnosed can write.\n\t\tconst path =\n\t\t\toptions !== undefined && SchemaCloner.#hasOwn(options, 'path') ? options.path : undefined\n\t\tconst context = path === undefined ? { shape: 'schema' } : { path, shape: 'schema' }\n\t\tconst error =\n\t\t\toptions !== undefined && SchemaCloner.#hasOwn(options, 'cause')\n\t\t\t\t? new ContractError(message, { code: 'clone', context, cause: options.cause })\n\t\t\t\t: new ContractError(message, { code: 'clone', context })\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t// The rules this engine OWNS rather than adopts: the record-rooted snapshot\n\t// and the shared depth bound. Registered as owned exactly as `#create` does,\n\t// so terminal replay still answers by identity.\n\t#refuse(message: string, code: 'structure' | 'depth', path: readonly string[]): never {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode,\n\t\t\tcontext:\n\t\t\t\tcode === 'depth'\n\t\t\t\t\t? { path, shape: 'schema', limit: COMPILE_DEPTH_LIMIT }\n\t\t\t\t\t: { path, shape: 'schema' },\n\t\t})\n\t\tadmitVisited(this.#owned, error)\n\t\tthrow error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t// Assignment only: the working list takes the class's shared frozen empty peer\n\t// and the working map is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection, so\n\t// settlement cannot be redirected into leaving state behind.\n\t#settle(result: Result<JSONSchema, ContractError>): JSONSchema {\n\t\tthis.#pending = SchemaCloner.#emptyPending\n\t\tthis.#memo = undefined\n\t\tthis.#state = { phase: 'settled', result }\n\t\tif (isSuccess(result)) return result.value\n\t\tthrow result.error\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peer and stop\n\t\t// it satisfying the mutable working field it is assigned to.\n\t\tINTRINSICS.freeze(SchemaCloner.#emptyPending)\n\t\t// Pinned while this class is DEFINED: `cloneSchema` reaches it through\n\t\t// `SchemaCloner.prototype.clone`, so an assignment there decides what a door\n\t\t// the caller never touched publishes.\n\t\tpinMembers(SchemaCloner.prototype, 'SchemaCloner')\n\t}\n}\n","import type { ContractShape } from './types.js'\nimport { CLONE_NODE_LIMIT, COMPILE_DEPTH_LIMIT, INTRINSICS, SHAPE_FIELDS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitMember,\n\tadmitVisited,\n\tappendEntries,\n\tattempt,\n\titerateIndices,\n\tcollectMembers,\n\tholds,\n\tisFailure,\n\tisSuccess,\n\tmatchesMember,\n\tmatchesJSONValue,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isRecord, isRegExp } from './validators.js'\n\n/** Owns the traversal and reentry poison of one validation call. */\nexport class ShapePass {\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\tstatic readonly #arrays = Array.prototype\n\tstatic readonly #pop = Array.prototype.pop\n\tstatic readonly #iterators = INTRINSICS.prototype(\n\t\tINTRINSICS.reflect.apply(INTRINSICS.indices, [], []),\n\t)\n\tstatic readonly #blank = INTRINSICS.freeze(new INTRINSICS.pattern(''))\n\t// Every field a node may leave out, so every read an inherited value could answer.\n\t// A sealed node's own fields cannot change, but a walk of one still refuses a\n\t// polluted `Object.prototype`, because a field the node does not hold reads through\n\t// to it. A required field is own on every node that recognizes it.\n\tstatic readonly #fields = [\n\t\t'min',\n\t\t'max',\n\t\t'pattern',\n\t\t'description',\n\t\t'integer',\n\t\t'additionalProperties',\n\t\t'mode',\n\t\t'default',\n\t]\n\t// What a walk of a builder's node found, kept so a later builder or compiler need\n\t// not walk it again. Building a declaration walked every subtree once per ancestor,\n\t// which is quadratic in depth, and compiling it cloned the graph and walked it twice\n\t// more. Only `#survey` writes here, and only for a frozen node this package made\n\t// whose children are all sealed, so a mutable node, a node frozen by a caller, and a\n\t// node with an accessor are never recorded and take the whole walk. `reach` is the\n\t// deepest level the subtree occupies, a raw node's embedded schema included, `count`\n\t// is the expansion, `defaulted` is a default on this node, and `held` is one\n\t// anywhere in the subtree.\n\tstatic readonly #seals = new ShapePass.#weakMap<\n\t\tContractShape,\n\t\t{\n\t\t\treadonly category: ContractShape['category']\n\t\t\treadonly reach: number\n\t\t\treadonly count: number\n\t\t\treadonly defaulted: boolean\n\t\t\treadonly held: boolean\n\t\t}\n\t>()\n\treadonly #source: unknown\n\treadonly #budget: { left: number } | undefined\n\t#stack: Array<\n\t\t| {\n\t\t\t\treadonly operation: 'enter'\n\t\t\t\treadonly shape: unknown\n\t\t\t\treadonly depth: number\n\t\t\t\treadonly optional: boolean\n\t\t\t\treadonly first?: string\n\t\t\t\treadonly second?: string\n\t\t }\n\t\t| { readonly operation: 'exit'; readonly index: number; readonly segments: number }\n\t> = []\n\t#path: string[] = []\n\t#active = new ShapePass.#weakSet<object>()\n\t// The capture. Discovery observes each unique node ONCE — descriptors, two\n\t// stable reads, scalar evidence and ordered outgoing edges — and every later\n\t// incoming edge is answered from here instead of from the caller's source.\n\t// Re-observing per incoming edge cost one whole observation per DISTINCT depth\n\t// a node was reached at, so an object holding one leaf at sixteen nesting\n\t// levels read that leaf sixteen times, and the subtree under it was re-walked\n\t// with it. `raw` is the height of a raw node's embedded schema, `0` for every\n\t// other node.\n\t#index = new ShapePass.#weakMap<object, number>()\n\t#captures: Array<{\n\t\treadonly shape: object\n\t\treadonly category: unknown\n\t\treadonly children: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}>\n\t\treadonly raw: number\n\t\treadonly defaulted: boolean\n\t\treadonly open: boolean\n\t}> = []\n\t// Discovery postorder: children finish before parents, so reading it forwards\n\t// solves any bottom-up fact in one pass and reading it backwards solves any\n\t// top-down one. Both replace a walk that was multiplicative in incoming edges.\n\t#post: number[] = []\n\t#height: number[] = []\n\t#reach: number[] = []\n\t// The edge that last raised `#reach`, so the position a depth verdict was\n\t// taken FROM can be spelled back out as a path. A refusal answered from the\n\t// deepest occurrence and reported at the first-discovered one accuses a slot\n\t// the same declaration proves legal on its own.\n\t#via: Array<{ readonly parent: number; readonly first: string; readonly second?: string }> = []\n\t// The edge that first put a node below a union, so a default's refusal can spell\n\t// the route through that union rather than the node's deepest one.\n\t#within: Array<{ readonly parent: number; readonly first: string; readonly second?: string }> = []\n\t// One node per node per incoming edge: the size of the TREE a compiler would\n\t// build from this DAG, which is what actually bounds compilation.\n\t#counts: number[] = []\n\t#schemas = new ShapePass.#weakMap<object, number>()\n\t#children: Array<{\n\t\treadonly shape: unknown\n\t\treadonly optional: boolean\n\t\treadonly first: string\n\t\treadonly second?: string\n\t}> = []\n\t#category: unknown\n\t#raw = 0\n\t#defaulted = false\n\t#open = false\n\t#structure: ContractError | undefined\n\t#cycle: ContractError | undefined\n\t#domain: ContractError | undefined\n\n\t#poison: ContractError | undefined\n\n\tconstructor(shape: unknown, budget?: { left: number }) {\n\t\tthis.#source = shape\n\t\tthis.#budget = budget\n\t}\n\n\t/**\n\t * Validates a node fresh from a builder, freezes it, and records what the walk found.\n\t *\n\t * @remarks\n\t * The node's own fields are always observed, and each child is answered from its\n\t * seal rather than walked. Anything short of a clean answer takes the whole walk\n\t * instead, which is what authors every refusal, so a refusal reads the same and\n\t * fires at the same call as it would with no seals at all. That second look is safe\n\t * because the first read nothing a caller wrote: the node is this package's own\n\t * literal, and a child with no seal stops the survey before it is read.\n\t *\n\t * @param shape - The builder's fresh node, which no caller has seen\n\t * @param check - What the whole walk validates, when the node is only legal in a slot\n\t * @returns The frozen node\n\t * @throws {ContractError} When the node is refused\n\t */\n\tstatic seal<S extends ContractShape>(shape: S, check: ContractShape = shape): Readonly<S> {\n\t\tconst frozen = INTRINSICS.freeze(shape)\n\t\tif (!new ShapePass(shape).#survey(check === shape ? 0 : 1)) {\n\t\t\tnew ShapePass(check, { left: CLONE_NODE_LIMIT }).validate()\n\t\t}\n\t\treturn frozen\n\t}\n\n\t/**\n\t * Reports the expansion of a sealed node a compiler can take as it stands.\n\t *\n\t * @remarks\n\t * `undefined` sends the caller to its own ownership and validation: the node was\n\t * never sealed, an inherited field would answer a walk of it, or it is an `optional`\n\t * node, which a walk refuses as a root.\n\t *\n\t * @param shape - The declaration to look up\n\t * @returns The expansion a walk would report, or `undefined`\n\t */\n\tstatic expansionOf(shape: ContractShape): number | undefined {\n\t\tif (ShapePass.polluted()) return undefined\n\t\tconst seal = INTRINSICS.reflect.apply(INTRINSICS.recall, ShapePass.#seals, [shape])\n\t\treturn seal === undefined || seal.category === 'optional' ? undefined : seal.count\n\t}\n\n\t/**\n\t * Reports whether a walk could answer differently from a seal.\n\t *\n\t * @remarks\n\t * A field a node may leave out reads through to `Object.prototype`, which is a\n\t * verdict about the declaration, and a {@link tampered} host breaks a walk into a\n\t * refusal a seal would otherwise skip.\n\t *\n\t * @returns True when a walk has to answer rather than a seal\n\t */\n\tstatic polluted(): boolean {\n\t\tif (ShapePass.tampered()) return true\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, ShapePass.#fields, [\n\t\t\t(field: string) => INTRINSICS.own(INTRINSICS.base, field),\n\t\t])\n\t}\n\n\t/**\n\t * Reports whether a member a walk or a compile runs on has been replaced.\n\t *\n\t * @remarks\n\t * An index on either prototype, reached by array writes, a replaced `pop` or array\n\t * iterator `next`, and a flag getter a pattern's `flags` reads. An array's `length`\n\t * always passes its highest index, and own keys list an index first, so one read\n\t * answers for every index, and a name that merely opens with a digit only costs a walk.\n\t *\n\t * @returns True when the host is not the one this package loaded on\n\t */\n\tstatic tampered(): boolean {\n\t\tif (ShapePass.#arrays.length !== 0) return true\n\t\tconst first = INTRINSICS.reflect.members(INTRINSICS.base)[0]\n\t\tif (typeof first === 'string' && first >= '0' && first < ':') return true\n\t\tif (INTRINSICS.describe(ShapePass.#arrays, 'pop')?.value !== ShapePass.#pop) return true\n\t\tconst next = INTRINSICS.describe(ShapePass.#iterators, 'next')?.value\n\t\tif (next !== INTRINSICS.advance) return true\n\t\treturn !holds(() => readPatternFlags(ShapePass.#blank) === '')\n\t}\n\n\t/** Poisons this pass and throws the same refusal on every reentry. */\n\tinterrupt(): never {\n\t\tthis.#poison ??= new ContractError(\n\t\t\t'ShapeValidator.validate: shape validation may not be reentered',\n\t\t\t{ code: 'structure', context: { path: [] } },\n\t\t)\n\t\tthrow this.#poison\n\t}\n\n\t/** Validates the captured source and returns its expansion. */\n\tvalidate(): number {\n\t\tconst outcome = attempt(() => this.#execute())\n\t\tif (this.#poison !== undefined) throw this.#poison\n\t\tif (isSuccess(outcome)) return this.#counts[0] ?? 1\n\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\tthrow new ContractError('validateShape: shape reflection failed', {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: [] },\n\t\t\tcause: outcome.error,\n\t\t})\n\t}\n\n\t// One observation of the node, and its children answered from their seals. Each\n\t// rule the walk asks across an edge is asked here too: optional placement in the\n\t// slot, a default below a union or beside an open object's extras, and depth. `lift`\n\t// is how far below the walk's root this node sits, which is one under the object an\n\t// optional node is validated inside. A false answer says nothing about the node\n\t// beyond that the walk has to decide.\n\t#survey(lift: number): boolean {\n\t\tif (ShapePass.polluted()) return false\n\t\tconst shape = this.#source\n\t\tif (!isRecord(shape)) return false\n\t\tconst outcome = attempt(() => this.#observe(shape, 0))\n\t\tif (isFailure(outcome) || !outcome.value || this.#domain !== undefined) return false\n\t\tconst seal = {\n\t\t\tcategory: shape.category,\n\t\t\treach: this.#raw,\n\t\t\tcount: 1,\n\t\t\tdefaulted: this.#defaulted,\n\t\t\theld: this.#defaulted,\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#children.length)) {\n\t\t\tconst child = this.#children[index]\n\t\t\tconst known = INTRINSICS.reflect.apply(INTRINSICS.recall, ShapePass.#seals, [child?.shape])\n\t\t\tif (child === undefined || known === undefined) return false\n\t\t\tif (known.category === 'optional' && !child.optional) return false\n\t\t\tif (known.held && shape.category === 'union') return false\n\t\t\tif (known.defaulted && this.#open) return false\n\t\t\tseal.reach = INTRINSICS.max(seal.reach, known.reach + 1)\n\t\t\tseal.count += known.count\n\t\t\tseal.held ||= known.held\n\t\t}\n\t\tif (seal.reach + lift > COMPILE_DEPTH_LIMIT) return false\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, ShapePass.#seals, [shape, seal])\n\t\treturn true\n\t}\n\n\t#execute(): void {\n\t\tthis.#stack[this.#stack.length] = {\n\t\t\toperation: 'enter',\n\t\t\tshape: this.#source,\n\t\t\tdepth: 0,\n\t\t\toptional: false,\n\t\t}\n\t\twhile (this.#stack.length > 0) this.#visit()\n\t\tthis.#measure()\n\t\tthis.#finish()\n\t}\n\n\t#visit(): void {\n\t\tconst frame = this.#stack.pop()\n\t\tif (frame === undefined) return\n\t\tif (frame.operation === 'exit') {\n\t\t\tconst capture = this.#captures[frame.index]\n\t\t\tif (capture !== undefined) omitVisited(this.#active, capture.shape)\n\t\t\tthis.#post[this.#post.length] = frame.index\n\t\t\tthis.#path.length -= frame.segments\n\t\t\treturn\n\t\t}\n\n\t\tconst first = INTRINSICS.own(frame, 'first') ? frame.first : undefined\n\t\tconst second = INTRINSICS.own(frame, 'second') ? frame.second : undefined\n\t\tconst segments = (first === undefined ? 0 : 1) + (second === undefined ? 0 : 1)\n\t\tif (first !== undefined) {\n\t\t\tthis.#path[this.#path.length] = first\n\t\t}\n\t\tif (second !== undefined) {\n\t\t\tthis.#path[this.#path.length] = second\n\t\t}\n\n\t\tconst current = frame.shape\n\t\tif (typeof current !== 'object' || current === null || !isRecord(current)) {\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: every structural child must be a shape',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t\t},\n\t\t\t)\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\t\tif (matchesVisited(this.#active, current)) {\n\t\t\tthis.#cycle ??= new ContractError('validateShape: a shape graph may not contain a cycle', {\n\t\t\t\tcode: 'cycle',\n\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t})\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\t// The refinement, and the whole reason discovery is separate from\n\t\t// measurement: a node already captured is not observed again. Every rule the\n\t\t// OBSERVATION enforces is a property of the node, so a second look at the\n\t\t// same node can only produce the same answer at a longer path. Optional\n\t\t// placement and depth are properties of the POSITION instead, and they are\n\t\t// answered in separate\n\t\t// places: where an `optional` node is legal is re-asked here, from the\n\t\t// capture, for every incoming edge, while depth — the shape's own and a raw\n\t\t// node's embedded schema alike — is measured over the whole captured graph in\n\t\t// `#measure`, which is why its diagnostics are spelled from the deepest\n\t\t// occurrence rather than from whichever edge discovery arrived on.\n\t\tconst seen = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#index, [current])\n\t\tif (seen !== undefined) {\n\t\t\tthis.#place(seen, frame.optional)\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\tthis.#children = []\n\t\tthis.#category = undefined\n\t\tthis.#raw = 0\n\t\tthis.#defaulted = false\n\t\tthis.#open = false\n\t\tconst outcome = attempt(() => this.#observe(current, frame.depth))\n\t\tthis.#spend(0)\n\t\tif (isFailure(outcome) || !outcome.value) {\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t\t},\n\t\t\t)\n\t\t\t// Captured as a childless leaf. Its subtree is not walked, and every later\n\t\t\t// edge to it measures its depth from the capture instead of re-running the\n\t\t\t// observation that already refused.\n\t\t\tthis.#post[this.#post.length] = this.#capture(current, [])\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\tthis.#place(this.#schedule(current, frame.depth, segments), frame.optional)\n\t}\n\n\t#observe(current: Record<string, unknown>, depth: number): boolean {\n\t\tconst descriptor = INTRINSICS.describe(current, 'category')\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tconst category = current.category\n\t\tif (current.category !== category || descriptor.value !== category) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tconst fields =\n\t\t\ttypeof category === 'string' && INTRINSICS.own(SHAPE_FIELDS, category)\n\t\t\t\t? SHAPE_FIELDS[category]\n\t\t\t\t: undefined\n\t\tif (fields === undefined) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tthis.#category = category\n\t\tif (!this.#scan(current, fields)) return false\n\t\tif (!this.#constrain(current)) return false\n\t\tif (category === 'raw') {\n\t\t\tconst schema = current.schema\n\t\t\tconst outcome = attempt(() => this.#inspect(schema))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'schema')\n\t\t\t}\n\t\t\tif (!outcome.value) return false\n\t\t\t// The embedded schema's own nesting is measured once per unique record\n\t\t\t// and applied at THIS node's depth, so a schema shared by two raw nodes\n\t\t\t// is validated once and still refuses at whichever node is too deep for\n\t\t\t// it. The deeper-occurrence case is re-asked in `#measure`.\n\t\t\tif (depth + this.#raw > COMPILE_DEPTH_LIMIT) {\n\t\t\t\treturn this.#refuse(\n\t\t\t\t\t'validateShape: raw schema exceeds the compilation depth limit',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (category === 'object') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'properties')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\tif (category === 'union') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'variants')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\tif (category === 'literal') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'values')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\treturn this.#populate(current)\n\t}\n\n\t#scan(current: Record<string, unknown>, fields: readonly string[]): boolean {\n\t\tfor (const fieldIndex of iterateIndices(() => fields.length)) {\n\t\t\tconst field = fields[fieldIndex]\n\t\t\tif (field === undefined) continue\n\t\t\tconst outcome = attempt((): boolean => {\n\t\t\t\tconst descriptor = INTRINSICS.describe(current, field)\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\t!INTRINSICS.own(descriptor, 'value') &&\n\t\t\t\t\tfield !== 'pattern'\n\t\t\t\t) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tconst first: unknown = INTRINSICS.reflect.read(current, field)\n\t\t\t\tconst second: unknown = INTRINSICS.reflect.read(current, field)\n\t\t\t\tif (descriptor === undefined) return first === undefined && second === undefined\n\t\t\t\tif (INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\tconst described: unknown = descriptor.value\n\t\t\t\t\treturn INTRINSICS.same(first, described) && INTRINSICS.same(second, first)\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\tfield === 'pattern' &&\n\t\t\t\t\tisRegExp(first) &&\n\t\t\t\t\tisRegExp(second) &&\n\t\t\t\t\treadPatternSource(first) === readPatternSource(second) &&\n\t\t\t\t\treadPatternFlags(first) === readPatternFlags(second) &&\n\t\t\t\t\tINTRINSICS.frozen(first) &&\n\t\t\t\t\tINTRINSICS.frozen(second)\n\t\t\t\t)\n\t\t\t})\n\t\t\tif (isFailure(outcome) || !outcome.value) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', field)\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\t#constrain(current: Record<string, unknown>): boolean {\n\t\tif (\n\t\t\tcurrent.category !== 'optional' &&\n\t\t\tcurrent.category !== 'nullable' &&\n\t\t\tcurrent.category !== 'raw' &&\n\t\t\tcurrent.description !== undefined &&\n\t\t\ttypeof current.description !== 'string'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: description must be a string', 'description')\n\t\t}\n\t\tif (current.category === 'optional' && INTRINSICS.own(current, 'default')) {\n\t\t\tif (!holds(() => matchesJSONValue(current.default, new ShapePass.#weakSet(), this.#budget))) {\n\t\t\t\treturn this.#refuse('validateShape: an optional default must be a JSON value', 'default')\n\t\t\t}\n\t\t\tthis.#defaulted = true\n\t\t}\n\t\tif (current.category === 'string') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: string min must be a number', 'min')\n\t\t\t}\n\t\t\tif (current.max !== undefined && typeof current.max !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: string max must be a number', 'max')\n\t\t\t}\n\t\t\tif (current.pattern !== undefined) {\n\t\t\t\tconst pattern = current.pattern\n\t\t\t\tif (!isRegExp(pattern)) {\n\t\t\t\t\treturn this.#refuse('validateShape: string pattern must be a RegExp', 'pattern')\n\t\t\t\t}\n\t\t\t\t// Both observations go through the CAPTURED accessors: a replaced\n\t\t\t\t// `source` getter reports for every pattern in the realm, so the\n\t\t\t\t// stability this gate publishes would be stability of the caller's\n\t\t\t\t// answer rather than of the pattern.\n\t\t\t\tconst source = readPatternSource(pattern)\n\t\t\t\tconst flags = readPatternFlags(pattern)\n\t\t\t\tif (\n\t\t\t\t\ttypeof source !== 'string' ||\n\t\t\t\t\ttypeof flags !== 'string' ||\n\t\t\t\t\treadPatternSource(pattern) !== source ||\n\t\t\t\t\treadPatternFlags(pattern) !== flags\n\t\t\t\t) {\n\t\t\t\t\treturn this.#refuse('validateShape: string pattern must be stable', 'pattern')\n\t\t\t\t}\n\t\t\t\tthis.#restrict(current, source, flags)\n\t\t\t} else {\n\t\t\t\tthis.#restrict(current)\n\t\t\t}\n\t\t}\n\t\tif (current.category === 'number') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: number min must be a number', 'min')\n\t\t\t}\n\t\t\tif (current.max !== undefined && typeof current.max !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: number max must be a number', 'max')\n\t\t\t}\n\t\t\tif (current.integer !== undefined && typeof current.integer !== 'boolean') {\n\t\t\t\treturn this.#refuse('validateShape: number integer must be a boolean', 'integer')\n\t\t\t}\n\t\t\tconst shape = current.integer === true ? 'integer' : 'number'\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.min !== undefined &&\n\t\t\t\t!INTRINSICS.finite(current.min)\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape min must be finite', {\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tlimit: 'finite number',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.max !== undefined &&\n\t\t\t\t!INTRINSICS.finite(current.max)\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape max must be finite', {\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tlimit: 'finite number',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.min !== undefined &&\n\t\t\t\tcurrent.max !== undefined &&\n\t\t\t\ttypeof current.min === 'number' &&\n\t\t\t\ttypeof current.max === 'number' &&\n\t\t\t\tcurrent.min > current.max\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape has min greater than max', {\n\t\t\t\t\tcode: 'range',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape },\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (this.#domain === undefined && current.integer === true) {\n\t\t\t\tconst lo = INTRINSICS.ceil(current.min ?? Number.NEGATIVE_INFINITY)\n\t\t\t\tconst hi = INTRINSICS.floor(current.max ?? Number.POSITIVE_INFINITY)\n\t\t\t\tif (lo > hi) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: an integer number shape has an empty integer range',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'range',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'integer' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\ttypeof current.min !== 'number'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: array min must be a number', 'min')\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.max !== 'number'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: array max must be a number', 'max')\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(typeof current.min !== 'number' || !INTRINSICS.safe(current.min) || current.min < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: an array shape min must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'array',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\t(typeof current.max !== 'number' || !INTRINSICS.safe(current.max) || current.max < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: an array shape max must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'array',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.min === 'number' &&\n\t\t\ttypeof current.max === 'number' &&\n\t\t\tcurrent.min > current.max\n\t\t) {\n\t\t\tthis.#domain = new ContractError('validateShape: an array shape has min greater than max', {\n\t\t\t\tcode: 'range',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'array' },\n\t\t\t})\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'union' &&\n\t\t\tcurrent.mode !== undefined &&\n\t\t\tcurrent.mode !== 'anyOf' &&\n\t\t\tcurrent.mode !== 'oneOf'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: union mode must be anyOf or oneOf', 'mode')\n\t\t}\n\t\treturn true\n\t}\n\n\t// Where an `optional` node is legal depends on the SLOT it arrived through, not\n\t// on the node, so this is the one rule discovery asks per incoming edge rather\n\t// than once per node. It reads the captured category instead of the source: a\n\t// second read of `category` would be a second observation of a node already\n\t// observed, and an unrecognized node has no category to answer with.\n\t#place(index: number, optional: boolean): void {\n\t\tif (optional || this.#domain !== undefined) return\n\t\tif (this.#captures[index]?.category !== 'optional') return\n\t\tthis.#domain = new ContractError(\n\t\t\t'validateShape: an optional shape may only appear as a direct object-property value',\n\t\t\t{\n\t\t\t\tcode: 'placement',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'optional' },\n\t\t\t},\n\t\t)\n\t}\n\n\t#restrict(current: Record<string, unknown>, source = '', flags = ''): void {\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(typeof current.min !== 'number' || !INTRINSICS.safe(current.min) || current.min < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape min must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\t(typeof current.max !== 'number' || !INTRINSICS.safe(current.max) || current.max < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape max must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (this.#domain === undefined && flags.length > 0) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape pattern must not use flags; use inline pattern constructs instead',\n\t\t\t\t{\n\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\treceived: `/${source}/${flags}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.min === 'number' &&\n\t\t\ttypeof current.max === 'number' &&\n\t\t\tcurrent.min > current.max\n\t\t) {\n\t\t\tthis.#domain = new ContractError('validateShape: a string shape has min greater than max', {\n\t\t\t\tcode: 'range',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'string' },\n\t\t\t})\n\t\t}\n\t}\n\n\t// Validates the embedded schema graph and leaves its HEIGHT in `#raw` — the\n\t// number of levels it adds below the raw node that carries it. Each unique\n\t// record is validated once per call and memoized, so a schema shared between\n\t// two raw nodes, or reached twice inside one, costs its records and edges\n\t// rather than its paths. The depth verdict moved out with it: a height is a\n\t// property of the schema, while whether that height fits is a property of the\n\t// node's position, and only the second one varies per occurrence.\n\t#inspect(source: unknown): boolean {\n\t\tif (this.#structure !== undefined) return true\n\t\tif (!isRecord(source)) {\n\t\t\treturn this.#refuse('validateShape: raw schema must be a plain record', 'schema')\n\t\t}\n\t\tconst active = new ShapePass.#weakSet<object>()\n\t\tconst stack: Array<\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'enter'\n\t\t\t\t\treadonly schema: unknown\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'exit'\n\t\t\t\t\treadonly schema: object\n\t\t\t\t\treadonly nested: readonly unknown[]\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t }\n\t\t> = [{ operation: 'enter', schema: source }]\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack.pop()\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tomitVisited(active, frame.schema)\n\t\t\t\tthis.#settleSchema(frame.schema, frame.nested)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst first = INTRINSICS.own(frame, 'first') ? frame.first : undefined\n\t\t\tconst second = INTRINSICS.own(frame, 'second') ? frame.second : undefined\n\t\t\tconst schema = frame.schema\n\t\t\tif (!isRecord(schema)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: every raw schema child must be a plain record',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (matchesVisited(active, schema)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: a raw schema may not contain a cycle',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [schema]) !== undefined)\n\t\t\t\tcontinue\n\t\t\tadmitVisited(active, schema)\n\n\t\t\tconst keyList = INTRINSICS.keys(schema)\n\t\t\tfor (const keyIndex of iterateIndices(() => keyList.length)) {\n\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tif (\n\t\t\t\t\tkey !== 'type' &&\n\t\t\t\t\tkey !== 'description' &&\n\t\t\t\t\tkey !== 'default' &&\n\t\t\t\t\tkey !== 'enum' &&\n\t\t\t\t\tkey !== 'minLength' &&\n\t\t\t\t\tkey !== 'maxLength' &&\n\t\t\t\t\tkey !== 'pattern' &&\n\t\t\t\t\tkey !== 'format' &&\n\t\t\t\t\tkey !== 'minimum' &&\n\t\t\t\t\tkey !== 'maximum' &&\n\t\t\t\t\tkey !== 'minItems' &&\n\t\t\t\t\tkey !== 'maxItems' &&\n\t\t\t\t\tkey !== 'items' &&\n\t\t\t\t\tkey !== 'properties' &&\n\t\t\t\t\tkey !== 'required' &&\n\t\t\t\t\tkey !== 'additionalProperties' &&\n\t\t\t\t\tkey !== 'anyOf' &&\n\t\t\t\t\tkey !== 'oneOf'\n\t\t\t\t) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema contains an unsupported keyword',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst category = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\t\tif (\n\t\t\t\tcategory !== undefined &&\n\t\t\t\tcategory !== 'null' &&\n\t\t\t\tcategory !== 'boolean' &&\n\t\t\t\tcategory !== 'object' &&\n\t\t\t\tcategory !== 'array' &&\n\t\t\t\tcategory !== 'number' &&\n\t\t\t\tcategory !== 'integer' &&\n\t\t\t\tcategory !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema type is outside the supported vocabulary',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'type',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'description') &&\n\t\t\t\tschema.description !== undefined &&\n\t\t\t\ttypeof schema.description !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema description must be a string',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'description',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'default') && !isJSONValue(schema.default)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema default must be a JSON value',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'default',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'format') &&\n\t\t\t\tschema.format !== undefined &&\n\t\t\t\ttypeof schema.format !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema format must be a string',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'format',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'pattern') && schema.pattern !== undefined) {\n\t\t\t\tif (typeof schema.pattern !== 'string') {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema pattern must be a string',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'pattern',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// The CAPTURED `RegExp`, not the live global: the result of this read is\n\t\t\t\t// the refusal `rawShape` documents, and a caller who installed a\n\t\t\t\t// non-throwing stub made a malformed pattern compile clean.\n\t\t\t\tconst pattern = attempt(() =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.pattern, undefined, [schema.pattern]),\n\t\t\t\t)\n\t\t\t\tif (isFailure(pattern)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema pattern must be valid',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'pattern',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst lengthList = ['minLength', 'maxLength', 'minItems', 'maxItems']\n\t\t\tfor (const lengthIndex of iterateIndices(() => lengthList.length)) {\n\t\t\t\tconst key = lengthList[lengthIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (value !== undefined && (!INTRINSICS.safe(value) || INTRINSICS.numeric(value) < 0)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema length bounds must be non-negative safe integers',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst rangeList = ['minimum', 'maximum']\n\t\t\tfor (const rangeIndex of iterateIndices(() => rangeList.length)) {\n\t\t\t\tconst key = rangeList[rangeIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (value !== undefined && (typeof value !== 'number' || !INTRINSICS.finite(value))) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema numeric bounds must be finite numbers',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst population = INTRINSICS.own(schema, 'enum') ? schema.enum : undefined\n\t\t\tif (population !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(population)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be a non-empty array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(population)\n\t\t\t\tif (isFailure(snapshot) || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be a non-empty array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be dense',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// A module-scope membership question, not `set.has(value)`: this\n\t\t\t\t// uniqueness test decides whether the door accepts or refuses, so\n\t\t\t\t// `Set.prototype.has = () => false` would admit a duplicate vocabulary\n\t\t\t\t// the shape gate exists to reject.\n\t\t\t\tconst values = collectMembers([])\n\t\t\t\tfor (const valueIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\t// A present member whose captured value is `undefined` is refused by\n\t\t\t\t\t// the literal test below rather than skipped.\n\t\t\t\t\tconst value = snapshot.value.entries[valueIndex]\n\t\t\t\t\tif (\n\t\t\t\t\t\t!isLiteralValue(value) ||\n\t\t\t\t\t\t(typeof value === 'number' && !INTRINSICS.finite(value)) ||\n\t\t\t\t\t\tmatchesMember(values, value)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t\t'validateShape: raw schema enum values must be finite unique primitives',\n\t\t\t\t\t\t\tstack,\n\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t\t'enum',\n\t\t\t\t\t\t\tINTRINSICS.text(valueIndex),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(values, value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst names = INTRINSICS.own(schema, 'required') ? schema.required : undefined\n\t\t\tif (names !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(names)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be an array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(names)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be an array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be dense',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst required = collectMembers([])\n\t\t\t\tfor (const valueIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\tconst value = snapshot.value.entries[valueIndex]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tif (typeof value !== 'string' || matchesMember(required, value)) {\n\t\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t\t'validateShape: raw schema required values must be unique strings',\n\t\t\t\t\t\t\tstack,\n\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t\t'required',\n\t\t\t\t\t\t\tINTRINSICS.text(valueIndex),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(required, value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst nested: unknown[] = []\n\t\t\tconst edges: Array<readonly [string, string?]> = []\n\t\t\tif (INTRINSICS.own(schema, 'items') && schema.items !== undefined) {\n\t\t\t\tedges[nested.length] = ['items']\n\t\t\t\tnested[nested.length] = schema.items\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'properties') && schema.properties !== undefined) {\n\t\t\t\tif (!isRecord(schema.properties)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema properties must be a plain record',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst propertyList = INTRINSICS.keys(schema.properties)\n\t\t\t\tfor (const propertyIndex of iterateIndices(() => propertyList.length)) {\n\t\t\t\t\tconst key = propertyList[propertyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tedges[nested.length] = ['properties', key]\n\t\t\t\t\tnested[nested.length] = INTRINSICS.own(schema.properties, key)\n\t\t\t\t\t\t? schema.properties[key]\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'additionalProperties') &&\n\t\t\t\tschema.additionalProperties !== undefined &&\n\t\t\t\tschema.additionalProperties !== true &&\n\t\t\t\tschema.additionalProperties !== false\n\t\t\t) {\n\t\t\t\tedges[nested.length] = ['additionalProperties']\n\t\t\t\tnested[nested.length] = schema.additionalProperties\n\t\t\t}\n\t\t\tconst unionList = ['anyOf', 'oneOf']\n\t\t\tfor (const unionIndex of iterateIndices(() => unionList.length)) {\n\t\t\t\tconst key = unionList[unionIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst variants = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (variants === undefined) continue\n\t\t\t\tif (!INTRINSICS.array(variants)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(variants)\n\t\t\t\tif (isFailure(snapshot) || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be dense arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tfor (const variantIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\t// A present member whose captured value is `undefined` is still a\n\t\t\t\t\t// present member, so it is scheduled and refused as a nonrecord\n\t\t\t\t\t// rather than skipped.\n\t\t\t\t\tedges[nested.length] = [key, INTRINSICS.text(variantIndex)]\n\t\t\t\t\tnested[nested.length] = snapshot.value.entries[variantIndex]\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack[stack.length] = {\n\t\t\t\toperation: 'exit',\n\t\t\t\tschema,\n\t\t\t\tnested,\n\t\t\t\t...(first === undefined ? {} : { first: first }),\n\t\t\t\t...(second === undefined ? {} : { second: second }),\n\t\t\t}\n\t\t\tfor (const offset of iterateIndices(() => nested.length)) {\n\t\t\t\tconst index = nested.length - 1 - offset\n\t\t\t\tconst childFirst = edges[index]?.[0]\n\t\t\t\tconst edge = edges[index]\n\t\t\t\tconst childSecond = edge !== undefined && INTRINSICS.own(edge, 1) ? edge[1] : undefined\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tschema: nested[index],\n\t\t\t\t\t...(childFirst === undefined ? {} : { first: childFirst }),\n\t\t\t\t\t...(childSecond === undefined ? {} : { second: childSecond }),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.#raw = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [source]) ?? 0\n\t\treturn true\n\t}\n\n\t// One raw-schema record's height, recorded as its walk finishes. Every nested\n\t// record has already finished, so its own height is in the memo.\n\t#settleSchema(schema: object, nested: readonly unknown[]): void {\n\t\tconst height: number = INTRINSICS.reflect.apply(INTRINSICS.fold, nested, [\n\t\t\t(highest: number, child: unknown) => {\n\t\t\t\tconst recorded =\n\t\t\t\t\ttypeof child !== 'object' || child === null\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [child]) ?? 0)\n\t\t\t\treturn INTRINSICS.max(highest, recorded + 1)\n\t\t\t},\n\t\t\t0,\n\t\t])\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#schemas, [schema, height])\n\t}\n\n\t#populate(current: Record<string, unknown>): boolean {\n\t\tswitch (current.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#spend(1)\n\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\tshape: current.items,\n\t\t\t\t\tfirst: 'items',\n\t\t\t\t\toptional: false,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'object': {\n\t\t\t\tconst properties = current.properties\n\t\t\t\tif (!isRecord(properties)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: properties must be a plain property map',\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst keys = INTRINSICS.keys(properties)\n\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(properties, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst childOutcome = attempt(() => {\n\t\t\t\t\t\tconst population = current.properties\n\t\t\t\t\t\treturn isRecord(population) ? population[key] : undefined\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(childOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst child = childOutcome.value\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.properties\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tisRecord(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[key], child) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, child)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: child,\n\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\toptional: true,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst extra = current.additionalProperties\n\t\t\t\tthis.#open = extra !== undefined && extra !== false\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: extra,\n\t\t\t\t\t\tfirst: 'additionalProperties',\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tif (!INTRINSICS.array(current.variants)) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a finite array', 'variants')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(current.variants)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a finite array', 'variants')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a dense data array', 'variants')\n\t\t\t\t}\n\t\t\t\tconst variants = snapshot.value.entries\n\t\t\t\tconst length = variants.length\n\t\t\t\tif (this.#domain === undefined && length === 0) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: a union shape needs at least one variant',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'empty',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'union' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => length)) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.variants, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'variants',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: false,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst variant = variants[index]\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.variants\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tINTRINSICS.array(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[index], variant) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, variant)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'variants',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: false,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: variant,\n\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'literal': {\n\t\t\t\tif (!INTRINSICS.array(current.values)) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a finite literal array', 'values')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(current.values)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a finite literal array', 'values')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a dense data array', 'values')\n\t\t\t\t}\n\t\t\t\tconst literals = snapshot.value.entries\n\t\t\t\tconst length = literals.length\n\t\t\t\tif (this.#domain === undefined && length === 0) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: a literal shape needs at least one value',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'empty',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'literal' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// A module-scope membership question, not `set.has(value)`: this\n\t\t\t\t// uniqueness test decides whether the door accepts or refuses, so\n\t\t\t\t// `Set.prototype.has = () => false` would admit a duplicate vocabulary\n\t\t\t\t// the shape gate exists to reject.\n\t\t\t\tconst values = collectMembers([])\n\t\t\t\tfor (const index of iterateIndices(() => length)) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.values, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: values must be a dense data array', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tconst value = literals[index]\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.values\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tINTRINSICS.array(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[index], value) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, value)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: values must be a stable data array', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (matchesMember(values, value)) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: literal values must be unique', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(values, value)\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.#domain === undefined &&\n\t\t\t\t\t\ttypeof value === 'number' &&\n\t\t\t\t\t\t!INTRINSICS.finite(value)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t\t'validateShape: a literal shape may not contain non-finite number values',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'literal',\n\t\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\t\t\t\tshape: 'literal',\n\t\t\t\t\t\t\t\t\treceived: INTRINSICS.text(value),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#spend(1)\n\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\tshape: current.inner,\n\t\t\t\t\tfirst: 'inner',\n\t\t\t\t\toptional: false,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'string':\n\t\t\tcase 'number':\n\t\t\tcase 'boolean':\n\t\t\tcase 'null':\n\t\t\tcase 'json':\n\t\t\tcase 'shape':\n\t\t\tcase 'raw':\n\t\t\t\tbreak\n\t\t}\n\t\treturn true\n\t}\n\n\t#spend(count: number): void {\n\t\tconst budget = this.#budget\n\t\tif (budget === undefined) return\n\t\tbudget.left -= count\n\t\tif (budget.left < 0) {\n\t\t\tthrow new ContractError(`validateShape: capture exceeds the node limit ${CLONE_NODE_LIMIT}`, {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path: pathOf(this.#path), limit: CLONE_NODE_LIMIT },\n\t\t\t})\n\t\t}\n\t}\n\n\t#schedule(current: object, depth: number, segments: number): number {\n\t\tadmitVisited(this.#active, current)\n\t\tconst children: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(this.#children), [\n\t\t\t(child: unknown) => child !== undefined,\n\t\t])\n\t\tconst captured = this.#capture(current, children)\n\t\tthis.#stack[this.#stack.length] = { operation: 'exit', index: captured, segments }\n\t\tfor (const offset of iterateIndices(() => children.length)) {\n\t\t\tconst index = children.length - 1 - offset\n\t\t\tconst child = children[index]\n\t\t\tif (child === undefined) continue\n\t\t\tthis.#stack[this.#stack.length] = {\n\t\t\t\toperation: 'enter',\n\t\t\t\tshape: child.shape,\n\t\t\t\tdepth: depth + 1,\n\t\t\t\toptional: child.optional,\n\t\t\t\tfirst: child.first,\n\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t}\n\t\treturn captured\n\t}\n\n\t#capture(\n\t\tshape: object,\n\t\tchildren: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}>,\n\t): number {\n\t\tconst index = this.#captures.length\n\t\tthis.#captures[index] = {\n\t\t\tshape,\n\t\t\tcategory: this.#category,\n\t\t\tchildren,\n\t\t\traw: this.#raw,\n\t\t\tdefaulted: this.#defaulted,\n\t\t\topen: this.#open,\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#index, [shape, index])\n\t\treturn index\n\t}\n\n\t#locate(shape: unknown): number | undefined {\n\t\tif (typeof shape !== 'object' || shape === null) return undefined\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.recall, this.#index, [shape])\n\t}\n\n\t// Everything a second walk would answer, answered from the capture instead.\n\t// Reading the discovery\n\t// postorder forwards gives every bottom-up fact — subtree height and emitted\n\t// expansion — and reading it backwards gives the top-down one, the deepest\n\t// position each node occupies. Both are one pass over the captured nodes and\n\t// edges, which is what makes a shared-child declaration cost its DECLARATION\n\t// rather than its paths.\n\t#measure(): void {\n\t\t// Capture has already decided cycles in linear time. Only a DAG has a depth.\n\t\tif (this.#cycle !== undefined) {\n\t\t\tthis.#finish()\n\t\t\treturn\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#captures.length)) {\n\t\t\tthis.#height[index] = 0\n\t\t\tthis.#reach[index] = 0\n\t\t\tthis.#counts[index] = 1\n\t\t}\n\t\tfor (const step of iterateIndices(() => this.#post.length)) {\n\t\t\tconst index = this.#post[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst totals: { readonly height: number; readonly count: number } = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.fold,\n\t\t\t\tcapture.children,\n\t\t\t\t[\n\t\t\t\t\t(\n\t\t\t\t\t\tcurrent: { readonly height: number; readonly count: number },\n\t\t\t\t\t\tchild: (typeof capture.children)[number],\n\t\t\t\t\t) => {\n\t\t\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\theight: INTRINSICS.max(current.height, reached + 1),\n\t\t\t\t\t\t\tcount: current.count + (located === undefined ? 1 : (this.#counts[located] ?? 1)),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{ height: 0, count: 1 },\n\t\t\t\t],\n\t\t\t)\n\t\t\tthis.#height[index] = totals.height\n\t\t\tthis.#counts[index] = totals.count\n\t\t}\n\t\tif ((this.#height[0] ?? 0) > COMPILE_DEPTH_LIMIT) this.#witness(0, 0, [])\n\t\t// Reverse postorder is a topological order, so a node's own deepest position\n\t\t// is final before its edges are read. Recording the edge that raised it\n\t\t// leaves a parent chain from any node back to the root, each link one level\n\t\t// shallower than the last.\n\t\tfor (const offset of iterateIndices(() => this.#post.length)) {\n\t\t\tconst step = this.#post.length - 1 - offset\n\t\t\tconst index = this.#post[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst base = this.#reach[index] ?? 0\n\t\t\tfor (const edge of iterateIndices(() => capture.children.length)) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tif (located === undefined) continue\n\t\t\t\tif ((this.#reach[located] ?? 0) >= base + 1) continue\n\t\t\t\tthis.#reach[located] = base + 1\n\t\t\t\tthis.#via[located] = {\n\t\t\t\t\tparent: index,\n\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#captures.length)) {\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined || capture.raw === 0) continue\n\t\t\tif ((this.#reach[index] ?? 0) + capture.raw <= COMPILE_DEPTH_LIMIT) continue\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: raw schema exceeds the compilation depth limit',\n\t\t\t\t{ code: 'structure', context: { path: pathOf(this.#ascend(index), 'schema') } },\n\t\t\t)\n\t\t}\n\t\tthis.#placeDefaults()\n\t}\n\n\t// Where a default can fill is a fact about every route to it, and a shared node is\n\t// discovered through one route alone, so this is asked over the captured graph. It\n\t// reads the reverse postorder top-down: a node's union ancestry is final before its\n\t// edges are read, so one pass answers every route. A union's parser returns a\n\t// guard-valid value by identity, so a default below one fills only the inputs that\n\t// needed a coercion. An open object takes a misspelled key as an extra, so a default\n\t// beside one fills the real key with no fault to report it.\n\t#placeDefaults(): void {\n\t\tconst carried = INTRINSICS.reflect.apply(INTRINSICS.some, this.#captures, [\n\t\t\t(capture: { readonly defaulted: boolean }) => capture.defaulted,\n\t\t])\n\t\tif (!carried) return\n\t\tfor (const offset of iterateIndices(() => this.#post.length)) {\n\t\t\tconst index = this.#post[this.#post.length - 1 - offset]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst enclosed =\n\t\t\t\tcapture.category === 'union' ||\n\t\t\t\t(INTRINSICS.own(this.#within, index) && this.#within[index] !== undefined)\n\t\t\tfor (const edge of iterateIndices(() => capture.children.length)) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tif (located === undefined) continue\n\t\t\t\tif (\n\t\t\t\t\tenclosed &&\n\t\t\t\t\t(!INTRINSICS.own(this.#within, located) || this.#within[located] === undefined)\n\t\t\t\t) {\n\t\t\t\t\tthis.#within[located] = {\n\t\t\t\t\t\tparent: index,\n\t\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.#captures[located]?.defaulted !== true) continue\n\t\t\t\t// Keep own guards consistent; valid optional-property edges always own their second segment.\n\t\t\t\tif (enclosed) {\n\t\t\t\t\tthis.#domain ??= new ContractError(\n\t\t\t\t\t\t'validateShape: a default may not sit under a union, whose parser can return a valid value without filling it; move the default outside the union or remove it',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\tpath: pathOf(\n\t\t\t\t\t\t\t\t\tthis.#route(index),\n\t\t\t\t\t\t\t\t\tchild.first,\n\t\t\t\t\t\t\t\t\tINTRINSICS.own(child, 'second') ? child.second : undefined,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (capture.open) {\n\t\t\t\t\tthis.#domain ??= new ContractError(\n\t\t\t\t\t\t'validateShape: a default may not sit on a property of an open object, where a misspelled key would fill it unreported; close the object or remove the default',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\tpath: pathOf(\n\t\t\t\t\t\t\t\t\tthis.#ascend(index),\n\t\t\t\t\t\t\t\t\tchild.first,\n\t\t\t\t\t\t\t\t\tINTRINSICS.own(child, 'second') ? child.second : undefined,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// The path to a node through the union edge recorded for it, falling back to its\n\t// deepest occurrence above the union that encloses it.\n\t#route(index: number): readonly string[] {\n\t\tconst edge = INTRINSICS.own(this.#within, index) ? this.#within[index] : undefined\n\t\treturn edge === undefined\n\t\t\t? this.#ascend(index)\n\t\t\t: pathOf(\n\t\t\t\t\tthis.#route(edge.parent),\n\t\t\t\t\tedge.first,\n\t\t\t\t\tINTRINSICS.own(edge, 'second') ? edge.second : undefined,\n\t\t\t\t)\n\t}\n\n\t// The declaration path to a node's DEEPEST occurrence, spelled out by walking\n\t// the improving edges back to the root and reversing them. The raw-depth rule\n\t// is re-asked from that occurrence, so the diagnostic has to name it too: the\n\t// first-discovered path names a slot that, on its own, validates.\n\t#ascend(index: number): readonly string[] {\n\t\tif (index === 0) return []\n\t\tconst edge = INTRINSICS.own(this.#via, index) ? this.#via[index] : undefined\n\t\treturn edge === undefined\n\t\t\t? []\n\t\t\t: pathOf(\n\t\t\t\t\tthis.#ascend(edge.parent),\n\t\t\t\t\tedge.first,\n\t\t\t\t\tINTRINSICS.own(edge, 'second') ? edge.second : undefined,\n\t\t\t\t)\n\t}\n\n\t// The first excessive-depth witness in declaration order, reconstructed rather\n\t// than searched for: at each level the earliest edge whose remaining height\n\t// still overshoots the allowance is the edge a pre-order walk would have taken.\n\t#witness(index: number | undefined, depth: number, path: readonly string[]): never {\n\t\tif (depth <= COMPILE_DEPTH_LIMIT) {\n\t\t\tconst capture = index === undefined ? undefined : this.#captures[index]\n\t\t\tconst children = capture === undefined ? [] : capture.children\n\t\t\tconst selected: number = INTRINSICS.reflect.apply(INTRINSICS.find, children, [\n\t\t\t\t(child: (typeof children)[number]) => {\n\t\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\t\treturn depth + 1 + reached > COMPILE_DEPTH_LIMIT\n\t\t\t\t},\n\t\t\t])\n\t\t\tconst chosen = children[selected]\n\t\t\tif (chosen !== undefined) {\n\t\t\t\treturn this.#witness(\n\t\t\t\t\tthis.#locate(chosen.shape),\n\t\t\t\t\tdepth + 1,\n\t\t\t\t\tpathOf(path, chosen.first, INTRINSICS.own(chosen, 'second') ? chosen.second : undefined),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tthrow new ContractError('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\tcode: 'depth',\n\t\t\tcontext: { path: pathOf(path), limit: COMPILE_DEPTH_LIMIT },\n\t\t})\n\t}\n\n\t#finish(): void {\n\t\tif (this.#structure !== undefined) throw this.#structure\n\t\tif (this.#cycle !== undefined) throw this.#cycle\n\t\tif (this.#domain !== undefined) throw this.#domain\n\t}\n\n\t#refuseSchema(\n\t\tmessage: string,\n\t\tstack: ReadonlyArray<{\n\t\t\treadonly operation: 'enter' | 'exit'\n\t\t\treadonly first?: string\n\t\t\treadonly second?: string\n\t\t}>,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t\tkeyword?: string,\n\t\tmember?: string,\n\t): false {\n\t\tif (this.#structure !== undefined) return false\n\t\tconst ancestors: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.expand,\n\t\t\treadIndexView(stack),\n\t\t\t[\n\t\t\t\t(frame: {\n\t\t\t\t\treadonly operation: 'enter' | 'exit'\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t\t}) =>\n\t\t\t\t\tframe.operation === 'exit'\n\t\t\t\t\t\t? pathOf(\n\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\tINTRINSICS.own(frame, 'first') ? frame.first : undefined,\n\t\t\t\t\t\t\t\tINTRINSICS.own(frame, 'second') ? frame.second : undefined,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [],\n\t\t\t],\n\t\t)\n\t\tconst prefix: string[] = []\n\t\tappendEntries(prefix, this.#path)\n\t\tprefix[prefix.length] = 'schema'\n\t\tappendEntries(prefix, ancestors)\n\t\tconst path = pathOf(prefix, first, second)\n\t\treturn this.#refuse(message, keyword, member, path)\n\t}\n\n\t#refuse(\n\t\tmessage: string,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t\tprefix: readonly string[] = this.#path,\n\t): false {\n\t\tif (this.#structure === undefined) {\n\t\t\tconst path = pathOf(prefix, first, second)\n\t\t\tthis.#structure = new ContractError(message, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\treturn false\n\t}\n}\n","import type { ShapeValidatorInterface } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { pinMembers } from './helpers.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Validates one retained contract-shape source live on every call.\n *\n * @remarks\n * Construction performs no source observation. Every non-overlapping\n * {@link validate} call starts a fresh pass over the source's current state.\n * Reentry poisons the active pass with one shared cause-free structure error;\n * cleanup always restores an idle validator for the next independent call.\n *\n * @example\n * ```ts\n * const validator = new ShapeValidator({ category: 'string', min: 1 })\n * validator.validate()\n * ```\n */\nexport class ShapeValidator implements ShapeValidatorInterface {\n\treadonly #source: unknown\n\treadonly #passes = new INTRINSICS.set<ShapePass>()\n\t#expansion: number | undefined\n\n\t/**\n\t * Retains a shape source without observing it.\n\t *\n\t * @param shape - The live shape source validated by each call\n\t */\n\tconstructor(shape: unknown) {\n\t\tthis.#source = shape\n\t}\n\n\t/**\n\t * Reports the number of nodes the last successful {@link validate} found the\n\t * source expands into.\n\t *\n\t * @remarks\n\t * One per node per INCOMING EDGE, summed bottom-up — the size of the tree a\n\t * compiler would build from this DAG, which a node count of the declaration\n\t * itself does not describe. `undefined` before the first successful pass and\n\t * after a failed one, because a failed pass has no expansion to report and\n\t * `0` is a measurement no declaration produces.\n\t */\n\tget expansion(): number | undefined {\n\t\treturn this.#expansion\n\t}\n\n\t/**\n\t * Validates the retained source's current declaration.\n\t *\n\t * @remarks\n\t * The whole traversal is contained, and a failure this class did not author\n\t * is translated into `validateShape: shape reflection failed` carrying\n\t * the exact thrown value. Containment is what makes that claim hold for\n\t * dispatch nobody enumerated — including the recognition of an authored error,\n\t * which is why that recognition is no longer answerable by any member a caller\n\t * can write. The sentence this replaces asserted the same conclusion from the\n\t * absence of reachable dispatch, and the absence was not established.\n\t *\n\t * @returns Nothing when the declaration is valid\n\t * @throws {ContractError} When the declaration is malformed, cyclic, too deep, unreadable, or reentered\n\t */\n\tvalidate(): void {\n\t\tINTRINSICS.reflect.apply(INTRINSICS.sweep, this.#passes, [\n\t\t\t(pass: ShapePass) => pass.interrupt(),\n\t\t])\n\t\tconst pass = new ShapePass(this.#source, { left: CLONE_NODE_LIMIT })\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, this.#passes, [pass])\n\t\tthis.#expansion = undefined\n\t\ttry {\n\t\t\tthis.#expansion = pass.validate()\n\t\t} finally {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.remove, this.#passes, [pass])\n\t\t}\n\t}\n\n\tstatic {\n\t\tpinMembers(ShapeValidator.prototype, 'ShapeValidator')\n\t}\n}\n","import type {\n\tArrayShape,\n\tBooleanShape,\n\tContractErrorOptions,\n\tContractShape,\n\tJSONShape,\n\tLiteralShape,\n\tLiteralValue,\n\tNullableShape,\n\tNullShape,\n\tNumberShape,\n\tObjectShape,\n\tOptionalShape,\n\tRawShape,\n\tResult,\n\tShapeClonerInterface,\n\tShapeProperty,\n\tShapeShape,\n\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport { CLONE_NODE_LIMIT, COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitVisited,\n\tappendEntries,\n\tattempt,\n\tfailure,\n\tisFailure,\n\tisSuccess,\n\titerateIndices,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isObject, isRecord, isRegExp } from './validators.js'\nimport { JSONCloner } from './JSONCloner.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Owns the state of one contract-shape snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call captures and validates one owned graph and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned or directly adopted error. Nonredirectable settlement\n * releases populated traversal state before publishing that result. Reentry\n * poisons the active operation and every later call with one shared cause-free\n * error.\n *\n * @param shape - The contract-shape graph to retain for cloning\n *\n * @example\n * ```ts\n * const cloner = new ShapeCloner({ category: 'string', min: 1 })\n * const clone = cloner.clone()\n * cloner.clone() === clone // true\n * ```\n */\nexport class ShapeCloner implements ShapeClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// CONSTRUCTOR of each collection is captured beside its members, because\n\t// construction happens first: capturing `WeakSet.prototype.has` while still\n\t// reaching `globalThis.WeakSet` leaves the door open one call earlier than\n\t// the member rows can see, and the constructor runs outside every\n\t// containment this class has.\n\tstatic readonly #map = Map\n\tstatic readonly #weakSet = WeakSet\n\t// The released state, shared by every cloner this class ever builds. `#settle`\n\t// assigns these in place of the working lists, so an instance allocates one\n\t// collection per family instead of two and construction carries no empty peer\n\t// of its own. Sharing them is safe because nothing writes to a released list:\n\t// every writer runs inside the walk and `#settle` is the walk's last step. The\n\t// static block at the foot of the class freezes them, so a write that did\n\t// reach one fails loudly at its own line rather than leaking one cloner's node\n\t// into every other cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly shape: ContractShape\n\t\treadonly depth: number\n\t}> = []\n\tstatic readonly #emptySources: ContractShape[] = []\n\treadonly #source: ContractShape\n\treadonly #owned: WeakSet<object>\n\t// The working maps are the fields with no shared peer: `Object.freeze` reaches\n\t// an array's writes and not a `Map`'s, so a shared empty map would be a\n\t// class-lifetime cache any write could fill with one cloner's nodes. `#settle`\n\t// drops them instead, and absence is `undefined`.\n\t#memo: Map<ContractShape, ContractShape> | undefined\n\t#paths: Map<ContractShape, readonly string[]> | undefined\n\t// An ordered ENTRY LIST rather than a `Map`: every consumer of this snapshot\n\t// walks it to decide the published property population, and iterating a `Map`\n\t// dispatches through `Map.prototype[Symbol.iterator]` while destructuring each\n\t// `[key, child]` pair dispatches through `Array.prototype[Symbol.iterator]`.\n\t// A caller-installed iterator that substitutes the first element of a\n\t// two-element entry — same arity, so every downstream structural check still\n\t// passes — published a frozen shape whose property was RENAMED to the\n\t// caller's text.\n\t#properties: Map<ContractShape, readonly ShapeProperty[]> | undefined\n\t#variants: Map<ContractShape, ReadonlyArray<ContractShape | undefined>> | undefined\n\t// FIFO, walked with a read cursor rather than `pop()`. A LIFO drain captured\n\t// siblings in REVERSE declaration order, so the first refusal this class threw\n\t// named the LAST offending sibling while the shared gate named the first — one\n\t// declaration, two different codes, messages and `context.path` values from\n\t// doors the guide names in one sentence as agreeing.\n\t#pending: Array<{ readonly shape: ContractShape; readonly depth: number }>\n\t#sources: ContractShape[]\n\t#fidelity: ContractError | undefined\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'settled'; readonly result: Result<ContractShape, ContractError> }\n\n\tconstructor(shape: ContractShape) {\n\t\tthis.#source = shape\n\t\tthis.#owned = new ShapeCloner.#weakSet()\n\t\tthis.#memo = new ShapeCloner.#map()\n\t\tthis.#paths = new ShapeCloner.#map()\n\t\tthis.#properties = new ShapeCloner.#map()\n\t\tthis.#variants = new ShapeCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#sources = []\n\t\tthis.#fidelity = undefined\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clones the retained declaration into an owned, validated frozen graph.\n\t *\n\t * @returns The settled contract-shape snapshot\n\t * @throws {ContractError} When the declaration is malformed, unreadable, cyclic, too deep, or cloning is reentered\n\t */\n\tclone(): ContractShape {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'settled') {\n\t\t\tif (isSuccess(state.result)) return state.result.value\n\t\t\tthrow state.result.error\n\t\t}\n\t\tif (state.phase === 'running' || state.phase === 'interrupted') {\n\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\tthrow state.poison\n\t\t}\n\n\t\tconst poison = this.#create('ShapeCloner.clone: shape cloning may not be reentered', {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'shape' },\n\t\t})\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#complete(attempt(() => this.#execute()))\n\t}\n\n\t#complete(outcome: Result<ContractShape>): ContractShape {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') {\n\t\t\treturn this.#settle(failure(state.poison))\n\t\t}\n\t\tif (isSuccess(outcome)) return this.#settle(outcome)\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneShape: failed to create an owned shape snapshot', {\n\t\t\t\t\tcode: 'clone',\n\t\t\t\t\tcontext: { shape: 'shape' },\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t})\n\t\treturn this.#settle(failure(error))\n\t}\n\n\t#execute(): ContractShape {\n\t\tconst budget = { left: CLONE_NODE_LIMIT }\n\t\t// Narrowed once at the door, because both dispatches below take their\n\t\t// receiver type from these values. The walk runs before `#settle` drops\n\t\t// them, so it always finds the maps the constructor built; this refusal is\n\t\t// what keeps that a statement the types carry rather than one a comment\n\t\t// makes.\n\t\tconst paths = this.#paths\n\t\tconst memo = this.#memo\n\t\tif (paths === undefined || memo === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, paths, [this.#source, []])\n\t\tthis.#pending[this.#pending.length] = { shape: this.#source, depth: 0 }\n\t\tthis.#drain(budget)\n\t\tthis.#wireNodes()\n\t\tconst root = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [this.#source])\n\t\tif (root === undefined) {\n\t\t\tthrow this.#create('ShapeCloner.clone: captured root is unavailable', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'shape' },\n\t\t\t})\n\t\t}\n\t\tthis.#freezeNodes()\n\t\t// Capture has already charged the retained edges and copied defaults. The\n\t\t// existing validation inspects that bounded owned graph without charging\n\t\t// the same ownership a second time.\n\t\tthis.#validateShape(root)\n\t\tif (this.#fidelity !== undefined) throw this.#fidelity\n\t\treturn root\n\t}\n\n\t#drain(budget: { left: number }): void {\n\t\t// A read cursor, so the walk is breadth-first in DECLARATION order. The\n\t\t// cursor also makes the level a node was reached at meaningful: it is the\n\t\t// SHORTEST path to that node, so this bound never refuses a graph the\n\t\t// validator would accept.\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tfor (const cursor of iterateIndices(() => this.#pending.length)) {\n\t\t\tconst entry = this.#pending[cursor]\n\t\t\tif (entry === undefined) continue\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.keyed, memo, [entry.shape])) continue\n\t\t\t// The depth verdict is reached in time proportional to the LIMIT rather\n\t\t\t// than to the caller's declaration. Capturing, wiring and freezing a\n\t\t\t// 4,000-level chain that is CERTAIN to be refused cost 120 ms against\n\t\t\t// `validateShape`'s 1 ms for the identical verdict, and the cost is\n\t\t\t// quadratic because every child registration copies its whole path.\n\t\t\tif (entry.depth > COMPILE_DEPTH_LIMIT) this.#refuseDepth(budget)\n\t\t\tthis.#captureNode(entry.shape, entry.depth, budget)\n\t\t}\n\t}\n\n\t// Acceptance agrees with validation; refusal diagnoses agree only below the capture limit.\n\t#refuseDepth(budget: { left: number }): never {\n\t\tthis.#validateShape(this.#source, [], budget)\n\t\tthrow this.#create('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\tcode: 'depth',\n\t\t\tcontext: { path: [], limit: COMPILE_DEPTH_LIMIT },\n\t\t})\n\t}\n\n\t#captureShell(\n\t\tsource: ContractShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ContractShape {\n\t\tif (!matchesRecordBrand(source)) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\tconst descriptor = INTRINSICS.describe(source, 'category')\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\tthrow this.#create('cloneShape: every node needs an own data discriminant', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\tconst category = source.category\n\t\tconst repeated = source.category\n\t\tif (!INTRINSICS.same(descriptor.value, category) || !INTRINSICS.same(repeated, category)) {\n\t\t\tthrow this.#create('cloneShape: every node needs an own data discriminant', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\n\t\tswitch (category) {\n\t\t\tcase 'string':\n\t\t\t\treturn this.#captureString(source, path)\n\t\t\tcase 'number':\n\t\t\t\treturn this.#captureNumber(source, path)\n\t\t\tcase 'boolean':\n\t\t\t\treturn this.#captureSimple(source, path, 'boolean')\n\t\t\tcase 'null':\n\t\t\t\treturn this.#captureSimple(source, path, 'null')\n\t\t\tcase 'literal':\n\t\t\t\treturn this.#captureLiteral(source, path)\n\t\t\tcase 'array':\n\t\t\t\treturn this.#captureArray(source, path, budget)\n\t\t\tcase 'object':\n\t\t\t\treturn this.#captureObject(source, path, budget)\n\t\t\tcase 'union':\n\t\t\t\treturn this.#captureUnion(source, path, budget)\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#captureOptional(source, path, budget)\n\t\t\tcase 'nullable':\n\t\t\t\treturn this.#captureNullable(source, path, budget)\n\t\t\tcase 'json':\n\t\t\t\treturn this.#captureSimple(source, path, 'json')\n\t\t\tcase 'shape':\n\t\t\t\treturn this.#captureSimple(source, path, 'shape')\n\t\t\tcase 'raw':\n\t\t\t\treturn this.#captureRaw(source, path, budget)\n\t\t\tdefault:\n\t\t\t\tthrow this.#create('validateShape: every node must be a recognized shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path },\n\t\t\t\t})\n\t\t}\n\t}\n\n\t#captureField<S extends object, K extends keyof S & string>(\n\t\tsource: S,\n\t\tfield: K,\n\t\tpath: readonly string[],\n\t): S[K] | undefined {\n\t\tconst descriptor = INTRINSICS.describe(source, field)\n\t\tif (descriptor === undefined) {\n\t\t\tif (INTRINSICS.reflect.present(source, field)) {\n\t\t\t\tthrow this.#create('cloneShape: inherited shape fields cannot be owned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t\tif (!INTRINSICS.own(descriptor, 'value')) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t})\n\t\t}\n\t\tconst first = source[field]\n\t\tconst second = source[field]\n\t\tif (!INTRINSICS.same(first, descriptor.value) || !INTRINSICS.same(second, first)) {\n\t\t\tthrow this.#create('cloneShape: shape fields must be stable data', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t})\n\t\t}\n\t\treturn first\n\t}\n\n\t#capturePattern(\n\t\tsource: StringShape,\n\t\tpath: readonly string[],\n\t): { readonly source: string; readonly flags: string } | undefined {\n\t\tconst descriptor = INTRINSICS.describe(source, 'pattern')\n\t\tif (descriptor === undefined) {\n\t\t\tif (INTRINSICS.reflect.present(source, 'pattern')) {\n\t\t\t\tthrow this.#create('cloneShape: inherited shape fields cannot be owned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (INTRINSICS.own(descriptor, 'value')) {\n\t\t\tconst first = source.pattern\n\t\t\tconst second = source.pattern\n\t\t\tif (!INTRINSICS.same(first, descriptor.value) || !INTRINSICS.same(second, first)) {\n\t\t\t\tthrow this.#create('cloneShape: shape fields must be stable data', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn this.#capturePatternValue(first, path)\n\t\t}\n\n\t\tconst first = source.pattern\n\t\tconst second = source.pattern\n\t\tif (!isRegExp(first) || !isRegExp(second)) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\t// Each revealed RegExp is captured once, through the same scalar-pair\n\t\t// routine the data population uses, and the two captured PRIMITIVE pairs\n\t\t// are what get compared. Reading scalars here and then handing a\n\t\t// already-observed RegExp back to that routine would observe it twice, so\n\t\t// an accessor that answers one observation per value lost its deferred\n\t\t// stable-pattern diagnosis to an outer hostile-read translation.\n\t\tconst firstValue = this.#capturePatternValue(first, path)\n\t\tif (firstValue === undefined) return undefined\n\t\tconst secondValue = this.#capturePatternValue(second, path)\n\t\tif (secondValue === undefined) return undefined\n\t\tif (\n\t\t\tfirstValue.source !== secondValue.source ||\n\t\t\tfirstValue.flags !== secondValue.flags ||\n\t\t\t!INTRINSICS.frozen(first) ||\n\t\t\t!INTRINSICS.frozen(second)\n\t\t) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\treturn firstValue\n\t}\n\n\t#capturePatternValue(\n\t\tpattern: RegExp | undefined,\n\t\tpath: readonly string[],\n\t): { readonly source: string; readonly flags: string } | undefined {\n\t\tif (pattern === undefined) return undefined\n\t\tif (!isRegExp(pattern)) {\n\t\t\tthrow this.#create('validateShape: string pattern must be a RegExp', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\t// Both reads go through the CAPTURED accessors. `source` and `flags` are\n\t\t// getters on a shared prototype, so a replaced getter reports for every\n\t\t// pattern in the realm, not only the caller's — and it decided the pattern a\n\t\t// published shape carries. The repeated read still earns its place: it\n\t\t// diagnoses an accessor that answers once per value, which capture does not\n\t\t// address.\n\t\tconst sourceText: unknown = readPatternSource(pattern)\n\t\tconst flags: unknown = readPatternFlags(pattern)\n\t\tconst repeated = attempt(() => {\n\t\t\tconst repeatedFlags: unknown = readPatternFlags(pattern)\n\t\t\tconst repeatedSource: unknown = readPatternSource(pattern)\n\t\t\treturn { flags: repeatedFlags, source: repeatedSource }\n\t\t})\n\t\tif (\n\t\t\ttypeof sourceText !== 'string' ||\n\t\t\ttypeof flags !== 'string' ||\n\t\t\tisFailure(repeated) ||\n\t\t\ttypeof repeated.value.source !== 'string' ||\n\t\t\ttypeof repeated.value.flags !== 'string' ||\n\t\t\trepeated.value.source !== sourceText ||\n\t\t\trepeated.value.flags !== flags\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: string pattern must be stable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t\treturn undefined\n\t\t}\n\t\treturn { source: sourceText, flags }\n\t}\n\n\t#captureNode(source: ContractShape, depth: number, budget: { left: number }): void {\n\t\tconst paths = this.#paths\n\t\tconst memo = this.#memo\n\t\tif (paths === undefined || memo === undefined) throw this.#unavailable()\n\t\tconst path = INTRINSICS.reflect.apply(INTRINSICS.fetch, paths, [source]) ?? []\n\t\tconst clone = this.#captureShell(source, path, budget)\n\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [source, clone])\n\t\tthis.#sources[this.#sources.length] = source\n\t\tthis.#scheduleNode(source, clone, path, depth)\n\t}\n\n\t#captureString(source: StringShape, path: readonly string[]): StringShape {\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst pattern = this.#capturePattern(source, path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// No declaration-policy rule is enforced here. `ShapeValidator` owns every\n\t\t// bound, range and pattern-flag rule and runs on the carried clone at\n\t\t// `#execute`. A second copy here would fire EARLIER, in capture order rather\n\t\t// than declaration order and before structure outranks domain, so `cloneShape`\n\t\t// would name a different rule at a different path than the shared gate for one\n\t\t// declaration. One rule, one arbiter.\n\t\tconst fields: StringShape = {\n\t\t\tcategory: 'string',\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t\tif (pattern === undefined) return fields\n\t\tconst sourceText = pattern.source\n\t\tconst flags = pattern.flags\n\t\treturn {\n\t\t\t...fields,\n\t\t\tget pattern() {\n\t\t\t\treturn INTRINSICS.freeze(new INTRINSICS.pattern(sourceText, flags))\n\t\t\t},\n\t\t}\n\t}\n\n\t#captureNumber(source: NumberShape, path: readonly string[]): NumberShape {\n\t\tconst integer = this.#captureField(source, 'integer', path)\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// Domain rules belong to the single gate on the carried clone; see\n\t\t// `#captureString`.\n\t\treturn {\n\t\t\tcategory: 'number',\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(integer === undefined ? {} : { integer }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureSimple(\n\t\tsource: BooleanShape | NullShape | JSONShape | ShapeShape,\n\t\tpath: readonly string[],\n\t\tcategory: 'boolean' | 'null' | 'json' | 'shape',\n\t): BooleanShape | NullShape | JSONShape | ShapeShape {\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tif (category === 'boolean') {\n\t\t\treturn { category: 'boolean', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\tif (category === 'null') {\n\t\t\treturn { category: 'null', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\tif (category === 'shape') {\n\t\t\treturn { category: 'shape', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\treturn { category: 'json', ...(description === undefined ? {} : { description }) }\n\t}\n\n\t#captureLiteral(source: LiteralShape, path: readonly string[]): LiteralShape {\n\t\tconst values = this.#captureField(source, 'values', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tconst entries = this.#captureLiterals(values, path)\n\t\treturn {\n\t\t\tcategory: 'literal',\n\t\t\tvalues: entries,\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureArray(source: ArrayShape, path: readonly string[], budget: { left: number }): ArrayShape {\n\t\tthis.#spend(budget, 1, path)\n\t\tconst items = this.#captureField(source, 'items', path)\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// Domain rules belong to the single gate on the carried clone; see\n\t\t// `#captureString`. A missing `items` is not a domain rule — the node\n\t\t// cannot be BUILT without it — so that refusal stays here, and it is\n\t\t// `structure`, the family the validator itself ranks first.\n\t\tif (items === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'items') },\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcategory: 'array',\n\t\t\titems,\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureObject(\n\t\tsource: ObjectShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ObjectShape {\n\t\tconst propertySource = this.#captureField(source, 'properties', path)\n\t\tconst additional = this.#captureField(source, 'additionalProperties', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tif (!isRecord(propertySource)) {\n\t\t\tthrow this.#create('validateShape: properties must be a plain property map', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'properties') },\n\t\t\t})\n\t\t}\n\t\tthis.#captureProperties(source, propertySource, path, budget)\n\t\tif (additional !== undefined && additional !== true && additional !== false)\n\t\t\tthis.#spend(budget, 1, path)\n\t\tconst properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\treturn {\n\t\t\tcategory: 'object',\n\t\t\tproperties,\n\t\t\t...(additional === undefined ? {} : { additionalProperties: additional }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureUnion(source: UnionShape, path: readonly string[], budget: { left: number }): UnionShape {\n\t\tconst variantSource = this.#captureField(source, 'variants', path)\n\t\tconst mode = this.#captureField(source, 'mode', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tthis.#captureVariants(source, variantSource, path, budget)\n\t\treturn {\n\t\t\tcategory: 'union',\n\t\t\tvariants: [],\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureOptional(\n\t\tsource: OptionalShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): OptionalShape {\n\t\tconst inner = this.#captureInner(source, path, budget)\n\t\tconst value = this.#captureField(source, 'default', path)\n\t\tif (!INTRINSICS.own(source, 'default')) return { category: 'optional', inner }\n\t\t// The one domain rule capture must answer itself, because a value that cannot be\n\t\t// copied cannot be carried to the gate; it refuses as that gate does.\n\t\tconst owned = isJSONValue(value)\n\t\t\t? attempt(() => new JSONCloner(value).clone(budget))\n\t\t\t: undefined\n\t\tif (\n\t\t\towned !== undefined &&\n\t\t\tisFailure(owned) &&\n\t\t\tbudget.left < 0 &&\n\t\t\tisContractError(owned.error)\n\t\t) {\n\t\t\tthrow this.#prefix(owned.error, pathOf(path, 'default'))\n\t\t}\n\t\tif (owned === undefined || isFailure(owned)) {\n\t\t\tthrow this.#create('validateShape: an optional default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'default') },\n\t\t\t})\n\t\t}\n\t\treturn { category: 'optional', inner, default: owned.value }\n\t}\n\n\t#captureNullable(\n\t\tsource: NullableShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): NullableShape {\n\t\treturn { category: 'nullable', inner: this.#captureInner(source, path, budget) }\n\t}\n\n\t#captureInner(\n\t\tsource: OptionalShape | NullableShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ContractShape {\n\t\tthis.#spend(budget, 1, path)\n\t\tconst inner = this.#captureField(source, 'inner', path)\n\t\tif (inner === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'inner') },\n\t\t\t})\n\t\t}\n\t\treturn inner\n\t}\n\n\t#captureRaw(source: RawShape, path: readonly string[], budget: { left: number }): RawShape {\n\t\tconst schema = this.#captureField(source, 'schema', path)\n\t\tif (!isRecord(schema)) {\n\t\t\tthrow this.#create('validateShape: raw schema must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'schema') },\n\t\t\t})\n\t\t}\n\t\tthis.#validateShape({ category: 'raw', schema }, path, budget)\n\t\tconst outcome = attempt(() => new SchemaCloner(schema).clone())\n\t\tif (isFailure(outcome)) {\n\t\t\tif (isContractError(outcome.error)) {\n\t\t\t\tthrow this.#prefix(outcome.error, pathOf(path, 'schema'))\n\t\t\t}\n\t\t\tthrow outcome.error\n\t\t}\n\t\treturn { category: 'raw', schema: outcome.value }\n\t}\n\n\t#captureLiterals(\n\t\tvalues: readonly LiteralValue[] | undefined,\n\t\tpath: readonly string[],\n\t): readonly LiteralValue[] {\n\t\tif (!INTRINSICS.array(values)) {\n\t\t\tthrow this.#create('validateShape: values must be a finite literal array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tconst snapshot = readArrayEntries(values)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow this.#create('validateShape: values must be a finite literal array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow this.#create('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tconst entries = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.value.entries.length),\n\t\t\t(index) => this.#literal(values, snapshot.value.entries[index], index, path),\n\t\t)\n\t\treturn INTRINSICS.freeze(entries)\n\t}\n\n\t#literal(\n\t\tvalues: readonly LiteralValue[],\n\t\tvalue: unknown,\n\t\tindex: number,\n\t\tpath: readonly string[],\n\t): LiteralValue {\n\t\tconst key = INTRINSICS.text(index)\n\t\tconst descriptor = attempt(() => INTRINSICS.describe(values, key))\n\t\tconst repeated = attempt(() => values[index])\n\t\tif (\n\t\t\tisFailure(descriptor) ||\n\t\t\tdescriptor.value === undefined ||\n\t\t\t!INTRINSICS.own(descriptor.value, 'value')\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t})\n\t\t} else if (\n\t\t\tisFailure(repeated) ||\n\t\t\t!INTRINSICS.same(repeated.value, value) ||\n\t\t\t!INTRINSICS.same(descriptor.value.value, value)\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: values must be a stable data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t})\n\t\t}\n\t\tif (!isLiteralValue(value)) {\n\t\t\tthrow this.#create(\n\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn value\n\t}\n\n\t#captureProperties(\n\t\tsource: ObjectShape,\n\t\tproperties: Readonly<Record<string, ContractShape>>,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): void {\n\t\tconst keys = INTRINSICS.keys(properties)\n\t\tconst snapshot: readonly ShapeProperty[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(keys),\n\t\t\t[\n\t\t\t\t(key: string) => {\n\t\t\t\t\tthis.#spend(budget, 1, path)\n\t\t\t\t\tconst descriptor = INTRINSICS.describe(properties, key)\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst child = properties[key]\n\t\t\t\t\tconst repeated = properties[key]\n\t\t\t\t\tconst described: unknown = descriptor.value\n\t\t\t\t\tif (!INTRINSICS.same(described, child) || !INTRINSICS.same(child, repeated)) {\n\t\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn { key, child }\n\t\t\t\t},\n\t\t\t],\n\t\t)\n\t\tconst repeated = INTRINSICS.keys(properties)\n\t\tconst drifted =\n\t\t\trepeated.length !== keys.length ||\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, repeated, [\n\t\t\t\t(key: string, index: number) => key !== keys[index],\n\t\t\t])\n\t\tif (drifted) {\n\t\t\tthrow this.#create('cloneShape: property keys must be stable data', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'properties') },\n\t\t\t})\n\t\t}\n\t\tconst captured = this.#properties\n\t\tif (captured === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, captured, [source, snapshot])\n\t}\n\n\t#captureVariants(\n\t\tsource: UnionShape,\n\t\tvariants: readonly ContractShape[] | undefined,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): void {\n\t\tif (!INTRINSICS.array(variants)) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst snapshot = readArrayEntries(variants)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow this.#create('validateShape: variants must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst entries = snapshot.value.entries\n\t\tthis.#spend(budget, entries.length, path)\n\t\tconst captured = this.#variants\n\t\tif (captured === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, captured, [source, entries])\n\t\tfor (const index of iterateIndices(() => entries.length)) {\n\t\t\tconst variant = entries[index]\n\t\t\tconst key = INTRINSICS.text(index)\n\t\t\tconst descriptor = attempt(() => INTRINSICS.describe(variants, key))\n\t\t\tconst repeated = attempt(() => variants[index])\n\t\t\tif (\n\t\t\t\tisFailure(descriptor) ||\n\t\t\t\tdescriptor.value === undefined ||\n\t\t\t\t!INTRINSICS.own(descriptor.value, 'value') ||\n\t\t\t\tisFailure(repeated) ||\n\t\t\t\t!INTRINSICS.same(repeated.value, variant) ||\n\t\t\t\t!INTRINSICS.same(descriptor.value.value, variant)\n\t\t\t) {\n\t\t\t\tthis.#fidelity ??= this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'variants', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t#scheduleNode(\n\t\tsource: ContractShape,\n\t\tclone: ContractShape,\n\t\tpath: readonly string[],\n\t\tdepth: number,\n\t): void {\n\t\tswitch (clone.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#registerChild(clone.items, pathOf(path, 'items'), depth)\n\t\t\t\tbreak\n\t\t\tcase 'object': {\n\t\t\t\tconst captured = this.#properties\n\t\t\t\tif (captured === undefined) throw this.#unavailable()\n\t\t\t\tconst properties = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\t\t\tif (properties === undefined) {\n\t\t\t\t\tthrow this.#create('cloneShape: properties could not be read', {\n\t\t\t\t\t\tcode: 'clone',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties'), shape: 'object' },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => properties.length)) {\n\t\t\t\t\tconst entry = properties[index]\n\t\t\t\t\tif (entry === undefined || entry.child === undefined) continue\n\t\t\t\t\tthis.#registerChild(entry.child, pathOf(path, 'properties', entry.key), depth)\n\t\t\t\t}\n\t\t\t\tconst additional = clone.additionalProperties\n\t\t\t\tif (additional !== undefined && additional !== true && additional !== false) {\n\t\t\t\t\tthis.#registerChild(additional, pathOf(path, 'additionalProperties'), depth)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst captured = this.#variants\n\t\t\t\tif (captured === undefined) throw this.#unavailable()\n\t\t\t\tconst variants = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\t\t\tif (variants === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => variants.length)) {\n\t\t\t\t\tconst variant = variants[index]\n\t\t\t\t\tif (variant !== undefined) {\n\t\t\t\t\t\tthis.#registerChild(variant, pathOf(path, 'variants', INTRINSICS.text(index)), depth)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#registerChild(clone.inner, pathOf(path, 'inner'), depth)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t#registerChild(child: ContractShape, path: readonly string[], depth: number): void {\n\t\tconst paths = this.#paths\n\t\tif (paths === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, paths, [child, path])\n\t\tthis.#pending[this.#pending.length] = { shape: child, depth: depth + 1 }\n\t}\n\n\t#wireNodes(): void {\n\t\tconst memo = this.#memo\n\t\tconst paths = this.#paths\n\t\tif (memo === undefined || paths === undefined) throw this.#unavailable()\n\t\tfor (const sourceIndex of iterateIndices(() => this.#sources.length)) {\n\t\t\tconst source = this.#sources[sourceIndex]\n\t\t\tif (source === undefined) continue\n\t\t\tconst clone = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [source])\n\t\t\tif (clone === undefined) continue\n\t\t\tconst path = INTRINSICS.reflect.apply(INTRINSICS.fetch, paths, [source]) ?? []\n\t\t\tswitch (clone.category) {\n\t\t\t\tcase 'array':\n\t\t\t\t\tthis.#wireArray(clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'object':\n\t\t\t\t\tthis.#wireObject(source, clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'union':\n\t\t\t\t\tthis.#wireUnion(source, clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'optional':\n\t\t\t\tcase 'nullable':\n\t\t\t\t\tthis.#wireWrapper(clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t#wireArray(clone: ArrayShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst items = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [clone.items])\n\t\tif (items === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'items') },\n\t\t\t})\n\t\t}\n\t\tINTRINSICS.reflect.write(clone, 'items', items)\n\t}\n\n\t#wireObject(source: ContractShape, clone: ObjectShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tconst captured = this.#properties\n\t\tif (memo === undefined || captured === undefined) throw this.#unavailable()\n\t\tconst snapshot = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\tif (snapshot === undefined) {\n\t\t\tthrow this.#create('cloneShape: properties could not be read', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path: pathOf(path, 'properties'), shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(snapshot), [\n\t\t\t(entry: ShapeProperty | undefined) => {\n\t\t\t\tif (entry === undefined) return []\n\t\t\t\tconst { key, child } = entry\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [child])\n\t\t\t\tif (cloned === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn [[key, cloned]]\n\t\t\t},\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tINTRINSICS.reflect.write(clone, 'properties', INTRINSICS.freeze(properties))\n\t\tconst additional = clone.additionalProperties\n\t\tif (additional !== undefined && additional !== true && additional !== false) {\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [additional])\n\t\t\tif (cloned === undefined) {\n\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'additionalProperties') },\n\t\t\t\t})\n\t\t\t}\n\t\t\tINTRINSICS.reflect.write(clone, 'additionalProperties', cloned)\n\t\t}\n\t}\n\n\t#wireUnion(source: ContractShape, clone: UnionShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tconst captured = this.#variants\n\t\tif (memo === undefined || captured === undefined) throw this.#unavailable()\n\t\tconst snapshot = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\tif (snapshot === undefined) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst variants = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.length),\n\t\t\t(index) => {\n\t\t\t\tconst variant = snapshot[index]\n\t\t\t\tif (variant === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [variant])\n\t\t\t\tif (cloned === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn cloned\n\t\t\t},\n\t\t)\n\t\tINTRINSICS.reflect.write(clone, 'variants', INTRINSICS.freeze(variants))\n\t}\n\n\t#wireWrapper(clone: OptionalShape | NullableShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst inner = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [clone.inner])\n\t\tif (inner === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'inner') },\n\t\t\t})\n\t\t}\n\t\tINTRINSICS.reflect.write(clone, 'inner', inner)\n\t}\n\n\t#freezeNodes(): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tfor (const sourceIndex of iterateIndices(() => this.#sources.length)) {\n\t\t\tconst source = this.#sources[sourceIndex]\n\t\t\tif (source === undefined) continue\n\t\t\tconst clone = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [source])\n\t\t\tif (clone !== undefined) INTRINSICS.freeze(clone)\n\t\t}\n\t}\n\n\t#validateShape(\n\t\tshape: ContractShape,\n\t\tpath: readonly string[] = [],\n\t\tbudget?: { left: number },\n\t): void {\n\t\tconst outcome = attempt(() => new ShapePass(shape, budget).validate())\n\t\tif (isSuccess(outcome)) return\n\t\tif (isContractError(outcome.error)) {\n\t\t\tthrow this.#prefix(outcome.error, path)\n\t\t}\n\t\tthrow outcome.error\n\t}\n\n\t#spend(budget: { left: number }, count: number, path: readonly string[]): void {\n\t\tbudget.left -= count\n\t\tif (budget.left < 0) {\n\t\t\tthrow this.#create(`cloneShape: capture exceeds the node limit ${CLONE_NODE_LIMIT}`, {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path, limit: CLONE_NODE_LIMIT },\n\t\t\t})\n\t\t}\n\t}\n\n\t#prefix(error: ContractError, path: readonly string[]): ContractError {\n\t\tif (path.length === 0) {\n\t\t\tadmitVisited(this.#owned, error)\n\t\t\treturn error\n\t\t}\n\t\tconst tail = error.context?.path\n\t\tconst location: string[] = []\n\t\tappendEntries(location, path)\n\t\tappendEntries(location, typeof tail === 'string' ? [tail] : (tail ?? []))\n\t\treturn this.#create(error.message, {\n\t\t\tcode: error.code,\n\t\t\tcontext: { ...error.context, path: location },\n\t\t\t...(INTRINSICS.own(error, 'cause') ? { cause: error.cause } : {}),\n\t\t})\n\t}\n\n\t// One refusal for every dropped working map, because a settled cloner replays\n\t// from `#state` and re-enters no walk method: nothing reachable settles here,\n\t// and every guard that says so must say it the same way.\n\t#unavailable(): ContractError {\n\t\treturn this.#create('ShapeCloner.clone: the capture state is unavailable', {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'shape' },\n\t\t})\n\t}\n\n\t#create(message: string, options: ContractErrorOptions): ContractError {\n\t\tconst error = new ContractError(message, options)\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t// Assignment only: every working list takes the class's shared frozen empty\n\t// peer and every working map is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection, so\n\t// settlement cannot be redirected into leaving state behind.\n\t#settle(result: Result<ContractShape, ContractError>): ContractShape {\n\t\tthis.#memo = undefined\n\t\tthis.#paths = undefined\n\t\tthis.#properties = undefined\n\t\tthis.#variants = undefined\n\t\tthis.#pending = ShapeCloner.#emptyPending\n\t\tthis.#sources = ShapeCloner.#emptySources\n\t\tthis.#fidelity = undefined\n\t\tthis.#state = { phase: 'settled', result }\n\t\tif (isSuccess(result)) return result.value\n\t\tthrow result.error\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peers and\n\t\t// stop them satisfying the mutable working fields they are assigned to.\n\t\tINTRINSICS.freeze(ShapeCloner.#emptyPending)\n\t\tINTRINSICS.freeze(ShapeCloner.#emptySources)\n\t\t// Pinned while this class is DEFINED. `cloneShape` / `ownShape` reach it\n\t\t// through `ShapeCloner.prototype.clone`, so one assignment there made\n\t\t// `compileSchema`, `contract.audit` and `contract.explain` publish whatever\n\t\t// the caller chose while none of those doors was touched.\n\t\tpinMembers(ShapeCloner.prototype, 'ShapeCloner')\n\t}\n}\n","import type { ContractShape, JSONRecord, JSONSchema, JSONValue, StringShape } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport { attempt, contain, holds, isFailure, isSuccess } from './helpers.js'\nimport { isRecord } from './validators.js'\nimport { JSONCloner } from './JSONCloner.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { ShapeCloner } from './ShapeCloner.js'\n\n/**\n * Deep-clones exact JSON data into an owned frozen snapshot.\n *\n * @remarks\n * Traverses iteratively so deeply nested input cannot exhaust the call stack.\n * Repeated noncyclic aliases are duplicated because JSON persistence represents\n * a tree, while a structural back-edge on the active path is rejected as a\n * cycle. Arrays are rebuilt as standard dense arrays and records as\n * null-prototype objects; every produced node is frozen after its children are\n * wired. Array keys must be exactly `length` plus every canonical index.\n * Writable and configurable index flags are normalized rather than treated as\n * JSON data, so frozen arrays remain valid. Property descriptors are inspected\n * without reading values through accessors, and every hostile reflective\n * operation is contained before a new clone-coded error is exposed.\n * Each call creates a fresh {@link JSONCloner}; use the class directly when\n * terminal success or failure identity must be replayed without another read.\n *\n * @param value - The unknown value to validate and snapshot\n * @returns The primitive unchanged, or a deeply cloned and frozen JSON graph\n * @throws {ContractError} When the value is not exact acyclic JSON data or traversal fails\n *\n * @example\n * ```ts\n * const source = { settings: { enabled: true } }\n * const clone = cloneJSONValue(source)\n * source.settings.enabled = false\n * clone // { settings: { enabled: true } }\n * ```\n */\nexport function cloneJSONValue(value: unknown): JSONValue {\n\treturn contain(() => {\n\t\treturn new JSONCloner(value).clone()\n\t}, 'cloneJSONValue')\n}\n\n/**\n * Deep-clones an exact JSON object record into an owned frozen snapshot.\n *\n * @remarks\n * Adds a record-root boundary to {@link cloneJSONValue}. The output is a\n * deeply frozen null-prototype record, and repeated noncyclic aliases are\n * duplicated as independent JSON tree branches.\n *\n * @param value - The unknown record value to validate and snapshot\n * @returns A deeply cloned and frozen JSON record\n * @throws {ContractError} When the root is not a record, nested data is inexact, or traversal fails\n *\n * @example\n * ```ts\n * cloneJSONRecord({ attempt: 1 }) // frozen null-prototype record\n * ```\n */\nexport function cloneJSONRecord(value: unknown): JSONRecord {\n\treturn contain(() => {\n\t\tif (!isRecord(value)) {\n\t\t\tthrow new ContractError('cloneJSONRecord: value is not a plain record', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'json' },\n\t\t\t})\n\t\t}\n\t\tconst clone = cloneJSONValue(value)\n\t\tif (!isRecord(clone)) {\n\t\t\tthrow new ContractError('cloneJSONRecord: cloned value is not a record', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'json' },\n\t\t\t})\n\t\t}\n\t\treturn clone\n\t}, 'cloneJSONRecord')\n}\n\n/**\n * Deep-clones a JSON Schema graph into an owned frozen snapshot.\n *\n * @remarks\n * Walks arrays and records iteratively with a memo, preserving shared\n * references and closing cyclic edges onto their cloned nodes. Primitive\n * values and own enumerable string-keyed edges are copied; record nodes use\n * null prototypes, arrays retain only their intrinsic array prototype, and\n * every produced object is frozen after its edges are wired. Hostile traversal\n * throws a clone-coded {@link ContractError}, never a caller-owned raw error.\n * Each call creates a fresh {@link SchemaCloner}; use the class directly when\n * terminal success or failure identity must be replayed without another read.\n *\n * @param schema - The JSON Schema graph to snapshot\n * @returns A deeply cloned and frozen JSON Schema graph\n * @throws {ContractError} When hostile schema traversal prevents ownership\n *\n * @example\n * ```ts\n * const child = { type: 'string' }\n * const clone = cloneSchema({ anyOf: [child, child] })\n * clone.anyOf?.[0] === clone.anyOf?.[1] // true\n * ```\n */\nexport function cloneSchema(schema: JSONSchema): JSONSchema {\n\treturn contain(() => {\n\t\treturn new SchemaCloner(schema).clone()\n\t}, 'cloneSchema')\n}\n\n/**\n * Deep-clones a contract shape graph into an owned frozen snapshot.\n *\n * @remarks\n * A fresh public {@link ShapeCloner} preserves shared-child identity while\n * building the candidate snapshot, owns raw schemas, validates the exact\n * completed root, applies deferred fidelity, and translates unexpected hostile\n * failures. Inside the engine, each node's own data discriminant and every\n * declared field are captured descriptor-first from two agreeing reads, and the\n * carried population alone supplies its shallow shell, semantic checks, child\n * scheduling, and later edge wiring. An inherited field is refused through a\n * non-invoking presence check, and a revealed accessor is refused without\n * invocation except for the builder's `pattern` contract: two fresh frozen\n * genuine `RegExp` values with equal source and flags are captured as owned\n * source/flags semantics.\n *\n * Literal and union members retain their own-index descriptor/repeated-read\n * checks; property entries retain descriptor/first/second agreement plus two\n * exactly equal ordered key populations; raw schemas delegate to\n * {@link cloneSchema}. Before return, a fresh {@link ShapeValidator} independently\n * validates the exact cloned root. Ownership never erases a structural edge or\n * normalizes an invalid scalar/bound into a plausible declaration: those\n * inputs throw their coded structure/bound error. Hostile traversal remains\n * distinct and throws a clone-coded {@link ContractError}.\n *\n * @param shape - The contract shape graph to snapshot\n * @returns A deeply cloned and frozen shape graph\n * @throws {ContractError} When the declaration cannot be copied faithfully or hostile shape or raw-schema traversal prevents ownership\n *\n * @example\n * ```ts\n * const child = arrayShape(stringShape())\n * const clone = cloneShape(objectShape({ first: child, second: child }))\n * clone.category === 'object' && clone.properties.first === clone.properties.second // true\n * ```\n */\nexport function cloneShape(shape: StringShape): StringShape\nexport function cloneShape(shape: ContractShape): ContractShape\nexport function cloneShape(shape: ContractShape): ContractShape {\n\treturn contain(() => {\n\t\treturn new ShapeCloner(shape).clone()\n\t}, 'cloneShape')\n}\n\n/**\n * Takes ownership of a contract shape node as an independent {@link cloneShape}\n * snapshot of its graph.\n *\n * @remarks\n * Every successful return is a deeply frozen caller-independent graph, and\n * \"frozen\" here means frozen by the `Object.freeze` this package captured while\n * it loaded, not by whatever `Object.freeze` names when the call is made. The\n * distinction is the whole guarantee: a replaced `Object.freeze` that returns\n * its argument untouched would otherwise let this door publish a mutable graph,\n * with no throw and no signal a caller could read. A frozen caller root receives no identity\n * exception: shallow freezing cannot establish ownership of nested collections,\n * child nodes, raw schemas, or `RegExp` internal state, and the fidelity clone\n * has already paid the traversal cost needed to prove and carry those values.\n *\n * @param shape - The contract shape to own\n * @returns A deeply cloned frozen snapshot\n * @throws {ContractError} When the declaration cannot be copied faithfully, when hostile shape or raw-schema traversal prevents ownership, or when a frozen root fails validation\n *\n * @example\n * ```ts\n * const authored = stringShape()\n * ownShape(authored) === authored // false\n * ```\n */\nexport function ownShape(shape: ContractShape): ContractShape {\n\treturn contain(() => {\n\t\tconst frozen = holds(() => INTRINSICS.frozen(shape))\n\t\tconst fidelity = attempt(() => cloneShape(shape))\n\t\tif (isSuccess(fidelity)) return fidelity.value\n\t\tif (\n\t\t\tisContractError(fidelity.error) &&\n\t\t\t(fidelity.error.code !== 'clone' || fidelity.error.context?.limit === CLONE_NODE_LIMIT)\n\t\t) {\n\t\t\tthrow fidelity.error\n\t\t}\n\t\tif (!frozen) throw fidelity.error\n\t\tconst validation = attempt(() => new ShapeValidator(shape).validate())\n\t\tif (isFailure(validation) && isContractError(validation.error)) throw validation.error\n\t\tthrow fidelity.error\n\t}, 'ownShape')\n}\n","import type { Guard } from './types.js'\nimport { GUARD_DEPTH_LIMIT } from './constants.js'\nimport { holds } from './helpers.js'\n\n/** Owns the active depth shared by calls to one deferred guard. */\nexport class LazyGuard<T> {\n\treadonly #thunk: () => Guard<T>\n\t#depth = 0\n\n\tconstructor(thunk: () => Guard<T>) {\n\t\tthis.#thunk = thunk\n\t}\n\n\t/** Tests one value within the guard's shared recursion allowance. */\n\ttest(value: unknown): value is T {\n\t\tif (this.#depth >= GUARD_DEPTH_LIMIT) return false\n\t\tthis.#depth += 1\n\t\ttry {\n\t\t\treturn holds(() => this.#thunk()(value))\n\t\t} finally {\n\t\t\tthis.#depth -= 1\n\t\t}\n\t}\n}\n","import type {\n\tFromGuards,\n\tGuard,\n\tGuardsShape,\n\tGuardType,\n\tIntersectionFromGuards,\n\tLiteralValue,\n\tOptionalFromGuards,\n\tStringGuardOptions,\n\tTupleFromGuards,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { LazyGuard } from './LazyGuard.js'\nimport {\n\tisArray,\n\tisConstructor,\n\tisFiniteNumber,\n\tisFunction,\n\tisInstance,\n\tisLiteralValue,\n\tisMap,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisRegExp,\n\tisSet,\n\tisString,\n\tisSymbol,\n} from './validators.js'\nimport {\n\treadIndexView,\n\tcollectMembers,\n\tcontain,\n\tholds,\n\tisFailure,\n\titerateIndices,\n\tmatchesMember,\n\tmatchesPattern,\n\tmatchesStringLength,\n\townPattern,\n\treadArrayEntries,\n\treadGuardShape,\n\treadMapEntries,\n\treadOptions,\n\treadPattern,\n\treadSetEntries,\n\treadValue,\n} from './helpers.js'\n\n// Every combinator returns a `Guard<T>` — a total function, as\n// `.claude/rules/patterns.md` § Validation and contracts requires. The\n// combinators that invoke a caller-supplied callback inside the guard body\n// contain the whole call through `holds`, so\n// the produced guard reports a non-match instead of propagating. The container\n// combinators likewise wrap their complete element/entry/key-read walk in\n// `holds` — a hostile Proxy trap, a throwing getter, a throwing\n// iterator, or a throwing caller-supplied predicate yields a non-match, never a\n// propagated throw.\n\n/**\n * Builds a guard that accepts DENSE arrays whose every element satisfies\n * `elementGuard`.\n *\n * @remarks\n * Density is part of the contract, not an accident: the guard reads the array\n * through the shared reflected own-index lens {@link readArrayEntries}, which is\n * what makes it immune to caller-defined iteration and what `parseArray` reads\n * too. A SPARSE array is therefore refused outright — `[1, , 3]` fails even when\n * the element guard accepts `undefined` — because a hole is an absent own\n * property rather than a present `undefined`, and the two are different facts.\n * Pass `[1, undefined, 3]` when the middle slot is meant to exist.\n *\n * @param elementGuard - The guard each element must satisfy\n * @returns A guard accepting a dense array whose every element is accepted\n *\n * @example\n * ```ts\n * const isStringArray = arrayOf(isString)\n * isStringArray(['a', 'b']) // true\n * isStringArray(['a', 1]) // false\n * isStringArray(['a', , 'b']) // false — sparse\n * ```\n */\nexport function arrayOf<T>(elementGuard: Guard<T>): Guard<readonly T[]>\nexport function arrayOf(elementGuard: (value: unknown) => boolean): Guard<readonly unknown[]>\nexport function arrayOf(elementGuard: (value: unknown) => boolean): Guard<readonly unknown[]> {\n\treturn (value: unknown): value is readonly unknown[] =>\n\t\tholds(() => {\n\t\t\tif (!isArray(value)) return false\n\t\t\tconst entries = readArrayEntries(value)\n\t\t\tif (isFailure(entries) || !entries.value.dense) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\tif (!elementGuard(entries.value.entries[index])) return false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts fixed-arity DENSE tuples, testing each index with\n * the corresponding guard.\n *\n * @param guards - One guard per tuple index, in declaration order\n * @returns A guard accepting a dense tuple of that exact arity whose every index is accepted\n *\n * @example\n * ```ts\n * const isPair = tupleOf(isString, isNumber)\n * isPair(['hello', 42]) // true\n * isPair(['hello']) // false — wrong arity\n * isPair([, 42]) // false — sparse; see arrayOf for the dense lens\n * ```\n */\nexport function tupleOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<TupleFromGuards<Gs>>\nexport function tupleOf(\n\t...predicates: ReadonlyArray<(value: unknown) => boolean>\n): Guard<readonly unknown[]>\nexport function tupleOf(\n\t...guards: ReadonlyArray<(value: unknown) => boolean>\n): Guard<readonly unknown[]> {\n\treturn (value: unknown): value is readonly unknown[] =>\n\t\tholds(() => {\n\t\t\tif (!isArray(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst entries = readArrayEntries(value)\n\t\t\tif (isFailure(entries) || !entries.value.dense) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (entries.value.entries.length !== guards.length) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\t\tconst guard = guards[index]\n\t\t\t\tif (guard === undefined || !guard(entries.value.entries[index])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts a provided literal primitive using SameValueZero\n * comparison.\n *\n * @remarks\n * Signed zero compares equal, while `NaN` compares equal to `NaN`. Two call\n * forms, one meaning: list the literals inline, or hand in one array of them.\n * The array form exists for a vocabulary that is machine-generated rather than\n * hand-written — a `literalShape` built from an untrusted schema's `enum`, say\n * — where spreading a list of tens of thousands of entries would exhaust the\n * engine's argument limit. `compileGuard` / `compileParser` / `compileReporter`\n * take the array form for exactly that reason.\n *\n * @param literals - The permitted literal primitives, listed inline or as one array\n * @returns A guard narrowing to the provided literal union\n *\n * @example\n * ```ts\n * const isRole = literalOf('admin', 'member', 'guest')\n * isRole('admin') // true\n * isRole('owner') // false\n *\n * const isSameRole = literalOf(['admin', 'member', 'guest']) // the same guard, from an array\n * ```\n */\nexport function literalOf<const Literals extends readonly LiteralValue[]>(\n\tliterals: Literals,\n): Guard<Literals[number]>\nexport function literalOf<const Literals extends readonly LiteralValue[]>(\n\t...literals: Literals\n): Guard<Literals[number]>\nexport function literalOf(\n\t...literals: ReadonlyArray<LiteralValue | readonly LiteralValue[]>\n): Guard<LiteralValue> {\n\treturn contain(\n\t\t() => {\n\t\t\t// An indexed read, not array destructuring: destructuring dispatches through\n\t\t\t// `Array.prototype[Symbol.iterator]`, a caller-writable member.\n\t\t\tconst first = literals[0]\n\t\t\tconst collected =\n\t\t\t\tliterals.length === 1\n\t\t\t\t\t? readValue(() => INTRINSICS.array(first), 'literalOf', {\n\t\t\t\t\t\t\tsubject: 'literals',\n\t\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t\t})\n\t\t\t\t\t: false\n\t\t\tconst snapshot =\n\t\t\t\tcollected && isArray(first)\n\t\t\t\t\t? readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tconst entries = readArrayEntries(first)\n\t\t\t\t\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\t\t\t\t\tif (!entries.value.dense) {\n\t\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('Literal vocabulary must be dense')\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn entries.value.entries\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'literalOf',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubject: 'literals',\n\t\t\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t: literals\n\t\t\t// Indexed, not `every`: an array prototype method is a caller-writable\n\t\t\t// member reached by name, and this statement sits between two statements an\n\t\t\t// earlier round repaired for exactly that reason. A boundary placed per\n\t\t\t// statement is only ever as complete as the last sweep; an indexed read\n\t\t\t// dispatches through nothing at all.\n\t\t\tconst literal = !INTRINSICS.reflect.apply(INTRINSICS.some, snapshot, [\n\t\t\t\t(value: unknown) => !isLiteralValue(value),\n\t\t\t])\n\t\t\tif (!literal) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'literalOf: literals must contain only string, number, or boolean values',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'literal',\n\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\t// A module-scope membership question, not `set.has(value)` and not a\n\t\t\t// method on a class this package exports: the answer this guard returns IS\n\t\t\t// the package's published verdict, and BOTH of those spellings ask a\n\t\t\t// property every caller can rewrite. `Set.prototype.has = () => true` made\n\t\t\t// this guard accept a value outside its declared vocabulary; relocating\n\t\t\t// the read onto an exported class's `has` reproduced it one prototype\n\t\t\t// higher. A module binding is not a property.\n\t\t\tconst allowed = collectMembers(snapshot)\n\t\t\treturn (value: unknown): value is LiteralValue => holds(() => matchesMember(allowed, value))\n\t\t},\n\t\t'literalOf',\n\t\t{ code: 'literal', context: { path: ['literals'], shape: 'literal' } },\n\t)\n}\n\n/**\n * Builds a guard that accepts instances of the provided constructor.\n *\n * @remarks\n * Verifies that `ctor` is a real constructor (through {@link isConstructor}) first,\n * so passing an arrow function does not silently produce a broken guard.\n *\n * A callable instance passes. The exclusion is a bad constructor, never a callable\n * value: an `isObject` pre-filter made `instanceOf(Function)(() => {})` answer `false`\n * while {@link isInstance}, the helper this is built on, answered `true` for the same\n * pair.\n *\n * @param ctor - The constructor whose instances the guard accepts\n * @returns A guard narrowing to that constructor's instance type\n *\n * @example\n * ```ts\n * const isDateValue = instanceOf(Date)\n * isDateValue(new Date()) // true\n * isDateValue({}) // false\n * ```\n */\nexport function instanceOf<C extends abstract new (...args: never) => object>(\n\tctor: C,\n): Guard<InstanceType<C>> {\n\t// No `isObject` pre-filter: `typeof fn === 'function'`, so it rejected every\n\t// CALLABLE instance and `instanceOf(Function)(() => {})` answered `false`\n\t// while `isInstance(() => {}, Function)` — the helper this combinator is\n\t// documented to be built on — answered `true`. `isInstance` already refuses a\n\t// primitive (`primitive instanceof X` is `false`) and is itself contained, so\n\t// the pre-filter narrowed the domain and bought nothing.\n\treturn (value: unknown): value is InstanceType<C> =>\n\t\tisConstructor(ctor) && isInstance(value, ctor)\n}\n\n/**\n * Builds a guard from a native `enum` or any object whose values are strings or\n * numbers.\n *\n * @remarks\n * An unreadable enumeration is refused at factory time with the shared `structure` read\n * refusal; the returned guard stays total.\n *\n * @param enumeration - The readable enumeration whose values the guard accepts\n * @returns A guard accepting one enumeration value\n * @throws {ContractError} When the enumeration cannot be read\n *\n * @example\n * ```ts\n * enum Direction { Up = 'up', Down = 'down' }\n * const isDirection = enumOf(Direction)\n * isDirection('up') // true\n * isDirection('left') // false\n * ```\n */\nexport function enumOf<const E extends Record<string, string | number>>(\n\tenumeration: E,\n): Guard<E[keyof E]> {\n\treturn contain(() => {\n\t\tconst values = collectMembers(\n\t\t\treadValue(() => INTRINSICS.values(enumeration), 'enumOf', { subject: 'enumeration' }),\n\t\t)\n\t\t// `holds`, exactly as `literalOf` does one screen up. The membership read is\n\t\t// unredirectable, but the guard contract is \"never throws\" and a guard\n\t\t// that states it for one builder and not its sibling is a guard nobody can\n\t\t// rely on.\n\t\treturn (value: unknown): value is E[keyof E] =>\n\t\t\tholds(() => (isString(value) || isNumber(value)) && matchesMember(values, value))\n\t}, 'enumOf')\n}\n\n/**\n * Builds a guard that accepts `Set` instances whose every element satisfies\n * `elementGuard`.\n *\n * @param elementGuard - The guard each element must satisfy\n * @returns A guard accepting a `Set` whose every element is accepted\n *\n * @example\n * ```ts\n * const isStringSet = setOf(isString)\n * isStringSet(new Set(['a', 'b'])) // true\n * isStringSet(new Set(['a', 1])) // false\n * ```\n */\nexport function setOf<T>(elementGuard: Guard<T>): Guard<ReadonlySet<T>>\nexport function setOf(elementGuard: (value: unknown) => boolean): Guard<ReadonlySet<unknown>>\nexport function setOf(elementGuard: (value: unknown) => boolean): Guard<ReadonlySet<unknown>> {\n\treturn (value: unknown): value is ReadonlySet<unknown> =>\n\t\tholds(() => {\n\t\t\tif (!isSet(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// The genuine contents, read through the captured sweep rather than\n\t\t\t// through `Set.prototype[Symbol.iterator]`. An iterator that silently\n\t\t\t// skipped the non-string in `new Set(['a', 42])` made this guard answer\n\t\t\t// `true` while `forEach` and `size` still reported the real contents — the\n\t\t\t// guard's verdict and every other view of the same object disagreeing is\n\t\t\t// exactly the silent lie the sibling `arrayOf` was already hardened against.\n\t\t\tconst entries = readSetEntries(value)\n\t\t\tif (isFailure(entries)) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.length)) {\n\t\t\t\tif (!elementGuard(entries.value[index])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts `Map` instances where every key satisfies\n * `keyGuard` and every value satisfies `valueGuard`.\n *\n * @param keyGuard - The guard each key must satisfy\n * @param valueGuard - The guard each value must satisfy\n * @returns A guard accepting a `Map` whose every entry is accepted\n *\n * @example\n * ```ts\n * const isStringNumberMap = mapOf(isString, isNumber)\n * isStringNumberMap(new Map([['a', 1]])) // true\n * isStringNumberMap(new Map([[1, 'a']])) // false\n * ```\n */\nexport function mapOf<K, V>(keyGuard: Guard<K>, valueGuard: Guard<V>): Guard<ReadonlyMap<K, V>>\nexport function mapOf(\n\tkeyPredicate: (value: unknown) => boolean,\n\tvaluePredicate: (value: unknown) => boolean,\n): Guard<ReadonlyMap<unknown, unknown>>\nexport function mapOf(\n\tkeyGuard: (value: unknown) => boolean,\n\tvalueGuard: (value: unknown) => boolean,\n): Guard<ReadonlyMap<unknown, unknown>> {\n\treturn (value: unknown): value is ReadonlyMap<unknown, unknown> =>\n\t\tholds(() => {\n\t\t\tif (!isMap(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// The captured sweep, and each pair read POSITIONALLY: destructuring\n\t\t\t// `[key, entryValue]` adds `Array.prototype[Symbol.iterator]` to the\n\t\t\t// `Map.prototype[Symbol.iterator]` this already avoided, and a\n\t\t\t// substituting iterator can replace one half of a pair while every\n\t\t\t// downstream check still passes.\n\t\t\tconst entries = readMapEntries(value)\n\t\t\tif (isFailure(entries)) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.length)) {\n\t\t\t\tconst entry = entries.value[index]\n\t\t\t\tif (entry === undefined) return false\n\t\t\t\tif (!keyGuard(entry[0]) || !valueGuard(entry[1])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts plain records matching a guard shape.\n *\n * @remarks\n * The calling modes depend on the `optional` argument:\n * - **No `optional`** — all shape keys required; extra keys rejected.\n * - **`optional: K[]`** — the listed keys are optional; all others required.\n * - **`optional: true`** — every shape key is optional.\n *\n * Key presence is tested with `Object.hasOwn`, so a shape key satisfied only by\n * an inherited prototype member (`toString`, `constructor`, …) counts as absent.\n * A non-object / `null` / array input returns `false` rather than throwing.\n * The exactness check inspects every own string key, including non-enumerable\n * keys. Symbol keys are ignored intentionally for JSON fidelity.\n *\n * @param shape - The guard shape whose own string keys the record must satisfy\n * @param optional - The optional-key list, `true` for every key, or absent for none\n * @returns A guard accepting a record satisfying the shape under the selected mode\n *\n * @example\n * ```ts\n * const isUser = recordOf({ name: isString, age: isNumber })\n * isUser({ name: 'Ada', age: 36 }) // true\n * isUser({ name: 'Ada' }) // false — age missing\n *\n * const isPartial = recordOf({ name: isString, age: isNumber }, ['age'])\n * isPartial({ name: 'Ada' }) // true\n * ```\n */\nexport function recordOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>\nexport function recordOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\toptional: K,\n): Guard<OptionalFromGuards<S, K>>\nexport function recordOf<S extends GuardsShape>(\n\tshape: S,\n\toptional: true,\n): Guard<Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>>\nexport function recordOf<\n\tS extends GuardsShape,\n\tK extends ReadonlyArray<keyof S & string> | true | undefined,\n>(\n\tshape: S,\n\toptional?: K,\n): Guard<\n\tK extends true\n\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t? OptionalFromGuards<S, K>\n\t\t\t: FromGuards<S>\n> {\n\treturn contain(() => {\n\t\tconst declared = readGuardShape(shape, optional, 'recordOf')\n\n\t\treturn (\n\t\t\tvalue: unknown,\n\t\t): value is K extends true\n\t\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t\t? OptionalFromGuards<S, K>\n\t\t\t\t: FromGuards<S> =>\n\t\t\tholds(() => {\n\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tconst members = INTRINSICS.reflect.members(value)\n\t\t\t\tfor (const index of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && !matchesMember(declared.vocabulary, key)) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of iterateIndices(() => declared.names.length)) {\n\t\t\t\t\tconst key = declared.names[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst guard = declared.guards[key]\n\t\t\t\t\tconst present = INTRINSICS.own(value, key)\n\t\t\t\t\tif (!matchesMember(declared.optional, key) && !present) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tif (present) {\n\t\t\t\t\t\tif (guard === undefined || !guard(value[key])) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\t}, 'recordOf')\n}\n\n/**\n * Builds a guard that accepts non-array objects matching an open guard shape.\n *\n * @remarks\n * The calling modes mirror {@link recordOf}:\n * - **No `optional`** — all shape keys required; unknown members admitted.\n * - **`optional: K[]`** — the listed keys are optional; all others required.\n * - **`optional: true`** — every shape key is optional.\n *\n * Each declared member is read through `Reflect.get`, so inherited data and\n * prototype accessors can satisfy the shape. An optional member passes when its\n * read value is `undefined`; otherwise its guard must accept the value. Unknown\n * members are never enumerated or inspected. Member-carrying functions are\n * accepted. Arrays, `null`, and primitives are rejected. Hostile reads return\n * `false` rather than throwing.\n *\n * @param shape - The guard shape whose declared members the object must satisfy\n * @param optional - The optional-key list, `true` for every key, or absent for none\n * @returns A guard accepting an object satisfying the shape under the selected mode\n *\n * @example\n * ```ts\n * const isResult = objectOf({ conclusion: isBoolean })\n * isResult({ conclusion: true, metadata: 'retained' }) // true\n * isResult([]) // false\n * ```\n */\nexport function objectOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>\nexport function objectOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\toptional: K,\n): Guard<OptionalFromGuards<S, K>>\nexport function objectOf<S extends GuardsShape>(\n\tshape: S,\n\toptional: true,\n): Guard<Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>>\nexport function objectOf<\n\tS extends GuardsShape,\n\tK extends ReadonlyArray<keyof S & string> | true | undefined,\n>(\n\tshape: S,\n\toptional?: K,\n): Guard<\n\tK extends true\n\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t? OptionalFromGuards<S, K>\n\t\t\t: FromGuards<S>\n> {\n\treturn contain(() => {\n\t\tconst declared = readGuardShape(shape, optional, 'objectOf')\n\n\t\treturn (\n\t\t\tvalue: unknown,\n\t\t): value is K extends true\n\t\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t\t? OptionalFromGuards<S, K>\n\t\t\t\t: FromGuards<S> =>\n\t\t\tholds(() => {\n\t\t\t\tif ((!isObject(value) && !isFunction(value)) || INTRINSICS.array(value)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tfor (const index of iterateIndices(() => declared.names.length)) {\n\t\t\t\t\tconst key = declared.names[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst guard = declared.guards[key]\n\t\t\t\t\tconst member = INTRINSICS.reflect.read(value, key)\n\t\t\t\t\tif (matchesMember(declared.optional, key)) {\n\t\t\t\t\t\tif (member !== undefined && (guard === undefined || !guard(member))) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (guard === undefined || !guard(member)) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\t}, 'objectOf')\n}\n\n/**\n * Builds a guard that accepts values that are own keys of the provided object.\n *\n * @remarks\n * Membership is tested with `Object.hasOwn`, so inherited prototype-chain keys\n * (`toString`, `constructor`, …) are rejected. An own property that shadows a\n * prototype name is accepted.\n *\n * @param value - The object whose own keys the guard accepts\n * @returns A guard narrowing to that object's own key union\n *\n * @example\n * ```ts\n * const COLORS = { red: '#f00', green: '#0f0', blue: '#00f' } as const\n * const isColorKey = keyOf(COLORS)\n * isColorKey('red') // true\n * isColorKey('purple') // false\n * isColorKey('toString') // false — inherited, not an own key\n * ```\n */\nexport function keyOf<const O extends Readonly<Record<PropertyKey, unknown>>>(\n\tvalue: O,\n): Guard<keyof O> {\n\treturn contain(() => {\n\t\tconst keys = collectMembers(readValue(() => INTRINSICS.reflect.members(value), 'keyOf'))\n\t\treturn (entry: unknown): entry is keyof O =>\n\t\t\tholds(\n\t\t\t\t() =>\n\t\t\t\t\t(isString(entry) && matchesMember(keys, entry)) ||\n\t\t\t\t\t(isSymbol(entry) && matchesMember(keys, entry)) ||\n\t\t\t\t\t(isNumber(entry) && matchesMember(keys, INTRINSICS.text(entry))),\n\t\t\t)\n\t}, 'keyOf')\n}\n\n/**\n * Builds a new guard shape by keeping only the listed keys — the structural\n * equivalent of `Pick<T, K>`. Produces a shape for {@link recordOf}, not a guard.\n *\n * @remarks\n * An unreadable `keys` list and an unreadable `shape` are refused separately, each\n * under its own name, so a caller reads which argument failed.\n *\n * @param shape - The guard shape to narrow\n * @param keys - The keys to keep\n * @returns A guard shape carrying only the kept keys\n *\n * @example\n * ```ts\n * const full = { name: isString, age: isNumber, role: isString }\n * const isName = recordOf(pickOf(full, ['name']))\n * isName({ name: 'Ada' }) // true\n * ```\n */\nexport function pickOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\tkeys: K,\n): Pick<S, K[number]> {\n\treturn contain(() => {\n\t\t// Sound over-approximation: only selected keys are defined on the genuine\n\t\t// null-prototype accumulator; its mapped value slots remain checked against S.\n\t\tconst selected = readValue(\n\t\t\t() => {\n\t\t\t\tconst entries = readArrayEntries(keys)\n\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Picked key list must be dense')\n\t\t\t\treturn collectMembers(entries.value.entries)\n\t\t\t},\n\t\t\t'pickOf',\n\t\t\t{ subject: 'keys' },\n\t\t)\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t\t(key: PropertyKey) =>\n\t\t\t\t\t\tisString(key) && matchesMember(selected, key)\n\t\t\t\t\t\t\t? [[key, { value: shape[key], enumerable: true, configurable: true, writable: true }]]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t])\n\t\t\t\tconst result: { [P in keyof S]: S[P] } = INTRINSICS.create(\n\t\t\t\t\tnull,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn result\n\t\t\t},\n\t\t\t'pickOf',\n\t\t\t{ subject: 'shape' },\n\t\t)\n\t}, 'pickOf')\n}\n\n/**\n * Builds a new guard shape by removing the listed keys — the structural\n * equivalent of `Omit<T, K>`. Produces a shape for {@link recordOf}, not a guard.\n *\n * @remarks\n * An unreadable `keys` list and an unreadable `shape` are refused separately, each\n * under its own name, for the reason {@link pickOf} states.\n *\n * @param shape - The guard shape to narrow\n * @param keys - The keys to remove\n * @returns A guard shape carrying every key except the removed ones\n *\n * @example\n * ```ts\n * const full = { name: isString, age: isNumber, role: isString }\n * const isPublic = recordOf(omitOf(full, ['role']))\n * isPublic({ name: 'Ada', age: 36 }) // true\n * ```\n */\nexport function omitOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\tkeys: K,\n): Omit<S, K[number]> {\n\treturn contain(() => {\n\t\tconst skipped = readValue(\n\t\t\t() => {\n\t\t\t\tconst entries = readArrayEntries(keys)\n\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Omitted key list must be dense')\n\t\t\t\treturn collectMembers(entries.value.entries)\n\t\t\t},\n\t\t\t'omitOf',\n\t\t\t{ subject: 'keys' },\n\t\t)\n\t\t// Sound over-approximation: only kept keys are written, so the value\n\t\t// structurally satisfies `Omit<S, K[number]>`. Same honest typing as\n\t\t// `pickOf` — no `as` / `!` / `asserts`.\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t\t(key: PropertyKey) =>\n\t\t\t\t\t\tisString(key) && !matchesMember(skipped, key)\n\t\t\t\t\t\t\t? [[key, { value: shape[key], enumerable: true, configurable: true, writable: true }]]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t])\n\t\t\t\tconst result: { [P in keyof S]: S[P] } = INTRINSICS.create(\n\t\t\t\t\tnull,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn result\n\t\t\t},\n\t\t\t'omitOf',\n\t\t\t{ subject: 'shape' },\n\t\t)\n\t}, 'omitOf')\n}\n\n/**\n * Combines `left` and `right` with logical AND — passes only when both pass.\n *\n * @remarks\n * Use {@link whereOf} when the right side refines an already-narrowed type; use\n * `andOf` to combine independent guards.\n *\n * @param left - The guard tested first\n * @param right - The guard tested only after `left` passes\n * @returns A guard accepting a value both accept\n *\n * @example\n * ```ts\n * const isShortString = andOf(isString, isNonEmptyString)\n * ```\n */\nexport function andOf<A, B>(left: Guard<A>, right: Guard<B>): Guard<A & B>\nexport function andOf<T, U extends T>(left: Guard<T>, right: (value: T) => value is U): Guard<U>\nexport function andOf<T>(left: Guard<T>, right: (value: T) => boolean): Guard<T>\nexport function andOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown>\nexport function andOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown> {\n\treturn (value: unknown): value is unknown => holds(() => left(value) && right(value))\n}\n\n/**\n * Combines `left` and `right` with logical OR — passes when at least one passes.\n * Prefer {@link unionOf} for a wider set of variants.\n *\n * @remarks\n * Each member is contained on its own, so a throwing member is a non-match rather than\n * a veto over its sibling. One containment around the whole disjunction made `orOf(a,\n * b)` and `orOf(b, a)` answer differently for one value.\n *\n * @param left - The guard tested first\n * @param right - The guard tested only after `left` fails\n * @returns A guard accepting a value either accepts\n *\n * @example\n * ```ts\n * const isStringOrNumber = orOf(isString, isNumber)\n * ```\n */\nexport function orOf<A, B>(left: Guard<A>, right: Guard<B>): Guard<A | B>\nexport function orOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown>\nexport function orOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown> {\n\t// Each member is contained SEPARATELY. One `holds` around the whole\n\t// disjunction let a throwing member veto every later passing one, so\n\t// `orOf(isNull, naive)(null)` was `true` and `orOf(naive, isNull)(null)` was\n\t// `false` — the same disjunction, the same value, two answers. Disjunction is\n\t// commutative by definition, and the package's own doctrine everywhere else\n\t// is that a throw is contained as a NON-MATCH, not as a veto over siblings.\n\treturn (value: unknown): value is unknown => holds(() => left(value)) || holds(() => right(value))\n}\n\n/**\n * Negates a guard or predicate — passes when `guard` returns `false`.\n *\n * @remarks\n * Typed as `Guard<unknown>` because `Exclude<unknown, T>` is not useful; use\n * {@link complementOf} when you need the narrowed `Exclude<TBase, TExcluded>`.\n *\n * The negation applies to the contained verdict, so a throwing guard is a non-match and\n * its negation passes. Containing the negation instead made a guard and its `notOf`\n * both reject the same value, which broke `orOf(g, notOf(g))` as a tautology.\n *\n * @param guard - The guard or predicate to negate\n * @returns A guard accepting exactly the values `guard` rejects\n *\n * @example\n * ```ts\n * const isNotNull = notOf(isNull)\n * ```\n */\nexport function notOf(guard: (value: unknown) => boolean): Guard<unknown> {\n\t// The negation is applied to the CONTAINED verdict, not contained around the\n\t// negation. `holds(() => !guard(value))` never evaluated `!` when the guard\n\t// threw, so a guard and its negation both reported a non-match for the same\n\t// value and `orOf(g, notOf(g))` stopped being a tautology.\n\treturn (value: unknown): value is unknown => !holds(() => guard(value))\n}\n\n/**\n * Builds a guard for `Exclude<TBase, TExcluded>` — accepts values that pass\n * `base` but not `excluded`.\n *\n * @remarks\n * The base and the exclusion are contained separately, for the reason {@link notOf}\n * states: a throwing exclusion is a non-match, so the complement passes.\n *\n * @param base - The guard establishing the accepted domain\n * @param excluded - The guard whose accepted values are removed from that domain\n * @returns A guard accepting a value `base` accepts and `excluded` rejects\n *\n * @example\n * ```ts\n * const isNonEmpty = complementOf(isString, isEmptyString)\n * isNonEmpty('hi') // true\n * isNonEmpty('') // false\n * ```\n */\nexport function complementOf<TBase, TExcluded extends TBase>(\n\tbase: Guard<TBase>,\n\texcluded: Guard<TExcluded> | ((value: TBase) => value is TExcluded),\n): Guard<Exclude<TBase, TExcluded>> {\n\t// Two separate containments, for the reason `notOf` carries: a throwing\n\t// EXCLUSION is a non-match, so the complement must PASS when the base passes.\n\t// One containment around `base(value) && !excluded(value)` made a value fail\n\t// both a guard and its complement.\n\treturn (value: unknown): value is Exclude<TBase, TExcluded> =>\n\t\tholds(() => {\n\t\t\tif (!base(value)) return false\n\t\t\tconst accepted = value\n\t\t\treturn !holds(() => excluded(accepted))\n\t\t})\n}\n\n/**\n * Builds a guard that accepts values matching at least one of the provided\n * guards — the variadic form of {@link orOf}.\n *\n * @remarks\n * Zero guards yield a guard that always answers `false`. Each member is contained\n * separately, exactly as {@link orOf} contains its two, so a throwing member cannot\n * erase a later passing one and the answer does not depend on argument order.\n *\n * @param guards - The guards tried in order\n * @returns A guard accepting a value at least one guard accepts\n *\n * @example\n * ```ts\n * const isStringOrBoolean = unionOf(isString, isBoolean)\n * ```\n */\nexport function unionOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<GuardType<Gs[number]>>\nexport function unionOf(...predicates: ReadonlyArray<(value: unknown) => boolean>): Guard<unknown>\nexport function unionOf(...guards: ReadonlyArray<(value: unknown) => boolean>): Guard<unknown> {\n\t// Per-member containment, exactly as its declared twin `orOf`: one `holds`\n\t// around the whole loop made a throwing member erase every later passing one,\n\t// so `unionOf(a, b)` and `unionOf(b, a)` answered differently for one value.\n\treturn (value: unknown): value is unknown => {\n\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\tconst guard = guards[index]\n\t\t\tif (guard !== undefined && holds(() => guard(value))) return true\n\t\t}\n\t\treturn false\n\t}\n}\n\n/**\n * Builds a guard that accepts values matching ALL of the provided guards — the\n * variadic form of {@link andOf}.\n *\n * @remarks\n * Zero guards yield a guard that always answers `true`, the identity of an\n * intersection.\n *\n * @param guards - The guards every accepted value must satisfy\n * @returns A guard accepting a value every guard accepts\n *\n * @example\n * ```ts\n * const isNonEmpty = intersectionOf(isString, isNonEmptyString)\n * ```\n */\nexport function intersectionOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<IntersectionFromGuards<Gs>>\nexport function intersectionOf(\n\t...predicates: ReadonlyArray<(value: unknown) => boolean>\n): Guard<unknown>\nexport function intersectionOf(\n\t...guards: ReadonlyArray<(value: unknown) => boolean>\n): Guard<unknown> {\n\treturn (value: unknown): value is unknown =>\n\t\tholds(() => {\n\t\t\t// Indexed, exactly as its declared twin `unionOf` is. `Array.prototype.every`\n\t\t\t// is forbidden here for the reason `literalOf` states earlier in this file:\n\t\t\t// a replaced `every` answering `true` for everything makes this guard accept\n\t\t\t// a value no constituent guard admits.\n\t\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\t\tconst guard = guards[index]\n\t\t\t\tif (guard === undefined || !guard(value)) return false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Refines a base guard with an additional predicate that runs only when the base\n * passes.\n *\n * @remarks\n * The predicate receives a value already narrowed to `T`. When the predicate is\n * itself a type guard (`value is U`), the result narrows to `Guard<U>` — it\n * passes only when the value is genuinely a `U`, so the narrowing is sound. The\n * returned guard never throws, as `.claude/rules/patterns.md` § Validation and\n * contracts requires: if `predicate` throws, the throw is contained and the\n * guard reports a non-match.\n *\n * @param base - The guard establishing the accepted domain\n * @param predicate - The refinement run only after `base` passes\n * @returns A guard accepting a value `base` accepts and the refinement admits\n *\n * @example\n * ```ts\n * const isPositive = whereOf(isNumber, (n) => n > 0)\n * isPositive(5) // true\n * isPositive(-1) // false\n *\n * // A narrowing predicate refines the result type to Guard<5>\n * const isFive = whereOf(isNumber, (n): n is 5 => n === 5)\n * ```\n */\nexport function whereOf<T, U extends T>(\n\tbase: Guard<T>,\n\tpredicate: (value: T) => value is U,\n): Guard<U>\nexport function whereOf<T>(base: Guard<T>, predicate: (value: T) => boolean): Guard<T>\nexport function whereOf<T>(base: Guard<T>, predicate: (value: T) => boolean): Guard<T> {\n\treturn (value: unknown): value is T => holds(() => base(value) && predicate(value))\n}\n\n/**\n * Defers guard creation until first use by calling `thunk()` on every\n * invocation.\n *\n * @remarks\n * `thunk` is called on every guard call, not cached — this lets it close over a\n * binding assigned *after* `lazyOf` is called, the primary use case for\n * self-referential recursive guards. A throw from `thunk` (or the guard it\n * resolves to) is contained and reported as a non-match, as\n * `.claude/rules/patterns.md` § Validation and contracts requires.\n *\n * Each lazy guard tracks its active invocation depth. An invocation that would\n * exceed {@link GUARD_DEPTH_LIMIT} returns `false` before resolving `thunk`; the\n * counter always unwinds after the contained call, so one deep or cyclic input\n * cannot poison later guard calls.\n *\n * @param thunk - The factory producing the guard to apply, called on every invocation\n * @returns A guard deferring each call to the thunk's guard\n *\n * @example\n * ```ts\n * type Tree = { readonly value: number; readonly children: readonly Tree[] }\n * const isTree: Guard<Tree> = recordOf({\n * value: isNumber,\n * children: arrayOf(lazyOf(() => isTree)),\n * })\n * ```\n */\nexport function lazyOf<T>(thunk: () => Guard<T>): Guard<T> {\n\tconst deferred = new LazyGuard(thunk)\n\treturn (value: unknown): value is T => deferred.test(value)\n}\n\n/**\n * Builds a guard that passes when the base passes AND the projection of the value\n * satisfies the target guard. Still narrows to `T` (the base type) — the target\n * check is a validity constraint on a derived view, not a type transformation.\n *\n * @remarks\n * `project` is a plain `(value: T) => U`. The returned guard never\n * throws, as `.claude/rules/patterns.md` § Validation and contracts requires: a\n * throw from `project` or `target` is contained and reported as a\n * non-match. (Unlike the reference implementation, there is no\n * \"curried projector\" branch — a projection that legitimately returns a function\n * would be double-invoked under that scheme. Compose explicitly if you need it.)\n *\n * @param base - The guard establishing the accepted domain\n * @param project - The projection applied to a value `base` accepted\n * @param target - The guard the projection's result must satisfy\n * @returns A guard narrowing to the base type, accepting only a value whose projection satisfies `target`\n *\n * @example\n * ```ts\n * const isBounded = transformOf(\n * isString,\n * (s) => s.trim().length,\n * whereOf(isNumber, (n) => n >= 1 && n <= 50),\n * )\n * isBounded('hello') // true\n * isBounded('') // false\n * ```\n */\nexport function transformOf<T, U>(\n\tbase: Guard<T>,\n\tproject: (value: T) => U,\n\ttarget: Guard<U>,\n): Guard<T>\nexport function transformOf<T>(\n\tbase: Guard<T>,\n\tproject: (value: T) => unknown,\n\ttarget: (value: unknown) => boolean,\n): Guard<T>\nexport function transformOf<T>(\n\tbase: Guard<T>,\n\tproject: (value: T) => unknown,\n\ttarget: (value: unknown) => boolean,\n): Guard<T> {\n\treturn (value: unknown): value is T => holds(() => base(value) && target(project(value)))\n}\n\n/**\n * Builds a guard that accepts finite numbers within an inclusive `[min, max]`\n * range.\n *\n * @remarks\n * Refines {@link isFiniteNumber} with the bound comparison, so `NaN` /\n * `±Infinity` are rejected before any comparison runs. An absent bound never\n * constrains that side. Reused for a number's own value AND, applied to a\n * `.length`, for string and array length refinements — the single source of the\n * bound logic shared by the compiled guard and parser (compilers.ts).\n *\n * @param min - The inclusive lower bound, absent for unbounded below\n * @param max - The inclusive upper bound, absent for unbounded above\n * @returns A guard accepting a finite number inside the bounds\n *\n * @example\n * ```ts\n * const inRange = boundsOf(1, 5)\n * inRange(3) // true\n * inRange(0) // false — below min\n * inRange(6) // false — above max\n *\n * const atLeastTwo = boundsOf(2)\n * atLeastTwo(2) // true — unbounded above\n * ```\n */\nexport function boundsOf(min?: number, max?: number): Guard<number> {\n\treturn whereOf(\n\t\tisFiniteNumber,\n\t\t(value) => (min === undefined || value >= min) && (max === undefined || value <= max),\n\t)\n}\n\n/**\n * Builds a guard that accepts strings matching a regular expression.\n *\n * @remarks\n * Clones the pattern for the guard and strips the stateful `g` / `y` flags, so\n * repeated checks are stable and never change the caller's `lastIndex`.\n *\n * @param pattern - The regular expression to own and apply\n * @returns A stateless string guard\n *\n * @example\n * ```ts\n * const isHex = matchOf(/^[0-9a-f]+$/)\n * isHex('1a2f') // true\n * isHex('xyz') // false\n * ```\n */\nexport function matchOf(pattern: RegExp): Guard<string> {\n\treturn contain(() => {\n\t\tif (!isRegExp(pattern)) {\n\t\t\tthrow new ContractError('matchOf: pattern must be a RegExp', { code: 'pattern' })\n\t\t}\n\t\tconst owned = readValue(() => readPattern(pattern), 'matchOf', {\n\t\t\tsubject: 'pattern',\n\t\t\tcode: 'pattern',\n\t\t})\n\t\treturn whereOf(isString, (value) => matchesPattern(owned, value))\n\t}, 'matchOf')\n}\n\n/**\n * Builds a guard that accepts strings satisfying optional length and pattern\n * refinements — `min` / `max` length and a `pattern`.\n *\n * @remarks\n * Composes {@link isString} with {@link matchesStringLength}, which counts code\n * points as the `minLength` and `maxLength` a string shape emits do, and an owned\n * stateless pattern (the same refinement {@link matchOf} performs).\n * When `min`, `max`, and `pattern` are all absent it returns the bare {@link isString} guard\n * (the unconstrained fast path), so an unrefined string leaf pays no wrapping\n * cost. The single source of the string refinement shared by the compiled guard\n * and parser (compilers.ts).\n *\n * @param options - Optional length bounds and regular expression refinement\n * @returns A string guard enforcing the requested refinements\n * @throws {ContractError} When the options cannot be read\n *\n * @example\n * ```ts\n * const isSlug = stringOf({ min: 1, max: 32, pattern: /^[a-z-]+$/ })\n * isSlug('hello-world') // true\n * isSlug('') // false — below min\n * isSlug('Hello') // false — pattern miss\n *\n * stringOf() // identical to isString\n * ```\n */\nexport function stringOf(options?: StringGuardOptions): Guard<string> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'pattern'], 'stringOf', 'string')\n\t\t// Own reads, because the snapshot's prototype is `Object.prototype`, and a field\n\t\t// these options leave out must not answer from there.\n\t\tconst min = safe !== undefined && INTRINSICS.own(safe, 'min') ? safe.min : undefined\n\t\tconst max = safe !== undefined && INTRINSICS.own(safe, 'max') ? safe.max : undefined\n\t\tconst source = safe !== undefined && INTRINSICS.own(safe, 'pattern') ? safe.pattern : undefined\n\t\tif (source !== undefined && !isRegExp(source)) {\n\t\t\tthrow new ContractError('stringOf: pattern must be a RegExp', { code: 'pattern' })\n\t\t}\n\t\tconst pattern = source === undefined ? undefined : ownPattern(source, 'stringOf')\n\t\tif (min === undefined && max === undefined && pattern === undefined) {\n\t\t\treturn isString\n\t\t}\n\t\treturn whereOf(\n\t\t\tisString,\n\t\t\t(value) =>\n\t\t\t\tmatchesStringLength(value, min, max) &&\n\t\t\t\t(pattern === undefined || matchesPattern(pattern, value)),\n\t\t)\n\t}, 'stringOf')\n}\n\n/**\n * Extends a guard to also allow `null`.\n *\n * @param guard - The guard to extend\n * @returns A guard accepting `null` and every value `guard` accepts\n *\n * @example\n * ```ts\n * const isNullableString = nullableOf(isString)\n * isNullableString('hi') // true\n * isNullableString(null) // true\n * isNullableString(42) // false\n * ```\n */\nexport function nullableOf<T>(guard: Guard<T>): Guard<T | null> {\n\treturn (value: unknown): value is T | null => holds(() => value === null || guard(value))\n}\n\n/**\n * Extends a guard to also allow `undefined` — the optional counterpart of\n * {@link nullableOf}.\n *\n * @param guard - The guard to extend\n * @returns A guard accepting `undefined` and every value `guard` accepts\n *\n * @example\n * ```ts\n * const isOptionalString = optionalOf(isString)\n * isOptionalString('hi') // true\n * isOptionalString(undefined) // true\n * isOptionalString(null) // false\n * ```\n */\nexport function optionalOf<T>(guard: Guard<T>): Guard<T | undefined> {\n\treturn (value: unknown): value is T | undefined =>\n\t\tholds(() => value === undefined || guard(value))\n}\n","import type { FieldPath, Guard, JSONValue, LiteralValue } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tisArray,\n\tisFiniteNumber,\n\tisLiteralValue,\n\tisNull,\n\tisObject,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport {\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tholds,\n\tisFailure,\n\tisSuccess,\n\titerateIndices,\n\tmatchesJSONValue,\n\tmatchesMember,\n\treadArrayEntries,\n\treadValue,\n\tresolveField,\n} from './helpers.js'\n\n// `.claude/rules/patterns.md` § Validation and contracts: a parser answers\n// \"give me a `T` or nothing\" — it returns the\n// typed value or `undefined` for readable invalid input. `parseRecord` and\n// `parseJSONValue` refuse a failed traversal with a coded `ContractError`, so\n// unreadability cannot masquerade as ordinary invalidity. Each leaf parser here forms a\n// SOUND pair with the guard for its output TYPE: a guard-valid input is returned\n// UNCHANGED (by identity, never rejected), and every non-`undefined` output\n// satisfies that type guard. The pairings (verified in parsers.test.ts):\n//\n// parseString ↔ isString parseRecord ↔ isRecord\n// parseNumber ↔ isFiniteNumber parseArray ↔ arrayOf(guard) / isArray\n// parseInteger ↔ isInteger parseEnum ↔ literalOf(...allowed)\n// parseBoolean ↔ isBoolean parseNull ↔ isNull\n// parseJSONValue ↔ isJSONValue\n//\n// Coercion of NON-valid inputs (for example numeric strings → numbers) is a\n// bonus on top of soundness, not a violation of it — soundness constrains only\n// the inputs the guard already accepts.\n//\n// These leaf parsers are deliberately TYPE-only: they know nothing about a\n// shape's `min` / `max` / `pattern` refinements. Those refinements are enforced\n// one layer up, by the compiled parser (compilers.ts `compileParser`), which\n// re-applies the shared refinement combinators (`stringOf` / `boundsOf`,\n// combinators.ts) after coercion — the same source the compiled guard uses. So `createContract(...).parse` IS sound against the FULL\n// guard (refinements included); the split keeps each leaf parser small while the\n// compiler composes the full soundness.\n//\n// Coercion policy — which types cross into which:\n// - number <-> string is BIDIRECTIONAL by design: parseNumber accepts a\n// numeric string ('42' -> 42) and parseString accepts a finite number,\n// stringifying it (42 -> '42'). Use isString / isFiniteNumber directly\n// (never the parser) when you need STRICT type rejection with no coercion.\n// - boolean is a coercion SINK, never a source: parseBoolean accepts\n// 'true'/'false'/'1'/'0' and 1/0 and coerces them TO a boolean, but\n// parseNumber and parseString both reject booleans outright — a boolean\n// never coerces INTO a number or string. This is intentional asymmetry:\n// '1' meaning \"the number one\" and '1' meaning \"true\" are genuinely\n// different domains, so only the boolean parser treats the numeric/string\n// forms as booleans.\n\n// === Primitive parsers\n\n/**\n * Parses an unknown value to a string.\n *\n * @remarks\n * A string is returned unchanged; a finite number is coerced to its decimal\n * string (`42` → `'42'`). `NaN`, `±Infinity`, and every other type → `undefined`.\n *\n * @param value - The value to parse\n * @returns A string, or `undefined`\n *\n * @example\n * ```ts\n * parseString('hi') // 'hi'\n * parseString(42) // '42'\n * parseString(true) // undefined\n * ```\n */\nexport function parseString(value: unknown): string | undefined {\n\tif (isString(value)) return value\n\tif (isFiniteNumber(value)) return INTRINSICS.text(value)\n\treturn undefined\n}\n\n/**\n * Parses an unknown value to a finite number.\n *\n * @remarks\n * A finite number is returned unchanged; a non-blank numeric string is parsed\n * through `Number(...)`. `NaN`, `±Infinity`, blank/non-numeric strings, and every\n * other type → `undefined`.\n *\n * @param value - The value to parse\n * @returns A finite number, or `undefined`\n *\n * @example\n * ```ts\n * parseNumber(42) // 42\n * parseNumber('42') // 42\n * parseNumber('abc') // undefined\n * ```\n */\nexport function parseNumber(value: unknown): number | undefined {\n\tif (typeof value === 'number') {\n\t\treturn INTRINSICS.finite(value) ? value : undefined\n\t}\n\tif (!isString(value)) return undefined\n\t// Total by containment at the door. `String.prototype.trim` is a\n\t// caller-writable member reached by name, and this reader is documented to\n\t// ANSWER `undefined`, never to throw — so the boundary belongs here, where it\n\t// covers whatever the body reaches, rather than around the one dispatch\n\t// somebody happened to notice.\n\tconst outcome = attempt(() => {\n\t\tif (value.trim() === '') return undefined\n\t\tconst parsed = INTRINSICS.numeric(value)\n\t\treturn INTRINSICS.finite(parsed) ? parsed : undefined\n\t})\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Parses an unknown value to a finite integer.\n *\n * @remarks\n * Accepts whatever {@link parseNumber} accepts, then requires the result to have\n * no fractional part. `3.14` / `'3.14'` → `undefined`.\n *\n * @param value - The value to parse\n * @returns A finite integer, or `undefined`\n *\n * @example\n * ```ts\n * parseInteger(42) // 42\n * parseInteger(3.14) // undefined\n * ```\n */\nexport function parseInteger(value: unknown): number | undefined {\n\tconst parsed = parseNumber(value)\n\tif (parsed === undefined) return undefined\n\treturn INTRINSICS.integer(parsed) ? parsed : undefined\n}\n\n/**\n * Parses an unknown value to a boolean.\n *\n * @remarks\n * A boolean is returned unchanged. The strings `'true'` / `'false'` / `'1'` /\n * `'0'` and the numbers `1` / `0` coerce to the matching boolean. Everything\n * else → `undefined`.\n *\n * @param value - The value to parse\n * @returns A boolean, or `undefined`\n *\n * @example\n * ```ts\n * parseBoolean(true) // true\n * parseBoolean('1') // true\n * parseBoolean('nope') // undefined\n * ```\n */\nexport function parseBoolean(value: unknown): boolean | undefined {\n\tif (typeof value === 'boolean') return value\n\tif (value === 'true' || value === '1' || value === 1) return true\n\tif (value === 'false' || value === '0' || value === 0) return false\n\treturn undefined\n}\n\n/**\n * Parses an unknown value to `null`.\n *\n * @remarks\n * A successful parse returns `null` itself — distinct from the `undefined`\n * failure sentinel every other parser in this file uses. Only `null` passes;\n * every other value (including `undefined`) → `undefined`.\n *\n * @param value - The value to parse\n * @returns `null` on a successful parse, or `undefined`\n *\n * @example\n * ```ts\n * parseNull(null) // null\n * parseNull(undefined) // undefined\n * ```\n */\nexport function parseNull(value: unknown): null | undefined {\n\treturn isNull(value) ? value : undefined\n}\n\n// === Structural parsers\n\n/**\n * Parses an unknown value to a plain record — the input reference, never cloned.\n *\n * @remarks\n * Probes the record's own enumerable values before returning the reference, so a\n * hostile getter is met here rather than at the caller. A failed probe throws\n * `ContractError { code: 'structure' }` carrying `parseRecord: value could not be\n * read`; a readable non-record answers `undefined`.\n *\n * @param value - The value to parse\n * @returns The record, or `undefined`\n * @throws {ContractError} When an object value cannot be read\n */\nexport function parseRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn contain(() => {\n\t\tif (isObject(value)) readValue(() => INTRINSICS.values(value), 'parseRecord')\n\t\treturn isRecord(value) ? value : undefined\n\t}, 'parseRecord')\n}\n\n/**\n * Parses an unknown value to an array — the input reference, never cloned —\n * optionally guarding every element.\n *\n * @remarks\n * Without a `guard`, element types are NOT verified; let `T` default to\n * `unknown` rather than asserting a specific element type.\n *\n * @param value - The value to parse\n * @param guard - Optional element guard\n * @returns The array, or `undefined`\n *\n * @example\n * ```ts\n * parseArray([1, 2]) // [1, 2]\n * parseArray([1, 'x'], isNumber) // undefined\n * ```\n */\nexport function parseArray<T = unknown>(\n\tvalue: unknown,\n\tguard?: Guard<T>,\n): readonly T[] | undefined {\n\tif (!isArray<T>(value)) return undefined\n\tif (guard === undefined) return value\n\tconst entries = readArrayEntries(value)\n\tif (isFailure(entries) || !entries.value.dense) return undefined\n\tif (\n\t\t!holds(\n\t\t\t() =>\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, entries.value.entries, [\n\t\t\t\t\t(entry: unknown) => !guard(entry),\n\t\t\t\t]) === -1,\n\t\t)\n\t) {\n\t\treturn undefined\n\t}\n\treturn value\n}\n\n/**\n * Parses an unknown value to a cycle-safe JSON value — the input reference,\n * never cloned.\n *\n * @remarks\n * Unlike {@link parseRecord} / {@link parseArray}, this is a DEEP gate: it\n * walks the entire tree through {@link isJSONValue} rather than checking only the\n * top-level shape. That walk is cycle-safe. A readable non-JSON structure,\n * including a cycle, returns `undefined`; a failed property read throws a\n * `structure` {@link ContractError}, keeping unreadability distinct from an\n * honest invalid result.\n *\n * @param value - The value to parse\n * @returns The value, or `undefined` when it is not a valid JSON value\n * @throws {ContractError} When the JSON tree cannot be read\n *\n * @example\n * ```ts\n * parseJSONValue({ a: 1 }) // { a: 1 }\n * parseJSONValue(Number.NaN) // undefined\n * ```\n */\nexport function parseJSONValue(value: unknown): JSONValue | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => (matchesJSONValue(value, new INTRINSICS.weakSet()) ? value : undefined),\n\t\t\t'parseJSONValue',\n\t\t\t{ context: { shape: 'json' } },\n\t\t)\n\t}, 'parseJSONValue')\n}\n\n// === Enum parser\n\n/**\n * Parses an unknown value as one of the allowed literal primitives.\n *\n * @remarks\n * Pairs with {@link literalOf} — both match by SameValueZero, so the\n * `parseEnum ↔ literalOf(...allowed)` pairing covers every literal primitive\n * (string, number, or boolean), not only strings. Matching is identity, never\n * cross-type coercion: `parseEnum('1', [1])` stays `undefined`. The allowed\n * values are captured through their dense own-index view and copied into an\n * owned `Set`; caller-defined iteration is ignored and unreadability returns\n * `undefined` rather than escaping.\n *\n * @param value - The value to parse\n * @param allowed - The permitted literal values\n * @returns The input when it matches an allowed literal by SameValueZero, or `undefined`\n *\n * @example\n * ```ts\n * parseEnum('b', ['a', 'b', 'c']) // 'b'\n * parseEnum('z', ['a', 'b', 'c']) // undefined\n * ```\n */\nexport function parseEnum<const T extends LiteralValue>(\n\tvalue: unknown,\n\tallowed: readonly T[],\n): T | undefined\nexport function parseEnum(\n\tvalue: unknown,\n\tallowed: readonly LiteralValue[],\n): LiteralValue | undefined\nexport function parseEnum(\n\tvalue: unknown,\n\tallowed: readonly LiteralValue[],\n): LiteralValue | undefined {\n\tconst outcome = readArrayEntries(allowed)\n\tif (isFailure(outcome) || !outcome.value.dense) return undefined\n\t// A parser answers `undefined`, never throws, so the vocabulary is built and\n\t// consulted inside the never-throw boundary — and the membership question is\n\t// asked through a module binding rather than any property, because a coercer\n\t// that returns a value outside its own allowed list is the same silent lie the\n\t// paired guard was answering: `Set.prototype.has = () => true` made\n\t// `parseEnum('zzz', ['a', 'b'])` answer `'zzz'`.\n\tif (!holds(() => matchesMember(collectMembers(outcome.value.entries), value))) return undefined\n\treturn isLiteralValue(value) ? value : undefined\n}\n\n/**\n * Parses indexed enum members, ending after the first undefined result.\n *\n * @param values - The source array, read by index\n * @param allowed - The accepted literal vocabulary\n * @returns Parsed members, including the first invalid member's undefined result\n *\n * @example\n * ```ts\n * Array.from(parseEnumValues(['a', 'x', 'b'], ['a', 'b'])) // ['a', undefined]\n * ```\n */\nexport function* parseEnumValues<const T extends LiteralValue>(\n\tvalues: readonly unknown[],\n\tallowed: readonly T[],\n): Generator<T | undefined, void, unknown> {\n\tfor (const index of iterateIndices(() => values.length)) {\n\t\tconst member = parseEnum(values[index], allowed)\n\t\tyield member\n\t\tif (member === undefined) return\n\t}\n}\n\nfor (const key of ['next', 'return', 'throw', Symbol.iterator]) {\n\tINTRINSICS.define(parseEnumValues.prototype, key, {\n\t\tvalue: INTRINSICS.reflect.read(parseEnumValues.prototype, key),\n\t})\n}\nINTRINSICS.freeze(parseEnumValues.prototype)\nINTRINSICS.freeze(parseEnumValues)\n\n// === Record-field parsers\n\n/**\n * Reads and parses a string field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A string, or `undefined`\n */\nexport function parseStringField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): string | undefined {\n\treturn parseString(resolveField(record, path))\n}\n\n/**\n * Reads and parses a finite-number field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A finite number, or `undefined`\n *\n * @example\n * ```ts\n * parseNumberField({ age: '42' }, 'age') // 42\n * parseNumberField({}, 'age') // undefined\n * ```\n */\nexport function parseNumberField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): number | undefined {\n\treturn parseNumber(resolveField(record, path))\n}\n\n/**\n * Reads and parses a finite-integer field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A finite integer, or `undefined`\n */\nexport function parseIntegerField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): number | undefined {\n\treturn parseInteger(resolveField(record, path))\n}\n\n/**\n * Reads and parses a boolean field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A boolean, or `undefined`\n *\n * @example\n * ```ts\n * parseBooleanField({ on: 'true' }, 'on') // true\n * parseBooleanField({}, 'on') // undefined\n * ```\n */\nexport function parseBooleanField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): boolean | undefined {\n\treturn parseBoolean(resolveField(record, path))\n}\n\n/**\n * Reads and parses a `null` field from a record by key or nested key path.\n *\n * @remarks\n * A successful parse returns `null` itself — distinct from the `undefined`\n * failure sentinel, which also covers a missing field.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns `null` on a successful parse, or `undefined`\n *\n * @example\n * ```ts\n * parseNullField({ value: null }, 'value') // null\n * parseNullField({}, 'value') // undefined\n * ```\n */\nexport function parseNullField(record: Record<string, unknown>, path: FieldPath): null | undefined {\n\treturn parseNull(resolveField(record, path))\n}\n\n/**\n * Reads and parses a nested record field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A plain record, or `undefined`\n */\nexport function parseRecordField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): Record<string, unknown> | undefined {\n\treturn parseRecord(resolveField(record, path))\n}\n\n/**\n * Reads and parses an array field from a record by key or nested key path,\n * optionally guarding elements.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @param guard - Optional element guard\n * @returns An array, or `undefined`\n *\n * @example\n * ```ts\n * parseArrayField({ tags: [1, 2] }, 'tags') // [1, 2]\n * parseArrayField({}, 'tags') // undefined\n * ```\n */\nexport function parseArrayField<T = unknown>(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n\tguard?: Guard<T>,\n): readonly T[] | undefined {\n\treturn parseArray(resolveField(record, path), guard)\n}\n\n/**\n * Reads and parses an enum field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @param allowed - The permitted literal values\n * @returns The matched literal, or `undefined`\n */\nexport function parseEnumField<const T extends LiteralValue>(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n\tallowed: readonly T[],\n): T | undefined {\n\treturn parseEnum(resolveField(record, path), allowed)\n}\n\n/**\n * Reads and parses a JSON-value field from a record by key or nested key path.\n *\n * @remarks\n * Deep-gates the field's whole subtree through {@link parseJSONValue} — see that\n * function's remarks for why this differs from the shallow\n * {@link parseRecordField} / {@link parseArrayField}.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns The value, or `undefined`\n *\n * @example\n * ```ts\n * parseJSONValueField({ data: { a: 1 } }, 'data') // { a: 1 }\n * parseJSONValueField({}, 'data') // undefined\n * ```\n */\nexport function parseJSONValueField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): JSONValue | undefined {\n\treturn parseJSONValue(resolveField(record, path))\n}\n\n// === JSON\n\n/**\n * Parses a JSON string, returning `undefined` instead of throwing.\n *\n * @remarks\n * The safe boundary for untrusted JSON text: a malformed string yields\n * `undefined`, never an exception. Returns `unknown` — a successful parse proves\n * nothing about shape, so narrow the result with a guard (or use\n * {@link parseJSONAs}). A large document is not walked here; parsing is shallow\n * and lazy validation is the caller's to compose.\n *\n * @param value - The JSON string to parse\n * @returns The parsed value, or `undefined` when `value` is not valid JSON\n */\nexport function parseJSON(value: string): unknown {\n\ttry {\n\t\treturn INTRINSICS.decode(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Parses a JSON string and validates the result against a guard.\n *\n * @remarks\n * The lazy, safe path from an untrusted string to a typed `T`: parse, then check\n * the parsed value with the guard you bring — typically one composed from the\n * combinators (`recordOf`, `arrayOf`, …). Only the shape the guard inspects is\n * validated, so a large document is never walked in full unless the guard does.\n *\n * @param value - The JSON string to parse\n * @param guard - The guard for the expected shape\n * @returns The parsed value when it satisfies `guard`, otherwise `undefined`\n *\n * @example\n * ```ts\n * const isConfig = recordOf({ host: isString, tags: arrayOf(isString) })\n * parseJSONAs('{\"host\":\"localhost\",\"tags\":[\"a\"]}', isConfig) // { host: 'localhost', tags: ['a'] }\n * parseJSONAs('{\"host\":\"localhost\"}', isConfig) // undefined — guard fails\n * parseJSONAs('not json', isConfig) // undefined — never throws\n * ```\n */\nexport function parseJSONAs<T>(value: string, guard: Guard<T>): T | undefined {\n\tconst parsed = parseJSON(value)\n\tif (parsed === undefined) return undefined\n\t// The guard runs inside the shared result boundary rather than beside a `let`\n\t// the callback assigns into: the narrowed value IS the callback's answer, so\n\t// it is returned rather than ferried out of the branch that proved it.\n\tconst checked = attempt(() => (guard(parsed) ? parsed : undefined))\n\treturn isSuccess(checked) ? checked.value : undefined\n}\n","import type { EvaluationFunction } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { isFailure, readSetEntries } from './helpers.js'\nimport { isObject } from './validators.js'\n\n/** Owns compiled-node memo entries for one synchronous evaluation. */\nexport class EvaluationScope {\n\tstatic readonly #active = new INTRINSICS.set<EvaluationScope>()\n\tstatic readonly #path: readonly string[] = INTRINSICS.freeze([])\n\treadonly #answers = new INTRINSICS.weakMap<object, WeakMap<object, unknown>>()\n\n\t/** Evaluates a node within the active call, disposing a newly opened scope on settlement. */\n\tstatic run<T>(\n\t\tplan: EvaluationFunction<T>,\n\t\tvalue: unknown,\n\t\tpath: readonly string[] = EvaluationScope.#path,\n\t\tclean = false,\n\t): T {\n\t\tif (!isObject(value)) return plan(value, path)\n\t\tconst entries = readSetEntries(EvaluationScope.#active)\n\t\tif (isFailure(entries)) throw entries.error\n\t\tconst active = entries.value[0]\n\t\tif (active instanceof EvaluationScope) return active.#evaluate(plan, value, path, clean)\n\t\tif (active !== undefined) throw new INTRINSICS.error('Evaluation scope is unavailable')\n\t\tconst scope = new EvaluationScope()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, EvaluationScope.#active, [scope])\n\t\ttry {\n\t\t\treturn scope.#evaluate(plan, value, path, clean)\n\t\t} finally {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.remove, EvaluationScope.#active, [scope])\n\t\t}\n\t}\n\n\t#evaluate<T>(\n\t\tplan: EvaluationFunction<T>,\n\t\tvalue: object,\n\t\tpath: readonly string[],\n\t\tclean: boolean,\n\t): T {\n\t\tconst cached: WeakMap<object, unknown> | undefined = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.recall,\n\t\t\tthis.#answers,\n\t\t\t[plan],\n\t\t)\n\t\tconst memo = cached ?? new INTRINSICS.weakMap<object, unknown>()\n\t\tif (cached === undefined) {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#answers, [plan, memo])\n\t\t}\n\t\tconst recalled: T | undefined = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\tif (recalled !== undefined) return recalled\n\t\tconst answer = plan(value, path)\n\t\tif (!clean || (INTRINSICS.array(answer) && answer.length === 0)) {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t}\n\t\treturn answer\n\t}\n}\n","import { INTRINSICS } from './constants.js'\n\n/** Owns the changing state projected by one seeded random function. */\nexport class RandomSource {\n\t#state: number\n\n\tconstructor(seed: number) {\n\t\tthis.#state = seed >>> 0\n\t}\n\n\t/** Advances the generator and returns its next unit-interval value. */\n\tnext(): number {\n\t\tthis.#state = (this.#state + 0x6d2b79f5) >>> 0\n\t\tconst mixed = INTRINSICS.imul(this.#state ^ (this.#state >>> 15), this.#state | 1)\n\t\tconst final = mixed ^ (mixed + INTRINSICS.imul(mixed ^ (mixed >>> 7), mixed | 61))\n\t\treturn ((final ^ (final >>> 14)) >>> 0) / 4_294_967_296\n\t}\n}\n","import type { RandomFunction } from './types.js'\nimport { ContractError } from './errors.js'\nimport { preview } from './helpers.js'\nimport { RandomSource } from './RandomSource.js'\nimport { isNumber } from './validators.js'\n\n/**\n * Builds a deterministic pseudo-random source seeded from a single number.\n *\n * @remarks\n * A mulberry32 generator — the same seed always yields the same sequence, so\n * generated seed data is reproducible across runs. Used as the default random\n * source for {@link compileGenerator}, seeded from the wall clock so casual\n * callers still get varied output without passing a source themselves.\n *\n * @param seed - The seed for the sequence\n * @returns A {@link RandomFunction} returning values in `[0, 1)`\n *\n * @example\n * ```ts\n * const random = seededRandom(42)\n * random() // always the same first value for seed 42\n * ```\n */\nexport function seededRandom(seed: number): RandomFunction {\n\tif (!isNumber(seed)) {\n\t\tthrow new ContractError('seededRandom: seed must be a number', {\n\t\t\tcode: 'random',\n\t\t\tcontext: { limit: 'number', received: preview(seed) },\n\t\t})\n\t}\n\tconst source = new RandomSource(seed)\n\treturn () => source.next()\n}\n","import type {\n\tArrayShape,\n\tAuditFault,\n\tAuditorFunction,\n\tContractCompilerInterface,\n\tContractInterface,\n\tContractShape,\n\tFault,\n\tFaultKind,\n\tGuard,\n\tInfer,\n\tJSONSchema,\n\tJSONValue,\n\tLiteralValue,\n\tNumberShape,\n\tObjectShape,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tResult,\n\tSeederFunction,\n\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport {\n\tFAULT_LIMIT,\n\tGENERATION_ATTEMPT_LIMIT,\n\tINTRINSICS,\n\tPRESENCE_MASK_LIMIT,\n\tSHAPE_FIELDS,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tappendEntries,\n\tattempt,\n\titerateIndices,\n\tcollectMembers,\n\tcontain,\n\tbuildArrayFaults,\n\tbuildPositions,\n\tbuildNumberFaults,\n\tbuildStringFaults,\n\tdrawRandom,\n\tenumerableKeys,\n\tisFailure,\n\tisSuccess,\n\tlimitEntries,\n\tmatchesMember,\n\townPattern,\n\tpathOf,\n\tpinMembers,\n\tpreview,\n\treadArrayEntries,\n\treadPatternSource,\n\treadPresence,\n\treadValue,\n\trefuseExpansion,\n\tselectClosestFaults,\n\tshapeToKind,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisJSONValue,\n\tisNull,\n\tisObject,\n\tisRecord,\n\tisString,\n\tisUndefined,\n} from './validators.js'\nimport {\n\tarrayOf,\n\tboundsOf,\n\tintersectionOf,\n\tliteralOf,\n\tmatchOf,\n\tnullableOf,\n\torOf,\n\tstringOf,\n\tunionOf,\n\twhereOf,\n} from './combinators.js'\nimport { parseBoolean, parseInteger, parseJSONValue, parseNumber, parseString } from './parsers.js'\nimport { cloneJSONValue, cloneSchema, ownShape } from './cloners.js'\nimport { ShapePass } from './ShapePass.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { EvaluationScope } from './EvaluationScope.js'\nimport { seededRandom } from './seeders.js'\n\n/**\n * Owns one contract shape's artifacts and their bundle, compiled lazily.\n *\n * @remarks\n * The engine every standalone `compile*` function and `createContract` runs\n * on. A recursive compiler re-owns and\n * re-validates the SUBGRAPH at every node it descends into, so a depth-100\n * chain pays a hundred clones of shrinking graphs and a hundred validations —\n * quadratic work for a linear declaration. Here ownership runs once, validation runs once over\n * that owned result, and each unique node and structural edge is indexed once\n * into children-before-parent order. A declaration a builder sealed is frozen and\n * validated all the way down already, so it takes neither and is indexed as it\n * stands. Every artifact family is then a single\n * postorder pass whose entries are keyed by node identity, so a shared child is\n * compiled once however many parents point at it. The same asymmetry exists on\n * the VALUE side and is answered the same way: `guard`, `auditor` and `reporter`\n * carry a call-scoped ledger, so a shared object costs one visit per compiled\n * node rather than one per path through the graph.\n *\n * Construction observes nothing at all: no read, no validation, no clone, no\n * graph-sized allocation, no clock, no draw. The first getter read prepares; the\n * getters after it replay. A getter builds its own family and no other, except\n * that `parser`, `reporter` and `generator` build the guard plan when the graph\n * holds a union, because a union's membership question IS a guard question in\n * all three, and every getter builds it when the graph holds a default, because\n * a default that its inner shape refuses refuses at whichever artifact is read\n * first.\n *\n * One terminal lifecycle covers preparation and every family. A failure settles\n * the compiler: later getters rethrow that exact error, while an artifact\n * already handed out keeps working, because each compiled artifact is\n * self-contained. Reentry — reachable only through a caller accessor the\n * declaration itself exposes, since a `pattern` getter is the one accessor\n * ownership invokes — poisons the nested read, the interrupted outer read, and\n * every later read with one shared cause-free error.\n *\n * @typeParam S - The declaration's shape type, which types the published artifacts\n *\n * @example\n * ```ts\n * const compiler = new ContractCompiler({ category: 'string', min: 1 })\n * compiler.guard('Ada') // true\n * compiler.guard === compiler.guard // true — every getter replays its exact root\n * ```\n */\nexport class ContractCompiler<\n\tS extends ContractShape = ContractShape,\n> implements ContractCompilerInterface<S> {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. The\n\t// node index is built and released outside every containment this class has,\n\t// so a replaced `globalThis.WeakMap` would throw a caller value out of a door\n\t// documented to publish a `ContractError`.\n\tstatic readonly #weakMap = WeakMap\n\t// The released state, shared by every compiler this class ever builds.\n\t// `#release` assigns these in place of the working collections, so an instance\n\t// allocates one collection per family instead of two and construction carries\n\t// no empty peer of its own. Sharing them is safe because nothing MUTATES a\n\t// released collection: every element write — `#discover`, `#schedule`, and the\n\t// family loops — runs behind `#prepare`, which refuses after `#release`\n\t// clears `#source`; the constructor and `#release` assign the field and never\n\t// touch a sentinel's elements. The static block beneath freezes them, so a\n\t// write that did reach one fails at its own line rather than leaking a node of\n\t// one compiler's graph into every other compiler's release — under the same\n\t// qualification `#weakMap` carries earlier: `INTRINSICS.freeze` is captured\n\t// while this module evaluates, so a consumer module ordered before\n\t// `constants.ts` defeats it, and that limit is stated there rather than\n\t// defended.\n\tstatic readonly #emptyStack: Array<\n\t\t| { readonly operation: 'enter'; readonly shape: ContractShape }\n\t\t| { readonly operation: 'exit'; readonly index: number }\n\t> = []\n\tstatic readonly #emptyNodes: ContractShape[] = []\n\tstatic readonly #emptyOrder: number[] = []\n\tstatic readonly #emptySchemas: JSONSchema[] = []\n\tstatic readonly #emptyGuards: Array<Guard<unknown>> = []\n\tstatic readonly #emptyParsers: Array<Parser<unknown>> = []\n\tstatic readonly #emptyAudits: Array<\n\t\t(value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t> = []\n\tstatic readonly #emptyReports: Array<\n\t\t(value: unknown, path: readonly string[]) => readonly Fault[]\n\t> = []\n\tstatic readonly #emptySeeds: Array<(random: RandomFunction) => unknown> = []\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peers and\n\t\t// stop them satisfying the mutable working fields they are assigned to.\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyStack)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyNodes)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyOrder)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptySchemas)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyGuards)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyParsers)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyAudits)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyReports)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptySeeds)\n\t}\n\n\t#source: ContractShape | undefined\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'failed'; readonly error: ContractError }\n\t#stack: Array<\n\t\t| { readonly operation: 'enter'; readonly shape: ContractShape }\n\t\t| { readonly operation: 'exit'; readonly index: number }\n\t>\n\t// The prepared index. `#nodes[0]` is the owned root by construction, `#index`\n\t// answers \"which node is this child\" by identity, and `#order` lists every\n\t// node with its children already listed before it — so a family solves any\n\t// bottom-up fact by reading it forwards once. The index is the one working\n\t// field with no shared peer: `Object.freeze` reaches an array's writes and not\n\t// a `WeakMap`'s, so a shared empty map would be a class-lifetime cache that\n\t// any write could fill with the caller's own shapes. Release drops the map\n\t// instead, and absence is `undefined`.\n\t#nodes: ContractShape[]\n\t#index: WeakMap<ContractShape, number> | undefined\n\t#order: number[]\n\t// One plan per family, each indexed by the same node index. A plan entry is a\n\t// self-contained artifact for that node: it closes over the CHILD entries it\n\t// needs, resolved while the family is built, so nothing a compiled artifact\n\t// does at call time reaches back into the index this class later releases.\n\t#schemas: JSONSchema[]\n\t#guards: Array<Guard<unknown>>\n\t#parsers: Array<Parser<unknown>>\n\t#audits: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]>\n\t#reports: Array<(value: unknown, path: readonly string[]) => readonly Fault[]>\n\t#seeds: Array<(random: RandomFunction) => unknown>\n\t#schema: JSONSchema | undefined\n\t#guard: Guard<unknown> | undefined\n\t#parser: Parser<unknown> | undefined\n\t#auditor: AuditorFunction | undefined\n\t#reporter: ReporterFunction | undefined\n\t#generator: SeederFunction<unknown> | undefined\n\t#bundle: ContractInterface<unknown> | undefined\n\n\t/**\n\t * Retains a shape declaration without observing it.\n\t *\n\t * @param shape - The live declaration the first getter read will own\n\t */\n\tconstructor(shape: S) {\n\t\tthis.#source = shape\n\t\tthis.#state = { phase: 'ready' }\n\t\tthis.#stack = []\n\t\tthis.#nodes = []\n\t\tthis.#index = new ContractCompiler.#weakMap()\n\t\tthis.#order = []\n\t\tthis.#schemas = []\n\t\tthis.#guards = []\n\t\tthis.#parsers = []\n\t\tthis.#audits = []\n\t\tthis.#reports = []\n\t\tthis.#seeds = []\n\t\tthis.#schema = undefined\n\t\tthis.#guard = undefined\n\t\tthis.#parser = undefined\n\t\tthis.#auditor = undefined\n\t\tthis.#reporter = undefined\n\t\tthis.#generator = undefined\n\t\tthis.#bundle = undefined\n\t}\n\n\t/**\n\t * Returns the emitted JSON Schema for the owned declaration.\n\t *\n\t * @remarks\n\t * A deeply frozen graph that preserves shared declaration identity: two\n\t * property slots holding the same authored node hold the same emitted\n\t * subschema, while structurally equal distinct nodes stay distinct objects.\n\t */\n\tget schema(): JSONSchema {\n\t\tconst ready = this.#schema\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildSchema())\n\t}\n\n\t/** Returns the compiled strict guard for the owned declaration. */\n\tget guard(): Guard<Infer<S>> {\n\t\tconst ready = this.#guard\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildGuard()))\n\t}\n\n\t/** Returns the compiled coercive parser for the owned declaration. */\n\tget parser(): Parser<Infer<S>> {\n\t\tconst ready = this.#parser\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildParser()))\n\t}\n\n\t/** Returns the compiled strict-domain diagnostic for the owned declaration. */\n\tget auditor(): AuditorFunction {\n\t\tconst ready = this.#auditor\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildAuditor())\n\t}\n\n\t/** Returns the compiled coercive-domain diagnostic for the owned declaration. */\n\tget reporter(): ReporterFunction {\n\t\tconst ready = this.#reporter\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildReporter())\n\t}\n\n\t/** Returns the compiled seed-data source for the owned declaration. */\n\tget generator(): SeederFunction<Infer<S>> {\n\t\tconst ready = this.#generator\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildGenerator()))\n\t}\n\n\t/**\n\t * Returns the frozen bundle of this compiler's artifacts.\n\t *\n\t * @remarks\n\t * Own enumerable keys `schema`, `is`, `parse`, `audit`, `explain`,\n\t * `generate`, in that order, each holding the exact value the corresponding\n\t * getter publishes.\n\t */\n\tget contract(): ContractInterface<Infer<S>> {\n\t\tconst ready = this.#bundle\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildContract()))\n\t}\n\n\t// The one typed boundary in this class. Every family is compiled over the\n\t// OWNED graph, whose static type is the widened `ContractShape` union, while\n\t// the compiler publishes artifacts under the inferred type of the declaration\n\t// it was constructed from. The standalone `compile*` functions make the\n\t// identical claim through their own overload pairs; declaring it once here is\n\t// that same statement rather than an extra one, and it is the reason no\n\t// assertion appears anywhere in this file.\n\t#publish(root: Guard<unknown>): Guard<Infer<S>>\n\t#publish(root: Parser<unknown>): Parser<Infer<S>>\n\t#publish(root: SeederFunction<unknown>): SeederFunction<Infer<S>>\n\t#publish(root: ContractInterface<unknown>): ContractInterface<Infer<S>>\n\t#publish(root: unknown): unknown {\n\t\treturn root\n\t}\n\n\t// Lifecycle. Every getter runs its build inside this, so preparation and every\n\t// family share one terminal state.\n\t#enter<T>(build: () => T): T {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'failed') throw state.error\n\t\tif (state.phase === 'running' || state.phase === 'interrupted') {\n\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\tthrow state.poison\n\t\t}\n\t\t// Created BEFORE the source is observed, for the same reason the cloners\n\t\t// create theirs there: a poison built on the settlement path would be built\n\t\t// under whatever the caller installed while the build was running.\n\t\tconst poison = new ContractError(\n\t\t\t'ContractCompiler: contract compilation may not be reentered',\n\t\t\t{ code: 'structure', context: { path: [], shape: 'contract' } },\n\t\t)\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#leave(attempt(build))\n\t}\n\n\t#leave<T>(outcome: Result<T>): T {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') return this.#fail(state.poison)\n\t\tif (isFailure(outcome)) {\n\t\t\treturn this.#fail(\n\t\t\t\tisContractError(outcome.error)\n\t\t\t\t\t? outcome.error\n\t\t\t\t\t: new ContractError('ContractCompiler: contract compilation failed', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t\t\t\t\tcause: outcome.error,\n\t\t\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tthis.#state = { phase: 'ready' }\n\t\tthis.#collect()\n\t\treturn outcome.value\n\t}\n\n\t#fail(error: ContractError): never {\n\t\tthis.#state = { phase: 'failed', error }\n\t\tthis.#release()\n\t\tthrow error\n\t}\n\n\t// Once every root exists nothing can need the graph again, so the graph, the\n\t// index, the order and every family plan go. The roots and the optional\n\t// frozen bundle stay, and so does terminal state.\n\t#collect(): void {\n\t\tif (this.#schema === undefined || this.#guard === undefined) return\n\t\tif (this.#parser === undefined || this.#auditor === undefined) return\n\t\tif (this.#reporter === undefined || this.#generator === undefined) return\n\t\tthis.#release()\n\t}\n\n\t// Assignment only: every working collection takes the class's shared frozen\n\t// empty peer and the index is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection at\n\t// all, so release cannot be redirected into leaving state behind.\n\t#release(): void {\n\t\tthis.#source = undefined\n\t\tthis.#stack = ContractCompiler.#emptyStack\n\t\tthis.#nodes = ContractCompiler.#emptyNodes\n\t\tthis.#index = undefined\n\t\tthis.#order = ContractCompiler.#emptyOrder\n\t\tthis.#schemas = ContractCompiler.#emptySchemas\n\t\tthis.#guards = ContractCompiler.#emptyGuards\n\t\tthis.#parsers = ContractCompiler.#emptyParsers\n\t\tthis.#audits = ContractCompiler.#emptyAudits\n\t\tthis.#reports = ContractCompiler.#emptyReports\n\t\tthis.#seeds = ContractCompiler.#emptySeeds\n\t}\n\n\t// === Preparation\n\n\t#prepare(): void {\n\t\tif (this.#nodes.length > 0) return\n\t\tconst source = this.#source\n\t\tif (source === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the retained declaration is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\t// A node a builder sealed is already frozen and validated all the way down, so\n\t\t// it is owned as it stands and only the emitted-node bound is left to ask.\n\t\tconst sealed = ShapePass.expansionOf(source)\n\t\tif (sealed !== undefined) {\n\t\t\trefuseExpansion(sealed)\n\t\t\tthis.#discover(source)\n\t\t\tthis.#source = undefined\n\t\t\treturn\n\t\t}\n\t\t// ONE ownership population for the whole compiler. `ownShape` runs the\n\t\t// accepted `ShapeCloner`, whose completed-root pass validates what it built;\n\t\t// the pass below is this compiler's own single validation of that owned\n\t\t// result, and it is where the emitted-node bound is applied — the gate that\n\t\t// owns that rule authors its diagnosis, so the refusal reads identically\n\t\t// however the caller arrived.\n\t\tconst owned = ownShape(source)\n\t\t// Ownership has already bounded capture. This existing validation checks\n\t\t// that bounded graph without opening a second capture budget for this call.\n\t\trefuseExpansion(new ShapePass(owned).validate())\n\t\tthis.#discover(owned)\n\t\tthis.#source = undefined\n\t}\n\n\t#discover(root: ContractShape): void {\n\t\t// Narrowed once at the door, because both dispatches below take their\n\t\t// receiver type from this value. `#prepare` is the only caller and it\n\t\t// refuses while the declaration is gone, so the walk always finds the map\n\t\t// the constructor built; this refusal is what keeps that a statement the\n\t\t// types carry rather than one a comment makes.\n\t\tconst known = this.#index\n\t\tif (known === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the prepared index is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: root }\n\t\twhile (this.#stack.length > 0) {\n\t\t\t// Popped by index and truncated by `length`, never through\n\t\t\t// `Array.prototype.pop`: that member is caller-writable and this walk runs\n\t\t\t// after the two contained engines have finished, so a redirect here would\n\t\t\t// be the one dispatch in this class with nothing between it and the\n\t\t\t// caller. Indexed reads and a `length` assignment on an array this class\n\t\t\t// built reach no member at all.\n\t\t\tconst top = this.#stack.length - 1\n\t\t\tconst frame = this.#stack[top]\n\t\t\tthis.#stack.length = top\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tthis.#order[this.#order.length] = frame.index\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst shape = frame.shape\n\t\t\t// A node reached a second time is already indexed, and the graph is\n\t\t\t// acyclic by validation, so it is already finished too — which is exactly\n\t\t\t// what makes one entry per unique node correct rather than merely cheap.\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, known, [shape]) !== undefined) continue\n\t\t\tconst index = this.#nodes.length\n\t\t\t// `Object.prototype` can gain a field a node leaves out at any time after this\n\t\t\t// call, and a family or a report plan reading the node would answer from it, so\n\t\t\t// they read an own copy that cannot inherit.\n\t\t\tconst node: ContractShape = INTRINSICS.rebase({ ...shape }, null)\n\t\t\tthis.#nodes[index] = node\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, known, [node, index])\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, known, [shape, index])\n\t\t\tthis.#stack[this.#stack.length] = { operation: 'exit', index }\n\t\t\tthis.#schedule(shape)\n\t\t}\n\t}\n\n\t// Children are pushed in REVERSE slot order so the walk discovers them in\n\t// declaration order, which keeps node indices deterministic for one graph.\n\t#schedule(shape: ContractShape): void {\n\t\tswitch (shape.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: shape.items }\n\t\t\t\treturn\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: shape.inner }\n\t\t\t\treturn\n\t\t\tcase 'union': {\n\t\t\t\tfor (const offset of iterateIndices(() => shape.variants.length)) {\n\t\t\t\t\tconst index = shape.variants.length - 1 - offset\n\t\t\t\t\tconst variant = shape.variants[index]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: variant }\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: extra }\n\t\t\t\t}\n\t\t\t\tconst keys = INTRINSICS.keys(shape.properties)\n\t\t\t\tfor (const offset of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst index = keys.length - 1 - offset\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = shape.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: child }\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t}\n\t}\n\n\t#locate(shape: ContractShape): number {\n\t\t// The receiver is narrowed BEFORE the dispatch. `INTRINSICS.reflect.apply` takes its\n\t\t// receiver type from this argument rather than from the target, so a dropped\n\t\t// index would leave `WeakMap.prototype.get` throwing a host `TypeError`\n\t\t// through a door whose whole contract is that it publishes this package's\n\t\t// error class. Defense in depth, not a live path: a released compiler holds\n\t\t// every root, so every family returns its ready root before locating\n\t\t// anything, and a failed one rethrows at `#enter` — which is why no\n\t\t// reachable vector settles here and the guard still belongs.\n\t\tconst known = this.#index\n\t\tif (known === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the prepared index is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\tconst index = INTRINSICS.reflect.apply(INTRINSICS.recall, known, [shape])\n\t\tif (index === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a structural child is not in the prepared index', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn index\n\t}\n\n\t#node(index: number): ContractShape {\n\t\tconst shape = this.#nodes[index]\n\t\tif (shape === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a prepared node is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn shape\n\t}\n\n\t// A union's membership answer is its compiled guard in the parser, the\n\t// reporter and the generator alike, so those three build the guard plan when —\n\t// and only when — the graph actually holds one.\n\t#unions(): boolean {\n\t\tfor (const index of iterateIndices(() => this.#nodes.length)) {\n\t\t\tif (this.#nodes[index]?.category === 'union') return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// A default is judged by the guard of the shape it fills, and a declaration that\n\t// refuses has to refuse at whichever artifact is read first, so every family builds\n\t// the guard plan when — and only when — the graph holds a default.\n\t#defaults(): boolean {\n\t\tfor (const index of iterateIndices(() => this.#nodes.length)) {\n\t\t\tconst node = this.#nodes[index]\n\t\t\tif (node?.category === 'optional' && INTRINSICS.own(node, 'default')) return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// Walks the declaration rather than the node list, because the path a refusal names\n\t// exists only on the way down. Validation bounded the tree this expands into, and\n\t// `#buildGuard` runs this once, on a graph that holds a default.\n\t#checkDefaults(shape: ContractShape, path: readonly string[]): void {\n\t\tswitch (shape.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#checkDefaults(shape.items, pathOf(path, 'items'))\n\t\t\t\treturn\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#checkDefaults(shape.inner, pathOf(path, 'inner'))\n\t\t\t\treturn\n\t\t\tcase 'optional': {\n\t\t\t\tthis.#checkDefaults(shape.inner, pathOf(path, 'inner'))\n\t\t\t\tif (!INTRINSICS.own(shape, 'default') || this.#guardAt(shape.inner)(shape.default)) return\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'ContractCompiler: a default must satisfy the shape it fills; change the default or the shape',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tpath: pathOf(path, 'default'),\n\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\treceived: preview(shape.default),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'union':\n\t\t\t\tfor (const index of iterateIndices(() => shape.variants.length)) {\n\t\t\t\t\tconst variant = shape.variants[index]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tthis.#checkDefaults(variant, pathOf(path, 'variants', INTRINSICS.text(index)))\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\tcase 'object': {\n\t\t\t\tconst keys = INTRINSICS.keys(shape.properties)\n\t\t\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tconst child = key === undefined ? undefined : shape.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tthis.#checkDefaults(child, pathOf(path, 'properties', key))\n\t\t\t\t}\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#checkDefaults(extra, pathOf(path, 'additionalProperties'))\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t}\n\t}\n\n\t// Each root evaluation owns the answers for its active synchronous walk.\n\t// Shared objects reuse one answer per compiled node; the scope is removed\n\t// in finally so later calls always observe the caller's current value.\n\n\t// Only a node that descends into a child artifact can be reached twice through\n\t// one value; a leaf answers about the value in front of it, so tracking one\n\t// would buy nothing and would replace the package's own guards and parsers in\n\t// the artifacts a leaf-rooted declaration publishes.\n\t#repeats(index: number): boolean {\n\t\tconst category = this.#node(index).category\n\t\tif (category === 'array' || category === 'object' || category === 'union') return true\n\t\treturn category === 'optional' || category === 'nullable'\n\t}\n\n\t#trackGuard(plan: Guard<unknown>): Guard<unknown> {\n\t\treturn (value: unknown): value is unknown => EvaluationScope.run(plan, value)\n\t}\n\n\t// The diagnostic families reuse only the CLEAN verdict, because a fault\n\t// carries the path it was found at while emptiness carries nothing: a node\n\t// that reported no fault about an object reports none about it wherever else\n\t// the walk arrives. A faulted node is re-walked at its new path, and stays\n\t// bounded by `FAULT_LIMIT` — every collector stops once the cap is reached, so\n\t// a value that faults everywhere saturates instead of expanding.\n\t#trackFaults<T>(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly T[],\n\t): (value: unknown, path: readonly string[]) => readonly T[] {\n\t\treturn (value, path) => EvaluationScope.run(plan, value, path, true)\n\t}\n\n\t// What tells a union's arms apart, when anything does: a property every arm is an\n\t// object declaring as a required literal. A value names an arm when its own data\n\t// property exactly equals a literal only that arm holds, which is the membership the\n\t// literal guard asks, so no other arm's guard could accept that value and the named\n\t// arm answers for the whole union. A key whose literal two arms share names nothing,\n\t// so the next such key is asked. The answer closes over no part of this compiler.\n\t#discriminate(owned: UnionShape):\n\t\t| {\n\t\t\t\treadonly select: (value: unknown) => number | undefined\n\t\t\t\treadonly hint: { readonly key: string; readonly expected: readonly LiteralValue[] }\n\t\t }\n\t\t| undefined {\n\t\tconst arms: readonly ObjectShape[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(owned.variants),\n\t\t\t[(variant: ContractShape | undefined) => variant?.category === 'object'],\n\t\t)\n\t\tconst first = arms[0]\n\t\tif (first === undefined || arms.length !== owned.variants.length) return undefined\n\t\tconst keys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(INTRINSICS.keys(first.properties)),\n\t\t\t[\n\t\t\t\t(key: string) =>\n\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, arms, [\n\t\t\t\t\t\t(arm: ObjectShape) =>\n\t\t\t\t\t\t\t!INTRINSICS.own(arm.properties, key) || arm.properties[key]?.category !== 'literal',\n\t\t\t\t\t]),\n\t\t\t],\n\t\t)\n\t\tconst tables: ReadonlyArray<{\n\t\t\treadonly key: string\n\t\t\treadonly members: Map<unknown, number>\n\t\t\treadonly expected: readonly LiteralValue[]\n\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keys), [\n\t\t\t(key: string) => ContractCompiler.#tableOf(key, arms),\n\t\t])\n\t\tconst named = tables[0]\n\t\tif (named === undefined) return undefined\n\t\treturn {\n\t\t\thint: INTRINSICS.freeze({ key: named.key, expected: named.expected }),\n\t\t\tselect: (value: unknown): number | undefined => {\n\t\t\t\tif (!isObject(value)) return undefined\n\t\t\t\tfor (const index of iterateIndices(() => tables.length)) {\n\t\t\t\t\tconst table = tables[index]\n\t\t\t\t\tif (table === undefined) continue\n\t\t\t\t\tconst held = attempt(() => INTRINSICS.describe(value, table.key))\n\t\t\t\t\tif (isFailure(held) || held.value === undefined) continue\n\t\t\t\t\tif (!INTRINSICS.own(held.value, 'value')) continue\n\t\t\t\t\tconst arm = INTRINSICS.reflect.apply(INTRINSICS.fetch, table.members, [held.value.value])\n\t\t\t\t\tif (arm !== undefined && arm >= 0) return arm\n\t\t\t\t}\n\t\t\t\treturn undefined\n\t\t\t},\n\t\t}\n\t}\n\n\t// One key's literals, each with the arm that alone holds it, or -1 when two arms do.\n\tstatic #tableOf(\n\t\tkey: string,\n\t\tarms: readonly ObjectShape[],\n\t): {\n\t\treadonly key: string\n\t\treadonly members: Map<unknown, number>\n\t\treadonly expected: readonly LiteralValue[]\n\t} {\n\t\tconst members = new INTRINSICS.map<unknown, number>()\n\t\tconst expected: LiteralValue[] = []\n\t\tfor (const armIndex of iterateIndices(() => arms.length)) {\n\t\t\tconst node = arms[armIndex]?.properties[key]\n\t\t\tif (node?.category !== 'literal') continue\n\t\t\tfor (const valueIndex of iterateIndices(() => node.values.length)) {\n\t\t\t\tconst literal = node.values[valueIndex]\n\t\t\t\tif (literal === undefined) continue\n\t\t\t\tconst known = INTRINSICS.reflect.apply(INTRINSICS.fetch, members, [literal])\n\t\t\t\tif (known === undefined) expected[expected.length] = literal\n\t\t\t\tconst arm = known === undefined || known === armIndex ? armIndex : -1\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.store, members, [literal, arm])\n\t\t\t}\n\t\t}\n\t\treturn { key, members, expected: INTRINSICS.freeze(expected) }\n\t}\n\n\t// The union parser's own two steps, over the named arm alone. A value that arm accepts\n\t// returns by identity, and a coercion must satisfy the arm's guard.\n\tstatic #parseArm(\n\t\tarm: { readonly parse: Parser<unknown>; readonly guard: Guard<unknown> },\n\t\tvalue: unknown,\n\t): unknown {\n\t\tif (arm.guard(value)) return value\n\t\tconst parsed = arm.parse(value)\n\t\treturn parsed !== undefined && arm.guard(parsed) ? parsed : undefined\n\t}\n\n\t// === Schema family\n\n\t#buildSchema(): JSONSchema {\n\t\tconst ready = this.#schema\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#schemas[index] = this.#schemaOf(index)\n\t\t}\n\t\tconst root = this.#schemaAt(this.#node(0))\n\t\tthis.#schema = root\n\t\treturn root\n\t}\n\n\t#schemaAt(shape: ContractShape): JSONSchema {\n\t\tconst emitted = this.#schemas[this.#locate(shape)]\n\t\tif (emitted === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child schema is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn emitted\n\t}\n\n\t#schemaOf(index: number): JSONSchema {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'shape':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\towned.description ??\n\t\t\t\t\t\t'Over-approximates declarations whose JSON projection preserves their own enumerable data; values without that projection are outside this schema. is decides whether the complete shape is valid.',\n\t\t\t\t\tproperties: INTRINSICS.freeze({\n\t\t\t\t\t\tcategory: INTRINSICS.freeze({ enum: INTRINSICS.freeze(INTRINSICS.keys(SHAPE_FIELDS)) }),\n\t\t\t\t\t}),\n\t\t\t\t\trequired: INTRINSICS.freeze(['category']),\n\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t})\n\t\t\tcase 'string': {\n\t\t\t\t// The pattern text is read through the CAPTURED `source` getter. It is an\n\t\t\t\t// accessor on a shared prototype, so a replaced getter chose the\n\t\t\t\t// `pattern` keyword inside a frozen schema this door publishes as exact —\n\t\t\t\t// and a schema that quietly dropped the keyword instead would be the same\n\t\t\t\t// lie with a smaller footprint, so an unreadable source refuses.\n\t\t\t\tconst text = owned.pattern === undefined ? undefined : readPatternSource(owned.pattern)\n\t\t\t\tif (owned.pattern !== undefined && text === undefined) {\n\t\t\t\t\tthrow new ContractError('compileSchema: pattern source could not be read', {\n\t\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\t\tcontext: { shape: 'string' },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\t...(owned.min !== undefined ? { minLength: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maxLength: owned.max } : {}),\n\t\t\t\t\t...(text !== undefined ? { pattern: text } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'number':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: owned.integer === true ? 'integer' : 'number',\n\t\t\t\t\t...(owned.min !== undefined ? { minimum: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maximum: owned.max } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'boolean':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'null':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'null',\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'json':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'literal': {\n\t\t\t\t// Indexed, not spread: this list is published inside the emitted schema,\n\t\t\t\t// and an array spread retrieves `Array.prototype[Symbol.iterator]` at the\n\t\t\t\t// moment of use, so a caller could add a member to a vocabulary this\n\t\t\t\t// package documents as exactly the shape's own.\n\t\t\t\tconst vocabulary: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(owned.values),\n\t\t\t\t\t[(value: LiteralValue | undefined) => value !== undefined],\n\t\t\t\t)\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\tenum: INTRINSICS.freeze(vocabulary),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'array':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\titems: this.#schemaAt(owned.items),\n\t\t\t\t\t...(owned.min !== undefined ? { minItems: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maxItems: owned.max } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'object': {\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly schema: JSONSchema\n\t\t\t\t\treadonly required: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(owned.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tschema: this.#schemaAt(child),\n\t\t\t\t\t\t\t\t\trequired: child.category !== 'optional',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t(entry: (typeof entries)[number]) => [entry.key, entry.schema],\n\t\t\t\t])\n\t\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => (entry.required ? [entry.key] : [])],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst additionalProperties: boolean | JSONSchema =\n\t\t\t\t\textra === true\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: extra !== undefined && extra !== false\n\t\t\t\t\t\t\t? this.#schemaAt(extra)\n\t\t\t\t\t\t\t: false\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\t...(INTRINSICS.keys(properties).length > 0\n\t\t\t\t\t\t? { properties: INTRINSICS.freeze(properties) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(required.length > 0 ? { required: INTRINSICS.freeze(required) } : {}),\n\t\t\t\t\tadditionalProperties,\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\t// Indexed, not `map`: this array IS the published schema, and\n\t\t\t\t// `Array.prototype.map = () => ['INJECTED']` made `compileSchema` answer\n\t\t\t\t// `{\"anyOf\":[\"INJECTED\"]}` — a success, with the caller's content inside\n\t\t\t\t// the package's own output.\n\t\t\t\tconst variants: JSONSchema[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#schemaAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\t...(owned.mode === 'oneOf'\n\t\t\t\t\t\t? { oneOf: INTRINSICS.freeze(variants) }\n\t\t\t\t\t\t: { anyOf: INTRINSICS.freeze(variants) }),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst emitted = this.#schemaAt(owned.inner)\n\t\t\t\tconst value = owned.default\n\t\t\t\treturn value === undefined ? emitted : INTRINSICS.freeze({ ...emitted, default: value })\n\t\t\t}\n\t\t\tcase 'nullable':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\tanyOf: INTRINSICS.freeze([\n\t\t\t\t\t\tthis.#schemaAt(owned.inner),\n\t\t\t\t\t\tINTRINSICS.freeze({ type: 'null' }),\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\tcase 'raw':\n\t\t\t\treturn cloneSchema(owned.schema)\n\t\t}\n\t}\n\n\t// === Guard family\n\n\t#buildGuard(): Guard<unknown> {\n\t\tconst ready = this.#guard\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#guardOf(index)\n\t\t\tthis.#guards[index] = this.#repeats(index) ? this.#trackGuard(plan) : plan\n\t\t}\n\t\tconst root = this.#guardAt(this.#node(0))\n\t\tif (this.#defaults()) this.#checkDefaults(this.#node(0), [])\n\t\tthis.#guard = root\n\t\treturn root\n\t}\n\n\t#guardAt(shape: ContractShape): Guard<unknown> {\n\t\tconst compiled = this.#guards[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child guard is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t// `stringOf` returns bare `isString` when unrefined, else composes the length-bounds\n\t// + pattern refinement — the same guard the parser re-applies. It reads its options\n\t// through the prototype chain and a family may build after `Object.prototype` gained\n\t// a field these leave out, so they carry no prototype.\n\t#stringGuard(owned: StringShape): Guard<string> {\n\t\treturn stringOf(\n\t\t\tINTRINSICS.rebase(\n\t\t\t\t{\n\t\t\t\t\t...(owned.min === undefined ? {} : { min: owned.min }),\n\t\t\t\t\t...(owned.max === undefined ? {} : { max: owned.max }),\n\t\t\t\t\t...(owned.pattern === undefined ? {} : { pattern: owned.pattern }),\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t),\n\t\t)\n\t}\n\n\tstatic #acceptShape(value: unknown): boolean {\n\t\treturn isSuccess(\n\t\t\tattempt(() => {\n\t\t\t\tconst validator = new ShapeValidator(value)\n\t\t\t\tvalidator.validate()\n\t\t\t\trefuseExpansion(validator.expansion)\n\t\t\t}),\n\t\t)\n\t}\n\n\t#guardOf(index: number): Guard<unknown> {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string':\n\t\t\t\treturn this.#stringGuard(owned)\n\t\t\tcase 'number': {\n\t\t\t\tconst base = owned.integer === true ? isInteger : isFiniteNumber\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\t// `boundsOf` already refines `isFiniteNumber`; intersect with `isInteger`\n\t\t\t\t// when the leaf is an integer so both the integrality and the bounds hold.\n\t\t\t\treturn owned.integer === true\n\t\t\t\t\t? intersectionOf(isInteger, boundsOf(owned.min, owned.max))\n\t\t\t\t\t: boundsOf(owned.min, owned.max)\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn isBoolean\n\t\t\tcase 'null':\n\t\t\t\treturn isNull\n\t\t\tcase 'json':\n\t\t\t\treturn isJSONValue\n\t\t\tcase 'shape':\n\t\t\t\treturn (value): value is ContractShape => ContractCompiler.#acceptShape(value)\n\t\t\tcase 'literal':\n\t\t\t\t// `literalOf` IS the package's literal match (SameValueZero over an owned\n\t\t\t\t// `Set`); the array form takes a machine-generated vocabulary no spread\n\t\t\t\t// could carry.\n\t\t\t\treturn literalOf(owned.values)\n\t\t\tcase 'array': {\n\t\t\t\tconst base = arrayOf(this.#guardAt(owned.items))\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\tconst withinLength = boundsOf(owned.min, owned.max)\n\t\t\t\treturn whereOf(base, (value) => withinLength(value.length))\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t\t\t// prototype — the same pattern `pickOf` uses (combinators.ts).\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(owned.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\t\treturn [{ key, guard: this.#guardAt(optional ? child.inner : child), optional }]\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t(entry: (typeof entries)[number]) => [entry.key, entry.guard],\n\t\t\t\t])\n\t\t\t\tconst map = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<Guard<unknown>>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst optionalKeys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => (entry.optional ? [entry.key] : [])],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst closed = extra === undefined || extra === false\n\t\t\t\tconst additional = closed || extra === true ? undefined : this.#guardAt(extra)\n\t\t\t\t// Indexed, not `filter`/`includes`: both are caller-writable members of\n\t\t\t\t// `Array.prototype` reached by name, one line above a boundary whose own\n\t\t\t\t// comment promises this walk never throws.\n\t\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(map)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) =>\n\t\t\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, optionalKeys, [\n\t\t\t\t\t\t\t\t(optional: string) => optional === key,\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\t// The required keys are fixed here, so their presence question is\n\t\t\t\t// answered by one integer rather than by a per-call vocabulary: each\n\t\t\t\t// required key takes a bit position here, and a call ORs one bit per own\n\t\t\t\t// key it recognizes and compares the result against the full mask. The\n\t\t\t\t// record is null-prototype own data so a key literally named\n\t\t\t\t// '__proto__' takes a position like any other. Past the mask's width\n\t\t\t\t// the collected-vocabulary form below still answers.\n\t\t\t\tconst maskable = required.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(maskable ? required : [])\n\t\t\t\tconst full = maskable ? readPresence(required, positions) : 0\n\t\t\t\treturn (value: unknown): value is unknown => {\n\t\t\t\t\tif (!isRecord(value)) return false\n\t\t\t\t\tconst keys = enumerableKeys(value)\n\t\t\t\t\tif (keys === undefined) return false\n\t\t\t\t\t// Contain the whole key-enumeration + value-read walk — a hostile\n\t\t\t\t\t// getter on `value`, or a replaced `globalThis.Set` reached by the\n\t\t\t\t\t// presence view, must yield `false`, never throw, as\n\t\t\t\t\t// `.claude/rules/patterns.md` § Validation and contracts requires.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tif (maskable) {\n\t\t\t\t\t\t\tconst seen = readPresence(keys, positions)\n\t\t\t\t\t\t\tif (seen !== full) return false\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst present = collectMembers(keys)\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => required.length)) {\n\t\t\t\t\t\t\t\tconst key = required[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (!matchesMember(present, key)) return false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tconst guard = INTRINSICS.own(map, key) ? map[key] : undefined\n\t\t\t\t\t\t\tif (guard !== undefined) {\n\t\t\t\t\t\t\t\tif (!guard(value[key])) return false\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (closed) return false\n\t\t\t\t\t\t\t// An open object declares an undeclared key UNCONSTRAINED, not\n\t\t\t\t\t\t\t// UNOBSERVED. The compiled parser copies every one of them into\n\t\t\t\t\t\t\t// its result, so a guard that skipped the read certified a value\n\t\t\t\t\t\t\t// its own parser then refused as unreadable — `is` true, `audit`\n\t\t\t\t\t\t\t// and `explain` empty, `parse` throwing, on one input. The read is\n\t\t\t\t\t\t\t// the advertised read of the open-object domain; its RESULT is\n\t\t\t\t\t\t\t// only tested when a tail shape constrains it.\n\t\t\t\t\t\t\tconst observed: unknown = value[key]\n\t\t\t\t\t\t\tif (additional !== undefined && !additional(observed)) return false\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true\n\t\t\t\t\t})\n\t\t\t\t\treturn isSuccess(outcome) && outcome.value\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst guards: Array<Guard<unknown>> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#guardAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\t// A `oneOf`-mode union matches the emitted JSON Schema `oneOf` keyword —\n\t\t\t\t// EXACTLY one variant must guard-accept the value, not \"at least one\"\n\t\t\t\t// (unionOf's anyOf semantics). A value matching two-or-more variants is\n\t\t\t\t// rejected, since it would violate the compiled schema.\n\t\t\t\tif (owned.mode === 'oneOf') {\n\t\t\t\t\treturn (value: unknown): value is unknown => {\n\t\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, guards, [\n\t\t\t\t\t\t\t(total: number, guard: Guard<unknown>) => total + (guard(value) ? 1 : 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t])\n\t\t\t\t\t\treturn matched === 1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// `Reflect.apply` reads its argument list by index (CreateListFromArrayLike),\n\t\t\t\t// where `unionOf(...guards)` would spread through the array iterator.\n\t\t\t\treturn INTRINSICS.reflect.apply(unionOf, undefined, guards)\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\t\treturn orOf(isUndefined, this.#guardAt(owned.inner))\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableOf(this.#guardAt(owned.inner))\n\t\t\tcase 'raw':\n\t\t\t\treturn (value: unknown): value is unknown => value !== undefined\n\t\t}\n\t}\n\n\t// === Parser family\n\n\t#buildParser(): Parser<unknown> {\n\t\tconst ready = this.#parser\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#parsers[index] = this.#parserOf(index)\n\t\t}\n\t\tconst root = this.#parserAt(this.#node(0))\n\t\tthis.#parser = root\n\t\treturn root\n\t}\n\n\t#parserAt(shape: ContractShape): Parser<unknown> {\n\t\tconst compiled = this.#parsers[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child parser is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#parserOf(index: number): Parser<unknown> {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string': {\n\t\t\t\tif (owned.min === undefined && owned.max === undefined && owned.pattern === undefined) {\n\t\t\t\t\treturn parseString\n\t\t\t\t}\n\t\t\t\t// Coerce by type, then re-apply the SAME refinement the guard enforces (the\n\t\t\t\t// identical `stringOf`) — a value that parses but violates a bound or the\n\t\t\t\t// pattern fails the parse (returns `undefined`).\n\t\t\t\tconst guard = this.#stringGuard(owned)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst parsed = parseString(value)\n\t\t\t\t\treturn parsed !== undefined && guard(parsed) ? parsed : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst base = owned.integer === true ? parseInteger : parseNumber\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\t// The same bound check the guard applies (integrality is already enforced by\n\t\t\t\t// `parseInteger`, so only the bounds need re-checking after coercion).\n\t\t\t\tconst within = boundsOf(owned.min, owned.max)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst parsed = base(value)\n\t\t\t\t\treturn parsed !== undefined && within(parsed) ? parsed : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn parseBoolean\n\t\t\tcase 'null':\n\t\t\t\treturn (value) => (value === null ? null : undefined)\n\t\t\tcase 'json':\n\t\t\t\treturn parseJSONValue\n\t\t\tcase 'shape':\n\t\t\t\treturn (value) => (ContractCompiler.#acceptShape(value) ? value : undefined)\n\t\t\t// The literal parser trims a matching string but never numeric-coerces —\n\t\t\t// `'42'` never parses to the literal `42`; only an exact (post-trim) match\n\t\t\t// of one of the shape's `values` succeeds. This is an intended leniency,\n\t\t\t// not a soundness gap: a trimmed value is re-checked against `allowed`,\n\t\t\t// the same `literalOf` guard the compiled guard uses.\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tif (allowed(value)) return value\n\t\t\t\t\tif (isString(value)) {\n\t\t\t\t\t\tconst trimmed = value.trim()\n\t\t\t\t\t\tif (allowed(trimmed)) return trimmed\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst item = this.#parserAt(owned.items)\n\t\t\t\tconst unbounded = owned.min === undefined && owned.max === undefined\n\t\t\t\tconst withinLength = boundsOf(owned.min, owned.max)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.array(value), 'compileParser', {\n\t\t\t\t\t\t\tsubject: 'array',\n\t\t\t\t\t\t\tcontext: { shape: 'array' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isArray(value)) return undefined\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow entries.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileParser',\n\t\t\t\t\t\t\t{ subject: 'array', context: { shape: 'array' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!entries.value.dense) return undefined\n\t\t\t\t\tconst result: unknown[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\t// Indexed rather than iterated, and read in place: a hole and a\n\t\t\t\t\t\t// present `undefined` are the same observation to the item parser,\n\t\t\t\t\t\t// so neither is silently dropped from the assembled result.\n\t\t\t\t\t\tconst parsed = item(entries.value.entries[entryIndex])\n\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\tresult[result.length] = parsed\n\t\t\t\t\t}\n\t\t\t\t\t// Enforce the SAME length bounds the guard does (coercion never changes\n\t\t\t\t\t// length, so this is checked once on the assembled result).\n\t\t\t\t\treturn unbounded || withinLength(result.length) ? result : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\t// A closed object (no `additionalProperties`) silently drops unknown keys\n\t\t\t// present on the input rather than failing the parse — an intended\n\t\t\t// coercion leniency, and an observable one. The compiled guard rejects\n\t\t\t// such an input, so `parse` returning a value never implies `is` accepted\n\t\t\t// what it was handed: `parse({ id: 'a', debug: true })` answers\n\t\t\t// `{ id: 'a' }` for a shape whose `is` says false. The compiled reporter\n\t\t\t// mirrors this parser and reports nothing for a dropped key; the compiled\n\t\t\t// auditor is the artifact that reports it, one `'extra'` fault per\n\t\t\t// undeclared key.\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly fill: JSONValue | undefined\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tparse: this.#parserAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tfill: optional && INTRINSICS.own(child, 'default') ? child.default : undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst known = readValue(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcollectMembers(\n\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t'compileParser',\n\t\t\t\t\t{\n\t\t\t\t\t\tsubject: 'object',\n\t\t\t\t\t\tcontext: { shape: 'object' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t// One bit position per declared entry, assigned here because the entry\n\t\t\t\t// list is fixed here: a call then reads presence as a bit test instead\n\t\t\t\t// of a membership dispatch per entry. Null-prototype own data, so an\n\t\t\t\t// entry named '__proto__' takes a position like any other. Past the\n\t\t\t\t// mask's width the collected-vocabulary form still answers.\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst additional =\n\t\t\t\t\textra === undefined || extra === false || extra === true\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: this.#parserAt(extra)\n\t\t\t\tconst open = extra === true || additional !== undefined\n\t\t\t\treturn (value) => {\n\t\t\t\t\t// A brand check, not `parseRecord`: that door's eager whole-record\n\t\t\t\t\t// `Object.values` probe reads EVERY own enumerable value, including\n\t\t\t\t\t// undeclared keys this parser is about to DROP. A closed object shape\n\t\t\t\t\t// whose input carried one throwing extra therefore refused as\n\t\t\t\t\t// unreadable while `explain` — which never performs that probe —\n\t\t\t\t\t// published the empty report that means \"parse will succeed\". The\n\t\t\t\t\t// reads this parser genuinely needs are the per-key reads below, and\n\t\t\t\t\t// they are already contained.\n\t\t\t\t\tif (!isRecord(value)) return undefined\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = enumerableKeys(record)\n\t\t\t\t\tif (keys === undefined) return undefined\n\t\t\t\t\t// Contain the whole record walk — a hostile getter on `record`, or a\n\t\t\t\t\t// replaced `globalThis.Set` reached by the presence view, must yield\n\t\t\t\t\t// `undefined`, never throw, as `.claude/rules/patterns.md`\n\t\t\t\t\t// § Validation and contracts requires.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\t// Honest typing: a null-prototype accumulator so an input own key\n\t\t\t\t\t\t// literally named '__proto__' lands as an own data key instead of\n\t\t\t\t\t\t// mutating the prototype (same pattern as `pickOf`).\n\t\t\t\t\t\tconst selected: Array<readonly [string, unknown]> = []\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tconst raw = absent ? undefined : record[entry.key]\n\t\t\t\t\t\t\tif (raw === undefined) {\n\t\t\t\t\t\t\t\tif (!entry.optional) return undefined\n\t\t\t\t\t\t\t\t// A container parses from a fresh copy, so nested defaults apply and no\n\t\t\t\t\t\t\t\t// two results share a tree, whichever parser the inner shape holds.\n\t\t\t\t\t\t\t\tif (entry.fill !== undefined) {\n\t\t\t\t\t\t\t\t\tconst fill = isObject(entry.fill) ? cloneJSONValue(entry.fill) : entry.fill\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [entry.key, entry.parse(fill)]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst parsed = entry.parse(raw)\n\t\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\t\tselected[selected.length] = [entry.key, parsed]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (open) {\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (matchesMember(known, key)) continue\n\t\t\t\t\t\t\t\tif (additional === undefined) {\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [key, record[key]]\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst parsed = additional(record[key])\n\t\t\t\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [key, parsed]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn INTRINSICS.rebase(\n\t\t\t\t\t\t\tINTRINSICS.record<unknown>({\n\t\t\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\t\t\tselected,\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isSuccess(outcome)) return outcome.value\n\t\t\t\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'compileParser',\n\t\t\t\t\t\t{ subject: 'object', context: { shape: 'object' } },\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst variants: ReadonlyArray<{\n\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\tvariant === undefined\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tparse: this.#parserAt(variant),\n\t\t\t\t\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\t// `oneOf` exactly-one semantics (documented on `oneOfShape`): judged on\n\t\t\t\t// the RAW input's guard matches only — no coercion fallback. Exactly one\n\t\t\t\t// variant's guard must accept the raw value; preserve that value by\n\t\t\t\t// identity so rebuilding cannot change which variants accept it.\n\t\t\t\t// Zero matches (no variant fits) or two-or-more matches (ambiguous —\n\t\t\t\t// which variant the value belongs to isn't well-defined) both fail the\n\t\t\t\t// parse, deliberately simpler than attempting a coercion-then-recheck\n\t\t\t\t// resolution for ambiguous input.\n\t\t\t\tif (owned.mode === 'oneOf') {\n\t\t\t\t\treturn (value) => {\n\t\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\t\tconst arm = selected === undefined ? undefined : variants[selected]\n\t\t\t\t\t\tif (arm !== undefined) return ContractCompiler.#parseArm(arm, value)\n\t\t\t\t\t\t// Indexed, not `filter`: an array prototype method decides how many\n\t\t\t\t\t\t// variants matched, and a substitute answering a rigged list decides\n\t\t\t\t\t\t// what this parser publishes.\n\t\t\t\t\t\tconst matching: ReadonlyArray<{\n\t\t\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(variants), [\n\t\t\t\t\t\t\t(variant: { readonly guard: Guard<unknown> }) => variant.guard(value),\n\t\t\t\t\t\t])\n\t\t\t\t\t\tconst only = matching[0]\n\t\t\t\t\t\treturn matching.length === 1 && only !== undefined ? value : undefined\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : variants[selected]\n\t\t\t\t\tif (arm !== undefined) return ContractCompiler.#parseArm(arm, value)\n\t\t\t\t\t// Identity pass first, so guard-valid input is never rejected by its\n\t\t\t\t\t// parser (`.claude/rules/patterns.md` § Validation and contracts): a\n\t\t\t\t\t// value already valid against ANY variant's guard is returned\n\t\t\t\t\t// unchanged, so an earlier variant's coercion never overwrites it.\n\t\t\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\t\t\tconst variant = variants[variantIndex]\n\t\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\t\tif (variant.guard(value)) return value\n\t\t\t\t\t}\n\t\t\t\t\t// Coercion pass: no variant matched as-is, so parse-then-guard,\n\t\t\t\t\t// first variant that both parses and guards wins.\n\t\t\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\t\t\tconst variant = variants[variantIndex]\n\t\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\t\tconst parsed = variant.parse(value)\n\t\t\t\t\t\tif (parsed !== undefined && variant.guard(parsed)) return parsed\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#parserAt(owned.inner)\n\t\t\t\treturn (value) => (value === undefined ? undefined : inner(value))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#parserAt(owned.inner)\n\t\t\t\treturn (value) => (value === null ? null : inner(value))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value) => value\n\t\t}\n\t}\n\n\t// === Auditor family\n\n\t#buildAuditor(): AuditorFunction {\n\t\tconst ready = this.#auditor\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#auditOf(index)\n\t\t\tthis.#audits[index] = this.#repeats(index) ? this.#trackFaults(plan) : plan\n\t\t}\n\t\tconst root = this.#exposeAudit(this.#auditAt(this.#node(0)))\n\t\tthis.#auditor = root\n\t\treturn root\n\t}\n\n\t// The published root supplies the documented default root path and carries the\n\t// door boundary around the whole walk, so a host failure under a hostile value\n\t// publishes this package's error class rather than the caller's raw value.\n\t#exposeAudit(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly AuditFault[],\n\t): AuditorFunction {\n\t\treturn (value: unknown, path: readonly string[] = []): readonly AuditFault[] =>\n\t\t\tcontain(() => plan(value, path), 'compileAuditor')\n\t}\n\n\t#auditAt(\n\t\tshape: ContractShape,\n\t): (value: unknown, path: readonly string[]) => readonly AuditFault[] {\n\t\tconst compiled = this.#audits[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child auditor is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#auditOf(index: number): (value: unknown, path: readonly string[]) => readonly AuditFault[] {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\t// A leaf's refinement fields are fixed when its plan is built, exactly as\n\t\t\t// its `kind` is, so a declaration carrying none has no refinement report\n\t\t\t// to build at all: the only question such a leaf asks is the type test\n\t\t\t// above the gate, and its answer past that test is empty for every\n\t\t\t// accepted value. The helper stays the single source for every REFINED\n\t\t\t// leaf and is entered unchanged there — the gate decides whether the leaf\n\t\t\t// has a refinement question, never how one is answered. Each clean answer\n\t\t\t// is its own array, because a report's identity is the caller's.\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\n\t\t\t\t// The clone's `pattern` is an ACCESSOR that mints a fresh frozen\n\t\t\t\t// `RegExp` per read, so the plan reads it once and carries its\n\t\t\t\t// stateless rebuild into every answer instead of rebuilding one per\n\t\t\t\t// value. The rebuild is safe to share exactly because `readPattern`\n\t\t\t\t// strips `g` and `y`: it holds no `lastIndex` an answer could move.\n\t\t\t\t// `ownPattern` takes that read, and this door publishes only a\n\t\t\t\t// `ContractError`, so an unreadable source or flags refuses with the\n\t\t\t\t// same `pattern` code and `{ shape: 'string' }` context the schema leaf\n\t\t\t\t// publishes.\n\t\t\t\tconst declared = owned.pattern\n\t\t\t\tconst refined = owned.min !== undefined || owned.max !== undefined || declared !== undefined\n\t\t\t\tconst pattern = declared === undefined ? undefined : ownPattern(declared, 'compileAuditor')\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isString(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'string', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildStringFaults(node, value, path, pattern) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst node: NumberShape = owned\n\t\t\t\tconst kind: FaultKind = owned.integer === true ? 'integer' : 'number'\n\t\t\t\tconst refined = owned.integer === true || owned.min !== undefined || owned.max !== undefined\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isFiniteNumber(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildNumberFaults(node, value, path) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisBoolean(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'boolean', received: preview(value) }]\n\t\t\tcase 'null':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'null', received: preview(value) }]\n\t\t\tcase 'json':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisJSONValue(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\tcase 'shape':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tContractCompiler.#acceptShape(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'shape', received: preview(value) }]\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tallowed(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'literal', received: preview(value) }]\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst node: ArrayShape = owned\n\t\t\t\tconst item = this.#auditAt(owned.items)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.array(value), 'compileAuditor', {\n\t\t\t\t\t\t\tsubject: 'array',\n\t\t\t\t\t\t\tcontext: { path, shape: 'array' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isArray(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow entries.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t\t{ subject: 'array', context: { path, shape: 'array' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: AuditFault[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) break\n\t\t\t\t\t\tappendEntries(\n\t\t\t\t\t\t\tfaults,\n\t\t\t\t\t\t\titem(entries.value.entries[entryIndex], pathOf(path, INTRINSICS.text(entryIndex))),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tappendEntries(faults, buildArrayFaults(node, entries.value.entries.length, path))\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst declaredKeys = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly audit: (value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly kind: FaultKind\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(declaredKeys), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\taudit: this.#auditAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst closed = extra === undefined || extra === false\n\t\t\t\tconst additional = closed || extra === true ? undefined : this.#auditAt(extra)\n\t\t\t\t// The declared vocabulary is a compile-time constant, so it is built\n\t\t\t\t// once here rather than rebuilt on every report. One bit position per\n\t\t\t\t// declared entry answers the per-entry presence question the same way,\n\t\t\t\t// with a bit test in place of a membership dispatch; past the mask's\n\t\t\t\t// width the collected-vocabulary form still answers.\n\t\t\t\t//\n\t\t\t\t// Plan time is not a call, so it has no path to name and no refusal to\n\t\t\t\t// publish: this build is contained by `attempt` and holds `undefined`\n\t\t\t\t// when it fails. A `globalThis.Set` replaced before this module loaded,\n\t\t\t\t// and so captured into `INTRINSICS`, is what makes it fail. The call\n\t\t\t\t// rebuilds it inside the walk's own containment, where that failure\n\t\t\t\t// reaches the coded refusal this door publishes, carrying the path.\n\t\t\t\tconst planned = attempt(() => collectMembers(declaredKeys))\n\t\t\t\tconst declared = isSuccess(planned) ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.reflect.prototype(value), 'compileAuditor', {\n\t\t\t\t\t\t\tsubject: 'object',\n\t\t\t\t\t\t\tcontext: { path, shape: 'object' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = readValue(\n\t\t\t\t\t\t() => INTRINSICS.freeze(INTRINSICS.keys(record)),\n\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t{ subject: 'object', context: { path, shape: 'object' } },\n\t\t\t\t\t)\n\t\t\t\t\tconst faults: AuditFault[] = []\n\t\t\t\t\t// The value-side presence view is built inside the contained walk, and\n\t\t\t\t\t// the declared vocabulary rebuilt there whenever its plan-time build\n\t\t\t\t\t// failed: a replaced `globalThis.Set` must reach the auditor's own\n\t\t\t\t\t// containment rather than throw the caller's raw value out of a report\n\t\t\t\t\t// this door answers.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst vocabulary = declared ?? collectMembers(declaredKeys)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tif (absent) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tappendEntries(faults, entry.audit(record[entry.key], pathOf(path, entry.key)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\tif (matchesMember(vocabulary, key)) continue\n\t\t\t\t\t\t\tif (closed) {\n\t\t\t\t\t\t\t\tfaults[faults.length] = { reason: 'extra', path: pathOf(path, key) }\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// The same advertised read the compiled guard performs on an open\n\t\t\t\t\t\t\t// object's undeclared key, so this report cannot call a value clean\n\t\t\t\t\t\t\t// that `is` rejects and `parse` refuses as unreadable.\n\t\t\t\t\t\t\tconst observed: unknown = record[key]\n\t\t\t\t\t\t\tif (additional !== undefined) {\n\t\t\t\t\t\t\t\tappendEntries(faults, additional(observed, pathOf(path, key)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(outcome)) {\n\t\t\t\t\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t\t{ subject: 'object', context: { path, shape: 'object' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst plans: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#auditAt(variant)],\n\t\t\t\t\t])\n\t\t\t\tconst exclusive = owned.mode === 'oneOf'\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : plans[selected]\n\t\t\t\t\tif (arm !== undefined) return arm(value, path)\n\t\t\t\t\tconst perVariant: Array<readonly AuditFault[]> = []\n\t\t\t\t\tfor (const index2 of iterateIndices(() => plans.length)) {\n\t\t\t\t\t\tconst plan = plans[index2]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst variantFaults = plan(value, path)\n\t\t\t\t\t\tif (variantFaults.length === 0) {\n\t\t\t\t\t\t\t// An `anyOf` verdict is settled by the FIRST clean variant in\n\t\t\t\t\t\t\t// declaration order, so no later variant plan runs for a value an\n\t\t\t\t\t\t\t// earlier variant already accepted. That is the stop the compiled\n\t\t\t\t\t\t\t// guard and parser already make, and joining it is what keeps a\n\t\t\t\t\t\t\t// later object variant's prototype probe from publishing a coded\n\t\t\t\t\t\t\t// refusal for a value `is` answers `true` for. A `oneOf` verdict is\n\t\t\t\t\t\t\t// the match count over every variant, so it reads all of them.\n\t\t\t\t\t\t\tif (!exclusive) return []\n\t\t\t\t\t\t}\n\t\t\t\t\t\tperVariant[perVariant.length] = variantFaults\n\t\t\t\t\t}\n\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, perVariant, [\n\t\t\t\t\t\t(total: number, faults: readonly AuditFault[]) => total + (faults.length === 0 ? 1 : 0),\n\t\t\t\t\t\t0,\n\t\t\t\t\t])\n\t\t\t\t\tif (exclusive) {\n\t\t\t\t\t\tif (matched === 1) return []\n\t\t\t\t\t\tif (matched > 1) return [{ reason: 'oneOf', path, matched, ...discriminated?.hint }]\n\t\t\t\t\t}\n\t\t\t\t\tconst closest = selectClosestFaults(perVariant)\n\t\t\t\t\tconst report: AuditFault[] = [\n\t\t\t\t\t\texclusive\n\t\t\t\t\t\t\t? { reason: 'oneOf', path, matched: 0, ...discriminated?.hint }\n\t\t\t\t\t\t\t: { reason: 'variant', path, variants: count, ...discriminated?.hint },\n\t\t\t\t\t]\n\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#auditAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === undefined ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#auditAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === null ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t}\n\t}\n\n\t// === Reporter family\n\n\t#buildReporter(): ReporterFunction {\n\t\tconst ready = this.#reporter\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#reportOf(index)\n\t\t\tthis.#reports[index] = this.#repeats(index) ? this.#trackFaults(plan) : plan\n\t\t}\n\t\tconst root = this.#exposeReport(this.#reportAt(this.#node(0)))\n\t\tthis.#reporter = root\n\t\treturn root\n\t}\n\n\t#exposeReport(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly Fault[],\n\t): ReporterFunction {\n\t\treturn (value: unknown, path: readonly string[] = []): readonly Fault[] =>\n\t\t\tcontain(() => plan(value, path), 'compileReporter')\n\t}\n\n\t#reportAt(shape: ContractShape): (value: unknown, path: readonly string[]) => readonly Fault[] {\n\t\tconst compiled = this.#reports[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child reporter is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#reportOf(index: number): (value: unknown, path: readonly string[]) => readonly Fault[] {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\t// The same compile-time gate the auditor's leaves carry, over the COERCED\n\t\t\t// value: the two doors differ in how they obtain the primitive and not in\n\t\t\t// what an unrefined declaration has to say about it.\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\n\t\t\t\t// The same one-time pattern read the auditor's leaf takes, for the same\n\t\t\t\t// accessor and the same reason; see `#auditOf`.\n\t\t\t\tconst declared = owned.pattern\n\t\t\t\tconst refined = owned.min !== undefined || owned.max !== undefined || declared !== undefined\n\t\t\t\tconst pattern = declared === undefined ? undefined : ownPattern(declared, 'compileReporter')\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst parsed = parseString(value)\n\t\t\t\t\tif (parsed === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'string', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildStringFaults(node, parsed, path, pattern) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst node: NumberShape = owned\n\t\t\t\tconst kind: FaultKind = owned.integer === true ? 'integer' : 'number'\n\t\t\t\tconst refined = owned.integer === true || owned.min !== undefined || owned.max !== undefined\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst parsed = parseNumber(value)\n\t\t\t\t\tif (parsed === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildNumberFaults(node, parsed, path) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tparseBoolean(value) === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'boolean', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t\tcase 'null':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'null', received: preview(value) }]\n\t\t\tcase 'json':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisJSONValue(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tallowed(value) || (isString(value) && allowed(value.trim()))\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'literal', received: preview(value) }]\n\t\t\t}\n\t\t\tcase 'shape':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tContractCompiler.#acceptShape(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'shape', received: preview(value) }]\n\t\t\tcase 'array': {\n\t\t\t\tconst node: ArrayShape = owned\n\t\t\t\tconst item = this.#reportAt(owned.items)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isArray(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: Fault[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) break\n\t\t\t\t\t\tappendEntries(\n\t\t\t\t\t\t\tfaults,\n\t\t\t\t\t\t\titem(entries.value.entries[entryIndex], pathOf(path, INTRINSICS.text(entryIndex))),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tappendEntries(faults, buildArrayFaults(node, entries.value.entries.length, path))\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly report: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly kind: FaultKind\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\treport: this.#reportAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => entry.key],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst tail =\n\t\t\t\t\textra === undefined || extra === true || extra === false\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: this.#reportAt(extra)\n\t\t\t\tconst open = extra === true || tail !== undefined\n\t\t\t\t// The declared vocabulary is a compile-time constant, so it is built\n\t\t\t\t// once here over the entry key names rather than admitted key by key on\n\t\t\t\t// every report. One bit position per declared entry answers the\n\t\t\t\t// per-entry presence question the same way, with a bit test in place of\n\t\t\t\t// a membership dispatch; past the mask's width the collected-vocabulary\n\t\t\t\t// form still answers.\n\t\t\t\t//\n\t\t\t\t// Plan time is not a call, so it has no value to report on: this build\n\t\t\t\t// is contained by `attempt` and holds `undefined` when it fails. A\n\t\t\t\t// `globalThis.Set` replaced before this module loaded, and so captured\n\t\t\t\t// into `INTRINSICS`, is what makes it fail. The call rebuilds it inside\n\t\t\t\t// the walk's own containment, which keeps this door's answer a fault\n\t\t\t\t// array in exactly the regime its totality promise names.\n\t\t\t\tconst planned = attempt(() => collectMembers(names))\n\t\t\t\tconst known = isSuccess(planned) ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = enumerableKeys(record)\n\t\t\t\t\tif (keys === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: Fault[] = []\n\t\t\t\t\t// The value-side presence view is built inside the contained walk, and\n\t\t\t\t\t// the declared vocabulary rebuilt there whenever its plan-time build\n\t\t\t\t\t// failed: a replaced `globalThis.Set` must reach the reporter's own\n\t\t\t\t\t// diagnostic containment rather than throw the caller's raw value out\n\t\t\t\t\t// of a total report.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst vocabulary = known ?? collectMembers(names)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\t// Mirror the parser's presence gate exactly: only an own\n\t\t\t\t\t\t\t// enumerable string key is present. A present key with an\n\t\t\t\t\t\t\t// explicit `undefined` value is still treated like absence, so\n\t\t\t\t\t\t\t// `explain` never faults where `parse` silently skips it.\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tif (absent) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst raw = record[entry.key]\n\t\t\t\t\t\t\tif (raw === undefined) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tappendEntries(faults, entry.report(raw, pathOf(path, entry.key)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A CLOSED object's undeclared key is never read here, because `parse`\n\t\t\t\t\t\t// drops it without reading it either. An OPEN one's is, because `parse`\n\t\t\t\t\t\t// copies it — and a report that skipped that read published the empty\n\t\t\t\t\t\t// report, its documented \"parse will succeed\" signal, for a value\n\t\t\t\t\t\t// `parse` refused as unreadable.\n\t\t\t\t\t\tif (open) {\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\t\tif (matchesMember(vocabulary, key)) continue\n\t\t\t\t\t\t\t\tconst observed: unknown = record[key]\n\t\t\t\t\t\t\t\tif (tail !== undefined) {\n\t\t\t\t\t\t\t\t\tappendEntries(faults, tail(observed, pathOf(path, key)))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(outcome)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst variants: ReadonlyArray<{\n\t\t\t\t\treadonly report: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\tvariant === undefined\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\treport: this.#reportAt(variant),\n\t\t\t\t\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst plans: ReadonlyArray<(value: unknown, path: readonly string[]) => readonly Fault[]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(variants), [\n\t\t\t\t\t\t(variant: (typeof variants)[number]) => variant.report,\n\t\t\t\t\t])\n\t\t\t\tconst guards: ReadonlyArray<Guard<unknown>> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(variants),\n\t\t\t\t\t[(variant: (typeof variants)[number]) => variant.guard],\n\t\t\t\t)\n\t\t\t\tconst exclusive = owned.mode === 'oneOf'\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : plans[selected]\n\t\t\t\t\tif (arm !== undefined) return arm(value, path)\n\t\t\t\t\tconst perVariant: Array<readonly Fault[]> = []\n\t\t\t\t\tfor (const index2 of iterateIndices(() => plans.length)) {\n\t\t\t\t\t\tconst plan = plans[index2]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst variantFaults = plan(value, path)\n\t\t\t\t\t\t// The auditor's first-clean-variant stop, mirrored: an `anyOf` report\n\t\t\t\t\t\t// is settled by the FIRST variant that reports nothing, in declaration\n\t\t\t\t\t\t// order, and no later variant plan reads the value after it. A `oneOf`\n\t\t\t\t\t\t// report is the guard-match count over every variant, so it reads all\n\t\t\t\t\t\t// of them.\n\t\t\t\t\t\tif (!exclusive && variantFaults.length === 0) return []\n\t\t\t\t\t\tperVariant[perVariant.length] = variantFaults\n\t\t\t\t\t}\n\t\t\t\t\tconst closest = selectClosestFaults(perVariant)\n\t\t\t\t\tif (exclusive) {\n\t\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, guards, [\n\t\t\t\t\t\t\t(total: number, guard: Guard<unknown>) => total + (guard(value) ? 1 : 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tif (matched === 1) return []\n\t\t\t\t\t\tif (matched === 0) {\n\t\t\t\t\t\t\tconst report: Fault[] = [\n\t\t\t\t\t\t\t\t{ reason: 'oneOf', path, matched: 0, ...discriminated?.hint },\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [{ reason: 'oneOf', path, matched, ...discriminated?.hint }]\n\t\t\t\t\t}\n\t\t\t\t\tconst report: Fault[] = [\n\t\t\t\t\t\t{ reason: 'variant', path, variants: count, ...discriminated?.hint },\n\t\t\t\t\t]\n\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#reportAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === undefined ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#reportAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === null ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t}\n\t}\n\n\t// === Generator family\n\n\t#buildGenerator(): SeederFunction<unknown> {\n\t\tconst ready = this.#generator\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#seeds[index] = this.#seedOf(index)\n\t\t}\n\t\tconst root = this.#exposeSeed(this.#seedAt(this.#node(0)))\n\t\tthis.#generator = root\n\t\treturn root\n\t}\n\n\t// The default seed is drawn INSIDE the boundary, not in a parameter list. A\n\t// default-parameter initializer is evaluated in the function environment\n\t// before the first statement of the body, so no at-the-door containment could\n\t// ever reach it — `Date.now = () => { throw x }` made this door and\n\t// `contract.generate()` throw the caller's raw object by identity. The read is\n\t// captured too: `INTRINSICS.now` rather than the live global.\n\t#exposeSeed(plan: (random: RandomFunction) => unknown): SeederFunction<unknown> {\n\t\treturn (random?: RandomFunction): unknown =>\n\t\t\tcontain(() => plan(random ?? seededRandom(INTRINSICS.now())), 'compileGenerator', {\n\t\t\t\tcode: 'generate',\n\t\t\t})\n\t}\n\n\t#seedAt(shape: ContractShape): (random: RandomFunction) => unknown {\n\t\tconst compiled = this.#seeds[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child generator is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#seedOf(index: number): (random: RandomFunction) => unknown {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string': {\n\t\t\t\tconst min = owned.min ?? 0\n\t\t\t\tconst max = owned.max ?? INTRINSICS.max(min, 12)\n\t\t\t\tconst length = INTRINSICS.max(min, INTRINSICS.min(max, 8))\n\t\t\t\tconst pattern = owned.pattern\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789'\n\t\t\t\t\tconst characters = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => length),\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tINTRINSICS.text(\n\t\t\t\t\t\t\t\talphabet[INTRINSICS.floor(drawRandom(random, 'string') * alphabet.length)],\n\t\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\tconst value: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\t\t\t\t\tif (pattern !== undefined && !matchOf(pattern)(value)) {\n\t\t\t\t\t\tconst limit = readPatternSource(pattern)\n\t\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t\t'compileGenerator: a pattern-constrained string shape cannot be auto-generated — supply or verify values another way',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\t\tcontext: { shape: 'string', ...(limit === undefined ? {} : { limit }) },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst whole = owned.integer === true\n\t\t\t\tconst minimum = owned.min\n\t\t\t\tconst maximum = owned.max\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst sample = drawRandom(random, whole ? 'integer' : 'number')\n\t\t\t\t\tif (whole) {\n\t\t\t\t\t\tconst lo = INTRINSICS.ceil(minimum ?? (maximum === undefined ? -100 : maximum - 100))\n\t\t\t\t\t\tconst hi = INTRINSICS.floor(maximum ?? (minimum === undefined ? 100 : minimum + 100))\n\t\t\t\t\t\treturn lo === hi ? lo : INTRINSICS.floor(lo * (1 - sample) + hi * sample)\n\t\t\t\t\t}\n\t\t\t\t\tconst lo = minimum ?? (maximum === undefined ? -100 : maximum - 100)\n\t\t\t\t\tconst hi = maximum ?? (minimum === undefined ? 100 : minimum + 100)\n\t\t\t\t\treturn lo === hi ? lo : lo * (1 - sample) + hi * sample\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (random) => drawRandom(random, 'boolean') >= 0.5\n\t\t\tcase 'null':\n\t\t\t\treturn () => null\n\t\t\tcase 'shape':\n\t\t\t\treturn () => ({ category: 'object', properties: {}, additionalProperties: false })\n\t\t\tcase 'json':\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst pick = INTRINSICS.floor(drawRandom(random, 'json') * 5)\n\t\t\t\t\tif (pick === 0) return null\n\t\t\t\t\tif (pick === 1) return drawRandom(random, 'json') >= 0.5\n\t\t\t\t\tif (pick === 2) return INTRINSICS.floor(drawRandom(random, 'json') * 1000)\n\t\t\t\t\tif (pick === 3) {\n\t\t\t\t\t\tconst alphabet = 'abcdefghijklmnopqrstuvwxyz'\n\t\t\t\t\t\tconst characters = INTRINSICS.from(\n\t\t\t\t\t\t\titerateIndices(() => 6),\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tINTRINSICS.text(\n\t\t\t\t\t\t\t\t\talphabet[INTRINSICS.floor(drawRandom(random, 'json') * alphabet.length)],\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst value: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\t\t\t\t\t\treturn value\n\t\t\t\t\t}\n\t\t\t\t\treturn { value: INTRINSICS.floor(drawRandom(random, 'json') * 1000) }\n\t\t\t\t}\n\t\t\tcase 'literal': {\n\t\t\t\tconst values = owned.values\n\t\t\t\treturn (random) => {\n\t\t\t\t\tif (values.length === 0) {\n\t\t\t\t\t\tthrow new ContractError('compileGenerator: a literal shape needs at least one value', {\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'literal', limit: 1 },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn values[INTRINSICS.floor(drawRandom(random, 'literal') * values.length)]\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst item = this.#seedAt(owned.items)\n\t\t\t\tconst lo = owned.min ?? INTRINSICS.min(1, owned.max ?? 1)\n\t\t\t\tconst hi = owned.max ?? INTRINSICS.max(lo, 3)\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst length = INTRINSICS.floor(drawRandom(random, 'array') * (hi - lo + 1)) + lo\n\t\t\t\t\treturn INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => length),\n\t\t\t\t\t\t() => item(random),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly seed: (random: RandomFunction) => unknown\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tseed: this.#seedAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst tail =\n\t\t\t\t\textra === undefined || extra === true || extra === false ? undefined : this.#seedAt(extra)\n\t\t\t\treturn (random) => {\n\t\t\t\t\t// Honest typing: generated data is a value the caller keeps, so unlike the\n\t\t\t\t\t// guard's and parser's null-prototype property views it carries the normal\n\t\t\t\t\t// object prototype — `defineProperty` (never assignment) still lands a\n\t\t\t\t\t// '__proto__' key as an own data key rather than mutating that prototype.\n\t\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(entries), [\n\t\t\t\t\t\t(entry: (typeof entries)[number]) =>\n\t\t\t\t\t\t\tentry.optional && drawRandom(random, 'object') < 0.3\n\t\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t\t: [[entry.key, entry.seed(random)]],\n\t\t\t\t\t])\n\t\t\t\t\tconst declared = INTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t})\n\t\t\t\t\tconst count =\n\t\t\t\t\t\ttail === undefined ? 0 : 1 + INTRINSICS.floor(drawRandom(random, 'object') * 2)\n\t\t\t\t\tconst extras = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => count),\n\t\t\t\t\t\t(step) => {\n\t\t\t\t\t\t\tconst key = `key${step}`\n\t\t\t\t\t\t\treturn INTRINSICS.own(declared, key) || tail === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: [key, tail(random)]\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tconst selected = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(extras), [\n\t\t\t\t\t\t(entry: unknown) => entry !== undefined,\n\t\t\t\t\t])\n\t\t\t\t\tconst additional = INTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tselected,\n\t\t\t\t\t\t]),\n\t\t\t\t\t})\n\t\t\t\t\tconst result = { ...declared, ...additional }\n\t\t\t\t\treturn result\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst plans: Array<(random: RandomFunction) => unknown> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#seedAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst guard = count === 0 ? undefined : this.#guardAt(owned)\n\t\t\t\tconst attempts = INTRINSICS.max(GENERATION_ATTEMPT_LIMIT, count)\n\t\t\t\treturn (random) => {\n\t\t\t\t\tif (count === 0 || guard === undefined) {\n\t\t\t\t\t\tthrow new ContractError('compileGenerator: a union shape needs at least one variant', {\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'union', limit: 1 },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst start = INTRINSICS.floor(drawRandom(random, 'union') * count)\n\t\t\t\t\tfor (const attemptIndex of iterateIndices(() => attempts)) {\n\t\t\t\t\t\tconst plan = plans[(start + attemptIndex) % count]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst outcome = attempt(() => plan(random))\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisFailure(outcome) &&\n\t\t\t\t\t\t\tisContractError(outcome.error) &&\n\t\t\t\t\t\t\toutcome.error.code === 'random'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isSuccess(outcome) && guard(outcome.value)) return outcome.value\n\t\t\t\t\t}\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'compileGenerator: no union candidate satisfied the compiled guard',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'union', limit: attempts },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#seedAt(owned.inner)\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#seedAt(owned.inner)\n\t\t\t\treturn (random) => (drawRandom(random, 'nullable') < 0.2 ? null : inner(random))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn () => {\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'compileGenerator: a raw shape embeds an arbitrary JSON Schema and cannot be auto-generated — supply values another way',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'raw', limit: 'explicit value source' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t}\n\t}\n\n\t// === Bundle\n\n\t#buildContract(): ContractInterface<unknown> {\n\t\tconst ready = this.#bundle\n\t\tif (ready !== undefined) return ready\n\t\t// Getter order, so a declaration that refuses refuses at the same artifact\n\t\t// whether the caller reads the roots one at a time or asks for the bundle.\n\t\tconst schema = this.#buildSchema()\n\t\tconst guard = this.#buildGuard()\n\t\tconst parser = this.#buildParser()\n\t\tconst auditor = this.#buildAuditor()\n\t\tconst reporter = this.#buildReporter()\n\t\tconst generator = this.#buildGenerator()\n\t\tconst bundle = INTRINSICS.freeze({\n\t\t\tschema,\n\t\t\tis: guard,\n\t\t\tparse: parser,\n\t\t\taudit: auditor,\n\t\t\texplain: reporter,\n\t\t\tgenerate: generator,\n\t\t})\n\t\tthis.#bundle = bundle\n\t\treturn bundle\n\t}\n\n\tstatic {\n\t\t// Pinned while this class is DEFINED. Every standalone compiler and\n\t\t// `createContract` reaches these getters, so one assignment on this\n\t\t// prototype would decide what the public doors publish while none of them\n\t\t// was touched.\n\t\tpinMembers(ContractCompiler.prototype, 'ContractCompiler')\n\t}\n}\n","import type {\n\tAuditFault,\n\tContractShape,\n\tFault,\n\tGuard,\n\tInfer,\n\tJSONSchema,\n\tParser,\n\tRandomFunction,\n} from './types.js'\nimport { contain, refuseExpansion } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapeValidator } from './ShapeValidator.js'\n\n// The public function boundaries over the engines. `ShapeValidator` owns the\n// stateful declaration walk; `ContractCompiler` owns ownership, preparation and\n// every artifact family. Each function below is a real typed door — its own\n// overloads, its own containment, its own diagnostics — that requests exactly\n// the root it is named for and nothing else, so asking for a guard never\n// compiles a generator. Recursion lives in the compiler, not here: a module that\n// re-entered its own public functions per node would re-own and re-validate the\n// subgraph at every level.\n\n// === Validation\n\n/**\n * Gates recursive compiler work on shape structure, depth, and cycles.\n *\n * @remarks\n * Constructs a fresh {@link ShapeValidator} and eagerly validates the graph.\n * The validator walks iteratively with explicit stack space and observes each\n * unique node exactly ONCE per call, so a shared-child DAG costs its AUTHORED\n * nodes and edges rather than its paths. Every incoming edge is still inspected:\n * where an `optional` node is legal depends on the slot it arrived through, and\n * depth is measured over the captured graph afterwards rather than by walking\n * each path.\n *\n * This is also where the compilers' expansion bound lives. Every compiled\n * artifact is a tree, so a DAG's cost is the size of the tree it expands into —\n * `objectShape({ left: node, right: node })` nested thirty times is thirty-one\n * authored nodes and more than a billion emitted ones. The validator counts\n * that expansion and {@link refuseExpansion} refuses past\n * {@link COMPILE_NODE_LIMIT} with an `expansion`-coded {@link ContractError}, so\n * every standalone compiler and {@link createContract} answer a shared-child\n * declaration in bounded time instead of not answering. {@link cloneShape} /\n * {@link ownShape} are deliberately NOT bounded by it: they preserve\n * shared-child identity, so ownership of the same declaration stays\n * proportional to its authored nodes.\n * Every structural child slot must contain a shape node before it can enter the\n * walk; every scalar field must hold its declared runtime domain before a\n * compiler can use it; and a missing child, corrupt container, inherited\n * discriminant, or unrecognized node reports `structure`. This is the SOLE\n * eager well-formedness pass — there is no second prepass and no alias for it:\n * it enforces every bound domain and range used by the artifacts, including\n * non-empty literal/union vocabularies, finite literal numbers, integer-range\n * satisfiability, unflagged string patterns, optional-shape and default\n * placement, and the recursively supported raw-schema vocabulary where every\n * present property or dense union member is a record. It judges a default's\n * structure only; each compiler refuses a default its inner guard refuses.\n * Active ancestors are tracked so shared children remain legal. Every\n * standalone compiler reaches this same validation once, over its owned\n * snapshot, through {@link ContractCompiler} preparation.\n * Cyclic graphs refuse before depth measurement, with structure before cycle.\n * Acyclic graphs report depth before structure, then field and vocabulary policy.\n *\n * @param shape - The shape graph to gate\n * @returns Nothing; successful return means recursive compilation is structurally safe, depth-safe, and bounded in emitted nodes\n * @throws {ContractError} When a node or structural slot is corrupt, a bound or vocabulary is outside its declared domain, the graph is cyclic, it exceeds the compilation depth limit, or it expands past the compilation node limit\n *\n * @example\n * ```ts\n * validateShape(stringShape({ min: 1 })) // returns; the declaration is compilable\n * ```\n */\nexport function validateShape(shape: unknown): void {\n\treturn contain(() => {\n\t\tconst validator = new ShapeValidator(shape)\n\t\tvalidator.validate()\n\t\trefuseExpansion(validator.expansion)\n\t}, 'validateShape')\n}\n\n// === Schema\n\n/**\n * Compiles a {@link ContractShape} into a JSON Schema document.\n *\n * @remarks\n * Object shapes emit `additionalProperties: false` (unless opened) and list only\n * required keys in `required`; nullable shapes emit an `anyOf` with `{ type:\n * 'null' }`. The result is an owned deeply frozen graph; raw schemas are cloned\n * rather than retained by reference. Emission only — it never inspects a\n * runtime value. It requests exactly the `schema` root of a fresh\n * {@link ContractCompiler}, so the declaration is owned once and validated once\n * and no other artifact family is built. Shared declaration identity survives\n * into the emitted document: two slots holding one authored node hold one\n * emitted subschema, while structurally equal distinct nodes stay distinct.\n *\n * @param shape - The shape to compile\n * @returns The emitted JSON Schema\n *\n * @example\n * ```ts\n * compileSchema(stringShape({ min: 1 })) // { type: 'string', minLength: 1 }\n * ```\n */\nexport function compileSchema(shape: ContractShape): JSONSchema {\n\treturn contain(() => new ContractCompiler(shape).schema, 'compileSchema')\n}\n\n// === Guard\n\n/**\n * Compiles a {@link ContractShape} into a runtime type guard.\n *\n * @remarks\n * Reuses the combinators for structural and refined shapes, including\n * {@link literalOf} for SameValueZero literal matching. Compiled object shapes\n * observe own enumerable string keys through {@link enumerableKeys}, the same\n * key view their parser, reporter, auditor, and inference use for both open and\n * closed objects — the view is shared, the verdict on an undeclared key is not\n * (this guard rejects the object; the parser drops the key).\n * Like every guard it is total — it never throws, as `.claude/rules/patterns.md`\n * § Validation and contracts requires. It requests\n * exactly the `guard` root of a fresh {@link ContractCompiler}, which owns the\n * declaration once through {@link ownShape} and validates that snapshot once,\n * unless the builders already did, so an unfrozen caller-owned graph compiles\n * from a snapshot and excessive\n * nesting, cycles, and excessive expansion are rejected before any guard is\n * built.\n *\n * @param shape - The shape to compile\n * @returns A guard narrowing to the shape's inferred type\n *\n * @example\n * ```ts\n * const isUser = compileGuard(objectShape({ name: stringShape() }))\n * isUser({ name: 'Ada' }) // true\n * ```\n */\nexport function compileGuard<S extends ContractShape>(shape: S): Guard<Infer<S>>\nexport function compileGuard(shape: ContractShape): Guard<unknown>\nexport function compileGuard(shape: ContractShape): Guard<unknown> {\n\treturn contain(() => new ContractCompiler(shape).guard, 'compileGuard')\n}\n\n// === Parser\n\n/**\n * Compiles a {@link ContractShape} into an input parser.\n *\n * @remarks\n * Reuses the leaf parsers (`parseString` / `parseInteger` / `parseNumber` /\n * `parseBoolean`) and coerces structurally. An object fails as a\n * whole on any required-field failure; a union returns a guard-valid value\n * unchanged, otherwise the first variant that both parses and guards wins.\n *\n * After coercing a leaf, it re-applies that leaf's REFINEMENTS through the same\n * combinators {@link compileGuard} uses — `stringOf` for a string's\n * length/pattern, `boundsOf` for a number's value and an array's length, and\n * {@link literalOf} for literal membership — so a value that coerces but\n * violates a bound parses to `undefined`. The result is full parse↔guard\n * soundness, which `.claude/rules/patterns.md` § Validation and contracts\n * mandates: a\n * non-`undefined` parse always satisfies the contract's `is`, refinements\n * included — a statement about the OUTPUT, never about the input, which may be\n * a value `is` rejects. Object presence and extra-key processing read the same\n * own-enumerable-string key view as the guard, reporter, auditor, and inference\n * — one key set, deliberately different verdicts: this parser drops an\n * undeclared key that {@link compileGuard} rejects and {@link compileAuditor}\n * faults. It requests exactly the `parser` root of a fresh\n * {@link ContractCompiler}, which owns and validates the declaration once; a\n * union's variant selection is a guard question, so a declaration containing one\n * also builds the compiler's guard plan.\n *\n * @param shape - The shape to compile\n * @returns A parser yielding the shape's inferred type or `undefined`\n *\n * @example\n * ```ts\n * const parseUser = compileParser(objectShape({ name: stringShape() }))\n * parseUser({ name: 'Ada' }) // { name: 'Ada' }\n * ```\n */\nexport function compileParser<S extends ContractShape>(shape: S): Parser<Infer<S>>\nexport function compileParser(shape: ContractShape): Parser<unknown>\nexport function compileParser(shape: ContractShape): Parser<unknown> {\n\treturn contain(() => new ContractCompiler(shape).parser, 'compileParser')\n}\n\n// === Generator\n\n/**\n * Compiles a {@link ContractShape} into a deterministic seed value.\n *\n * @remarks\n * The same shape and the same `random` source always produce the same value, so\n * seed data is reproducible. Defaults to a {@link seededRandom} source seeded\n * from the wall clock when none is supplied. Shape-generation failures throw a\n * {@link ContractError} with code `'generate'`; {@link drawRandom} failures use\n * code `'random'` and retain the consuming shape category in context.\n * Failures include a pattern-constrained `stringShape` whose generated sample\n * cannot satisfy the pattern, an invalid random sample, and a `rawShape` whose\n * arbitrary embedded schema cannot be auto-generated. Degenerate empty\n * literal/union vocabularies fail earlier with the shared gate's `empty` code.\n * It requests exactly the `generator` root of a fresh\n * {@link ContractCompiler} and invokes it once, so the declaration is owned and\n * validated once before any draw. Union candidates are bounded by\n * {@link GENERATION_ATTEMPT_LIMIT} and accepted only when they satisfy the\n * union's compiled guard, which is why a declaration containing a union also\n * builds the compiler's guard plan.\n *\n * @param shape - The shape to generate from\n * @param random - A seeded random source (defaults to a wall-clock seed drawn inside the door's boundary)\n * @returns A value matching the shape\n * @throws {ContractError} When the shape or random source cannot produce a valid value\n *\n * @example\n * ```ts\n * compileGenerator(stringShape({ min: 1, max: 4 })) // a random string of 1-4 characters (seed a RandomFunction for determinism)\n * ```\n */\nexport function compileGenerator<S extends ContractShape>(\n\tshape: S,\n\trandom?: RandomFunction,\n): Infer<S>\nexport function compileGenerator(shape: ContractShape, random?: RandomFunction): unknown\nexport function compileGenerator(shape: ContractShape, random?: RandomFunction): unknown {\n\treturn contain(() => new ContractCompiler(shape).generator(random), 'compileGenerator', {\n\t\tcode: 'generate',\n\t})\n}\n\n// === Reporter\n\n/**\n * Compiles a {@link ContractShape} into a structured fault report for a value —\n * the diagnostic counterpart of {@link compileGuard} / {@link compileParser}.\n *\n * @remarks\n * MIRROR-PARSE semantics: reuses the exact leaf parsers/guards\n * {@link compileParser} uses (`parseString` / `parseNumber` / `parseBoolean` /\n * `isJSONValue` / …), so the soundness invariant\n * `compileReporter(shape, v).length === 0 ⟺ compileParser(shape)(v) !== undefined`\n * holds structurally — `explain` mirrors `parse`, not the stricter `is` (a\n * coercible value like `'42'` against a `numberShape` reports no fault, the\n * same leniency `parse` grants, even though the strict guard would reject it).\n * The invariant relates two separate calls, so it holds for a value whose reads\n * are stable across calls; see the read-stability precondition on\n * {@link ContractInterface}. {@link compileAuditor} is the counterpart report\n * for the strict domain, mirroring {@link compileGuard} the way this one\n * mirrors {@link compileParser}.\n *\n * Faults are collected in stable pre-order (declared key/index order); every\n * call — object, array, and union alike, including a union's `oneOf` \"no\n * match\" / \"no consensus\" summary fault prepended to its closest variant's\n * faults — slices its return to at most {@link FAULT_LIMIT} entries, so the\n * bound holds at every level of nesting rather than at the outermost container alone, on\n * adversarial input (a huge array, a wide record, a wide union of wide\n * records). A closed object's extra keys never\n * fault — `parse` silently drops them, so `explain` mirrors that leniency, and\n * {@link compileAuditor} is where they do fault; an open object with a\n * constraining `additionalProperties` shape recurses extras against it instead.\n * A hostile getter or throwing `Proxy` trap is contained through {@link attempt}\n * and surfaces as a single top-level type fault, never a throw, as\n * `.claude/rules/patterns.md` § Validation and contracts requires.\n * It requests exactly the `reporter` root of a fresh {@link ContractCompiler}\n * and applies it once, so one call owns and validates the declaration once\n * rather than re-gating every node it descends into. Reuse the compiler (or a\n * contract's `explain`) when many values are reported against one shape.\n *\n * @param shape - The shape to report against\n * @param value - The value to check\n * @param path - The path prefix for faults produced at this call (defaults to the root)\n * @returns The faults found, empty when the value parses successfully\n *\n * @example\n * ```ts\n * const user = objectShape({ name: stringShape({ min: 1 }) })\n * compileReporter(user, { name: '' })\n * // [{ reason: 'constraint', path: ['name'], expected: 'string', constraint: 'min', limit: 1, received: '\"\"' }]\n * compileReporter(user, { name: 'Ada' }) // []\n * ```\n */\nexport function compileReporter(\n\tshape: ContractShape,\n\tvalue: unknown,\n\tpath: readonly string[] = [],\n): readonly Fault[] {\n\treturn contain(() => new ContractCompiler(shape).reporter(value, path), 'compileReporter')\n}\n\n/**\n * Audits a value against the strict acceptance domain of a {@link ContractShape}.\n *\n * @remarks\n * The diagnostic for the domain {@link compileGuard} and {@link compileSchema}\n * describe, where {@link compileReporter} diagnoses the wider preimage\n * {@link compileParser} maps into it. This walk therefore mirrors the guard:\n * leaf coercions are faults, closed-object extras are faults, and union\n * acceptance is decided from each variant's strict audit emptiness, so the\n * soundness invariant\n * `compileAuditor(shape, v).length === 0 ⟺ compileGuard(shape)(v)` holds\n * structurally. The shared declaration gate rejects structural and bound-domain\n * malformations before either artifact is built, so the invariant is only\n * evaluated for a valid declaration. The invariant relates two\n * separate calls, so it holds for a value whose reads are stable across calls;\n * see the read-stability precondition on {@link ContractInterface}. Every\n * recursive call returns at most {@link FAULT_LIMIT} entries. Hostile property\n * access raises the shared coded read refusal with the current container path\n * and shape, so unreadability never masquerades as a type mismatch.\n * It requests exactly the `auditor` root of a fresh {@link ContractCompiler}\n * and applies it once; reuse the compiler (or a contract's `audit`) when many\n * values are audited against one shape.\n *\n * @param shape - The shape to audit against\n * @param value - The value to check\n * @param path - The path prefix for faults produced at this call\n * @returns The strict faults found, empty exactly when the compiled guard accepts a stably-read value\n *\n * @example\n * ```ts\n * const user = objectShape({ name: stringShape() })\n * compileAuditor(user, { name: 'Ada', extra: true })\n * // [{ reason: 'extra', path: ['extra'] }]\n * ```\n */\nexport function compileAuditor(\n\tshape: ContractShape,\n\tvalue: unknown,\n\tpath: readonly string[] = [],\n): readonly AuditFault[] {\n\treturn contain(() => new ContractCompiler(shape).auditor(value, path), 'compileAuditor')\n}\n","import type {\n\tAuditorFunction,\n\tContractInterface,\n\tContractShape,\n\tGuard,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tSeederFunction,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { attempt, contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Owns a contract whose function members compile together on the first call to any.\n *\n * @remarks\n * For a declaration made entirely by builders, where preparation and the schema have\n * already asked everything that can refuse. A module that declares its contracts as\n * data then pays for a contract only when something uses it, and each member is a\n * plain function with one identity, so destructuring and spreading compile nothing.\n *\n * A compile can still fail for the host's reasons: a first call near the stack limit,\n * or a host whose members were replaced after this contract was created, which it\n * refuses to compile on since the result would outlive the replacement. Neither says\n * anything about a later call, which compiles afresh. Until then a guard answers\n * `false` and a parser `undefined`, and the diagnostic and seed members publish the\n * failure as their doors do.\n */\nexport class LazyContract {\n\treadonly #shape: ContractShape\n\t#pending: ContractCompiler | undefined\n\t#settled: ContractCompiler | undefined\n\t#bundle: ContractInterface<unknown> | undefined\n\n\t/**\n\t * Retains a declaration and the compiler already prepared from it.\n\t *\n\t * @param shape - The sealed declaration\n\t * @param compiler - The compiler that owns its prepared index\n\t */\n\tconstructor(shape: ContractShape, compiler: ContractCompiler) {\n\t\tthis.#shape = shape\n\t\tthis.#pending = compiler\n\t}\n\n\t/**\n\t * Compiles the schema, which refuses a bad declaration, and publishes the bundle.\n\t *\n\t * @param schema - The schema the prepared compiler emitted\n\t * @returns The frozen bundle, in the key order the compiler's own bundle uses\n\t */\n\tpublish(schema: ContractInterface<unknown>['schema']): ContractInterface<unknown> {\n\t\treturn INTRINSICS.freeze({\n\t\t\tschema,\n\t\t\tis: this.#is(),\n\t\t\tparse: this.#parse(),\n\t\t\taudit: this.#audit(),\n\t\t\texplain: this.#explain(),\n\t\t\tgenerate: this.#generate(),\n\t\t})\n\t}\n\n\t#is(): Guard<unknown> {\n\t\treturn (value: unknown): value is unknown => {\n\t\t\tconst bundle = this.#bundle ?? this.#attempt()\n\t\t\treturn bundle !== undefined && bundle.is(value)\n\t\t}\n\t}\n\n\t#parse(): Parser<unknown> {\n\t\treturn (value: unknown): unknown => {\n\t\t\tconst bundle = this.#bundle ?? this.#attempt()\n\t\t\treturn bundle === undefined ? undefined : bundle.parse(value)\n\t\t}\n\t}\n\n\t#audit(): AuditorFunction {\n\t\treturn (value: unknown, path: readonly string[] = []) =>\n\t\t\t(this.#settled ?? this.#settle('compileAuditor')).auditor(value, path)\n\t}\n\n\t#explain(): ReporterFunction {\n\t\treturn (value: unknown, path: readonly string[] = []) =>\n\t\t\t(this.#settled ?? this.#settle('compileReporter')).reporter(value, path)\n\t}\n\n\t#generate(): SeederFunction<unknown> {\n\t\treturn (random?: RandomFunction): unknown =>\n\t\t\t(this.#settled ?? this.#settle('compileGenerator')).generator(random)\n\t}\n\n\t#attempt(): ContractInterface<unknown> | undefined {\n\t\tattempt(() => this.#settle('createContract'))\n\t\treturn this.#bundle\n\t}\n\n\t// The pending compiler is dropped before it compiles, because a failure settles a\n\t// compiler for good, and this one must not answer a later call.\n\t#settle(door: string): ContractCompiler {\n\t\treturn contain(() => {\n\t\t\tif (ShapePass.tampered()) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t`${door}: a host member this contract compiles on was replaced after it was created`,\n\t\t\t\t\t{ code: 'structure', context: { path: [], shape: 'contract' } },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst compiler = this.#pending ?? new ContractCompiler(this.#shape)\n\t\t\tthis.#pending = undefined\n\t\t\tthis.#bundle = compiler.contract\n\t\t\tthis.#settled = compiler\n\t\t\treturn compiler\n\t\t}, door)\n\t}\n}\n","import type { ContractInterface, ContractShape, Infer } from './types.js'\nimport { contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { LazyContract } from './LazyContract.js'\nimport { ShapePass } from './ShapePass.js'\n\n// The entity door over the compiler engine. Every other door in `compilers.ts`\n// requests one artifact root and returns that artifact; this one returns the\n// live `ContractInterface` bundle, which is an entity rather than a compiled\n// projection, so it sits in the factory kind file its `create*` form names.\n\n/**\n * Compiles a {@link ContractShape} into a {@link ContractInterface} — the\n * lockstep outputs from one declaration, lockstep meaning derived from one\n * owned snapshot rather than accepting the same values.\n *\n * @remarks\n * Creates ONE {@link ContractCompiler} and returns that compiler's exact\n * `contract` bundle. One ownership population governs the whole contract: the\n * declaration is owned once through {@link ownShape}, that owned graph is\n * validated once, and every artifact is compiled from it. There is no\n * discarded pre-ownership pass over the caller's declaration and no second\n * snapshot — ownership already refuses a malformed structural slot, scalar\n * field, or bound rather than normalizing it, so a second walk of the caller's\n * live source only added a population that could disagree with the one the\n * artifacts actually use. A declaration made entirely by this package's builders\n * is frozen and validated all the way down already, so it is that owned graph.\n * Every artifact compiles once, so `audit`, `explain` and `generate` re-walk and\n * re-gate nothing on a later call; `contract.audit` and `compileAuditor` run the\n * same compiled plan reached by different names.\n * A declaration made entirely by builders compiles its schema at this call and\n * its function members together on the first call to any of them, so a module\n * can declare contracts as data and pay only for the ones it uses. Any other\n * declaration, and a bare leaf, compiles every member at this call. Either way\n * the members are plain data properties, so `const { is, parse } =\n * createContract(shape)` destructures those exact values, a spread of the result\n * copies them, and neither compiles anything. A malformed declaration refuses at\n * this call rather than at the first read of whichever member a caller happens\n * to touch, so the failure arrives at the call the caller made — carrying the\n * authoring door's own diagnosis, which this door adopts rather than rewraps.\n * Every compiled member is self-contained, and the compiler this call builds\n * releases its working set once every member has compiled. The contract keeps\n * part of the declaration even so: the auditor and reporter plans close over the\n * leaf and array nodes they read their bounds from, and a contract with deferred\n * members retains its declaration. Nothing the caller keeps reaches back into the\n * compiler. A deferred member compiled on a host whose members were replaced after\n * this call would outlive the replacement, so it refuses to compile until they are\n * restored: until then its guard answers `false`, its parser `undefined`, and its\n * diagnostics and generator refuse.\n *\n * @param shape - The shape to compile\n * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`\n *\n * @example Compiling a contract\n * ```ts\n * import {\n * \tcreateContract,\n * \tintegerShape,\n * \tobjectShape,\n * \tseededRandom,\n * \tstringShape,\n * } from '@orkestrel/contract'\n *\n * const user = createContract(objectShape({ name: stringShape({ min: 1 }), age: integerShape() }))\n *\n * user.is({ name: 'Ada', age: 36 }) // true — a typed guard (narrows to Infer<typeof shape>)\n * user.parse({ name: 'Ada', age: '36' }) // { name: 'Ada', age: 36 } — coerces, or undefined\n * user.parse({ name: '', age: 36 }) // undefined — '' violates name min:1 (parse enforces refinements, like is)\n * user.explain({ name: '', age: 36 }) // [{ reason: 'constraint', path: ['name'], expected: 'string', constraint: 'min', limit: 1, received: '\"\"' }]\n * user.schema // the owned, deeply frozen { type: 'object', properties: { … }, required: ['name', 'age'], additionalProperties: false }\n * user.generate(seededRandom(42)) // reproducible seed data; omit the arg for a wall-clock-seeded source\n * ```\n */\nexport function createContract<S extends ContractShape>(shape: S): ContractInterface<Infer<S>>\nexport function createContract(shape: ContractShape): ContractInterface<unknown>\nexport function createContract(shape: ContractShape): ContractInterface<unknown> {\n\treturn contain(() => {\n\t\tconst compiler = new ContractCompiler(shape)\n\t\tconst expansion = ShapePass.expansionOf(shape)\n\t\tif (expansion === undefined || expansion === 1) return compiler.contract\n\t\treturn new LazyContract(shape, compiler).publish(compiler.schema)\n\t}, 'createContract')\n}\n","import type { JSONSchema } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tadmitVisited,\n\tattempt,\n\tenumerableKeys,\n\tisFailure,\n\tlimitEntries,\n\tmatchesVisited,\n\tomitVisited,\n\treadArrayEntries,\n\tretainDepth,\n\tsortValues,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisDate,\n\tisFiniteNumber,\n\tisInteger,\n\tisNull,\n\tisNumber,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport { stringToFormat, unifySchemas } from './inferers.js'\n\n/**\n * Owns the state of one single-value inference walk.\n *\n * @remarks\n * The engine behind `valueToSchema`, and the per-sample classifier\n * `samplesToSchema` reaches through {@link SampleInferer}. The walk's ancestor\n * set and its `(object, remaining depth)` memo are `#` fields rather than\n * parameters, so no caller can pre-populate either and change what the walk\n * treats as a cycle or serves from cache. Construction observes nothing;\n * `infer` runs the whole walk.\n *\n * Every budget arrives already sanitized: the door applies `sanitizeDepth` and\n * `sanitizeBudget` once, so the walk carries a depth no deeper than\n * `INFER_DEPTH_LIMIT` and a finite non-negative breadth. Depth decrements per\n * level and exhaustion widens to the empty accept-anything schema.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class ValueInferer {\n\t// Captured while this module evaluates: the constructor runs outside every\n\t// containment the doors place, so reaching `globalThis` there would leave the\n\t// door open one call earlier than any boundary can see.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: unknown\n\treadonly #depth: number\n\treadonly #breadth: number\n\treadonly #closed: boolean\n\treadonly #format: boolean\n\treadonly #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, JSONSchema>>\n\n\tconstructor(value: unknown, depth: number, breadth: number, closed: boolean, format: boolean) {\n\t\tthis.#source = value\n\t\tthis.#depth = depth\n\t\tthis.#breadth = breadth\n\t\tthis.#closed = closed\n\t\tthis.#format = format\n\t\tthis.#visited = new ValueInferer.#weakSet()\n\t\tthis.#memo = new ValueInferer.#weakMap()\n\t}\n\n\t/**\n\t * Infers a JSON Schema fragment for the retained value.\n\t *\n\t * @returns The inferred schema fragment\n\t * @throws When a traversed container cannot be read\n\t */\n\tinfer(): JSONSchema {\n\t\treturn this.#infer(this.#source, this.#depth)\n\t}\n\n\t// The recursive spine, shared by the root and by every collected property or\n\t// element. Terminates on cyclic readable input through the ancestor set; a\n\t// failed traversal is refused by the containing public reader. Leaf\n\t// classification order: `null`, boolean, integer (`Number.isInteger`\n\t// semantics — `-0` counts), finite non-integer number, string (gaining a\n\t// `format` keyword when `format` is on and `stringToFormat` matches), array\n\t// (recurse), plain record (recurse), `Date` (`{ type: 'string' }`, plus\n\t// `format: 'date-time'` when `format` is on); everything else — a NON-FINITE\n\t// number (`NaN` / `±Infinity`), a function, a symbol, a bigint, `undefined`,\n\t// and other non-plain objects such as `Map` / `Set` — is the empty\n\t// accept-anything schema `{}`.\n\t//\n\t// A non-finite number bottoms out with the other JSON-inexpressible values on\n\t// purpose: JSON carries no `NaN` / `±Infinity` (`JSON.stringify(Number.NaN)`\n\t// is `'null'`), so `{ type: 'number' }` would ASSERT something a JSON Schema\n\t// validator rejects — and the shape `schemaToShape` builds from it would\n\t// reject the very sample it was inferred from. `{}` is the truthful\n\t// description, and it inverts to an accept-anything shape, keeping\n\t// `compileGuard(schemaToShape(valueToSchema(v)))(v)` true.\n\t#infer(value: unknown, depth: number): JSONSchema {\n\t\tif (isNull(value)) return { type: 'null' }\n\t\tif (isBoolean(value)) return { type: 'boolean' }\n\t\tif (isInteger(value)) return { type: 'integer' }\n\t\tif (isFiniteNumber(value)) return { type: 'number' }\n\t\t// A non-finite number has no JSON representation at all, so it widens to\n\t\t// `{}` with the other inexpressible values rather than claiming a `number`\n\t\t// type no validator would accept it under.\n\t\tif (isNumber(value)) return {}\n\t\tif (isString(value)) {\n\t\t\tif (this.#format) {\n\t\t\t\tconst detected = stringToFormat(value)\n\t\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t\t}\n\t\t\treturn { type: 'string' }\n\t\t}\n\t\tif (isArray(value)) return this.#walkArray(value, depth)\n\t\tif (isRecord(value)) return this.#walkRecord(value, depth)\n\t\tif (isDate(value)) {\n\t\t\treturn this.#format ? { type: 'string', format: 'date-time' } : { type: 'string' }\n\t\t}\n\t\treturn {}\n\t}\n\n\t// The array branch. An empty array infers `{ type: 'array' }` with no `items`.\n\t// Otherwise the first `#breadth` elements are classified and unified with\n\t// `unifySchemas`: a single distinct element schema becomes `items` directly;\n\t// several distinct schemas become `items: { anyOf: [...] }`. Depth exhaustion\n\t// or a cyclic re-encounter both yield `{}` instead of descending. A SPARSE\n\t// array (holes, for example `[1, , 3]`) has no JSON expression and widens to\n\t// the accept-anything `{}`, the same treatment `NaN`, a function, a symbol, a\n\t// `Map` and a `Set` receive — it is not read as a list of present `undefined`\n\t// leaves, because the array schema that reading produced was rejected by its\n\t// own compiled guard, which is the one direction the round-trip law forbids.\n\t//\n\t// ALL reads of `value` — including its `length` — happen inside `attempt`, and\n\t// the ancestor set is restored before the captured failure is rethrown, so a\n\t// hostile `length` getter, throwing own-getter element, or hostile element\n\t// access reaches the door's boundary with the walk already unwound. A\n\t// genuinely empty sampled list still returns `{ type: 'array' }` with no\n\t// `items`. A same-object re-inference at the same remaining depth is served\n\t// from the memo instead of recomputing, which guards a shared-reference DAG\n\t// against exponential blowup.\n\t#walkArray(value: readonly unknown[], depth: number): JSONSchema {\n\t\tif (!(depth > 0) || matchesVisited(this.#visited, value)) return {}\n\t\t// At a node reached through a cycle at the SAME remaining depth through two\n\t\t// different paths, the memo may serve the first traversal's already\n\t\t// cycle-truncated fragment (`{}`) to the second path instead of a fully\n\t\t// re-descended schema — a sound, deterministic over-approximation, never\n\t\t// a false-reject (a schema too permissive, never too strict).\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#memo, [value])?.get(depth)\n\t\tif (cached) return cached\n\t\tadmitVisited(this.#visited, value)\n\t\tconst outcome = attempt(() => {\n\t\t\tconst snapshot = readArrayEntries(value)\n\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t// A HOLE is an absent own property, and that is the lens every other\n\t\t\t// door in this package applies: `arrayOf`, `parseArray`, `isJSONValue`,\n\t\t\t// `cloneJSONValue`, `canonicalStringify` and the compiled array guard\n\t\t\t// all refuse a sparse array. Reading a hole as a PRESENT `undefined`\n\t\t\t// leaf made this door the one dissenter, and the disagreement was not\n\t\t\t// cosmetic: `valueToSchema([1, , 3])` emitted an array schema whose\n\t\t\t// guard REJECTED `[1, , 3]`, so the package published a schema that\n\t\t\t// refused the value it was inferred from. A non-dense snapshot has no\n\t\t\t// JSON expression, so it widens to `{}` alongside `NaN`, a function, a\n\t\t\t// symbol, a `Map` and a `Set` — which restores the round-trip law\n\t\t\t// rather than adding a fourth exception to it.\n\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\tconst entries = snapshot.value.entries\n\t\t\tconst length = INTRINSICS.ceil(INTRINSICS.min(entries.length, this.#breadth))\n\t\t\treturn INTRINSICS.from(\n\t\t\t\titerateIndices(() => length),\n\t\t\t\t(index) => this.#infer(entries[index], depth - 1),\n\t\t\t)\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (isFailure(outcome)) throw outcome.error\n\t\tconst sampled = outcome.value\n\t\tconst schema: JSONSchema =\n\t\t\tsampled === undefined\n\t\t\t\t? {}\n\t\t\t\t: sampled.length > 0\n\t\t\t\t\t? { type: 'array', items: unifySchemas(sampled) }\n\t\t\t\t\t: { type: 'array' }\n\t\tretainDepth(this.#memo, value, depth, schema)\n\t\treturn schema\n\t}\n\n\t// The plain-record branch. Own enumerable string keys through\n\t// `enumerableKeys`, sorted lexicographically for deterministic output, capped\n\t// at `#breadth`. This is the same property view compiled object guards,\n\t// parsers, and reporters use. Each property value is read inside `attempt`; a\n\t// hostile getter reaches the door's boundary. A readable property whose value\n\t// is `undefined` is DROPPED — JSON encodes no such property\n\t// (`JSON.stringify({ a: undefined })` is `'{}'`), so it contributes neither a\n\t// `properties` entry nor a `required` entry. Every other present key is\n\t// required.\n\t//\n\t// Emits `additionalProperties: false` when closed, `true` otherwise —\n\t// mirroring `compileSchema`'s object-emission convention — EXCEPT when the\n\t// sampled key list no longer describes every key `value` actually carries,\n\t// which happens when the own-key list exceeds `#breadth` (truncation), or when\n\t// a key was dropped for holding `undefined`. Either way `additionalProperties`\n\t// is forced to `true` regardless of the flag, because a CLOSED schema built\n\t// from an incomplete key list would reject the very object it was inferred\n\t// from (`recordOf` rejects any own key the shape does not declare).\n\t#walkRecord(value: Record<string, unknown>, depth: number): JSONSchema {\n\t\tif (!(depth > 0) || matchesVisited(this.#visited, value)) return {}\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#memo, [value])?.get(depth)\n\t\tif (cached) return cached\n\t\tadmitVisited(this.#visited, value)\n\t\t// Capture the whole key-enumeration and value-read walk, then unwind the\n\t\t// ancestor set before rethrowing. Readable depth or cycle exhaustion widens\n\t\t// to `{}`; unreadability never does.\n\t\tconst outcome = attempt(() => {\n\t\t\tconst snapshot = enumerableKeys(value)\n\t\t\tif (snapshot === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('property enumeration failed')\n\t\t\t}\n\t\t\tconst allKeys = sortValues(snapshot)\n\t\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\t\tconst truncated = allKeys.length > this.#breadth\n\t\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t\t// prototype — the same pattern compileGuard / compileParser use\n\t\t\t// (compilers.ts).\n\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) return { key, schema: undefined }\n\t\t\t\t\tconst propertyValue = value[key]\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tschema: propertyValue === undefined ? undefined : this.#infer(propertyValue, depth - 1),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst selected: ReadonlyArray<{ readonly key: string; readonly schema: JSONSchema }> =\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t(entry: (typeof observed)[number]) =>\n\t\t\t\t\t\tentry.key !== undefined && entry.schema !== undefined,\n\t\t\t\t])\n\t\t\tconst pairs: ReadonlyArray<readonly [string, JSONSchema]> = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(selected),\n\t\t\t\t[(entry: (typeof selected)[number]) => [entry.key, entry.schema]],\n\t\t\t)\n\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t\tnull,\n\t\t\t)\n\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(selected),\n\t\t\t\t[(entry: (typeof selected)[number]) => entry.key],\n\t\t\t)\n\t\t\tconst dropped: boolean = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t(entry: (typeof observed)[number]) => entry.key !== undefined && entry.schema === undefined,\n\t\t\t])\n\t\t\treturn { properties, required, partial: truncated || dropped }\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (isFailure(outcome)) throw outcome.error\n\t\tconst { properties, required, partial } = outcome.value\n\t\tconst schema: JSONSchema = {\n\t\t\ttype: 'object',\n\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\tadditionalProperties: partial ? true : !this.#closed,\n\t\t}\n\t\tretainDepth(this.#memo, value, depth, schema)\n\t\treturn schema\n\t}\n}\n","import type { JSONSchema, SampleMemo } from './types.js'\nimport { INFER_ENUM_LIMIT, INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tbuildSampleMemo,\n\tenumerableKeys,\n\tisFailure,\n\tlimitEntries,\n\treadSampleMemo,\n\tsortValues,\n} from './helpers.js'\nimport { isRecord } from './validators.js'\nimport { inferPrimitiveEnum, samplesToFormat, unifySchemas } from './inferers.js'\nimport { ValueInferer } from './ValueInferer.js'\n\n/**\n * Owns the state of one multi-sample inference walk.\n *\n * @remarks\n * The engine behind `samplesToSchema`, which is the only door that constructs\n * it. The walk's {@link SampleMemo} is a `#` field rather than a parameter, so\n * no caller can pre-populate it and serve one walk another walk's answer.\n * Construction observes nothing; `infer` runs the whole walk.\n *\n * Every sample list the walk carries is owned: the door reads and dense-checks\n * the caller's array before construction, and every list below the root is\n * collected by this class. Every budget arrives already sanitized. Unlike the\n * single-value walk, the record path carries no ancestor set — a value shared by\n * reference across sample rows is legitimate data rather than a cycle back to an\n * ancestor — so termination rests on the decrementing depth budget and the\n * shared memo.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class SampleInferer {\n\treadonly #samples: readonly unknown[]\n\treadonly #depth: number\n\treadonly #breadth: number\n\treadonly #closed: boolean\n\treadonly #format: boolean\n\treadonly #enumerated: boolean\n\treadonly #memo: SampleMemo\n\n\tconstructor(\n\t\tsamples: readonly unknown[],\n\t\tdepth: number,\n\t\tbreadth: number,\n\t\tclosed: boolean,\n\t\tformat: boolean,\n\t\tenumerated: boolean,\n\t) {\n\t\tthis.#samples = samples\n\t\tthis.#depth = depth\n\t\tthis.#breadth = breadth\n\t\tthis.#closed = closed\n\t\tthis.#format = format\n\t\tthis.#enumerated = enumerated\n\t\tthis.#memo = buildSampleMemo()\n\t}\n\n\t/**\n\t * Infers one JSON Schema over the retained sample list.\n\t *\n\t * @returns The inferred schema\n\t * @throws When a sample row cannot be read\n\t */\n\tinfer(): JSONSchema {\n\t\treturn this.#infer(this.#samples, this.#depth, this.#memo)\n\t}\n\n\t// The shared non-record recursion step, entered at the top level and again per\n\t// collected property. When every value is itself a plain record, delegates to\n\t// the record branch. Otherwise: enum inference runs FIRST when enabled —\n\t// `inferPrimitiveEnum` fires only for a low-cardinality, repeated,\n\t// single-primitive-kind slot, and its `{ enum: [...] }` result wins outright\n\t// (ENUM > FORMAT > bare string). Failing that, each value is classified\n\t// independently by a fresh single-value walk with `format` FORCED OFF (the\n\t// multi-sample seam: nested formats never compound into an `anyOf`) and\n\t// unified with `unifySchemas`; only when that unified result is exactly\n\t// `{ type: 'string' }` and the outer format flag is on does `samplesToFormat`\n\t// run to (maybe) reattach a unanimous `format`.\n\t#infer(samples: readonly unknown[], depth: number, memo: SampleMemo): JSONSchema {\n\t\tif (samples.length === 0) return {}\n\t\tconst observed = INTRINSICS.from(\n\t\t\titerateIndices(() => samples.length),\n\t\t\t(index) => {\n\t\t\t\tconst sample = samples[index]\n\t\t\t\treturn isRecord(sample) ? sample : undefined\n\t\t\t},\n\t\t)\n\t\tconst records: ReadonlyArray<Record<string, unknown>> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(observed),\n\t\t\t[(sample: unknown) => sample !== undefined],\n\t\t)\n\t\tif (records.length === samples.length) {\n\t\t\treturn this.#walkRecords(records, depth, memo)\n\t\t}\n\t\tif (this.#enumerated) {\n\t\t\tconst enumSchema = inferPrimitiveEnum(samples, INFER_ENUM_LIMIT)\n\t\t\tif (enumSchema) return enumSchema\n\t\t}\n\t\tconst schemas = INTRINSICS.from(\n\t\t\titerateIndices(() => samples.length),\n\t\t\t(index) =>\n\t\t\t\tnew ValueInferer(samples[index], depth, this.#breadth, this.#closed, false).infer(),\n\t\t)\n\t\tconst unified = unifySchemas(schemas)\n\t\tif (this.#format && unified.type === 'string' && INTRINSICS.keys(unified).length === 1) {\n\t\t\tconst detected = samplesToFormat(samples)\n\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t}\n\t\treturn unified\n\t}\n\n\t// The record-specialized branch. `properties` is the union of every sample's\n\t// own keys (sorted, capped at `#breadth`); a key is `required` only when\n\t// present (and non-`undefined`) in EVERY sample. Each key's schema is inferred\n\t// over the collected values for that key through the shared step above (one\n\t// less depth), so a property that is itself an array or object of varying\n\t// shape across rows is unified the same way the top level is, and the same\n\t// format and enum gating applies per key.\n\t//\n\t// `additionalProperties` is forced to `true` regardless of the closed flag when\n\t// the key union exceeds `#breadth`, or a readable row carries a key as an own\n\t// property holding `undefined`. A hostile getter or failed KEY walk reaches the\n\t// door's boundary instead of dropping a key or widening the whole slot.\n\t//\n\t// The memo is keyed by the slot's ORDERED row identities, not by a single row.\n\t// Keying only the one-row slot left every MULTI-row slot — the shape this walk\n\t// exists for — re-inferring a shared child once per path: two rows sharing one\n\t// `{ a: child, b: child }` detail cost `2^depth` inferences, the identical\n\t// denial of service the one-row memo was added to remove.\n\t#walkRecords(\n\t\tsamples: ReadonlyArray<Record<string, unknown>>,\n\t\tdepth: number,\n\t\tmemo: SampleMemo,\n\t): JSONSchema {\n\t\tif (!(depth > 0)) return {}\n\t\t// The slot's ROW LIST is the key, followed one row at a time through the\n\t\t// memo's prefix chain, and the recorded schema is keyed by every budget and\n\t\t// flag the emission depends on. A multi-row list is a fresh array on every\n\t\t// call, but its rows are not: following their identities lands on the same\n\t\t// node whichever array carried them.\n\t\tconst node: SampleMemo = INTRINSICS.reflect.apply(INTRINSICS.fold, samples, [\n\t\t\t(current: SampleMemo, row: Record<string, unknown>) => {\n\t\t\t\tconst next = INTRINSICS.reflect.apply(INTRINSICS.recall, current.rows, [row])\n\t\t\t\tif (next !== undefined) return readSampleMemo(next, 'samplesToSchema')\n\t\t\t\tconst fresh = buildSampleMemo()\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, current.rows, [row, fresh])\n\t\t\t\treturn fresh\n\t\t\t},\n\t\t\tmemo,\n\t\t])\n\t\tconst signature = `${depth}|${this.#breadth}|${this.#closed}|${this.#format}|${this.#enumerated}`\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.fetch, node.schemas, [signature])\n\t\tif (cached !== undefined) return cached\n\t\tconst keyPairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(samples), [\n\t\t\t(sample: Record<string, unknown> | undefined) => {\n\t\t\t\tif (sample === undefined) {\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t}\n\t\t\t\tconst sampleKeys = enumerableKeys(sample)\n\t\t\t\tif (sampleKeys === undefined) {\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: property enumeration failed')\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(sampleKeys), [\n\t\t\t\t\t(key: string) => [key, true],\n\t\t\t\t])\n\t\t\t},\n\t\t])\n\t\tconst keySet = INTRINSICS.record<boolean>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [keyPairs]),\n\t\t})\n\t\tconst allKeys = sortValues(INTRINSICS.keys(keySet))\n\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\tconst truncated = allKeys.length > this.#breadth\n\t\tconst columns = INTRINSICS.from(\n\t\t\titerateIndices(() => keys.length),\n\t\t\t(index) => {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) return { key, schema: undefined, dropped: false, required: false }\n\t\t\t\tconst valuesOutcome = attempt(() => {\n\t\t\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => samples.length),\n\t\t\t\t\t\t(sampleIndex) => {\n\t\t\t\t\t\t\tconst sample = samples[sampleIndex]\n\t\t\t\t\t\t\tif (sample === undefined) {\n\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst value = sample[key]\n\t\t\t\t\t\t\treturn { value, dropped: value === undefined && INTRINSICS.own(sample, key) }\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tconst present = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t\t(entry: { readonly value: unknown }) => entry.value !== undefined,\n\t\t\t\t\t])\n\t\t\t\t\tconst values: readonly unknown[] = INTRINSICS.reflect.apply(\n\t\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\t\treadIndexView(present),\n\t\t\t\t\t\t[(entry: { readonly value: unknown }) => entry.value],\n\t\t\t\t\t)\n\t\t\t\t\tconst dropped: boolean = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t\t\t(entry: { readonly dropped: boolean }) => entry.dropped,\n\t\t\t\t\t])\n\t\t\t\t\treturn { values, dropped }\n\t\t\t\t})\n\t\t\t\tif (isFailure(valuesOutcome)) throw valuesOutcome.error\n\t\t\t\tconst { values, dropped } = valuesOutcome.value\n\t\t\t\treturn {\n\t\t\t\t\tkey,\n\t\t\t\t\tschema: values.length > 0 ? this.#infer(values, depth - 1, memo) : undefined,\n\t\t\t\t\tdropped,\n\t\t\t\t\trequired: !dropped && values.length === samples.length,\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(columns), [\n\t\t\t(column: { readonly key: string | undefined; readonly schema: JSONSchema | undefined }) =>\n\t\t\t\tcolumn.key === undefined || column.schema === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [[column.key, column.schema]],\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.expand,\n\t\t\treadIndexView(columns),\n\t\t\t[\n\t\t\t\t(column: { readonly key: string | undefined; readonly required: boolean }) =>\n\t\t\t\t\tcolumn.required && column.key !== undefined ? [column.key] : [],\n\t\t\t],\n\t\t)\n\t\tconst partial =\n\t\t\ttruncated ||\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, columns, [\n\t\t\t\t(column: { readonly dropped: boolean }) => column.dropped,\n\t\t\t])\n\t\tconst schema: JSONSchema = {\n\t\t\ttype: 'object',\n\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\tadditionalProperties: partial ? true : !this.#closed,\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, node.schemas, [signature, schema])\n\t\treturn schema\n\t}\n}\n","import type { JSONSchema, SchemaFormat, ValueToSchemaOptions } from './types.js'\nimport { FORMAT_MAX_LENGTH, INFER_BREADTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { isFiniteNumber, isRecord, isString } from './validators.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tcanonicalStringify,\n\tclassifyFormat,\n\tcontain,\n\tisFailure,\n\tisSuccess,\n\treadArrayEntries,\n\treadOptions,\n\treadValue,\n\tsanitizeBudget,\n\tsanitizeDepth,\n\tsortValues,\n} from './helpers.js'\nimport { SampleInferer } from './SampleInferer.js'\nimport { ValueInferer } from './ValueInferer.js'\n\n// The inferers walk an UNKNOWN, possibly adversarial runtime value (or a set\n// of example values) and emit a JSONSchema — the reverse direction of\n// compileSchema (compilers.ts), which walks a finite, developer-authored\n// ContractShape tree. Recursion here is runtime-only and bounded on three\n// axes: a WeakSet of ancestor objects/arrays (cycle safety), a decrementing\n// depth budget held at the INFER_DEPTH_LIMIT ceiling, and a per-container sampling cap\n// (INFER_BREADTH_LIMIT default). Readable unsupported values widen only where\n// documented; failed traversal is a coded refusal, never a permissive schema.\n\n/**\n * Unifies a list of inferred `JSONSchema` fragments into one schema.\n *\n * @remarks\n * De-duplicates by {@link canonicalStringify}, then applies the one\n * special-case subsumption inference performs: a bare `{ type: 'integer' }`\n * alongside a bare `{ type: 'number' }` collapses to `{ type: 'number' }`\n * (an integer sample is also a valid `number` sample). A single surviving\n * distinct schema is returned directly; two or more are wrapped as\n * `{ anyOf: [...] }`, sorted by their canonical key for deterministic output.\n * An empty input list returns the empty accept-anything schema `{}`.\n *\n * Every captured member must first be a non-null object record. This runtime\n * requirement is realm-agnostic and admits ordinary and null-prototype schema\n * records while refusing primitives and callables before canonicalization.\n *\n * A readable member {@link canonicalStringify} cannot key — a cyclic or\n * otherwise JSON-inexpressible fragment, which only a direct caller can supply\n * since the inferers always build plain encodable fragments — has NO\n * de-duplication key, so it can participate in neither de-duplication nor the\n * canonical-key ordering. It is KEPT (dropping a variant would narrow the\n * union, and unification only ever widens), appended in input order after the\n * sorted keyed members. A failed member read propagates the canonicalizer's\n * coded refusal instead of participating in the union.\n *\n * @param schemas - The schemas to unify\n * @returns The unified schema\n *\n * @example\n * ```ts\n * unifySchemas([{ type: 'integer' }, { type: 'number' }]) // { type: 'number' }\n * unifySchemas([{ type: 'string' }, { type: 'boolean' }])\n * // { anyOf: [{ type: 'boolean' }, { type: 'string' }] }\n * ```\n */\nexport function unifySchemas(schemas: readonly JSONSchema[]): JSONSchema {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(schemas)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense) throw new INTRINSICS.error('unifySchemas: schemas must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length === 0) return {}\n\t\t\t\tconst keyed = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => owned.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst schema = owned[index]\n\t\t\t\t\t\tif (schema === undefined || !isRecord(schema)) {\n\t\t\t\t\t\t\tthrow new INTRINSICS.error('unifySchemas: schemas must be records')\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { key: canonicalStringify(schema), schema }\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst encodable = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(keyed), [\n\t\t\t\t\t(entry: { readonly key: string | undefined }) => entry.key !== undefined,\n\t\t\t\t])\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(encodable), [\n\t\t\t\t\t(entry: { readonly key: string; readonly schema: JSONSchema }) => [\n\t\t\t\t\t\tentry.key,\n\t\t\t\t\t\tentry.schema,\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst reversed = INTRINSICS.reflect.apply(INTRINSICS.flip, pairs, [])\n\t\t\t\tconst byKey = INTRINSICS.record<JSONSchema>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\treversed,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst integerKey = canonicalStringify({ type: 'integer' })\n\t\t\t\tconst numberKey = canonicalStringify({ type: 'number' })\n\t\t\t\tconst subsumed =\n\t\t\t\t\tintegerKey !== undefined &&\n\t\t\t\t\tnumberKey !== undefined &&\n\t\t\t\t\tINTRINSICS.own(byKey, integerKey) &&\n\t\t\t\t\tINTRINSICS.own(byKey, numberKey)\n\t\t\t\t\t\t? integerKey\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst keys = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(byKey)),\n\t\t\t\t\t[(key: string) => key !== subsumed],\n\t\t\t\t)\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst unkeyed: ReadonlyArray<{ readonly schema: JSONSchema }> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(keyed),\n\t\t\t\t\t[(entry: { readonly key: string | undefined }) => entry.key === undefined],\n\t\t\t\t)\n\t\t\t\tconst members = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => ordered.length + unkeyed.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\t\treturn key === undefined ? unkeyed[index - ordered.length]?.schema : byKey[key]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tif (members.length <= 1) {\n\t\t\t\t\tconst only = members[0]\n\t\t\t\t\treturn only ?? {}\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tanyOf: INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(members), [\n\t\t\t\t\t\t(schema: JSONSchema | undefined) => schema !== undefined,\n\t\t\t\t\t]),\n\t\t\t\t}\n\t\t\t},\n\t\t\t'unifySchemas',\n\t\t\t{ subject: 'schemas' },\n\t\t)\n\t}, 'unifySchemas')\n}\n\n// === Format inference\n\n/**\n * Classifies a string against the {@link SchemaFormat} vocabulary.\n *\n * @remarks\n * Total, pure, and deterministic. Fixed precedence, most specific first:\n * `'uuid'`, `'date-time'`, `'date'`, `'time'`, `'email'`, `'uri'` — the first\n * match wins. The `date-time` / `date` / `time` branches require BOTH a\n * strict ISO-8601 shape match AND a real {@link matchesISOInstant} validity\n * check, so a shape-plausible but impossible date (`2020-13-45`) is rejected.\n * Returns `undefined` when no format matches (including the empty string).\n *\n * @param value - The string to classify\n * @returns The matched {@link SchemaFormat}, or `undefined`\n *\n * @example\n * ```ts\n * stringToFormat('550e8400-e29b-41d4-a716-446655440000') // 'uuid'\n * stringToFormat('2024-01-15') // 'date'\n * stringToFormat('2020-13-45') // undefined — invalid date\n * stringToFormat('ada@example.com') // 'email'\n * stringToFormat('10:30:00') // undefined — RFC 3339 time requires an offset\n * stringToFormat('10:30:00+02:00') // 'time'\n * ```\n */\nexport function stringToFormat(value: string): SchemaFormat | undefined {\n\tif (!isString(value)) return undefined\n\tif (value.length > FORMAT_MAX_LENGTH) return undefined\n\t// Total by containment at the door: every classification below dispatches\n\t// through `RegExp.prototype.test`/`.exec`, caller-writable members reached by\n\t// name, and this reader is documented to answer `SchemaFormat | undefined`\n\t// with no `@throws` at all.\n\tconst outcome = attempt(() => classifyFormat(value))\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Classifies a list of sample values against the {@link SchemaFormat}\n * vocabulary, requiring unanimity.\n *\n * @remarks\n * A format is returned ONLY IF every value is a string AND every one maps to\n * the SAME {@link stringToFormat} result (including all mapping to\n * `undefined`, which itself returns `undefined` here). A single disagreeing\n * value, a non-string value, or an empty list all yield `undefined` — the\n * multi-sample seam behind {@link samplesToSchema}\n * relies on this unanimity so a slot with mixed string shapes emits a bare\n * `{ type: 'string' }` rather than an `anyOf` of formats.\n *\n * @param values - The sample values to classify\n * @returns The unanimous {@link SchemaFormat}, or `undefined`\n *\n * @example\n * ```ts\n * samplesToFormat(['2024-01-01', '2024-02-02']) // 'date'\n * samplesToFormat(['2024-01-01', 'not a date']) // undefined\n * samplesToFormat([]) // undefined\n * ```\n */\nexport function samplesToFormat(values: readonly unknown[]): SchemaFormat | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(values)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense)\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToFormat: values must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length === 0) return undefined\n\t\t\t\tconst initial = owned[0]\n\t\t\t\tconst first = isString(initial) ? stringToFormat(initial) : undefined\n\t\t\t\tif (first === undefined) return undefined\n\t\t\t\tconst mismatch = INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t(value: unknown, index: number) =>\n\t\t\t\t\t\tindex > 0 && (!isString(value) || stringToFormat(value) !== first),\n\t\t\t\t])\n\t\t\t\tif (mismatch) return undefined\n\t\t\t\treturn first\n\t\t\t},\n\t\t\t'samplesToFormat',\n\t\t\t{ subject: 'values' },\n\t\t)\n\t}, 'samplesToFormat')\n}\n\n// === Enum inference\n\n/**\n * Infers an `{ enum: [...] }` fragment for a low-cardinality, repeated\n * primitive slot — the multi-sample-only counterpart to\n * {@link stringToFormat} ({@link valueToSchema} never emits `enum`).\n *\n * @remarks\n * Fires only when ALL of: every value is the same primitive kind (all string\n * or all FINITE number through {@link isFiniteNumber} — any `null`/boolean/mixed\n * slot never qualifies, and a slot containing `NaN` / `±Infinity` never\n * qualifies either, since {@link canonicalStringify} collapses `NaN` to\n * `'null'` and would otherwise risk an invalid-JSON `enum`); at least 2\n * values are given; the distinct-by-{@link canonicalStringify} count is LESS\n * than the value count (repetition required — separates a categorical column\n * from an ID column); and the distinct count is at most `limit`. The emitted\n * schema carries `enum` with NO `type` key, byte-matching `compileSchema`'s\n * `literalShape` emission. Members are sorted by canonical key for\n * deterministic output.\n *\n * A member {@link canonicalStringify} cannot key has no identity to\n * de-duplicate against, so the whole slot is enum-INELIGIBLE and returns\n * `undefined` — widening to the caller's bare `type` rather than emitting an\n * `enum` that might silently omit a value. (A string or finite number always\n * canonicalizes, so this only guards the total contract.)\n *\n * @param values - The collected slot values\n * @param limit - The maximum distinct-value count before giving up\n * @returns The `{ enum: [...] }` fragment, or `undefined` when ineligible\n *\n * @example\n * ```ts\n * inferPrimitiveEnum(['active', 'inactive', 'active'], 12)\n * // { enum: ['active', 'inactive'] }\n * inferPrimitiveEnum(['a', 'b', 'c'], 12) // undefined — no repetition\n * ```\n */\nexport function inferPrimitiveEnum(\n\tvalues: readonly unknown[],\n\tlimit: number,\n): JSONSchema | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(values)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense)\n\t\t\t\t\tthrow new INTRINSICS.error('inferPrimitiveEnum: values must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length < 2) return undefined\n\t\t\t\tconst allString = !INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t(value: unknown) => !isString(value),\n\t\t\t\t])\n\t\t\t\tconst allNumber =\n\t\t\t\t\t!allString &&\n\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t\t(value: unknown) => !isFiniteNumber(value),\n\t\t\t\t\t])\n\t\t\t\tif (!allString && !allNumber) return undefined\n\t\t\t\tconst pairs = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => owned.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\t\treturn [canonicalStringify(value), value]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, pairs, [\n\t\t\t\t\t\t(pair: readonly unknown[]) => pair[0] === undefined,\n\t\t\t\t\t])\n\t\t\t\t) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst byKey = INTRINSICS.record<string | number>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst keys = INTRINSICS.keys(byKey)\n\t\t\t\tif (keys.length >= owned.length || keys.length > limit) return undefined\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst population: ReadonlyArray<string | number> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(ordered),\n\t\t\t\t\t[(key: string) => byKey[key]],\n\t\t\t\t)\n\t\t\t\treturn { enum: population }\n\t\t\t},\n\t\t\t'inferPrimitiveEnum',\n\t\t\t{ subject: 'values' },\n\t\t)\n\t}, 'inferPrimitiveEnum')\n}\n\n// === Single-value inference\n\n/**\n * Infers a `JSONSchema` for one unknown value — the reverse direction of\n * {@link compileSchema}.\n *\n * @remarks\n * Cycle-, depth-, and breadth-bounded: the walk keeps an ancestor set and an\n * `(object, remaining depth)` memo of its own, so a cyclic host terminates and a\n * shared-reference DAG costs its nodes rather than its paths. A failed traversal\n * throws a `structure`\n * {@link ContractError}; it never becomes `{}` or another permissive schema. Nested\n * objects close to unknown keys (`additionalProperties: false`) by default;\n * pass `closed: false` to open them. `format` (default `false`) opts a\n * string/`Date` leaf into the `format` keyword. Structurally-equal inputs\n * infer byte-identical schemas (object keys and `anyOf` members are sorted).\n *\n * A non-object root — for example `valueToSchema('hi')` yielding `{ type: 'string'\n * }` — is structurally accepted by `schemaToParameters`, but MCP clients\n * expect an object-shaped `inputSchema`; wrap a non-object payload with\n * {@link schemaToObject} before advertising it as a tool's parameters.\n *\n * `limits.properties` is sanitized through {@link sanitizeBudget} to a finite\n * non-negative integer, falling back to {@link INFER_BREADTH_LIMIT} for anything\n * else (`NaN`, `Infinity`, negative, fractional), so a malformed breadth cannot\n * corrupt the sampled key/element list.\n *\n * `limits.depth` goes through {@link sanitizeDepth}, which does the same and then caps\n * at {@link INFER_DEPTH_LIMIT}, so the option NARROWS the walk and cannot widen\n * it. The cap is what makes the depth guard unbreakable: depth is the recursing\n * axis, so an uncapped large-but-valid budget would descend until the call STACK\n * failed rather than until the guard says stop.\n *\n * @param value - The value to infer a schema from\n * @param options - Optional {@link ValueToSchemaLimits} `limits` plus `closed` / `format` bounds\n * @returns The inferred `JSONSchema`\n * @throws {ContractError} When the value or options cannot be read\n *\n * @example\n * ```ts\n * valueToSchema({ id: 1, name: 'Ada', tags: ['a', 'b'] })\n * // { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' },\n * // tags: { type: 'array', items: { type: 'string' } } },\n * // required: ['id', 'name', 'tags'], additionalProperties: false }\n * ```\n */\nexport function valueToSchema(value: unknown, options?: ValueToSchemaOptions): JSONSchema {\n\treturn contain(() => {\n\t\tconst optionsSnapshot = readOptions(\n\t\t\toptions,\n\t\t\t['limits', 'closed', 'format', 'enum'],\n\t\t\t'valueToSchema',\n\t\t\t'schema',\n\t\t)\n\t\t// The grouped budgets cross the same contained read the flat keys crossed:\n\t\t// `limits` is a caller-owned record, so a hostile getter or `ownKeys` trap\n\t\t// on it refuses under this door's name rather than reaching the walk.\n\t\tconst limits = readOptions(\n\t\t\toptionsSnapshot?.limits,\n\t\t\t['depth', 'properties'],\n\t\t\t'valueToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst depth = sanitizeDepth(limits?.depth)\n\t\tconst properties = sanitizeBudget(limits?.properties, INFER_BREADTH_LIMIT)\n\t\tconst closed = optionsSnapshot?.closed ?? true\n\t\tconst format = optionsSnapshot?.format ?? false\n\t\t// The whole walk runs inside this door's own read boundary, so a hostile\n\t\t// getter, `length` trap, or key enumeration anywhere below it is published\n\t\t// under this door's name rather than under the name of an engine method no\n\t\t// consumer can call.\n\t\treturn readValue(\n\t\t\t() => new ValueInferer(value, depth, properties, closed, format).infer(),\n\t\t\t'valueToSchema',\n\t\t)\n\t}, 'valueToSchema')\n}\n\n// === Multi-sample inference\n\n/**\n * Infers a `JSONSchema` from a set of example values — the multi-example\n * counterpart of {@link valueToSchema} (for example inferring one schema from\n * several database rows).\n *\n * @remarks\n * An empty `samples` array infers the empty accept-anything schema `{}`.\n * When every sample is a plain record, properties/required are unified\n * per-key across all samples — a key\n * required iff present and non-`undefined` in every sample. Otherwise the\n * slot is inferred one value at a time (independent {@link valueToSchema}\n * per sample, unified with {@link unifySchemas} — the same de-duplication and\n * `anyOf` ordering an array's element schemas receive). `format`\n * and `enum` (both default `false`) opt a low-cardinality/unanimous-format\n * slot into the corresponding keyword: enum inference runs first and wins\n * outright, and a unanimous format is reattached only to a slot that unified to\n * exactly `{ type: 'string' }`, with nested formats forced off. `limits.depth` /\n * `limits.properties` are resolved exactly as {@link valueToSchema} resolves them —\n * breadth through {@link sanitizeBudget}, depth through {@link sanitizeDepth},\n * which also caps at {@link INFER_DEPTH_LIMIT}; see there for why.\n *\n * @param samples - The example values to infer a schema from\n * @param options - Optional {@link ValueToSchemaLimits} `limits` plus `closed` / `format` / `enum` bounds\n * @returns The inferred `JSONSchema`\n * @throws {ContractError} When the samples or options cannot be read\n *\n * @example\n * ```ts\n * samplesToSchema([{ id: 1 }, { id: 2, name: 'Ada' }])\n * // { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } },\n * // required: ['id'], additionalProperties: false }\n * samplesToSchema([]) // {}\n * ```\n */\nexport function samplesToSchema(\n\tsamples: readonly unknown[],\n\toptions?: ValueToSchemaOptions,\n): JSONSchema {\n\treturn contain(() => {\n\t\tconst optionsSnapshot = readOptions(\n\t\t\toptions,\n\t\t\t['limits', 'closed', 'format', 'enum'],\n\t\t\t'samplesToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst limits = readOptions(\n\t\t\toptionsSnapshot?.limits,\n\t\t\t['depth', 'properties'],\n\t\t\t'samplesToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst depth = sanitizeDepth(limits?.depth)\n\t\tconst properties = sanitizeBudget(limits?.properties, INFER_BREADTH_LIMIT)\n\t\tconst closed = optionsSnapshot?.closed ?? true\n\t\tconst format = optionsSnapshot?.format ?? false\n\t\tconst enumOn = optionsSnapshot?.enum ?? false\n\t\tconst read = readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(samples)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\treturn snapshot.value\n\t\t\t},\n\t\t\t'samplesToSchema',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t\t// A hole is READABLE. Reporting it as `samples could not be read` paired a\n\t\t// true refusal with a false diagnosis and contradicted the guide's own\n\t\t// attribution of that message to \"a hostile getter or failed key walk\".\n\t\tif (!read.dense) {\n\t\t\tthrow new ContractError('samplesToSchema: samples must be a dense array', {\n\t\t\t\tcode: 'structure',\n\t\t\t})\n\t\t}\n\t\t// The recursion stays inside this door's own read boundary, so a failed read\n\t\t// anywhere below is still published as `samplesToSchema: samples could not\n\t\t// be read` rather than under the name of an internal spine function.\n\t\treturn readValue(\n\t\t\t() => new SampleInferer(read.entries, depth, properties, closed, format, enumOn).infer(),\n\t\t\t'samplesToSchema',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t}, 'samplesToSchema')\n}\n","import type {\n\tContractShape,\n\tJSONSchema,\n\tJSONSchemaType,\n\tLiteralValue,\n\tOptionalShape,\n} from './types.js'\nimport {\n\tCOMPILE_NODE_LIMIT,\n\tFAULT_SCHEMA_LIMIT,\n\tINFER_BREADTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tJSON_SCHEMA_TYPES,\n\tSTRICT_SCHEMA_KEYWORDS,\n} from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitMember,\n\tadmitVisited,\n\tcollectMembers,\n\tderiveLengthBounds,\n\tderiveRangeBounds,\n\tisFailure,\n\tlimitEntries,\n\titerateIndices,\n\tmatchesMember,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\trenderPath,\n\ttruncateFaultText,\n\treadArrayEntries,\n\tretainDepth,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisJSONValue,\n\tisLiteralValue,\n\tisObject,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport { parseEnumValues } from './parsers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnullableShape,\n\tnullShape,\n\tnumberShape,\n\tobjectShape,\n\toneOfShape,\n\toptionalShape,\n\trawShape,\n\tstringShape,\n\tunionShape,\n} from './shapers.js'\n\n/**\n * Owns the state of one schema-inversion walk.\n *\n * @remarks\n * The engine behind `schemaToShape`, which is the only door that constructs it.\n * The walk's cycle set and its `(node, remaining depth)` memo are `#` fields\n * rather than parameters, so no caller can pre-populate either and change what\n * the conversion widens. Construction observes nothing; `shape` runs the whole\n * walk and every refusal it raises is published by that door under the door's\n * own name. A strict walk refuses where a lenient one widens, through the one\n * `#widen` both share, and its per-node `#inspect` refuses every keyword the\n * lenient precedence would read past.\n *\n * The recursion is `#` private for the same reason it is bounded: it is the\n * class's defining spine, and its state has no meaning outside one call. The\n * collection constructors are captured while this module evaluates, so a caller\n * who replaces `globalThis.WeakSet` or `globalThis.WeakMap` before the door runs\n * cannot make construction throw a raw value out of a door documented to refuse\n * with a `ContractError`.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class SchemaShaper {\n\t// Captured while this module evaluates, exactly as the cloners capture theirs:\n\t// the constructor runs outside every containment this class has, so reaching\n\t// `globalThis` there would leave the door open one call earlier than any\n\t// boundary can see.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: JSONSchema\n\treadonly #strict: boolean\n\treadonly #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, ContractShape>>\n\t// A second memo for the nodes reached below a union, because a default that fills\n\t// beside a union must drop inside one, so one node converts to two different shapes.\n\treadonly #enclosed: WeakMap<object, Map<number, ContractShape>>\n\t// A third for the nodes reached below a strict `oneOf`, where a silent object refuses\n\t// though it would close anywhere else.\n\treadonly #exclusive: WeakMap<object, Map<number, ContractShape>>\n\treadonly #path: string[]\n\t#oneOfs: number\n\t// The steps that built a shape node, and whether a memo served a node twice, so a tree\n\t// too small to overflow the compile limit pays for no second count.\n\t#built: number\n\t#shared: boolean\n\n\tconstructor(schema: JSONSchema, strict = false) {\n\t\tthis.#source = schema\n\t\tthis.#strict = strict\n\t\tthis.#visited = new SchemaShaper.#weakSet()\n\t\tthis.#memo = new SchemaShaper.#weakMap()\n\t\tthis.#enclosed = new SchemaShaper.#weakMap()\n\t\tthis.#exclusive = new SchemaShaper.#weakMap()\n\t\tthis.#path = []\n\t\tthis.#oneOfs = 0\n\t\tthis.#built = 0\n\t\tthis.#shared = false\n\t}\n\n\t/**\n\t * Converts the retained schema into a validating contract shape.\n\t *\n\t * @returns The built shape, widened wherever a lenient schema is inexpressible\n\t * @throws {ContractError} When schema traversal fails, or when a strict conversion refuses\n\t */\n\tshape(): ContractShape {\n\t\tif (this.#strict && isRecord(this.#source) && INTRINSICS.own(this.#source, 'default')) {\n\t\t\tthrow this.#refusal('a default needs an optional property to fill', 'default')\n\t\t}\n\t\tconst shape = this.#convert(this.#source, INFER_DEPTH_LIMIT, false)\n\t\treturn !this.#strict && this.#exceeds(shape) ? this.#shallow(shape) : shape\n\t}\n\n\t// A lenient schema must always compile, so one past the compile limit keeps only its\n\t// root. No step builds more than nine shape nodes, so a sharing-free walk of a\n\t// sixteenth of the limit cannot overflow it and pays for no second count. A memo hit\n\t// means the walk built less than the shape expands into, so it always asks the\n\t// validator.\n\t#exceeds(shape: ContractShape): boolean {\n\t\tif (!this.#shared && this.#built <= COMPILE_NODE_LIMIT / 16) return false\n\t\tconst validator = new ShapeValidator(shape)\n\t\tvalidator.validate()\n\t\treturn (validator.expansion ?? 0) > COMPILE_NODE_LIMIT\n\t}\n\n\t// What a shape too large to compile can still enforce: its root's type, an array's\n\t// bounds, and an object's required keys and closure, with every value below them raw.\n\t// A root with no such form widens whole. Keys stop at `INFER_BREADTH_LIMIT`, so what\n\t// this builds always compiles.\n\t#shallow(shape: ContractShape): ContractShape {\n\t\tconst raw = rawShape({})\n\t\tswitch (shape.category) {\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableShape(this.#shallow(shape.inner))\n\t\t\tcase 'array':\n\t\t\t\treturn arrayShape(\n\t\t\t\t\traw,\n\t\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...(shape.min === undefined ? {} : { min: shape.min }),\n\t\t\t\t\t\t\t...(shape.max === undefined ? {} : { max: shape.max }),\n\t\t\t\t\t\t\t...(shape.description === undefined ? {} : { description: shape.description }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\tcase 'object': {\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(shape.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tshape.properties[key]?.category === 'optional' ? optionalShape(raw) : raw,\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\treturn objectShape(\n\t\t\t\t\tproperties,\n\t\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadditionalProperties: isObject(extra) ? raw : (extra ?? false),\n\t\t\t\t\t\t\t...(shape.description === undefined ? {} : { description: shape.description }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn raw\n\t\t}\n\t}\n\n\t// The per-node entry point the root and every child recursion share. Guards\n\t// depth exhaustion, a readable non-record node (the node's static `JSONSchema`\n\t// type is not trusted at runtime), and a cyclic re-encounter — all three widen\n\t// to `rawShape`. The ancestor set is added to and removed from around the\n\t// WHOLE subtree conversion, so a DAG-shaped schema reached twice through two\n\t// different noncyclic paths does not false-positive as a cycle. A same-node\n\t// re-conversion at the same remaining depth is served from the memo, which\n\t// guards a shared-reference schema DAG against exponential blowup.\n\t#convert(schema: JSONSchema, depth: number, enclosed: boolean): ContractShape {\n\t\tif (!(depth > 0)) return this.#widen('a schema may not nest past the depth limit', undefined)\n\t\tif (!matchesRecordBrand(schema)) {\n\t\t\treturn this.#widen('every schema node must be a plain record', undefined)\n\t\t}\n\t\tif (matchesVisited(this.#visited, schema)) {\n\t\t\treturn this.#widen('a schema may not contain a cycle', undefined)\n\t\t}\n\t\t// The memo read is dispatched through the captured `Map.prototype.get`\n\t\t// too: a substitute answering a decoy would put a shape this package\n\t\t// never built into one it publishes as its own.\n\t\tconst memo = this.#oneOfs > 0 ? this.#exclusive : enclosed ? this.#enclosed : this.#memo\n\t\tconst depthMemo = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [schema])\n\t\tconst cached =\n\t\t\tdepthMemo === undefined\n\t\t\t\t? undefined\n\t\t\t\t: INTRINSICS.reflect.apply(INTRINSICS.fetch, depthMemo, [depth])\n\t\tif (cached) {\n\t\t\tthis.#shared = true\n\t\t\treturn cached\n\t\t}\n\t\tadmitVisited(this.#visited, schema)\n\t\ttry {\n\t\t\tif (this.#strict) this.#inspect(schema)\n\t\t\tconst built = this.#build(schema, depth, enclosed)\n\t\t\t// Read here rather than in `#build`, which a type list re-enters per member. The\n\t\t\t// OpenAPI keyword stays out of `JSONSchema`, and a strict walk has refused it.\n\t\t\tconst nullable =\n\t\t\t\tINTRINSICS.own(schema, 'nullable') && INTRINSICS.reflect.read(schema, 'nullable') === true\n\t\t\tconst shape = nullable ? nullableShape(built) : built\n\t\t\tretainDepth(memo, schema, depth, shape)\n\t\t\treturn shape\n\t\t} finally {\n\t\t\tomitVisited(this.#visited, schema)\n\t\t}\n\t}\n\n\t// One step down the schema, carrying the path a strict refusal names. Only a\n\t// property's optional wrapper can hold a default, so every other child refuses one.\n\t#descend(\n\t\tschema: JSONSchema,\n\t\tdepth: number,\n\t\tenclosed: boolean,\n\t\tfirst: string,\n\t\tsecond?: string,\n\t): ContractShape {\n\t\tthis.#path[this.#path.length] = first\n\t\tif (second !== undefined) this.#path[this.#path.length] = second\n\t\tif (\n\t\t\tthis.#strict &&\n\t\t\tfirst !== 'properties' &&\n\t\t\tisRecord(schema) &&\n\t\t\tINTRINSICS.own(schema, 'default')\n\t\t) {\n\t\t\tthrow this.#refusal('a default needs an optional property to fill', 'default')\n\t\t}\n\t\tconst shape = this.#convert(schema, depth, enclosed)\n\t\tthis.#path.length -= second === undefined ? 1 : 2\n\t\treturn shape\n\t}\n\n\t// What the lenient walk widens, the strict walk refuses. The widening keeps the\n\t// node's description, as it always has.\n\t#widen(\n\t\tmessage: string,\n\t\tdescription: string | undefined,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t): ContractShape {\n\t\tif (this.#strict) throw this.#refusal(message, first, second)\n\t\tthis.#built += 1\n\t\treturn rawShape(description === undefined ? {} : { description })\n\t}\n\n\t// Sets a description on a shape that has a place for one, overriding its own: a keyword\n\t// beside a union describes the field, which outranks what one arm says of itself.\n\t#describe(shape: ContractShape, description: string | undefined): ContractShape {\n\t\tif (description === undefined) return shape\n\t\tswitch (shape.category) {\n\t\t\tcase 'optional':\n\t\t\t\treturn shape\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableShape(this.#describe(shape.inner, description))\n\t\t\tcase 'raw':\n\t\t\t\treturn rawShape({ ...shape.schema, description })\n\t\t\tdefault:\n\t\t\t\treturn INTRINSICS.freeze({ ...shape, description })\n\t\t}\n\t}\n\n\t#refusal(message: string, first?: string, second?: string, third?: string): ContractError {\n\t\tconst path = pathOf(this.#path, first, second, third)\n\t\treturn new ContractError(\n\t\t\t`schemaToShape: ${message} at ${truncateFaultText(renderPath(path) || 'value', FAULT_SCHEMA_LIMIT)}`,\n\t\t\t{\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path, shape: 'schema' },\n\t\t\t},\n\t\t)\n\t}\n\n\t// The per-node keyword check of a strict conversion. It refuses every keyword the\n\t// lenient walk would read past, so `#build` never drops an assertion: a malformed\n\t// value, a keyword outside the vocabulary, a keyword the node's type never reads,\n\t// and a pair of keywords only one of which the walk would keep.\n\t#inspect(schema: JSONSchema): void {\n\t\tconst keys = INTRINSICS.keys(schema)\n\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) continue\n\t\t\tconst known = INTRINSICS.reflect.apply(INTRINSICS.some, STRICT_SCHEMA_KEYWORDS, [\n\t\t\t\t(keyword: string) => keyword === key,\n\t\t\t])\n\t\t\tif (!known) throw this.#refusal('a strict conversion refuses a keyword it cannot honour', key)\n\t\t}\n\t\tthis.#inspectAnnotations(schema)\n\t\tif (INTRINSICS.own(schema, 'default') && !isJSONValue(schema.default)) {\n\t\t\tthrow this.#refusal('a default must be a JSON value', 'default')\n\t\t}\n\t\tconst types = this.#inspectType(schema)\n\t\tthis.#inspectForm(schema, types)\n\t\tconst hasForm =\n\t\t\tINTRINSICS.own(schema, 'enum') ||\n\t\t\tINTRINSICS.own(schema, 'oneOf') ||\n\t\t\tINTRINSICS.own(schema, 'anyOf')\n\t\tconst object = types.length === 0 && INTRINSICS.own(schema, 'properties') ? ['object'] : types\n\t\tconst effective: readonly string[] = hasForm ? [] : object\n\t\tthis.#confine(schema, ['minLength', 'maxLength'], this.#names(effective, 'string'))\n\t\tthis.#confine(schema, ['minimum', 'maximum'], this.#names(effective, 'number', 'integer'))\n\t\tthis.#confine(schema, ['items', 'minItems', 'maxItems'], this.#names(effective, 'array'))\n\t\tthis.#confine(\n\t\t\tschema,\n\t\t\t['properties', 'required', 'additionalProperties'],\n\t\t\tthis.#names(effective, 'object'),\n\t\t)\n\t\tthis.#inspectLength(\n\t\t\tINTRINSICS.own(schema, 'minLength') ? schema.minLength : undefined,\n\t\t\tINTRINSICS.own(schema, 'maxLength') ? schema.maxLength : undefined,\n\t\t\t'minLength',\n\t\t\t'maxLength',\n\t\t)\n\t\tthis.#inspectLength(\n\t\t\tINTRINSICS.own(schema, 'minItems') ? schema.minItems : undefined,\n\t\t\tINTRINSICS.own(schema, 'maxItems') ? schema.maxItems : undefined,\n\t\t\t'minItems',\n\t\t\t'maxItems',\n\t\t)\n\t\tthis.#inspectRange(schema, this.#names(effective, 'integer'))\n\t\tthis.#inspectObject(schema)\n\t}\n\n\t#inspectAnnotations(schema: JSONSchema): void {\n\t\tconst texts = ['title', 'description', '$schema', '$id', '$comment']\n\t\tfor (const index of iterateIndices(() => texts.length)) {\n\t\t\tconst keyword = texts[index]\n\t\t\tif (keyword === undefined) continue\n\t\t\tconst value: unknown = INTRINSICS.own(schema, keyword)\n\t\t\t\t? INTRINSICS.reflect.read(schema, keyword)\n\t\t\t\t: undefined\n\t\t\tif (value !== undefined && !isString(value)) {\n\t\t\t\tthrow this.#refusal(`${keyword} must be a string`, keyword)\n\t\t\t}\n\t\t}\n\t\tconst flags = ['deprecated', 'readOnly', 'writeOnly']\n\t\tfor (const index of iterateIndices(() => flags.length)) {\n\t\t\tconst keyword = flags[index]\n\t\t\tif (keyword === undefined) continue\n\t\t\tconst value: unknown = INTRINSICS.own(schema, keyword)\n\t\t\t\t? INTRINSICS.reflect.read(schema, keyword)\n\t\t\t\t: undefined\n\t\t\tif (value !== undefined && !isBoolean(value)) {\n\t\t\t\tthrow this.#refusal(`${keyword} must be a boolean`, keyword)\n\t\t\t}\n\t\t}\n\t\tconst examples: unknown = INTRINSICS.own(schema, 'examples')\n\t\t\t? INTRINSICS.reflect.read(schema, 'examples')\n\t\t\t: undefined\n\t\tif (examples !== undefined && !isArray(examples)) {\n\t\t\tthrow this.#refusal('examples must be an array', 'examples')\n\t\t}\n\t}\n\n\t// The node's type names, an absent keyword reading as none.\n\t#inspectType(schema: JSONSchema): readonly string[] {\n\t\tconst declared: unknown = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\tif (declared === undefined) return []\n\t\tconst names = isArray(declared) ? this.#entries(declared, 'type') : [declared]\n\t\tconst known = names.length > 0 && this.#unique(names)\n\t\tconst types: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(JSON_SCHEMA_TYPES),\n\t\t\t[\n\t\t\t\t(type: JSONSchemaType) =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, names, [(name: unknown) => name === type]),\n\t\t\t],\n\t\t)\n\t\tif (!known || types.length !== names.length) {\n\t\t\tthrow this.#refusal('type must name the supported types', 'type')\n\t\t}\n\t\treturn types\n\t}\n\n\t#inspectForm(schema: JSONSchema, types: readonly string[]): void {\n\t\tif (INTRINSICS.own(schema, 'enum')) {\n\t\t\tconst members = this.#entries(schema.enum, 'enum')\n\t\t\tconst malformed = INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(entry: unknown) =>\n\t\t\t\t\tentry !== null &&\n\t\t\t\t\t(!isLiteralValue(entry) || (typeof entry === 'number' && !isFiniteNumber(entry))),\n\t\t\t])\n\t\t\tif (members.length === 0 || malformed || !this.#unique(members)) {\n\t\t\t\tthrow this.#refusal('enum must list unique finite primitives', 'enum')\n\t\t\t}\n\t\t\tconst contradicted = INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(entry: unknown) => types.length > 0 && !this.#fits(entry, types),\n\t\t\t])\n\t\t\tif (contradicted) throw this.#refusal('an enum member contradicts the type', 'enum')\n\t\t\tif (INTRINSICS.own(schema, 'oneOf')) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses oneOf beside enum', 'oneOf')\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'anyOf')) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses anyOf beside enum', 'anyOf')\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tconst keywords = ['oneOf', 'anyOf']\n\t\tfor (const index of iterateIndices(() => keywords.length)) {\n\t\t\tconst keyword = keywords[index]\n\t\t\tif (keyword === undefined || !INTRINSICS.own(schema, keyword)) continue\n\t\t\tconst variants = this.#entries(INTRINSICS.reflect.read(schema, keyword), keyword)\n\t\t\tif (variants.length === 0) throw this.#refusal(`${keyword} needs a variant`, keyword)\n\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\tif (!isRecord(variants[variantIndex])) {\n\t\t\t\t\tthrow this.#refusal(\n\t\t\t\t\t\t'every variant must be a schema',\n\t\t\t\t\t\tkeyword,\n\t\t\t\t\t\tINTRINSICS.text(variantIndex),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst union = INTRINSICS.own(schema, 'oneOf') || INTRINSICS.own(schema, 'anyOf')\n\t\tif (INTRINSICS.own(schema, 'oneOf') && INTRINSICS.own(schema, 'anyOf')) {\n\t\t\tthrow this.#refusal('a strict conversion refuses anyOf beside oneOf', 'anyOf')\n\t\t}\n\t\tif (union && types.length > 0) {\n\t\t\tthrow this.#refusal('a strict conversion refuses type beside a union', 'type')\n\t\t}\n\t}\n\n\t#inspectLength(min: unknown, max: unknown, minKey: string, maxKey: string): void {\n\t\tif (min !== undefined && !(INTRINSICS.safe(min) && INTRINSICS.numeric(min) >= 0)) {\n\t\t\tthrow this.#refusal('a length bound must be a non-negative safe integer', minKey)\n\t\t}\n\t\tif (max !== undefined && !(INTRINSICS.safe(max) && INTRINSICS.numeric(max) >= 0)) {\n\t\t\tthrow this.#refusal('a length bound must be a non-negative safe integer', maxKey)\n\t\t}\n\t\tif (isFiniteNumber(min) && isFiniteNumber(max) && min > max) {\n\t\t\tthrow this.#refusal('a length range may not be contradictory', minKey)\n\t\t}\n\t}\n\n\t#inspectRange(schema: JSONSchema, integer: boolean): void {\n\t\tconst min: unknown = INTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined\n\t\tconst max: unknown = INTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined\n\t\tif (min !== undefined && !isFiniteNumber(min)) {\n\t\t\tthrow this.#refusal('a range bound must be a finite number', 'minimum')\n\t\t}\n\t\tif (max !== undefined && !isFiniteNumber(max)) {\n\t\t\tthrow this.#refusal('a range bound must be a finite number', 'maximum')\n\t\t}\n\t\tif (isFiniteNumber(min) && isFiniteNumber(max)) {\n\t\t\tif (min > max) throw this.#refusal('a range may not be contradictory', 'minimum')\n\t\t\tif (integer && INTRINSICS.ceil(min) > INTRINSICS.floor(max)) {\n\t\t\t\tthrow this.#refusal('an integer range may not be empty', 'minimum')\n\t\t\t}\n\t\t}\n\t}\n\n\t#inspectObject(schema: JSONSchema): void {\n\t\tconst properties: unknown = INTRINSICS.own(schema, 'properties') ? schema.properties : undefined\n\t\tif (properties !== undefined && !isRecord(properties)) {\n\t\t\tthrow this.#refusal('properties must be a plain record', 'properties')\n\t\t}\n\t\tconst extra: unknown = INTRINSICS.own(schema, 'additionalProperties')\n\t\t\t? schema.additionalProperties\n\t\t\t: undefined\n\t\tif (extra !== undefined && !isBoolean(extra) && !isRecord(extra)) {\n\t\t\tthrow this.#refusal(\n\t\t\t\t'additionalProperties must be a boolean or a schema',\n\t\t\t\t'additionalProperties',\n\t\t\t)\n\t\t}\n\t\tif (!INTRINSICS.own(schema, 'required')) return\n\t\tconst names = this.#entries(schema.required, 'required')\n\t\tconst undeclared = INTRINSICS.reflect.apply(INTRINSICS.some, names, [\n\t\t\t(name: unknown) =>\n\t\t\t\t!isString(name) || !isRecord(properties) || !INTRINSICS.own(properties, name),\n\t\t])\n\t\tif (undeclared || !this.#unique(names)) {\n\t\t\tthrow this.#refusal('required must list unique declared properties', 'required')\n\t\t}\n\t}\n\n\t#confine(schema: JSONSchema, keywords: readonly string[], applies: boolean): void {\n\t\tif (applies) return\n\t\tfor (const index of iterateIndices(() => keywords.length)) {\n\t\t\tconst keyword = keywords[index]\n\t\t\tif (keyword !== undefined && INTRINSICS.own(schema, keyword)) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses a keyword this node never reads', keyword)\n\t\t\t}\n\t\t}\n\t}\n\n\t#names(types: readonly string[], ...names: readonly string[]): boolean {\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, types, [\n\t\t\t(type: string) =>\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, names, [(name: string) => name === type]),\n\t\t])\n\t}\n\n\t#fits(entry: unknown, types: readonly string[]): boolean {\n\t\tif (entry === null) return this.#names(types, 'null')\n\t\tif (isString(entry)) return this.#names(types, 'string')\n\t\tif (isBoolean(entry)) return this.#names(types, 'boolean')\n\t\treturn isInteger(entry) ? this.#names(types, 'number', 'integer') : this.#names(types, 'number')\n\t}\n\n\t#entries(value: unknown, keyword: string): readonly unknown[] {\n\t\tif (!isArray(value)) throw this.#refusal(`${keyword} must be an array`, keyword)\n\t\tconst snapshot = readArrayEntries(value)\n\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\tif (!snapshot.value.dense) throw this.#refusal(`${keyword} must be a dense array`, keyword)\n\t\treturn snapshot.value.entries\n\t}\n\n\t#unique(entries: readonly unknown[]): boolean {\n\t\tconst seen = collectMembers([])\n\t\tfor (const index of iterateIndices(() => entries.length)) {\n\t\t\tconst entry = entries[index]\n\t\t\tif (matchesMember(seen, entry)) return false\n\t\t\tadmitMember(seen, entry)\n\t\t}\n\t\treturn true\n\t}\n\n\t// The per-keyword precedence switch. Every keyword is read defensively — the\n\t// node's static `JSONSchema` type is NOT trusted at runtime — so a malformed\n\t// keyword falls through to the next rule instead of throwing. Precedence,\n\t// top-down:\n\t//\n\t// 0. `$ref` — this walk resolves no reference, and under draft-07 a reference\n\t// replaces its siblings, so nothing beside one can be read and the node widens.\n\t// 1. `enum` — finite string/number/boolean entries become a literal shape, a\n\t// `null` entry wraps it in a nullable, and `null` alone becomes a null shape.\n\t// Any other entry widens the node, because dropping it would narrow. An empty\n\t// list falls through.\n\t// 2. `oneOf` — an array with at least one arm becomes a union over the\n\t// recursively-built arms, provided the arm count is at or under\n\t// `INFER_BREADTH_LIMIT`; OVER the limit, building a subset union would be\n\t// strictly narrower than the schema's full union (a value matching only a\n\t// dropped variant would be wrongly rejected), so the whole node widens to\n\t// `rawShape` instead of sampling a subset. The union is inclusive, because a\n\t// keyword this walk does not read can make two arms overlap that the schema\n\t// keeps apart, and exactly-one over those arms refuses a value the schema\n\t// accepts. A strict walk reads every keyword, so it keeps exactly-one.\n\t// 3. `anyOf` — identically. In both, a `true` arm admits anything and a `false`\n\t// arm admits nothing, so `true` is a raw variant in declaration order and\n\t// `false` is dropped; a list its `false` arms leave empty widens. Two arms, one\n\t// of them `{ type: 'null' }`, read as a nullable of the other, which stays\n\t// outside a union, except under a strict `oneOf`. A description carries.\n\t// 4. Array-valued `type` — distinct recognized names become an inclusive\n\t// union, or a single shape for one name. Two names, one of them `null`, read\n\t// as a nullable of the other, in both modes: the list means what the `anyOf`\n\t// spelling means, and it has no exactly-one to keep. An empty list or any\n\t// unrecognized member widens the whole node; dropping a member would narrow it.\n\t// 5. `type: 'string'` / `'number'` / `'integer'` / `'boolean'` / `'null'` —\n\t// the matching primitive shape, with length/range bounds derived through\n\t// `deriveLengthBounds` / `deriveRangeBounds`. An integer node additionally\n\t// drops its bounds when they describe an EMPTY integer range (for example\n\t// `minimum: 1.5, maximum: 1.6`) — the same emptiness `validateShape`\n\t// rejects — so the result is always a valid shape.\n\t// 6. `type: 'array'` — an array shape whose element shape recurses into a\n\t// record-valued `items`, widening to `rawShape` otherwise, with bounds from\n\t// `minItems` / `maxItems`. A present `prefixItems` widens the elements too,\n\t// because `items` then applies only past the prefix.\n\t// 7. `type: 'object'` — delegates to the object branch. No `type` / `enum` /\n\t// `oneOf` / `anyOf` but a record-valued `properties` — `properties` and\n\t// `required` constrain only an object, so a lenient walk builds a union of\n\t// that object first, for field validation, and every other JSON type. A strict\n\t// walk reads it as an object.\n\t// 8. Everything else — an empty schema, an unrecognized/absent `type`, or\n\t// exhausted depth/breadth — widens to `rawShape`, whose guard accepts every\n\t// defined value and whose emitted schema is the same `{}` (plus\n\t// `description`) the node carried. That is the exact inverse of `{}`, JSON\n\t// Schema's accept-anything schema, and where the inferers themselves bottom\n\t// out at their own limits.\n\t//\n\t// `format` and `pattern` are NEVER read into the compiled shape — `format` is\n\t// annotation-only and compiling an attacker-supplied `pattern` into a `RegExp`\n\t// is a ReDoS vector. `description`, when a string, carries through to the\n\t// produced shape's `description` option.\n\t#build(schema: JSONSchema, depth: number, enclosed: boolean): ContractShape {\n\t\tthis.#built += 1\n\t\tconst description =\n\t\t\tINTRINSICS.own(schema, 'description') && isString(schema.description)\n\t\t\t\t? schema.description\n\t\t\t\t: undefined\n\n\t\tif (INTRINSICS.own(schema, '$ref')) {\n\t\t\treturn this.#widen('a reference is not resolved', description, '$ref')\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'enum') && isArray(schema.enum)) {\n\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\titerateIndices(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'enum']).length,\n\t\t\t\t),\n\t\t\t\t(index) =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'enum'])[index],\n\t\t\t)\n\t\t\tconst widened = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t(entry: unknown) =>\n\t\t\t\t\tentry !== null &&\n\t\t\t\t\t(!isLiteralValue(entry) || (typeof entry === 'number' && !isFiniteNumber(entry))),\n\t\t\t])\n\t\t\tif (widened) return this.#widen('an enum entry has no literal form', description, 'enum')\n\t\t\tconst valid: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(observed),\n\t\t\t\t[(entry: unknown) => entry !== null],\n\t\t\t)\n\t\t\tconst nullable = valid.length < observed.length\n\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(valid), [\n\t\t\t\t(entry: LiteralValue, index: number) => [\n\t\t\t\t\t`${typeof entry}:${INTRINSICS.text(entry)}`,\n\t\t\t\t\tindex,\n\t\t\t\t],\n\t\t\t])\n\t\t\tconst reversed = INTRINSICS.reflect.apply(INTRINSICS.flip, pairs, [])\n\t\t\tconst first = INTRINSICS.record<number>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\treversed,\n\t\t\t\t]),\n\t\t\t})\n\t\t\tconst literals: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(valid),\n\t\t\t\t[\n\t\t\t\t\t(entry: LiteralValue, index: number) =>\n\t\t\t\t\t\tfirst[`${typeof entry}:${INTRINSICS.text(entry)}`] === index,\n\t\t\t\t],\n\t\t\t)\n\t\t\tif (literals.length > 0) {\n\t\t\t\tconst literal = literalShape(\n\t\t\t\t\tliterals,\n\t\t\t\t\tdescription === undefined ? undefined : { description },\n\t\t\t\t)\n\t\t\t\treturn nullable ? nullableShape(literal) : literal\n\t\t\t}\n\t\t\tif (nullable) return nullShape(description === undefined ? undefined : { description })\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'oneOf') && isArray(schema.oneOf)) {\n\t\t\tconst union = this.#buildUnion(schema.oneOf, 'oneOf', depth, description, enclosed)\n\t\t\tif (union !== undefined) return union\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'anyOf') && isArray(schema.anyOf)) {\n\t\t\tconst union = this.#buildUnion(schema.anyOf, 'anyOf', depth, description, enclosed)\n\t\t\tif (union !== undefined) return union\n\t\t}\n\n\t\tconst category = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\tif (isArray(category)) {\n\t\t\tconst observed = INTRINSICS.from(parseEnumValues(category, JSON_SCHEMA_TYPES))\n\t\t\tif (\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t\t(entry: JSONSchemaType | undefined) => entry === undefined,\n\t\t\t\t])\n\t\t\t) {\n\t\t\t\treturn this.#widen('type must name the supported types', description, 'type')\n\t\t\t}\n\t\t\tconst members: readonly JSONSchemaType[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(observed),\n\t\t\t\t[\n\t\t\t\t\t(member: JSONSchemaType, index: number) =>\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, observed, [\n\t\t\t\t\t\t\t(entry: unknown) => entry === member,\n\t\t\t\t\t\t]) === index,\n\t\t\t\t],\n\t\t\t)\n\t\t\tif (members.length === 0 || members.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn this.#widen('type must name the supported types', description, 'type')\n\t\t\t}\n\t\t\tconst others: readonly JSONSchemaType[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[(member: JSONSchemaType) => member !== 'null'],\n\t\t\t)\n\t\t\tconst other = others[0]\n\t\t\tif (members.length === 2 && others.length === 1 && other !== undefined) {\n\t\t\t\treturn nullableShape(this.#build({ ...schema, type: other }, depth, enclosed))\n\t\t\t}\n\t\t\tconst variants: readonly ContractShape[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[\n\t\t\t\t\t(member: JSONSchemaType) =>\n\t\t\t\t\t\tthis.#build({ ...schema, type: member }, depth, enclosed || members.length > 1),\n\t\t\t\t],\n\t\t\t)\n\t\t\tconst first = variants[0]\n\t\t\tif (variants.length === 1 && first !== undefined) return first\n\t\t\tconst union = INTRINSICS.reflect.apply(unionShape, undefined, variants)\n\t\t\treturn description === undefined ? union : INTRINSICS.freeze({ ...union, description })\n\t\t}\n\n\t\tconst type = isString(category) && INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\n\t\tif (type === 'string') {\n\t\t\tconst bounds = deriveLengthBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minLength') ? schema.minLength : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maxLength') ? schema.maxLength : undefined,\n\t\t\t)\n\t\t\t// Builder options admit inherited values; this projection must carry only\n\t\t\t// the schema's own keywords, without reacquiring prototype data.\n\t\t\treturn stringShape(\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'number') {\n\t\t\tconst bounds = deriveRangeBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined,\n\t\t\t)\n\t\t\treturn numberShape(\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'integer') {\n\t\t\tconst bounds = deriveRangeBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined,\n\t\t\t)\n\t\t\tconst emptyRange =\n\t\t\t\tINTRINSICS.ceil(bounds.min ?? Number.NEGATIVE_INFINITY) >\n\t\t\t\tINTRINSICS.floor(bounds.max ?? Number.POSITIVE_INFINITY)\n\t\t\treturn integerShape(\n\t\t\t\temptyRange\n\t\t\t\t\t? description === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: INTRINSICS.rebase({ description }, null)\n\t\t\t\t\t: INTRINSICS.rebase(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'boolean') {\n\t\t\treturn booleanShape(description === undefined ? undefined : { description })\n\t\t}\n\t\tif (type === 'null') {\n\t\t\treturn nullShape(description === undefined ? undefined : { description })\n\t\t}\n\n\t\tif (type === 'array') {\n\t\t\tconst items = INTRINSICS.own(schema, 'prefixItems')\n\t\t\t\t? rawShape({})\n\t\t\t\t: INTRINSICS.own(schema, 'items') && isRecord(schema.items)\n\t\t\t\t\t? this.#descend(schema.items, depth - 1, enclosed, 'items')\n\t\t\t\t\t: this.#widen('an array needs an items schema', undefined, 'items')\n\t\t\tconst bounds = deriveLengthBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minItems') ? schema.minItems : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maxItems') ? schema.maxItems : undefined,\n\t\t\t)\n\t\t\treturn arrayShape(\n\t\t\t\titems,\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\tif (\n\t\t\ttype === 'object' ||\n\t\t\t(this.#strict &&\n\t\t\t\ttype === undefined &&\n\t\t\t\tINTRINSICS.own(schema, 'properties') &&\n\t\t\t\tisRecord(schema.properties))\n\t\t) {\n\t\t\treturn this.#buildObject(schema, depth, description, enclosed)\n\t\t}\n\t\tif (type === undefined && INTRINSICS.own(schema, 'properties') && isRecord(schema.properties)) {\n\t\t\treturn this.#describe(\n\t\t\t\tunionShape(\n\t\t\t\t\tthis.#buildObject(schema, depth, undefined, true),\n\t\t\t\t\tstringShape(),\n\t\t\t\t\tnumberShape(),\n\t\t\t\t\tbooleanShape(),\n\t\t\t\t\tnullShape(),\n\t\t\t\t\tarrayShape(rawShape({})),\n\t\t\t\t),\n\t\t\t\tdescription,\n\t\t\t)\n\t\t}\n\n\t\treturn this.#widen('a schema must name a type, an enum, or a union', description)\n\t}\n\n\t// One union keyword's arms, in declaration order. Answers `undefined` for a list\n\t// with no arm and no `false` entry, so a malformed keyword falls through.\n\t#buildUnion(\n\t\tlist: readonly unknown[],\n\t\tkeyword: 'oneOf' | 'anyOf',\n\t\tdepth: number,\n\t\tdescription: string | undefined,\n\t\tenclosed: boolean,\n\t): ContractShape | undefined {\n\t\tconst observed = INTRINSICS.from(\n\t\t\titerateIndices(() => list.length),\n\t\t\t(index) => list[index],\n\t\t)\n\t\tconst arms: ReadonlyArray<JSONSchema | true> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(observed),\n\t\t\t[(entry: unknown) => entry === true || isRecord(entry)],\n\t\t)\n\t\tif (arms.length > INFER_BREADTH_LIMIT) {\n\t\t\treturn this.#widen(`${keyword} exceeds the breadth limit`, description, keyword)\n\t\t}\n\t\tconst nulls: ReadonlyArray<JSONSchema | true> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(arms),\n\t\t\t[\n\t\t\t\t(entry: JSONSchema | true) =>\n\t\t\t\t\tentry !== true &&\n\t\t\t\t\tINTRINSICS.own(entry, 'type') &&\n\t\t\t\t\tentry.type === 'null' &&\n\t\t\t\t\t!INTRINSICS.own(entry, '$ref') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'enum') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'oneOf') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'anyOf'),\n\t\t\t],\n\t\t)\n\t\tconst hasTrue = INTRINSICS.reflect.apply(INTRINSICS.some, arms, [\n\t\t\t(entry: JSONSchema | true) => entry === true,\n\t\t])\n\t\tconst paired =\n\t\t\tarms.length === 2 && nulls.length === 1 && !hasTrue && !(this.#strict && keyword === 'oneOf')\n\t\tconst exclusive = this.#strict && keyword === 'oneOf' ? 1 : 0\n\t\tthis.#oneOfs += exclusive\n\t\tconst variants: readonly ContractShape[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(arms),\n\t\t\t[\n\t\t\t\t(entry: JSONSchema | true, index: number) => {\n\t\t\t\t\tif (entry !== true) {\n\t\t\t\t\t\tconst position = paired ? enclosed : true\n\t\t\t\t\t\treturn this.#descend(entry, depth - 1, position, keyword, INTRINSICS.text(index))\n\t\t\t\t\t}\n\t\t\t\t\tthis.#built += 1\n\t\t\t\t\treturn rawShape({})\n\t\t\t\t},\n\t\t\t],\n\t\t)\n\t\tthis.#oneOfs -= exclusive\n\t\tconst other = variants[arms[0] === nulls[0] ? 1 : 0]\n\t\tif (paired && other !== undefined) {\n\t\t\treturn nullableShape(this.#describe(other, description))\n\t\t}\n\t\t// `Reflect.apply` reads its argument list by index, where a spread call\n\t\t// would dispatch through the caller-writable array iterator.\n\t\tif (variants.length > 0) {\n\t\t\tconst build = this.#strict && keyword === 'oneOf' ? oneOfShape : unionShape\n\t\t\treturn this.#describe(INTRINSICS.reflect.apply(build, undefined, variants), description)\n\t\t}\n\t\tconst dropped = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t(entry: unknown) => entry === false,\n\t\t])\n\t\treturn dropped ? this.#widen(`${keyword} admits nothing`, description, keyword) : undefined\n\t}\n\n\t// The object-specialized branch. `properties` (when a record) contributes one\n\t// child shape per own key, capped at `INFER_BREADTH_LIMIT`; a key is wrapped\n\t// in `optionalShape` unless it appears as a string entry of `required`. A\n\t// property whose value is not itself a record widens to `rawShape`.\n\t// `additionalProperties`: `false` closes the object; a record value recurses\n\t// into it (`objectShape` validates extras against that shape); anything else —\n\t// `true`, absent, or malformed — leaves the object OPEN (`true`), matching\n\t// JSON Schema's own absent-means-open default and the fact that the inference\n\t// doors always emit the keyword explicitly, so an absent value only arises\n\t// from a hand-written schema. When `properties` has MORE keys than\n\t// `INFER_BREADTH_LIMIT`, the schema's own `additionalProperties` is OVERRIDDEN\n\t// and forced to `true` (fully open) — a dropped key's value could otherwise\n\t// fail a `false` or record-valued rest shape it was never checked against —\n\t// mirroring the record inference's partial-key handling. The accumulator uses\n\t// a null-prototype record so a property literally named `__proto__` becomes an\n\t// own data key rather than mutating the prototype. A present `patternProperties`\n\t// opens the object whatever its own `additionalProperties` says, because a key\n\t// that keyword admits is unread here; `propertyNames` exempts no key from\n\t// `additionalProperties`, so it opens nothing. A strict conversion refuses the\n\t// truncation and closes an object whose schema is silent, except below a `oneOf`,\n\t// where closing it could change which arms match, so it refuses that too.\n\t#buildObject(\n\t\tschema: JSONSchema,\n\t\tdepth: number,\n\t\tdescription: string | undefined,\n\t\tenclosed: boolean,\n\t): ContractShape {\n\t\tif (this.#oneOfs > 0 && !INTRINSICS.own(schema, 'additionalProperties')) {\n\t\t\tthrow this.#refusal(\n\t\t\t\t'an object below a oneOf must declare additionalProperties, because closing it could change which arms match',\n\t\t\t\t'additionalProperties',\n\t\t\t)\n\t\t}\n\t\tconst propertiesSource =\n\t\t\tINTRINSICS.own(schema, 'properties') && isRecord(schema.properties)\n\t\t\t\t? schema.properties\n\t\t\t\t: undefined\n\t\tconst requiredSource =\n\t\t\tINTRINSICS.own(schema, 'required') && isArray(schema.required)\n\t\t\t\t? INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'required'])\n\t\t\t\t\t\t\t\t\t.length,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t(index) =>\n\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'required'])[\n\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t],\n\t\t\t\t\t)\n\t\t\t\t: []\n\t\tconst allKeys = propertiesSource === undefined ? [] : INTRINSICS.keys(propertiesSource)\n\t\tconst truncated = allKeys.length > INFER_BREADTH_LIMIT\n\t\tif (this.#strict && truncated) {\n\t\t\tthrow this.#refusal('properties exceeds the breadth limit', 'properties')\n\t\t}\n\t\tconst keys = limitEntries(allKeys, INFER_BREADTH_LIMIT)\n\t\tconst extra = INTRINSICS.own(schema, 'additionalProperties')\n\t\t\t? schema.additionalProperties\n\t\t\t: undefined\n\t\tconst unread = truncated || INTRINSICS.own(schema, 'patternProperties')\n\t\tconst open = unread || (extra !== false && (!this.#strict || extra !== undefined))\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keys), [\n\t\t\t(key: string) => {\n\t\t\t\tconst child =\n\t\t\t\t\tpropertiesSource !== undefined && INTRINSICS.own(propertiesSource, key)\n\t\t\t\t\t\t? propertiesSource[key]\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst childShape = isRecord(child)\n\t\t\t\t\t? this.#descend(child, depth - 1, enclosed, 'properties', key)\n\t\t\t\t\t: this.#widen(\n\t\t\t\t\t\t\t'every property schema must be a plain record',\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\tconst required = INTRINSICS.reflect.apply(INTRINSICS.some, requiredSource, [\n\t\t\t\t\t(entry: unknown) => isString(entry) && entry === key,\n\t\t\t\t])\n\t\t\t\tif (!required) return [key, this.#wrap(key, child, childShape, open || enclosed)]\n\t\t\t\tif (this.#strict && isRecord(child) && INTRINSICS.own(child, 'default')) {\n\t\t\t\t\tthrow this.#refusal(\n\t\t\t\t\t\t'a default needs an optional property to fill',\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t'default',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn [key, childShape]\n\t\t\t},\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tconst additionalProperties: boolean | ContractShape = unread\n\t\t\t? true\n\t\t\t: isRecord(extra)\n\t\t\t\t? this.#descend(extra, depth - 1, enclosed, 'additionalProperties')\n\t\t\t\t: open\n\t\treturn INTRINSICS.freeze({\n\t\t\tcategory: 'object',\n\t\t\tproperties: INTRINSICS.freeze(properties),\n\t\t\tadditionalProperties,\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t})\n\t}\n\n\t// The one place a schema's `default` becomes a shape's. The lenient walk stays total\n\t// by carrying only what can compile: a primitive or literal the property's guard\n\t// accepts, in a slot that can fill. The strict walk carries any default, and refuses\n\t// one the guard refuses or a slot that cannot fill, naming the path in the schema.\n\t#wrap(\n\t\tkey: string,\n\t\tchild: JSONSchema | undefined,\n\t\tshape: ContractShape,\n\t\tsealed: boolean,\n\t): OptionalShape {\n\t\tthis.#built += 1\n\t\tif (!isRecord(child) || !INTRINSICS.own(child, 'default')) return optionalShape(shape)\n\t\tconst value = child.default\n\t\tif (!isJSONValue(value)) return optionalShape(shape)\n\t\tif (this.#strict) {\n\t\t\tif (sealed) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'schemaToShape: a default cannot fill under a union or on a property of an open object; close the object or remove the default',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\tcontext: { path: pathOf(this.#path, 'properties', key, 'default'), shape: 'schema' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (new ContractCompiler(shape).guard(value)) return optionalShape(shape, { default: value })\n\t\t\tthrow this.#refusal('a default must satisfy its schema', 'properties', key, 'default')\n\t\t}\n\t\tconst leaf =\n\t\t\tshape.category === 'string' ||\n\t\t\tshape.category === 'number' ||\n\t\t\tshape.category === 'boolean' ||\n\t\t\tshape.category === 'null' ||\n\t\t\tshape.category === 'literal'\n\t\treturn !sealed && leaf && new ContractCompiler(shape).guard(value)\n\t\t\t? optionalShape(shape, { default: value })\n\t\t\t: optionalShape(shape)\n\t}\n}\n","import type { AuditFaultShape } from './types.js'\nimport { FAULT_CONSTRAINTS, FAULT_KINDS } from './constants.js'\nimport { pinMembers } from './helpers.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnumberShape,\n\tobjectShape,\n\toptionalShape,\n\tstringShape,\n\tunionShape,\n} from './shapers.js'\n\n/**\n * Retains a lazily built fault declaration without building shapes during module evaluation.\n *\n * @example\n * ```ts\n * FaultShaper.shape === FaultShaper.shape // true\n * ```\n */\nexport class FaultShaper {\n\tstatic #shape: AuditFaultShape | undefined\n\n\t/** Returns the shared fault declaration, building it on the first read. */\n\tstatic get shape(): AuditFaultShape {\n\t\treturn (FaultShaper.#shape ??= new FaultShaper().build())\n\t}\n\n\t/**\n\t * Builds a closed fault union whose inferred values satisfy the audit fault contract.\n\t *\n\t * @example\n\t * ```ts\n\t * createContract(new FaultShaper().build()).is({ reason: 'extra', path: [] }) // true\n\t * ```\n\t */\n\tbuild() {\n\t\tconst path = unionShape(stringShape(), arrayShape(stringShape()))\n\t\tconst expected = literalShape(FAULT_KINDS)\n\t\tconst hints = arrayShape(unionShape(stringShape(), numberShape(), booleanShape()))\n\t\treturn unionShape(\n\t\t\tobjectShape({ reason: literalShape(['type']), path, expected, received: stringShape() }),\n\t\t\tobjectShape({ reason: literalShape(['missing']), path, expected }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['constraint']),\n\t\t\t\tpath,\n\t\t\t\texpected,\n\t\t\t\tconstraint: literalShape(FAULT_CONSTRAINTS),\n\t\t\t\tlimit: optionalShape(unionShape(numberShape(), stringShape())),\n\t\t\t\treceived: stringShape(),\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['variant']), path, variants: integerShape({ min: 0 }) }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['variant']),\n\t\t\t\tpath,\n\t\t\t\tvariants: integerShape({ min: 0 }),\n\t\t\t\tkey: stringShape(),\n\t\t\t\texpected: hints,\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['oneOf']), path, matched: integerShape({ min: 0 }) }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['oneOf']),\n\t\t\t\tpath,\n\t\t\t\tmatched: integerShape({ min: 0 }),\n\t\t\t\tkey: stringShape(),\n\t\t\t\texpected: hints,\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['extra']), path }),\n\t\t)\n\t}\n\n\tstatic {\n\t\tpinMembers(FaultShaper.prototype, 'FaultShaper')\n\t}\n}\n","import type {\n\tArrayShape,\n\tAuditFaultShape,\n\tArrayShapeOptions,\n\tBooleanShape,\n\tBooleanShapeOptions,\n\tContractShape,\n\tJSONSchema,\n\tJSONShape,\n\tJSONShapeOptions,\n\tLiteralShape,\n\tLiteralShapeOptions,\n\tLiteralValue,\n\tNullableShape,\n\tNullShape,\n\tNullShapeOptions,\n\tNumberShape,\n\tNumberShapeOptions,\n\tObjectShape,\n\tObjectShapeOptions,\n\tOptionalShape,\n\tOptionalShapeOptions,\n\tRawShape,\n\tRecordShapeOptions,\n\tSchemaToShapeOptions,\n\tShapeShape,\n\tShapeShapeOptions,\n\tStringShape,\n\tStringShapeOptions,\n\tUnionShape,\n} from './types.js'\nimport { cloneJSONValue, cloneSchema, cloneShape } from './cloners.js'\nimport { SchemaShaper } from './SchemaShaper.js'\nimport { ShapePass } from './ShapePass.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { FaultShaper } from './FaultShaper.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tcontain,\n\tisFailure,\n\tisSuccess,\n\tmatchesRecordBrand,\n\tpreview,\n\treadArrayEntries,\n\treadOptions,\n\treadPatternFlags,\n\treadPatternSource,\n\treadValue,\n\trefuseOptionKeys,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isObject, isRegExp } from './validators.js'\nimport { ContractError, isContractError } from './errors.js'\n\n/**\n * Returns the shared closed audit-fault shape, building it on the first call.\n *\n * @remarks\n * Numeric bounds, counts, and discriminator literals must be finite. Discriminator hints\n * carry both key and expected together. The inferred union is assignable to AuditFault.\n *\n * @example\n * ```ts\n * createContract(auditFaultShape()).is({ reason: 'extra', path: ['typo'] }) // true\n * ```\n */\nexport function auditFaultShape(): AuditFaultShape {\n\treturn contain(() => FaultShaper.shape, 'auditFaultShape')\n}\n\n// The builders return the parameterized types.ts interfaces (for example `ArrayShape<S>`,\n// `ObjectShape<P>`), never inline object literals — the generic parameter keeps\n// `Infer<typeof shape>` exact while the return type still enforces conformance to\n// the shared shape interface.\n\n// Shape builders — pure constructors for the `ContractShape` union. Each returns\n// a plain descriptor; the compilers (compilers.ts) turn it into a guard, parser,\n// schema, and generator. The precise return types (for example literal tuples, generic\n// `items` / `properties`) are preserved so `Infer<typeof shape>` stays exact.\n\n// === Primitives\n\n/**\n * Builds a string {@link StringShape}.\n *\n * @remarks\n * A supplied pattern is captured by source and flags. The shape exposes a fresh\n * frozen zero-state `RegExp` on every `pattern` read, so neither the caller's\n * original nor a value read from the shape can drift later compiled artifacts.\n *\n * @param options - Optional length (`min` / `max`), `pattern`, and `description`\n * @returns A string shape\n * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, or `pattern` has flags\n *\n * @example\n * ```ts\n * const name = stringShape({ min: 1, max: 80, description: 'Display name' })\n * ```\n */\nexport function stringShape(options?: StringShapeOptions): StringShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['min', 'max', 'pattern', 'description'],\n\t\t\t'stringShape',\n\t\t\t'string',\n\t\t)\n\t\tconst pattern = safe?.pattern\n\t\tif (safe?.min !== undefined && (!INTRINSICS.safe(safe.min) || safe.min < 0)) {\n\t\t\tthrow new ContractError('stringShape: min must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'string',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.min),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && (!INTRINSICS.safe(safe.max) || safe.max < 0)) {\n\t\t\tthrow new ContractError('stringShape: max must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'string',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.max),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (pattern !== undefined && !isRegExp(pattern)) {\n\t\t\tthrow new ContractError('stringShape: pattern must be a RegExp', {\n\t\t\t\tcode: 'pattern',\n\t\t\t\tcontext: { shape: 'string', received: typeof pattern },\n\t\t\t})\n\t\t}\n\t\tconst patternSnapshot =\n\t\t\tpattern === undefined\n\t\t\t\t? undefined\n\t\t\t\t: readValue(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Source and flags through the CAPTURED accessors, and the\n\t\t\t\t\t\t\t// rendered text built from them rather than through\n\t\t\t\t\t\t\t// `RegExp.prototype.toString`: all three are caller-writable\n\t\t\t\t\t\t\t// members, and this snapshot decides both the pattern a published\n\t\t\t\t\t\t\t// shape carries and the text a refusal quotes back.\n\t\t\t\t\t\t\tconst source = readPatternSource(pattern)\n\t\t\t\t\t\t\tconst flags = readPatternFlags(pattern)\n\t\t\t\t\t\t\tif (source === undefined || flags === undefined) {\n\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('Pattern source and flags could not be read')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn { source, flags, text: `/${source}/${flags}` }\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'stringShape',\n\t\t\t\t\t\t{ subject: 'pattern', code: 'pattern', context: { shape: 'string' } },\n\t\t\t\t\t)\n\t\tif (patternSnapshot !== undefined && patternSnapshot.flags.length > 0) {\n\t\t\tthrow new ContractError(\n\t\t\t\t'stringShape: pattern must not use flags; use inline pattern constructs instead',\n\t\t\t\t{\n\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\tcontext: { shape: 'string', received: patternSnapshot.text },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst shape: StringShape = {\n\t\t\tcategory: 'string',\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(patternSnapshot === undefined\n\t\t\t\t? {}\n\t\t\t\t: { pattern: new INTRINSICS.pattern(patternSnapshot.source) }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\t// The snapshot is what refuses a field inherited as `undefined`, which a walk reads\n\t\t// as absent, so only a clean prototype lets a plain node skip it.\n\t\tif (patternSnapshot === undefined && !ShapePass.polluted()) return ShapePass.seal(shape)\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn ShapePass.seal(cloneShape(shape))\n\t}, 'stringShape')\n}\n\n/**\n * Builds a numeric {@link NumberShape}.\n *\n * @remarks\n * A present `min` or `max` must be finite. `NaN` and `±Infinity` throw a `bound` {@link\n * ContractError} at construction, because no finite value satisfies them and no JSON\n * Schema keyword expresses them.\n *\n * @param options - Optional bounds (`min` / `max`), `integer`, and `description`\n * @returns A number shape\n * @throws {ContractError} When a present bound is not finite\n *\n * @example\n * ```ts\n * const age = numberShape({ min: 0, max: 120 })\n * ```\n */\nexport function numberShape(options?: NumberShapeOptions): NumberShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['min', 'max', 'integer', 'description'],\n\t\t\t'numberShape',\n\t\t\t'number',\n\t\t)\n\t\tconst shape = safe?.integer === true ? 'integer' : 'number'\n\t\tif (safe?.min !== undefined && !INTRINSICS.finite(safe.min)) {\n\t\t\tthrow new ContractError('numberShape: min must be finite', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: { shape, limit: 'finite number', received: preview(safe.min) },\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && !INTRINSICS.finite(safe.max)) {\n\t\t\tthrow new ContractError('numberShape: max must be finite', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: { shape, limit: 'finite number', received: preview(safe.max) },\n\t\t\t})\n\t\t}\n\t\tconst result: NumberShape = {\n\t\t\tcategory: 'number',\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(safe?.integer === undefined ? {} : { integer: safe.integer }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(result)\n\t}, 'numberShape')\n}\n\n/**\n * Builds an integer {@link NumberShape} — forces `integer: true`.\n *\n * @remarks\n * The emitted JSON Schema uses `\"type\": \"integer\"` and the guard rejects\n * fractional numbers.\n *\n * @param options - Optional bounds and `description` (no `integer` key)\n * @returns An integer number shape\n * @throws {ContractError} When a present bound is not finite\n */\nexport function integerShape(options?: Omit<NumberShapeOptions, 'integer'>): NumberShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'description'], 'integerShape', 'integer')\n\t\treturn numberShape({ ...safe, integer: true })\n\t}, 'integerShape')\n}\n\n/**\n * Builds a {@link BooleanShape}.\n *\n * @param options - Optional `description`\n * @returns A boolean shape\n *\n * @example\n * ```ts\n * const active = booleanShape({ description: 'Whether the record is active' })\n * ```\n */\nexport function booleanShape(options?: BooleanShapeOptions): BooleanShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'booleanShape', 'boolean')\n\t\tconst shape: BooleanShape = {\n\t\t\tcategory: 'boolean',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'booleanShape')\n}\n\n/**\n * Builds a {@link NullShape}.\n *\n * @param options - Optional `description`\n * @returns A null shape\n *\n * @example\n * ```ts\n * const empty = nullShape()\n * ```\n */\nexport function nullShape(options?: NullShapeOptions): NullShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'nullShape', 'null')\n\t\tconst shape: NullShape = {\n\t\t\tcategory: 'null',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'nullShape')\n}\n\n/**\n * Builds a literal shape from a fixed set of primitive values.\n *\n * @param values - The permitted literals\n * @param options - Optional `description`\n * @returns A literal shape whose `Infer` is the union of `values`\n *\n * @example\n * ```ts\n * const role = literalShape(['admin', 'member', 'guest'])\n * // Infer<typeof role> = 'admin' | 'member' | 'guest'\n *\n * const via = literalShape(['function', 'tool', 'agent'], { description: 'How to run the step.' })\n * ```\n */\nexport function literalShape<const T extends readonly LiteralValue[]>(\n\tvalues: T,\n\toptions?: LiteralShapeOptions,\n): LiteralShape<Readonly<T>>\nexport function literalShape(\n\tvalues: readonly LiteralValue[],\n\toptions?: LiteralShapeOptions,\n): LiteralShape {\n\treturn contain(() => {\n\t\tconst input: unknown = values\n\t\tconst array = attempt(() => INTRINSICS.array(input))\n\t\tif (isFailure(array) || !array.value) {\n\t\t\tthrow new ContractError('literalShape: values must be an array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t\t...(isFailure(array) ? { cause: array.error } : {}),\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(options, ['description'], 'literalShape', 'literal')\n\t\tconst snapshot = readArrayEntries(values)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow new ContractError('literalShape: values could not be copied', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t\tcause: snapshot.error,\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow new ContractError('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t})\n\t\t}\n\t\tconst literals = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.value.entries.length),\n\t\t\t(index) => {\n\t\t\t\tconst value = snapshot.value.entries[index]\n\t\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: ['values', INTRINSICS.text(index)], shape: 'literal' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn value\n\t\t\t},\n\t\t)\n\t\tconst owned = INTRINSICS.freeze(literals)\n\t\tconst shape: LiteralShape = {\n\t\t\tcategory: 'literal',\n\t\t\tvalues: owned,\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'literalShape')\n}\n\n// === Collections\n\n/**\n * Builds an {@link ArrayShape} from an element shape.\n *\n * @param items - The element shape\n * @param options - Optional length bounds and `description`\n * @returns An array shape\n * @throws {ContractError} When a present bound is not a non-negative safe integer\n *\n * @example\n * ```ts\n * const tags = arrayShape(stringShape(), { max: 10 })\n * ```\n */\nexport function arrayShape<S extends ContractShape>(\n\titems: S,\n\toptions?: ArrayShapeOptions,\n): ArrayShape<S> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'description'], 'arrayShape', 'array')\n\t\tif (safe?.min !== undefined && (!INTRINSICS.safe(safe.min) || safe.min < 0)) {\n\t\t\tthrow new ContractError('arrayShape: min must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'array',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.min),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && (!INTRINSICS.safe(safe.max) || safe.max < 0)) {\n\t\t\tthrow new ContractError('arrayShape: max must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'array',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.max),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst shape: ArrayShape<S> = {\n\t\t\tcategory: 'array',\n\t\t\titems,\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'arrayShape')\n}\n\n/**\n * Builds an {@link ObjectShape} from a property map.\n *\n * @remarks\n * Wrap any property in {@link optionalShape} to allow its absence. By default\n * the compiled guard rejects unknown keys; pass `additionalProperties` to open\n * the object.\n *\n * @param properties - Map of property names to child shapes\n * @param options - Optional `additionalProperties` and `description`\n * @returns An object shape\n *\n * @example\n * ```ts\n * const user = objectShape({\n * \tname: stringShape({ min: 1 }),\n * \tage: integerShape({ min: 0, max: 120 }),\n * \tbio: optionalShape(stringShape()),\n * })\n * ```\n */\nexport function objectShape<\n\tP extends Readonly<Record<string, ContractShape>>,\n\tconst A extends boolean | ContractShape = false,\n>(properties: P, options?: ObjectShapeOptions<A>): ObjectShape<P, A> {\n\treturn contain(() => {\n\t\tconst input: unknown = properties\n\t\tif (!isObject(input)) {\n\t\t\tthrow new ContractError('objectShape: properties must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['properties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['additionalProperties', 'description'],\n\t\t\t'objectShape',\n\t\t\t'object',\n\t\t)\n\t\tconst copied = readValue(\n\t\t\t() => {\n\t\t\t\tconst record = matchesRecordBrand(input)\n\t\t\t\tconst keyList = INTRINSICS.keys(input)\n\t\t\t\tconst entries: ReadonlyArray<readonly [string, PropertyDescriptor]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keyList), [\n\t\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: INTRINSICS.reflect.read(input, key),\n\t\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\t\twritable: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t])\n\t\t\t\tconst descriptors = INTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tentries,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst snapshot: { [K in keyof P]: P[K] } = INTRINSICS.create(null, descriptors)\n\t\t\t\treturn { record, snapshot: INTRINSICS.freeze(snapshot) }\n\t\t\t},\n\t\t\t'objectShape',\n\t\t\t{ subject: 'properties', context: { path: ['properties'], shape: 'object' } },\n\t\t)\n\t\tif (!copied.record) {\n\t\t\tthrow new ContractError('objectShape: properties must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['properties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst shape: ObjectShape<P, A> = {\n\t\t\tcategory: 'object',\n\t\t\tproperties: copied.snapshot,\n\t\t\t...(safe?.additionalProperties === undefined\n\t\t\t\t? {}\n\t\t\t\t: { additionalProperties: safe.additionalProperties }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'objectShape')\n}\n\n/**\n * Builds an open {@link ObjectShape} with no fixed properties — a dictionary.\n *\n * @remarks\n * Every value is validated against `values`; keys are unconstrained. Equivalent\n * to `objectShape({}, { additionalProperties: values })`.\n *\n * @param values - The shape every value must match\n * @param options - Optional `description`\n * @returns An open object shape\n * @throws {ContractError} When `values` is absent at runtime\n *\n * @example\n * ```ts\n * const bindings = recordShape(numberShape()) // ~ Record<string, number>\n * ```\n */\nexport function recordShape<S extends ContractShape>(\n\tvalues: S,\n\toptions?: RecordShapeOptions,\n): ObjectShape<Record<never, never>, S> {\n\treturn contain(() => {\n\t\tconst value: unknown = values\n\t\tif (value === undefined || value === null || value === true || value === false) {\n\t\t\tthrow new ContractError('recordShape: values must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['additionalProperties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(options, ['description'], 'recordShape', 'object')\n\t\tconst shape: ObjectShape<Record<never, never>, S> = {\n\t\t\tcategory: 'object',\n\t\t\tproperties: INTRINSICS.freeze({}),\n\t\t\tadditionalProperties: values,\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'recordShape')\n}\n\n// === Composition\n\n/**\n * Builds a {@link UnionShape} from a list of variant shapes (`anyOf` in JSON Schema).\n *\n * @remarks\n * When every arm is an object declaring one required literal property, and a value's\n * own property exactly equals a literal only one arm holds, that arm answers: `explain`\n * and `audit` report its faults at their real paths, and `parse` repairs through it\n * alone. Any other value reports `variant`, with `key` and `expected` saying what would\n * have named an arm. `is` does not change.\n *\n * @param variants - The candidate shapes; the first match wins at runtime\n * @returns A union shape whose `Infer` is the union of the variants\n *\n * @example\n * ```ts\n * const id = unionShape(stringShape(), integerShape())\n * // Infer<typeof id> = string | number\n * ```\n */\nexport function unionShape<V extends readonly ContractShape[]>(\n\t...variants: V\n): UnionShape<Readonly<V>> {\n\treturn contain(() => {\n\t\treturn ShapePass.seal({ category: 'union', variants: INTRINSICS.freeze(variants) })\n\t}, 'unionShape')\n}\n\n/**\n * Builds a {@link UnionShape} that emits `oneOf` (exactly one match) in JSON Schema.\n *\n * @remarks\n * Unlike {@link unionShape} (`anyOf` — at least one variant matches),\n * `oneOfShape`'s compiled guard and parser enforce EXACTLY one match:\n *\n * - **Guard**: accepts the value only when exactly one variant's guard\n * accepts it. A value matching two-or-more variants — which would violate\n * the emitted `oneOf` schema — is rejected, even though it would pass\n * {@link unionShape}'s guard.\n * - **Parser**: judged on the RAW input's guard matches only, with NO\n * coercion fallback for an ambiguous input. When exactly one variant's\n * guard accepts the raw value, the input itself is returned. Zero matches or\n * two-or-more matches both parse to `undefined` — a value ambiguous\n * between variants has no well-defined coercion target. A value that names one\n * arm through a required literal is not ambiguous, so as in {@link unionShape}\n * that arm answers alone, and its parser may coerce.\n *\n * Prefer {@link unionShape} when a value may legitimately satisfy more than\n * one variant (for example overlapping shapes) and any match is acceptable. Prefer\n * `oneOfShape` when overlap between variants indicates malformed input that\n * must be rejected.\n *\n * @param variants - The candidate shapes\n * @returns A union shape with `mode: 'oneOf'`\n *\n * @example\n * ```ts\n * const id = oneOfShape(numberShape(), integerShape())\n * // 3 fails — matches both numberShape and integerShape\n * // 3.5 passes — matches numberShape only\n * ```\n */\nexport function oneOfShape<V extends readonly ContractShape[]>(\n\t...variants: V\n): UnionShape<Readonly<V>> {\n\treturn contain(() => {\n\t\treturn ShapePass.seal({\n\t\t\tcategory: 'union',\n\t\t\tvariants: INTRINSICS.freeze(variants),\n\t\t\tmode: 'oneOf',\n\t\t})\n\t}, 'oneOfShape')\n}\n\n/**\n * Wraps a shape so it may be absent (`undefined`).\n *\n * @remarks\n * As an {@link objectShape} property, the field becomes a true optional property\n * in the inferred type. A `default` is captured as an owned frozen copy, and the\n * compiled parser fills it where the property is absent or `undefined`; the guard,\n * the audit, the report, and the generator keep treating the property as optional.\n * The compilers refuse a default `inner` refuses, a default under a union, and a\n * default on a property of an open object.\n *\n * @param inner - The wrapped shape\n * @param options - Optional `default`, a JSON value\n * @returns An optional shape\n * @throws {ContractError} When a present `default` is not a JSON value, `undefined` included\n *\n * @example\n * ```ts\n * const retries = optionalShape(integerShape({ min: 0 }), { default: 3 })\n * ```\n */\nexport function optionalShape<S extends ContractShape>(\n\tinner: S,\n\toptions?: OptionalShapeOptions,\n): OptionalShape<S> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['default'], 'optionalShape', 'optional')\n\t\trefuseOptionKeys(options, ['default'], 'optionalShape', 'optional')\n\t\t// Own presence, read apart from the value: the snapshot above omits a present\n\t\t// `undefined` and keeps an inherited value, and neither may decide this field.\n\t\tconst present = options !== undefined && INTRINSICS.own(options, 'default')\n\t\tconst value = present ? safe?.default : undefined\n\t\tif (present && !isJSONValue(value)) {\n\t\t\tthrow new ContractError('optionalShape: default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['default'], shape: 'optional', received: preview(value) },\n\t\t\t})\n\t\t}\n\t\tconst owned = value === undefined ? undefined : attempt(() => cloneJSONValue(value))\n\t\tif (owned !== undefined && isFailure(owned)) {\n\t\t\tthrow new ContractError('optionalShape: default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['default'], shape: 'optional', received: preview(value) },\n\t\t\t\tcause: owned.error,\n\t\t\t})\n\t\t}\n\t\tconst shape: OptionalShape<S> = {\n\t\t\tcategory: 'optional',\n\t\t\tinner,\n\t\t\t...(owned === undefined ? {} : { default: owned.value }),\n\t\t}\n\t\treturn ShapePass.seal(shape, { category: 'object', properties: { value: shape } })\n\t}, 'optionalShape')\n}\n\n/**\n * Wraps a shape so it may be `null`.\n *\n * @param inner - The wrapped shape\n * @returns A nullable shape\n *\n * @example\n * ```ts\n * const bio = nullableShape(stringShape())\n * // Infer<typeof bio> = string | null\n * ```\n */\nexport function nullableShape<S extends ContractShape>(inner: S): NullableShape<S> {\n\treturn contain(() => {\n\t\tconst shape: NullableShape<S> = { category: 'nullable', inner }\n\t\treturn ShapePass.seal(shape)\n\t}, 'nullableShape')\n}\n\n// === Escape hatch\n\n/**\n * Builds a {@link JSONShape}.\n *\n * @remarks\n * The sound counterpart of {@link rawShape}: `rawShape` embeds an arbitrary\n * schema fragment and accepts every defined value at runtime, while `jsonShape`\n * validates that a value is real JSON (through {@link isJSONValue}). Its emitted\n * schema is the empty accept-anything `{}`, so here the schema claims MORE than\n * the compiled guard accepts — `NaN`, a `Map`, and a class instance all satisfy\n * `{}` and all fail `isJSONValue`.\n *\n * This is the shape an author writes to mean \"any JSON value\". Inference never produces\n * it: {@link schemaToShape} widening always lands on {@link RawShape} instead.\n *\n * @param options - Optional `description`\n * @returns A JSON passthrough shape\n *\n * @example\n * ```ts\n * const payload = jsonShape({ description: 'Arbitrary JSON payload' })\n * ```\n */\nexport function jsonShape(options?: JSONShapeOptions): JSONShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'jsonShape', 'json')\n\t\tconst shape: JSONShape = {\n\t\t\tcategory: 'json',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'jsonShape')\n}\n\n/**\n * Builds a {@link ShapeShape}.\n *\n * @param options - Optional description\n * @returns A shape-valued declaration\n *\n * @example\n * ```ts\n * const definition = objectShape({ shape: shapeShape() })\n * ```\n */\nexport function shapeShape(options?: ShapeShapeOptions): ShapeShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'shapeShape', 'shape')\n\t\tconst shape: ShapeShape = {\n\t\t\tcategory: 'shape',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'shapeShape')\n}\n\n/**\n * Builds a {@link RawShape} from a supported JSON Schema fragment.\n *\n * @remarks\n * For values the shape DSL can't express. The fragment is recursively checked\n * against the lean {@link JSONSchema} vocabulary before ownership is taken;\n * malformed or unsupported keywords throw a coded {@link ContractError}. The\n * refusal path starts at `schema` and names the nested keyword or member.\n * A non-record root is refused at `schema` itself. The\n * compiled guard accepts every\n * DEFINED value — `undefined` alone fails, because it is the parser's failure\n * sentinel; wrap the shape in {@link optionalShape} to admit absence. The\n * parser passes a defined value through unchanged, and the fragment is\n * deep-cloned into an owned frozen snapshot ({@link cloneSchema}), so\n * `rawShape(fragment).schema !== fragment` and later edits to the caller's\n * fragment cannot reach the shape. `compileSchema` re-emits that snapshot\n * structurally verbatim, so here the schema claims LESS than the compiled guard\n * accepts — `rawShape({ type: 'string' })` emits `{ type: 'string' }` and its\n * guard still accepts `42`, the mirror of {@link jsonShape}'s looseness.\n * `compileGenerator` throws, since an arbitrary embedded schema has no\n * auto-generatable sample.\n *\n * @param schema - The JSON Schema fragment to embed\n * @returns A raw shape owning a frozen copy of the fragment\n *\n * @example\n * ```ts\n * const custom = rawShape({ type: 'string', format: 'uuid' })\n * ```\n */\nexport function rawShape(schema: JSONSchema): RawShape {\n\treturn contain(() => {\n\t\tnew ShapeValidator({ category: 'raw', schema }).validate()\n\t\treturn ShapePass.seal({ category: 'raw', schema: cloneSchema(schema) })\n\t}, 'rawShape')\n}\n\n// === Schema inversion\n\n// schemaToShape walks an UNKNOWN, possibly adversarial runtime JSONSchema value\n// (a hand-written schema, or one produced by valueToSchema / samplesToSchema)\n// and emits a validating ContractShape — the reverse direction of\n// compileSchema (compilers.ts), which walks a finite, developer-authored\n// ContractShape tree and emits a JSONSchema. Recursion here is runtime-only\n// and bounded on three axes, mirroring the inferers: a WeakSet of ancestor\n// schema nodes (cycle safety), a decrementing depth budget (INFER_DEPTH_LIMIT\n// default), and a per-container sampling cap (INFER_BREADTH_LIMIT) on\n// properties/oneOf/anyOf entries — every branch stays total, as\n// `.claude/rules/patterns.md` § Validation and contracts requires.\n// Every keyword read is type-guarded: a malformed keyword is IGNORED, falling\n// through to the next rule, never thrown. `format` and `pattern` are NEVER\n// asserted — `format` is annotation-only, and compiling an attacker-supplied\n// `pattern` into a `RegExp` is a ReDoS vector — so neither keyword narrows the\n// compiled guard; the returned shape is always one `validateShape` accepts.\n//\n// Every widening — an empty/unrecognized node, an exhausted budget, a cycle —\n// lands on `rawShape`, NOT `jsonShape`. A hostile throw is NOT a widening: a\n// keyword access, enumeration, or recursive traversal that throws is not\n// malformed schema vocabulary, so `schemaToShape` runs the whole walk inside\n// `readValue` and refuses it as `ContractError { code: 'structure', context: {\n// shape: 'schema' } }` instead of inventing an accept-anything node for a\n// schema nobody could read. `{}` is JSON Schema's\n// accept-anything schema, and `rawShape` is its exact inverse: its compiled\n// guard accepts every defined value, and it re-emits `{}` verbatim. `jsonShape`\n// also emits `{}` but its guard is the strictly narrower `isJSONValue`, so\n// widening through it would REJECT the exotic originals (`Map`, `Set`, a class\n// instance, a function, `NaN`) whose inferred schema is exactly `{}` — the\n// round trip below would then be a false claim. `jsonShape` remains the shape a\n// user AUTHORS to mean \"any JSON value\"; it is never inferred.\n\n/**\n * Converts a runtime `JSONSchema` value into a validating {@link ContractShape}\n * — the inverse of {@link compileSchema}. Unlike direct {@link rawShape}\n * construction, which rejects malformed supported-vocabulary keywords, the\n * lenient conversion is total and widens an inexpressible input to a valid raw\n * `{}`, and a strict conversion refuses that input.\n *\n * @remarks\n * Readable malformed, cyclic, or deeply nested schema nodes widen to\n * {@link rawShape}; a failed traversal raises the shared coded refusal because\n * an unreadable value is not a schema. `createContract(schemaToShape(x))`\n * therefore remains safe for every readable `x`. The per-keyword precedence is\n * `enum`, then `oneOf`, then `anyOf`, then `type`, then a record-valued\n * `properties`, then the accept-anything widening.\n *\n * `format` and `pattern` are NEVER asserted by the compiled shape — `format`\n * is annotation-only (per the JSON Schema spec, it never narrows validation\n * on its own) and compiling an attacker-controlled `pattern` string into a\n * `RegExp` is a ReDoS vector; both keywords are read only far enough to be\n * ignored. Any node the walk cannot express — an empty `{}`, an\n * unrecognized `type`, a schema past {@link INFER_DEPTH_LIMIT} deep, or a\n * cyclic re-encounter — widens to {@link rawShape} (accept any defined\n * value), never narrows.\n *\n * ROUND TRIP: for every readable `v`,\n * `compileGuard(schemaToShape(valueToSchema(v)))(v)` is `true` — including\n * values no JSON Schema keyword describes (`NaN`, `±Infinity`, a `Map`, a\n * `Set`, a class instance, a function, a symbol, a bigint, and readable cyclic\n * hosts), which infer `{}` and widen back to an accept-anything\n * {@link rawShape}. An unreadable host is refused by {@link valueToSchema}\n * before this law produces a schema; direct hostile input to\n * {@link schemaToShape} receives the same coded refusal.\n * Widening is the only source of looseness. The law has three explicit host\n * limits:\n *\n * - **Absence.** `undefined` is not a value: no compiled guard accepts it\n * (`rawShape` reserves it as the parser failure sentinel). So `undefined`\n * itself, an array element holding it, and an array HOLE (`arrayOf` requires\n * every index to be an own property, the same rule `isJSONValue` applies)\n * all fall outside the law. An OBJECT property holding `undefined` does not:\n * `valueToSchema` drops the key and opens the object, so the source object\n * is still accepted.\n * - **`Date` serialization.** A `Date` infers the schema of its JSON form\n * (`{ type: 'string' }`, plus `format: 'date-time'` when `format` is on), so\n * the law applies to `date.toISOString()` rather than the runtime instance.\n * - **Stateful access.** A getter whose result changes between inference and\n * guard evaluation can invalidate the sampled fact. Likewise, an array that\n * overrides iteration behavior can present different elements to the two\n * phases. The law applies only while the sampled host's observable own\n * enumerable string properties and array iteration remain stable.\n *\n * A widened node cannot be auto-generated: `rawShape` embeds an arbitrary\n * schema fragment, so `createContract(schemaToShape(x)).generate()` throws\n * when the conversion widened anywhere — `schema` / `is` / `parse` / `explain`\n * stay total.\n *\n * LENIENT LAW: a value a JSON Schema accepts is never refused by the shape a\n * lenient conversion builds from it, because the walk widens what it cannot read.\n * So `oneOf` builds an inclusive union, a `true` arm is a raw variant and a `false`\n * arm is dropped, an `enum` holding `null` admits it, `nullable: true` wraps the\n * node, a present `patternProperties` opens the object, a present `prefixItems`\n * widens the elements, and a `$ref` widens the node before anything beside it is read.\n * A schema past the compile limit keeps only its root's type, an array's bounds, and an\n * object's required keys and closure, with every value below them raw.\n *\n * DEFAULTS: a lenient conversion carries a property's `default` when the key is\n * not `required`, its object is closed with no union ancestor, and the value is\n * one the property's primitive or literal guard accepts. It drops every other\n * `default`, because carrying it would make the shape refuse to compile.\n *\n * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with\n * code `structure`, every node the lenient walk would widen, every keyword it\n * would ignore (`pattern`, `format`, `nullable`, `patternProperties`,\n * `propertyNames`, `prefixItems`, and anything else outside\n * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry\n * that is neither a finite primitive nor `null`, a contradictory bound, a `required` name not in\n * `properties`, breadth past {@link INFER_BREADTH_LIMIT}, and a `default` with no\n * optional property to fill. An object with no `additionalProperties` closes\n * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads\n * every keyword that could keep two arms apart. Below a `oneOf` that object refuses\n * instead, since closing it could change which arms match.\n *\n * @param schema - The JSON Schema value to convert\n * @param options - Optional `strict`, default `false`\n * @returns The built {@link ContractShape}\n * @throws {ContractError} When schema traversal fails, or when a strict conversion refuses\n *\n * @example\n * ```ts\n * const schema = samplesToSchema([{ id: 1, name: 'Ada' }, { id: 2, name: 'Grace' }])\n * const contract = createContract(schemaToShape(schema))\n * contract.parse({ id: 3, name: 'Alan' }) // { id: 3, name: 'Alan' }\n * contract.parse({ id: 'nope' }) // undefined\n * ```\n */\nexport function schemaToShape(schema: JSONSchema, options?: SchemaToShapeOptions): ContractShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['strict'], 'schemaToShape', 'schema')\n\t\trefuseOptionKeys(options, ['strict'], 'schemaToShape', 'schema')\n\t\tconst named = options !== undefined && INTRINSICS.own(options, 'strict')\n\t\tconst strict = named ? safe?.strict : undefined\n\t\tif (strict !== undefined && typeof strict !== 'boolean') {\n\t\t\tthrow new ContractError('schemaToShape: strict must be a boolean', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['strict'], shape: 'schema', received: preview(strict) },\n\t\t\t})\n\t\t}\n\t\t// The whole walk runs inside this door's own read boundary, so a hostile\n\t\t// keyword, enumeration, or recursion anywhere below it is published under\n\t\t// this door's name rather than under the name of an engine method no\n\t\t// consumer can call. The engine captures its own collection constructors\n\t\t// while ITS module evaluates — a module function cannot — so a caller who\n\t\t// replaces `globalThis.WeakSet` or `globalThis.WeakMap` can no longer make\n\t\t// construction throw a raw value out of a door documented to refuse with a\n\t\t// `ContractError`.\n\t\tconst shaper = new SchemaShaper(schema, strict === true)\n\t\tif (strict !== true) {\n\t\t\treturn readValue(() => shaper.shape(), 'schemaToShape', {\n\t\t\t\tsubject: 'schema',\n\t\t\t\tcontext: { shape: 'schema' },\n\t\t\t})\n\t\t}\n\t\t// A strict refusal names the keyword it refuses, so it passes through the\n\t\t// boundary that would otherwise restate it as an unreadable schema.\n\t\tconst outcome = attempt(() => shaper.shape())\n\t\tif (isSuccess(outcome)) return outcome.value\n\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tthrow outcome.error\n\t\t\t},\n\t\t\t'schemaToShape',\n\t\t\t{ subject: 'schema', context: { shape: 'schema' } },\n\t\t)\n\t}, 'schemaToShape')\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAa,eAA4D,OAAO,OAAO;CACtF,QAAQ,OAAO,OAAO;EAAC;EAAO;EAAO;EAAW;CAAa,CAAC;CAC9D,QAAQ,OAAO,OAAO;EAAC;EAAW;EAAO;EAAO;CAAa,CAAC;CAC9D,SAAS,OAAO,OAAO,CAAC,aAAa,CAAC;CACtC,MAAM,OAAO,OAAO,CAAC,aAAa,CAAC;CACnC,SAAS,OAAO,OAAO,CAAC,UAAU,aAAa,CAAC;CAChD,OAAO,OAAO,OAAO;EAAC;EAAS;EAAO;EAAO;CAAa,CAAC;CAC3D,QAAQ,OAAO,OAAO;EAAC;EAAc;EAAwB;CAAa,CAAC;CAC3E,OAAO,OAAO,OAAO;EAAC;EAAY;EAAQ;CAAa,CAAC;CACxD,UAAU,OAAO,OAAO,CAAC,SAAS,SAAS,CAAC;CAC5C,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC;CACjC,MAAM,OAAO,OAAO,CAAC,aAAa,CAAC;CACnC,KAAK,OAAO,OAAO,CAAC,QAAQ,CAAC;CAC7B,OAAO,OAAO,OAAO,CAAC,aAAa,CAAC;AACrC,CAAgE;;;;;;;;;;;AAYhE,IAAa,uBAAuB,OAAO,IAAI,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsElF,IAAa,aAAa,OAAO,OAAO;;CAEvC,QAAQ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;;;;;;;;;;;;;;;AAkIA,SAAgB,cAAc,QAAoB,SAA+C;CAChG,OAAO,cAAc;EACpB,MAAM,OAAO,YAAY,SAAS,CAAC,QAAQ,GAAG,iBAAiB,QAAQ;EACvE,iBAAiB,SAAS,CAAC,QAAQ,GAAG,iBAAiB,QAAQ;EAE/D,MAAM,SADQ,YAAY,KAAA,KAAa,WAAW,IAAI,SAAS,QAAQ,IAChD,MAAM,SAAS,KAAA;EACtC,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,WAC7C,MAAM,IAAI,cAAc,2CAA2C;GAClE,MAAM;GACN,SAAS;IAAE,MAAM,CAAC,QAAQ;IAAG,OAAO;IAAU,UAAU,QAAQ,MAAM;GAAE;EACzE,CAAC;EAUF,MAAM,SAAS,IAAI,aAAa,QAAQ,WAAW,IAAI;EACvD,IAAI,WAAW,MACd,OAAO,gBAAgB,OAAO,MAAM,GAAG,iBAAiB;GACvD,SAAS;GACT,SAAS,EAAE,OAAO,SAAS;EAC5B,CAAC;EAIF,MAAM,UAAU,cAAc,OAAO,MAAM,CAAC;EAC5C,IAAI,UAAU,OAAO,GAAG,OAAO,QAAQ;EACvC,IAAI,gBAAgB,QAAQ,KAAK,GAAG,MAAM,QAAQ;EAClD,OAAO,gBACA;GACL,MAAM,QAAQ;EACf,GACA,iBACA;GAAE,SAAS;GAAU,SAAS,EAAE,OAAO,SAAS;EAAE,CACnD;CACD,GAAG,eAAe;AACnB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/helpers.ts","../../../src/core/JSONCloner.ts","../../../src/core/SchemaCloner.ts","../../../src/core/ShapePass.ts","../../../src/core/ShapeValidator.ts","../../../src/core/ShapeCloner.ts","../../../src/core/cloners.ts","../../../src/core/LazyGuard.ts","../../../src/core/combinators.ts","../../../src/core/parsers.ts","../../../src/core/EvaluationScope.ts","../../../src/core/RandomSource.ts","../../../src/core/seeders.ts","../../../src/core/ContractCompiler.ts","../../../src/core/compilers.ts","../../../src/core/LazyContract.ts","../../../src/core/factories.ts","../../../src/core/ValueInferer.ts","../../../src/core/SampleInferer.ts","../../../src/core/inferers.ts","../../../src/core/SchemaShaper.ts","../../../src/core/FaultShaper.ts","../../../src/core/shapers.ts"],"sourcesContent":["import type {\n\tContractCode,\n\tContractShape,\n\tFaultConstraint,\n\tFaultKind,\n\tJSONSchemaType,\n} from './types.js'\n\n/**\n * Lists the fields recognized for every contract declaration category, frozen.\n *\n * @example\n * ```ts\n * SHAPE_FIELDS.shape // ['description']\n * ```\n */\nexport const SHAPE_FIELDS: Readonly<Record<string, readonly string[]>> = Object.freeze({\n\tstring: Object.freeze(['min', 'max', 'pattern', 'date', 'description']),\n\tnumber: Object.freeze(['integer', 'min', 'max', 'description']),\n\tboolean: Object.freeze(['description']),\n\tnull: Object.freeze(['description']),\n\tliteral: Object.freeze(['values', 'description']),\n\tarray: Object.freeze(['items', 'min', 'max', 'description']),\n\tobject: Object.freeze(['properties', 'additionalProperties', 'description']),\n\tunion: Object.freeze(['variants', 'mode', 'description']),\n\toptional: Object.freeze(['inner', 'default']),\n\tnullable: Object.freeze(['inner']),\n\tjson: Object.freeze(['description']),\n\traw: Object.freeze(['schema']),\n\tshape: Object.freeze(['description']),\n} satisfies Record<ContractShape['category'], readonly string[]>)\n\n/**\n * Holds the registry-global key used to recognize {@link ContractError} values\n * across package copies.\n *\n * @remarks\n * The descriptor stores the branded value itself. Recognition compares that\n * identity, so a transparent proxy cannot forward its target's brand as its\n * own. The registry makes the key discoverable; it is a recognition mechanism,\n * not an unforgeable provenance marker.\n */\nexport const CONTRACT_ERROR_BRAND = Symbol.for('@orkestrel/contract.ContractError')\n\n// === Captured host operations\n\n/**\n * Captures every host operation this package dispatches through, while this\n * module evaluates.\n *\n * @remarks\n * THE answer to a defect class that mutated four times before anyone stated it\n * as a class. A caller can replace a global constructor, a static, a prototype\n * member, or a symbol-keyed hook, and a replacement can fail by THROWING, which\n * a boundary contains, or by LYING, which no boundary can\n * see. `Object.freeze = (value) => value` lies, and that is the\n * worse failure: every cloner succeeds, publishes a mutable graph, and the caller\n * cannot tell that the package's central guarantee evaporated.\n *\n * Containment cannot close that, because there is nothing to contain — only\n * capture can, and only capture taken while this module evaluates. A module's\n * initializers run at import, so a reference read here is whatever was\n * installed at the moment THIS module evaluated, and reading it later, at the\n * call site, is reading whatever the caller most recently installed. \"Before any\n * caller code runs\" is the tempting phrasing and it is false in exactly the case\n * the limit below names, so it is not used.\n *\n * The limit that follows, stated as a limit rather than as a guarantee: capture\n * is only as early as this package's own evaluation. A consumer module that\n * evaluates BEFORE `@orkestrel/contract` — ESM evaluates imports in source\n * order — chooses what this table captures, and no mechanism inside the package\n * can reach code that ran before the package existed. That precondition is\n * outside this package's control, and an adversary who holds it can replace the\n * package wholesale rather than bother with the table, so it is named here\n * instead of defended.\n *\n * Membership rule, stated so a reviewer can apply it and a new call site knows\n * where to go: **every host operation this package dispatches by name whose\n * result a published answer depends on.** That admits statics, constructors and\n * namespaces, and — this is the part the earlier wording got wrong by writing\n * the rule from the rows instead of the rows from the rule — it admits a\n * PROTOTYPE member on the same terms, including an ACCESSOR's getter,\n * dispatched onto the package's own receiver through {@link INTRINSICS.reflect.apply}.\n * A round that read `Object.getOwnPropertyDescriptor(RegExp.prototype, 'source')`\n * per call had captured nothing: capture is decided by WHEN the reference is\n * taken, not by which reflective spelling takes it.\n *\n * Collection membership needs a data structure rather than one operation, and\n * answering it from an exported class's `has` method reproduces the whole defect\n * one prototype higher, because every consumer can rewrite that method. The rule\n * has no exception\n * for it: `Set.prototype.has` / `.add` / `.forEach`,\n * `Map.prototype.has` / `.forEach`, and\n * `WeakSet.prototype.has` / `.add` / `.delete` are ordinary rows here, dispatched\n * onto collections this package built and no caller holds, and every membership\n * and visitation answer in the package is asked through the module-scope\n * functions {@link matchesMember} / {@link admitMember} /\n * {@link matchesVisited} / {@link admitVisited} / {@link omitVisited}. A module\n * binding is not a property, so there is no member on that path to replace.\n *\n * The walk-collection exclusion the earlier wording carried — \"a redirect\n * corrupts it inside a boundary and the door refuses, which is loud\" — was\n * false in the direction the corpus itself installs. `WeakSet.prototype.has`\n * answering `false` does not make a cyclic clone refuse; it removes the\n * termination bound, and a door that never returns is the one failure no\n * boundary can report. Visitation state is captured here for that reason.\n *\n * @example\n * ```ts\n * INTRINSICS.freeze(snapshot) // the genuine Object.freeze, whatever the caller installed\n * ```\n */\nexport const INTRINSICS = Object.freeze({\n\t/** Captures `Object.freeze` — the operation the ownership guarantee is made of. */\n\tfreeze: Object.freeze,\n\t/** Captures `Object.isFrozen` — the independent check that the guarantee actually held. */\n\tfrozen: Object.isFrozen,\n\t/** Captures `Object.keys` — the own enumerable string-key population of a snapshot. */\n\tkeys: Object.keys,\n\t/** Captures `Object.values` — the own enumerable value population of a snapshot. */\n\tvalues: Object.values,\n\t/** Captures `Object.hasOwn` — own presence, so no read leaves a container for its prototype. */\n\town: Object.hasOwn,\n\t/** Captures `Object.is` — `SameValue`, so a `NaN` or signed-zero comparison stays exact. */\n\tsame: Object.is,\n\t/** Captures `Object.create` — the null-prototype and prototype-pinned accumulators. */\n\tcreate: Object.create,\n\t/** Captures `Proxy` for non-array indexed views. */\n\tproxy: Proxy,\n\t/** Captures `Object.getOwnPropertyDescriptor` — value observation that runs no accessor. */\n\tdescribe: Object.getOwnPropertyDescriptor,\n\t/** Captures `Object.defineProperty` — exact placement of an own data property. */\n\tdefine: Object.defineProperty,\n\t/** Captures `Object.defineProperties` — sparse snapshot construction. */\n\tdefinitions: Object.defineProperties,\n\t/** Captures `Object.getPrototypeOf` — the record-brand observation. */\n\tprototype: Object.getPrototypeOf,\n\t/** Captures `Object.getOwnPropertySymbols` — the own-symbol population. */\n\tsymbols: Object.getOwnPropertySymbols,\n\t/** Captures `Object.prototype` — the realm-local plain-record prototype identity. */\n\tbase: Object.prototype,\n\t/**\n\t * Captures the proxy-visible operations, grouped because that is what separates them:\n\t * each reports the trap's exact answer where `Object`'s flat peer above\n\t * reports the target's.\n\t *\n\t * @remarks\n\t * Frozen on its own, so the sub-entity is as immutable as the table holding\n\t * it. `describe`, `define`, and `prototype` name the same operations their\n\t * flat peers name, and the group is what tells a reader which of the two a\n\t * call site asked for.\n\t */\n\treflect: Object.freeze({\n\t\t/** Captures `Reflect.get` — a proxy-visible read that reports the trap's exact answer. */\n\t\tread: Reflect.get,\n\t\t/** Captures `Reflect.set` — a proxy-visible write. */\n\t\twrite: Reflect.set,\n\t\t/** Captures `Reflect.ownKeys` — the complete own-key population, strings and symbols. */\n\t\tmembers: Reflect.ownKeys,\n\t\t/** Captures `Reflect.has` — a proxy-visible presence observation. */\n\t\tpresent: Reflect.has,\n\t\t/** Captures `Reflect.getOwnPropertyDescriptor` — the reflective descriptor observation. */\n\t\tdescribe: Reflect.getOwnPropertyDescriptor,\n\t\t/** Captures `Reflect.defineProperty` — placement that answers instead of throwing. */\n\t\tdefine: Reflect.defineProperty,\n\t\t/** Captures `Reflect.getPrototypeOf` — the reflective prototype observation. */\n\t\tprototype: Reflect.getPrototypeOf,\n\t\t/** Captures `Reflect.apply` — dispatch of a captured method onto its receiver. */\n\t\tapply: Reflect.apply,\n\t\t/** Captures `Reflect.construct` — construction with an explicit new target. */\n\t\tconstruct: Reflect.construct,\n\t}),\n\t/** Captures `Number.isFinite` — the finite-bound test every numeric shape refuses on. */\n\tfinite: Number.isFinite,\n\t/** Captures `Number.isInteger` — the integer-budget test the inference caps refuse on. */\n\tinteger: Number.isInteger,\n\t/** Captures `Number.isSafeInteger` — the safe-integer test every length bound refuses on. */\n\tsafe: Number.isSafeInteger,\n\t/** Captures `Number.isNaN` — the calendar-validity test for a parsed instant. */\n\tnan: Number.isNaN,\n\t/** Captures `Array.isArray` — array identity across realms. */\n\tarray: Array.isArray,\n\t/** Captures `JSON.stringify` — the escaping used by previews and canonical text. */\n\tstringify: JSON.stringify,\n\t/** Captures `JSON.parse` — document decoding. */\n\tdecode: JSON.parse,\n\t/** Captures `Math.floor` — index and quantity flooring. */\n\tfloor: Math.floor,\n\t/** Captures `Math.ceil` — index and quantity ceiling. */\n\tceil: Math.ceil,\n\t/** Captures `Math.max` — bound selection. */\n\tmax: Math.max,\n\t/** Captures `Math.min` — bound selection. */\n\tmin: Math.min,\n\t/** Captures `Math.imul` — the seeded generator's mixing step. */\n\timul: Math.imul,\n\t/** Captures `String` — primitive text coercion. */\n\ttext: String,\n\t/** Captures `Number` — primitive numeric coercion. */\n\tnumeric: Number,\n\t/** Captures `RegExp` — pattern construction from captured source and flags. */\n\tpattern: RegExp,\n\t/**\n\t * Captures `RegExp.prototype.exec` — THE pattern membership answer, dispatched through\n\t * `apply`.\n\t *\n\t * @remarks\n\t * `test` is deliberately absent. `RegExp.prototype.test` is spec-defined in\n\t * terms of `RegExpExec`, which re-reads `exec` OFF THE RECEIVER and calls it\n\t * when it is callable, so capturing `test` and dispatching it still asks\n\t * whatever the caller installed on `RegExp.prototype.exec`. Only\n\t * `RegExp.prototype.exec` itself is `RegExpBuiltinExec`, which reads the\n\t * pattern's internal slots and no member at all. A capture that still routes\n\t * through the replaced member is not a capture.\n\t */\n\tcaptures: RegExp.prototype.exec,\n\t/** Captures the `RegExp.prototype.source` getter — the pattern text a published schema embeds, dispatched through `apply`. */\n\texpression: Object.getOwnPropertyDescriptor(RegExp.prototype, 'source')?.get,\n\t/** Captures the `RegExp.prototype.flags` getter — the flag text an owned pattern is rebuilt from, dispatched through `apply`. */\n\tmodifiers: Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags')?.get,\n\t/** Captures `Array` — array construction. */\n\tlist: Array,\n\t/** Captures `Array.prototype.sort` — the deterministic ordering every published schema is emitted in, dispatched through `apply`. */\n\torder: Array.prototype.sort,\n\t/** Captures `Array.prototype.some` for short-circuit membership checks. */\n\tsome: Array.prototype.some,\n\t/** Captures `Array.prototype.findIndex`, including reads of sparse positions. */\n\tfind: Array.prototype.findIndex,\n\t/** Captures `Array.prototype.forEach` for indexed visits of owned arrays. */\n\teach: Array.prototype.forEach,\n\t/** Captures `Array.from` for ordered array construction. */\n\tfrom: Array.from,\n\t/** Captures `Array.prototype.reduce` for derived aggregate values. */\n\tfold: Array.prototype.reduce,\n\t/** Captures `Iterator.prototype.reduce` — ordered lazy reduction. */\n\treduce: Iterator.prototype.reduce,\n\t/** Captures `Array.prototype.filter` for derived selections. */\n\tselect: Array.prototype.filter,\n\t/** Captures `Array.prototype.map` for derived projections. */\n\tproject: Array.prototype.map,\n\t/** Captures `Array.prototype.flatMap` — ordered list expansion. */\n\texpand: Array.prototype.flatMap,\n\t/** Captures `Array.prototype.toReversed` — reverse-order derivation. */\n\tflip: Array.prototype.toReversed,\n\t/** Captures `Array.prototype.values` for owned iterable construction. */\n\titerator: Array.prototype.values,\n\t/** Captures `Array.prototype.keys` — an indexed cursor that reads length per step. */\n\tindices: Array.prototype.keys,\n\t/** Captures the native array iterator advance operation. */\n\tadvance: Object.getPrototypeOf([][Symbol.iterator]()).next,\n\t/** Captures `Array.prototype.join` — text assembly from derived parts. */\n\tjoin: Array.prototype.join,\n\t/** Captures `Function.prototype.bind` for a receiver-bound host operation. */\n\tbind: Function.prototype.bind,\n\t/** Captures `Object.fromEntries` for derived records. */\n\trecord: Object.fromEntries,\n\t/** Captures `Object.setPrototypeOf` for owned record prototypes. */\n\trebase: Object.setPrototypeOf,\n\t/** Captures `Map` — keyed working state. */\n\tmap: Map,\n\t/** Captures `Map.prototype.get` — a memo read whose answer a published graph embeds, dispatched through `apply`. */\n\tfetch: Map.prototype.get,\n\t/** Captures `Map.prototype.set` — a memo write a published graph is later assembled from, dispatched through `apply`. */\n\tstore: Map.prototype.set,\n\t/** Captures `Map.prototype.has` — a memo presence answer that decides whether a node is captured, dispatched through `apply`. */\n\tkeyed: Map.prototype.has,\n\t/** Captures `Map.prototype.forEach` — the only full view of a caller's `Map` that runs no iterator, dispatched through `apply`. */\n\tpairs: Map.prototype.forEach,\n\t/** Captures `Set` — membership working state. */\n\tset: Set,\n\t/** Captures `Set.prototype.union` — construction without a live `add` dispatch. */\n\tunion: Set.prototype.union,\n\t/** Captures `Set.prototype.has` — THE membership answer every published verdict rests on, dispatched through `apply`. */\n\tmember: Set.prototype.has,\n\t/** Captures `Set.prototype.add` — collection of one more member, dispatched through `apply`. */\n\tadmit: Set.prototype.add,\n\t/** Captures `Set.prototype.forEach` — the only full view of a caller's `Set` that runs no iterator, dispatched through `apply`. */\n\tsweep: Set.prototype.forEach,\n\t/** Captures `Set.prototype.delete` — settlement of an active operation. */\n\tremove: Set.prototype.delete,\n\t/** Captures `WeakMap` — object-keyed working state. */\n\tweakMap: WeakMap,\n\t/** Captures `WeakMap.prototype.get` — an object-keyed memo read a published graph embeds, dispatched through `apply`. */\n\trecall: WeakMap.prototype.get,\n\t/** Captures `WeakMap.prototype.set` — an object-keyed memo write, dispatched through `apply`. */\n\tretain: WeakMap.prototype.set,\n\t/** Captures `WeakSet` — object-membership working state. */\n\tweakSet: WeakSet,\n\t/** Captures `WeakSet.prototype.has` — the visitation answer every traversal's termination rests on, dispatched through `apply`. */\n\ttracked: WeakSet.prototype.has,\n\t/** Captures `WeakSet.prototype.add` — entry onto the active path, dispatched through `apply`. */\n\ttrack: WeakSet.prototype.add,\n\t/** Captures `WeakSet.prototype.delete` — exit from the active path, dispatched through `apply`. */\n\tuntrack: WeakSet.prototype.delete,\n\t/** Captures `Error` — the internal marker an engine throws into its own contained walk. */\n\terror: Error,\n\t/** Captures `Date` — calendar validation of an ISO instant. */\n\tdate: Date,\n\t/** Captures `Date.prototype.getTime` — the calendar verdict a published `format` rests on, dispatched through `apply`. */\n\tinstant: Date.prototype.getTime,\n\t/** Captures `Date.now` — the wall-clock reading a default generator seed is drawn from. */\n\tnow: Date.now,\n})\n\n// JSON-related constants. Kept as plain frozen data so the shipped combinators\n// and parsers operate on them directly — there is deliberately no bespoke\n// JSON-Schema guard (`.claude/rules/patterns.md` § Validation and contracts — the\n// deep recursive validators stay out by design).\n\n/**\n * Lists the seven standard JSON Schema `type` names, frozen.\n *\n * @remarks\n * The runtime source of truth for the {@link JSONSchemaType} vocabulary. Compose\n * it with the shipped primitives instead of reaching for a bespoke guard:\n * `literalOf(...JSON_SCHEMA_TYPES)` is the guard, and\n * `parseEnum(value, JSON_SCHEMA_TYPES)` / `parseEnumField(record, path, JSON_SCHEMA_TYPES)`\n * is the parser.\n *\n * @example\n * ```ts\n * import { JSON_SCHEMA_TYPES, literalOf, parseEnumField } from '@orkestrel/contract'\n *\n * const isSchemaType = literalOf(...JSON_SCHEMA_TYPES) // Guard<JSONSchemaType>\n * parseEnumField(schema, 'type', JSON_SCHEMA_TYPES) // JSONSchemaType | undefined\n * ```\n */\nexport const JSON_SCHEMA_TYPES: readonly JSONSchemaType[] = Object.freeze([\n\t'null',\n\t'boolean',\n\t'object',\n\t'array',\n\t'number',\n\t'integer',\n\t'string',\n])\n\n/**\n * Lists the JSON Schema keywords a strict `schemaToShape` conversion reads, frozen.\n *\n * @remarks\n * The keywords a shape can honour, plus the annotations that assert nothing and so\n * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,\n * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.\n * `pattern` and `format` are absent because no compiled shape asserts them, so a\n * schema holding one would convert to a shape wider than the schema it came from. The\n * one exception is `format: 'date'` on a string node, which a strict conversion reads\n * as a date string shape.\n *\n * @example\n * ```ts\n * STRICT_SCHEMA_KEYWORDS.includes('title') // true\n * STRICT_SCHEMA_KEYWORDS.includes('pattern') // false\n * ```\n */\nexport const STRICT_SCHEMA_KEYWORDS: readonly string[] = Object.freeze([\n\t'type',\n\t'title',\n\t'description',\n\t'$schema',\n\t'$id',\n\t'$comment',\n\t'examples',\n\t'deprecated',\n\t'readOnly',\n\t'writeOnly',\n\t'default',\n\t'enum',\n\t'minLength',\n\t'maxLength',\n\t'minimum',\n\t'maximum',\n\t'minItems',\n\t'maxItems',\n\t'items',\n\t'properties',\n\t'required',\n\t'additionalProperties',\n\t'anyOf',\n\t'oneOf',\n])\n\n/**\n * Lists every declared {@link ContractCode} refusal category, frozen.\n *\n * @remarks\n * The runtime source of truth for the {@link ContractCode} vocabulary, and the\n * one list every membership test over it reads: `readValue` decides from it\n * whether a caller-supplied code is declared, and `isContractError` decides\n * from it whether a candidate error carries a declared one. A code added to the\n * union is added here, so neither test can drift from the type or from the\n * other.\n *\n * @example\n * ```ts\n * import { CONTRACT_CODES, literalOf } from '@orkestrel/contract'\n *\n * const isContractCode = literalOf(...CONTRACT_CODES) // Guard<ContractCode>\n * ```\n */\nexport const CONTRACT_CODES: readonly ContractCode[] = Object.freeze([\n\t'bound',\n\t'range',\n\t'empty',\n\t'placement',\n\t'structure',\n\t'literal',\n\t'cycle',\n\t'pattern',\n\t'generate',\n\t'random',\n\t'clone',\n\t'depth',\n\t'expansion',\n])\n\n/**\n * Lists every {@link FaultKind}, frozen.\n *\n * @remarks\n * The runtime source of truth for the vocabulary, which {@link isFault} reads.\n *\n * @example\n * ```ts\n * FAULT_KINDS.includes('string') // true\n * ```\n */\nexport const FAULT_KINDS: readonly FaultKind[] = Object.freeze([\n\t'string',\n\t'date',\n\t'number',\n\t'integer',\n\t'boolean',\n\t'null',\n\t'literal',\n\t'array',\n\t'object',\n\t'union',\n\t'json',\n\t'shape',\n])\n\n/**\n * Lists every {@link FaultConstraint}, frozen.\n *\n * @remarks\n * The runtime source of truth for the vocabulary, which {@link isFault} reads.\n *\n * @example\n * ```ts\n * FAULT_CONSTRAINTS.includes('min') // true\n * ```\n */\nexport const FAULT_CONSTRAINTS: readonly FaultConstraint[] = Object.freeze([\n\t'min',\n\t'max',\n\t'pattern',\n\t'date',\n\t'integer',\n])\n\n// Reporting-surface bounds (`compileReporter` / `compileAuditor` —\n// `ContractInterface.explain` / `ContractInterface.audit`).\n\n/**\n * Caps at `64` the number of {@link Fault} / {@link AuditFault} entries a single\n * `explain` or `audit` report ever returns, frozen.\n *\n * @remarks\n * Bounds BOTH reports against adversarial input (a giant array, a wide record)\n * — `compileReporter` and `compileAuditor` each collect faults in stable\n * pre-order and stop once this cap is reached, and every recursive call slices\n * to it, so the report size (and the work to build it) stays finite and\n * deterministic at every nesting level regardless of the input's size. Size a\n * diagnostic surface off this constant and it bounds `audit` exactly as it\n * bounds `explain`.\n */\nexport const FAULT_LIMIT = 64\n\n/**\n * Caps at `64` the character length of a {@link preview}-rendered string, frozen.\n *\n * @remarks\n * A previewed string longer than this is clipped with a trailing `…` so a\n * {@link Fault}'s `received` field never embeds an unbounded amount of\n * untrusted text.\n */\nexport const PREVIEW_LIMIT = 64\n\n// Runtime recursion and generation bounds.\n\n/**\n * Caps the active recursion or JSON container depth for runtime guards, frozen.\n *\n * @remarks\n * Bounds explicitly recursive guards before the JavaScript call stack becomes\n * the limiting mechanism. It also caps array/plain-record containers on each\n * active path inspected by {@link matchesJSONDepth}: noncontainers are depth\n * zero, an empty container is depth one, 512 containers pass, and the 513th\n * fails. Active cycle edges do not add a level.\n *\n * @example\n * ```ts\n * GUARD_DEPTH_LIMIT // 512\n * ```\n */\nexport const GUARD_DEPTH_LIMIT = 512\n\n/**\n * Caps at `512` the supported nesting depth of a compiled contract shape, frozen.\n *\n * @remarks\n * {@link validateShape} rejects the next level\n * with a depth-coded {@link ContractError} before recursive artifact\n * compilation begins, so a finite but pathologically deep developer-authored\n * shape fails predictably instead of reaching the JavaScript call-stack limit.\n *\n * @example\n * ```ts\n * COMPILE_DEPTH_LIMIT // 512\n * ```\n */\nexport const COMPILE_DEPTH_LIMIT = 512\n\n/**\n * Caps at `16384` the number of nodes a compiled artifact may expand a shape into,\n * frozen.\n *\n * @remarks\n * A shape graph is a DAG; every compiled artifact is a TREE. A declaration may\n * therefore be tiny and its schema, guard, parser, reporter, auditor and\n * generated value enormous: `objectShape({ left: node, right: node })` nested\n * thirty times is thirty-one authored nodes that expand into more than a\n * billion emitted ones. Sharing one child is ordinary authoring, not an attack,\n * and the compilers cannot fold the expansion away without publishing a schema\n * whose members alias each other.\n *\n * So the cost is BOUNDED rather than paid. {@link validateShape} and\n * {@link ContractCompiler} preparation both count the nodes the declaration\n * expands into (one per node, summed over every incoming edge) and refuse past\n * this cap through {@link refuseExpansion}, with an `expansion`-coded\n * {@link ContractError}. Ownership is deliberately NOT bounded by it:\n * {@link cloneShape} and {@link ownShape} preserve shared-child identity, so\n * they answer a shared-child graph in time proportional to its authored nodes\n * and keep working above this cap.\n *\n * This cap does not bound compilation, because the compilers do not expand a\n * DAG. Every artifact family is one entry per unique node, so the boundary\n * declaration above compiles its unique nodes in about a millisecond.\n * What does expand is what a CONSUMER materializes from the artifacts: the\n * value `generate` builds, and the document a compiled schema serializes to,\n * are trees of exactly this size. The cap survives as a bound on what a caller\n * can be handed, not on what the compiler pays.\n *\n * @example\n * ```ts\n * COMPILE_NODE_LIMIT // 16384\n * ```\n */\nexport const COMPILE_NODE_LIMIT = 16_384\n\n/**\n * Caps at `31` the number of object keys one compiled presence mask carries, frozen.\n *\n * @remarks\n * A compiled object plan decides which declared keys a value carries. The keys\n * it asks about are fixed when the plan is built, so the plan assigns each one a\n * bit position once and a call ORs one bit per own key it finds and compares the\n * result against the full mask — no per-call collection, and one integer compare\n * instead of one membership dispatch per declared key.\n *\n * The bound is the width a JavaScript bitwise operand has: `1 << position`\n * evaluates on a 32-bit signed integer, so positions run `0` through `30` and a\n * mask stays positive. A declaration with more keys than this is ordinary\n * authoring rather than an attack, so it is answered rather than refused:\n * {@link ContractCompiler} builds no position record for it and its compiled\n * guard, parser, auditor, and reporter decide presence from a collected key\n * vocabulary instead. Both branches answer identically; only the cost differs.\n *\n * @example\n * ```ts\n * PRESENCE_MASK_LIMIT // 31\n * ```\n */\nexport const PRESENCE_MASK_LIMIT = 31\n\n/**\n * Caps at `262144` the number of nodes one JSON snapshot may produce, frozen.\n *\n * @remarks\n * JSON persistence is a TREE, so `cloneJSONValue` / `cloneJSONRecord`\n * deliberately duplicate a repeated noncyclic alias into distinct equal\n * branches — `clone.primary !== clone.fallback` is a documented guarantee, not\n * an accident, and a memo would silently take it away. The price of that\n * guarantee is that output size is exponential in the number of shared aliases:\n * an ordinary in-memory graph of twenty-one objects, a few hundred bytes,\n * produced two million nodes and took seconds, and thirty aliases took hours.\n * No attacker is needed — shared references are normal data.\n *\n * So the cost is BOUNDED rather than paid: the walk counts the nodes it\n * produces and refuses past this cap with the ordinary cause-free `clone`\n * refusal, which makes the door's worst case a function of this constant\n * instead of the caller's input. Size a snapshot against it: a document with\n * more than this many nodes — counting every array, record, and leaf the\n * snapshot would contain AFTER alias duplication — is refused rather than\n * cloned.\n *\n * @example\n * ```ts\n * CLONE_NODE_LIMIT // 262144\n * ```\n */\nexport const CLONE_NODE_LIMIT = 262_144\n\n/**\n * Caps at `32` the number of candidate-generation attempts for a constrained generated\n * value, frozen.\n *\n * @remarks\n * Provides one deterministic work bound for generators that must retry a\n * candidate against a contract constraint.\n *\n * @example\n * ```ts\n * GENERATION_ATTEMPT_LIMIT // 32\n * ```\n */\nexport const GENERATION_ATTEMPT_LIMIT = 32\n\n// Value-to-schema inference bounds (`valueToSchema` / `samplesToSchema`).\n\n/**\n * Caps at `32` the object/array nesting depth {@link valueToSchema} walks, frozen.\n *\n * @remarks\n * Bounds inference against adversarial or cyclic runtime input — once the\n * remaining depth budget reaches zero, inference stops descending and emits\n * the empty accept-anything schema `{}` for that branch instead of recursing\n * further. LOWERABLE per call through {@link ValueToSchemaLimits.depth}; a\n * higher value is held here.\n *\n * A ceiling rather than a default, because the walk recurses: what a deeper\n * walk spends is the JavaScript call stack rather than this budget, and that\n * stack is not a fixed quantity. The survivable depth measured on one host rose\n * across repeated calls within a single process as the engine optimized, and\n * fell to roughly this number under a reduced stack size. Any larger constant\n * therefore has a host where it fails, which is why none is published.\n */\nexport const INFER_DEPTH_LIMIT = 32\n\n/**\n * Caps by default at `256` the number of object properties / array elements {@link\n * valueToSchema} samples per container, frozen.\n *\n * @remarks\n * Bounds the work (and the emitted schema's size) against a wide record or a\n * huge array — properties/elements beyond this cap are never inspected.\n * Overridable per call through {@link ValueToSchemaLimits.properties}.\n */\nexport const INFER_BREADTH_LIMIT = 256\n\n/**\n * Caps by default at `12` the number of distinct values a multi-sample slot may hold\n * before enum inference gives up and falls back to a bare `type`, frozen.\n *\n * @remarks\n * Bounds how large an `enum` list {@link samplesToSchema} will emit — a slot with distinct-value count at or above this limit is\n * treated as unbounded (an ID column, not a category) and never gets an\n * `enum` keyword. Overridable per call through {@link ValueToSchemaOptions.enum}\n * (which gates whether enum inference runs at all).\n */\nexport const INFER_ENUM_LIMIT = 12\n\n/**\n * Caps at `128` the string length {@link stringToFormat} attempts to classify, frozen.\n *\n * @remarks\n * Bounds per-string format-detection work: a value longer than this returns\n * `undefined` immediately, before any pattern match runs. 128 sits\n * comfortably above the longest real format token — an RFC 3339 date-time\n * with fractional seconds and a UTC offset — so no legitimate classification\n * changes; only pathologically long strings (a multi-megabyte payload passed\n * as a candidate email/URI) are skipped.\n */\nexport const FORMAT_MAX_LENGTH = 128\n\n/**\n * Holds the pure-regex matchers backing {@link stringToFormat}'s pattern-only\n * formats (`uuid` / `email` / `uri`), frozen as data.\n *\n * @remarks\n * The ISO-8601 date/time formats are NOT listed here — they additionally\n * require an attempt-guarded `Date` validity check, so their pattern lives\n * inline in `stringToFormat` rather than as reusable standalone data.\n */\nexport const FORMAT_PATTERNS: Readonly<Record<'uuid' | 'email' | 'uri', RegExp>> = Object.freeze({\n\tuuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n\temail: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\n\turi: /^[a-z][a-z0-9+.-]*:\\/\\//i,\n})\n\n/**\n * Holds `10`, the length of every `YYYY-MM-DD` date a date string shape admits.\n *\n * @remarks\n * A date string shape whose `min` or `max` excludes this length admits no value, so\n * building one refuses with code `range`.\n *\n * @example\n * ```ts\n * DATE_LENGTH // 10\n * ```\n */\nexport const DATE_LENGTH = 10\n\n// Schema retention limits, declared for a package whose schema retains authored data.\n\n/**\n * Caps at `1024` the number of choices one schema field may offer, frozen.\n *\n * @remarks\n * A retention limit that a declaring package, such as a form or table schema\n * package, enforces; this package enforces none of the retention limits itself.\n *\n * @example\n * ```ts\n * CHOICE_LIMIT // 1024\n * ```\n */\nexport const CHOICE_LIMIT = 1024\n\n/**\n * Caps at `128` the length, in UTF-16 code units, of one name a schema declares, frozen:\n * a schema, group, or field name, or a column key.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * NAME_LIMIT // 128\n * ```\n */\nexport const NAME_LIMIT = 128\n\n/**\n * Caps at `65536` the length, in UTF-16 code units, of any single string one schema\n * retains, frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * STRING_LIMIT // 65536\n * ```\n */\nexport const STRING_LIMIT = 65_536\n\n/**\n * Caps at `1048576` the total length, in UTF-16 code units, of every string one schema\n * retains, frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * TEXT_LIMIT // 1048576\n * ```\n */\nexport const TEXT_LIMIT = 1_048_576\n\n/**\n * Caps at `16384` the total number of records, arrays, and leaves one schema retains,\n * frozen.\n *\n * @remarks\n * A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.\n *\n * @example\n * ```ts\n * NODE_LIMIT // 16384\n * ```\n */\nexport const NODE_LIMIT = 16_384\n\n/** Caps a fault message at 2048 UTF-16 code units. */\nexport const FAULT_TEXT_LIMIT = 2048\n\n/** Caps the keys or literal candidates named in a fault line. */\nexport const FAULT_LIST_LIMIT = 12\n\n/** Caps a schema summary's UTF-16 code units. */\nexport const FAULT_SCHEMA_LIMIT = 160\n","import type { ContractErrorContext, ContractErrorOptions } from './types.js'\nimport { CONTRACT_CODES, CONTRACT_ERROR_BRAND, INTRINSICS } from './constants.js'\n\n/**\n * Carries a machine-readable contract category, optional context, and an exact optional\n * cause.\n *\n * @remarks\n * Omitting `cause` omits the own property; explicitly supplying `cause: undefined`\n * retains an own property with that value. Both optional options are read as OWN\n * properties, so a construction never consults the caller-writable prototype chain of\n * the container it was handed.\n *\n * @example\n * ```ts\n * const error = new ContractError('Minimum exceeds maximum', {\n * \tcode: 'range',\n * \tcontext: { path: ['properties', 'age'] },\n * })\n * ```\n */\nexport class ContractError extends Error {\n\toverride readonly name: string = 'ContractError'\n\treadonly code\n\treadonly context: ContractErrorContext | undefined\n\n\t/**\n\t * Creates a contract error.\n\t *\n\t * @param message - Human-readable error description\n\t * @param options - Machine-readable category, optional context, and optional cause\n\t */\n\tconstructor(message: string, options: ContractErrorOptions) {\n\t\tsuper(message, INTRINSICS.own(options, 'cause') ? { cause: options.cause } : undefined)\n\t\tINTRINSICS.define(this, CONTRACT_ERROR_BRAND, { value: this, configurable: true })\n\t\tthis.code = options.code\n\t\tthis.context = INTRINSICS.own(options, 'context') ? options.context : undefined\n\t}\n\n\tstatic {\n\t\t// The `pinMembers` body, inlined for the reason that helper's `@remarks`\n\t\t// records: `helpers.ts` imports this module, so calling it here would invert\n\t\t// the dependency. It stays aligned with that helper, accessor branch and\n\t\t// answering `declare` included, so this body and `pinMembers` cannot pin\n\t\t// differently.\n\t\tconst members = INTRINSICS.reflect.members(this.prototype)\n\t\tfor (const key of members) {\n\t\t\tif (key === undefined) continue\n\t\t\tconst declared = INTRINSICS.describe(this.prototype, key)\n\t\t\tconst accessor = declared !== undefined && !INTRINSICS.own(declared, 'value')\n\t\t\tINTRINSICS.reflect.define(\n\t\t\t\tthis.prototype,\n\t\t\t\tkey,\n\t\t\t\taccessor ? { configurable: false } : { writable: false, configurable: false },\n\t\t\t)\n\t\t\tconst pinned = INTRINSICS.describe(this.prototype, key)\n\t\t\tif (pinned?.configurable !== false || (!accessor && pinned.writable !== false)) {\n\t\t\t\tthrow new ContractError('ContractError: a prototype member could not be pinned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Checks whether an unknown value is a {@link ContractError}.\n *\n * @remarks\n * Recognition combines a global own-property brand with the native `Error`\n * base, a subclass prototype, an own declared contract code, and valid context.\n * Context may be a class instance or callable object; paths are checked by index.\n * Optional context fields are read only when owned; inherited fields are ignored.\n * A subclass may replace its name without changing recognition.\n * The brand stores the error itself and recognition requires that exact\n * identity. A transparent proxy is therefore refused because its forwarded\n * descriptor still stores the target, not the proxy.\n * The brand is recognized across duplicate installations and ESM/CommonJS\n * module copies at 0.0.13 or later. A copy earlier than 0.0.13 stamps no brand,\n * so an error it throws stays outside the type, and so does a plain or\n * property-only lookalike.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `ContractError` instance; false otherwise\n *\n * @example\n * ```ts\n * isContractError(new ContractError('Invalid shape', { code: 'placement' })) // true\n * isContractError(new Error('Invalid shape')) // false\n * ```\n */\nexport function isContractError(value: unknown): value is ContractError {\n\tif (typeof value !== 'object' || value === null) return false\n\ttry {\n\t\tif (\n\t\t\t!(value instanceof INTRINSICS.error) ||\n\t\t\tINTRINSICS.prototype(value) === INTRINSICS.error.prototype\n\t\t) {\n\t\t\treturn false\n\t\t}\n\t\tif (!INTRINSICS.own(value, 'code')) return false\n\t\tconst descriptor = INTRINSICS.describe(value, CONTRACT_ERROR_BRAND)\n\t\tif (descriptor?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, CONTRACT_CODES, [\n\t\t\t\t(candidate: unknown) => candidate === code,\n\t\t\t])\n\t\t) {\n\t\t\treturn false\n\t\t}\n\t\tconst context: unknown = INTRINSICS.own(value, 'context')\n\t\t\t? INTRINSICS.reflect.read(value, 'context')\n\t\t\t: undefined\n\t\tif (context === undefined) return true\n\t\tif ((typeof context !== 'object' || context === null) && typeof context !== 'function') {\n\t\t\treturn false\n\t\t}\n\t\tconst path: unknown = INTRINSICS.own(context, 'path')\n\t\t\t? INTRINSICS.reflect.read(context, 'path')\n\t\t\t: undefined\n\t\tif (path !== undefined && typeof path !== 'string') {\n\t\t\tif (!INTRINSICS.array(path)) return false\n\t\t\tif (\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, path, [\n\t\t\t\t\t(segment: unknown) => typeof segment !== 'string',\n\t\t\t\t]) !== -1\n\t\t\t) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tconst shape: unknown = INTRINSICS.own(context, 'shape')\n\t\t\t? INTRINSICS.reflect.read(context, 'shape')\n\t\t\t: undefined\n\t\tif (shape !== undefined && typeof shape !== 'string') return false\n\t\tconst limit: unknown = INTRINSICS.own(context, 'limit')\n\t\t\t? INTRINSICS.reflect.read(context, 'limit')\n\t\t\t: undefined\n\t\tif (limit !== undefined && typeof limit !== 'number' && typeof limit !== 'string') return false\n\t\tconst received: unknown = INTRINSICS.own(context, 'received')\n\t\t\t? INTRINSICS.reflect.read(context, 'received')\n\t\t\t: undefined\n\t\treturn received === undefined || typeof received === 'string'\n\t} catch {\n\t\treturn false\n\t}\n}\n","import type {\n\tAnyAsyncFunction,\n\tAnyConstructor,\n\tAnyFunction,\n\tAuditFault,\n\tFault,\n\tFieldPath,\n\tJSONPrimitive,\n\tJSONRecord,\n\tJSONValue,\n\tLiteralValue,\n\tZeroArgAsyncFunction,\n\tZeroArgFunction,\n} from './types.js'\nimport { FAULT_CONSTRAINTS, FAULT_KINDS, INTRINSICS } from './constants.js'\nimport {\n\tholds,\n\tisFailure,\n\tmatchesExactKeys,\n\tmatchesJSONDepth,\n\tmatchesJSONValue,\n\tmatchesRecordBrand,\n\treadArrayEntries,\n\treadPatternSource,\n} from './helpers.js'\n\n// `.claude/rules/patterns.md` § Validation and contracts: guards are total\n// functions — a guard NEVER throws. Adversarial\n// input (hostile getters, exotic objects, cycles) returns `false`, never an\n// error. Guards built from a single `typeof` / strict-equality test are\n// immediately total — no probe of the value's internals can throw. Every\n// OTHER guard here probes the value in some way — a property read through\n// `Reflect.get`, a structural walk (`isPromiseLike`, `isIterable`,\n// `isAsyncIterable`, `isJSONValue`, `isRecord`), an `instanceof` check (which\n// invokes the target's `[Symbol.hasInstance]` / triggers a `getPrototypeOf`\n// trap), or an own-key enumeration (`isEmptyObject` / `isNonEmptyObject`) —\n// so a hostile getter, a revoked `Proxy`, or an exotic trap can throw\n// mid-probe. Totality is NOT automatic for these: each contains its whole\n// probe/walk in `holds` (see ./helpers.js) and returns `false` on a caught\n// throw. Every `instanceof`-based guard in this file routes through the\n// shared {@link isInstance} helper, which is the one place that containment\n// lives for that family.\n\n// === Primitive guards\n\n/** Determines whether a value is `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is `null`; false otherwise\n *\n * @example\n * ```ts\n * isNull(null) // true\n * isNull(undefined) // false\n * ```\n */\nexport function isNull(value: unknown): value is null {\n\treturn value === null\n}\n\n/** Determines whether a value is `undefined`.\n *\n * @param value - The value to inspect\n * @returns True if the value is `undefined`; false otherwise\n *\n * @example\n * ```ts\n * isUndefined(undefined) // true\n * isUndefined(null) // false\n * ```\n */\nexport function isUndefined(value: unknown): value is undefined {\n\treturn value === undefined\n}\n\n/** Determines whether a value is defined (neither `null` nor `undefined`).\n *\n * @param value - The value to inspect\n * @returns True if the value is defined; false otherwise\n *\n * @example\n * ```ts\n * isDefined('hi') // true\n * isDefined(null) // false\n * isDefined(undefined) // false\n * ```\n */\nexport function isDefined<T>(value: T | null | undefined): value is T {\n\treturn value !== null && value !== undefined\n}\n\n/** Determines whether a value is a string.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string; false otherwise\n *\n * @example\n * ```ts\n * isString('hi') // true\n * isString(42) // false\n * ```\n */\nexport function isString(value: unknown): value is string {\n\treturn typeof value === 'string'\n}\n\n/**\n * Determines whether a value is a number.\n *\n * @remarks\n * Includes `NaN` and `±Infinity` — use {@link isFiniteNumber} to exclude them.\n *\n * @param value - The value to inspect\n * @returns True if the value is a number; false otherwise\n *\n * @example\n * ```ts\n * isNumber(42) // true\n * isNumber(Number.NaN) // true — NaN is still a number\n * isNumber('42') // false\n * ```\n */\nexport function isNumber(value: unknown): value is number {\n\treturn typeof value === 'number'\n}\n\n/** Determines whether a value is a finite number (excludes `NaN` and `±Infinity`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite number; false otherwise\n *\n * @example\n * ```ts\n * isFiniteNumber(42) // true\n * isFiniteNumber(Number.NaN) // false\n * isFiniteNumber(Infinity) // false\n * ```\n */\nexport function isFiniteNumber(value: unknown): value is number {\n\treturn typeof value === 'number' && INTRINSICS.finite(value)\n}\n\n/** Determines whether a value is a finite integer (excludes `NaN`, `±Infinity`, and fractional numbers).\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite integer; false otherwise\n *\n * @example\n * ```ts\n * isInteger(3) // true\n * isInteger(3.5) // false\n * ```\n */\nexport function isInteger(value: unknown): value is number {\n\treturn INTRINSICS.integer(value)\n}\n\n/**\n * Determines whether a value is a finite primitive number at or above positive zero.\n *\n * @remarks\n * Positive fractions pass. Negative zero is rejected explicitly, and no\n * coercion or property access is performed for non-number inputs.\n *\n * @param value - The value to inspect\n * @returns True if the value is a finite primitive number greater than or equal\n * to zero, except `-0`; false otherwise\n *\n * @example\n * ```ts\n * isNonNegativeNumber(0.5) // true\n * isNonNegativeNumber(-0) // false\n * ```\n */\nexport function isNonNegativeNumber(value: unknown): value is number {\n\treturn isFiniteNumber(value) && value >= 0 && !INTRINSICS.same(value, -0)\n}\n\n/**\n * Determines whether a value is a non-negative finite primitive integer.\n *\n * @remarks\n * Composes {@link isNonNegativeNumber} with {@link isInteger}. Representable\n * unsafe integers remain integers; safe-integer policy is a separate domain.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-negative integer other than `-0`; false otherwise\n *\n * @example\n * ```ts\n * isNonNegativeInteger(3) // true\n * isNonNegativeInteger(3.5) // false\n * ```\n */\nexport function isNonNegativeInteger(value: unknown): value is number {\n\treturn isNonNegativeNumber(value) && isInteger(value)\n}\n\n/** Determines whether a value is a boolean.\n *\n * @param value - The value to inspect\n * @returns True if the value is a boolean; false otherwise\n *\n * @example\n * ```ts\n * isBoolean(true) // true\n * isBoolean(1) // false\n * ```\n */\nexport function isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean'\n}\n\n/**\n * Determines whether a value belongs to the string, number, or boolean literal domain.\n *\n * @remarks\n * Every JavaScript number belongs to this structural domain, including `NaN`,\n * `±Infinity`, and signed zero. Declaration and schema policies apply finiteness\n * separately where their contracts require it.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string, number, or boolean; false otherwise\n *\n * @example\n * ```ts\n * isLiteralValue(Number.NaN) // true\n * isLiteralValue(null) // false\n * ```\n */\nexport function isLiteralValue(value: unknown): value is LiteralValue {\n\treturn isString(value) || isNumber(value) || isBoolean(value)\n}\n\n/** Determines whether a value is exactly `true`.\n *\n * @param value - The value to inspect\n * @returns True if the value is exactly `true`; false otherwise\n *\n * @example\n * ```ts\n * isTrue(true) // true\n * isTrue(false) // false\n * ```\n */\nexport function isTrue(value: unknown): value is true {\n\treturn value === true\n}\n\n/** Determines whether a value is exactly `false`.\n *\n * @param value - The value to inspect\n * @returns True if the value is exactly `false`; false otherwise\n *\n * @example\n * ```ts\n * isFalse(false) // true\n * isFalse(true) // false\n * ```\n */\nexport function isFalse(value: unknown): value is false {\n\treturn value === false\n}\n\n/** Determines whether a value is a bigint.\n *\n * @param value - The value to inspect\n * @returns True if the value is a bigint; false otherwise\n *\n * @example\n * ```ts\n * isBigInt(1n) // true\n * isBigInt(1) // false\n * ```\n */\nexport function isBigInt(value: unknown): value is bigint {\n\treturn typeof value === 'bigint'\n}\n\n/** Determines whether a value is a symbol.\n *\n * @param value - The value to inspect\n * @returns True if the value is a symbol; false otherwise\n *\n * @example\n * ```ts\n * isSymbol(Symbol('x')) // true\n * isSymbol('x') // false\n * ```\n */\nexport function isSymbol(value: unknown): value is symbol {\n\treturn typeof value === 'symbol'\n}\n\n/** Determines whether a value is callable.\n *\n * @param value - The value to inspect\n * @returns True if the value is callable; false otherwise\n *\n * @example\n * ```ts\n * isFunction(() => {}) // true\n * isFunction({}) // false\n * ```\n */\nexport function isFunction(value: unknown): value is AnyFunction {\n\treturn typeof value === 'function'\n}\n\n/** Determines whether a value is a string or `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableString('hi') // true\n * isNullableString(null) // true\n * isNullableString(42) // false\n * ```\n */\nexport function isNullableString(value: unknown): value is string | null {\n\treturn value === null || isString(value)\n}\n\n/** Determines whether a value is a number or `null` (the number may be `NaN` / `±Infinity`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a number or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableNumber(42) // true\n * isNullableNumber(null) // true\n * isNullableNumber('hi') // false\n * ```\n */\nexport function isNullableNumber(value: unknown): value is number | null {\n\treturn value === null || isNumber(value)\n}\n\n/** Determines whether a value is a boolean or `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a boolean or `null`; false otherwise\n *\n * @example\n * ```ts\n * isNullableBoolean(true) // true\n * isNullableBoolean(null) // true\n * isNullableBoolean(1) // false\n * ```\n */\nexport function isNullableBoolean(value: unknown): value is boolean | null {\n\treturn value === null || isBoolean(value)\n}\n\n// === Built-in guards\n//\n// The `instanceof`-based guard families below (Date/RegExp/Error/Promise,\n// Map/Set/WeakMap/WeakSet, the typed-array guards) are same-realm checks:\n// `instanceof` compares against the constructor's prototype in the CURRENT\n// realm, so a value built by another realm (a different `vm.Context`, iframe,\n// or worker global) fails even when it is structurally identical. This is a\n// known, accepted limitation — cross-realm identity would require duck-typing\n// every built-in, which trades soundness for portability.\n\n/**\n * Determines whether a value is an instance of a constructor, contained against\n * a throwing `instanceof` check.\n *\n * @remarks\n * The low-level total helper every `instanceof`-based guard in this file (and\n * the `instanceOf` combinator) routes through. A bare `value instanceof X` is\n * NOT total, which `.claude/rules/patterns.md` § Validation and contracts\n * requires: it invokes `getPrototypeOf` on `value` — which a\n * revoked `Proxy` or a `getPrototypeOf`-trap `Proxy` throws from — and, when\n * `X[Symbol.hasInstance]` is user-defined, can throw from arbitrary code. This\n * wraps the check in {@link holds} (see ./helpers.js) so any such throw\n * yields `false` instead of escaping.\n *\n * Narrows `value` to `InstanceType<C>`, which reads the constructor's last\n * construct signature. Accepts the same constructors as `instanceOf`: a public\n * or abstract construct signature returning an object (or `any`). A class with a\n * private or protected constructor and the bare `AnyConstructor` are refused at the call.\n * A value typed `Function` cannot be passed because the `Function` interface has\n * no construct signature. The constructor `Function` can be passed through\n * `FunctionConstructor`'s construct signature and narrows to `Function`.\n * The false branch drops each member of the declared union that is a subtype\n * of the instance type and keeps the rest, so a subclass that adds no member\n * narrows its base out as well (and a subclass that adds only an optional member\n * does not). A constructor whose instance type admits\n * primitives structurally, such as `Object`, makes the false branch unsound;\n * use `isObject` for that check.\n *\n * @param value - The value to test\n * @param ctor - The constructor to test against\n * @returns True if `value instanceof ctor`; false otherwise, including on a\n * contained throw\n *\n * @example\n * ```ts\n * isInstance(new Date(), Date) // true\n * isInstance({}, Date) // false\n * ```\n */\nexport function isInstance<C extends abstract new (...args: never) => object>(\n\tvalue: unknown,\n\tctor: C,\n): value is InstanceType<C> {\n\t// Keep the published runtime behaviour: `isFunction` makes a non-callable\n\t// right-hand side return `false` without consulting its `Symbol.hasInstance`\n\t// or causing a contained `TypeError`.\n\tconst target: unknown = ctor\n\treturn holds(() => isFunction(target) && value instanceof target)\n}\n\n/** Determines whether a value is a `Date`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Date`; false otherwise\n *\n * @example\n * ```ts\n * isDate(new Date()) // true\n * isDate('2024-01-01') // false\n * ```\n */\nexport function isDate(value: unknown): value is Date {\n\treturn isInstance(value, Date)\n}\n\n/** Determines whether a value is a `RegExp`.\n *\n * @remarks\n * A total native internal-slot brand check rather than a property read: it accepts a\n * genuine pattern from this realm and from another, and refuses a proxy or a hand-built\n * forgery without reading an advertised field.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `RegExp`; false otherwise\n *\n * @example\n * ```ts\n * isRegExp(/a/) // true\n * isRegExp('a') // false\n * ```\n */\nexport function isRegExp(value: unknown): value is RegExp {\n\t// The CAPTURED `source` getter applied to the candidate. That getter is\n\t// defined only on an object carrying the pattern's internal slots, so a\n\t// non-pattern throws and this total guard answers `false`. Re-reading the\n\t// descriptor off `RegExp.prototype` per call would observe whatever getter is\n\t// installed at that moment and check only that it returned a string — so\n\t// `Object.defineProperty(RegExp.prototype, 'source', { get: () => '.*' })`\n\t// would make this guard accept a plain string, and it gates `matchOf`,\n\t// `stringOf` and every string shape builder.\n\treturn holds(() => readPatternSource(value) !== undefined)\n}\n\n/** Determines whether a value is an `Error`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Error`; false otherwise\n *\n * @example\n * ```ts\n * isError(new Error('boom')) // true\n * isError('boom') // false\n * ```\n */\nexport function isError(value: unknown): value is Error {\n\treturn isInstance(value, Error)\n}\n\n/** Determines whether a value is a native `Promise` (use {@link isPromiseLike} for any thenable).\n *\n * @param value - The value to inspect\n * @returns True if the value is a native `Promise`; false otherwise\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve()) // true\n * isPromise({ then() {} }) // false\n * ```\n */\nexport function isPromise<T = unknown>(value: unknown): value is Promise<T> {\n\treturn isInstance(value, Promise)\n}\n\n/**\n * Determines whether a value is promise-like — an object exposing callable\n * `then`, `catch`, and `finally` methods.\n *\n * @remarks\n * Accepts any object with all three methods, not only native `Promise`\n * instances. Use {@link isPromise} when you specifically need `instanceof Promise`.\n *\n * @param value - The value to inspect\n * @returns True if the value is promise-like; false otherwise\n *\n * @example\n * ```ts\n * isPromiseLike(Promise.resolve()) // true\n * isPromiseLike({ then() {}, catch() {}, finally() {} }) // true\n * isPromiseLike({ then() {} }) // false\n * ```\n */\nexport function isPromiseLike<T = unknown>(\n\tvalue: unknown,\n): value is Promise<T> | (PromiseLike<T> & { catch: unknown; finally: unknown }) {\n\treturn holds(() => {\n\t\tif (!isObject(value)) {\n\t\t\treturn false\n\t\t}\n\t\tconst thenValue = INTRINSICS.reflect.read(value, 'then')\n\t\tconst catchValue = INTRINSICS.reflect.read(value, 'catch')\n\t\tconst finallyValue = INTRINSICS.reflect.read(value, 'finally')\n\t\treturn isFunction(thenValue) && isFunction(catchValue) && isFunction(finallyValue)\n\t})\n}\n\n/** Determines whether a value is an `ArrayBuffer`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `ArrayBuffer`; false otherwise\n *\n * @example\n * ```ts\n * isArrayBuffer(new ArrayBuffer(8)) // true\n * isArrayBuffer([]) // false\n * ```\n */\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n\treturn isInstance(value, ArrayBuffer)\n}\n\n/**\n * Determines whether a value is a `SharedArrayBuffer`.\n *\n * @remarks\n * Guards the global existence of `SharedArrayBuffer` first — safe where it is\n * absent or disabled (for example a context that is not cross-origin isolated).\n *\n * @param value - The value to inspect\n * @returns True if the value is a `SharedArrayBuffer`; false otherwise\n *\n * @example\n * ```ts\n * isSharedArrayBuffer(new SharedArrayBuffer(8)) // true\n * isSharedArrayBuffer(new ArrayBuffer(8)) // false\n * ```\n */\nexport function isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer {\n\treturn typeof SharedArrayBuffer !== 'undefined' && isInstance(value, SharedArrayBuffer)\n}\n\n// === Protocol guards\n\n/**\n * Determines whether a value implements the iterable protocol (`Symbol.iterator`).\n *\n * @remarks\n * Strings are explicitly included: a string has a callable `Symbol.iterator`\n * but is not an object, so the generic object path alone would miss it.\n *\n * @param value - The value to inspect\n * @returns True if the value implements the iterable protocol; false otherwise\n *\n * @example\n * ```ts\n * isIterable([1, 2]) // true\n * isIterable('abc') // true\n * isIterable({ a: 1 }) // false\n * ```\n */\nexport function isIterable<T = unknown>(value: unknown): value is Iterable<T> {\n\treturn holds(() => {\n\t\tif (isString(value)) {\n\t\t\treturn true\n\t\t}\n\t\treturn isObject(value) && isFunction(INTRINSICS.reflect.read(value, Symbol.iterator))\n\t})\n}\n\n/** Determines whether a value implements the async iterable protocol (`Symbol.asyncIterator`).\n *\n * @param value - The value to inspect\n * @returns True if the value implements the async iterable protocol; false otherwise\n *\n * @example\n * ```ts\n * isAsyncIterable({ [Symbol.asyncIterator]() {} }) // true\n * isAsyncIterable([1, 2]) // false\n * ```\n */\nexport function isAsyncIterable<T = unknown>(value: unknown): value is AsyncIterable<T> {\n\treturn holds(\n\t\t() => isObject(value) && isFunction(INTRINSICS.reflect.read(value, Symbol.asyncIterator)),\n\t)\n}\n\n// === Object & collection guards\n\n/**\n * Determines whether a value is a non-null object.\n *\n * @remarks\n * `true` for every non-null object, including an array, a class instance, a\n * plain object, a `Map`, and a `Set` — use\n * {@link isRecord} when you need a plain-record check.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-null object; false otherwise\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject([]) // true\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && value !== null\n}\n\n/**\n * Determines whether a value is a plain record (object literal or null-prototype),\n * not an array or class instance.\n *\n * @remarks\n * The total form of the shared {@link matchesRecordBrand} rule, and the only\n * one a guard may use: the whole brand runs inside `holds`, as\n * `.claude/rules/patterns.md` § Validation and contracts requires, so a\n * revoked `Proxy` or a hostile `getPrototypeOf` trap answers `false` instead of\n * escaping as a thrown error. Use instead of {@link isObject} to distinguish a\n * plain `{}` / `Object.create(null)` — or a plain object from another realm,\n * whose prototype is that realm's `Object.prototype` — from arrays, `Date`,\n * `Map`, and class instances, including a class whose prototype a caller\n * reparented to `null`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a plain record; false otherwise\n *\n * @example\n * ```ts\n * isRecord({ a: 1 }) // true\n * isRecord(Object.create(null)) // true\n * isRecord([]) // false\n * isRecord(new Date()) // false\n * ```\n */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn holds(() => matchesRecordBrand(value))\n}\n\n/**\n * Determines whether a value is the {@link FieldPath} a fault carries: a key, or a dense list of keys.\n *\n * @param value - The value to inspect\n * @returns True if the value is a string or a dense array of strings; false otherwise\n *\n * @example\n * ```ts\n * isFaultPath(['user', 'name']) // true\n * isFaultPath([1]) // false\n * ```\n */\nexport function isFaultPath(value: unknown): value is FieldPath {\n\tif (isString(value)) return true\n\treturn holds(() => {\n\t\tif (!isArray(value)) return false\n\t\tconst snapshot = readArrayEntries(value)\n\t\tif (isFailure(snapshot) || !snapshot.value.dense) return false\n\t\treturn !INTRINSICS.reflect.apply(INTRINSICS.some, snapshot.value.entries, [\n\t\t\t(entry: unknown) => !isString(entry),\n\t\t])\n\t})\n}\n\n/**\n * Determines whether a value is exactly one {@link Fault}.\n *\n * @remarks\n * A closed reading of the union: each reason's required fields, each with its own\n * vocabulary, and no other key, so `{}` and a fault carrying a stray field both answer\n * `false`. An undeclared-key fault is an {@link AuditFault} and answers `false` here.\n *\n * @param value - The value to inspect\n * @returns True if the value is a well-formed fault; false otherwise\n *\n * @example\n * ```ts\n * isFault({ reason: 'missing', path: ['a'], expected: 'string' }) // true\n * isFault({}) // false\n * ```\n */\nexport function isFault(value: unknown): value is Fault {\n\treturn holds(() => {\n\t\tif (!isRecord(value) || !isFaultPath(value.path)) return false\n\t\tconst kind = INTRINSICS.reflect.apply(INTRINSICS.some, FAULT_KINDS, [\n\t\t\t(entry: string) => entry === value.expected,\n\t\t])\n\t\tconst named = INTRINSICS.own(value, 'key') || INTRINSICS.own(value, 'expected')\n\t\tconst list = readArrayEntries(isArray(value.expected) ? value.expected : [undefined])\n\t\tconst hinted =\n\t\t\t!named ||\n\t\t\t(isString(value.key) &&\n\t\t\t\t!isFailure(list) &&\n\t\t\t\tlist.value.dense &&\n\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, list.value.entries, [\n\t\t\t\t\t(entry: unknown) => !isLiteralValue(entry) || (isNumber(entry) && !isFiniteNumber(entry)),\n\t\t\t\t]))\n\t\tswitch (value.reason) {\n\t\t\tcase 'type':\n\t\t\t\treturn (\n\t\t\t\t\tkind &&\n\t\t\t\t\tisString(value.received) &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'expected', 'received'])\n\t\t\t\t)\n\t\t\tcase 'missing':\n\t\t\t\treturn kind && matchesExactKeys(value, ['reason', 'path', 'expected'])\n\t\t\tcase 'constraint':\n\t\t\t\treturn (\n\t\t\t\t\tkind &&\n\t\t\t\t\tisString(value.received) &&\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, FAULT_CONSTRAINTS, [\n\t\t\t\t\t\t(entry: string) => entry === value.constraint,\n\t\t\t\t\t]) &&\n\t\t\t\t\t(!INTRINSICS.own(value, 'limit') ||\n\t\t\t\t\t\tisFiniteNumber(value.limit) ||\n\t\t\t\t\t\tisString(value.limit)) &&\n\t\t\t\t\tmatchesExactKeys(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t['reason', 'path', 'expected', 'constraint', 'received'],\n\t\t\t\t\t\t['limit'],\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\tcase 'variant':\n\t\t\t\treturn (\n\t\t\t\t\tisNonNegativeInteger(value.variants) &&\n\t\t\t\t\thinted &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'variants'], named ? ['key', 'expected'] : [])\n\t\t\t\t)\n\t\t\tcase 'oneOf':\n\t\t\t\treturn (\n\t\t\t\t\tisNonNegativeInteger(value.matched) &&\n\t\t\t\t\thinted &&\n\t\t\t\t\tmatchesExactKeys(value, ['reason', 'path', 'matched'], named ? ['key', 'expected'] : [])\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn false\n\t\t}\n\t})\n}\n\n/**\n * Determines whether a value is exactly one {@link AuditFault}.\n *\n * @remarks\n * Every {@link Fault}, and the undeclared-key fault an audit adds.\n *\n * @param value - The value to inspect\n * @returns True if the value is a well-formed audit fault; false otherwise\n *\n * @example\n * ```ts\n * isAuditFault({ reason: 'extra', path: ['a'] }) // true\n * isAuditFault({}) // false\n * ```\n */\nexport function isAuditFault(value: unknown): value is AuditFault {\n\tif (isFault(value)) return true\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.reason === 'extra' &&\n\t\t\tisFaultPath(value.path) &&\n\t\t\tmatchesExactKeys(value, ['reason', 'path']),\n\t)\n}\n\n/** Determines whether a value is a `Map`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Map`; false otherwise\n *\n * @example\n * ```ts\n * isMap(new Map()) // true\n * isMap({}) // false\n * ```\n */\nexport function isMap<K = unknown, V = unknown>(value: unknown): value is ReadonlyMap<K, V> {\n\treturn isInstance(value, Map)\n}\n\n/** Determines whether a value is a `Set`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Set`; false otherwise\n *\n * @example\n * ```ts\n * isSet(new Set()) // true\n * isSet([]) // false\n * ```\n */\nexport function isSet<T = unknown>(value: unknown): value is ReadonlySet<T> {\n\treturn isInstance(value, Set)\n}\n\n/** Determines whether a value is a `WeakMap`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `WeakMap`; false otherwise\n *\n * @example\n * ```ts\n * isWeakMap(new WeakMap()) // true\n * isWeakMap({}) // false\n * ```\n */\nexport function isWeakMap(value: unknown): value is WeakMap<object, unknown> {\n\treturn isInstance(value, WeakMap)\n}\n\n/** Determines whether a value is a `WeakSet`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `WeakSet`; false otherwise\n *\n * @example\n * ```ts\n * isWeakSet(new WeakSet()) // true\n * isWeakSet({}) // false\n * ```\n */\nexport function isWeakSet(value: unknown): value is WeakSet<object> {\n\treturn isInstance(value, WeakSet)\n}\n\n// === Array & typed-array guards\n\n/** Determines whether a value is an array.\n *\n * @remarks\n * Checks the container alone — no element is inspected. Use {@link arrayOf} to check\n * every element against a guard.\n *\n * @param value - The value to inspect\n * @returns True if the value is an array; false otherwise\n *\n * @example\n * ```ts\n * isArray([1, 2]) // true\n * isArray('12') // false\n * ```\n */\nexport function isArray<T = unknown>(value: unknown): value is readonly T[] {\n\treturn holds(() => INTRINSICS.array(value))\n}\n\n/** Determines whether a value is a `DataView`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `DataView`; false otherwise\n *\n * @example\n * ```ts\n * isDataView(new DataView(new ArrayBuffer(8))) // true\n * isDataView(new ArrayBuffer(8)) // false\n * ```\n */\nexport function isDataView(value: unknown): value is DataView<ArrayBufferLike> {\n\treturn isInstance(value, DataView)\n}\n\n/** Determines whether a value is an `ArrayBufferView` (any typed array or `DataView`).\n *\n * @param value - The value to inspect\n * @returns True if the value is an `ArrayBufferView`; false otherwise\n *\n * @example\n * ```ts\n * isArrayBufferView(new Uint8Array(4)) // true\n * isArrayBufferView([1, 2, 3, 4]) // false\n * ```\n */\nexport function isArrayBufferView(value: unknown): value is ArrayBufferView {\n\treturn holds(() => ArrayBuffer.isView(value))\n}\n\n/** Determines whether a value is an `Int8Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int8Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt8Array(new Int8Array(2)) // true\n * isInt8Array(new Uint8Array(2)) // false\n * ```\n */\nexport function isInt8Array(value: unknown): value is Int8Array {\n\treturn isInstance(value, Int8Array)\n}\n\n/** Determines whether a value is a `Uint8Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint8Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint8Array(new Uint8Array(2)) // true\n * isUint8Array(new Int8Array(2)) // false\n * ```\n */\nexport function isUint8Array(value: unknown): value is Uint8Array {\n\treturn isInstance(value, Uint8Array)\n}\n\n/** Determines whether a value is a `Uint8ClampedArray`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint8ClampedArray`; false otherwise\n *\n * @example\n * ```ts\n * isUint8ClampedArray(new Uint8ClampedArray(2)) // true\n * isUint8ClampedArray(new Uint8Array(2)) // false\n * ```\n */\nexport function isUint8ClampedArray(value: unknown): value is Uint8ClampedArray {\n\treturn isInstance(value, Uint8ClampedArray)\n}\n\n/** Determines whether a value is an `Int16Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int16Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt16Array(new Int16Array(2)) // true\n * isInt16Array(new Int8Array(2)) // false\n * ```\n */\nexport function isInt16Array(value: unknown): value is Int16Array {\n\treturn isInstance(value, Int16Array)\n}\n\n/** Determines whether a value is a `Uint16Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint16Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint16Array(new Uint16Array(2)) // true\n * isUint16Array(new Int16Array(2)) // false\n * ```\n */\nexport function isUint16Array(value: unknown): value is Uint16Array {\n\treturn isInstance(value, Uint16Array)\n}\n\n/** Determines whether a value is an `Int32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an `Int32Array`; false otherwise\n *\n * @example\n * ```ts\n * isInt32Array(new Int32Array(2)) // true\n * isInt32Array(new Int16Array(2)) // false\n * ```\n */\nexport function isInt32Array(value: unknown): value is Int32Array {\n\treturn isInstance(value, Int32Array)\n}\n\n/** Determines whether a value is a `Uint32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Uint32Array`; false otherwise\n *\n * @example\n * ```ts\n * isUint32Array(new Uint32Array(2)) // true\n * isUint32Array(new Int32Array(2)) // false\n * ```\n */\nexport function isUint32Array(value: unknown): value is Uint32Array {\n\treturn isInstance(value, Uint32Array)\n}\n\n/** Determines whether a value is a `Float32Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Float32Array`; false otherwise\n *\n * @example\n * ```ts\n * isFloat32Array(new Float32Array(2)) // true\n * isFloat32Array(new Float64Array(2)) // false\n * ```\n */\nexport function isFloat32Array(value: unknown): value is Float32Array {\n\treturn isInstance(value, Float32Array)\n}\n\n/** Determines whether a value is a `Float64Array`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `Float64Array`; false otherwise\n *\n * @example\n * ```ts\n * isFloat64Array(new Float64Array(2)) // true\n * isFloat64Array(new Float32Array(2)) // false\n * ```\n */\nexport function isFloat64Array(value: unknown): value is Float64Array {\n\treturn isInstance(value, Float64Array)\n}\n\n/**\n * Determines whether a value is a `BigInt64Array`.\n *\n * @remarks\n * Guards the global existence of `BigInt64Array` first — safe in environments\n * that pre-date the BigInt typed-array additions.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `BigInt64Array`; false otherwise\n *\n * @example\n * ```ts\n * isBigInt64Array(new BigInt64Array(2)) // true\n * isBigInt64Array(new Float64Array(2)) // false\n * ```\n */\nexport function isBigInt64Array(value: unknown): value is BigInt64Array {\n\treturn typeof BigInt64Array !== 'undefined' && isInstance(value, BigInt64Array)\n}\n\n/**\n * Determines whether a value is a `BigUint64Array`.\n *\n * @remarks\n * Guards the global existence of `BigUint64Array` first — safe in environments\n * that pre-date the BigInt typed-array additions.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `BigUint64Array`; false otherwise\n *\n * @example\n * ```ts\n * isBigUint64Array(new BigUint64Array(2)) // true\n * isBigUint64Array(new BigInt64Array(2)) // false\n * ```\n */\nexport function isBigUint64Array(value: unknown): value is BigUint64Array {\n\treturn typeof BigUint64Array !== 'undefined' && isInstance(value, BigUint64Array)\n}\n\n// === Emptiness guards\n\n/** Determines whether a value is the empty string `''`.\n *\n * @param value - The value to inspect\n * @returns True if the value is the empty string `''`; false otherwise\n *\n * @example\n * ```ts\n * isEmptyString('') // true\n * isEmptyString('a') // false\n * ```\n */\nexport function isEmptyString(value: unknown): value is '' {\n\treturn isString(value) && value.length === 0\n}\n\n/** Determines whether a value is an empty array.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty array; false otherwise\n *\n * @example\n * ```ts\n * isEmptyArray([]) // true\n * isEmptyArray([1]) // false\n * ```\n */\nexport function isEmptyArray(value: unknown): value is readonly [] {\n\treturn holds(() => isArray(value) && value.length === 0)\n}\n\n/** Determines whether a value is an empty plain object — no OWN keys at all, of any\n * kind: string or symbol, enumerable or not.\n *\n * @remarks\n * The own-key population is the one `recordOf` inspects (`Reflect.ownKeys`), and\n * it has to be: this guard narrows to `Record<string | symbol, never>`, so\n * counting only ENUMERABLE keys made the narrowing unsound — a record carrying\n * an own non-enumerable `hidden: 1` answered `true` here while `recordOf({})`\n * saw the key and rejected the same value, and the enumerable-symbol and\n * non-enumerable-string cases were treated differently for no stated reason.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty plain object; false otherwise\n *\n * @example\n * ```ts\n * isEmptyObject({}) // true\n * isEmptyObject({ a: 1 }) // false\n * isEmptyObject(Object.defineProperty({}, 'hidden', { value: 1 })) // false\n * ```\n */\nexport function isEmptyObject(value: unknown): value is Record<string | symbol, never> {\n\treturn holds(() => isRecord(value) && INTRINSICS.reflect.members(value).length === 0)\n}\n\n/** Determines whether a value is an empty `Map`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty `Map`; false otherwise\n *\n * @example\n * ```ts\n * isEmptyMap(new Map()) // true\n * isEmptyMap(new Map([['a', 1]])) // false\n * ```\n */\nexport function isEmptyMap(value: unknown): value is ReadonlyMap<never, never> {\n\treturn holds(() => isMap(value) && value.size === 0)\n}\n\n/** Determines whether a value is an empty `Set`.\n *\n * @param value - The value to inspect\n * @returns True if the value is an empty `Set`; false otherwise\n *\n * @example\n * ```ts\n * isEmptySet(new Set()) // true\n * isEmptySet(new Set([1])) // false\n * ```\n */\nexport function isEmptySet(value: unknown): value is ReadonlySet<never> {\n\treturn holds(() => isSet(value) && value.size === 0)\n}\n\n/** Determines whether a value is a non-empty string (at least one character).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty string; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyString('a') // true\n * isNonEmptyString('') // false\n * ```\n */\nexport function isNonEmptyString(value: unknown): value is string {\n\treturn isString(value) && value.length > 0\n}\n\n/** Determines whether a value is a non-empty array (at least one element).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty array; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyArray([1]) // true\n * isNonEmptyArray([]) // false\n * ```\n */\nexport function isNonEmptyArray<T = unknown>(value: unknown): value is readonly [T, ...T[]] {\n\treturn holds(() => isArray<T>(value) && value.length > 0)\n}\n\n/** Determines whether a value is a non-empty plain object — at least one own key of\n * any kind: string or symbol, enumerable or not.\n *\n * @remarks\n * The exact negation of {@link isEmptyObject} over the same own-key population;\n * see there for why enumerability is not part of the rule.\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty plain object; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyObject({ a: 1 }) // true\n * isNonEmptyObject({}) // false\n * ```\n */\nexport function isNonEmptyObject(value: unknown): value is Record<string | symbol, unknown> {\n\treturn holds(() => isRecord(value) && INTRINSICS.reflect.members(value).length > 0)\n}\n\n/** Determines whether a value is a non-empty `Map` (at least one entry).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty `Map`; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptyMap(new Map([['a', 1]])) // true\n * isNonEmptyMap(new Map()) // false\n * ```\n */\nexport function isNonEmptyMap<K = unknown, V = unknown>(\n\tvalue: unknown,\n): value is ReadonlyMap<K, V> {\n\treturn holds(() => isMap<K, V>(value) && value.size > 0)\n}\n\n/** Determines whether a value is a non-empty `Set` (at least one element).\n *\n * @param value - The value to inspect\n * @returns True if the value is a non-empty `Set`; false otherwise\n *\n * @example\n * ```ts\n * isNonEmptySet(new Set([1])) // true\n * isNonEmptySet(new Set()) // false\n * ```\n */\nexport function isNonEmptySet<T = unknown>(value: unknown): value is ReadonlySet<T> {\n\treturn holds(() => isSet<T>(value) && value.size > 0)\n}\n\n// === Function guards\n\n/** Determines whether a value is a function that declares zero parameters (`Function.length === 0`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a function that declares zero parameters; false otherwise\n *\n * @example\n * ```ts\n * isZeroArg(() => {}) // true\n * isZeroArg((a) => a) // false\n * ```\n */\nexport function isZeroArg(value: unknown): value is ZeroArgFunction {\n\treturn holds(() => isFunction(value) && value.length === 0)\n}\n\n/**\n * Determines whether a value is a native `async function`.\n *\n * @remarks\n * Uses `constructor.name === 'AsyncFunction'` — not `instanceof`, which is\n * unreliable across realms. The `?.` keeps the guard total, as\n * `.claude/rules/patterns.md` § Validation and contracts requires: a function\n * whose `constructor` was nulled yields `undefined`, never a thrown `null.name`.\n *\n * @param value - The value to inspect\n * @returns True if the value is a native `async function`; false otherwise\n *\n * @example\n * ```ts\n * isAsyncFunction(async () => {}) // true\n * isAsyncFunction(() => {}) // false\n * ```\n */\nexport function isAsyncFunction(value: unknown): value is AnyAsyncFunction {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'AsyncFunction')\n}\n\n/** Determines whether a value is a generator function (`function*`).\n *\n * @param value - The value to inspect\n * @returns True if the value is a generator function; false otherwise\n *\n * @example\n * ```ts\n * isGeneratorFunction(function* () {}) // true\n * isGeneratorFunction(() => {}) // false\n * ```\n */\nexport function isGeneratorFunction(\n\tvalue: unknown,\n): value is (...args: unknown[]) => Generator<unknown, unknown, unknown> {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'GeneratorFunction')\n}\n\n/** Determines whether a value is an async generator function (`async function*`).\n *\n * @param value - The value to inspect\n * @returns True if the value is an async generator function; false otherwise\n *\n * @example\n * ```ts\n * isAsyncGeneratorFunction(async function* () {}) // true\n * isAsyncGeneratorFunction(function* () {}) // false\n * ```\n */\nexport function isAsyncGeneratorFunction(\n\tvalue: unknown,\n): value is (...args: unknown[]) => AsyncGenerator<unknown, unknown, unknown> {\n\treturn holds(() => isFunction(value) && value.constructor?.name === 'AsyncGeneratorFunction')\n}\n\n/** Determines whether a value is a zero-argument async function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument async function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgAsync(async () => {}) // true\n * isZeroArgAsync(async (a) => a) // false\n * ```\n */\nexport function isZeroArgAsync(value: unknown): value is ZeroArgAsyncFunction {\n\treturn isZeroArg(value) && isAsyncFunction(value)\n}\n\n/** Determines whether a value is a zero-argument generator function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument generator function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgGenerator(function* () {}) // true\n * isZeroArgGenerator(function* (a) {}) // false\n * ```\n */\nexport function isZeroArgGenerator(\n\tvalue: unknown,\n): value is () => Generator<unknown, unknown, unknown> {\n\treturn isZeroArg(value) && isGeneratorFunction(value)\n}\n\n/** Determines whether a value is a zero-argument async generator function.\n *\n * @param value - The value to inspect\n * @returns True if the value is a zero-argument async generator function; false otherwise\n *\n * @example\n * ```ts\n * isZeroArgAsyncGenerator(async function* () {}) // true\n * isZeroArgAsyncGenerator(async function* (a) {}) // false\n * ```\n */\nexport function isZeroArgAsyncGenerator(\n\tvalue: unknown,\n): value is () => AsyncGenerator<unknown, unknown, unknown> {\n\treturn isZeroArg(value) && isAsyncGeneratorFunction(value)\n}\n\n/**\n * Determines whether a value can be used as a `new`-target constructor.\n *\n * @remarks\n * Probes with `Reflect.construct(String, [], value)`: a real constructor\n * succeeds, while arrow functions, plain functions, and non-functions throw\n * and yield `false`. Never throws. Backs the `instanceOf` combinator.\n *\n * @param value - The value to inspect\n * @returns True if the value can be used as a `new`-target constructor; false otherwise\n *\n * @example\n * ```ts\n * isConstructor(class X {}) // true\n * isConstructor(() => {}) // false\n * ```\n */\nexport function isConstructor(value: unknown): value is AnyConstructor<object> {\n\treturn holds(() => {\n\t\tif (!isFunction(value)) {\n\t\t\treturn false\n\t\t}\n\t\tINTRINSICS.reflect.construct(String, [], value)\n\t\treturn true\n\t})\n}\n\n// === JSON\n\n/**\n * Determines whether a value is a cycle-safe JSON value.\n *\n * @remarks\n * Total guard: never throws, returns `false` for cycles, functions, `Date`\n * instances, class instances, `NaN`, and `±Infinity`. Arrays and plain records\n * are walked with an ancestor set so recursive input fails instead of hanging.\n * The whole walk runs inside `holds`, as `.claude/rules/patterns.md`\n * § Validation and contracts requires: a hostile getter on a\n * record property, or a revoked `Proxy` anywhere in the structure, is caught\n * and yields `false` instead of escaping as a thrown error.\n *\n * @param value - The value to test\n * @returns True if the value has a JSON representation; false otherwise\n *\n * @example\n * ```ts\n * isJSONValue({ nested: [1, 'x', null] }) // true\n * isJSONValue(Number.NaN) // false\n * ```\n */\nexport function isJSONValue(value: unknown): value is JSONValue {\n\treturn holds(() => matchesJSONValue(value, new INTRINSICS.weakSet()))\n}\n\n/**\n * Determines whether a value is JSON-valid within the fixed container-depth limit.\n *\n * @remarks\n * Runs the total depth predicate before the existing JSON guard. These are\n * sequential observations of caller-owned input, not an atomic snapshot.\n *\n * @param value - The value to inspect\n * @returns True if the value is both depth-bounded and a valid {@link JSONValue}; false otherwise\n *\n * @example\n * ```ts\n * isBoundedJSONValue({ nested: [1] }) // true\n * isBoundedJSONValue(new Date()) // false\n * ```\n */\nexport function isBoundedJSONValue(value: unknown): value is JSONValue {\n\treturn matchesJSONDepth(value) && isJSONValue(value)\n}\n\n/**\n * Determines whether a value is a depth-bounded JSON record.\n *\n * @remarks\n * Requires the existing plain-record root invariant before applying\n * {@link isBoundedJSONValue}. Arrays therefore remain valid bounded JSON\n * values but never bounded JSON records.\n *\n * @param value - The value to inspect\n * @returns True if the value is a plain-record-rooted bounded JSON value; false otherwise\n *\n * @example\n * ```ts\n * isBoundedJSONRecord({ value: 1 }) // true\n * isBoundedJSONRecord([1]) // false\n * ```\n */\nexport function isBoundedJSONRecord(value: unknown): value is JSONRecord {\n\treturn isRecord(value) && isBoundedJSONValue(value)\n}\n\n/**\n * Determines whether a value is a primitive JSON value.\n *\n * @remarks\n * The flat leaf of any JSON document: `null`, a string, a **finite** number, or\n * a boolean. Uses {@link isFiniteNumber} (not {@link isNumber}) because real JSON\n * carries no `NaN` / `±Infinity` — `JSON.stringify(NaN)` is `'null'`.\n *\n * The recursive {@link isJSONValue} guard is shipped and stays total with\n * cycle-safe walking. Dedicated `isJSONObject` / `isJSONSchema` validators and\n * the broad `JSONSchemaDefinition` remain omitted; compose narrower shapes with\n * the combinators and gate untrusted strings with `parseJSON` / `parseJSONAs`.\n *\n * @param value - The value to test\n * @returns True if `value` is `null`, a string, a finite number, or a boolean; false otherwise\n *\n * @example\n * ```ts\n * isJSONPrimitive(null) // true\n * isJSONPrimitive('hi') // true\n * isJSONPrimitive(42) // true\n * isJSONPrimitive(Number.NaN) // false — not representable in JSON\n * isJSONPrimitive({}) // false\n * ```\n */\nexport function isJSONPrimitive(value: unknown): value is JSONPrimitive {\n\treturn isNull(value) || isString(value) || isFiniteNumber(value) || isBoolean(value)\n}\n","import type {\n\tArrayRead,\n\tArrayShape,\n\tAuditFault,\n\tBoundsRead,\n\tContainOptions,\n\tContractCode,\n\tContractAdmission,\n\tContractRefusal,\n\tContractInterface,\n\tFaultTextOptions,\n\tContractShape,\n\tEntryCollectorFunction,\n\tFailure,\n\tFault,\n\tFaultKind,\n\tFieldPath,\n\tGuard,\n\tGuardShapeRead,\n\tGuardsShape,\n\tJSONSchema,\n\tJSONValue,\n\tLengthReader,\n\tNumberShape,\n\tRandomFunction,\n\tReadValueOptions,\n\tResult,\n\tSampleMemo,\n\tSchemaFormat,\n\tStringShape,\n\tSuccess,\n} from './types.js'\nimport {\n\tCLONE_NODE_LIMIT,\n\tCOMPILE_NODE_LIMIT,\n\tCONTRACT_CODES,\n\tFORMAT_PATTERNS,\n\tFAULT_LIMIT,\n\tFAULT_TEXT_LIMIT,\n\tFAULT_LIST_LIMIT,\n\tFAULT_SCHEMA_LIMIT,\n\tGUARD_DEPTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tJSON_SCHEMA_TYPES,\n\tPREVIEW_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tisBigInt,\n\tisArray,\n\tisError,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisMap,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n\tisSymbol,\n\tisWeakMap,\n} from './validators.js'\n\n/**\n * Admits a stable readable value with only lossless repairs and returns the parser's value.\n *\n * @remarks\n * Reads must remain stable across artifacts. Guard-valid input skips both reports and parses\n * once. Repairs use audit, parse once, and explain only on parse failure. Unresolved unions,\n * extras, lossy repairs, and a capped audit refuse. An own optional undefined field omitted or\n * filled by its declared default is not a repair. The result preserves parser ownership, including union input identity.\n * A read failure returns its cause rather than throwing.\n * Snapshot a foreign object before admission, as Tool.execute does. A getter changing between\n * is and parse can publish a value that no recorded repair describes. A shallow snapshot only\n * stabilizes its own level; nested foreign values must also provide stable reads.\n *\n * @example\n * ```ts\n * admitValue(createContract(numberShape()), '3') // success carrying 3 and its type repair\n * ```\n */\nexport function admitValue<T>(\n\tcontract: ContractInterface<T>,\n\tvalue: unknown,\n): Result<ContractAdmission<T>, ContractRefusal> {\n\ttry {\n\t\tif (contract.is(value)) {\n\t\t\tconst parsed = contract.parse(value)\n\t\t\tif (parsed === undefined && value !== undefined) return failure({ faults: [] })\n\t\t\treturn success({ value: parsed === undefined ? value : parsed, repairs: [] })\n\t\t}\n\t\tconst audited = contract.audit(value)\n\t\tconst parsed = contract.parse(value)\n\t\tconst explained = parsed === undefined ? contract.explain(value) : []\n\t\tconst repairs = audited.filter((fault) => matchesLosslessRepair(fault, value, parsed))\n\t\tconst refused = audited.filter(\n\t\t\t(fault) => !repairs.includes(fault) && !matchesUndefinedField(fault, value, parsed),\n\t\t)\n\t\tconst merged = [...explained, ...refused]\n\t\tconst faults = [\n\t\t\t...new Map(\n\t\t\t\tmerged.map((fault) => [JSON.stringify([fault.reason, extractPath(fault)]), fault]),\n\t\t\t).values(),\n\t\t]\n\t\tconst covers = faults\n\t\t\t.filter((fault) => fault.reason === 'variant' || fault.reason === 'oneOf')\n\t\t\t.map((fault) => extractPath(fault))\n\t\tconst uncovered = faults.filter((fault) => {\n\t\t\tconst path = extractPath(fault)\n\t\t\tconst room = fault.reason === 'variant' || fault.reason === 'oneOf' ? 1 : 0\n\t\t\treturn !covers.some(\n\t\t\t\t(cover) =>\n\t\t\t\t\tcover.length + room <= path.length &&\n\t\t\t\t\tcover.every((segment, index) => segment === path[index]),\n\t\t\t)\n\t\t})\n\t\tif (uncovered.length > 0) return failure({ faults: limitEntries(uncovered, FAULT_LIMIT) })\n\t\tif (audited.length >= FAULT_LIMIT)\n\t\t\treturn failure({ faults: limitEntries(audited, FAULT_LIMIT) })\n\t\tif (parsed === undefined) return failure({ faults: limitEntries(audited, FAULT_LIMIT) })\n\t\treturn success({ value: parsed, repairs })\n\t} catch (cause) {\n\t\treturn failure({ faults: [], cause })\n\t}\n}\n\n/**\n * Checks whether a type fault describes an own undefined field omitted or defaulted by a successful parse.\n *\n * @remarks\n * Reads own members directly so absence and an unreadable member cannot stand for undefined.\n * A compiled parser fills an undefined field only through its declared default; it never coerces it.\n * Required reads propagate their cause to the admission boundary.\n *\n * @example\n * ```ts\n * matchesUndefinedField({ reason: 'type', path: ['note'], expected: 'string', received: 'undefined' }, { note: undefined }, {}) // true\n * ```\n */\nexport function matchesUndefinedField(fault: AuditFault, value: unknown, parsed: unknown): boolean {\n\tif (fault.reason !== 'type' || parsed === undefined) return false\n\tconst path = extractPath(fault)\n\tconst key = path.at(-1)\n\tif (key === undefined) return false\n\tconst parents = path\n\t\t.slice(0, -1)\n\t\t.reduce<readonly [unknown, unknown]>(\n\t\t\t([raw, result], segment) => [\n\t\t\t\tisObject(raw) && INTRINSICS.own(raw, segment)\n\t\t\t\t\t? INTRINSICS.reflect.read(raw, segment)\n\t\t\t\t\t: undefined,\n\t\t\t\tisObject(result) && INTRINSICS.own(result, segment)\n\t\t\t\t\t? INTRINSICS.reflect.read(result, segment)\n\t\t\t\t\t: undefined,\n\t\t\t],\n\t\t\t[value, parsed],\n\t\t)\n\tconst [raw, result] = parents\n\treturn (\n\t\tisObject(raw) &&\n\t\tINTRINSICS.own(raw, key) &&\n\t\tINTRINSICS.reflect.read(raw, key) === undefined &&\n\t\tisObject(result)\n\t)\n}\n\n/**\n * Truncates text to a UTF-16 budget without splitting a surrogate pair.\n *\n * @example\n * ```ts\n * truncateFaultText('abcdef', 4) // 'abc…'\n * ```\n */\nexport function truncateFaultText(text: string, limit: number): string {\n\tif (limit <= 0) return ''\n\tif (text.length <= limit) return text\n\treturn `${text.slice(0, limit - 1).replace(/[\\uD800-\\uDBFF]$/u, '')}…`\n}\n\n/**\n * Describes bounded faults with encoded values and a schema-derived correction summary.\n *\n * @remarks\n * Default: 2048 UTF-16 code units. A smaller non-negative integer limit reserves a caller's\n * heading budget. The report reserves room for omitted-fault and cap notices, and ends with a\n * send summary when a schema is supplied. Untrusted names, descriptions, and strings use preview.\n *\n * @example\n * ```ts\n * describeFaults([{ reason: 'missing', path: ['age'], expected: 'number' }])\n * // 'age: missing; expected number'\n * ```\n */\nexport function describeFaults(\n\tfaults: readonly AuditFault[],\n\tschema?: JSONSchema,\n\toptions?: FaultTextOptions,\n): string {\n\tconst requested = options?.limit ?? FAULT_TEXT_LIMIT\n\tif (!isInteger(requested) || requested < 0) {\n\t\tthrow new ContractError('Fault text limit must be a non-negative integer', { code: 'range' })\n\t}\n\tconst limit = Math.min(requested, FAULT_TEXT_LIMIT)\n\tconst send =\n\t\tschema === undefined\n\t\t\t? ''\n\t\t\t: `send ${renderForm(schema, Math.min(FAULT_SCHEMA_LIMIT, Math.floor(limit / 3)))}`\n\tconst lines = limitEntries(faults, FAULT_LIMIT).map((fault) =>\n\t\tdescribeFaultLine(fault, schema ?? {}),\n\t)\n\tconst room = Math.max(0, limit - send.length - 82)\n\tconst kept = lines.filter((_, index) => lines.slice(0, index + 1).join('\\n').length <= room)\n\tconst hidden = faults.length - kept.length\n\tconst note = [\n\t\t...(hidden > 0 ? [`and ${String(hidden)} more faults`] : []),\n\t\t...(faults.length >= FAULT_LIMIT ? [`the report stops at ${String(FAULT_LIMIT)}`] : []),\n\t].join(', ')\n\tconst text = [\n\t\t...kept,\n\t\t...(kept.length === 0 && lines.length > 0 && room > 0\n\t\t\t? [truncateFaultText(lines[0] ?? '', room)]\n\t\t\t: []),\n\t\t...(note.length === 0 ? [] : [note]),\n\t\t...(send.length === 0 ? [] : [send]),\n\t].join('\\n')\n\treturn truncateFaultText(text, limit)\n}\n\n/**\n * Iterates indices while rereading the upper bound before every step.\n *\n * @remarks\n * Uses a captured native cursor and never reads an element or a caller's\n * iterator. Fractional bounds include the last index below the bound.\n *\n * @param read - Reads the current upper bound\n * @returns The indices below each observed bound\n *\n * @example\n * ```ts\n * Array.from(iterateIndices(() => 3)) // [0, 1, 2]\n * ```\n */\nexport function* iterateIndices(read: LengthReader): Generator<number, void, unknown> {\n\tconst cursor = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.indices,\n\t\t{\n\t\t\tget length() {\n\t\t\t\tconst length = read()\n\t\t\t\treturn length > 0 ? INTRINSICS.ceil(length) : 0\n\t\t\t},\n\t\t},\n\t\t[],\n\t)\n\twhile (true) {\n\t\tconst step: IteratorResult<number> = INTRINSICS.reflect.apply(INTRINSICS.advance, cursor, [])\n\t\tif (step.done) return\n\t\tyield step.value\n\t}\n}\n\n/**\n * Exposes indexed reads through a non-array receiver without species dispatch.\n *\n * @remarks\n * Captured array methods read length, membership, and elements lazily through\n * the source receiver. The view is not an array, so native map, filter, and\n * flatMap never consult its constructor or species. Their callback's collection\n * argument is this view. No source element is observed while constructing it.\n *\n * @param values - The array whose live indexed reads and membership are forwarded\n * @returns A non-array receiver for captured array methods\n *\n * @example\n * ```ts\n * INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView([1, 2]), [\n * \t(value: number) => value * 2,\n * ]) // [2, 4]\n * ```\n */\nexport function readIndexView(values: readonly unknown[]): object {\n\treturn new INTRINSICS.proxy(\n\t\t{ __proto__: null },\n\t\t{\n\t\t\tget(_target, key) {\n\t\t\t\treturn INTRINSICS.reflect.read(values, key)\n\t\t\t},\n\t\t\thas(_target, key) {\n\t\t\t\treturn INTRINSICS.reflect.present(values, key)\n\t\t\t},\n\t\t},\n\t)\n}\n\n/**\n * Builds a diagnostic path from an existing path and further segments, without\n * dispatching through array iteration.\n *\n * @remarks\n * `[...path, key]` reads well and dispatches through\n * `Array.prototype[Symbol.iterator]`, a member every caller can write — and the\n * damaging installation is not a thrower but a LIAR. An iterator yielding one\n * extra value before the array's real contents turns a refusal this package\n * authored into `path: ['INJECTED', 'properties', 'INJECTED']`, so the caller\n * writes their own text into a diagnostic this package published. An indexed\n * walk reads only own index properties of an array this package owns, and a\n * rest parameter collects its arguments without an iterator either, so nothing\n * on the path is caller-reachable.\n *\n * @param path - The path segments accumulated so far\n * @param segments - Further segments to append in order; an absent segment is\n * omitted, so an optional level needs no branch at the call site\n * @returns A fresh path carrying every existing segment and each new one\n *\n * @example\n * ```ts\n * pathOf(['properties'], 'age') // ['properties', 'age']\n * pathOf(path) // an owned copy\n * ```\n */\nexport function pathOf(\n\tpath: readonly string[],\n\t...segments: ReadonlyArray<string | undefined>\n): readonly string[] {\n\tconst existing = INTRINSICS.from(\n\t\titerateIndices(() => path.length),\n\t\t(index) => path[index],\n\t)\n\tconst added = INTRINSICS.from(\n\t\titerateIndices(() => segments.length),\n\t\t(index) => segments[index],\n\t)\n\tconst combined = INTRINSICS.from(\n\t\titerateIndices(() => existing.length + added.length),\n\t\t(index) => (index < existing.length ? existing[index] : added[index - existing.length]),\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(combined), [\n\t\t(segment: string | undefined) => segment !== undefined,\n\t])\n}\n\n/**\n * Appends every element of one array onto another, by index.\n *\n * @remarks\n * The sibling of {@link pathOf}, for the other shape the same defect takes.\n * `target[target.length] = ...source` and `[summary, ...rest]` both dispatch through\n * `Array.prototype[Symbol.iterator]`, and a caller-installed iterator that\n * yields one extra value writes the caller's text into a diagnostic this\n * package publishes as its own. Both operands here are arrays this package\n * built, and an indexed read of an own index property dispatches through\n * nothing.\n *\n * @param target - The array to extend in place\n * @param source - The elements to append, read by index\n *\n * @example\n * ```ts\n * appendEntries(faults, compileReporter(inner, raw, pathOf(path, key)))\n * ```\n */\nexport function appendEntries<T>(target: T[], source: readonly T[]): void {\n\tfor (const index of iterateIndices(() => source.length)) {\n\t\tconst entry = source[index]\n\t\t// A hole is skipped rather than materialized as a present `undefined`: the\n\t\t// arrays this appends are dense reports this package built, so the branch\n\t\t// exists to keep the honest typing rather than to hide a case.\n\t\tif (entry === undefined) continue\n\t\ttarget[target.length] = entry\n\t}\n}\n\n/**\n * Takes at most `limit` leading elements of an array, by index.\n *\n * @remarks\n * `Array.prototype.slice` is a caller-writable member on every path that bounds\n * a published report, so a substitute decides how much of a diagnostic the\n * caller sees. Returns the input untouched when it already fits, so a bounded\n * report allocates nothing in the ordinary case.\n *\n * @param entries - The entries to bound\n * @param limit - The maximum number of leading entries to retain\n * @returns The input when it already fits, otherwise a fresh bounded copy\n *\n * @example\n * ```ts\n * limitEntries(faults, FAULT_LIMIT)\n * ```\n */\nexport function limitEntries<T>(entries: readonly T[], limit: number): readonly T[] {\n\tif (entries.length <= limit) return entries\n\tconst selected = INTRINSICS.from(\n\t\titerateIndices(() => limit),\n\t\t(index) => entries[index],\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(selected), [\n\t\t(entry: T | undefined) => entry !== undefined,\n\t])\n}\n\n/**\n * Orders two primitive keys or indices ascending.\n *\n * @remarks\n * The comparison {@link sortValues} hands to the captured sort, extracted rather\n * than written inline. `Reflect.apply` takes its arguments as a LIST, so an\n * inline comparator is a function expression inside an array literal rather than\n * one passed directly as an argument — a hidden function assignment, which this\n * repository forbids wherever it appears because a function that is not a named\n * declaration is a function no caller can reach and no test can exercise. As a\n * declaration it is both. The comparison is `<` / `>` on primitives, which\n * dispatches through nothing: no `valueOf`, no `toString`, and no member a\n * caller can replace, so the order a published schema is emitted in is decided\n * by the values and not by the environment.\n *\n * @param left - The value ordered first when it compares lower\n * @param right - The value compared against\n * @returns `-1`, `1`, or `0` as `left` sorts before, after, or with `right`\n *\n * @example\n * ```ts\n * comparePrimitives('a', 'b') // -1\n * ```\n */\nexport function comparePrimitives<T extends string | number>(left: T, right: T): number {\n\treturn left < right ? -1 : left > right ? 1 : 0\n}\n\n/**\n * Orders primitive keys or indices deterministically, on an owned copy, through\n * the captured sort.\n *\n * @remarks\n * Every schema this package emits is ordered so the same input produces the\n * same bytes, and `Array.prototype.sort` is a caller-writable member on every\n * one of those paths: a substitute that empties its receiver made\n * `valueToSchema({ b: 1, a: 2 })` publish `{\"type\":\"object\",\"additionalProperties\":false}`\n * — a successful answer with the caller's properties silently gone. The copy is\n * taken first so a caller-owned array is never reordered in place, and the order\n * is decided by {@link comparePrimitives}, whose `<` / `>` comparison dispatches\n * through nothing.\n *\n * @param values - The keys or indices to order\n * @returns A fresh array in ascending order\n *\n * @example\n * ```ts\n * sortValues(['b', 'a']) // ['a', 'b']\n * ```\n */\nexport function sortValues<T extends string | number>(values: readonly T[]): readonly T[] {\n\tconst observed = INTRINSICS.from(\n\t\titerateIndices(() => values.length),\n\t\t(index) => values[index],\n\t)\n\tconst owned: T[] = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t(value: T | undefined) => value !== undefined,\n\t])\n\tINTRINSICS.reflect.apply(INTRINSICS.order, owned, [comparePrimitives])\n\treturn owned\n}\n\n// === Captured membership, visitation, and pattern reads\n\n/**\n * Collects an array's entries into a membership collection this package owns.\n *\n * @remarks\n * THE builder behind every declared vocabulary, and the first half of the answer\n * to a defect that survived three rounds by moving rather than closing. A guard\n * deciding membership with `set.has(value)` answers whatever the caller most\n * recently installed on `Set.prototype`, and answering it instead through the\n * `has` method of an exported class only moved the writable member one prototype\n * up: `Vocabulary.prototype.has = () => true` reproduced the whole defect at\n * nineteen door groups. There is no property lookup here to redirect —\n * membership is asked of a MODULE BINDING, which the specification makes\n * immutable to every importer, over operations {@link INTRINSICS} captured while\n * it evaluated.\n *\n * Collection is by INDEX rather than from an iterable on purpose:\n * `new Set(values)` reads `Symbol.iterator` off the argument and `add` off the\n * instance, so building from an iterable would reintroduce two replaceable\n * dispatches to remove one.\n * A captured native union consumes the owned indexed snapshot through a cursor\n * whose `next` is bound to the captured array advance operation.\n *\n * @param values - The members to collect, read by index\n * @returns A collection no caller holds a reference to\n *\n * @example\n * ```ts\n * const allowed = collectMembers(['admin', 'guest'])\n * matchesMember(allowed, 'admin') // true\n * ```\n */\nexport function collectMembers(values: readonly unknown[]): Set<unknown> {\n\tconst indices = iterateIndices(() => values.length)\n\tconst entries = INTRINSICS.from(indices, (index) => values[index])\n\treturn INTRINSICS.reflect.apply(INTRINSICS.union, new INTRINSICS.set<unknown>(), [\n\t\t{\n\t\t\tsize: entries.length,\n\t\t\thas(value: unknown): boolean {\n\t\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, entries, [\n\t\t\t\t\t(entry: unknown) => entry === value || INTRINSICS.same(entry, value),\n\t\t\t\t])\n\t\t\t},\n\t\t\tkeys(): Iterator<unknown> {\n\t\t\t\tconst cursor = INTRINSICS.reflect.apply(INTRINSICS.iterator, entries, [])\n\t\t\t\treturn {\n\t\t\t\t\tnext: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.advance, [cursor]),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t])\n}\n\n/**\n * Determines whether a value is a member of a collected vocabulary, by\n * SameValueZero.\n *\n * @remarks\n * Dispatched through the captured `Set.prototype.has` onto a collection no caller\n * holds, and asked as a module binding rather than as a property: `set.has(value)` asks\n * a member every caller can rewrite, and moving that read onto an exported class's\n * `has` method reproduced the identical defect one prototype higher, because every\n * public class method is dispatched through a reachable prototype.\n *\n * @param members - The vocabulary to ask, built by {@link collectMembers}\n * @param value - The value to test for membership\n * @returns True if the value was collected; false otherwise\n *\n * @example\n * ```ts\n * matchesMember(collectMembers([Number.NaN]), Number.NaN) // true — SameValueZero\n * ```\n */\nexport function matchesMember(members: ReadonlySet<unknown>, value: unknown): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.member, members, [value]) === true\n}\n\n/**\n * Collects one more member into a vocabulary that grows as a walk proceeds.\n *\n * @remarks\n * Collects through the captured adder, for a vocabulary that grows as a walk proceeds —\n * a uniqueness gate, a de-duplicating key population.\n *\n * @param members - The vocabulary to extend\n * @param value - The value to admit\n *\n * @example\n * ```ts\n * const seen = collectMembers([])\n * admitMember(seen, 'a')\n * matchesMember(seen, 'a') // true\n * ```\n */\nexport function admitMember(members: Set<unknown>, value: unknown): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.admit, members, [value])\n}\n\n/**\n * Determines whether an object is already on a traversal's active path.\n *\n * @remarks\n * The visitation half, and the one an earlier ruling wrongly excused as safe\n * because \"a redirect corrupts it inside a boundary and the door refuses, which\n * is loud\". It is not loud in the direction that matters:\n * `WeakSet.prototype.has` answering `false` does not make a cyclic clone refuse,\n * it removes the door's termination bound, and a door that never returns is the\n * one failure a containment boundary cannot report. Every walk's termination\n * therefore rests on a captured operation rather than on a caller-writable one.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object to test\n * @returns True if the object is already on the active path; false otherwise\n *\n * @example\n * ```ts\n * const active = new WeakSet<object>()\n * admitVisited(active, node)\n * matchesVisited(active, node) // true\n * ```\n */\nexport function matchesVisited(visited: WeakSet<object>, value: object): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.tracked, visited, [value]) === true\n}\n\n/**\n * Records an object as entered on a traversal's active path.\n *\n * @remarks\n * Records through the captured `WeakSet.prototype.add`, on the same terms {@link\n * matchesVisited} states for the membership answer.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object being entered\n *\n * @example\n * ```ts\n * admitVisited(active, node)\n * ```\n */\nexport function admitVisited(visited: WeakSet<object>, value: object): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.track, visited, [value])\n}\n\n/**\n * Records an object as exited from a traversal's active path.\n *\n * @remarks\n * Records through the captured `WeakSet.prototype.delete`, on the same terms {@link\n * matchesVisited} states for the membership answer.\n *\n * @param visited - The active-path set this traversal owns\n * @param value - The object being exited\n *\n * @example\n * ```ts\n * omitVisited(active, node)\n * ```\n */\nexport function omitVisited(visited: WeakSet<object>, value: object): void {\n\tINTRINSICS.reflect.apply(INTRINSICS.untrack, visited, [value])\n}\n\n/**\n * Records one node's answer at one remaining-depth allowance in a shared memo.\n *\n * @remarks\n * A depth-bounded walk answers the same node differently depending on how much\n * allowance was left when it arrived, so each node keeps a `Map` of answers\n * inside one `WeakMap`. Written inline, the get-or-create ferried that map out\n * of the branch that built it through a `let`, three times over across the two\n * container branches of value inference and the schema-inversion walk. Written\n * once it is one statement per caller, and the captured `WeakMap`/`Map` members\n * stay the only ones all three dispatch through — a substituted `WeakMap.prototype.get` that\n * answered a decoy map would otherwise decide what a later call replays.\n *\n * @param memo - The per-node depth memo this walk owns\n * @param node - The source node the answer was computed for\n * @param depth - The remaining-depth allowance the answer was computed under\n * @param answer - The answer to record for that node at that allowance\n *\n * @example\n * ```ts\n * const memo = new WeakMap<object, Map<number, string>>()\n * retainDepth(memo, node, 8, 'answer')\n * memo.get(node)?.get(8) // 'answer'\n * ```\n */\nexport function retainDepth<T>(\n\tmemo: WeakMap<object, Map<number, T>>,\n\tnode: object,\n\tdepth: number,\n\tanswer: T,\n): void {\n\tconst known = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [node])\n\tconst depths = known || new INTRINSICS.map<number, T>()\n\tif (!known) INTRINSICS.reflect.apply(INTRINSICS.retain, memo, [node, depths])\n\tINTRINSICS.reflect.apply(INTRINSICS.store, depths, [depth, answer])\n}\n\n/**\n * Builds one empty {@link SampleMemo} node.\n *\n * @remarks\n * The root a multi-sample walk starts from and the node every further row\n * prefix is grown into, built from the CAPTURED `WeakMap` and `Map` so a\n * replaced global cannot decide what a published schema is served from. One\n * memo belongs to one walk: {@link samplesToSchema} builds one at the door and\n * grows a fresh node per row prefix inside it.\n *\n * @returns An empty memo node with no recorded rows and no recorded schemas\n *\n * @example\n * ```ts\n * buildSampleMemo() // { rows: WeakMap {}, schemas: Map {} }\n * ```\n */\nexport function buildSampleMemo(): SampleMemo {\n\treturn { rows: new INTRINSICS.weakMap<object, SampleMemo>(), schemas: new INTRINSICS.map() }\n}\n\n/**\n * Checks that a value really is a {@link SampleMemo} before a walk stores a\n * published schema in it.\n *\n * @remarks\n * The memo reaches a `WeakMap` and a `Map` the walk stored a node in, and a\n * wrong value there fails inside the traversal and is published as\n * `samples could not be read` — a true refusal naming the wrong argument. This\n * refuses under the memo's own name and its own path instead. The multi-sample\n * walk asks it of every node it reads back out of its own prefix chain.\n *\n * @param memo - The candidate memo\n * @param reader - The door name the refusal is published under\n * @returns The same memo when it carries a real `rows` `WeakMap` and `schemas` `Map`\n * @throws {ContractError} When the memo is not a `SampleMemo`\n *\n * @example\n * ```ts\n * readSampleMemo(buildSampleMemo(), 'samplesToSchema') // the same memo\n * ```\n */\nexport function readSampleMemo(memo: SampleMemo, reader: string): SampleMemo {\n\tif (!isObject(memo) || !isWeakMap(memo.rows) || !isMap(memo.schemas)) {\n\t\tthrow new ContractError(`${reader}: memo must be a sample memo`, {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: ['memo'], limit: 'SampleMemo', received: preview(memo) },\n\t\t})\n\t}\n\treturn memo\n}\n\n/**\n * Builds the collector a captured `forEach` sweep appends through.\n *\n * @remarks\n * Extracted rather than written inline for the same reason\n * {@link comparePrimitives} is: `Reflect.apply` takes its arguments as a LIST, so an\n * inline collector is a function expression inside an array literal rather than\n * one passed directly as an argument — a hidden function assignment this\n * repository forbids wherever it appears. Returned directly from a factory it is\n * both named and testable. Both sweeps hand the callback `(value, key)`; a `Set`\n * passes its entry in both positions, so one collector serves both.\n *\n * @param target - The pair list to append each swept entry onto\n * @returns The collector a captured `forEach` invokes per entry\n *\n * @example\n * ```ts\n * const collected: unknown[][] = []\n * new Set(['a']).forEach(collectEntries(collected)) // [['a', 'a']]\n * ```\n */\nexport function collectEntries(target: unknown[][]): EntryCollectorFunction {\n\treturn (value: unknown, key: unknown) => {\n\t\ttarget[target.length] = [key, value]\n\t}\n}\n\n/**\n * Snapshots the genuine contents of a caller's `Set` without running an iterator.\n *\n * @remarks\n * `Set.prototype[Symbol.iterator]` is a caller-writable member, and every other\n * view of the same collection disagrees with a replaced one: an iterator that\n * silently skips the non-string in `new Set(['a', 42])` made `setOf(isString)`\n * answer `true` while `forEach` and `size` still reported the real contents. The\n * sibling `arrayOf` already read its caller's collection through captured\n * reflection, so the exclusion was not even self-consistent within one file.\n * `forEach` is the only complete view of `[[SetData]]` that runs no iterator, so\n * it is dispatched here from the captured table.\n *\n * @param value - The set whose genuine entries to snapshot\n * @returns A frozen entry snapshot, or a failure carrying the exact thrown value\n *\n * @example\n * ```ts\n * readSetEntries(new Set(['a', 42])) // { success: true, value: ['a', 42] }\n * ```\n */\nexport function readSetEntries(value: ReadonlySet<unknown>): Result<readonly unknown[]> {\n\treturn attempt(() => {\n\t\tconst collected: unknown[][] = []\n\t\tINTRINSICS.reflect.apply(INTRINSICS.sweep, value, [collectEntries(collected)])\n\t\tconst entries: readonly unknown[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(collected),\n\t\t\t[(pair: readonly unknown[]) => pair[1]],\n\t\t)\n\t\treturn INTRINSICS.freeze(entries)\n\t})\n}\n\n/**\n * Snapshots the genuine entries of a caller's `Map` without running an iterator.\n *\n * @remarks\n * The `Map` half of {@link readSetEntries}, with one further replaceable\n * dispatch removed: destructuring `for (const [key, value] of map)` reads\n * `Map.prototype[Symbol.iterator]` AND `Array.prototype[Symbol.iterator]` for\n * every pair, so a substituting iterator could rename a key or replace a value\n * while every downstream structural check still passed. Each pair is read\n * positionally from a list this package built.\n *\n * @param value - The map whose genuine entries to snapshot\n * @returns A frozen `[key, value]` pair snapshot, or a failure carrying the exact thrown value\n *\n * @example\n * ```ts\n * readMapEntries(new Map([['a', 1]])) // { success: true, value: [['a', 1]] }\n * ```\n */\nexport function readMapEntries(\n\tvalue: ReadonlyMap<unknown, unknown>,\n): Result<ReadonlyArray<readonly unknown[]>> {\n\treturn attempt(() => {\n\t\tconst collected: unknown[][] = []\n\t\tINTRINSICS.reflect.apply(INTRINSICS.pairs, value, [collectEntries(collected)])\n\t\treturn INTRINSICS.freeze(collected)\n\t})\n}\n\n/**\n * Reads a regular expression's source text through the captured accessor.\n *\n * @remarks\n * `RegExp.prototype.source` is an ACCESSOR on a shared prototype, so replacing\n * its getter changes what every pattern in the realm reports — not only the\n * caller's own. A getter answering `'.*'` made `compileSchema` publish\n * `pattern: \".*\"` inside a frozen schema and made `isRegExp('x')` answer `true`.\n * Reading the descriptor per call, as an earlier round did, captures nothing:\n * capture is decided by WHEN the reference is taken.\n *\n * @param pattern - The candidate regular expression to read\n * @returns The pattern's source text, or `undefined` when it cannot be read as a string\n * @throws The exact value the captured accessor throws for a receiver that is not a pattern\n *\n * @example\n * ```ts\n * readPatternSource(/^a+$/) // '^a+$'\n * ```\n */\nexport function readPatternSource(pattern: unknown): string | undefined {\n\tconst read = INTRINSICS.expression\n\tif (read === undefined) return undefined\n\tconst source: unknown = INTRINSICS.reflect.apply(read, pattern, [])\n\treturn isString(source) ? source : undefined\n}\n\n/**\n * Reads a regular expression's flag text through the captured accessor.\n *\n * @remarks\n * The flags half of {@link readPatternSource}, on the same captured-accessor terms and\n * for the same reason.\n *\n * @param pattern - The candidate regular expression to read\n * @returns The pattern's flag text, or `undefined` when it cannot be read as a string\n * @throws The exact value the captured accessor throws for a receiver that is not a pattern\n *\n * @example\n * ```ts\n * readPatternFlags(/^a+$/giu) // 'giu'\n * ```\n */\nexport function readPatternFlags(pattern: unknown): string | undefined {\n\tconst read = INTRINSICS.modifiers\n\tif (read === undefined) return undefined\n\tconst flags: unknown = INTRINSICS.reflect.apply(read, pattern, [])\n\treturn isString(flags) ? flags : undefined\n}\n\n/**\n * Determines whether a string is in the language of a pattern this package owns.\n *\n * @remarks\n * The pattern-membership answer, asked exactly as {@link matchesMember} asks the\n * literal one, and asked through `exec` rather than `test` on purpose:\n * `RegExp.prototype.test` is spec-defined in terms of `RegExpExec`, which\n * re-reads `exec` off the receiver, so even a CAPTURED `test` still answers\n * whatever the caller installed. Replacing either member decided what `matchOf`,\n * `stringOf`, `contract.is`, `contract.parse`, `audit`, `explain` and the format\n * inferers published — a wrong yes for a non-member and a wrong no for a member,\n * silently.\n *\n * @param pattern - The owned pattern to apply\n * @param value - The string to test\n * @returns True if the pattern genuinely matches; false otherwise\n *\n * @example\n * ```ts\n * matchesPattern(/^[0-9a-f]+$/, '1a2f') // true\n * ```\n */\nexport function matchesPattern(pattern: RegExp, value: string): boolean {\n\treturn INTRINSICS.reflect.apply(INTRINSICS.captures, pattern, [value]) !== null\n}\n\n/**\n * Checks whether a string's length in code points falls within optional bounds.\n *\n * @remarks\n * Counts what JSON Schema's `minLength` and `maxLength` count: a surrogate pair is\n * one, and a lone surrogate is one. A string holds at most `.length` code points and\n * at least half that, so `.length` decides every bound it can with no count. The\n * count runs only where a bound sits between those two figures, which limits its\n * work to about twice the bound rather than to the size of the string.\n *\n * @param value - The string to measure\n * @param min - The inclusive lower bound, when there is one\n * @param max - The inclusive upper bound, when there is one\n * @returns True if the code-point count is within every present bound; false otherwise\n *\n * @example\n * ```ts\n * matchesStringLength('😀😀', undefined, 2) // true\n * matchesStringLength('😀', 2, undefined) // false\n * ```\n */\nexport function matchesStringLength(\n\tvalue: string,\n\tmin: number | undefined,\n\tmax: number | undefined,\n): boolean {\n\tconst length = value.length\n\tif (min !== undefined && length < min) return false\n\tif (max !== undefined && length > 2 * max) return false\n\tif (\n\t\t(min === undefined || INTRINSICS.ceil(length / 2) >= min) &&\n\t\t(max === undefined || length <= max)\n\t) {\n\t\treturn true\n\t}\n\t// The code points are the units less the pairs. `max` holds at `length - max` pairs,\n\t// and `min` fails one past `length - min`, so the walk stops at whichever it reaches.\n\tconst pairs = computeSurrogatePairs(value, length - (min === undefined ? (max ?? 0) : min - 1))\n\tconst points = length - pairs\n\treturn (min === undefined || points >= min) && (max === undefined || points <= max)\n}\n\n/**\n * Counts the surrogate pairs in a string, stopping at a limit.\n *\n * @remarks\n * A regular-expression literal builds a fresh `RegExp` per evaluation, so this call\n * owns the `lastIndex` that is its cursor, and the captured `exec` reads the internal\n * slots and no member a caller can replace. Text with no surrogate costs one native\n * scan, and a string of pairs costs one `exec` per pair up to the limit.\n *\n * @param value - The string to scan\n * @param limit - The count to stop at\n * @returns The number of surrogate pairs, or `limit` when the string holds at least that many\n *\n * @example\n * ```ts\n * computeSurrogatePairs('😀a😀', 8) // 2\n * computeSurrogatePairs('😀😀😀', 2) // 2\n * ```\n */\nexport function computeSurrogatePairs(value: string, limit: number): number {\n\tconst pair = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g\n\tconst steps = limit > 0 ? INTRINSICS.ceil(limit) : 0\n\tfor (const step of iterateIndices(() => steps)) {\n\t\tif (INTRINSICS.reflect.apply(INTRINSICS.captures, pair, [value]) === null) return step\n\t}\n\treturn steps\n}\n\n/**\n * Refuses an options record that holds a key its builder does not read.\n *\n * @remarks\n * The door for an option that decides what a contract accepts, where a misspelled key\n * would otherwise read as an absent option and fail open. It looks at own enumerable\n * string keys, so an inherited or symbol-keyed member is not a misspelling.\n *\n * @param source - The builder options, when there are any\n * @param keys - The keys that builder reads\n * @param builder - The builder name used in the refusal\n * @param shape - The shape category used in structured error context\n * @throws {ContractError} When the record holds any other key\n *\n * @example\n * ```ts\n * refuseOptionKeys({ strict: true }, ['strict'], 'schemaToShape', 'schema') // returns\n * refuseOptionKeys({ strct: true }, ['strict'], 'schemaToShape', 'schema') // throws\n * ```\n */\nexport function refuseOptionKeys(\n\tsource: object | undefined,\n\tkeys: readonly string[],\n\tbuilder: string,\n\tshape: string,\n): void {\n\tif (source === undefined) return\n\tconst strays: readonly string[] = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.select,\n\t\treadIndexView(INTRINSICS.keys(source)),\n\t\t[\n\t\t\t(key: string) =>\n\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, keys, [(name: string) => name === key]),\n\t\t],\n\t)\n\tconst first = strays[0]\n\tif (first === undefined) return\n\tconst known: string = INTRINSICS.reflect.apply(INTRINSICS.join, keys, [', '])\n\tthrow new ContractError(\n\t\t`${builder}: unknown option ${preview(first)}; the options are ${known}`,\n\t\t{ code: 'structure', context: { path: [first], shape } },\n\t)\n}\n\n/**\n * Escapes every regular-expression metacharacter in a text, so the text\n * matches literally inside a larger `RegExp` source.\n *\n * @remarks\n * Prefixes each of `\\ ^ $ . * + ? ( ) [ ] { } |` with a backslash and leaves\n * every other character, `-` and `/` included, unchanged; the empty string\n * returns unchanged. The escape is an INDEXED character map rather than\n * `String.prototype.replace`, which dispatches through the caller-writable\n * `RegExp.prototype[Symbol.replace]` and `exec` members.\n *\n * @param value - The literal text to escape\n * @returns The text with every metacharacter backslash-escaped\n *\n * @example\n * ```ts\n * escapeRegExp('a.b*c') // 'a\\\\.b\\\\*c'\n * new RegExp(`^${escapeRegExp('a.b')}$`).test('axb') // false\n * ```\n */\nexport function escapeRegExp(value: string): string {\n\tconst metacharacters = collectMembers([\n\t\t'\\\\',\n\t\t'^',\n\t\t'$',\n\t\t'.',\n\t\t'*',\n\t\t'+',\n\t\t'?',\n\t\t'(',\n\t\t')',\n\t\t'[',\n\t\t']',\n\t\t'{',\n\t\t'}',\n\t\t'|',\n\t])\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => value.length),\n\t\t(index) => (matchesMember(metacharacters, value[index]) ? `\\\\${value[index]}` : value[index]),\n\t)\n\treturn INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n}\n\n/**\n * Rebuilds a caller's regular expression as a stateless pattern this package\n * owns.\n *\n * @remarks\n * Strips the stateful `g` / `y` flags so repeated checks are stable and the\n * caller's `lastIndex` never moves. The strip is an INDEXED character filter\n * rather than `String.prototype.replaceAll`, which is itself a caller-writable\n * member: a substitute answering `'i'` made `matchOf(/^abc$/)` accept `'ABC'` —\n * the package building a case-insensitive pattern the developer never wrote.\n *\n * @param pattern - The caller's regular expression\n * @returns An owned, stateless equivalent\n * @throws The exact value thrown when the pattern's source or flags cannot be read\n *\n * @example\n * ```ts\n * readPattern(/^a+$/gy) // /^a+$/\n * ```\n */\nexport function readPattern(pattern: RegExp): RegExp {\n\tconst source = readPatternSource(pattern)\n\tconst flags = readPatternFlags(pattern)\n\tif (source === undefined || flags === undefined) {\n\t\tthrow new INTRINSICS.error('Pattern source and flags could not be read')\n\t}\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => flags.length),\n\t\t(index) => flags[index],\n\t)\n\tconst selected = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(characters), [\n\t\t(flag: string | undefined) => flag !== undefined && flag !== 'g' && flag !== 'y',\n\t])\n\tconst stateless: string = INTRINSICS.reflect.apply(INTRINSICS.join, selected, [''])\n\treturn new INTRINSICS.pattern(source, stateless)\n}\n\n/**\n * Rebuilds a declaration's regular expression as a stateless pattern this\n * package owns, and refuses an unreadable one under the reader's own name.\n *\n * @remarks\n * The one construction the compiled string leaves and `stringOf` share.\n * {@link readPattern} strips `g` and `y`, so the result carries no `lastIndex`\n * an answer could move and one rebuild answers every value alike — which is\n * what lets a compiled door take the read while the plan is built and hold the\n * rebuild for the plan's life, instead of minting a `RegExp` per answered\n * value. The read runs through {@link readValue}, so a source or flags that\n * cannot be read refuses with this module's uniform `pattern` diagnostic under\n * the reader that asked, rather than with the host's raw `TypeError`.\n *\n * @param pattern - The declaration's regular expression to rebuild\n * @param reader - The public reader name the diagnostic carries\n * @returns An owned, stateless equivalent of the declaration's pattern\n * @throws {ContractError} Thrown when the pattern's source or flags cannot be\n * read, coded `pattern` as `<reader>: pattern could not be read`\n *\n * @example\n * ```ts\n * ownPattern(/^a+$/gy, 'stringOf') // /^a+$/\n * ```\n */\nexport function ownPattern(pattern: RegExp, reader: string): RegExp {\n\treturn readValue(() => readPattern(pattern), reader, {\n\t\tsubject: 'pattern',\n\t\tcode: 'pattern',\n\t\tcontext: { shape: 'string' },\n\t})\n}\n\n/**\n * Pins every own member of a class prototype as a non-configurable member —\n * non-writable too when it is a data property — and verify the pin took.\n *\n * @remarks\n * The other half of the structural answer. Membership answers moved off class\n * methods entirely, but a class this package EXPORTS still has methods its own\n * modules dispatch through — `cloneShape` reaches `ShapeCloner.prototype.clone`,\n * and one assignment there made `compileSchema` publish whatever the caller\n * chose while `compileSchema` itself was never touched. That is the same defect\n * as a replaced host member with the package's own name on it, so every exported\n * class pins its prototype while it is DEFINED.\n *\n * The pin buys exactly this: no code that runs AFTER this class is defined can\n * replace a member on its prototype. It reaches no earlier, in exactly the case\n * {@link INTRINSICS} already states and does not defend — ESM evaluates imports\n * in source order, so a module that evaluates before this package has already\n * run.\n *\n * Placement goes through the captured `Reflect.defineProperty`, which ANSWERS\n * instead of throwing, and the answer is then corroborated by reading the\n * descriptor back. Installing is not reading: a pin that silently did not happen\n * is indistinguishable from one that did until something asks, so this asks. The\n * residual is named rather than denied: an adversary who also answers the\n * verifying descriptor read defeats this, and that adversary already chose what\n * {@link INTRINSICS} captured.\n *\n * {@link ContractError} is the one exempt class, and it inlines this body rather\n * than calling it: `errors.ts` sits beneath this module in the graph — this file\n * imports it — so reaching back for the helper would invert the dependency, the\n * same reason {@link isContractError} carries its own `try` / `catch`. That copy\n * is held aligned with this one, accessor branch and answering placement\n * included. Every other exported class calls this helper.\n *\n * @param prototype - The class prototype to pin\n * @param owner - The class name used in the refusal\n * @throws {ContractError} When a member cannot be pinned or the pin cannot be verified\n *\n * @example\n * ```ts\n * class Widget { static { pinMembers(Widget.prototype, 'Widget') } }\n * ```\n */\nexport function pinMembers(prototype: object, owner: string): void {\n\tconst members = INTRINSICS.reflect.members(prototype)\n\tfor (const index of iterateIndices(() => members.length)) {\n\t\tconst key = members[index]\n\t\tif (key === undefined) continue\n\t\t// An ACCESSOR is pinned by its configurability alone. `writable` belongs to\n\t\t// a data property, and asking for it on a getter REPLACES the accessor with\n\t\t// a data property holding `undefined` — a pin that silently deletes the\n\t\t// member it was protecting, which is the failure mode this whole helper\n\t\t// exists to make impossible.\n\t\tconst declared = INTRINSICS.describe(prototype, key)\n\t\tconst accessor = declared !== undefined && !INTRINSICS.own(declared, 'value')\n\t\tINTRINSICS.reflect.define(\n\t\t\tprototype,\n\t\t\tkey,\n\t\t\taccessor ? { configurable: false } : { writable: false, configurable: false },\n\t\t)\n\t\tconst pinned = INTRINSICS.describe(prototype, key)\n\t\tif (pinned?.configurable !== false || (!accessor && pinned.writable !== false)) {\n\t\t\tthrow new ContractError(`${owner}: a prototype member could not be pinned`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape: owner, received: preview(key) },\n\t\t\t})\n\t\t}\n\t}\n}\n\n// === Result helpers\n\n/**\n * Boxes a value as the {@link Success} branch of a {@link Result}.\n *\n * @param value - The value to box, retained exactly\n * @returns A fresh `{ success: true, value }` record\n *\n * @example\n * ```ts\n * success(42) // { success: true, value: 42 }\n * ```\n */\nexport function success<T>(value: T): Success<T> {\n\treturn { success: true, value }\n}\n\n/**\n * Boxes an error as the {@link Failure} branch of a {@link Result}.\n *\n * @param error - The error to box, retained exactly\n * @returns A fresh `{ success: false, error }` record\n *\n * @example\n * ```ts\n * failure('offline') // { success: false, error: 'offline' }\n * ```\n */\nexport function failure<E>(error: E): Failure<E> {\n\treturn { success: false, error }\n}\n\n/**\n * Narrows a {@link Result} to its {@link Success} branch.\n *\n * @param result - The result to narrow\n * @returns True if the result succeeded; false otherwise\n *\n * @example\n * ```ts\n * isSuccess(success(1)) // true\n * ```\n */\nexport function isSuccess<T, E>(result: Result<T, E>): result is Success<T> {\n\treturn result.success\n}\n\n/**\n * Narrows a {@link Result} to its {@link Failure} branch.\n *\n * @param result - The result to narrow\n * @returns True if the result failed; false otherwise\n *\n * @example\n * ```ts\n * isFailure(failure('offline')) // true\n * ```\n */\nexport function isFailure<T, E>(result: Result<T, E>): result is Failure<E> {\n\treturn !result.success\n}\n\n/**\n * Invokes a callback once and synchronously captures its exact outcome as a\n * {@link Result}.\n *\n * @remarks\n * The sanctioned never-throw boundary for the guards, required by\n * `.claude/rules/patterns.md` § Validation and contracts. The\n * `whereOf`, `lazyOf`, and `transformOf` combinators invoke caller-supplied\n * callbacks *inside* a guard body, yet a guard must NEVER throw — it returns a\n * `boolean`. This converts a throwing callback into a `Failure` so the\n * surrounding guard can treat it as a non-match instead of propagating the\n * exception, written once and shared rather than copy-pasted as ad-hoc\n * `try`/`catch`. The return or thrown value is retained exactly and is never\n * inspected, coerced, cloned, frozen, or mutated. A returned Promise or\n * thenable is an ordinary successful value; later settlement is outside this\n * synchronous boundary. {@link isContractError} does not use this boundary and\n * is not an exception to it: it carries its own `try`/`catch` inside the class\n * body, because `errors.ts` cannot import this module without inverting the\n * dependency. A guard whose totality rests on an\n * argument that nothing inside it can throw is one refactor away from throwing.\n *\n * @param callback - The callback to invoke with no arguments\n * @returns A `Success` carrying the exact return value, or a `Failure` carrying\n * the exact thrown value as `unknown`\n *\n * @example\n * ```ts\n * const outcome = attempt(() => predicate(value))\n * return isSuccess(outcome) && outcome.value\n * ```\n */\nexport function attempt<T>(callback: () => T): Result<T> {\n\ttry {\n\t\treturn success(callback())\n\t} catch (error) {\n\t\treturn failure(error)\n\t}\n}\n\n/**\n * Renders a thrown value as a non-empty message.\n *\n * @remarks\n * Reads an `Error`'s `message` and converts any other value with the `String`\n * function {@link INTRINSICS} captured at load, so a symbol renders as\n * `Symbol(description)` and a caller that replaces the global `String` does not\n * change the result. Returns `'unknown failure'` when\n * that read throws, as a throwing `message` getter or `toString` method does,\n * when an `Error`'s `message` is not a string, and when the rendered text is\n * empty. Never throws.\n *\n * @param error - The caught value, of any shape\n * @returns The rendered message, never empty\n *\n * @example\n * ```ts\n * errorToMessage(new Error('boom')) // 'boom'\n * errorToMessage('') // 'unknown failure'\n * ```\n */\nexport function errorToMessage(error: unknown): string {\n\tconst read = attempt(() => (isError(error) ? error.message : INTRINSICS.text(error)))\n\treturn isSuccess(read) && isString(read.value) && read.value.length > 0\n\t\t? read.value\n\t\t: 'unknown failure'\n}\n\n/**\n * Reads a value through the shared containment boundary or refuses it with the\n * contract module's uniform read diagnostic.\n *\n * @remarks\n * Unlike {@link attempt}, this is not an optional-result boundary: a caller\n * has committed to reading the supplied value, so a failed read cannot be\n * represented as absence or another permissive answer. Every reader using\n * this helper throws with the same `<reader>: <subject> could not be read`\n * message shape and retains the exact thrown value as its cause. Required\n * structural readers use the defaults; pattern readers supply `pattern` for\n * both the subject and code.\n *\n * @param callback - The read operation to perform\n * @param reader - The public reader name used in the diagnostic\n * @param options - Optional subject, code, and structured context\n * @returns The successfully read value\n * @throws {ContractError} When the read operation fails\n *\n * @example\n * ```ts\n * readValue(() => source.value, 'parseRecord')\n * ```\n */\nexport function readValue<T>(callback: () => T, reader: string, options?: ReadValueOptions): T {\n\tconst diagnostics = attempt(() => {\n\t\tconst source = options?.context\n\t\t// Every consumed field is projected through a literal that already OWNS\n\t\t// every consumed name, so an absent field resolves to that own `undefined`\n\t\t// instead of leaving the container for `Object.prototype` — which every\n\t\t// caller can write. An unqualified `source.path` on a context literal\n\t\t// carrying only `shape` is an ordinary `Get`, and it walked, so a polluted\n\t\t// prototype chose what a refusal this module authored published and\n\t\t// retained the caller's object by identity. Spread copies own enumerable\n\t\t// properties only through the spec's own copy operation, so the projection\n\t\t// stays own-only without dispatching through a replaceable global. The\n\t\t// copy stays EAGER because performing it is what refuses a hostile\n\t\t// context: a throwing getter on any own key — advertised or not — must\n\t\t// refuse this call whether or not the callback goes on to succeed.\n\t\tconst owned =\n\t\t\tsource === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tpath: undefined,\n\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\tlimit: undefined,\n\t\t\t\t\t\treceived: undefined,\n\t\t\t\t\t\t...source,\n\t\t\t\t\t}\n\t\tconst requested = options?.code\n\t\tconst subject = options?.subject\n\t\t// Membership over the one declared vocabulary, not a re-spelled chain of\n\t\t// equality tests: a copy of the union written here drifts from it silently,\n\t\t// and the copy this replaced had already lost `expansion`, so a door asking\n\t\t// for that code published `structure` instead.\n\t\tconst code: ContractCode =\n\t\t\trequested !== undefined &&\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, CONTRACT_CODES, [\n\t\t\t\t(known: ContractCode) => known === requested,\n\t\t\t])\n\t\t\t\t? requested\n\t\t\t\t: 'structure'\n\t\treturn {\n\t\t\treader: isString(reader) ? reader : 'readValue',\n\t\t\tsubject: isString(subject) ? subject : 'value',\n\t\t\tcode,\n\t\t\towned,\n\t\t}\n\t})\n\tif (isFailure(diagnostics)) {\n\t\tthrow new ContractError('readValue: options could not be read', {\n\t\t\tcode: 'structure',\n\t\t\tcause: diagnostics.error,\n\t\t})\n\t}\n\tconst outcome = attempt(callback)\n\tif (isFailure(outcome)) {\n\t\t// Only a refusal publishes a context, so the published object is assembled\n\t\t// in this branch rather than beside the copy. `owned` already holds copied\n\t\t// values, so assembling it outside the contained read cannot throw.\n\t\tconst owned = diagnostics.value.owned\n\t\tconst context =\n\t\t\towned === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\t...(owned.path === undefined ? {} : { path: owned.path }),\n\t\t\t\t\t\t...(owned.shape === undefined ? {} : { shape: owned.shape }),\n\t\t\t\t\t\t...(owned.limit === undefined ? {} : { limit: owned.limit }),\n\t\t\t\t\t\t...(owned.received === undefined ? {} : { received: owned.received }),\n\t\t\t\t\t}\n\t\tthrow new ContractError(\n\t\t\t`${diagnostics.value.reader}: ${diagnostics.value.subject} could not be read`,\n\t\t\t{\n\t\t\t\tcode: diagnostics.value.code,\n\t\t\t\t...(context === undefined ? {} : { context }),\n\t\t\t\tcause: outcome.error,\n\t\t\t},\n\t\t)\n\t}\n\treturn outcome.value\n}\n\n/**\n * Runs a public door's whole body and publishes only this package's error class.\n *\n * @remarks\n * The other half of the answer {@link INTRINSICS} gives, and the half that does\n * not depend on anyone enumerating anything. Capture removes a named dispatch;\n * this removes the CONSEQUENCE of every dispatch a door's path still makes,\n * named or not. Four consecutive rounds fixed the statements they were shown\n * and were defeated by a statement one line later, because a boundary placed\n * per statement is only ever as complete as the last sweep. A boundary at the\n * door composes: whatever the body reaches, and whatever a caller installs\n * under it, the door publishes a {@link ContractError} or the value it\n * promised.\n *\n * A {@link ContractError} reaching this boundary passes through by identity —\n * the diagnosis a door spent its whole body computing is the point of the door,\n * and rewrapping it would demote it to a cause. The mechanism is\n * {@link isContractError}, which establishes CLASS MEMBERSHIP; it does not and\n * cannot establish that this package authored the error, and the passthrough is\n * described by what it tests rather than by what it intends. Anything else is a\n * host failure the caller arranged, so it is republished under the door's own\n * name with the exact thrown value retained as `cause`.\n *\n * Its population is exactly the public doors that can refuse — every door whose\n * TSDoc carries `@throws {ContractError}`, and no door whose body cannot throw\n * at all. A wrapper around a body that only allocates a closure buys nothing\n * and misreports where the refusals are.\n *\n * Use {@link readValue} instead where a single read has its own subject and\n * deserves its own diagnostic; use this where the subject is the door.\n *\n * @param callback - The door body to run\n * @param door - The public door name used in the diagnostic\n * @param options - Optional code and structured context for the published refusal\n * @returns The body's exact return value\n * @throws {ContractError} The body's own refusal, or a coded translation of a host failure\n *\n * @example\n * ```ts\n * export function nullShape(options?: NullShapeOptions): NullShape {\n * \treturn contain(() => buildNullShape(options), 'nullShape')\n * }\n * ```\n */\nexport function contain<T>(callback: () => T, door: string, options?: ContainOptions): T {\n\tconst outcome = attempt(callback)\n\tif (isSuccess(outcome)) return outcome.value\n\tif (isContractError(outcome.error)) throw outcome.error\n\tthrow new ContractError(`${door}: a host operation this door depends on failed`, {\n\t\tcode: options?.code ?? 'structure',\n\t\t...(options?.context === undefined ? {} : { context: options.context }),\n\t\tcause: outcome.error,\n\t})\n}\n\n/**\n * Invokes a predicate through the sanctioned never-throw boundary.\n *\n * @remarks\n * Backs the `instanceof`-based validators and every container combinator's element\n * walk. The answer is `true` only for the boolean literal `true`; a throw and every\n * other return are `false`.\n *\n * @param callback - The predicate to invoke with no arguments\n * @returns True if the callback returns the boolean value `true`; false otherwise\n *\n * @example\n * ```ts\n * holds(() => value instanceof Widget) // false when inspection throws\n * ```\n */\nexport function holds(callback: () => boolean): boolean {\n\tconst outcome = attempt(callback)\n\treturn isSuccess(outcome) && outcome.value === true\n}\n\n/**\n * Determines whether a value carries the plain-record brand, raising a hostile\n * prototype observation instead of answering it.\n *\n * @remarks\n * THE single record-brand rule: a plain record is a non-array object whose\n * prototype is `null`, or is a realm's `Object.prototype`. Realm-agnosticism is\n * why the second arm cannot compare against this realm's\n * `Object.prototype` — a plain object from another `vm.Context`, iframe, or\n * worker inherits from THAT realm's `Object.prototype`, which is a different\n * object. The earlier rule accepted any prototype that itself had a `null`\n * prototype, which every realm's `Object.prototype` satisfies — and so does a\n * class prototype a caller reparented to `null`, which is how a class instance\n * laundered through every ownership door. A foreign `Object.prototype` is\n * therefore identified by the own members ECMAScript requires every realm to\n * put on it (`constructor`, `hasOwnProperty`, `isPrototypeOf`,\n * `propertyIsEnumerable`, `toLocaleString`, `toString`, `valueOf`), each read\n * through its own DESCRIPTOR so no accessor on a hostile prototype ever runs.\n * Each must be an own DATA property whose value is a FUNCTION — true of every\n * conformant realm, so the requirement costs a genuine foreign record nothing,\n * and it refuses the cheapest forgery (stamping the mandated names with\n * `undefined`) for free.\n *\n * That is a structural test, not a provenance one, and the residual is stated\n * as exactly what it is: a FUNCTION-VALUED forgery passes, and this realm's own\n * `Object.prototype` supplies those functions to stamp, so the price is a\n * few lines rather than nothing. Reparenting a class prototype to `null` and\n * stamping the mandated names with real functions passes; so does leaving the\n * class untouched and putting a `Proxy` in prototype position that reports\n * `null` as its own prototype and answers those descriptor reads with\n * functions. In both cases the value is a live class instance whose methods are\n * still reachable on it. A further own-key SUBSET rule buys even less: it\n * refuses a forgery that left methods on its prototype and accepts the same\n * class with those methods moved onto the instance, where they are\n * indistinguishable from a plain record's function\n * properties — so it raises the forgery's price and narrows the realm-agnostic\n * arm this rule exists to keep open. What the pass buys is acceptance at\n * brand-governed doors and nothing after it: every ownership engine publishes a\n * frozen plain record built only from captured data, so no class instance,\n * class behavior, or forged prototype survives into a snapshot.\n *\n * `Object.create(<null-prototype object>)` is refused, and NOT because it is\n * structurally identical to a reparented class instance — it is not, since a\n * class prototype always owns `constructor` and a bare `Object.create(null)`\n * owns nothing. It is refused as policy: no realm produces that chain for a\n * plain object, no consumer of it has been named, and a caller erases the\n * difference by deleting `constructor`.\n *\n * This is the diagnosing form, deliberately NOT total: a revoked `Proxy` or a\n * hostile `getPrototypeOf` trap throws out of it, so an ownership engine can\n * report an unreadable value as a failed read with the exact cause rather than\n * as a well-formed structural refusal. {@link isRecord} is the total form for\n * every guard consumer and contains that throw as `false`.\n *\n * @param value - The value whose record brand to inspect\n * @returns True if the value is a plain record; false otherwise\n * @throws The exact value thrown by a hostile brand observation\n *\n * @example\n * ```ts\n * matchesRecordBrand({}) // true\n * matchesRecordBrand(Object.create(null)) // true\n * matchesRecordBrand(new Date()) // false\n * ```\n */\nexport function matchesRecordBrand(value: unknown): boolean {\n\tif (!isObject(value) || INTRINSICS.array(value)) return false\n\tconst prototype = INTRINSICS.prototype(value)\n\tif (prototype === null || prototype === INTRINSICS.base) return true\n\tif (INTRINSICS.prototype(prototype) !== null) return false\n\tconst mandated = [\n\t\t'constructor',\n\t\t'hasOwnProperty',\n\t\t'isPrototypeOf',\n\t\t'propertyIsEnumerable',\n\t\t'toLocaleString',\n\t\t'toString',\n\t\t'valueOf',\n\t]\n\t// Indexed, not iterated: `for…of` over an array this module built still reads\n\t// `Array.prototype[Symbol.iterator]`, a caller-writable member, and an\n\t// iterator yielding a name this list never held decides a brand verdict.\n\tfor (const index of iterateIndices(() => mandated.length)) {\n\t\tconst member = mandated[index]\n\t\tif (member === undefined) return false\n\t\t// A descriptor read, not a value read: it answers ownership, data-ness and\n\t\t// the member's kind in one observation while running no accessor a hostile\n\t\t// prototype installed. Every realm's members are function-valued data\n\t\t// properties, so requiring that costs a genuine realm nothing and costs a\n\t\t// forger the work of finding seven functions to stamp.\n\t\tconst descriptor = INTRINSICS.describe(prototype, member)\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) return false\n\t\tif (typeof descriptor.value !== 'function') return false\n\t}\n\treturn true\n}\n\n/**\n * Snapshots an array through its reflected own-index population.\n *\n * @remarks\n * Reads `length` once and one reflected own-key population, then corroborates\n * and reads only those reflected canonical indices in ascending order. The\n * frozen native snapshot retains actual holes: reading one yields `undefined`,\n * while own membership remains absent. Its work is proportional to the\n * reflected population, so a length-driven consumer must require `dense` or\n * carry an independent bound. A population that is exactly the canonical\n * indices in ascending order followed by `length` is copied straight by index\n * under the same per-index corroboration, and answers with the same entries,\n * the same `dense` fact, and the same refusals as the walk. Caller-defined\n * iteration is ignored. A descriptor-only index omitted from reflection is\n * deliberately outside this lens and remains a hole. Failure retains the exact\n * thrown value when length, reflection, membership, or indexed value\n * observation throws; a non-native length or view disagreement is also\n * failure. `4294967295` is metadata rather than an array index.\n *\n * @param value - The array whose reflected indexed entries to read\n * @returns A successful frozen entry snapshot with its dense fact, or a\n * failure carrying the exact thrown value as `unknown`\n *\n * @example\n * ```ts\n * readArrayEntries([1, 2]) // { success: true, value: { entries: [1, 2], dense: true } }\n * ```\n */\nexport function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>> {\n\treturn attempt(() => {\n\t\tconst length = value.length\n\t\tif (!INTRINSICS.safe(length) || length < 0 || length > 2 ** 32 - 1) {\n\t\t\tthrow new INTRINSICS.error('Array length is outside the native array domain')\n\t\t}\n\t\tconst members = INTRINSICS.reflect.members(value)\n\t\t// One canonicality question, asked once: the reported population is the\n\t\t// ascending index texts and `length`, and nothing else. The scan stops at\n\t\t// the first disagreement, so a population that fails the question pays for\n\t\t// the prefix it shares with a canonical one before it walks.\n\t\tconst canonical =\n\t\t\tmembers.length === length + 1 &&\n\t\t\tmembers[length] === 'length' &&\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(key: PropertyKey, index: number) => index < length && key !== INTRINSICS.text(index),\n\t\t\t])\n\t\tif (canonical) {\n\t\t\tconst packed = INTRINSICS.from(\n\t\t\t\titerateIndices(() => length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t\t\t}\n\t\t\t\t\treturn value[index]\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn INTRINSICS.freeze({ entries: INTRINSICS.freeze(packed), dense: true })\n\t\t}\n\t\tconst selected: ReadonlyArray<{ readonly index: number; readonly key: string }> =\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t(key: PropertyKey) => {\n\t\t\t\t\tif (!isString(key)) return []\n\t\t\t\t\tconst index = INTRINSICS.numeric(key)\n\t\t\t\t\tif (\n\t\t\t\t\t\t!INTRINSICS.integer(index) ||\n\t\t\t\t\t\tindex < 0 ||\n\t\t\t\t\t\tindex >= 2 ** 32 - 1 ||\n\t\t\t\t\t\tINTRINSICS.text(index) !== key\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn []\n\t\t\t\t\t}\n\t\t\t\t\tif (index >= length) throw new INTRINSICS.error('Array index views disagree')\n\t\t\t\t\treturn [{ index, key }]\n\t\t\t\t},\n\t\t\t])\n\t\tconst collected: readonly number[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(selected),\n\t\t\t[(entry: { readonly index: number }) => entry.index],\n\t\t)\n\t\tconst keys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(selected),\n\t\t\t[(entry: { readonly key: string }) => entry.key],\n\t\t)\n\t\tconst ascending = !INTRINSICS.reflect.apply(INTRINSICS.some, collected, [\n\t\t\t(index: number, position: number) => index <= (collected[position - 1] ?? -1),\n\t\t])\n\t\t// Ordered on arrival, not by default: a caller-defined key view may deliver\n\t\t// the canonical indices in any order, so the sort answers that view alone\n\t\t// and the parallel key list carries the string already proven canonical\n\t\t// against its index, which the ordered arrival then never re-derives.\n\t\tconst indices = ascending ? collected : sortValues(collected)\n\t\tconst pairs = INTRINSICS.from(\n\t\t\titerateIndices(() => indices.length),\n\t\t\t(position) => {\n\t\t\t\tconst index = indices[position]\n\t\t\t\tconst key = ascending ? keys[position] : INTRINSICS.text(index)\n\t\t\t\tif (index === undefined || key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t\t}\n\t\t\t\treturn [key, { value: value[index], enumerable: true, configurable: true, writable: true }]\n\t\t\t},\n\t\t)\n\t\tconst descriptors = INTRINSICS.record<PropertyDescriptor>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t})\n\t\tconst entries = INTRINSICS.definitions(new INTRINSICS.list<T | undefined>(length), descriptors)\n\t\treturn INTRINSICS.freeze({\n\t\t\tentries: INTRINSICS.freeze(entries),\n\t\t\tdense: indices.length === length,\n\t\t})\n\t})\n}\n\n/**\n * Snapshots a guard shape and its optional-key mode for a shape combinator.\n *\n * @remarks\n * A null-prototype record plus its own key list is used instead of a `Map`.\n * The declared-key population decides the guard's answer, and\n * `Map.prototype.has`, `Map.prototype.get`, and map iteration are three\n * caller-writable members on that path. An own data key read by index\n * dispatches through nothing.\n *\n * @param shape - The guard shape whose own string declarations to snapshot\n * @param optional - The optional-key list, `true` for every key, or `undefined`\n * @param reader - The public combinator name used in read refusals\n * @returns The owned guards and names plus the collected optional-key membership\n * @throws {ContractError} When the shape or optional-key list cannot be read\n *\n * @example\n * ```ts\n * readGuardShape({ id: isString }, undefined, 'recordOf')\n * ```\n */\nexport function readGuardShape(\n\tshape: GuardsShape,\n\toptional: readonly string[] | true | undefined,\n\treader: string,\n): GuardShapeRead {\n\tconst declared = readValue(\n\t\t() => {\n\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[(key: PropertyKey) => isString(key)],\n\t\t\t)\n\t\t\tconst pairs = INTRINSICS.from(\n\t\t\t\titerateIndices(() => names.length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = names[index]\n\t\t\t\t\treturn [key, key === undefined ? undefined : shape[key]]\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst guards = INTRINSICS.rebase(\n\t\t\t\tINTRINSICS.record<Guard<unknown> | undefined>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t\tnull,\n\t\t\t)\n\t\t\treturn { guards, names, vocabulary: collectMembers(names) }\n\t\t},\n\t\treader,\n\t\t{ subject: 'shape' },\n\t)\n\tconst optionalKeys = readValue(\n\t\t() => {\n\t\t\tif (optional === true) return collectMembers(declared.names)\n\t\t\tif (!INTRINSICS.array(optional)) return collectMembers([])\n\t\t\tconst entries = readArrayEntries(optional)\n\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Optional key list must be dense')\n\t\t\treturn collectMembers(\n\t\t\t\tINTRINSICS.from(\n\t\t\t\t\titerateIndices(() => entries.value.entries.length),\n\t\t\t\t\t(index) => INTRINSICS.text(entries.value.entries[index]),\n\t\t\t\t),\n\t\t\t)\n\t\t},\n\t\treader,\n\t\t{ subject: 'optional' },\n\t)\n\n\treturn {\n\t\tguards: declared.guards,\n\t\tnames: declared.names,\n\t\toptional: optionalKeys,\n\t\tvocabulary: declared.vocabulary,\n\t}\n}\n\n/**\n * Snapshots an object's own enumerable string keys through a total boundary.\n *\n * @remarks\n * This is the package-wide runtime property view used by compiled object\n * guards, parsers, reporters, schema inference, and owned schema cloning. It\n * matches the object-key view serialized by `JSON.stringify`: inherited,\n * symbol, and non-enumerable properties are excluded. A hostile Proxy trap\n * returns `undefined` rather than escaping.\n *\n * @param value - The object whose keys to snapshot\n * @returns A frozen owned key list, or `undefined` when enumeration throws\n *\n * @example\n * ```ts\n * enumerableKeys({ visible: 1 }) // ['visible']\n * ```\n */\nexport function enumerableKeys(value: object): readonly string[] | undefined {\n\t// `Object.keys` already returns a fresh own array, so it is frozen directly:\n\t// the copy it replaces was an array SPREAD, which dispatches through\n\t// `Array.prototype[Symbol.iterator]` — a caller-writable member — and sat\n\t// outside the boundary, so a redirected iterator threw the caller's raw value\n\t// out of a helper documented to answer `undefined`, and out of every compiled\n\t// guard and parser layered on it.\n\tconst outcome = attempt(() => INTRINSICS.freeze(INTRINSICS.keys(value)))\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Validates and snapshots a shape-builder options record through every reflective\n * operation the builder relies on.\n *\n * @remarks\n * Primitive inputs are rejected before reflection so ordinary caller mistakes\n * retain the reader's precise plain-record diagnostic. For an object, every\n * consumed key is read exactly once, checked for presence, and inspected for an\n * own descriptor while the container is enumerated once. Every successfully\n * read non-`undefined` consumed value enters the fresh own-enumerable snapshot,\n * including an inherited or non-enumerable option. A hostile host is reported\n * uniformly as an unreadable options record, while a readable array or class\n * instance retains the plain-record diagnostic.\n *\n * @param source - The optional builder options value\n * @param keys - Every option key consumed by that builder\n * @param builder - The builder name used in diagnostics\n * @param shape - The shape category used in structured error context\n * @returns An owned options snapshot, or `undefined` when options are absent\n * @throws {ContractError} When the value is not a plain record or reflection fails\n *\n * @example\n * ```ts\n * const options = readOptions(source, ['min', 'max'], 'numberShape', 'number')\n * ```\n */\nexport function readOptions<T extends object>(\n\tsource: T | undefined,\n\tkeys: ReadonlyArray<keyof T & string>,\n\tbuilder: string,\n\tshape: string,\n): T | undefined {\n\treturn contain(() => {\n\t\tif (source === undefined) return undefined\n\t\tconst input: unknown = source\n\t\tif (!isObject(input)) {\n\t\t\tthrow new ContractError(`${builder}: options must be a plain record`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape },\n\t\t\t})\n\t\t}\n\t\tconst result = readValue(\n\t\t\t() => {\n\t\t\t\t// A null-prototype accumulator, indexed — not a `Map`. The values read\n\t\t\t\t// here become the builder's published options, and `Map.prototype.get`\n\t\t\t\t// is a caller-writable member: a substitute answering a decoy would put\n\t\t\t\t// the caller's value into a snapshot the builder swears it observed.\n\t\t\t\t// An own data key on a null-prototype object dispatches through nothing,\n\t\t\t\t// including for a key literally named '__proto__'.\n\t\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\t\tif (key === undefined) return undefined\n\t\t\t\t\t\tconst value = INTRINSICS.reflect.read(input, key)\n\t\t\t\t\t\tINTRINSICS.reflect.present(input, key)\n\t\t\t\t\t\tINTRINSICS.reflect.describe(input, key)\n\t\t\t\t\t\treturn [key, value]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t(entry: unknown) => entry !== undefined,\n\t\t\t\t])\n\t\t\t\tconst values = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tINTRINSICS.reflect.members(input)\n\t\t\t\tconst record = matchesRecordBrand(input)\n\t\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(\n\t\t\t\t\t\tINTRINSICS.from(\n\t\t\t\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t\t\t\t(index) => keys[index],\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\t[(key: string | undefined) => key !== undefined && values[key] !== undefined],\n\t\t\t\t)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(names), [\n\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{ value: values[key], enumerable: true, configurable: true, writable: true },\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst snapshot: T = INTRINSICS.create(\n\t\t\t\t\tINTRINSICS.base,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn { snapshot, record }\n\t\t\t},\n\t\t\tbuilder,\n\t\t\t{ subject: 'options', context: { shape } },\n\t\t)\n\t\tif (!result.record) {\n\t\t\tthrow new ContractError(`${builder}: options must be a plain record`, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { shape },\n\t\t\t})\n\t\t}\n\t\treturn result.snapshot\n\t}, 'readOptions')\n}\n\n/**\n * Draws and validates one generator random sample.\n *\n * @remarks\n * A broken source is the source's fault rather than the shape's, so the refusal\n * carries code `random` and never the `generate` code, and {@link compileGenerator}\n * rethrows it at whatever draw depth it happened instead of rotating to the next union\n * variant. The diagnostic names the consuming shape category, the `[0, 1)` limit, and a\n * total non-coercing {@link preview} of the offending sample (or `threw`), so a hostile\n * object runs no conversion hook while the diagnostic is built and a primitive symbol\n * renders without consulting mutable `Symbol.prototype.toString`.\n *\n * @param random - The caller-supplied random source\n * @param shape - The shape category consuming the sample\n * @returns A finite sample in `[0, 1)`\n * @throws {ContractError} When the source throws or returns outside `[0, 1)`;\n * a thrown value is retained exactly as the cause\n *\n * @example\n * ```ts\n * drawRandom(() => 0.5, 'number') // 0.5\n * ```\n */\nexport function drawRandom(random: RandomFunction, shape: string): number {\n\treturn contain(() => {\n\t\tconst outcome = attempt(random)\n\t\tif (isFailure(outcome)) {\n\t\t\tthrow new ContractError('drawRandom: the random source threw', {\n\t\t\t\tcode: 'random',\n\t\t\t\tcontext: { shape, limit: '[0, 1)', received: 'threw' },\n\t\t\t\tcause: outcome.error,\n\t\t\t})\n\t\t}\n\t\tconst sample = outcome.value\n\t\tif (!isFiniteNumber(sample) || sample < 0 || sample >= 1) {\n\t\t\tthrow new ContractError('drawRandom: the random source must return a value in [0, 1)', {\n\t\t\t\tcode: 'random',\n\t\t\t\tcontext: { shape, limit: '[0, 1)', received: preview(sample) },\n\t\t\t})\n\t\t}\n\t\treturn sample\n\t}, 'drawRandom')\n}\n\n// === Record-field access\n\n/**\n * Resolves a (possibly nested) field value from a record by a key or key path.\n *\n * @remarks\n * A single `string` is ONE key (never split on `.`, so dotted keys are safe); a\n * string array descends left-to-right through own properties of nested objects.\n * The root must satisfy {@link isRecord}; inherited properties are never fields.\n * Intermediates may be objects or arrays indexed by string. Returns `undefined`\n * the moment a segment is missing or lands on a non-object, so the lookup is\n * total — even against a hostile getter or Proxy trap that throws on read,\n * contained through {@link attempt} so the throw never escapes.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns The resolved value, or `undefined`\n *\n * @example\n * ```ts\n * resolveField({ user: { name: 'Ada' } }, ['user', 'name']) // 'Ada'\n * resolveField({ 'a.b': 1 }, 'a.b') // 1 (one key)\n * resolveField({ a: 1 }, ['a', 'b']) // undefined\n * ```\n */\nexport function resolveField(record: Readonly<Record<string, unknown>>, path: FieldPath): unknown {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(record)) return undefined\n\t\tconst keys = isString(path) ? [path] : path\n\t\tconst indices = iterateIndices(() => keys.length)\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.reduce, indices, [\n\t\t\t(current: unknown, index: number): unknown => {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined || !isObject(current) || !INTRINSICS.own(current, key)) {\n\t\t\t\t\t// Closing the cursor prevents even a later path-length observation.\n\t\t\t\t\tindices.return()\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.reflect.read(current, key)\n\t\t\t},\n\t\t\trecord,\n\t\t])\n\t})\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Determines whether an object holds exactly the named own keys.\n *\n * @remarks\n * Every required key must be own, and every own key, symbols and non-enumerable ones\n * included, must be named, so an inherited field and a stray one both answer `false`.\n *\n * @param value - The object to inspect\n * @param required - The keys it must own\n * @param optional - The keys it may own\n * @returns True if its own keys are exactly those; false otherwise\n *\n * @example\n * ```ts\n * matchesExactKeys({ a: 1 }, ['a']) // true\n * matchesExactKeys({ a: 1, b: 2 }, ['a']) // false\n * matchesExactKeys({ a: 1, b: 2 }, ['a'], ['b']) // true\n * ```\n */\nexport function matchesExactKeys(\n\tvalue: object,\n\trequired: readonly string[],\n\toptional: readonly string[] = [],\n): boolean {\n\tconst absent = INTRINSICS.reflect.apply(INTRINSICS.some, required, [\n\t\t(key: string) => !INTRINSICS.own(value, key),\n\t])\n\tif (absent) return false\n\treturn !INTRINSICS.reflect.apply(INTRINSICS.some, INTRINSICS.reflect.members(value), [\n\t\t(key: string | symbol) =>\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, required, [(name: string) => name === key]) &&\n\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, optional, [(name: string) => name === key]),\n\t])\n}\n\n/**\n * Determines whether a repair `parse` made kept everything the value said.\n *\n * @remarks\n * `parse`'s coercions are published and form input relies on them, but some change what\n * a value means: `1` to `true`, `'9007199254740993'` to `...992`, `'1e-400'` to `0`,\n * `'0x10'` to `16`. A door that must not guess asks this about each fault `audit` reported,\n * since `audit` already names every nested repair with its path and the kind it wanted.\n *\n * Only a `type` fault is a repair. A number needs a string whose trim is the number's own\n * text, so `'30'` and `' 30 '` pass while `'30.0'`, `'007'`, `'0x10'`, `'1e3'`, `'+5'`,\n * `'.5'`, `'-0'`, and `'9007199254740993'` do not. A boolean needs `'true'` or `'false'`,\n * a literal its trimmed text, and a string a finite number. Anything else refuses.\n *\n * @param fault - A fault `audit` reported\n * @param input - The value as it arrived\n * @param parsed - What `parse` made of it\n * @returns True if the repair loses nothing; false otherwise\n *\n * @example\n * ```ts\n * const fault = { reason: 'type', path: ['a'], expected: 'number', received: '' } as const\n * matchesLosslessRepair(fault, { a: ' 30 ' }, { a: 30 }) // true\n * matchesLosslessRepair(fault, { a: '30.0' }, { a: 30 }) // false\n * ```\n */\nexport function matchesLosslessRepair(fault: AuditFault, input: unknown, parsed: unknown): boolean {\n\tif (fault.reason !== 'type') return false\n\tconst keys = isString(fault.path) ? [fault.path] : fault.path\n\tconst route = INTRINSICS.from(\n\t\titerateIndices(() => keys.length + 1),\n\t\t(index) => (index === 0 ? 'root' : (keys[index - 1] ?? '')),\n\t)\n\tconst raw = resolveField({ root: input }, route)\n\tconst value = resolveField({ root: parsed }, route)\n\tswitch (fault.expected) {\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn isString(raw) && isNumber(value) && raw.trim() === INTRINSICS.text(value)\n\t\tcase 'literal':\n\t\t\treturn (\n\t\t\t\tisString(raw) &&\n\t\t\t\t(isString(value) || isNumber(value) || isBoolean(value)) &&\n\t\t\t\traw.trim() === INTRINSICS.text(value)\n\t\t\t)\n\t\tcase 'boolean':\n\t\t\treturn raw === 'true' || raw === 'false'\n\t\tcase 'string':\n\t\t\treturn isFiniteNumber(raw)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\n/**\n * Determines whether a readable value stays within the fixed JSON container-depth limit.\n *\n * @remarks\n * Counts array and plain-record containers on each active root-to-value path.\n * Primitive and readable non-record objects are leaves, active cycles add no\n * level, and shared aliases are answered from the shallowest depth at which\n * the alias already fit. Arrays are traversed through their reflected\n * own-index population, so sparse work is proportional to populated entries\n * rather than advertised length. Every observable operation is contained;\n * hostile or contradictory reads return `false`.\n *\n * The walk carries a settled-depth memo beside its active-path set: a\n * container that fit at depth `d` also fits at any depth `<= d`, because every\n * path below it is then shallower than the one already measured. Without it a\n * node reachable by `k` distinct paths was re-walked `k` times, so an ORDINARY\n * record graph with thirty shared aliases — thirty-one nodes — cost `2^30`\n * visits through a public guard.\n *\n * @param value - The value whose readable container depth to inspect\n * @returns True if no active path exceeds {@link GUARD_DEPTH_LIMIT}; false otherwise\n *\n * @example\n * ```ts\n * matchesJSONDepth({ nested: [1] }) // true\n * ```\n */\nexport function matchesJSONDepth(value: unknown): boolean {\n\treturn holds(() => {\n\t\tconst stack: Array<\n\t\t\t| { readonly operation: 'enter'; readonly value: unknown; readonly depth: number }\n\t\t\t| { readonly operation: 'exit'; readonly value: object; readonly depth: number }\n\t\t> = [{ operation: 'enter', value, depth: 0 }]\n\t\tconst active = new INTRINSICS.weakSet<object>()\n\t\tconst settled = new INTRINSICS.weakMap<object, number>()\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack.pop()\n\t\t\tif (frame === undefined) return false\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tomitVisited(active, frame.value)\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, settled, [frame.value, frame.depth])\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst entry = frame.value\n\t\t\tif (entry === null || typeof entry !== 'object') continue\n\t\t\tconst array = INTRINSICS.array(entry)\n\t\t\tif (!array && !matchesRecordBrand(entry)) continue\n\t\t\tif (matchesVisited(active, entry)) continue\n\n\t\t\tconst depth = frame.depth + 1\n\t\t\tif (depth > GUARD_DEPTH_LIMIT) return false\n\t\t\t// Settled at a deeper start means every path below it was measured with\n\t\t\t// LESS headroom than this one has, so it cannot exceed the limit here.\n\t\t\tconst deepest: unknown = INTRINSICS.reflect.apply(INTRINSICS.recall, settled, [entry])\n\t\t\tif (isNumber(deepest) && depth <= deepest) continue\n\t\t\tadmitVisited(active, entry)\n\t\t\tstack[stack.length] = { operation: 'exit', value: entry, depth }\n\n\t\t\tif (array) {\n\t\t\t\tconst snapshot = readArrayEntries(entry)\n\t\t\t\tif (isFailure(snapshot)) return false\n\t\t\t\tconst children = INTRINSICS.values(snapshot.value.entries)\n\t\t\t\tfor (const index of iterateIndices(() => children.length)) {\n\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: children[index], depth }\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst keys = enumerableKeys(entry)\n\t\t\tif (keys === undefined) return false\n\t\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) return false\n\t\t\t\tif (!INTRINSICS.own(entry, key)) return false\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tvalue: INTRINSICS.reflect.read(entry, key),\n\t\t\t\t\tdepth,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t})\n}\n\n/**\n * Matches an unknown value against the recursive JSON value structure.\n *\n * @remarks\n * The caller-owned ancestor set tracks only the active traversal path, so\n * cycles fail while shared references across sibling branches remain valid.\n * The set belongs to one traversal from one entry point; passing a shared or\n * pre-populated set is unsupported. Arrays descend through the shared dense\n * own-index lens and plain records descend by values; class instances and\n * non-finite numbers are rejected.\n *\n * The walk is ITERATIVE, over an explicit enter/exit stack, exactly as\n * {@link matchesJSONDepth} is. A recursive walk makes the verdict a function of\n * the REMAINING CALL STACK rather than of the value, and a cap enforced by the\n * JavaScript stack is not a cap. This walk carries no depth cap of its own —\n * `isJSONValue` is deliberately the unbounded deep gate and\n * {@link matchesJSONDepth} / `isBoundedJSONValue` are the bounded pair beside\n * it — so the answer depends only on the value, at every depth and from every\n * call site.\n *\n * Beside the ancestor set the walk keeps a walk-local PROVED set, so a node\n * whose whole subtree already matched is not re-walked when a second path\n * reaches it. A supplied capture budget instead charges each occurrence that\n * ownership would copy; exhaustion throws `structure` with a `clone` cause.\n * Removing the recursion alone left the work exponential in shared\n * aliases: thirty aliases — thirty-one ordinary records — cost `2^30` visits\n * through `isJSONValue`, `parseJSONValue`, `canonicalStringify` and every\n * `jsonShape` contract.\n *\n * @param entry - The value to inspect\n * @param ancestors - Objects on the active traversal path\n * @param budget - Remaining capture nodes; aliases are charged for each copied occurrence when supplied\n * @returns True if the value is a cycle-free JSON value; false otherwise\n *\n * @example\n * ```ts\n * matchesJSONValue({ nested: [1, 'x', null] }, new WeakSet()) // true\n * matchesJSONValue(Number.NaN, new WeakSet()) // false\n * ```\n */\nexport function matchesJSONValue(\n\tentry: unknown,\n\tancestors: WeakSet<object>,\n\tbudget?: { left: number },\n): entry is JSONValue {\n\treturn readValue(\n\t\t() => {\n\t\t\tif (budget !== undefined) {\n\t\t\t\tif (!INTRINSICS.safe(budget.left)) {\n\t\t\t\t\tthrow new ContractError('matchesJSONValue: invalid node budget', { code: 'clone' })\n\t\t\t\t}\n\t\t\t\tbudget.left = INTRINSICS.min(budget.left, CLONE_NODE_LIMIT)\n\t\t\t}\n\t\t\tconst stack: Array<\n\t\t\t\t| { readonly operation: 'enter'; readonly value: unknown }\n\t\t\t\t| { readonly operation: 'exit'; readonly value: object }\n\t\t\t> = [{ operation: 'enter', value: entry }]\n\t\t\t// Walk-local, never the caller's set: a node whose WHOLE subtree already\n\t\t\t// matched needs no second walk. Soundness — if a proved node could reach\n\t\t\t// an ancestor active on some later path, that ancestor was inside the\n\t\t\t// proved node's own subtree, so the first walk descended into it, met the\n\t\t\t// proved node again while it was still active, and refused. A proved node\n\t\t\t// therefore cannot participate in a cycle any later path could discover.\n\t\t\tconst proved = new INTRINSICS.weakSet<object>()\n\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst frame = stack.pop()\n\t\t\t\tif (frame === undefined) return false\n\t\t\t\tif (frame.operation === 'exit') {\n\t\t\t\t\tomitVisited(ancestors, frame.value)\n\t\t\t\t\tadmitVisited(proved, frame.value)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif (budget !== undefined) {\n\t\t\t\t\tbudget.left -= 1\n\t\t\t\t\tif (budget.left < 0) {\n\t\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t\t`validateShape: default exceeds the capture node limit ${CLONE_NODE_LIMIT}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'clone',\n\t\t\t\t\t\t\t\tcontext: { limit: CLONE_NODE_LIMIT },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst node = frame.value\n\t\t\t\tif (node === null || isString(node) || isBoolean(node) || isFiniteNumber(node)) continue\n\t\t\t\tif (INTRINSICS.array(node)) {\n\t\t\t\t\tif (matchesVisited(ancestors, node)) return false\n\t\t\t\t\tif (budget === undefined && matchesVisited(proved, node)) continue\n\t\t\t\t\tconst snapshot = readArrayEntries(node)\n\t\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\t\tif (!snapshot.value.dense) return false\n\t\t\t\t\tadmitVisited(ancestors, node)\n\t\t\t\t\tstack[stack.length] = { operation: 'exit', value: node }\n\t\t\t\t\t// Pushed in reverse so the LIFO stack visits siblings in source order,\n\t\t\t\t\t// which is the order the recursive walk this replaced descended in.\n\t\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\t\tfor (const offset of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\tconst index = entries.length - 1 - offset\n\t\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: entries[index] }\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (!isRecord(node)) return false\n\t\t\t\tif (matchesVisited(ancestors, node)) return false\n\t\t\t\tif (budget === undefined && matchesVisited(proved, node)) continue\n\t\t\t\tadmitVisited(ancestors, node)\n\t\t\t\tstack[stack.length] = { operation: 'exit', value: node }\n\t\t\t\tconst members = INTRINSICS.values(node)\n\t\t\t\tfor (const offset of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst index = members.length - 1 - offset\n\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: members[index] }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true\n\t\t},\n\t\t'matchesJSONValue',\n\t\t{ context: { shape: 'json' } },\n\t)\n}\n\n/**\n * Counts the enumerable own-symbol keys on a value.\n *\n * @remarks\n * String keys are ignored — only `Object.getOwnPropertySymbols` entries whose\n * descriptor is `enumerable` are counted, and each descriptor is read through\n * the captured observation so no accessor runs. It answers exactly the\n * `JSON.stringify`-invisible half of a record's own-symbol population, for a\n * consumer that needs that count directly. It does NOT back `isEmptyObject` /\n * `isNonEmptyObject` — those ask the complete own-key question `recordOf` asks,\n * because an enumerable-only count made their `never` narrowing unsound for an\n * own non-enumerable key.\n *\n * @param value - The object to inspect\n * @returns The number of enumerable own-symbol keys\n *\n * @example\n * ```ts\n * const flag = Symbol('flag')\n * enumerableSymbolCount(Object.defineProperty({}, flag, { value: 1, enumerable: true })) // 1\n * enumerableSymbolCount({}) // 0\n * ```\n */\nexport function enumerableSymbolCount(value: object): number {\n\treturn readValue(() => {\n\t\tconst symbols = INTRINSICS.symbols(value)\n\t\tconst count: number = INTRINSICS.reflect.apply(INTRINSICS.fold, symbols, [\n\t\t\t(total: number, symbol: symbol) =>\n\t\t\t\ttotal + (INTRINSICS.describe(value, symbol)?.enumerable ? 1 : 0),\n\t\t\t0,\n\t\t])\n\t\treturn count\n\t}, 'enumerableSymbolCount')\n}\n\n/**\n * Narrows a compiled {@link JSONSchema} down to the open `Readonly<Record<string, unknown>>` shape\n * tool definitions advertise as `parameters` — through the {@link isRecord} boundary guard, never\n * an assertion, as `.claude/rules/patterns.md` § Validation and contracts requires.\n *\n * @remarks\n * A `JSONSchema` is the closed contract-compiler fragment (it has no index signature), whereas a\n * tool advertises its `parameters` as an open record. The two are structurally compatible but not\n * assignable, so the schema crosses that boundary through `isRecord` — a compiled contract schema\n * is always a record, so the guard passes for one. A readable value that satisfies the all-optional\n * `JSONSchema` interface without being a plain record — a class instance, whose prototype is the\n * class rather than `Object.prototype` — fails that guard and returns `undefined`, so the\n * `undefined` branch is a real answer a direct caller reaches rather than a decorative fallback.\n * This is the single sanctioned narrowing from a compiled contract schema to the open\n * tool-parameters record, so the crossing lives once rather than being copy-pasted per call site.\n *\n * @param schema - The compiled JSON Schema (a contract's `schema`)\n * @returns The schema as the open tool-parameters record, or `undefined` when it is not a record\n * @throws {ContractError} When the schema cannot be read\n *\n * @example\n * ```ts\n * import { createContract, schemaToParameters } from '@orkestrel/contract'\n *\n * const contract = createContract(shape)\n * const parameters = schemaToParameters(contract.schema) // the open record a tool advertises\n * ```\n */\nexport function schemaToParameters(\n\tschema: JSONSchema,\n): Readonly<Record<string, unknown>> | undefined {\n\treturn contain(() => {\n\t\treadValue(() => INTRINSICS.values(schema), 'schemaToParameters')\n\t\treturn isRecord(schema) ? schema : undefined\n\t}, 'schemaToParameters')\n}\n\n/**\n * Wraps a non-object `JSONSchema` root in a single-property object schema, so\n * an inferred primitive/array/union schema can flow into {@link schemaToParameters}\n * as an MCP-compatible `inputSchema`.\n *\n * @remarks\n * Deterministic for readable input. `schema.type === 'object'` passes through\n * unchanged; every other root (a primitive/array `type`, an `anyOf`/`enum`-only\n * schema with no `type`, or the empty `{}`) is wrapped as a single required\n * `value` property: `{ type: 'object', properties: { value: schema },\n * required: ['value'], additionalProperties: false }`. Composition:\n * `schemaToParameters(schemaToObject(valueToSchema(payload)))`.\n *\n * @param schema - The schema to wrap\n * @returns `schema` unchanged when object-rooted, otherwise the wrapped object schema\n * @throws {ContractError} When the schema root cannot be read\n *\n * @example\n * ```ts\n * schemaToObject({ type: 'string' })\n * // { type: 'object', properties: { value: { type: 'string' } },\n * // required: ['value'], additionalProperties: false }\n * schemaToObject({ type: 'object', properties: {} }) // unchanged\n * ```\n */\nexport function schemaToObject(schema: JSONSchema): JSONSchema {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tINTRINSICS.values(schema)\n\t\t\t\tif (INTRINSICS.own(schema, 'type') && schema.type === 'object') return schema\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: { value: schema },\n\t\t\t\t\trequired: ['value'],\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t}\n\t\t\t},\n\t\t\t'schemaToObject',\n\t\t\t{ subject: 'schema' },\n\t\t)\n\t}, 'schemaToObject')\n}\n\n// === Canonicalization\n\n/**\n * Encodes one non-container value the way JSON encodes it, or `undefined` when\n * JSON cannot encode it at all.\n *\n * @remarks\n * The leaf half of {@link canonicalStringify}: `JSON.stringify` returns\n * `undefined` (never a string) for `undefined`, a function, and a symbol —\n * exactly the values with no JSON encoding — and THROWS on a bigint, which is\n * refused before the call rather than through it. A `Date` and any other\n * non-record object encode through the same captured `JSON.stringify`, so a\n * `toJSON` member keeps its ordinary meaning.\n *\n * @param value - The non-container value to encode\n * @returns The JSON encoding, or `undefined` when JSON cannot encode `value`\n *\n * @example\n * ```ts\n * encodeLeaf(Number.NaN) // 'null'\n * encodeLeaf(undefined) // undefined\n * ```\n */\nexport function encodeLeaf(value: unknown): string | undefined {\n\tif (typeof value === 'bigint') return undefined\n\treturn INTRINSICS.stringify(value)\n}\n\n/**\n * Renders a value as a deterministic, key-sorted JSON string — or `undefined`\n * when it has no faithful JSON encoding.\n *\n * @remarks\n * The stable-stringify backing {@link unifySchemas}'s de-duplication and\n * ordering: unlike `JSON.stringify`, object keys are sorted before encoding\n * (recursively, at every nesting level), so two structurally-equal\n * `JSONSchema` fragments built independently always canonicalize to the same\n * string. Pure host-independent ECMAScript with no environment-specific imports.\n *\n * For READABLE input it returns `undefined` — never a partial or invalid\n * encoding — for every value JSON cannot faithfully encode:\n *\n * - `undefined` itself, a function, a symbol, or an array hole (JSON encodes\n * none of them), at the top level or anywhere inside a container;\n * - a bigint (`JSON.stringify` throws on one);\n * - cyclic input, tracked with the same ancestor-{@link WeakSet} discipline\n * the container branches of value inference use, so a shared (non-cyclic)\n * reference reached twice through different paths still encodes;\n * A hostile traversal is categorically different: a throwing own-getter,\n * hostile `ownKeys` trap, or revoked `Proxy` throws a `structure`\n * {@link ContractError} through {@link readValue}. A caller can therefore\n * distinguish \"not JSON-encodable\" from \"could not be read\".\n *\n * A caller therefore treats `undefined` as \"this value has no canonical key\",\n * never as an encoding: see {@link unifySchemas} (an un-keyed member cannot\n * participate in de-duplication or ordering) and {@link inferPrimitiveEnum} (an\n * un-keyed member makes the slot enum-ineligible).\n *\n * @param value - The value to canonicalize (a `JSONSchema` fragment, or any\n * nested piece of one)\n * @returns A deterministic string encoding of `value`, or `undefined` when JSON\n * cannot encode it\n * @throws {ContractError} When the value cannot be read\n *\n * @example\n * ```ts\n * canonicalStringify({ type: 'object', properties: {} }) ===\n * \tcanonicalStringify({ properties: {}, type: 'object' }) // true\n * canonicalStringify(Number.NaN) // 'null' — JSON.stringify semantics\n * canonicalStringify(undefined) // undefined\n * canonicalStringify(cyclicValue) // undefined\n * ```\n */\nexport function canonicalStringify(value: unknown): string | undefined {\n\treturn contain(() => {\n\t\treturn readValue(() => {\n\t\t\tif (!isObject(value) || (!isArray(value) && !matchesRecordBrand(value))) {\n\t\t\t\treturn encodeLeaf(value)\n\t\t\t}\n\t\t\tconst ancestors = new INTRINSICS.weakSet<object>()\n\t\t\tconst encodings = new INTRINSICS.weakMap<object, string>()\n\t\t\tconst stack: Array<\n\t\t\t\t| { readonly operation: 'enter'; readonly value: object }\n\t\t\t\t| {\n\t\t\t\t\t\treadonly operation: 'exit'\n\t\t\t\t\t\treadonly value: object\n\t\t\t\t\t\treadonly members: readonly unknown[]\n\t\t\t\t\t\treadonly keys: readonly string[] | undefined\n\t\t\t\t }\n\t\t\t> = [{ operation: 'enter', value }]\n\t\t\twhile (stack.length > 0) {\n\t\t\t\tconst frame = stack.pop()\n\t\t\t\tif (frame === undefined) return undefined\n\t\t\t\tif (frame.operation === 'exit') {\n\t\t\t\t\tconst parts = INTRINSICS.from(encodeParts(frame.members, frame.keys, encodings))\n\t\t\t\t\tif (parts.length !== frame.members.length) return undefined\n\t\t\t\t\tconst encoded: string = INTRINSICS.reflect.apply(INTRINSICS.join, parts, [','])\n\t\t\t\t\tconst text = frame.keys === undefined ? `[${encoded}]` : `{${encoded}}`\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, encodings, [frame.value, text])\n\t\t\t\t\tomitVisited(ancestors, frame.value)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst container = frame.value\n\t\t\t\tif (matchesVisited(ancestors, container)) return undefined\n\t\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [container]) !== undefined)\n\t\t\t\t\tcontinue\n\t\t\t\tconst snapshot = isArray(container) ? readArrayEntries(container) : undefined\n\t\t\t\tif (snapshot !== undefined && isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (snapshot !== undefined && !snapshot.value.dense) return undefined\n\t\t\t\tconst keys = snapshot === undefined ? sortValues(INTRINSICS.keys(container)) : undefined\n\t\t\t\tconst members =\n\t\t\t\t\tsnapshot === undefined\n\t\t\t\t\t\t? INTRINSICS.from(\n\t\t\t\t\t\t\t\titerateIndices(() => keys?.length ?? 0),\n\t\t\t\t\t\t\t\t(index) => {\n\t\t\t\t\t\t\t\t\tconst key = keys?.[index]\n\t\t\t\t\t\t\t\t\treturn key === undefined ? undefined : INTRINSICS.reflect.read(container, key)\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: snapshot.value.entries\n\t\t\t\tadmitVisited(ancestors, container)\n\t\t\t\tstack[stack.length] = { operation: 'exit', value: container, members, keys }\n\t\t\t\tfor (const offset of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst index = members.length - 1 - offset\n\t\t\t\t\tconst member = members[index]\n\t\t\t\t\tif (isObject(member) && (isArray(member) || matchesRecordBrand(member))) {\n\t\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: member }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [value])\n\t\t}, 'canonicalStringify')\n\t}, 'canonicalStringify')\n}\n\n// === Format classification\n\n/**\n * Computes the number of days in a month of the Gregorian calendar.\n *\n * @remarks\n * February has 29 days in a year divisible by 4, except a century year not divisible\n * by 400. The caller supplies a month from 1 to 12.\n *\n * @param year - The calendar year\n * @param month - The month, from 1 for January to 12 for December\n * @returns The days in that month, from 28 to 31\n *\n * @example\n * ```ts\n * computeMonthLength(2024, 2) // 29\n * computeMonthLength(1900, 2) // 28\n * ```\n */\nexport function computeMonthLength(year: number, month: number): number {\n\tconst leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)\n\treturn month === 2\n\t\t? 28 + INTRINSICS.numeric(leap)\n\t\t: 31 - INTRINSICS.numeric(month === 4 || month === 6 || month === 9 || month === 11)\n}\n\n/**\n * Checks whether a supported ISO-8601 date or date-time names a real instant.\n *\n * @remarks\n * Accepts exactly `YYYY-MM-DD`, or `YYYY-MM-DDTHH:MM:SS` with optional\n * fractional seconds followed by `Z` or a numeric offset. Inside the\n * {@link attempt} boundary, captured components receive explicit Gregorian\n * month/leap/day and clock validation before `Date#getTime` performs the final\n * offset/instant refusal. Backs {@link stringToFormat}'s `date`, `date-time`,\n * and prefixed `time` validation.\n *\n * @param value - The candidate ISO-8601 string\n * @returns True if `value` parses to a real instant; false otherwise\n *\n * @example\n * ```ts\n * matchesISOInstant('2024-02-29') // true\n * matchesISOInstant('2024-01-01T24:00Z') // false — incomplete normalized clock\n * ```\n */\nexport function matchesISOInstant(value: string): boolean {\n\tconst outcome = attempt(() => {\n\t\t// The CAPTURED `exec`, not the live member: `RegExp.prototype.test` is\n\t\t// spec-defined in terms of `RegExpExec`, so both spellings of a pattern\n\t\t// question answer whatever the caller most recently installed, and a decoy\n\t\t// match published a `format` for a string that never had one.\n\t\tconst match = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.captures,\n\t\t\t/^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2}))?$/,\n\t\t\t[value],\n\t\t)\n\t\tconst yearText = match?.[1]\n\t\tconst monthText = match?.[2]\n\t\tconst dayText = match?.[3]\n\t\tif (yearText === undefined || monthText === undefined || dayText === undefined) return false\n\t\tconst year = INTRINSICS.numeric(yearText)\n\t\tconst month = INTRINSICS.numeric(monthText)\n\t\tconst day = INTRINSICS.numeric(dayText)\n\t\tif (month < 1 || month > 12) return false\n\t\tif (day < 1 || day > computeMonthLength(year, month)) return false\n\t\tconst hourText = match?.[4]\n\t\tconst minuteText = match?.[5]\n\t\tconst secondText = match?.[6]\n\t\tif (hourText !== undefined || minuteText !== undefined || secondText !== undefined) {\n\t\t\tif (hourText === undefined || minuteText === undefined || secondText === undefined)\n\t\t\t\treturn false\n\t\t\tconst hour = INTRINSICS.numeric(hourText)\n\t\t\tconst minute = INTRINSICS.numeric(minuteText)\n\t\t\tconst second = INTRINSICS.numeric(secondText)\n\t\t\tif (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tconst date = new INTRINSICS.date(value)\n\t\treturn !INTRINSICS.nan(INTRINSICS.reflect.apply(INTRINSICS.instant, date, []))\n\t})\n\treturn isSuccess(outcome) && outcome.value\n}\n\n/**\n * Checks whether a string is exactly a calendar-valid `YYYY-MM-DD` date.\n *\n * @remarks\n * Refuses a date-time, surrounding whitespace, and a date the Gregorian calendar\n * lacks, such as `2026-02-29`. Backs a date string shape and {@link classifyFormat}'s\n * `date`.\n *\n * @param value - The candidate string\n * @returns True if `value` is a calendar-valid `YYYY-MM-DD`; false otherwise\n * @throws The exact value thrown by a redirected pattern dispatch\n *\n * @example\n * ```ts\n * matchesCalendarDate('2024-02-29') // true\n * matchesCalendarDate('2026-02-29') // false\n * ```\n */\nexport function matchesCalendarDate(value: string): boolean {\n\treturn matchesPattern(/^\\d{4}-\\d{2}-\\d{2}$/, value) && matchesISOInstant(value)\n}\n\n/**\n * Classifies an already-bounded string against the pattern-only and\n * calendar-checked {@link SchemaFormat} vocabulary.\n *\n * @remarks\n * The pure leaf behind {@link stringToFormat}'s total boundary: it performs the\n * pattern dispatch, and the door decides what a failed dispatch answers. Order\n * is significant — `date-time` is tried before `date`, and both require the\n * calendar check, so `2020-13-45` matches the pattern and is still refused.\n *\n * @param value - The candidate string, already length-bounded\n * @returns The matched {@link SchemaFormat}, or `undefined`\n * @throws The exact value thrown by a redirected pattern dispatch\n *\n * @example\n * ```ts\n * classifyFormat('ada@example.com') // 'email'\n * ```\n */\nexport function classifyFormat(value: string): SchemaFormat | undefined {\n\tif (matchesPattern(FORMAT_PATTERNS.uuid, value)) return 'uuid'\n\tif (\n\t\tmatchesPattern(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/, value) &&\n\t\tmatchesISOInstant(value)\n\t) {\n\t\treturn 'date-time'\n\t}\n\tif (matchesCalendarDate(value)) return 'date'\n\tif (\n\t\tmatchesPattern(/^\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/, value) &&\n\t\tmatchesISOInstant(`1970-01-01T${value}`)\n\t) {\n\t\treturn 'time'\n\t}\n\tif (matchesPattern(FORMAT_PATTERNS.email, value)) return 'email'\n\tif (matchesPattern(FORMAT_PATTERNS.uri, value)) return 'uri'\n\treturn undefined\n}\n\n// === Schema keyword derivation\n\n/**\n * Derives `min`/`max` shape bounds from a pair of non-negative-integer JSON\n * Schema length keywords (`minLength`/`maxLength`, `minItems`/`maxItems`).\n *\n * @remarks\n * Total and pure. Either keyword is used only when it is a non-negative\n * safe integer (`Number.isSafeInteger` + `>= 0`); a malformed value (a string,\n * a negative number, `NaN`, `Infinity`, a fraction, or an unsafe integer) is\n * dropped as if absent. When both bounds are present and `min` exceeds `max`,\n * the PAIR is dropped entirely (an unbounded shape is always a legal widening\n * of a contradictory schema).\n *\n * @param min - The raw `minLength` / `minItems` keyword value\n * @param max - The raw `maxLength` / `maxItems` keyword value\n * @returns The derived `min` / `max` pair, either possibly `undefined`\n *\n * @example\n * ```ts\n * deriveLengthBounds(1, 10) // { min: 1, max: 10 }\n * deriveLengthBounds(10, 1) // {} — contradictory, dropped\n * deriveLengthBounds(-1, 10) // { max: 10 } — negative min dropped\n * ```\n */\nexport function deriveLengthBounds(min: unknown, max: unknown): BoundsRead {\n\treturn contain(() => {\n\t\tconst lo = isInteger(min) && INTRINSICS.safe(min) && min >= 0 ? min : undefined\n\t\tconst hi = isInteger(max) && INTRINSICS.safe(max) && max >= 0 ? max : undefined\n\t\tif (lo !== undefined && hi !== undefined && lo > hi) return {}\n\t\treturn {\n\t\t\t...(lo === undefined ? {} : { min: lo }),\n\t\t\t...(hi === undefined ? {} : { max: hi }),\n\t\t}\n\t}, 'deriveLengthBounds')\n}\n\n/**\n * Derives `min`/`max` shape bounds from a pair of finite-number JSON Schema\n * range keywords (`minimum`/`maximum`).\n *\n * @remarks\n * Total and pure. Either keyword is used only when it is a finite number\n * ({@link isFiniteNumber} — rejects `NaN` / `±Infinity` / non-numbers); when\n * both bounds are present and `min` exceeds `max`, the PAIR is dropped\n * entirely, the same contradiction rule {@link deriveLengthBounds} applies.\n *\n * @param min - The raw `minimum` keyword value\n * @param max - The raw `maximum` keyword value\n * @returns The derived `min` / `max` pair, either possibly `undefined`\n *\n * @example\n * ```ts\n * deriveRangeBounds(0, 120) // { min: 0, max: 120 }\n * deriveRangeBounds(5, 1) // {} — contradictory, dropped\n * ```\n */\nexport function deriveRangeBounds(min: unknown, max: unknown): BoundsRead {\n\treturn contain(() => {\n\t\tconst lo = isFiniteNumber(min) ? min : undefined\n\t\tconst hi = isFiniteNumber(max) ? max : undefined\n\t\tif (lo !== undefined && hi !== undefined && lo > hi) return {}\n\t\treturn {\n\t\t\t...(lo === undefined ? {} : { min: lo }),\n\t\t\t...(hi === undefined ? {} : { max: hi }),\n\t\t}\n\t}, 'deriveRangeBounds')\n}\n\n// === Inference option sanitization\n\n/**\n * Sanitizes a user-supplied inference budget (`limits.depth` / `limits.properties`) to\n * a finite non-negative integer, selecting a valid fallback for anything else.\n *\n * @remarks\n * Guards {@link valueToSchema} / {@link samplesToSchema} against a hostile or\n * malformed budget: an unclamped `NaN` defeats every `depth <= 0` guard\n * (`NaN <= 0` is `false`, so recursion never halts), and a negative\n * `limits.properties` makes `slice(0, -1)` silently drop the LAST sorted key\n * instead of capping the list (a fractional value has a similarly undefined\n * `slice` bound). `Infinity` is rejected too — `Number.isInteger(Infinity)`\n * is `false` — since an unbounded budget is exactly the adversarial case the\n * caps exist to prevent. A valid candidate passes through unchanged without\n * inspecting the fallback. When the candidate is invalid, the fallback must\n * satisfy the same finite non-negative-integer contract or this boundary\n * refuses it with a coded error instead of returning an invalid budget.\n *\n * @param value - The candidate budget value\n * @param fallback - The default to select when `value` is not a finite\n * non-negative integer\n * @returns A finite non-negative integer budget\n * @throws {ContractError} When the selected fallback is not a finite\n * non-negative integer\n *\n * @example\n * ```ts\n * sanitizeBudget(Number.NaN, INFER_DEPTH_LIMIT) // INFER_DEPTH_LIMIT\n * sanitizeBudget(-1, INFER_BREADTH_LIMIT) // INFER_BREADTH_LIMIT\n * sanitizeBudget(4, INFER_DEPTH_LIMIT) // 4\n * ```\n */\nexport function sanitizeBudget(value: number | undefined, fallback: number): number {\n\treturn contain(() => {\n\t\tif (typeof value === 'number' && INTRINSICS.integer(value) && value >= 0) return value\n\t\tif (typeof fallback === 'number' && INTRINSICS.integer(fallback) && fallback >= 0)\n\t\t\treturn fallback\n\t\tthrow new ContractError('sanitizeBudget: fallback must be a finite non-negative integer', {\n\t\t\tcode: 'bound',\n\t\t\tcontext: { limit: 'finite non-negative integer', received: preview(fallback) },\n\t\t})\n\t}, 'sanitizeBudget')\n}\n\n/**\n * Resolves a caller's depth budget to one the traversal can actually survive.\n *\n * @remarks\n * {@link sanitizeBudget} decides the SHAPE of a budget and deliberately lets any\n * finite non-negative integer through, because it must never read a fallback a\n * hostile caller supplied. That left the depth axis unbounded from above, and\n * depth is the axis that recurses: `1e9` is a valid integer, so the walk descended\n * until the call STACK failed, at a depth that varied between runs, and the\n * refusal surfaced as an unreadable value rather than as the exhaustion the guard\n * promises. Breadth needs no such ceiling — its loop is already bounded by the\n * entries actually present.\n *\n * So {@link INFER_DEPTH_LIMIT} is the ceiling as well as the default, and\n * `limits.depth` narrows the walk rather than widening it. One bound, and the same\n * answer on every host.\n *\n * @param value - The candidate depth budget\n * @returns A finite non-negative integer no greater than `INFER_DEPTH_LIMIT`\n *\n * @example\n * ```ts\n * sanitizeDepth(4) // 4\n * sanitizeDepth(1e9) // 32\n * ```\n */\nexport function sanitizeDepth(value: number | undefined): number {\n\treturn INTRINSICS.min(sanitizeBudget(value, INFER_DEPTH_LIMIT), INFER_DEPTH_LIMIT)\n}\n\n// === Reporting\n\n/**\n * Renders an unknown value as a short, safe, TOTAL string for a {@link Fault}'s\n * `received` field.\n *\n * @remarks\n * A primitive renders as printable text: a string retains its quoted JSON\n * representation, while a narrowed symbol renders through intrinsic `String`\n * and receives the same escaping without outer quotes. A string of at most\n * {@link PREVIEW_LIMIT} code units takes its answer from one whole-string\n * encode when that encode fits the same limit, and the length predicate\n * deciding it is exact rather than approximate. Every other string and every\n * symbol renders through one bounded indexed encoder that appends only\n * complete escaped code-point tokens within {@link PREVIEW_LIMIT}; clipping\n * therefore never retrieves the mutable string iterator or splits an\n * escape/surrogate pair before its trailing `…`, and enormous primitive text\n * is not fully traversed. A number / boolean / bigint renders through `String`;\n * `null` and `undefined` render as their own name. An array renders as\n * `'array'`. Every other host — a plain object, a function, a class instance,\n * a `Map` — is NEVER traversed or stringified; it renders as its bare\n * `typeof` tag (`'object'` / `'function'`).\n *\n * The indexed encoder appends every token and closes with the quote exactly\n * when the escaped inner length is at most `PREVIEW_LIMIT - 2`, which is\n * character for character what one `JSON.stringify` call returns. At an inner\n * length of `PREVIEW_LIMIT - 1` the indexed encoder appends every token and\n * closes with `…` instead, while one `JSON.stringify` call over that same\n * string measures `PREVIEW_LIMIT + 1` — so the predicate refuses that string\n * and every longer one, and each of them renders through the indexed encoder.\n * Escaping never shrinks text, so the leading `source.length` gate admits\n * every string the predicate could accept while keeping enormous primitive\n * text out of the whole-string encode. A symbol renders through the indexed\n * encoder because its unquoted text is not what a `JSON.stringify` call\n * returns.\n *\n * @param value - The value to preview\n * @returns A short descriptive string, always safe to embed in a diagnostic\n *\n * @example\n * ```ts\n * preview('hi') // '\"hi\"'\n * preview(42) // '42'\n * preview(null) // 'null'\n * preview({ a: 1 }) // 'object'\n * preview([1, 2, 3]) // 'array'\n * ```\n */\nexport function preview(value: unknown): string {\n\tif (value === null) return 'null'\n\tif (value === undefined) return 'undefined'\n\tif (isString(value) || isSymbol(value)) {\n\t\tconst quoted = isString(value)\n\t\tconst source = INTRINSICS.text(value)\n\t\tif (quoted && source.length <= PREVIEW_LIMIT) {\n\t\t\tconst whole = INTRINSICS.stringify(source)\n\t\t\tif (whole.length <= PREVIEW_LIMIT) return whole\n\t\t}\n\t\tconst parts = previewParts(source, 0, PREVIEW_LIMIT - (quoted ? 1 : 0), quoted)\n\t\tconst body: string = INTRINSICS.reflect.apply(INTRINSICS.join, parts, [''])\n\t\treturn quoted ? `\"${body}` : body\n\t}\n\tif (isNumber(value) || isBoolean(value)) return INTRINSICS.text(value)\n\tif (isBigInt(value)) return `${value}n`\n\tif (isArray(value)) return 'array'\n\treturn typeof value\n}\n\n/**\n * Builds the refinement faults a string value has against a {@link StringShape}.\n *\n * @remarks\n * The single source of the string refinement report, shared by\n * `compileReporter` and `compileAuditor`. The two doors differ only in how they\n * OBTAIN the string — the reporter coerces through `parseString`, the auditor\n * demands a primitive string — and share every constraint afterwards through\n * this helper, so a constraint cannot drift between them.\n * Faults come out in declaration order — `date`, then `min`, then `max`, then\n * `pattern` — because a report is read top to bottom and its order is public.\n * `expected` is `'date'` on a date string shape and `'string'` otherwise, as\n * {@link buildNumberFaults} names `'integer'`.\n *\n * The declaration's pattern is applied through an OWNED stateless rebuild\n * ({@link readPattern}) asked through {@link matchesPattern}, so the shape's own\n * pattern never moves a caller's `lastIndex` and no caller-writable member\n * decides whether the value matched. The rebuild is stateless precisely because\n * `g` and `y` are stripped, so one rebuilt pattern answers identically for every\n * value and every call — which is what lets a compiled door build it once\n * ({@link ownPattern}) and hand it down through `pattern` instead of rebuilding\n * it on each answer. The `limit` text is read from the applied rebuild, so it\n * names the pattern that decided the match. Left to rebuild, the helper asks\n * the shape's `pattern` accessor once for the presence test that decides\n * whether a pattern was declared at all, and once more for the rebuild that\n * decides the match and names the `limit` when one was.\n *\n * The whole body reads the caller's SHAPE, so it runs through the same\n * {@link readValue} boundary {@link shapeToKind} uses and refuses an\n * out-of-domain declaration with the same diagnostic. The compiled doors gate a\n * non-`RegExp` `pattern` and a non-finite bound long before this helper sees\n * them, so the package's own path never arrives here off-domain — but the door\n * is PUBLISHED, and a shape a `StringShape` annotation merely vouched for\n * (parsed out of a document, say) reaches it unchecked. Publishing the host's\n * own `TypeError` from such a shape would falsify the promise this module makes\n * for every one of its doors.\n *\n * @param shape - The string shape whose refinements are checked\n * @param value - The already-obtained string to check\n * @param path - The path every produced fault is rooted at\n * @param pattern - The one-time stateless rebuild that decides the pattern\n * refinement. Must be a {@link readPattern} result for this\n * shape's own pattern; supplied, it decides the match, the\n * `limit` text, and whether a pattern fault is reported at\n * all, and `shape.pattern` is not read. A pattern carrying `g`\n * or `y` moves the caller's `lastIndex` and makes repeated\n * answers for one value disagree. Default: rebuilt from\n * `shape.pattern` on every call, when the shape declares one\n * @returns A fresh array of faults, empty when the value satisfies every refinement\n * @throws {ContractError} When the shape's refinement fields cannot be read\n *\n * @example\n * ```ts\n * buildStringFaults({ category: 'string', min: 3 }, 'ab', [])\n * // [{ reason: 'constraint', path: [], expected: 'string', constraint: 'min', limit: 3, received: '\"ab\"' }]\n * ```\n */\nexport function buildStringFaults(\n\tshape: StringShape,\n\tvalue: string,\n\tpath: readonly string[],\n\tpattern?: RegExp,\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst dated = INTRINSICS.own(shape, 'date') && shape.date === true\n\t\t\tconst expected: FaultKind = dated ? 'date' : 'string'\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (dated && !matchesCalendarDate(value)) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'date',\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'min') &&\n\t\t\t\tshape.min !== undefined &&\n\t\t\t\t!matchesStringLength(value, shape.min, undefined)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'max') &&\n\t\t\t\tshape.max !== undefined &&\n\t\t\t\t!matchesStringLength(value, undefined, shape.max)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The bounds are read from the shape on every call because a number is\n\t\t\t// what the fault carries. The pattern is not: rebuilding it allocates a\n\t\t\t// `RegExp` per answer, so a caller holding the same shape for the life of\n\t\t\t// a compiled door supplies the rebuild once and this reads it instead.\n\t\t\t// Whatever arrives is what decides the match and names the fault's `limit`,\n\t\t\t// so a rebuild of this shape's own pattern reports exactly what the\n\t\t\t// shape's own read would: `readPattern` preserves `source` exactly.\n\t\t\tconst stateless =\n\t\t\t\tpattern ??\n\t\t\t\t(!INTRINSICS.own(shape, 'pattern') || shape.pattern === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: readPattern(shape.pattern))\n\t\t\tif (stateless !== undefined && !matchesPattern(stateless, value)) {\n\t\t\t\tconst limit = readPatternSource(stateless)\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'pattern',\n\t\t\t\t\t...(limit === undefined ? {} : { limit }),\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildStringFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Builds the refinement faults a number value has against a {@link NumberShape}.\n *\n * @remarks\n * The numeric sibling of {@link buildStringFaults}, shared by the same two\n * doors for the same reason. `expected` is the shape's own kind — `'integer'`\n * when `integer: true`, otherwise `'number'` — so a caller reading the report\n * sees the declaration's vocabulary rather than the value's. Order is\n * `integer`, then `min`, then `max`. It refuses an unreadable shape through the\n * same boundary and for the same reason {@link buildStringFaults} does.\n *\n * @param shape - The number shape whose refinements are checked\n * @param value - The already-obtained number to check\n * @param path - The path every produced fault is rooted at\n * @returns A fresh array of faults, empty when the value satisfies every refinement\n * @throws {ContractError} When the shape's refinement fields cannot be read\n *\n * @example\n * ```ts\n * buildNumberFaults({ category: 'number', integer: true }, 1.5, [])\n * // [{ reason: 'constraint', path: [], expected: 'integer', constraint: 'integer', received: '1.5' }]\n * ```\n */\nexport function buildNumberFaults(\n\tshape: NumberShape,\n\tvalue: number,\n\tpath: readonly string[],\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst expected: FaultKind =\n\t\t\t\tINTRINSICS.own(shape, 'integer') && shape.integer === true ? 'integer' : 'number'\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(shape, 'integer') &&\n\t\t\t\tshape.integer === true &&\n\t\t\t\t!INTRINSICS.integer(value)\n\t\t\t) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'integer',\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'min') && shape.min !== undefined && value < shape.min) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'max') && shape.max !== undefined && value > shape.max) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected,\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildNumberFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Builds the length faults an array has against an {@link ArrayShape}.\n *\n * @remarks\n * Takes the LENGTH rather than the array, because both doors have already read\n * their entries through {@link readArrayEntries} and must report the length that\n * read observed rather than re-asking the caller's value for it. `received` is\n * that count rendered through the captured `String`, matching the other length\n * diagnostics in the package. Order is `min`, then `max`. It refuses an\n * unreadable shape through the same boundary and for the same reason\n * {@link buildStringFaults} does.\n *\n * @param shape - The array shape whose bounds are checked\n * @param length - The entry count the door already observed\n * @param path - The path every produced fault is rooted at\n * @returns A fresh array of faults, empty when the length satisfies both bounds\n * @throws {ContractError} When the shape's bound fields cannot be read\n *\n * @example\n * ```ts\n * buildArrayFaults({ category: 'array', items: { category: 'string' }, min: 2 }, 1, [])\n * // [{ reason: 'constraint', path: [], expected: 'array', constraint: 'min', limit: 2, received: '1' }]\n * ```\n */\nexport function buildArrayFaults(\n\tshape: ArrayShape,\n\tlength: number,\n\tpath: readonly string[],\n): readonly Fault[] {\n\treturn readValue(\n\t\t() => {\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (INTRINSICS.own(shape, 'min') && shape.min !== undefined && length < shape.min) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'array',\n\t\t\t\t\tconstraint: 'min',\n\t\t\t\t\tlimit: shape.min,\n\t\t\t\t\treceived: INTRINSICS.text(length),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (INTRINSICS.own(shape, 'max') && shape.max !== undefined && length > shape.max) {\n\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\treason: 'constraint',\n\t\t\t\t\tpath,\n\t\t\t\t\texpected: 'array',\n\t\t\t\t\tconstraint: 'max',\n\t\t\t\t\tlimit: shape.max,\n\t\t\t\t\treceived: INTRINSICS.text(length),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn faults\n\t\t},\n\t\t'buildArrayFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Selects the report of the variant that came closest to matching.\n *\n * @remarks\n * The union summary both diagnostic doors append their closest variant's faults\n * to. \"Closest\" is the SHORTEST report, and an earlier variant wins a tie, so a\n * union's diagnostic follows declaration order rather than whichever variant a\n * later comparison happened to visit. The winning report is returned BY\n * IDENTITY, never copied, so the summary carries the exact fault objects the\n * variant produced. No report at all — a union whose every variant slot was\n * unreadable — yields a frozen empty collection rather than `undefined`, so the\n * caller appends nothing instead of branching.\n *\n * The scan is an indexed read of arrays this package built, so neither the\n * choice of variant nor the length comparison dispatches through a member a\n * caller can replace.\n *\n * @param reports - One report per variant, in declaration order\n * @returns The first shortest report, or a frozen empty collection when there are none\n *\n * @example\n * ```ts\n * selectClosestFaults([[fault, fault], [fault]]) // the second report\n * selectClosestFaults([]) // []\n * ```\n */\nexport function selectClosestFaults<T extends AuditFault>(\n\treports: ReadonlyArray<readonly T[]>,\n): readonly T[] {\n\tconst closest: readonly T[] | undefined = INTRINSICS.reflect.apply(\n\t\tINTRINSICS.reduce,\n\t\titerateIndices(() => reports.length),\n\t\t[\n\t\t\t(best: readonly T[] | undefined, index: number) => {\n\t\t\t\tconst report = reports[index]\n\t\t\t\treturn report !== undefined && (best === undefined || report.length < best.length)\n\t\t\t\t\t? report\n\t\t\t\t\t: best\n\t\t\t},\n\t\t\tundefined,\n\t\t],\n\t)\n\treturn closest ?? INTRINSICS.freeze([])\n}\n\n/**\n * Projects a {@link ContractShape} to the {@link FaultKind} it describes.\n *\n * @remarks\n * A structural mapping used by {@link compileReporter} to fill a `Fault`'s\n * `expected` field and by {@link compileAuditor} to fill an `AuditFault`'s:\n * most shapes map to their own `category` (`numberShape` maps to\n * `'integer'` when `integer: true`, else `'number'`, and `stringShape` maps to\n * `'date'` when `date: true`, else `'string'`); `optionalShape` /\n * `nullableShape` project through to their inner shape's kind, and `rawShape`\n * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.\n *\n * A hand-authored node carrying an unrecognized discriminant is REFUSED rather\n * than answered out of type, which keeps the declared non-optional\n * {@link FaultKind} return type true at a public export; every other door in\n * this module refuses out-of-domain input, so this one does too.\n *\n * @param shape - The shape to project\n * @returns The shape's {@link FaultKind}\n * @throws {ContractError} When the node carries no recognized shape discriminant\n *\n * @example\n * ```ts\n * shapeToKind(stringShape()) // 'string'\n * shapeToKind(integerShape()) // 'integer'\n * shapeToKind(optionalShape(nullShape())) // 'null'\n * ```\n */\nexport function shapeToKind(shape: ContractShape): FaultKind {\n\treturn readValue(\n\t\t() => {\n\t\t\tswitch (shape.category) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn INTRINSICS.own(shape, 'date') && shape.date === true ? 'date' : 'string'\n\t\t\t\tcase 'number':\n\t\t\t\t\treturn INTRINSICS.own(shape, 'integer') && shape.integer === true ? 'integer' : 'number'\n\t\t\t\tcase 'boolean':\n\t\t\t\t\treturn 'boolean'\n\t\t\t\tcase 'null':\n\t\t\t\t\treturn 'null'\n\t\t\t\tcase 'literal':\n\t\t\t\t\treturn 'literal'\n\t\t\t\tcase 'array':\n\t\t\t\t\treturn 'array'\n\t\t\t\tcase 'object':\n\t\t\t\t\treturn 'object'\n\t\t\t\tcase 'union':\n\t\t\t\t\treturn 'union'\n\t\t\t\tcase 'json':\n\t\t\t\t\treturn 'json'\n\t\t\t\tcase 'shape':\n\t\t\t\t\treturn 'shape'\n\t\t\t\tcase 'optional':\n\t\t\t\t\treturn shapeToKind(shape.inner)\n\t\t\t\tcase 'nullable':\n\t\t\t\t\treturn shapeToKind(shape.inner)\n\t\t\t\tcase 'raw':\n\t\t\t\t\treturn 'json'\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new INTRINSICS.error('shapeToKind: unrecognized shape discriminant')\n\t\t\t}\n\t\t},\n\t\t'shapeToKind',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Refuses a validated declaration whose compiled expansion exceeds\n * {@link COMPILE_NODE_LIMIT}.\n *\n * @remarks\n * The compilers' emitted-node bound, written once because two boundaries apply\n * it over a {@link ShapeValidatorInterface.expansion} count: the eager\n * {@link validateShape} function and the lazy {@link ContractCompiler}\n * preparation. The refusal keeps `validateShape`'s name because that gate\n * OWNS the rule and its exact diagnostic is public API — the same reason\n * `ShapeCloner` publishes the gate's depth wording rather than inventing a\n * second vocabulary for one rule. Two constructions of one refusal are two\n * messages waiting to drift apart.\n *\n * @param expansion - The node count one successful validation measured, or\n * `undefined` when no pass measured one\n * @returns Nothing when the count is within the limit\n * @throws {ContractError} When the count exceeds {@link COMPILE_NODE_LIMIT}, or when no successful pass measured one\n *\n * @example\n * ```ts\n * const validator = new ShapeValidator(shape)\n * validator.validate()\n * refuseExpansion(validator.expansion)\n * ```\n */\nexport function refuseExpansion(expansion: number | undefined): void {\n\t// An absent measurement is not a small one. Both boundaries call this\n\t// immediately after a successful pass, so `undefined` here means the pass that\n\t// was supposed to measure the graph did not — and letting that through would\n\t// publish the compilers' node bound as satisfied by a count nobody took.\n\tif (expansion === undefined) {\n\t\tthrow new ContractError('validateShape: a validated shape measured no expansion', {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: [] },\n\t\t})\n\t}\n\tif (expansion <= COMPILE_NODE_LIMIT) return\n\tthrow new ContractError('validateShape: a shape expands past the compilation node limit', {\n\t\tcode: 'expansion',\n\t\tcontext: {\n\t\t\tpath: [],\n\t\t\tlimit: COMPILE_NODE_LIMIT,\n\t\t\treceived: INTRINSICS.text(expansion),\n\t\t},\n\t})\n}\n\n/**\n * Encodes ordered members, stopping before the first unencodable member.\n *\n * @param members - The owned members in source order\n * @param keys - Object keys, or undefined for an array\n * @param encodings - Encodings already computed for child containers\n * @returns The encoded prefix\n *\n * @example\n * ```ts\n * Array.from(encodeParts([1, undefined, 2], undefined, new WeakMap())) // ['1']\n * ```\n */\nexport function* encodeParts(\n\tmembers: readonly unknown[],\n\tkeys: readonly string[] | undefined,\n\tencodings: WeakMap<object, string>,\n): Generator<string, void, unknown> {\n\tfor (const index of iterateIndices(() => members.length)) {\n\t\tconst member = members[index]\n\t\tconst part = isObject(member)\n\t\t\t? (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [member]) ?? encodeLeaf(member))\n\t\t\t: encodeLeaf(member)\n\t\tif (part === undefined) return\n\t\tconst key = keys?.[index]\n\t\tyield key === undefined ? part : `${INTRINSICS.stringify(key)}:${part}`\n\t}\n}\n\n/**\n * Builds bounded escaped preview parts without splitting a surrogate pair.\n *\n * @param source - The source text\n * @param index - The next UTF-16 offset\n * @param capacity - The unused preview width\n * @param quoted - Whether the final part closes a string quote\n * @returns The escaped parts with their closing quote or truncation mark\n *\n * @example\n * ```ts\n * previewParts('abc', 0, 2, false) // ['a', 'b', '…']\n * ```\n */\nexport function previewParts(\n\tsource: string,\n\tindex: number,\n\tcapacity: number,\n\tquoted: boolean,\n): readonly string[] {\n\tconst available = INTRINSICS.min(capacity, PREVIEW_LIMIT)\n\tconst first = source[index]\n\tif (index >= source.length || first === undefined) {\n\t\treturn quoted ? [available > 0 ? '\"' : '…'] : []\n\t}\n\tconst second = index + 1 < source.length ? source[index + 1] : undefined\n\tconst paired =\n\t\tfirst >= '\\ud800' &&\n\t\tfirst <= '\\udbff' &&\n\t\tsecond !== undefined &&\n\t\tsecond >= '\\udc00' &&\n\t\tsecond <= '\\udfff'\n\tconst character = paired ? `${first}${second}` : first\n\tconst encoded = INTRINSICS.stringify(character)\n\tconst length = encoded.length - 2\n\tif (length > available) return ['…']\n\tconst characters = INTRINSICS.from(\n\t\titerateIndices(() => length),\n\t\t(offset) => encoded[offset + 1],\n\t)\n\tconst token: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\tconst tail = previewParts(source, index + (paired ? 2 : 1), available - length, quoted)\n\treturn INTRINSICS.from(\n\t\titerateIndices(() => tail.length + 1),\n\t\t(offset) => (offset === 0 ? token : (tail[offset - 1] ?? '')),\n\t)\n}\n\n/**\n * Builds a null-prototype lookup from names to their last index.\n *\n * @param names - Names in declaration order\n * @returns The indexed lookup\n *\n * @example\n * ```ts\n * buildPositions(['id', '__proto__']).id // 0\n * ```\n */\nexport function buildPositions(names: readonly string[]): Readonly<Record<string, number>> {\n\tconst pairs = INTRINSICS.from(\n\t\titerateIndices(() => names.length),\n\t\t(index) => [names[index], index],\n\t)\n\treturn INTRINSICS.rebase(\n\t\tINTRINSICS.record<number>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t}),\n\t\tnull,\n\t)\n}\n\n/**\n * Derives the bit mask of names present in an indexed lookup.\n *\n * @param names - Names to observe in order\n * @param positions - The bit position of each declared name\n * @returns The combined signed 32-bit mask\n *\n * @example\n * ```ts\n * readPresence(['id'], buildPositions(['id', 'name'])) // 1\n * ```\n */\nexport function readPresence(\n\tnames: readonly string[],\n\tpositions: Readonly<Record<string, number>>,\n): number {\n\treturn INTRINSICS.reflect.apply(\n\t\tINTRINSICS.reduce,\n\t\titerateIndices(() => names.length),\n\t\t[\n\t\t\t(mask: number, index: number) => {\n\t\t\t\tconst name = names[index]\n\t\t\t\tif (name === undefined || !INTRINSICS.own(positions, name)) return mask\n\t\t\t\tconst position = positions[name]\n\t\t\t\treturn position === undefined ? mask : mask | (1 << position)\n\t\t\t},\n\t\t\t0,\n\t\t],\n\t)\n}\n\n// Pin the iterator protocol before any caller can reach these exported generators.\nfor (const generator of [iterateIndices, encodeParts]) {\n\tfor (const key of ['next', 'return', 'throw', Symbol.iterator]) {\n\t\tINTRINSICS.define(generator.prototype, key, {\n\t\t\tvalue: INTRINSICS.reflect.read(generator.prototype, key),\n\t\t})\n\t}\n\tINTRINSICS.freeze(generator.prototype)\n\tINTRINSICS.freeze(generator)\n}\n\n/**\n * Extracts a fault's path as its segments, reading a string path as one segment.\n *\n * @param fault - The fault to read\n * @returns The path's segments, empty at the root\n *\n * @example\n * ```ts\n * import { extractPath } from '@orkestrel/contract'\n *\n * extractPath({ reason: 'extra', path: ['page', 'typo'] }) // ['page', 'typo']\n * ```\n */\nexport function extractPath(fault: AuditFault): readonly string[] {\n\treturn isString(fault.path) ? [fault.path] : fault.path\n}\n\n/**\n * Extracts a schema's forms: the schema itself, then its union arms, so a read looks\n * through a nullable the same way everywhere.\n *\n * @param schema - The schema to read, or `undefined` where none was found\n * @returns The forms, empty when there is no schema\n *\n * @example\n * ```ts\n * import { extractForms } from '@orkestrel/contract'\n *\n * const object = { type: 'object' } as const\n * extractForms({ anyOf: [object] }) // [{ anyOf: [object] }, object]\n * ```\n */\nexport function extractForms(schema: JSONSchema | undefined): readonly JSONSchema[] {\n\tif (schema === undefined) return []\n\tconst anyOf = INTRINSICS.own(schema, 'anyOf') ? schema.anyOf : undefined\n\tconst oneOf = INTRINSICS.own(schema, 'oneOf') ? schema.oneOf : undefined\n\treturn [schema, ...(anyOf ?? oneOf ?? [])]\n}\n\n/**\n * Extracts the part of a schema a path reaches, through properties, array items, record values,\n * and the arms of a union.\n *\n * @remarks\n * Each path segment takes one step, so a union that nests itself cannot hold the walk. Only a\n * schema's own `properties` keys match, so `constructor` reaches nothing. The walk keeps every\n * matching union declaration until the end; differing declarations yield no schema. Independently\n * built declarations agree when their canonical JSON encodings agree.\n *\n * @param schema - The schema to walk\n * @param path - The segments to follow\n * @returns The schema at that path, or `undefined` where no declaration or no agreement exists\n *\n * @example\n * ```ts\n * import { extractSchema } from '@orkestrel/contract'\n *\n * const schema = { type: 'object', properties: { limit: { type: 'number' } } } as const\n * extractSchema(schema, ['limit']) // { type: 'number' }\n * ```\n */\nexport function extractSchema(schema: JSONSchema, path: readonly string[]): JSONSchema | undefined {\n\tconst nodes = path.reduce<readonly JSONSchema[]>(\n\t\t(parents, key) =>\n\t\t\tArray.from(\n\t\t\t\tnew Set(\n\t\t\t\t\tparents\n\t\t\t\t\t\t.flatMap((node) => extractForms(node))\n\t\t\t\t\t\t.map((form) => {\n\t\t\t\t\t\t\tconst properties = INTRINSICS.own(form, 'properties') ? form.properties : undefined\n\t\t\t\t\t\t\tconst additional = INTRINSICS.own(form, 'additionalProperties')\n\t\t\t\t\t\t\t\t? form.additionalProperties\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\treturn properties !== undefined && INTRINSICS.own(properties, key)\n\t\t\t\t\t\t\t\t? properties[key]\n\t\t\t\t\t\t\t\t: isRecord(additional)\n\t\t\t\t\t\t\t\t\t? additional\n\t\t\t\t\t\t\t\t\t: INTRINSICS.own(form, 'items')\n\t\t\t\t\t\t\t\t\t\t? form.items\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((child) => child !== undefined),\n\t\t\t\t),\n\t\t\t),\n\t\t[schema],\n\t)\n\tconst first = nodes[0]\n\tif (nodes.length < 2) return first\n\tconst encoded = canonicalStringify(first)\n\treturn encoded !== undefined && nodes.every((node) => canonicalStringify(node) === encoded)\n\t\t? first\n\t\t: undefined\n}\n\n/**\n * Renders a path as text, encoding what a caller could have sent and eliding the middle of a long\n * one.\n *\n * @remarks\n * A segment that is not a plain identifier is JSON-encoded and length-capped, because a key the\n * caller sent is untrusted text. A path of more than four segments past 120 characters keeps its\n * first segment and its last three.\n *\n * @param path - The segments to render\n * @returns The segments joined with `.`, empty at the root\n *\n * @example\n * ```ts\n * import { renderPath } from '@orkestrel/contract'\n *\n * renderPath(['rows', '0', 'a b']) // 'rows.0.\"a b\"'\n * ```\n */\nexport function renderPath(path: readonly string[]): string {\n\tconst segments = path.map((segment) =>\n\t\t/^[\\w$-]{1,64}$/u.test(segment) ? segment : preview(segment),\n\t)\n\tconst text = segments.join('.')\n\treturn segments.length <= 4 || text.length <= 120\n\t\t? text\n\t\t: [...segments.slice(0, 1), '…', ...segments.slice(-3)].join('.')\n}\n\n/**\n * Renders a list as text, naming at most `FAULT_LIST_LIMIT` of its entries and counting the rest.\n *\n * @param entries - The rendered entries\n * @returns The entries joined with `, `\n *\n * @example\n * ```ts\n * import { renderList } from '@orkestrel/contract'\n *\n * renderList(['city', 'units']) // 'city, units'\n * ```\n */\nexport function renderList(entries: readonly string[]): string {\n\tconst listed = entries.slice(0, FAULT_LIST_LIMIT).join(', ')\n\treturn entries.length > FAULT_LIST_LIMIT\n\t\t? `${listed} and ${String(entries.length - FAULT_LIST_LIMIT)} more`\n\t\t: listed\n}\n\n/**\n * Renders a schema as a short summary of what to send, such as `{\"city\": string, \"note\"?: string}`.\n *\n * @remarks\n * An object lists its required keys first and marks the rest with `?`, at most `FAULT_LIST_LIMIT`\n * of them. A leaf or array keeps its numeric bounds, pattern, and format, a union joins its forms with ` | `,\n * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and\n * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past\n * `room` is cut and closes with `…`. A type word outside JSON Schema's vocabulary is encoded.\n *\n * @param schema - The schema to summarize\n * @param room - The characters the summary can take. Default: `FAULT_SCHEMA_LIMIT`\n * @returns The summary\n *\n * @example\n * ```ts\n * import { renderForm } from '@orkestrel/contract'\n *\n * renderForm({ type: 'object', properties: { zip: { type: 'number' } }, required: ['zip'] }) // '{\"zip\": number}'\n * ```\n */\nexport function renderForm(schema: JSONSchema, room: number = FAULT_SCHEMA_LIMIT): string {\n\tconst deep = room >= 16\n\tconst inner = Math.floor(room / 2)\n\tconst anyOf = INTRINSICS.own(schema, 'anyOf') ? schema.anyOf : undefined\n\tconst oneOf = INTRINSICS.own(schema, 'oneOf') ? schema.oneOf : undefined\n\tconst forms = anyOf ?? oneOf\n\tconst required = (INTRINSICS.own(schema, 'required') ? schema.required : undefined) ?? []\n\tconst entries = Object.entries(\n\t\t(INTRINSICS.own(schema, 'properties') ? schema.properties : undefined) ?? {},\n\t)\n\tconst type = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\tconst enumeration = INTRINSICS.own(schema, 'enum') ? schema.enum : undefined\n\tconst additional = INTRINSICS.own(schema, 'additionalProperties')\n\t\t? schema.additionalProperties\n\t\t: undefined\n\tconst listed = (deep ? entries : [])\n\t\t.toSorted(\n\t\t\t([left], [right]) => Number(required.includes(right)) - Number(required.includes(left)),\n\t\t)\n\t\t.slice(0, FAULT_LIST_LIMIT)\n\t\t.map(\n\t\t\t([key, child]) =>\n\t\t\t\t`${preview(key)}${required.includes(key) ? '' : '?'}: ${renderForm(child, inner)}`,\n\t\t)\n\tconst left = entries.length - listed.length\n\tconst child =\n\t\ttype === 'array'\n\t\t\t? INTRINSICS.own(schema, 'items')\n\t\t\t\t? schema.items\n\t\t\t\t: undefined\n\t\t\t: isRecord(additional)\n\t\t\t\t? additional\n\t\t\t\t: undefined\n\tconst bounds = Object.entries(schema)\n\t\t.filter(([key]) =>\n\t\t\t[\n\t\t\t\t'minLength',\n\t\t\t\t'maxLength',\n\t\t\t\t'minimum',\n\t\t\t\t'maximum',\n\t\t\t\t'minItems',\n\t\t\t\t'maxItems',\n\t\t\t\t'pattern',\n\t\t\t\t'format',\n\t\t\t].includes(key),\n\t\t)\n\t\t.map(([key, value]) => `${key} ${preview(value)}`)\n\tconst text =\n\t\tforms !== undefined\n\t\t\t? deep\n\t\t\t\t? forms.map((form) => renderForm(form, inner)).join(' | ')\n\t\t\t\t: 'any'\n\t\t\t: enumeration !== undefined\n\t\t\t\t? enumeration.map((value) => preview(value)).join(' | ')\n\t\t\t\t: listed.length > 0\n\t\t\t\t\t? `{${[...listed, ...(left > 0 ? [`and ${String(left)} more`] : [])].join(', ')}}`\n\t\t\t\t\t: [\n\t\t\t\t\t\t\ttype === undefined\n\t\t\t\t\t\t\t\t? entries.length > 0\n\t\t\t\t\t\t\t\t\t? 'object'\n\t\t\t\t\t\t\t\t\t: 'any'\n\t\t\t\t\t\t\t\t: JSON_SCHEMA_TYPES.some((name) => name === type)\n\t\t\t\t\t\t\t\t\t? type\n\t\t\t\t\t\t\t\t\t: preview(type),\n\t\t\t\t\t\t\t...(deep && child !== undefined ? [` of ${renderForm(child, inner)}`] : []),\n\t\t\t\t\t\t\t...(bounds.length > 0 ? [` (${bounds.join(', ')})`] : []),\n\t\t\t\t\t\t].join('')\n\treturn truncateFaultText(text, room)\n}\n\n/**\n * Describes one fault as the line a caller corrects from, naming what to send where the schema\n * says.\n *\n * @remarks\n * Each line opens with the fault's path (or `value` at the root) and reason. An `extra` fault lists\n * its parent's keys only when the declaring arms agree. A literal names candidates only where\n * the declarations agree; lists are deduplicated and bounded. A received preview stays as written\n * within PREVIEW_LIMIT and without control or line-separator characters; otherwise it is encoded\n * through preview. Received, constraint, and limit details read only own fields. A `variant` or\n * `oneOf` fault says that the value matches none of the declared forms, or several where one must\n * match, and summarizes each form through `renderForm`. It names no fault of any one form, because\n * none of them holds for the others. Those summaries share half of `FAULT_TEXT_LIMIT`.\n *\n * @param fault - The fault to describe\n * @param schema - The compiled schema the fault's path reads\n * @returns The line, with no line break\n *\n * @example\n * ```ts\n * import { describeFaultLine } from '@orkestrel/contract'\n *\n * describeFaultLine({ reason: 'missing', path: ['left'], expected: 'number' }, {}) // 'left: missing; expected number'\n * ```\n */\nexport function describeFaultLine(fault: AuditFault, schema: JSONSchema): string {\n\tconst path = extractPath(fault)\n\tconst head = `${renderPath(path) || 'value'}: ${fault.reason}`\n\tif (fault.reason === 'extra') {\n\t\tconst declarations = extractForms(extractSchema(schema, path.slice(0, -1)))\n\t\t\t.filter((form) => INTRINSICS.own(form, 'properties') && form.properties !== undefined)\n\t\t\t.map((form) => Object.keys(form.properties ?? {}))\n\t\tconst first = declarations[0] ?? []\n\t\tconst keys = declarations.every(\n\t\t\t(declared) =>\n\t\t\t\tdeclared.length === first.length && declared.every((key) => first.includes(key)),\n\t\t)\n\t\t\t? first\n\t\t\t: []\n\t\treturn keys.length === 0\n\t\t\t? `${head}; this key is not declared, remove it`\n\t\t\t: `${head}; this key is not declared, remove it or use a declared key: ${renderList(keys.map((key) => renderPath([key])))}`\n\t}\n\tconst node = extractSchema(schema, path)\n\tconst anyOf = node !== undefined && INTRINSICS.own(node, 'anyOf') ? node.anyOf : undefined\n\tconst oneOf = node !== undefined && INTRINSICS.own(node, 'oneOf') ? node.oneOf : undefined\n\tif (fault.reason === 'variant' || fault.reason === 'oneOf') {\n\t\tconst count = fault.reason === 'variant' ? fault.variants : oneOf?.length\n\t\tconst forms = count === undefined ? 'the declared forms' : `the ${String(count)} declared forms`\n\t\tconst claim =\n\t\t\tfault.reason === 'oneOf' && fault.matched > 0\n\t\t\t\t? `the value matches ${String(fault.matched)} of ${forms} and must match exactly one`\n\t\t\t\t: `the value matches none of ${forms}`\n\t\tconst declared = anyOf ?? oneOf ?? []\n\t\tconst shown = declared.slice(0, FAULT_LIST_LIMIT)\n\t\tconst room = Math.min(\n\t\t\tFAULT_SCHEMA_LIMIT,\n\t\t\tMath.floor(FAULT_TEXT_LIMIT / 2 / Math.max(shown.length, 1)),\n\t\t)\n\t\tconst more = declared.length - shown.length\n\t\tconst summary =\n\t\t\tshown.length === 0\n\t\t\t\t? ''\n\t\t\t\t: `, one of: ${shown.map((form) => renderForm(form, room)).join(' or ')}${more > 0 ? ` and ${String(more)} more` : ''}`\n\t\treturn `${head}; ${claim}${fault.key === undefined ? '' : `; discriminator ${preview(fault.key)} expects ${renderList((fault.expected ?? []).map((value) => preview(value)))}`}; send it exactly as the schema declares${summary}`\n\t}\n\tconst candidates =\n\t\tfault.expected === 'literal'\n\t\t\t? extractForms(node).flatMap((form) => [\n\t\t\t\t\t...((INTRINSICS.own(form, 'enum') ? form.enum : undefined) ?? []),\n\t\t\t\t\t...(INTRINSICS.own(form, 'type') && form.type === 'null' ? [null] : []),\n\t\t\t\t])\n\t\t\t: []\n\tconst description =\n\t\tnode !== undefined && INTRINSICS.own(node, 'description') ? node.description : undefined\n\tconst received =\n\t\t'received' in fault && INTRINSICS.own(fault, 'received') ? fault.received : undefined\n\tconst shown =\n\t\treceived !== undefined &&\n\t\treceived.length <= PREVIEW_LIMIT &&\n\t\t!/[\\p{Cc}\\p{Zl}\\p{Zp}]/u.test(received)\n\t\t\t? received\n\t\t\t: preview(received)\n\treturn [\n\t\thead,\n\t\t`expected ${fault.expected}`,\n\t\t...(received !== undefined ? [`received ${shown}`] : []),\n\t\t...('constraint' in fault && INTRINSICS.own(fault, 'constraint')\n\t\t\t? [`constraint ${fault.constraint}`]\n\t\t\t: []),\n\t\t...('limit' in fault && INTRINSICS.own(fault, 'limit') && fault.limit !== undefined\n\t\t\t? [`limit ${preview(fault.limit)}`]\n\t\t\t: []),\n\t\t...(description === undefined ? [] : [`description ${preview(description)}`]),\n\t\t...(candidates.length > 0\n\t\t\t? [`send one of ${renderList(Array.from(new Set(candidates), (value) => preview(value)))}`]\n\t\t\t: []),\n\t].join('; ')\n}\n","import type { JSONClonerInterface, JSONRecord, JSONValue, Result } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\titerateIndices,\n\tadmitVisited,\n\tattempt,\n\tfailure,\n\tcollectMembers,\n\tisFailure,\n\tisSuccess,\n\tmatchesMember,\n\tmatchesVisited,\n\tomitVisited,\n\tpinMembers,\n} from './helpers.js'\nimport { isObject, isRecord } from './validators.js'\n\n/**\n * Owns the state of one exact JSON snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call performs one iterative descriptor walk and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned error. Nonredirectable terminal failure releases partial\n * traversal working state while retaining the source and exact error. Reentry\n * poisons the active operation and every later call with one shared cause-free\n * error.\n *\n * @param value - The unknown value to retain for cloning\n *\n * @example\n * ```ts\n * const source = { settings: { enabled: true } }\n * const cloner = new JSONCloner(source)\n * const clone = cloner.clone()\n * source.settings.enabled = false\n * cloner.clone() === clone // true\n * ```\n */\nexport class JSONCloner implements JSONClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// The active-path set is NOT an exception to that, and the sentence that made\n\t// it one was wrong: a redirected member there does not produce an owned\n\t// refusal, it removes the cycle test, and `WeakSet.prototype.has` answering\n\t// `false` made this class grow `#pending` without bound on a cyclic source —\n\t// no refusal, no return, and no instrument in the corpus able to report it.\n\t// Both sets are read through the captured visitation operations.\n\tstatic readonly #weakSet = WeakSet\n\t// The released state, shared by every cloner this class ever builds. `#fail`\n\t// assigns it in place of the working list, so a failed clone releases its\n\t// frames to collection instead of retaining an emptied array's capacity for\n\t// the instance's life. Sharing is safe because nothing writes to a released\n\t// list: every writer runs inside the walk, and a failed clone has already set\n\t// `#terminal`, which every later call answers from. The static block at the\n\t// foot of the class freezes it, so a write that did reach it fails loudly at\n\t// its own line rather than leaking one cloner's frame into every other\n\t// cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: JSONValue[] | JSONRecord\n\t\treadonly array: boolean\n\t\tentries: ReadonlyArray<readonly [key: string, value: unknown]> | undefined\n\t\tindex: number\n\t}> = []\n\treadonly #source: unknown\n\treadonly #owned: WeakSet<object>\n\treadonly #active: WeakSet<object>\n\t#pending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: JSONValue[] | JSONRecord\n\t\treadonly array: boolean\n\t\tentries: ReadonlyArray<readonly [key: string, value: unknown]> | undefined\n\t\tindex: number\n\t}>\n\t#poison: ContractError | undefined\n\t#terminal: Result<JSONValue, ContractError> | undefined\n\n\tconstructor(value: unknown) {\n\t\tthis.#source = value\n\t\tthis.#owned = new JSONCloner.#weakSet()\n\t\tthis.#active = new JSONCloner.#weakSet()\n\t\tthis.#pending = []\n\t\tthis.#poison = undefined\n\t\tthis.#terminal = undefined\n\t}\n\n\t/**\n\t * Clones the retained source into exact, deeply frozen JSON data.\n\t *\n\t * @param budget - Remaining nodes shared with an enclosing ownership operation\n\t * @returns The settled JSON snapshot\n\t * @throws {ContractError} When the source is inexact, cyclic, unreadable, or cloning is reentered\n\t */\n\tclone(budget: { left: number } = { left: CLONE_NODE_LIMIT }): JSONValue {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined) {\n\t\t\tif (isSuccess(terminal)) return terminal.value\n\t\t\tthrow terminal.error\n\t\t}\n\n\t\tconst poison = this.#poison\n\t\tif (poison !== undefined) {\n\t\t\tthis.#terminal = failure(poison)\n\t\t\tthrow poison\n\t\t}\n\n\t\tthis.#poison = this.#create('JSONCloner.clone: JSON cloning may not be reentered')\n\t\tconst outcome = attempt(() => this.#execute(budget))\n\t\tconst interruption = this.#terminal\n\t\tif (interruption !== undefined) {\n\t\t\tif (isSuccess(interruption)) return interruption.value\n\t\t\tthis.#fail(interruption.error)\n\t\t}\n\t\tif (isSuccess(outcome)) {\n\t\t\tthis.#terminal = outcome\n\t\t\treturn outcome.value\n\t\t}\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneJSONValue: failed to create an owned JSON snapshot')\n\t\tthis.#fail(error)\n\t}\n\n\t// Assignment only: the working list takes the class's shared frozen empty peer\n\t// rather than being truncated in place, so the abandoned frames are released\n\t// instead of held by an emptied array. `length` is a caller-reachable write on\n\t// the instance's own array; an assignment reaches no member at all.\n\t#fail(error: ContractError): never {\n\t\tthis.#terminal = failure(error)\n\t\tthis.#pending = JSONCloner.#emptyPending\n\t\tthrow error\n\t}\n\n\t#execute(budget: { left: number }): JSONValue {\n\t\tif (!INTRINSICS.safe(budget.left)) this.#refuse('cloneJSONValue: invalid node budget')\n\t\tbudget.left = INTRINSICS.min(budget.left, CLONE_NODE_LIMIT)\n\t\tconst root = this.#capture(this.#source, budget)\n\t\tthis.#drain(budget)\n\t\treturn root\n\t}\n\n\t#drain(budget: { left: number }): void {\n\t\twhile (this.#pending.length > 0) {\n\t\t\tconst frame = this.#pending[this.#pending.length - 1]\n\t\t\tif (frame === undefined) continue\n\n\t\t\tif (frame.entries === undefined) {\n\t\t\t\tframe.entries = frame.array\n\t\t\t\t\t? this.#captureArray(frame.source)\n\t\t\t\t\t: this.#captureRecord(frame.source)\n\t\t\t}\n\n\t\t\tconst entry = frame.entries[frame.index]\n\t\t\tif (entry === undefined) {\n\t\t\t\tINTRINSICS.freeze(frame.clone)\n\t\t\t\tomitVisited(this.#active, frame.source)\n\t\t\t\tthis.#pending.pop()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tframe.index += 1\n\n\t\t\tconst clone = this.#capture(entry[1], budget)\n\t\t\tINTRINSICS.define(frame.clone, entry[0], {\n\t\t\t\tvalue: clone,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t})\n\t\t}\n\t}\n\n\t#capture(value: unknown, budget: { left: number }): JSONValue {\n\t\t// Counted before the value is classified, so a leaf costs a tick too: the\n\t\t// blowup is in how many nodes the OUTPUT holds, and every produced node is\n\t\t// one unit of work and one unit of retained memory.\n\t\tbudget.left -= 1\n\t\tif (budget.left < 0) {\n\t\t\tthis.#refuse(\n\t\t\t\t`cloneJSONValue: snapshot exceeds the node limit ${CLONE_NODE_LIMIT}`,\n\t\t\t\tCLONE_NODE_LIMIT,\n\t\t\t)\n\t\t}\n\t\tif (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n\t\tif (typeof value === 'number') {\n\t\t\tif (INTRINSICS.finite(value)) return value\n\t\t\tthis.#refuse('cloneJSONValue: number is not finite')\n\t\t}\n\t\tif (typeof value === 'object') return this.#captureObject(value)\n\t\tthis.#refuse(\n\t\t\tthis.#pending.length === 0\n\t\t\t\t? 'cloneJSONValue: value is not JSON data'\n\t\t\t\t: 'cloneJSONValue: property is not JSON data',\n\t\t)\n\t}\n\n\t#captureObject(source: object): JSONValue[] | JSONRecord {\n\t\tif (matchesVisited(this.#active, source)) this.#refuse('cloneJSONValue: cycle detected')\n\t\tconst arrayOutcome = attempt(() => INTRINSICS.array(source))\n\t\tif (isFailure(arrayOutcome)) this.#refuse('cloneJSONValue: value brand could not be inspected')\n\t\tif (arrayOutcome.value) return this.#schedule(source, true)\n\t\tif (isRecord(source)) return this.#schedule(source, false)\n\t\tthis.#refuse('cloneJSONValue: object is not a plain record')\n\t}\n\n\t#schedule(source: object, array: boolean): JSONValue[] | JSONRecord {\n\t\tconst clone: JSONValue[] | JSONRecord = array ? [] : INTRINSICS.create(null)\n\t\tadmitVisited(this.#active, source)\n\t\tthis.#pending[this.#pending.length] = {\n\t\t\tsource,\n\t\t\tclone,\n\t\t\tarray,\n\t\t\tentries: undefined,\n\t\t\tindex: 0,\n\t\t}\n\t\treturn clone\n\t}\n\n\t#captureArray(source: object): ReadonlyArray<readonly [key: string, value: unknown]> {\n\t\tconst keysOutcome = attempt(() => INTRINSICS.reflect.members(source))\n\t\tif (isFailure(keysOutcome)) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst lengthOutcome = attempt(() => INTRINSICS.reflect.describe(source, 'length'))\n\t\tif (isFailure(lengthOutcome))\n\t\t\tthis.#refuse('cloneJSONValue: array length could not be inspected')\n\t\tconst lengthDescriptor = lengthOutcome.value\n\t\tif (\n\t\t\tlengthDescriptor === undefined ||\n\t\t\t!('value' in lengthDescriptor) ||\n\t\t\ttypeof lengthDescriptor.value !== 'number' ||\n\t\t\t!INTRINSICS.integer(lengthDescriptor.value) ||\n\t\t\tlengthDescriptor.value < 0 ||\n\t\t\tlengthDescriptor.value > 4_294_967_295 ||\n\t\t\tlengthDescriptor.enumerable !== false ||\n\t\t\tlengthDescriptor.configurable !== false\n\t\t) {\n\t\t\tthis.#refuse('cloneJSONValue: array is not intrinsic and dense')\n\t\t}\n\n\t\t// A collected vocabulary plus an exact count, not a shrinking `Set`:\n\t\t// exactness is the verdict this door PUBLISHES about the caller's array, and\n\t\t// `Set.prototype.delete` and the `size` accessor are two more members the\n\t\t// caller can answer for. `Reflect.ownKeys` never repeats a key — a proxy\n\t\t// trap returning duplicates is rejected by the host — so \"every index plus\n\t\t// `length`, and nothing else\" is exactly \"each is present, and the count\n\t\t// matches\".\n\t\tconst owned = collectMembers(keysOutcome.value)\n\t\tif (!matchesMember(owned, 'length')) {\n\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t}\n\t\tif (keysOutcome.value.length !== lengthDescriptor.value + 1) {\n\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t}\n\t\treturn INTRINSICS.from(\n\t\t\titerateIndices(() => lengthDescriptor.value),\n\t\t\t(index): readonly [string, unknown] => {\n\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\tif (!matchesMember(owned, key)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t\t\t}\n\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array index could not be inspected')\n\t\t\t\t}\n\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\tif (\n\t\t\t\t\tdescriptor === undefined ||\n\t\t\t\t\t!('value' in descriptor) ||\n\t\t\t\t\tdescriptor.enumerable !== true\n\t\t\t\t) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: array index is not enumerable data')\n\t\t\t\t}\n\t\t\t\treturn [key, descriptor.value]\n\t\t\t},\n\t\t)\n\t}\n\n\t#captureRecord(source: object): ReadonlyArray<readonly [key: string, value: unknown]> {\n\t\tconst keysOutcome = attempt(() => INTRINSICS.reflect.members(source))\n\t\tif (isFailure(keysOutcome)) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst names = keysOutcome.value\n\t\t// Indexed, not iterated: this walk decides the published record's own-key\n\t\t// population, and an iterator is a caller-writable member that can yield a\n\t\t// key the source never had.\n\t\treturn INTRINSICS.from(\n\t\t\titerateIndices(() => names.length),\n\t\t\t(index): readonly [string, unknown] => {\n\t\t\t\tconst key = names[index]\n\t\t\t\tif (typeof key !== 'string') this.#refuse('cloneJSONValue: record has a symbol property')\n\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: record property could not be inspected')\n\t\t\t\t}\n\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\tif (\n\t\t\t\t\tdescriptor === undefined ||\n\t\t\t\t\t!('value' in descriptor) ||\n\t\t\t\t\tdescriptor.enumerable !== true\n\t\t\t\t) {\n\t\t\t\t\tthis.#refuse('cloneJSONValue: record property is not enumerable data')\n\t\t\t\t}\n\t\t\t\treturn [key, descriptor.value]\n\t\t\t},\n\t\t)\n\t}\n\n\t#create(message: string, limit?: number): ContractError {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'json', ...(limit === undefined ? {} : { limit }) },\n\t\t})\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t#refuse(message: string, limit?: number): never {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined && isFailure(terminal)) throw terminal.error\n\t\tthrow this.#create(message, limit)\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peer and stop\n\t\t// it satisfying the mutable working field it is assigned to.\n\t\tINTRINSICS.freeze(JSONCloner.#emptyPending)\n\t\t// Pinned while this class is DEFINED. `cloneJSONValue` reaches this class\n\t\t// through `JSONCloner.prototype.clone`, so one assignment there decided what\n\t\t// a door the caller never touched published — the same defect as a replaced\n\t\t// host member, with this package's own name on it.\n\t\tpinMembers(JSONCloner.prototype, 'JSONCloner')\n\t}\n}\n","import type { JSONSchema, Result, SchemaClonerInterface } from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tfailure,\n\tenumerableKeys,\n\tisSuccess,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n} from './helpers.js'\nimport { isObject } from './validators.js'\n\n/**\n * Owns the state of one JSON Schema snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call performs one iterative identity-memoized walk and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned error. Nonredirectable terminal settlement releases\n * populated traversal state before publishing that result, while retaining\n * the source and exact result afterward. Reentry poisons the active operation\n * and every later call with one shared cause-free error.\n *\n * @param schema - The JSON Schema graph to retain for cloning\n *\n * @example\n * ```ts\n * const child = { type: 'string' }\n * const cloner = new SchemaCloner({ anyOf: [child, child] })\n * const clone = cloner.clone()\n * clone.anyOf?.[0] === clone.anyOf?.[1] // true\n * cloner.clone() === clone // true\n * ```\n */\nexport class SchemaCloner implements SchemaClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// CONSTRUCTOR of each collection is captured beside its members, because\n\t// construction happens first: capturing `WeakSet.prototype.has` while still\n\t// reaching `globalThis.Map` leaves the door open one call earlier than the\n\t// member rows can see, and the constructor runs outside every containment\n\t// this class has.\n\tstatic readonly #map = Map\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #hasOwn = Object.hasOwn\n\t// The released state, shared by every cloner this class ever builds. `#settle`\n\t// assigns it in place of the working list, so an instance allocates one\n\t// collection instead of two and construction carries no empty peer of its own.\n\t// Sharing is safe because nothing writes to a released list: every writer runs\n\t// inside the walk and `#settle` is the walk's last step. The static block at\n\t// the foot of the class freezes it, so a write that did reach it fails loudly\n\t// at its own line rather than leaking one cloner's frame into every other\n\t// cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: object\n\t\treadonly path: readonly string[]\n\t\treadonly depth: number\n\t}> = []\n\treadonly #source: JSONSchema\n\treadonly #owned: WeakSet<object>\n\t// The working map is the field with no shared peer: `Object.freeze` reaches an\n\t// array's writes and not a `Map`'s, so a shared empty map would be a\n\t// class-lifetime cache any write could fill with one cloner's nodes. `#settle`\n\t// drops it instead, and absence is `undefined`.\n\t#memo: Map<object, object> | undefined\n\t#pending: Array<{\n\t\treadonly source: object\n\t\treadonly clone: object\n\t\treadonly path: readonly string[]\n\t\treadonly depth: number\n\t}>\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'settled'; readonly result: Result<JSONSchema, ContractError> }\n\n\tconstructor(schema: JSONSchema) {\n\t\tthis.#source = schema\n\t\tthis.#owned = new SchemaCloner.#weakSet()\n\t\tthis.#memo = new SchemaCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clones the retained schema into an identity-preserving frozen graph.\n\t *\n\t * @returns The settled JSON Schema snapshot\n\t * @throws {ContractError} When traversal is unreadable or cloning is reentered\n\t */\n\tclone(): JSONSchema {\n\t\tconst state = this.#state\n\t\tswitch (state.phase) {\n\t\t\tcase 'settled':\n\t\t\t\tif (isSuccess(state.result)) return state.result.value\n\t\t\t\tthrow state.result.error\n\t\t\tcase 'running':\n\t\t\tcase 'interrupted':\n\t\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\t\tthrow state.poison\n\t\t\tcase 'ready':\n\t\t\t\tbreak\n\t\t}\n\n\t\tconst poison = this.#create('SchemaCloner.clone: schema cloning may not be reentered')\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#complete(attempt(() => this.#execute()))\n\t}\n\n\t#complete(outcome: Result<JSONSchema>): JSONSchema {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') {\n\t\t\treturn this.#settle(failure(state.poison))\n\t\t}\n\t\tif (isSuccess(outcome)) return this.#settle(outcome)\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneSchema: failed to create an owned schema snapshot', {\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t})\n\t\treturn this.#settle(failure(error))\n\t}\n\n\t#execute(): JSONSchema {\n\t\t// The root is branded like every other node. `#schedule` has always branched\n\t\t// on `Array.isArray`, so a nested array kept its brand while an ARRAY ROOT\n\t\t// was silently republished as a null-prototype record — one construct, two\n\t\t// answers depending on position, from a door whose whole contract is a\n\t\t// faithful owned snapshot. A `JSONSchema` root is a record, and a snapshot\n\t\t// that cannot be faithful refuses rather than rebrands. The rule is the ROOT's\n\t\t// alone: a schema graph is otherwise deliberately unbranded, so a class\n\t\t// instance stays acceptable schema data.\n\t\tif (INTRINSICS.array(this.#source)) {\n\t\t\tthis.#refuse('cloneSchema: a schema root must be a record, not an array', 'structure', [])\n\t\t}\n\t\t// Narrowed once at the door, because the dispatch below takes its receiver\n\t\t// type from this value. The walk runs before `#settle` drops the map, so it\n\t\t// always finds the one the constructor built; this refusal is what keeps\n\t\t// that a statement the types carry rather than one a comment makes.\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst root: JSONSchema = INTRINSICS.create(null)\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [this.#source, root])\n\t\tthis.#pending[this.#pending.length] = {\n\t\t\tsource: this.#source,\n\t\t\tclone: root,\n\t\t\tpath: [],\n\t\t\tdepth: 0,\n\t\t}\n\t\tthis.#drain()\n\t\treturn root\n\t}\n\n\t#drain(): void {\n\t\twhile (this.#pending.length > 0) {\n\t\t\tconst frame = this.#pending.pop()\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.depth > COMPILE_DEPTH_LIMIT) {\n\t\t\t\t// This door carried NO depth bound at all while every other public\n\t\t\t\t// traversal carried one, and its per-key path copy makes the walk\n\t\t\t\t// quadratic, so a 16,000-level schema — a few hundred kilobytes of\n\t\t\t\t// `JSON.parse`-able text — bought tens of seconds of work. The bound is\n\t\t\t\t// the shared compilation limit, and it is unreachable from `ShapeCloner`,\n\t\t\t\t// whose raw path validates the fragment against the same limit first.\n\t\t\t\tthis.#refuse('cloneSchema: schema exceeds the compilation depth limit', 'depth', frame.path)\n\t\t\t}\n\t\t\tconst keys = enumerableKeys(frame.source)\n\t\t\tif (keys === undefined) {\n\t\t\t\tthrow this.#create('cloneSchema: property enumeration failed', { path: frame.path })\n\t\t\t}\n\n\t\t\t// Indexed, not iterated: this walk decides the cloned node's own-key\n\t\t\t// population, so a lying `Array.prototype[Symbol.iterator]` would place a\n\t\t\t// key the source never had into a snapshot documented as faithful.\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.each, keys, [\n\t\t\t\t(key: string | undefined) => {\n\t\t\t\t\tif (key === undefined) return\n\t\t\t\t\tconst path = pathOf(frame.path, key)\n\t\t\t\t\tconst source = this.#read(frame.source, key, path)\n\t\t\t\t\tconst clone = this.#capture(source, path, frame.depth + 1)\n\t\t\t\t\tINTRINSICS.define(frame.clone, key, {\n\t\t\t\t\t\tvalue: clone,\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\twritable: true,\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t])\n\n\t\t\tINTRINSICS.freeze(frame.clone)\n\t\t}\n\t}\n\n\t#capture(value: unknown, path: readonly string[], depth: number): unknown {\n\t\tif (typeof value !== 'object' || value === null) return value\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst existing = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [value])\n\t\tif (existing !== undefined) return existing\n\t\treturn this.#schedule(value, path, depth)\n\t}\n\n\t#schedule(source: object, path: readonly string[], depth: number): object {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst clone: object = INTRINSICS.array(source) ? [] : INTRINSICS.create(null)\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [source, clone])\n\t\tthis.#pending[this.#pending.length] = { source, clone, path, depth }\n\t\treturn clone\n\t}\n\n\t#read(source: object, key: string, path: readonly string[]): unknown {\n\t\tconst outcome = attempt(() => INTRINSICS.reflect.read(source, key))\n\t\tif (isSuccess(outcome)) return outcome.value\n\t\tthrow this.#create('cloneSchema: property access failed', {\n\t\t\tpath,\n\t\t\tcause: outcome.error,\n\t\t})\n\t}\n\n\t// One refusal for the dropped working map, because a settled cloner replays\n\t// from `#state` and re-enters no walk method: nothing reachable settles here,\n\t// and every guard that says so must say it the same way.\n\t#unavailable(): ContractError {\n\t\treturn this.#create('SchemaCloner.clone: the capture state is unavailable')\n\t}\n\n\t#create(\n\t\tmessage: string,\n\t\toptions?: { readonly path?: readonly string[]; readonly cause?: unknown },\n\t): ContractError {\n\t\t// Own reads only, exactly as the diagnostic's `cause` already was: the\n\t\t// translation literal below carries `cause` and no `path`, so an\n\t\t// unqualified `options.path` would leave the literal and consult\n\t\t// `Object.prototype`, which the caller being diagnosed can write.\n\t\tconst path =\n\t\t\toptions !== undefined && SchemaCloner.#hasOwn(options, 'path') ? options.path : undefined\n\t\tconst context = path === undefined ? { shape: 'schema' } : { path, shape: 'schema' }\n\t\tconst error =\n\t\t\toptions !== undefined && SchemaCloner.#hasOwn(options, 'cause')\n\t\t\t\t? new ContractError(message, { code: 'clone', context, cause: options.cause })\n\t\t\t\t: new ContractError(message, { code: 'clone', context })\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t// The rules this engine OWNS rather than adopts: the record-rooted snapshot\n\t// and the shared depth bound. Registered as owned exactly as `#create` does,\n\t// so terminal replay still answers by identity.\n\t#refuse(message: string, code: 'structure' | 'depth', path: readonly string[]): never {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode,\n\t\t\tcontext:\n\t\t\t\tcode === 'depth'\n\t\t\t\t\t? { path, shape: 'schema', limit: COMPILE_DEPTH_LIMIT }\n\t\t\t\t\t: { path, shape: 'schema' },\n\t\t})\n\t\tadmitVisited(this.#owned, error)\n\t\tthrow error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t// Assignment only: the working list takes the class's shared frozen empty peer\n\t// and the working map is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection, so\n\t// settlement cannot be redirected into leaving state behind.\n\t#settle(result: Result<JSONSchema, ContractError>): JSONSchema {\n\t\tthis.#pending = SchemaCloner.#emptyPending\n\t\tthis.#memo = undefined\n\t\tthis.#state = { phase: 'settled', result }\n\t\tif (isSuccess(result)) return result.value\n\t\tthrow result.error\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peer and stop\n\t\t// it satisfying the mutable working field it is assigned to.\n\t\tINTRINSICS.freeze(SchemaCloner.#emptyPending)\n\t\t// Pinned while this class is DEFINED: `cloneSchema` reaches it through\n\t\t// `SchemaCloner.prototype.clone`, so an assignment there decides what a door\n\t\t// the caller never touched publishes.\n\t\tpinMembers(SchemaCloner.prototype, 'SchemaCloner')\n\t}\n}\n","import type { ContractShape } from './types.js'\nimport {\n\tCLONE_NODE_LIMIT,\n\tCOMPILE_DEPTH_LIMIT,\n\tDATE_LENGTH,\n\tINTRINSICS,\n\tSHAPE_FIELDS,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitMember,\n\tadmitVisited,\n\tappendEntries,\n\tattempt,\n\titerateIndices,\n\tcollectMembers,\n\tholds,\n\tisFailure,\n\tisSuccess,\n\tmatchesMember,\n\tmatchesJSONValue,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isRecord, isRegExp } from './validators.js'\n\n/** Owns the traversal and reentry poison of one validation call. */\nexport class ShapePass {\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\tstatic readonly #arrays = Array.prototype\n\tstatic readonly #pop = Array.prototype.pop\n\tstatic readonly #iterators = INTRINSICS.prototype(\n\t\tINTRINSICS.reflect.apply(INTRINSICS.indices, [], []),\n\t)\n\tstatic readonly #blank = INTRINSICS.freeze(new INTRINSICS.pattern(''))\n\t// Every field a node may leave out, so every read an inherited value could answer.\n\t// A sealed node's own fields cannot change, but a walk of one still refuses a\n\t// polluted `Object.prototype`, because a field the node does not hold reads through\n\t// to it. A required field is own on every node that recognizes it.\n\tstatic readonly #fields = [\n\t\t'min',\n\t\t'max',\n\t\t'pattern',\n\t\t'date',\n\t\t'description',\n\t\t'integer',\n\t\t'additionalProperties',\n\t\t'mode',\n\t\t'default',\n\t]\n\t// What a walk of a builder's node found, kept so a later builder or compiler need\n\t// not walk it again. Building a declaration walked every subtree once per ancestor,\n\t// which is quadratic in depth, and compiling it cloned the graph and walked it twice\n\t// more. Only `#survey` writes here, and only for a frozen node this package made\n\t// whose children are all sealed, so a mutable node, a node frozen by a caller, and a\n\t// node with an accessor are never recorded and take the whole walk. `reach` is the\n\t// deepest level the subtree occupies, a raw node's embedded schema included, `count`\n\t// is the expansion, `defaulted` is a default on this node, and `held` is one\n\t// anywhere in the subtree.\n\tstatic readonly #seals = new ShapePass.#weakMap<\n\t\tContractShape,\n\t\t{\n\t\t\treadonly category: ContractShape['category']\n\t\t\treadonly reach: number\n\t\t\treadonly count: number\n\t\t\treadonly defaulted: boolean\n\t\t\treadonly held: boolean\n\t\t}\n\t>()\n\treadonly #source: unknown\n\treadonly #budget: { left: number } | undefined\n\t#stack: Array<\n\t\t| {\n\t\t\t\treadonly operation: 'enter'\n\t\t\t\treadonly shape: unknown\n\t\t\t\treadonly depth: number\n\t\t\t\treadonly optional: boolean\n\t\t\t\treadonly first?: string\n\t\t\t\treadonly second?: string\n\t\t }\n\t\t| { readonly operation: 'exit'; readonly index: number; readonly segments: number }\n\t> = []\n\t#path: string[] = []\n\t#active = new ShapePass.#weakSet<object>()\n\t// The capture. Discovery observes each unique node ONCE — descriptors, two\n\t// stable reads, scalar evidence and ordered outgoing edges — and every later\n\t// incoming edge is answered from here instead of from the caller's source.\n\t// Re-observing per incoming edge cost one whole observation per DISTINCT depth\n\t// a node was reached at, so an object holding one leaf at sixteen nesting\n\t// levels read that leaf sixteen times, and the subtree under it was re-walked\n\t// with it. `raw` is the height of a raw node's embedded schema, `0` for every\n\t// other node.\n\t#index = new ShapePass.#weakMap<object, number>()\n\t#captures: Array<{\n\t\treadonly shape: object\n\t\treadonly category: unknown\n\t\treadonly children: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}>\n\t\treadonly raw: number\n\t\treadonly defaulted: boolean\n\t\treadonly open: boolean\n\t}> = []\n\t// Discovery postorder: children finish before parents, so reading it forwards\n\t// solves any bottom-up fact in one pass and reading it backwards solves any\n\t// top-down one. Both replace a walk that was multiplicative in incoming edges.\n\t#post: number[] = []\n\t#height: number[] = []\n\t#reach: number[] = []\n\t// The edge that last raised `#reach`, so the position a depth verdict was\n\t// taken FROM can be spelled back out as a path. A refusal answered from the\n\t// deepest occurrence and reported at the first-discovered one accuses a slot\n\t// the same declaration proves legal on its own.\n\t#via: Array<{ readonly parent: number; readonly first: string; readonly second?: string }> = []\n\t// The edge that first put a node below a union, so a default's refusal can spell\n\t// the route through that union rather than the node's deepest one.\n\t#within: Array<{ readonly parent: number; readonly first: string; readonly second?: string }> = []\n\t// One node per node per incoming edge: the size of the TREE a compiler would\n\t// build from this DAG, which is what actually bounds compilation.\n\t#counts: number[] = []\n\t#schemas = new ShapePass.#weakMap<object, number>()\n\t#children: Array<{\n\t\treadonly shape: unknown\n\t\treadonly optional: boolean\n\t\treadonly first: string\n\t\treadonly second?: string\n\t}> = []\n\t#category: unknown\n\t#raw = 0\n\t#defaulted = false\n\t#open = false\n\t#structure: ContractError | undefined\n\t#cycle: ContractError | undefined\n\t#domain: ContractError | undefined\n\n\t#poison: ContractError | undefined\n\n\tconstructor(shape: unknown, budget?: { left: number }) {\n\t\tthis.#source = shape\n\t\tthis.#budget = budget\n\t}\n\n\t/**\n\t * Validates a node fresh from a builder, freezes it, and records what the walk found.\n\t *\n\t * @remarks\n\t * The node's own fields are always observed, and each child is answered from its\n\t * seal rather than walked. Anything short of a clean answer takes the whole walk\n\t * instead, which is what authors every refusal, so a refusal reads the same and\n\t * fires at the same call as it would with no seals at all. That second look is safe\n\t * because the first read nothing a caller wrote: the node is this package's own\n\t * literal, and a child with no seal stops the survey before it is read.\n\t *\n\t * @param shape - The builder's fresh node, which no caller has seen\n\t * @param check - What the whole walk validates, when the node is only legal in a slot\n\t * @returns The frozen node\n\t * @throws {ContractError} When the node is refused\n\t */\n\tstatic seal<S extends ContractShape>(shape: S, check: ContractShape = shape): Readonly<S> {\n\t\tconst frozen = INTRINSICS.freeze(shape)\n\t\tif (!new ShapePass(shape).#survey(check === shape ? 0 : 1)) {\n\t\t\tnew ShapePass(check, { left: CLONE_NODE_LIMIT }).validate()\n\t\t}\n\t\treturn frozen\n\t}\n\n\t/**\n\t * Reports the expansion of a sealed node a compiler can take as it stands.\n\t *\n\t * @remarks\n\t * `undefined` sends the caller to its own ownership and validation: the node was\n\t * never sealed, an inherited field would answer a walk of it, or it is an `optional`\n\t * node, which a walk refuses as a root.\n\t *\n\t * @param shape - The declaration to look up\n\t * @returns The expansion a walk would report, or `undefined`\n\t */\n\tstatic expansionOf(shape: ContractShape): number | undefined {\n\t\tif (ShapePass.polluted()) return undefined\n\t\tconst seal = INTRINSICS.reflect.apply(INTRINSICS.recall, ShapePass.#seals, [shape])\n\t\treturn seal === undefined || seal.category === 'optional' ? undefined : seal.count\n\t}\n\n\t/**\n\t * Reports whether a walk could answer differently from a seal.\n\t *\n\t * @remarks\n\t * A field a node may leave out reads through to `Object.prototype`, which is a\n\t * verdict about the declaration, and a {@link tampered} host breaks a walk into a\n\t * refusal a seal would otherwise skip.\n\t *\n\t * @returns True when a walk has to answer rather than a seal\n\t */\n\tstatic polluted(): boolean {\n\t\tif (ShapePass.tampered()) return true\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, ShapePass.#fields, [\n\t\t\t(field: string) => INTRINSICS.own(INTRINSICS.base, field),\n\t\t])\n\t}\n\n\t/**\n\t * Reports whether a member a walk or a compile runs on has been replaced.\n\t *\n\t * @remarks\n\t * An index on either prototype, reached by array writes, a replaced `pop` or array\n\t * iterator `next`, and a flag getter a pattern's `flags` reads. An array's `length`\n\t * always passes its highest index, and own keys list an index first, so one read\n\t * answers for every index, and a name that merely opens with a digit only costs a walk.\n\t *\n\t * @returns True when the host is not the one this package loaded on\n\t */\n\tstatic tampered(): boolean {\n\t\tif (ShapePass.#arrays.length !== 0) return true\n\t\tconst first = INTRINSICS.reflect.members(INTRINSICS.base)[0]\n\t\tif (typeof first === 'string' && first >= '0' && first < ':') return true\n\t\tif (INTRINSICS.describe(ShapePass.#arrays, 'pop')?.value !== ShapePass.#pop) return true\n\t\tconst next = INTRINSICS.describe(ShapePass.#iterators, 'next')?.value\n\t\tif (next !== INTRINSICS.advance) return true\n\t\treturn !holds(() => readPatternFlags(ShapePass.#blank) === '')\n\t}\n\n\t/** Poisons this pass and throws the same refusal on every reentry. */\n\tinterrupt(): never {\n\t\tthis.#poison ??= new ContractError(\n\t\t\t'ShapeValidator.validate: shape validation may not be reentered',\n\t\t\t{ code: 'structure', context: { path: [] } },\n\t\t)\n\t\tthrow this.#poison\n\t}\n\n\t/** Validates the captured source and returns its expansion. */\n\tvalidate(): number {\n\t\tconst outcome = attempt(() => this.#execute())\n\t\tif (this.#poison !== undefined) throw this.#poison\n\t\tif (isSuccess(outcome)) return this.#counts[0] ?? 1\n\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\tthrow new ContractError('validateShape: shape reflection failed', {\n\t\t\tcode: 'structure',\n\t\t\tcontext: { path: [] },\n\t\t\tcause: outcome.error,\n\t\t})\n\t}\n\n\t// One observation of the node, and its children answered from their seals. Each\n\t// rule the walk asks across an edge is asked here too: optional placement in the\n\t// slot, a default below a union or beside an open object's extras, and depth. `lift`\n\t// is how far below the walk's root this node sits, which is one under the object an\n\t// optional node is validated inside. A false answer says nothing about the node\n\t// beyond that the walk has to decide.\n\t#survey(lift: number): boolean {\n\t\tif (ShapePass.polluted()) return false\n\t\tconst shape = this.#source\n\t\tif (!isRecord(shape)) return false\n\t\tconst outcome = attempt(() => this.#observe(shape, 0))\n\t\tif (isFailure(outcome) || !outcome.value || this.#domain !== undefined) return false\n\t\tconst seal = {\n\t\t\tcategory: shape.category,\n\t\t\treach: this.#raw,\n\t\t\tcount: 1,\n\t\t\tdefaulted: this.#defaulted,\n\t\t\theld: this.#defaulted,\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#children.length)) {\n\t\t\tconst child = this.#children[index]\n\t\t\tconst known = INTRINSICS.reflect.apply(INTRINSICS.recall, ShapePass.#seals, [child?.shape])\n\t\t\tif (child === undefined || known === undefined) return false\n\t\t\tif (known.category === 'optional' && !child.optional) return false\n\t\t\tif (known.held && shape.category === 'union') return false\n\t\t\tif (known.defaulted && this.#open) return false\n\t\t\tseal.reach = INTRINSICS.max(seal.reach, known.reach + 1)\n\t\t\tseal.count += known.count\n\t\t\tseal.held ||= known.held\n\t\t}\n\t\tif (seal.reach + lift > COMPILE_DEPTH_LIMIT) return false\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, ShapePass.#seals, [shape, seal])\n\t\treturn true\n\t}\n\n\t#execute(): void {\n\t\tthis.#stack[this.#stack.length] = {\n\t\t\toperation: 'enter',\n\t\t\tshape: this.#source,\n\t\t\tdepth: 0,\n\t\t\toptional: false,\n\t\t}\n\t\twhile (this.#stack.length > 0) this.#visit()\n\t\tthis.#measure()\n\t\tthis.#finish()\n\t}\n\n\t#visit(): void {\n\t\tconst frame = this.#stack.pop()\n\t\tif (frame === undefined) return\n\t\tif (frame.operation === 'exit') {\n\t\t\tconst capture = this.#captures[frame.index]\n\t\t\tif (capture !== undefined) omitVisited(this.#active, capture.shape)\n\t\t\tthis.#post[this.#post.length] = frame.index\n\t\t\tthis.#path.length -= frame.segments\n\t\t\treturn\n\t\t}\n\n\t\tconst first = INTRINSICS.own(frame, 'first') ? frame.first : undefined\n\t\tconst second = INTRINSICS.own(frame, 'second') ? frame.second : undefined\n\t\tconst segments = (first === undefined ? 0 : 1) + (second === undefined ? 0 : 1)\n\t\tif (first !== undefined) {\n\t\t\tthis.#path[this.#path.length] = first\n\t\t}\n\t\tif (second !== undefined) {\n\t\t\tthis.#path[this.#path.length] = second\n\t\t}\n\n\t\tconst current = frame.shape\n\t\tif (typeof current !== 'object' || current === null || !isRecord(current)) {\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: every structural child must be a shape',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t\t},\n\t\t\t)\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\t\tif (matchesVisited(this.#active, current)) {\n\t\t\tthis.#cycle ??= new ContractError('validateShape: a shape graph may not contain a cycle', {\n\t\t\t\tcode: 'cycle',\n\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t})\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\t// The refinement, and the whole reason discovery is separate from\n\t\t// measurement: a node already captured is not observed again. Every rule the\n\t\t// OBSERVATION enforces is a property of the node, so a second look at the\n\t\t// same node can only produce the same answer at a longer path. Optional\n\t\t// placement and depth are properties of the POSITION instead, and they are\n\t\t// answered in separate\n\t\t// places: where an `optional` node is legal is re-asked here, from the\n\t\t// capture, for every incoming edge, while depth — the shape's own and a raw\n\t\t// node's embedded schema alike — is measured over the whole captured graph in\n\t\t// `#measure`, which is why its diagnostics are spelled from the deepest\n\t\t// occurrence rather than from whichever edge discovery arrived on.\n\t\tconst seen = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#index, [current])\n\t\tif (seen !== undefined) {\n\t\t\tthis.#place(seen, frame.optional)\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\tthis.#children = []\n\t\tthis.#category = undefined\n\t\tthis.#raw = 0\n\t\tthis.#defaulted = false\n\t\tthis.#open = false\n\t\tconst outcome = attempt(() => this.#observe(current, frame.depth))\n\t\tthis.#spend(0)\n\t\tif (isFailure(outcome) || !outcome.value) {\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(this.#path) },\n\t\t\t\t},\n\t\t\t)\n\t\t\t// Captured as a childless leaf. Its subtree is not walked, and every later\n\t\t\t// edge to it measures its depth from the capture instead of re-running the\n\t\t\t// observation that already refused.\n\t\t\tthis.#post[this.#post.length] = this.#capture(current, [])\n\t\t\tthis.#path.length -= segments\n\t\t\treturn\n\t\t}\n\n\t\tthis.#place(this.#schedule(current, frame.depth, segments), frame.optional)\n\t}\n\n\t#observe(current: Record<string, unknown>, depth: number): boolean {\n\t\tconst descriptor = INTRINSICS.describe(current, 'category')\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tconst category = current.category\n\t\tif (current.category !== category || descriptor.value !== category) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tconst fields =\n\t\t\ttypeof category === 'string' && INTRINSICS.own(SHAPE_FIELDS, category)\n\t\t\t\t? SHAPE_FIELDS[category]\n\t\t\t\t: undefined\n\t\tif (fields === undefined) {\n\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape')\n\t\t}\n\t\tthis.#category = category\n\t\tif (!this.#scan(current, fields)) return false\n\t\tif (!this.#constrain(current)) return false\n\t\tif (category === 'raw') {\n\t\t\tconst schema = current.schema\n\t\t\tconst outcome = attempt(() => this.#inspect(schema))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'schema')\n\t\t\t}\n\t\t\tif (!outcome.value) return false\n\t\t\t// The embedded schema's own nesting is measured once per unique record\n\t\t\t// and applied at THIS node's depth, so a schema shared by two raw nodes\n\t\t\t// is validated once and still refuses at whichever node is too deep for\n\t\t\t// it. The deeper-occurrence case is re-asked in `#measure`.\n\t\t\tif (depth + this.#raw > COMPILE_DEPTH_LIMIT) {\n\t\t\t\treturn this.#refuse(\n\t\t\t\t\t'validateShape: raw schema exceeds the compilation depth limit',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (category === 'object') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'properties')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\tif (category === 'union') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'variants')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\tif (category === 'literal') {\n\t\t\tconst outcome = attempt(() => this.#populate(current))\n\t\t\tif (isFailure(outcome)) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', 'values')\n\t\t\t}\n\t\t\treturn outcome.value\n\t\t}\n\t\treturn this.#populate(current)\n\t}\n\n\t#scan(current: Record<string, unknown>, fields: readonly string[]): boolean {\n\t\tfor (const fieldIndex of iterateIndices(() => fields.length)) {\n\t\t\tconst field = fields[fieldIndex]\n\t\t\tif (field === undefined) continue\n\t\t\tconst outcome = attempt((): boolean => {\n\t\t\t\tconst descriptor = INTRINSICS.describe(current, field)\n\t\t\t\tif (\n\t\t\t\t\tdescriptor !== undefined &&\n\t\t\t\t\t!INTRINSICS.own(descriptor, 'value') &&\n\t\t\t\t\tfield !== 'pattern'\n\t\t\t\t) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tconst first: unknown = INTRINSICS.reflect.read(current, field)\n\t\t\t\tconst second: unknown = INTRINSICS.reflect.read(current, field)\n\t\t\t\tif (descriptor === undefined) return first === undefined && second === undefined\n\t\t\t\tif (INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\tconst described: unknown = descriptor.value\n\t\t\t\t\treturn INTRINSICS.same(first, described) && INTRINSICS.same(second, first)\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\tfield === 'pattern' &&\n\t\t\t\t\tisRegExp(first) &&\n\t\t\t\t\tisRegExp(second) &&\n\t\t\t\t\treadPatternSource(first) === readPatternSource(second) &&\n\t\t\t\t\treadPatternFlags(first) === readPatternFlags(second) &&\n\t\t\t\t\tINTRINSICS.frozen(first) &&\n\t\t\t\t\tINTRINSICS.frozen(second)\n\t\t\t\t)\n\t\t\t})\n\t\t\tif (isFailure(outcome) || !outcome.value) {\n\t\t\t\treturn this.#refuse('validateShape: every node must be a recognized shape', field)\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\t#constrain(current: Record<string, unknown>): boolean {\n\t\tif (\n\t\t\tcurrent.category !== 'optional' &&\n\t\t\tcurrent.category !== 'nullable' &&\n\t\t\tcurrent.category !== 'raw' &&\n\t\t\tcurrent.description !== undefined &&\n\t\t\ttypeof current.description !== 'string'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: description must be a string', 'description')\n\t\t}\n\t\tif (current.category === 'optional' && INTRINSICS.own(current, 'default')) {\n\t\t\tif (!holds(() => matchesJSONValue(current.default, new ShapePass.#weakSet(), this.#budget))) {\n\t\t\t\treturn this.#refuse('validateShape: an optional default must be a JSON value', 'default')\n\t\t\t}\n\t\t\tthis.#defaulted = true\n\t\t}\n\t\tif (current.category === 'string') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: string min must be a number', 'min')\n\t\t\t}\n\t\t\tif (current.max !== undefined && typeof current.max !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: string max must be a number', 'max')\n\t\t\t}\n\t\t\tif (current.date !== undefined && typeof current.date !== 'boolean') {\n\t\t\t\treturn this.#refuse('validateShape: string date must be a boolean', 'date')\n\t\t\t}\n\t\t\tif (current.pattern !== undefined) {\n\t\t\t\tconst pattern = current.pattern\n\t\t\t\tif (!isRegExp(pattern)) {\n\t\t\t\t\treturn this.#refuse('validateShape: string pattern must be a RegExp', 'pattern')\n\t\t\t\t}\n\t\t\t\t// Both observations go through the CAPTURED accessors: a replaced\n\t\t\t\t// `source` getter reports for every pattern in the realm, so the\n\t\t\t\t// stability this gate publishes would be stability of the caller's\n\t\t\t\t// answer rather than of the pattern.\n\t\t\t\tconst source = readPatternSource(pattern)\n\t\t\t\tconst flags = readPatternFlags(pattern)\n\t\t\t\tif (\n\t\t\t\t\ttypeof source !== 'string' ||\n\t\t\t\t\ttypeof flags !== 'string' ||\n\t\t\t\t\treadPatternSource(pattern) !== source ||\n\t\t\t\t\treadPatternFlags(pattern) !== flags\n\t\t\t\t) {\n\t\t\t\t\treturn this.#refuse('validateShape: string pattern must be stable', 'pattern')\n\t\t\t\t}\n\t\t\t\tthis.#restrict(current, source, flags)\n\t\t\t} else {\n\t\t\t\tthis.#restrict(current)\n\t\t\t}\n\t\t}\n\t\tif (current.category === 'number') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: number min must be a number', 'min')\n\t\t\t}\n\t\t\tif (current.max !== undefined && typeof current.max !== 'number') {\n\t\t\t\treturn this.#refuse('validateShape: number max must be a number', 'max')\n\t\t\t}\n\t\t\tif (current.integer !== undefined && typeof current.integer !== 'boolean') {\n\t\t\t\treturn this.#refuse('validateShape: number integer must be a boolean', 'integer')\n\t\t\t}\n\t\t\tconst shape = current.integer === true ? 'integer' : 'number'\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.min !== undefined &&\n\t\t\t\t!INTRINSICS.finite(current.min)\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape min must be finite', {\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tlimit: 'finite number',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.max !== undefined &&\n\t\t\t\t!INTRINSICS.finite(current.max)\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape max must be finite', {\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tlimit: 'finite number',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#domain === undefined &&\n\t\t\t\tcurrent.min !== undefined &&\n\t\t\t\tcurrent.max !== undefined &&\n\t\t\t\ttypeof current.min === 'number' &&\n\t\t\t\ttypeof current.max === 'number' &&\n\t\t\t\tcurrent.min > current.max\n\t\t\t) {\n\t\t\t\tthis.#domain = new ContractError('validateShape: a number shape has min greater than max', {\n\t\t\t\t\tcode: 'range',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape },\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (this.#domain === undefined && current.integer === true) {\n\t\t\t\tconst lo = INTRINSICS.ceil(current.min ?? Number.NEGATIVE_INFINITY)\n\t\t\t\tconst hi = INTRINSICS.floor(current.max ?? Number.POSITIVE_INFINITY)\n\t\t\t\tif (lo > hi) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: an integer number shape has an empty integer range',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'range',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'integer' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\ttypeof current.min !== 'number'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: array min must be a number', 'min')\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.max !== 'number'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: array max must be a number', 'max')\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(typeof current.min !== 'number' || !INTRINSICS.safe(current.min) || current.min < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: an array shape min must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'array',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\t(typeof current.max !== 'number' || !INTRINSICS.safe(current.max) || current.max < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: an array shape max must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'array',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'array' &&\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.min === 'number' &&\n\t\t\ttypeof current.max === 'number' &&\n\t\t\tcurrent.min > current.max\n\t\t) {\n\t\t\tthis.#domain = new ContractError('validateShape: an array shape has min greater than max', {\n\t\t\t\tcode: 'range',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'array' },\n\t\t\t})\n\t\t}\n\t\tif (\n\t\t\tcurrent.category === 'union' &&\n\t\t\tcurrent.mode !== undefined &&\n\t\t\tcurrent.mode !== 'anyOf' &&\n\t\t\tcurrent.mode !== 'oneOf'\n\t\t) {\n\t\t\treturn this.#refuse('validateShape: union mode must be anyOf or oneOf', 'mode')\n\t\t}\n\t\treturn true\n\t}\n\n\t// Where an `optional` node is legal depends on the SLOT it arrived through, not\n\t// on the node, so this is the one rule discovery asks per incoming edge rather\n\t// than once per node. It reads the captured category instead of the source: a\n\t// second read of `category` would be a second observation of a node already\n\t// observed, and an unrecognized node has no category to answer with.\n\t#place(index: number, optional: boolean): void {\n\t\tif (optional || this.#domain !== undefined) return\n\t\tif (this.#captures[index]?.category !== 'optional') return\n\t\tthis.#domain = new ContractError(\n\t\t\t'validateShape: an optional shape may only appear as a direct object-property value',\n\t\t\t{\n\t\t\t\tcode: 'placement',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'optional' },\n\t\t\t},\n\t\t)\n\t}\n\n\t#restrict(current: Record<string, unknown>, source = '', flags = ''): void {\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(typeof current.min !== 'number' || !INTRINSICS.safe(current.min) || current.min < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape min must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.min),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\t(typeof current.max !== 'number' || !INTRINSICS.safe(current.max) || current.max < 0)\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape max must be a non-negative safe integer',\n\t\t\t\t{\n\t\t\t\t\tcode: 'bound',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\t\treceived: INTRINSICS.text(current.max),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (this.#domain === undefined && flags.length > 0) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape pattern must not use flags; use inline pattern constructs instead',\n\t\t\t\t{\n\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\tshape: 'string',\n\t\t\t\t\t\treceived: `/${source}/${flags}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\tcurrent.max !== undefined &&\n\t\t\ttypeof current.min === 'number' &&\n\t\t\ttypeof current.max === 'number' &&\n\t\t\tcurrent.min > current.max\n\t\t) {\n\t\t\tthis.#domain = new ContractError('validateShape: a string shape has min greater than max', {\n\t\t\t\tcode: 'range',\n\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'string' },\n\t\t\t})\n\t\t}\n\t\tif (this.#domain === undefined && current.date === true && current.pattern !== undefined) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t'validateShape: a string shape declares date or pattern, never both',\n\t\t\t\t{\n\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'string' },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.date === true &&\n\t\t\t((typeof current.min === 'number' && current.min > DATE_LENGTH) ||\n\t\t\t\t(typeof current.max === 'number' && current.max < DATE_LENGTH))\n\t\t) {\n\t\t\tthis.#domain = new ContractError(\n\t\t\t\t`validateShape: a date string shape needs min and max to admit length ${DATE_LENGTH}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'range',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'string', limit: DATE_LENGTH },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n\n\t// Validates the embedded schema graph and leaves its HEIGHT in `#raw` — the\n\t// number of levels it adds below the raw node that carries it. Each unique\n\t// record is validated once per call and memoized, so a schema shared between\n\t// two raw nodes, or reached twice inside one, costs its records and edges\n\t// rather than its paths. The depth verdict moved out with it: a height is a\n\t// property of the schema, while whether that height fits is a property of the\n\t// node's position, and only the second one varies per occurrence.\n\t#inspect(source: unknown): boolean {\n\t\tif (this.#structure !== undefined) return true\n\t\tif (!isRecord(source)) {\n\t\t\treturn this.#refuse('validateShape: raw schema must be a plain record', 'schema')\n\t\t}\n\t\tconst active = new ShapePass.#weakSet<object>()\n\t\tconst stack: Array<\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'enter'\n\t\t\t\t\treadonly schema: unknown\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'exit'\n\t\t\t\t\treadonly schema: object\n\t\t\t\t\treadonly nested: readonly unknown[]\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t }\n\t\t> = [{ operation: 'enter', schema: source }]\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack.pop()\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tomitVisited(active, frame.schema)\n\t\t\t\tthis.#settleSchema(frame.schema, frame.nested)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst first = INTRINSICS.own(frame, 'first') ? frame.first : undefined\n\t\t\tconst second = INTRINSICS.own(frame, 'second') ? frame.second : undefined\n\t\t\tconst schema = frame.schema\n\t\t\tif (!isRecord(schema)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: every raw schema child must be a plain record',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (matchesVisited(active, schema)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: a raw schema may not contain a cycle',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [schema]) !== undefined)\n\t\t\t\tcontinue\n\t\t\tadmitVisited(active, schema)\n\n\t\t\tconst keyList = INTRINSICS.keys(schema)\n\t\t\tfor (const keyIndex of iterateIndices(() => keyList.length)) {\n\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tif (\n\t\t\t\t\tkey !== 'type' &&\n\t\t\t\t\tkey !== 'description' &&\n\t\t\t\t\tkey !== 'default' &&\n\t\t\t\t\tkey !== 'enum' &&\n\t\t\t\t\tkey !== 'minLength' &&\n\t\t\t\t\tkey !== 'maxLength' &&\n\t\t\t\t\tkey !== 'pattern' &&\n\t\t\t\t\tkey !== 'format' &&\n\t\t\t\t\tkey !== 'minimum' &&\n\t\t\t\t\tkey !== 'maximum' &&\n\t\t\t\t\tkey !== 'minItems' &&\n\t\t\t\t\tkey !== 'maxItems' &&\n\t\t\t\t\tkey !== 'items' &&\n\t\t\t\t\tkey !== 'properties' &&\n\t\t\t\t\tkey !== 'required' &&\n\t\t\t\t\tkey !== 'additionalProperties' &&\n\t\t\t\t\tkey !== 'anyOf' &&\n\t\t\t\t\tkey !== 'oneOf'\n\t\t\t\t) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema contains an unsupported keyword',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst category = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\t\tif (\n\t\t\t\tcategory !== undefined &&\n\t\t\t\tcategory !== 'null' &&\n\t\t\t\tcategory !== 'boolean' &&\n\t\t\t\tcategory !== 'object' &&\n\t\t\t\tcategory !== 'array' &&\n\t\t\t\tcategory !== 'number' &&\n\t\t\t\tcategory !== 'integer' &&\n\t\t\t\tcategory !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema type is outside the supported vocabulary',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'type',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'description') &&\n\t\t\t\tschema.description !== undefined &&\n\t\t\t\ttypeof schema.description !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema description must be a string',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'description',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'default') && !isJSONValue(schema.default)) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema default must be a JSON value',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'default',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'format') &&\n\t\t\t\tschema.format !== undefined &&\n\t\t\t\ttypeof schema.format !== 'string'\n\t\t\t) {\n\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t'validateShape: raw schema format must be a string',\n\t\t\t\t\tstack,\n\t\t\t\t\tfirst,\n\t\t\t\t\tsecond,\n\t\t\t\t\t'format',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'pattern') && schema.pattern !== undefined) {\n\t\t\t\tif (typeof schema.pattern !== 'string') {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema pattern must be a string',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'pattern',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// The CAPTURED `RegExp`, not the live global: the result of this read is\n\t\t\t\t// the refusal `rawShape` documents, and a caller who installed a\n\t\t\t\t// non-throwing stub made a malformed pattern compile clean.\n\t\t\t\tconst pattern = attempt(() =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.pattern, undefined, [schema.pattern]),\n\t\t\t\t)\n\t\t\t\tif (isFailure(pattern)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema pattern must be valid',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'pattern',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst lengthList = ['minLength', 'maxLength', 'minItems', 'maxItems']\n\t\t\tfor (const lengthIndex of iterateIndices(() => lengthList.length)) {\n\t\t\t\tconst key = lengthList[lengthIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (value !== undefined && (!INTRINSICS.safe(value) || INTRINSICS.numeric(value) < 0)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema length bounds must be non-negative safe integers',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst rangeList = ['minimum', 'maximum']\n\t\t\tfor (const rangeIndex of iterateIndices(() => rangeList.length)) {\n\t\t\t\tconst key = rangeList[rangeIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (value !== undefined && (typeof value !== 'number' || !INTRINSICS.finite(value))) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema numeric bounds must be finite numbers',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst population = INTRINSICS.own(schema, 'enum') ? schema.enum : undefined\n\t\t\tif (population !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(population)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be a non-empty array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(population)\n\t\t\t\tif (isFailure(snapshot) || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be a non-empty array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema enum must be dense',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'enum',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// A module-scope membership question, not `set.has(value)`: this\n\t\t\t\t// uniqueness test decides whether the door accepts or refuses, so\n\t\t\t\t// `Set.prototype.has = () => false` would admit a duplicate vocabulary\n\t\t\t\t// the shape gate exists to reject.\n\t\t\t\tconst values = collectMembers([])\n\t\t\t\tfor (const valueIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\t// A present member whose captured value is `undefined` is refused by\n\t\t\t\t\t// the literal test below rather than skipped.\n\t\t\t\t\tconst value = snapshot.value.entries[valueIndex]\n\t\t\t\t\tif (\n\t\t\t\t\t\t!isLiteralValue(value) ||\n\t\t\t\t\t\t(typeof value === 'number' && !INTRINSICS.finite(value)) ||\n\t\t\t\t\t\tmatchesMember(values, value)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t\t'validateShape: raw schema enum values must be finite unique primitives',\n\t\t\t\t\t\t\tstack,\n\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t\t'enum',\n\t\t\t\t\t\t\tINTRINSICS.text(valueIndex),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(values, value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst names = INTRINSICS.own(schema, 'required') ? schema.required : undefined\n\t\t\tif (names !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(names)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be an array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(names)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be an array',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema required must be dense',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'required',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst required = collectMembers([])\n\t\t\t\tfor (const valueIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\tconst value = snapshot.value.entries[valueIndex]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tif (typeof value !== 'string' || matchesMember(required, value)) {\n\t\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t\t'validateShape: raw schema required values must be unique strings',\n\t\t\t\t\t\t\tstack,\n\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t\t'required',\n\t\t\t\t\t\t\tINTRINSICS.text(valueIndex),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(required, value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst nested: unknown[] = []\n\t\t\tconst edges: Array<readonly [string, string?]> = []\n\t\t\tif (INTRINSICS.own(schema, 'items') && schema.items !== undefined) {\n\t\t\t\tedges[nested.length] = ['items']\n\t\t\t\tnested[nested.length] = schema.items\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'properties') && schema.properties !== undefined) {\n\t\t\t\tif (!isRecord(schema.properties)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema properties must be a plain record',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst propertyList = INTRINSICS.keys(schema.properties)\n\t\t\t\tfor (const propertyIndex of iterateIndices(() => propertyList.length)) {\n\t\t\t\t\tconst key = propertyList[propertyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tedges[nested.length] = ['properties', key]\n\t\t\t\t\tnested[nested.length] = INTRINSICS.own(schema.properties, key)\n\t\t\t\t\t\t? schema.properties[key]\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tINTRINSICS.own(schema, 'additionalProperties') &&\n\t\t\t\tschema.additionalProperties !== undefined &&\n\t\t\t\tschema.additionalProperties !== true &&\n\t\t\t\tschema.additionalProperties !== false\n\t\t\t) {\n\t\t\t\tedges[nested.length] = ['additionalProperties']\n\t\t\t\tnested[nested.length] = schema.additionalProperties\n\t\t\t}\n\t\t\tconst unionList = ['anyOf', 'oneOf']\n\t\t\tfor (const unionIndex of iterateIndices(() => unionList.length)) {\n\t\t\t\tconst key = unionList[unionIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst variants = INTRINSICS.own(schema, key) ? schema[key] : undefined\n\t\t\t\tif (variants === undefined) continue\n\t\t\t\tif (!INTRINSICS.array(variants)) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(variants)\n\t\t\t\tif (isFailure(snapshot) || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuseSchema(\n\t\t\t\t\t\t'validateShape: raw schema unions must be dense arrays',\n\t\t\t\t\t\tstack,\n\t\t\t\t\t\tfirst,\n\t\t\t\t\t\tsecond,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tfor (const variantIndex of iterateIndices(() => snapshot.value.entries.length)) {\n\t\t\t\t\t// A present member whose captured value is `undefined` is still a\n\t\t\t\t\t// present member, so it is scheduled and refused as a nonrecord\n\t\t\t\t\t// rather than skipped.\n\t\t\t\t\tedges[nested.length] = [key, INTRINSICS.text(variantIndex)]\n\t\t\t\t\tnested[nested.length] = snapshot.value.entries[variantIndex]\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack[stack.length] = {\n\t\t\t\toperation: 'exit',\n\t\t\t\tschema,\n\t\t\t\tnested,\n\t\t\t\t...(first === undefined ? {} : { first: first }),\n\t\t\t\t...(second === undefined ? {} : { second: second }),\n\t\t\t}\n\t\t\tfor (const offset of iterateIndices(() => nested.length)) {\n\t\t\t\tconst index = nested.length - 1 - offset\n\t\t\t\tconst childFirst = edges[index]?.[0]\n\t\t\t\tconst edge = edges[index]\n\t\t\t\tconst childSecond = edge !== undefined && INTRINSICS.own(edge, 1) ? edge[1] : undefined\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tschema: nested[index],\n\t\t\t\t\t...(childFirst === undefined ? {} : { first: childFirst }),\n\t\t\t\t\t...(childSecond === undefined ? {} : { second: childSecond }),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.#raw = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [source]) ?? 0\n\t\treturn true\n\t}\n\n\t// One raw-schema record's height, recorded as its walk finishes. Every nested\n\t// record has already finished, so its own height is in the memo.\n\t#settleSchema(schema: object, nested: readonly unknown[]): void {\n\t\tconst height: number = INTRINSICS.reflect.apply(INTRINSICS.fold, nested, [\n\t\t\t(highest: number, child: unknown) => {\n\t\t\t\tconst recorded =\n\t\t\t\t\ttypeof child !== 'object' || child === null\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [child]) ?? 0)\n\t\t\t\treturn INTRINSICS.max(highest, recorded + 1)\n\t\t\t},\n\t\t\t0,\n\t\t])\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#schemas, [schema, height])\n\t}\n\n\t#populate(current: Record<string, unknown>): boolean {\n\t\tswitch (current.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#spend(1)\n\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\tshape: current.items,\n\t\t\t\t\tfirst: 'items',\n\t\t\t\t\toptional: false,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'object': {\n\t\t\t\tconst properties = current.properties\n\t\t\t\tif (!isRecord(properties)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: properties must be a plain property map',\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst keys = INTRINSICS.keys(properties)\n\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(properties, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst childOutcome = attempt(() => {\n\t\t\t\t\t\tconst population = current.properties\n\t\t\t\t\t\treturn isRecord(population) ? population[key] : undefined\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(childOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst child = childOutcome.value\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.properties\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tisRecord(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[key], child) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, child)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: child,\n\t\t\t\t\t\tfirst: 'properties',\n\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\toptional: true,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst extra = current.additionalProperties\n\t\t\t\tthis.#open = extra !== undefined && extra !== false\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: extra,\n\t\t\t\t\t\tfirst: 'additionalProperties',\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tif (!INTRINSICS.array(current.variants)) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a finite array', 'variants')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(current.variants)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a finite array', 'variants')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: variants must be a dense data array', 'variants')\n\t\t\t\t}\n\t\t\t\tconst variants = snapshot.value.entries\n\t\t\t\tconst length = variants.length\n\t\t\t\tif (this.#domain === undefined && length === 0) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: a union shape needs at least one variant',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'empty',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'union' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => length)) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tthis.#spend(1)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.variants, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'variants',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: false,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tconst variant = variants[index]\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.variants\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tINTRINSICS.array(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[index], variant) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, variant)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'variants',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\t\tshape: undefined,\n\t\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\t\toptional: false,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\t\tshape: variant,\n\t\t\t\t\t\tfirst: 'variants',\n\t\t\t\t\t\tsecond: key,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'literal': {\n\t\t\t\tif (!INTRINSICS.array(current.values)) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a finite literal array', 'values')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(current.values)\n\t\t\t\tif (isFailure(snapshot)) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a finite literal array', 'values')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: values must be a dense data array', 'values')\n\t\t\t\t}\n\t\t\t\tconst literals = snapshot.value.entries\n\t\t\t\tconst length = literals.length\n\t\t\t\tif (this.#domain === undefined && length === 0) {\n\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t'validateShape: a literal shape needs at least one value',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'empty',\n\t\t\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'literal' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// A module-scope membership question, not `set.has(value)`: this\n\t\t\t\t// uniqueness test decides whether the door accepts or refuses, so\n\t\t\t\t// `Set.prototype.has = () => false` would admit a duplicate vocabulary\n\t\t\t\t// the shape gate exists to reject.\n\t\t\t\tconst values = collectMembers([])\n\t\t\t\tfor (const index of iterateIndices(() => length)) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.values, key))\n\t\t\t\t\tif (isFailure(descriptorOutcome)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: values must be a dense data array', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tconst value = literals[index]\n\t\t\t\t\tconst stable = attempt(() => {\n\t\t\t\t\t\tconst population = current.values\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tINTRINSICS.array(population) &&\n\t\t\t\t\t\t\tINTRINSICS.same(population[index], value) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, value)\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(stable)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every node must be a recognized shape',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!stable.value) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: values must be a stable data array', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t\t\t'values',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (matchesMember(values, value)) {\n\t\t\t\t\t\treturn this.#refuse('validateShape: literal values must be unique', 'values', key)\n\t\t\t\t\t}\n\t\t\t\t\tadmitMember(values, value)\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.#domain === undefined &&\n\t\t\t\t\t\ttypeof value === 'number' &&\n\t\t\t\t\t\t!INTRINSICS.finite(value)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.#domain = new ContractError(\n\t\t\t\t\t\t\t'validateShape: a literal shape may not contain non-finite number values',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'literal',\n\t\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\t\tpath: pathOf(this.#path),\n\t\t\t\t\t\t\t\t\tshape: 'literal',\n\t\t\t\t\t\t\t\t\treceived: INTRINSICS.text(value),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#spend(1)\n\t\t\t\tthis.#children[this.#children.length] = {\n\t\t\t\t\tshape: current.inner,\n\t\t\t\t\tfirst: 'inner',\n\t\t\t\t\toptional: false,\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'string':\n\t\t\tcase 'number':\n\t\t\tcase 'boolean':\n\t\t\tcase 'null':\n\t\t\tcase 'json':\n\t\t\tcase 'shape':\n\t\t\tcase 'raw':\n\t\t\t\tbreak\n\t\t}\n\t\treturn true\n\t}\n\n\t#spend(count: number): void {\n\t\tconst budget = this.#budget\n\t\tif (budget === undefined) return\n\t\tbudget.left -= count\n\t\tif (budget.left < 0) {\n\t\t\tthrow new ContractError(`validateShape: capture exceeds the node limit ${CLONE_NODE_LIMIT}`, {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path: pathOf(this.#path), limit: CLONE_NODE_LIMIT },\n\t\t\t})\n\t\t}\n\t}\n\n\t#schedule(current: object, depth: number, segments: number): number {\n\t\tadmitVisited(this.#active, current)\n\t\tconst children: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(this.#children), [\n\t\t\t(child: unknown) => child !== undefined,\n\t\t])\n\t\tconst captured = this.#capture(current, children)\n\t\tthis.#stack[this.#stack.length] = { operation: 'exit', index: captured, segments }\n\t\tfor (const offset of iterateIndices(() => children.length)) {\n\t\t\tconst index = children.length - 1 - offset\n\t\t\tconst child = children[index]\n\t\t\tif (child === undefined) continue\n\t\t\tthis.#stack[this.#stack.length] = {\n\t\t\t\toperation: 'enter',\n\t\t\t\tshape: child.shape,\n\t\t\t\tdepth: depth + 1,\n\t\t\t\toptional: child.optional,\n\t\t\t\tfirst: child.first,\n\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t}\n\t\treturn captured\n\t}\n\n\t#capture(\n\t\tshape: object,\n\t\tchildren: ReadonlyArray<{\n\t\t\treadonly shape: unknown\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}>,\n\t): number {\n\t\tconst index = this.#captures.length\n\t\tthis.#captures[index] = {\n\t\t\tshape,\n\t\t\tcategory: this.#category,\n\t\t\tchildren,\n\t\t\traw: this.#raw,\n\t\t\tdefaulted: this.#defaulted,\n\t\t\topen: this.#open,\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#index, [shape, index])\n\t\treturn index\n\t}\n\n\t#locate(shape: unknown): number | undefined {\n\t\tif (typeof shape !== 'object' || shape === null) return undefined\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.recall, this.#index, [shape])\n\t}\n\n\t// Everything a second walk would answer, answered from the capture instead.\n\t// Reading the discovery\n\t// postorder forwards gives every bottom-up fact — subtree height and emitted\n\t// expansion — and reading it backwards gives the top-down one, the deepest\n\t// position each node occupies. Both are one pass over the captured nodes and\n\t// edges, which is what makes a shared-child declaration cost its DECLARATION\n\t// rather than its paths.\n\t#measure(): void {\n\t\t// Capture has already decided cycles in linear time. Only a DAG has a depth.\n\t\tif (this.#cycle !== undefined) {\n\t\t\tthis.#finish()\n\t\t\treturn\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#captures.length)) {\n\t\t\tthis.#height[index] = 0\n\t\t\tthis.#reach[index] = 0\n\t\t\tthis.#counts[index] = 1\n\t\t}\n\t\tfor (const step of iterateIndices(() => this.#post.length)) {\n\t\t\tconst index = this.#post[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst totals: { readonly height: number; readonly count: number } = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.fold,\n\t\t\t\tcapture.children,\n\t\t\t\t[\n\t\t\t\t\t(\n\t\t\t\t\t\tcurrent: { readonly height: number; readonly count: number },\n\t\t\t\t\t\tchild: (typeof capture.children)[number],\n\t\t\t\t\t) => {\n\t\t\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\theight: INTRINSICS.max(current.height, reached + 1),\n\t\t\t\t\t\t\tcount: current.count + (located === undefined ? 1 : (this.#counts[located] ?? 1)),\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{ height: 0, count: 1 },\n\t\t\t\t],\n\t\t\t)\n\t\t\tthis.#height[index] = totals.height\n\t\t\tthis.#counts[index] = totals.count\n\t\t}\n\t\tif ((this.#height[0] ?? 0) > COMPILE_DEPTH_LIMIT) this.#witness(0, 0, [])\n\t\t// Reverse postorder is a topological order, so a node's own deepest position\n\t\t// is final before its edges are read. Recording the edge that raised it\n\t\t// leaves a parent chain from any node back to the root, each link one level\n\t\t// shallower than the last.\n\t\tfor (const offset of iterateIndices(() => this.#post.length)) {\n\t\t\tconst step = this.#post.length - 1 - offset\n\t\t\tconst index = this.#post[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst base = this.#reach[index] ?? 0\n\t\t\tfor (const edge of iterateIndices(() => capture.children.length)) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tif (located === undefined) continue\n\t\t\t\tif ((this.#reach[located] ?? 0) >= base + 1) continue\n\t\t\t\tthis.#reach[located] = base + 1\n\t\t\t\tthis.#via[located] = {\n\t\t\t\t\tparent: index,\n\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const index of iterateIndices(() => this.#captures.length)) {\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined || capture.raw === 0) continue\n\t\t\tif ((this.#reach[index] ?? 0) + capture.raw <= COMPILE_DEPTH_LIMIT) continue\n\t\t\tthis.#structure ??= new ContractError(\n\t\t\t\t'validateShape: raw schema exceeds the compilation depth limit',\n\t\t\t\t{ code: 'structure', context: { path: pathOf(this.#ascend(index), 'schema') } },\n\t\t\t)\n\t\t}\n\t\tthis.#placeDefaults()\n\t}\n\n\t// Where a default can fill is a fact about every route to it, and a shared node is\n\t// discovered through one route alone, so this is asked over the captured graph. It\n\t// reads the reverse postorder top-down: a node's union ancestry is final before its\n\t// edges are read, so one pass answers every route. A union's parser returns a\n\t// guard-valid value by identity, so a default below one fills only the inputs that\n\t// needed a coercion. An open object takes a misspelled key as an extra, so a default\n\t// beside one fills the real key with no fault to report it.\n\t#placeDefaults(): void {\n\t\tconst carried = INTRINSICS.reflect.apply(INTRINSICS.some, this.#captures, [\n\t\t\t(capture: { readonly defaulted: boolean }) => capture.defaulted,\n\t\t])\n\t\tif (!carried) return\n\t\tfor (const offset of iterateIndices(() => this.#post.length)) {\n\t\t\tconst index = this.#post[this.#post.length - 1 - offset]\n\t\t\tif (index === undefined) continue\n\t\t\tconst capture = this.#captures[index]\n\t\t\tif (capture === undefined) continue\n\t\t\tconst enclosed =\n\t\t\t\tcapture.category === 'union' ||\n\t\t\t\t(INTRINSICS.own(this.#within, index) && this.#within[index] !== undefined)\n\t\t\tfor (const edge of iterateIndices(() => capture.children.length)) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tif (located === undefined) continue\n\t\t\t\tif (\n\t\t\t\t\tenclosed &&\n\t\t\t\t\t(!INTRINSICS.own(this.#within, located) || this.#within[located] === undefined)\n\t\t\t\t) {\n\t\t\t\t\tthis.#within[located] = {\n\t\t\t\t\t\tparent: index,\n\t\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t\t...(INTRINSICS.own(child, 'second') && child.second !== undefined\n\t\t\t\t\t\t\t? { second: child.second }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.#captures[located]?.defaulted !== true) continue\n\t\t\t\t// Keep own guards consistent; valid optional-property edges always own their second segment.\n\t\t\t\tif (enclosed) {\n\t\t\t\t\tthis.#domain ??= new ContractError(\n\t\t\t\t\t\t'validateShape: a default may not sit under a union, whose parser can return a valid value without filling it; move the default outside the union or remove it',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\tpath: pathOf(\n\t\t\t\t\t\t\t\t\tthis.#route(index),\n\t\t\t\t\t\t\t\t\tchild.first,\n\t\t\t\t\t\t\t\t\tINTRINSICS.own(child, 'second') ? child.second : undefined,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (capture.open) {\n\t\t\t\t\tthis.#domain ??= new ContractError(\n\t\t\t\t\t\t'validateShape: a default may not sit on a property of an open object, where a misspelled key would fill it unreported; close the object or remove the default',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\tpath: pathOf(\n\t\t\t\t\t\t\t\t\tthis.#ascend(index),\n\t\t\t\t\t\t\t\t\tchild.first,\n\t\t\t\t\t\t\t\t\tINTRINSICS.own(child, 'second') ? child.second : undefined,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// The path to a node through the union edge recorded for it, falling back to its\n\t// deepest occurrence above the union that encloses it.\n\t#route(index: number): readonly string[] {\n\t\tconst edge = INTRINSICS.own(this.#within, index) ? this.#within[index] : undefined\n\t\treturn edge === undefined\n\t\t\t? this.#ascend(index)\n\t\t\t: pathOf(\n\t\t\t\t\tthis.#route(edge.parent),\n\t\t\t\t\tedge.first,\n\t\t\t\t\tINTRINSICS.own(edge, 'second') ? edge.second : undefined,\n\t\t\t\t)\n\t}\n\n\t// The declaration path to a node's DEEPEST occurrence, spelled out by walking\n\t// the improving edges back to the root and reversing them. The raw-depth rule\n\t// is re-asked from that occurrence, so the diagnostic has to name it too: the\n\t// first-discovered path names a slot that, on its own, validates.\n\t#ascend(index: number): readonly string[] {\n\t\tif (index === 0) return []\n\t\tconst edge = INTRINSICS.own(this.#via, index) ? this.#via[index] : undefined\n\t\treturn edge === undefined\n\t\t\t? []\n\t\t\t: pathOf(\n\t\t\t\t\tthis.#ascend(edge.parent),\n\t\t\t\t\tedge.first,\n\t\t\t\t\tINTRINSICS.own(edge, 'second') ? edge.second : undefined,\n\t\t\t\t)\n\t}\n\n\t// The first excessive-depth witness in declaration order, reconstructed rather\n\t// than searched for: at each level the earliest edge whose remaining height\n\t// still overshoots the allowance is the edge a pre-order walk would have taken.\n\t#witness(index: number | undefined, depth: number, path: readonly string[]): never {\n\t\tif (depth <= COMPILE_DEPTH_LIMIT) {\n\t\t\tconst capture = index === undefined ? undefined : this.#captures[index]\n\t\t\tconst children = capture === undefined ? [] : capture.children\n\t\t\tconst selected: number = INTRINSICS.reflect.apply(INTRINSICS.find, children, [\n\t\t\t\t(child: (typeof children)[number]) => {\n\t\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\t\treturn depth + 1 + reached > COMPILE_DEPTH_LIMIT\n\t\t\t\t},\n\t\t\t])\n\t\t\tconst chosen = children[selected]\n\t\t\tif (chosen !== undefined) {\n\t\t\t\treturn this.#witness(\n\t\t\t\t\tthis.#locate(chosen.shape),\n\t\t\t\t\tdepth + 1,\n\t\t\t\t\tpathOf(path, chosen.first, INTRINSICS.own(chosen, 'second') ? chosen.second : undefined),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tthrow new ContractError('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\tcode: 'depth',\n\t\t\tcontext: { path: pathOf(path), limit: COMPILE_DEPTH_LIMIT },\n\t\t})\n\t}\n\n\t#finish(): void {\n\t\tif (this.#structure !== undefined) throw this.#structure\n\t\tif (this.#cycle !== undefined) throw this.#cycle\n\t\tif (this.#domain !== undefined) throw this.#domain\n\t}\n\n\t#refuseSchema(\n\t\tmessage: string,\n\t\tstack: ReadonlyArray<{\n\t\t\treadonly operation: 'enter' | 'exit'\n\t\t\treadonly first?: string\n\t\t\treadonly second?: string\n\t\t}>,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t\tkeyword?: string,\n\t\tmember?: string,\n\t): false {\n\t\tif (this.#structure !== undefined) return false\n\t\tconst ancestors: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.expand,\n\t\t\treadIndexView(stack),\n\t\t\t[\n\t\t\t\t(frame: {\n\t\t\t\t\treadonly operation: 'enter' | 'exit'\n\t\t\t\t\treadonly first?: string\n\t\t\t\t\treadonly second?: string\n\t\t\t\t}) =>\n\t\t\t\t\tframe.operation === 'exit'\n\t\t\t\t\t\t? pathOf(\n\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\tINTRINSICS.own(frame, 'first') ? frame.first : undefined,\n\t\t\t\t\t\t\t\tINTRINSICS.own(frame, 'second') ? frame.second : undefined,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [],\n\t\t\t],\n\t\t)\n\t\tconst prefix: string[] = []\n\t\tappendEntries(prefix, this.#path)\n\t\tprefix[prefix.length] = 'schema'\n\t\tappendEntries(prefix, ancestors)\n\t\tconst path = pathOf(prefix, first, second)\n\t\treturn this.#refuse(message, keyword, member, path)\n\t}\n\n\t#refuse(\n\t\tmessage: string,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t\tprefix: readonly string[] = this.#path,\n\t): false {\n\t\tif (this.#structure === undefined) {\n\t\t\tconst path = pathOf(prefix, first, second)\n\t\t\tthis.#structure = new ContractError(message, {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\treturn false\n\t}\n}\n","import type { ShapeValidatorInterface } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { pinMembers } from './helpers.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Validates one retained contract-shape source live on every call.\n *\n * @remarks\n * Construction performs no source observation. Every non-overlapping\n * {@link validate} call starts a fresh pass over the source's current state.\n * Reentry poisons the active pass with one shared cause-free structure error;\n * cleanup always restores an idle validator for the next independent call.\n *\n * @example\n * ```ts\n * const validator = new ShapeValidator({ category: 'string', min: 1 })\n * validator.validate()\n * ```\n */\nexport class ShapeValidator implements ShapeValidatorInterface {\n\treadonly #source: unknown\n\treadonly #passes = new INTRINSICS.set<ShapePass>()\n\t#expansion: number | undefined\n\n\t/**\n\t * Retains a shape source without observing it.\n\t *\n\t * @param shape - The live shape source validated by each call\n\t */\n\tconstructor(shape: unknown) {\n\t\tthis.#source = shape\n\t}\n\n\t/**\n\t * Reports the number of nodes the last successful {@link validate} found the\n\t * source expands into.\n\t *\n\t * @remarks\n\t * One per node per INCOMING EDGE, summed bottom-up — the size of the tree a\n\t * compiler would build from this DAG, which a node count of the declaration\n\t * itself does not describe. `undefined` before the first successful pass and\n\t * after a failed one, because a failed pass has no expansion to report and\n\t * `0` is a measurement no declaration produces.\n\t */\n\tget expansion(): number | undefined {\n\t\treturn this.#expansion\n\t}\n\n\t/**\n\t * Validates the retained source's current declaration.\n\t *\n\t * @remarks\n\t * The whole traversal is contained, and a failure this class did not author\n\t * is translated into `validateShape: shape reflection failed` carrying\n\t * the exact thrown value. Containment is what makes that claim hold for\n\t * dispatch nobody enumerated — including the recognition of an authored error,\n\t * which is why that recognition is no longer answerable by any member a caller\n\t * can write. The sentence this replaces asserted the same conclusion from the\n\t * absence of reachable dispatch, and the absence was not established.\n\t *\n\t * @returns Nothing when the declaration is valid\n\t * @throws {ContractError} When the declaration is malformed, cyclic, too deep, unreadable, or reentered\n\t */\n\tvalidate(): void {\n\t\tINTRINSICS.reflect.apply(INTRINSICS.sweep, this.#passes, [\n\t\t\t(pass: ShapePass) => pass.interrupt(),\n\t\t])\n\t\tconst pass = new ShapePass(this.#source, { left: CLONE_NODE_LIMIT })\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, this.#passes, [pass])\n\t\tthis.#expansion = undefined\n\t\ttry {\n\t\t\tthis.#expansion = pass.validate()\n\t\t} finally {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.remove, this.#passes, [pass])\n\t\t}\n\t}\n\n\tstatic {\n\t\tpinMembers(ShapeValidator.prototype, 'ShapeValidator')\n\t}\n}\n","import type {\n\tArrayShape,\n\tBooleanShape,\n\tContractErrorOptions,\n\tContractShape,\n\tJSONShape,\n\tLiteralShape,\n\tLiteralValue,\n\tNullableShape,\n\tNullShape,\n\tNumberShape,\n\tObjectShape,\n\tOptionalShape,\n\tRawShape,\n\tResult,\n\tShapeClonerInterface,\n\tShapeProperty,\n\tShapeShape,\n\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport { CLONE_NODE_LIMIT, COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitVisited,\n\tappendEntries,\n\tattempt,\n\tfailure,\n\tisFailure,\n\tisSuccess,\n\titerateIndices,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isObject, isRecord, isRegExp } from './validators.js'\nimport { JSONCloner } from './JSONCloner.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Owns the state of one contract-shape snapshot operation.\n *\n * @remarks\n * Construction retains the source without observing it. The first\n * {@link clone} call captures and validates one owned graph and settles\n * permanently. Success replays the exact frozen root; failure rethrows the\n * exact class-owned or directly adopted error. Nonredirectable settlement\n * releases populated traversal state before publishing that result. Reentry\n * poisons the active operation and every later call with one shared cause-free\n * error.\n *\n * @param shape - The contract-shape graph to retain for cloning\n *\n * @example\n * ```ts\n * const cloner = new ShapeCloner({ category: 'string', min: 1 })\n * const clone = cloner.clone()\n * cloner.clone() === clone // true\n * ```\n */\nexport class ShapeCloner implements ShapeClonerInterface {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. So no\n\t// caller code that runs AFTER this module can replace\n\t// them. Terminal settlement must reach the genuine implementation of every\n\t// intrinsic it dispatches through, or a caller who redirects one after\n\t// construction makes the first call escape with a raw caller value while the\n\t// replay reports the reentry poison — two different answers for one\n\t// operation. The constructor is already too late: a poison error, and so its\n\t// ownership record, is created before the source is ever observed. The\n\t// CONSTRUCTOR of each collection is captured beside its members, because\n\t// construction happens first: capturing `WeakSet.prototype.has` while still\n\t// reaching `globalThis.WeakSet` leaves the door open one call earlier than\n\t// the member rows can see, and the constructor runs outside every\n\t// containment this class has.\n\tstatic readonly #map = Map\n\tstatic readonly #weakSet = WeakSet\n\t// The released state, shared by every cloner this class ever builds. `#settle`\n\t// assigns these in place of the working lists, so an instance allocates one\n\t// collection per family instead of two and construction carries no empty peer\n\t// of its own. Sharing them is safe because nothing writes to a released list:\n\t// every writer runs inside the walk and `#settle` is the walk's last step. The\n\t// static block at the foot of the class freezes them, so a write that did\n\t// reach one fails loudly at its own line rather than leaking one cloner's node\n\t// into every other cloner's release.\n\tstatic readonly #emptyPending: Array<{\n\t\treadonly shape: ContractShape\n\t\treadonly depth: number\n\t}> = []\n\tstatic readonly #emptySources: ContractShape[] = []\n\treadonly #source: ContractShape\n\treadonly #owned: WeakSet<object>\n\t// The working maps are the fields with no shared peer: `Object.freeze` reaches\n\t// an array's writes and not a `Map`'s, so a shared empty map would be a\n\t// class-lifetime cache any write could fill with one cloner's nodes. `#settle`\n\t// drops them instead, and absence is `undefined`.\n\t#memo: Map<ContractShape, ContractShape> | undefined\n\t#paths: Map<ContractShape, readonly string[]> | undefined\n\t// An ordered ENTRY LIST rather than a `Map`: every consumer of this snapshot\n\t// walks it to decide the published property population, and iterating a `Map`\n\t// dispatches through `Map.prototype[Symbol.iterator]` while destructuring each\n\t// `[key, child]` pair dispatches through `Array.prototype[Symbol.iterator]`.\n\t// A caller-installed iterator that substitutes the first element of a\n\t// two-element entry — same arity, so every downstream structural check still\n\t// passes — published a frozen shape whose property was RENAMED to the\n\t// caller's text.\n\t#properties: Map<ContractShape, readonly ShapeProperty[]> | undefined\n\t#variants: Map<ContractShape, ReadonlyArray<ContractShape | undefined>> | undefined\n\t// FIFO, walked with a read cursor rather than `pop()`. A LIFO drain captured\n\t// siblings in REVERSE declaration order, so the first refusal this class threw\n\t// named the LAST offending sibling while the shared gate named the first — one\n\t// declaration, two different codes, messages and `context.path` values from\n\t// doors the guide names in one sentence as agreeing.\n\t#pending: Array<{ readonly shape: ContractShape; readonly depth: number }>\n\t#sources: ContractShape[]\n\t#fidelity: ContractError | undefined\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'settled'; readonly result: Result<ContractShape, ContractError> }\n\n\tconstructor(shape: ContractShape) {\n\t\tthis.#source = shape\n\t\tthis.#owned = new ShapeCloner.#weakSet()\n\t\tthis.#memo = new ShapeCloner.#map()\n\t\tthis.#paths = new ShapeCloner.#map()\n\t\tthis.#properties = new ShapeCloner.#map()\n\t\tthis.#variants = new ShapeCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#sources = []\n\t\tthis.#fidelity = undefined\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clones the retained declaration into an owned, validated frozen graph.\n\t *\n\t * @returns The settled contract-shape snapshot\n\t * @throws {ContractError} When the declaration is malformed, unreadable, cyclic, too deep, or cloning is reentered\n\t */\n\tclone(): ContractShape {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'settled') {\n\t\t\tif (isSuccess(state.result)) return state.result.value\n\t\t\tthrow state.result.error\n\t\t}\n\t\tif (state.phase === 'running' || state.phase === 'interrupted') {\n\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\tthrow state.poison\n\t\t}\n\n\t\tconst poison = this.#create('ShapeCloner.clone: shape cloning may not be reentered', {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'shape' },\n\t\t})\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#complete(attempt(() => this.#execute()))\n\t}\n\n\t#complete(outcome: Result<ContractShape>): ContractShape {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') {\n\t\t\treturn this.#settle(failure(state.poison))\n\t\t}\n\t\tif (isSuccess(outcome)) return this.#settle(outcome)\n\n\t\tconst error = this.#owns(outcome.error)\n\t\t\t? outcome.error\n\t\t\t: this.#create('cloneShape: failed to create an owned shape snapshot', {\n\t\t\t\t\tcode: 'clone',\n\t\t\t\t\tcontext: { shape: 'shape' },\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t})\n\t\treturn this.#settle(failure(error))\n\t}\n\n\t#execute(): ContractShape {\n\t\tconst budget = { left: CLONE_NODE_LIMIT }\n\t\t// Narrowed once at the door, because both dispatches below take their\n\t\t// receiver type from these values. The walk runs before `#settle` drops\n\t\t// them, so it always finds the maps the constructor built; this refusal is\n\t\t// what keeps that a statement the types carry rather than one a comment\n\t\t// makes.\n\t\tconst paths = this.#paths\n\t\tconst memo = this.#memo\n\t\tif (paths === undefined || memo === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, paths, [this.#source, []])\n\t\tthis.#pending[this.#pending.length] = { shape: this.#source, depth: 0 }\n\t\tthis.#drain(budget)\n\t\tthis.#wireNodes()\n\t\tconst root = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [this.#source])\n\t\tif (root === undefined) {\n\t\t\tthrow this.#create('ShapeCloner.clone: captured root is unavailable', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'shape' },\n\t\t\t})\n\t\t}\n\t\tthis.#freezeNodes()\n\t\t// Capture has already charged the retained edges and copied defaults. The\n\t\t// existing validation inspects that bounded owned graph without charging\n\t\t// the same ownership a second time.\n\t\tthis.#validateShape(root)\n\t\tif (this.#fidelity !== undefined) throw this.#fidelity\n\t\treturn root\n\t}\n\n\t#drain(budget: { left: number }): void {\n\t\t// A read cursor, so the walk is breadth-first in DECLARATION order. The\n\t\t// cursor also makes the level a node was reached at meaningful: it is the\n\t\t// SHORTEST path to that node, so this bound never refuses a graph the\n\t\t// validator would accept.\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tfor (const cursor of iterateIndices(() => this.#pending.length)) {\n\t\t\tconst entry = this.#pending[cursor]\n\t\t\tif (entry === undefined) continue\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.keyed, memo, [entry.shape])) continue\n\t\t\t// The depth verdict is reached in time proportional to the LIMIT rather\n\t\t\t// than to the caller's declaration. Capturing, wiring and freezing a\n\t\t\t// 4,000-level chain that is CERTAIN to be refused cost 120 ms against\n\t\t\t// `validateShape`'s 1 ms for the identical verdict, and the cost is\n\t\t\t// quadratic because every child registration copies its whole path.\n\t\t\tif (entry.depth > COMPILE_DEPTH_LIMIT) this.#refuseDepth(budget)\n\t\t\tthis.#captureNode(entry.shape, entry.depth, budget)\n\t\t}\n\t}\n\n\t// Acceptance agrees with validation; refusal diagnoses agree only below the capture limit.\n\t#refuseDepth(budget: { left: number }): never {\n\t\tthis.#validateShape(this.#source, [], budget)\n\t\tthrow this.#create('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\tcode: 'depth',\n\t\t\tcontext: { path: [], limit: COMPILE_DEPTH_LIMIT },\n\t\t})\n\t}\n\n\t#captureShell(\n\t\tsource: ContractShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ContractShape {\n\t\tif (!matchesRecordBrand(source)) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\tconst descriptor = INTRINSICS.describe(source, 'category')\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\tthrow this.#create('cloneShape: every node needs an own data discriminant', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\t\tconst category = source.category\n\t\tconst repeated = source.category\n\t\tif (!INTRINSICS.same(descriptor.value, category) || !INTRINSICS.same(repeated, category)) {\n\t\t\tthrow this.#create('cloneShape: every node needs an own data discriminant', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path },\n\t\t\t})\n\t\t}\n\n\t\tswitch (category) {\n\t\t\tcase 'string':\n\t\t\t\treturn this.#captureString(source, path)\n\t\t\tcase 'number':\n\t\t\t\treturn this.#captureNumber(source, path)\n\t\t\tcase 'boolean':\n\t\t\t\treturn this.#captureSimple(source, path, 'boolean')\n\t\t\tcase 'null':\n\t\t\t\treturn this.#captureSimple(source, path, 'null')\n\t\t\tcase 'literal':\n\t\t\t\treturn this.#captureLiteral(source, path)\n\t\t\tcase 'array':\n\t\t\t\treturn this.#captureArray(source, path, budget)\n\t\t\tcase 'object':\n\t\t\t\treturn this.#captureObject(source, path, budget)\n\t\t\tcase 'union':\n\t\t\t\treturn this.#captureUnion(source, path, budget)\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#captureOptional(source, path, budget)\n\t\t\tcase 'nullable':\n\t\t\t\treturn this.#captureNullable(source, path, budget)\n\t\t\tcase 'json':\n\t\t\t\treturn this.#captureSimple(source, path, 'json')\n\t\t\tcase 'shape':\n\t\t\t\treturn this.#captureSimple(source, path, 'shape')\n\t\t\tcase 'raw':\n\t\t\t\treturn this.#captureRaw(source, path, budget)\n\t\t\tdefault:\n\t\t\t\tthrow this.#create('validateShape: every node must be a recognized shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path },\n\t\t\t\t})\n\t\t}\n\t}\n\n\t#captureField<S extends object, K extends keyof S & string>(\n\t\tsource: S,\n\t\tfield: K,\n\t\tpath: readonly string[],\n\t): S[K] | undefined {\n\t\tconst descriptor = INTRINSICS.describe(source, field)\n\t\tif (descriptor === undefined) {\n\t\t\tif (INTRINSICS.reflect.present(source, field)) {\n\t\t\t\tthrow this.#create('cloneShape: inherited shape fields cannot be owned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\t\tif (!INTRINSICS.own(descriptor, 'value')) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t})\n\t\t}\n\t\tconst first = source[field]\n\t\tconst second = source[field]\n\t\tif (!INTRINSICS.same(first, descriptor.value) || !INTRINSICS.same(second, first)) {\n\t\t\tthrow this.#create('cloneShape: shape fields must be stable data', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, field) },\n\t\t\t})\n\t\t}\n\t\treturn first\n\t}\n\n\t#capturePattern(\n\t\tsource: StringShape,\n\t\tpath: readonly string[],\n\t): { readonly source: string; readonly flags: string } | undefined {\n\t\tconst descriptor = INTRINSICS.describe(source, 'pattern')\n\t\tif (descriptor === undefined) {\n\t\t\tif (INTRINSICS.reflect.present(source, 'pattern')) {\n\t\t\t\tthrow this.#create('cloneShape: inherited shape fields cannot be owned', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn undefined\n\t\t}\n\n\t\tif (INTRINSICS.own(descriptor, 'value')) {\n\t\t\tconst first = source.pattern\n\t\t\tconst second = source.pattern\n\t\t\tif (!INTRINSICS.same(first, descriptor.value) || !INTRINSICS.same(second, first)) {\n\t\t\t\tthrow this.#create('cloneShape: shape fields must be stable data', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn this.#capturePatternValue(first, path)\n\t\t}\n\n\t\tconst first = source.pattern\n\t\tconst second = source.pattern\n\t\tif (!isRegExp(first) || !isRegExp(second)) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\t// Each revealed RegExp is captured once, through the same scalar-pair\n\t\t// routine the data population uses, and the two captured PRIMITIVE pairs\n\t\t// are what get compared. Reading scalars here and then handing a\n\t\t// already-observed RegExp back to that routine would observe it twice, so\n\t\t// an accessor that answers one observation per value lost its deferred\n\t\t// stable-pattern diagnosis to an outer hostile-read translation.\n\t\tconst firstValue = this.#capturePatternValue(first, path)\n\t\tif (firstValue === undefined) return undefined\n\t\tconst secondValue = this.#capturePatternValue(second, path)\n\t\tif (secondValue === undefined) return undefined\n\t\tif (\n\t\t\tfirstValue.source !== secondValue.source ||\n\t\t\tfirstValue.flags !== secondValue.flags ||\n\t\t\t!INTRINSICS.frozen(first) ||\n\t\t\t!INTRINSICS.frozen(second)\n\t\t) {\n\t\t\tthrow this.#create('cloneShape: shape accessors cannot be owned faithfully', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\treturn firstValue\n\t}\n\n\t#capturePatternValue(\n\t\tpattern: RegExp | undefined,\n\t\tpath: readonly string[],\n\t): { readonly source: string; readonly flags: string } | undefined {\n\t\tif (pattern === undefined) return undefined\n\t\tif (!isRegExp(pattern)) {\n\t\t\tthrow this.#create('validateShape: string pattern must be a RegExp', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t}\n\t\t// Both reads go through the CAPTURED accessors. `source` and `flags` are\n\t\t// getters on a shared prototype, so a replaced getter reports for every\n\t\t// pattern in the realm, not only the caller's — and it decided the pattern a\n\t\t// published shape carries. The repeated read still earns its place: it\n\t\t// diagnoses an accessor that answers once per value, which capture does not\n\t\t// address.\n\t\tconst sourceText: unknown = readPatternSource(pattern)\n\t\tconst flags: unknown = readPatternFlags(pattern)\n\t\tconst repeated = attempt(() => {\n\t\t\tconst repeatedFlags: unknown = readPatternFlags(pattern)\n\t\t\tconst repeatedSource: unknown = readPatternSource(pattern)\n\t\t\treturn { flags: repeatedFlags, source: repeatedSource }\n\t\t})\n\t\tif (\n\t\t\ttypeof sourceText !== 'string' ||\n\t\t\ttypeof flags !== 'string' ||\n\t\t\tisFailure(repeated) ||\n\t\t\ttypeof repeated.value.source !== 'string' ||\n\t\t\ttypeof repeated.value.flags !== 'string' ||\n\t\t\trepeated.value.source !== sourceText ||\n\t\t\trepeated.value.flags !== flags\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: string pattern must be stable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'pattern') },\n\t\t\t})\n\t\t\treturn undefined\n\t\t}\n\t\treturn { source: sourceText, flags }\n\t}\n\n\t#captureNode(source: ContractShape, depth: number, budget: { left: number }): void {\n\t\tconst paths = this.#paths\n\t\tconst memo = this.#memo\n\t\tif (paths === undefined || memo === undefined) throw this.#unavailable()\n\t\tconst path = INTRINSICS.reflect.apply(INTRINSICS.fetch, paths, [source]) ?? []\n\t\tconst clone = this.#captureShell(source, path, budget)\n\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, memo, [source, clone])\n\t\tthis.#sources[this.#sources.length] = source\n\t\tthis.#scheduleNode(source, clone, path, depth)\n\t}\n\n\t#captureString(source: StringShape, path: readonly string[]): StringShape {\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst pattern = this.#capturePattern(source, path)\n\t\tconst date = this.#captureField(source, 'date', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// No declaration-policy rule is enforced here. `ShapeValidator` owns every\n\t\t// bound, range and pattern-flag rule and runs on the carried clone at\n\t\t// `#execute`. A second copy here would fire EARLIER, in capture order rather\n\t\t// than declaration order and before structure outranks domain, so `cloneShape`\n\t\t// would name a different rule at a different path than the shared gate for one\n\t\t// declaration. One rule, one arbiter.\n\t\tconst fields: StringShape = {\n\t\t\tcategory: 'string',\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(date === undefined ? {} : { date }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t\tif (pattern === undefined) return fields\n\t\tconst sourceText = pattern.source\n\t\tconst flags = pattern.flags\n\t\treturn {\n\t\t\t...fields,\n\t\t\tget pattern() {\n\t\t\t\treturn INTRINSICS.freeze(new INTRINSICS.pattern(sourceText, flags))\n\t\t\t},\n\t\t}\n\t}\n\n\t#captureNumber(source: NumberShape, path: readonly string[]): NumberShape {\n\t\tconst integer = this.#captureField(source, 'integer', path)\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// Domain rules belong to the single gate on the carried clone; see\n\t\t// `#captureString`.\n\t\treturn {\n\t\t\tcategory: 'number',\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(integer === undefined ? {} : { integer }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureSimple(\n\t\tsource: BooleanShape | NullShape | JSONShape | ShapeShape,\n\t\tpath: readonly string[],\n\t\tcategory: 'boolean' | 'null' | 'json' | 'shape',\n\t): BooleanShape | NullShape | JSONShape | ShapeShape {\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tif (category === 'boolean') {\n\t\t\treturn { category: 'boolean', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\tif (category === 'null') {\n\t\t\treturn { category: 'null', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\tif (category === 'shape') {\n\t\t\treturn { category: 'shape', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\treturn { category: 'json', ...(description === undefined ? {} : { description }) }\n\t}\n\n\t#captureLiteral(source: LiteralShape, path: readonly string[]): LiteralShape {\n\t\tconst values = this.#captureField(source, 'values', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tconst entries = this.#captureLiterals(values, path)\n\t\treturn {\n\t\t\tcategory: 'literal',\n\t\t\tvalues: entries,\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureArray(source: ArrayShape, path: readonly string[], budget: { left: number }): ArrayShape {\n\t\tthis.#spend(budget, 1, path)\n\t\tconst items = this.#captureField(source, 'items', path)\n\t\tconst min = this.#captureField(source, 'min', path)\n\t\tconst max = this.#captureField(source, 'max', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\t// Domain rules belong to the single gate on the carried clone; see\n\t\t// `#captureString`. A missing `items` is not a domain rule — the node\n\t\t// cannot be BUILT without it — so that refusal stays here, and it is\n\t\t// `structure`, the family the validator itself ranks first.\n\t\tif (items === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'items') },\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcategory: 'array',\n\t\t\titems,\n\t\t\t...(min === undefined ? {} : { min }),\n\t\t\t...(max === undefined ? {} : { max }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureObject(\n\t\tsource: ObjectShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ObjectShape {\n\t\tconst propertySource = this.#captureField(source, 'properties', path)\n\t\tconst additional = this.#captureField(source, 'additionalProperties', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tif (!isRecord(propertySource)) {\n\t\t\tthrow this.#create('validateShape: properties must be a plain property map', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'properties') },\n\t\t\t})\n\t\t}\n\t\tthis.#captureProperties(source, propertySource, path, budget)\n\t\tif (additional !== undefined && additional !== true && additional !== false)\n\t\t\tthis.#spend(budget, 1, path)\n\t\tconst properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\treturn {\n\t\t\tcategory: 'object',\n\t\t\tproperties,\n\t\t\t...(additional === undefined ? {} : { additionalProperties: additional }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureUnion(source: UnionShape, path: readonly string[], budget: { left: number }): UnionShape {\n\t\tconst variantSource = this.#captureField(source, 'variants', path)\n\t\tconst mode = this.#captureField(source, 'mode', path)\n\t\tconst description = this.#captureField(source, 'description', path)\n\t\tthis.#captureVariants(source, variantSource, path, budget)\n\t\treturn {\n\t\t\tcategory: 'union',\n\t\t\tvariants: [],\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t}\n\t}\n\n\t#captureOptional(\n\t\tsource: OptionalShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): OptionalShape {\n\t\tconst inner = this.#captureInner(source, path, budget)\n\t\tconst value = this.#captureField(source, 'default', path)\n\t\tif (!INTRINSICS.own(source, 'default')) return { category: 'optional', inner }\n\t\t// The one domain rule capture must answer itself, because a value that cannot be\n\t\t// copied cannot be carried to the gate; it refuses as that gate does.\n\t\tconst owned = isJSONValue(value)\n\t\t\t? attempt(() => new JSONCloner(value).clone(budget))\n\t\t\t: undefined\n\t\tif (\n\t\t\towned !== undefined &&\n\t\t\tisFailure(owned) &&\n\t\t\tbudget.left < 0 &&\n\t\t\tisContractError(owned.error)\n\t\t) {\n\t\t\tthrow this.#prefix(owned.error, pathOf(path, 'default'))\n\t\t}\n\t\tif (owned === undefined || isFailure(owned)) {\n\t\t\tthrow this.#create('validateShape: an optional default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'default') },\n\t\t\t})\n\t\t}\n\t\treturn { category: 'optional', inner, default: owned.value }\n\t}\n\n\t#captureNullable(\n\t\tsource: NullableShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): NullableShape {\n\t\treturn { category: 'nullable', inner: this.#captureInner(source, path, budget) }\n\t}\n\n\t#captureInner(\n\t\tsource: OptionalShape | NullableShape,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): ContractShape {\n\t\tthis.#spend(budget, 1, path)\n\t\tconst inner = this.#captureField(source, 'inner', path)\n\t\tif (inner === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'inner') },\n\t\t\t})\n\t\t}\n\t\treturn inner\n\t}\n\n\t#captureRaw(source: RawShape, path: readonly string[], budget: { left: number }): RawShape {\n\t\tconst schema = this.#captureField(source, 'schema', path)\n\t\tif (!isRecord(schema)) {\n\t\t\tthrow this.#create('validateShape: raw schema must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'schema') },\n\t\t\t})\n\t\t}\n\t\tthis.#validateShape({ category: 'raw', schema }, path, budget)\n\t\tconst outcome = attempt(() => new SchemaCloner(schema).clone())\n\t\tif (isFailure(outcome)) {\n\t\t\tif (isContractError(outcome.error)) {\n\t\t\t\tthrow this.#prefix(outcome.error, pathOf(path, 'schema'))\n\t\t\t}\n\t\t\tthrow outcome.error\n\t\t}\n\t\treturn { category: 'raw', schema: outcome.value }\n\t}\n\n\t#captureLiterals(\n\t\tvalues: readonly LiteralValue[] | undefined,\n\t\tpath: readonly string[],\n\t): readonly LiteralValue[] {\n\t\tif (!INTRINSICS.array(values)) {\n\t\t\tthrow this.#create('validateShape: values must be a finite literal array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tconst snapshot = readArrayEntries(values)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow this.#create('validateShape: values must be a finite literal array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow this.#create('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values') },\n\t\t\t})\n\t\t}\n\t\tconst entries = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.value.entries.length),\n\t\t\t(index) => this.#literal(values, snapshot.value.entries[index], index, path),\n\t\t)\n\t\treturn INTRINSICS.freeze(entries)\n\t}\n\n\t#literal(\n\t\tvalues: readonly LiteralValue[],\n\t\tvalue: unknown,\n\t\tindex: number,\n\t\tpath: readonly string[],\n\t): LiteralValue {\n\t\tconst key = INTRINSICS.text(index)\n\t\tconst descriptor = attempt(() => INTRINSICS.describe(values, key))\n\t\tconst repeated = attempt(() => values[index])\n\t\tif (\n\t\t\tisFailure(descriptor) ||\n\t\t\tdescriptor.value === undefined ||\n\t\t\t!INTRINSICS.own(descriptor.value, 'value')\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t})\n\t\t} else if (\n\t\t\tisFailure(repeated) ||\n\t\t\t!INTRINSICS.same(repeated.value, value) ||\n\t\t\t!INTRINSICS.same(descriptor.value.value, value)\n\t\t) {\n\t\t\tthis.#fidelity ??= this.#create('validateShape: values must be a stable data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t})\n\t\t}\n\t\tif (!isLiteralValue(value)) {\n\t\t\tthrow this.#create(\n\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t{\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'values', key) },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn value\n\t}\n\n\t#captureProperties(\n\t\tsource: ObjectShape,\n\t\tproperties: Readonly<Record<string, ContractShape>>,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): void {\n\t\tconst keys = INTRINSICS.keys(properties)\n\t\tconst snapshot: readonly ShapeProperty[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(keys),\n\t\t\t[\n\t\t\t\t(key: string) => {\n\t\t\t\t\tthis.#spend(budget, 1, path)\n\t\t\t\t\tconst descriptor = INTRINSICS.describe(properties, key)\n\t\t\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst child = properties[key]\n\t\t\t\t\tconst repeated = properties[key]\n\t\t\t\t\tconst described: unknown = descriptor.value\n\t\t\t\t\tif (!INTRINSICS.same(described, child) || !INTRINSICS.same(child, repeated)) {\n\t\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn { key, child }\n\t\t\t\t},\n\t\t\t],\n\t\t)\n\t\tconst repeated = INTRINSICS.keys(properties)\n\t\tconst drifted =\n\t\t\trepeated.length !== keys.length ||\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, repeated, [\n\t\t\t\t(key: string, index: number) => key !== keys[index],\n\t\t\t])\n\t\tif (drifted) {\n\t\t\tthrow this.#create('cloneShape: property keys must be stable data', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'properties') },\n\t\t\t})\n\t\t}\n\t\tconst captured = this.#properties\n\t\tif (captured === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, captured, [source, snapshot])\n\t}\n\n\t#captureVariants(\n\t\tsource: UnionShape,\n\t\tvariants: readonly ContractShape[] | undefined,\n\t\tpath: readonly string[],\n\t\tbudget: { left: number },\n\t): void {\n\t\tif (!INTRINSICS.array(variants)) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst snapshot = readArrayEntries(variants)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow this.#create('validateShape: variants must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst entries = snapshot.value.entries\n\t\tthis.#spend(budget, entries.length, path)\n\t\tconst captured = this.#variants\n\t\tif (captured === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, captured, [source, entries])\n\t\tfor (const index of iterateIndices(() => entries.length)) {\n\t\t\tconst variant = entries[index]\n\t\t\tconst key = INTRINSICS.text(index)\n\t\t\tconst descriptor = attempt(() => INTRINSICS.describe(variants, key))\n\t\t\tconst repeated = attempt(() => variants[index])\n\t\t\tif (\n\t\t\t\tisFailure(descriptor) ||\n\t\t\t\tdescriptor.value === undefined ||\n\t\t\t\t!INTRINSICS.own(descriptor.value, 'value') ||\n\t\t\t\tisFailure(repeated) ||\n\t\t\t\t!INTRINSICS.same(repeated.value, variant) ||\n\t\t\t\t!INTRINSICS.same(descriptor.value.value, variant)\n\t\t\t) {\n\t\t\t\tthis.#fidelity ??= this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'variants', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t#scheduleNode(\n\t\tsource: ContractShape,\n\t\tclone: ContractShape,\n\t\tpath: readonly string[],\n\t\tdepth: number,\n\t): void {\n\t\tswitch (clone.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#registerChild(clone.items, pathOf(path, 'items'), depth)\n\t\t\t\tbreak\n\t\t\tcase 'object': {\n\t\t\t\tconst captured = this.#properties\n\t\t\t\tif (captured === undefined) throw this.#unavailable()\n\t\t\t\tconst properties = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\t\t\tif (properties === undefined) {\n\t\t\t\t\tthrow this.#create('cloneShape: properties could not be read', {\n\t\t\t\t\t\tcode: 'clone',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties'), shape: 'object' },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => properties.length)) {\n\t\t\t\t\tconst entry = properties[index]\n\t\t\t\t\tif (entry === undefined || entry.child === undefined) continue\n\t\t\t\t\tthis.#registerChild(entry.child, pathOf(path, 'properties', entry.key), depth)\n\t\t\t\t}\n\t\t\t\tconst additional = clone.additionalProperties\n\t\t\t\tif (additional !== undefined && additional !== true && additional !== false) {\n\t\t\t\t\tthis.#registerChild(additional, pathOf(path, 'additionalProperties'), depth)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst captured = this.#variants\n\t\t\t\tif (captured === undefined) throw this.#unavailable()\n\t\t\t\tconst variants = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\t\t\tif (variants === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const index of iterateIndices(() => variants.length)) {\n\t\t\t\t\tconst variant = variants[index]\n\t\t\t\t\tif (variant !== undefined) {\n\t\t\t\t\t\tthis.#registerChild(variant, pathOf(path, 'variants', INTRINSICS.text(index)), depth)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#registerChild(clone.inner, pathOf(path, 'inner'), depth)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t#registerChild(child: ContractShape, path: readonly string[], depth: number): void {\n\t\tconst paths = this.#paths\n\t\tif (paths === undefined) throw this.#unavailable()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, paths, [child, path])\n\t\tthis.#pending[this.#pending.length] = { shape: child, depth: depth + 1 }\n\t}\n\n\t#wireNodes(): void {\n\t\tconst memo = this.#memo\n\t\tconst paths = this.#paths\n\t\tif (memo === undefined || paths === undefined) throw this.#unavailable()\n\t\tfor (const sourceIndex of iterateIndices(() => this.#sources.length)) {\n\t\t\tconst source = this.#sources[sourceIndex]\n\t\t\tif (source === undefined) continue\n\t\t\tconst clone = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [source])\n\t\t\tif (clone === undefined) continue\n\t\t\tconst path = INTRINSICS.reflect.apply(INTRINSICS.fetch, paths, [source]) ?? []\n\t\t\tswitch (clone.category) {\n\t\t\t\tcase 'array':\n\t\t\t\t\tthis.#wireArray(clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'object':\n\t\t\t\t\tthis.#wireObject(source, clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'union':\n\t\t\t\t\tthis.#wireUnion(source, clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tcase 'optional':\n\t\t\t\tcase 'nullable':\n\t\t\t\t\tthis.#wireWrapper(clone, path)\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t#wireArray(clone: ArrayShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst items = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [clone.items])\n\t\tif (items === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'items') },\n\t\t\t})\n\t\t}\n\t\tINTRINSICS.reflect.write(clone, 'items', items)\n\t}\n\n\t#wireObject(source: ContractShape, clone: ObjectShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tconst captured = this.#properties\n\t\tif (memo === undefined || captured === undefined) throw this.#unavailable()\n\t\tconst snapshot = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\tif (snapshot === undefined) {\n\t\t\tthrow this.#create('cloneShape: properties could not be read', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path: pathOf(path, 'properties'), shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(snapshot), [\n\t\t\t(entry: ShapeProperty | undefined) => {\n\t\t\t\tif (entry === undefined) return []\n\t\t\t\tconst { key, child } = entry\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [child])\n\t\t\t\tif (cloned === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'properties', key) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn [[key, cloned]]\n\t\t\t},\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tINTRINSICS.reflect.write(clone, 'properties', INTRINSICS.freeze(properties))\n\t\tconst additional = clone.additionalProperties\n\t\tif (additional !== undefined && additional !== true && additional !== false) {\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [additional])\n\t\t\tif (cloned === undefined) {\n\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: pathOf(path, 'additionalProperties') },\n\t\t\t\t})\n\t\t\t}\n\t\t\tINTRINSICS.reflect.write(clone, 'additionalProperties', cloned)\n\t\t}\n\t}\n\n\t#wireUnion(source: ContractShape, clone: UnionShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tconst captured = this.#variants\n\t\tif (memo === undefined || captured === undefined) throw this.#unavailable()\n\t\tconst snapshot = INTRINSICS.reflect.apply(INTRINSICS.fetch, captured, [source])\n\t\tif (snapshot === undefined) {\n\t\t\tthrow this.#create('validateShape: variants must be a finite array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'variants') },\n\t\t\t})\n\t\t}\n\t\tconst variants = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.length),\n\t\t\t(index) => {\n\t\t\t\tconst variant = snapshot[index]\n\t\t\t\tif (variant === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [variant])\n\t\t\t\tif (cloned === undefined) {\n\t\t\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn cloned\n\t\t\t},\n\t\t)\n\t\tINTRINSICS.reflect.write(clone, 'variants', INTRINSICS.freeze(variants))\n\t}\n\n\t#wireWrapper(clone: OptionalShape | NullableShape, path: readonly string[]): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tconst inner = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [clone.inner])\n\t\tif (inner === undefined) {\n\t\t\tthrow this.#create('validateShape: every structural child must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: pathOf(path, 'inner') },\n\t\t\t})\n\t\t}\n\t\tINTRINSICS.reflect.write(clone, 'inner', inner)\n\t}\n\n\t#freezeNodes(): void {\n\t\tconst memo = this.#memo\n\t\tif (memo === undefined) throw this.#unavailable()\n\t\tfor (const sourceIndex of iterateIndices(() => this.#sources.length)) {\n\t\t\tconst source = this.#sources[sourceIndex]\n\t\t\tif (source === undefined) continue\n\t\t\tconst clone = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [source])\n\t\t\tif (clone !== undefined) INTRINSICS.freeze(clone)\n\t\t}\n\t}\n\n\t#validateShape(\n\t\tshape: ContractShape,\n\t\tpath: readonly string[] = [],\n\t\tbudget?: { left: number },\n\t): void {\n\t\tconst outcome = attempt(() => new ShapePass(shape, budget).validate())\n\t\tif (isSuccess(outcome)) return\n\t\tif (isContractError(outcome.error)) {\n\t\t\tthrow this.#prefix(outcome.error, path)\n\t\t}\n\t\tthrow outcome.error\n\t}\n\n\t#spend(budget: { left: number }, count: number, path: readonly string[]): void {\n\t\tbudget.left -= count\n\t\tif (budget.left < 0) {\n\t\t\tthrow this.#create(`cloneShape: capture exceeds the node limit ${CLONE_NODE_LIMIT}`, {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { path, limit: CLONE_NODE_LIMIT },\n\t\t\t})\n\t\t}\n\t}\n\n\t#prefix(error: ContractError, path: readonly string[]): ContractError {\n\t\tif (path.length === 0) {\n\t\t\tadmitVisited(this.#owned, error)\n\t\t\treturn error\n\t\t}\n\t\tconst tail = error.context?.path\n\t\tconst location: string[] = []\n\t\tappendEntries(location, path)\n\t\tappendEntries(location, typeof tail === 'string' ? [tail] : (tail ?? []))\n\t\treturn this.#create(error.message, {\n\t\t\tcode: error.code,\n\t\t\tcontext: { ...error.context, path: location },\n\t\t\t...(INTRINSICS.own(error, 'cause') ? { cause: error.cause } : {}),\n\t\t})\n\t}\n\n\t// One refusal for every dropped working map, because a settled cloner replays\n\t// from `#state` and re-enters no walk method: nothing reachable settles here,\n\t// and every guard that says so must say it the same way.\n\t#unavailable(): ContractError {\n\t\treturn this.#create('ShapeCloner.clone: the capture state is unavailable', {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'shape' },\n\t\t})\n\t}\n\n\t#create(message: string, options: ContractErrorOptions): ContractError {\n\t\tconst error = new ContractError(message, options)\n\t\tadmitVisited(this.#owned, error)\n\t\treturn error\n\t}\n\n\t#owns(error: unknown): error is ContractError {\n\t\treturn isObject(error) && matchesVisited(this.#owned, error)\n\t}\n\n\t// Assignment only: every working list takes the class's shared frozen empty\n\t// peer and every working map is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection, so\n\t// settlement cannot be redirected into leaving state behind.\n\t#settle(result: Result<ContractShape, ContractError>): ContractShape {\n\t\tthis.#memo = undefined\n\t\tthis.#paths = undefined\n\t\tthis.#properties = undefined\n\t\tthis.#variants = undefined\n\t\tthis.#pending = ShapeCloner.#emptyPending\n\t\tthis.#sources = ShapeCloner.#emptySources\n\t\tthis.#fidelity = undefined\n\t\tthis.#state = { phase: 'settled', result }\n\t\tif (isSuccess(result)) return result.value\n\t\tthrow result.error\n\t}\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peers and\n\t\t// stop them satisfying the mutable working fields they are assigned to.\n\t\tINTRINSICS.freeze(ShapeCloner.#emptyPending)\n\t\tINTRINSICS.freeze(ShapeCloner.#emptySources)\n\t\t// Pinned while this class is DEFINED. `cloneShape` / `ownShape` reach it\n\t\t// through `ShapeCloner.prototype.clone`, so one assignment there made\n\t\t// `compileSchema`, `contract.audit` and `contract.explain` publish whatever\n\t\t// the caller chose while none of those doors was touched.\n\t\tpinMembers(ShapeCloner.prototype, 'ShapeCloner')\n\t}\n}\n","import type { ContractShape, JSONRecord, JSONSchema, JSONValue, StringShape } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport { attempt, contain, holds, isFailure, isSuccess } from './helpers.js'\nimport { isRecord } from './validators.js'\nimport { JSONCloner } from './JSONCloner.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { ShapeCloner } from './ShapeCloner.js'\n\n/**\n * Deep-clones exact JSON data into an owned frozen snapshot.\n *\n * @remarks\n * Traverses iteratively so deeply nested input cannot exhaust the call stack.\n * Repeated noncyclic aliases are duplicated because JSON persistence represents\n * a tree, while a structural back-edge on the active path is rejected as a\n * cycle. Arrays are rebuilt as standard dense arrays and records as\n * null-prototype objects; every produced node is frozen after its children are\n * wired. Array keys must be exactly `length` plus every canonical index.\n * Writable and configurable index flags are normalized rather than treated as\n * JSON data, so frozen arrays remain valid. Property descriptors are inspected\n * without reading values through accessors, and every hostile reflective\n * operation is contained before a new clone-coded error is exposed.\n * Each call creates a fresh {@link JSONCloner}; use the class directly when\n * terminal success or failure identity must be replayed without another read.\n *\n * @param value - The unknown value to validate and snapshot\n * @returns The primitive unchanged, or a deeply cloned and frozen JSON graph\n * @throws {ContractError} When the value is not exact acyclic JSON data or traversal fails\n *\n * @example\n * ```ts\n * const source = { settings: { enabled: true } }\n * const clone = cloneJSONValue(source)\n * source.settings.enabled = false\n * clone // { settings: { enabled: true } }\n * ```\n */\nexport function cloneJSONValue(value: unknown): JSONValue {\n\treturn contain(() => {\n\t\treturn new JSONCloner(value).clone()\n\t}, 'cloneJSONValue')\n}\n\n/**\n * Deep-clones an exact JSON object record into an owned frozen snapshot.\n *\n * @remarks\n * Adds a record-root boundary to {@link cloneJSONValue}. The output is a\n * deeply frozen null-prototype record, and repeated noncyclic aliases are\n * duplicated as independent JSON tree branches.\n *\n * @param value - The unknown record value to validate and snapshot\n * @returns A deeply cloned and frozen JSON record\n * @throws {ContractError} When the root is not a record, nested data is inexact, or traversal fails\n *\n * @example\n * ```ts\n * cloneJSONRecord({ attempt: 1 }) // frozen null-prototype record\n * ```\n */\nexport function cloneJSONRecord(value: unknown): JSONRecord {\n\treturn contain(() => {\n\t\tif (!isRecord(value)) {\n\t\t\tthrow new ContractError('cloneJSONRecord: value is not a plain record', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'json' },\n\t\t\t})\n\t\t}\n\t\tconst clone = cloneJSONValue(value)\n\t\tif (!isRecord(clone)) {\n\t\t\tthrow new ContractError('cloneJSONRecord: cloned value is not a record', {\n\t\t\t\tcode: 'clone',\n\t\t\t\tcontext: { shape: 'json' },\n\t\t\t})\n\t\t}\n\t\treturn clone\n\t}, 'cloneJSONRecord')\n}\n\n/**\n * Deep-clones a JSON Schema graph into an owned frozen snapshot.\n *\n * @remarks\n * Walks arrays and records iteratively with a memo, preserving shared\n * references and closing cyclic edges onto their cloned nodes. Primitive\n * values and own enumerable string-keyed edges are copied; record nodes use\n * null prototypes, arrays retain only their intrinsic array prototype, and\n * every produced object is frozen after its edges are wired. Hostile traversal\n * throws a clone-coded {@link ContractError}, never a caller-owned raw error.\n * Each call creates a fresh {@link SchemaCloner}; use the class directly when\n * terminal success or failure identity must be replayed without another read.\n *\n * @param schema - The JSON Schema graph to snapshot\n * @returns A deeply cloned and frozen JSON Schema graph\n * @throws {ContractError} When hostile schema traversal prevents ownership\n *\n * @example\n * ```ts\n * const child = { type: 'string' }\n * const clone = cloneSchema({ anyOf: [child, child] })\n * clone.anyOf?.[0] === clone.anyOf?.[1] // true\n * ```\n */\nexport function cloneSchema(schema: JSONSchema): JSONSchema {\n\treturn contain(() => {\n\t\treturn new SchemaCloner(schema).clone()\n\t}, 'cloneSchema')\n}\n\n/**\n * Deep-clones a contract shape graph into an owned frozen snapshot.\n *\n * @remarks\n * A fresh public {@link ShapeCloner} preserves shared-child identity while\n * building the candidate snapshot, owns raw schemas, validates the exact\n * completed root, applies deferred fidelity, and translates unexpected hostile\n * failures. Inside the engine, each node's own data discriminant and every\n * declared field are captured descriptor-first from two agreeing reads, and the\n * carried population alone supplies its shallow shell, semantic checks, child\n * scheduling, and later edge wiring. An inherited field is refused through a\n * non-invoking presence check, and a revealed accessor is refused without\n * invocation except for the builder's `pattern` contract: two fresh frozen\n * genuine `RegExp` values with equal source and flags are captured as owned\n * source/flags semantics.\n *\n * Literal and union members retain their own-index descriptor/repeated-read\n * checks; property entries retain descriptor/first/second agreement plus two\n * exactly equal ordered key populations; raw schemas delegate to\n * {@link cloneSchema}. Before return, a fresh {@link ShapeValidator} independently\n * validates the exact cloned root. Ownership never erases a structural edge or\n * normalizes an invalid scalar/bound into a plausible declaration: those\n * inputs throw their coded structure/bound error. Hostile traversal remains\n * distinct and throws a clone-coded {@link ContractError}.\n *\n * @param shape - The contract shape graph to snapshot\n * @returns A deeply cloned and frozen shape graph\n * @throws {ContractError} When the declaration cannot be copied faithfully or hostile shape or raw-schema traversal prevents ownership\n *\n * @example\n * ```ts\n * const child = arrayShape(stringShape())\n * const clone = cloneShape(objectShape({ first: child, second: child }))\n * clone.category === 'object' && clone.properties.first === clone.properties.second // true\n * ```\n */\nexport function cloneShape(shape: StringShape): StringShape\nexport function cloneShape(shape: ContractShape): ContractShape\nexport function cloneShape(shape: ContractShape): ContractShape {\n\treturn contain(() => {\n\t\treturn new ShapeCloner(shape).clone()\n\t}, 'cloneShape')\n}\n\n/**\n * Takes ownership of a contract shape node as an independent {@link cloneShape}\n * snapshot of its graph.\n *\n * @remarks\n * Every successful return is a deeply frozen caller-independent graph, and\n * \"frozen\" here means frozen by the `Object.freeze` this package captured while\n * it loaded, not by whatever `Object.freeze` names when the call is made. The\n * distinction is the whole guarantee: a replaced `Object.freeze` that returns\n * its argument untouched would otherwise let this door publish a mutable graph,\n * with no throw and no signal a caller could read. A frozen caller root receives no identity\n * exception: shallow freezing cannot establish ownership of nested collections,\n * child nodes, raw schemas, or `RegExp` internal state, and the fidelity clone\n * has already paid the traversal cost needed to prove and carry those values.\n *\n * @param shape - The contract shape to own\n * @returns A deeply cloned frozen snapshot\n * @throws {ContractError} When the declaration cannot be copied faithfully, when hostile shape or raw-schema traversal prevents ownership, or when a frozen root fails validation\n *\n * @example\n * ```ts\n * const authored = stringShape()\n * ownShape(authored) === authored // false\n * ```\n */\nexport function ownShape(shape: ContractShape): ContractShape {\n\treturn contain(() => {\n\t\tconst frozen = holds(() => INTRINSICS.frozen(shape))\n\t\tconst fidelity = attempt(() => cloneShape(shape))\n\t\tif (isSuccess(fidelity)) return fidelity.value\n\t\tif (\n\t\t\tisContractError(fidelity.error) &&\n\t\t\t(fidelity.error.code !== 'clone' || fidelity.error.context?.limit === CLONE_NODE_LIMIT)\n\t\t) {\n\t\t\tthrow fidelity.error\n\t\t}\n\t\tif (!frozen) throw fidelity.error\n\t\tconst validation = attempt(() => new ShapeValidator(shape).validate())\n\t\tif (isFailure(validation) && isContractError(validation.error)) throw validation.error\n\t\tthrow fidelity.error\n\t}, 'ownShape')\n}\n","import type { Guard } from './types.js'\nimport { GUARD_DEPTH_LIMIT } from './constants.js'\nimport { holds } from './helpers.js'\n\n/** Owns the active depth shared by calls to one deferred guard. */\nexport class LazyGuard<T> {\n\treadonly #thunk: () => Guard<T>\n\t#depth = 0\n\n\tconstructor(thunk: () => Guard<T>) {\n\t\tthis.#thunk = thunk\n\t}\n\n\t/** Tests one value within the guard's shared recursion allowance. */\n\ttest(value: unknown): value is T {\n\t\tif (this.#depth >= GUARD_DEPTH_LIMIT) return false\n\t\tthis.#depth += 1\n\t\ttry {\n\t\t\treturn holds(() => this.#thunk()(value))\n\t\t} finally {\n\t\t\tthis.#depth -= 1\n\t\t}\n\t}\n}\n","import type {\n\tFromGuards,\n\tGuard,\n\tGuardsShape,\n\tGuardType,\n\tIntersectionFromGuards,\n\tLiteralValue,\n\tOptionalFromGuards,\n\tStringGuardOptions,\n\tTupleFromGuards,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { LazyGuard } from './LazyGuard.js'\nimport {\n\tisArray,\n\tisConstructor,\n\tisFiniteNumber,\n\tisFunction,\n\tisInstance,\n\tisLiteralValue,\n\tisMap,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisRegExp,\n\tisSet,\n\tisString,\n\tisSymbol,\n} from './validators.js'\nimport {\n\treadIndexView,\n\tcollectMembers,\n\tcontain,\n\tholds,\n\tisFailure,\n\titerateIndices,\n\tmatchesMember,\n\tmatchesPattern,\n\tmatchesStringLength,\n\townPattern,\n\treadArrayEntries,\n\treadGuardShape,\n\treadMapEntries,\n\treadOptions,\n\treadPattern,\n\treadSetEntries,\n\treadValue,\n} from './helpers.js'\n\n// Every combinator returns a `Guard<T>` — a total function, as\n// `.claude/rules/patterns.md` § Validation and contracts requires. The\n// combinators that invoke a caller-supplied callback inside the guard body\n// contain the whole call through `holds`, so\n// the produced guard reports a non-match instead of propagating. The container\n// combinators likewise wrap their complete element/entry/key-read walk in\n// `holds` — a hostile Proxy trap, a throwing getter, a throwing\n// iterator, or a throwing caller-supplied predicate yields a non-match, never a\n// propagated throw.\n\n/**\n * Builds a guard that accepts DENSE arrays whose every element satisfies\n * `elementGuard`.\n *\n * @remarks\n * Density is part of the contract, not an accident: the guard reads the array\n * through the shared reflected own-index lens {@link readArrayEntries}, which is\n * what makes it immune to caller-defined iteration and what `parseArray` reads\n * too. A SPARSE array is therefore refused outright — `[1, , 3]` fails even when\n * the element guard accepts `undefined` — because a hole is an absent own\n * property rather than a present `undefined`, and the two are different facts.\n * Pass `[1, undefined, 3]` when the middle slot is meant to exist.\n *\n * @param elementGuard - The guard each element must satisfy\n * @returns A guard accepting a dense array whose every element is accepted\n *\n * @example\n * ```ts\n * const isStringArray = arrayOf(isString)\n * isStringArray(['a', 'b']) // true\n * isStringArray(['a', 1]) // false\n * isStringArray(['a', , 'b']) // false — sparse\n * ```\n */\nexport function arrayOf<T>(elementGuard: Guard<T>): Guard<readonly T[]>\nexport function arrayOf(elementGuard: (value: unknown) => boolean): Guard<readonly unknown[]>\nexport function arrayOf(elementGuard: (value: unknown) => boolean): Guard<readonly unknown[]> {\n\treturn (value: unknown): value is readonly unknown[] =>\n\t\tholds(() => {\n\t\t\tif (!isArray(value)) return false\n\t\t\tconst entries = readArrayEntries(value)\n\t\t\tif (isFailure(entries) || !entries.value.dense) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\tif (!elementGuard(entries.value.entries[index])) return false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts fixed-arity DENSE tuples, testing each index with\n * the corresponding guard.\n *\n * @param guards - One guard per tuple index, in declaration order\n * @returns A guard accepting a dense tuple of that exact arity whose every index is accepted\n *\n * @example\n * ```ts\n * const isPair = tupleOf(isString, isNumber)\n * isPair(['hello', 42]) // true\n * isPair(['hello']) // false — wrong arity\n * isPair([, 42]) // false — sparse; see arrayOf for the dense lens\n * ```\n */\nexport function tupleOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<TupleFromGuards<Gs>>\nexport function tupleOf(\n\t...predicates: ReadonlyArray<(value: unknown) => boolean>\n): Guard<readonly unknown[]>\nexport function tupleOf(\n\t...guards: ReadonlyArray<(value: unknown) => boolean>\n): Guard<readonly unknown[]> {\n\treturn (value: unknown): value is readonly unknown[] =>\n\t\tholds(() => {\n\t\t\tif (!isArray(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tconst entries = readArrayEntries(value)\n\t\t\tif (isFailure(entries) || !entries.value.dense) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (entries.value.entries.length !== guards.length) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\t\tconst guard = guards[index]\n\t\t\t\tif (guard === undefined || !guard(entries.value.entries[index])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts a provided literal primitive using SameValueZero\n * comparison.\n *\n * @remarks\n * Signed zero compares equal, while `NaN` compares equal to `NaN`. Two call\n * forms, one meaning: list the literals inline, or hand in one array of them.\n * The array form exists for a vocabulary that is machine-generated rather than\n * hand-written — a `literalShape` built from an untrusted schema's `enum`, say\n * — where spreading a list of tens of thousands of entries would exhaust the\n * engine's argument limit. `compileGuard` / `compileParser` / `compileReporter`\n * take the array form for exactly that reason.\n *\n * @param literals - The permitted literal primitives, listed inline or as one array\n * @returns A guard narrowing to the provided literal union\n *\n * @example\n * ```ts\n * const isRole = literalOf('admin', 'member', 'guest')\n * isRole('admin') // true\n * isRole('owner') // false\n *\n * const isSameRole = literalOf(['admin', 'member', 'guest']) // the same guard, from an array\n * ```\n */\nexport function literalOf<const Literals extends readonly LiteralValue[]>(\n\tliterals: Literals,\n): Guard<Literals[number]>\nexport function literalOf<const Literals extends readonly LiteralValue[]>(\n\t...literals: Literals\n): Guard<Literals[number]>\nexport function literalOf(\n\t...literals: ReadonlyArray<LiteralValue | readonly LiteralValue[]>\n): Guard<LiteralValue> {\n\treturn contain(\n\t\t() => {\n\t\t\t// An indexed read, not array destructuring: destructuring dispatches through\n\t\t\t// `Array.prototype[Symbol.iterator]`, a caller-writable member.\n\t\t\tconst first = literals[0]\n\t\t\tconst collected =\n\t\t\t\tliterals.length === 1\n\t\t\t\t\t? readValue(() => INTRINSICS.array(first), 'literalOf', {\n\t\t\t\t\t\t\tsubject: 'literals',\n\t\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t\t})\n\t\t\t\t\t: false\n\t\t\tconst snapshot =\n\t\t\t\tcollected && isArray(first)\n\t\t\t\t\t? readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tconst entries = readArrayEntries(first)\n\t\t\t\t\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\t\t\t\t\tif (!entries.value.dense) {\n\t\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('Literal vocabulary must be dense')\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn entries.value.entries\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'literalOf',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubject: 'literals',\n\t\t\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t: literals\n\t\t\t// Indexed, not `every`: an array prototype method is a caller-writable\n\t\t\t// member reached by name, and this statement sits between two statements an\n\t\t\t// earlier round repaired for exactly that reason. A boundary placed per\n\t\t\t// statement is only ever as complete as the last sweep; an indexed read\n\t\t\t// dispatches through nothing at all.\n\t\t\tconst literal = !INTRINSICS.reflect.apply(INTRINSICS.some, snapshot, [\n\t\t\t\t(value: unknown) => !isLiteralValue(value),\n\t\t\t])\n\t\t\tif (!literal) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'literalOf: literals must contain only string, number, or boolean values',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'literal',\n\t\t\t\t\t\tcontext: { path: ['literals'], shape: 'literal' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\t// A module-scope membership question, not `set.has(value)` and not a\n\t\t\t// method on a class this package exports: the answer this guard returns IS\n\t\t\t// the package's published verdict, and BOTH of those spellings ask a\n\t\t\t// property every caller can rewrite. `Set.prototype.has = () => true` made\n\t\t\t// this guard accept a value outside its declared vocabulary; relocating\n\t\t\t// the read onto an exported class's `has` reproduced it one prototype\n\t\t\t// higher. A module binding is not a property.\n\t\t\tconst allowed = collectMembers(snapshot)\n\t\t\treturn (value: unknown): value is LiteralValue => holds(() => matchesMember(allowed, value))\n\t\t},\n\t\t'literalOf',\n\t\t{ code: 'literal', context: { path: ['literals'], shape: 'literal' } },\n\t)\n}\n\n/**\n * Builds a guard that accepts instances of the provided constructor.\n *\n * @remarks\n * Verifies that `ctor` is a real constructor (through {@link isConstructor}) first,\n * so passing an arrow function does not silently produce a broken guard.\n *\n * A callable instance passes. The exclusion is a bad constructor, never a callable\n * value: an `isObject` pre-filter made `instanceOf(Function)(() => {})` answer `false`\n * while {@link isInstance}, the helper this is built on, answered `true` for the same\n * pair.\n *\n * @param ctor - The constructor whose instances the guard accepts\n * @returns A guard narrowing to that constructor's instance type\n *\n * @example\n * ```ts\n * const isDateValue = instanceOf(Date)\n * isDateValue(new Date()) // true\n * isDateValue({}) // false\n * ```\n */\nexport function instanceOf<C extends abstract new (...args: never) => object>(\n\tctor: C,\n): Guard<InstanceType<C>> {\n\t// No `isObject` pre-filter: `typeof fn === 'function'`, so it rejected every\n\t// CALLABLE instance and `instanceOf(Function)(() => {})` answered `false`\n\t// while `isInstance(() => {}, Function)` — the helper this combinator is\n\t// documented to be built on — answered `true`. `isInstance` already refuses a\n\t// primitive (`primitive instanceof X` is `false`) and is itself contained, so\n\t// the pre-filter narrowed the domain and bought nothing.\n\treturn (value: unknown): value is InstanceType<C> =>\n\t\tisConstructor(ctor) && isInstance(value, ctor)\n}\n\n/**\n * Builds a guard from a native `enum` or any object whose values are strings or\n * numbers.\n *\n * @remarks\n * An unreadable enumeration is refused at factory time with the shared `structure` read\n * refusal; the returned guard stays total.\n *\n * @param enumeration - The readable enumeration whose values the guard accepts\n * @returns A guard accepting one enumeration value\n * @throws {ContractError} When the enumeration cannot be read\n *\n * @example\n * ```ts\n * enum Direction { Up = 'up', Down = 'down' }\n * const isDirection = enumOf(Direction)\n * isDirection('up') // true\n * isDirection('left') // false\n * ```\n */\nexport function enumOf<const E extends Record<string, string | number>>(\n\tenumeration: E,\n): Guard<E[keyof E]> {\n\treturn contain(() => {\n\t\tconst values = collectMembers(\n\t\t\treadValue(() => INTRINSICS.values(enumeration), 'enumOf', { subject: 'enumeration' }),\n\t\t)\n\t\t// `holds`, exactly as `literalOf` does one screen up. The membership read is\n\t\t// unredirectable, but the guard contract is \"never throws\" and a guard\n\t\t// that states it for one builder and not its sibling is a guard nobody can\n\t\t// rely on.\n\t\treturn (value: unknown): value is E[keyof E] =>\n\t\t\tholds(() => (isString(value) || isNumber(value)) && matchesMember(values, value))\n\t}, 'enumOf')\n}\n\n/**\n * Builds a guard that accepts `Set` instances whose every element satisfies\n * `elementGuard`.\n *\n * @param elementGuard - The guard each element must satisfy\n * @returns A guard accepting a `Set` whose every element is accepted\n *\n * @example\n * ```ts\n * const isStringSet = setOf(isString)\n * isStringSet(new Set(['a', 'b'])) // true\n * isStringSet(new Set(['a', 1])) // false\n * ```\n */\nexport function setOf<T>(elementGuard: Guard<T>): Guard<ReadonlySet<T>>\nexport function setOf(elementGuard: (value: unknown) => boolean): Guard<ReadonlySet<unknown>>\nexport function setOf(elementGuard: (value: unknown) => boolean): Guard<ReadonlySet<unknown>> {\n\treturn (value: unknown): value is ReadonlySet<unknown> =>\n\t\tholds(() => {\n\t\t\tif (!isSet(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// The genuine contents, read through the captured sweep rather than\n\t\t\t// through `Set.prototype[Symbol.iterator]`. An iterator that silently\n\t\t\t// skipped the non-string in `new Set(['a', 42])` made this guard answer\n\t\t\t// `true` while `forEach` and `size` still reported the real contents — the\n\t\t\t// guard's verdict and every other view of the same object disagreeing is\n\t\t\t// exactly the silent lie the sibling `arrayOf` was already hardened against.\n\t\t\tconst entries = readSetEntries(value)\n\t\t\tif (isFailure(entries)) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.length)) {\n\t\t\t\tif (!elementGuard(entries.value[index])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts `Map` instances where every key satisfies\n * `keyGuard` and every value satisfies `valueGuard`.\n *\n * @param keyGuard - The guard each key must satisfy\n * @param valueGuard - The guard each value must satisfy\n * @returns A guard accepting a `Map` whose every entry is accepted\n *\n * @example\n * ```ts\n * const isStringNumberMap = mapOf(isString, isNumber)\n * isStringNumberMap(new Map([['a', 1]])) // true\n * isStringNumberMap(new Map([[1, 'a']])) // false\n * ```\n */\nexport function mapOf<K, V>(keyGuard: Guard<K>, valueGuard: Guard<V>): Guard<ReadonlyMap<K, V>>\nexport function mapOf(\n\tkeyPredicate: (value: unknown) => boolean,\n\tvaluePredicate: (value: unknown) => boolean,\n): Guard<ReadonlyMap<unknown, unknown>>\nexport function mapOf(\n\tkeyGuard: (value: unknown) => boolean,\n\tvalueGuard: (value: unknown) => boolean,\n): Guard<ReadonlyMap<unknown, unknown>> {\n\treturn (value: unknown): value is ReadonlyMap<unknown, unknown> =>\n\t\tholds(() => {\n\t\t\tif (!isMap(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// The captured sweep, and each pair read POSITIONALLY: destructuring\n\t\t\t// `[key, entryValue]` adds `Array.prototype[Symbol.iterator]` to the\n\t\t\t// `Map.prototype[Symbol.iterator]` this already avoided, and a\n\t\t\t// substituting iterator can replace one half of a pair while every\n\t\t\t// downstream check still passes.\n\t\t\tconst entries = readMapEntries(value)\n\t\t\tif (isFailure(entries)) return false\n\t\t\tfor (const index of iterateIndices(() => entries.value.length)) {\n\t\t\t\tconst entry = entries.value[index]\n\t\t\t\tif (entry === undefined) return false\n\t\t\t\tif (!keyGuard(entry[0]) || !valueGuard(entry[1])) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Builds a guard that accepts plain records matching a guard shape.\n *\n * @remarks\n * The calling modes depend on the `optional` argument:\n * - **No `optional`** — all shape keys required; extra keys rejected.\n * - **`optional: K[]`** — the listed keys are optional; all others required.\n * - **`optional: true`** — every shape key is optional.\n *\n * Key presence is tested with `Object.hasOwn`, so a shape key satisfied only by\n * an inherited prototype member (`toString`, `constructor`, …) counts as absent.\n * A non-object / `null` / array input returns `false` rather than throwing.\n * The exactness check inspects every own string key, including non-enumerable\n * keys. Symbol keys are ignored intentionally for JSON fidelity.\n *\n * @param shape - The guard shape whose own string keys the record must satisfy\n * @param optional - The optional-key list, `true` for every key, or absent for none\n * @returns A guard accepting a record satisfying the shape under the selected mode\n *\n * @example\n * ```ts\n * const isUser = recordOf({ name: isString, age: isNumber })\n * isUser({ name: 'Ada', age: 36 }) // true\n * isUser({ name: 'Ada' }) // false — age missing\n *\n * const isPartial = recordOf({ name: isString, age: isNumber }, ['age'])\n * isPartial({ name: 'Ada' }) // true\n * ```\n */\nexport function recordOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>\nexport function recordOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\toptional: K,\n): Guard<OptionalFromGuards<S, K>>\nexport function recordOf<S extends GuardsShape>(\n\tshape: S,\n\toptional: true,\n): Guard<Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>>\nexport function recordOf<\n\tS extends GuardsShape,\n\tK extends ReadonlyArray<keyof S & string> | true | undefined,\n>(\n\tshape: S,\n\toptional?: K,\n): Guard<\n\tK extends true\n\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t? OptionalFromGuards<S, K>\n\t\t\t: FromGuards<S>\n> {\n\treturn contain(() => {\n\t\tconst declared = readGuardShape(shape, optional, 'recordOf')\n\n\t\treturn (\n\t\t\tvalue: unknown,\n\t\t): value is K extends true\n\t\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t\t? OptionalFromGuards<S, K>\n\t\t\t\t: FromGuards<S> =>\n\t\t\tholds(() => {\n\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tconst members = INTRINSICS.reflect.members(value)\n\t\t\t\tfor (const index of iterateIndices(() => members.length)) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && !matchesMember(declared.vocabulary, key)) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of iterateIndices(() => declared.names.length)) {\n\t\t\t\t\tconst key = declared.names[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst guard = declared.guards[key]\n\t\t\t\t\tconst present = INTRINSICS.own(value, key)\n\t\t\t\t\tif (!matchesMember(declared.optional, key) && !present) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tif (present) {\n\t\t\t\t\t\tif (guard === undefined || !guard(value[key])) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\t}, 'recordOf')\n}\n\n/**\n * Builds a guard that accepts non-array objects matching an open guard shape.\n *\n * @remarks\n * The calling modes mirror {@link recordOf}:\n * - **No `optional`** — all shape keys required; unknown members admitted.\n * - **`optional: K[]`** — the listed keys are optional; all others required.\n * - **`optional: true`** — every shape key is optional.\n *\n * Each declared member is read through `Reflect.get`, so inherited data and\n * prototype accessors can satisfy the shape. An optional member passes when its\n * read value is `undefined`; otherwise its guard must accept the value. Unknown\n * members are never enumerated or inspected. Member-carrying functions are\n * accepted. Arrays, `null`, and primitives are rejected. Hostile reads return\n * `false` rather than throwing.\n *\n * @param shape - The guard shape whose declared members the object must satisfy\n * @param optional - The optional-key list, `true` for every key, or absent for none\n * @returns A guard accepting an object satisfying the shape under the selected mode\n *\n * @example\n * ```ts\n * const isResult = objectOf({ conclusion: isBoolean })\n * isResult({ conclusion: true, metadata: 'retained' }) // true\n * isResult([]) // false\n * ```\n */\nexport function objectOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>\nexport function objectOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\toptional: K,\n): Guard<OptionalFromGuards<S, K>>\nexport function objectOf<S extends GuardsShape>(\n\tshape: S,\n\toptional: true,\n): Guard<Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>>\nexport function objectOf<\n\tS extends GuardsShape,\n\tK extends ReadonlyArray<keyof S & string> | true | undefined,\n>(\n\tshape: S,\n\toptional?: K,\n): Guard<\n\tK extends true\n\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t? OptionalFromGuards<S, K>\n\t\t\t: FromGuards<S>\n> {\n\treturn contain(() => {\n\t\tconst declared = readGuardShape(shape, optional, 'objectOf')\n\n\t\treturn (\n\t\t\tvalue: unknown,\n\t\t): value is K extends true\n\t\t\t? Readonly<{ [P in keyof S]?: FromGuards<S>[P] }>\n\t\t\t: K extends ReadonlyArray<keyof S & string>\n\t\t\t\t? OptionalFromGuards<S, K>\n\t\t\t\t: FromGuards<S> =>\n\t\t\tholds(() => {\n\t\t\t\tif ((!isObject(value) && !isFunction(value)) || INTRINSICS.array(value)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tfor (const index of iterateIndices(() => declared.names.length)) {\n\t\t\t\t\tconst key = declared.names[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst guard = declared.guards[key]\n\t\t\t\t\tconst member = INTRINSICS.reflect.read(value, key)\n\t\t\t\t\tif (matchesMember(declared.optional, key)) {\n\t\t\t\t\t\tif (member !== undefined && (guard === undefined || !guard(member))) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (guard === undefined || !guard(member)) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\t}, 'objectOf')\n}\n\n/**\n * Builds a guard that accepts values that are own keys of the provided object.\n *\n * @remarks\n * Membership is tested with `Object.hasOwn`, so inherited prototype-chain keys\n * (`toString`, `constructor`, …) are rejected. An own property that shadows a\n * prototype name is accepted.\n *\n * @param value - The object whose own keys the guard accepts\n * @returns A guard narrowing to that object's own key union\n *\n * @example\n * ```ts\n * const COLORS = { red: '#f00', green: '#0f0', blue: '#00f' } as const\n * const isColorKey = keyOf(COLORS)\n * isColorKey('red') // true\n * isColorKey('purple') // false\n * isColorKey('toString') // false — inherited, not an own key\n * ```\n */\nexport function keyOf<const O extends Readonly<Record<PropertyKey, unknown>>>(\n\tvalue: O,\n): Guard<keyof O> {\n\treturn contain(() => {\n\t\tconst keys = collectMembers(readValue(() => INTRINSICS.reflect.members(value), 'keyOf'))\n\t\treturn (entry: unknown): entry is keyof O =>\n\t\t\tholds(\n\t\t\t\t() =>\n\t\t\t\t\t(isString(entry) && matchesMember(keys, entry)) ||\n\t\t\t\t\t(isSymbol(entry) && matchesMember(keys, entry)) ||\n\t\t\t\t\t(isNumber(entry) && matchesMember(keys, INTRINSICS.text(entry))),\n\t\t\t)\n\t}, 'keyOf')\n}\n\n/**\n * Builds a new guard shape by keeping only the listed keys — the structural\n * equivalent of `Pick<T, K>`. Produces a shape for {@link recordOf}, not a guard.\n *\n * @remarks\n * An unreadable `keys` list and an unreadable `shape` are refused separately, each\n * under its own name, so a caller reads which argument failed.\n *\n * @param shape - The guard shape to narrow\n * @param keys - The keys to keep\n * @returns A guard shape carrying only the kept keys\n *\n * @example\n * ```ts\n * const full = { name: isString, age: isNumber, role: isString }\n * const isName = recordOf(pickOf(full, ['name']))\n * isName({ name: 'Ada' }) // true\n * ```\n */\nexport function pickOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\tkeys: K,\n): Pick<S, K[number]> {\n\treturn contain(() => {\n\t\t// Sound over-approximation: only selected keys are defined on the genuine\n\t\t// null-prototype accumulator; its mapped value slots remain checked against S.\n\t\tconst selected = readValue(\n\t\t\t() => {\n\t\t\t\tconst entries = readArrayEntries(keys)\n\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Picked key list must be dense')\n\t\t\t\treturn collectMembers(entries.value.entries)\n\t\t\t},\n\t\t\t'pickOf',\n\t\t\t{ subject: 'keys' },\n\t\t)\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t\t(key: PropertyKey) =>\n\t\t\t\t\t\tisString(key) && matchesMember(selected, key)\n\t\t\t\t\t\t\t? [[key, { value: shape[key], enumerable: true, configurable: true, writable: true }]]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t])\n\t\t\t\tconst result: { [P in keyof S]: S[P] } = INTRINSICS.create(\n\t\t\t\t\tnull,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn result\n\t\t\t},\n\t\t\t'pickOf',\n\t\t\t{ subject: 'shape' },\n\t\t)\n\t}, 'pickOf')\n}\n\n/**\n * Builds a new guard shape by removing the listed keys — the structural\n * equivalent of `Omit<T, K>`. Produces a shape for {@link recordOf}, not a guard.\n *\n * @remarks\n * An unreadable `keys` list and an unreadable `shape` are refused separately, each\n * under its own name, for the reason {@link pickOf} states.\n *\n * @param shape - The guard shape to narrow\n * @param keys - The keys to remove\n * @returns A guard shape carrying every key except the removed ones\n *\n * @example\n * ```ts\n * const full = { name: isString, age: isNumber, role: isString }\n * const isPublic = recordOf(omitOf(full, ['role']))\n * isPublic({ name: 'Ada', age: 36 }) // true\n * ```\n */\nexport function omitOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(\n\tshape: S,\n\tkeys: K,\n): Omit<S, K[number]> {\n\treturn contain(() => {\n\t\tconst skipped = readValue(\n\t\t\t() => {\n\t\t\t\tconst entries = readArrayEntries(keys)\n\t\t\t\tif (isFailure(entries)) throw entries.error\n\t\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Omitted key list must be dense')\n\t\t\t\treturn collectMembers(entries.value.entries)\n\t\t\t},\n\t\t\t'omitOf',\n\t\t\t{ subject: 'keys' },\n\t\t)\n\t\t// Sound over-approximation: only kept keys are written, so the value\n\t\t// structurally satisfies `Omit<S, K[number]>`. Same honest typing as\n\t\t// `pickOf` — no `as` / `!` / `asserts`.\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tconst descriptors = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(members), [\n\t\t\t\t\t(key: PropertyKey) =>\n\t\t\t\t\t\tisString(key) && !matchesMember(skipped, key)\n\t\t\t\t\t\t\t? [[key, { value: shape[key], enumerable: true, configurable: true, writable: true }]]\n\t\t\t\t\t\t\t: [],\n\t\t\t\t])\n\t\t\t\tconst result: { [P in keyof S]: S[P] } = INTRINSICS.create(\n\t\t\t\t\tnull,\n\t\t\t\t\tINTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tdescriptors,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn result\n\t\t\t},\n\t\t\t'omitOf',\n\t\t\t{ subject: 'shape' },\n\t\t)\n\t}, 'omitOf')\n}\n\n/**\n * Combines `left` and `right` with logical AND — passes only when both pass.\n *\n * @remarks\n * Use {@link whereOf} when the right side refines an already-narrowed type; use\n * `andOf` to combine independent guards.\n *\n * @param left - The guard tested first\n * @param right - The guard tested only after `left` passes\n * @returns A guard accepting a value both accept\n *\n * @example\n * ```ts\n * const isShortString = andOf(isString, isNonEmptyString)\n * ```\n */\nexport function andOf<A, B>(left: Guard<A>, right: Guard<B>): Guard<A & B>\nexport function andOf<T, U extends T>(left: Guard<T>, right: (value: T) => value is U): Guard<U>\nexport function andOf<T>(left: Guard<T>, right: (value: T) => boolean): Guard<T>\nexport function andOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown>\nexport function andOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown> {\n\treturn (value: unknown): value is unknown => holds(() => left(value) && right(value))\n}\n\n/**\n * Combines `left` and `right` with logical OR — passes when at least one passes.\n * Prefer {@link unionOf} for a wider set of variants.\n *\n * @remarks\n * Each member is contained on its own, so a throwing member is a non-match rather than\n * a veto over its sibling. One containment around the whole disjunction made `orOf(a,\n * b)` and `orOf(b, a)` answer differently for one value.\n *\n * @param left - The guard tested first\n * @param right - The guard tested only after `left` fails\n * @returns A guard accepting a value either accepts\n *\n * @example\n * ```ts\n * const isStringOrNumber = orOf(isString, isNumber)\n * ```\n */\nexport function orOf<A, B>(left: Guard<A>, right: Guard<B>): Guard<A | B>\nexport function orOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown>\nexport function orOf(\n\tleft: (value: unknown) => boolean,\n\tright: (value: unknown) => boolean,\n): Guard<unknown> {\n\t// Each member is contained SEPARATELY. One `holds` around the whole\n\t// disjunction let a throwing member veto every later passing one, so\n\t// `orOf(isNull, naive)(null)` was `true` and `orOf(naive, isNull)(null)` was\n\t// `false` — the same disjunction, the same value, two answers. Disjunction is\n\t// commutative by definition, and the package's own doctrine everywhere else\n\t// is that a throw is contained as a NON-MATCH, not as a veto over siblings.\n\treturn (value: unknown): value is unknown => holds(() => left(value)) || holds(() => right(value))\n}\n\n/**\n * Negates a guard or predicate — passes when `guard` returns `false`.\n *\n * @remarks\n * Typed as `Guard<unknown>` because `Exclude<unknown, T>` is not useful; use\n * {@link complementOf} when you need the narrowed `Exclude<TBase, TExcluded>`.\n *\n * The negation applies to the contained verdict, so a throwing guard is a non-match and\n * its negation passes. Containing the negation instead made a guard and its `notOf`\n * both reject the same value, which broke `orOf(g, notOf(g))` as a tautology.\n *\n * @param guard - The guard or predicate to negate\n * @returns A guard accepting exactly the values `guard` rejects\n *\n * @example\n * ```ts\n * const isNotNull = notOf(isNull)\n * ```\n */\nexport function notOf(guard: (value: unknown) => boolean): Guard<unknown> {\n\t// The negation is applied to the CONTAINED verdict, not contained around the\n\t// negation. `holds(() => !guard(value))` never evaluated `!` when the guard\n\t// threw, so a guard and its negation both reported a non-match for the same\n\t// value and `orOf(g, notOf(g))` stopped being a tautology.\n\treturn (value: unknown): value is unknown => !holds(() => guard(value))\n}\n\n/**\n * Builds a guard for `Exclude<TBase, TExcluded>` — accepts values that pass\n * `base` but not `excluded`.\n *\n * @remarks\n * The base and the exclusion are contained separately, for the reason {@link notOf}\n * states: a throwing exclusion is a non-match, so the complement passes.\n *\n * @param base - The guard establishing the accepted domain\n * @param excluded - The guard whose accepted values are removed from that domain\n * @returns A guard accepting a value `base` accepts and `excluded` rejects\n *\n * @example\n * ```ts\n * const isNonEmpty = complementOf(isString, isEmptyString)\n * isNonEmpty('hi') // true\n * isNonEmpty('') // false\n * ```\n */\nexport function complementOf<TBase, TExcluded extends TBase>(\n\tbase: Guard<TBase>,\n\texcluded: Guard<TExcluded> | ((value: TBase) => value is TExcluded),\n): Guard<Exclude<TBase, TExcluded>> {\n\t// Two separate containments, for the reason `notOf` carries: a throwing\n\t// EXCLUSION is a non-match, so the complement must PASS when the base passes.\n\t// One containment around `base(value) && !excluded(value)` made a value fail\n\t// both a guard and its complement.\n\treturn (value: unknown): value is Exclude<TBase, TExcluded> =>\n\t\tholds(() => {\n\t\t\tif (!base(value)) return false\n\t\t\tconst accepted = value\n\t\t\treturn !holds(() => excluded(accepted))\n\t\t})\n}\n\n/**\n * Builds a guard that accepts values matching at least one of the provided\n * guards — the variadic form of {@link orOf}.\n *\n * @remarks\n * Zero guards yield a guard that always answers `false`. Each member is contained\n * separately, exactly as {@link orOf} contains its two, so a throwing member cannot\n * erase a later passing one and the answer does not depend on argument order.\n *\n * @param guards - The guards tried in order\n * @returns A guard accepting a value at least one guard accepts\n *\n * @example\n * ```ts\n * const isStringOrBoolean = unionOf(isString, isBoolean)\n * ```\n */\nexport function unionOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<GuardType<Gs[number]>>\nexport function unionOf(...predicates: ReadonlyArray<(value: unknown) => boolean>): Guard<unknown>\nexport function unionOf(...guards: ReadonlyArray<(value: unknown) => boolean>): Guard<unknown> {\n\t// Per-member containment, exactly as its declared twin `orOf`: one `holds`\n\t// around the whole loop made a throwing member erase every later passing one,\n\t// so `unionOf(a, b)` and `unionOf(b, a)` answered differently for one value.\n\treturn (value: unknown): value is unknown => {\n\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\tconst guard = guards[index]\n\t\t\tif (guard !== undefined && holds(() => guard(value))) return true\n\t\t}\n\t\treturn false\n\t}\n}\n\n/**\n * Builds a guard that accepts values matching ALL of the provided guards — the\n * variadic form of {@link andOf}.\n *\n * @remarks\n * Zero guards yield a guard that always answers `true`, the identity of an\n * intersection.\n *\n * @param guards - The guards every accepted value must satisfy\n * @returns A guard accepting a value every guard accepts\n *\n * @example\n * ```ts\n * const isNonEmpty = intersectionOf(isString, isNonEmptyString)\n * ```\n */\nexport function intersectionOf<const Gs extends ReadonlyArray<Guard<unknown>>>(\n\t...guards: Gs\n): Guard<IntersectionFromGuards<Gs>>\nexport function intersectionOf(\n\t...predicates: ReadonlyArray<(value: unknown) => boolean>\n): Guard<unknown>\nexport function intersectionOf(\n\t...guards: ReadonlyArray<(value: unknown) => boolean>\n): Guard<unknown> {\n\treturn (value: unknown): value is unknown =>\n\t\tholds(() => {\n\t\t\t// Indexed, exactly as its declared twin `unionOf` is. `Array.prototype.every`\n\t\t\t// is forbidden here for the reason `literalOf` states earlier in this file:\n\t\t\t// a replaced `every` answering `true` for everything makes this guard accept\n\t\t\t// a value no constituent guard admits.\n\t\t\tfor (const index of iterateIndices(() => guards.length)) {\n\t\t\t\tconst guard = guards[index]\n\t\t\t\tif (guard === undefined || !guard(value)) return false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * Refines a base guard with an additional predicate that runs only when the base\n * passes.\n *\n * @remarks\n * The predicate receives a value already narrowed to `T`. When the predicate is\n * itself a type guard (`value is U`), the result narrows to `Guard<U>` — it\n * passes only when the value is genuinely a `U`, so the narrowing is sound. The\n * returned guard never throws, as `.claude/rules/patterns.md` § Validation and\n * contracts requires: if `predicate` throws, the throw is contained and the\n * guard reports a non-match.\n *\n * @param base - The guard establishing the accepted domain\n * @param predicate - The refinement run only after `base` passes\n * @returns A guard accepting a value `base` accepts and the refinement admits\n *\n * @example\n * ```ts\n * const isPositive = whereOf(isNumber, (n) => n > 0)\n * isPositive(5) // true\n * isPositive(-1) // false\n *\n * // A narrowing predicate refines the result type to Guard<5>\n * const isFive = whereOf(isNumber, (n): n is 5 => n === 5)\n * ```\n */\nexport function whereOf<T, U extends T>(\n\tbase: Guard<T>,\n\tpredicate: (value: T) => value is U,\n): Guard<U>\nexport function whereOf<T>(base: Guard<T>, predicate: (value: T) => boolean): Guard<T>\nexport function whereOf<T>(base: Guard<T>, predicate: (value: T) => boolean): Guard<T> {\n\treturn (value: unknown): value is T => holds(() => base(value) && predicate(value))\n}\n\n/**\n * Defers guard creation until first use by calling `thunk()` on every\n * invocation.\n *\n * @remarks\n * `thunk` is called on every guard call, not cached — this lets it close over a\n * binding assigned *after* `lazyOf` is called, the primary use case for\n * self-referential recursive guards. A throw from `thunk` (or the guard it\n * resolves to) is contained and reported as a non-match, as\n * `.claude/rules/patterns.md` § Validation and contracts requires.\n *\n * Each lazy guard tracks its active invocation depth. An invocation that would\n * exceed {@link GUARD_DEPTH_LIMIT} returns `false` before resolving `thunk`; the\n * counter always unwinds after the contained call, so one deep or cyclic input\n * cannot poison later guard calls.\n *\n * @param thunk - The factory producing the guard to apply, called on every invocation\n * @returns A guard deferring each call to the thunk's guard\n *\n * @example\n * ```ts\n * type Tree = { readonly value: number; readonly children: readonly Tree[] }\n * const isTree: Guard<Tree> = recordOf({\n * value: isNumber,\n * children: arrayOf(lazyOf(() => isTree)),\n * })\n * ```\n */\nexport function lazyOf<T>(thunk: () => Guard<T>): Guard<T> {\n\tconst deferred = new LazyGuard(thunk)\n\treturn (value: unknown): value is T => deferred.test(value)\n}\n\n/**\n * Builds a guard that passes when the base passes AND the projection of the value\n * satisfies the target guard. Still narrows to `T` (the base type) — the target\n * check is a validity constraint on a derived view, not a type transformation.\n *\n * @remarks\n * `project` is a plain `(value: T) => U`. The returned guard never\n * throws, as `.claude/rules/patterns.md` § Validation and contracts requires: a\n * throw from `project` or `target` is contained and reported as a\n * non-match. (Unlike the reference implementation, there is no\n * \"curried projector\" branch — a projection that legitimately returns a function\n * would be double-invoked under that scheme. Compose explicitly if you need it.)\n *\n * @param base - The guard establishing the accepted domain\n * @param project - The projection applied to a value `base` accepted\n * @param target - The guard the projection's result must satisfy\n * @returns A guard narrowing to the base type, accepting only a value whose projection satisfies `target`\n *\n * @example\n * ```ts\n * const isBounded = transformOf(\n * isString,\n * (s) => s.trim().length,\n * whereOf(isNumber, (n) => n >= 1 && n <= 50),\n * )\n * isBounded('hello') // true\n * isBounded('') // false\n * ```\n */\nexport function transformOf<T, U>(\n\tbase: Guard<T>,\n\tproject: (value: T) => U,\n\ttarget: Guard<U>,\n): Guard<T>\nexport function transformOf<T>(\n\tbase: Guard<T>,\n\tproject: (value: T) => unknown,\n\ttarget: (value: unknown) => boolean,\n): Guard<T>\nexport function transformOf<T>(\n\tbase: Guard<T>,\n\tproject: (value: T) => unknown,\n\ttarget: (value: unknown) => boolean,\n): Guard<T> {\n\treturn (value: unknown): value is T => holds(() => base(value) && target(project(value)))\n}\n\n/**\n * Builds a guard that accepts finite numbers within an inclusive `[min, max]`\n * range.\n *\n * @remarks\n * Refines {@link isFiniteNumber} with the bound comparison, so `NaN` /\n * `±Infinity` are rejected before any comparison runs. An absent bound never\n * constrains that side. Reused for a number's own value AND, applied to a\n * `.length`, for string and array length refinements — the single source of the\n * bound logic shared by the compiled guard and parser (compilers.ts).\n *\n * @param min - The inclusive lower bound, absent for unbounded below\n * @param max - The inclusive upper bound, absent for unbounded above\n * @returns A guard accepting a finite number inside the bounds\n *\n * @example\n * ```ts\n * const inRange = boundsOf(1, 5)\n * inRange(3) // true\n * inRange(0) // false — below min\n * inRange(6) // false — above max\n *\n * const atLeastTwo = boundsOf(2)\n * atLeastTwo(2) // true — unbounded above\n * ```\n */\nexport function boundsOf(min?: number, max?: number): Guard<number> {\n\treturn whereOf(\n\t\tisFiniteNumber,\n\t\t(value) => (min === undefined || value >= min) && (max === undefined || value <= max),\n\t)\n}\n\n/**\n * Builds a guard that accepts strings matching a regular expression.\n *\n * @remarks\n * Clones the pattern for the guard and strips the stateful `g` / `y` flags, so\n * repeated checks are stable and never change the caller's `lastIndex`.\n *\n * @param pattern - The regular expression to own and apply\n * @returns A stateless string guard\n *\n * @example\n * ```ts\n * const isHex = matchOf(/^[0-9a-f]+$/)\n * isHex('1a2f') // true\n * isHex('xyz') // false\n * ```\n */\nexport function matchOf(pattern: RegExp): Guard<string> {\n\treturn contain(() => {\n\t\tif (!isRegExp(pattern)) {\n\t\t\tthrow new ContractError('matchOf: pattern must be a RegExp', { code: 'pattern' })\n\t\t}\n\t\tconst owned = readValue(() => readPattern(pattern), 'matchOf', {\n\t\t\tsubject: 'pattern',\n\t\t\tcode: 'pattern',\n\t\t})\n\t\treturn whereOf(isString, (value) => matchesPattern(owned, value))\n\t}, 'matchOf')\n}\n\n/**\n * Builds a guard that accepts strings satisfying optional length and pattern\n * refinements — `min` / `max` length and a `pattern`.\n *\n * @remarks\n * Composes {@link isString} with {@link matchesStringLength}, which counts code\n * points as the `minLength` and `maxLength` a string shape emits do, and an owned\n * stateless pattern (the same refinement {@link matchOf} performs).\n * When `min`, `max`, and `pattern` are all absent it returns the bare {@link isString} guard\n * (the unconstrained fast path), so an unrefined string leaf pays no wrapping\n * cost. The single source of the string refinement shared by the compiled guard\n * and parser (compilers.ts).\n *\n * @param options - Optional length bounds and regular expression refinement\n * @returns A string guard enforcing the requested refinements\n * @throws {ContractError} When the options cannot be read\n *\n * @example\n * ```ts\n * const isSlug = stringOf({ min: 1, max: 32, pattern: /^[a-z-]+$/ })\n * isSlug('hello-world') // true\n * isSlug('') // false — below min\n * isSlug('Hello') // false — pattern miss\n *\n * stringOf() // identical to isString\n * ```\n */\nexport function stringOf(options?: StringGuardOptions): Guard<string> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'pattern'], 'stringOf', 'string')\n\t\t// Own reads, because the snapshot's prototype is `Object.prototype`, and a field\n\t\t// these options leave out must not answer from there.\n\t\tconst min = safe !== undefined && INTRINSICS.own(safe, 'min') ? safe.min : undefined\n\t\tconst max = safe !== undefined && INTRINSICS.own(safe, 'max') ? safe.max : undefined\n\t\tconst source = safe !== undefined && INTRINSICS.own(safe, 'pattern') ? safe.pattern : undefined\n\t\tif (source !== undefined && !isRegExp(source)) {\n\t\t\tthrow new ContractError('stringOf: pattern must be a RegExp', { code: 'pattern' })\n\t\t}\n\t\tconst pattern = source === undefined ? undefined : ownPattern(source, 'stringOf')\n\t\tif (min === undefined && max === undefined && pattern === undefined) {\n\t\t\treturn isString\n\t\t}\n\t\treturn whereOf(\n\t\t\tisString,\n\t\t\t(value) =>\n\t\t\t\tmatchesStringLength(value, min, max) &&\n\t\t\t\t(pattern === undefined || matchesPattern(pattern, value)),\n\t\t)\n\t}, 'stringOf')\n}\n\n/**\n * Extends a guard to also allow `null`.\n *\n * @param guard - The guard to extend\n * @returns A guard accepting `null` and every value `guard` accepts\n *\n * @example\n * ```ts\n * const isNullableString = nullableOf(isString)\n * isNullableString('hi') // true\n * isNullableString(null) // true\n * isNullableString(42) // false\n * ```\n */\nexport function nullableOf<T>(guard: Guard<T>): Guard<T | null> {\n\treturn (value: unknown): value is T | null => holds(() => value === null || guard(value))\n}\n\n/**\n * Extends a guard to also allow `undefined` — the optional counterpart of\n * {@link nullableOf}.\n *\n * @param guard - The guard to extend\n * @returns A guard accepting `undefined` and every value `guard` accepts\n *\n * @example\n * ```ts\n * const isOptionalString = optionalOf(isString)\n * isOptionalString('hi') // true\n * isOptionalString(undefined) // true\n * isOptionalString(null) // false\n * ```\n */\nexport function optionalOf<T>(guard: Guard<T>): Guard<T | undefined> {\n\treturn (value: unknown): value is T | undefined =>\n\t\tholds(() => value === undefined || guard(value))\n}\n","import type { FieldPath, Guard, JSONValue, LiteralValue } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tisArray,\n\tisFiniteNumber,\n\tisLiteralValue,\n\tisNull,\n\tisObject,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport {\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tholds,\n\tisFailure,\n\tisSuccess,\n\titerateIndices,\n\tmatchesJSONValue,\n\tmatchesMember,\n\treadArrayEntries,\n\treadValue,\n\tresolveField,\n} from './helpers.js'\n\n// `.claude/rules/patterns.md` § Validation and contracts: a parser answers\n// \"give me a `T` or nothing\" — it returns the\n// typed value or `undefined` for readable invalid input. `parseRecord` and\n// `parseJSONValue` refuse a failed traversal with a coded `ContractError`, so\n// unreadability cannot masquerade as ordinary invalidity. Each leaf parser here forms a\n// SOUND pair with the guard for its output TYPE: a guard-valid input is returned\n// UNCHANGED (by identity, never rejected), and every non-`undefined` output\n// satisfies that type guard. The pairings (verified in parsers.test.ts):\n//\n// parseString ↔ isString parseRecord ↔ isRecord\n// parseNumber ↔ isFiniteNumber parseArray ↔ arrayOf(guard) / isArray\n// parseInteger ↔ isInteger parseEnum ↔ literalOf(...allowed)\n// parseBoolean ↔ isBoolean parseNull ↔ isNull\n// parseJSONValue ↔ isJSONValue\n//\n// Coercion of NON-valid inputs (for example numeric strings → numbers) is a\n// bonus on top of soundness, not a violation of it — soundness constrains only\n// the inputs the guard already accepts.\n//\n// These leaf parsers are deliberately TYPE-only: they know nothing about a\n// shape's `min` / `max` / `pattern` refinements. Those refinements are enforced\n// one layer up, by the compiled parser (compilers.ts `compileParser`), which\n// re-applies the shared refinement combinators (`stringOf` / `boundsOf`,\n// combinators.ts) after coercion — the same source the compiled guard uses. So `createContract(...).parse` IS sound against the FULL\n// guard (refinements included); the split keeps each leaf parser small while the\n// compiler composes the full soundness.\n//\n// Coercion policy — which types cross into which:\n// - number <-> string is BIDIRECTIONAL by design: parseNumber accepts a\n// numeric string ('42' -> 42) and parseString accepts a finite number,\n// stringifying it (42 -> '42'). Use isString / isFiniteNumber directly\n// (never the parser) when you need STRICT type rejection with no coercion.\n// - boolean is a coercion SINK, never a source: parseBoolean accepts\n// 'true'/'false'/'1'/'0' and 1/0 and coerces them TO a boolean, but\n// parseNumber and parseString both reject booleans outright — a boolean\n// never coerces INTO a number or string. This is intentional asymmetry:\n// '1' meaning \"the number one\" and '1' meaning \"true\" are genuinely\n// different domains, so only the boolean parser treats the numeric/string\n// forms as booleans.\n\n// === Primitive parsers\n\n/**\n * Parses an unknown value to a string.\n *\n * @remarks\n * A string is returned unchanged; a finite number is coerced to its decimal\n * string (`42` → `'42'`). `NaN`, `±Infinity`, and every other type → `undefined`.\n *\n * @param value - The value to parse\n * @returns A string, or `undefined`\n *\n * @example\n * ```ts\n * parseString('hi') // 'hi'\n * parseString(42) // '42'\n * parseString(true) // undefined\n * ```\n */\nexport function parseString(value: unknown): string | undefined {\n\tif (isString(value)) return value\n\tif (isFiniteNumber(value)) return INTRINSICS.text(value)\n\treturn undefined\n}\n\n/**\n * Parses an unknown value to a finite number.\n *\n * @remarks\n * A finite number is returned unchanged; a non-blank numeric string is parsed\n * through `Number(...)`. `NaN`, `±Infinity`, blank/non-numeric strings, and every\n * other type → `undefined`.\n *\n * @param value - The value to parse\n * @returns A finite number, or `undefined`\n *\n * @example\n * ```ts\n * parseNumber(42) // 42\n * parseNumber('42') // 42\n * parseNumber('abc') // undefined\n * ```\n */\nexport function parseNumber(value: unknown): number | undefined {\n\tif (typeof value === 'number') {\n\t\treturn INTRINSICS.finite(value) ? value : undefined\n\t}\n\tif (!isString(value)) return undefined\n\t// Total by containment at the door. `String.prototype.trim` is a\n\t// caller-writable member reached by name, and this reader is documented to\n\t// ANSWER `undefined`, never to throw — so the boundary belongs here, where it\n\t// covers whatever the body reaches, rather than around the one dispatch\n\t// somebody happened to notice.\n\tconst outcome = attempt(() => {\n\t\tif (value.trim() === '') return undefined\n\t\tconst parsed = INTRINSICS.numeric(value)\n\t\treturn INTRINSICS.finite(parsed) ? parsed : undefined\n\t})\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Parses an unknown value to a finite integer.\n *\n * @remarks\n * Accepts whatever {@link parseNumber} accepts, then requires the result to have\n * no fractional part. `3.14` / `'3.14'` → `undefined`.\n *\n * @param value - The value to parse\n * @returns A finite integer, or `undefined`\n *\n * @example\n * ```ts\n * parseInteger(42) // 42\n * parseInteger(3.14) // undefined\n * ```\n */\nexport function parseInteger(value: unknown): number | undefined {\n\tconst parsed = parseNumber(value)\n\tif (parsed === undefined) return undefined\n\treturn INTRINSICS.integer(parsed) ? parsed : undefined\n}\n\n/**\n * Parses an unknown value to a boolean.\n *\n * @remarks\n * A boolean is returned unchanged. The strings `'true'` / `'false'` / `'1'` /\n * `'0'` and the numbers `1` / `0` coerce to the matching boolean. Everything\n * else → `undefined`.\n *\n * @param value - The value to parse\n * @returns A boolean, or `undefined`\n *\n * @example\n * ```ts\n * parseBoolean(true) // true\n * parseBoolean('1') // true\n * parseBoolean('nope') // undefined\n * ```\n */\nexport function parseBoolean(value: unknown): boolean | undefined {\n\tif (typeof value === 'boolean') return value\n\tif (value === 'true' || value === '1' || value === 1) return true\n\tif (value === 'false' || value === '0' || value === 0) return false\n\treturn undefined\n}\n\n/**\n * Parses an unknown value to `null`.\n *\n * @remarks\n * A successful parse returns `null` itself — distinct from the `undefined`\n * failure sentinel every other parser in this file uses. Only `null` passes;\n * every other value (including `undefined`) → `undefined`.\n *\n * @param value - The value to parse\n * @returns `null` on a successful parse, or `undefined`\n *\n * @example\n * ```ts\n * parseNull(null) // null\n * parseNull(undefined) // undefined\n * ```\n */\nexport function parseNull(value: unknown): null | undefined {\n\treturn isNull(value) ? value : undefined\n}\n\n// === Structural parsers\n\n/**\n * Parses an unknown value to a plain record — the input reference, never cloned.\n *\n * @remarks\n * Probes the record's own enumerable values before returning the reference, so a\n * hostile getter is met here rather than at the caller. A failed probe throws\n * `ContractError { code: 'structure' }` carrying `parseRecord: value could not be\n * read`; a readable non-record answers `undefined`.\n *\n * @param value - The value to parse\n * @returns The record, or `undefined`\n * @throws {ContractError} When an object value cannot be read\n */\nexport function parseRecord(value: unknown): Record<string, unknown> | undefined {\n\treturn contain(() => {\n\t\tif (isObject(value)) readValue(() => INTRINSICS.values(value), 'parseRecord')\n\t\treturn isRecord(value) ? value : undefined\n\t}, 'parseRecord')\n}\n\n/**\n * Parses an unknown value to an array — the input reference, never cloned —\n * optionally guarding every element.\n *\n * @remarks\n * Without a `guard`, element types are NOT verified; let `T` default to\n * `unknown` rather than asserting a specific element type.\n *\n * @param value - The value to parse\n * @param guard - Optional element guard\n * @returns The array, or `undefined`\n *\n * @example\n * ```ts\n * parseArray([1, 2]) // [1, 2]\n * parseArray([1, 'x'], isNumber) // undefined\n * ```\n */\nexport function parseArray<T = unknown>(\n\tvalue: unknown,\n\tguard?: Guard<T>,\n): readonly T[] | undefined {\n\tif (!isArray<T>(value)) return undefined\n\tif (guard === undefined) return value\n\tconst entries = readArrayEntries(value)\n\tif (isFailure(entries) || !entries.value.dense) return undefined\n\tif (\n\t\t!holds(\n\t\t\t() =>\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, entries.value.entries, [\n\t\t\t\t\t(entry: unknown) => !guard(entry),\n\t\t\t\t]) === -1,\n\t\t)\n\t) {\n\t\treturn undefined\n\t}\n\treturn value\n}\n\n/**\n * Parses an unknown value to a cycle-safe JSON value — the input reference,\n * never cloned.\n *\n * @remarks\n * Unlike {@link parseRecord} / {@link parseArray}, this is a DEEP gate: it\n * walks the entire tree through {@link isJSONValue} rather than checking only the\n * top-level shape. That walk is cycle-safe. A readable non-JSON structure,\n * including a cycle, returns `undefined`; a failed property read throws a\n * `structure` {@link ContractError}, keeping unreadability distinct from an\n * honest invalid result.\n *\n * @param value - The value to parse\n * @returns The value, or `undefined` when it is not a valid JSON value\n * @throws {ContractError} When the JSON tree cannot be read\n *\n * @example\n * ```ts\n * parseJSONValue({ a: 1 }) // { a: 1 }\n * parseJSONValue(Number.NaN) // undefined\n * ```\n */\nexport function parseJSONValue(value: unknown): JSONValue | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => (matchesJSONValue(value, new INTRINSICS.weakSet()) ? value : undefined),\n\t\t\t'parseJSONValue',\n\t\t\t{ context: { shape: 'json' } },\n\t\t)\n\t}, 'parseJSONValue')\n}\n\n// === Enum parser\n\n/**\n * Parses an unknown value as one of the allowed literal primitives.\n *\n * @remarks\n * Pairs with {@link literalOf} — both match by SameValueZero, so the\n * `parseEnum ↔ literalOf(...allowed)` pairing covers every literal primitive\n * (string, number, or boolean), not only strings. Matching is identity, never\n * cross-type coercion: `parseEnum('1', [1])` stays `undefined`. The allowed\n * values are captured through their dense own-index view and copied into an\n * owned `Set`; caller-defined iteration is ignored and unreadability returns\n * `undefined` rather than escaping.\n *\n * @param value - The value to parse\n * @param allowed - The permitted literal values\n * @returns The input when it matches an allowed literal by SameValueZero, or `undefined`\n *\n * @example\n * ```ts\n * parseEnum('b', ['a', 'b', 'c']) // 'b'\n * parseEnum('z', ['a', 'b', 'c']) // undefined\n * ```\n */\nexport function parseEnum<const T extends LiteralValue>(\n\tvalue: unknown,\n\tallowed: readonly T[],\n): T | undefined\nexport function parseEnum(\n\tvalue: unknown,\n\tallowed: readonly LiteralValue[],\n): LiteralValue | undefined\nexport function parseEnum(\n\tvalue: unknown,\n\tallowed: readonly LiteralValue[],\n): LiteralValue | undefined {\n\tconst outcome = readArrayEntries(allowed)\n\tif (isFailure(outcome) || !outcome.value.dense) return undefined\n\t// A parser answers `undefined`, never throws, so the vocabulary is built and\n\t// consulted inside the never-throw boundary — and the membership question is\n\t// asked through a module binding rather than any property, because a coercer\n\t// that returns a value outside its own allowed list is the same silent lie the\n\t// paired guard was answering: `Set.prototype.has = () => true` made\n\t// `parseEnum('zzz', ['a', 'b'])` answer `'zzz'`.\n\tif (!holds(() => matchesMember(collectMembers(outcome.value.entries), value))) return undefined\n\treturn isLiteralValue(value) ? value : undefined\n}\n\n/**\n * Parses indexed enum members, ending after the first undefined result.\n *\n * @param values - The source array, read by index\n * @param allowed - The accepted literal vocabulary\n * @returns Parsed members, including the first invalid member's undefined result\n *\n * @example\n * ```ts\n * Array.from(parseEnumValues(['a', 'x', 'b'], ['a', 'b'])) // ['a', undefined]\n * ```\n */\nexport function* parseEnumValues<const T extends LiteralValue>(\n\tvalues: readonly unknown[],\n\tallowed: readonly T[],\n): Generator<T | undefined, void, unknown> {\n\tfor (const index of iterateIndices(() => values.length)) {\n\t\tconst member = parseEnum(values[index], allowed)\n\t\tyield member\n\t\tif (member === undefined) return\n\t}\n}\n\nfor (const key of ['next', 'return', 'throw', Symbol.iterator]) {\n\tINTRINSICS.define(parseEnumValues.prototype, key, {\n\t\tvalue: INTRINSICS.reflect.read(parseEnumValues.prototype, key),\n\t})\n}\nINTRINSICS.freeze(parseEnumValues.prototype)\nINTRINSICS.freeze(parseEnumValues)\n\n// === Record-field parsers\n\n/**\n * Reads and parses a string field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A string, or `undefined`\n */\nexport function parseStringField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): string | undefined {\n\treturn parseString(resolveField(record, path))\n}\n\n/**\n * Reads and parses a finite-number field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A finite number, or `undefined`\n *\n * @example\n * ```ts\n * parseNumberField({ age: '42' }, 'age') // 42\n * parseNumberField({}, 'age') // undefined\n * ```\n */\nexport function parseNumberField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): number | undefined {\n\treturn parseNumber(resolveField(record, path))\n}\n\n/**\n * Reads and parses a finite-integer field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A finite integer, or `undefined`\n */\nexport function parseIntegerField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): number | undefined {\n\treturn parseInteger(resolveField(record, path))\n}\n\n/**\n * Reads and parses a boolean field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A boolean, or `undefined`\n *\n * @example\n * ```ts\n * parseBooleanField({ on: 'true' }, 'on') // true\n * parseBooleanField({}, 'on') // undefined\n * ```\n */\nexport function parseBooleanField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): boolean | undefined {\n\treturn parseBoolean(resolveField(record, path))\n}\n\n/**\n * Reads and parses a `null` field from a record by key or nested key path.\n *\n * @remarks\n * A successful parse returns `null` itself — distinct from the `undefined`\n * failure sentinel, which also covers a missing field.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns `null` on a successful parse, or `undefined`\n *\n * @example\n * ```ts\n * parseNullField({ value: null }, 'value') // null\n * parseNullField({}, 'value') // undefined\n * ```\n */\nexport function parseNullField(record: Record<string, unknown>, path: FieldPath): null | undefined {\n\treturn parseNull(resolveField(record, path))\n}\n\n/**\n * Reads and parses a nested record field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns A plain record, or `undefined`\n */\nexport function parseRecordField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): Record<string, unknown> | undefined {\n\treturn parseRecord(resolveField(record, path))\n}\n\n/**\n * Reads and parses an array field from a record by key or nested key path,\n * optionally guarding elements.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @param guard - Optional element guard\n * @returns An array, or `undefined`\n *\n * @example\n * ```ts\n * parseArrayField({ tags: [1, 2] }, 'tags') // [1, 2]\n * parseArrayField({}, 'tags') // undefined\n * ```\n */\nexport function parseArrayField<T = unknown>(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n\tguard?: Guard<T>,\n): readonly T[] | undefined {\n\treturn parseArray(resolveField(record, path), guard)\n}\n\n/**\n * Reads and parses an enum field from a record by key or nested key path.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @param allowed - The permitted literal values\n * @returns The matched literal, or `undefined`\n */\nexport function parseEnumField<const T extends LiteralValue>(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n\tallowed: readonly T[],\n): T | undefined {\n\treturn parseEnum(resolveField(record, path), allowed)\n}\n\n/**\n * Reads and parses a JSON-value field from a record by key or nested key path.\n *\n * @remarks\n * Deep-gates the field's whole subtree through {@link parseJSONValue} — see that\n * function's remarks for why this differs from the shallow\n * {@link parseRecordField} / {@link parseArrayField}.\n *\n * @param record - The source record\n * @param path - A property key, or a key path descending into nested objects\n * @returns The value, or `undefined`\n *\n * @example\n * ```ts\n * parseJSONValueField({ data: { a: 1 } }, 'data') // { a: 1 }\n * parseJSONValueField({}, 'data') // undefined\n * ```\n */\nexport function parseJSONValueField(\n\trecord: Record<string, unknown>,\n\tpath: FieldPath,\n): JSONValue | undefined {\n\treturn parseJSONValue(resolveField(record, path))\n}\n\n// === JSON\n\n/**\n * Parses a JSON string, returning `undefined` instead of throwing.\n *\n * @remarks\n * The safe boundary for untrusted JSON text: a malformed string yields\n * `undefined`, never an exception. Returns `unknown` — a successful parse proves\n * nothing about shape, so narrow the result with a guard (or use\n * {@link parseJSONAs}). A large document is not walked here; parsing is shallow\n * and lazy validation is the caller's to compose.\n *\n * @param value - The JSON string to parse\n * @returns The parsed value, or `undefined` when `value` is not valid JSON\n */\nexport function parseJSON(value: string): unknown {\n\ttry {\n\t\treturn INTRINSICS.decode(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Parses a JSON string and validates the result against a guard.\n *\n * @remarks\n * The lazy, safe path from an untrusted string to a typed `T`: parse, then check\n * the parsed value with the guard you bring — typically one composed from the\n * combinators (`recordOf`, `arrayOf`, …). Only the shape the guard inspects is\n * validated, so a large document is never walked in full unless the guard does.\n *\n * @param value - The JSON string to parse\n * @param guard - The guard for the expected shape\n * @returns The parsed value when it satisfies `guard`, otherwise `undefined`\n *\n * @example\n * ```ts\n * const isConfig = recordOf({ host: isString, tags: arrayOf(isString) })\n * parseJSONAs('{\"host\":\"localhost\",\"tags\":[\"a\"]}', isConfig) // { host: 'localhost', tags: ['a'] }\n * parseJSONAs('{\"host\":\"localhost\"}', isConfig) // undefined — guard fails\n * parseJSONAs('not json', isConfig) // undefined — never throws\n * ```\n */\nexport function parseJSONAs<T>(value: string, guard: Guard<T>): T | undefined {\n\tconst parsed = parseJSON(value)\n\tif (parsed === undefined) return undefined\n\t// The guard runs inside the shared result boundary rather than beside a `let`\n\t// the callback assigns into: the narrowed value IS the callback's answer, so\n\t// it is returned rather than ferried out of the branch that proved it.\n\tconst checked = attempt(() => (guard(parsed) ? parsed : undefined))\n\treturn isSuccess(checked) ? checked.value : undefined\n}\n","import type { EvaluationFunction } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { isFailure, readSetEntries } from './helpers.js'\nimport { isObject } from './validators.js'\n\n/** Owns compiled-node memo entries for one synchronous evaluation. */\nexport class EvaluationScope {\n\tstatic readonly #active = new INTRINSICS.set<EvaluationScope>()\n\tstatic readonly #path: readonly string[] = INTRINSICS.freeze([])\n\treadonly #answers = new INTRINSICS.weakMap<object, WeakMap<object, unknown>>()\n\n\t/** Evaluates a node within the active call, disposing a newly opened scope on settlement. */\n\tstatic run<T>(\n\t\tplan: EvaluationFunction<T>,\n\t\tvalue: unknown,\n\t\tpath: readonly string[] = EvaluationScope.#path,\n\t\tclean = false,\n\t): T {\n\t\tif (!isObject(value)) return plan(value, path)\n\t\tconst entries = readSetEntries(EvaluationScope.#active)\n\t\tif (isFailure(entries)) throw entries.error\n\t\tconst active = entries.value[0]\n\t\tif (active instanceof EvaluationScope) return active.#evaluate(plan, value, path, clean)\n\t\tif (active !== undefined) throw new INTRINSICS.error('Evaluation scope is unavailable')\n\t\tconst scope = new EvaluationScope()\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, EvaluationScope.#active, [scope])\n\t\ttry {\n\t\t\treturn scope.#evaluate(plan, value, path, clean)\n\t\t} finally {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.remove, EvaluationScope.#active, [scope])\n\t\t}\n\t}\n\n\t#evaluate<T>(\n\t\tplan: EvaluationFunction<T>,\n\t\tvalue: object,\n\t\tpath: readonly string[],\n\t\tclean: boolean,\n\t): T {\n\t\tconst cached: WeakMap<object, unknown> | undefined = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.recall,\n\t\t\tthis.#answers,\n\t\t\t[plan],\n\t\t)\n\t\tconst memo = cached ?? new INTRINSICS.weakMap<object, unknown>()\n\t\tif (cached === undefined) {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#answers, [plan, memo])\n\t\t}\n\t\tconst recalled: T | undefined = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\tif (recalled !== undefined) return recalled\n\t\tconst answer = plan(value, path)\n\t\tif (!clean || (INTRINSICS.array(answer) && answer.length === 0)) {\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t}\n\t\treturn answer\n\t}\n}\n","import { INTRINSICS } from './constants.js'\n\n/** Owns the changing state projected by one seeded random function. */\nexport class RandomSource {\n\t#state: number\n\n\tconstructor(seed: number) {\n\t\tthis.#state = seed >>> 0\n\t}\n\n\t/** Advances the generator and returns its next unit-interval value. */\n\tnext(): number {\n\t\tthis.#state = (this.#state + 0x6d2b79f5) >>> 0\n\t\tconst mixed = INTRINSICS.imul(this.#state ^ (this.#state >>> 15), this.#state | 1)\n\t\tconst final = mixed ^ (mixed + INTRINSICS.imul(mixed ^ (mixed >>> 7), mixed | 61))\n\t\treturn ((final ^ (final >>> 14)) >>> 0) / 4_294_967_296\n\t}\n}\n","import type { RandomFunction } from './types.js'\nimport { ContractError } from './errors.js'\nimport { preview } from './helpers.js'\nimport { RandomSource } from './RandomSource.js'\nimport { isNumber } from './validators.js'\n\n/**\n * Builds a deterministic pseudo-random source seeded from a single number.\n *\n * @remarks\n * A mulberry32 generator — the same seed always yields the same sequence, so\n * generated seed data is reproducible across runs. Used as the default random\n * source for {@link compileGenerator}, seeded from the wall clock so casual\n * callers still get varied output without passing a source themselves.\n *\n * @param seed - The seed for the sequence\n * @returns A {@link RandomFunction} returning values in `[0, 1)`\n *\n * @example\n * ```ts\n * const random = seededRandom(42)\n * random() // always the same first value for seed 42\n * ```\n */\nexport function seededRandom(seed: number): RandomFunction {\n\tif (!isNumber(seed)) {\n\t\tthrow new ContractError('seededRandom: seed must be a number', {\n\t\t\tcode: 'random',\n\t\t\tcontext: { limit: 'number', received: preview(seed) },\n\t\t})\n\t}\n\tconst source = new RandomSource(seed)\n\treturn () => source.next()\n}\n","import type {\n\tArrayShape,\n\tAuditFault,\n\tAuditorFunction,\n\tContractCompilerInterface,\n\tContractInterface,\n\tContractShape,\n\tFault,\n\tFaultKind,\n\tGuard,\n\tInfer,\n\tJSONSchema,\n\tJSONValue,\n\tLiteralValue,\n\tNumberShape,\n\tObjectShape,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tResult,\n\tSeederFunction,\n\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport {\n\tFAULT_LIMIT,\n\tGENERATION_ATTEMPT_LIMIT,\n\tINTRINSICS,\n\tPRESENCE_MASK_LIMIT,\n\tSHAPE_FIELDS,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tappendEntries,\n\tattempt,\n\titerateIndices,\n\tcollectMembers,\n\tcontain,\n\tbuildArrayFaults,\n\tbuildPositions,\n\tbuildNumberFaults,\n\tbuildStringFaults,\n\tcomputeMonthLength,\n\tdrawRandom,\n\tenumerableKeys,\n\tisFailure,\n\tisSuccess,\n\tlimitEntries,\n\tmatchesCalendarDate,\n\tmatchesMember,\n\townPattern,\n\tpathOf,\n\tpinMembers,\n\tpreview,\n\treadArrayEntries,\n\treadPatternSource,\n\treadPresence,\n\treadValue,\n\trefuseExpansion,\n\tselectClosestFaults,\n\tshapeToKind,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisJSONValue,\n\tisNull,\n\tisObject,\n\tisRecord,\n\tisString,\n\tisUndefined,\n} from './validators.js'\nimport {\n\tarrayOf,\n\tboundsOf,\n\tintersectionOf,\n\tliteralOf,\n\tmatchOf,\n\tnullableOf,\n\torOf,\n\tstringOf,\n\tunionOf,\n\twhereOf,\n} from './combinators.js'\nimport { parseBoolean, parseInteger, parseJSONValue, parseNumber, parseString } from './parsers.js'\nimport { cloneJSONValue, cloneSchema, ownShape } from './cloners.js'\nimport { ShapePass } from './ShapePass.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { EvaluationScope } from './EvaluationScope.js'\nimport { seededRandom } from './seeders.js'\n\n/**\n * Owns one contract shape's artifacts and their bundle, compiled lazily.\n *\n * @remarks\n * The engine every standalone `compile*` function and `createContract` runs\n * on. A recursive compiler re-owns and\n * re-validates the SUBGRAPH at every node it descends into, so a depth-100\n * chain pays a hundred clones of shrinking graphs and a hundred validations —\n * quadratic work for a linear declaration. Here ownership runs once, validation runs once over\n * that owned result, and each unique node and structural edge is indexed once\n * into children-before-parent order. A declaration a builder sealed is frozen and\n * validated all the way down already, so it takes neither and is indexed as it\n * stands. Every artifact family is then a single\n * postorder pass whose entries are keyed by node identity, so a shared child is\n * compiled once however many parents point at it. The same asymmetry exists on\n * the VALUE side and is answered the same way: `guard`, `auditor` and `reporter`\n * carry a call-scoped ledger, so a shared object costs one visit per compiled\n * node rather than one per path through the graph.\n *\n * Construction observes nothing at all: no read, no validation, no clone, no\n * graph-sized allocation, no clock, no draw. The first getter read prepares; the\n * getters after it replay. A getter builds its own family and no other, except\n * that `parser`, `reporter` and `generator` build the guard plan when the graph\n * holds a union, because a union's membership question IS a guard question in\n * all three, and every getter builds it when the graph holds a default, because\n * a default that its inner shape refuses refuses at whichever artifact is read\n * first.\n *\n * One terminal lifecycle covers preparation and every family. A failure settles\n * the compiler: later getters rethrow that exact error, while an artifact\n * already handed out keeps working, because each compiled artifact is\n * self-contained. Reentry — reachable only through a caller accessor the\n * declaration itself exposes, since a `pattern` getter is the one accessor\n * ownership invokes — poisons the nested read, the interrupted outer read, and\n * every later read with one shared cause-free error.\n *\n * @typeParam S - The declaration's shape type, which types the published artifacts\n *\n * @example\n * ```ts\n * const compiler = new ContractCompiler({ category: 'string', min: 1 })\n * compiler.guard('Ada') // true\n * compiler.guard === compiler.guard // true — every getter replays its exact root\n * ```\n */\nexport class ContractCompiler<\n\tS extends ContractShape = ContractShape,\n> implements ContractCompilerInterface<S> {\n\t// Captured while this module evaluates — the qualification matters, because\n\t// \"before any caller code runs\" is false for a consumer module ordered\n\t// earlier, which is the limit `constants.ts` states and does not defend. The\n\t// node index is built and released outside every containment this class has,\n\t// so a replaced `globalThis.WeakMap` would throw a caller value out of a door\n\t// documented to publish a `ContractError`.\n\tstatic readonly #weakMap = WeakMap\n\t// The released state, shared by every compiler this class ever builds.\n\t// `#release` assigns these in place of the working collections, so an instance\n\t// allocates one collection per family instead of two and construction carries\n\t// no empty peer of its own. Sharing them is safe because nothing MUTATES a\n\t// released collection: every element write — `#discover`, `#schedule`, and the\n\t// family loops — runs behind `#prepare`, which refuses after `#release`\n\t// clears `#source`; the constructor and `#release` assign the field and never\n\t// touch a sentinel's elements. The static block beneath freezes them, so a\n\t// write that did reach one fails at its own line rather than leaking a node of\n\t// one compiler's graph into every other compiler's release — under the same\n\t// qualification `#weakMap` carries earlier: `INTRINSICS.freeze` is captured\n\t// while this module evaluates, so a consumer module ordered before\n\t// `constants.ts` defeats it, and that limit is stated there rather than\n\t// defended.\n\tstatic readonly #emptyStack: Array<\n\t\t| { readonly operation: 'enter'; readonly shape: ContractShape }\n\t\t| { readonly operation: 'exit'; readonly index: number }\n\t> = []\n\tstatic readonly #emptyNodes: ContractShape[] = []\n\tstatic readonly #emptyOrder: number[] = []\n\tstatic readonly #emptySchemas: JSONSchema[] = []\n\tstatic readonly #emptyGuards: Array<Guard<unknown>> = []\n\tstatic readonly #emptyParsers: Array<Parser<unknown>> = []\n\tstatic readonly #emptyAudits: Array<\n\t\t(value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t> = []\n\tstatic readonly #emptyReports: Array<\n\t\t(value: unknown, path: readonly string[]) => readonly Fault[]\n\t> = []\n\tstatic readonly #emptySeeds: Array<(random: RandomFunction) => unknown> = []\n\n\tstatic {\n\t\t// Frozen in a statement of its own, and the result discarded: `Object.freeze`\n\t\t// returns a readonly view, so binding it back would retype the peers and\n\t\t// stop them satisfying the mutable working fields they are assigned to.\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyStack)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyNodes)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyOrder)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptySchemas)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyGuards)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyParsers)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyAudits)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptyReports)\n\t\tINTRINSICS.freeze(ContractCompiler.#emptySeeds)\n\t}\n\n\t#source: ContractShape | undefined\n\t#state:\n\t\t| { readonly phase: 'ready' }\n\t\t| { readonly phase: 'running'; readonly poison: ContractError }\n\t\t| { readonly phase: 'interrupted'; readonly poison: ContractError }\n\t\t| { readonly phase: 'failed'; readonly error: ContractError }\n\t#stack: Array<\n\t\t| { readonly operation: 'enter'; readonly shape: ContractShape }\n\t\t| { readonly operation: 'exit'; readonly index: number }\n\t>\n\t// The prepared index. `#nodes[0]` is the owned root by construction, `#index`\n\t// answers \"which node is this child\" by identity, and `#order` lists every\n\t// node with its children already listed before it — so a family solves any\n\t// bottom-up fact by reading it forwards once. The index is the one working\n\t// field with no shared peer: `Object.freeze` reaches an array's writes and not\n\t// a `WeakMap`'s, so a shared empty map would be a class-lifetime cache that\n\t// any write could fill with the caller's own shapes. Release drops the map\n\t// instead, and absence is `undefined`.\n\t#nodes: ContractShape[]\n\t#index: WeakMap<ContractShape, number> | undefined\n\t#order: number[]\n\t// One plan per family, each indexed by the same node index. A plan entry is a\n\t// self-contained artifact for that node: it closes over the CHILD entries it\n\t// needs, resolved while the family is built, so nothing a compiled artifact\n\t// does at call time reaches back into the index this class later releases.\n\t#schemas: JSONSchema[]\n\t#guards: Array<Guard<unknown>>\n\t#parsers: Array<Parser<unknown>>\n\t#audits: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]>\n\t#reports: Array<(value: unknown, path: readonly string[]) => readonly Fault[]>\n\t#seeds: Array<(random: RandomFunction) => unknown>\n\t#schema: JSONSchema | undefined\n\t#guard: Guard<unknown> | undefined\n\t#parser: Parser<unknown> | undefined\n\t#auditor: AuditorFunction | undefined\n\t#reporter: ReporterFunction | undefined\n\t#generator: SeederFunction<unknown> | undefined\n\t#bundle: ContractInterface<unknown> | undefined\n\n\t/**\n\t * Retains a shape declaration without observing it.\n\t *\n\t * @param shape - The live declaration the first getter read will own\n\t */\n\tconstructor(shape: S) {\n\t\tthis.#source = shape\n\t\tthis.#state = { phase: 'ready' }\n\t\tthis.#stack = []\n\t\tthis.#nodes = []\n\t\tthis.#index = new ContractCompiler.#weakMap()\n\t\tthis.#order = []\n\t\tthis.#schemas = []\n\t\tthis.#guards = []\n\t\tthis.#parsers = []\n\t\tthis.#audits = []\n\t\tthis.#reports = []\n\t\tthis.#seeds = []\n\t\tthis.#schema = undefined\n\t\tthis.#guard = undefined\n\t\tthis.#parser = undefined\n\t\tthis.#auditor = undefined\n\t\tthis.#reporter = undefined\n\t\tthis.#generator = undefined\n\t\tthis.#bundle = undefined\n\t}\n\n\t/**\n\t * Returns the emitted JSON Schema for the owned declaration.\n\t *\n\t * @remarks\n\t * A deeply frozen graph that preserves shared declaration identity: two\n\t * property slots holding the same authored node hold the same emitted\n\t * subschema, while structurally equal distinct nodes stay distinct objects.\n\t */\n\tget schema(): JSONSchema {\n\t\tconst ready = this.#schema\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildSchema())\n\t}\n\n\t/** Returns the compiled strict guard for the owned declaration. */\n\tget guard(): Guard<Infer<S>> {\n\t\tconst ready = this.#guard\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildGuard()))\n\t}\n\n\t/** Returns the compiled coercive parser for the owned declaration. */\n\tget parser(): Parser<Infer<S>> {\n\t\tconst ready = this.#parser\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildParser()))\n\t}\n\n\t/** Returns the compiled strict-domain diagnostic for the owned declaration. */\n\tget auditor(): AuditorFunction {\n\t\tconst ready = this.#auditor\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildAuditor())\n\t}\n\n\t/** Returns the compiled coercive-domain diagnostic for the owned declaration. */\n\tget reporter(): ReporterFunction {\n\t\tconst ready = this.#reporter\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return ready\n\t\treturn this.#enter(() => this.#buildReporter())\n\t}\n\n\t/** Returns the compiled seed-data source for the owned declaration. */\n\tget generator(): SeederFunction<Infer<S>> {\n\t\tconst ready = this.#generator\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildGenerator()))\n\t}\n\n\t/**\n\t * Returns the frozen bundle of this compiler's artifacts.\n\t *\n\t * @remarks\n\t * Own enumerable keys `schema`, `is`, `parse`, `audit`, `explain`,\n\t * `generate`, in that order, each holding the exact value the corresponding\n\t * getter publishes.\n\t */\n\tget contract(): ContractInterface<Infer<S>> {\n\t\tconst ready = this.#bundle\n\t\tif (ready !== undefined && this.#state.phase === 'ready') return this.#publish(ready)\n\t\treturn this.#publish(this.#enter(() => this.#buildContract()))\n\t}\n\n\t// The one typed boundary in this class. Every family is compiled over the\n\t// OWNED graph, whose static type is the widened `ContractShape` union, while\n\t// the compiler publishes artifacts under the inferred type of the declaration\n\t// it was constructed from. The standalone `compile*` functions make the\n\t// identical claim through their own overload pairs; declaring it once here is\n\t// that same statement rather than an extra one, and it is the reason no\n\t// assertion appears anywhere in this file.\n\t#publish(root: Guard<unknown>): Guard<Infer<S>>\n\t#publish(root: Parser<unknown>): Parser<Infer<S>>\n\t#publish(root: SeederFunction<unknown>): SeederFunction<Infer<S>>\n\t#publish(root: ContractInterface<unknown>): ContractInterface<Infer<S>>\n\t#publish(root: unknown): unknown {\n\t\treturn root\n\t}\n\n\t// Lifecycle. Every getter runs its build inside this, so preparation and every\n\t// family share one terminal state.\n\t#enter<T>(build: () => T): T {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'failed') throw state.error\n\t\tif (state.phase === 'running' || state.phase === 'interrupted') {\n\t\t\tthis.#state = { phase: 'interrupted', poison: state.poison }\n\t\t\tthrow state.poison\n\t\t}\n\t\t// Created BEFORE the source is observed, for the same reason the cloners\n\t\t// create theirs there: a poison built on the settlement path would be built\n\t\t// under whatever the caller installed while the build was running.\n\t\tconst poison = new ContractError(\n\t\t\t'ContractCompiler: contract compilation may not be reentered',\n\t\t\t{ code: 'structure', context: { path: [], shape: 'contract' } },\n\t\t)\n\t\tthis.#state = { phase: 'running', poison }\n\t\treturn this.#leave(attempt(build))\n\t}\n\n\t#leave<T>(outcome: Result<T>): T {\n\t\tconst state = this.#state\n\t\tif (state.phase === 'interrupted') return this.#fail(state.poison)\n\t\tif (isFailure(outcome)) {\n\t\t\treturn this.#fail(\n\t\t\t\tisContractError(outcome.error)\n\t\t\t\t\t? outcome.error\n\t\t\t\t\t: new ContractError('ContractCompiler: contract compilation failed', {\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t\t\t\t\tcause: outcome.error,\n\t\t\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tthis.#state = { phase: 'ready' }\n\t\tthis.#collect()\n\t\treturn outcome.value\n\t}\n\n\t#fail(error: ContractError): never {\n\t\tthis.#state = { phase: 'failed', error }\n\t\tthis.#release()\n\t\tthrow error\n\t}\n\n\t// Once every root exists nothing can need the graph again, so the graph, the\n\t// index, the order and every family plan go. The roots and the optional\n\t// frozen bundle stay, and so does terminal state.\n\t#collect(): void {\n\t\tif (this.#schema === undefined || this.#guard === undefined) return\n\t\tif (this.#parser === undefined || this.#auditor === undefined) return\n\t\tif (this.#reporter === undefined || this.#generator === undefined) return\n\t\tthis.#release()\n\t}\n\n\t// Assignment only: every working collection takes the class's shared frozen\n\t// empty peer and the index is dropped outright. Nothing here calls a\n\t// caller-mutable cleanup member and nothing here constructs a collection at\n\t// all, so release cannot be redirected into leaving state behind.\n\t#release(): void {\n\t\tthis.#source = undefined\n\t\tthis.#stack = ContractCompiler.#emptyStack\n\t\tthis.#nodes = ContractCompiler.#emptyNodes\n\t\tthis.#index = undefined\n\t\tthis.#order = ContractCompiler.#emptyOrder\n\t\tthis.#schemas = ContractCompiler.#emptySchemas\n\t\tthis.#guards = ContractCompiler.#emptyGuards\n\t\tthis.#parsers = ContractCompiler.#emptyParsers\n\t\tthis.#audits = ContractCompiler.#emptyAudits\n\t\tthis.#reports = ContractCompiler.#emptyReports\n\t\tthis.#seeds = ContractCompiler.#emptySeeds\n\t}\n\n\t// === Preparation\n\n\t#prepare(): void {\n\t\tif (this.#nodes.length > 0) return\n\t\tconst source = this.#source\n\t\tif (source === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the retained declaration is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\t// A node a builder sealed is already frozen and validated all the way down, so\n\t\t// it is owned as it stands and only the emitted-node bound is left to ask.\n\t\tconst sealed = ShapePass.expansionOf(source)\n\t\tif (sealed !== undefined) {\n\t\t\trefuseExpansion(sealed)\n\t\t\tthis.#discover(source)\n\t\t\tthis.#source = undefined\n\t\t\treturn\n\t\t}\n\t\t// ONE ownership population for the whole compiler. `ownShape` runs the\n\t\t// accepted `ShapeCloner`, whose completed-root pass validates what it built;\n\t\t// the pass below is this compiler's own single validation of that owned\n\t\t// result, and it is where the emitted-node bound is applied — the gate that\n\t\t// owns that rule authors its diagnosis, so the refusal reads identically\n\t\t// however the caller arrived.\n\t\tconst owned = ownShape(source)\n\t\t// Ownership has already bounded capture. This existing validation checks\n\t\t// that bounded graph without opening a second capture budget for this call.\n\t\trefuseExpansion(new ShapePass(owned).validate())\n\t\tthis.#discover(owned)\n\t\tthis.#source = undefined\n\t}\n\n\t#discover(root: ContractShape): void {\n\t\t// Narrowed once at the door, because both dispatches below take their\n\t\t// receiver type from this value. `#prepare` is the only caller and it\n\t\t// refuses while the declaration is gone, so the walk always finds the map\n\t\t// the constructor built; this refusal is what keeps that a statement the\n\t\t// types carry rather than one a comment makes.\n\t\tconst known = this.#index\n\t\tif (known === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the prepared index is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: root }\n\t\twhile (this.#stack.length > 0) {\n\t\t\t// Popped by index and truncated by `length`, never through\n\t\t\t// `Array.prototype.pop`: that member is caller-writable and this walk runs\n\t\t\t// after the two contained engines have finished, so a redirect here would\n\t\t\t// be the one dispatch in this class with nothing between it and the\n\t\t\t// caller. Indexed reads and a `length` assignment on an array this class\n\t\t\t// built reach no member at all.\n\t\t\tconst top = this.#stack.length - 1\n\t\t\tconst frame = this.#stack[top]\n\t\t\tthis.#stack.length = top\n\t\t\tif (frame === undefined) continue\n\t\t\tif (frame.operation === 'exit') {\n\t\t\t\tthis.#order[this.#order.length] = frame.index\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst shape = frame.shape\n\t\t\t// A node reached a second time is already indexed, and the graph is\n\t\t\t// acyclic by validation, so it is already finished too — which is exactly\n\t\t\t// what makes one entry per unique node correct rather than merely cheap.\n\t\t\tif (INTRINSICS.reflect.apply(INTRINSICS.recall, known, [shape]) !== undefined) continue\n\t\t\tconst index = this.#nodes.length\n\t\t\t// `Object.prototype` can gain a field a node leaves out at any time after this\n\t\t\t// call, and a family or a report plan reading the node would answer from it, so\n\t\t\t// they read an own copy that cannot inherit.\n\t\t\tconst node: ContractShape = INTRINSICS.rebase({ ...shape }, null)\n\t\t\tthis.#nodes[index] = node\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, known, [node, index])\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, known, [shape, index])\n\t\t\tthis.#stack[this.#stack.length] = { operation: 'exit', index }\n\t\t\tthis.#schedule(shape)\n\t\t}\n\t}\n\n\t// Children are pushed in REVERSE slot order so the walk discovers them in\n\t// declaration order, which keeps node indices deterministic for one graph.\n\t#schedule(shape: ContractShape): void {\n\t\tswitch (shape.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: shape.items }\n\t\t\t\treturn\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: shape.inner }\n\t\t\t\treturn\n\t\t\tcase 'union': {\n\t\t\t\tfor (const offset of iterateIndices(() => shape.variants.length)) {\n\t\t\t\t\tconst index = shape.variants.length - 1 - offset\n\t\t\t\t\tconst variant = shape.variants[index]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: variant }\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: extra }\n\t\t\t\t}\n\t\t\t\tconst keys = INTRINSICS.keys(shape.properties)\n\t\t\t\tfor (const offset of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst index = keys.length - 1 - offset\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = shape.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tthis.#stack[this.#stack.length] = { operation: 'enter', shape: child }\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t}\n\t}\n\n\t#locate(shape: ContractShape): number {\n\t\t// The receiver is narrowed BEFORE the dispatch. `INTRINSICS.reflect.apply` takes its\n\t\t// receiver type from this argument rather than from the target, so a dropped\n\t\t// index would leave `WeakMap.prototype.get` throwing a host `TypeError`\n\t\t// through a door whose whole contract is that it publishes this package's\n\t\t// error class. Defense in depth, not a live path: a released compiler holds\n\t\t// every root, so every family returns its ready root before locating\n\t\t// anything, and a failed one rethrows at `#enter` — which is why no\n\t\t// reachable vector settles here and the guard still belongs.\n\t\tconst known = this.#index\n\t\tif (known === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: the prepared index is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\tconst index = INTRINSICS.reflect.apply(INTRINSICS.recall, known, [shape])\n\t\tif (index === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a structural child is not in the prepared index', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn index\n\t}\n\n\t#node(index: number): ContractShape {\n\t\tconst shape = this.#nodes[index]\n\t\tif (shape === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a prepared node is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn shape\n\t}\n\n\t// A union's membership answer is its compiled guard in the parser, the\n\t// reporter and the generator alike, so those three build the guard plan when —\n\t// and only when — the graph actually holds one.\n\t#unions(): boolean {\n\t\tfor (const index of iterateIndices(() => this.#nodes.length)) {\n\t\t\tif (this.#nodes[index]?.category === 'union') return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// A default is judged by the guard of the shape it fills, and a declaration that\n\t// refuses has to refuse at whichever artifact is read first, so every family builds\n\t// the guard plan when — and only when — the graph holds a default.\n\t#defaults(): boolean {\n\t\tfor (const index of iterateIndices(() => this.#nodes.length)) {\n\t\t\tconst node = this.#nodes[index]\n\t\t\tif (node?.category === 'optional' && INTRINSICS.own(node, 'default')) return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// Walks the declaration rather than the node list, because the path a refusal names\n\t// exists only on the way down. Validation bounded the tree this expands into, and\n\t// `#buildGuard` runs this once, on a graph that holds a default.\n\t#checkDefaults(shape: ContractShape, path: readonly string[]): void {\n\t\tswitch (shape.category) {\n\t\t\tcase 'array':\n\t\t\t\tthis.#checkDefaults(shape.items, pathOf(path, 'items'))\n\t\t\t\treturn\n\t\t\tcase 'nullable':\n\t\t\t\tthis.#checkDefaults(shape.inner, pathOf(path, 'inner'))\n\t\t\t\treturn\n\t\t\tcase 'optional': {\n\t\t\t\tthis.#checkDefaults(shape.inner, pathOf(path, 'inner'))\n\t\t\t\tif (!INTRINSICS.own(shape, 'default') || this.#guardAt(shape.inner)(shape.default)) return\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'ContractCompiler: a default must satisfy the shape it fills; change the default or the shape',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\tpath: pathOf(path, 'default'),\n\t\t\t\t\t\t\tshape: 'optional',\n\t\t\t\t\t\t\treceived: preview(shape.default),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase 'union':\n\t\t\t\tfor (const index of iterateIndices(() => shape.variants.length)) {\n\t\t\t\t\tconst variant = shape.variants[index]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tthis.#checkDefaults(variant, pathOf(path, 'variants', INTRINSICS.text(index)))\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\tcase 'object': {\n\t\t\t\tconst keys = INTRINSICS.keys(shape.properties)\n\t\t\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tconst child = key === undefined ? undefined : shape.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tthis.#checkDefaults(child, pathOf(path, 'properties', key))\n\t\t\t\t}\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\tif (extra !== undefined && extra !== true && extra !== false) {\n\t\t\t\t\tthis.#checkDefaults(extra, pathOf(path, 'additionalProperties'))\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t}\n\t}\n\n\t// Each root evaluation owns the answers for its active synchronous walk.\n\t// Shared objects reuse one answer per compiled node; the scope is removed\n\t// in finally so later calls always observe the caller's current value.\n\n\t// Only a node that descends into a child artifact can be reached twice through\n\t// one value; a leaf answers about the value in front of it, so tracking one\n\t// would buy nothing and would replace the package's own guards and parsers in\n\t// the artifacts a leaf-rooted declaration publishes.\n\t#repeats(index: number): boolean {\n\t\tconst category = this.#node(index).category\n\t\tif (category === 'array' || category === 'object' || category === 'union') return true\n\t\treturn category === 'optional' || category === 'nullable'\n\t}\n\n\t#trackGuard(plan: Guard<unknown>): Guard<unknown> {\n\t\treturn (value: unknown): value is unknown => EvaluationScope.run(plan, value)\n\t}\n\n\t// The diagnostic families reuse only the CLEAN verdict, because a fault\n\t// carries the path it was found at while emptiness carries nothing: a node\n\t// that reported no fault about an object reports none about it wherever else\n\t// the walk arrives. A faulted node is re-walked at its new path, and stays\n\t// bounded by `FAULT_LIMIT` — every collector stops once the cap is reached, so\n\t// a value that faults everywhere saturates instead of expanding.\n\t#trackFaults<T>(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly T[],\n\t): (value: unknown, path: readonly string[]) => readonly T[] {\n\t\treturn (value, path) => EvaluationScope.run(plan, value, path, true)\n\t}\n\n\t// What tells a union's arms apart, when anything does: a property every arm is an\n\t// object declaring as a required literal. A value names an arm when its own data\n\t// property exactly equals a literal only that arm holds, which is the membership the\n\t// literal guard asks, so no other arm's guard could accept that value and the named\n\t// arm answers for the whole union. A key whose literal two arms share names nothing,\n\t// so the next such key is asked. The answer closes over no part of this compiler.\n\t#discriminate(owned: UnionShape):\n\t\t| {\n\t\t\t\treadonly select: (value: unknown) => number | undefined\n\t\t\t\treadonly hint: { readonly key: string; readonly expected: readonly LiteralValue[] }\n\t\t }\n\t\t| undefined {\n\t\tconst arms: readonly ObjectShape[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(owned.variants),\n\t\t\t[(variant: ContractShape | undefined) => variant?.category === 'object'],\n\t\t)\n\t\tconst first = arms[0]\n\t\tif (first === undefined || arms.length !== owned.variants.length) return undefined\n\t\tconst keys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(INTRINSICS.keys(first.properties)),\n\t\t\t[\n\t\t\t\t(key: string) =>\n\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, arms, [\n\t\t\t\t\t\t(arm: ObjectShape) =>\n\t\t\t\t\t\t\t!INTRINSICS.own(arm.properties, key) || arm.properties[key]?.category !== 'literal',\n\t\t\t\t\t]),\n\t\t\t],\n\t\t)\n\t\tconst tables: ReadonlyArray<{\n\t\t\treadonly key: string\n\t\t\treadonly members: Map<unknown, number>\n\t\t\treadonly expected: readonly LiteralValue[]\n\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keys), [\n\t\t\t(key: string) => ContractCompiler.#tableOf(key, arms),\n\t\t])\n\t\tconst named = tables[0]\n\t\tif (named === undefined) return undefined\n\t\treturn {\n\t\t\thint: INTRINSICS.freeze({ key: named.key, expected: named.expected }),\n\t\t\tselect: (value: unknown): number | undefined => {\n\t\t\t\tif (!isObject(value)) return undefined\n\t\t\t\tfor (const index of iterateIndices(() => tables.length)) {\n\t\t\t\t\tconst table = tables[index]\n\t\t\t\t\tif (table === undefined) continue\n\t\t\t\t\tconst held = attempt(() => INTRINSICS.describe(value, table.key))\n\t\t\t\t\tif (isFailure(held) || held.value === undefined) continue\n\t\t\t\t\tif (!INTRINSICS.own(held.value, 'value')) continue\n\t\t\t\t\tconst arm = INTRINSICS.reflect.apply(INTRINSICS.fetch, table.members, [held.value.value])\n\t\t\t\t\tif (arm !== undefined && arm >= 0) return arm\n\t\t\t\t}\n\t\t\t\treturn undefined\n\t\t\t},\n\t\t}\n\t}\n\n\t// One key's literals, each with the arm that alone holds it, or -1 when two arms do.\n\tstatic #tableOf(\n\t\tkey: string,\n\t\tarms: readonly ObjectShape[],\n\t): {\n\t\treadonly key: string\n\t\treadonly members: Map<unknown, number>\n\t\treadonly expected: readonly LiteralValue[]\n\t} {\n\t\tconst members = new INTRINSICS.map<unknown, number>()\n\t\tconst expected: LiteralValue[] = []\n\t\tfor (const armIndex of iterateIndices(() => arms.length)) {\n\t\t\tconst node = arms[armIndex]?.properties[key]\n\t\t\tif (node?.category !== 'literal') continue\n\t\t\tfor (const valueIndex of iterateIndices(() => node.values.length)) {\n\t\t\t\tconst literal = node.values[valueIndex]\n\t\t\t\tif (literal === undefined) continue\n\t\t\t\tconst known = INTRINSICS.reflect.apply(INTRINSICS.fetch, members, [literal])\n\t\t\t\tif (known === undefined) expected[expected.length] = literal\n\t\t\t\tconst arm = known === undefined || known === armIndex ? armIndex : -1\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.store, members, [literal, arm])\n\t\t\t}\n\t\t}\n\t\treturn { key, members, expected: INTRINSICS.freeze(expected) }\n\t}\n\n\t// The union parser's own two steps, over the named arm alone. A value that arm accepts\n\t// returns by identity, and a coercion must satisfy the arm's guard.\n\tstatic #parseArm(\n\t\tarm: { readonly parse: Parser<unknown>; readonly guard: Guard<unknown> },\n\t\tvalue: unknown,\n\t): unknown {\n\t\tif (arm.guard(value)) return value\n\t\tconst parsed = arm.parse(value)\n\t\treturn parsed !== undefined && arm.guard(parsed) ? parsed : undefined\n\t}\n\n\t// === Schema family\n\n\t#buildSchema(): JSONSchema {\n\t\tconst ready = this.#schema\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#schemas[index] = this.#schemaOf(index)\n\t\t}\n\t\tconst root = this.#schemaAt(this.#node(0))\n\t\tthis.#schema = root\n\t\treturn root\n\t}\n\n\t#schemaAt(shape: ContractShape): JSONSchema {\n\t\tconst emitted = this.#schemas[this.#locate(shape)]\n\t\tif (emitted === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child schema is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn emitted\n\t}\n\n\t#schemaOf(index: number): JSONSchema {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'shape':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\towned.description ??\n\t\t\t\t\t\t'Over-approximates declarations whose JSON projection preserves their own enumerable data; values without that projection are outside this schema. is decides whether the complete shape is valid.',\n\t\t\t\t\tproperties: INTRINSICS.freeze({\n\t\t\t\t\t\tcategory: INTRINSICS.freeze({ enum: INTRINSICS.freeze(INTRINSICS.keys(SHAPE_FIELDS)) }),\n\t\t\t\t\t}),\n\t\t\t\t\trequired: INTRINSICS.freeze(['category']),\n\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t})\n\t\t\tcase 'string': {\n\t\t\t\t// The pattern text is read through the CAPTURED `source` getter. It is an\n\t\t\t\t// accessor on a shared prototype, so a replaced getter chose the\n\t\t\t\t// `pattern` keyword inside a frozen schema this door publishes as exact —\n\t\t\t\t// and a schema that quietly dropped the keyword instead would be the same\n\t\t\t\t// lie with a smaller footprint, so an unreadable source refuses.\n\t\t\t\tconst text = owned.pattern === undefined ? undefined : readPatternSource(owned.pattern)\n\t\t\t\tif (owned.pattern !== undefined && text === undefined) {\n\t\t\t\t\tthrow new ContractError('compileSchema: pattern source could not be read', {\n\t\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\t\tcontext: { shape: 'string' },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\t...(owned.min !== undefined ? { minLength: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maxLength: owned.max } : {}),\n\t\t\t\t\t...(text !== undefined ? { pattern: text } : {}),\n\t\t\t\t\t...(owned.date === true ? { format: 'date' } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'number':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: owned.integer === true ? 'integer' : 'number',\n\t\t\t\t\t...(owned.min !== undefined ? { minimum: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maximum: owned.max } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'boolean':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'null':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'null',\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'json':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'literal': {\n\t\t\t\t// Indexed, not spread: this list is published inside the emitted schema,\n\t\t\t\t// and an array spread retrieves `Array.prototype[Symbol.iterator]` at the\n\t\t\t\t// moment of use, so a caller could add a member to a vocabulary this\n\t\t\t\t// package documents as exactly the shape's own.\n\t\t\t\tconst vocabulary: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(owned.values),\n\t\t\t\t\t[(value: LiteralValue | undefined) => value !== undefined],\n\t\t\t\t)\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\tenum: INTRINSICS.freeze(vocabulary),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'array':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\titems: this.#schemaAt(owned.items),\n\t\t\t\t\t...(owned.min !== undefined ? { minItems: owned.min } : {}),\n\t\t\t\t\t...(owned.max !== undefined ? { maxItems: owned.max } : {}),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\tcase 'object': {\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly schema: JSONSchema\n\t\t\t\t\treadonly required: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(owned.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tschema: this.#schemaAt(child),\n\t\t\t\t\t\t\t\t\trequired: child.category !== 'optional',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t(entry: (typeof entries)[number]) => [entry.key, entry.schema],\n\t\t\t\t])\n\t\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => (entry.required ? [entry.key] : [])],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst additionalProperties: boolean | JSONSchema =\n\t\t\t\t\textra === true\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: extra !== undefined && extra !== false\n\t\t\t\t\t\t\t? this.#schemaAt(extra)\n\t\t\t\t\t\t\t: false\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\t...(INTRINSICS.keys(properties).length > 0\n\t\t\t\t\t\t? { properties: INTRINSICS.freeze(properties) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(required.length > 0 ? { required: INTRINSICS.freeze(required) } : {}),\n\t\t\t\t\tadditionalProperties,\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\t// Indexed, not `map`: this array IS the published schema, and\n\t\t\t\t// `Array.prototype.map = () => ['INJECTED']` made `compileSchema` answer\n\t\t\t\t// `{\"anyOf\":[\"INJECTED\"]}` — a success, with the caller's content inside\n\t\t\t\t// the package's own output.\n\t\t\t\tconst variants: JSONSchema[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#schemaAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\t...(owned.mode === 'oneOf'\n\t\t\t\t\t\t? { oneOf: INTRINSICS.freeze(variants) }\n\t\t\t\t\t\t: { anyOf: INTRINSICS.freeze(variants) }),\n\t\t\t\t\t...(owned.description !== undefined ? { description: owned.description } : {}),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst emitted = this.#schemaAt(owned.inner)\n\t\t\t\tconst value = owned.default\n\t\t\t\treturn value === undefined ? emitted : INTRINSICS.freeze({ ...emitted, default: value })\n\t\t\t}\n\t\t\tcase 'nullable':\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\tanyOf: INTRINSICS.freeze([\n\t\t\t\t\t\tthis.#schemaAt(owned.inner),\n\t\t\t\t\t\tINTRINSICS.freeze({ type: 'null' }),\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\tcase 'raw':\n\t\t\t\treturn cloneSchema(owned.schema)\n\t\t}\n\t}\n\n\t// === Guard family\n\n\t#buildGuard(): Guard<unknown> {\n\t\tconst ready = this.#guard\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#guardOf(index)\n\t\t\tthis.#guards[index] = this.#repeats(index) ? this.#trackGuard(plan) : plan\n\t\t}\n\t\tconst root = this.#guardAt(this.#node(0))\n\t\tif (this.#defaults()) this.#checkDefaults(this.#node(0), [])\n\t\tthis.#guard = root\n\t\treturn root\n\t}\n\n\t#guardAt(shape: ContractShape): Guard<unknown> {\n\t\tconst compiled = this.#guards[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child guard is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t// `stringOf` returns bare `isString` when unrefined, else composes the length-bounds\n\t// + pattern refinement, and a date shape adds the calendar check — the same guard\n\t// the parser re-applies. It reads its options\n\t// through the prototype chain and a family may build after `Object.prototype` gained\n\t// a field these leave out, so they carry no prototype.\n\t#stringGuard(owned: StringShape): Guard<string> {\n\t\tconst guard = stringOf(\n\t\t\tINTRINSICS.rebase(\n\t\t\t\t{\n\t\t\t\t\t...(owned.min === undefined ? {} : { min: owned.min }),\n\t\t\t\t\t...(owned.max === undefined ? {} : { max: owned.max }),\n\t\t\t\t\t...(owned.pattern === undefined ? {} : { pattern: owned.pattern }),\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t),\n\t\t)\n\t\treturn owned.date === true ? whereOf(guard, matchesCalendarDate) : guard\n\t}\n\n\tstatic #acceptShape(value: unknown): boolean {\n\t\treturn isSuccess(\n\t\t\tattempt(() => {\n\t\t\t\tconst validator = new ShapeValidator(value)\n\t\t\t\tvalidator.validate()\n\t\t\t\trefuseExpansion(validator.expansion)\n\t\t\t}),\n\t\t)\n\t}\n\n\t#guardOf(index: number): Guard<unknown> {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string':\n\t\t\t\treturn this.#stringGuard(owned)\n\t\t\tcase 'number': {\n\t\t\t\tconst base = owned.integer === true ? isInteger : isFiniteNumber\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\t// `boundsOf` already refines `isFiniteNumber`; intersect with `isInteger`\n\t\t\t\t// when the leaf is an integer so both the integrality and the bounds hold.\n\t\t\t\treturn owned.integer === true\n\t\t\t\t\t? intersectionOf(isInteger, boundsOf(owned.min, owned.max))\n\t\t\t\t\t: boundsOf(owned.min, owned.max)\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn isBoolean\n\t\t\tcase 'null':\n\t\t\t\treturn isNull\n\t\t\tcase 'json':\n\t\t\t\treturn isJSONValue\n\t\t\tcase 'shape':\n\t\t\t\treturn (value): value is ContractShape => ContractCompiler.#acceptShape(value)\n\t\t\tcase 'literal':\n\t\t\t\t// `literalOf` IS the package's literal match (SameValueZero over an owned\n\t\t\t\t// `Set`); the array form takes a machine-generated vocabulary no spread\n\t\t\t\t// could carry.\n\t\t\t\treturn literalOf(owned.values)\n\t\t\tcase 'array': {\n\t\t\t\tconst base = arrayOf(this.#guardAt(owned.items))\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\tconst withinLength = boundsOf(owned.min, owned.max)\n\t\t\t\treturn whereOf(base, (value) => withinLength(value.length))\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t\t\t// prototype — the same pattern `pickOf` uses (combinators.ts).\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(owned.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\t\treturn [{ key, guard: this.#guardAt(optional ? child.inner : child), optional }]\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t(entry: (typeof entries)[number]) => [entry.key, entry.guard],\n\t\t\t\t])\n\t\t\t\tconst map = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<Guard<unknown>>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst optionalKeys: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => (entry.optional ? [entry.key] : [])],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst closed = extra === undefined || extra === false\n\t\t\t\tconst additional = closed || extra === true ? undefined : this.#guardAt(extra)\n\t\t\t\t// Indexed, not `filter`/`includes`: both are caller-writable members of\n\t\t\t\t// `Array.prototype` reached by name, one line above a boundary whose own\n\t\t\t\t// comment promises this walk never throws.\n\t\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(map)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) =>\n\t\t\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, optionalKeys, [\n\t\t\t\t\t\t\t\t(optional: string) => optional === key,\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\t// The required keys are fixed here, so their presence question is\n\t\t\t\t// answered by one integer rather than by a per-call vocabulary: each\n\t\t\t\t// required key takes a bit position here, and a call ORs one bit per own\n\t\t\t\t// key it recognizes and compares the result against the full mask. The\n\t\t\t\t// record is null-prototype own data so a key literally named\n\t\t\t\t// '__proto__' takes a position like any other. Past the mask's width\n\t\t\t\t// the collected-vocabulary form below still answers.\n\t\t\t\tconst maskable = required.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(maskable ? required : [])\n\t\t\t\tconst full = maskable ? readPresence(required, positions) : 0\n\t\t\t\treturn (value: unknown): value is unknown => {\n\t\t\t\t\tif (!isRecord(value)) return false\n\t\t\t\t\tconst keys = enumerableKeys(value)\n\t\t\t\t\tif (keys === undefined) return false\n\t\t\t\t\t// Contain the whole key-enumeration + value-read walk — a hostile\n\t\t\t\t\t// getter on `value`, or a replaced `globalThis.Set` reached by the\n\t\t\t\t\t// presence view, must yield `false`, never throw, as\n\t\t\t\t\t// `.claude/rules/patterns.md` § Validation and contracts requires.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tif (maskable) {\n\t\t\t\t\t\t\tconst seen = readPresence(keys, positions)\n\t\t\t\t\t\t\tif (seen !== full) return false\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst present = collectMembers(keys)\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => required.length)) {\n\t\t\t\t\t\t\t\tconst key = required[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (!matchesMember(present, key)) return false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tconst guard = INTRINSICS.own(map, key) ? map[key] : undefined\n\t\t\t\t\t\t\tif (guard !== undefined) {\n\t\t\t\t\t\t\t\tif (!guard(value[key])) return false\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (closed) return false\n\t\t\t\t\t\t\t// An open object declares an undeclared key UNCONSTRAINED, not\n\t\t\t\t\t\t\t// UNOBSERVED. The compiled parser copies every one of them into\n\t\t\t\t\t\t\t// its result, so a guard that skipped the read certified a value\n\t\t\t\t\t\t\t// its own parser then refused as unreadable — `is` true, `audit`\n\t\t\t\t\t\t\t// and `explain` empty, `parse` throwing, on one input. The read is\n\t\t\t\t\t\t\t// the advertised read of the open-object domain; its RESULT is\n\t\t\t\t\t\t\t// only tested when a tail shape constrains it.\n\t\t\t\t\t\t\tconst observed: unknown = value[key]\n\t\t\t\t\t\t\tif (additional !== undefined && !additional(observed)) return false\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true\n\t\t\t\t\t})\n\t\t\t\t\treturn isSuccess(outcome) && outcome.value\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst guards: Array<Guard<unknown>> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#guardAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\t// A `oneOf`-mode union matches the emitted JSON Schema `oneOf` keyword —\n\t\t\t\t// EXACTLY one variant must guard-accept the value, not \"at least one\"\n\t\t\t\t// (unionOf's anyOf semantics). A value matching two-or-more variants is\n\t\t\t\t// rejected, since it would violate the compiled schema.\n\t\t\t\tif (owned.mode === 'oneOf') {\n\t\t\t\t\treturn (value: unknown): value is unknown => {\n\t\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, guards, [\n\t\t\t\t\t\t\t(total: number, guard: Guard<unknown>) => total + (guard(value) ? 1 : 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t])\n\t\t\t\t\t\treturn matched === 1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// `Reflect.apply` reads its argument list by index (CreateListFromArrayLike),\n\t\t\t\t// where `unionOf(...guards)` would spread through the array iterator.\n\t\t\t\treturn INTRINSICS.reflect.apply(unionOf, undefined, guards)\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\t\treturn orOf(isUndefined, this.#guardAt(owned.inner))\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableOf(this.#guardAt(owned.inner))\n\t\t\tcase 'raw':\n\t\t\t\treturn (value: unknown): value is unknown => value !== undefined\n\t\t}\n\t}\n\n\t// === Parser family\n\n\t#buildParser(): Parser<unknown> {\n\t\tconst ready = this.#parser\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#parsers[index] = this.#parserOf(index)\n\t\t}\n\t\tconst root = this.#parserAt(this.#node(0))\n\t\tthis.#parser = root\n\t\treturn root\n\t}\n\n\t#parserAt(shape: ContractShape): Parser<unknown> {\n\t\tconst compiled = this.#parsers[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child parser is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#parserOf(index: number): Parser<unknown> {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string': {\n\t\t\t\tif (\n\t\t\t\t\towned.min === undefined &&\n\t\t\t\t\towned.max === undefined &&\n\t\t\t\t\towned.pattern === undefined &&\n\t\t\t\t\towned.date !== true\n\t\t\t\t) {\n\t\t\t\t\treturn parseString\n\t\t\t\t}\n\t\t\t\t// Coerce by type, then re-apply the SAME refinement the guard enforces (the\n\t\t\t\t// identical `stringOf`) — a value that parses but violates a bound or the\n\t\t\t\t// pattern fails the parse (returns `undefined`).\n\t\t\t\tconst guard = this.#stringGuard(owned)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst parsed = parseString(value)\n\t\t\t\t\treturn parsed !== undefined && guard(parsed) ? parsed : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst base = owned.integer === true ? parseInteger : parseNumber\n\t\t\t\tif (owned.min === undefined && owned.max === undefined) return base\n\t\t\t\t// The same bound check the guard applies (integrality is already enforced by\n\t\t\t\t// `parseInteger`, so only the bounds need re-checking after coercion).\n\t\t\t\tconst within = boundsOf(owned.min, owned.max)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst parsed = base(value)\n\t\t\t\t\treturn parsed !== undefined && within(parsed) ? parsed : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn parseBoolean\n\t\t\tcase 'null':\n\t\t\t\treturn (value) => (value === null ? null : undefined)\n\t\t\tcase 'json':\n\t\t\t\treturn parseJSONValue\n\t\t\tcase 'shape':\n\t\t\t\treturn (value) => (ContractCompiler.#acceptShape(value) ? value : undefined)\n\t\t\t// The literal parser trims a matching string but never numeric-coerces —\n\t\t\t// `'42'` never parses to the literal `42`; only an exact (post-trim) match\n\t\t\t// of one of the shape's `values` succeeds. This is an intended leniency,\n\t\t\t// not a soundness gap: a trimmed value is re-checked against `allowed`,\n\t\t\t// the same `literalOf` guard the compiled guard uses.\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tif (allowed(value)) return value\n\t\t\t\t\tif (isString(value)) {\n\t\t\t\t\t\tconst trimmed = value.trim()\n\t\t\t\t\t\tif (allowed(trimmed)) return trimmed\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst item = this.#parserAt(owned.items)\n\t\t\t\tconst unbounded = owned.min === undefined && owned.max === undefined\n\t\t\t\tconst withinLength = boundsOf(owned.min, owned.max)\n\t\t\t\treturn (value) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.array(value), 'compileParser', {\n\t\t\t\t\t\t\tsubject: 'array',\n\t\t\t\t\t\t\tcontext: { shape: 'array' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isArray(value)) return undefined\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow entries.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileParser',\n\t\t\t\t\t\t\t{ subject: 'array', context: { shape: 'array' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!entries.value.dense) return undefined\n\t\t\t\t\tconst result: unknown[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\t// Indexed rather than iterated, and read in place: a hole and a\n\t\t\t\t\t\t// present `undefined` are the same observation to the item parser,\n\t\t\t\t\t\t// so neither is silently dropped from the assembled result.\n\t\t\t\t\t\tconst parsed = item(entries.value.entries[entryIndex])\n\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\tresult[result.length] = parsed\n\t\t\t\t\t}\n\t\t\t\t\t// Enforce the SAME length bounds the guard does (coercion never changes\n\t\t\t\t\t// length, so this is checked once on the assembled result).\n\t\t\t\t\treturn unbounded || withinLength(result.length) ? result : undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\t// A closed object (no `additionalProperties`) silently drops unknown keys\n\t\t\t// present on the input rather than failing the parse — an intended\n\t\t\t// coercion leniency, and an observable one. The compiled guard rejects\n\t\t\t// such an input, so `parse` returning a value never implies `is` accepted\n\t\t\t// what it was handed: `parse({ id: 'a', debug: true })` answers\n\t\t\t// `{ id: 'a' }` for a shape whose `is` says false. The compiled reporter\n\t\t\t// mirrors this parser and reports nothing for a dropped key; the compiled\n\t\t\t// auditor is the artifact that reports it, one `'extra'` fault per\n\t\t\t// undeclared key.\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly fill: JSONValue | undefined\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tparse: this.#parserAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tfill: optional && INTRINSICS.own(child, 'default') ? child.default : undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst known = readValue(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tcollectMembers(\n\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t'compileParser',\n\t\t\t\t\t{\n\t\t\t\t\t\tsubject: 'object',\n\t\t\t\t\t\tcontext: { shape: 'object' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t// One bit position per declared entry, assigned here because the entry\n\t\t\t\t// list is fixed here: a call then reads presence as a bit test instead\n\t\t\t\t// of a membership dispatch per entry. Null-prototype own data, so an\n\t\t\t\t// entry named '__proto__' takes a position like any other. Past the\n\t\t\t\t// mask's width the collected-vocabulary form still answers.\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst additional =\n\t\t\t\t\textra === undefined || extra === false || extra === true\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: this.#parserAt(extra)\n\t\t\t\tconst open = extra === true || additional !== undefined\n\t\t\t\treturn (value) => {\n\t\t\t\t\t// A brand check, not `parseRecord`: that door's eager whole-record\n\t\t\t\t\t// `Object.values` probe reads EVERY own enumerable value, including\n\t\t\t\t\t// undeclared keys this parser is about to DROP. A closed object shape\n\t\t\t\t\t// whose input carried one throwing extra therefore refused as\n\t\t\t\t\t// unreadable while `explain` — which never performs that probe —\n\t\t\t\t\t// published the empty report that means \"parse will succeed\". The\n\t\t\t\t\t// reads this parser genuinely needs are the per-key reads below, and\n\t\t\t\t\t// they are already contained.\n\t\t\t\t\tif (!isRecord(value)) return undefined\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = enumerableKeys(record)\n\t\t\t\t\tif (keys === undefined) return undefined\n\t\t\t\t\t// Contain the whole record walk — a hostile getter on `record`, or a\n\t\t\t\t\t// replaced `globalThis.Set` reached by the presence view, must yield\n\t\t\t\t\t// `undefined`, never throw, as `.claude/rules/patterns.md`\n\t\t\t\t\t// § Validation and contracts requires.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\t// Honest typing: a null-prototype accumulator so an input own key\n\t\t\t\t\t\t// literally named '__proto__' lands as an own data key instead of\n\t\t\t\t\t\t// mutating the prototype (same pattern as `pickOf`).\n\t\t\t\t\t\tconst selected: Array<readonly [string, unknown]> = []\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tconst raw = absent ? undefined : record[entry.key]\n\t\t\t\t\t\t\tif (raw === undefined) {\n\t\t\t\t\t\t\t\tif (!entry.optional) return undefined\n\t\t\t\t\t\t\t\t// A container parses from a fresh copy, so nested defaults apply and no\n\t\t\t\t\t\t\t\t// two results share a tree, whichever parser the inner shape holds.\n\t\t\t\t\t\t\t\tif (entry.fill !== undefined) {\n\t\t\t\t\t\t\t\t\tconst fill = isObject(entry.fill) ? cloneJSONValue(entry.fill) : entry.fill\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [entry.key, entry.parse(fill)]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst parsed = entry.parse(raw)\n\t\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\t\tselected[selected.length] = [entry.key, parsed]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (open) {\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (matchesMember(known, key)) continue\n\t\t\t\t\t\t\t\tif (additional === undefined) {\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [key, record[key]]\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst parsed = additional(record[key])\n\t\t\t\t\t\t\t\t\tif (parsed === undefined) return undefined\n\t\t\t\t\t\t\t\t\tselected[selected.length] = [key, parsed]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn INTRINSICS.rebase(\n\t\t\t\t\t\t\tINTRINSICS.record<unknown>({\n\t\t\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\t\t\tselected,\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t\t\t\tif (isSuccess(outcome)) return outcome.value\n\t\t\t\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'compileParser',\n\t\t\t\t\t\t{ subject: 'object', context: { shape: 'object' } },\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst variants: ReadonlyArray<{\n\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\tvariant === undefined\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tparse: this.#parserAt(variant),\n\t\t\t\t\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\t// `oneOf` exactly-one semantics (documented on `oneOfShape`): judged on\n\t\t\t\t// the RAW input's guard matches only — no coercion fallback. Exactly one\n\t\t\t\t// variant's guard must accept the raw value; preserve that value by\n\t\t\t\t// identity so rebuilding cannot change which variants accept it.\n\t\t\t\t// Zero matches (no variant fits) or two-or-more matches (ambiguous —\n\t\t\t\t// which variant the value belongs to isn't well-defined) both fail the\n\t\t\t\t// parse, deliberately simpler than attempting a coercion-then-recheck\n\t\t\t\t// resolution for ambiguous input.\n\t\t\t\tif (owned.mode === 'oneOf') {\n\t\t\t\t\treturn (value) => {\n\t\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\t\tconst arm = selected === undefined ? undefined : variants[selected]\n\t\t\t\t\t\tif (arm !== undefined) return ContractCompiler.#parseArm(arm, value)\n\t\t\t\t\t\t// Indexed, not `filter`: an array prototype method decides how many\n\t\t\t\t\t\t// variants matched, and a substitute answering a rigged list decides\n\t\t\t\t\t\t// what this parser publishes.\n\t\t\t\t\t\tconst matching: ReadonlyArray<{\n\t\t\t\t\t\t\treadonly parse: Parser<unknown>\n\t\t\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(variants), [\n\t\t\t\t\t\t\t(variant: { readonly guard: Guard<unknown> }) => variant.guard(value),\n\t\t\t\t\t\t])\n\t\t\t\t\t\tconst only = matching[0]\n\t\t\t\t\t\treturn matching.length === 1 && only !== undefined ? value : undefined\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (value) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : variants[selected]\n\t\t\t\t\tif (arm !== undefined) return ContractCompiler.#parseArm(arm, value)\n\t\t\t\t\t// Identity pass first, so guard-valid input is never rejected by its\n\t\t\t\t\t// parser (`.claude/rules/patterns.md` § Validation and contracts): a\n\t\t\t\t\t// value already valid against ANY variant's guard is returned\n\t\t\t\t\t// unchanged, so an earlier variant's coercion never overwrites it.\n\t\t\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\t\t\tconst variant = variants[variantIndex]\n\t\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\t\tif (variant.guard(value)) return value\n\t\t\t\t\t}\n\t\t\t\t\t// Coercion pass: no variant matched as-is, so parse-then-guard,\n\t\t\t\t\t// first variant that both parses and guards wins.\n\t\t\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\t\t\tconst variant = variants[variantIndex]\n\t\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\t\tconst parsed = variant.parse(value)\n\t\t\t\t\t\tif (parsed !== undefined && variant.guard(parsed)) return parsed\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#parserAt(owned.inner)\n\t\t\t\treturn (value) => (value === undefined ? undefined : inner(value))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#parserAt(owned.inner)\n\t\t\t\treturn (value) => (value === null ? null : inner(value))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value) => value\n\t\t}\n\t}\n\n\t// === Auditor family\n\n\t#buildAuditor(): AuditorFunction {\n\t\tconst ready = this.#auditor\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#auditOf(index)\n\t\t\tthis.#audits[index] = this.#repeats(index) ? this.#trackFaults(plan) : plan\n\t\t}\n\t\tconst root = this.#exposeAudit(this.#auditAt(this.#node(0)))\n\t\tthis.#auditor = root\n\t\treturn root\n\t}\n\n\t// The published root supplies the documented default root path and carries the\n\t// door boundary around the whole walk, so a host failure under a hostile value\n\t// publishes this package's error class rather than the caller's raw value.\n\t#exposeAudit(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly AuditFault[],\n\t): AuditorFunction {\n\t\treturn (value: unknown, path: readonly string[] = []): readonly AuditFault[] =>\n\t\t\tcontain(() => plan(value, path), 'compileAuditor')\n\t}\n\n\t#auditAt(\n\t\tshape: ContractShape,\n\t): (value: unknown, path: readonly string[]) => readonly AuditFault[] {\n\t\tconst compiled = this.#audits[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child auditor is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#auditOf(index: number): (value: unknown, path: readonly string[]) => readonly AuditFault[] {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\t// A leaf's refinement fields are fixed when its plan is built, exactly as\n\t\t\t// its `kind` is, so a declaration carrying none has no refinement report\n\t\t\t// to build at all: the only question such a leaf asks is the type test\n\t\t\t// above the gate, and its answer past that test is empty for every\n\t\t\t// accepted value. The helper stays the single source for every REFINED\n\t\t\t// leaf and is entered unchanged there — the gate decides whether the leaf\n\t\t\t// has a refinement question, never how one is answered. Each clean answer\n\t\t\t// is its own array, because a report's identity is the caller's.\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\n\t\t\t\t// The clone's `pattern` is an ACCESSOR that mints a fresh frozen\n\t\t\t\t// `RegExp` per read, so the plan reads it once and carries its\n\t\t\t\t// stateless rebuild into every answer instead of rebuilding one per\n\t\t\t\t// value. The rebuild is safe to share exactly because `readPattern`\n\t\t\t\t// strips `g` and `y`: it holds no `lastIndex` an answer could move.\n\t\t\t\t// `ownPattern` takes that read, and this door publishes only a\n\t\t\t\t// `ContractError`, so an unreadable source or flags refuses with the\n\t\t\t\t// same `pattern` code and `{ shape: 'string' }` context the schema leaf\n\t\t\t\t// publishes.\n\t\t\t\tconst declared = owned.pattern\n\t\t\t\tconst kind: FaultKind = owned.date === true ? 'date' : 'string'\n\t\t\t\tconst refined =\n\t\t\t\t\towned.min !== undefined ||\n\t\t\t\t\towned.max !== undefined ||\n\t\t\t\t\tdeclared !== undefined ||\n\t\t\t\t\towned.date === true\n\t\t\t\tconst pattern = declared === undefined ? undefined : ownPattern(declared, 'compileAuditor')\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isString(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildStringFaults(node, value, path, pattern) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst node: NumberShape = owned\n\t\t\t\tconst kind: FaultKind = owned.integer === true ? 'integer' : 'number'\n\t\t\t\tconst refined = owned.integer === true || owned.min !== undefined || owned.max !== undefined\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isFiniteNumber(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildNumberFaults(node, value, path) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisBoolean(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'boolean', received: preview(value) }]\n\t\t\tcase 'null':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'null', received: preview(value) }]\n\t\t\tcase 'json':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisJSONValue(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\tcase 'shape':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tContractCompiler.#acceptShape(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'shape', received: preview(value) }]\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tallowed(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'literal', received: preview(value) }]\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst node: ArrayShape = owned\n\t\t\t\tconst item = this.#auditAt(owned.items)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.array(value), 'compileAuditor', {\n\t\t\t\t\t\t\tsubject: 'array',\n\t\t\t\t\t\t\tcontext: { path, shape: 'array' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isArray(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow entries.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t\t{ subject: 'array', context: { path, shape: 'array' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: AuditFault[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) break\n\t\t\t\t\t\tappendEntries(\n\t\t\t\t\t\t\tfaults,\n\t\t\t\t\t\t\titem(entries.value.entries[entryIndex], pathOf(path, INTRINSICS.text(entryIndex))),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tappendEntries(faults, buildArrayFaults(node, entries.value.entries.length, path))\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst declaredKeys = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly audit: (value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly kind: FaultKind\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(declaredKeys), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\taudit: this.#auditAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst closed = extra === undefined || extra === false\n\t\t\t\tconst additional = closed || extra === true ? undefined : this.#auditAt(extra)\n\t\t\t\t// The declared vocabulary is a compile-time constant, so it is built\n\t\t\t\t// once here rather than rebuilt on every report. One bit position per\n\t\t\t\t// declared entry answers the per-entry presence question the same way,\n\t\t\t\t// with a bit test in place of a membership dispatch; past the mask's\n\t\t\t\t// width the collected-vocabulary form still answers.\n\t\t\t\t//\n\t\t\t\t// Plan time is not a call, so it has no path to name and no refusal to\n\t\t\t\t// publish: this build is contained by `attempt` and holds `undefined`\n\t\t\t\t// when it fails. A `globalThis.Set` replaced before this module loaded,\n\t\t\t\t// and so captured into `INTRINSICS`, is what makes it fail. The call\n\t\t\t\t// rebuilds it inside the walk's own containment, where that failure\n\t\t\t\t// reaches the coded refusal this door publishes, carrying the path.\n\t\t\t\tconst planned = attempt(() => collectMembers(declaredKeys))\n\t\t\t\tconst declared = isSuccess(planned) ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.reflect.prototype(value), 'compileAuditor', {\n\t\t\t\t\t\t\tsubject: 'object',\n\t\t\t\t\t\t\tcontext: { path, shape: 'object' },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = readValue(\n\t\t\t\t\t\t() => INTRINSICS.freeze(INTRINSICS.keys(record)),\n\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t{ subject: 'object', context: { path, shape: 'object' } },\n\t\t\t\t\t)\n\t\t\t\t\tconst faults: AuditFault[] = []\n\t\t\t\t\t// The value-side presence view is built inside the contained walk, and\n\t\t\t\t\t// the declared vocabulary rebuilt there whenever its plan-time build\n\t\t\t\t\t// failed: a replaced `globalThis.Set` must reach the auditor's own\n\t\t\t\t\t// containment rather than throw the caller's raw value out of a report\n\t\t\t\t\t// this door answers.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst vocabulary = declared ?? collectMembers(declaredKeys)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tif (absent) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tappendEntries(faults, entry.audit(record[entry.key], pathOf(path, entry.key)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\tif (matchesMember(vocabulary, key)) continue\n\t\t\t\t\t\t\tif (closed) {\n\t\t\t\t\t\t\t\tfaults[faults.length] = { reason: 'extra', path: pathOf(path, key) }\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// The same advertised read the compiled guard performs on an open\n\t\t\t\t\t\t\t// object's undeclared key, so this report cannot call a value clean\n\t\t\t\t\t\t\t// that `is` rejects and `parse` refuses as unreadable.\n\t\t\t\t\t\t\tconst observed: unknown = record[key]\n\t\t\t\t\t\t\tif (additional !== undefined) {\n\t\t\t\t\t\t\t\tappendEntries(faults, additional(observed, pathOf(path, key)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(outcome)) {\n\t\t\t\t\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\t\t\t\t\treturn readValue(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'compileAuditor',\n\t\t\t\t\t\t\t{ subject: 'object', context: { path, shape: 'object' } },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst plans: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#auditAt(variant)],\n\t\t\t\t\t])\n\t\t\t\tconst exclusive = owned.mode === 'oneOf'\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : plans[selected]\n\t\t\t\t\tif (arm !== undefined) return arm(value, path)\n\t\t\t\t\tconst perVariant: Array<readonly AuditFault[]> = []\n\t\t\t\t\tfor (const index2 of iterateIndices(() => plans.length)) {\n\t\t\t\t\t\tconst plan = plans[index2]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst variantFaults = plan(value, path)\n\t\t\t\t\t\tif (variantFaults.length === 0) {\n\t\t\t\t\t\t\t// An `anyOf` verdict is settled by the FIRST clean variant in\n\t\t\t\t\t\t\t// declaration order, so no later variant plan runs for a value an\n\t\t\t\t\t\t\t// earlier variant already accepted. That is the stop the compiled\n\t\t\t\t\t\t\t// guard and parser already make, and joining it is what keeps a\n\t\t\t\t\t\t\t// later object variant's prototype probe from publishing a coded\n\t\t\t\t\t\t\t// refusal for a value `is` answers `true` for. A `oneOf` verdict is\n\t\t\t\t\t\t\t// the match count over every variant, so it reads all of them.\n\t\t\t\t\t\t\tif (!exclusive) return []\n\t\t\t\t\t\t}\n\t\t\t\t\t\tperVariant[perVariant.length] = variantFaults\n\t\t\t\t\t}\n\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, perVariant, [\n\t\t\t\t\t\t(total: number, faults: readonly AuditFault[]) => total + (faults.length === 0 ? 1 : 0),\n\t\t\t\t\t\t0,\n\t\t\t\t\t])\n\t\t\t\t\tif (exclusive) {\n\t\t\t\t\t\tif (matched === 1) return []\n\t\t\t\t\t\tif (matched > 1) return [{ reason: 'oneOf', path, matched, ...discriminated?.hint }]\n\t\t\t\t\t}\n\t\t\t\t\tconst closest = selectClosestFaults(perVariant)\n\t\t\t\t\tconst report: AuditFault[] = [\n\t\t\t\t\t\texclusive\n\t\t\t\t\t\t\t? { reason: 'oneOf', path, matched: 0, ...discriminated?.hint }\n\t\t\t\t\t\t\t: { reason: 'variant', path, variants: count, ...discriminated?.hint },\n\t\t\t\t\t]\n\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#auditAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === undefined ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#auditAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === null ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t}\n\t}\n\n\t// === Reporter family\n\n\t#buildReporter(): ReporterFunction {\n\t\tconst ready = this.#reporter\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tconst plan = this.#reportOf(index)\n\t\t\tthis.#reports[index] = this.#repeats(index) ? this.#trackFaults(plan) : plan\n\t\t}\n\t\tconst root = this.#exposeReport(this.#reportAt(this.#node(0)))\n\t\tthis.#reporter = root\n\t\treturn root\n\t}\n\n\t#exposeReport(\n\t\tplan: (value: unknown, path: readonly string[]) => readonly Fault[],\n\t): ReporterFunction {\n\t\treturn (value: unknown, path: readonly string[] = []): readonly Fault[] =>\n\t\t\tcontain(() => plan(value, path), 'compileReporter')\n\t}\n\n\t#reportAt(shape: ContractShape): (value: unknown, path: readonly string[]) => readonly Fault[] {\n\t\tconst compiled = this.#reports[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child reporter is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#reportOf(index: number): (value: unknown, path: readonly string[]) => readonly Fault[] {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\t// The same compile-time gate the auditor's leaves carry, over the COERCED\n\t\t\t// value: the two doors differ in how they obtain the primitive and not in\n\t\t\t// what an unrefined declaration has to say about it.\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\n\t\t\t\t// The same one-time pattern read the auditor's leaf takes, for the same\n\t\t\t\t// accessor and the same reason; see `#auditOf`.\n\t\t\t\tconst declared = owned.pattern\n\t\t\t\tconst kind: FaultKind = owned.date === true ? 'date' : 'string'\n\t\t\t\tconst refined =\n\t\t\t\t\towned.min !== undefined ||\n\t\t\t\t\towned.max !== undefined ||\n\t\t\t\t\tdeclared !== undefined ||\n\t\t\t\t\towned.date === true\n\t\t\t\tconst pattern = declared === undefined ? undefined : ownPattern(declared, 'compileReporter')\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst parsed = parseString(value)\n\t\t\t\t\tif (parsed === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildStringFaults(node, parsed, path, pattern) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst node: NumberShape = owned\n\t\t\t\tconst kind: FaultKind = owned.integer === true ? 'integer' : 'number'\n\t\t\t\tconst refined = owned.integer === true || owned.min !== undefined || owned.max !== undefined\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst parsed = parseNumber(value)\n\t\t\t\t\tif (parsed === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: kind, received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn refined ? buildNumberFaults(node, parsed, path) : []\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tparseBoolean(value) === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'boolean', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t\tcase 'null':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === null\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'null', received: preview(value) }]\n\t\t\tcase 'json':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tisJSONValue(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\tcase 'literal': {\n\t\t\t\tconst allowed = literalOf(owned.values)\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tallowed(value) || (isString(value) && allowed(value.trim()))\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'literal', received: preview(value) }]\n\t\t\t}\n\t\t\tcase 'shape':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tContractCompiler.#acceptShape(value)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [{ reason: 'type', path, expected: 'shape', received: preview(value) }]\n\t\t\tcase 'array': {\n\t\t\t\tconst node: ArrayShape = owned\n\t\t\t\tconst item = this.#reportAt(owned.items)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isArray(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst entries = readArrayEntries(value)\n\t\t\t\t\tif (isFailure(entries)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'array', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: Fault[] = []\n\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.value.entries.length)) {\n\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) break\n\t\t\t\t\t\tappendEntries(\n\t\t\t\t\t\t\tfaults,\n\t\t\t\t\t\t\titem(entries.value.entries[entryIndex], pathOf(path, INTRINSICS.text(entryIndex))),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tappendEntries(faults, buildArrayFaults(node, entries.value.entries.length, path))\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly report: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t\treadonly kind: FaultKind\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\treport: this.#reportAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst names: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(entries),\n\t\t\t\t\t[(entry: (typeof entries)[number]) => entry.key],\n\t\t\t\t)\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst tail =\n\t\t\t\t\textra === undefined || extra === true || extra === false\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: this.#reportAt(extra)\n\t\t\t\tconst open = extra === true || tail !== undefined\n\t\t\t\t// The declared vocabulary is a compile-time constant, so it is built\n\t\t\t\t// once here over the entry key names rather than admitted key by key on\n\t\t\t\t// every report. One bit position per declared entry answers the\n\t\t\t\t// per-entry presence question the same way, with a bit test in place of\n\t\t\t\t// a membership dispatch; past the mask's width the collected-vocabulary\n\t\t\t\t// form still answers.\n\t\t\t\t//\n\t\t\t\t// Plan time is not a call, so it has no value to report on: this build\n\t\t\t\t// is contained by `attempt` and holds `undefined` when it fails. A\n\t\t\t\t// `globalThis.Set` replaced before this module loaded, and so captured\n\t\t\t\t// into `INTRINSICS`, is what makes it fail. The call rebuilds it inside\n\t\t\t\t// the walk's own containment, which keeps this door's answer a fault\n\t\t\t\t// array in exactly the regime its totality promise names.\n\t\t\t\tconst planned = attempt(() => collectMembers(names))\n\t\t\t\tconst known = isSuccess(planned) ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions = buildPositions(\n\t\t\t\t\tmaskable\n\t\t\t\t\t\t? INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(entries), [\n\t\t\t\t\t\t\t\t(entry: { readonly key: string }) => entry.key,\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: [],\n\t\t\t\t)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tif (!isRecord(value)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst record = value\n\t\t\t\t\tconst keys = enumerableKeys(record)\n\t\t\t\t\tif (keys === undefined) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\tconst faults: Fault[] = []\n\t\t\t\t\t// The value-side presence view is built inside the contained walk, and\n\t\t\t\t\t// the declared vocabulary rebuilt there whenever its plan-time build\n\t\t\t\t\t// failed: a replaced `globalThis.Set` must reach the reporter's own\n\t\t\t\t\t// diagnostic containment rather than throw the caller's raw value out\n\t\t\t\t\t// of a total report.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = maskable ? undefined : collectMembers(keys)\n\t\t\t\t\t\tconst vocabulary = known ?? collectMembers(names)\n\t\t\t\t\t\tconst seen = present === undefined ? readPresence(keys, positions) : 0\n\t\t\t\t\t\tfor (const entryIndex of iterateIndices(() => entries.length)) {\n\t\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\t// Mirror the parser's presence gate exactly: only an own\n\t\t\t\t\t\t\t// enumerable string key is present. A present key with an\n\t\t\t\t\t\t\t// explicit `undefined` value is still treated like absence, so\n\t\t\t\t\t\t\t// `explain` never faults where `parse` silently skips it.\n\t\t\t\t\t\t\tconst absent =\n\t\t\t\t\t\t\t\tpresent === undefined\n\t\t\t\t\t\t\t\t\t? (seen & (1 << entryIndex)) === 0\n\t\t\t\t\t\t\t\t\t: !matchesMember(present, entry.key)\n\t\t\t\t\t\t\tif (absent) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst raw = record[entry.key]\n\t\t\t\t\t\t\tif (raw === undefined) {\n\t\t\t\t\t\t\t\tif (!entry.optional) {\n\t\t\t\t\t\t\t\t\tfaults[faults.length] = {\n\t\t\t\t\t\t\t\t\t\treason: 'missing',\n\t\t\t\t\t\t\t\t\t\tpath: pathOf(path, entry.key),\n\t\t\t\t\t\t\t\t\t\texpected: entry.kind,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tappendEntries(faults, entry.report(raw, pathOf(path, entry.key)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A CLOSED object's undeclared key is never read here, because `parse`\n\t\t\t\t\t\t// drops it without reading it either. An OPEN one's is, because `parse`\n\t\t\t\t\t\t// copies it — and a report that skipped that read published the empty\n\t\t\t\t\t\t// report, its documented \"parse will succeed\" signal, for a value\n\t\t\t\t\t\t// `parse` refused as unreadable.\n\t\t\t\t\t\tif (open) {\n\t\t\t\t\t\t\tfor (const keyIndex of iterateIndices(() => keys.length)) {\n\t\t\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\t\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\t\tif (matchesMember(vocabulary, key)) continue\n\t\t\t\t\t\t\t\tconst observed: unknown = record[key]\n\t\t\t\t\t\t\t\tif (tail !== undefined) {\n\t\t\t\t\t\t\t\t\tappendEntries(faults, tail(observed, pathOf(path, key)))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (isFailure(outcome)) {\n\t\t\t\t\t\treturn [{ reason: 'type', path, expected: 'object', received: preview(value) }]\n\t\t\t\t\t}\n\t\t\t\t\treturn limitEntries(faults, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst variants: ReadonlyArray<{\n\t\t\t\t\treadonly report: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\treadonly guard: Guard<unknown>\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(owned.variants), [\n\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\tvariant === undefined\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\treport: this.#reportAt(variant),\n\t\t\t\t\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst plans: ReadonlyArray<(value: unknown, path: readonly string[]) => readonly Fault[]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(variants), [\n\t\t\t\t\t\t(variant: (typeof variants)[number]) => variant.report,\n\t\t\t\t\t])\n\t\t\t\tconst guards: ReadonlyArray<Guard<unknown>> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(variants),\n\t\t\t\t\t[(variant: (typeof variants)[number]) => variant.guard],\n\t\t\t\t)\n\t\t\t\tconst exclusive = owned.mode === 'oneOf'\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst discriminated = this.#discriminate(owned)\n\t\t\t\treturn (value, path) => {\n\t\t\t\t\tconst selected = discriminated?.select(value)\n\t\t\t\t\tconst arm = selected === undefined ? undefined : plans[selected]\n\t\t\t\t\tif (arm !== undefined) return arm(value, path)\n\t\t\t\t\tconst perVariant: Array<readonly Fault[]> = []\n\t\t\t\t\tfor (const index2 of iterateIndices(() => plans.length)) {\n\t\t\t\t\t\tconst plan = plans[index2]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst variantFaults = plan(value, path)\n\t\t\t\t\t\t// The auditor's first-clean-variant stop, mirrored: an `anyOf` report\n\t\t\t\t\t\t// is settled by the FIRST variant that reports nothing, in declaration\n\t\t\t\t\t\t// order, and no later variant plan reads the value after it. A `oneOf`\n\t\t\t\t\t\t// report is the guard-match count over every variant, so it reads all\n\t\t\t\t\t\t// of them.\n\t\t\t\t\t\tif (!exclusive && variantFaults.length === 0) return []\n\t\t\t\t\t\tperVariant[perVariant.length] = variantFaults\n\t\t\t\t\t}\n\t\t\t\t\tconst closest = selectClosestFaults(perVariant)\n\t\t\t\t\tif (exclusive) {\n\t\t\t\t\t\tconst matched: number = INTRINSICS.reflect.apply(INTRINSICS.fold, guards, [\n\t\t\t\t\t\t\t(total: number, guard: Guard<unknown>) => total + (guard(value) ? 1 : 0),\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t])\n\t\t\t\t\t\tif (matched === 1) return []\n\t\t\t\t\t\tif (matched === 0) {\n\t\t\t\t\t\t\tconst report: Fault[] = [\n\t\t\t\t\t\t\t\t{ reason: 'oneOf', path, matched: 0, ...discriminated?.hint },\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [{ reason: 'oneOf', path, matched, ...discriminated?.hint }]\n\t\t\t\t\t}\n\t\t\t\t\tconst report: Fault[] = [\n\t\t\t\t\t\t{ reason: 'variant', path, variants: count, ...discriminated?.hint },\n\t\t\t\t\t]\n\t\t\t\t\tappendEntries(report, closest)\n\t\t\t\t\treturn limitEntries(report, FAULT_LIMIT)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional': {\n\t\t\t\tconst inner = this.#reportAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === undefined ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#reportAt(owned.inner)\n\t\t\t\treturn (value, path) => (value === null ? [] : inner(value, path))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn (value, path) =>\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t\t? [{ reason: 'type', path, expected: 'json', received: preview(value) }]\n\t\t\t\t\t\t: []\n\t\t}\n\t}\n\n\t// === Generator family\n\n\t#buildGenerator(): SeederFunction<unknown> {\n\t\tconst ready = this.#generator\n\t\tif (ready !== undefined) return ready\n\t\tthis.#prepare()\n\t\tif (this.#unions() || this.#defaults()) this.#buildGuard()\n\t\tfor (const step of iterateIndices(() => this.#order.length)) {\n\t\t\tconst index = this.#order[step]\n\t\t\tif (index === undefined) continue\n\t\t\tthis.#seeds[index] = this.#seedOf(index)\n\t\t}\n\t\tconst root = this.#exposeSeed(this.#seedAt(this.#node(0)))\n\t\tthis.#generator = root\n\t\treturn root\n\t}\n\n\t// The default seed is drawn INSIDE the boundary, not in a parameter list. A\n\t// default-parameter initializer is evaluated in the function environment\n\t// before the first statement of the body, so no at-the-door containment could\n\t// ever reach it — `Date.now = () => { throw x }` made this door and\n\t// `contract.generate()` throw the caller's raw object by identity. The read is\n\t// captured too: `INTRINSICS.now` rather than the live global.\n\t#exposeSeed(plan: (random: RandomFunction) => unknown): SeederFunction<unknown> {\n\t\treturn (random?: RandomFunction): unknown =>\n\t\t\tcontain(() => plan(random ?? seededRandom(INTRINSICS.now())), 'compileGenerator', {\n\t\t\t\tcode: 'generate',\n\t\t\t})\n\t}\n\n\t#seedAt(shape: ContractShape): (random: RandomFunction) => unknown {\n\t\tconst compiled = this.#seeds[this.#locate(shape)]\n\t\tif (compiled === undefined) {\n\t\t\tthrow new ContractError('ContractCompiler: a child generator is unavailable', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: [], shape: 'contract' },\n\t\t\t})\n\t\t}\n\t\treturn compiled\n\t}\n\n\t#seedOf(index: number): (random: RandomFunction) => unknown {\n\t\tconst owned = this.#node(index)\n\t\tswitch (owned.category) {\n\t\t\tcase 'string': {\n\t\t\t\t// Every date is 10 characters long, and validation refuses a date shape\n\t\t\t\t// whose bounds exclude that length, so the draw never reads them.\n\t\t\t\tif (owned.date === true) {\n\t\t\t\t\treturn (random) => {\n\t\t\t\t\t\tconst year = 2000 + INTRINSICS.floor(drawRandom(random, 'string') * 100)\n\t\t\t\t\t\tconst month = 1 + INTRINSICS.floor(drawRandom(random, 'string') * 12)\n\t\t\t\t\t\tconst length = computeMonthLength(year, month)\n\t\t\t\t\t\tconst day = 1 + INTRINSICS.floor(drawRandom(random, 'string') * length)\n\t\t\t\t\t\treturn `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst min = owned.min ?? 0\n\t\t\t\tconst max = owned.max ?? INTRINSICS.max(min, 12)\n\t\t\t\tconst length = INTRINSICS.max(min, INTRINSICS.min(max, 8))\n\t\t\t\tconst pattern = owned.pattern\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789'\n\t\t\t\t\tconst characters = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => length),\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tINTRINSICS.text(\n\t\t\t\t\t\t\t\talphabet[INTRINSICS.floor(drawRandom(random, 'string') * alphabet.length)],\n\t\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\tconst value: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\t\t\t\t\tif (pattern !== undefined && !matchOf(pattern)(value)) {\n\t\t\t\t\t\tconst limit = readPatternSource(pattern)\n\t\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t\t'compileGenerator: a pattern-constrained string shape cannot be auto-generated — supply or verify values another way',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\t\tcontext: { shape: 'string', ...(limit === undefined ? {} : { limit }) },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'number': {\n\t\t\t\tconst whole = owned.integer === true\n\t\t\t\tconst minimum = owned.min\n\t\t\t\tconst maximum = owned.max\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst sample = drawRandom(random, whole ? 'integer' : 'number')\n\t\t\t\t\tif (whole) {\n\t\t\t\t\t\tconst lo = INTRINSICS.ceil(minimum ?? (maximum === undefined ? -100 : maximum - 100))\n\t\t\t\t\t\tconst hi = INTRINSICS.floor(maximum ?? (minimum === undefined ? 100 : minimum + 100))\n\t\t\t\t\t\treturn lo === hi ? lo : INTRINSICS.floor(lo * (1 - sample) + hi * sample)\n\t\t\t\t\t}\n\t\t\t\t\tconst lo = minimum ?? (maximum === undefined ? -100 : maximum - 100)\n\t\t\t\t\tconst hi = maximum ?? (minimum === undefined ? 100 : minimum + 100)\n\t\t\t\t\treturn lo === hi ? lo : lo * (1 - sample) + hi * sample\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'boolean':\n\t\t\t\treturn (random) => drawRandom(random, 'boolean') >= 0.5\n\t\t\tcase 'null':\n\t\t\t\treturn () => null\n\t\t\tcase 'shape':\n\t\t\t\treturn () => ({ category: 'object', properties: {}, additionalProperties: false })\n\t\t\tcase 'json':\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst pick = INTRINSICS.floor(drawRandom(random, 'json') * 5)\n\t\t\t\t\tif (pick === 0) return null\n\t\t\t\t\tif (pick === 1) return drawRandom(random, 'json') >= 0.5\n\t\t\t\t\tif (pick === 2) return INTRINSICS.floor(drawRandom(random, 'json') * 1000)\n\t\t\t\t\tif (pick === 3) {\n\t\t\t\t\t\tconst alphabet = 'abcdefghijklmnopqrstuvwxyz'\n\t\t\t\t\t\tconst characters = INTRINSICS.from(\n\t\t\t\t\t\t\titerateIndices(() => 6),\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tINTRINSICS.text(\n\t\t\t\t\t\t\t\t\talphabet[INTRINSICS.floor(drawRandom(random, 'json') * alphabet.length)],\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst value: string = INTRINSICS.reflect.apply(INTRINSICS.join, characters, [''])\n\t\t\t\t\t\treturn value\n\t\t\t\t\t}\n\t\t\t\t\treturn { value: INTRINSICS.floor(drawRandom(random, 'json') * 1000) }\n\t\t\t\t}\n\t\t\tcase 'literal': {\n\t\t\t\tconst values = owned.values\n\t\t\t\treturn (random) => {\n\t\t\t\t\tif (values.length === 0) {\n\t\t\t\t\t\tthrow new ContractError('compileGenerator: a literal shape needs at least one value', {\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'literal', limit: 1 },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn values[INTRINSICS.floor(drawRandom(random, 'literal') * values.length)]\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst item = this.#seedAt(owned.items)\n\t\t\t\tconst lo = owned.min ?? INTRINSICS.min(1, owned.max ?? 1)\n\t\t\t\tconst hi = owned.max ?? INTRINSICS.max(lo, 3)\n\t\t\t\treturn (random) => {\n\t\t\t\t\tconst length = INTRINSICS.floor(drawRandom(random, 'array') * (hi - lo + 1)) + lo\n\t\t\t\t\treturn INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => length),\n\t\t\t\t\t\t() => item(random),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tconst entries: ReadonlyArray<{\n\t\t\t\t\treadonly key: string\n\t\t\t\t\treadonly seed: (random: RandomFunction) => unknown\n\t\t\t\t\treadonly optional: boolean\n\t\t\t\t}> = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(keyList), [\n\t\t\t\t\t(key: string) => {\n\t\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\t\tif (child === undefined) return []\n\t\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tseed: this.#seedAt(inner),\n\t\t\t\t\t\t\t\toptional,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\tconst extra = owned.additionalProperties\n\t\t\t\tconst tail =\n\t\t\t\t\textra === undefined || extra === true || extra === false ? undefined : this.#seedAt(extra)\n\t\t\t\treturn (random) => {\n\t\t\t\t\t// Honest typing: generated data is a value the caller keeps, so unlike the\n\t\t\t\t\t// guard's and parser's null-prototype property views it carries the normal\n\t\t\t\t\t// object prototype — `defineProperty` (never assignment) still lands a\n\t\t\t\t\t// '__proto__' key as an own data key rather than mutating that prototype.\n\t\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(entries), [\n\t\t\t\t\t\t(entry: (typeof entries)[number]) =>\n\t\t\t\t\t\t\tentry.optional && drawRandom(random, 'object') < 0.3\n\t\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t\t: [[entry.key, entry.seed(random)]],\n\t\t\t\t\t])\n\t\t\t\t\tconst declared = INTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t})\n\t\t\t\t\tconst count =\n\t\t\t\t\t\ttail === undefined ? 0 : 1 + INTRINSICS.floor(drawRandom(random, 'object') * 2)\n\t\t\t\t\tconst extras = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => count),\n\t\t\t\t\t\t(step) => {\n\t\t\t\t\t\t\tconst key = `key${step}`\n\t\t\t\t\t\t\treturn INTRINSICS.own(declared, key) || tail === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: [key, tail(random)]\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tconst selected = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(extras), [\n\t\t\t\t\t\t(entry: unknown) => entry !== undefined,\n\t\t\t\t\t])\n\t\t\t\t\tconst additional = INTRINSICS.record<unknown>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tselected,\n\t\t\t\t\t\t]),\n\t\t\t\t\t})\n\t\t\t\t\tconst result = { ...declared, ...additional }\n\t\t\t\t\treturn result\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'union': {\n\t\t\t\tconst plans: Array<(random: RandomFunction) => unknown> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.expand,\n\t\t\t\t\treadIndexView(owned.variants),\n\t\t\t\t\t[\n\t\t\t\t\t\t(variant: ContractShape | undefined) =>\n\t\t\t\t\t\t\tvariant === undefined ? [] : [this.#seedAt(variant)],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst count = owned.variants.length\n\t\t\t\tconst guard = count === 0 ? undefined : this.#guardAt(owned)\n\t\t\t\tconst attempts = INTRINSICS.max(GENERATION_ATTEMPT_LIMIT, count)\n\t\t\t\treturn (random) => {\n\t\t\t\t\tif (count === 0 || guard === undefined) {\n\t\t\t\t\t\tthrow new ContractError('compileGenerator: a union shape needs at least one variant', {\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'union', limit: 1 },\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst start = INTRINSICS.floor(drawRandom(random, 'union') * count)\n\t\t\t\t\tfor (const attemptIndex of iterateIndices(() => attempts)) {\n\t\t\t\t\t\tconst plan = plans[(start + attemptIndex) % count]\n\t\t\t\t\t\tif (plan === undefined) continue\n\t\t\t\t\t\tconst outcome = attempt(() => plan(random))\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisFailure(outcome) &&\n\t\t\t\t\t\t\tisContractError(outcome.error) &&\n\t\t\t\t\t\t\toutcome.error.code === 'random'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow outcome.error\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isSuccess(outcome) && guard(outcome.value)) return outcome.value\n\t\t\t\t\t}\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'compileGenerator: no union candidate satisfied the compiled guard',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'union', limit: attempts },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#seedAt(owned.inner)\n\t\t\tcase 'nullable': {\n\t\t\t\tconst inner = this.#seedAt(owned.inner)\n\t\t\t\treturn (random) => (drawRandom(random, 'nullable') < 0.2 ? null : inner(random))\n\t\t\t}\n\t\t\tcase 'raw':\n\t\t\t\treturn () => {\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'compileGenerator: a raw shape embeds an arbitrary JSON Schema and cannot be auto-generated — supply values another way',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'generate',\n\t\t\t\t\t\t\tcontext: { shape: 'raw', limit: 'explicit value source' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t}\n\t}\n\n\t// === Bundle\n\n\t#buildContract(): ContractInterface<unknown> {\n\t\tconst ready = this.#bundle\n\t\tif (ready !== undefined) return ready\n\t\t// Getter order, so a declaration that refuses refuses at the same artifact\n\t\t// whether the caller reads the roots one at a time or asks for the bundle.\n\t\tconst schema = this.#buildSchema()\n\t\tconst guard = this.#buildGuard()\n\t\tconst parser = this.#buildParser()\n\t\tconst auditor = this.#buildAuditor()\n\t\tconst reporter = this.#buildReporter()\n\t\tconst generator = this.#buildGenerator()\n\t\tconst bundle = INTRINSICS.freeze({\n\t\t\tschema,\n\t\t\tis: guard,\n\t\t\tparse: parser,\n\t\t\taudit: auditor,\n\t\t\texplain: reporter,\n\t\t\tgenerate: generator,\n\t\t})\n\t\tthis.#bundle = bundle\n\t\treturn bundle\n\t}\n\n\tstatic {\n\t\t// Pinned while this class is DEFINED. Every standalone compiler and\n\t\t// `createContract` reaches these getters, so one assignment on this\n\t\t// prototype would decide what the public doors publish while none of them\n\t\t// was touched.\n\t\tpinMembers(ContractCompiler.prototype, 'ContractCompiler')\n\t}\n}\n","import type {\n\tAuditFault,\n\tContractShape,\n\tFault,\n\tGuard,\n\tInfer,\n\tJSONSchema,\n\tParser,\n\tRandomFunction,\n} from './types.js'\nimport { contain, refuseExpansion } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapeValidator } from './ShapeValidator.js'\n\n// The public function boundaries over the engines. `ShapeValidator` owns the\n// stateful declaration walk; `ContractCompiler` owns ownership, preparation and\n// every artifact family. Each function below is a real typed door — its own\n// overloads, its own containment, its own diagnostics — that requests exactly\n// the root it is named for and nothing else, so asking for a guard never\n// compiles a generator. Recursion lives in the compiler, not here: a module that\n// re-entered its own public functions per node would re-own and re-validate the\n// subgraph at every level.\n\n// === Validation\n\n/**\n * Gates recursive compiler work on shape structure, depth, and cycles.\n *\n * @remarks\n * Constructs a fresh {@link ShapeValidator} and eagerly validates the graph.\n * The validator walks iteratively with explicit stack space and observes each\n * unique node exactly ONCE per call, so a shared-child DAG costs its AUTHORED\n * nodes and edges rather than its paths. Every incoming edge is still inspected:\n * where an `optional` node is legal depends on the slot it arrived through, and\n * depth is measured over the captured graph afterwards rather than by walking\n * each path.\n *\n * This is also where the compilers' expansion bound lives. Every compiled\n * artifact is a tree, so a DAG's cost is the size of the tree it expands into —\n * `objectShape({ left: node, right: node })` nested thirty times is thirty-one\n * authored nodes and more than a billion emitted ones. The validator counts\n * that expansion and {@link refuseExpansion} refuses past\n * {@link COMPILE_NODE_LIMIT} with an `expansion`-coded {@link ContractError}, so\n * every standalone compiler and {@link createContract} answer a shared-child\n * declaration in bounded time instead of not answering. {@link cloneShape} /\n * {@link ownShape} are deliberately NOT bounded by it: they preserve\n * shared-child identity, so ownership of the same declaration stays\n * proportional to its authored nodes.\n * Every structural child slot must contain a shape node before it can enter the\n * walk; every scalar field must hold its declared runtime domain before a\n * compiler can use it; and a missing child, corrupt container, inherited\n * discriminant, or unrecognized node reports `structure`. This is the SOLE\n * eager well-formedness pass — there is no second prepass and no alias for it:\n * it enforces every bound domain and range used by the artifacts, including\n * non-empty literal/union vocabularies, finite literal numbers, integer-range\n * satisfiability, unflagged string patterns, optional-shape and default\n * placement, and the recursively supported raw-schema vocabulary where every\n * present property or dense union member is a record. It judges a default's\n * structure only; each compiler refuses a default its inner guard refuses.\n * Active ancestors are tracked so shared children remain legal. Every\n * standalone compiler reaches this same validation once, over its owned\n * snapshot, through {@link ContractCompiler} preparation.\n * Cyclic graphs refuse before depth measurement, with structure before cycle.\n * Acyclic graphs report depth before structure, then field and vocabulary policy.\n *\n * @param shape - The shape graph to gate\n * @returns Nothing; successful return means recursive compilation is structurally safe, depth-safe, and bounded in emitted nodes\n * @throws {ContractError} When a node or structural slot is corrupt, a bound or vocabulary is outside its declared domain, the graph is cyclic, it exceeds the compilation depth limit, or it expands past the compilation node limit\n *\n * @example\n * ```ts\n * validateShape(stringShape({ min: 1 })) // returns; the declaration is compilable\n * ```\n */\nexport function validateShape(shape: unknown): void {\n\treturn contain(() => {\n\t\tconst validator = new ShapeValidator(shape)\n\t\tvalidator.validate()\n\t\trefuseExpansion(validator.expansion)\n\t}, 'validateShape')\n}\n\n// === Schema\n\n/**\n * Compiles a {@link ContractShape} into a JSON Schema document.\n *\n * @remarks\n * Object shapes emit `additionalProperties: false` (unless opened) and list only\n * required keys in `required`; nullable shapes emit an `anyOf` with `{ type:\n * 'null' }`. The result is an owned deeply frozen graph; raw schemas are cloned\n * rather than retained by reference. Emission only — it never inspects a\n * runtime value. It requests exactly the `schema` root of a fresh\n * {@link ContractCompiler}, so the declaration is owned once and validated once\n * and no other artifact family is built. Shared declaration identity survives\n * into the emitted document: two slots holding one authored node hold one\n * emitted subschema, while structurally equal distinct nodes stay distinct.\n *\n * @param shape - The shape to compile\n * @returns The emitted JSON Schema\n *\n * @example\n * ```ts\n * compileSchema(stringShape({ min: 1 })) // { type: 'string', minLength: 1 }\n * ```\n */\nexport function compileSchema(shape: ContractShape): JSONSchema {\n\treturn contain(() => new ContractCompiler(shape).schema, 'compileSchema')\n}\n\n// === Guard\n\n/**\n * Compiles a {@link ContractShape} into a runtime type guard.\n *\n * @remarks\n * Reuses the combinators for structural and refined shapes, including\n * {@link literalOf} for SameValueZero literal matching. Compiled object shapes\n * observe own enumerable string keys through {@link enumerableKeys}, the same\n * key view their parser, reporter, auditor, and inference use for both open and\n * closed objects — the view is shared, the verdict on an undeclared key is not\n * (this guard rejects the object; the parser drops the key).\n * Like every guard it is total — it never throws, as `.claude/rules/patterns.md`\n * § Validation and contracts requires. It requests\n * exactly the `guard` root of a fresh {@link ContractCompiler}, which owns the\n * declaration once through {@link ownShape} and validates that snapshot once,\n * unless the builders already did, so an unfrozen caller-owned graph compiles\n * from a snapshot and excessive\n * nesting, cycles, and excessive expansion are rejected before any guard is\n * built.\n *\n * @param shape - The shape to compile\n * @returns A guard narrowing to the shape's inferred type\n *\n * @example\n * ```ts\n * const isUser = compileGuard(objectShape({ name: stringShape() }))\n * isUser({ name: 'Ada' }) // true\n * ```\n */\nexport function compileGuard<S extends ContractShape>(shape: S): Guard<Infer<S>>\nexport function compileGuard(shape: ContractShape): Guard<unknown>\nexport function compileGuard(shape: ContractShape): Guard<unknown> {\n\treturn contain(() => new ContractCompiler(shape).guard, 'compileGuard')\n}\n\n// === Parser\n\n/**\n * Compiles a {@link ContractShape} into an input parser.\n *\n * @remarks\n * Reuses the leaf parsers (`parseString` / `parseInteger` / `parseNumber` /\n * `parseBoolean`) and coerces structurally. An object fails as a\n * whole on any required-field failure; a union returns a guard-valid value\n * unchanged, otherwise the first variant that both parses and guards wins.\n *\n * After coercing a leaf, it re-applies that leaf's REFINEMENTS through the same\n * combinators {@link compileGuard} uses — `stringOf` for a string's\n * length/pattern, `boundsOf` for a number's value and an array's length, and\n * {@link literalOf} for literal membership — so a value that coerces but\n * violates a bound parses to `undefined`. The result is full parse↔guard\n * soundness, which `.claude/rules/patterns.md` § Validation and contracts\n * mandates: a\n * non-`undefined` parse always satisfies the contract's `is`, refinements\n * included — a statement about the OUTPUT, never about the input, which may be\n * a value `is` rejects. Object presence and extra-key processing read the same\n * own-enumerable-string key view as the guard, reporter, auditor, and inference\n * — one key set, deliberately different verdicts: this parser drops an\n * undeclared key that {@link compileGuard} rejects and {@link compileAuditor}\n * faults. It requests exactly the `parser` root of a fresh\n * {@link ContractCompiler}, which owns and validates the declaration once; a\n * union's variant selection is a guard question, so a declaration containing one\n * also builds the compiler's guard plan.\n *\n * @param shape - The shape to compile\n * @returns A parser yielding the shape's inferred type or `undefined`\n *\n * @example\n * ```ts\n * const parseUser = compileParser(objectShape({ name: stringShape() }))\n * parseUser({ name: 'Ada' }) // { name: 'Ada' }\n * ```\n */\nexport function compileParser<S extends ContractShape>(shape: S): Parser<Infer<S>>\nexport function compileParser(shape: ContractShape): Parser<unknown>\nexport function compileParser(shape: ContractShape): Parser<unknown> {\n\treturn contain(() => new ContractCompiler(shape).parser, 'compileParser')\n}\n\n// === Generator\n\n/**\n * Compiles a {@link ContractShape} into a deterministic seed value.\n *\n * @remarks\n * The same shape and the same `random` source always produce the same value, so\n * seed data is reproducible. Defaults to a {@link seededRandom} source seeded\n * from the wall clock when none is supplied. Shape-generation failures throw a\n * {@link ContractError} with code `'generate'`; {@link drawRandom} failures use\n * code `'random'` and retain the consuming shape category in context.\n * Failures include a pattern-constrained `stringShape` whose generated sample\n * cannot satisfy the pattern, an invalid random sample, and a `rawShape` whose\n * arbitrary embedded schema cannot be auto-generated. Degenerate empty\n * literal/union vocabularies fail earlier with the shared gate's `empty` code.\n * It requests exactly the `generator` root of a fresh\n * {@link ContractCompiler} and invokes it once, so the declaration is owned and\n * validated once before any draw. Union candidates are bounded by\n * {@link GENERATION_ATTEMPT_LIMIT} and accepted only when they satisfy the\n * union's compiled guard, which is why a declaration containing a union also\n * builds the compiler's guard plan.\n *\n * @param shape - The shape to generate from\n * @param random - A seeded random source (defaults to a wall-clock seed drawn inside the door's boundary)\n * @returns A value matching the shape\n * @throws {ContractError} When the shape or random source cannot produce a valid value\n *\n * @example\n * ```ts\n * compileGenerator(stringShape({ min: 1, max: 4 })) // a random string of 1-4 characters (seed a RandomFunction for determinism)\n * ```\n */\nexport function compileGenerator<S extends ContractShape>(\n\tshape: S,\n\trandom?: RandomFunction,\n): Infer<S>\nexport function compileGenerator(shape: ContractShape, random?: RandomFunction): unknown\nexport function compileGenerator(shape: ContractShape, random?: RandomFunction): unknown {\n\treturn contain(() => new ContractCompiler(shape).generator(random), 'compileGenerator', {\n\t\tcode: 'generate',\n\t})\n}\n\n// === Reporter\n\n/**\n * Compiles a {@link ContractShape} into a structured fault report for a value —\n * the diagnostic counterpart of {@link compileGuard} / {@link compileParser}.\n *\n * @remarks\n * MIRROR-PARSE semantics: reuses the exact leaf parsers/guards\n * {@link compileParser} uses (`parseString` / `parseNumber` / `parseBoolean` /\n * `isJSONValue` / …), so the soundness invariant\n * `compileReporter(shape, v).length === 0 ⟺ compileParser(shape)(v) !== undefined`\n * holds structurally — `explain` mirrors `parse`, not the stricter `is` (a\n * coercible value like `'42'` against a `numberShape` reports no fault, the\n * same leniency `parse` grants, even though the strict guard would reject it).\n * The invariant relates two separate calls, so it holds for a value whose reads\n * are stable across calls; see the read-stability precondition on\n * {@link ContractInterface}. {@link compileAuditor} is the counterpart report\n * for the strict domain, mirroring {@link compileGuard} the way this one\n * mirrors {@link compileParser}.\n *\n * Faults are collected in stable pre-order (declared key/index order); every\n * call — object, array, and union alike, including a union's `oneOf` \"no\n * match\" / \"no consensus\" summary fault prepended to its closest variant's\n * faults — slices its return to at most {@link FAULT_LIMIT} entries, so the\n * bound holds at every level of nesting rather than at the outermost container alone, on\n * adversarial input (a huge array, a wide record, a wide union of wide\n * records). A closed object's extra keys never\n * fault — `parse` silently drops them, so `explain` mirrors that leniency, and\n * {@link compileAuditor} is where they do fault; an open object with a\n * constraining `additionalProperties` shape recurses extras against it instead.\n * A hostile getter or throwing `Proxy` trap is contained through {@link attempt}\n * and surfaces as a single top-level type fault, never a throw, as\n * `.claude/rules/patterns.md` § Validation and contracts requires.\n * It requests exactly the `reporter` root of a fresh {@link ContractCompiler}\n * and applies it once, so one call owns and validates the declaration once\n * rather than re-gating every node it descends into. Reuse the compiler (or a\n * contract's `explain`) when many values are reported against one shape.\n *\n * @param shape - The shape to report against\n * @param value - The value to check\n * @param path - The path prefix for faults produced at this call (defaults to the root)\n * @returns The faults found, empty when the value parses successfully\n *\n * @example\n * ```ts\n * const user = objectShape({ name: stringShape({ min: 1 }) })\n * compileReporter(user, { name: '' })\n * // [{ reason: 'constraint', path: ['name'], expected: 'string', constraint: 'min', limit: 1, received: '\"\"' }]\n * compileReporter(user, { name: 'Ada' }) // []\n * ```\n */\nexport function compileReporter(\n\tshape: ContractShape,\n\tvalue: unknown,\n\tpath: readonly string[] = [],\n): readonly Fault[] {\n\treturn contain(() => new ContractCompiler(shape).reporter(value, path), 'compileReporter')\n}\n\n/**\n * Audits a value against the strict acceptance domain of a {@link ContractShape}.\n *\n * @remarks\n * The diagnostic for the domain {@link compileGuard} and {@link compileSchema}\n * describe, where {@link compileReporter} diagnoses the wider preimage\n * {@link compileParser} maps into it. This walk therefore mirrors the guard:\n * leaf coercions are faults, closed-object extras are faults, and union\n * acceptance is decided from each variant's strict audit emptiness, so the\n * soundness invariant\n * `compileAuditor(shape, v).length === 0 ⟺ compileGuard(shape)(v)` holds\n * structurally. The shared declaration gate rejects structural and bound-domain\n * malformations before either artifact is built, so the invariant is only\n * evaluated for a valid declaration. The invariant relates two\n * separate calls, so it holds for a value whose reads are stable across calls;\n * see the read-stability precondition on {@link ContractInterface}. Every\n * recursive call returns at most {@link FAULT_LIMIT} entries. Hostile property\n * access raises the shared coded read refusal with the current container path\n * and shape, so unreadability never masquerades as a type mismatch.\n * It requests exactly the `auditor` root of a fresh {@link ContractCompiler}\n * and applies it once; reuse the compiler (or a contract's `audit`) when many\n * values are audited against one shape.\n *\n * @param shape - The shape to audit against\n * @param value - The value to check\n * @param path - The path prefix for faults produced at this call\n * @returns The strict faults found, empty exactly when the compiled guard accepts a stably-read value\n *\n * @example\n * ```ts\n * const user = objectShape({ name: stringShape() })\n * compileAuditor(user, { name: 'Ada', extra: true })\n * // [{ reason: 'extra', path: ['extra'] }]\n * ```\n */\nexport function compileAuditor(\n\tshape: ContractShape,\n\tvalue: unknown,\n\tpath: readonly string[] = [],\n): readonly AuditFault[] {\n\treturn contain(() => new ContractCompiler(shape).auditor(value, path), 'compileAuditor')\n}\n","import type {\n\tAuditorFunction,\n\tContractInterface,\n\tContractShape,\n\tGuard,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tSeederFunction,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { attempt, contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapePass } from './ShapePass.js'\n\n/**\n * Owns a contract whose function members compile together on the first call to any.\n *\n * @remarks\n * For a declaration made entirely by builders, where preparation and the schema have\n * already asked everything that can refuse. A module that declares its contracts as\n * data then pays for a contract only when something uses it, and each member is a\n * plain function with one identity, so destructuring and spreading compile nothing.\n *\n * A compile can still fail for the host's reasons: a first call near the stack limit,\n * or a host whose members were replaced after this contract was created, which it\n * refuses to compile on since the result would outlive the replacement. Neither says\n * anything about a later call, which compiles afresh. Until then a guard answers\n * `false` and a parser `undefined`, and the diagnostic and seed members publish the\n * failure as their doors do.\n */\nexport class LazyContract {\n\treadonly #shape: ContractShape\n\t#pending: ContractCompiler | undefined\n\t#settled: ContractCompiler | undefined\n\t#bundle: ContractInterface<unknown> | undefined\n\n\t/**\n\t * Retains a declaration and the compiler already prepared from it.\n\t *\n\t * @param shape - The sealed declaration\n\t * @param compiler - The compiler that owns its prepared index\n\t */\n\tconstructor(shape: ContractShape, compiler: ContractCompiler) {\n\t\tthis.#shape = shape\n\t\tthis.#pending = compiler\n\t}\n\n\t/**\n\t * Compiles the schema, which refuses a bad declaration, and publishes the bundle.\n\t *\n\t * @param schema - The schema the prepared compiler emitted\n\t * @returns The frozen bundle, in the key order the compiler's own bundle uses\n\t */\n\tpublish(schema: ContractInterface<unknown>['schema']): ContractInterface<unknown> {\n\t\treturn INTRINSICS.freeze({\n\t\t\tschema,\n\t\t\tis: this.#is(),\n\t\t\tparse: this.#parse(),\n\t\t\taudit: this.#audit(),\n\t\t\texplain: this.#explain(),\n\t\t\tgenerate: this.#generate(),\n\t\t})\n\t}\n\n\t#is(): Guard<unknown> {\n\t\treturn (value: unknown): value is unknown => {\n\t\t\tconst bundle = this.#bundle ?? this.#attempt()\n\t\t\treturn bundle !== undefined && bundle.is(value)\n\t\t}\n\t}\n\n\t#parse(): Parser<unknown> {\n\t\treturn (value: unknown): unknown => {\n\t\t\tconst bundle = this.#bundle ?? this.#attempt()\n\t\t\treturn bundle === undefined ? undefined : bundle.parse(value)\n\t\t}\n\t}\n\n\t#audit(): AuditorFunction {\n\t\treturn (value: unknown, path: readonly string[] = []) =>\n\t\t\t(this.#settled ?? this.#settle('compileAuditor')).auditor(value, path)\n\t}\n\n\t#explain(): ReporterFunction {\n\t\treturn (value: unknown, path: readonly string[] = []) =>\n\t\t\t(this.#settled ?? this.#settle('compileReporter')).reporter(value, path)\n\t}\n\n\t#generate(): SeederFunction<unknown> {\n\t\treturn (random?: RandomFunction): unknown =>\n\t\t\t(this.#settled ?? this.#settle('compileGenerator')).generator(random)\n\t}\n\n\t#attempt(): ContractInterface<unknown> | undefined {\n\t\tattempt(() => this.#settle('createContract'))\n\t\treturn this.#bundle\n\t}\n\n\t// The pending compiler is dropped before it compiles, because a failure settles a\n\t// compiler for good, and this one must not answer a later call.\n\t#settle(door: string): ContractCompiler {\n\t\treturn contain(() => {\n\t\t\tif (ShapePass.tampered()) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t`${door}: a host member this contract compiles on was replaced after it was created`,\n\t\t\t\t\t{ code: 'structure', context: { path: [], shape: 'contract' } },\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst compiler = this.#pending ?? new ContractCompiler(this.#shape)\n\t\t\tthis.#pending = undefined\n\t\t\tthis.#bundle = compiler.contract\n\t\t\tthis.#settled = compiler\n\t\t\treturn compiler\n\t\t}, door)\n\t}\n}\n","import type { ContractInterface, ContractShape, Infer } from './types.js'\nimport { contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { LazyContract } from './LazyContract.js'\nimport { ShapePass } from './ShapePass.js'\n\n// The entity door over the compiler engine. Every other door in `compilers.ts`\n// requests one artifact root and returns that artifact; this one returns the\n// live `ContractInterface` bundle, which is an entity rather than a compiled\n// projection, so it sits in the factory kind file its `create*` form names.\n\n/**\n * Compiles a {@link ContractShape} into a {@link ContractInterface} — the\n * lockstep outputs from one declaration, lockstep meaning derived from one\n * owned snapshot rather than accepting the same values.\n *\n * @remarks\n * Creates ONE {@link ContractCompiler} and returns that compiler's exact\n * `contract` bundle. One ownership population governs the whole contract: the\n * declaration is owned once through {@link ownShape}, that owned graph is\n * validated once, and every artifact is compiled from it. There is no\n * discarded pre-ownership pass over the caller's declaration and no second\n * snapshot — ownership already refuses a malformed structural slot, scalar\n * field, or bound rather than normalizing it, so a second walk of the caller's\n * live source only added a population that could disagree with the one the\n * artifacts actually use. A declaration made entirely by this package's builders\n * is frozen and validated all the way down already, so it is that owned graph.\n * Every artifact compiles once, so `audit`, `explain` and `generate` re-walk and\n * re-gate nothing on a later call; `contract.audit` and `compileAuditor` run the\n * same compiled plan reached by different names.\n * A declaration made entirely by builders compiles its schema at this call and\n * its function members together on the first call to any of them, so a module\n * can declare contracts as data and pay only for the ones it uses. Any other\n * declaration, and a bare leaf, compiles every member at this call. Either way\n * the members are plain data properties, so `const { is, parse } =\n * createContract(shape)` destructures those exact values, a spread of the result\n * copies them, and neither compiles anything. A malformed declaration refuses at\n * this call rather than at the first read of whichever member a caller happens\n * to touch, so the failure arrives at the call the caller made — carrying the\n * authoring door's own diagnosis, which this door adopts rather than rewraps.\n * Every compiled member is self-contained, and the compiler this call builds\n * releases its working set once every member has compiled. The contract keeps\n * part of the declaration even so: the auditor and reporter plans close over the\n * leaf and array nodes they read their bounds from, and a contract with deferred\n * members retains its declaration. Nothing the caller keeps reaches back into the\n * compiler. A deferred member compiled on a host whose members were replaced after\n * this call would outlive the replacement, so it refuses to compile until they are\n * restored: until then its guard answers `false`, its parser `undefined`, and its\n * diagnostics and generator refuse.\n *\n * @param shape - The shape to compile\n * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`\n *\n * @example Compiling a contract\n * ```ts\n * import {\n * \tcreateContract,\n * \tintegerShape,\n * \tobjectShape,\n * \tseededRandom,\n * \tstringShape,\n * } from '@orkestrel/contract'\n *\n * const user = createContract(objectShape({ name: stringShape({ min: 1 }), age: integerShape() }))\n *\n * user.is({ name: 'Ada', age: 36 }) // true — a typed guard (narrows to Infer<typeof shape>)\n * user.parse({ name: 'Ada', age: '36' }) // { name: 'Ada', age: 36 } — coerces, or undefined\n * user.parse({ name: '', age: 36 }) // undefined — '' violates name min:1 (parse enforces refinements, like is)\n * user.explain({ name: '', age: 36 }) // [{ reason: 'constraint', path: ['name'], expected: 'string', constraint: 'min', limit: 1, received: '\"\"' }]\n * user.schema // the owned, deeply frozen { type: 'object', properties: { … }, required: ['name', 'age'], additionalProperties: false }\n * user.generate(seededRandom(42)) // reproducible seed data; omit the arg for a wall-clock-seeded source\n * ```\n */\nexport function createContract<S extends ContractShape>(shape: S): ContractInterface<Infer<S>>\nexport function createContract(shape: ContractShape): ContractInterface<unknown>\nexport function createContract(shape: ContractShape): ContractInterface<unknown> {\n\treturn contain(() => {\n\t\tconst compiler = new ContractCompiler(shape)\n\t\tconst expansion = ShapePass.expansionOf(shape)\n\t\tif (expansion === undefined || expansion === 1) return compiler.contract\n\t\treturn new LazyContract(shape, compiler).publish(compiler.schema)\n\t}, 'createContract')\n}\n","import type { JSONSchema } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tadmitVisited,\n\tattempt,\n\tenumerableKeys,\n\tisFailure,\n\tlimitEntries,\n\tmatchesVisited,\n\tomitVisited,\n\treadArrayEntries,\n\tretainDepth,\n\tsortValues,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisDate,\n\tisFiniteNumber,\n\tisInteger,\n\tisNull,\n\tisNumber,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport { stringToFormat, unifySchemas } from './inferers.js'\n\n/**\n * Owns the state of one single-value inference walk.\n *\n * @remarks\n * The engine behind `valueToSchema`, and the per-sample classifier\n * `samplesToSchema` reaches through {@link SampleInferer}. The walk's ancestor\n * set and its `(object, remaining depth)` memo are `#` fields rather than\n * parameters, so no caller can pre-populate either and change what the walk\n * treats as a cycle or serves from cache. Construction observes nothing;\n * `infer` runs the whole walk.\n *\n * Every budget arrives already sanitized: the door applies `sanitizeDepth` and\n * `sanitizeBudget` once, so the walk carries a depth no deeper than\n * `INFER_DEPTH_LIMIT` and a finite non-negative breadth. Depth decrements per\n * level and exhaustion widens to the empty accept-anything schema.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class ValueInferer {\n\t// Captured while this module evaluates: the constructor runs outside every\n\t// containment the doors place, so reaching `globalThis` there would leave the\n\t// door open one call earlier than any boundary can see.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: unknown\n\treadonly #depth: number\n\treadonly #breadth: number\n\treadonly #closed: boolean\n\treadonly #format: boolean\n\treadonly #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, JSONSchema>>\n\n\tconstructor(value: unknown, depth: number, breadth: number, closed: boolean, format: boolean) {\n\t\tthis.#source = value\n\t\tthis.#depth = depth\n\t\tthis.#breadth = breadth\n\t\tthis.#closed = closed\n\t\tthis.#format = format\n\t\tthis.#visited = new ValueInferer.#weakSet()\n\t\tthis.#memo = new ValueInferer.#weakMap()\n\t}\n\n\t/**\n\t * Infers a JSON Schema fragment for the retained value.\n\t *\n\t * @returns The inferred schema fragment\n\t * @throws When a traversed container cannot be read\n\t */\n\tinfer(): JSONSchema {\n\t\treturn this.#infer(this.#source, this.#depth)\n\t}\n\n\t// The recursive spine, shared by the root and by every collected property or\n\t// element. Terminates on cyclic readable input through the ancestor set; a\n\t// failed traversal is refused by the containing public reader. Leaf\n\t// classification order: `null`, boolean, integer (`Number.isInteger`\n\t// semantics — `-0` counts), finite non-integer number, string (gaining a\n\t// `format` keyword when `format` is on and `stringToFormat` matches), array\n\t// (recurse), plain record (recurse), `Date` (`{ type: 'string' }`, plus\n\t// `format: 'date-time'` when `format` is on); everything else — a NON-FINITE\n\t// number (`NaN` / `±Infinity`), a function, a symbol, a bigint, `undefined`,\n\t// and other non-plain objects such as `Map` / `Set` — is the empty\n\t// accept-anything schema `{}`.\n\t//\n\t// A non-finite number bottoms out with the other JSON-inexpressible values on\n\t// purpose: JSON carries no `NaN` / `±Infinity` (`JSON.stringify(Number.NaN)`\n\t// is `'null'`), so `{ type: 'number' }` would ASSERT something a JSON Schema\n\t// validator rejects — and the shape `schemaToShape` builds from it would\n\t// reject the very sample it was inferred from. `{}` is the truthful\n\t// description, and it inverts to an accept-anything shape, keeping\n\t// `compileGuard(schemaToShape(valueToSchema(v)))(v)` true.\n\t#infer(value: unknown, depth: number): JSONSchema {\n\t\tif (isNull(value)) return { type: 'null' }\n\t\tif (isBoolean(value)) return { type: 'boolean' }\n\t\tif (isInteger(value)) return { type: 'integer' }\n\t\tif (isFiniteNumber(value)) return { type: 'number' }\n\t\t// A non-finite number has no JSON representation at all, so it widens to\n\t\t// `{}` with the other inexpressible values rather than claiming a `number`\n\t\t// type no validator would accept it under.\n\t\tif (isNumber(value)) return {}\n\t\tif (isString(value)) {\n\t\t\tif (this.#format) {\n\t\t\t\tconst detected = stringToFormat(value)\n\t\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t\t}\n\t\t\treturn { type: 'string' }\n\t\t}\n\t\tif (isArray(value)) return this.#walkArray(value, depth)\n\t\tif (isRecord(value)) return this.#walkRecord(value, depth)\n\t\tif (isDate(value)) {\n\t\t\treturn this.#format ? { type: 'string', format: 'date-time' } : { type: 'string' }\n\t\t}\n\t\treturn {}\n\t}\n\n\t// The array branch. An empty array infers `{ type: 'array' }` with no `items`.\n\t// Otherwise the first `#breadth` elements are classified and unified with\n\t// `unifySchemas`: a single distinct element schema becomes `items` directly;\n\t// several distinct schemas become `items: { anyOf: [...] }`. Depth exhaustion\n\t// or a cyclic re-encounter both yield `{}` instead of descending. A SPARSE\n\t// array (holes, for example `[1, , 3]`) has no JSON expression and widens to\n\t// the accept-anything `{}`, the same treatment `NaN`, a function, a symbol, a\n\t// `Map` and a `Set` receive — it is not read as a list of present `undefined`\n\t// leaves, because the array schema that reading produced was rejected by its\n\t// own compiled guard, which is the one direction the round-trip law forbids.\n\t//\n\t// ALL reads of `value` — including its `length` — happen inside `attempt`, and\n\t// the ancestor set is restored before the captured failure is rethrown, so a\n\t// hostile `length` getter, throwing own-getter element, or hostile element\n\t// access reaches the door's boundary with the walk already unwound. A\n\t// genuinely empty sampled list still returns `{ type: 'array' }` with no\n\t// `items`. A same-object re-inference at the same remaining depth is served\n\t// from the memo instead of recomputing, which guards a shared-reference DAG\n\t// against exponential blowup.\n\t#walkArray(value: readonly unknown[], depth: number): JSONSchema {\n\t\tif (!(depth > 0) || matchesVisited(this.#visited, value)) return {}\n\t\t// At a node reached through a cycle at the SAME remaining depth through two\n\t\t// different paths, the memo may serve the first traversal's already\n\t\t// cycle-truncated fragment (`{}`) to the second path instead of a fully\n\t\t// re-descended schema — a sound, deterministic over-approximation, never\n\t\t// a false-reject (a schema too permissive, never too strict).\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#memo, [value])?.get(depth)\n\t\tif (cached) return cached\n\t\tadmitVisited(this.#visited, value)\n\t\tconst outcome = attempt(() => {\n\t\t\tconst snapshot = readArrayEntries(value)\n\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t// A HOLE is an absent own property, and that is the lens every other\n\t\t\t// door in this package applies: `arrayOf`, `parseArray`, `isJSONValue`,\n\t\t\t// `cloneJSONValue`, `canonicalStringify` and the compiled array guard\n\t\t\t// all refuse a sparse array. Reading a hole as a PRESENT `undefined`\n\t\t\t// leaf made this door the one dissenter, and the disagreement was not\n\t\t\t// cosmetic: `valueToSchema([1, , 3])` emitted an array schema whose\n\t\t\t// guard REJECTED `[1, , 3]`, so the package published a schema that\n\t\t\t// refused the value it was inferred from. A non-dense snapshot has no\n\t\t\t// JSON expression, so it widens to `{}` alongside `NaN`, a function, a\n\t\t\t// symbol, a `Map` and a `Set` — which restores the round-trip law\n\t\t\t// rather than adding a fourth exception to it.\n\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\tconst entries = snapshot.value.entries\n\t\t\tconst length = INTRINSICS.ceil(INTRINSICS.min(entries.length, this.#breadth))\n\t\t\treturn INTRINSICS.from(\n\t\t\t\titerateIndices(() => length),\n\t\t\t\t(index) => this.#infer(entries[index], depth - 1),\n\t\t\t)\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (isFailure(outcome)) throw outcome.error\n\t\tconst sampled = outcome.value\n\t\tconst schema: JSONSchema =\n\t\t\tsampled === undefined\n\t\t\t\t? {}\n\t\t\t\t: sampled.length > 0\n\t\t\t\t\t? { type: 'array', items: unifySchemas(sampled) }\n\t\t\t\t\t: { type: 'array' }\n\t\tretainDepth(this.#memo, value, depth, schema)\n\t\treturn schema\n\t}\n\n\t// The plain-record branch. Own enumerable string keys through\n\t// `enumerableKeys`, sorted lexicographically for deterministic output, capped\n\t// at `#breadth`. This is the same property view compiled object guards,\n\t// parsers, and reporters use. Each property value is read inside `attempt`; a\n\t// hostile getter reaches the door's boundary. A readable property whose value\n\t// is `undefined` is DROPPED — JSON encodes no such property\n\t// (`JSON.stringify({ a: undefined })` is `'{}'`), so it contributes neither a\n\t// `properties` entry nor a `required` entry. Every other present key is\n\t// required.\n\t//\n\t// Emits `additionalProperties: false` when closed, `true` otherwise —\n\t// mirroring `compileSchema`'s object-emission convention — EXCEPT when the\n\t// sampled key list no longer describes every key `value` actually carries,\n\t// which happens when the own-key list exceeds `#breadth` (truncation), or when\n\t// a key was dropped for holding `undefined`. Either way `additionalProperties`\n\t// is forced to `true` regardless of the flag, because a CLOSED schema built\n\t// from an incomplete key list would reject the very object it was inferred\n\t// from (`recordOf` rejects any own key the shape does not declare).\n\t#walkRecord(value: Record<string, unknown>, depth: number): JSONSchema {\n\t\tif (!(depth > 0) || matchesVisited(this.#visited, value)) return {}\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#memo, [value])?.get(depth)\n\t\tif (cached) return cached\n\t\tadmitVisited(this.#visited, value)\n\t\t// Capture the whole key-enumeration and value-read walk, then unwind the\n\t\t// ancestor set before rethrowing. Readable depth or cycle exhaustion widens\n\t\t// to `{}`; unreadability never does.\n\t\tconst outcome = attempt(() => {\n\t\t\tconst snapshot = enumerableKeys(value)\n\t\t\tif (snapshot === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('property enumeration failed')\n\t\t\t}\n\t\t\tconst allKeys = sortValues(snapshot)\n\t\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\t\tconst truncated = allKeys.length > this.#breadth\n\t\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t\t// prototype — the same pattern compileGuard / compileParser use\n\t\t\t// (compilers.ts).\n\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\titerateIndices(() => keys.length),\n\t\t\t\t(index) => {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) return { key, schema: undefined }\n\t\t\t\t\tconst propertyValue = value[key]\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tschema: propertyValue === undefined ? undefined : this.#infer(propertyValue, depth - 1),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst selected: ReadonlyArray<{ readonly key: string; readonly schema: JSONSchema }> =\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t(entry: (typeof observed)[number]) =>\n\t\t\t\t\t\tentry.key !== undefined && entry.schema !== undefined,\n\t\t\t\t])\n\t\t\tconst pairs: ReadonlyArray<readonly [string, JSONSchema]> = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(selected),\n\t\t\t\t[(entry: (typeof selected)[number]) => [entry.key, entry.schema]],\n\t\t\t)\n\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t}),\n\t\t\t\tnull,\n\t\t\t)\n\t\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(selected),\n\t\t\t\t[(entry: (typeof selected)[number]) => entry.key],\n\t\t\t)\n\t\t\tconst dropped: boolean = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t(entry: (typeof observed)[number]) => entry.key !== undefined && entry.schema === undefined,\n\t\t\t])\n\t\t\treturn { properties, required, partial: truncated || dropped }\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (isFailure(outcome)) throw outcome.error\n\t\tconst { properties, required, partial } = outcome.value\n\t\tconst schema: JSONSchema = {\n\t\t\ttype: 'object',\n\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\tadditionalProperties: partial ? true : !this.#closed,\n\t\t}\n\t\tretainDepth(this.#memo, value, depth, schema)\n\t\treturn schema\n\t}\n}\n","import type { JSONSchema, SampleMemo } from './types.js'\nimport { INFER_ENUM_LIMIT, INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tbuildSampleMemo,\n\tenumerableKeys,\n\tisFailure,\n\tlimitEntries,\n\treadSampleMemo,\n\tsortValues,\n} from './helpers.js'\nimport { isRecord } from './validators.js'\nimport { inferPrimitiveEnum, samplesToFormat, unifySchemas } from './inferers.js'\nimport { ValueInferer } from './ValueInferer.js'\n\n/**\n * Owns the state of one multi-sample inference walk.\n *\n * @remarks\n * The engine behind `samplesToSchema`, which is the only door that constructs\n * it. The walk's {@link SampleMemo} is a `#` field rather than a parameter, so\n * no caller can pre-populate it and serve one walk another walk's answer.\n * Construction observes nothing; `infer` runs the whole walk.\n *\n * Every sample list the walk carries is owned: the door reads and dense-checks\n * the caller's array before construction, and every list below the root is\n * collected by this class. Every budget arrives already sanitized. Unlike the\n * single-value walk, the record path carries no ancestor set — a value shared by\n * reference across sample rows is legitimate data rather than a cycle back to an\n * ancestor — so termination rests on the decrementing depth budget and the\n * shared memo.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class SampleInferer {\n\treadonly #samples: readonly unknown[]\n\treadonly #depth: number\n\treadonly #breadth: number\n\treadonly #closed: boolean\n\treadonly #format: boolean\n\treadonly #enumerated: boolean\n\treadonly #memo: SampleMemo\n\n\tconstructor(\n\t\tsamples: readonly unknown[],\n\t\tdepth: number,\n\t\tbreadth: number,\n\t\tclosed: boolean,\n\t\tformat: boolean,\n\t\tenumerated: boolean,\n\t) {\n\t\tthis.#samples = samples\n\t\tthis.#depth = depth\n\t\tthis.#breadth = breadth\n\t\tthis.#closed = closed\n\t\tthis.#format = format\n\t\tthis.#enumerated = enumerated\n\t\tthis.#memo = buildSampleMemo()\n\t}\n\n\t/**\n\t * Infers one JSON Schema over the retained sample list.\n\t *\n\t * @returns The inferred schema\n\t * @throws When a sample row cannot be read\n\t */\n\tinfer(): JSONSchema {\n\t\treturn this.#infer(this.#samples, this.#depth, this.#memo)\n\t}\n\n\t// The shared non-record recursion step, entered at the top level and again per\n\t// collected property. When every value is itself a plain record, delegates to\n\t// the record branch. Otherwise: enum inference runs FIRST when enabled —\n\t// `inferPrimitiveEnum` fires only for a low-cardinality, repeated,\n\t// single-primitive-kind slot, and its `{ enum: [...] }` result wins outright\n\t// (ENUM > FORMAT > bare string). Failing that, each value is classified\n\t// independently by a fresh single-value walk with `format` FORCED OFF (the\n\t// multi-sample seam: nested formats never compound into an `anyOf`) and\n\t// unified with `unifySchemas`; only when that unified result is exactly\n\t// `{ type: 'string' }` and the outer format flag is on does `samplesToFormat`\n\t// run to (maybe) reattach a unanimous `format`.\n\t#infer(samples: readonly unknown[], depth: number, memo: SampleMemo): JSONSchema {\n\t\tif (samples.length === 0) return {}\n\t\tconst observed = INTRINSICS.from(\n\t\t\titerateIndices(() => samples.length),\n\t\t\t(index) => {\n\t\t\t\tconst sample = samples[index]\n\t\t\t\treturn isRecord(sample) ? sample : undefined\n\t\t\t},\n\t\t)\n\t\tconst records: ReadonlyArray<Record<string, unknown>> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(observed),\n\t\t\t[(sample: unknown) => sample !== undefined],\n\t\t)\n\t\tif (records.length === samples.length) {\n\t\t\treturn this.#walkRecords(records, depth, memo)\n\t\t}\n\t\tif (this.#enumerated) {\n\t\t\tconst enumSchema = inferPrimitiveEnum(samples, INFER_ENUM_LIMIT)\n\t\t\tif (enumSchema) return enumSchema\n\t\t}\n\t\tconst schemas = INTRINSICS.from(\n\t\t\titerateIndices(() => samples.length),\n\t\t\t(index) =>\n\t\t\t\tnew ValueInferer(samples[index], depth, this.#breadth, this.#closed, false).infer(),\n\t\t)\n\t\tconst unified = unifySchemas(schemas)\n\t\tif (this.#format && unified.type === 'string' && INTRINSICS.keys(unified).length === 1) {\n\t\t\tconst detected = samplesToFormat(samples)\n\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t}\n\t\treturn unified\n\t}\n\n\t// The record-specialized branch. `properties` is the union of every sample's\n\t// own keys (sorted, capped at `#breadth`); a key is `required` only when\n\t// present (and non-`undefined`) in EVERY sample. Each key's schema is inferred\n\t// over the collected values for that key through the shared step above (one\n\t// less depth), so a property that is itself an array or object of varying\n\t// shape across rows is unified the same way the top level is, and the same\n\t// format and enum gating applies per key.\n\t//\n\t// `additionalProperties` is forced to `true` regardless of the closed flag when\n\t// the key union exceeds `#breadth`, or a readable row carries a key as an own\n\t// property holding `undefined`. A hostile getter or failed KEY walk reaches the\n\t// door's boundary instead of dropping a key or widening the whole slot.\n\t//\n\t// The memo is keyed by the slot's ORDERED row identities, not by a single row.\n\t// Keying only the one-row slot left every MULTI-row slot — the shape this walk\n\t// exists for — re-inferring a shared child once per path: two rows sharing one\n\t// `{ a: child, b: child }` detail cost `2^depth` inferences, the identical\n\t// denial of service the one-row memo was added to remove.\n\t#walkRecords(\n\t\tsamples: ReadonlyArray<Record<string, unknown>>,\n\t\tdepth: number,\n\t\tmemo: SampleMemo,\n\t): JSONSchema {\n\t\tif (!(depth > 0)) return {}\n\t\t// The slot's ROW LIST is the key, followed one row at a time through the\n\t\t// memo's prefix chain, and the recorded schema is keyed by every budget and\n\t\t// flag the emission depends on. A multi-row list is a fresh array on every\n\t\t// call, but its rows are not: following their identities lands on the same\n\t\t// node whichever array carried them.\n\t\tconst node: SampleMemo = INTRINSICS.reflect.apply(INTRINSICS.fold, samples, [\n\t\t\t(current: SampleMemo, row: Record<string, unknown>) => {\n\t\t\t\tconst next = INTRINSICS.reflect.apply(INTRINSICS.recall, current.rows, [row])\n\t\t\t\tif (next !== undefined) return readSampleMemo(next, 'samplesToSchema')\n\t\t\t\tconst fresh = buildSampleMemo()\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, current.rows, [row, fresh])\n\t\t\t\treturn fresh\n\t\t\t},\n\t\t\tmemo,\n\t\t])\n\t\tconst signature = `${depth}|${this.#breadth}|${this.#closed}|${this.#format}|${this.#enumerated}`\n\t\tconst cached = INTRINSICS.reflect.apply(INTRINSICS.fetch, node.schemas, [signature])\n\t\tif (cached !== undefined) return cached\n\t\tconst keyPairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(samples), [\n\t\t\t(sample: Record<string, unknown> | undefined) => {\n\t\t\t\tif (sample === undefined) {\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t}\n\t\t\t\tconst sampleKeys = enumerableKeys(sample)\n\t\t\t\tif (sampleKeys === undefined) {\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: property enumeration failed')\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(sampleKeys), [\n\t\t\t\t\t(key: string) => [key, true],\n\t\t\t\t])\n\t\t\t},\n\t\t])\n\t\tconst keySet = INTRINSICS.record<boolean>({\n\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [keyPairs]),\n\t\t})\n\t\tconst allKeys = sortValues(INTRINSICS.keys(keySet))\n\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\tconst truncated = allKeys.length > this.#breadth\n\t\tconst columns = INTRINSICS.from(\n\t\t\titerateIndices(() => keys.length),\n\t\t\t(index) => {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) return { key, schema: undefined, dropped: false, required: false }\n\t\t\t\tconst valuesOutcome = attempt(() => {\n\t\t\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(() => samples.length),\n\t\t\t\t\t\t(sampleIndex) => {\n\t\t\t\t\t\t\tconst sample = samples[sampleIndex]\n\t\t\t\t\t\t\tif (sample === undefined) {\n\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst value = sample[key]\n\t\t\t\t\t\t\treturn { value, dropped: value === undefined && INTRINSICS.own(sample, key) }\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tconst present = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(observed), [\n\t\t\t\t\t\t(entry: { readonly value: unknown }) => entry.value !== undefined,\n\t\t\t\t\t])\n\t\t\t\t\tconst values: readonly unknown[] = INTRINSICS.reflect.apply(\n\t\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\t\treadIndexView(present),\n\t\t\t\t\t\t[(entry: { readonly value: unknown }) => entry.value],\n\t\t\t\t\t)\n\t\t\t\t\tconst dropped: boolean = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t\t\t(entry: { readonly dropped: boolean }) => entry.dropped,\n\t\t\t\t\t])\n\t\t\t\t\treturn { values, dropped }\n\t\t\t\t})\n\t\t\t\tif (isFailure(valuesOutcome)) throw valuesOutcome.error\n\t\t\t\tconst { values, dropped } = valuesOutcome.value\n\t\t\t\treturn {\n\t\t\t\t\tkey,\n\t\t\t\t\tschema: values.length > 0 ? this.#infer(values, depth - 1, memo) : undefined,\n\t\t\t\t\tdropped,\n\t\t\t\t\trequired: !dropped && values.length === samples.length,\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.expand, readIndexView(columns), [\n\t\t\t(column: { readonly key: string | undefined; readonly schema: JSONSchema | undefined }) =>\n\t\t\t\tcolumn.key === undefined || column.schema === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [[column.key, column.schema]],\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<JSONSchema>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tconst required: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.expand,\n\t\t\treadIndexView(columns),\n\t\t\t[\n\t\t\t\t(column: { readonly key: string | undefined; readonly required: boolean }) =>\n\t\t\t\t\tcolumn.required && column.key !== undefined ? [column.key] : [],\n\t\t\t],\n\t\t)\n\t\tconst partial =\n\t\t\ttruncated ||\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, columns, [\n\t\t\t\t(column: { readonly dropped: boolean }) => column.dropped,\n\t\t\t])\n\t\tconst schema: JSONSchema = {\n\t\t\ttype: 'object',\n\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\tadditionalProperties: partial ? true : !this.#closed,\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.store, node.schemas, [signature, schema])\n\t\treturn schema\n\t}\n}\n","import type { JSONSchema, SchemaFormat, ValueToSchemaOptions } from './types.js'\nimport { FORMAT_MAX_LENGTH, INFER_BREADTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport { isFiniteNumber, isRecord, isString } from './validators.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tcanonicalStringify,\n\tclassifyFormat,\n\tcontain,\n\tisFailure,\n\tisSuccess,\n\treadArrayEntries,\n\treadOptions,\n\treadValue,\n\tsanitizeBudget,\n\tsanitizeDepth,\n\tsortValues,\n} from './helpers.js'\nimport { SampleInferer } from './SampleInferer.js'\nimport { ValueInferer } from './ValueInferer.js'\n\n// The inferers walk an UNKNOWN, possibly adversarial runtime value (or a set\n// of example values) and emit a JSONSchema — the reverse direction of\n// compileSchema (compilers.ts), which walks a finite, developer-authored\n// ContractShape tree. Recursion here is runtime-only and bounded on three\n// axes: a WeakSet of ancestor objects/arrays (cycle safety), a decrementing\n// depth budget held at the INFER_DEPTH_LIMIT ceiling, and a per-container sampling cap\n// (INFER_BREADTH_LIMIT default). Readable unsupported values widen only where\n// documented; failed traversal is a coded refusal, never a permissive schema.\n\n/**\n * Unifies a list of inferred `JSONSchema` fragments into one schema.\n *\n * @remarks\n * De-duplicates by {@link canonicalStringify}, then applies the one\n * special-case subsumption inference performs: a bare `{ type: 'integer' }`\n * alongside a bare `{ type: 'number' }` collapses to `{ type: 'number' }`\n * (an integer sample is also a valid `number` sample). A single surviving\n * distinct schema is returned directly; two or more are wrapped as\n * `{ anyOf: [...] }`, sorted by their canonical key for deterministic output.\n * An empty input list returns the empty accept-anything schema `{}`.\n *\n * Every captured member must first be a non-null object record. This runtime\n * requirement is realm-agnostic and admits ordinary and null-prototype schema\n * records while refusing primitives and callables before canonicalization.\n *\n * A readable member {@link canonicalStringify} cannot key — a cyclic or\n * otherwise JSON-inexpressible fragment, which only a direct caller can supply\n * since the inferers always build plain encodable fragments — has NO\n * de-duplication key, so it can participate in neither de-duplication nor the\n * canonical-key ordering. It is KEPT (dropping a variant would narrow the\n * union, and unification only ever widens), appended in input order after the\n * sorted keyed members. A failed member read propagates the canonicalizer's\n * coded refusal instead of participating in the union.\n *\n * @param schemas - The schemas to unify\n * @returns The unified schema\n *\n * @example\n * ```ts\n * unifySchemas([{ type: 'integer' }, { type: 'number' }]) // { type: 'number' }\n * unifySchemas([{ type: 'string' }, { type: 'boolean' }])\n * // { anyOf: [{ type: 'boolean' }, { type: 'string' }] }\n * ```\n */\nexport function unifySchemas(schemas: readonly JSONSchema[]): JSONSchema {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(schemas)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense) throw new INTRINSICS.error('unifySchemas: schemas must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length === 0) return {}\n\t\t\t\tconst keyed = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => owned.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst schema = owned[index]\n\t\t\t\t\t\tif (schema === undefined || !isRecord(schema)) {\n\t\t\t\t\t\t\tthrow new INTRINSICS.error('unifySchemas: schemas must be records')\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { key: canonicalStringify(schema), schema }\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tconst encodable = INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(keyed), [\n\t\t\t\t\t(entry: { readonly key: string | undefined }) => entry.key !== undefined,\n\t\t\t\t])\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(encodable), [\n\t\t\t\t\t(entry: { readonly key: string; readonly schema: JSONSchema }) => [\n\t\t\t\t\t\tentry.key,\n\t\t\t\t\t\tentry.schema,\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t\tconst reversed = INTRINSICS.reflect.apply(INTRINSICS.flip, pairs, [])\n\t\t\t\tconst byKey = INTRINSICS.record<JSONSchema>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\treversed,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst integerKey = canonicalStringify({ type: 'integer' })\n\t\t\t\tconst numberKey = canonicalStringify({ type: 'number' })\n\t\t\t\tconst subsumed =\n\t\t\t\t\tintegerKey !== undefined &&\n\t\t\t\t\tnumberKey !== undefined &&\n\t\t\t\t\tINTRINSICS.own(byKey, integerKey) &&\n\t\t\t\t\tINTRINSICS.own(byKey, numberKey)\n\t\t\t\t\t\t? integerKey\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst keys = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(byKey)),\n\t\t\t\t\t[(key: string) => key !== subsumed],\n\t\t\t\t)\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst unkeyed: ReadonlyArray<{ readonly schema: JSONSchema }> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.select,\n\t\t\t\t\treadIndexView(keyed),\n\t\t\t\t\t[(entry: { readonly key: string | undefined }) => entry.key === undefined],\n\t\t\t\t)\n\t\t\t\tconst members = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => ordered.length + unkeyed.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\t\treturn key === undefined ? unkeyed[index - ordered.length]?.schema : byKey[key]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tif (members.length <= 1) {\n\t\t\t\t\tconst only = members[0]\n\t\t\t\t\treturn only ?? {}\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tanyOf: INTRINSICS.reflect.apply(INTRINSICS.select, readIndexView(members), [\n\t\t\t\t\t\t(schema: JSONSchema | undefined) => schema !== undefined,\n\t\t\t\t\t]),\n\t\t\t\t}\n\t\t\t},\n\t\t\t'unifySchemas',\n\t\t\t{ subject: 'schemas' },\n\t\t)\n\t}, 'unifySchemas')\n}\n\n// === Format inference\n\n/**\n * Classifies a string against the {@link SchemaFormat} vocabulary.\n *\n * @remarks\n * Total, pure, and deterministic. Fixed precedence, most specific first:\n * `'uuid'`, `'date-time'`, `'date'`, `'time'`, `'email'`, `'uri'` — the first\n * match wins. The `date-time` / `date` / `time` branches require BOTH a\n * strict ISO-8601 shape match AND a real {@link matchesISOInstant} validity\n * check, so a shape-plausible but impossible date (`2020-13-45`) is rejected.\n * Returns `undefined` when no format matches (including the empty string).\n *\n * @param value - The string to classify\n * @returns The matched {@link SchemaFormat}, or `undefined`\n *\n * @example\n * ```ts\n * stringToFormat('550e8400-e29b-41d4-a716-446655440000') // 'uuid'\n * stringToFormat('2024-01-15') // 'date'\n * stringToFormat('2020-13-45') // undefined — invalid date\n * stringToFormat('ada@example.com') // 'email'\n * stringToFormat('10:30:00') // undefined — RFC 3339 time requires an offset\n * stringToFormat('10:30:00+02:00') // 'time'\n * ```\n */\nexport function stringToFormat(value: string): SchemaFormat | undefined {\n\tif (!isString(value)) return undefined\n\tif (value.length > FORMAT_MAX_LENGTH) return undefined\n\t// Total by containment at the door: every classification below dispatches\n\t// through `RegExp.prototype.test`/`.exec`, caller-writable members reached by\n\t// name, and this reader is documented to answer `SchemaFormat | undefined`\n\t// with no `@throws` at all.\n\tconst outcome = attempt(() => classifyFormat(value))\n\treturn isSuccess(outcome) ? outcome.value : undefined\n}\n\n/**\n * Classifies a list of sample values against the {@link SchemaFormat}\n * vocabulary, requiring unanimity.\n *\n * @remarks\n * A format is returned ONLY IF every value is a string AND every one maps to\n * the SAME {@link stringToFormat} result (including all mapping to\n * `undefined`, which itself returns `undefined` here). A single disagreeing\n * value, a non-string value, or an empty list all yield `undefined` — the\n * multi-sample seam behind {@link samplesToSchema}\n * relies on this unanimity so a slot with mixed string shapes emits a bare\n * `{ type: 'string' }` rather than an `anyOf` of formats.\n *\n * @param values - The sample values to classify\n * @returns The unanimous {@link SchemaFormat}, or `undefined`\n *\n * @example\n * ```ts\n * samplesToFormat(['2024-01-01', '2024-02-02']) // 'date'\n * samplesToFormat(['2024-01-01', 'not a date']) // undefined\n * samplesToFormat([]) // undefined\n * ```\n */\nexport function samplesToFormat(values: readonly unknown[]): SchemaFormat | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(values)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense)\n\t\t\t\t\tthrow new INTRINSICS.error('samplesToFormat: values must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length === 0) return undefined\n\t\t\t\tconst initial = owned[0]\n\t\t\t\tconst first = isString(initial) ? stringToFormat(initial) : undefined\n\t\t\t\tif (first === undefined) return undefined\n\t\t\t\tconst mismatch = INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t(value: unknown, index: number) =>\n\t\t\t\t\t\tindex > 0 && (!isString(value) || stringToFormat(value) !== first),\n\t\t\t\t])\n\t\t\t\tif (mismatch) return undefined\n\t\t\t\treturn first\n\t\t\t},\n\t\t\t'samplesToFormat',\n\t\t\t{ subject: 'values' },\n\t\t)\n\t}, 'samplesToFormat')\n}\n\n// === Enum inference\n\n/**\n * Infers an `{ enum: [...] }` fragment for a low-cardinality, repeated\n * primitive slot — the multi-sample-only counterpart to\n * {@link stringToFormat} ({@link valueToSchema} never emits `enum`).\n *\n * @remarks\n * Fires only when ALL of: every value is the same primitive kind (all string\n * or all FINITE number through {@link isFiniteNumber} — any `null`/boolean/mixed\n * slot never qualifies, and a slot containing `NaN` / `±Infinity` never\n * qualifies either, since {@link canonicalStringify} collapses `NaN` to\n * `'null'` and would otherwise risk an invalid-JSON `enum`); at least 2\n * values are given; the distinct-by-{@link canonicalStringify} count is LESS\n * than the value count (repetition required — separates a categorical column\n * from an ID column); and the distinct count is at most `limit`. The emitted\n * schema carries `enum` with NO `type` key, byte-matching `compileSchema`'s\n * `literalShape` emission. Members are sorted by canonical key for\n * deterministic output.\n *\n * A member {@link canonicalStringify} cannot key has no identity to\n * de-duplicate against, so the whole slot is enum-INELIGIBLE and returns\n * `undefined` — widening to the caller's bare `type` rather than emitting an\n * `enum` that might silently omit a value. (A string or finite number always\n * canonicalizes, so this only guards the total contract.)\n *\n * @param values - The collected slot values\n * @param limit - The maximum distinct-value count before giving up\n * @returns The `{ enum: [...] }` fragment, or `undefined` when ineligible\n *\n * @example\n * ```ts\n * inferPrimitiveEnum(['active', 'inactive', 'active'], 12)\n * // { enum: ['active', 'inactive'] }\n * inferPrimitiveEnum(['a', 'b', 'c'], 12) // undefined — no repetition\n * ```\n */\nexport function inferPrimitiveEnum(\n\tvalues: readonly unknown[],\n\tlimit: number,\n): JSONSchema | undefined {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(values)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\tif (!snapshot.value.dense)\n\t\t\t\t\tthrow new INTRINSICS.error('inferPrimitiveEnum: values must be dense')\n\t\t\t\tconst owned = snapshot.value.entries\n\t\t\t\tif (owned.length < 2) return undefined\n\t\t\t\tconst allString = !INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t(value: unknown) => !isString(value),\n\t\t\t\t])\n\t\t\t\tconst allNumber =\n\t\t\t\t\t!allString &&\n\t\t\t\t\t!INTRINSICS.reflect.apply(INTRINSICS.some, owned, [\n\t\t\t\t\t\t(value: unknown) => !isFiniteNumber(value),\n\t\t\t\t\t])\n\t\t\t\tif (!allString && !allNumber) return undefined\n\t\t\t\tconst pairs = INTRINSICS.from(\n\t\t\t\t\titerateIndices(() => owned.length),\n\t\t\t\t\t(index) => {\n\t\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\t\treturn [canonicalStringify(value), value]\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, pairs, [\n\t\t\t\t\t\t(pair: readonly unknown[]) => pair[0] === undefined,\n\t\t\t\t\t])\n\t\t\t\t) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst byKey = INTRINSICS.record<string | number>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tpairs,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst keys = INTRINSICS.keys(byKey)\n\t\t\t\tif (keys.length >= owned.length || keys.length > limit) return undefined\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst population: ReadonlyArray<string | number> = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(ordered),\n\t\t\t\t\t[(key: string) => byKey[key]],\n\t\t\t\t)\n\t\t\t\treturn { enum: population }\n\t\t\t},\n\t\t\t'inferPrimitiveEnum',\n\t\t\t{ subject: 'values' },\n\t\t)\n\t}, 'inferPrimitiveEnum')\n}\n\n// === Single-value inference\n\n/**\n * Infers a `JSONSchema` for one unknown value — the reverse direction of\n * {@link compileSchema}.\n *\n * @remarks\n * Cycle-, depth-, and breadth-bounded: the walk keeps an ancestor set and an\n * `(object, remaining depth)` memo of its own, so a cyclic host terminates and a\n * shared-reference DAG costs its nodes rather than its paths. A failed traversal\n * throws a `structure`\n * {@link ContractError}; it never becomes `{}` or another permissive schema. Nested\n * objects close to unknown keys (`additionalProperties: false`) by default;\n * pass `closed: false` to open them. `format` (default `false`) opts a\n * string/`Date` leaf into the `format` keyword. Structurally-equal inputs\n * infer byte-identical schemas (object keys and `anyOf` members are sorted).\n *\n * A non-object root — for example `valueToSchema('hi')` yielding `{ type: 'string'\n * }` — is structurally accepted by `schemaToParameters`, but MCP clients\n * expect an object-shaped `inputSchema`; wrap a non-object payload with\n * {@link schemaToObject} before advertising it as a tool's parameters.\n *\n * `limits.properties` is sanitized through {@link sanitizeBudget} to a finite\n * non-negative integer, falling back to {@link INFER_BREADTH_LIMIT} for anything\n * else (`NaN`, `Infinity`, negative, fractional), so a malformed breadth cannot\n * corrupt the sampled key/element list.\n *\n * `limits.depth` goes through {@link sanitizeDepth}, which does the same and then caps\n * at {@link INFER_DEPTH_LIMIT}, so the option NARROWS the walk and cannot widen\n * it. The cap is what makes the depth guard unbreakable: depth is the recursing\n * axis, so an uncapped large-but-valid budget would descend until the call STACK\n * failed rather than until the guard says stop.\n *\n * @param value - The value to infer a schema from\n * @param options - Optional {@link ValueToSchemaLimits} `limits` plus `closed` / `format` bounds\n * @returns The inferred `JSONSchema`\n * @throws {ContractError} When the value or options cannot be read\n *\n * @example\n * ```ts\n * valueToSchema({ id: 1, name: 'Ada', tags: ['a', 'b'] })\n * // { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' },\n * // tags: { type: 'array', items: { type: 'string' } } },\n * // required: ['id', 'name', 'tags'], additionalProperties: false }\n * ```\n */\nexport function valueToSchema(value: unknown, options?: ValueToSchemaOptions): JSONSchema {\n\treturn contain(() => {\n\t\tconst optionsSnapshot = readOptions(\n\t\t\toptions,\n\t\t\t['limits', 'closed', 'format', 'enum'],\n\t\t\t'valueToSchema',\n\t\t\t'schema',\n\t\t)\n\t\t// The grouped budgets cross the same contained read the flat keys crossed:\n\t\t// `limits` is a caller-owned record, so a hostile getter or `ownKeys` trap\n\t\t// on it refuses under this door's name rather than reaching the walk.\n\t\tconst limits = readOptions(\n\t\t\toptionsSnapshot?.limits,\n\t\t\t['depth', 'properties'],\n\t\t\t'valueToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst depth = sanitizeDepth(limits?.depth)\n\t\tconst properties = sanitizeBudget(limits?.properties, INFER_BREADTH_LIMIT)\n\t\tconst closed = optionsSnapshot?.closed ?? true\n\t\tconst format = optionsSnapshot?.format ?? false\n\t\t// The whole walk runs inside this door's own read boundary, so a hostile\n\t\t// getter, `length` trap, or key enumeration anywhere below it is published\n\t\t// under this door's name rather than under the name of an engine method no\n\t\t// consumer can call.\n\t\treturn readValue(\n\t\t\t() => new ValueInferer(value, depth, properties, closed, format).infer(),\n\t\t\t'valueToSchema',\n\t\t)\n\t}, 'valueToSchema')\n}\n\n// === Multi-sample inference\n\n/**\n * Infers a `JSONSchema` from a set of example values — the multi-example\n * counterpart of {@link valueToSchema} (for example inferring one schema from\n * several database rows).\n *\n * @remarks\n * An empty `samples` array infers the empty accept-anything schema `{}`.\n * When every sample is a plain record, properties/required are unified\n * per-key across all samples — a key\n * required iff present and non-`undefined` in every sample. Otherwise the\n * slot is inferred one value at a time (independent {@link valueToSchema}\n * per sample, unified with {@link unifySchemas} — the same de-duplication and\n * `anyOf` ordering an array's element schemas receive). `format`\n * and `enum` (both default `false`) opt a low-cardinality/unanimous-format\n * slot into the corresponding keyword: enum inference runs first and wins\n * outright, and a unanimous format is reattached only to a slot that unified to\n * exactly `{ type: 'string' }`, with nested formats forced off. `limits.depth` /\n * `limits.properties` are resolved exactly as {@link valueToSchema} resolves them —\n * breadth through {@link sanitizeBudget}, depth through {@link sanitizeDepth},\n * which also caps at {@link INFER_DEPTH_LIMIT}; see there for why.\n *\n * @param samples - The example values to infer a schema from\n * @param options - Optional {@link ValueToSchemaLimits} `limits` plus `closed` / `format` / `enum` bounds\n * @returns The inferred `JSONSchema`\n * @throws {ContractError} When the samples or options cannot be read\n *\n * @example\n * ```ts\n * samplesToSchema([{ id: 1 }, { id: 2, name: 'Ada' }])\n * // { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } },\n * // required: ['id'], additionalProperties: false }\n * samplesToSchema([]) // {}\n * ```\n */\nexport function samplesToSchema(\n\tsamples: readonly unknown[],\n\toptions?: ValueToSchemaOptions,\n): JSONSchema {\n\treturn contain(() => {\n\t\tconst optionsSnapshot = readOptions(\n\t\t\toptions,\n\t\t\t['limits', 'closed', 'format', 'enum'],\n\t\t\t'samplesToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst limits = readOptions(\n\t\t\toptionsSnapshot?.limits,\n\t\t\t['depth', 'properties'],\n\t\t\t'samplesToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst depth = sanitizeDepth(limits?.depth)\n\t\tconst properties = sanitizeBudget(limits?.properties, INFER_BREADTH_LIMIT)\n\t\tconst closed = optionsSnapshot?.closed ?? true\n\t\tconst format = optionsSnapshot?.format ?? false\n\t\tconst enumOn = optionsSnapshot?.enum ?? false\n\t\tconst read = readValue(\n\t\t\t() => {\n\t\t\t\tconst snapshot = readArrayEntries(samples)\n\t\t\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\t\t\treturn snapshot.value\n\t\t\t},\n\t\t\t'samplesToSchema',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t\t// A hole is READABLE. Reporting it as `samples could not be read` paired a\n\t\t// true refusal with a false diagnosis and contradicted the guide's own\n\t\t// attribution of that message to \"a hostile getter or failed key walk\".\n\t\tif (!read.dense) {\n\t\t\tthrow new ContractError('samplesToSchema: samples must be a dense array', {\n\t\t\t\tcode: 'structure',\n\t\t\t})\n\t\t}\n\t\t// The recursion stays inside this door's own read boundary, so a failed read\n\t\t// anywhere below is still published as `samplesToSchema: samples could not\n\t\t// be read` rather than under the name of an internal spine function.\n\t\treturn readValue(\n\t\t\t() => new SampleInferer(read.entries, depth, properties, closed, format, enumOn).infer(),\n\t\t\t'samplesToSchema',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t}, 'samplesToSchema')\n}\n","import type {\n\tContractShape,\n\tJSONSchema,\n\tJSONSchemaType,\n\tLiteralValue,\n\tOptionalShape,\n} from './types.js'\nimport {\n\tCOMPILE_NODE_LIMIT,\n\tDATE_LENGTH,\n\tFAULT_SCHEMA_LIMIT,\n\tINFER_BREADTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tJSON_SCHEMA_TYPES,\n\tSTRICT_SCHEMA_KEYWORDS,\n} from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\treadIndexView,\n\tadmitMember,\n\tadmitVisited,\n\tcollectMembers,\n\tderiveLengthBounds,\n\tderiveRangeBounds,\n\tisFailure,\n\tlimitEntries,\n\titerateIndices,\n\tmatchesMember,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\trenderPath,\n\ttruncateFaultText,\n\treadArrayEntries,\n\tretainDepth,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisFiniteNumber,\n\tisInteger,\n\tisJSONValue,\n\tisLiteralValue,\n\tisObject,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport { parseEnumValues } from './parsers.js'\nimport { ContractCompiler } from './ContractCompiler.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnullableShape,\n\tnullShape,\n\tnumberShape,\n\tobjectShape,\n\toneOfShape,\n\toptionalShape,\n\trawShape,\n\tstringShape,\n\tunionShape,\n} from './shapers.js'\n\n/**\n * Owns the state of one schema-inversion walk.\n *\n * @remarks\n * The engine behind `schemaToShape`, which is the only door that constructs it.\n * The walk's cycle set and its `(node, remaining depth)` memo are `#` fields\n * rather than parameters, so no caller can pre-populate either and change what\n * the conversion widens. Construction observes nothing; `shape` runs the whole\n * walk and every refusal it raises is published by that door under the door's\n * own name. A strict walk refuses where a lenient one widens, through the one\n * `#widen` both share, and its per-node `#inspect` refuses every keyword the\n * lenient precedence would read past.\n *\n * The recursion is `#` private for the same reason it is bounded: it is the\n * class's defining spine, and its state has no meaning outside one call. The\n * collection constructors are captured while this module evaluates, so a caller\n * who replaces `globalThis.WeakSet` or `globalThis.WeakMap` before the door runs\n * cannot make construction throw a raw value out of a door documented to refuse\n * with a `ContractError`.\n *\n * The class is not published and no instance escapes its door, so its prototype\n * carries nothing a caller can reach and it needs no member pinning.\n */\nexport class SchemaShaper {\n\t// Captured while this module evaluates, exactly as the cloners capture theirs:\n\t// the constructor runs outside every containment this class has, so reaching\n\t// `globalThis` there would leave the door open one call earlier than any\n\t// boundary can see.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: JSONSchema\n\treadonly #strict: boolean\n\treadonly #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, ContractShape>>\n\t// A second memo for the nodes reached below a union, because a default that fills\n\t// beside a union must drop inside one, so one node converts to two different shapes.\n\treadonly #enclosed: WeakMap<object, Map<number, ContractShape>>\n\t// A third for the nodes reached below a strict `oneOf`, where a silent object refuses\n\t// though it would close anywhere else.\n\treadonly #exclusive: WeakMap<object, Map<number, ContractShape>>\n\treadonly #path: string[]\n\t#oneOfs: number\n\t// The steps that built a shape node, and whether a memo served a node twice, so a tree\n\t// too small to overflow the compile limit pays for no second count.\n\t#built: number\n\t#shared: boolean\n\n\tconstructor(schema: JSONSchema, strict = false) {\n\t\tthis.#source = schema\n\t\tthis.#strict = strict\n\t\tthis.#visited = new SchemaShaper.#weakSet()\n\t\tthis.#memo = new SchemaShaper.#weakMap()\n\t\tthis.#enclosed = new SchemaShaper.#weakMap()\n\t\tthis.#exclusive = new SchemaShaper.#weakMap()\n\t\tthis.#path = []\n\t\tthis.#oneOfs = 0\n\t\tthis.#built = 0\n\t\tthis.#shared = false\n\t}\n\n\t/**\n\t * Converts the retained schema into a validating contract shape.\n\t *\n\t * @returns The built shape, widened wherever a lenient schema is inexpressible\n\t * @throws {ContractError} When schema traversal fails, or when a strict conversion refuses\n\t */\n\tshape(): ContractShape {\n\t\tif (this.#strict && isRecord(this.#source) && INTRINSICS.own(this.#source, 'default')) {\n\t\t\tthrow this.#refusal('a default needs an optional property to fill', 'default')\n\t\t}\n\t\tconst shape = this.#convert(this.#source, INFER_DEPTH_LIMIT, false)\n\t\treturn !this.#strict && this.#exceeds(shape) ? this.#shallow(shape) : shape\n\t}\n\n\t// A lenient schema must always compile, so one past the compile limit keeps only its\n\t// root. No step builds more than nine shape nodes, so a sharing-free walk of a\n\t// sixteenth of the limit cannot overflow it and pays for no second count. A memo hit\n\t// means the walk built less than the shape expands into, so it always asks the\n\t// validator.\n\t#exceeds(shape: ContractShape): boolean {\n\t\tif (!this.#shared && this.#built <= COMPILE_NODE_LIMIT / 16) return false\n\t\tconst validator = new ShapeValidator(shape)\n\t\tvalidator.validate()\n\t\treturn (validator.expansion ?? 0) > COMPILE_NODE_LIMIT\n\t}\n\n\t// What a shape too large to compile can still enforce: its root's type, an array's\n\t// bounds, and an object's required keys and closure, with every value below them raw.\n\t// A root with no such form widens whole. Keys stop at `INFER_BREADTH_LIMIT`, so what\n\t// this builds always compiles.\n\t#shallow(shape: ContractShape): ContractShape {\n\t\tconst raw = rawShape({})\n\t\tswitch (shape.category) {\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableShape(this.#shallow(shape.inner))\n\t\t\tcase 'array':\n\t\t\t\treturn arrayShape(\n\t\t\t\t\traw,\n\t\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...(shape.min === undefined ? {} : { min: shape.min }),\n\t\t\t\t\t\t\t...(shape.max === undefined ? {} : { max: shape.max }),\n\t\t\t\t\t\t\t...(shape.description === undefined ? {} : { description: shape.description }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\tcase 'object': {\n\t\t\t\tconst pairs = INTRINSICS.reflect.apply(\n\t\t\t\t\tINTRINSICS.project,\n\t\t\t\t\treadIndexView(INTRINSICS.keys(shape.properties)),\n\t\t\t\t\t[\n\t\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tshape.properties[key]?.category === 'optional' ? optionalShape(raw) : raw,\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t\tconst properties = INTRINSICS.rebase(\n\t\t\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\t\tpairs,\n\t\t\t\t\t\t]),\n\t\t\t\t\t}),\n\t\t\t\t\tnull,\n\t\t\t\t)\n\t\t\t\tconst extra = shape.additionalProperties\n\t\t\t\treturn objectShape(\n\t\t\t\t\tproperties,\n\t\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadditionalProperties: isObject(extra) ? raw : (extra ?? false),\n\t\t\t\t\t\t\t...(shape.description === undefined ? {} : { description: shape.description }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnull,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn raw\n\t\t}\n\t}\n\n\t// The per-node entry point the root and every child recursion share. Guards\n\t// depth exhaustion, a readable non-record node (the node's static `JSONSchema`\n\t// type is not trusted at runtime), and a cyclic re-encounter — all three widen\n\t// to `rawShape`. The ancestor set is added to and removed from around the\n\t// WHOLE subtree conversion, so a DAG-shaped schema reached twice through two\n\t// different noncyclic paths does not false-positive as a cycle. A same-node\n\t// re-conversion at the same remaining depth is served from the memo, which\n\t// guards a shared-reference schema DAG against exponential blowup.\n\t#convert(schema: JSONSchema, depth: number, enclosed: boolean): ContractShape {\n\t\tif (!(depth > 0)) return this.#widen('a schema may not nest past the depth limit', undefined)\n\t\tif (!matchesRecordBrand(schema)) {\n\t\t\treturn this.#widen('every schema node must be a plain record', undefined)\n\t\t}\n\t\tif (matchesVisited(this.#visited, schema)) {\n\t\t\treturn this.#widen('a schema may not contain a cycle', undefined)\n\t\t}\n\t\t// The memo read is dispatched through the captured `Map.prototype.get`\n\t\t// too: a substitute answering a decoy would put a shape this package\n\t\t// never built into one it publishes as its own.\n\t\tconst memo = this.#oneOfs > 0 ? this.#exclusive : enclosed ? this.#enclosed : this.#memo\n\t\tconst depthMemo = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [schema])\n\t\tconst cached =\n\t\t\tdepthMemo === undefined\n\t\t\t\t? undefined\n\t\t\t\t: INTRINSICS.reflect.apply(INTRINSICS.fetch, depthMemo, [depth])\n\t\tif (cached) {\n\t\t\tthis.#shared = true\n\t\t\treturn cached\n\t\t}\n\t\tadmitVisited(this.#visited, schema)\n\t\ttry {\n\t\t\tif (this.#strict) this.#inspect(schema)\n\t\t\tconst built = this.#build(schema, depth, enclosed)\n\t\t\t// Read here rather than in `#build`, which a type list re-enters per member. The\n\t\t\t// OpenAPI keyword stays out of `JSONSchema`, and a strict walk has refused it.\n\t\t\tconst nullable =\n\t\t\t\tINTRINSICS.own(schema, 'nullable') && INTRINSICS.reflect.read(schema, 'nullable') === true\n\t\t\tconst shape = nullable ? nullableShape(built) : built\n\t\t\tretainDepth(memo, schema, depth, shape)\n\t\t\treturn shape\n\t\t} finally {\n\t\t\tomitVisited(this.#visited, schema)\n\t\t}\n\t}\n\n\t// One step down the schema, carrying the path a strict refusal names. Only a\n\t// property's optional wrapper can hold a default, so every other child refuses one.\n\t#descend(\n\t\tschema: JSONSchema,\n\t\tdepth: number,\n\t\tenclosed: boolean,\n\t\tfirst: string,\n\t\tsecond?: string,\n\t): ContractShape {\n\t\tthis.#path[this.#path.length] = first\n\t\tif (second !== undefined) this.#path[this.#path.length] = second\n\t\tif (\n\t\t\tthis.#strict &&\n\t\t\tfirst !== 'properties' &&\n\t\t\tisRecord(schema) &&\n\t\t\tINTRINSICS.own(schema, 'default')\n\t\t) {\n\t\t\tthrow this.#refusal('a default needs an optional property to fill', 'default')\n\t\t}\n\t\tconst shape = this.#convert(schema, depth, enclosed)\n\t\tthis.#path.length -= second === undefined ? 1 : 2\n\t\treturn shape\n\t}\n\n\t// What the lenient walk widens, the strict walk refuses. The widening keeps the\n\t// node's description, as it always has.\n\t#widen(\n\t\tmessage: string,\n\t\tdescription: string | undefined,\n\t\tfirst?: string,\n\t\tsecond?: string,\n\t): ContractShape {\n\t\tif (this.#strict) throw this.#refusal(message, first, second)\n\t\tthis.#built += 1\n\t\treturn rawShape(description === undefined ? {} : { description })\n\t}\n\n\t// Sets a description on a shape that has a place for one, overriding its own: a keyword\n\t// beside a union describes the field, which outranks what one arm says of itself.\n\t#describe(shape: ContractShape, description: string | undefined): ContractShape {\n\t\tif (description === undefined) return shape\n\t\tswitch (shape.category) {\n\t\t\tcase 'optional':\n\t\t\t\treturn shape\n\t\t\tcase 'nullable':\n\t\t\t\treturn nullableShape(this.#describe(shape.inner, description))\n\t\t\tcase 'raw':\n\t\t\t\treturn rawShape({ ...shape.schema, description })\n\t\t\tdefault:\n\t\t\t\treturn INTRINSICS.freeze({ ...shape, description })\n\t\t}\n\t}\n\n\t#refusal(message: string, first?: string, second?: string, third?: string): ContractError {\n\t\tconst path = pathOf(this.#path, first, second, third)\n\t\treturn new ContractError(\n\t\t\t`schemaToShape: ${message} at ${truncateFaultText(renderPath(path) || 'value', FAULT_SCHEMA_LIMIT)}`,\n\t\t\t{\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path, shape: 'schema' },\n\t\t\t},\n\t\t)\n\t}\n\n\t// The per-node keyword check of a strict conversion. It refuses every keyword the\n\t// lenient walk would read past, so `#build` never drops an assertion: a malformed\n\t// value, a keyword outside the vocabulary, a keyword the node's type never reads,\n\t// and a pair of keywords only one of which the walk would keep.\n\t#inspect(schema: JSONSchema): void {\n\t\tconst keys = INTRINSICS.keys(schema)\n\t\tfor (const index of iterateIndices(() => keys.length)) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) continue\n\t\t\tconst known =\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, STRICT_SCHEMA_KEYWORDS, [\n\t\t\t\t\t(keyword: string) => keyword === key,\n\t\t\t\t]) ||\n\t\t\t\t(key === 'format' && schema.format === 'date')\n\t\t\tif (!known) throw this.#refusal('a strict conversion refuses a keyword it cannot honour', key)\n\t\t}\n\t\tthis.#inspectAnnotations(schema)\n\t\tif (INTRINSICS.own(schema, 'default') && !isJSONValue(schema.default)) {\n\t\t\tthrow this.#refusal('a default must be a JSON value', 'default')\n\t\t}\n\t\tconst types = this.#inspectType(schema)\n\t\tthis.#inspectForm(schema, types)\n\t\tconst hasForm =\n\t\t\tINTRINSICS.own(schema, 'enum') ||\n\t\t\tINTRINSICS.own(schema, 'oneOf') ||\n\t\t\tINTRINSICS.own(schema, 'anyOf')\n\t\tconst object = types.length === 0 && INTRINSICS.own(schema, 'properties') ? ['object'] : types\n\t\tconst effective: readonly string[] = hasForm ? [] : object\n\t\tthis.#confine(schema, ['minLength', 'maxLength', 'format'], this.#names(effective, 'string'))\n\t\tthis.#confine(schema, ['minimum', 'maximum'], this.#names(effective, 'number', 'integer'))\n\t\tthis.#confine(schema, ['items', 'minItems', 'maxItems'], this.#names(effective, 'array'))\n\t\tthis.#confine(\n\t\t\tschema,\n\t\t\t['properties', 'required', 'additionalProperties'],\n\t\t\tthis.#names(effective, 'object'),\n\t\t)\n\t\tthis.#inspectLength(\n\t\t\tINTRINSICS.own(schema, 'minLength') ? schema.minLength : undefined,\n\t\t\tINTRINSICS.own(schema, 'maxLength') ? schema.maxLength : undefined,\n\t\t\t'minLength',\n\t\t\t'maxLength',\n\t\t)\n\t\tthis.#inspectLength(\n\t\t\tINTRINSICS.own(schema, 'minItems') ? schema.minItems : undefined,\n\t\t\tINTRINSICS.own(schema, 'maxItems') ? schema.maxItems : undefined,\n\t\t\t'minItems',\n\t\t\t'maxItems',\n\t\t)\n\t\tthis.#inspectRange(schema, this.#names(effective, 'integer'))\n\t\tthis.#inspectObject(schema)\n\t}\n\n\t#inspectAnnotations(schema: JSONSchema): void {\n\t\tconst texts = ['title', 'description', '$schema', '$id', '$comment']\n\t\tfor (const index of iterateIndices(() => texts.length)) {\n\t\t\tconst keyword = texts[index]\n\t\t\tif (keyword === undefined) continue\n\t\t\tconst value: unknown = INTRINSICS.own(schema, keyword)\n\t\t\t\t? INTRINSICS.reflect.read(schema, keyword)\n\t\t\t\t: undefined\n\t\t\tif (value !== undefined && !isString(value)) {\n\t\t\t\tthrow this.#refusal(`${keyword} must be a string`, keyword)\n\t\t\t}\n\t\t}\n\t\tconst flags = ['deprecated', 'readOnly', 'writeOnly']\n\t\tfor (const index of iterateIndices(() => flags.length)) {\n\t\t\tconst keyword = flags[index]\n\t\t\tif (keyword === undefined) continue\n\t\t\tconst value: unknown = INTRINSICS.own(schema, keyword)\n\t\t\t\t? INTRINSICS.reflect.read(schema, keyword)\n\t\t\t\t: undefined\n\t\t\tif (value !== undefined && !isBoolean(value)) {\n\t\t\t\tthrow this.#refusal(`${keyword} must be a boolean`, keyword)\n\t\t\t}\n\t\t}\n\t\tconst examples: unknown = INTRINSICS.own(schema, 'examples')\n\t\t\t? INTRINSICS.reflect.read(schema, 'examples')\n\t\t\t: undefined\n\t\tif (examples !== undefined && !isArray(examples)) {\n\t\t\tthrow this.#refusal('examples must be an array', 'examples')\n\t\t}\n\t}\n\n\t// The node's type names, an absent keyword reading as none.\n\t#inspectType(schema: JSONSchema): readonly string[] {\n\t\tconst declared: unknown = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\tif (declared === undefined) return []\n\t\tconst names = isArray(declared) ? this.#entries(declared, 'type') : [declared]\n\t\tconst known = names.length > 0 && this.#unique(names)\n\t\tconst types: readonly string[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(JSON_SCHEMA_TYPES),\n\t\t\t[\n\t\t\t\t(type: JSONSchemaType) =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, names, [(name: unknown) => name === type]),\n\t\t\t],\n\t\t)\n\t\tif (!known || types.length !== names.length) {\n\t\t\tthrow this.#refusal('type must name the supported types', 'type')\n\t\t}\n\t\treturn types\n\t}\n\n\t#inspectForm(schema: JSONSchema, types: readonly string[]): void {\n\t\tif (INTRINSICS.own(schema, 'enum')) {\n\t\t\tconst members = this.#entries(schema.enum, 'enum')\n\t\t\tconst malformed = INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(entry: unknown) =>\n\t\t\t\t\tentry !== null &&\n\t\t\t\t\t(!isLiteralValue(entry) || (typeof entry === 'number' && !isFiniteNumber(entry))),\n\t\t\t])\n\t\t\tif (members.length === 0 || malformed || !this.#unique(members)) {\n\t\t\t\tthrow this.#refusal('enum must list unique finite primitives', 'enum')\n\t\t\t}\n\t\t\tconst contradicted = INTRINSICS.reflect.apply(INTRINSICS.some, members, [\n\t\t\t\t(entry: unknown) => types.length > 0 && !this.#fits(entry, types),\n\t\t\t])\n\t\t\tif (contradicted) throw this.#refusal('an enum member contradicts the type', 'enum')\n\t\t\tif (INTRINSICS.own(schema, 'oneOf')) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses oneOf beside enum', 'oneOf')\n\t\t\t}\n\t\t\tif (INTRINSICS.own(schema, 'anyOf')) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses anyOf beside enum', 'anyOf')\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tconst keywords = ['oneOf', 'anyOf']\n\t\tfor (const index of iterateIndices(() => keywords.length)) {\n\t\t\tconst keyword = keywords[index]\n\t\t\tif (keyword === undefined || !INTRINSICS.own(schema, keyword)) continue\n\t\t\tconst variants = this.#entries(INTRINSICS.reflect.read(schema, keyword), keyword)\n\t\t\tif (variants.length === 0) throw this.#refusal(`${keyword} needs a variant`, keyword)\n\t\t\tfor (const variantIndex of iterateIndices(() => variants.length)) {\n\t\t\t\tif (!isRecord(variants[variantIndex])) {\n\t\t\t\t\tthrow this.#refusal(\n\t\t\t\t\t\t'every variant must be a schema',\n\t\t\t\t\t\tkeyword,\n\t\t\t\t\t\tINTRINSICS.text(variantIndex),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst union = INTRINSICS.own(schema, 'oneOf') || INTRINSICS.own(schema, 'anyOf')\n\t\tif (INTRINSICS.own(schema, 'oneOf') && INTRINSICS.own(schema, 'anyOf')) {\n\t\t\tthrow this.#refusal('a strict conversion refuses anyOf beside oneOf', 'anyOf')\n\t\t}\n\t\tif (union && types.length > 0) {\n\t\t\tthrow this.#refusal('a strict conversion refuses type beside a union', 'type')\n\t\t}\n\t}\n\n\t#inspectLength(min: unknown, max: unknown, minKey: string, maxKey: string): void {\n\t\tif (min !== undefined && !(INTRINSICS.safe(min) && INTRINSICS.numeric(min) >= 0)) {\n\t\t\tthrow this.#refusal('a length bound must be a non-negative safe integer', minKey)\n\t\t}\n\t\tif (max !== undefined && !(INTRINSICS.safe(max) && INTRINSICS.numeric(max) >= 0)) {\n\t\t\tthrow this.#refusal('a length bound must be a non-negative safe integer', maxKey)\n\t\t}\n\t\tif (isFiniteNumber(min) && isFiniteNumber(max) && min > max) {\n\t\t\tthrow this.#refusal('a length range may not be contradictory', minKey)\n\t\t}\n\t}\n\n\t#inspectRange(schema: JSONSchema, integer: boolean): void {\n\t\tconst min: unknown = INTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined\n\t\tconst max: unknown = INTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined\n\t\tif (min !== undefined && !isFiniteNumber(min)) {\n\t\t\tthrow this.#refusal('a range bound must be a finite number', 'minimum')\n\t\t}\n\t\tif (max !== undefined && !isFiniteNumber(max)) {\n\t\t\tthrow this.#refusal('a range bound must be a finite number', 'maximum')\n\t\t}\n\t\tif (isFiniteNumber(min) && isFiniteNumber(max)) {\n\t\t\tif (min > max) throw this.#refusal('a range may not be contradictory', 'minimum')\n\t\t\tif (integer && INTRINSICS.ceil(min) > INTRINSICS.floor(max)) {\n\t\t\t\tthrow this.#refusal('an integer range may not be empty', 'minimum')\n\t\t\t}\n\t\t}\n\t}\n\n\t#inspectObject(schema: JSONSchema): void {\n\t\tconst properties: unknown = INTRINSICS.own(schema, 'properties') ? schema.properties : undefined\n\t\tif (properties !== undefined && !isRecord(properties)) {\n\t\t\tthrow this.#refusal('properties must be a plain record', 'properties')\n\t\t}\n\t\tconst extra: unknown = INTRINSICS.own(schema, 'additionalProperties')\n\t\t\t? schema.additionalProperties\n\t\t\t: undefined\n\t\tif (extra !== undefined && !isBoolean(extra) && !isRecord(extra)) {\n\t\t\tthrow this.#refusal(\n\t\t\t\t'additionalProperties must be a boolean or a schema',\n\t\t\t\t'additionalProperties',\n\t\t\t)\n\t\t}\n\t\tif (!INTRINSICS.own(schema, 'required')) return\n\t\tconst names = this.#entries(schema.required, 'required')\n\t\tconst undeclared = INTRINSICS.reflect.apply(INTRINSICS.some, names, [\n\t\t\t(name: unknown) =>\n\t\t\t\t!isString(name) || !isRecord(properties) || !INTRINSICS.own(properties, name),\n\t\t])\n\t\tif (undeclared || !this.#unique(names)) {\n\t\t\tthrow this.#refusal('required must list unique declared properties', 'required')\n\t\t}\n\t}\n\n\t#confine(schema: JSONSchema, keywords: readonly string[], applies: boolean): void {\n\t\tif (applies) return\n\t\tfor (const index of iterateIndices(() => keywords.length)) {\n\t\t\tconst keyword = keywords[index]\n\t\t\tif (keyword !== undefined && INTRINSICS.own(schema, keyword)) {\n\t\t\t\tthrow this.#refusal('a strict conversion refuses a keyword this node never reads', keyword)\n\t\t\t}\n\t\t}\n\t}\n\n\t#names(types: readonly string[], ...names: readonly string[]): boolean {\n\t\treturn INTRINSICS.reflect.apply(INTRINSICS.some, types, [\n\t\t\t(type: string) =>\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, names, [(name: string) => name === type]),\n\t\t])\n\t}\n\n\t#fits(entry: unknown, types: readonly string[]): boolean {\n\t\tif (entry === null) return this.#names(types, 'null')\n\t\tif (isString(entry)) return this.#names(types, 'string')\n\t\tif (isBoolean(entry)) return this.#names(types, 'boolean')\n\t\treturn isInteger(entry) ? this.#names(types, 'number', 'integer') : this.#names(types, 'number')\n\t}\n\n\t#entries(value: unknown, keyword: string): readonly unknown[] {\n\t\tif (!isArray(value)) throw this.#refusal(`${keyword} must be an array`, keyword)\n\t\tconst snapshot = readArrayEntries(value)\n\t\tif (isFailure(snapshot)) throw snapshot.error\n\t\tif (!snapshot.value.dense) throw this.#refusal(`${keyword} must be a dense array`, keyword)\n\t\treturn snapshot.value.entries\n\t}\n\n\t#unique(entries: readonly unknown[]): boolean {\n\t\tconst seen = collectMembers([])\n\t\tfor (const index of iterateIndices(() => entries.length)) {\n\t\t\tconst entry = entries[index]\n\t\t\tif (matchesMember(seen, entry)) return false\n\t\t\tadmitMember(seen, entry)\n\t\t}\n\t\treturn true\n\t}\n\n\t// The per-keyword precedence switch. Every keyword is read defensively — the\n\t// node's static `JSONSchema` type is NOT trusted at runtime — so a malformed\n\t// keyword falls through to the next rule instead of throwing. Precedence,\n\t// top-down:\n\t//\n\t// 0. `$ref` — this walk resolves no reference, and under draft-07 a reference\n\t// replaces its siblings, so nothing beside one can be read and the node widens.\n\t// 1. `enum` — finite string/number/boolean entries become a literal shape, a\n\t// `null` entry wraps it in a nullable, and `null` alone becomes a null shape.\n\t// Any other entry widens the node, because dropping it would narrow. An empty\n\t// list falls through.\n\t// 2. `oneOf` — an array with at least one arm becomes a union over the\n\t// recursively-built arms, provided the arm count is at or under\n\t// `INFER_BREADTH_LIMIT`; OVER the limit, building a subset union would be\n\t// strictly narrower than the schema's full union (a value matching only a\n\t// dropped variant would be wrongly rejected), so the whole node widens to\n\t// `rawShape` instead of sampling a subset. The union is inclusive, because a\n\t// keyword this walk does not read can make two arms overlap that the schema\n\t// keeps apart, and exactly-one over those arms refuses a value the schema\n\t// accepts. A strict walk reads every keyword, so it keeps exactly-one.\n\t// 3. `anyOf` — identically. In both, a `true` arm admits anything and a `false`\n\t// arm admits nothing, so `true` is a raw variant in declaration order and\n\t// `false` is dropped; a list its `false` arms leave empty widens. Two arms, one\n\t// of them `{ type: 'null' }`, read as a nullable of the other, which stays\n\t// outside a union, except under a strict `oneOf`. A description carries.\n\t// 4. Array-valued `type` — distinct recognized names become an inclusive\n\t// union, or a single shape for one name. Two names, one of them `null`, read\n\t// as a nullable of the other, in both modes: the list means what the `anyOf`\n\t// spelling means, and it has no exactly-one to keep. An empty list or any\n\t// unrecognized member widens the whole node; dropping a member would narrow it.\n\t// 5. `type: 'string'` / `'number'` / `'integer'` / `'boolean'` / `'null'` —\n\t// the matching primitive shape, with length/range bounds derived through\n\t// `deriveLengthBounds` / `deriveRangeBounds`. An integer node additionally\n\t// drops its bounds when they describe an EMPTY integer range (for example\n\t// `minimum: 1.5, maximum: 1.6`) — the same emptiness `validateShape`\n\t// rejects — so the result is always a valid shape.\n\t// 6. `type: 'array'` — an array shape whose element shape recurses into a\n\t// record-valued `items`, widening to `rawShape` otherwise, with bounds from\n\t// `minItems` / `maxItems`. A present `prefixItems` widens the elements too,\n\t// because `items` then applies only past the prefix.\n\t// 7. `type: 'object'` — delegates to the object branch. No `type` / `enum` /\n\t// `oneOf` / `anyOf` but a record-valued `properties` — `properties` and\n\t// `required` constrain only an object, so a lenient walk builds a union of\n\t// that object first, for field validation, and every other JSON type. A strict\n\t// walk reads it as an object.\n\t// 8. Everything else — an empty schema, an unrecognized/absent `type`, or\n\t// exhausted depth/breadth — widens to `rawShape`, whose guard accepts every\n\t// defined value and whose emitted schema is the same `{}` (plus\n\t// `description`) the node carried. That is the exact inverse of `{}`, JSON\n\t// Schema's accept-anything schema, and where the inferers themselves bottom\n\t// out at their own limits.\n\t//\n\t// `format` and `pattern` are NEVER read into a lenient walk's shape — `format` is\n\t// annotation-only and compiling an attacker-supplied `pattern` into a `RegExp`\n\t// is a ReDoS vector. A strict walk reads `format: 'date'` on a string node as a\n\t// date string shape. `description`, when a string, carries through to the\n\t// produced shape's `description` option.\n\t#build(schema: JSONSchema, depth: number, enclosed: boolean): ContractShape {\n\t\tthis.#built += 1\n\t\tconst description =\n\t\t\tINTRINSICS.own(schema, 'description') && isString(schema.description)\n\t\t\t\t? schema.description\n\t\t\t\t: undefined\n\n\t\tif (INTRINSICS.own(schema, '$ref')) {\n\t\t\treturn this.#widen('a reference is not resolved', description, '$ref')\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'enum') && isArray(schema.enum)) {\n\t\t\tconst observed = INTRINSICS.from(\n\t\t\t\titerateIndices(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'enum']).length,\n\t\t\t\t),\n\t\t\t\t(index) =>\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'enum'])[index],\n\t\t\t)\n\t\t\tconst widened = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t(entry: unknown) =>\n\t\t\t\t\tentry !== null &&\n\t\t\t\t\t(!isLiteralValue(entry) || (typeof entry === 'number' && !isFiniteNumber(entry))),\n\t\t\t])\n\t\t\tif (widened) return this.#widen('an enum entry has no literal form', description, 'enum')\n\t\t\tconst valid: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(observed),\n\t\t\t\t[(entry: unknown) => entry !== null],\n\t\t\t)\n\t\t\tconst nullable = valid.length < observed.length\n\t\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(valid), [\n\t\t\t\t(entry: LiteralValue, index: number) => [\n\t\t\t\t\t`${typeof entry}:${INTRINSICS.text(entry)}`,\n\t\t\t\t\tindex,\n\t\t\t\t],\n\t\t\t])\n\t\t\tconst reversed = INTRINSICS.reflect.apply(INTRINSICS.flip, pairs, [])\n\t\t\tconst first = INTRINSICS.record<number>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\treversed,\n\t\t\t\t]),\n\t\t\t})\n\t\t\tconst literals: readonly LiteralValue[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(valid),\n\t\t\t\t[\n\t\t\t\t\t(entry: LiteralValue, index: number) =>\n\t\t\t\t\t\tfirst[`${typeof entry}:${INTRINSICS.text(entry)}`] === index,\n\t\t\t\t],\n\t\t\t)\n\t\t\tif (literals.length > 0) {\n\t\t\t\tconst literal = literalShape(\n\t\t\t\t\tliterals,\n\t\t\t\t\tdescription === undefined ? undefined : { description },\n\t\t\t\t)\n\t\t\t\treturn nullable ? nullableShape(literal) : literal\n\t\t\t}\n\t\t\tif (nullable) return nullShape(description === undefined ? undefined : { description })\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'oneOf') && isArray(schema.oneOf)) {\n\t\t\tconst union = this.#buildUnion(schema.oneOf, 'oneOf', depth, description, enclosed)\n\t\t\tif (union !== undefined) return union\n\t\t}\n\n\t\tif (INTRINSICS.own(schema, 'anyOf') && isArray(schema.anyOf)) {\n\t\t\tconst union = this.#buildUnion(schema.anyOf, 'anyOf', depth, description, enclosed)\n\t\t\tif (union !== undefined) return union\n\t\t}\n\n\t\tconst category = INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\t\tif (isArray(category)) {\n\t\t\tconst observed = INTRINSICS.from(parseEnumValues(category, JSON_SCHEMA_TYPES))\n\t\t\tif (\n\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t\t\t(entry: JSONSchemaType | undefined) => entry === undefined,\n\t\t\t\t])\n\t\t\t) {\n\t\t\t\treturn this.#widen('type must name the supported types', description, 'type')\n\t\t\t}\n\t\t\tconst members: readonly JSONSchemaType[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(observed),\n\t\t\t\t[\n\t\t\t\t\t(member: JSONSchemaType, index: number) =>\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.find, observed, [\n\t\t\t\t\t\t\t(entry: unknown) => entry === member,\n\t\t\t\t\t\t]) === index,\n\t\t\t\t],\n\t\t\t)\n\t\t\tif (members.length === 0 || members.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn this.#widen('type must name the supported types', description, 'type')\n\t\t\t}\n\t\t\tconst others: readonly JSONSchemaType[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.select,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[(member: JSONSchemaType) => member !== 'null'],\n\t\t\t)\n\t\t\tconst other = others[0]\n\t\t\tif (members.length === 2 && others.length === 1 && other !== undefined) {\n\t\t\t\treturn nullableShape(this.#build({ ...schema, type: other }, depth, enclosed))\n\t\t\t}\n\t\t\tconst variants: readonly ContractShape[] = INTRINSICS.reflect.apply(\n\t\t\t\tINTRINSICS.project,\n\t\t\t\treadIndexView(members),\n\t\t\t\t[\n\t\t\t\t\t(member: JSONSchemaType) =>\n\t\t\t\t\t\tthis.#build({ ...schema, type: member }, depth, enclosed || members.length > 1),\n\t\t\t\t],\n\t\t\t)\n\t\t\tconst first = variants[0]\n\t\t\tif (variants.length === 1 && first !== undefined) return first\n\t\t\tconst union = INTRINSICS.reflect.apply(unionShape, undefined, variants)\n\t\t\treturn description === undefined ? union : INTRINSICS.freeze({ ...union, description })\n\t\t}\n\n\t\tconst type = isString(category) && INTRINSICS.own(schema, 'type') ? schema.type : undefined\n\n\t\tif (type === 'string') {\n\t\t\tconst bounds = deriveLengthBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minLength') ? schema.minLength : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maxLength') ? schema.maxLength : undefined,\n\t\t\t)\n\t\t\t// A lenient walk keeps `format` an annotation, as JSON Schema's default does, so\n\t\t\t// a foreign schema's own answers are never refused; only a strict walk asserts it.\n\t\t\tconst formatted = this.#strict && INTRINSICS.own(schema, 'format') && schema.format === 'date'\n\t\t\tconst dated =\n\t\t\t\tformatted && (bounds.min ?? 0) <= DATE_LENGTH && (bounds.max ?? DATE_LENGTH) >= DATE_LENGTH\n\t\t\tif (formatted && !dated) {\n\t\t\t\tthrow this.#refusal(`a date length range must admit length ${DATE_LENGTH}`, 'format')\n\t\t\t}\n\t\t\t// Builder options admit inherited values; this projection must carry only\n\t\t\t// the schema's own keywords, without reacquiring prototype data.\n\t\t\treturn stringShape(\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(dated ? { date: true } : {}),\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'number') {\n\t\t\tconst bounds = deriveRangeBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined,\n\t\t\t)\n\t\t\treturn numberShape(\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'integer') {\n\t\t\tconst bounds = deriveRangeBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minimum') ? schema.minimum : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maximum') ? schema.maximum : undefined,\n\t\t\t)\n\t\t\tconst emptyRange =\n\t\t\t\tINTRINSICS.ceil(bounds.min ?? Number.NEGATIVE_INFINITY) >\n\t\t\t\tINTRINSICS.floor(bounds.max ?? Number.POSITIVE_INFINITY)\n\t\t\treturn integerShape(\n\t\t\t\temptyRange\n\t\t\t\t\t? description === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: INTRINSICS.rebase({ description }, null)\n\t\t\t\t\t: INTRINSICS.rebase(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tif (type === 'boolean') {\n\t\t\treturn booleanShape(description === undefined ? undefined : { description })\n\t\t}\n\t\tif (type === 'null') {\n\t\t\treturn nullShape(description === undefined ? undefined : { description })\n\t\t}\n\n\t\tif (type === 'array') {\n\t\t\tconst items = INTRINSICS.own(schema, 'prefixItems')\n\t\t\t\t? rawShape({})\n\t\t\t\t: INTRINSICS.own(schema, 'items') && isRecord(schema.items)\n\t\t\t\t\t? this.#descend(schema.items, depth - 1, enclosed, 'items')\n\t\t\t\t\t: this.#widen('an array needs an items schema', undefined, 'items')\n\t\t\tconst bounds = deriveLengthBounds(\n\t\t\t\tINTRINSICS.own(schema, 'minItems') ? schema.minItems : undefined,\n\t\t\t\tINTRINSICS.own(schema, 'maxItems') ? schema.maxItems : undefined,\n\t\t\t)\n\t\t\treturn arrayShape(\n\t\t\t\titems,\n\t\t\t\tINTRINSICS.rebase(\n\t\t\t\t\t{\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\tif (\n\t\t\ttype === 'object' ||\n\t\t\t(this.#strict &&\n\t\t\t\ttype === undefined &&\n\t\t\t\tINTRINSICS.own(schema, 'properties') &&\n\t\t\t\tisRecord(schema.properties))\n\t\t) {\n\t\t\treturn this.#buildObject(schema, depth, description, enclosed)\n\t\t}\n\t\tif (type === undefined && INTRINSICS.own(schema, 'properties') && isRecord(schema.properties)) {\n\t\t\treturn this.#describe(\n\t\t\t\tunionShape(\n\t\t\t\t\tthis.#buildObject(schema, depth, undefined, true),\n\t\t\t\t\tstringShape(),\n\t\t\t\t\tnumberShape(),\n\t\t\t\t\tbooleanShape(),\n\t\t\t\t\tnullShape(),\n\t\t\t\t\tarrayShape(rawShape({})),\n\t\t\t\t),\n\t\t\t\tdescription,\n\t\t\t)\n\t\t}\n\n\t\treturn this.#widen('a schema must name a type, an enum, or a union', description)\n\t}\n\n\t// One union keyword's arms, in declaration order. Answers `undefined` for a list\n\t// with no arm and no `false` entry, so a malformed keyword falls through.\n\t#buildUnion(\n\t\tlist: readonly unknown[],\n\t\tkeyword: 'oneOf' | 'anyOf',\n\t\tdepth: number,\n\t\tdescription: string | undefined,\n\t\tenclosed: boolean,\n\t): ContractShape | undefined {\n\t\tconst observed = INTRINSICS.from(\n\t\t\titerateIndices(() => list.length),\n\t\t\t(index) => list[index],\n\t\t)\n\t\tconst arms: ReadonlyArray<JSONSchema | true> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(observed),\n\t\t\t[(entry: unknown) => entry === true || isRecord(entry)],\n\t\t)\n\t\tif (arms.length > INFER_BREADTH_LIMIT) {\n\t\t\treturn this.#widen(`${keyword} exceeds the breadth limit`, description, keyword)\n\t\t}\n\t\tconst nulls: ReadonlyArray<JSONSchema | true> = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.select,\n\t\t\treadIndexView(arms),\n\t\t\t[\n\t\t\t\t(entry: JSONSchema | true) =>\n\t\t\t\t\tentry !== true &&\n\t\t\t\t\tINTRINSICS.own(entry, 'type') &&\n\t\t\t\t\tentry.type === 'null' &&\n\t\t\t\t\t!INTRINSICS.own(entry, '$ref') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'enum') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'oneOf') &&\n\t\t\t\t\t!INTRINSICS.own(entry, 'anyOf'),\n\t\t\t],\n\t\t)\n\t\tconst hasTrue = INTRINSICS.reflect.apply(INTRINSICS.some, arms, [\n\t\t\t(entry: JSONSchema | true) => entry === true,\n\t\t])\n\t\tconst paired =\n\t\t\tarms.length === 2 && nulls.length === 1 && !hasTrue && !(this.#strict && keyword === 'oneOf')\n\t\tconst exclusive = this.#strict && keyword === 'oneOf' ? 1 : 0\n\t\tthis.#oneOfs += exclusive\n\t\tconst variants: readonly ContractShape[] = INTRINSICS.reflect.apply(\n\t\t\tINTRINSICS.project,\n\t\t\treadIndexView(arms),\n\t\t\t[\n\t\t\t\t(entry: JSONSchema | true, index: number) => {\n\t\t\t\t\tif (entry !== true) {\n\t\t\t\t\t\tconst position = paired ? enclosed : true\n\t\t\t\t\t\treturn this.#descend(entry, depth - 1, position, keyword, INTRINSICS.text(index))\n\t\t\t\t\t}\n\t\t\t\t\tthis.#built += 1\n\t\t\t\t\treturn rawShape({})\n\t\t\t\t},\n\t\t\t],\n\t\t)\n\t\tthis.#oneOfs -= exclusive\n\t\tconst other = variants[arms[0] === nulls[0] ? 1 : 0]\n\t\tif (paired && other !== undefined) {\n\t\t\treturn nullableShape(this.#describe(other, description))\n\t\t}\n\t\t// `Reflect.apply` reads its argument list by index, where a spread call\n\t\t// would dispatch through the caller-writable array iterator.\n\t\tif (variants.length > 0) {\n\t\t\tconst build = this.#strict && keyword === 'oneOf' ? oneOfShape : unionShape\n\t\t\treturn this.#describe(INTRINSICS.reflect.apply(build, undefined, variants), description)\n\t\t}\n\t\tconst dropped = INTRINSICS.reflect.apply(INTRINSICS.some, observed, [\n\t\t\t(entry: unknown) => entry === false,\n\t\t])\n\t\treturn dropped ? this.#widen(`${keyword} admits nothing`, description, keyword) : undefined\n\t}\n\n\t// The object-specialized branch. `properties` (when a record) contributes one\n\t// child shape per own key, capped at `INFER_BREADTH_LIMIT`; a key is wrapped\n\t// in `optionalShape` unless it appears as a string entry of `required`. A\n\t// property whose value is not itself a record widens to `rawShape`.\n\t// `additionalProperties`: `false` closes the object; a record value recurses\n\t// into it (`objectShape` validates extras against that shape); anything else —\n\t// `true`, absent, or malformed — leaves the object OPEN (`true`), matching\n\t// JSON Schema's own absent-means-open default and the fact that the inference\n\t// doors always emit the keyword explicitly, so an absent value only arises\n\t// from a hand-written schema. When `properties` has MORE keys than\n\t// `INFER_BREADTH_LIMIT`, the schema's own `additionalProperties` is OVERRIDDEN\n\t// and forced to `true` (fully open) — a dropped key's value could otherwise\n\t// fail a `false` or record-valued rest shape it was never checked against —\n\t// mirroring the record inference's partial-key handling. The accumulator uses\n\t// a null-prototype record so a property literally named `__proto__` becomes an\n\t// own data key rather than mutating the prototype. A present `patternProperties`\n\t// opens the object whatever its own `additionalProperties` says, because a key\n\t// that keyword admits is unread here; `propertyNames` exempts no key from\n\t// `additionalProperties`, so it opens nothing. A strict conversion refuses the\n\t// truncation and closes an object whose schema is silent, except below a `oneOf`,\n\t// where closing it could change which arms match, so it refuses that too.\n\t#buildObject(\n\t\tschema: JSONSchema,\n\t\tdepth: number,\n\t\tdescription: string | undefined,\n\t\tenclosed: boolean,\n\t): ContractShape {\n\t\tif (this.#oneOfs > 0 && !INTRINSICS.own(schema, 'additionalProperties')) {\n\t\t\tthrow this.#refusal(\n\t\t\t\t'an object below a oneOf must declare additionalProperties, because closing it could change which arms match',\n\t\t\t\t'additionalProperties',\n\t\t\t)\n\t\t}\n\t\tconst propertiesSource =\n\t\t\tINTRINSICS.own(schema, 'properties') && isRecord(schema.properties)\n\t\t\t\t? schema.properties\n\t\t\t\t: undefined\n\t\tconst requiredSource =\n\t\t\tINTRINSICS.own(schema, 'required') && isArray(schema.required)\n\t\t\t\t? INTRINSICS.from(\n\t\t\t\t\t\titerateIndices(\n\t\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'required'])\n\t\t\t\t\t\t\t\t\t.length,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t(index) =>\n\t\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.reflect.read, undefined, [schema, 'required'])[\n\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t],\n\t\t\t\t\t)\n\t\t\t\t: []\n\t\tconst allKeys = propertiesSource === undefined ? [] : INTRINSICS.keys(propertiesSource)\n\t\tconst truncated = allKeys.length > INFER_BREADTH_LIMIT\n\t\tif (this.#strict && truncated) {\n\t\t\tthrow this.#refusal('properties exceeds the breadth limit', 'properties')\n\t\t}\n\t\tconst keys = limitEntries(allKeys, INFER_BREADTH_LIMIT)\n\t\tconst extra = INTRINSICS.own(schema, 'additionalProperties')\n\t\t\t? schema.additionalProperties\n\t\t\t: undefined\n\t\tconst unread = truncated || INTRINSICS.own(schema, 'patternProperties')\n\t\tconst open = unread || (extra !== false && (!this.#strict || extra !== undefined))\n\t\tconst pairs = INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keys), [\n\t\t\t(key: string) => {\n\t\t\t\tconst child =\n\t\t\t\t\tpropertiesSource !== undefined && INTRINSICS.own(propertiesSource, key)\n\t\t\t\t\t\t? propertiesSource[key]\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst childShape = isRecord(child)\n\t\t\t\t\t? this.#descend(child, depth - 1, enclosed, 'properties', key)\n\t\t\t\t\t: this.#widen(\n\t\t\t\t\t\t\t'every property schema must be a plain record',\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t'properties',\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t)\n\t\t\t\tconst required = INTRINSICS.reflect.apply(INTRINSICS.some, requiredSource, [\n\t\t\t\t\t(entry: unknown) => isString(entry) && entry === key,\n\t\t\t\t])\n\t\t\t\tif (!required) return [key, this.#wrap(key, child, childShape, open || enclosed)]\n\t\t\t\tif (this.#strict && isRecord(child) && INTRINSICS.own(child, 'default')) {\n\t\t\t\t\tthrow this.#refusal(\n\t\t\t\t\t\t'a default needs an optional property to fill',\n\t\t\t\t\t\t'properties',\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t'default',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn [key, childShape]\n\t\t\t},\n\t\t])\n\t\tconst properties = INTRINSICS.rebase(\n\t\t\tINTRINSICS.record<ContractShape>({\n\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [pairs]),\n\t\t\t}),\n\t\t\tnull,\n\t\t)\n\t\tconst additionalProperties: boolean | ContractShape = unread\n\t\t\t? true\n\t\t\t: isRecord(extra)\n\t\t\t\t? this.#descend(extra, depth - 1, enclosed, 'additionalProperties')\n\t\t\t\t: open\n\t\treturn INTRINSICS.freeze({\n\t\t\tcategory: 'object',\n\t\t\tproperties: INTRINSICS.freeze(properties),\n\t\t\tadditionalProperties,\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t})\n\t}\n\n\t// The one place a schema's `default` becomes a shape's. The lenient walk stays total\n\t// by carrying only what can compile: a primitive or literal the property's guard\n\t// accepts, in a slot that can fill. The strict walk carries any default, and refuses\n\t// one the guard refuses or a slot that cannot fill, naming the path in the schema.\n\t#wrap(\n\t\tkey: string,\n\t\tchild: JSONSchema | undefined,\n\t\tshape: ContractShape,\n\t\tsealed: boolean,\n\t): OptionalShape {\n\t\tthis.#built += 1\n\t\tif (!isRecord(child) || !INTRINSICS.own(child, 'default')) return optionalShape(shape)\n\t\tconst value = child.default\n\t\tif (!isJSONValue(value)) return optionalShape(shape)\n\t\tif (this.#strict) {\n\t\t\tif (sealed) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'schemaToShape: a default cannot fill under a union or on a property of an open object; close the object or remove the default',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'placement',\n\t\t\t\t\t\tcontext: { path: pathOf(this.#path, 'properties', key, 'default'), shape: 'schema' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (new ContractCompiler(shape).guard(value)) return optionalShape(shape, { default: value })\n\t\t\tthrow this.#refusal('a default must satisfy its schema', 'properties', key, 'default')\n\t\t}\n\t\tconst leaf =\n\t\t\tshape.category === 'string' ||\n\t\t\tshape.category === 'number' ||\n\t\t\tshape.category === 'boolean' ||\n\t\t\tshape.category === 'null' ||\n\t\t\tshape.category === 'literal'\n\t\treturn !sealed && leaf && new ContractCompiler(shape).guard(value)\n\t\t\t? optionalShape(shape, { default: value })\n\t\t\t: optionalShape(shape)\n\t}\n}\n","import type { AuditFaultShape } from './types.js'\nimport { FAULT_CONSTRAINTS, FAULT_KINDS } from './constants.js'\nimport { pinMembers } from './helpers.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnumberShape,\n\tobjectShape,\n\toptionalShape,\n\tstringShape,\n\tunionShape,\n} from './shapers.js'\n\n/**\n * Retains a lazily built fault declaration without building shapes during module evaluation.\n *\n * @example\n * ```ts\n * FaultShaper.shape === FaultShaper.shape // true\n * ```\n */\nexport class FaultShaper {\n\tstatic #shape: AuditFaultShape | undefined\n\n\t/** Returns the shared fault declaration, building it on the first read. */\n\tstatic get shape(): AuditFaultShape {\n\t\treturn (FaultShaper.#shape ??= new FaultShaper().build())\n\t}\n\n\t/**\n\t * Builds a closed fault union whose inferred values satisfy the audit fault contract.\n\t *\n\t * @example\n\t * ```ts\n\t * createContract(new FaultShaper().build()).is({ reason: 'extra', path: [] }) // true\n\t * ```\n\t */\n\tbuild() {\n\t\tconst path = unionShape(stringShape(), arrayShape(stringShape()))\n\t\tconst expected = literalShape(FAULT_KINDS)\n\t\tconst hints = arrayShape(unionShape(stringShape(), numberShape(), booleanShape()))\n\t\treturn unionShape(\n\t\t\tobjectShape({ reason: literalShape(['type']), path, expected, received: stringShape() }),\n\t\t\tobjectShape({ reason: literalShape(['missing']), path, expected }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['constraint']),\n\t\t\t\tpath,\n\t\t\t\texpected,\n\t\t\t\tconstraint: literalShape(FAULT_CONSTRAINTS),\n\t\t\t\tlimit: optionalShape(unionShape(numberShape(), stringShape())),\n\t\t\t\treceived: stringShape(),\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['variant']), path, variants: integerShape({ min: 0 }) }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['variant']),\n\t\t\t\tpath,\n\t\t\t\tvariants: integerShape({ min: 0 }),\n\t\t\t\tkey: stringShape(),\n\t\t\t\texpected: hints,\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['oneOf']), path, matched: integerShape({ min: 0 }) }),\n\t\t\tobjectShape({\n\t\t\t\treason: literalShape(['oneOf']),\n\t\t\t\tpath,\n\t\t\t\tmatched: integerShape({ min: 0 }),\n\t\t\t\tkey: stringShape(),\n\t\t\t\texpected: hints,\n\t\t\t}),\n\t\t\tobjectShape({ reason: literalShape(['extra']), path }),\n\t\t)\n\t}\n\n\tstatic {\n\t\tpinMembers(FaultShaper.prototype, 'FaultShaper')\n\t}\n}\n","import type {\n\tArrayShape,\n\tAuditFaultShape,\n\tArrayShapeOptions,\n\tBooleanShape,\n\tBooleanShapeOptions,\n\tContractShape,\n\tJSONSchema,\n\tJSONShape,\n\tJSONShapeOptions,\n\tLiteralShape,\n\tLiteralShapeOptions,\n\tLiteralValue,\n\tNullableShape,\n\tNullShape,\n\tNullShapeOptions,\n\tNumberShape,\n\tNumberShapeOptions,\n\tObjectShape,\n\tObjectShapeOptions,\n\tOptionalShape,\n\tOptionalShapeOptions,\n\tRawShape,\n\tRecordShapeOptions,\n\tSchemaToShapeOptions,\n\tShapeShape,\n\tShapeShapeOptions,\n\tStringShape,\n\tStringShapeOptions,\n\tUnionShape,\n} from './types.js'\nimport { cloneJSONValue, cloneSchema, cloneShape } from './cloners.js'\nimport { SchemaShaper } from './SchemaShaper.js'\nimport { ShapePass } from './ShapePass.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { FaultShaper } from './FaultShaper.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\treadIndexView,\n\titerateIndices,\n\tattempt,\n\tcontain,\n\tisFailure,\n\tisSuccess,\n\tmatchesRecordBrand,\n\tpreview,\n\treadArrayEntries,\n\treadOptions,\n\treadPatternFlags,\n\treadPatternSource,\n\treadValue,\n\trefuseOptionKeys,\n} from './helpers.js'\nimport { isJSONValue, isLiteralValue, isObject, isRegExp } from './validators.js'\nimport { ContractError, isContractError } from './errors.js'\n\n/**\n * Returns the shared closed audit-fault shape, building it on the first call.\n *\n * @remarks\n * Numeric bounds, counts, and discriminator literals must be finite. Discriminator hints\n * carry both key and expected together. The inferred union is assignable to AuditFault.\n *\n * @example\n * ```ts\n * createContract(auditFaultShape()).is({ reason: 'extra', path: ['typo'] }) // true\n * ```\n */\nexport function auditFaultShape(): AuditFaultShape {\n\treturn contain(() => FaultShaper.shape, 'auditFaultShape')\n}\n\n// The builders return the parameterized types.ts interfaces (for example `ArrayShape<S>`,\n// `ObjectShape<P>`), never inline object literals — the generic parameter keeps\n// `Infer<typeof shape>` exact while the return type still enforces conformance to\n// the shared shape interface.\n\n// Shape builders — pure constructors for the `ContractShape` union. Each returns\n// a plain descriptor; the compilers (compilers.ts) turn it into a guard, parser,\n// schema, and generator. The precise return types (for example literal tuples, generic\n// `items` / `properties`) are preserved so `Infer<typeof shape>` stays exact.\n\n// === Primitives\n\n/**\n * Builds a string {@link StringShape}.\n *\n * @remarks\n * A supplied pattern is captured by source and flags. The shape exposes a fresh\n * frozen zero-state `RegExp` on every `pattern` read, so neither the caller's\n * original nor a value read from the shape can drift later compiled artifacts.\n * `date: true` restricts the string to a calendar-valid `YYYY-MM-DD`, as\n * {@link dateShape} builds it.\n *\n * @param options - Optional length (`min` / `max`), `pattern`, `date`, and `description`\n * @returns A string shape\n * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, `pattern` has flags, `date` is not a boolean, or `date` meets `pattern` or a bound that excludes length 10\n *\n * @example\n * ```ts\n * const name = stringShape({ min: 1, max: 80, description: 'Display name' })\n * ```\n */\nexport function stringShape(options?: StringShapeOptions): StringShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['min', 'max', 'pattern', 'date', 'description'],\n\t\t\t'stringShape',\n\t\t\t'string',\n\t\t)\n\t\tconst pattern = safe?.pattern\n\t\tif (safe?.min !== undefined && (!INTRINSICS.safe(safe.min) || safe.min < 0)) {\n\t\t\tthrow new ContractError('stringShape: min must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'string',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.min),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && (!INTRINSICS.safe(safe.max) || safe.max < 0)) {\n\t\t\tthrow new ContractError('stringShape: max must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'string',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.max),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (pattern !== undefined && !isRegExp(pattern)) {\n\t\t\tthrow new ContractError('stringShape: pattern must be a RegExp', {\n\t\t\t\tcode: 'pattern',\n\t\t\t\tcontext: { shape: 'string', received: typeof pattern },\n\t\t\t})\n\t\t}\n\t\tconst patternSnapshot =\n\t\t\tpattern === undefined\n\t\t\t\t? undefined\n\t\t\t\t: readValue(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t// Source and flags through the CAPTURED accessors, and the\n\t\t\t\t\t\t\t// rendered text built from them rather than through\n\t\t\t\t\t\t\t// `RegExp.prototype.toString`: all three are caller-writable\n\t\t\t\t\t\t\t// members, and this snapshot decides both the pattern a published\n\t\t\t\t\t\t\t// shape carries and the text a refusal quotes back.\n\t\t\t\t\t\t\tconst source = readPatternSource(pattern)\n\t\t\t\t\t\t\tconst flags = readPatternFlags(pattern)\n\t\t\t\t\t\t\tif (source === undefined || flags === undefined) {\n\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('Pattern source and flags could not be read')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn { source, flags, text: `/${source}/${flags}` }\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'stringShape',\n\t\t\t\t\t\t{ subject: 'pattern', code: 'pattern', context: { shape: 'string' } },\n\t\t\t\t\t)\n\t\tif (patternSnapshot !== undefined && patternSnapshot.flags.length > 0) {\n\t\t\tthrow new ContractError(\n\t\t\t\t'stringShape: pattern must not use flags; use inline pattern constructs instead',\n\t\t\t\t{\n\t\t\t\t\tcode: 'pattern',\n\t\t\t\t\tcontext: { shape: 'string', received: patternSnapshot.text },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst shape: StringShape = {\n\t\t\tcategory: 'string',\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(patternSnapshot === undefined\n\t\t\t\t? {}\n\t\t\t\t: { pattern: new INTRINSICS.pattern(patternSnapshot.source) }),\n\t\t\t// A `false` flag reads as absent, and any other value stays for the seal to refuse.\n\t\t\t...(safe?.date === undefined || safe.date === false ? {} : { date: safe.date }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\t// The snapshot is what refuses a field inherited as `undefined`, which a walk reads\n\t\t// as absent, so only a clean prototype lets a plain node skip it.\n\t\tif (patternSnapshot === undefined && !ShapePass.polluted()) return ShapePass.seal(shape)\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn ShapePass.seal(cloneShape(shape))\n\t}, 'stringShape')\n}\n\n/**\n * Builds a numeric {@link NumberShape}.\n *\n * @remarks\n * A present `min` or `max` must be finite. `NaN` and `±Infinity` throw a `bound` {@link\n * ContractError} at construction, because no finite value satisfies them and no JSON\n * Schema keyword expresses them.\n *\n * @param options - Optional bounds (`min` / `max`), `integer`, and `description`\n * @returns A number shape\n * @throws {ContractError} When a present bound is not finite\n *\n * @example\n * ```ts\n * const age = numberShape({ min: 0, max: 120 })\n * ```\n */\nexport function numberShape(options?: NumberShapeOptions): NumberShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['min', 'max', 'integer', 'description'],\n\t\t\t'numberShape',\n\t\t\t'number',\n\t\t)\n\t\tconst shape = safe?.integer === true ? 'integer' : 'number'\n\t\tif (safe?.min !== undefined && !INTRINSICS.finite(safe.min)) {\n\t\t\tthrow new ContractError('numberShape: min must be finite', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: { shape, limit: 'finite number', received: preview(safe.min) },\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && !INTRINSICS.finite(safe.max)) {\n\t\t\tthrow new ContractError('numberShape: max must be finite', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: { shape, limit: 'finite number', received: preview(safe.max) },\n\t\t\t})\n\t\t}\n\t\tconst result: NumberShape = {\n\t\t\tcategory: 'number',\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(safe?.integer === undefined ? {} : { integer: safe.integer }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(result)\n\t}, 'numberShape')\n}\n\n/**\n * Builds an integer {@link NumberShape} — forces `integer: true`.\n *\n * @remarks\n * The emitted JSON Schema uses `\"type\": \"integer\"` and the guard rejects\n * fractional numbers.\n *\n * @param options - Optional bounds and `description` (no `integer` key)\n * @returns An integer number shape\n * @throws {ContractError} When a present bound is not finite\n */\nexport function integerShape(options?: Omit<NumberShapeOptions, 'integer'>): NumberShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'description'], 'integerShape', 'integer')\n\t\treturn numberShape({ ...safe, integer: true })\n\t}, 'integerShape')\n}\n\n/**\n * Builds a calendar-date {@link StringShape} — forces `date: true`.\n *\n * @remarks\n * The guard and the parser admit exactly a calendar-valid `YYYY-MM-DD` and coerce\n * nothing, so `2026-02-30`, `2026-1-10`, and a date-time all refuse. The emitted JSON\n * Schema carries `\"format\": \"date\"`. Options other than `min`, `max`, and `description`\n * refuse, because a dropped `pattern` would widen the shape.\n *\n * @param options - Optional length bounds and `description` (no `date` or `pattern` key)\n * @returns A date string shape\n * @throws {ContractError} When an option key is unknown, or a present bound is invalid or excludes length 10\n *\n * @example\n * ```ts\n * createContract(dateShape()).is('2024-02-29') // true\n * ```\n */\nexport function dateShape(options?: Omit<StringShapeOptions, 'date' | 'pattern'>): StringShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'description'], 'dateShape', 'string')\n\t\trefuseOptionKeys(options, ['min', 'max', 'description'], 'dateShape', 'string')\n\t\treturn stringShape({ ...safe, date: true })\n\t}, 'dateShape')\n}\n\n/**\n * Builds a {@link BooleanShape}.\n *\n * @param options - Optional `description`\n * @returns A boolean shape\n *\n * @example\n * ```ts\n * const active = booleanShape({ description: 'Whether the record is active' })\n * ```\n */\nexport function booleanShape(options?: BooleanShapeOptions): BooleanShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'booleanShape', 'boolean')\n\t\tconst shape: BooleanShape = {\n\t\t\tcategory: 'boolean',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'booleanShape')\n}\n\n/**\n * Builds a {@link NullShape}.\n *\n * @param options - Optional `description`\n * @returns A null shape\n *\n * @example\n * ```ts\n * const empty = nullShape()\n * ```\n */\nexport function nullShape(options?: NullShapeOptions): NullShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'nullShape', 'null')\n\t\tconst shape: NullShape = {\n\t\t\tcategory: 'null',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'nullShape')\n}\n\n/**\n * Builds a literal shape from a fixed set of primitive values.\n *\n * @param values - The permitted literals\n * @param options - Optional `description`\n * @returns A literal shape whose `Infer` is the union of `values`\n *\n * @example\n * ```ts\n * const role = literalShape(['admin', 'member', 'guest'])\n * // Infer<typeof role> = 'admin' | 'member' | 'guest'\n *\n * const via = literalShape(['function', 'tool', 'agent'], { description: 'How to run the step.' })\n * ```\n */\nexport function literalShape<const T extends readonly LiteralValue[]>(\n\tvalues: T,\n\toptions?: LiteralShapeOptions,\n): LiteralShape<Readonly<T>>\nexport function literalShape(\n\tvalues: readonly LiteralValue[],\n\toptions?: LiteralShapeOptions,\n): LiteralShape {\n\treturn contain(() => {\n\t\tconst input: unknown = values\n\t\tconst array = attempt(() => INTRINSICS.array(input))\n\t\tif (isFailure(array) || !array.value) {\n\t\t\tthrow new ContractError('literalShape: values must be an array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t\t...(isFailure(array) ? { cause: array.error } : {}),\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(options, ['description'], 'literalShape', 'literal')\n\t\tconst snapshot = readArrayEntries(values)\n\t\tif (isFailure(snapshot)) {\n\t\t\tthrow new ContractError('literalShape: values could not be copied', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t\tcause: snapshot.error,\n\t\t\t})\n\t\t}\n\t\tif (!snapshot.value.dense) {\n\t\t\tthrow new ContractError('validateShape: values must be a dense data array', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['values'], shape: 'literal' },\n\t\t\t})\n\t\t}\n\t\tconst literals = INTRINSICS.from(\n\t\t\titerateIndices(() => snapshot.value.entries.length),\n\t\t\t(index) => {\n\t\t\t\tconst value = snapshot.value.entries[index]\n\t\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\t\tthrow new ContractError(\n\t\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\t\tcontext: { path: ['values', INTRINSICS.text(index)], shape: 'literal' },\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn value\n\t\t\t},\n\t\t)\n\t\tconst owned = INTRINSICS.freeze(literals)\n\t\tconst shape: LiteralShape = {\n\t\t\tcategory: 'literal',\n\t\t\tvalues: owned,\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'literalShape')\n}\n\n// === Collections\n\n/**\n * Builds an {@link ArrayShape} from an element shape.\n *\n * @param items - The element shape\n * @param options - Optional length bounds and `description`\n * @returns An array shape\n * @throws {ContractError} When a present bound is not a non-negative safe integer\n *\n * @example\n * ```ts\n * const tags = arrayShape(stringShape(), { max: 10 })\n * ```\n */\nexport function arrayShape<S extends ContractShape>(\n\titems: S,\n\toptions?: ArrayShapeOptions,\n): ArrayShape<S> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['min', 'max', 'description'], 'arrayShape', 'array')\n\t\tif (safe?.min !== undefined && (!INTRINSICS.safe(safe.min) || safe.min < 0)) {\n\t\t\tthrow new ContractError('arrayShape: min must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'array',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.min),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (safe?.max !== undefined && (!INTRINSICS.safe(safe.max) || safe.max < 0)) {\n\t\t\tthrow new ContractError('arrayShape: max must be a non-negative safe integer', {\n\t\t\t\tcode: 'bound',\n\t\t\t\tcontext: {\n\t\t\t\t\tshape: 'array',\n\t\t\t\t\tlimit: 'non-negative safe integer',\n\t\t\t\t\treceived: preview(safe.max),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tconst shape: ArrayShape<S> = {\n\t\t\tcategory: 'array',\n\t\t\titems,\n\t\t\t...(safe?.min === undefined ? {} : { min: safe.min }),\n\t\t\t...(safe?.max === undefined ? {} : { max: safe.max }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'arrayShape')\n}\n\n/**\n * Builds an {@link ObjectShape} from a property map.\n *\n * @remarks\n * Wrap any property in {@link optionalShape} to allow its absence. By default\n * the compiled guard rejects unknown keys; pass `additionalProperties` to open\n * the object.\n *\n * @param properties - Map of property names to child shapes\n * @param options - Optional `additionalProperties` and `description`\n * @returns An object shape\n *\n * @example\n * ```ts\n * const user = objectShape({\n * \tname: stringShape({ min: 1 }),\n * \tage: integerShape({ min: 0, max: 120 }),\n * \tbio: optionalShape(stringShape()),\n * })\n * ```\n */\nexport function objectShape<\n\tP extends Readonly<Record<string, ContractShape>>,\n\tconst A extends boolean | ContractShape = false,\n>(properties: P, options?: ObjectShapeOptions<A>): ObjectShape<P, A> {\n\treturn contain(() => {\n\t\tconst input: unknown = properties\n\t\tif (!isObject(input)) {\n\t\t\tthrow new ContractError('objectShape: properties must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['properties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(\n\t\t\toptions,\n\t\t\t['additionalProperties', 'description'],\n\t\t\t'objectShape',\n\t\t\t'object',\n\t\t)\n\t\tconst copied = readValue(\n\t\t\t() => {\n\t\t\t\tconst record = matchesRecordBrand(input)\n\t\t\t\tconst keyList = INTRINSICS.keys(input)\n\t\t\t\tconst entries: ReadonlyArray<readonly [string, PropertyDescriptor]> =\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.project, readIndexView(keyList), [\n\t\t\t\t\t\t(key: string) => [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: INTRINSICS.reflect.read(input, key),\n\t\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\t\twritable: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t])\n\t\t\t\tconst descriptors = INTRINSICS.record<PropertyDescriptor>({\n\t\t\t\t\t[Symbol.iterator]: INTRINSICS.reflect.apply(INTRINSICS.bind, INTRINSICS.iterator, [\n\t\t\t\t\t\tentries,\n\t\t\t\t\t]),\n\t\t\t\t})\n\t\t\t\tconst snapshot: { [K in keyof P]: P[K] } = INTRINSICS.create(null, descriptors)\n\t\t\t\treturn { record, snapshot: INTRINSICS.freeze(snapshot) }\n\t\t\t},\n\t\t\t'objectShape',\n\t\t\t{ subject: 'properties', context: { path: ['properties'], shape: 'object' } },\n\t\t)\n\t\tif (!copied.record) {\n\t\t\tthrow new ContractError('objectShape: properties must be a plain record', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['properties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst shape: ObjectShape<P, A> = {\n\t\t\tcategory: 'object',\n\t\t\tproperties: copied.snapshot,\n\t\t\t...(safe?.additionalProperties === undefined\n\t\t\t\t? {}\n\t\t\t\t: { additionalProperties: safe.additionalProperties }),\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'objectShape')\n}\n\n/**\n * Builds an open {@link ObjectShape} with no fixed properties — a dictionary.\n *\n * @remarks\n * Every value is validated against `values`; keys are unconstrained. Equivalent\n * to `objectShape({}, { additionalProperties: values })`.\n *\n * @param values - The shape every value must match\n * @param options - Optional `description`\n * @returns An open object shape\n * @throws {ContractError} When `values` is absent at runtime\n *\n * @example\n * ```ts\n * const bindings = recordShape(numberShape()) // ~ Record<string, number>\n * ```\n */\nexport function recordShape<S extends ContractShape>(\n\tvalues: S,\n\toptions?: RecordShapeOptions,\n): ObjectShape<Record<never, never>, S> {\n\treturn contain(() => {\n\t\tconst value: unknown = values\n\t\tif (value === undefined || value === null || value === true || value === false) {\n\t\t\tthrow new ContractError('recordShape: values must be a shape', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['additionalProperties'], shape: 'object' },\n\t\t\t})\n\t\t}\n\t\tconst safe = readOptions(options, ['description'], 'recordShape', 'object')\n\t\tconst shape: ObjectShape<Record<never, never>, S> = {\n\t\t\tcategory: 'object',\n\t\t\tproperties: INTRINSICS.freeze({}),\n\t\t\tadditionalProperties: values,\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'recordShape')\n}\n\n// === Composition\n\n/**\n * Builds a {@link UnionShape} from a list of variant shapes (`anyOf` in JSON Schema).\n *\n * @remarks\n * When every arm is an object declaring one required literal property, and a value's\n * own property exactly equals a literal only one arm holds, that arm answers: `explain`\n * and `audit` report its faults at their real paths, and `parse` repairs through it\n * alone. Any other value reports `variant`, with `key` and `expected` saying what would\n * have named an arm. `is` does not change.\n *\n * @param variants - The candidate shapes; the first match wins at runtime\n * @returns A union shape whose `Infer` is the union of the variants\n *\n * @example\n * ```ts\n * const id = unionShape(stringShape(), integerShape())\n * // Infer<typeof id> = string | number\n * ```\n */\nexport function unionShape<V extends readonly ContractShape[]>(\n\t...variants: V\n): UnionShape<Readonly<V>> {\n\treturn contain(() => {\n\t\treturn ShapePass.seal({ category: 'union', variants: INTRINSICS.freeze(variants) })\n\t}, 'unionShape')\n}\n\n/**\n * Builds a {@link UnionShape} that emits `oneOf` (exactly one match) in JSON Schema.\n *\n * @remarks\n * Unlike {@link unionShape} (`anyOf` — at least one variant matches),\n * `oneOfShape`'s compiled guard and parser enforce EXACTLY one match:\n *\n * - **Guard**: accepts the value only when exactly one variant's guard\n * accepts it. A value matching two-or-more variants — which would violate\n * the emitted `oneOf` schema — is rejected, even though it would pass\n * {@link unionShape}'s guard.\n * - **Parser**: judged on the RAW input's guard matches only, with NO\n * coercion fallback for an ambiguous input. When exactly one variant's\n * guard accepts the raw value, the input itself is returned. Zero matches or\n * two-or-more matches both parse to `undefined` — a value ambiguous\n * between variants has no well-defined coercion target. A value that names one\n * arm through a required literal is not ambiguous, so as in {@link unionShape}\n * that arm answers alone, and its parser may coerce.\n *\n * Prefer {@link unionShape} when a value may legitimately satisfy more than\n * one variant (for example overlapping shapes) and any match is acceptable. Prefer\n * `oneOfShape` when overlap between variants indicates malformed input that\n * must be rejected.\n *\n * @param variants - The candidate shapes\n * @returns A union shape with `mode: 'oneOf'`\n *\n * @example\n * ```ts\n * const id = oneOfShape(numberShape(), integerShape())\n * // 3 fails — matches both numberShape and integerShape\n * // 3.5 passes — matches numberShape only\n * ```\n */\nexport function oneOfShape<V extends readonly ContractShape[]>(\n\t...variants: V\n): UnionShape<Readonly<V>> {\n\treturn contain(() => {\n\t\treturn ShapePass.seal({\n\t\t\tcategory: 'union',\n\t\t\tvariants: INTRINSICS.freeze(variants),\n\t\t\tmode: 'oneOf',\n\t\t})\n\t}, 'oneOfShape')\n}\n\n/**\n * Wraps a shape so it may be absent (`undefined`).\n *\n * @remarks\n * As an {@link objectShape} property, the field becomes a true optional property\n * in the inferred type. A `default` is captured as an owned frozen copy, and the\n * compiled parser fills it where the property is absent or `undefined`; the guard,\n * the audit, the report, and the generator keep treating the property as optional.\n * The compilers refuse a default `inner` refuses, a default under a union, and a\n * default on a property of an open object.\n *\n * @param inner - The wrapped shape\n * @param options - Optional `default`, a JSON value\n * @returns An optional shape\n * @throws {ContractError} When a present `default` is not a JSON value, `undefined` included\n *\n * @example\n * ```ts\n * const retries = optionalShape(integerShape({ min: 0 }), { default: 3 })\n * ```\n */\nexport function optionalShape<S extends ContractShape>(\n\tinner: S,\n\toptions?: OptionalShapeOptions,\n): OptionalShape<S> {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['default'], 'optionalShape', 'optional')\n\t\trefuseOptionKeys(options, ['default'], 'optionalShape', 'optional')\n\t\t// Own presence, read apart from the value: the snapshot above omits a present\n\t\t// `undefined` and keeps an inherited value, and neither may decide this field.\n\t\tconst present = options !== undefined && INTRINSICS.own(options, 'default')\n\t\tconst value = present ? safe?.default : undefined\n\t\tif (present && !isJSONValue(value)) {\n\t\t\tthrow new ContractError('optionalShape: default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['default'], shape: 'optional', received: preview(value) },\n\t\t\t})\n\t\t}\n\t\tconst owned = value === undefined ? undefined : attempt(() => cloneJSONValue(value))\n\t\tif (owned !== undefined && isFailure(owned)) {\n\t\t\tthrow new ContractError('optionalShape: default must be a JSON value', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['default'], shape: 'optional', received: preview(value) },\n\t\t\t\tcause: owned.error,\n\t\t\t})\n\t\t}\n\t\tconst shape: OptionalShape<S> = {\n\t\t\tcategory: 'optional',\n\t\t\tinner,\n\t\t\t...(owned === undefined ? {} : { default: owned.value }),\n\t\t}\n\t\treturn ShapePass.seal(shape, { category: 'object', properties: { value: shape } })\n\t}, 'optionalShape')\n}\n\n/**\n * Wraps a shape so it may be `null`.\n *\n * @param inner - The wrapped shape\n * @returns A nullable shape\n *\n * @example\n * ```ts\n * const bio = nullableShape(stringShape())\n * // Infer<typeof bio> = string | null\n * ```\n */\nexport function nullableShape<S extends ContractShape>(inner: S): NullableShape<S> {\n\treturn contain(() => {\n\t\tconst shape: NullableShape<S> = { category: 'nullable', inner }\n\t\treturn ShapePass.seal(shape)\n\t}, 'nullableShape')\n}\n\n// === Escape hatch\n\n/**\n * Builds a {@link JSONShape}.\n *\n * @remarks\n * The sound counterpart of {@link rawShape}: `rawShape` embeds an arbitrary\n * schema fragment and accepts every defined value at runtime, while `jsonShape`\n * validates that a value is real JSON (through {@link isJSONValue}). Its emitted\n * schema is the empty accept-anything `{}`, so here the schema claims MORE than\n * the compiled guard accepts — `NaN`, a `Map`, and a class instance all satisfy\n * `{}` and all fail `isJSONValue`.\n *\n * This is the shape an author writes to mean \"any JSON value\". Inference never produces\n * it: {@link schemaToShape} widening always lands on {@link RawShape} instead.\n *\n * @param options - Optional `description`\n * @returns A JSON passthrough shape\n *\n * @example\n * ```ts\n * const payload = jsonShape({ description: 'Arbitrary JSON payload' })\n * ```\n */\nexport function jsonShape(options?: JSONShapeOptions): JSONShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'jsonShape', 'json')\n\t\tconst shape: JSONShape = {\n\t\t\tcategory: 'json',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'jsonShape')\n}\n\n/**\n * Builds a {@link ShapeShape}.\n *\n * @param options - Optional description\n * @returns A shape-valued declaration\n *\n * @example\n * ```ts\n * const definition = objectShape({ shape: shapeShape() })\n * ```\n */\nexport function shapeShape(options?: ShapeShapeOptions): ShapeShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['description'], 'shapeShape', 'shape')\n\t\tconst shape: ShapeShape = {\n\t\t\tcategory: 'shape',\n\t\t\t...(safe?.description === undefined ? {} : { description: safe.description }),\n\t\t}\n\t\treturn ShapePass.seal(shape)\n\t}, 'shapeShape')\n}\n\n/**\n * Builds a {@link RawShape} from a supported JSON Schema fragment.\n *\n * @remarks\n * For values the shape DSL can't express. The fragment is recursively checked\n * against the lean {@link JSONSchema} vocabulary before ownership is taken;\n * malformed or unsupported keywords throw a coded {@link ContractError}. The\n * refusal path starts at `schema` and names the nested keyword or member.\n * A non-record root is refused at `schema` itself. The\n * compiled guard accepts every\n * DEFINED value — `undefined` alone fails, because it is the parser's failure\n * sentinel; wrap the shape in {@link optionalShape} to admit absence. The\n * parser passes a defined value through unchanged, and the fragment is\n * deep-cloned into an owned frozen snapshot ({@link cloneSchema}), so\n * `rawShape(fragment).schema !== fragment` and later edits to the caller's\n * fragment cannot reach the shape. `compileSchema` re-emits that snapshot\n * structurally verbatim, so here the schema claims LESS than the compiled guard\n * accepts — `rawShape({ type: 'string' })` emits `{ type: 'string' }` and its\n * guard still accepts `42`, the mirror of {@link jsonShape}'s looseness.\n * `compileGenerator` throws, since an arbitrary embedded schema has no\n * auto-generatable sample.\n *\n * @param schema - The JSON Schema fragment to embed\n * @returns A raw shape owning a frozen copy of the fragment\n *\n * @example\n * ```ts\n * const custom = rawShape({ type: 'string', format: 'uuid' })\n * ```\n */\nexport function rawShape(schema: JSONSchema): RawShape {\n\treturn contain(() => {\n\t\tnew ShapeValidator({ category: 'raw', schema }).validate()\n\t\treturn ShapePass.seal({ category: 'raw', schema: cloneSchema(schema) })\n\t}, 'rawShape')\n}\n\n// === Schema inversion\n\n// schemaToShape walks an UNKNOWN, possibly adversarial runtime JSONSchema value\n// (a hand-written schema, or one produced by valueToSchema / samplesToSchema)\n// and emits a validating ContractShape — the reverse direction of\n// compileSchema (compilers.ts), which walks a finite, developer-authored\n// ContractShape tree and emits a JSONSchema. Recursion here is runtime-only\n// and bounded on three axes, mirroring the inferers: a WeakSet of ancestor\n// schema nodes (cycle safety), a decrementing depth budget (INFER_DEPTH_LIMIT\n// default), and a per-container sampling cap (INFER_BREADTH_LIMIT) on\n// properties/oneOf/anyOf entries — every branch stays total, as\n// `.claude/rules/patterns.md` § Validation and contracts requires.\n// Every keyword read is type-guarded: a malformed keyword is IGNORED, falling\n// through to the next rule, never thrown. `format` and `pattern` are NEVER\n// asserted — `format` is annotation-only, and compiling an attacker-supplied\n// `pattern` into a `RegExp` is a ReDoS vector — so neither keyword narrows the\n// compiled guard; the returned shape is always one `validateShape` accepts.\n//\n// Every widening — an empty/unrecognized node, an exhausted budget, a cycle —\n// lands on `rawShape`, NOT `jsonShape`. A hostile throw is NOT a widening: a\n// keyword access, enumeration, or recursive traversal that throws is not\n// malformed schema vocabulary, so `schemaToShape` runs the whole walk inside\n// `readValue` and refuses it as `ContractError { code: 'structure', context: {\n// shape: 'schema' } }` instead of inventing an accept-anything node for a\n// schema nobody could read. `{}` is JSON Schema's\n// accept-anything schema, and `rawShape` is its exact inverse: its compiled\n// guard accepts every defined value, and it re-emits `{}` verbatim. `jsonShape`\n// also emits `{}` but its guard is the strictly narrower `isJSONValue`, so\n// widening through it would REJECT the exotic originals (`Map`, `Set`, a class\n// instance, a function, `NaN`) whose inferred schema is exactly `{}` — the\n// round trip below would then be a false claim. `jsonShape` remains the shape a\n// user AUTHORS to mean \"any JSON value\"; it is never inferred.\n\n/**\n * Converts a runtime `JSONSchema` value into a validating {@link ContractShape}\n * — the inverse of {@link compileSchema}. Unlike direct {@link rawShape}\n * construction, which rejects malformed supported-vocabulary keywords, the\n * lenient conversion is total and widens an inexpressible input to a valid raw\n * `{}`, and a strict conversion refuses that input.\n *\n * @remarks\n * Readable malformed, cyclic, or deeply nested schema nodes widen to\n * {@link rawShape}; a failed traversal raises the shared coded refusal because\n * an unreadable value is not a schema. `createContract(schemaToShape(x))`\n * therefore remains safe for every readable `x`. The per-keyword precedence is\n * `enum`, then `oneOf`, then `anyOf`, then `type`, then a record-valued\n * `properties`, then the accept-anything widening.\n *\n * `format` and `pattern` are NEVER asserted by the compiled shape — `format`\n * is annotation-only (per the JSON Schema spec, it never narrows validation\n * on its own) and compiling an attacker-controlled `pattern` string into a\n * `RegExp` is a ReDoS vector; both keywords are read only far enough to be\n * ignored. Any node the walk cannot express — an empty `{}`, an\n * unrecognized `type`, a schema past {@link INFER_DEPTH_LIMIT} deep, or a\n * cyclic re-encounter — widens to {@link rawShape} (accept any defined\n * value), never narrows.\n *\n * ROUND TRIP: for every readable `v`,\n * `compileGuard(schemaToShape(valueToSchema(v)))(v)` is `true` — including\n * values no JSON Schema keyword describes (`NaN`, `±Infinity`, a `Map`, a\n * `Set`, a class instance, a function, a symbol, a bigint, and readable cyclic\n * hosts), which infer `{}` and widen back to an accept-anything\n * {@link rawShape}. An unreadable host is refused by {@link valueToSchema}\n * before this law produces a schema; direct hostile input to\n * {@link schemaToShape} receives the same coded refusal.\n * Widening is the only source of looseness. The law has three explicit host\n * limits:\n *\n * - **Absence.** `undefined` is not a value: no compiled guard accepts it\n * (`rawShape` reserves it as the parser failure sentinel). So `undefined`\n * itself, an array element holding it, and an array HOLE (`arrayOf` requires\n * every index to be an own property, the same rule `isJSONValue` applies)\n * all fall outside the law. An OBJECT property holding `undefined` does not:\n * `valueToSchema` drops the key and opens the object, so the source object\n * is still accepted.\n * - **`Date` serialization.** A `Date` infers the schema of its JSON form\n * (`{ type: 'string' }`, plus `format: 'date-time'` when `format` is on), so\n * the law applies to `date.toISOString()` rather than the runtime instance.\n * - **Stateful access.** A getter whose result changes between inference and\n * guard evaluation can invalidate the sampled fact. Likewise, an array that\n * overrides iteration behavior can present different elements to the two\n * phases. The law applies only while the sampled host's observable own\n * enumerable string properties and array iteration remain stable.\n *\n * A widened node cannot be auto-generated: `rawShape` embeds an arbitrary\n * schema fragment, so `createContract(schemaToShape(x)).generate()` throws\n * when the conversion widened anywhere — `schema` / `is` / `parse` / `explain`\n * stay total.\n *\n * LENIENT LAW: a value a JSON Schema accepts is never refused by the shape a\n * lenient conversion builds from it, because the walk widens what it cannot read.\n * So `oneOf` builds an inclusive union, a `true` arm is a raw variant and a `false`\n * arm is dropped, an `enum` holding `null` admits it, `nullable: true` wraps the\n * node, a present `patternProperties` opens the object, a present `prefixItems`\n * widens the elements, and a `$ref` widens the node before anything beside it is read.\n * A schema past the compile limit keeps only its root's type, an array's bounds, and an\n * object's required keys and closure, with every value below them raw.\n *\n * DEFAULTS: a lenient conversion carries a property's `default` when the key is\n * not `required`, its object is closed with no union ancestor, and the value is\n * one the property's primitive or literal guard accepts. It drops every other\n * `default`, because carrying it would make the shape refuse to compile.\n *\n * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with\n * code `structure`, every node the lenient walk would widen, every keyword it\n * would ignore (`pattern`, every `format` but `'date'` on a string node, `nullable`,\n * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside\n * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry\n * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose\n * length bounds exclude length 10, a `required` name not in\n * `properties`, breadth past {@link INFER_BREADTH_LIMIT}, and a `default` with no\n * optional property to fill. An object with no `additionalProperties` closes\n * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads\n * every keyword that could keep two arms apart. Below a `oneOf` that object refuses\n * instead, since closing it could change which arms match. A strict conversion is the\n * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a\n * date string shape, so a compiled {@link dateShape} round-trips.\n *\n * @param schema - The JSON Schema value to convert\n * @param options - Optional `strict`, default `false`\n * @returns The built {@link ContractShape}\n * @throws {ContractError} When schema traversal fails, or when a strict conversion refuses\n *\n * @example\n * ```ts\n * const schema = samplesToSchema([{ id: 1, name: 'Ada' }, { id: 2, name: 'Grace' }])\n * const contract = createContract(schemaToShape(schema))\n * contract.parse({ id: 3, name: 'Alan' }) // { id: 3, name: 'Alan' }\n * contract.parse({ id: 'nope' }) // undefined\n * ```\n */\nexport function schemaToShape(schema: JSONSchema, options?: SchemaToShapeOptions): ContractShape {\n\treturn contain(() => {\n\t\tconst safe = readOptions(options, ['strict'], 'schemaToShape', 'schema')\n\t\trefuseOptionKeys(options, ['strict'], 'schemaToShape', 'schema')\n\t\tconst named = options !== undefined && INTRINSICS.own(options, 'strict')\n\t\tconst strict = named ? safe?.strict : undefined\n\t\tif (strict !== undefined && typeof strict !== 'boolean') {\n\t\t\tthrow new ContractError('schemaToShape: strict must be a boolean', {\n\t\t\t\tcode: 'structure',\n\t\t\t\tcontext: { path: ['strict'], shape: 'schema', received: preview(strict) },\n\t\t\t})\n\t\t}\n\t\t// The whole walk runs inside this door's own read boundary, so a hostile\n\t\t// keyword, enumeration, or recursion anywhere below it is published under\n\t\t// this door's name rather than under the name of an engine method no\n\t\t// consumer can call. The engine captures its own collection constructors\n\t\t// while ITS module evaluates — a module function cannot — so a caller who\n\t\t// replaces `globalThis.WeakSet` or `globalThis.WeakMap` can no longer make\n\t\t// construction throw a raw value out of a door documented to refuse with a\n\t\t// `ContractError`.\n\t\tconst shaper = new SchemaShaper(schema, strict === true)\n\t\tif (strict !== true) {\n\t\t\treturn readValue(() => shaper.shape(), 'schemaToShape', {\n\t\t\t\tsubject: 'schema',\n\t\t\t\tcontext: { shape: 'schema' },\n\t\t\t})\n\t\t}\n\t\t// A strict refusal names the keyword it refuses, so it passes through the\n\t\t// boundary that would otherwise restate it as an unreadable schema.\n\t\tconst outcome = attempt(() => shaper.shape())\n\t\tif (isSuccess(outcome)) return outcome.value\n\t\tif (isContractError(outcome.error)) throw outcome.error\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tthrow outcome.error\n\t\t\t},\n\t\t\t'schemaToShape',\n\t\t\t{ subject: 'schema', context: { shape: 'schema' } },\n\t\t)\n\t}, 'schemaToShape')\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAa,eAA4D,OAAO,OAAO;CACtF,QAAQ,OAAO,OAAO;EAAC;EAAO;EAAO;EAAW;EAAQ;CAAa,CAAC;CACtE,QAAQ,OAAO,OAAO;EAAC;EAAW;EAAO;EAAO;CAAa,CAAC;CAC9D,SAAS,OAAO,OAAO,CAAC,aAAa,CAAC;CACtC,MAAM,OAAO,OAAO,CAAC,aAAa,CAAC;CACnC,SAAS,OAAO,OAAO,CAAC,UAAU,aAAa,CAAC;CAChD,OAAO,OAAO,OAAO;EAAC;EAAS;EAAO;EAAO;CAAa,CAAC;CAC3D,QAAQ,OAAO,OAAO;EAAC;EAAc;EAAwB;CAAa,CAAC;CAC3E,OAAO,OAAO,OAAO;EAAC;EAAY;EAAQ;CAAa,CAAC;CACxD,UAAU,OAAO,OAAO,CAAC,SAAS,SAAS,CAAC;CAC5C,UAAU,OAAO,OAAO,CAAC,OAAO,CAAC;CACjC,MAAM,OAAO,OAAO,CAAC,aAAa,CAAC;CACnC,KAAK,OAAO,OAAO,CAAC,QAAQ,CAAC;CAC7B,OAAO,OAAO,OAAO,CAAC,aAAa,CAAC;AACrC,CAAgE;;;;;;;;;;;AAYhE,IAAa,uBAAuB,OAAO,IAAI,mCAAmC;;;;;;;;;;;;;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