@orkestrel/contract 0.0.17 → 0.0.19

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.
@@ -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/ShapeValidator.ts","../../../src/core/ShapeCloner.ts","../../../src/core/cloners.ts","../../../src/core/combinators.ts","../../../src/core/parsers.ts","../../../src/core/ContractCompiler.ts","../../../src/core/compilers.ts","../../../src/core/factories.ts","../../../src/core/ValueInferer.ts","../../../src/core/SampleInferer.ts","../../../src/core/inferers.ts","../../../src/core/SchemaShaper.ts","../../../src/core/shapers.ts"],"sourcesContent":["import type { ContractCode, JSONSchemaType } from './types.js'\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.error')\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 `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.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 `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.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 `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 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// 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","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 = '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 (let index = 0; index < members.length; index += 1) {\n\t\t\tconst key = members[index]\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, the fixed name, and a declared contract code.\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 (value.name !== 'ContractError' || !('code' in value)) 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 = value.code\n\t\t// Indexed over the one declared vocabulary. `collectMembers` /\n\t\t// `matchesMember` express the same membership everywhere else in the\n\t\t// package, and this file cannot reach them: `helpers.ts` imports this\n\t\t// module, so asking it would invert the dependency — the same reason this\n\t\t// guard carries its own `try` / `catch`.\n\t\tfor (let index = 0; index < CONTRACT_CODES.length; index += 1) {\n\t\t\tif (code === CONTRACT_CODES[index]) return true\n\t\t}\n\t\treturn false\n\t} catch {\n\t\treturn false\n\t}\n}\n","import type {\n\tAnyAsyncFunction,\n\tAnyConstructor,\n\tAnyFunction,\n\tJSONPrimitive,\n\tJSONRecord,\n\tJSONValue,\n\tLiteralValue,\n\tZeroArgAsyncFunction,\n\tZeroArgFunction,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tholds,\n\tmatchesJSONDepth,\n\tmatchesJSONValue,\n\tmatchesRecordBrand,\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 * @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>(\n\tvalue: unknown,\n\tctor: C,\n): value is InstanceType<C & AnyConstructor<object>> {\n\t// `ctor` is narrowed to a function through `isFunction` before the `instanceof`\n\t// check — an unconstrained generic RHS loses TS's built-in instanceof leniency\n\t// once nested inside another generic call (the `holds` callback), so the\n\t// narrowing keeps this call legal without a constraint that would reject\n\t// combinators.ts's `instanceOf`, which validates `ctor` separately.\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/** 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\tContractShape,\n\tEntryCollectorFunction,\n\tFault,\n\tFaultKind,\n\tFieldPath,\n\tGuard,\n\tGuardShapeRead,\n\tGuardsShape,\n\tJSONSchema,\n\tJSONValue,\n\tNumberShape,\n\tRandomFunction,\n\tReadValueOptions,\n\tResult,\n\tSampleMemo,\n\tSchemaFormat,\n\tStringShape,\n} from './types.js'\nimport {\n\tCOMPILE_NODE_LIMIT,\n\tCONTRACT_CODES,\n\tFORMAT_PATTERNS,\n\tGUARD_DEPTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tPREVIEW_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tisBigInt,\n\tisArray,\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 * 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 extended: string[] = []\n\tfor (let index = 0; index < path.length; index += 1) {\n\t\tconst existing = path[index]\n\t\tif (existing === undefined) continue\n\t\textended[extended.length] = existing\n\t}\n\tfor (let index = 0; index < segments.length; index += 1) {\n\t\tconst segment = segments[index]\n\t\tif (segment === undefined) continue\n\t\textended[extended.length] = segment\n\t}\n\treturn extended\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 (let index = 0; index < source.length; index += 1) {\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 bounded: T[] = []\n\tfor (let index = 0; index < limit; index += 1) {\n\t\tconst entry = entries[index]\n\t\tif (entry === undefined) continue\n\t\tbounded[bounded.length] = entry\n\t}\n\treturn bounded\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 * compareValues('a', 'b') // -1\n * ```\n */\nexport function compareValues<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 compareValues}, 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 owned: T[] = []\n\tfor (let index = 0; index < values.length; index += 1) {\n\t\tconst value = values[index]\n\t\tif (value === undefined) continue\n\t\towned[owned.length] = value\n\t}\n\tINTRINSICS.reflect.apply(INTRINSICS.order, owned, [compareValues])\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 *\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 members = new INTRINSICS.set<unknown>()\n\tfor (let index = 0; index < values.length; index += 1) {\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, members, [values[index]])\n\t}\n\treturn members\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 compareValues} 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: unknown[] = []\n\t\tfor (let index = 0; index < collected.length; index += 1) {\n\t\t\tconst pair = collected[index]\n\t\t\tif (pair === undefined) continue\n\t\t\tentries[entries.length] = 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 * 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\tlet stateless = ''\n\tfor (let index = 0; index < flags.length; index += 1) {\n\t\tconst flag = flags[index]\n\t\tif (flag === undefined || flag === 'g' || flag === 'y') continue\n\t\tstateless += flag\n\t}\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 (let index = 0; index < members.length; index += 1) {\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 * 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 outcome.success && outcome.value\n * ```\n */\nexport function attempt<T>(callback: () => T): Result<T> {\n\ttry {\n\t\treturn { success: true, value: callback() }\n\t} catch (error) {\n\t\treturn { success: false, error }\n\t}\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 && matchesMember(collectMembers(CONTRACT_CODES), requested)\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 (!diagnostics.success) {\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 (!outcome.success) {\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 (outcome.success) 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 outcome.success && 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 (let index = 0; index < mandated.length; index += 1) {\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\tlet matched = 0\n\t\twhile (matched < length && members[matched] === INTRINSICS.text(matched)) matched += 1\n\t\tif (matched === length && members.length === length + 1 && members[length] === 'length') {\n\t\t\tconst packed = new INTRINSICS.list<T | undefined>(length)\n\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\tconst key = members[index]\n\t\t\t\tif (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\tpacked[index] = value[index]\n\t\t\t}\n\t\t\treturn INTRINSICS.freeze({ entries: INTRINSICS.freeze(packed), dense: true })\n\t\t}\n\t\tconst collected: number[] = []\n\t\tconst keys: string[] = []\n\t\tlet ascending = true\n\t\tlet previous = -1\n\t\tfor (let position = 0; position < members.length; position += 1) {\n\t\t\tconst key = members[position]\n\t\t\tif (!isString(key)) continue\n\t\t\tconst index = INTRINSICS.numeric(key)\n\t\t\tif (\n\t\t\t\tINTRINSICS.integer(index) &&\n\t\t\t\tindex >= 0 &&\n\t\t\t\tindex < 2 ** 32 - 1 &&\n\t\t\t\tINTRINSICS.text(index) === key\n\t\t\t) {\n\t\t\t\tif (index >= length) throw new INTRINSICS.error('Array index views disagree')\n\t\t\t\tif (index <= previous) ascending = false\n\t\t\t\tprevious = index\n\t\t\t\tcollected[collected.length] = index\n\t\t\t\tkeys[keys.length] = key\n\t\t\t}\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 entries = new INTRINSICS.list<T | undefined>(length)\n\t\tfor (let position = 0; position < indices.length; position += 1) {\n\t\t\tconst index = indices[position]\n\t\t\tif (index === undefined) continue\n\t\t\tconst key = ascending ? keys[position] : INTRINSICS.text(index)\n\t\t\tif (key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t}\n\t\t\tentries[index] = value[index]\n\t\t}\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 guards: Record<string, Guard<unknown> | undefined> = INTRINSICS.create(null)\n\t\t\tconst names: string[] = []\n\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\tconst key = members[index]\n\t\t\t\tif (!isString(key)) continue\n\t\t\t\tif (!INTRINSICS.own(guards, key)) names[names.length] = key\n\t\t\t\tguards[key] = shape[key]\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 (!entries.success) throw entries.error\n\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Optional key list must be dense')\n\t\t\tconst keys = collectMembers([])\n\t\t\tfor (let index = 0; index < entries.value.entries.length; index += 1) {\n\t\t\t\tadmitMember(keys, INTRINSICS.text(entries.value.entries[index]))\n\t\t\t}\n\t\t\treturn keys\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 outcome.success ? 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 values: Record<string, unknown> = INTRINSICS.create(null)\n\t\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tvalues[key] = INTRINSICS.reflect.read(input, key)\n\t\t\t\t\tINTRINSICS.reflect.present(input, key)\n\t\t\t\t\tINTRINSICS.reflect.describe(input, key)\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 snapshot: T = INTRINSICS.create(INTRINSICS.base)\n\t\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst value = values[key]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tINTRINSICS.reflect.define(snapshot, key, {\n\t\t\t\t\t\tvalue,\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\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 (!outcome.success) {\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\tlet current: unknown = record\n\t\t// Indexed: the caller's own path array is walked through its own index\n\t\t// properties rather than through `Array.prototype[Symbol.iterator]`, so an\n\t\t// injected leading segment cannot redirect the lookup.\n\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) return undefined\n\t\t\tif (!isObject(current) || !INTRINSICS.own(current, key)) return undefined\n\t\t\tcurrent = INTRINSICS.reflect.read(current, key)\n\t\t}\n\t\treturn current\n\t})\n\treturn outcome.success ? outcome.value : undefined\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 (!snapshot.success) return false\n\t\t\t\tconst children = INTRINSICS.values(snapshot.value.entries)\n\t\t\t\tfor (let index = 0; index < children.length; index += 1) {\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 (let index = 0; index < keys.length; index += 1) {\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. 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 * @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(entry: unknown, ancestors: WeakSet<object>): entry is JSONValue {\n\treturn readValue(\n\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\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 (matchesVisited(proved, node)) continue\n\t\t\t\t\tconst snapshot = readArrayEntries(node)\n\t\t\t\t\tif (!snapshot.success) 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 (let index = entries.length - 1; index >= 0; index -= 1) {\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 (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 (let index = members.length - 1; index >= 0; index -= 1) {\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// === Random\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\tlet state = seed >>> 0\n\treturn () => {\n\t\tstate = (state + 0x6d2b79f5) >>> 0\n\t\tlet t = state\n\t\tt = INTRINSICS.imul(t ^ (t >>> 15), t | 1)\n\t\tt ^= t + INTRINSICS.imul(t ^ (t >>> 7), t | 61)\n\t\treturn ((t ^ (t >>> 14)) >>> 0) / 4_294_967_296\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\tlet count = 0\n\t\t// Indexed: `Object.getOwnPropertySymbols` returns a fresh array this module\n\t\t// owns, and walking it through `Array.prototype[Symbol.iterator]` would let\n\t\t// a replaced iterator decide an emptiness verdict.\n\t\tconst symbols = INTRINSICS.symbols(value)\n\t\tfor (let index = 0; index < symbols.length; index += 1) {\n\t\t\tconst symbol = symbols[index]\n\t\t\tif (symbol === undefined) continue\n\t\t\tif (INTRINSICS.describe(value, symbol)?.enumerable) {\n\t\t\t\tcount += 1\n\t\t\t}\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 (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\t// Indexed and concatenated, not iterated and joined: this string IS\n\t\t\t\t\t// the canonical identity every schema de-duplication and every `enum`\n\t\t\t\t\t// ordering is keyed by, and both `Array.prototype[Symbol.iterator]`\n\t\t\t\t\t// and `Array.prototype.join` are caller-writable members on it.\n\t\t\t\t\tlet encoded = ''\n\t\t\t\t\tfor (let index = 0; index < frame.members.length; index += 1) {\n\t\t\t\t\t\tconst member = frame.members[index]\n\t\t\t\t\t\tconst part = isObject(member)\n\t\t\t\t\t\t\t? (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [member]) ??\n\t\t\t\t\t\t\t\tencodeLeaf(member))\n\t\t\t\t\t\t\t: encodeLeaf(member)\n\t\t\t\t\t\tif (part === undefined) return undefined\n\t\t\t\t\t\tconst key = frame.keys?.[index]\n\t\t\t\t\t\tconst text = key === undefined ? part : `${INTRINSICS.stringify(key)}:${part}`\n\t\t\t\t\t\tencoded += index === 0 ? text : `,${text}`\n\t\t\t\t\t}\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 members: unknown[] = []\n\t\t\t\tconst selected: string[] = []\n\t\t\t\tlet keys: readonly string[] | undefined\n\t\t\t\tif (isArray(container)) {\n\t\t\t\t\tconst snapshot = readArrayEntries(container)\n\t\t\t\t\tif (!snapshot.success) throw snapshot.error\n\t\t\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\t\t\t// Indexed, not `appendEntries`: a PRESENT `undefined` element is a\n\t\t\t\t\t// value JSON cannot encode and must abandon the whole encoding, and\n\t\t\t\t\t// the shared appender skips `undefined` by design.\n\t\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\t\tfor (let index = 0; index < entries.length; index += 1) {\n\t\t\t\t\t\tmembers[members.length] = entries[index]\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst names = sortValues(INTRINSICS.keys(container))\n\t\t\t\t\tfor (let index = 0; index < names.length; index += 1) {\n\t\t\t\t\t\tconst key = names[index]\n\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\tselected[selected.length] = key\n\t\t\t\t\t\tmembers[members.length] = INTRINSICS.reflect.read(container, key)\n\t\t\t\t\t}\n\t\t\t\t\tkeys = selected\n\t\t\t\t}\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 (let index = members.length - 1; index >= 0; index -= 1) {\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 outcome.success && 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\tlet text = quoted ? '\"' : ''\n\t\tlet index = 0\n\t\twhile (index < source.length) {\n\t\t\tconst first = source[index]\n\t\t\tif (first === undefined) break\n\t\t\tconst second = index + 1 < source.length ? source[index + 1] : undefined\n\t\t\tconst paired =\n\t\t\t\tfirst >= '\\ud800' &&\n\t\t\t\tfirst <= '\\udbff' &&\n\t\t\t\tsecond !== undefined &&\n\t\t\t\tsecond >= '\\udc00' &&\n\t\t\t\tsecond <= '\\udfff'\n\t\t\tconst character = paired ? `${first}${second}` : first\n\t\t\tconst encoded = INTRINSICS.stringify(character)\n\t\t\tconst tokenLength = encoded.length - 2\n\t\t\tif (text.length + tokenLength > PREVIEW_LIMIT) return `${text}…`\n\t\t\tlet tokenIndex = 1\n\t\t\twhile (tokenIndex <= tokenLength) {\n\t\t\t\tconst token = encoded[tokenIndex]\n\t\t\t\tif (token !== undefined) text += token\n\t\t\t\ttokenIndex += 1\n\t\t\t}\n\t\t\tindex += paired ? 2 : 1\n\t\t}\n\t\tif (!quoted) return text\n\t\treturn text.length < PREVIEW_LIMIT ? `${text}\"` : `${text}…`\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 (shape.min !== undefined && value.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: '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 (shape.max !== undefined && value.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: '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 ?? (shape.pattern === undefined ? undefined : 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 = shape.integer === true ? 'integer' : 'number'\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (shape.integer === true && !INTRINSICS.integer(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: 'integer',\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (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 (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 (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 (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\tlet closest: readonly T[] | undefined\n\tfor (let index = 0; index < reports.length; index += 1) {\n\t\tconst report = reports[index]\n\t\tif (report === undefined) continue\n\t\tif (closest === undefined || report.length < closest.length) closest = report\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 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 '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","import type { JSONClonerInterface, JSONRecord, JSONValue, Result } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tcollectMembers,\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// Every node this walk PRODUCES, not every node the source holds: the two\n\t// differ by exactly the alias duplication the tree contract requires, and it\n\t// is the produced count that grows exponentially.\n\t#produced: number\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.#produced = 0\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 * @returns The settled JSON snapshot\n\t * @throws {ContractError} When the source is inexact, cyclic, unreadable, or cloning is reentered\n\t */\n\tclone(): JSONValue {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined) {\n\t\t\tif (terminal.success) 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 = { success: false, error: 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())\n\t\tconst interruption = this.#terminal\n\t\tif (interruption !== undefined) {\n\t\t\tif (interruption.success) return interruption.value\n\t\t\tthis.#fail(interruption.error)\n\t\t}\n\t\tif (outcome.success) {\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 = { success: false, error }\n\t\tthis.#pending = JSONCloner.#emptyPending\n\t\tthrow error\n\t}\n\n\t#execute(): JSONValue {\n\t\tconst root = this.#capture(this.#source)\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[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])\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): 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\tthis.#produced += 1\n\t\tif (this.#produced > CLONE_NODE_LIMIT) {\n\t\t\tthis.#refuse('cloneJSONValue: snapshot exceeds the node limit')\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 (!arrayOutcome.success) 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 (!keysOutcome.success) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst lengthOutcome = attempt(() => INTRINSICS.reflect.describe(source, 'length'))\n\t\tif (!lengthOutcome.success) this.#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\tconst entries: Array<[key: string, value: unknown]> = []\n\t\tfor (let index = 0; index < lengthDescriptor.value; index += 1) {\n\t\t\tconst key = INTRINSICS.text(index)\n\t\t\tif (!matchesMember(owned, key)) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t\t}\n\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\tif (!descriptorOutcome.success) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array index could not be inspected')\n\t\t\t}\n\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\tif (descriptor === undefined || !('value' in descriptor) || descriptor.enumerable !== true) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array index is not enumerable data')\n\t\t\t}\n\t\t\tentries[entries.length] = [key, descriptor.value]\n\t\t}\n\t\treturn entries\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 (!keysOutcome.success) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst entries: Array<[key: string, value: unknown]> = []\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\tfor (let index = 0; index < names.length; index += 1) {\n\t\t\tconst key = names[index]\n\t\t\tif (typeof key !== 'string') this.#refuse('cloneJSONValue: record has a symbol property')\n\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\tif (!descriptorOutcome.success) {\n\t\t\t\tthis.#refuse('cloneJSONValue: record property could not be inspected')\n\t\t\t}\n\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\tif (descriptor === undefined || !('value' in descriptor) || descriptor.enumerable !== true) {\n\t\t\t\tthis.#refuse('cloneJSONValue: record property is not enumerable data')\n\t\t\t}\n\t\t\tentries[entries.length] = [key, descriptor.value]\n\t\t}\n\t\treturn entries\n\t}\n\n\t#create(message: string): ContractError {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'json' },\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): never {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined && !terminal.success) throw terminal.error\n\t\tthrow this.#create(message)\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\tenumerableKeys,\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 (state.result.success) 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({ success: false, error: state.poison })\n\t\t}\n\t\tif (outcome.success) 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({ success: false, 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\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst path = pathOf(frame.path, key)\n\t\t\t\tconst source = this.#read(frame.source, key, path)\n\t\t\t\tconst clone = this.#capture(source, path, frame.depth + 1)\n\t\t\t\tINTRINSICS.define(frame.clone, key, {\n\t\t\t\t\tvalue: clone,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\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 (outcome.success) 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 (result.success) 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, ShapeValidatorInterface, StringShape } from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tattempt,\n\tcollectMembers,\n\tmatchesMember,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isLiteralValue, isRecord, isRegExp } from './validators.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\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// the global binding. Cleanup runs OUTSIDE the contained walk, at both ends\n\t// of every call, so a replaced `WeakSet` would throw the caller's raw value\n\t// out of a door documented to throw a `ContractError` before any containment\n\t// exists. Every other dispatch on the traversal path runs inside the\n\t// contained walk and is translated below.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: ContractShape\n\t#state:\n\t\t| { readonly phase: 'idle' }\n\t\t| { readonly phase: 'active'; readonly poison?: ContractError } = { phase: 'idle' }\n\t#stack: Array<\n\t\t| {\n\t\t\t\treadonly operation: 'enter'\n\t\t\t\treadonly shape: ContractShape | undefined\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 ShapeValidator.#weakSet<ContractShape>()\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 ShapeValidator.#weakMap<ContractShape, number>()\n\t#captures: Array<{\n\t\treadonly shape: ContractShape\n\t\treadonly category: ContractShape['category'] | undefined\n\t\treadonly children: ReadonlyArray<{\n\t\t\treadonly shape: ContractShape | undefined\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}> = []\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// 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 ShapeValidator.#weakMap<object, number>()\n\t#expansion: number | undefined = undefined\n\t#children: Array<{\n\t\treadonly shape: ContractShape | undefined\n\t\treadonly optional: boolean\n\t\treadonly first: string\n\t\treadonly second?: string\n\t}> = []\n\t#category: ContractShape['category'] | undefined\n\t#raw = 0\n\t#structure: ContractError | undefined\n\t#cycle: ContractError | undefined\n\t#domain: ContractError | 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: ContractShape) {\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\tif (this.#state.phase === 'active') {\n\t\t\tconst poison =\n\t\t\t\tthis.#state.poison ??\n\t\t\t\tnew ContractError('ShapeValidator.validate: shape validation may not be reentered', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: [] },\n\t\t\t\t})\n\t\t\tthis.#state = { phase: 'active', poison }\n\t\t\tthrow poison\n\t\t}\n\n\t\tthis.#clear()\n\t\tthis.#state = { phase: 'active' }\n\t\tconst outcome = attempt(() => this.#execute())\n\t\tconst poison = this.#state.phase === 'active' ? this.#state.poison : undefined\n\t\tthis.#clear()\n\t\tif (poison !== undefined) {\n\t\t\tthis.#expansion = undefined\n\t\t\tthrow poison\n\t\t}\n\t\tif (outcome.success) return\n\t\t// A contained failure this class did not author came from a caller-\n\t\t// reachable dispatch on the traversal path — a replaced intrinsic member,\n\t\t// a polluted diagnostic read — and rethrowing it verbatim would put the\n\t\t// caller's raw value through a door whose contract is a `ContractError`.\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#clear(): void {\n\t\tthis.#state = { phase: 'idle' }\n\t\tthis.#stack = []\n\t\tthis.#path = []\n\t\tthis.#active = new ShapeValidator.#weakSet()\n\t\tthis.#index = new ShapeValidator.#weakMap()\n\t\tthis.#captures = []\n\t\tthis.#post = []\n\t\tthis.#height = []\n\t\tthis.#reach = []\n\t\tthis.#via = []\n\t\tthis.#counts = []\n\t\tthis.#schemas = new ShapeValidator.#weakMap()\n\t\tthis.#children = []\n\t\tthis.#category = undefined\n\t\tthis.#raw = 0\n\t\tthis.#structure = undefined\n\t\tthis.#cycle = undefined\n\t\tthis.#domain = undefined\n\t}\n\n\t#execute(): void {\n\t\tthis.#expansion = undefined\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\tthis.#expansion = this.#counts[0] ?? 1\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\tlet segments = 0\n\t\tif (frame.first !== undefined) {\n\t\t\tthis.#path[this.#path.length] = frame.first\n\t\t\tsegments += 1\n\t\t}\n\t\tif (frame.second !== undefined) {\n\t\t\tthis.#path[this.#path.length] = frame.second\n\t\t\tsegments += 1\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\tconst outcome = attempt(() => this.#observe(current, frame.depth))\n\t\tif (!outcome.success || !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: ContractShape, 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 = this.#recognize(category)\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 (!outcome.success) {\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 (!outcome.success) {\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 (!outcome.success) {\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 (!outcome.success) {\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#recognize(category: ContractShape['category']): readonly string[] | undefined {\n\t\tswitch (category) {\n\t\t\tcase 'string':\n\t\t\t\treturn ['min', 'max', 'pattern', 'description']\n\t\t\tcase 'number':\n\t\t\t\treturn ['integer', 'min', 'max', 'description']\n\t\t\tcase 'boolean':\n\t\t\tcase 'null':\n\t\t\tcase 'json':\n\t\t\t\treturn ['description']\n\t\t\tcase 'literal':\n\t\t\t\treturn ['values', 'description']\n\t\t\tcase 'array':\n\t\t\t\treturn ['items', 'min', 'max', 'description']\n\t\t\tcase 'object':\n\t\t\t\treturn ['properties', 'additionalProperties', 'description']\n\t\t\tcase 'union':\n\t\t\t\treturn ['variants', 'mode', 'description']\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\treturn ['inner']\n\t\t\tcase 'raw':\n\t\t\t\treturn ['schema']\n\t\t}\n\t}\n\n\t#scan(current: ContractShape, fields: readonly string[]): boolean {\n\t\tfor (let fieldIndex = 0; fieldIndex < fields.length; fieldIndex += 1) {\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 (!outcome.success || !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: ContractShape): 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 === '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\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(!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(!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\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: StringShape, source = '', flags = ''): void {\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(!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(!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\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 (!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 ShapeValidator.#weakSet<object>()\n\t\tconst stack: Array<\n\t\t\t| { readonly operation: 'enter'; readonly schema: unknown }\n\t\t\t| { readonly operation: 'exit'; readonly schema: object; readonly nested: readonly unknown[] }\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 schema = frame.schema\n\t\t\tif (!isRecord(schema)) {\n\t\t\t\treturn this.#refuse(\n\t\t\t\t\t'validateShape: every raw schema child must be a plain record',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (matchesVisited(active, schema)) {\n\t\t\t\treturn this.#refuse('validateShape: a raw schema may not contain a cycle', 'schema')\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 (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\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 !== '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.#refuse('validateShape: raw schema contains an unsupported keyword', 'schema')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst category = schema.type\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.#refuse(\n\t\t\t\t\t'validateShape: raw schema type is outside the supported vocabulary',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (schema.description !== undefined && typeof schema.description !== 'string') {\n\t\t\t\treturn this.#refuse('validateShape: raw schema description must be a string', 'schema')\n\t\t\t}\n\t\t\tif (schema.format !== undefined && typeof schema.format !== 'string') {\n\t\t\t\treturn this.#refuse('validateShape: raw schema format must be a string', 'schema')\n\t\t\t}\n\t\t\tif (schema.pattern !== undefined) {\n\t\t\t\tif (typeof schema.pattern !== 'string') {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema pattern must be a string', 'schema')\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 (!pattern.success) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema pattern must be valid', 'schema')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst lengthList = ['minLength', 'maxLength', 'minItems', 'maxItems']\n\t\t\tfor (let lengthIndex = 0; lengthIndex < lengthList.length; lengthIndex += 1) {\n\t\t\t\tconst key = lengthList[lengthIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = schema[key]\n\t\t\t\tif (value !== undefined && (!INTRINSICS.safe(value) || INTRINSICS.numeric(value) < 0)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema length bounds must be non-negative safe integers',\n\t\t\t\t\t\t'schema',\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 (let rangeIndex = 0; rangeIndex < rangeList.length; rangeIndex += 1) {\n\t\t\t\tconst key = rangeList[rangeIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = schema[key]\n\t\t\t\tif (value !== undefined && (typeof value !== 'number' || !INTRINSICS.finite(value))) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema numeric bounds must be finite numbers',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst population = schema.enum\n\t\t\tif (population !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(population)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be a non-empty array', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(population)\n\t\t\t\tif (!snapshot.success || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be a non-empty array', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be dense', 'schema')\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 (let valueIndex = 0; valueIndex < snapshot.value.entries.length; valueIndex += 1) {\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.#refuse(\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\t'schema',\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 = schema.required\n\t\t\tif (names !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(names)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be an array', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(names)\n\t\t\t\tif (!snapshot.success) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be an array', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be dense', 'schema')\n\t\t\t\t}\n\t\t\t\tconst required = collectMembers([])\n\t\t\t\tfor (let valueIndex = 0; valueIndex < snapshot.value.entries.length; valueIndex += 1) {\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.#refuse(\n\t\t\t\t\t\t\t'validateShape: raw schema required values must be unique strings',\n\t\t\t\t\t\t\t'schema',\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\tif (schema.items !== undefined) nested[nested.length] = schema.items\n\t\t\tif (schema.properties !== undefined) {\n\t\t\t\tif (!isRecord(schema.properties)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema properties must be a plain record',\n\t\t\t\t\t\t'schema',\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 (let propertyIndex = 0; propertyIndex < propertyList.length; propertyIndex += 1) {\n\t\t\t\t\tconst key = propertyList[propertyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tnested[nested.length] = schema.properties[key]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\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\tnested[nested.length] = schema.additionalProperties\n\t\t\t}\n\t\t\tconst unionList = ['anyOf', 'oneOf']\n\t\t\tfor (let unionIndex = 0; unionIndex < unionList.length; unionIndex += 1) {\n\t\t\t\tconst key = unionList[unionIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst variants = schema[key]\n\t\t\t\tif (variants === undefined) continue\n\t\t\t\tif (!INTRINSICS.array(variants)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be non-empty arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(variants)\n\t\t\t\tif (!snapshot.success || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be non-empty arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be dense arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tfor (\n\t\t\t\t\tlet variantIndex = 0;\n\t\t\t\t\tvariantIndex < snapshot.value.entries.length;\n\t\t\t\t\tvariantIndex += 1\n\t\t\t\t) {\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\tnested[nested.length] = snapshot.value.entries[variantIndex]\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack[stack.length] = { operation: 'exit', schema, nested }\n\t\t\tfor (let index = nested.length - 1; index >= 0; index -= 1) {\n\t\t\t\tstack[stack.length] = { operation: 'enter', schema: nested[index] }\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\tlet height = 0\n\t\tfor (let index = 0; index < nested.length; index += 1) {\n\t\t\tconst child = nested[index]\n\t\t\tconst recorded =\n\t\t\t\ttypeof child !== 'object' || child === null\n\t\t\t\t\t? 0\n\t\t\t\t\t: (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [child]) ?? 0)\n\t\t\tif (recorded + 1 > height) height = recorded + 1\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#schemas, [schema, height])\n\t}\n\n\t#populate(current: ContractShape): boolean {\n\t\tswitch (current.category) {\n\t\t\tcase 'array':\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(properties, key))\n\t\t\t\t\tif (!descriptorOutcome.success) {\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(() => current.properties[key])\n\t\t\t\t\tif (!childOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.properties[key], child) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, child),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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\tif (extra !== undefined && extra !== true && extra !== false) {\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 (!snapshot.success) {\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 (let index = 0; index < length; index += 1) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.variants, key))\n\t\t\t\t\tif (!descriptorOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.variants[index], variant) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, variant),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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 (!snapshot.success) {\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 (let index = 0; index < length; index += 1) {\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 (!descriptorOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.values[index], value) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, value),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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.#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 'raw':\n\t\t\t\tbreak\n\t\t}\n\t\treturn true\n\t}\n\n\t#schedule(current: ContractShape, depth: number, segments: number): number {\n\t\tadmitVisited(this.#active, current)\n\t\tconst children: Array<{\n\t\t\treadonly shape: ContractShape | undefined\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}> = []\n\t\tfor (let index = 0; index < this.#children.length; index += 1) {\n\t\t\tconst child = this.#children[index]\n\t\t\tif (child === undefined) continue\n\t\t\tchildren[children.length] = child\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 (let index = children.length - 1; index >= 0; index -= 1) {\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...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t}\n\t\t}\n\t\treturn captured\n\t}\n\n\t#capture(\n\t\tshape: ContractShape,\n\t\tchildren: ReadonlyArray<{\n\t\t\treadonly shape: ContractShape | undefined\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] = { shape, category: this.#category, children, raw: this.#raw }\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#index, [shape, index])\n\t\treturn index\n\t}\n\n\t#locate(shape: ContractShape | undefined): number | undefined {\n\t\tif (shape === undefined) 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\tfor (let index = 0; index < this.#captures.length; index += 1) {\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\t// A back edge to a still-open ancestor leaves no order to compute a height\n\t\t// in, so a cyclic capture takes the ordered path walk instead.\n\t\tif (this.#cycle !== undefined) {\n\t\t\tthis.#trace()\n\t\t\treturn\n\t\t}\n\t\tfor (let step = 0; step < this.#post.length; step += 1) {\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\tlet height = 0\n\t\t\tlet count = 1\n\t\t\tfor (let edge = 0; edge < capture.children.length; edge += 1) {\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\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\tif (reached + 1 > height) height = reached + 1\n\t\t\t\tcount += located === undefined ? 1 : (this.#counts[located] ?? 1)\n\t\t\t}\n\t\t\tthis.#height[index] = height\n\t\t\tthis.#counts[index] = count\n\t\t}\n\t\tif ((this.#height[0] ?? 0) > COMPILE_DEPTH_LIMIT) this.#witness()\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 (let step = this.#post.length - 1; step >= 0; step -= 1) {\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 (let edge = 0; edge < capture.children.length; edge += 1) {\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...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (let index = 0; index < this.#captures.length; index += 1) {\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}\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\tconst reversed: string[] = []\n\t\tlet current = index\n\t\twhile (current !== 0) {\n\t\t\tconst edge = this.#via[current]\n\t\t\tif (edge === undefined) break\n\t\t\tif (edge.second !== undefined) reversed[reversed.length] = edge.second\n\t\t\treversed[reversed.length] = edge.first\n\t\t\tcurrent = edge.parent\n\t\t}\n\t\tconst path: string[] = []\n\t\tfor (let step = reversed.length - 1; step >= 0; step -= 1) {\n\t\t\tconst segment = reversed[step]\n\t\t\tif (segment === undefined) continue\n\t\t\tpath[path.length] = segment\n\t\t}\n\t\treturn path\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(): never {\n\t\tconst path: string[] = []\n\t\tlet index: number | undefined = 0\n\t\tlet depth = 0\n\t\twhile (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\tlet chosen:\n\t\t\t\t| {\n\t\t\t\t\t\treadonly shape: ContractShape | undefined\n\t\t\t\t\t\treadonly first: string\n\t\t\t\t\t\treadonly second?: string\n\t\t\t\t }\n\t\t\t\t| undefined\n\t\t\tfor (let edge = 0; edge < children.length; edge += 1) {\n\t\t\t\tconst child = children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\tif (depth + 1 + reached > COMPILE_DEPTH_LIMIT) {\n\t\t\t\t\tchosen = child\n\t\t\t\t\tindex = located\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (chosen === undefined) break\n\t\t\tpath[path.length] = chosen.first\n\t\t\tif (chosen.second !== undefined) path[path.length] = chosen.second\n\t\t\tdepth += 1\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// The cyclic fallback. It walks the CAPTURED nodes and edges — never the\n\t// caller's source again — carrying the deepest start each node already cleared,\n\t// so a shared child off the cycle is still not re-walked from a shallower\n\t// position. Depth outranks the recorded cycle, exactly as before: a back edge\n\t// first reached beyond the limit is a depth refusal, and one reached inside it\n\t// leaves the cycle to speak.\n\t//\n\t// A clearance is only reusable when the walk that produced it did not depend on\n\t// the CALLER's path. A walk stopped by the active set stopped at some ancestor,\n\t// and which ancestor decides everything: one admitted inside this subtree is\n\t// re-admitted at the same relative place on every later arrival, so the walk\n\t// repeats and the clearance holds; one that was already active when the subtree\n\t// was entered belongs to the route in, and a later, shallower arrival without it\n\t// walks on through the cycle to a depth this walk never measured. Memoizing that\n\t// second kind made the verdict depend on how long the alias chain to the node\n\t// was — shortening a declaration by one link turned `depth` into `cycle`.\n\t//\n\t// Admission order tells the two apart with one comparison and no extra\n\t// collection: a node's own admission number bounds its subtree, so a blocker\n\t// numbered below it came from outside. `oldest` carries the lowest-numbered\n\t// blocker the open subtree met, seeded one past the subtree root so an\n\t// unblocked walk compares as internal, and each exit hands its parent the lower\n\t// of the two.\n\t#trace(): void {\n\t\tconst settled: number[] = []\n\t\tconst order: number[] = []\n\t\tlet clock = 0\n\t\tlet oldest = 0\n\t\tconst active = new ShapeValidator.#weakSet<ContractShape>()\n\t\tconst path: string[] = []\n\t\tconst stack: Array<\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'enter'\n\t\t\t\t\treadonly index: number | undefined\n\t\t\t\t\treadonly depth: number\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 index: number\n\t\t\t\t\treadonly depth: number\n\t\t\t\t\treadonly segments: number\n\t\t\t\t\treadonly outer: number\n\t\t\t }\n\t\t> = [{ operation: 'enter', index: 0, depth: 0 }]\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\tconst capture = this.#captures[frame.index]\n\t\t\t\tif (capture !== undefined) omitVisited(active, capture.shape)\n\t\t\t\tif (oldest >= (order[frame.index] ?? 0) && (settled[frame.index] ?? -1) < frame.depth) {\n\t\t\t\t\tsettled[frame.index] = frame.depth\n\t\t\t\t}\n\t\t\t\tif (frame.outer < oldest) oldest = frame.outer\n\t\t\t\tpath.length -= frame.segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet segments = 0\n\t\t\tif (frame.first !== undefined) {\n\t\t\t\tpath[path.length] = frame.first\n\t\t\t\tsegments += 1\n\t\t\t}\n\t\t\tif (frame.second !== undefined) {\n\t\t\t\tpath[path.length] = frame.second\n\t\t\t\tsegments += 1\n\t\t\t}\n\t\t\tif (frame.depth > COMPILE_DEPTH_LIMIT) {\n\t\t\t\tthrow new ContractError('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\t\t\tcode: 'depth',\n\t\t\t\t\tcontext: { path: pathOf(path), limit: COMPILE_DEPTH_LIMIT },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst index = frame.index\n\t\t\tconst capture = index === undefined ? undefined : this.#captures[index]\n\t\t\tif (index === undefined || capture === undefined) {\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (matchesVisited(active, capture.shape)) {\n\t\t\t\tconst blocker = order[index] ?? 0\n\t\t\t\tif (blocker < oldest) oldest = blocker\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst recorded = settled[index]\n\t\t\tif (recorded !== undefined && frame.depth <= recorded) {\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tadmitVisited(active, capture.shape)\n\t\t\torder[index] = clock\n\t\t\tclock += 1\n\t\t\tstack[stack.length] = {\n\t\t\t\toperation: 'exit',\n\t\t\t\tindex,\n\t\t\t\tdepth: frame.depth,\n\t\t\t\tsegments,\n\t\t\t\touter: oldest,\n\t\t\t}\n\t\t\toldest = clock\n\t\t\tfor (let edge = capture.children.length - 1; edge >= 0; edge -= 1) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tindex: this.#locate(child.shape),\n\t\t\t\t\tdepth: frame.depth + 1,\n\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t\t}\n\t\t\t}\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#refuse(message: string, first?: string, second?: string): false {\n\t\tif (this.#structure === undefined) {\n\t\t\tconst path = pathOf(this.#path, 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\tstatic {\n\t\t// Pinned while this class is DEFINED: `ShapeCloner`'s `#validateShape` and\n\t\t// `validateShape` reach it through `ShapeValidator.prototype.validate`,\n\t\t// so an assignment there decides whether a shape gate the caller never\n\t\t// touched ever runs.\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\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isLiteralValue, isObject, isRecord, isRegExp } from './validators.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapeValidator } from './ShapeValidator.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 (state.result.success) 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({ success: false, error: state.poison })\n\t\t}\n\t\tif (outcome.success) 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({ success: false, error })\n\t}\n\n\t#execute(): ContractShape {\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()\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\tthis.#validateShape(root)\n\t\tif (this.#fidelity !== undefined) throw this.#fidelity\n\t\treturn root\n\t}\n\n\t#drain(): 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\tlet cursor = 0\n\t\twhile (cursor < this.#pending.length) {\n\t\t\tconst entry = this.#pending[cursor]\n\t\t\tcursor += 1\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()\n\t\t\tthis.#captureNode(entry.shape, entry.depth)\n\t\t}\n\t}\n\n\t// The gate that OWNS the depth rule authors the diagnosis, on the same source\n\t// `validateShape` would be handed, so `cloneShape` and `validateShape` cannot disagree about\n\t// which node exceeded the limit or what the refusal says.\n\t#refuseDepth(): never {\n\t\tthis.#validateShape(this.#source)\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(source: ContractShape, path: readonly string[]): 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)\n\t\t\tcase 'object':\n\t\t\t\treturn this.#captureObject(source, path)\n\t\t\tcase 'union':\n\t\t\t\treturn this.#captureUnion(source, path)\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#captureWrapper(source, path, 'optional')\n\t\t\tcase 'nullable':\n\t\t\t\treturn this.#captureWrapper(source, path, 'nullable')\n\t\t\tcase 'json':\n\t\t\t\treturn this.#captureSimple(source, path, 'json')\n\t\t\tcase 'raw':\n\t\t\t\treturn this.#captureRaw(source, path)\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\t!repeated.success ||\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): 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)\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,\n\t\tpath: readonly string[],\n\t\tcategory: 'boolean' | 'null' | 'json',\n\t): BooleanShape | NullShape | JSONShape {\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\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[]): ArrayShape {\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(source: ObjectShape, path: readonly string[]): 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)\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[]): 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)\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#captureWrapper(\n\t\tsource: OptionalShape | NullableShape,\n\t\tpath: readonly string[],\n\t\tcategory: 'optional' | 'nullable',\n\t): OptionalShape | NullableShape {\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 category === 'optional'\n\t\t\t? { category: 'optional', inner }\n\t\t\t: { category: 'nullable', inner }\n\t}\n\n\t#captureRaw(source: RawShape, path: readonly string[]): 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 })\n\t\tconst outcome = attempt(() => new SchemaCloner(schema).clone())\n\t\tif (!outcome.success) {\n\t\t\tif (isContractError(outcome.error)) {\n\t\t\t\tadmitVisited(this.#owned, outcome.error)\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 (!snapshot.success) {\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: LiteralValue[] = []\n\t\tfor (let index = 0; index < snapshot.value.entries.length; index += 1) {\n\t\t\tentries[entries.length] = 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\t!descriptor.success ||\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\t!repeated.success ||\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): void {\n\t\tconst keys = INTRINSICS.keys(properties)\n\t\tconst snapshot: ShapeProperty[] = []\n\t\t// Indexed, not iterated: this walk decides the cloned shape's property\n\t\t// population.\n\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) continue\n\t\t\tconst descriptor = INTRINSICS.describe(properties, key)\n\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst child = properties[key]\n\t\t\tconst repeated = properties[key]\n\t\t\tconst described: unknown = descriptor.value\n\t\t\tif (!INTRINSICS.same(described, child) || !INTRINSICS.same(child, repeated)) {\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tsnapshot[snapshot.length] = { key, child }\n\t\t}\n\t\tconst repeated = INTRINSICS.keys(properties)\n\t\tlet drifted = repeated.length !== keys.length\n\t\tfor (let index = 0; index < repeated.length; index += 1) {\n\t\t\tif (repeated[index] !== keys[index]) drifted = true\n\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): 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 (!snapshot.success) {\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\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 (let index = 0; index < entries.length; index += 1) {\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\t!descriptor.success ||\n\t\t\t\tdescriptor.value === undefined ||\n\t\t\t\t!INTRINSICS.own(descriptor.value, 'value') ||\n\t\t\t\t!repeated.success ||\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 (let index = 0; index < properties.length; index += 1) {\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 (let index = 0; index < variants.length; index += 1) {\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 (let sourceIndex = 0; sourceIndex < this.#sources.length; sourceIndex += 1) {\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 properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\tconst entry = snapshot[index]\n\t\t\tif (entry === undefined) continue\n\t\t\tconst { key, child } = entry\n\t\t\tif (child === 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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [child])\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tproperties[key] = cloned\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: ContractShape[] = []\n\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\tconst variant = snapshot[index]\n\t\t\tif (variant === 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, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [variant])\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, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tvariants[variants.length] = cloned\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 (let sourceIndex = 0; sourceIndex < this.#sources.length; sourceIndex += 1) {\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(shape: ContractShape): void {\n\t\tconst outcome = attempt(() => new ShapeValidator(shape).validate())\n\t\tif (outcome.success) return\n\t\tif (isContractError(outcome.error)) {\n\t\t\tadmitVisited(this.#owned, outcome.error)\n\t\t}\n\t\tthrow outcome.error\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 (result.success) 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 { INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport { attempt, contain, holds } 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 (fidelity.success) return fidelity.value\n\t\tif (isContractError(fidelity.error) && fidelity.error.code !== 'clone') {\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 (!validation.success && isContractError(validation.error)) throw validation.error\n\t\tthrow fidelity.error\n\t}, 'ownShape')\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 { GUARD_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.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\tcollectMembers,\n\tcontain,\n\tholds,\n\tmatchesMember,\n\tmatchesPattern,\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 (!entries.success || !entries.value.dense) return false\n\t\t\tfor (let index = 0; index < entries.value.entries.length; index += 1) {\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 (!entries.success || !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 (let index = 0; index < guards.length; index += 1) {\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 (!entries.success) 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\tlet literal = true\n\t\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\t\tif (!isLiteralValue(snapshot[index])) literal = false\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 (!entries.success) return false\n\t\t\tfor (let index = 0; index < entries.value.length; index += 1) {\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 (!entries.success) return false\n\t\t\tfor (let index = 0; index < entries.value.length; index += 1) {\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 (let index = 0; index < members.length; index += 1) {\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 (let index = 0; index < declared.names.length; index += 1) {\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 (let index = 0; index < declared.names.length; index += 1) {\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 (!entries.success) 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 result: { [P in keyof S]: S[P] } = INTRINSICS.create(null)\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && matchesMember(selected, key)) {\n\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\tvalue: shape[key],\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\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 (!entries.success) 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 result: { [P in keyof S]: S[P] } = INTRINSICS.create(null)\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && !matchesMember(skipped, key)) {\n\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\tvalue: shape[key],\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\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 (let index = 0; index < guards.length; index += 1) {\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 (let index = 0; index < guards.length; index += 1) {\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 = { value: number; children: Tree[] }\n * let isTree: Guard<Tree>\n * isTree = recordOf({ value: isNumber, children: arrayOf(lazyOf(() => isTree)) })\n * ```\n */\nexport function lazyOf<T>(thunk: () => Guard<T>): Guard<T> {\n\tlet depth = 0\n\treturn (value: unknown): value is T => {\n\t\tif (depth >= GUARD_DEPTH_LIMIT) return false\n\t\tdepth += 1\n\t\ttry {\n\t\t\treturn holds(() => thunk()(value))\n\t\t} finally {\n\t\t\tdepth -= 1\n\t\t}\n\t}\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 boundsOf} on the string's `.length` and\n * an owned 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\tconst min = safe?.min\n\t\tconst max = safe?.max\n\t\tconst source = safe?.pattern\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\tconst withinLength = boundsOf(min, max)\n\t\treturn whereOf(\n\t\t\tisString,\n\t\t\t(value) =>\n\t\t\t\twithinLength(value.length) && (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\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 outcome.success ? 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 (!entries.success || !entries.value.dense) return undefined\n\tif (\n\t\t!holds(() => {\n\t\t\t// Indexed: the snapshot is an array this package built, and walking it\n\t\t\t// through `Array.prototype[Symbol.iterator]` would let a replaced iterator\n\t\t\t// decide which elements this parser ever guards.\n\t\t\tconst collected = entries.value.entries\n\t\t\tfor (let index = 0; index < collected.length; index += 1) {\n\t\t\t\tif (!guard(collected[index])) return false\n\t\t\t}\n\t\t\treturn true\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 (!outcome.success || !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// === 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 checked.success ? checked.value : undefined\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\tLiteralValue,\n\tNumberShape,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tResult,\n\tSeederFunction,\n\tStringShape,\n} from './types.js'\nimport {\n\tFAULT_LIMIT,\n\tGENERATION_ATTEMPT_LIMIT,\n\tINTRINSICS,\n\tPRESENCE_MASK_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tappendEntries,\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tbuildArrayFaults,\n\tbuildNumberFaults,\n\tbuildStringFaults,\n\tdrawRandom,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\n\townPattern,\n\tpathOf,\n\tpinMembers,\n\tpreview,\n\treadArrayEntries,\n\treadPatternSource,\n\treadValue,\n\trefuseExpansion,\n\tseededRandom,\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 { cloneSchema, ownShape } from './cloners.js'\nimport { ShapeValidator } from './ShapeValidator.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. 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.\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 call-scoped value ledger's clock. `#visits` hands out one identity per\n\t// top-level walk and `#scope` names the walk that is running, so a node's memo can\n\t// say which call filled it. Both are static because a compiled artifact is\n\t// self-contained by design — it must not reach instance state its compiler\n\t// releases — and because those numbers are the whole of it: no value, no\n\t// answer, and nothing that outlives the walk that set them.\n\tstatic #visits = 0\n\tstatic #scope = 0\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 (!outcome.success) {\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// 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\tconst validator = new ShapeValidator(owned)\n\t\tvalidator.validate()\n\t\trefuseExpansion(validator.expansion)\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\tthis.#nodes[index] = shape\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 (let index = shape.variants.length - 1; index >= 0; index -= 1) {\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 (let index = keys.length - 1; index >= 0; index -= 1) {\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 (let index = 0; index < this.#nodes.length; index += 1) {\n\t\t\tif (this.#nodes[index]?.category === 'union') return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// === Call-scoped value ledger\n\t//\n\t// A compiled artifact applies each child artifact once per OCCURRENCE, and a\n\t// value graph is a DAG as often as a declaration is — two slots holding one\n\t// object is ordinary data, not an attack. That costs one visit per PATH: a\n\t// twenty-three-node `arrayShape` chain over twenty-two shared arrays measured\n\t// 524,286 node reads, 4.4 s for `is` and 8.4 s for `audit`, growing fourfold\n\t// per two levels, for a declaration inside every published bound. The answer a\n\t// compiled node gives about one object is a function of that object, so it is\n\t// computed once per call and reused by every later path that arrives at the\n\t// same pair. The scope tag is what keeps that reuse INSIDE one call, since a\n\t// value the caller changes between two calls must be read again. It is the\n\t// per-call identity memo `valueToSchema` and `schemaToShape` already carry,\n\t// and it publishes nothing.\n\t//\n\t// The ledger a tracked node keeps is one inline SLOT — the object it last\n\t// answered about and the answer it gave — because the call that reaches a\n\t// tracked node with one object is the common one, and a slot costs a\n\t// comparison where a map costs an allocation. A `WeakMap` is built only when\n\t// a SECOND distinct object arrives inside one scope, and the slot's entry is\n\t// carried into it as it is built, so the first object keeps its answer for\n\t// every later path. `filled` starts below every scope the clock hands out —\n\t// `#visits` rises before it names a scope, so no scope is 0 — and the first\n\t// call therefore always refreshes. A refresh drops the map and empties the\n\t// slot together, which is what keeps an answer from crossing calls.\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\tlet filled = 0\n\t\tlet memo: WeakMap<object, boolean> | undefined\n\t\tlet slot: object | undefined\n\t\tlet kept = false\n\t\treturn (value: unknown): value is unknown => {\n\t\t\tif (!isObject(value)) return plan(value)\n\t\t\tconst opened = ContractCompiler.#scope === 0\n\t\t\tif (opened) {\n\t\t\t\tContractCompiler.#visits += 1\n\t\t\t\tContractCompiler.#scope = ContractCompiler.#visits\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst scope = ContractCompiler.#scope\n\t\t\t\tif (filled !== scope) {\n\t\t\t\t\tmemo = undefined\n\t\t\t\t\tslot = undefined\n\t\t\t\t\tkept = false\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tif (slot === value) return kept\n\t\t\t\tif (memo !== undefined) {\n\t\t\t\t\tconst recalled = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\t}\n\t\t\t\tconst answer = plan(value)\n\t\t\t\tif (slot === undefined) {\n\t\t\t\t\tslot = value\n\t\t\t\t\tkept = answer\n\t\t\t\t} else {\n\t\t\t\t\tif (memo === undefined) {\n\t\t\t\t\t\tmemo = new ContractCompiler.#weakMap()\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [slot, kept])\n\t\t\t\t\t}\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t\t\t}\n\t\t\t\treturn answer\n\t\t\t} finally {\n\t\t\t\tif (opened) ContractCompiler.#scope = 0\n\t\t\t}\n\t\t}\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. The slot\n\t// carries that rule too: a faulted first value fills it with nothing kept, so\n\t// the node holds that value in front of it and still re-walks every later\n\t// arrival of it.\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\tlet filled = 0\n\t\tlet memo: WeakMap<object, readonly T[]> | undefined\n\t\tlet slot: object | undefined\n\t\tlet kept: readonly T[] | undefined\n\t\treturn (value: unknown, path: readonly string[]): readonly T[] => {\n\t\t\tif (!isObject(value)) return plan(value, path)\n\t\t\tconst opened = ContractCompiler.#scope === 0\n\t\t\tif (opened) {\n\t\t\t\tContractCompiler.#visits += 1\n\t\t\t\tContractCompiler.#scope = ContractCompiler.#visits\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst scope = ContractCompiler.#scope\n\t\t\t\tif (filled !== scope) {\n\t\t\t\t\tmemo = undefined\n\t\t\t\t\tslot = undefined\n\t\t\t\t\tkept = undefined\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tif (slot === value && kept !== undefined) return kept\n\t\t\t\tif (memo !== undefined) {\n\t\t\t\t\tconst recalled = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\t}\n\t\t\t\tconst answer = plan(value, path)\n\t\t\t\tif (slot === undefined) {\n\t\t\t\t\tslot = value\n\t\t\t\t\tkept = answer.length === 0 ? answer : undefined\n\t\t\t\t} else if (answer.length === 0) {\n\t\t\t\t\tif (memo === undefined) {\n\t\t\t\t\t\tmemo = new ContractCompiler.#weakMap()\n\t\t\t\t\t\tif (kept !== undefined) INTRINSICS.reflect.apply(INTRINSICS.retain, memo, [slot, kept])\n\t\t\t\t\t}\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t\t\t}\n\t\t\t\treturn answer\n\t\t\t} finally {\n\t\t\t\tif (opened) ContractCompiler.#scope = 0\n\t\t\t}\n\t\t}\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\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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: LiteralValue[] = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.values.length; index2 += 1) {\n\t\t\t\t\tconst value = owned.values[index2]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tvocabulary[vocabulary.length] = value\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 properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst required: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tproperties[key] = this.#schemaAt(child.category === 'optional' ? child.inner : child)\n\t\t\t\t\tif (child.category !== 'optional') required[required.length] = 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[] = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tvariants[variants.length] = this.#schemaAt(variant)\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\treturn this.#schemaAt(owned.inner)\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 (let step = 0; step < this.#order.length; step += 1) {\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\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#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\t// `stringOf` returns bare `isString` when unrefined, else composes the\n\t\t\t\t// length-bounds + pattern refinement — the same guard the parser re-applies.\n\t\t\t\treturn stringOf({\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\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 '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 map: Record<string, Guard<unknown>> = INTRINSICS.create(null)\n\t\t\t\tconst optionalKeys: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tif (child.category === 'optional') {\n\t\t\t\t\t\tmap[key] = this.#guardAt(child.inner)\n\t\t\t\t\t\toptionalKeys[optionalKeys.length] = key\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmap[key] = this.#guardAt(child)\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.#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: string[] = []\n\t\t\t\tconst declared = INTRINSICS.keys(map)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < declared.length; keyIndex += 1) {\n\t\t\t\t\tconst key = declared[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tlet optional = false\n\t\t\t\t\tfor (let optionalIndex = 0; optionalIndex < optionalKeys.length; optionalIndex += 1) {\n\t\t\t\t\t\tif (optionalKeys[optionalIndex] === key) optional = true\n\t\t\t\t\t}\n\t\t\t\t\tif (!optional) required[required.length] = key\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: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tlet full = 0\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let keyIndex = 0; keyIndex < required.length; keyIndex += 1) {\n\t\t\t\t\t\tconst key = required[keyIndex]\n\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\tpositions[key] = keyIndex\n\t\t\t\t\t\tfull |= 1 << keyIndex\n\t\t\t\t\t}\n\t\t\t\t}\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\tlet seen = 0\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\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 (let keyIndex = 0; keyIndex < required.length; keyIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 outcome.success && 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>> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tguards[guards.length] = this.#guardAt(variant)\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\tlet matched = 0\n\t\t\t\t\t\tfor (let index2 = 0; index2 < guards.length; index2 += 1) {\n\t\t\t\t\t\t\tconst guard = guards[index2]\n\t\t\t\t\t\t\tif (guard !== undefined && guard(value)) matched += 1\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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 = stringOf({\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\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\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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{ key: string; parse: Parser<unknown>; optional: boolean }> = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tparse: this.#parserAt(optional ? child.inner : child),\n\t\t\t\t\t\toptional,\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\tconst declared = collectMembers([])\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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\tadmitMember(declared, entry.key)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn declared\n\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: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\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 result: Record<string, unknown> = INTRINSICS.create(null)\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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\tif (absent) {\n\t\t\t\t\t\t\t\tif (entry.optional) continue\n\t\t\t\t\t\t\t\treturn undefined\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) continue\n\t\t\t\t\t\t\t\treturn undefined\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\tresult[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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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\tresult[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\tresult[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 result\n\t\t\t\t\t})\n\t\t\t\t\tif (outcome.success) 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: Array<{ parse: Parser<unknown>; guard: Guard<unknown> }> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tvariants[variants.length] = {\n\t\t\t\t\t\tparse: this.#parserAt(variant),\n\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t}\n\t\t\t\t}\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; that variant's parser then\n\t\t\t\t// runs (its parse must equal the already guard-valid input by clause A).\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\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\tlet matched = 0\n\t\t\t\t\t\tlet only: { parse: Parser<unknown>; guard: Guard<unknown> } | undefined\n\t\t\t\t\t\tfor (let index2 = 0; index2 < variants.length; index2 += 1) {\n\t\t\t\t\t\t\tconst variant = variants[index2]\n\t\t\t\t\t\t\tif (variant === undefined || !variant.guard(value)) continue\n\t\t\t\t\t\t\tmatched += 1\n\t\t\t\t\t\t\tif (matched === 1) only = variant\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn matched === 1 && only !== undefined ? only.parse(value) : undefined\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (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 (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {\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 (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {\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\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\taudit: (value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t\t\t\t\toptional: boolean\n\t\t\t\t\tkind: FaultKind\n\t\t\t\t}> = []\n\t\t\t\tconst declaredKeys = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < declaredKeys.length; keyIndex += 1) {\n\t\t\t\t\tconst key = declaredKeys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\taudit: this.#auditAt(inner),\n\t\t\t\t\t\toptional,\n\t\t\t\t\t\tkind: shapeToKind(inner),\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 = planned.success ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!outcome.success) {\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\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#auditAt(variant)\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\treturn (value, path) => {\n\t\t\t\t\tconst perVariant: Array<readonly AuditFault[]> = []\n\t\t\t\t\tlet matched = 0\n\t\t\t\t\tfor (let index2 = 0; index2 < plans.length; index2 += 1) {\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\tmatched += 1\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\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 }]\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 }\n\t\t\t\t\t\t\t: { reason: 'variant', path, variants: count },\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\treport: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\toptional: boolean\n\t\t\t\t\tkind: FaultKind\n\t\t\t\t}> = []\n\t\t\t\tconst names: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\treport: this.#reportAt(inner),\n\t\t\t\t\t\toptional,\n\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t}\n\t\t\t\t\tnames[names.length] = 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 = planned.success ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!outcome.success) {\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 plans: Array<(value: unknown, path: readonly string[]) => readonly Fault[]> = []\n\t\t\t\tconst guards: Array<Guard<unknown>> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#reportAt(variant)\n\t\t\t\t\tguards[guards.length] = this.#guardAt(variant)\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\treturn (value, path) => {\n\t\t\t\t\tconst perVariant: Array<readonly Fault[]> = []\n\t\t\t\t\tfor (let index2 = 0; index2 < plans.length; index2 += 1) {\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\tlet matched = 0\n\t\t\t\t\t\tfor (let index2 = 0; index2 < guards.length; index2 += 1) {\n\t\t\t\t\t\t\tconst guard = guards[index2]\n\t\t\t\t\t\t\tif (guard !== undefined && guard(value)) matched += 1\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[] = [{ reason: 'oneOf', path, matched: 0 }]\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 }]\n\t\t\t\t\t}\n\t\t\t\t\tconst report: Fault[] = [{ reason: 'variant', path, variants: count }]\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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\tlet value = ''\n\t\t\t\t\tfor (let step = 0; step < length; step += 1) {\n\t\t\t\t\t\tvalue += alphabet[INTRINSICS.floor(drawRandom(random, 'string') * alphabet.length)]\n\t\t\t\t\t}\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 '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\tlet value = ''\n\t\t\t\t\t\tfor (let step = 0; step < 6; step += 1) {\n\t\t\t\t\t\t\tvalue += alphabet[INTRINSICS.floor(drawRandom(random, 'json') * alphabet.length)]\n\t\t\t\t\t\t}\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\tconst result: unknown[] = []\n\t\t\t\t\tfor (let step = 0; step < length; step += 1) {\n\t\t\t\t\t\tresult[result.length] = item(random)\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\tseed: (random: RandomFunction) => unknown\n\t\t\t\t\toptional: boolean\n\t\t\t\t}> = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tseed: this.#seedAt(optional ? child.inner : child),\n\t\t\t\t\t\toptional,\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 result: Record<string, unknown> = {}\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tif (entry.optional && drawRandom(random, 'object') < 0.3) continue\n\t\t\t\t\t\tINTRINSICS.define(result, entry.key, {\n\t\t\t\t\t\t\tvalue: entry.seed(random),\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\t// An open object (additionalProperties is a shape, not a boolean) also\n\t\t\t\t\t// generates synthetic extra entries so the shape does not trivially\n\t\t\t\t\t// generate as `{}` — skip any collision with a declared property name.\n\t\t\t\t\tif (tail !== undefined) {\n\t\t\t\t\t\tconst count = 1 + INTRINSICS.floor(drawRandom(random, 'object') * 2)\n\t\t\t\t\t\tfor (let step = 0; step < count; step += 1) {\n\t\t\t\t\t\t\tconst key = `key${step}`\n\t\t\t\t\t\t\tif (INTRINSICS.own(result, key)) continue\n\t\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\t\tvalue: tail(random),\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\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> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#seedAt(variant)\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 (let attemptIndex = 0; attemptIndex < attempts; attemptIndex += 1) {\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\t!outcome.success &&\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 (outcome.success && 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 placement, and the\n * recursively supported raw-schema vocabulary where every present property or\n * dense union member is a record.\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 * Failures have deterministic precedence independent of traversal order: depth,\n * then structure, then cycle, 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: ContractShape): 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 * so an unfrozen caller-owned graph compiles 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 { ContractInterface, ContractShape, Infer } from './types.js'\nimport { contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.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.\n * Every artifact is precompiled, so `audit`, `explain` and `generate` re-walk\n * and re-gate nothing on a later call; `contract.audit` and `compileAuditor` are\n * the same compiled function reached by different names.\n * The bundle is eager by intent. Its members are plain data properties holding\n * the compiled artifacts, so `const { is, parse } = createContract(shape)`\n * destructures those exact values and a spread of the result copies them; a\n * lazily compiled member would compile on either, which spends the laziness\n * rather than saving it. A malformed declaration refuses at this call rather\n * than at the first read of whichever member a caller happens to touch, so the\n * failure arrives at the call the caller made — carrying the authoring door's\n * own diagnosis, which this door adopts rather than rewraps. Every member is\n * self-contained, and the compiler this call builds releases its working set\n * before the call returns. The contract keeps part of the declaration even so:\n * the auditor and reporter plans close over the owned leaf and array nodes they\n * read their bounds from, so a kept contract retains those nodes and, through\n * an array node's `items` field, the subgraph beneath them. Nothing the caller\n * keeps reaches back into the compiler.\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(() => new ContractCompiler(shape).contract, 'createContract')\n}\n","import type { JSONSchema } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tenumerableKeys,\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 (!snapshot.success) 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 sampled: JSONSchema[] = []\n\t\t\tconst length = INTRINSICS.min(entries.length, this.#breadth)\n\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\tsampled[sampled.length] = this.#infer(entries[index], depth - 1)\n\t\t\t}\n\t\t\treturn sampled\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (!outcome.success) 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 properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\tconst required: string[] = []\n\t\t\tlet dropped = false\n\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst propertyValue = value[key]\n\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\tdropped = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tproperties[key] = this.#infer(propertyValue, depth - 1)\n\t\t\t\trequired[required.length] = key\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 (!outcome.success) 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\tadmitMember,\n\tattempt,\n\tbuildSampleMemo,\n\tcollectMembers,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\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\t// Indexed rather than `every`, and the narrowed rows are collected as they\n\t\t// are recognized so the record branch keeps its honest typing without an\n\t\t// assertion.\n\t\tconst records: Array<Record<string, unknown>> = []\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tconst sample = samples[index]\n\t\t\tif (isRecord(sample)) records[records.length] = sample\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: JSONSchema[] = []\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tschemas[schemas.length] = new ValueInferer(\n\t\t\t\tsamples[index],\n\t\t\t\tdepth,\n\t\t\t\tthis.#breadth,\n\t\t\t\tthis.#closed,\n\t\t\t\tfalse,\n\t\t\t).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\tlet node = memo\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tconst row = samples[index]\n\t\t\tif (row === undefined) break\n\t\t\tconst next = INTRINSICS.reflect.apply(INTRINSICS.recall, node.rows, [row])\n\t\t\tif (next !== undefined) {\n\t\t\t\tnode = readSampleMemo(next, 'samplesToSchema')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst fresh = buildSampleMemo()\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, node.rows, [row, fresh])\n\t\t\tnode = fresh\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\t// Refuse the whole key-enumeration claim when any row cannot be read.\n\t\tconst seen = collectMembers([])\n\t\tconst collected: string[] = []\n\t\tfor (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex += 1) {\n\t\t\tconst sample = samples[sampleIndex]\n\t\t\t// Indexed, never iterated: the row list is walked by index so no answer\n\t\t\t// this class publishes depends on `Array.prototype[Symbol.iterator]`. The\n\t\t\t// caller's own list was already read into an owned dense snapshot, so an\n\t\t\t// absent row here is unreachable and the refusal states the invariant.\n\t\t\tif (sample === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t}\n\t\t\tconst sampleKeys = enumerableKeys(sample)\n\t\t\tif (sampleKeys === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: property enumeration failed')\n\t\t\t}\n\t\t\tfor (let keyIndex = 0; keyIndex < sampleKeys.length; keyIndex += 1) {\n\t\t\t\tconst key = sampleKeys[keyIndex]\n\t\t\t\tif (key === undefined || matchesMember(seen, key)) continue\n\t\t\t\tadmitMember(seen, key)\n\t\t\t\tcollected[collected.length] = key\n\t\t\t}\n\t\t}\n\t\tconst allKeys = sortValues(collected)\n\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\tconst truncated = allKeys.length > this.#breadth\n\t\t// Honest typing: a null-prototype accumulator so a key literally named\n\t\t// '__proto__' becomes an own data key instead of mutating the prototype —\n\t\t// the same pattern compileGuard / compileParser use (compilers.ts).\n\t\tconst properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\tconst required: string[] = []\n\t\tlet partial = truncated\n\t\t// Bounded by depth alone: unlike the single-value walk, this record-sample\n\t\t// path carries no ancestor set. A shared reference across sample rows is\n\t\t// legitimate data (not a cycle back to an ancestor), so the decrementing\n\t\t// depth budget is the sole termination guarantee here.\n\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\tconst key = keys[keyIndex]\n\t\t\tif (key === undefined) continue\n\t\t\t// Refuse the whole per-key claim when any sample value cannot be read.\n\t\t\tconst valuesOutcome = attempt(() => {\n\t\t\t\tconst values: unknown[] = []\n\t\t\t\tlet dropped = false\n\t\t\t\tfor (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex += 1) {\n\t\t\t\t\tconst sample = samples[sampleIndex]\n\t\t\t\t\tif (sample === undefined) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t\t}\n\t\t\t\t\tconst propertyValue = sample[key]\n\t\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\t\tif (INTRINSICS.own(sample, key)) dropped = true\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tvalues[values.length] = propertyValue\n\t\t\t\t}\n\t\t\t\treturn { values, dropped }\n\t\t\t})\n\t\t\tif (!valuesOutcome.success) throw valuesOutcome.error\n\t\t\tconst { values, dropped } = valuesOutcome.value\n\t\t\t// A row holding `undefined` for this key OPENS the schema; it does not\n\t\t\t// delete the column. Skipping the key entirely discarded a property two\n\t\t\t// of three rows carried as a real integer, and neither the TSDoc nor the\n\t\t\t// guide ever promised more than the opening.\n\t\t\tif (dropped) partial = true\n\t\t\tif (values.length > 0) {\n\t\t\t\t// The slot below is followed from the node this call was ENTERED with,\n\t\t\t\t// not from the row-prefix node reached above: two keys of one record\n\t\t\t\t// carry different row lists, so a shared base is what lets each land on\n\t\t\t\t// its own node instead of on a prefix of its sibling's.\n\t\t\t\tproperties[key] = this.#infer(values, depth - 1, memo)\n\t\t\t}\n\t\t\tif (!dropped && values.length === samples.length) required[required.length] = key\n\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\tadmitMember,\n\tappendEntries,\n\tattempt,\n\tcanonicalStringify,\n\tclassifyFormat,\n\tcollectMembers,\n\tcontain,\n\tmatchesMember,\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 (!snapshot.success) 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\t// A key list plus a null-prototype table, walked by index — not a `Map`\n\t\t\t\t// spread into `.sort().map()`. Every one of those is a caller-writable\n\t\t\t\t// member on the path that decides the PUBLISHED union: an emptying\n\t\t\t\t// `sort` truncated the answer and a substituted `map` replaced it\n\t\t\t\t// wholesale, both without throwing.\n\t\t\t\tconst keys: string[] = []\n\t\t\t\tconst collected = collectMembers([])\n\t\t\t\tconst byKey: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst unkeyed: JSONSchema[] = []\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst schema = owned[index]\n\t\t\t\t\tif (schema === undefined || !isRecord(schema)) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('unifySchemas: schemas must be records')\n\t\t\t\t\t}\n\t\t\t\t\tconst key = canonicalStringify(schema)\n\t\t\t\t\tif (key === undefined) {\n\t\t\t\t\t\tunkeyed[unkeyed.length] = schema\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (matchesMember(collected, key)) continue\n\t\t\t\t\tadmitMember(collected, key)\n\t\t\t\t\tkeys[keys.length] = key\n\t\t\t\t\tbyKey[key] = schema\n\t\t\t\t}\n\t\t\t\t// Both literals always canonicalize; the explicit checks keep the\n\t\t\t\t// subsumption total against `canonicalStringify`'s optional result.\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\tmatchesMember(collected, integerKey) &&\n\t\t\t\t\tmatchesMember(collected, numberKey)\n\t\t\t\t\t\t? integerKey\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst members: JSONSchema[] = []\n\t\t\t\tfor (let index = 0; index < ordered.length; index += 1) {\n\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\tif (key === undefined || key === subsumed) continue\n\t\t\t\t\tconst schema = byKey[key]\n\t\t\t\t\tif (schema === undefined) continue\n\t\t\t\t\tmembers[members.length] = schema\n\t\t\t\t}\n\t\t\t\tappendEntries(members, unkeyed)\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 { anyOf: members }\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 outcome.success ? 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 (!snapshot.success) 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\tlet first: SchemaFormat | undefined\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (!isString(value)) return undefined\n\t\t\t\t\tconst format = stringToFormat(value)\n\t\t\t\t\tif (format === undefined) return undefined\n\t\t\t\t\tif (index === 0) first = format\n\t\t\t\t\telse if (format !== first) return undefined\n\t\t\t\t}\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 (!snapshot.success) 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\tlet strings = 0\n\t\t\t\tlet numbers = 0\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (isString(value)) strings += 1\n\t\t\t\t\telse if (isFiniteNumber(value)) numbers += 1\n\t\t\t\t}\n\t\t\t\tconst allString = strings === owned.length\n\t\t\t\tconst allNumber = !allString && numbers === owned.length\n\t\t\t\tif (!allString && !allNumber) return undefined\n\t\t\t\t// A key list plus a null-prototype table, ordered through the captured\n\t\t\t\t// sort: `Map` iteration, array spread, `.sort` and `.map` are four\n\t\t\t\t// caller-writable dispatches deciding a published `enum`.\n\t\t\t\tconst keys: string[] = []\n\t\t\t\tconst collected = collectMembers([])\n\t\t\t\tconst byKey: Record<string, string | number> = INTRINSICS.create(null)\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (!isString(value) && !isFiniteNumber(value)) continue\n\t\t\t\t\tconst key = canonicalStringify(value)\n\t\t\t\t\tif (key === undefined) return undefined\n\t\t\t\t\tif (!matchesMember(collected, key)) {\n\t\t\t\t\t\tadmitMember(collected, key)\n\t\t\t\t\t\tkeys[keys.length] = key\n\t\t\t\t\t}\n\t\t\t\t\tbyKey[key] = value\n\t\t\t\t}\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: Array<string | number> = []\n\t\t\t\tfor (let index = 0; index < ordered.length; index += 1) {\n\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst value = byKey[key]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tpopulation[population.length] = value\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 (!snapshot.success) 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 { ContractShape, JSONSchema, LiteralValue } from './types.js'\nimport { INFER_BREADTH_LIMIT, INFER_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tcollectMembers,\n\tderiveLengthBounds,\n\tderiveRangeBounds,\n\tlimitEntries,\n\tmatchesMember,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\tretainDepth,\n} from './helpers.js'\nimport { isArray, isFiniteNumber, isLiteralValue, isRecord, isString } from './validators.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnullShape,\n\tnumberShape,\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.\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 #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, ContractShape>>\n\n\tconstructor(schema: JSONSchema) {\n\t\tthis.#source = schema\n\t\tthis.#visited = new SchemaShaper.#weakSet()\n\t\tthis.#memo = new SchemaShaper.#weakMap()\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 the schema is inexpressible\n\t * @throws {ContractError} When schema traversal fails\n\t */\n\tshape(): ContractShape {\n\t\treturn this.#convert(this.#source, INFER_DEPTH_LIMIT)\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): ContractShape {\n\t\tif (!(depth > 0)) return rawShape({})\n\t\tif (!matchesRecordBrand(schema)) return rawShape({})\n\t\tif (matchesVisited(this.#visited, schema)) return rawShape({})\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 depthMemo = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#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) return cached\n\t\tadmitVisited(this.#visited, schema)\n\t\ttry {\n\t\t\tconst shape = this.#build(schema, depth)\n\t\t\tretainDepth(this.#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// 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// 1. `enum` — an array with at least one string/number/boolean entry (finite\n\t// numbers only) becomes a literal shape over the filtered entries.\n\t// Non-primitive / non-finite entries are dropped; an empty result falls\n\t// through.\n\t// 2. `oneOf` — an array with at least one record entry becomes a one-of shape\n\t// over the recursively-built variants, provided the record-entry count is\n\t// at or under `INFER_BREADTH_LIMIT`; OVER the limit, building a subset\n\t// union would be strictly narrower than the schema's full union (a value\n\t// matching only a dropped variant would be wrongly rejected), so the whole\n\t// node widens to `rawShape` instead of sampling a subset.\n\t// 3. `anyOf` — identically, through `unionShape`.\n\t// 4. `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// 5. `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`.\n\t// 6. `type: 'object'`, OR no `type` / `enum` / `oneOf` / `anyOf` but a\n\t// record-valued `properties` — delegates to the object branch.\n\t// 7. 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): ContractShape {\n\t\tconst description = isString(schema.description) ? schema.description : undefined\n\n\t\tif (isArray(schema.enum)) {\n\t\t\tconst literals: LiteralValue[] = []\n\t\t\t// De-duplicated in the same pass that already drops non-literal and\n\t\t\t// non-finite entries, by the package's own SameValueZero membership.\n\t\t\t// `literalShape` refuses a repeated vocabulary, and that refusal was\n\t\t\t// republished as `schema could not be read` — a data defect reported as\n\t\t\t// unreadability, for a schema every keyword of which was read. JSON\n\t\t\t// Schema requires `enum` members to be unique, so a repeat is malformed\n\t\t\t// vocabulary, and this conversion's stated rule for malformed vocabulary\n\t\t\t// is to ignore it and widen, never to throw. First occurrence wins, so\n\t\t\t// the emitted order still follows the source.\n\t\t\tconst seen = collectMembers([])\n\t\t\tfor (let index = 0; index < schema.enum.length; index += 1) {\n\t\t\t\tconst entry = schema.enum[index]\n\t\t\t\tif (isLiteralValue(entry) && (typeof entry !== 'number' || isFiniteNumber(entry))) {\n\t\t\t\t\tif (matchesMember(seen, entry)) continue\n\t\t\t\t\tadmitMember(seen, entry)\n\t\t\t\t\tliterals[literals.length] = entry\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (literals.length > 0) {\n\t\t\t\treturn literalShape(literals, description === undefined ? undefined : { description })\n\t\t\t}\n\t\t}\n\n\t\tif (isArray(schema.oneOf)) {\n\t\t\tconst records: JSONSchema[] = []\n\t\t\tfor (let index = 0; index < schema.oneOf.length; index += 1) {\n\t\t\t\tconst entry = schema.oneOf[index]\n\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t}\n\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t}\n\t\t\tconst variants: ContractShape[] = []\n\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\tconst entry = records[index]\n\t\t\t\tif (entry === undefined) continue\n\t\t\t\tvariants[variants.length] = this.#convert(entry, depth - 1)\n\t\t\t}\n\t\t\t// `Reflect.apply` reads its argument list by index, where a spread call\n\t\t\t// would dispatch through the caller-writable array iterator.\n\t\t\tif (variants.length > 0) return INTRINSICS.reflect.apply(oneOfShape, undefined, variants)\n\t\t}\n\n\t\tif (isArray(schema.anyOf)) {\n\t\t\tconst records: JSONSchema[] = []\n\t\t\tfor (let index = 0; index < schema.anyOf.length; index += 1) {\n\t\t\t\tconst entry = schema.anyOf[index]\n\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t}\n\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t}\n\t\t\tconst variants: ContractShape[] = []\n\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\tconst entry = records[index]\n\t\t\t\tif (entry === undefined) continue\n\t\t\t\tvariants[variants.length] = this.#convert(entry, depth - 1)\n\t\t\t}\n\t\t\tif (variants.length > 0) return INTRINSICS.reflect.apply(unionShape, undefined, variants)\n\t\t}\n\n\t\tconst type = isString(schema.type) ? schema.type : undefined\n\n\t\tif (type === 'string') {\n\t\t\tconst bounds = deriveLengthBounds(schema.minLength, schema.maxLength)\n\t\t\treturn stringShape({\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\t\tif (type === 'number') {\n\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\n\t\t\treturn numberShape({\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\t\tif (type === 'integer') {\n\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\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: { description }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t\t...(description === undefined ? {} : { description }),\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 = isRecord(schema.items) ? this.#convert(schema.items, depth - 1) : rawShape({})\n\t\t\tconst bounds = deriveLengthBounds(schema.minItems, schema.maxItems)\n\t\t\treturn arrayShape(items, {\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\n\t\tif (type === 'object' || (type === undefined && isRecord(schema.properties))) {\n\t\t\treturn this.#buildObject(schema, depth, description)\n\t\t}\n\n\t\treturn rawShape(description === undefined ? {} : { description })\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.\n\t#buildObject(schema: JSONSchema, depth: number, description: string | undefined): ContractShape {\n\t\tconst propertiesSource = isRecord(schema.properties) ? schema.properties : undefined\n\t\t// Indexed rather than `filter` / `includes`: this list decides which\n\t\t// properties the published shape marks required, and both are\n\t\t// caller-writable members.\n\t\tconst requiredSource = collectMembers([])\n\t\tif (isArray(schema.required)) {\n\t\t\tfor (let index = 0; index < schema.required.length; index += 1) {\n\t\t\t\tconst entry = schema.required[index]\n\t\t\t\tif (isString(entry)) admitMember(requiredSource, entry)\n\t\t\t}\n\t\t}\n\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t// prototype — the same pattern the record inference uses.\n\t\tconst properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\tlet truncated = false\n\t\tif (propertiesSource) {\n\t\t\tconst allKeys = INTRINSICS.keys(propertiesSource)\n\t\t\ttruncated = allKeys.length > INFER_BREADTH_LIMIT\n\t\t\tconst keys = limitEntries(allKeys, INFER_BREADTH_LIMIT)\n\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst child = propertiesSource[key]\n\t\t\t\tconst childShape = isRecord(child) ? this.#convert(child, depth - 1) : rawShape({})\n\t\t\t\tproperties[key] = matchesMember(requiredSource, key)\n\t\t\t\t\t? childShape\n\t\t\t\t\t: optionalShape(childShape)\n\t\t\t}\n\t\t}\n\t\tconst extra = schema.additionalProperties\n\t\tconst additionalProperties: boolean | ContractShape = truncated\n\t\t\t? true\n\t\t\t: extra === false\n\t\t\t\t? false\n\t\t\t\t: isRecord(extra)\n\t\t\t\t\t? this.#convert(extra, depth - 1)\n\t\t\t\t\t: true\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","import type {\n\tArrayShape,\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\tRawShape,\n\tRecordShapeOptions,\n\tStringShape,\n\tStringShapeOptions,\n\tUnionShape,\n} from './types.js'\nimport { cloneSchema, cloneShape } from './cloners.js'\nimport { SchemaShaper } from './SchemaShaper.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tattempt,\n\tcontain,\n\tmatchesRecordBrand,\n\tpreview,\n\treadArrayEntries,\n\treadOptions,\n\treadPatternFlags,\n\treadPatternSource,\n\treadValue,\n} from './helpers.js'\nimport { isLiteralValue, isObject, isRegExp } from './validators.js'\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\tnew ShapeValidator(shape).validate()\n\t\treturn 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\tnew ShapeValidator(result).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 (!array.success || !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...(!array.success ? { 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 (!snapshot.success) {\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: LiteralValue[] = []\n\t\tfor (let index = 0; index < snapshot.value.entries.length; index += 1) {\n\t\t\tconst value = snapshot.value.entries[index]\n\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: ['values', INTRINSICS.text(index)], shape: 'literal' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tliterals[literals.length] = value\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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 snapshot: { [K in keyof P]: P[K] } = INTRINSICS.create(null)\n\t\t\t\tconst keyList = INTRINSICS.keys(input)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tINTRINSICS.reflect.define(snapshot, key, {\n\t\t\t\t\t\tvalue: INTRINSICS.reflect.read(input, key),\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\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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 * @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\tconst shape: UnionShape<V> = { category: 'union', variants }\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze({ 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, that variant's parser runs. Zero matches or\n * two-or-more matches both parse to `undefined` — a value ambiguous\n * between variants has no well-defined coercion target.\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\tconst shape: UnionShape<V> = {\n\t\t\tcategory: 'union',\n\t\t\tvariants,\n\t\t\tmode: 'oneOf',\n\t\t}\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze({ ...shape, variants: INTRINSICS.freeze(variants) })\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.\n *\n * @param inner - The wrapped shape\n * @returns An optional shape\n */\nexport function optionalShape<S extends ContractShape>(inner: S): OptionalShape<S> {\n\treturn contain(() => {\n\t\tconst shape: OptionalShape<S> = { category: 'optional', inner }\n\t\tnew ShapeValidator({ category: 'object', properties: { value: shape } }).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(shape)\n\t}, 'jsonShape')\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 * 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\tconst owned = cloneSchema(schema)\n\t\tnew ShapeValidator({ category: 'raw', schema: owned }).validate()\n\t\treturn INTRINSICS.freeze({ category: 'raw', schema: owned })\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, this\n * conversion is total and widens an inexpressible input to a valid raw `{}`.\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 * @param schema - The JSON Schema value to convert\n * @returns The built {@link ContractShape}\n * @throws {ContractError} When schema traversal fails\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): ContractShape {\n\treturn contain(() => {\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\treturn readValue(() => new SchemaShaper(schema).shape(), 'schemaToShape', {\n\t\t\tsubject: 'schema',\n\t\t\tcontext: { shape: 'schema' },\n\t\t})\n\t}, 'schemaToShape')\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,uBAAuB,OAAO,IAAI,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsE1E,IAAa,aAAa,OAAO,OAAO;;CAEvC,QAAQ,OAAO;;CAEf,QAAQ,OAAO;;CAEf,MAAM,OAAO;;CAEb,QAAQ,OAAO;;CAEf,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,QAAQ,OAAO;;CAEf,UAAU,OAAO;;CAEjB,QAAQ,OAAO;;CAEf,WAAW,OAAO;;CAElB,SAAS,OAAO;;CAEhB,MAAM,OAAO;;;;;;;;;;;;CAYb,SAAS,OAAO,OAAO;;EAEtB,MAAM,QAAQ;;EAEd,OAAO,QAAQ;;EAEf,SAAS,QAAQ;;EAEjB,SAAS,QAAQ;;EAEjB,UAAU,QAAQ;;EAElB,QAAQ,QAAQ;;EAEhB,WAAW,QAAQ;;EAEnB,OAAO,QAAQ;;EAEf,WAAW,QAAQ;CACpB,CAAC;;CAED,QAAQ,OAAO;;CAEf,SAAS,OAAO;;CAEhB,MAAM,OAAO;;CAEb,KAAK,OAAO;;CAEZ,OAAO,MAAM;;CAEb,WAAW,KAAK;;CAEhB,QAAQ,KAAK;;CAEb,OAAO,KAAK;;CAEZ,MAAM,KAAK;;CAEX,KAAK,KAAK;;CAEV,KAAK,KAAK;;CAEV,MAAM,KAAK;;CAEX,MAAM;;CAEN,SAAS;;CAET,SAAS;;;;;;;;;;;;;;CAcT,UAAU,OAAO,U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B,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,KAAK,YAAY;EAC5E;EACA,IAAI,eAAe,KAAK,CAAC,CAAC,SAAS;EACnC,OAAO,WAAW,OAAO,KAAK;CAC/B,GAAG,WAAW;AACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,SAAS,QAA8B;CACtD,OAAO,cAAc;EACpB,IAAI,eAAe;GAAE,UAAU;GAAO;EAAO,CAAC,CAAC,CAAC,SAAS;EACzD,MAAM,QAAQ,YAAY,MAAM;EAChC,IAAI,eAAe;GAAE,UAAU;GAAO,QAAQ;EAAM,CAAC,CAAC,CAAC,SAAS;EAChE,OAAO,WAAW,OAAO;GAAE,UAAU;GAAO,QAAQ;EAAM,CAAC;CAC5D,GAAG,UAAU;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,SAAgB,cAAc,QAAmC;CAChE,OAAO,cAAc;EASpB,OAAO,gBAAgB,IAAI,aAAa,MAAM,CAAC,CAAC,MAAM,GAAG,iBAAiB;GACzE,SAAS;GACT,SAAS,EAAE,OAAO,SAAS;EAC5B,CAAC;CACF,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/ShapeValidator.ts","../../../src/core/ShapeCloner.ts","../../../src/core/cloners.ts","../../../src/core/combinators.ts","../../../src/core/parsers.ts","../../../src/core/ContractCompiler.ts","../../../src/core/compilers.ts","../../../src/core/factories.ts","../../../src/core/ValueInferer.ts","../../../src/core/SampleInferer.ts","../../../src/core/inferers.ts","../../../src/core/SchemaShaper.ts","../../../src/core/shapers.ts"],"sourcesContent":["import type { ContractCode, JSONSchemaType } from './types.js'\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.error')\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 `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.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 `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.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 `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 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// 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","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 = '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 (let index = 0; index < members.length; index += 1) {\n\t\t\tconst key = members[index]\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, the fixed name, and a declared contract code.\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 (value.name !== 'ContractError' || !('code' in value)) 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 = value.code\n\t\t// Indexed over the one declared vocabulary. `collectMembers` /\n\t\t// `matchesMember` express the same membership everywhere else in the\n\t\t// package, and this file cannot reach them: `helpers.ts` imports this\n\t\t// module, so asking it would invert the dependency — the same reason this\n\t\t// guard carries its own `try` / `catch`.\n\t\tfor (let index = 0; index < CONTRACT_CODES.length; index += 1) {\n\t\t\tif (code === CONTRACT_CODES[index]) return true\n\t\t}\n\t\treturn false\n\t} catch {\n\t\treturn false\n\t}\n}\n","import type {\n\tAnyAsyncFunction,\n\tAnyConstructor,\n\tAnyFunction,\n\tJSONPrimitive,\n\tJSONRecord,\n\tJSONValue,\n\tLiteralValue,\n\tZeroArgAsyncFunction,\n\tZeroArgFunction,\n} from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tholds,\n\tmatchesJSONDepth,\n\tmatchesJSONValue,\n\tmatchesRecordBrand,\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/** 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\tContractShape,\n\tEntryCollectorFunction,\n\tFault,\n\tFaultKind,\n\tFieldPath,\n\tGuard,\n\tGuardShapeRead,\n\tGuardsShape,\n\tJSONSchema,\n\tJSONValue,\n\tNumberShape,\n\tRandomFunction,\n\tReadValueOptions,\n\tResult,\n\tSampleMemo,\n\tSchemaFormat,\n\tStringShape,\n} from './types.js'\nimport {\n\tCOMPILE_NODE_LIMIT,\n\tCONTRACT_CODES,\n\tFORMAT_PATTERNS,\n\tGUARD_DEPTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tPREVIEW_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tisBigInt,\n\tisArray,\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 * 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 extended: string[] = []\n\tfor (let index = 0; index < path.length; index += 1) {\n\t\tconst existing = path[index]\n\t\tif (existing === undefined) continue\n\t\textended[extended.length] = existing\n\t}\n\tfor (let index = 0; index < segments.length; index += 1) {\n\t\tconst segment = segments[index]\n\t\tif (segment === undefined) continue\n\t\textended[extended.length] = segment\n\t}\n\treturn extended\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 (let index = 0; index < source.length; index += 1) {\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 bounded: T[] = []\n\tfor (let index = 0; index < limit; index += 1) {\n\t\tconst entry = entries[index]\n\t\tif (entry === undefined) continue\n\t\tbounded[bounded.length] = entry\n\t}\n\treturn bounded\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 * compareValues('a', 'b') // -1\n * ```\n */\nexport function compareValues<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 compareValues}, 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 owned: T[] = []\n\tfor (let index = 0; index < values.length; index += 1) {\n\t\tconst value = values[index]\n\t\tif (value === undefined) continue\n\t\towned[owned.length] = value\n\t}\n\tINTRINSICS.reflect.apply(INTRINSICS.order, owned, [compareValues])\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 *\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 members = new INTRINSICS.set<unknown>()\n\tfor (let index = 0; index < values.length; index += 1) {\n\t\tINTRINSICS.reflect.apply(INTRINSICS.admit, members, [values[index]])\n\t}\n\treturn members\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 compareValues} 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: unknown[] = []\n\t\tfor (let index = 0; index < collected.length; index += 1) {\n\t\t\tconst pair = collected[index]\n\t\t\tif (pair === undefined) continue\n\t\t\tentries[entries.length] = 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 * 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\tlet stateless = ''\n\tfor (let index = 0; index < flags.length; index += 1) {\n\t\tconst flag = flags[index]\n\t\tif (flag === undefined || flag === 'g' || flag === 'y') continue\n\t\tstateless += flag\n\t}\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 (let index = 0; index < members.length; index += 1) {\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 * 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 outcome.success && outcome.value\n * ```\n */\nexport function attempt<T>(callback: () => T): Result<T> {\n\ttry {\n\t\treturn { success: true, value: callback() }\n\t} catch (error) {\n\t\treturn { success: false, error }\n\t}\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 && matchesMember(collectMembers(CONTRACT_CODES), requested)\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 (!diagnostics.success) {\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 (!outcome.success) {\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 (outcome.success) 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 outcome.success && 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 (let index = 0; index < mandated.length; index += 1) {\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\tlet matched = 0\n\t\twhile (matched < length && members[matched] === INTRINSICS.text(matched)) matched += 1\n\t\tif (matched === length && members.length === length + 1 && members[length] === 'length') {\n\t\t\tconst packed = new INTRINSICS.list<T | undefined>(length)\n\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\tconst key = members[index]\n\t\t\t\tif (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\tpacked[index] = value[index]\n\t\t\t}\n\t\t\treturn INTRINSICS.freeze({ entries: INTRINSICS.freeze(packed), dense: true })\n\t\t}\n\t\tconst collected: number[] = []\n\t\tconst keys: string[] = []\n\t\tlet ascending = true\n\t\tlet previous = -1\n\t\tfor (let position = 0; position < members.length; position += 1) {\n\t\t\tconst key = members[position]\n\t\t\tif (!isString(key)) continue\n\t\t\tconst index = INTRINSICS.numeric(key)\n\t\t\tif (\n\t\t\t\tINTRINSICS.integer(index) &&\n\t\t\t\tindex >= 0 &&\n\t\t\t\tindex < 2 ** 32 - 1 &&\n\t\t\t\tINTRINSICS.text(index) === key\n\t\t\t) {\n\t\t\t\tif (index >= length) throw new INTRINSICS.error('Array index views disagree')\n\t\t\t\tif (index <= previous) ascending = false\n\t\t\t\tprevious = index\n\t\t\t\tcollected[collected.length] = index\n\t\t\t\tkeys[keys.length] = key\n\t\t\t}\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 entries = new INTRINSICS.list<T | undefined>(length)\n\t\tfor (let position = 0; position < indices.length; position += 1) {\n\t\t\tconst index = indices[position]\n\t\t\tif (index === undefined) continue\n\t\t\tconst key = ascending ? keys[position] : INTRINSICS.text(index)\n\t\t\tif (key === undefined || !INTRINSICS.own(value, key)) {\n\t\t\t\tthrow new INTRINSICS.error('Array index views disagree')\n\t\t\t}\n\t\t\tentries[index] = value[index]\n\t\t}\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 guards: Record<string, Guard<unknown> | undefined> = INTRINSICS.create(null)\n\t\t\tconst names: string[] = []\n\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\tconst key = members[index]\n\t\t\t\tif (!isString(key)) continue\n\t\t\t\tif (!INTRINSICS.own(guards, key)) names[names.length] = key\n\t\t\t\tguards[key] = shape[key]\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 (!entries.success) throw entries.error\n\t\t\tif (!entries.value.dense) throw new INTRINSICS.error('Optional key list must be dense')\n\t\t\tconst keys = collectMembers([])\n\t\t\tfor (let index = 0; index < entries.value.entries.length; index += 1) {\n\t\t\t\tadmitMember(keys, INTRINSICS.text(entries.value.entries[index]))\n\t\t\t}\n\t\t\treturn keys\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 outcome.success ? 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 values: Record<string, unknown> = INTRINSICS.create(null)\n\t\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tvalues[key] = INTRINSICS.reflect.read(input, key)\n\t\t\t\t\tINTRINSICS.reflect.present(input, key)\n\t\t\t\t\tINTRINSICS.reflect.describe(input, key)\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 snapshot: T = INTRINSICS.create(INTRINSICS.base)\n\t\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\t\tconst key = keys[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst value = values[key]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tINTRINSICS.reflect.define(snapshot, key, {\n\t\t\t\t\t\tvalue,\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\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 (!outcome.success) {\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\tlet current: unknown = record\n\t\t// Indexed: the caller's own path array is walked through its own index\n\t\t// properties rather than through `Array.prototype[Symbol.iterator]`, so an\n\t\t// injected leading segment cannot redirect the lookup.\n\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) return undefined\n\t\t\tif (!isObject(current) || !INTRINSICS.own(current, key)) return undefined\n\t\t\tcurrent = INTRINSICS.reflect.read(current, key)\n\t\t}\n\t\treturn current\n\t})\n\treturn outcome.success ? outcome.value : undefined\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 (!snapshot.success) return false\n\t\t\t\tconst children = INTRINSICS.values(snapshot.value.entries)\n\t\t\t\tfor (let index = 0; index < children.length; index += 1) {\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 (let index = 0; index < keys.length; index += 1) {\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. 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 * @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(entry: unknown, ancestors: WeakSet<object>): entry is JSONValue {\n\treturn readValue(\n\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\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 (matchesVisited(proved, node)) continue\n\t\t\t\t\tconst snapshot = readArrayEntries(node)\n\t\t\t\t\tif (!snapshot.success) 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 (let index = entries.length - 1; index >= 0; index -= 1) {\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 (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 (let index = members.length - 1; index >= 0; index -= 1) {\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// === Random\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\tlet state = seed >>> 0\n\treturn () => {\n\t\tstate = (state + 0x6d2b79f5) >>> 0\n\t\tlet t = state\n\t\tt = INTRINSICS.imul(t ^ (t >>> 15), t | 1)\n\t\tt ^= t + INTRINSICS.imul(t ^ (t >>> 7), t | 61)\n\t\treturn ((t ^ (t >>> 14)) >>> 0) / 4_294_967_296\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\tlet count = 0\n\t\t// Indexed: `Object.getOwnPropertySymbols` returns a fresh array this module\n\t\t// owns, and walking it through `Array.prototype[Symbol.iterator]` would let\n\t\t// a replaced iterator decide an emptiness verdict.\n\t\tconst symbols = INTRINSICS.symbols(value)\n\t\tfor (let index = 0; index < symbols.length; index += 1) {\n\t\t\tconst symbol = symbols[index]\n\t\t\tif (symbol === undefined) continue\n\t\t\tif (INTRINSICS.describe(value, symbol)?.enumerable) {\n\t\t\t\tcount += 1\n\t\t\t}\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 (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\t// Indexed and concatenated, not iterated and joined: this string IS\n\t\t\t\t\t// the canonical identity every schema de-duplication and every `enum`\n\t\t\t\t\t// ordering is keyed by, and both `Array.prototype[Symbol.iterator]`\n\t\t\t\t\t// and `Array.prototype.join` are caller-writable members on it.\n\t\t\t\t\tlet encoded = ''\n\t\t\t\t\tfor (let index = 0; index < frame.members.length; index += 1) {\n\t\t\t\t\t\tconst member = frame.members[index]\n\t\t\t\t\t\tconst part = isObject(member)\n\t\t\t\t\t\t\t? (INTRINSICS.reflect.apply(INTRINSICS.recall, encodings, [member]) ??\n\t\t\t\t\t\t\t\tencodeLeaf(member))\n\t\t\t\t\t\t\t: encodeLeaf(member)\n\t\t\t\t\t\tif (part === undefined) return undefined\n\t\t\t\t\t\tconst key = frame.keys?.[index]\n\t\t\t\t\t\tconst text = key === undefined ? part : `${INTRINSICS.stringify(key)}:${part}`\n\t\t\t\t\t\tencoded += index === 0 ? text : `,${text}`\n\t\t\t\t\t}\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 members: unknown[] = []\n\t\t\t\tconst selected: string[] = []\n\t\t\t\tlet keys: readonly string[] | undefined\n\t\t\t\tif (isArray(container)) {\n\t\t\t\t\tconst snapshot = readArrayEntries(container)\n\t\t\t\t\tif (!snapshot.success) throw snapshot.error\n\t\t\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\t\t\t// Indexed, not `appendEntries`: a PRESENT `undefined` element is a\n\t\t\t\t\t// value JSON cannot encode and must abandon the whole encoding, and\n\t\t\t\t\t// the shared appender skips `undefined` by design.\n\t\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\t\tfor (let index = 0; index < entries.length; index += 1) {\n\t\t\t\t\t\tmembers[members.length] = entries[index]\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst names = sortValues(INTRINSICS.keys(container))\n\t\t\t\t\tfor (let index = 0; index < names.length; index += 1) {\n\t\t\t\t\t\tconst key = names[index]\n\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\tselected[selected.length] = key\n\t\t\t\t\t\tmembers[members.length] = INTRINSICS.reflect.read(container, key)\n\t\t\t\t\t}\n\t\t\t\t\tkeys = selected\n\t\t\t\t}\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 (let index = members.length - 1; index >= 0; index -= 1) {\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 outcome.success && 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\tlet text = quoted ? '\"' : ''\n\t\tlet index = 0\n\t\twhile (index < source.length) {\n\t\t\tconst first = source[index]\n\t\t\tif (first === undefined) break\n\t\t\tconst second = index + 1 < source.length ? source[index + 1] : undefined\n\t\t\tconst paired =\n\t\t\t\tfirst >= '\\ud800' &&\n\t\t\t\tfirst <= '\\udbff' &&\n\t\t\t\tsecond !== undefined &&\n\t\t\t\tsecond >= '\\udc00' &&\n\t\t\t\tsecond <= '\\udfff'\n\t\t\tconst character = paired ? `${first}${second}` : first\n\t\t\tconst encoded = INTRINSICS.stringify(character)\n\t\t\tconst tokenLength = encoded.length - 2\n\t\t\tif (text.length + tokenLength > PREVIEW_LIMIT) return `${text}…`\n\t\t\tlet tokenIndex = 1\n\t\t\twhile (tokenIndex <= tokenLength) {\n\t\t\t\tconst token = encoded[tokenIndex]\n\t\t\t\tif (token !== undefined) text += token\n\t\t\t\ttokenIndex += 1\n\t\t\t}\n\t\t\tindex += paired ? 2 : 1\n\t\t}\n\t\tif (!quoted) return text\n\t\treturn text.length < PREVIEW_LIMIT ? `${text}\"` : `${text}…`\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 (shape.min !== undefined && value.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: '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 (shape.max !== undefined && value.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: '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 ?? (shape.pattern === undefined ? undefined : 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 = shape.integer === true ? 'integer' : 'number'\n\t\t\tconst faults: Fault[] = []\n\t\t\tif (shape.integer === true && !INTRINSICS.integer(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: 'integer',\n\t\t\t\t\treceived: preview(value),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (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 (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 (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 (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\tlet closest: readonly T[] | undefined\n\tfor (let index = 0; index < reports.length; index += 1) {\n\t\tconst report = reports[index]\n\t\tif (report === undefined) continue\n\t\tif (closest === undefined || report.length < closest.length) closest = report\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 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 '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","import type { JSONClonerInterface, JSONRecord, JSONValue, Result } from './types.js'\nimport { CLONE_NODE_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tcollectMembers,\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// Every node this walk PRODUCES, not every node the source holds: the two\n\t// differ by exactly the alias duplication the tree contract requires, and it\n\t// is the produced count that grows exponentially.\n\t#produced: number\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.#produced = 0\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 * @returns The settled JSON snapshot\n\t * @throws {ContractError} When the source is inexact, cyclic, unreadable, or cloning is reentered\n\t */\n\tclone(): JSONValue {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined) {\n\t\t\tif (terminal.success) 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 = { success: false, error: 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())\n\t\tconst interruption = this.#terminal\n\t\tif (interruption !== undefined) {\n\t\t\tif (interruption.success) return interruption.value\n\t\t\tthis.#fail(interruption.error)\n\t\t}\n\t\tif (outcome.success) {\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 = { success: false, error }\n\t\tthis.#pending = JSONCloner.#emptyPending\n\t\tthrow error\n\t}\n\n\t#execute(): JSONValue {\n\t\tconst root = this.#capture(this.#source)\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[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])\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): 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\tthis.#produced += 1\n\t\tif (this.#produced > CLONE_NODE_LIMIT) {\n\t\t\tthis.#refuse('cloneJSONValue: snapshot exceeds the node limit')\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 (!arrayOutcome.success) 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 (!keysOutcome.success) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst lengthOutcome = attempt(() => INTRINSICS.reflect.describe(source, 'length'))\n\t\tif (!lengthOutcome.success) this.#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\tconst entries: Array<[key: string, value: unknown]> = []\n\t\tfor (let index = 0; index < lengthDescriptor.value; index += 1) {\n\t\t\tconst key = INTRINSICS.text(index)\n\t\t\tif (!matchesMember(owned, key)) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array own keys are not exact')\n\t\t\t}\n\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\tif (!descriptorOutcome.success) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array index could not be inspected')\n\t\t\t}\n\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\tif (descriptor === undefined || !('value' in descriptor) || descriptor.enumerable !== true) {\n\t\t\t\tthis.#refuse('cloneJSONValue: array index is not enumerable data')\n\t\t\t}\n\t\t\tentries[entries.length] = [key, descriptor.value]\n\t\t}\n\t\treturn entries\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 (!keysOutcome.success) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst entries: Array<[key: string, value: unknown]> = []\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\tfor (let index = 0; index < names.length; index += 1) {\n\t\t\tconst key = names[index]\n\t\t\tif (typeof key !== 'string') this.#refuse('cloneJSONValue: record has a symbol property')\n\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.reflect.describe(source, key))\n\t\t\tif (!descriptorOutcome.success) {\n\t\t\t\tthis.#refuse('cloneJSONValue: record property could not be inspected')\n\t\t\t}\n\t\t\tconst descriptor = descriptorOutcome.value\n\t\t\tif (descriptor === undefined || !('value' in descriptor) || descriptor.enumerable !== true) {\n\t\t\t\tthis.#refuse('cloneJSONValue: record property is not enumerable data')\n\t\t\t}\n\t\t\tentries[entries.length] = [key, descriptor.value]\n\t\t}\n\t\treturn entries\n\t}\n\n\t#create(message: string): ContractError {\n\t\tconst error = new ContractError(message, {\n\t\t\tcode: 'clone',\n\t\t\tcontext: { shape: 'json' },\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): never {\n\t\tconst terminal = this.#terminal\n\t\tif (terminal !== undefined && !terminal.success) throw terminal.error\n\t\tthrow this.#create(message)\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\tenumerableKeys,\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 (state.result.success) 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({ success: false, error: state.poison })\n\t\t}\n\t\tif (outcome.success) 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({ success: false, 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\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst path = pathOf(frame.path, key)\n\t\t\t\tconst source = this.#read(frame.source, key, path)\n\t\t\t\tconst clone = this.#capture(source, path, frame.depth + 1)\n\t\t\t\tINTRINSICS.define(frame.clone, key, {\n\t\t\t\t\tvalue: clone,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\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 (outcome.success) 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 (result.success) 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, ShapeValidatorInterface, StringShape } from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tattempt,\n\tcollectMembers,\n\tmatchesMember,\n\tmatchesVisited,\n\tomitVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isLiteralValue, isRecord, isRegExp } from './validators.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\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// the global binding. Cleanup runs OUTSIDE the contained walk, at both ends\n\t// of every call, so a replaced `WeakSet` would throw the caller's raw value\n\t// out of a door documented to throw a `ContractError` before any containment\n\t// exists. Every other dispatch on the traversal path runs inside the\n\t// contained walk and is translated below.\n\tstatic readonly #weakSet = WeakSet\n\tstatic readonly #weakMap = WeakMap\n\treadonly #source: ContractShape\n\t#state:\n\t\t| { readonly phase: 'idle' }\n\t\t| { readonly phase: 'active'; readonly poison?: ContractError } = { phase: 'idle' }\n\t#stack: Array<\n\t\t| {\n\t\t\t\treadonly operation: 'enter'\n\t\t\t\treadonly shape: ContractShape | undefined\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 ShapeValidator.#weakSet<ContractShape>()\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 ShapeValidator.#weakMap<ContractShape, number>()\n\t#captures: Array<{\n\t\treadonly shape: ContractShape\n\t\treadonly category: ContractShape['category'] | undefined\n\t\treadonly children: ReadonlyArray<{\n\t\t\treadonly shape: ContractShape | undefined\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}> = []\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// 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 ShapeValidator.#weakMap<object, number>()\n\t#expansion: number | undefined = undefined\n\t#children: Array<{\n\t\treadonly shape: ContractShape | undefined\n\t\treadonly optional: boolean\n\t\treadonly first: string\n\t\treadonly second?: string\n\t}> = []\n\t#category: ContractShape['category'] | undefined\n\t#raw = 0\n\t#structure: ContractError | undefined\n\t#cycle: ContractError | undefined\n\t#domain: ContractError | 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: ContractShape) {\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\tif (this.#state.phase === 'active') {\n\t\t\tconst poison =\n\t\t\t\tthis.#state.poison ??\n\t\t\t\tnew ContractError('ShapeValidator.validate: shape validation may not be reentered', {\n\t\t\t\t\tcode: 'structure',\n\t\t\t\t\tcontext: { path: [] },\n\t\t\t\t})\n\t\t\tthis.#state = { phase: 'active', poison }\n\t\t\tthrow poison\n\t\t}\n\n\t\tthis.#clear()\n\t\tthis.#state = { phase: 'active' }\n\t\tconst outcome = attempt(() => this.#execute())\n\t\tconst poison = this.#state.phase === 'active' ? this.#state.poison : undefined\n\t\tthis.#clear()\n\t\tif (poison !== undefined) {\n\t\t\tthis.#expansion = undefined\n\t\t\tthrow poison\n\t\t}\n\t\tif (outcome.success) return\n\t\t// A contained failure this class did not author came from a caller-\n\t\t// reachable dispatch on the traversal path — a replaced intrinsic member,\n\t\t// a polluted diagnostic read — and rethrowing it verbatim would put the\n\t\t// caller's raw value through a door whose contract is a `ContractError`.\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#clear(): void {\n\t\tthis.#state = { phase: 'idle' }\n\t\tthis.#stack = []\n\t\tthis.#path = []\n\t\tthis.#active = new ShapeValidator.#weakSet()\n\t\tthis.#index = new ShapeValidator.#weakMap()\n\t\tthis.#captures = []\n\t\tthis.#post = []\n\t\tthis.#height = []\n\t\tthis.#reach = []\n\t\tthis.#via = []\n\t\tthis.#counts = []\n\t\tthis.#schemas = new ShapeValidator.#weakMap()\n\t\tthis.#children = []\n\t\tthis.#category = undefined\n\t\tthis.#raw = 0\n\t\tthis.#structure = undefined\n\t\tthis.#cycle = undefined\n\t\tthis.#domain = undefined\n\t}\n\n\t#execute(): void {\n\t\tthis.#expansion = undefined\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\tthis.#expansion = this.#counts[0] ?? 1\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\tlet segments = 0\n\t\tif (frame.first !== undefined) {\n\t\t\tthis.#path[this.#path.length] = frame.first\n\t\t\tsegments += 1\n\t\t}\n\t\tif (frame.second !== undefined) {\n\t\t\tthis.#path[this.#path.length] = frame.second\n\t\t\tsegments += 1\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\tconst outcome = attempt(() => this.#observe(current, frame.depth))\n\t\tif (!outcome.success || !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: ContractShape, 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 = this.#recognize(category)\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 (!outcome.success) {\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 (!outcome.success) {\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 (!outcome.success) {\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 (!outcome.success) {\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#recognize(category: ContractShape['category']): readonly string[] | undefined {\n\t\tswitch (category) {\n\t\t\tcase 'string':\n\t\t\t\treturn ['min', 'max', 'pattern', 'description']\n\t\t\tcase 'number':\n\t\t\t\treturn ['integer', 'min', 'max', 'description']\n\t\t\tcase 'boolean':\n\t\t\tcase 'null':\n\t\t\tcase 'json':\n\t\t\t\treturn ['description']\n\t\t\tcase 'literal':\n\t\t\t\treturn ['values', 'description']\n\t\t\tcase 'array':\n\t\t\t\treturn ['items', 'min', 'max', 'description']\n\t\t\tcase 'object':\n\t\t\t\treturn ['properties', 'additionalProperties', 'description']\n\t\t\tcase 'union':\n\t\t\t\treturn ['variants', 'mode', 'description']\n\t\t\tcase 'optional':\n\t\t\tcase 'nullable':\n\t\t\t\treturn ['inner']\n\t\t\tcase 'raw':\n\t\t\t\treturn ['schema']\n\t\t}\n\t}\n\n\t#scan(current: ContractShape, fields: readonly string[]): boolean {\n\t\tfor (let fieldIndex = 0; fieldIndex < fields.length; fieldIndex += 1) {\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 (!outcome.success || !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: ContractShape): 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 === '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\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(!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(!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\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: StringShape, source = '', flags = ''): void {\n\t\tif (\n\t\t\tthis.#domain === undefined &&\n\t\t\tcurrent.min !== undefined &&\n\t\t\t(!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(!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\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 (!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 ShapeValidator.#weakSet<object>()\n\t\tconst stack: Array<\n\t\t\t| { readonly operation: 'enter'; readonly schema: unknown }\n\t\t\t| { readonly operation: 'exit'; readonly schema: object; readonly nested: readonly unknown[] }\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 schema = frame.schema\n\t\t\tif (!isRecord(schema)) {\n\t\t\t\treturn this.#refuse(\n\t\t\t\t\t'validateShape: every raw schema child must be a plain record',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (matchesVisited(active, schema)) {\n\t\t\t\treturn this.#refuse('validateShape: a raw schema may not contain a cycle', 'schema')\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 (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\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 !== '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.#refuse('validateShape: raw schema contains an unsupported keyword', 'schema')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst category = schema.type\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.#refuse(\n\t\t\t\t\t'validateShape: raw schema type is outside the supported vocabulary',\n\t\t\t\t\t'schema',\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (schema.description !== undefined && typeof schema.description !== 'string') {\n\t\t\t\treturn this.#refuse('validateShape: raw schema description must be a string', 'schema')\n\t\t\t}\n\t\t\tif (schema.format !== undefined && typeof schema.format !== 'string') {\n\t\t\t\treturn this.#refuse('validateShape: raw schema format must be a string', 'schema')\n\t\t\t}\n\t\t\tif (schema.pattern !== undefined) {\n\t\t\t\tif (typeof schema.pattern !== 'string') {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema pattern must be a string', 'schema')\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 (!pattern.success) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema pattern must be valid', 'schema')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst lengthList = ['minLength', 'maxLength', 'minItems', 'maxItems']\n\t\t\tfor (let lengthIndex = 0; lengthIndex < lengthList.length; lengthIndex += 1) {\n\t\t\t\tconst key = lengthList[lengthIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = schema[key]\n\t\t\t\tif (value !== undefined && (!INTRINSICS.safe(value) || INTRINSICS.numeric(value) < 0)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema length bounds must be non-negative safe integers',\n\t\t\t\t\t\t'schema',\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 (let rangeIndex = 0; rangeIndex < rangeList.length; rangeIndex += 1) {\n\t\t\t\tconst key = rangeList[rangeIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst value = schema[key]\n\t\t\t\tif (value !== undefined && (typeof value !== 'number' || !INTRINSICS.finite(value))) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema numeric bounds must be finite numbers',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst population = schema.enum\n\t\t\tif (population !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(population)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be a non-empty array', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(population)\n\t\t\t\tif (!snapshot.success || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be a non-empty array', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema enum must be dense', 'schema')\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 (let valueIndex = 0; valueIndex < snapshot.value.entries.length; valueIndex += 1) {\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.#refuse(\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\t'schema',\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 = schema.required\n\t\t\tif (names !== undefined) {\n\t\t\t\tif (!INTRINSICS.array(names)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be an array', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(names)\n\t\t\t\tif (!snapshot.success) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be an array', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema required must be dense', 'schema')\n\t\t\t\t}\n\t\t\t\tconst required = collectMembers([])\n\t\t\t\tfor (let valueIndex = 0; valueIndex < snapshot.value.entries.length; valueIndex += 1) {\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.#refuse(\n\t\t\t\t\t\t\t'validateShape: raw schema required values must be unique strings',\n\t\t\t\t\t\t\t'schema',\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\tif (schema.items !== undefined) nested[nested.length] = schema.items\n\t\t\tif (schema.properties !== undefined) {\n\t\t\t\tif (!isRecord(schema.properties)) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShape: raw schema properties must be a plain record',\n\t\t\t\t\t\t'schema',\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 (let propertyIndex = 0; propertyIndex < propertyList.length; propertyIndex += 1) {\n\t\t\t\t\tconst key = propertyList[propertyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tnested[nested.length] = schema.properties[key]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\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\tnested[nested.length] = schema.additionalProperties\n\t\t\t}\n\t\t\tconst unionList = ['anyOf', 'oneOf']\n\t\t\tfor (let unionIndex = 0; unionIndex < unionList.length; unionIndex += 1) {\n\t\t\t\tconst key = unionList[unionIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst variants = schema[key]\n\t\t\t\tif (variants === undefined) continue\n\t\t\t\tif (!INTRINSICS.array(variants)) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be non-empty arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tconst snapshot = readArrayEntries(variants)\n\t\t\t\tif (!snapshot.success || snapshot.value.entries.length === 0) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be non-empty arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShape: raw schema unions must be dense arrays', 'schema')\n\t\t\t\t}\n\t\t\t\tfor (\n\t\t\t\t\tlet variantIndex = 0;\n\t\t\t\t\tvariantIndex < snapshot.value.entries.length;\n\t\t\t\t\tvariantIndex += 1\n\t\t\t\t) {\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\tnested[nested.length] = snapshot.value.entries[variantIndex]\n\t\t\t\t}\n\t\t\t}\n\t\t\tstack[stack.length] = { operation: 'exit', schema, nested }\n\t\t\tfor (let index = nested.length - 1; index >= 0; index -= 1) {\n\t\t\t\tstack[stack.length] = { operation: 'enter', schema: nested[index] }\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\tlet height = 0\n\t\tfor (let index = 0; index < nested.length; index += 1) {\n\t\t\tconst child = nested[index]\n\t\t\tconst recorded =\n\t\t\t\ttypeof child !== 'object' || child === null\n\t\t\t\t\t? 0\n\t\t\t\t\t: (INTRINSICS.reflect.apply(INTRINSICS.recall, this.#schemas, [child]) ?? 0)\n\t\t\tif (recorded + 1 > height) height = recorded + 1\n\t\t}\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#schemas, [schema, height])\n\t}\n\n\t#populate(current: ContractShape): boolean {\n\t\tswitch (current.category) {\n\t\t\tcase 'array':\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(properties, key))\n\t\t\t\t\tif (!descriptorOutcome.success) {\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(() => current.properties[key])\n\t\t\t\t\tif (!childOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.properties[key], child) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, child),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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\tif (extra !== undefined && extra !== true && extra !== false) {\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 (!snapshot.success) {\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 (let index = 0; index < length; index += 1) {\n\t\t\t\t\tconst key = INTRINSICS.text(index)\n\t\t\t\t\tconst descriptorOutcome = attempt(() => INTRINSICS.describe(current.variants, key))\n\t\t\t\t\tif (!descriptorOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.variants[index], variant) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, variant),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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 (!snapshot.success) {\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 (let index = 0; index < length; index += 1) {\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 (!descriptorOutcome.success) {\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\t() =>\n\t\t\t\t\t\t\tINTRINSICS.same(current.values[index], value) &&\n\t\t\t\t\t\t\tINTRINSICS.same(descriptor.value, value),\n\t\t\t\t\t)\n\t\t\t\t\tif (!stable.success) {\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.#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 'raw':\n\t\t\t\tbreak\n\t\t}\n\t\treturn true\n\t}\n\n\t#schedule(current: ContractShape, depth: number, segments: number): number {\n\t\tadmitVisited(this.#active, current)\n\t\tconst children: Array<{\n\t\t\treadonly shape: ContractShape | undefined\n\t\t\treadonly optional: boolean\n\t\t\treadonly first: string\n\t\t\treadonly second?: string\n\t\t}> = []\n\t\tfor (let index = 0; index < this.#children.length; index += 1) {\n\t\t\tconst child = this.#children[index]\n\t\t\tif (child === undefined) continue\n\t\t\tchildren[children.length] = child\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 (let index = children.length - 1; index >= 0; index -= 1) {\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...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t}\n\t\t}\n\t\treturn captured\n\t}\n\n\t#capture(\n\t\tshape: ContractShape,\n\t\tchildren: ReadonlyArray<{\n\t\t\treadonly shape: ContractShape | undefined\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] = { shape, category: this.#category, children, raw: this.#raw }\n\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, this.#index, [shape, index])\n\t\treturn index\n\t}\n\n\t#locate(shape: ContractShape | undefined): number | undefined {\n\t\tif (shape === undefined) 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\tfor (let index = 0; index < this.#captures.length; index += 1) {\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\t// A back edge to a still-open ancestor leaves no order to compute a height\n\t\t// in, so a cyclic capture takes the ordered path walk instead.\n\t\tif (this.#cycle !== undefined) {\n\t\t\tthis.#trace()\n\t\t\treturn\n\t\t}\n\t\tfor (let step = 0; step < this.#post.length; step += 1) {\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\tlet height = 0\n\t\t\tlet count = 1\n\t\t\tfor (let edge = 0; edge < capture.children.length; edge += 1) {\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\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\tif (reached + 1 > height) height = reached + 1\n\t\t\t\tcount += located === undefined ? 1 : (this.#counts[located] ?? 1)\n\t\t\t}\n\t\t\tthis.#height[index] = height\n\t\t\tthis.#counts[index] = count\n\t\t}\n\t\tif ((this.#height[0] ?? 0) > COMPILE_DEPTH_LIMIT) this.#witness()\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 (let step = this.#post.length - 1; step >= 0; step -= 1) {\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 (let edge = 0; edge < capture.children.length; edge += 1) {\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...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (let index = 0; index < this.#captures.length; index += 1) {\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}\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\tconst reversed: string[] = []\n\t\tlet current = index\n\t\twhile (current !== 0) {\n\t\t\tconst edge = this.#via[current]\n\t\t\tif (edge === undefined) break\n\t\t\tif (edge.second !== undefined) reversed[reversed.length] = edge.second\n\t\t\treversed[reversed.length] = edge.first\n\t\t\tcurrent = edge.parent\n\t\t}\n\t\tconst path: string[] = []\n\t\tfor (let step = reversed.length - 1; step >= 0; step -= 1) {\n\t\t\tconst segment = reversed[step]\n\t\t\tif (segment === undefined) continue\n\t\t\tpath[path.length] = segment\n\t\t}\n\t\treturn path\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(): never {\n\t\tconst path: string[] = []\n\t\tlet index: number | undefined = 0\n\t\tlet depth = 0\n\t\twhile (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\tlet chosen:\n\t\t\t\t| {\n\t\t\t\t\t\treadonly shape: ContractShape | undefined\n\t\t\t\t\t\treadonly first: string\n\t\t\t\t\t\treadonly second?: string\n\t\t\t\t }\n\t\t\t\t| undefined\n\t\t\tfor (let edge = 0; edge < children.length; edge += 1) {\n\t\t\t\tconst child = children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tconst located = this.#locate(child.shape)\n\t\t\t\tconst reached = located === undefined ? 0 : (this.#height[located] ?? 0)\n\t\t\t\tif (depth + 1 + reached > COMPILE_DEPTH_LIMIT) {\n\t\t\t\t\tchosen = child\n\t\t\t\t\tindex = located\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (chosen === undefined) break\n\t\t\tpath[path.length] = chosen.first\n\t\t\tif (chosen.second !== undefined) path[path.length] = chosen.second\n\t\t\tdepth += 1\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// The cyclic fallback. It walks the CAPTURED nodes and edges — never the\n\t// caller's source again — carrying the deepest start each node already cleared,\n\t// so a shared child off the cycle is still not re-walked from a shallower\n\t// position. Depth outranks the recorded cycle, exactly as before: a back edge\n\t// first reached beyond the limit is a depth refusal, and one reached inside it\n\t// leaves the cycle to speak.\n\t//\n\t// A clearance is only reusable when the walk that produced it did not depend on\n\t// the CALLER's path. A walk stopped by the active set stopped at some ancestor,\n\t// and which ancestor decides everything: one admitted inside this subtree is\n\t// re-admitted at the same relative place on every later arrival, so the walk\n\t// repeats and the clearance holds; one that was already active when the subtree\n\t// was entered belongs to the route in, and a later, shallower arrival without it\n\t// walks on through the cycle to a depth this walk never measured. Memoizing that\n\t// second kind made the verdict depend on how long the alias chain to the node\n\t// was — shortening a declaration by one link turned `depth` into `cycle`.\n\t//\n\t// Admission order tells the two apart with one comparison and no extra\n\t// collection: a node's own admission number bounds its subtree, so a blocker\n\t// numbered below it came from outside. `oldest` carries the lowest-numbered\n\t// blocker the open subtree met, seeded one past the subtree root so an\n\t// unblocked walk compares as internal, and each exit hands its parent the lower\n\t// of the two.\n\t#trace(): void {\n\t\tconst settled: number[] = []\n\t\tconst order: number[] = []\n\t\tlet clock = 0\n\t\tlet oldest = 0\n\t\tconst active = new ShapeValidator.#weakSet<ContractShape>()\n\t\tconst path: string[] = []\n\t\tconst stack: Array<\n\t\t\t| {\n\t\t\t\t\treadonly operation: 'enter'\n\t\t\t\t\treadonly index: number | undefined\n\t\t\t\t\treadonly depth: number\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 index: number\n\t\t\t\t\treadonly depth: number\n\t\t\t\t\treadonly segments: number\n\t\t\t\t\treadonly outer: number\n\t\t\t }\n\t\t> = [{ operation: 'enter', index: 0, depth: 0 }]\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\tconst capture = this.#captures[frame.index]\n\t\t\t\tif (capture !== undefined) omitVisited(active, capture.shape)\n\t\t\t\tif (oldest >= (order[frame.index] ?? 0) && (settled[frame.index] ?? -1) < frame.depth) {\n\t\t\t\t\tsettled[frame.index] = frame.depth\n\t\t\t\t}\n\t\t\t\tif (frame.outer < oldest) oldest = frame.outer\n\t\t\t\tpath.length -= frame.segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlet segments = 0\n\t\t\tif (frame.first !== undefined) {\n\t\t\t\tpath[path.length] = frame.first\n\t\t\t\tsegments += 1\n\t\t\t}\n\t\t\tif (frame.second !== undefined) {\n\t\t\t\tpath[path.length] = frame.second\n\t\t\t\tsegments += 1\n\t\t\t}\n\t\t\tif (frame.depth > COMPILE_DEPTH_LIMIT) {\n\t\t\t\tthrow new ContractError('validateShape: a shape exceeds the compilation depth limit', {\n\t\t\t\t\tcode: 'depth',\n\t\t\t\t\tcontext: { path: pathOf(path), limit: COMPILE_DEPTH_LIMIT },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst index = frame.index\n\t\t\tconst capture = index === undefined ? undefined : this.#captures[index]\n\t\t\tif (index === undefined || capture === undefined) {\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (matchesVisited(active, capture.shape)) {\n\t\t\t\tconst blocker = order[index] ?? 0\n\t\t\t\tif (blocker < oldest) oldest = blocker\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst recorded = settled[index]\n\t\t\tif (recorded !== undefined && frame.depth <= recorded) {\n\t\t\t\tpath.length -= segments\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tadmitVisited(active, capture.shape)\n\t\t\torder[index] = clock\n\t\t\tclock += 1\n\t\t\tstack[stack.length] = {\n\t\t\t\toperation: 'exit',\n\t\t\t\tindex,\n\t\t\t\tdepth: frame.depth,\n\t\t\t\tsegments,\n\t\t\t\touter: oldest,\n\t\t\t}\n\t\t\toldest = clock\n\t\t\tfor (let edge = capture.children.length - 1; edge >= 0; edge -= 1) {\n\t\t\t\tconst child = capture.children[edge]\n\t\t\t\tif (child === undefined) continue\n\t\t\t\tstack[stack.length] = {\n\t\t\t\t\toperation: 'enter',\n\t\t\t\t\tindex: this.#locate(child.shape),\n\t\t\t\t\tdepth: frame.depth + 1,\n\t\t\t\t\tfirst: child.first,\n\t\t\t\t\t...(child.second === undefined ? {} : { second: child.second }),\n\t\t\t\t}\n\t\t\t}\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#refuse(message: string, first?: string, second?: string): false {\n\t\tif (this.#structure === undefined) {\n\t\t\tconst path = pathOf(this.#path, 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\tstatic {\n\t\t// Pinned while this class is DEFINED: `ShapeCloner`'s `#validateShape` and\n\t\t// `validateShape` reach it through `ShapeValidator.prototype.validate`,\n\t\t// so an assignment there decides whether a shape gate the caller never\n\t\t// touched ever runs.\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\tStringShape,\n\tUnionShape,\n} from './types.js'\nimport { COMPILE_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tpathOf,\n\tpinMembers,\n\treadArrayEntries,\n\treadPatternFlags,\n\treadPatternSource,\n} from './helpers.js'\nimport { isLiteralValue, isObject, isRecord, isRegExp } from './validators.js'\nimport { SchemaCloner } from './SchemaCloner.js'\nimport { ShapeValidator } from './ShapeValidator.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 (state.result.success) 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({ success: false, error: state.poison })\n\t\t}\n\t\tif (outcome.success) 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({ success: false, error })\n\t}\n\n\t#execute(): ContractShape {\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()\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\tthis.#validateShape(root)\n\t\tif (this.#fidelity !== undefined) throw this.#fidelity\n\t\treturn root\n\t}\n\n\t#drain(): 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\tlet cursor = 0\n\t\twhile (cursor < this.#pending.length) {\n\t\t\tconst entry = this.#pending[cursor]\n\t\t\tcursor += 1\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()\n\t\t\tthis.#captureNode(entry.shape, entry.depth)\n\t\t}\n\t}\n\n\t// The gate that OWNS the depth rule authors the diagnosis, on the same source\n\t// `validateShape` would be handed, so `cloneShape` and `validateShape` cannot disagree about\n\t// which node exceeded the limit or what the refusal says.\n\t#refuseDepth(): never {\n\t\tthis.#validateShape(this.#source)\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(source: ContractShape, path: readonly string[]): 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)\n\t\t\tcase 'object':\n\t\t\t\treturn this.#captureObject(source, path)\n\t\t\tcase 'union':\n\t\t\t\treturn this.#captureUnion(source, path)\n\t\t\tcase 'optional':\n\t\t\t\treturn this.#captureWrapper(source, path, 'optional')\n\t\t\tcase 'nullable':\n\t\t\t\treturn this.#captureWrapper(source, path, 'nullable')\n\t\t\tcase 'json':\n\t\t\t\treturn this.#captureSimple(source, path, 'json')\n\t\t\tcase 'raw':\n\t\t\t\treturn this.#captureRaw(source, path)\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\t!repeated.success ||\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): 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)\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,\n\t\tpath: readonly string[],\n\t\tcategory: 'boolean' | 'null' | 'json',\n\t): BooleanShape | NullShape | JSONShape {\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\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[]): ArrayShape {\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(source: ObjectShape, path: readonly string[]): 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)\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[]): 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)\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#captureWrapper(\n\t\tsource: OptionalShape | NullableShape,\n\t\tpath: readonly string[],\n\t\tcategory: 'optional' | 'nullable',\n\t): OptionalShape | NullableShape {\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 category === 'optional'\n\t\t\t? { category: 'optional', inner }\n\t\t\t: { category: 'nullable', inner }\n\t}\n\n\t#captureRaw(source: RawShape, path: readonly string[]): 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 })\n\t\tconst outcome = attempt(() => new SchemaCloner(schema).clone())\n\t\tif (!outcome.success) {\n\t\t\tif (isContractError(outcome.error)) {\n\t\t\t\tadmitVisited(this.#owned, outcome.error)\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 (!snapshot.success) {\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: LiteralValue[] = []\n\t\tfor (let index = 0; index < snapshot.value.entries.length; index += 1) {\n\t\t\tentries[entries.length] = 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\t!descriptor.success ||\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\t!repeated.success ||\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): void {\n\t\tconst keys = INTRINSICS.keys(properties)\n\t\tconst snapshot: ShapeProperty[] = []\n\t\t// Indexed, not iterated: this walk decides the cloned shape's property\n\t\t// population.\n\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\tconst key = keys[index]\n\t\t\tif (key === undefined) continue\n\t\t\tconst descriptor = INTRINSICS.describe(properties, key)\n\t\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst child = properties[key]\n\t\t\tconst repeated = properties[key]\n\t\t\tconst described: unknown = descriptor.value\n\t\t\tif (!INTRINSICS.same(described, child) || !INTRINSICS.same(child, repeated)) {\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tsnapshot[snapshot.length] = { key, child }\n\t\t}\n\t\tconst repeated = INTRINSICS.keys(properties)\n\t\tlet drifted = repeated.length !== keys.length\n\t\tfor (let index = 0; index < repeated.length; index += 1) {\n\t\t\tif (repeated[index] !== keys[index]) drifted = true\n\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): 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 (!snapshot.success) {\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\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 (let index = 0; index < entries.length; index += 1) {\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\t!descriptor.success ||\n\t\t\t\tdescriptor.value === undefined ||\n\t\t\t\t!INTRINSICS.own(descriptor.value, 'value') ||\n\t\t\t\t!repeated.success ||\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 (let index = 0; index < properties.length; index += 1) {\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 (let index = 0; index < variants.length; index += 1) {\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 (let sourceIndex = 0; sourceIndex < this.#sources.length; sourceIndex += 1) {\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 properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\tconst entry = snapshot[index]\n\t\t\tif (entry === undefined) continue\n\t\t\tconst { key, child } = entry\n\t\t\tif (child === 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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [child])\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, 'properties', key) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tproperties[key] = cloned\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: ContractShape[] = []\n\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\tconst variant = snapshot[index]\n\t\t\tif (variant === 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, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst cloned = INTRINSICS.reflect.apply(INTRINSICS.fetch, memo, [variant])\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, 'variants', INTRINSICS.text(index)) },\n\t\t\t\t})\n\t\t\t}\n\t\t\tvariants[variants.length] = cloned\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 (let sourceIndex = 0; sourceIndex < this.#sources.length; sourceIndex += 1) {\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(shape: ContractShape): void {\n\t\tconst outcome = attempt(() => new ShapeValidator(shape).validate())\n\t\tif (outcome.success) return\n\t\tif (isContractError(outcome.error)) {\n\t\t\tadmitVisited(this.#owned, outcome.error)\n\t\t}\n\t\tthrow outcome.error\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 (result.success) 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 { INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport { attempt, contain, holds } 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 (fidelity.success) return fidelity.value\n\t\tif (isContractError(fidelity.error) && fidelity.error.code !== 'clone') {\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 (!validation.success && isContractError(validation.error)) throw validation.error\n\t\tthrow fidelity.error\n\t}, 'ownShape')\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 { GUARD_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.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\tcollectMembers,\n\tcontain,\n\tholds,\n\tmatchesMember,\n\tmatchesPattern,\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 (!entries.success || !entries.value.dense) return false\n\t\t\tfor (let index = 0; index < entries.value.entries.length; index += 1) {\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 (!entries.success || !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 (let index = 0; index < guards.length; index += 1) {\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 (!entries.success) 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\tlet literal = true\n\t\t\tfor (let index = 0; index < snapshot.length; index += 1) {\n\t\t\t\tif (!isLiteralValue(snapshot[index])) literal = false\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 (!entries.success) return false\n\t\t\tfor (let index = 0; index < entries.value.length; index += 1) {\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 (!entries.success) return false\n\t\t\tfor (let index = 0; index < entries.value.length; index += 1) {\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 (let index = 0; index < members.length; index += 1) {\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 (let index = 0; index < declared.names.length; index += 1) {\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 (let index = 0; index < declared.names.length; index += 1) {\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 (!entries.success) 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 result: { [P in keyof S]: S[P] } = INTRINSICS.create(null)\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && matchesMember(selected, key)) {\n\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\tvalue: shape[key],\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\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 (!entries.success) 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 result: { [P in keyof S]: S[P] } = INTRINSICS.create(null)\n\t\t\t\tconst members = INTRINSICS.reflect.members(shape)\n\t\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\t\tconst key = members[index]\n\t\t\t\t\tif (isString(key) && !matchesMember(skipped, key)) {\n\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\tvalue: shape[key],\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\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 (let index = 0; index < guards.length; index += 1) {\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 (let index = 0; index < guards.length; index += 1) {\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 = { value: number; children: Tree[] }\n * let isTree: Guard<Tree>\n * isTree = recordOf({ value: isNumber, children: arrayOf(lazyOf(() => isTree)) })\n * ```\n */\nexport function lazyOf<T>(thunk: () => Guard<T>): Guard<T> {\n\tlet depth = 0\n\treturn (value: unknown): value is T => {\n\t\tif (depth >= GUARD_DEPTH_LIMIT) return false\n\t\tdepth += 1\n\t\ttry {\n\t\t\treturn holds(() => thunk()(value))\n\t\t} finally {\n\t\t\tdepth -= 1\n\t\t}\n\t}\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 boundsOf} on the string's `.length` and\n * an owned 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\tconst min = safe?.min\n\t\tconst max = safe?.max\n\t\tconst source = safe?.pattern\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\tconst withinLength = boundsOf(min, max)\n\t\treturn whereOf(\n\t\t\tisString,\n\t\t\t(value) =>\n\t\t\t\twithinLength(value.length) && (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\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 outcome.success ? 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 (!entries.success || !entries.value.dense) return undefined\n\tif (\n\t\t!holds(() => {\n\t\t\t// Indexed: the snapshot is an array this package built, and walking it\n\t\t\t// through `Array.prototype[Symbol.iterator]` would let a replaced iterator\n\t\t\t// decide which elements this parser ever guards.\n\t\t\tconst collected = entries.value.entries\n\t\t\tfor (let index = 0; index < collected.length; index += 1) {\n\t\t\t\tif (!guard(collected[index])) return false\n\t\t\t}\n\t\t\treturn true\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 (!outcome.success || !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// === 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 checked.success ? checked.value : undefined\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\tLiteralValue,\n\tNumberShape,\n\tParser,\n\tRandomFunction,\n\tReporterFunction,\n\tResult,\n\tSeederFunction,\n\tStringShape,\n} from './types.js'\nimport {\n\tFAULT_LIMIT,\n\tGENERATION_ATTEMPT_LIMIT,\n\tINTRINSICS,\n\tPRESENCE_MASK_LIMIT,\n} from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tappendEntries,\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tbuildArrayFaults,\n\tbuildNumberFaults,\n\tbuildStringFaults,\n\tdrawRandom,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\n\townPattern,\n\tpathOf,\n\tpinMembers,\n\tpreview,\n\treadArrayEntries,\n\treadPatternSource,\n\treadValue,\n\trefuseExpansion,\n\tseededRandom,\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 { cloneSchema, ownShape } from './cloners.js'\nimport { ShapeValidator } from './ShapeValidator.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. 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.\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 call-scoped value ledger's clock. `#visits` hands out one identity per\n\t// top-level walk and `#scope` names the walk that is running, so a node's memo can\n\t// say which call filled it. Both are static because a compiled artifact is\n\t// self-contained by design — it must not reach instance state its compiler\n\t// releases — and because those numbers are the whole of it: no value, no\n\t// answer, and nothing that outlives the walk that set them.\n\tstatic #visits = 0\n\tstatic #scope = 0\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 (!outcome.success) {\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// 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\tconst validator = new ShapeValidator(owned)\n\t\tvalidator.validate()\n\t\trefuseExpansion(validator.expansion)\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\tthis.#nodes[index] = shape\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 (let index = shape.variants.length - 1; index >= 0; index -= 1) {\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 (let index = keys.length - 1; index >= 0; index -= 1) {\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 (let index = 0; index < this.#nodes.length; index += 1) {\n\t\t\tif (this.#nodes[index]?.category === 'union') return true\n\t\t}\n\t\treturn false\n\t}\n\n\t// === Call-scoped value ledger\n\t//\n\t// A compiled artifact applies each child artifact once per OCCURRENCE, and a\n\t// value graph is a DAG as often as a declaration is — two slots holding one\n\t// object is ordinary data, not an attack. That costs one visit per PATH: a\n\t// twenty-three-node `arrayShape` chain over twenty-two shared arrays measured\n\t// 524,286 node reads, 4.4 s for `is` and 8.4 s for `audit`, growing fourfold\n\t// per two levels, for a declaration inside every published bound. The answer a\n\t// compiled node gives about one object is a function of that object, so it is\n\t// computed once per call and reused by every later path that arrives at the\n\t// same pair. The scope tag is what keeps that reuse INSIDE one call, since a\n\t// value the caller changes between two calls must be read again. It is the\n\t// per-call identity memo `valueToSchema` and `schemaToShape` already carry,\n\t// and it publishes nothing.\n\t//\n\t// The ledger a tracked node keeps is one inline SLOT — the object it last\n\t// answered about and the answer it gave — because the call that reaches a\n\t// tracked node with one object is the common one, and a slot costs a\n\t// comparison where a map costs an allocation. A `WeakMap` is built only when\n\t// a SECOND distinct object arrives inside one scope, and the slot's entry is\n\t// carried into it as it is built, so the first object keeps its answer for\n\t// every later path. `filled` starts below every scope the clock hands out —\n\t// `#visits` rises before it names a scope, so no scope is 0 — and the first\n\t// call therefore always refreshes. A refresh drops the map and empties the\n\t// slot together, which is what keeps an answer from crossing calls.\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\tlet filled = 0\n\t\tlet memo: WeakMap<object, boolean> | undefined\n\t\tlet slot: object | undefined\n\t\tlet kept = false\n\t\treturn (value: unknown): value is unknown => {\n\t\t\tif (!isObject(value)) return plan(value)\n\t\t\tconst opened = ContractCompiler.#scope === 0\n\t\t\tif (opened) {\n\t\t\t\tContractCompiler.#visits += 1\n\t\t\t\tContractCompiler.#scope = ContractCompiler.#visits\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst scope = ContractCompiler.#scope\n\t\t\t\tif (filled !== scope) {\n\t\t\t\t\tmemo = undefined\n\t\t\t\t\tslot = undefined\n\t\t\t\t\tkept = false\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tif (slot === value) return kept\n\t\t\t\tif (memo !== undefined) {\n\t\t\t\t\tconst recalled = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\t}\n\t\t\t\tconst answer = plan(value)\n\t\t\t\tif (slot === undefined) {\n\t\t\t\t\tslot = value\n\t\t\t\t\tkept = answer\n\t\t\t\t} else {\n\t\t\t\t\tif (memo === undefined) {\n\t\t\t\t\t\tmemo = new ContractCompiler.#weakMap()\n\t\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [slot, kept])\n\t\t\t\t\t}\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t\t\t}\n\t\t\t\treturn answer\n\t\t\t} finally {\n\t\t\t\tif (opened) ContractCompiler.#scope = 0\n\t\t\t}\n\t\t}\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. The slot\n\t// carries that rule too: a faulted first value fills it with nothing kept, so\n\t// the node holds that value in front of it and still re-walks every later\n\t// arrival of it.\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\tlet filled = 0\n\t\tlet memo: WeakMap<object, readonly T[]> | undefined\n\t\tlet slot: object | undefined\n\t\tlet kept: readonly T[] | undefined\n\t\treturn (value: unknown, path: readonly string[]): readonly T[] => {\n\t\t\tif (!isObject(value)) return plan(value, path)\n\t\t\tconst opened = ContractCompiler.#scope === 0\n\t\t\tif (opened) {\n\t\t\t\tContractCompiler.#visits += 1\n\t\t\t\tContractCompiler.#scope = ContractCompiler.#visits\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst scope = ContractCompiler.#scope\n\t\t\t\tif (filled !== scope) {\n\t\t\t\t\tmemo = undefined\n\t\t\t\t\tslot = undefined\n\t\t\t\t\tkept = undefined\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tif (slot === value && kept !== undefined) return kept\n\t\t\t\tif (memo !== undefined) {\n\t\t\t\t\tconst recalled = INTRINSICS.reflect.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\t}\n\t\t\t\tconst answer = plan(value, path)\n\t\t\t\tif (slot === undefined) {\n\t\t\t\t\tslot = value\n\t\t\t\t\tkept = answer.length === 0 ? answer : undefined\n\t\t\t\t} else if (answer.length === 0) {\n\t\t\t\t\tif (memo === undefined) {\n\t\t\t\t\t\tmemo = new ContractCompiler.#weakMap()\n\t\t\t\t\t\tif (kept !== undefined) INTRINSICS.reflect.apply(INTRINSICS.retain, memo, [slot, kept])\n\t\t\t\t\t}\n\t\t\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, memo, [value, answer])\n\t\t\t\t}\n\t\t\t\treturn answer\n\t\t\t} finally {\n\t\t\t\tif (opened) ContractCompiler.#scope = 0\n\t\t\t}\n\t\t}\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\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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: LiteralValue[] = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.values.length; index2 += 1) {\n\t\t\t\t\tconst value = owned.values[index2]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tvocabulary[vocabulary.length] = value\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 properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst required: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tproperties[key] = this.#schemaAt(child.category === 'optional' ? child.inner : child)\n\t\t\t\t\tif (child.category !== 'optional') required[required.length] = 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[] = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tvariants[variants.length] = this.#schemaAt(variant)\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\treturn this.#schemaAt(owned.inner)\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 (let step = 0; step < this.#order.length; step += 1) {\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\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#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\t// `stringOf` returns bare `isString` when unrefined, else composes the\n\t\t\t\t// length-bounds + pattern refinement — the same guard the parser re-applies.\n\t\t\t\treturn stringOf({\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\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 '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 map: Record<string, Guard<unknown>> = INTRINSICS.create(null)\n\t\t\t\tconst optionalKeys: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tif (child.category === 'optional') {\n\t\t\t\t\t\tmap[key] = this.#guardAt(child.inner)\n\t\t\t\t\t\toptionalKeys[optionalKeys.length] = key\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmap[key] = this.#guardAt(child)\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.#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: string[] = []\n\t\t\t\tconst declared = INTRINSICS.keys(map)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < declared.length; keyIndex += 1) {\n\t\t\t\t\tconst key = declared[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tlet optional = false\n\t\t\t\t\tfor (let optionalIndex = 0; optionalIndex < optionalKeys.length; optionalIndex += 1) {\n\t\t\t\t\t\tif (optionalKeys[optionalIndex] === key) optional = true\n\t\t\t\t\t}\n\t\t\t\t\tif (!optional) required[required.length] = key\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: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tlet full = 0\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let keyIndex = 0; keyIndex < required.length; keyIndex += 1) {\n\t\t\t\t\t\tconst key = required[keyIndex]\n\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\tpositions[key] = keyIndex\n\t\t\t\t\t\tfull |= 1 << keyIndex\n\t\t\t\t\t}\n\t\t\t\t}\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\tlet seen = 0\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\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 (let keyIndex = 0; keyIndex < required.length; keyIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 outcome.success && 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>> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tguards[guards.length] = this.#guardAt(variant)\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\tlet matched = 0\n\t\t\t\t\t\tfor (let index2 = 0; index2 < guards.length; index2 += 1) {\n\t\t\t\t\t\t\tconst guard = guards[index2]\n\t\t\t\t\t\t\tif (guard !== undefined && guard(value)) matched += 1\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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 = stringOf({\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\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\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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{ key: string; parse: Parser<unknown>; optional: boolean }> = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tparse: this.#parserAt(optional ? child.inner : child),\n\t\t\t\t\t\toptional,\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\tconst declared = collectMembers([])\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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\tadmitMember(declared, entry.key)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn declared\n\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: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\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 result: Record<string, unknown> = INTRINSICS.create(null)\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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\tif (absent) {\n\t\t\t\t\t\t\t\tif (entry.optional) continue\n\t\t\t\t\t\t\t\treturn undefined\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) continue\n\t\t\t\t\t\t\t\treturn undefined\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\tresult[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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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\tresult[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\tresult[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 result\n\t\t\t\t\t})\n\t\t\t\t\tif (outcome.success) 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: Array<{ parse: Parser<unknown>; guard: Guard<unknown> }> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tvariants[variants.length] = {\n\t\t\t\t\t\tparse: this.#parserAt(variant),\n\t\t\t\t\t\tguard: this.#guardAt(variant),\n\t\t\t\t\t}\n\t\t\t\t}\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; that variant's parser then\n\t\t\t\t// runs (its parse must equal the already guard-valid input by clause A).\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\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\tlet matched = 0\n\t\t\t\t\t\tlet only: { parse: Parser<unknown>; guard: Guard<unknown> } | undefined\n\t\t\t\t\t\tfor (let index2 = 0; index2 < variants.length; index2 += 1) {\n\t\t\t\t\t\t\tconst variant = variants[index2]\n\t\t\t\t\t\t\tif (variant === undefined || !variant.guard(value)) continue\n\t\t\t\t\t\t\tmatched += 1\n\t\t\t\t\t\t\tif (matched === 1) only = variant\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn matched === 1 && only !== undefined ? only.parse(value) : undefined\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn (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 (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {\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 (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {\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\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\taudit: (value: unknown, path: readonly string[]) => readonly AuditFault[]\n\t\t\t\t\toptional: boolean\n\t\t\t\t\tkind: FaultKind\n\t\t\t\t}> = []\n\t\t\t\tconst declaredKeys = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < declaredKeys.length; keyIndex += 1) {\n\t\t\t\t\tconst key = declaredKeys[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\taudit: this.#auditAt(inner),\n\t\t\t\t\t\toptional,\n\t\t\t\t\t\tkind: shapeToKind(inner),\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 = planned.success ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!outcome.success) {\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\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#auditAt(variant)\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\treturn (value, path) => {\n\t\t\t\t\tconst perVariant: Array<readonly AuditFault[]> = []\n\t\t\t\t\tlet matched = 0\n\t\t\t\t\tfor (let index2 = 0; index2 < plans.length; index2 += 1) {\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\tmatched += 1\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\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 }]\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 }\n\t\t\t\t\t\t\t: { reason: 'variant', path, variants: count },\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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 '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 (!entries.success) {\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 (let entryIndex = 0; entryIndex < entries.value.entries.length; entryIndex += 1) {\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 entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\treport: (value: unknown, path: readonly string[]) => readonly Fault[]\n\t\t\t\t\toptional: boolean\n\t\t\t\t\tkind: FaultKind\n\t\t\t\t}> = []\n\t\t\t\tconst names: string[] = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tconst inner = optional ? child.inner : child\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\treport: this.#reportAt(inner),\n\t\t\t\t\t\toptional,\n\t\t\t\t\t\tkind: shapeToKind(inner),\n\t\t\t\t\t}\n\t\t\t\t\tnames[names.length] = 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 = planned.success ? planned.value : undefined\n\t\t\t\tconst maskable = entries.length <= PRESENCE_MASK_LIMIT\n\t\t\t\tconst positions: Record<string, number> = INTRINSICS.create(null)\n\t\t\t\tif (maskable) {\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tpositions[entry.key] = entryIndex\n\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\tlet seen = 0\n\t\t\t\t\t\tif (present === undefined) {\n\t\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!INTRINSICS.own(positions, key)) continue\n\t\t\t\t\t\t\t\tconst position = positions[key]\n\t\t\t\t\t\t\t\tif (position !== undefined) seen |= 1 << position\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\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 (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\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 (!outcome.success) {\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 plans: Array<(value: unknown, path: readonly string[]) => readonly Fault[]> = []\n\t\t\t\tconst guards: Array<Guard<unknown>> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#reportAt(variant)\n\t\t\t\t\tguards[guards.length] = this.#guardAt(variant)\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\treturn (value, path) => {\n\t\t\t\t\tconst perVariant: Array<readonly Fault[]> = []\n\t\t\t\t\tfor (let index2 = 0; index2 < plans.length; index2 += 1) {\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\tlet matched = 0\n\t\t\t\t\t\tfor (let index2 = 0; index2 < guards.length; index2 += 1) {\n\t\t\t\t\t\t\tconst guard = guards[index2]\n\t\t\t\t\t\t\tif (guard !== undefined && guard(value)) matched += 1\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[] = [{ reason: 'oneOf', path, matched: 0 }]\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 }]\n\t\t\t\t\t}\n\t\t\t\t\tconst report: Fault[] = [{ reason: 'variant', path, variants: count }]\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.#buildGuard()\n\t\tfor (let step = 0; step < this.#order.length; step += 1) {\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\tlet value = ''\n\t\t\t\t\tfor (let step = 0; step < length; step += 1) {\n\t\t\t\t\t\tvalue += alphabet[INTRINSICS.floor(drawRandom(random, 'string') * alphabet.length)]\n\t\t\t\t\t}\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 '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\tlet value = ''\n\t\t\t\t\t\tfor (let step = 0; step < 6; step += 1) {\n\t\t\t\t\t\t\tvalue += alphabet[INTRINSICS.floor(drawRandom(random, 'json') * alphabet.length)]\n\t\t\t\t\t\t}\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\tconst result: unknown[] = []\n\t\t\t\t\tfor (let step = 0; step < length; step += 1) {\n\t\t\t\t\t\tresult[result.length] = item(random)\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst entries: Array<{\n\t\t\t\t\tkey: string\n\t\t\t\t\tseed: (random: RandomFunction) => unknown\n\t\t\t\t\toptional: boolean\n\t\t\t\t}> = []\n\t\t\t\tconst keyList = INTRINSICS.keys(owned.properties)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst child = owned.properties[key]\n\t\t\t\t\tif (child === undefined) continue\n\t\t\t\t\tconst optional = child.category === 'optional'\n\t\t\t\t\tentries[entries.length] = {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tseed: this.#seedAt(optional ? child.inner : child),\n\t\t\t\t\t\toptional,\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 result: Record<string, unknown> = {}\n\t\t\t\t\tfor (let entryIndex = 0; entryIndex < entries.length; entryIndex += 1) {\n\t\t\t\t\t\tconst entry = entries[entryIndex]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tif (entry.optional && drawRandom(random, 'object') < 0.3) continue\n\t\t\t\t\t\tINTRINSICS.define(result, entry.key, {\n\t\t\t\t\t\t\tvalue: entry.seed(random),\n\t\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\t\twritable: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\t// An open object (additionalProperties is a shape, not a boolean) also\n\t\t\t\t\t// generates synthetic extra entries so the shape does not trivially\n\t\t\t\t\t// generate as `{}` — skip any collision with a declared property name.\n\t\t\t\t\tif (tail !== undefined) {\n\t\t\t\t\t\tconst count = 1 + INTRINSICS.floor(drawRandom(random, 'object') * 2)\n\t\t\t\t\t\tfor (let step = 0; step < count; step += 1) {\n\t\t\t\t\t\t\tconst key = `key${step}`\n\t\t\t\t\t\t\tif (INTRINSICS.own(result, key)) continue\n\t\t\t\t\t\t\tINTRINSICS.define(result, key, {\n\t\t\t\t\t\t\t\tvalue: tail(random),\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\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> = []\n\t\t\t\tfor (let index2 = 0; index2 < owned.variants.length; index2 += 1) {\n\t\t\t\t\tconst variant = owned.variants[index2]\n\t\t\t\t\tif (variant === undefined) continue\n\t\t\t\t\tplans[plans.length] = this.#seedAt(variant)\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 (let attemptIndex = 0; attemptIndex < attempts; attemptIndex += 1) {\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\t!outcome.success &&\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 (outcome.success && 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 placement, and the\n * recursively supported raw-schema vocabulary where every present property or\n * dense union member is a record.\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 * Failures have deterministic precedence independent of traversal order: depth,\n * then structure, then cycle, 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: ContractShape): 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 * so an unfrozen caller-owned graph compiles 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 { ContractInterface, ContractShape, Infer } from './types.js'\nimport { contain } from './helpers.js'\nimport { ContractCompiler } from './ContractCompiler.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.\n * Every artifact is precompiled, so `audit`, `explain` and `generate` re-walk\n * and re-gate nothing on a later call; `contract.audit` and `compileAuditor` are\n * the same compiled function reached by different names.\n * The bundle is eager by intent. Its members are plain data properties holding\n * the compiled artifacts, so `const { is, parse } = createContract(shape)`\n * destructures those exact values and a spread of the result copies them; a\n * lazily compiled member would compile on either, which spends the laziness\n * rather than saving it. A malformed declaration refuses at this call rather\n * than at the first read of whichever member a caller happens to touch, so the\n * failure arrives at the call the caller made — carrying the authoring door's\n * own diagnosis, which this door adopts rather than rewraps. Every member is\n * self-contained, and the compiler this call builds releases its working set\n * before the call returns. The contract keeps part of the declaration even so:\n * the auditor and reporter plans close over the owned leaf and array nodes they\n * read their bounds from, so a kept contract retains those nodes and, through\n * an array node's `items` field, the subgraph beneath them. Nothing the caller\n * keeps reaches back into the compiler.\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(() => new ContractCompiler(shape).contract, 'createContract')\n}\n","import type { JSONSchema } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport {\n\tadmitVisited,\n\tattempt,\n\tenumerableKeys,\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 (!snapshot.success) 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 sampled: JSONSchema[] = []\n\t\t\tconst length = INTRINSICS.min(entries.length, this.#breadth)\n\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\tsampled[sampled.length] = this.#infer(entries[index], depth - 1)\n\t\t\t}\n\t\t\treturn sampled\n\t\t})\n\t\tomitVisited(this.#visited, value)\n\t\tif (!outcome.success) 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 properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\tconst required: string[] = []\n\t\t\tlet dropped = false\n\t\t\tfor (let index = 0; index < keys.length; index += 1) {\n\t\t\t\tconst key = keys[index]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst propertyValue = value[key]\n\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\tdropped = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tproperties[key] = this.#infer(propertyValue, depth - 1)\n\t\t\t\trequired[required.length] = key\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 (!outcome.success) 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\tadmitMember,\n\tattempt,\n\tbuildSampleMemo,\n\tcollectMembers,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\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\t// Indexed rather than `every`, and the narrowed rows are collected as they\n\t\t// are recognized so the record branch keeps its honest typing without an\n\t\t// assertion.\n\t\tconst records: Array<Record<string, unknown>> = []\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tconst sample = samples[index]\n\t\t\tif (isRecord(sample)) records[records.length] = sample\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: JSONSchema[] = []\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tschemas[schemas.length] = new ValueInferer(\n\t\t\t\tsamples[index],\n\t\t\t\tdepth,\n\t\t\t\tthis.#breadth,\n\t\t\t\tthis.#closed,\n\t\t\t\tfalse,\n\t\t\t).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\tlet node = memo\n\t\tfor (let index = 0; index < samples.length; index += 1) {\n\t\t\tconst row = samples[index]\n\t\t\tif (row === undefined) break\n\t\t\tconst next = INTRINSICS.reflect.apply(INTRINSICS.recall, node.rows, [row])\n\t\t\tif (next !== undefined) {\n\t\t\t\tnode = readSampleMemo(next, 'samplesToSchema')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst fresh = buildSampleMemo()\n\t\t\tINTRINSICS.reflect.apply(INTRINSICS.retain, node.rows, [row, fresh])\n\t\t\tnode = fresh\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\t// Refuse the whole key-enumeration claim when any row cannot be read.\n\t\tconst seen = collectMembers([])\n\t\tconst collected: string[] = []\n\t\tfor (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex += 1) {\n\t\t\tconst sample = samples[sampleIndex]\n\t\t\t// Indexed, never iterated: the row list is walked by index so no answer\n\t\t\t// this class publishes depends on `Array.prototype[Symbol.iterator]`. The\n\t\t\t// caller's own list was already read into an owned dense snapshot, so an\n\t\t\t// absent row here is unreachable and the refusal states the invariant.\n\t\t\tif (sample === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t}\n\t\t\tconst sampleKeys = enumerableKeys(sample)\n\t\t\tif (sampleKeys === undefined) {\n\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: property enumeration failed')\n\t\t\t}\n\t\t\tfor (let keyIndex = 0; keyIndex < sampleKeys.length; keyIndex += 1) {\n\t\t\t\tconst key = sampleKeys[keyIndex]\n\t\t\t\tif (key === undefined || matchesMember(seen, key)) continue\n\t\t\t\tadmitMember(seen, key)\n\t\t\t\tcollected[collected.length] = key\n\t\t\t}\n\t\t}\n\t\tconst allKeys = sortValues(collected)\n\t\tconst keys = limitEntries(allKeys, this.#breadth)\n\t\tconst truncated = allKeys.length > this.#breadth\n\t\t// Honest typing: a null-prototype accumulator so a key literally named\n\t\t// '__proto__' becomes an own data key instead of mutating the prototype —\n\t\t// the same pattern compileGuard / compileParser use (compilers.ts).\n\t\tconst properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\tconst required: string[] = []\n\t\tlet partial = truncated\n\t\t// Bounded by depth alone: unlike the single-value walk, this record-sample\n\t\t// path carries no ancestor set. A shared reference across sample rows is\n\t\t// legitimate data (not a cycle back to an ancestor), so the decrementing\n\t\t// depth budget is the sole termination guarantee here.\n\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\tconst key = keys[keyIndex]\n\t\t\tif (key === undefined) continue\n\t\t\t// Refuse the whole per-key claim when any sample value cannot be read.\n\t\t\tconst valuesOutcome = attempt(() => {\n\t\t\t\tconst values: unknown[] = []\n\t\t\t\tlet dropped = false\n\t\t\t\tfor (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex += 1) {\n\t\t\t\t\tconst sample = samples[sampleIndex]\n\t\t\t\t\tif (sample === undefined) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('samplesToSchema: every sample must be a record')\n\t\t\t\t\t}\n\t\t\t\t\tconst propertyValue = sample[key]\n\t\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\t\tif (INTRINSICS.own(sample, key)) dropped = true\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tvalues[values.length] = propertyValue\n\t\t\t\t}\n\t\t\t\treturn { values, dropped }\n\t\t\t})\n\t\t\tif (!valuesOutcome.success) throw valuesOutcome.error\n\t\t\tconst { values, dropped } = valuesOutcome.value\n\t\t\t// A row holding `undefined` for this key OPENS the schema; it does not\n\t\t\t// delete the column. Skipping the key entirely discarded a property two\n\t\t\t// of three rows carried as a real integer, and neither the TSDoc nor the\n\t\t\t// guide ever promised more than the opening.\n\t\t\tif (dropped) partial = true\n\t\t\tif (values.length > 0) {\n\t\t\t\t// The slot below is followed from the node this call was ENTERED with,\n\t\t\t\t// not from the row-prefix node reached above: two keys of one record\n\t\t\t\t// carry different row lists, so a shared base is what lets each land on\n\t\t\t\t// its own node instead of on a prefix of its sibling's.\n\t\t\t\tproperties[key] = this.#infer(values, depth - 1, memo)\n\t\t\t}\n\t\t\tif (!dropped && values.length === samples.length) required[required.length] = key\n\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\tadmitMember,\n\tappendEntries,\n\tattempt,\n\tcanonicalStringify,\n\tclassifyFormat,\n\tcollectMembers,\n\tcontain,\n\tmatchesMember,\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 (!snapshot.success) 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\t// A key list plus a null-prototype table, walked by index — not a `Map`\n\t\t\t\t// spread into `.sort().map()`. Every one of those is a caller-writable\n\t\t\t\t// member on the path that decides the PUBLISHED union: an emptying\n\t\t\t\t// `sort` truncated the answer and a substituted `map` replaced it\n\t\t\t\t// wholesale, both without throwing.\n\t\t\t\tconst keys: string[] = []\n\t\t\t\tconst collected = collectMembers([])\n\t\t\t\tconst byKey: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst unkeyed: JSONSchema[] = []\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst schema = owned[index]\n\t\t\t\t\tif (schema === undefined || !isRecord(schema)) {\n\t\t\t\t\t\tthrow new INTRINSICS.error('unifySchemas: schemas must be records')\n\t\t\t\t\t}\n\t\t\t\t\tconst key = canonicalStringify(schema)\n\t\t\t\t\tif (key === undefined) {\n\t\t\t\t\t\tunkeyed[unkeyed.length] = schema\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif (matchesMember(collected, key)) continue\n\t\t\t\t\tadmitMember(collected, key)\n\t\t\t\t\tkeys[keys.length] = key\n\t\t\t\t\tbyKey[key] = schema\n\t\t\t\t}\n\t\t\t\t// Both literals always canonicalize; the explicit checks keep the\n\t\t\t\t// subsumption total against `canonicalStringify`'s optional result.\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\tmatchesMember(collected, integerKey) &&\n\t\t\t\t\tmatchesMember(collected, numberKey)\n\t\t\t\t\t\t? integerKey\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst ordered = sortValues(keys)\n\t\t\t\tconst members: JSONSchema[] = []\n\t\t\t\tfor (let index = 0; index < ordered.length; index += 1) {\n\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\tif (key === undefined || key === subsumed) continue\n\t\t\t\t\tconst schema = byKey[key]\n\t\t\t\t\tif (schema === undefined) continue\n\t\t\t\t\tmembers[members.length] = schema\n\t\t\t\t}\n\t\t\t\tappendEntries(members, unkeyed)\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 { anyOf: members }\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 outcome.success ? 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 (!snapshot.success) 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\tlet first: SchemaFormat | undefined\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (!isString(value)) return undefined\n\t\t\t\t\tconst format = stringToFormat(value)\n\t\t\t\t\tif (format === undefined) return undefined\n\t\t\t\t\tif (index === 0) first = format\n\t\t\t\t\telse if (format !== first) return undefined\n\t\t\t\t}\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 (!snapshot.success) 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\tlet strings = 0\n\t\t\t\tlet numbers = 0\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (isString(value)) strings += 1\n\t\t\t\t\telse if (isFiniteNumber(value)) numbers += 1\n\t\t\t\t}\n\t\t\t\tconst allString = strings === owned.length\n\t\t\t\tconst allNumber = !allString && numbers === owned.length\n\t\t\t\tif (!allString && !allNumber) return undefined\n\t\t\t\t// A key list plus a null-prototype table, ordered through the captured\n\t\t\t\t// sort: `Map` iteration, array spread, `.sort` and `.map` are four\n\t\t\t\t// caller-writable dispatches deciding a published `enum`.\n\t\t\t\tconst keys: string[] = []\n\t\t\t\tconst collected = collectMembers([])\n\t\t\t\tconst byKey: Record<string, string | number> = INTRINSICS.create(null)\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst value = owned[index]\n\t\t\t\t\tif (!isString(value) && !isFiniteNumber(value)) continue\n\t\t\t\t\tconst key = canonicalStringify(value)\n\t\t\t\t\tif (key === undefined) return undefined\n\t\t\t\t\tif (!matchesMember(collected, key)) {\n\t\t\t\t\t\tadmitMember(collected, key)\n\t\t\t\t\t\tkeys[keys.length] = key\n\t\t\t\t\t}\n\t\t\t\t\tbyKey[key] = value\n\t\t\t\t}\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: Array<string | number> = []\n\t\t\t\tfor (let index = 0; index < ordered.length; index += 1) {\n\t\t\t\t\tconst key = ordered[index]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tconst value = byKey[key]\n\t\t\t\t\tif (value === undefined) continue\n\t\t\t\t\tpopulation[population.length] = value\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 (!snapshot.success) 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 { ContractShape, JSONSchema, JSONSchemaType, LiteralValue } from './types.js'\nimport {\n\tINFER_BREADTH_LIMIT,\n\tINFER_DEPTH_LIMIT,\n\tINTRINSICS,\n\tJSON_SCHEMA_TYPES,\n} from './constants.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tcollectMembers,\n\tderiveLengthBounds,\n\tderiveRangeBounds,\n\tlimitEntries,\n\tmatchesMember,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\tretainDepth,\n} from './helpers.js'\nimport { isArray, isFiniteNumber, isLiteralValue, isRecord, isString } from './validators.js'\nimport { parseEnum } from './parsers.js'\nimport {\n\tarrayShape,\n\tbooleanShape,\n\tintegerShape,\n\tliteralShape,\n\tnullShape,\n\tnumberShape,\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.\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 #visited: WeakSet<object>\n\treadonly #memo: WeakMap<object, Map<number, ContractShape>>\n\n\tconstructor(schema: JSONSchema) {\n\t\tthis.#source = schema\n\t\tthis.#visited = new SchemaShaper.#weakSet()\n\t\tthis.#memo = new SchemaShaper.#weakMap()\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 the schema is inexpressible\n\t * @throws {ContractError} When schema traversal fails\n\t */\n\tshape(): ContractShape {\n\t\treturn this.#convert(this.#source, INFER_DEPTH_LIMIT)\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): ContractShape {\n\t\tif (!(depth > 0)) return rawShape({})\n\t\tif (!matchesRecordBrand(schema)) return rawShape({})\n\t\tif (matchesVisited(this.#visited, schema)) return rawShape({})\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 depthMemo = INTRINSICS.reflect.apply(INTRINSICS.recall, this.#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) return cached\n\t\tadmitVisited(this.#visited, schema)\n\t\ttry {\n\t\t\tconst shape = this.#build(schema, depth)\n\t\t\tretainDepth(this.#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// 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// 1. `enum` — an array with at least one string/number/boolean entry (finite\n\t// numbers only) becomes a literal shape over the filtered entries.\n\t// Non-primitive / non-finite entries are dropped; an empty result falls\n\t// through.\n\t// 2. `oneOf` — an array with at least one record entry becomes a one-of shape\n\t// over the recursively-built variants, provided the record-entry count is\n\t// at or under `INFER_BREADTH_LIMIT`; OVER the limit, building a subset\n\t// union would be strictly narrower than the schema's full union (a value\n\t// matching only a dropped variant would be wrongly rejected), so the whole\n\t// node widens to `rawShape` instead of sampling a subset.\n\t// 3. `anyOf` — identically, through `unionShape`.\n\t// 4. Array-valued `type` — distinct recognized names become an inclusive\n\t// union, or a single shape for one name. An empty list or any unrecognized\n\t// 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`.\n\t// 7. `type: 'object'`, OR no `type` / `enum` / `oneOf` / `anyOf` but a\n\t// record-valued `properties` — delegates to the object branch.\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): ContractShape {\n\t\tconst description = isString(schema.description) ? schema.description : undefined\n\n\t\tif (isArray(schema.enum)) {\n\t\t\tconst literals: LiteralValue[] = []\n\t\t\t// De-duplicated in the same pass that already drops non-literal and\n\t\t\t// non-finite entries, by the package's own SameValueZero membership.\n\t\t\t// `literalShape` refuses a repeated vocabulary, and that refusal was\n\t\t\t// republished as `schema could not be read` — a data defect reported as\n\t\t\t// unreadability, for a schema every keyword of which was read. JSON\n\t\t\t// Schema requires `enum` members to be unique, so a repeat is malformed\n\t\t\t// vocabulary, and this conversion's stated rule for malformed vocabulary\n\t\t\t// is to ignore it and widen, never to throw. First occurrence wins, so\n\t\t\t// the emitted order still follows the source.\n\t\t\tconst seen = collectMembers([])\n\t\t\tfor (let index = 0; index < schema.enum.length; index += 1) {\n\t\t\t\tconst entry = schema.enum[index]\n\t\t\t\tif (isLiteralValue(entry) && (typeof entry !== 'number' || isFiniteNumber(entry))) {\n\t\t\t\t\tif (matchesMember(seen, entry)) continue\n\t\t\t\t\tadmitMember(seen, entry)\n\t\t\t\t\tliterals[literals.length] = entry\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (literals.length > 0) {\n\t\t\t\treturn literalShape(literals, description === undefined ? undefined : { description })\n\t\t\t}\n\t\t}\n\n\t\tif (isArray(schema.oneOf)) {\n\t\t\tconst records: JSONSchema[] = []\n\t\t\tfor (let index = 0; index < schema.oneOf.length; index += 1) {\n\t\t\t\tconst entry = schema.oneOf[index]\n\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t}\n\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t}\n\t\t\tconst variants: ContractShape[] = []\n\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\tconst entry = records[index]\n\t\t\t\tif (entry === undefined) continue\n\t\t\t\tvariants[variants.length] = this.#convert(entry, depth - 1)\n\t\t\t}\n\t\t\t// `Reflect.apply` reads its argument list by index, where a spread call\n\t\t\t// would dispatch through the caller-writable array iterator.\n\t\t\tif (variants.length > 0) return INTRINSICS.reflect.apply(oneOfShape, undefined, variants)\n\t\t}\n\n\t\tif (isArray(schema.anyOf)) {\n\t\t\tconst records: JSONSchema[] = []\n\t\t\tfor (let index = 0; index < schema.anyOf.length; index += 1) {\n\t\t\t\tconst entry = schema.anyOf[index]\n\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t}\n\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t}\n\t\t\tconst variants: ContractShape[] = []\n\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\tconst entry = records[index]\n\t\t\t\tif (entry === undefined) continue\n\t\t\t\tvariants[variants.length] = this.#convert(entry, depth - 1)\n\t\t\t}\n\t\t\tif (variants.length > 0) return INTRINSICS.reflect.apply(unionShape, undefined, variants)\n\t\t}\n\n\t\tconst category = schema.type\n\t\tif (isArray(category)) {\n\t\t\tconst members: JSONSchemaType[] = []\n\t\t\tconst seen = collectMembers([])\n\t\t\tfor (let index = 0; index < category.length; index += 1) {\n\t\t\t\tconst member = parseEnum(category[index], JSON_SCHEMA_TYPES)\n\t\t\t\tif (member === undefined) {\n\t\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t\t}\n\t\t\t\tif (matchesMember(seen, member)) continue\n\t\t\t\tadmitMember(seen, member)\n\t\t\t\tmembers[members.length] = member\n\t\t\t}\n\t\t\tif (members.length === 0 || members.length > INFER_BREADTH_LIMIT) {\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t}\n\t\t\tconst variants: ContractShape[] = []\n\t\t\tfor (let index = 0; index < members.length; index += 1) {\n\t\t\t\tconst member = members[index]\n\t\t\t\tif (member === undefined) continue\n\t\t\t\t// A type alternative stays at this node's depth and keeps its ancestor\n\t\t\t\t// identity active; only structural children spend the depth budget.\n\t\t\t\tvariants[variants.length] = this.#build({ ...schema, type: member }, depth)\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) ? schema.type : undefined\n\n\t\tif (type === 'string') {\n\t\t\tconst bounds = deriveLengthBounds(schema.minLength, schema.maxLength)\n\t\t\treturn stringShape({\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\t\tif (type === 'number') {\n\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\n\t\t\treturn numberShape({\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\t\tif (type === 'integer') {\n\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\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: { description }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t\t...(description === undefined ? {} : { description }),\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 = isRecord(schema.items) ? this.#convert(schema.items, depth - 1) : rawShape({})\n\t\t\tconst bounds = deriveLengthBounds(schema.minItems, schema.maxItems)\n\t\t\treturn arrayShape(items, {\n\t\t\t\t...bounds,\n\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t})\n\t\t}\n\n\t\tif (type === 'object' || (type === undefined && isRecord(schema.properties))) {\n\t\t\treturn this.#buildObject(schema, depth, description)\n\t\t}\n\n\t\treturn rawShape(description === undefined ? {} : { description })\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.\n\t#buildObject(schema: JSONSchema, depth: number, description: string | undefined): ContractShape {\n\t\tconst propertiesSource = isRecord(schema.properties) ? schema.properties : undefined\n\t\t// Indexed rather than `filter` / `includes`: this list decides which\n\t\t// properties the published shape marks required, and both are\n\t\t// caller-writable members.\n\t\tconst requiredSource = collectMembers([])\n\t\tif (isArray(schema.required)) {\n\t\t\tfor (let index = 0; index < schema.required.length; index += 1) {\n\t\t\t\tconst entry = schema.required[index]\n\t\t\t\tif (isString(entry)) admitMember(requiredSource, entry)\n\t\t\t}\n\t\t}\n\t\t// Honest typing: a null-prototype accumulator so a property literally\n\t\t// named '__proto__' becomes an own data key instead of mutating the\n\t\t// prototype — the same pattern the record inference uses.\n\t\tconst properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\tlet truncated = false\n\t\tif (propertiesSource) {\n\t\t\tconst allKeys = INTRINSICS.keys(propertiesSource)\n\t\t\ttruncated = allKeys.length > INFER_BREADTH_LIMIT\n\t\t\tconst keys = limitEntries(allKeys, INFER_BREADTH_LIMIT)\n\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\tif (key === undefined) continue\n\t\t\t\tconst child = propertiesSource[key]\n\t\t\t\tconst childShape = isRecord(child) ? this.#convert(child, depth - 1) : rawShape({})\n\t\t\t\tproperties[key] = matchesMember(requiredSource, key)\n\t\t\t\t\t? childShape\n\t\t\t\t\t: optionalShape(childShape)\n\t\t\t}\n\t\t}\n\t\tconst extra = schema.additionalProperties\n\t\tconst additionalProperties: boolean | ContractShape = truncated\n\t\t\t? true\n\t\t\t: extra === false\n\t\t\t\t? false\n\t\t\t\t: isRecord(extra)\n\t\t\t\t\t? this.#convert(extra, depth - 1)\n\t\t\t\t\t: true\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","import type {\n\tArrayShape,\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\tRawShape,\n\tRecordShapeOptions,\n\tStringShape,\n\tStringShapeOptions,\n\tUnionShape,\n} from './types.js'\nimport { cloneSchema, cloneShape } from './cloners.js'\nimport { SchemaShaper } from './SchemaShaper.js'\nimport { ShapeValidator } from './ShapeValidator.js'\nimport { INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tattempt,\n\tcontain,\n\tmatchesRecordBrand,\n\tpreview,\n\treadArrayEntries,\n\treadOptions,\n\treadPatternFlags,\n\treadPatternSource,\n\treadValue,\n} from './helpers.js'\nimport { isLiteralValue, isObject, isRegExp } from './validators.js'\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\tnew ShapeValidator(shape).validate()\n\t\treturn 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\tnew ShapeValidator(result).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 (!array.success || !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...(!array.success ? { 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 (!snapshot.success) {\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: LiteralValue[] = []\n\t\tfor (let index = 0; index < snapshot.value.entries.length; index += 1) {\n\t\t\tconst value = snapshot.value.entries[index]\n\t\t\tif (!isLiteralValue(value)) {\n\t\t\t\tthrow new ContractError(\n\t\t\t\t\t'validateShape: every literal value must be a string, number, or boolean',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: ['values', INTRINSICS.text(index)], shape: 'literal' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tliterals[literals.length] = value\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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 snapshot: { [K in keyof P]: P[K] } = INTRINSICS.create(null)\n\t\t\t\tconst keyList = INTRINSICS.keys(input)\n\t\t\t\tfor (let keyIndex = 0; keyIndex < keyList.length; keyIndex += 1) {\n\t\t\t\t\tconst key = keyList[keyIndex]\n\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\tINTRINSICS.reflect.define(snapshot, key, {\n\t\t\t\t\t\tvalue: INTRINSICS.reflect.read(input, key),\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\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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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 * @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\tconst shape: UnionShape<V> = { category: 'union', variants }\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze({ 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, that variant's parser runs. Zero matches or\n * two-or-more matches both parse to `undefined` — a value ambiguous\n * between variants has no well-defined coercion target.\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\tconst shape: UnionShape<V> = {\n\t\t\tcategory: 'union',\n\t\t\tvariants,\n\t\t\tmode: 'oneOf',\n\t\t}\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze({ ...shape, variants: INTRINSICS.freeze(variants) })\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.\n *\n * @param inner - The wrapped shape\n * @returns An optional shape\n */\nexport function optionalShape<S extends ContractShape>(inner: S): OptionalShape<S> {\n\treturn contain(() => {\n\t\tconst shape: OptionalShape<S> = { category: 'optional', inner }\n\t\tnew ShapeValidator({ category: 'object', properties: { value: shape } }).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(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\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze(shape)\n\t}, 'jsonShape')\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 * 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\tconst owned = cloneSchema(schema)\n\t\tnew ShapeValidator({ category: 'raw', schema: owned }).validate()\n\t\treturn INTRINSICS.freeze({ category: 'raw', schema: owned })\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, this\n * conversion is total and widens an inexpressible input to a valid raw `{}`.\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 * @param schema - The JSON Schema value to convert\n * @returns The built {@link ContractShape}\n * @throws {ContractError} When schema traversal fails\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): ContractShape {\n\treturn contain(() => {\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\treturn readValue(() => new SchemaShaper(schema).shape(), 'schemaToShape', {\n\t\t\tsubject: 'schema',\n\t\t\tcontext: { shape: 'schema' },\n\t\t})\n\t}, 'schemaToShape')\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,uBAAuB,OAAO,IAAI,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsE1E,IAAa,aAAa,OAAO,OAAO;;CAEvC,QAAQ,OAAO;;CAEf,QAAQ,OAAO;;CAEf,MAAM,OAAO;;CAEb,QAAQ,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