{"version":3,"file":"index.cjs","names":["#weakSet","#source","#owned","#active","#pending","#produced","#poison","#terminal","#create","#execute","#fail","#owns","#capture","#drain","#captureArray","#captureRecord","#refuse","#captureObject","#schedule","#map","#weakSet","#hasOwn","#source","#owned","#emptyMemo","#emptyPending","#memo","#pending","#state","#create","#complete","#execute","#settle","#owns","#refuse","#drain","#read","#capture","#schedule","#weakSet","#weakMap","#source","#expansion","#phase","#clear","#execute","#stack","#path","#active","#index","#captures","#post","#height","#reach","#via","#counts","#schemas","#children","#category","#raw","#structure","#cycle","#domain","#visit","#measure","#finish","#place","#observe","#capture","#schedule","#refuse","#recognize","#scan","#constrain","#inspect","#populate","#restrict","#settleSchema","#trace","#locate","#witness","#ascend","#map","#weakSet","#source","#owned","#emptyMemo","#emptyPaths","#emptyProperties","#emptyVariants","#emptyPending","#emptySources","#memo","#paths","#properties","#variants","#pending","#sources","#fidelity","#state","#create","#complete","#execute","#settle","#owns","#drain","#wireNodes","#freezeNodes","#validateShape","#refuseDepth","#captureNode","#captureString","#captureNumber","#captureSimple","#captureLiteral","#captureArray","#captureObject","#captureUnion","#captureWrapper","#captureRaw","#capturePatternValue","#captureShell","#scheduleNode","#captureField","#capturePattern","#captureLiterals","#captureProperties","#captureVariants","#literal","#registerChild","#wireArray","#wireObject","#wireUnion","#wireWrapper","#weakMap","#visits","#scope","#emptyStack","#emptyNodes","#emptyIndex","#emptyOrder","#emptySchemas","#emptyGuards","#emptyParsers","#emptyAudits","#emptyReports","#emptySeeds","#source","#state","#stack","#nodes","#index","#order","#schemas","#guards","#parsers","#audits","#reports","#seeds","#schema","#guard","#parser","#auditor","#reporter","#generator","#bundle","#enter","#buildSchema","#publish","#buildGuard","#buildParser","#buildAuditor","#buildReporter","#buildGenerator","#buildContract","#leave","#fail","#collect","#release","#discover","#schedule","#node","#prepare","#schemaOf","#schemaAt","#locate","#guardOf","#repeats","#trackGuard","#guardAt","#unions","#parserOf","#parserAt","#auditOf","#trackFaults","#exposeAudit","#auditAt","#reportOf","#exposeReport","#reportAt","#seedOf","#exposeSeed","#seedAt"],"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/inferers.ts","../../../src/core/shapers.ts"],"sourcesContent":["import type { JSONSchemaType } from './types.js'\n\n/**\n * The registry-global key used to recognize {@link ContractError} values across\n * 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 * Every host operation this package dispatches through, captured 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 each replacement can fail in two ways: it\n * can THROW, which a boundary contains, or it can LIE, which no boundary can\n * see. `Object.freeze = (value) => value` is the second kind and it is the\n * worse one: 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.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 was previously excluded on the grounds that it needs a\n * data structure rather than one operation, and the exclusion was answered with\n * an exported class whose `has` method every consumer could rewrite — which\n * reproduced the whole defect one prototype higher. The rule 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/** `Object.freeze` — the operation the ownership guarantee is made of. */\n\tfreeze: Object.freeze,\n\t/** `Object.isFrozen` — the independent check that the guarantee actually held. */\n\tfrozen: Object.isFrozen,\n\t/** `Object.keys` — the own enumerable string-key population of a snapshot. */\n\tkeys: Object.keys,\n\t/** `Object.values` — the own enumerable value population of a snapshot. */\n\tvalues: Object.values,\n\t/** `Object.hasOwn` — own presence, so no read leaves a container for its prototype. */\n\town: Object.hasOwn,\n\t/** `Object.is` — `SameValue`, so a `NaN` or signed-zero comparison stays exact. */\n\tsame: Object.is,\n\t/** `Object.create` — the null-prototype and prototype-pinned accumulators. */\n\tcreate: Object.create,\n\t/** `Object.getOwnPropertyDescriptor` — value observation that runs no accessor. */\n\tdescribe: Object.getOwnPropertyDescriptor,\n\t/** `Object.defineProperty` — exact placement of an own data property. */\n\tdefine: Object.defineProperty,\n\t/** `Object.getPrototypeOf` — the record-brand observation. */\n\tprototype: Object.getPrototypeOf,\n\t/** `Object.getOwnPropertySymbols` — the own-symbol population. */\n\tsymbols: Object.getOwnPropertySymbols,\n\t/** `Object.prototype` — the realm-local plain-record prototype identity. */\n\tbase: Object.prototype,\n\t/** `Reflect.get` — a proxy-visible read that reports the trap's exact answer. */\n\tread: Reflect.get,\n\t/** `Reflect.set` — a proxy-visible write. */\n\twrite: Reflect.set,\n\t/** `Reflect.ownKeys` — the complete own-key population, strings and symbols. */\n\tmembers: Reflect.ownKeys,\n\t/** `Reflect.has` — a proxy-visible presence observation. */\n\tpresent: Reflect.has,\n\t/** `Reflect.getOwnPropertyDescriptor` — the reflective descriptor observation. */\n\treveal: Reflect.getOwnPropertyDescriptor,\n\t/** `Reflect.defineProperty` — placement that answers instead of throwing. */\n\tdeclare: Reflect.defineProperty,\n\t/** `Reflect.getPrototypeOf` — the reflective prototype observation. */\n\tparent: Reflect.getPrototypeOf,\n\t/** `Reflect.apply` — dispatch of a captured method onto its receiver. */\n\tapply: Reflect.apply,\n\t/** `Reflect.construct` — construction with an explicit new target. */\n\tconstruct: Reflect.construct,\n\t/** `Number.isFinite` — the finite-bound test every numeric shape refuses on. */\n\tfinite: Number.isFinite,\n\t/** `Number.isInteger` — the integer-budget test the inference caps refuse on. */\n\tinteger: Number.isInteger,\n\t/** `Number.isSafeInteger` — the safe-integer test every length bound refuses on. */\n\tsafe: Number.isSafeInteger,\n\t/** `Number.isNaN` — the calendar-validity test for a parsed instant. */\n\tnan: Number.isNaN,\n\t/** `Array.isArray` — array identity across realms. */\n\tarray: Array.isArray,\n\t/** `JSON.stringify` — the escaping used by previews and canonical text. */\n\tstringify: JSON.stringify,\n\t/** `JSON.parse` — document decoding. */\n\tdecode: JSON.parse,\n\t/** `Math.floor` — index and quantity flooring. */\n\tfloor: Math.floor,\n\t/** `Math.ceil` — index and quantity ceiling. */\n\tceil: Math.ceil,\n\t/** `Math.max` — bound selection. */\n\tmax: Math.max,\n\t/** `Math.min` — bound selection. */\n\tmin: Math.min,\n\t/** `Math.imul` — the seeded generator's mixing step. */\n\timul: Math.imul,\n\t/** `String` — primitive text coercion. */\n\ttext: String,\n\t/** `Number` — primitive numeric coercion. */\n\tnumeric: Number,\n\t/** `RegExp` — pattern construction from captured source and flags. */\n\tpattern: RegExp,\n\t/**\n\t * `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/** 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/** 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/** `Array` — array construction. */\n\tlist: Array,\n\t/** `Array.prototype.sort` — the deterministic ordering every published schema is emitted in, dispatched through `apply`. */\n\torder: Array.prototype.sort,\n\t/** `Map` — keyed working state. */\n\tmap: Map,\n\t/** `Map.prototype.get` — a memo read whose answer a published graph embeds, dispatched through `apply`. */\n\tfetch: Map.prototype.get,\n\t/** `Map.prototype.set` — a memo write a published graph is later assembled from, dispatched through `apply`. */\n\tstore: Map.prototype.set,\n\t/** `Map.prototype.has` — a memo presence answer that decides whether a node is captured, dispatched through `apply`. */\n\tkeyed: Map.prototype.has,\n\t/** `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/** `Set` — membership working state. */\n\tset: Set,\n\t/** `Set.prototype.has` — THE membership answer every published verdict rests on, dispatched through `apply`. */\n\tmember: Set.prototype.has,\n\t/** `Set.prototype.add` — collection of one more member, dispatched through `apply`. */\n\tadmit: Set.prototype.add,\n\t/** `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/** `WeakMap` — object-keyed working state. */\n\tweakMap: WeakMap,\n\t/** `WeakMap.prototype.get` — an object-keyed memo read a published graph embeds, dispatched through `apply`. */\n\trecall: WeakMap.prototype.get,\n\t/** `WeakMap.prototype.set` — an object-keyed memo write, dispatched through `apply`. */\n\tretain: WeakMap.prototype.set,\n\t/** `WeakSet` — object-membership working state. */\n\tweakSet: WeakSet,\n\t/** `WeakSet.prototype.has` — the visitation answer every traversal's termination rests on, dispatched through `apply`. */\n\ttracked: WeakSet.prototype.has,\n\t/** `WeakSet.prototype.add` — entry onto the active path, dispatched through `apply`. */\n\ttrack: WeakSet.prototype.add,\n\t/** `WeakSet.prototype.delete` — exit from the active path, dispatched through `apply`. */\n\tuntrack: WeakSet.prototype.delete,\n\t/** `Error` — the internal marker an engine throws into its own contained walk. */\n\terror: Error,\n\t/** `Date` — calendar validation of an ISO instant. */\n\tdate: Date,\n\t/** `Date.prototype.getTime` — the calendar verdict a published `format` rests on, dispatched through `apply`. */\n\tinstant: Date.prototype.getTime,\n\t/** `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 (AGENTS §14 — the deep recursive validators stay out by\n// design).\n\n/**\n * 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// Reporting-surface bounds (`compileReporter` / `compileAuditor` —\n// `ContractInterface.explain` / `ContractInterface.audit`).\n\n/**\n * The maximum 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 * The maximum 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 * The maximum active recursion or JSON container depth for runtime guards,\n * 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 * The maximum supported nesting depth of a compiled contract shape, frozen.\n *\n * @remarks\n * {@link validateShapeDepth} 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 * The maximum 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 validateShapeDepth} 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 * What this cap bounds MOVED when the compilers stopped expanding a DAG. Every\n * artifact family is now one entry per unique node, so the boundary declaration\n * above compiles fourteen nodes in about a millisecond rather than sixteen\n * thousand in 1,342 ms, and the cap is no longer what keeps compilation finite.\n * What still expands 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 * The maximum 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 * The maximum number of candidate-generation attempts for a constrained\n * generated 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 * The maximum 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 via {@link ValueToSchemaOptions.maxDepth}; 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 * The default maximum number of object properties / array elements\n * {@link 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 via {@link ValueToSchemaOptions.maxProperties}.\n */\nexport const INFER_BREADTH_LIMIT = 256\n\n/**\n * The default maximum 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} / {@link inferRecordSamples}\n * 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 via {@link ValueToSchemaOptions.enum}\n * (which gates whether enum inference runs at all).\n */\nexport const INFER_ENUM_LIMIT = 12\n\n/**\n * The maximum string length {@link stringToFormat} attempts to classify,\n * 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 * Pure-regex matchers backing {@link stringToFormat}'s pattern-only formats\n * (`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_ERROR_BRAND, INTRINSICS } from './constants.js'\n\n/**\n * Error carrying a machine-readable contract category, optional context, and\n * an exact optional cause. Omitting `cause` omits the own property; explicitly\n * supplying `cause: undefined` retains an own property with that value. Both\n * optional options are read as OWN properties, so a construction never consults\n * the caller-writable prototype chain of 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 * Create 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\tconst members = INTRINSICS.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\tINTRINSICS.define(this.prototype, key, { writable: false, configurable: false })\n\t\t\tconst pinned = INTRINSICS.describe(this.prototype, key)\n\t\t\tif (pinned?.writable !== false || pinned.configurable !== 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 only for 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\treturn (\n\t\t\tcode === 'bound' ||\n\t\t\tcode === 'range' ||\n\t\t\tcode === 'empty' ||\n\t\t\tcode === 'placement' ||\n\t\t\tcode === 'structure' ||\n\t\t\tcode === 'literal' ||\n\t\t\tcode === 'cycle' ||\n\t\t\tcode === 'pattern' ||\n\t\t\tcode === 'generate' ||\n\t\t\tcode === 'random' ||\n\t\t\tcode === 'clone' ||\n\t\t\tcode === 'depth' ||\n\t\t\tcode === 'expansion'\n\t\t)\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// AGENTS §14: guards are total 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/** Determine whether a value is `null`.\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/** Determine whether a value is `undefined`.\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/** Determine whether a value is defined (neither `null` nor `undefined`).\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/** Determine whether a value is a string.\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 * Determine whether a value is a number.\n *\n * @remarks\n * Includes `NaN` and `±Infinity` — use {@link isFiniteNumber} to exclude them.\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/** Determine whether a value is a finite number (excludes `NaN` and `±Infinity`).\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/** Determine whether a value is a finite integer (excludes `NaN`, `±Infinity`, and fractional numbers).\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 * Determine 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` for finite primitive numbers greater than or equal to zero, except `-0`\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 * Determine 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` for non-negative integers other than `-0`\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/** Determine whether a value is a boolean.\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 * Determine 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` for a string, number, or boolean\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/** Determine whether a value is exactly `true`.\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/** Determine whether a value is exactly `false`.\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/** Determine whether a value is a bigint.\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/** Determine whether a value is a symbol.\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/** Determine whether a value is callable.\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/** Determine whether a value is a string or `null`.\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/** Determine whether a value is a number or `null` (the number may be `NaN` / `±Infinity`).\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/** Determine whether a value is a boolean or `null`.\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 * Determine 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 (AGENTS §14): 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` when `value instanceof ctor`, `false` on a non-match or 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/** Determine whether a value is a `Date`.\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/** Determine whether a value is a `RegExp`.\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, as this did, observed whatever\n\t// getter was CURRENTLY installed and only checked that it returned a string —\n\t// so `Object.defineProperty(RegExp.prototype, 'source', { get: () => '.*' })`\n\t// made this guard accept a plain string, and it gates `matchOf`, `stringOf`\n\t// and every string shape builder.\n\treturn holds(() => readPatternSource(value) !== undefined)\n}\n\n/** Determine whether a value is an `Error`.\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/** Determine whether a value is a native `Promise` (use {@link isPromiseLike} for any thenable).\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 * Determine 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 * @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.read(value, 'then')\n\t\tconst catchValue = INTRINSICS.read(value, 'catch')\n\t\tconst finallyValue = INTRINSICS.read(value, 'finally')\n\t\treturn isFunction(thenValue) && isFunction(catchValue) && isFunction(finallyValue)\n\t})\n}\n\n/** Determine whether a value is an `ArrayBuffer`.\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 * Determine 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 (e.g. a context that is not cross-origin isolated).\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 * Determine 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 * @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.read(value, Symbol.iterator))\n\t})\n}\n\n/** Determine whether a value implements the async iterable protocol (`Symbol.asyncIterator`).\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(() => isObject(value) && isFunction(INTRINSICS.read(value, Symbol.asyncIterator)))\n}\n\n// === Object & collection guards\n\n/**\n * Determine whether a value is a non-null object.\n *\n * @remarks\n * `true` for arrays, class instances, plain objects, `Map`, `Set`, etc. — use\n * {@link isRecord} when you need a plain-record check.\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 * Determine 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` (AGENTS §14) 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 * @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/** Determine whether a value is a `Map`.\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/** Determine whether a value is a `Set`.\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/** Determine whether a value is a `WeakMap`.\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/** Determine whether a value is a `WeakSet`.\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/** Determine whether a value is an array.\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/** Determine whether a value is a `DataView`.\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/** Determine whether a value is an `ArrayBufferView` (any typed array or `DataView`).\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/** Determine whether a value is an `Int8Array`.\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/** Determine whether a value is a `Uint8Array`.\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/** Determine whether a value is a `Uint8ClampedArray`.\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/** Determine whether a value is an `Int16Array`.\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/** Determine whether a value is a `Uint16Array`.\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/** Determine whether a value is an `Int32Array`.\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/** Determine whether a value is a `Uint32Array`.\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/** Determine whether a value is a `Float32Array`.\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/** Determine whether a value is a `Float64Array`.\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 * Determine 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 * @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 * Determine 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 * @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/** Determine whether a value is the empty string `''`.\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/** Determine whether a value is an empty array.\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/** Determine 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 * @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.members(value).length === 0)\n}\n\n/** Determine whether a value is an empty `Map`.\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/** Determine whether a value is an empty `Set`.\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/** Determine whether a value is a non-empty string (at least one character).\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/** Determine whether a value is a non-empty array (at least one element).\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/** Determine 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 * @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.members(value).length > 0)\n}\n\n/** Determine whether a value is a non-empty `Map` (at least one entry).\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/** Determine whether a value is a non-empty `Set` (at least one element).\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/** Determine whether a value is a function that declares zero parameters (`Function.length === 0`).\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 * Determine 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 (§14): a function\n * whose `constructor` was nulled yields `undefined`, never a thrown `null.name`.\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/** Determine whether a value is a generator function (`function*`).\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/** Determine whether a value is an async generator function (`async function*`).\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/** Determine whether a value is a zero-argument async function.\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/** Determine whether a value is a zero-argument generator function.\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/** Determine whether a value is a zero-argument async generator function.\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 * Determine 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 * @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.construct(String, [], value)\n\t\treturn true\n\t})\n}\n\n// === JSON\n\n/**\n * Determine 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` (AGENTS §14): 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` when the value has a JSON representation\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 * Determine 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` when the value is both depth-bounded and a valid {@link JSONValue}\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 * Determine 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` when the value is a plain-record-rooted bounded JSON value\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 * Determine 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` when `value` is `null`, a string, a finite number, or a boolean\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\tContainOptions,\n\tContractCode,\n\tContractShape,\n\tFault,\n\tFaultKind,\n\tFieldPath,\n\tGuard,\n\tGuardsShape,\n\tJSONSchema,\n\tJSONValue,\n\tNumberShape,\n\tRandomFunction,\n\tReadValueOptions,\n\tResult,\n\tSampleMemo,\n\tStringShape,\n} from './types.js'\nimport {\n\tCOMPILE_NODE_LIMIT,\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\tisMap,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n\tisSymbol,\n\tisWeakMap,\n} from './validators.js'\n\n/**\n * Build 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 * Append 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 * Take 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 * Order 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 * Order 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.apply(INTRINSICS.order, owned, [compareValues])\n\treturn owned\n}\n\n// === Captured membership, visitation, and pattern reads\n\n/**\n * Collect 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.apply(INTRINSICS.admit, members, [values[index]])\n\t}\n\treturn members\n}\n\n/**\n * Determine whether a value is a member of a collected vocabulary, by\n * SameValueZero.\n *\n * @param members - The vocabulary to ask, built by {@link collectMembers}\n * @param value - The value to test for membership\n * @returns `true` only when the value was collected\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.apply(INTRINSICS.member, members, [value]) === true\n}\n\n/**\n * Collect one more member into a vocabulary that grows as a walk proceeds.\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.apply(INTRINSICS.admit, members, [value])\n}\n\n/**\n * Determine 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` only when the object is already on the active path\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.apply(INTRINSICS.tracked, visited, [value]) === true\n}\n\n/**\n * Record an object as entered on a traversal's active path.\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.apply(INTRINSICS.track, visited, [value])\n}\n\n/**\n * Record an object as exited from a traversal's active path.\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.apply(INTRINSICS.untrack, visited, [value])\n}\n\n/**\n * Record 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 in\n * `inferArray`, `inferObject` and `schemaNodeToShape`. Written once it is one\n * statement per caller, and the captured `WeakMap`/`Map` members stay the only\n * 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.apply(INTRINSICS.recall, memo, [node])\n\tconst depths = known || new INTRINSICS.map<number, T>()\n\tif (!known) INTRINSICS.apply(INTRINSICS.retain, memo, [node, depths])\n\tINTRINSICS.apply(INTRINSICS.store, depths, [depth, answer])\n}\n\n/**\n * Build 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 it at the door, and\n * a direct caller of {@link inferSamples} / {@link inferRecordSamples} builds a\n * fresh one per call.\n *\n * @returns An empty memo node with no recorded rows and no recorded schemas\n *\n * @example\n * ```ts\n * inferRecordSamples([{ id: 1 }], 32, 256, true, false, false, buildSampleMemo())\n * ```\n */\nexport function buildSampleMemo(): SampleMemo {\n\treturn { rows: new INTRINSICS.weakMap<object, SampleMemo>(), schemas: new INTRINSICS.map() }\n}\n\n/**\n * Check that a value really is a {@link SampleMemo} before a walk stores a\n * published schema in it.\n *\n * @remarks\n * The memo is the one argument position on `inferSamples` /\n * `inferRecordSamples` that reaches a `WeakMap` and a `Map` the caller\n * supplied, and both doors are reachable untyped from JavaScript. Without this\n * check a wrong value there failed inside the traversal and was published as\n * `samples could not be read` — a true refusal naming the wrong argument, the\n * defect class those doors were already corrected for twice. It refuses under\n * the memo's own name and its own path instead.\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(), 'inferSamples') // 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 * Build 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[][]): (value: unknown, key: unknown) => void {\n\treturn (value: unknown, key: unknown) => {\n\t\ttarget[target.length] = [key, value]\n\t}\n}\n\n/**\n * Snapshot 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.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 * Snapshot 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.apply(INTRINSICS.pairs, value, [collectEntries(collected)])\n\t\treturn INTRINSICS.freeze(collected)\n\t})\n}\n\n/**\n * Read 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.apply(read, pattern, [])\n\treturn isString(source) ? source : undefined\n}\n\n/**\n * Read a regular expression's flag text through the captured accessor.\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.apply(read, pattern, [])\n\treturn isString(flags) ? flags : undefined\n}\n\n/**\n * Determine 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` only when the pattern genuinely matches\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.apply(INTRINSICS.captures, pattern, [value]) !== null\n}\n\n/**\n * Rebuild 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 * Pin 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 qualification that phrase used to carry — \"before any importer's code can\n * run\" — was FALSE, in exactly the case {@link INTRINSICS} already states and\n * does not defend: ESM evaluates imports in source order, so a module that\n * evaluates before this package has already run. What is true is narrower and is\n * what the pin buys: no code that runs AFTER this class is defined can replace a\n * member on its prototype.\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 * @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.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.declare(\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 * Invoke a callback once and synchronously capture its exact outcome as a\n * {@link Result}.\n *\n * @remarks\n * The sanctioned never-throw boundary for the guards (AGENTS §14). 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. The earlier claim here — that it was total BY CONSTRUCTION and had\n * nothing to contain — was false, and it is what justified deleting the\n * containment the committed baseline had. 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 * Read a value through the shared containment boundary or refuse 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// all four names, 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.\n\t\tconst owned = {\n\t\t\tpath: undefined,\n\t\t\tshape: undefined,\n\t\t\tlimit: undefined,\n\t\t\treceived: undefined,\n\t\t\t...source,\n\t\t}\n\t\tconst context =\n\t\t\tsource === 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\tconst requested = options?.code\n\t\tconst code: ContractCode =\n\t\t\trequested === 'bound' ||\n\t\t\trequested === 'range' ||\n\t\t\trequested === 'empty' ||\n\t\t\trequested === 'placement' ||\n\t\t\trequested === 'structure' ||\n\t\t\trequested === 'literal' ||\n\t\t\trequested === 'cycle' ||\n\t\t\trequested === 'pattern' ||\n\t\t\trequested === 'generate' ||\n\t\t\trequested === 'random' ||\n\t\t\trequested === 'clone' ||\n\t\t\trequested === 'depth'\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(options?.subject) ? options.subject : 'value',\n\t\t\tcode,\n\t\t\tcontext,\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\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...(diagnostics.value.context === undefined ? {} : { context: diagnostics.value.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 * Run a public door's whole body and publish 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 * Invoke a predicate through the sanctioned never-throw boundary.\n *\n * @param callback - The predicate to invoke with no arguments\n * @returns `true` only when the callback returns the boolean value `true`\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 * Determine 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 simply 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 seven 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 the seven functions to stamp, so the price is a\n * few lines rather than nothing. Reparenting a class prototype to `null` and\n * stamping the seven 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 seven 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` only when the value is a plain record\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 * Snapshot 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. Caller-defined iteration is ignored. A\n * descriptor-only index omitted from reflection is deliberately outside this\n * lens and remains a hole. Failure retains the exact thrown value when length,\n * reflection, membership, or indexed value observation throws; a non-native\n * length or view disagreement is also failure. `4294967295` is metadata rather\n * 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 collected: number[] = []\n\t\tconst members = INTRINSICS.members(value)\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\tcollected[collected.length] = index\n\t\t\t}\n\t\t}\n\t\tconst indices = 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 = INTRINSICS.text(index)\n\t\t\tif (!INTRINSICS.own(value, key)) throw new INTRINSICS.error('Array index views disagree')\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 * Snapshot 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): Readonly<{\n\treadonly guards: Readonly<Record<string, Guard<unknown> | undefined>>\n\treadonly names: readonly string[]\n\treadonly optional: ReadonlySet<unknown>\n\treadonly vocabulary: ReadonlySet<unknown>\n}> {\n\tconst declared = readValue(\n\t\t() => {\n\t\t\tconst members = INTRINSICS.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 * Snapshot 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 * Validate and snapshot 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.read(input, key)\n\t\t\t\t\tINTRINSICS.present(input, key)\n\t\t\t\t\tINTRINSICS.reveal(input, key)\n\t\t\t\t}\n\t\t\t\tINTRINSICS.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.declare(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 * Draw and validate one generator random sample.\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 * Resolve 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 via {@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.read(current, key)\n\t\t}\n\t\treturn current\n\t})\n\treturn outcome.success ? outcome.value : undefined\n}\n\n/**\n * Determine 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` when no active path exceeds {@link GUARD_DEPTH_LIMIT}\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.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.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] = { operation: 'enter', value: INTRINSICS.read(entry, key), depth }\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t})\n}\n\n/**\n * Match 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} already was. It used to recurse, and that made the\n * verdict a function of the REMAINING CALL STACK rather than of the value: the\n * same readable 4,000-deep document answered `true` at a root call site and\n * `false` a few frames down, and `parseJSONValue` republished the resulting\n * `RangeError` as `value could not be read` for a value every read of which\n * succeeded. A cap enforced by the JavaScript stack is not a cap. This walk\n * carries no depth cap of its own — `isJSONValue` is deliberately the unbounded\n * deep gate and {@link matchesJSONDepth} / `isBoundedJSONValue` are the bounded\n * pair beside it — so the answer now depends only on the value, at every depth\n * and from every 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` when the value is a cycle-free JSON value\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 * Build 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 * Count 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 * Narrow 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 (AGENTS §14).\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; the `undefined` fallback only satisfies the type's\n * optionality. 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 * Wrap 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// === Inference option sanitization\n\n/**\n * Sanitize a user-supplied inference budget (`maxDepth` / `maxProperties`) 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 * `maxProperties` 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 * Resolve 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 * `maxDepth` 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 * Render a short, safe, TOTAL preview of an unknown value 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. One bounded indexed\n * encoder appends only complete escaped code-point tokens within\n * {@link PREVIEW_LIMIT}; clipping therefore never retrieves the mutable string\n * iterator or splits an escape/surrogate pair before its trailing `…`, and\n * enormous primitive text is not fully traversed. A number / boolean / bigint\n * renders via `String`; `null` and `undefined` render as their own name. An\n * array renders as `'array'`. Every other host — a plain object, a function, a\n * class instance, a `Map` — is NEVER traversed or stringified; it renders as\n * its bare `typeof` tag (`'object'` / `'function'`).\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\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 * Build 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 agreed on every constraint afterwards by\n * carrying two copies of the same twenty-one lines, which is one edit away from\n * two contracts. 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 pattern is applied through an OWNED stateless rebuild\n * ({@link readPattern}) and asked through {@link matchesPattern}, so a caller's\n * `lastIndex` never moves and no caller-writable member decides whether the\n * value matched.\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 * @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 * createStringFaults({ type: 'string', min: 3 }, 'ab', [])\n * // [{ reason: 'constraint', path: [], expected: 'string', constraint: 'min', limit: 3, received: '\"ab\"' }]\n * ```\n */\nexport function createStringFaults(\n\tshape: StringShape,\n\tvalue: string,\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 && 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\tif (shape.pattern !== undefined && !matchesPattern(readPattern(shape.pattern), value)) {\n\t\t\t\tconst limit = readPatternSource(shape.pattern)\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'createStringFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Build the refinement faults a number value has against a {@link NumberShape}.\n *\n * @remarks\n * The numeric sibling of {@link createStringFaults}, 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 createStringFaults} 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 * createNumberFaults({ type: 'number', integer: true }, 1.5, [])\n * // [{ reason: 'constraint', path: [], expected: 'integer', constraint: 'integer', received: '1.5' }]\n * ```\n */\nexport function createNumberFaults(\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'createNumberFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Build 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 createStringFaults} 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 * createArrayFaults({ type: 'array', items: { type: 'string' }, min: 2 }, 1, [])\n * // [{ reason: 'constraint', path: [], expected: 'array', constraint: 'min', limit: 2, received: '1' }]\n * ```\n */\nexport function createArrayFaults(\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'createArrayFaults',\n\t\t{ subject: 'shape' },\n\t)\n}\n\n/**\n * Select 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 * Project 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 `type` (`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. The switch used to fall off its end and return\n * `undefined` for such a node, which made the declared non-optional\n * {@link FaultKind} return type a lie 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.type) {\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 * Refuse 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 validateShapeDepth} function and the lazy {@link ContractCompiler}\n * preparation. The refusal keeps `validateShapeDepth`'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\n * @returns Nothing when the count is within the limit\n * @throws {ContractError} When the count exceeds {@link COMPILE_NODE_LIMIT}\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): void {\n\tif (expansion <= COMPILE_NODE_LIMIT) return\n\tthrow new ContractError('validateShapeDepth: 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 * Stateful owner 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\treadonly #source: unknown\n\treadonly #owned: WeakSet<object>\n\treadonly #active: WeakSet<object>\n\treadonly #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 * Clone 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#fail(error: ContractError): never {\n\t\tthis.#terminal = { success: false, error }\n\t\tthis.#pending.length = 0\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.members(source))\n\t\tif (!keysOutcome.success) this.#refuse('cloneJSONValue: own keys could not be inspected')\n\t\tconst lengthOutcome = attempt(() => INTRINSICS.reveal(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.reveal(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.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.reveal(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// 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 * Stateful owner 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\treadonly #source: JSONSchema\n\treadonly #owned: WeakSet<object>\n\t#memo: Map<object, object>\n\treadonly #emptyMemo: Map<object, object>\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\treadonly #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\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.#emptyMemo = new SchemaCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#emptyPending = []\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clone 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\tconst root: JSONSchema = INTRINSICS.create(null)\n\t\tINTRINSICS.apply(INTRINSICS.store, this.#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 existing = INTRINSICS.apply(INTRINSICS.fetch, this.#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 clone: object = INTRINSICS.array(source) ? [] : INTRINSICS.create(null)\n\t\tINTRINSICS.apply(INTRINSICS.store, this.#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.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#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// Two 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#settle(result: Result<JSONSchema, ContractError>): JSONSchema {\n\t\tthis.#pending = this.#emptyPending\n\t\tthis.#memo = this.#emptyMemo\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// 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 * A reusable live validator for one retained contract-shape source.\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({ type: '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#phase:\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['type'] | 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 = 0\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['type'] | 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 * Retain 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 * The number of nodes the last successful {@link validate} found the source\n\t * 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. `0` before the first successful pass and after a\n\t * failed one, because a failed pass has no expansion to report.\n\t */\n\tget expansion(): number {\n\t\treturn this.#expansion\n\t}\n\n\t/**\n\t * Validate 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 `validateShapeDepth: 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.#phase.phase === 'active') {\n\t\t\tconst poison =\n\t\t\t\tthis.#phase.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.#phase = { phase: 'active', poison }\n\t\t\tthrow poison\n\t\t}\n\n\t\tthis.#clear()\n\t\tthis.#phase = { phase: 'active' }\n\t\tconst outcome = attempt(() => this.#execute())\n\t\tconst poison = this.#phase.phase === 'active' ? this.#phase.poison : undefined\n\t\tthis.#clear()\n\t\tif (poison !== undefined) throw poison\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('validateShapeDepth: 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.#phase = { 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 = 0\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'validateShapeDepth: 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(\n\t\t\t\t'validateShapeDepth: a shape graph may not contain a cycle',\n\t\t\t\t{\n\t\t\t\t\tcode: 'cycle',\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\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. Two rules are\n\t\t// properties of the POSITION instead, and they are answered in two different\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.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'validateShapeDepth: 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, exactly as\n\t\t\t// before, but every later edge to it now measures its depth from the\n\t\t\t// capture instead of re-running the 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, 'type')\n\t\tif (descriptor === undefined || !INTRINSICS.own(descriptor, 'value')) {\n\t\t\treturn this.#refuse('validateShapeDepth: every node must be a recognized shape')\n\t\t}\n\t\tconst category = current.type\n\t\tif (current.type !== category || descriptor.value !== category) {\n\t\t\treturn this.#refuse('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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(\n\t\t\t\t\t'validateShapeDepth: every node must be a recognized shape',\n\t\t\t\t\t'properties',\n\t\t\t\t)\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('validateShapeDepth: 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('validateShapeDepth: 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['type']): 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.read(current, field)\n\t\t\t\tconst second: unknown = INTRINSICS.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('validateShapeDepth: 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.type !== 'optional' &&\n\t\t\tcurrent.type !== 'nullable' &&\n\t\t\tcurrent.type !== 'raw' &&\n\t\t\tcurrent.description !== undefined &&\n\t\t\ttypeof current.description !== 'string'\n\t\t) {\n\t\t\treturn this.#refuse('validateShapeDepth: description must be a string', 'description')\n\t\t}\n\t\tif (current.type === 'string') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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.type === 'number') {\n\t\t\tif (current.min !== undefined && typeof current.min !== 'number') {\n\t\t\t\treturn this.#refuse('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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(\n\t\t\t\t\t'validateShapeDepth: a number shape has min greater than max',\n\t\t\t\t\t{ code: 'range', context: { 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'validateShapeDepth: 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 (current.type === 'array' && current.min !== undefined && typeof current.min !== 'number') {\n\t\t\treturn this.#refuse('validateShapeDepth: array min must be a number', 'min')\n\t\t}\n\t\tif (current.type === 'array' && current.max !== undefined && typeof current.max !== 'number') {\n\t\t\treturn this.#refuse('validateShapeDepth: array max must be a number', 'max')\n\t\t}\n\t\tif (\n\t\t\tcurrent.type === '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'validateShapeDepth: 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.type === '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'validateShapeDepth: 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.type === '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(\n\t\t\t\t'validateShapeDepth: an array shape has min greater than max',\n\t\t\t\t{\n\t\t\t\t\tcode: 'range',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'array' },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tcurrent.type === '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('validateShapeDepth: 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 `type` 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'validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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(\n\t\t\t\t'validateShapeDepth: a string shape has min greater than max',\n\t\t\t\t{\n\t\t\t\t\tcode: 'range',\n\t\t\t\t\tcontext: { path: pathOf(this.#path), shape: 'string' },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\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('validateShapeDepth: 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'validateShapeDepth: 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('validateShapeDepth: a raw schema may not contain a cycle', 'schema')\n\t\t\t}\n\t\t\tif (INTRINSICS.apply(INTRINSICS.recall, this.#schemas, [schema]) !== undefined) continue\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(\n\t\t\t\t\t\t'validateShapeDepth: raw schema contains an unsupported keyword',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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.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('validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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(\n\t\t\t\t\t\t'validateShapeDepth: raw schema enum must be a non-empty array',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\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(\n\t\t\t\t\t\t'validateShapeDepth: raw schema enum must be a non-empty array',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse('validateShapeDepth: 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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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(\n\t\t\t\t\t\t'validateShapeDepth: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\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(\n\t\t\t\t\t\t'validateShapeDepth: raw schema unions must be non-empty arrays',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!snapshot.value.dense) {\n\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t'validateShapeDepth: raw schema unions must be dense arrays',\n\t\t\t\t\t\t'schema',\n\t\t\t\t\t)\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.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.apply(INTRINSICS.recall, this.#schemas, [child]) ?? 0)\n\t\t\tif (recorded + 1 > height) height = recorded + 1\n\t\t}\n\t\tINTRINSICS.apply(INTRINSICS.retain, this.#schemas, [schema, height])\n\t}\n\n\t#populate(current: ContractShape): boolean {\n\t\tswitch (current.type) {\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'validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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'validateShapeDepth: 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(\n\t\t\t\t\t\t\t'validateShapeDepth: values must be a dense data array',\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 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'validateShapeDepth: 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(\n\t\t\t\t\t\t\t'validateShapeDepth: values must be a stable data array',\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 (!isLiteralValue(value)) {\n\t\t\t\t\t\treturn this.#refuse(\n\t\t\t\t\t\t\t'validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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.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.apply(INTRINSICS.recall, this.#index, [shape])\n\t}\n\n\t// Everything the walk used to answer by walking again. 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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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: `validateShape` and `validateShapeDepth`\n\t\t// reach it through `ShapeValidator.prototype.validate`, so an assignment\n\t\t// there decides whether a shape gate the caller never 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 * Stateful owner 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({ type: '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\treadonly #source: ContractShape\n\treadonly #owned: WeakSet<object>\n\t#memo: Map<ContractShape, ContractShape>\n\treadonly #emptyMemo: Map<ContractShape, ContractShape>\n\t#paths: Map<ContractShape, readonly string[]>\n\treadonly #emptyPaths: Map<ContractShape, readonly string[]>\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[]>\n\treadonly #emptyProperties: Map<ContractShape, readonly ShapeProperty[]>\n\t#variants: Map<ContractShape, ReadonlyArray<ContractShape | undefined>>\n\treadonly #emptyVariants: Map<ContractShape, ReadonlyArray<ContractShape | 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\treadonly #emptyPending: Array<{ readonly shape: ContractShape; readonly depth: number }>\n\t#sources: ContractShape[]\n\treadonly #emptySources: 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.#emptyMemo = new ShapeCloner.#map()\n\t\tthis.#paths = new ShapeCloner.#map()\n\t\tthis.#emptyPaths = new ShapeCloner.#map()\n\t\tthis.#properties = new ShapeCloner.#map()\n\t\tthis.#emptyProperties = new ShapeCloner.#map()\n\t\tthis.#variants = new ShapeCloner.#map()\n\t\tthis.#emptyVariants = new ShapeCloner.#map()\n\t\tthis.#pending = []\n\t\tthis.#emptyPending = []\n\t\tthis.#sources = []\n\t\tthis.#emptySources = []\n\t\tthis.#fidelity = undefined\n\t\tthis.#state = { phase: 'ready' }\n\t}\n\n\t/**\n\t * Clone 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\tINTRINSICS.apply(INTRINSICS.store, this.#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.apply(INTRINSICS.fetch, this.#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\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.apply(INTRINSICS.keyed, this.#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// `validateShapeDepth`'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// `validateShapeDepth` would be handed, so the two doors 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('validateShapeDepth: 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('validateShapeDepth: 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, 'type')\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.type\n\t\tconst repeated = source.type\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('validateShapeDepth: 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.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.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('validateShapeDepth: 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('validateShapeDepth: 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 path = INTRINSICS.apply(INTRINSICS.fetch, this.#paths, [source]) ?? []\n\t\tconst clone = this.#captureShell(source, path)\n\n\t\tINTRINSICS.apply(INTRINSICS.store, this.#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. Every bound, range and\n\t\t// pattern-flag rule this capture used to author has an exact twin in\n\t\t// `ShapeValidator`, which runs on the carried clone at `#execute` — and a\n\t\t// second copy that fires EARLIER, in capture order rather than declaration\n\t\t// order and before structure outranks domain, is exactly how `cloneShape`\n\t\t// came to name a different rule at a different path than the shared gate\n\t\t// for one declaration. One rule, one arbiter.\n\t\tconst fields: StringShape = {\n\t\t\ttype: '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\ttype: '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 { type: 'boolean', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\tif (category === 'null') {\n\t\t\treturn { type: 'null', ...(description === undefined ? {} : { description }) }\n\t\t}\n\t\treturn { type: '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\ttype: '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('validateShapeDepth: 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\ttype: '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('validateShapeDepth: 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\ttype: '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\ttype: '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('validateShapeDepth: 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' ? { type: 'optional', inner } : { type: '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('validateShapeDepth: 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({ type: '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 { type: '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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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'validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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\tINTRINSICS.apply(INTRINSICS.store, this.#properties, [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('validateShapeDepth: 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('validateShapeDepth: 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('validateShapeDepth: 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\tINTRINSICS.apply(INTRINSICS.store, this.#variants, [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(\n\t\t\t\t\t'validateShapeDepth: every structural child must be a shape',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'structure',\n\t\t\t\t\t\tcontext: { path: pathOf(path, 'variants', key) },\n\t\t\t\t\t},\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.type) {\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 properties = INTRINSICS.apply(INTRINSICS.fetch, this.#properties, [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 variants = INTRINSICS.apply(INTRINSICS.fetch, this.#variants, [source])\n\t\t\t\tif (variants === undefined) {\n\t\t\t\t\tthrow this.#create('validateShapeDepth: 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\tINTRINSICS.apply(INTRINSICS.store, this.#paths, [child, path])\n\t\tthis.#pending[this.#pending.length] = { shape: child, depth: depth + 1 }\n\t}\n\n\t#wireNodes(): void {\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.apply(INTRINSICS.fetch, this.#memo, [source])\n\t\t\tif (clone === undefined) continue\n\t\t\tconst path = INTRINSICS.apply(INTRINSICS.fetch, this.#paths, [source]) ?? []\n\t\t\tswitch (clone.type) {\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 items = INTRINSICS.apply(INTRINSICS.fetch, this.#memo, [clone.items])\n\t\tif (items === undefined) {\n\t\t\tthrow this.#create('validateShapeDepth: 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.write(clone, 'items', items)\n\t}\n\n\t#wireObject(source: ContractShape, clone: ObjectShape, path: readonly string[]): void {\n\t\tconst snapshot = INTRINSICS.apply(INTRINSICS.fetch, this.#properties, [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('validateShapeDepth: 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.apply(INTRINSICS.fetch, this.#memo, [child])\n\t\t\tif (cloned === undefined) {\n\t\t\t\tthrow this.#create('validateShapeDepth: 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.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.apply(INTRINSICS.fetch, this.#memo, [additional])\n\t\t\tif (cloned === undefined) {\n\t\t\t\tthrow this.#create('validateShapeDepth: 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.write(clone, 'additionalProperties', cloned)\n\t\t}\n\t}\n\n\t#wireUnion(source: ContractShape, clone: UnionShape, path: readonly string[]): void {\n\t\tconst snapshot = INTRINSICS.apply(INTRINSICS.fetch, this.#variants, [source])\n\t\tif (snapshot === undefined) {\n\t\t\tthrow this.#create('validateShapeDepth: 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('validateShapeDepth: 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.apply(INTRINSICS.fetch, this.#memo, [variant])\n\t\t\tif (cloned === undefined) {\n\t\t\t\tthrow this.#create('validateShapeDepth: 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.write(clone, 'variants', INTRINSICS.freeze(variants))\n\t}\n\n\t#wireWrapper(clone: OptionalShape | NullableShape, path: readonly string[]): void {\n\t\tconst inner = INTRINSICS.apply(INTRINSICS.fetch, this.#memo, [clone.inner])\n\t\tif (inner === undefined) {\n\t\t\tthrow this.#create('validateShapeDepth: 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.write(clone, 'inner', inner)\n\t}\n\n\t#freezeNodes(): void {\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.apply(INTRINSICS.fetch, this.#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#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#settle(result: Result<ContractShape, ContractError>): ContractShape {\n\t\tthis.#memo = this.#emptyMemo\n\t\tthis.#paths = this.#emptyPaths\n\t\tthis.#properties = this.#emptyProperties\n\t\tthis.#variants = this.#emptyVariants\n\t\tthis.#pending = this.#emptyPending\n\t\tthis.#sources = this.#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// 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-clone 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-clone 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-clone 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-clone 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.type === '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 * Take 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: under `Object.freeze = (value) => value`\n * this door used to SUCCEED and publish a mutable graph, with no throw and no\n * 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 *\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\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\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 (AGENTS §14). The\n// combinators that invoke a caller-supplied callback inside the guard body\n// contain the whole call via `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 * Build 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 * @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 * Build a guard that accepts fixed-arity DENSE tuples, testing each index with\n * the corresponding guard.\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 * Build 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 * Build a guard that accepts instances of the provided constructor.\n *\n * @remarks\n * Verifies that `ctor` is a real constructor (via {@link isConstructor}) first,\n * so passing an arrow function does not silently produce a broken guard.\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 * Build a guard from a native `enum` or any object whose values are strings or\n * numbers.\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// now 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 * Build a guard that accepts `Set` instances whose every element satisfies\n * `elementGuard`.\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 * Build a guard that accepts `Map` instances where every key satisfies\n * `keyGuard` and every value satisfies `valueGuard`.\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\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] }>>\n\n/**\n * Build a guard that accepts plain records matching a guard shape.\n *\n * @remarks\n * Three calling modes depending 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. The\n * The exactness check inspects every own string key, including non-enumerable\n * keys. Symbol keys are ignored intentionally for JSON fidelity.\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<\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.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\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] }>>\n\n/**\n * Build a guard that accepts non-array objects matching an open guard shape.\n *\n * @remarks\n * Three 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 * @example\n * ```ts\n * const isResult = objectOf({ conclusion: isBoolean })\n * isResult({ conclusion: true, metadata: 'retained' }) // true\n * isResult([]) // false\n * ```\n */\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.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 * Build 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 * @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.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 * Build 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 * @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.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 * Build 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 * @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.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 * Combine two guards 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 two independent guards.\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 * Combine two guards with logical OR — passes when at least one passes. For more\n * than two variants prefer {@link unionOf}.\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 * Negate 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 * @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 * Build a guard for `Exclude<TBase, TExcluded>` — accepts values that pass\n * `base` but not `excluded`.\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 * Build a guard that accepts values matching at least one of the provided\n * guards — the variadic form of {@link orOf}.\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 * Build a guard that accepts values matching ALL of the provided guards — the\n * variadic form of {@link andOf}.\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` twelve lines up. The\n\t\t\t// ruling forbidding `Array.prototype.every` here was already stated 528\n\t\t\t// lines earlier in this same file and applied to `literalOf`, and this\n\t\t\t// statement was missed by the sweep that wrote it: `every` answering\n\t\t\t// `true` for everything made this guard accept a value no constituent\n\t\t\t// 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 * Refine 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. Per\n * §14 the returned guard never throws: if `predicate` throws, the throw is\n * contained and the guard reports a non-match.\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 * Defer 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. Per §14 a throw from `thunk` (or the guard\n * it resolves to) is contained and reported as a non-match.\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 * @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 * Build 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`. Per §14 the returned guard never\n * throws: a 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 * @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 * Build 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 * @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 * Build 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 * Build 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 all three options are 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?: {\n\tmin?: number\n\tmax?: number\n\tpattern?: RegExp\n}): 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 =\n\t\t\tsource === undefined\n\t\t\t\t? undefined\n\t\t\t\t: readValue(() => readPattern(source), 'stringOf', {\n\t\t\t\t\t\tsubject: 'pattern',\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\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 * Extend a guard to also allow `null`.\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 * Extend a guard to also allow `undefined` — the optional counterpart of\n * {@link nullableOf}.\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 { Guard, JSONValue, LiteralValue } from './types.js'\nimport { INTRINSICS } from './constants.js'\nimport type { FieldPath } from './types.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// AGENTS §14: a parser answers \"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 (e.g. numeric strings → numbers) is a bonus on\n// top of soundness, not a violation of it — clause A only constrains inputs the\n// 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 * Parse 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 * Parse 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 * via `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 * Parse 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 * Parse 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 * Parse 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 * Parse an unknown value to a plain record — the input reference, never cloned.\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 * Parse 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 * Parse 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 via {@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 * Parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse 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 * Read and parse a JSON-value field from a record by key or nested key path.\n *\n * @remarks\n * Deep-gates the field's whole subtree via {@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 * Parse 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 * Parse a JSON string and validate 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 { FAULT_LIMIT, GENERATION_ATTEMPT_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError, isContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tappendEntries,\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tcreateArrayFaults,\n\tcreateNumberFaults,\n\tcreateStringFaults,\n\tdrawRandom,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\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 * Lazy compiler owning one contract shape's six artifacts and their bundle.\n *\n * @remarks\n * The engine every standalone `compile*` function and `createContract` now runs\n * on. Its reason for existing is that the recursive compilers used to re-own and\n * re-validate the SUBGRAPH at every node they descended into, so a depth-100\n * chain paid a hundred clones of shrinking graphs and a hundred validations —\n * quadratic work for a linear declaration, measured at 640 ms for one guard and\n * 1.87 s for one contract. 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({ type: '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 now 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 these two 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#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\treadonly #emptyStack: 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.\n\t#nodes: ContractShape[]\n\treadonly #emptyNodes: ContractShape[]\n\t#index: WeakMap<ContractShape, number>\n\treadonly #emptyIndex: WeakMap<ContractShape, number>\n\t#order: number[]\n\treadonly #emptyOrder: 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\treadonly #emptySchemas: JSONSchema[]\n\t#guards: Array<Guard<unknown>>\n\treadonly #emptyGuards: Array<Guard<unknown>>\n\t#parsers: Array<Parser<unknown>>\n\treadonly #emptyParsers: Array<Parser<unknown>>\n\t#audits: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]>\n\treadonly #emptyAudits: Array<(value: unknown, path: readonly string[]) => readonly AuditFault[]>\n\t#reports: Array<(value: unknown, path: readonly string[]) => readonly Fault[]>\n\treadonly #emptyReports: Array<(value: unknown, path: readonly string[]) => readonly Fault[]>\n\t#seeds: Array<(random: RandomFunction) => unknown>\n\treadonly #emptySeeds: 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 * Retain 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.#emptyStack = []\n\t\tthis.#nodes = []\n\t\tthis.#emptyNodes = []\n\t\tthis.#index = new ContractCompiler.#weakMap()\n\t\tthis.#emptyIndex = new ContractCompiler.#weakMap()\n\t\tthis.#order = []\n\t\tthis.#emptyOrder = []\n\t\tthis.#schemas = []\n\t\tthis.#emptySchemas = []\n\t\tthis.#guards = []\n\t\tthis.#emptyGuards = []\n\t\tthis.#parsers = []\n\t\tthis.#emptyParsers = []\n\t\tthis.#audits = []\n\t\tthis.#emptyAudits = []\n\t\tthis.#reports = []\n\t\tthis.#emptyReports = []\n\t\tthis.#seeds = []\n\t\tthis.#emptySeeds = []\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 * 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/** 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/** 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/** 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/** 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/** 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 * The frozen six-member 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 all\n\t// six families 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 all six roots exist nothing can need the graph again, so the graph, the\n\t// index, the order and every family plan go. The six 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 of preconstructed peers only. Nothing here calls a caller-mutable\n\t// cleanup member and nothing here constructs a collection after the source was\n\t// observed, so release cannot be redirected into leaving state behind.\n\t#release(): void {\n\t\tthis.#source = undefined\n\t\tthis.#stack = this.#emptyStack\n\t\tthis.#nodes = this.#emptyNodes\n\t\tthis.#index = this.#emptyIndex\n\t\tthis.#order = this.#emptyOrder\n\t\tthis.#schemas = this.#emptySchemas\n\t\tthis.#guards = this.#emptyGuards\n\t\tthis.#parsers = this.#emptyParsers\n\t\tthis.#audits = this.#emptyAudits\n\t\tthis.#reports = this.#emptyReports\n\t\tthis.#seeds = this.#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\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.apply(INTRINSICS.recall, this.#index, [shape]) !== undefined) continue\n\t\t\tconst index = this.#nodes.length\n\t\t\tthis.#nodes[index] = shape\n\t\t\tINTRINSICS.apply(INTRINSICS.retain, this.#index, [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.type) {\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\tconst index = INTRINSICS.apply(INTRINSICS.recall, this.#index, [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]?.type === '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\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 type = this.#node(index).type\n\t\tif (type === 'array' || type === 'object' || type === 'union') return true\n\t\treturn type === 'optional' || type === 'nullable'\n\t}\n\n\t#trackGuard(plan: Guard<unknown>): Guard<unknown> {\n\t\tlet filled = 0\n\t\tlet memo: WeakMap<object, boolean> = new ContractCompiler.#weakMap()\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 = new ContractCompiler.#weakMap()\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tconst recalled = INTRINSICS.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\tconst answer = plan(value)\n\t\t\t\tINTRINSICS.apply(INTRINSICS.retain, memo, [value, answer])\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.\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[]> = new ContractCompiler.#weakMap()\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 = new ContractCompiler.#weakMap()\n\t\t\t\t\tfilled = scope\n\t\t\t\t}\n\t\t\t\tconst recalled = INTRINSICS.apply(INTRINSICS.recall, memo, [value])\n\t\t\t\tif (recalled !== undefined) return recalled\n\t\t\t\tconst answer = plan(value, path)\n\t\t\t\tif (answer.length === 0) INTRINSICS.apply(INTRINSICS.retain, memo, [value, answer])\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.type) {\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.type === 'optional' ? child.inner : child)\n\t\t\t\t\tif (child.type !== '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.type) {\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.type === '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\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 (AGENTS §14).\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = collectMembers(keys)\n\t\t\t\t\t\tfor (let keyIndex = 0; keyIndex < required.length; keyIndex += 1) {\n\t\t\t\t\t\t\tconst key = required[keyIndex]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tif (!matchesMember(present, key)) return false\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.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.type) {\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.type === '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\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 (AGENTS §14).\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = collectMembers(keys)\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\tif (!matchesMember(present, entry.key)) {\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 (AGENTS §14 clause A): a value already valid\n\t\t\t\t\t// against ANY variant's guard is returned unchanged, so an earlier\n\t\t\t\t\t// variant's coercion never overwrites a guard-valid input.\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 the standalone `compileAuditor` used to provide around the\n\t// whole walk, so a host failure under a hostile value still publishes this\n\t// 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.type) {\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\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 createStringFaults(node, value, path)\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\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 createNumberFaults(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, createArrayFaults(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.type === '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\treturn (value, path) => {\n\t\t\t\t\tif (isObject(value)) {\n\t\t\t\t\t\treadValue(() => INTRINSICS.parent(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// Both views are built inside the contained walk: a replaced\n\t\t\t\t\t// `globalThis.Set` must reach the auditor's own containment rather than\n\t\t\t\t\t// throw the caller's raw value out of a total report.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = collectMembers(keys)\n\t\t\t\t\t\tconst declared = collectMembers(declaredKeys)\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\tif (!matchesMember(present, entry.key)) {\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(declared, 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\tperVariant[perVariant.length] = variantFaults\n\t\t\t\t\t\tif (variantFaults.length === 0) matched += 1\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} else if (matched > 0) {\n\t\t\t\t\t\treturn []\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.type) {\n\t\t\tcase 'string': {\n\t\t\t\tconst node: StringShape = owned\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 createStringFaults(node, parsed, path)\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\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 createNumberFaults(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, createArrayFaults(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 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.type === '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}\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\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// Both views are built inside the contained walk: a replaced\n\t\t\t\t\t// `globalThis.Set` must reach the reporter's own diagnostic containment\n\t\t\t\t\t// rather than throw the caller's raw value out of a total report.\n\t\t\t\t\tconst outcome = attempt(() => {\n\t\t\t\t\t\tconst present = collectMembers(keys)\n\t\t\t\t\t\tconst known = 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\tif (faults.length >= FAULT_LIMIT) return\n\t\t\t\t\t\t\tadmitMember(known, entry.key)\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\tif (!matchesMember(present, entry.key)) {\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(known, 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\tperVariant[perVariant.length] = plan(value, path)\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\tfor (let index2 = 0; index2 < perVariant.length; index2 += 1) {\n\t\t\t\t\t\tif (perVariant[index2]?.length === 0) return []\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.type) {\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.type === '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 six 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 six 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\tContractInterface,\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 two engines. `ShapeValidator` owns the\n// stateful declaration walk; `ContractCompiler` owns ownership, preparation and\n// the six artifact families. 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: the earlier\n// shape of this module re-entered its own public functions per node, which\n// re-owned and re-validated the subgraph at every level.\n\n// === Validation\n\n/**\n * Gate 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 * validateShapeDepth(stringShape({ min: 1 })) // returns; the declaration is compilable\n * ```\n */\nexport function validateShapeDepth(shape: ContractShape): void {\n\treturn contain(() => {\n\t\tconst validator = new ShapeValidator(shape)\n\t\tvalidator.validate()\n\t\trefuseExpansion(validator.expansion)\n\t}, 'validateShapeDepth')\n}\n\n// === Schema\n\n/**\n * Compile 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 * Compile 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 (AGENTS §14). 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 * Compile 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 (AGENTS §14): 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 * Compile 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 * Compile 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, not just the outermost container, 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 via {@link attempt}\n * and surfaces as a single top-level type fault, never a throw (AGENTS §14).\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 * Audit 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\n// === Contract\n\n/**\n * Compile a {@link ContractShape} into a {@link ContractInterface} — the six\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 the six artifacts are 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 * All six artifacts are precompiled, so `audit`, `explain` and `generate` no\n * longer re-walk and re-gate the declaration on every call the way they used\n * to; `contract.audit` and `compileAuditor` are the same compiled function\n * reached two ways.\n *\n * @param shape - The shape to compile\n * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`\n *\n * @example\n * ```ts\n * const user = createContract(objectShape({ name: stringShape(), age: integerShape() }))\n * user.is({ name: 'Ada', age: 36 })        // true\n * user.parse({ name: 'Ada', age: '36' })   // { name: 'Ada', age: 36 }\n * user.schema                              // { type: 'object', properties: { … }, … }\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, SampleMemo, SchemaFormat, ValueToSchemaOptions } from './types.js'\nimport {\n\tFORMAT_MAX_LENGTH,\n\tFORMAT_PATTERNS,\n\tINFER_BREADTH_LIMIT,\n\tINFER_ENUM_LIMIT,\n\tINTRINSICS,\n} from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tisArray,\n\tisBoolean,\n\tisDate,\n\tisFiniteNumber,\n\tisInteger,\n\tisNull,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n} from './validators.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tappendEntries,\n\tattempt,\n\tbuildSampleMemo,\n\tcollectMembers,\n\tcontain,\n\tenumerableKeys,\n\tlimitEntries,\n\tmatchesMember,\n\tmatchesPattern,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\treadArrayEntries,\n\treadOptions,\n\treadSampleMemo,\n\treadValue,\n\tretainDepth,\n\tsanitizeBudget,\n\tsanitizeDepth,\n\tsortValues,\n} from './helpers.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// === Canonicalization\n\n/**\n * Encode one value as a deterministic, key-sorted JSON string — the traversal\n * spine of {@link canonicalStringify}.\n *\n * @remarks\n * Arrays keep their element order through the shared dense own-index lens;\n * records sort their own keys before encoding, at every nesting level. Every\n * other value is encoded by\n * `JSON.stringify`, so `NaN` / `±Infinity` collapse to `'null'` and `-0`\n * encodes as `'0'` — the same lossy-but-deterministic mapping real JSON makes.\n *\n * Returns `undefined` for anything JSON cannot encode: `undefined` itself, a\n * function, a symbol, an array hole, or a cyclic back-edge to an ancestor. A\n * container carrying such a member is itself un-encodable and returns\n * `undefined` too, so the result is either a faithful encoding of the WHOLE\n * value or nothing — a partially-encoded key is never emitted. A hostile\n * getter or `Proxy` trap is refused through this function's own required-read\n * boundary, including when this spine is called directly.\n *\n * The walk is ITERATIVE over an explicit enter/exit stack and keeps a\n * walk-local encoding memo, so a container reached through several paths is\n * encoded ONCE. That memo is sound precisely because a partial answer does not\n * exist here: any cycle or JSON-inexpressible member abandons the whole call,\n * so a recorded encoding is the container's complete encoding on every path.\n * The earlier recursion re-encoded per path, which made thirty ordinary shared\n * aliases cost `2^30` encodings through the public {@link canonicalStringify}\n * and {@link unifySchemas} doors. Each container's members are read ONCE, at\n * the moment it is entered, and the ancestor set is restored on every exit\n * including the abandoning ones.\n *\n * @param value - The value to encode\n * @param ancestors - Objects on the active traversal path, guarding cycles\n * @returns The deterministic encoding, or `undefined` when JSON cannot encode\n *          `value`\n *\n * @example\n * ```ts\n * canonicalizeValue({ b: 1, a: 2 }, new WeakSet()) // '{\"a\":2,\"b\":1}'\n * canonicalizeValue(undefined, new WeakSet())      // undefined\n * ```\n */\nexport function canonicalizeValue(value: unknown, ancestors: WeakSet<object>): 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 encodings = new INTRINSICS.weakMap<object, string>()\n\t\t\tconst admitted: object[] = []\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\ttry {\n\t\t\t\twhile (stack.length > 0) {\n\t\t\t\t\tconst frame = stack.pop()\n\t\t\t\t\tif (frame === undefined) return undefined\n\t\t\t\t\tif (frame.operation === 'exit') {\n\t\t\t\t\t\t// Indexed and concatenated, not iterated and joined: this string IS\n\t\t\t\t\t\t// the canonical identity every schema de-duplication and every `enum`\n\t\t\t\t\t\t// ordering is keyed by, and both `Array.prototype[Symbol.iterator]`\n\t\t\t\t\t\t// and `Array.prototype.join` are caller-writable members on it.\n\t\t\t\t\t\tlet encoded = ''\n\t\t\t\t\t\tfor (let index = 0; index < frame.members.length; index += 1) {\n\t\t\t\t\t\t\tconst member = frame.members[index]\n\t\t\t\t\t\t\tconst part = isObject(member)\n\t\t\t\t\t\t\t\t? (INTRINSICS.apply(INTRINSICS.recall, encodings, [member]) ?? encodeLeaf(member))\n\t\t\t\t\t\t\t\t: encodeLeaf(member)\n\t\t\t\t\t\t\tif (part === undefined) return undefined\n\t\t\t\t\t\t\tconst key = frame.keys?.[index]\n\t\t\t\t\t\t\tconst text = key === undefined ? part : `${INTRINSICS.stringify(key)}:${part}`\n\t\t\t\t\t\t\tencoded += index === 0 ? text : `,${text}`\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst text = frame.keys === undefined ? `[${encoded}]` : `{${encoded}}`\n\t\t\t\t\t\tINTRINSICS.apply(INTRINSICS.retain, encodings, [frame.value, text])\n\t\t\t\t\t\tomitVisited(ancestors, frame.value)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tconst container = frame.value\n\t\t\t\t\tif (matchesVisited(ancestors, container)) return undefined\n\t\t\t\t\tif (INTRINSICS.apply(INTRINSICS.recall, encodings, [container]) !== undefined) continue\n\t\t\t\t\tconst members: unknown[] = []\n\t\t\t\t\tconst selected: string[] = []\n\t\t\t\t\tlet keys: readonly string[] | undefined\n\t\t\t\t\tif (isArray(container)) {\n\t\t\t\t\t\tconst snapshot = readArrayEntries(container)\n\t\t\t\t\t\tif (!snapshot.success) throw snapshot.error\n\t\t\t\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\t\t\t\t// Indexed, not `appendEntries`: a PRESENT `undefined` element is a\n\t\t\t\t\t\t// value JSON cannot encode and must abandon the whole encoding, and\n\t\t\t\t\t\t// the shared appender skips `undefined` by design.\n\t\t\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\t\t\tfor (let index = 0; index < entries.length; index += 1) {\n\t\t\t\t\t\t\tmembers[members.length] = entries[index]\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst names = sortValues(INTRINSICS.keys(container))\n\t\t\t\t\t\tfor (let index = 0; index < names.length; index += 1) {\n\t\t\t\t\t\t\tconst key = names[index]\n\t\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\t\tselected[selected.length] = key\n\t\t\t\t\t\t\tmembers[members.length] = INTRINSICS.read(container, key)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tkeys = selected\n\t\t\t\t\t}\n\t\t\t\t\tadmitVisited(ancestors, container)\n\t\t\t\t\tadmitted[admitted.length] = container\n\t\t\t\t\tstack[stack.length] = { operation: 'exit', value: container, members, keys }\n\t\t\t\t\tfor (let index = members.length - 1; index >= 0; index -= 1) {\n\t\t\t\t\t\tconst member = members[index]\n\t\t\t\t\t\tif (isObject(member) && (isArray(member) || matchesRecordBrand(member))) {\n\t\t\t\t\t\t\tstack[stack.length] = { operation: 'enter', value: member }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn INTRINSICS.apply(INTRINSICS.recall, encodings, [value])\n\t\t\t} finally {\n\t\t\t\t// An abandoning return leaves entered containers on the caller's\n\t\t\t\t// ancestor set, and that set outlives this call when a direct caller\n\t\t\t\t// brought it.\n\t\t\t\tfor (let index = 0; index < admitted.length; index += 1) {\n\t\t\t\t\tconst entered = admitted[index]\n\t\t\t\t\tif (entered !== undefined) omitVisited(ancestors, entered)\n\t\t\t\t}\n\t\t\t}\n\t\t}, 'canonicalizeValue')\n\t}, 'canonicalizeValue')\n}\n\n/**\n * Encode 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 canonicalizeValue}: `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 * Render 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 *   {@link inferArray} / {@link inferObject} 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(() => canonicalizeValue(value, new INTRINSICS.weakSet()), 'canonicalStringify')\n\t}, 'canonicalStringify')\n}\n\n/**\n * Unify 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 just `{ 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 * Determine whether a supported ISO-8601 date or date-time is valid.\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` when `value` parses to a real instant\n *\n * @example\n * ```ts\n * isValidISOInstant('2024-02-29')          // true\n * isValidISOInstant('2024-01-01T24:00Z')   // false — incomplete normalized clock\n * ```\n */\nexport function isValidISOInstant(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.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.apply(INTRINSICS.instant, date, []))\n\t})\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Classify 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 isValidISOInstant} 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 * Classify 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\tisValidISOInstant(value)\n\t) {\n\t\treturn 'date-time'\n\t}\n\tif (matchesPattern(/^\\d{4}-\\d{2}-\\d{2}$/, value) && isValidISOInstant(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\tisValidISOInstant(`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/**\n * Classify 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 ({@link samplesToSchema} / {@link inferRecordSamples})\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 * Infer 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 via {@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 * Infer a `JSONSchema` fragment for one runtime value — the recursive spine\n * shared by {@link valueToSchema} and, per collected property/element, by\n * {@link inferArray} / {@link inferObject}.\n *\n * @remarks\n * Terminates on cyclic readable input via `visited`; failed traversal is\n * refused by the containing public reader. Leaf\n * classification order: `null`, boolean, integer (`Number.isInteger`\n * semantics — `-0` counts), finite non-integer number, string (gaining a\n * `format` keyword when `format` is on and {@link stringToFormat} matches),\n * array (recurse), plain record (recurse), `Date` (`{ type: 'string' }`,\n * plus `format: 'date-time'` when `format` is on); everything else — a\n * NON-FINITE number (`NaN` / `±Infinity`), a function, a symbol, a bigint,\n * `undefined`, and other non-plain objects such as `Map` / `Set` — is the\n * empty accept-anything schema `{}`.\n *\n * A non-finite number bottoms out with the other JSON-inexpressible values on\n * purpose: JSON carries no `NaN` / `±Infinity` (`JSON.stringify(Number.NaN)`\n * is `'null'`), so `{ type: 'number' }` would ASSERT something a JSON Schema\n * validator rejects — and the shape {@link schemaToShape} builds from it would\n * reject the very sample it was inferred from. `{}` is the truthful\n * description, and it inverts to an accept-anything shape, keeping\n * `compileGuard(schemaToShape(valueToSchema(v)))(v)` true.\n *\n * @param value - The value to classify\n * @param depth - Remaining descent budget (0 halts recursion with `{}`)\n * @param breadth - The per-container sampling cap passed through to children\n * @param closed - Whether descended objects emit `additionalProperties: false`\n * @param format - Whether a string/`Date` leaf gains a `format` keyword\n * @param visited - The ancestor set guarding against cycles\n * @param memo - A per-call `(object, remaining depth) → schema` cache guarding\n *               against exponential re-inference of a shared-reference DAG\n * @returns The inferred schema fragment for `value`\n * @throws {ContractError} When a traversed container cannot be read\n *\n * @example\n * ```ts\n * inferValue(42, 32, 256, true, false, new WeakSet(), new WeakMap()) // { type: 'integer' }\n * ```\n */\nexport function inferValue(\n\tvalue: unknown,\n\tdepth: number,\n\tbreadth: number,\n\tclosed: boolean,\n\tformat: boolean,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, JSONSchema>>,\n): JSONSchema {\n\treturn contain(() => {\n\t\treturn readValue(() => {\n\t\t\tif (isNull(value)) return { type: 'null' }\n\t\t\tif (isBoolean(value)) return { type: 'boolean' }\n\t\t\tif (isInteger(value)) return { type: 'integer' }\n\t\t\tif (isFiniteNumber(value)) return { type: 'number' }\n\t\t\t// A non-finite number has no JSON representation at all, so it widens to\n\t\t\t// `{}` with the other inexpressible values rather than claiming a `number`\n\t\t\t// type no validator would accept it under.\n\t\t\tif (isNumber(value)) return {}\n\t\t\tif (isString(value)) {\n\t\t\t\tif (format) {\n\t\t\t\t\tconst detected = stringToFormat(value)\n\t\t\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t\t\t}\n\t\t\t\treturn { type: 'string' }\n\t\t\t}\n\t\t\tif (isArray(value)) return inferArray(value, depth, breadth, closed, format, visited, memo)\n\t\t\tif (isRecord(value)) return inferObject(value, depth, breadth, closed, format, visited, memo)\n\t\t\tif (isDate(value))\n\t\t\t\treturn format ? { type: 'string', format: 'date-time' } : { type: 'string' }\n\t\t\treturn {}\n\t\t}, 'inferValue')\n\t}, 'inferValue')\n}\n\n/**\n * Infer a `JSONSchema` array fragment from an array's sampled elements.\n *\n * @remarks\n * An empty array infers `{ type: 'array' }` with no `items`. Otherwise the\n * first `breadth` elements are classified via {@link inferValue} (one less\n * depth) and unified with {@link unifySchemas}: a single distinct element\n * schema becomes `items` directly; multiple distinct schemas become\n * `items: { anyOf: [...] }`. Depth exhaustion or a cyclic re-encounter of\n * `value` both yield the empty schema `{}` instead of descending. A SPARSE\n * array (holes, e.g. `[1, , 3]`) has no JSON expression and widens to the\n * accept-anything `{}`, the same treatment `NaN`, a function, a symbol, a\n * `Map` and a `Set` receive — it is not read as a list of present `undefined`\n * leaves, because the array schema that reading produced was rejected by its\n * own compiled guard, which is the one direction the round-trip law forbids.\n * Invalid direct depth and breadth budgets use {@link sanitizeBudget} with the\n * package defaults, matching the higher-level inference boundaries.\n *\n * ALL reads of `value` — including its `length` — happen inside\n * {@link attempt}, then cross {@link readValue}: a hostile `length` getter,\n * throwing own-getter element, or hostile element access raises the shared\n * coded refusal instead of returning the empty-array schema. A genuinely\n * empty sampled/classified list still returns `{ type: 'array' }` with no\n * `items`. A same-object re-inference at the same remaining `depth` is served\n * from `memo` instead of recomputing (guards a shared-reference DAG against\n * exponential blowup).\n *\n * @param value - The array to infer from\n * @param depth - Remaining descent budget; invalid values use the package default\n * @param breadth - Maximum elements sampled; invalid values use the package default\n * @param closed - Threaded through to nested object elements\n * @param format - Threaded through to nested string/`Date` elements\n * @param visited - The ancestor set guarding against cycles\n * @param memo - A per-call `(object, remaining depth) → schema` cache guarding\n *               against exponential re-inference of a shared-reference DAG\n * @returns The inferred array schema\n * @throws {ContractError} When the array cannot be read\n *\n * @example\n * ```ts\n * inferArray([1, 2.5], 32, 256, true, false, new WeakSet(), new WeakMap())\n * // { type: 'array', items: { type: 'number' } }\n * ```\n */\nexport function inferArray(\n\tvalue: readonly unknown[],\n\tdepth: number,\n\tbreadth: number,\n\tclosed: boolean,\n\tformat: boolean,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, JSONSchema>>,\n): JSONSchema {\n\treturn contain(() => {\n\t\tconst maxDepth = sanitizeDepth(depth)\n\t\tconst maxBreadth = sanitizeBudget(breadth, INFER_BREADTH_LIMIT)\n\t\treturn readValue(() => {\n\t\t\tif (!(maxDepth > 0) || matchesVisited(visited, value)) return {}\n\t\t\t// At a node reached through a cycle at the SAME remaining depth via two\n\t\t\t// different paths, the memo may serve the first traversal's already\n\t\t\t// cycle-truncated fragment (`{}`) to the second path instead of a fully\n\t\t\t// re-descended schema — a sound, deterministic over-approximation, never\n\t\t\t// a false-reject (a schema too permissive, never too strict).\n\t\t\tconst cached = INTRINSICS.apply(INTRINSICS.recall, memo, [value])?.get(maxDepth)\n\t\t\tif (cached) return cached\n\t\t\tadmitVisited(visited, value)\n\t\t\tconst outcome = attempt(() => {\n\t\t\t\tconst snapshot = readArrayEntries(value)\n\t\t\t\tif (!snapshot.success) throw snapshot.error\n\t\t\t\t// A HOLE is an absent own property, and that is the lens every other\n\t\t\t\t// door in this package applies: `arrayOf`, `parseArray`, `isJSONValue`,\n\t\t\t\t// `cloneJSONValue`, `canonicalStringify` and the compiled array guard\n\t\t\t\t// all refuse a sparse array. Reading a hole as a PRESENT `undefined`\n\t\t\t\t// leaf made this door the one dissenter, and the disagreement was not\n\t\t\t\t// cosmetic: `valueToSchema([1, , 3])` emitted an array schema whose\n\t\t\t\t// guard REJECTED `[1, , 3]`, so the package published a schema that\n\t\t\t\t// refused the value it was inferred from. A non-dense snapshot has no\n\t\t\t\t// JSON expression, so it widens to `{}` alongside `NaN`, a function, a\n\t\t\t\t// symbol, a `Map` and a `Set` — which restores the round-trip law\n\t\t\t\t// rather than adding a fourth exception to it.\n\t\t\t\tif (!snapshot.value.dense) return undefined\n\t\t\t\tconst entries = snapshot.value.entries\n\t\t\t\tconst sampled: JSONSchema[] = []\n\t\t\t\tconst length = INTRINSICS.min(entries.length, maxBreadth)\n\t\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\t\tsampled[sampled.length] = inferValue(\n\t\t\t\t\t\tentries[index],\n\t\t\t\t\t\tmaxDepth - 1,\n\t\t\t\t\t\tmaxBreadth,\n\t\t\t\t\t\tclosed,\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tvisited,\n\t\t\t\t\t\tmemo,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn sampled\n\t\t\t})\n\t\t\tomitVisited(visited, value)\n\t\t\tconst sampled = readValue(() => {\n\t\t\t\tif (!outcome.success) throw outcome.error\n\t\t\t\treturn outcome.value\n\t\t\t}, 'inferArray')\n\t\t\tconst schema: JSONSchema =\n\t\t\t\tsampled === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: sampled.length > 0\n\t\t\t\t\t\t? { type: 'array', items: unifySchemas(sampled) }\n\t\t\t\t\t\t: { type: 'array' }\n\t\t\tretainDepth(memo, value, maxDepth, schema)\n\t\t\treturn schema\n\t\t}, 'inferArray')\n\t}, 'inferArray')\n}\n\n/**\n * Infer a `JSONSchema` object fragment from a plain record's sampled\n * properties.\n *\n * @remarks\n * Own enumerable string keys via {@link enumerableKeys}, sorted\n * lexicographically for deterministic output, capped at `breadth`. This is the\n * same property view compiled object guards, parsers, and reporters use. Each\n * property value is read through {@link attempt} and {@link readValue}; a\n * hostile getter raises the shared coded refusal. A readable property whose\n * value is `undefined` is DROPPED\n * — JSON encodes no such property (`JSON.stringify({ a: undefined })` is\n * `'{}'`), so it contributes neither a `properties` entry nor a `required`\n * entry. Every other present key is required (single-value mode).\n *\n * Emits `additionalProperties: false` when `closed`, `true` otherwise —\n * mirroring {@link compileSchema}'s object-emission convention — EXCEPT when\n * the sampled key list no longer describes every key `value` actually carries,\n * which happens two ways: the own-key list exceeds `breadth` (truncation), or\n * a key was dropped for holding `undefined`. Either way `additionalProperties`\n * is forced to `true` regardless of `closed`, because a CLOSED schema built\n * from an incomplete key list would reject the very object it was inferred\n * from (`recordOf` rejects any own key the shape does not declare).\n *\n * Depth exhaustion or a cyclic re-encounter of `value` both yield `{}`. A\n * same-object re-inference at the same remaining `depth` is served from `memo`\n * instead of recomputing (guards a shared-reference DAG against exponential\n * blowup).\n *\n * @param value - The record to infer from\n * @param depth - Remaining descent budget\n * @param breadth - The maximum number of properties sampled\n * @param closed - Whether the emitted schema closes to unknown keys\n * @param format - Threaded through to nested string/`Date` properties\n * @param visited - The ancestor set guarding against cycles\n * @param memo - A per-call `(object, remaining depth) → schema` cache guarding\n *               against exponential re-inference of a shared-reference DAG\n * @returns The inferred object schema\n * @throws {ContractError} When the record cannot be read\n *\n * @example\n * ```ts\n * inferObject({ id: 1 }, 32, 256, true, false, new WeakSet(), new WeakMap())\n * // { type: 'object', properties: { id: { type: 'integer' } }, required: ['id'],\n * //   additionalProperties: false }\n * ```\n */\nexport function inferObject(\n\tvalue: Record<string, unknown>,\n\tdepth: number,\n\tbreadth: number,\n\tclosed: boolean,\n\tformat: boolean,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, JSONSchema>>,\n): JSONSchema {\n\treturn contain(() => {\n\t\t// The BREADTH budget passes through `sanitizeBudget`, as `inferArray`'s\n\t\t// already did. Without it `limitEntries(keys, NaN)` returned the EMPTY key\n\t\t// list while `allKeys.length > NaN` left `truncated` false, so a public\n\t\t// export emitted `{ type: 'object', additionalProperties: false }` — a\n\t\t// CLOSED schema that rejects the very record it was inferred from, the one\n\t\t// direction the schema-inversion law forbids. The DEPTH budget is left\n\t\t// exactly as it was in one respect — `!(maxDepth > 0)` still fails safe by\n\t\t// widening to `{}` — but it now passes through `sanitizeDepth` as well, so a\n\t\t// direct caller cannot hand this door a budget deeper than the walk survives.\n\t\t// `inferArray` already sanitized its depth and this one did not, so the two\n\t\t// containers answered a hostile budget differently at the same level.\n\t\tconst maxBreadth = sanitizeBudget(breadth, INFER_BREADTH_LIMIT)\n\t\tconst maxDepth = sanitizeDepth(depth)\n\t\treturn readValue(() => {\n\t\t\tif (!(maxDepth > 0) || matchesVisited(visited, value)) return {}\n\t\t\tconst cached = INTRINSICS.apply(INTRINSICS.recall, memo, [value])?.get(maxDepth)\n\t\t\tif (cached) return cached\n\t\t\tadmitVisited(visited, value)\n\t\t\t// Contain the whole key-enumeration + value-read walk before converting a\n\t\t\t// failed advertised read to the shared coded refusal below. Readable depth\n\t\t\t// or cycle exhaustion widens to `{}`; unreadability never does.\n\t\t\tconst outcome = attempt(() => {\n\t\t\t\tconst snapshot = enumerableKeys(value)\n\t\t\t\tif (snapshot === undefined)\n\t\t\t\t\tthrow new INTRINSICS.error('inferObject: property enumeration failed')\n\t\t\t\tconst allKeys = sortValues(snapshot)\n\t\t\t\tconst keys = limitEntries(allKeys, maxBreadth)\n\t\t\t\tconst truncated = allKeys.length > maxBreadth\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 compileGuard / compileParser use\n\t\t\t\t// (compilers.ts).\n\t\t\t\tconst properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst required: string[] = []\n\t\t\t\tlet dropped = false\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 propertyValue = value[key]\n\t\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\t\tdropped = true\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tproperties[key] = inferValue(\n\t\t\t\t\t\tpropertyValue,\n\t\t\t\t\t\tmaxDepth - 1,\n\t\t\t\t\t\tmaxBreadth,\n\t\t\t\t\t\tclosed,\n\t\t\t\t\t\tformat,\n\t\t\t\t\t\tvisited,\n\t\t\t\t\t\tmemo,\n\t\t\t\t\t)\n\t\t\t\t\trequired[required.length] = key\n\t\t\t\t}\n\t\t\t\treturn { properties, required, partial: truncated || dropped }\n\t\t\t})\n\t\t\tomitVisited(visited, value)\n\t\t\tconst readable = readValue(() => {\n\t\t\t\tif (!outcome.success) throw outcome.error\n\t\t\t\treturn outcome.value\n\t\t\t}, 'inferObject')\n\t\t\tconst { properties, required, partial } = readable\n\t\t\tconst schema: JSONSchema = {\n\t\t\t\ttype: 'object',\n\t\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\t\tadditionalProperties: partial ? true : !closed,\n\t\t\t}\n\t\t\tretainDepth(memo, value, maxDepth, schema)\n\t\t\treturn schema\n\t\t}, 'inferObject')\n\t}, 'inferObject')\n}\n\n/**\n * Infer a `JSONSchema` for one unknown value — the reverse direction of\n * {@link compileSchema}.\n *\n * @remarks\n * Cycle/depth/breadth-bounded (see {@link inferValue} / {@link inferArray} /\n * {@link inferObject}). A failed traversal 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 — e.g. `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 * `maxProperties` is sanitized via {@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 * `maxDepth` 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, and a large-but-valid budget used to descend until the call STACK failed\n * rather than until the guard said stop.\n *\n * @param value - The value to infer a schema from\n * @param options - Optional `maxDepth` / `maxProperties` / `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['maxDepth', 'maxProperties', 'closed', 'format', 'enum'],\n\t\t\t'valueToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst maxDepth = sanitizeDepth(optionsSnapshot?.maxDepth)\n\t\tconst maxProperties = sanitizeBudget(optionsSnapshot?.maxProperties, INFER_BREADTH_LIMIT)\n\t\tconst closed = optionsSnapshot?.closed ?? true\n\t\tconst format = optionsSnapshot?.format ?? false\n\t\treturn readValue(\n\t\t\t() =>\n\t\t\t\tinferValue(\n\t\t\t\t\tvalue,\n\t\t\t\t\tmaxDepth,\n\t\t\t\t\tmaxProperties,\n\t\t\t\t\tclosed,\n\t\t\t\t\tformat,\n\t\t\t\t\tnew INTRINSICS.weakSet(),\n\t\t\t\t\tnew INTRINSICS.weakMap(),\n\t\t\t\t),\n\t\t\t'valueToSchema',\n\t\t)\n\t}, 'valueToSchema')\n}\n\n// === Multi-sample inference\n\n/**\n * Infer a `JSONSchema` for a collected slot of sample values — the shared\n * non-record recursion step behind {@link samplesToSchema} (top level) and\n * {@link inferRecordSamples} (per collected property).\n *\n * @remarks\n * When every value is itself a plain record, delegates to\n * {@link inferRecordSamples}. Otherwise: enum inference runs FIRST when\n * `enumOn` — {@link inferPrimitiveEnum} fires only for a low-cardinality,\n * repeated, single-primitive-kind slot, and its `{ enum: [...] }` result wins\n * outright (ENUM > FORMAT > bare string). Failing that, each value is\n * classified independently via {@link inferValue} with `format` FORCED OFF\n * (the multi-sample seam: nested formats never compound into an `anyOf`) and\n * unified with {@link unifySchemas}; only when that unified result is exactly\n * `{ type: 'string' }` and the outer `format` flag is on does\n * {@link samplesToFormat} run to (maybe) reattach a unanimous `format`.\n *\n * @param samples - The collected slot values\n * @param depth - Remaining descent budget\n * @param breadth - The maximum number of properties/elements sampled per nested container\n * @param closed - Whether nested objects close to unknown keys\n * @param format - Whether a unanimous string slot gains a `format` keyword\n * @param enumOn - Whether low-cardinality primitive slots may emit `enum`\n * @param memo - The walk's {@link SampleMemo}, shared with\n *               {@link inferRecordSamples} so a row list reached through\n *               several slots is inferred once; build one with\n *               {@link buildSampleMemo}\n * @returns The inferred schema for the slot\n * @throws {ContractError} When the samples or the memo cannot be read\n *\n * @example\n * ```ts\n * inferSamples(['2024-01-01', '2024-02-02'], 32, 256, true, true, false, buildSampleMemo())\n * // { type: 'string', format: 'date' }\n * ```\n */\nexport function inferSamples(\n\tsamples: readonly unknown[],\n\tdepth: number,\n\tbreadth: number,\n\tclosed: boolean,\n\tformat: boolean,\n\tenumOn: boolean,\n\tmemo: SampleMemo,\n): JSONSchema {\n\treturn contain(() => {\n\t\tconst maxBreadth = sanitizeBudget(breadth, INFER_BREADTH_LIMIT)\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'inferSamples',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t\t// A HOLE is not an unreadable value, and saying so was a true refusal with a\n\t\t// false diagnosis: every read succeeded. This door requires a dense sample\n\t\t// list — the same own-index lens `arrayOf` and `parseArray` apply — and now\n\t\t// says that instead.\n\t\tif (!read.dense) {\n\t\t\tthrow new ContractError('inferSamples: samples must be a dense array', {\n\t\t\t\tcode: 'structure',\n\t\t\t})\n\t\t}\n\t\t// The memo is the one argument position whose failure used to be published\n\t\t// as `samples could not be read` — a true refusal naming the wrong\n\t\t// argument, and the only position these doors never checked. It is checked\n\t\t// here, under its own name and its own path, AFTER the sample list it\n\t\t// follows in the signature.\n\t\tconst cache = readSampleMemo(memo, 'inferSamples')\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst owned = read.entries\n\t\t\t\tif (owned.length === 0) return {}\n\t\t\t\t// Indexed rather than `every`, and the narrowed rows are collected as they\n\t\t\t\t// are recognized so the record branch keeps its honest typing without an\n\t\t\t\t// assertion.\n\t\t\t\tconst records: Array<Record<string, unknown>> = []\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tconst sample = owned[index]\n\t\t\t\t\tif (isRecord(sample)) records[records.length] = sample\n\t\t\t\t}\n\t\t\t\tif (records.length === owned.length) {\n\t\t\t\t\treturn inferRecordSamples(records, depth, maxBreadth, closed, format, enumOn, cache)\n\t\t\t\t}\n\t\t\t\tif (enumOn) {\n\t\t\t\t\tconst enumSchema = inferPrimitiveEnum(owned, INFER_ENUM_LIMIT)\n\t\t\t\t\tif (enumSchema) return enumSchema\n\t\t\t\t}\n\t\t\t\tconst schemas: JSONSchema[] = []\n\t\t\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\t\t\tschemas[schemas.length] = inferValue(\n\t\t\t\t\t\towned[index],\n\t\t\t\t\t\tdepth,\n\t\t\t\t\t\tmaxBreadth,\n\t\t\t\t\t\tclosed,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tnew INTRINSICS.weakSet(),\n\t\t\t\t\t\tnew INTRINSICS.weakMap(),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tconst unified = unifySchemas(schemas)\n\t\t\t\tif (format && unified.type === 'string' && INTRINSICS.keys(unified).length === 1) {\n\t\t\t\t\tconst detected = samplesToFormat(owned)\n\t\t\t\t\tif (detected) return { type: 'string', format: detected }\n\t\t\t\t}\n\t\t\t\treturn unified\n\t\t\t},\n\t\t\t'inferSamples',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t}, 'inferSamples')\n}\n\n/**\n * Infer a `JSONSchema` object fragment from a set of plain-record samples\n * (e.g. database rows) — the record-specialized branch of\n * {@link samplesToSchema}.\n *\n * @remarks\n * `properties` is the union of every sample's own keys (sorted, capped at\n * `breadth`); a key is `required` only when present (and non-`undefined`) in\n * EVERY sample. Each key's schema is inferred over the collected values for\n * that key via {@link inferSamples} itself (one less depth), so a\n * property that is itself an array/object of varying shape across rows is\n * unified the same way the top level is, and the same `format` / `enum`\n * gating applies per key. Unlike {@link inferObject}/\n * {@link inferArray}, this path carries no `visited` `WeakSet` — a value\n * shared by reference across multiple sample rows is legitimate (not a\n * cycle back to an ancestor), so termination on cyclic row data relies on\n * the decrementing `depth` budget and the shared {@link SampleMemo}.\n *\n * `additionalProperties` is forced to `true` regardless of `closed` when the\n * key union exceeds `breadth`, or a readable row carries a key as an own\n * property holding `undefined`. A hostile getter or failed KEY walk throws the\n * shared coded refusal instead of dropping a key or widening the whole slot.\n *\n * The memo is keyed by the slot's ORDERED row identities, not by a single row.\n * Keying only the one-row slot left every MULTI-row slot — the shape this door\n * exists for — re-inferring a shared child once per path: two rows sharing one\n * `{ a: child, b: child }` detail cost `2^depth` inferences, the identical\n * denial of service the one-row memo was added to remove, through the same\n * public door.\n *\n * @param samples - The plain-record samples\n * @param depth - Remaining descent budget\n * @param breadth - The maximum number of properties sampled\n * @param closed - Whether the emitted schema closes to unknown keys\n * @param format - Whether a unanimous string column gains a `format` keyword\n * @param enumOn - Whether a low-cardinality column may emit `enum`\n * @param memo - The walk's {@link SampleMemo}, shared with\n *               {@link inferSamples}; build one with {@link buildSampleMemo}\n * @returns The inferred object schema\n * @throws {ContractError} When a sample row or the memo cannot be read\n *\n * @example\n * ```ts\n * inferRecordSamples([{ id: 1 }, { id: 2, name: 'Ada' }], 32, 256, true, false, false, buildSampleMemo())\n * // { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } },\n * //   required: ['id'], additionalProperties: false }\n * ```\n */\nexport function inferRecordSamples(\n\tsamples: ReadonlyArray<Record<string, unknown>>,\n\tdepth: number,\n\tbreadth: number,\n\tclosed: boolean,\n\tformat: boolean,\n\tenumOn: boolean,\n\tmemo: SampleMemo,\n): JSONSchema {\n\treturn contain(() => {\n\t\t// Breadth hygiene, for the reason `inferObject` states: `limitEntries(keys,\n\t\t// NaN)` returned the EMPTY key list while `allKeys.length > NaN` left\n\t\t// `truncated` false, so this door emitted a CLOSED empty object schema that\n\t\t// rejects the very row it was inferred from. The depth budget keeps its\n\t\t// established meaning, including the no-read exhaustion check below.\n\t\tconst maxBreadth = sanitizeBudget(breadth, INFER_BREADTH_LIMIT)\n\t\tif (!(depth > 0)) return {}\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'inferRecordSamples',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t\tif (!read.dense) {\n\t\t\tthrow new ContractError('inferRecordSamples: samples must be a dense array', {\n\t\t\t\tcode: 'structure',\n\t\t\t})\n\t\t}\n\t\tconst cache = readSampleMemo(memo, 'inferRecordSamples')\n\t\tconst owned = read.entries\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 = cache\n\t\tfor (let index = 0; index < owned.length; index += 1) {\n\t\t\tconst row = owned[index]\n\t\t\tif (!isRecord(row)) break\n\t\t\tconst next = INTRINSICS.apply(INTRINSICS.recall, node.rows, [row])\n\t\t\tif (next !== undefined) {\n\t\t\t\tnode = readSampleMemo(next, 'inferRecordSamples')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst fresh = buildSampleMemo()\n\t\t\tINTRINSICS.apply(INTRINSICS.retain, node.rows, [row, fresh])\n\t\t\tnode = fresh\n\t\t}\n\t\tconst signature = `${depth}|${maxBreadth}|${closed}|${format}|${enumOn}`\n\t\tconst cached = INTRINSICS.apply(INTRINSICS.fetch, node.schemas, [signature])\n\t\tif (cached !== undefined) return cached\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\t// Refuse the whole key-enumeration claim when any row cannot be read.\n\t\t\t\tconst seen = collectMembers([])\n\t\t\t\tconst collected: string[] = []\n\t\t\t\tfor (let sampleIndex = 0; sampleIndex < owned.length; sampleIndex += 1) {\n\t\t\t\t\tconst sample = owned[sampleIndex]\n\t\t\t\t\tif (!isRecord(sample))\n\t\t\t\t\t\tthrow new INTRINSICS.error('inferRecordSamples: every sample must be a record')\n\t\t\t\t\tconst sampleKeys = readValue(() => {\n\t\t\t\t\t\tconst keys = enumerableKeys(sample)\n\t\t\t\t\t\tif (keys === undefined) {\n\t\t\t\t\t\t\tthrow new INTRINSICS.error('inferRecordSamples: property enumeration failed')\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn keys\n\t\t\t\t\t}, 'inferRecordSamples')\n\t\t\t\t\tfor (let keyIndex = 0; keyIndex < sampleKeys.length; keyIndex += 1) {\n\t\t\t\t\t\tconst key = sampleKeys[keyIndex]\n\t\t\t\t\t\tif (key === undefined || matchesMember(seen, key)) continue\n\t\t\t\t\t\tadmitMember(seen, key)\n\t\t\t\t\t\tcollected[collected.length] = key\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst allKeys = sortValues(collected)\n\t\t\t\tconst keys = limitEntries(allKeys, maxBreadth)\n\t\t\t\tconst truncated = allKeys.length > maxBreadth\n\t\t\t\t// Honest typing: a null-prototype accumulator so a key literally named\n\t\t\t\t// '__proto__' becomes an own data key instead of mutating the prototype —\n\t\t\t\t// the same pattern compileGuard / compileParser use (compilers.ts).\n\t\t\t\tconst properties: Record<string, JSONSchema> = INTRINSICS.create(null)\n\t\t\t\tconst required: string[] = []\n\t\t\t\tlet partial = truncated\n\t\t\t\t// Bounded by depth alone: unlike inferObject/inferArray, this record-\n\t\t\t\t// sample path carries no `visited` WeakSet. A shared reference across\n\t\t\t\t// sample rows is legitimate data (not a cycle back to an ancestor), so\n\t\t\t\t// the decrementing depth budget is the sole termination guarantee here.\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\t// Refuse the whole per-key claim when any sample value cannot be read.\n\t\t\t\t\tconst valuesOutcome = attempt(() => {\n\t\t\t\t\t\tconst values: unknown[] = []\n\t\t\t\t\t\tlet dropped = false\n\t\t\t\t\t\tfor (let sampleIndex = 0; sampleIndex < owned.length; sampleIndex += 1) {\n\t\t\t\t\t\t\tconst sample = owned[sampleIndex]\n\t\t\t\t\t\t\tif (!isRecord(sample)) {\n\t\t\t\t\t\t\t\tthrow new INTRINSICS.error('inferRecordSamples: every sample must be a record')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst propertyValue = sample[key]\n\t\t\t\t\t\t\tif (propertyValue === undefined) {\n\t\t\t\t\t\t\t\tif (INTRINSICS.own(sample, key)) dropped = true\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalues[values.length] = propertyValue\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { values, dropped }\n\t\t\t\t\t})\n\t\t\t\t\tconst readable = readValue(() => {\n\t\t\t\t\t\tif (!valuesOutcome.success) throw valuesOutcome.error\n\t\t\t\t\t\treturn valuesOutcome.value\n\t\t\t\t\t}, 'inferRecordSamples')\n\t\t\t\t\tconst { values, dropped } = readable\n\t\t\t\t\t// A row holding `undefined` for this key OPENS the schema; it does not\n\t\t\t\t\t// delete the column. Skipping the key entirely discarded a property two\n\t\t\t\t\t// of three rows carried as a real integer, and neither the TSDoc nor the\n\t\t\t\t\t// guide ever promised more than the opening.\n\t\t\t\t\tif (dropped) partial = true\n\t\t\t\t\tif (values.length > 0) {\n\t\t\t\t\t\tproperties[key] = inferSamples(\n\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\tdepth - 1,\n\t\t\t\t\t\t\tmaxBreadth,\n\t\t\t\t\t\t\tclosed,\n\t\t\t\t\t\t\tformat,\n\t\t\t\t\t\t\tenumOn,\n\t\t\t\t\t\t\tcache,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (!dropped && values.length === owned.length) required[required.length] = key\n\t\t\t\t}\n\t\t\t\tconst schema: JSONSchema = {\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\t...(INTRINSICS.keys(properties).length > 0 ? { properties } : {}),\n\t\t\t\t\t...(required.length > 0 ? { required } : {}),\n\t\t\t\t\tadditionalProperties: partial ? true : !closed,\n\t\t\t\t}\n\t\t\t\tINTRINSICS.apply(INTRINSICS.store, node.schemas, [signature, schema])\n\t\t\t\treturn schema\n\t\t\t},\n\t\t\t'inferRecordSamples',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t}, 'inferRecordSamples')\n}\n\n/**\n * Infer a `JSONSchema` from a set of example values — the multi-example\n * counterpart of {@link valueToSchema} (e.g. 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 (see {@link inferRecordSamples}) — a key\n * required iff present and non-`undefined` in every sample. Otherwise the\n * slot is inferred via {@link inferSamples} (independent {@link valueToSchema}\n * per sample, unified with {@link unifySchemas} — the same de-duplication and\n * `anyOf` ordering {@link inferArray} applies to element schemas). `format`\n * and `enum` (both default `false`) opt a low-cardinality/unanimous-format\n * slot into the corresponding keyword — see {@link inferSamples} for the\n * precedence and the multi-sample format-disabling seam. `maxDepth` /\n * `maxProperties` 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 `maxDepth` / `maxProperties` / `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['maxDepth', 'maxProperties', 'closed', 'format', 'enum'],\n\t\t\t'samplesToSchema',\n\t\t\t'schema',\n\t\t)\n\t\tconst maxDepth = sanitizeDepth(optionsSnapshot?.maxDepth)\n\t\tconst maxProperties = sanitizeBudget(optionsSnapshot?.maxProperties, 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() =>\n\t\t\t\tinferSamples(\n\t\t\t\t\tread.entries,\n\t\t\t\t\tmaxDepth,\n\t\t\t\t\tmaxProperties,\n\t\t\t\t\tclosed,\n\t\t\t\t\tformat,\n\t\t\t\t\tenumOn,\n\t\t\t\t\tbuildSampleMemo(),\n\t\t\t\t),\n\t\t\t'samplesToSchema',\n\t\t\t{ subject: 'samples' },\n\t\t)\n\t}, 'samplesToSchema')\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 { ShapeValidator } from './ShapeValidator.js'\nimport { INFER_BREADTH_LIMIT, INFER_DEPTH_LIMIT, INTRINSICS } from './constants.js'\nimport { ContractError } from './errors.js'\nimport {\n\tadmitMember,\n\tadmitVisited,\n\tattempt,\n\tcollectMembers,\n\tcontain,\n\tlimitEntries,\n\tmatchesMember,\n\tmatchesRecordBrand,\n\tmatchesVisited,\n\tomitVisited,\n\tpreview,\n\treadArrayEntries,\n\treadOptions,\n\treadPatternFlags,\n\treadPatternSource,\n\treadValue,\n\tretainDepth,\n} from './helpers.js'\nimport {\n\tisArray,\n\tisFiniteNumber,\n\tisInteger,\n\tisLiteralValue,\n\tisObject,\n\tisRecord,\n\tisRegExp,\n\tisString,\n} from './validators.js'\n\n// The builders return the parameterized types.ts interfaces (e.g. `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 (e.g. literal tuples, generic\n// `items` / `properties`) are preserved so `Infer<typeof shape>` stays exact.\n\n// === Primitives\n\n/**\n * Build 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\ttype: '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 * Build a numeric {@link NumberShape}.\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\ttype: '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 * Build 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 * Build 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\ttype: '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 * Build 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\ttype: '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 * Build 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('validateShapeDepth: 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'validateShapeDepth: 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\ttype: '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 * Build 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\ttype: '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 * Build 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.declare(snapshot, key, {\n\t\t\t\t\t\tvalue: INTRINSICS.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\ttype: '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 * Build 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\ttype: '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 * Build 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> = { type: 'union', variants }\n\t\tnew ShapeValidator(shape).validate()\n\t\treturn INTRINSICS.freeze({ type: 'union', variants: INTRINSICS.freeze(variants) })\n\t}, 'unionShape')\n}\n\n/**\n * Build 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 (e.g. 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\ttype: '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 * Wrap 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> = { type: 'optional', inner }\n\t\tnew ShapeValidator({ type: 'object', properties: { value: shape } }).validate()\n\t\treturn INTRINSICS.freeze(shape)\n\t}, 'optionalShape')\n}\n\n/**\n * Wrap 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> = { type: '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 * Build 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 (via {@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 * @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\ttype: '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 * Build 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({ type: 'raw', schema }).validate()\n\t\tconst owned = cloneSchema(schema)\n\t\tnew ShapeValidator({ type: 'raw', schema: owned }).validate()\n\t\treturn INTRINSICS.freeze({ type: '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, per AGENTS §14.\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 `validateShapeDepth` 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 `schemaNodeToShape` wraps its whole body in\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 * Derive `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(\n\tmin: unknown,\n\tmax: unknown,\n): { readonly min?: number; readonly max?: number } {\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 * Derive `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(\n\tmin: unknown,\n\tmax: unknown,\n): { readonly min?: number; readonly max?: number } {\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/**\n * Build an {@link ObjectShape} from a JSON Schema object node's `properties` /\n * `required` / `additionalProperties` keywords — the object-specialized branch\n * of {@link buildShapeFromNode}.\n *\n * @remarks\n * `properties` (when a record) contributes one child shape per own key, capped\n * at {@link INFER_BREADTH_LIMIT}; a key is wrapped in {@link optionalShape}\n * unless it appears as a string entry of `required`. A property whose value is\n * not itself a record widens to {@link rawShape}. `additionalProperties`:\n * `false` closes the object; a record value recurses into it (`objectShape`\n * validates extras against that shape); anything else — `true`, absent, or\n * malformed — leaves the object OPEN (`true`), matching JSON Schema's own\n * absent-means-open default and the fact that {@link valueToSchema} /\n * {@link samplesToSchema} always emit the keyword explicitly, so an absent\n * value only arises from a hand-written schema. When `properties` has MORE\n * keys than {@link INFER_BREADTH_LIMIT}, the schema's own\n * `additionalProperties` is OVERRIDDEN and forced to `true` (fully open) —\n * a dropped key's value could otherwise fail a `false` or record-valued rest\n * shape it was never checked against — mirroring {@link inferObject}'s\n * partial-key handling in `inferers.ts`. The accumulator uses a\n * null-prototype record so a property literally named `__proto__` becomes an\n * own data key rather than mutating the prototype, mirroring\n * {@link inferObject} (inferers.ts).\n *\n * @param schema - The object schema node\n * @param depth - Remaining descent budget passed to child properties\n * @param visited - The ancestor set guarding against cycles — recursion\n *   state owned by the {@link schemaToShape} entry point; passing a shared or\n *   pre-populated `WeakSet` changes cycle-detection behavior and is not\n *   supported usage\n * @param memo - A per-call `(schema node, remaining depth) → shape` cache —\n *   recursion state owned by the {@link schemaToShape} entry point; passing\n *   a shared or pre-populated `WeakMap` changes caching behavior and is not\n *   supported usage\n * @param description - The node's already-extracted `description`, if any\n * @returns The built object shape\n *\n * @example\n * ```ts\n * buildObjectShape(\n * \t{ type: 'object', properties: { id: { type: 'integer' } }, required: ['id'] },\n * \tINFER_DEPTH_LIMIT,\n * \tnew WeakSet(),\n * \tnew WeakMap(),\n * \tundefined,\n * )\n * // objectShape({ id: integerShape() }, { additionalProperties: true })\n * ```\n */\nexport function buildObjectShape(\n\tschema: JSONSchema,\n\tdepth: number,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, ContractShape>>,\n\tdescription: string | undefined,\n): ContractShape {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst propertiesSource = isRecord(schema.properties) ? schema.properties : undefined\n\t\t\t\t// Indexed rather than `filter` / `includes`: this list decides which\n\t\t\t\t// properties the published shape marks required, and both are\n\t\t\t\t// caller-writable members.\n\t\t\t\tconst requiredSource = collectMembers([])\n\t\t\t\tif (isArray(schema.required)) {\n\t\t\t\t\tfor (let index = 0; index < schema.required.length; index += 1) {\n\t\t\t\t\t\tconst entry = schema.required[index]\n\t\t\t\t\t\tif (isString(entry)) admitMember(requiredSource, entry)\n\t\t\t\t\t}\n\t\t\t\t}\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 inferObject uses (inferers.ts).\n\t\t\t\tconst properties: Record<string, ContractShape> = INTRINSICS.create(null)\n\t\t\t\tlet truncated = false\n\t\t\t\tif (propertiesSource) {\n\t\t\t\t\tconst allKeys = INTRINSICS.keys(propertiesSource)\n\t\t\t\t\ttruncated = allKeys.length > INFER_BREADTH_LIMIT\n\t\t\t\t\tconst keys = limitEntries(allKeys, INFER_BREADTH_LIMIT)\n\t\t\t\t\tfor (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {\n\t\t\t\t\t\tconst key = keys[keyIndex]\n\t\t\t\t\t\tif (key === undefined) continue\n\t\t\t\t\t\tconst child = propertiesSource[key]\n\t\t\t\t\t\tconst childShape = isRecord(child)\n\t\t\t\t\t\t\t? schemaNodeToShape(child, depth - 1, visited, memo)\n\t\t\t\t\t\t\t: rawShape({})\n\t\t\t\t\t\tproperties[key] = matchesMember(requiredSource, key)\n\t\t\t\t\t\t\t? childShape\n\t\t\t\t\t\t\t: optionalShape(childShape)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst extra = schema.additionalProperties\n\t\t\t\tconst additionalProperties: boolean | ContractShape = truncated\n\t\t\t\t\t? true\n\t\t\t\t\t: extra === false\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: isRecord(extra)\n\t\t\t\t\t\t\t? schemaNodeToShape(extra, depth - 1, visited, memo)\n\t\t\t\t\t\t\t: true\n\t\t\t\treturn INTRINSICS.freeze({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: INTRINSICS.freeze(properties),\n\t\t\t\t\tadditionalProperties,\n\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t})\n\t\t\t},\n\t\t\t'buildObjectShape',\n\t\t\t{ subject: 'schema', context: { shape: 'schema' } },\n\t\t)\n\t}, 'buildObjectShape')\n}\n\n/**\n * Build a {@link ContractShape} for one JSON Schema node — the recursive\n * spine of {@link schemaToShape}, shared with per-child recursion via\n * {@link schemaNodeToShape}.\n *\n * @remarks\n * Every keyword is read defensively (the node's static `JSONSchema` type is\n * NOT trusted at runtime — a caller-supplied node may be adversarial), so a\n * malformed keyword falls through to the next rule instead of throwing.\n * Precedence, top-down:\n *\n * 1. `enum` — an array with at least one string/number/boolean entry (finite\n *    numbers only) becomes a {@link literalShape} over the filtered entries.\n *    Non-primitive / non-finite entries are dropped; an empty result falls\n *    through.\n * 2. `oneOf` — an array with at least one record entry becomes an\n *    {@link oneOfShape} over the recursively-built variants, provided the\n *    record-entry count is at or under {@link INFER_BREADTH_LIMIT}; OVER the\n *    limit, building a subset union would be strictly narrower than the\n *    schema's full union (a value matching only a dropped variant would be\n *    wrongly rejected), so the whole node widens to {@link rawShape} instead\n *    of sampling a subset.\n * 3. `anyOf` — identically, via {@link unionShape}.\n * 4. `type: 'string'` / `'number'` / `'integer'` / `'boolean'` / `'null'` —\n *    the matching primitive shape, with length/range bounds derived via\n *    {@link deriveLengthBounds} / {@link deriveRangeBounds}. An integer node\n *    additionally drops its bounds when they describe an EMPTY integer range\n *    (e.g. `minimum: 1.5, maximum: 1.6`) — the same emptiness `validateShapeDepth`\n *    rejects — so the result is always a valid shape.\n * 5. `type: 'array'` — an {@link arrayShape} whose element shape recurses into\n *    a record-valued `items` (widening to {@link rawShape} otherwise), with\n *    bounds from `minItems` / `maxItems`.\n * 6. `type: 'object'`, OR no `type` / `enum` / `oneOf` / `anyOf` but a\n *    record-valued `properties` — delegates to {@link buildObjectShape}.\n * 7. Everything else — an empty schema, an unrecognized/absent `type`, or\n *    exhausted depth/breadth — widens to\n *    {@link rawShape}, whose guard accepts every defined value and whose\n *    emitted schema is the same `{}` (plus `description`) the node carried.\n *    This is the exact inverse of `{}`, JSON Schema's accept-anything schema,\n *    and where the inferers themselves bottom out at their own limits.\n *\n * `format` and `pattern` are NEVER read into the compiled shape — `format` is\n * annotation-only and `pattern` compiling an attacker-supplied string into a\n * `RegExp` is a ReDoS vector. `description`, when a string, carries through to\n * the produced shape's `description` option.\n *\n * @param schema - The schema node to convert\n * @param depth - Remaining descent budget (0 halts recursion with `rawShape({})`)\n * @param visited - The ancestor set guarding against cycles — recursion\n *   state owned by the {@link schemaToShape} entry point; passing a shared or\n *   pre-populated `WeakSet` changes cycle-detection behavior and is not\n *   supported usage\n * @param memo - A per-call `(schema node, remaining depth) → shape` cache\n *               guarding against exponential re-conversion of a\n *               shared-reference schema DAG — recursion state owned by the\n *               {@link schemaToShape} entry point; passing a shared or\n *               pre-populated `WeakMap` changes caching behavior and is not\n *               supported usage\n * @returns The built shape for `schema`\n *\n * @example\n * ```ts\n * buildShapeFromNode({ type: 'string', minLength: 1 }, INFER_DEPTH_LIMIT, new WeakSet(), new WeakMap())\n * // stringShape({ min: 1 })\n * ```\n */\nexport function buildShapeFromNode(\n\tschema: JSONSchema,\n\tdepth: number,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, ContractShape>>,\n): ContractShape {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tconst description = isString(schema.description) ? schema.description : undefined\n\n\t\t\t\tif (isArray(schema.enum)) {\n\t\t\t\t\tconst literals: LiteralValue[] = []\n\t\t\t\t\t// De-duplicated in the same pass that already drops non-literal and\n\t\t\t\t\t// non-finite entries, by the package's own SameValueZero membership.\n\t\t\t\t\t// `literalShape` refuses a repeated vocabulary, and that refusal was\n\t\t\t\t\t// republished as `schema could not be read` — a data defect reported as\n\t\t\t\t\t// unreadability, for a schema every keyword of which was read. JSON\n\t\t\t\t\t// Schema requires `enum` members to be unique, so a repeat is malformed\n\t\t\t\t\t// vocabulary, and this conversion's stated rule for malformed vocabulary\n\t\t\t\t\t// is to ignore it and widen, never to throw. First occurrence wins, so\n\t\t\t\t\t// the emitted order still follows the source.\n\t\t\t\t\tconst seen = collectMembers([])\n\t\t\t\t\tfor (let index = 0; index < schema.enum.length; index += 1) {\n\t\t\t\t\t\tconst entry = schema.enum[index]\n\t\t\t\t\t\tif (isLiteralValue(entry) && (typeof entry !== 'number' || isFiniteNumber(entry))) {\n\t\t\t\t\t\t\tif (matchesMember(seen, entry)) continue\n\t\t\t\t\t\t\tadmitMember(seen, entry)\n\t\t\t\t\t\t\tliterals[literals.length] = entry\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (literals.length > 0) {\n\t\t\t\t\t\treturn literalShape(literals, description === undefined ? undefined : { description })\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (isArray(schema.oneOf)) {\n\t\t\t\t\tconst records: JSONSchema[] = []\n\t\t\t\t\tfor (let index = 0; index < schema.oneOf.length; index += 1) {\n\t\t\t\t\t\tconst entry = schema.oneOf[index]\n\t\t\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t\t\t}\n\t\t\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t\t\t}\n\t\t\t\t\tconst variants: ContractShape[] = []\n\t\t\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\t\t\tconst entry = records[index]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tvariants[variants.length] = schemaNodeToShape(entry, depth - 1, visited, memo)\n\t\t\t\t\t}\n\t\t\t\t\t// `Reflect.apply` reads its argument list by index, where a spread call\n\t\t\t\t\t// would dispatch through the caller-writable array iterator.\n\t\t\t\t\tif (variants.length > 0) return INTRINSICS.apply(oneOfShape, undefined, variants)\n\t\t\t\t}\n\n\t\t\t\tif (isArray(schema.anyOf)) {\n\t\t\t\t\tconst records: JSONSchema[] = []\n\t\t\t\t\tfor (let index = 0; index < schema.anyOf.length; index += 1) {\n\t\t\t\t\t\tconst entry = schema.anyOf[index]\n\t\t\t\t\t\tif (isRecord(entry)) records[records.length] = entry\n\t\t\t\t\t}\n\t\t\t\t\tif (records.length > INFER_BREADTH_LIMIT) {\n\t\t\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t\t\t}\n\t\t\t\t\tconst variants: ContractShape[] = []\n\t\t\t\t\tfor (let index = 0; index < records.length; index += 1) {\n\t\t\t\t\t\tconst entry = records[index]\n\t\t\t\t\t\tif (entry === undefined) continue\n\t\t\t\t\t\tvariants[variants.length] = schemaNodeToShape(entry, depth - 1, visited, memo)\n\t\t\t\t\t}\n\t\t\t\t\tif (variants.length > 0) return INTRINSICS.apply(unionShape, undefined, variants)\n\t\t\t\t}\n\n\t\t\t\tconst type = isString(schema.type) ? schema.type : undefined\n\n\t\t\t\tif (type === 'string') {\n\t\t\t\t\tconst bounds = deriveLengthBounds(schema.minLength, schema.maxLength)\n\t\t\t\t\treturn stringShape({\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (type === 'number') {\n\t\t\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\n\t\t\t\t\treturn numberShape({\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (type === 'integer') {\n\t\t\t\t\tconst bounds = deriveRangeBounds(schema.minimum, schema.maximum)\n\t\t\t\t\tconst emptyRange =\n\t\t\t\t\t\tINTRINSICS.ceil(bounds.min ?? Number.NEGATIVE_INFINITY) >\n\t\t\t\t\t\tINTRINSICS.floor(bounds.max ?? Number.POSITIVE_INFINITY)\n\t\t\t\t\treturn integerShape(\n\t\t\t\t\t\temptyRange\n\t\t\t\t\t\t\t? description === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: { description }\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (type === 'boolean') {\n\t\t\t\t\treturn booleanShape(description === undefined ? undefined : { description })\n\t\t\t\t}\n\t\t\t\tif (type === 'null') {\n\t\t\t\t\treturn nullShape(description === undefined ? undefined : { description })\n\t\t\t\t}\n\n\t\t\t\tif (type === 'array') {\n\t\t\t\t\tconst items = isRecord(schema.items)\n\t\t\t\t\t\t? schemaNodeToShape(schema.items, depth - 1, visited, memo)\n\t\t\t\t\t\t: rawShape({})\n\t\t\t\t\tconst bounds = deriveLengthBounds(schema.minItems, schema.maxItems)\n\t\t\t\t\treturn arrayShape(items, {\n\t\t\t\t\t\t...bounds,\n\t\t\t\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tif (type === 'object' || (type === undefined && isRecord(schema.properties))) {\n\t\t\t\t\treturn buildObjectShape(schema, depth, visited, memo, description)\n\t\t\t\t}\n\n\t\t\t\treturn rawShape(description === undefined ? {} : { description })\n\t\t\t},\n\t\t\t'buildShapeFromNode',\n\t\t\t{ subject: 'schema', context: { shape: 'schema' } },\n\t\t)\n\t}, 'buildShapeFromNode')\n}\n\n/**\n * Convert one JSON Schema node into a {@link ContractShape} — the recursion\n * entry point {@link schemaToShape} and {@link buildShapeFromNode} share for\n * every child (`items`, `properties` values, `additionalProperties`,\n * `oneOf` / `anyOf` variants).\n *\n * @remarks\n * Guards depth exhaustion, a readable non-record node (the node's static\n * `JSONSchema` type is not trusted at runtime), and a cyclic re-encounter of\n * `schema` — all three widen to {@link rawShape}. The\n * ancestor set is added to and removed from around the WHOLE subtree\n * conversion (not permanently), so a DAG-shaped schema reached twice via two\n * different, non-cyclic paths does not false-positive as a cycle. The\n * subtree conversion itself runs through {@link readValue}, so a hostile\n * throwing getter/Proxy anywhere in `schema` raises a coded read refusal\n * instead of degrading to an accept-anything shape. A same-node re-conversion at\n * the same remaining `depth` is served from `memo` (guards a\n * shared-reference schema DAG against exponential blowup), mirroring\n * {@link inferObject} / {@link inferArray} (inferers.ts).\n *\n * @param schema - The schema node to convert\n * @param depth - Remaining descent budget\n * @param visited - The ancestor set guarding against cycles — recursion\n *   state owned by the {@link schemaToShape} entry point; passing a shared or\n *   pre-populated `WeakSet` changes cycle-detection behavior and is not\n *   supported usage\n * @param memo - A per-call `(schema node, remaining depth) → shape` cache —\n *   recursion state owned by the {@link schemaToShape} entry point; passing\n *   a shared or pre-populated `WeakMap` changes caching behavior and is not\n *   supported usage\n * @returns The built shape for `schema`, or {@link rawShape} for readable widening cases\n * @throws {ContractError} When schema traversal fails\n *\n * @example\n * ```ts\n * schemaNodeToShape({ type: 'boolean' }, INFER_DEPTH_LIMIT, new WeakSet(), new WeakMap())\n * // booleanShape()\n * ```\n */\nexport function schemaNodeToShape(\n\tschema: JSONSchema,\n\tdepth: number,\n\tvisited: WeakSet<object>,\n\tmemo: WeakMap<object, Map<number, ContractShape>>,\n): ContractShape {\n\treturn contain(() => {\n\t\treturn readValue(\n\t\t\t() => {\n\t\t\t\tif (!(depth > 0)) return rawShape({})\n\t\t\t\tif (!matchesRecordBrand(schema)) return rawShape({})\n\t\t\t\tif (matchesVisited(visited, schema)) return rawShape({})\n\t\t\t\t// The memo read is dispatched through the captured `Map.prototype.get`\n\t\t\t\t// too: a substitute answering a decoy would put a shape this package\n\t\t\t\t// never built into one it publishes as its own.\n\t\t\t\tconst depthMemo = INTRINSICS.apply(INTRINSICS.recall, memo, [schema])\n\t\t\t\tconst cached =\n\t\t\t\t\tdepthMemo === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: INTRINSICS.apply(INTRINSICS.fetch, depthMemo, [depth])\n\t\t\t\tif (cached) return cached\n\t\t\t\tadmitVisited(visited, schema)\n\t\t\t\ttry {\n\t\t\t\t\tconst shape = buildShapeFromNode(schema, depth, visited, memo)\n\t\t\t\t\tretainDepth(memo, schema, depth, shape)\n\t\t\t\t\treturn shape\n\t\t\t\t} finally {\n\t\t\t\t\tomitVisited(visited, schema)\n\t\t\t\t}\n\t\t\t},\n\t\t\t'schemaNodeToShape',\n\t\t\t{ subject: 'schema', context: { shape: 'schema' } },\n\t\t)\n\t}, 'schemaNodeToShape')\n}\n\n/**\n * Convert 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`. See\n * {@link buildShapeFromNode} for the exact per-keyword precedence.\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 traversal state is built INSIDE the shared read boundary. A module\n\t\t// function cannot capture an intrinsic at evaluation the way an engine class\n\t\t// can, so containment is the equivalent: a caller who replaces\n\t\t// `globalThis.WeakSet` or `globalThis.WeakMap` before this call would\n\t\t// otherwise have the constructor throw the caller's raw value out of a door\n\t\t// documented to refuse with a `ContractError`, before any traversal exists to\n\t\t// contain it.\n\t\tconst traversal = readValue(\n\t\t\t() => ({\n\t\t\t\tvisited: new INTRINSICS.weakSet<object>(),\n\t\t\t\tmemo: new INTRINSICS.weakMap<object, Map<number, ContractShape>>(),\n\t\t\t}),\n\t\t\t'schemaToShape',\n\t\t\t{ subject: 'schema' },\n\t\t)\n\t\treturn schemaNodeToShape(schema, INFER_DEPTH_LIMIT, traversal.visited, traversal.memo)\n\t}, 'schemaToShape')\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,uBAAuB,OAAO,IAAI,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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