@orkestrel/contract 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * Collects one more member into a vocabulary that grows as a walk proceeds.
3
3
  *
4
+ * @remarks
5
+ * Collects through the captured adder, for a vocabulary that grows as a walk proceeds —
6
+ * a uniqueness gate, a de-duplicating key population.
7
+ *
4
8
  * @param members - The vocabulary to extend
5
9
  * @param value - The value to admit
6
10
  *
@@ -16,6 +20,10 @@ export declare function admitMember(members: Set<unknown>, value: unknown): void
16
20
  /**
17
21
  * Records an object as entered on a traversal's active path.
18
22
  *
23
+ * @remarks
24
+ * Records through the captured `WeakSet.prototype.add`, on the same terms {@link
25
+ * matchesVisited} states for the membership answer.
26
+ *
19
27
  * @param visited - The active-path set this traversal owns
20
28
  * @param value - The object being entered
21
29
  *
@@ -122,6 +130,8 @@ export declare function arrayOf(elementGuard: (value: unknown) => boolean): Guar
122
130
  * {@link entries} is a frozen native array with actual holes: reading a hole
123
131
  * yields `undefined`, while own membership remains absent. A length-driven
124
132
  * consumer must first require {@link dense} or carry an independent work bound.
133
+ *
134
+ * {@link readArrayEntries} returns it.
125
135
  */
126
136
  export declare interface ArrayRead<T = unknown> {
127
137
  /** Holds the frozen native entries in index order, retaining sparse positions as holes. */
@@ -269,6 +279,8 @@ export declare function boundsOf(min?: number, max?: number): Guard<number>;
269
279
  * The reduced result of a JSON Schema length or range keyword pair. A malformed
270
280
  * keyword is dropped as if absent, and a contradictory pair drops both members,
271
281
  * so an absent member always widens rather than narrows.
282
+ *
283
+ * {@link deriveLengthBounds} and {@link deriveRangeBounds} return it.
272
284
  */
273
285
  export declare interface BoundsRead {
274
286
  /** Holds the derived lower bound, absent when the keyword was malformed or contradictory. */
@@ -473,7 +485,7 @@ export declare function canonicalStringify(value: unknown): string | undefined;
473
485
  export declare function classifyFormat(value: string): SchemaFormat | undefined;
474
486
 
475
487
  /**
476
- * Caps the number of nodes one JSON snapshot may produce, frozen.
488
+ * Caps at `262144` the number of nodes one JSON snapshot may produce, frozen.
477
489
  *
478
490
  * @remarks
479
491
  * JSON persistence is a TREE, so `cloneJSONValue` / `cloneJSONRecord`
@@ -697,7 +709,7 @@ export declare function collectMembers(values: readonly unknown[]): Set<unknown>
697
709
  export declare function compareValues<T extends string | number>(left: T, right: T): number;
698
710
 
699
711
  /**
700
- * Caps the supported nesting depth of a compiled contract shape, frozen.
712
+ * Caps at `512` the supported nesting depth of a compiled contract shape, frozen.
701
713
  *
702
714
  * @remarks
703
715
  * {@link validateShape} rejects the next level
@@ -713,7 +725,8 @@ export declare function compareValues<T extends string | number>(left: T, right:
713
725
  export declare const COMPILE_DEPTH_LIMIT = 512;
714
726
 
715
727
  /**
716
- * Caps the number of nodes a compiled artifact may expand a shape into, frozen.
728
+ * Caps at `16384` the number of nodes a compiled artifact may expand a shape into,
729
+ * frozen.
717
730
  *
718
731
  * @remarks
719
732
  * A shape graph is a DAG; every compiled artifact is a TREE. A declaration may
@@ -969,6 +982,10 @@ export declare function compileSchema(shape: ContractShape): JSONSchema;
969
982
  * Builds a guard for `Exclude<TBase, TExcluded>` — accepts values that pass
970
983
  * `base` but not `excluded`.
971
984
  *
985
+ * @remarks
986
+ * The base and the exclusion are contained separately, for the reason {@link notOf}
987
+ * states: a throwing exclusion is a non-match, so the complement passes.
988
+ *
972
989
  * @param base - The guard establishing the accepted domain
973
990
  * @param excluded - The guard whose accepted values are removed from that domain
974
991
  * @returns A guard accepting a value `base` accepts and `excluded` rejects
@@ -1076,7 +1093,19 @@ export declare const CONTRACT_CODES: readonly ContractCode[];
1076
1093
  */
1077
1094
  export declare const CONTRACT_ERROR_BRAND: unique symbol;
1078
1095
 
1079
- /** Names the machine-readable category carried by a {@link ContractError}. */
1096
+ /**
1097
+ * Names the machine-readable category carried by a {@link ContractError}.
1098
+ *
1099
+ * @remarks
1100
+ * The declared categories are `'bound'`, `'range'`, `'empty'`, `'placement'`,
1101
+ * `'structure'`, `'literal'`, `'cycle'`, `'pattern'`, `'generate'`, `'random'`,
1102
+ * `'clone'`, `'depth'`, and `'expansion'`. `placement` names a valid optional node in a
1103
+ * forbidden position; `structure` a corrupt node, container, or structural slot;
1104
+ * `generate` an unsatisfiable generation request; `random` a sample source that threw
1105
+ * or left `[0, 1)`; `clone` a failed ownership snapshot; `depth` nesting past {@link
1106
+ * COMPILE_DEPTH_LIMIT}; and `expansion` a declaration whose compiled tree would exceed
1107
+ * {@link COMPILE_NODE_LIMIT}.
1108
+ */
1080
1109
  export declare type ContractCode =
1081
1110
  /** Identifies a bound contract error. */
1082
1111
  'bound'
@@ -1215,6 +1244,15 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
1215
1244
  * own and outlives the compiler that produced it. When one artifact is what you
1216
1245
  * want, keep the artifact and let the compiler go.
1217
1246
  *
1247
+ * It declares no call-signature member, so its whole surface is the readonly data
1248
+ * properties: `schema` (a {@link JSONSchema}), `guard` (a `Guard<Infer<S>>`), `parser`
1249
+ * (a `Parser<Infer<S>>`), `auditor` (an {@link AuditorFunction}), `reporter` (a {@link
1250
+ * ReporterFunction}), `generator` (a `SeederFunction<Infer<S>>`), and `contract` (a
1251
+ * `ContractInterface<Infer<S>>`). `contract` is the frozen bundle whose own enumerable
1252
+ * keys are `schema`, `is`, `parse`, `audit`, `explain`, and `generate` in that order,
1253
+ * each holding the exact value the corresponding getter publishes — `contract.is` is
1254
+ * exactly `compiler.guard`, by identity rather than as a copy.
1255
+ *
1218
1256
  * @example
1219
1257
  * ```ts
1220
1258
  * const compiler = new ContractCompiler(stringShape({ min: 1 }))
@@ -1239,11 +1277,14 @@ export declare interface ContractCompilerInterface<S extends ContractShape> {
1239
1277
  }
1240
1278
 
1241
1279
  /**
1242
- * Carries a machine-readable contract category, optional context, and an exact
1243
- * optional cause. Omitting `cause` omits the own property; explicitly
1244
- * supplying `cause: undefined` retains an own property with that value. Both
1245
- * optional options are read as OWN properties, so a construction never consults
1246
- * the caller-writable prototype chain of the container it was handed.
1280
+ * Carries a machine-readable contract category, optional context, and an exact optional
1281
+ * cause.
1282
+ *
1283
+ * @remarks
1284
+ * Omitting `cause` omits the own property; explicitly supplying `cause: undefined`
1285
+ * retains an own property with that value. Both optional options are read as OWN
1286
+ * properties, so a construction never consults the caller-writable prototype chain of
1287
+ * the container it was handed.
1247
1288
  *
1248
1289
  * @example
1249
1290
  * ```ts
@@ -1266,7 +1307,14 @@ export declare class ContractError extends Error {
1266
1307
  constructor(message: string, options: ContractErrorOptions);
1267
1308
  }
1268
1309
 
1269
- /** Represents the optional structured details carried by a {@link ContractError}. */
1310
+ /**
1311
+ * Represents the optional structured details carried by a {@link ContractError}.
1312
+ *
1313
+ * @remarks
1314
+ * Every member is optional: `path` locates the offending node, `shape` names the shape
1315
+ * category, `limit` names the bound that was applied, and `received` carries a total
1316
+ * {@link preview} of the offending value.
1317
+ */
1270
1318
  export declare interface ContractErrorContext {
1271
1319
  /** Holds the location associated with the error. */
1272
1320
  readonly path?: FieldPath;
@@ -1278,7 +1326,13 @@ export declare interface ContractErrorContext {
1278
1326
  readonly received?: string;
1279
1327
  }
1280
1328
 
1281
- /** Represents the construction options for a {@link ContractError}. */
1329
+ /**
1330
+ * Represents the construction options for a {@link ContractError}.
1331
+ *
1332
+ * @remarks
1333
+ * `code` is required and carries the machine-readable category; `context` and `cause`
1334
+ * are optional, and each is read as an own property.
1335
+ */
1282
1336
  export declare interface ContractErrorOptions {
1283
1337
  /** Names the machine-readable error category. */
1284
1338
  readonly code: ContractCode;
@@ -1321,6 +1375,20 @@ export declare interface ContractErrorOptions {
1321
1375
  export declare interface ContractInterface<T> {
1322
1376
  readonly schema: JSONSchema;
1323
1377
  readonly is: Guard<T>;
1378
+ /**
1379
+ * Coerces a readable value to the contract's type, or returns `undefined`.
1380
+ *
1381
+ * @remarks
1382
+ * Coercion (`'36'` → `36`) and every leaf refinement (`min` / `max` /
1383
+ * `pattern`) both apply, so every non-`undefined` result satisfies `is`.
1384
+ * Honest invalidity answers `undefined`, while a failed required object,
1385
+ * JSON, or dense-array index read throws the shared coded refusal — the two
1386
+ * outcomes stay distinguishable.
1387
+ *
1388
+ * @param value - The value to coerce
1389
+ * @returns The typed value, or `undefined` when the value is readable and invalid
1390
+ * @throws {ContractError} When a required read fails
1391
+ */
1324
1392
  parse(value: unknown): T | undefined;
1325
1393
  /**
1326
1394
  * Reports every strict fault a value has against this contract.
@@ -1352,6 +1420,18 @@ export declare interface ContractInterface<T> {
1352
1420
  * @returns The faults found, empty when the value parses successfully
1353
1421
  */
1354
1422
  explain(value: unknown): readonly Fault[];
1423
+ /**
1424
+ * Produces deterministic seed data for this contract.
1425
+ *
1426
+ * @remarks
1427
+ * Compiled with the contract, so a call draws rather than recompiles, and an
1428
+ * absent `random` selects a source seeded inside the door's own boundary. The
1429
+ * generator retains no randomness between calls.
1430
+ *
1431
+ * @param random - The sample source, defaulting to a wall-clock-seeded one
1432
+ * @returns A value satisfying this contract
1433
+ * @throws {ContractError} When the declaration cannot be satisfied, or when the sample source fails
1434
+ */
1355
1435
  generate(random?: RandomFunction): T;
1356
1436
  }
1357
1437
 
@@ -1402,12 +1482,24 @@ export declare type ContractShape = StringShape | NumberShape | BooleanShape | N
1402
1482
  * @param shape - The shape to compile
1403
1483
  * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`
1404
1484
  *
1405
- * @example
1485
+ * @example Compiling a contract
1406
1486
  * ```ts
1407
- * const user = createContract(objectShape({ name: stringShape(), age: integerShape() }))
1408
- * user.is({ name: 'Ada', age: 36 }) // true
1409
- * user.parse({ name: 'Ada', age: '36' }) // { name: 'Ada', age: 36 }
1410
- * user.schema // { type: 'object', properties: { … }, … }
1487
+ * import {
1488
+ * createContract,
1489
+ * integerShape,
1490
+ * objectShape,
1491
+ * seededRandom,
1492
+ * stringShape,
1493
+ * } from '@orkestrel/contract'
1494
+ *
1495
+ * const user = createContract(objectShape({ name: stringShape({ min: 1 }), age: integerShape() }))
1496
+ *
1497
+ * user.is({ name: 'Ada', age: 36 }) // true — a typed guard (narrows to Infer<typeof shape>)
1498
+ * user.parse({ name: 'Ada', age: '36' }) // { name: 'Ada', age: 36 } — coerces, or undefined
1499
+ * user.parse({ name: '', age: 36 }) // undefined — '' violates name min:1 (parse enforces refinements, like is)
1500
+ * user.explain({ name: '', age: 36 }) // [{ reason: 'constraint', path: ['name'], expected: 'string', constraint: 'min', limit: 1, received: '""' }]
1501
+ * user.schema // the owned, deeply frozen { type: 'object', properties: { … }, required: ['name', 'age'], additionalProperties: false }
1502
+ * user.generate(seededRandom(42)) // reproducible seed data; omit the arg for a wall-clock-seeded source
1411
1503
  * ```
1412
1504
  */
1413
1505
  export declare function createContract<S extends ContractShape>(shape: S): ContractInterface<Infer<S>>;
@@ -1464,6 +1556,15 @@ export declare function deriveRangeBounds(min: unknown, max: unknown): BoundsRea
1464
1556
  /**
1465
1557
  * Draws and validates one generator random sample.
1466
1558
  *
1559
+ * @remarks
1560
+ * A broken source is the source's fault rather than the shape's, so the refusal
1561
+ * carries code `random` and never the `generate` code, and {@link compileGenerator}
1562
+ * rethrows it at whatever draw depth it happened instead of rotating to the next union
1563
+ * variant. The diagnostic names the consuming shape category, the `[0, 1)` limit, and a
1564
+ * total non-coercing {@link preview} of the offending sample (or `threw`), so a hostile
1565
+ * object runs no conversion hook while the diagnostic is built and a primitive symbol
1566
+ * renders without consulting mutable `Symbol.prototype.toString`.
1567
+ *
1467
1568
  * @param random - The caller-supplied random source
1468
1569
  * @param shape - The shape category consuming the sample
1469
1570
  * @returns A finite sample in `[0, 1)`
@@ -1506,6 +1607,8 @@ export declare function encodeLeaf(value: unknown): string | undefined;
1506
1607
  * @remarks
1507
1608
  * Both the `Set` and `Map` sweeps hand the callback `(value, key)`; a `Set`
1508
1609
  * passes its entry in both positions, so one collector serves both.
1610
+ *
1611
+ * {@link collectEntries} builds it.
1509
1612
  */
1510
1613
  export declare type EntryCollectorFunction = (value: unknown, key: unknown) => void;
1511
1614
 
@@ -1558,6 +1661,10 @@ export declare function enumerableSymbolCount(value: object): number;
1558
1661
  * Builds a guard from a native `enum` or any object whose values are strings or
1559
1662
  * numbers.
1560
1663
  *
1664
+ * @remarks
1665
+ * An unreadable enumeration is refused at factory time with the shared `structure` read
1666
+ * refusal; the returned guard stays total.
1667
+ *
1561
1668
  * @param enumeration - The readable enumeration whose values the guard accepts
1562
1669
  * @returns A guard accepting one enumeration value
1563
1670
  * @throws {ContractError} When the enumeration cannot be read
@@ -1572,7 +1679,13 @@ export declare function enumerableSymbolCount(value: object): number;
1572
1679
  */
1573
1680
  export declare function enumOf<const E extends Record<string, string | number>>(enumeration: E): Guard<E[keyof E]>;
1574
1681
 
1575
- /** Represents a key present on a value that its closed object shape does not declare. */
1682
+ /**
1683
+ * Represents a key present on a value that its closed object shape does not declare.
1684
+ *
1685
+ * @remarks
1686
+ * The final path segment is the offending key, and no value is read or carried — an
1687
+ * undeclared key faults on its presence alone.
1688
+ */
1576
1689
  export declare interface ExtraFault {
1577
1690
  readonly reason: 'extra';
1578
1691
  readonly path: FieldPath;
@@ -1632,7 +1745,7 @@ export declare type Fault = {
1632
1745
  };
1633
1746
 
1634
1747
  /**
1635
- * Caps the number of {@link Fault} / {@link AuditFault} entries a single
1748
+ * Caps at `64` the number of {@link Fault} / {@link AuditFault} entries a single
1636
1749
  * `explain` or `audit` report ever returns, frozen.
1637
1750
  *
1638
1751
  * @remarks
@@ -1646,10 +1759,22 @@ export declare type Fault = {
1646
1759
  */
1647
1760
  export declare const FAULT_LIMIT = 64;
1648
1761
 
1649
- /** Names the refinement a {@link Fault} of reason `'constraint'` violates. */
1762
+ /**
1763
+ * Names the refinement a {@link Fault} of reason `'constraint'` violates.
1764
+ *
1765
+ * @remarks
1766
+ * The vocabulary is `'min'`, `'max'`, `'pattern'`, and `'integer'`.
1767
+ */
1650
1768
  export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'integer';
1651
1769
 
1652
- /** Names the kind of value a {@link Fault} expected — the shape-projected counterpart of a `ContractShape`'s `category`. */
1770
+ /**
1771
+ * Names the kind of value a {@link Fault} expected — the shape-projected counterpart of
1772
+ * a `ContractShape`'s `category`.
1773
+ *
1774
+ * @remarks
1775
+ * The vocabulary is `'string'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
1776
+ * `'literal'`, `'array'`, `'object'`, `'union'`, and `'json'`.
1777
+ */
1653
1778
  export declare type FaultKind = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json';
1654
1779
 
1655
1780
  /**
@@ -1659,11 +1784,13 @@ export declare type FaultKind = 'string' | 'number' | 'integer' | 'boolean' | 'n
1659
1784
  * @remarks
1660
1785
  * A single `string` is ONE key — it is never split on `.`, so keys that contain
1661
1786
  * dots stay safe. Use a `readonly string[]` to descend into nested objects.
1787
+ *
1788
+ * {@link resolveField} and the `parse*Field` parsers consume it.
1662
1789
  */
1663
1790
  export declare type FieldPath = string | readonly string[];
1664
1791
 
1665
1792
  /**
1666
- * Caps the string length {@link stringToFormat} attempts to classify, frozen.
1793
+ * Caps at `128` the string length {@link stringToFormat} attempts to classify, frozen.
1667
1794
  *
1668
1795
  * @remarks
1669
1796
  * Bounds per-string format-detection work: a value longer than this returns
@@ -1692,8 +1819,8 @@ export declare type FromGuards<G extends GuardsShape> = Readonly<{
1692
1819
  }>;
1693
1820
 
1694
1821
  /**
1695
- * Caps the number of candidate-generation attempts for a constrained
1696
- * generated value, frozen.
1822
+ * Caps at `32` the number of candidate-generation attempts for a constrained generated
1823
+ * value, frozen.
1697
1824
  *
1698
1825
  * @remarks
1699
1826
  * Provides one deterministic work bound for generators that must retry a
@@ -1733,6 +1860,8 @@ export declare const GUARD_DEPTH_LIMIT = 512;
1733
1860
  * A null-prototype record plus its own key list, never a `Map`: the declared-key
1734
1861
  * population decides a shape combinator's answer, and map lookup and map
1735
1862
  * iteration are caller-writable members on that path.
1863
+ *
1864
+ * {@link readGuardShape} returns it.
1736
1865
  */
1737
1866
  export declare interface GuardShapeRead {
1738
1867
  /** Holds the owned guards, keyed by their own string declaration name. */
@@ -1759,6 +1888,11 @@ export declare type GuardType<G> = G extends Guard<infer T> ? T : never;
1759
1888
  /**
1760
1889
  * Invokes a predicate through the sanctioned never-throw boundary.
1761
1890
  *
1891
+ * @remarks
1892
+ * Backs the `instanceof`-based validators and every container combinator's element
1893
+ * walk. The answer is `true` only for the boolean literal `true`; a throw and every
1894
+ * other return are `false`.
1895
+ *
1762
1896
  * @param callback - The predicate to invoke with no arguments
1763
1897
  * @returns True if the callback returns the boolean value `true`; false otherwise
1764
1898
  *
@@ -1812,8 +1946,8 @@ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S]
1812
1946
  } ? I extends ContractShape ? Infer<I> | null : never : S extends JSONShape ? JSONValue : unknown;
1813
1947
 
1814
1948
  /**
1815
- * Caps by default the number of object properties / array elements
1816
- * {@link valueToSchema} samples per container, frozen.
1949
+ * Caps by default at `256` the number of object properties / array elements {@link
1950
+ * valueToSchema} samples per container, frozen.
1817
1951
  *
1818
1952
  * @remarks
1819
1953
  * Bounds the work (and the emitted schema's size) against a wide record or a
@@ -1823,7 +1957,7 @@ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S]
1823
1957
  export declare const INFER_BREADTH_LIMIT = 256;
1824
1958
 
1825
1959
  /**
1826
- * Caps the object/array nesting depth {@link valueToSchema} walks, frozen.
1960
+ * Caps at `32` the object/array nesting depth {@link valueToSchema} walks, frozen.
1827
1961
  *
1828
1962
  * @remarks
1829
1963
  * Bounds inference against adversarial or cyclic runtime input — once the
@@ -1842,7 +1976,7 @@ export declare const INFER_BREADTH_LIMIT = 256;
1842
1976
  export declare const INFER_DEPTH_LIMIT = 32;
1843
1977
 
1844
1978
  /**
1845
- * Caps by default the number of distinct values a multi-sample slot may hold
1979
+ * Caps by default at `12` the number of distinct values a multi-sample slot may hold
1846
1980
  * before enum inference gives up and falls back to a bare `type`, frozen.
1847
1981
  *
1848
1982
  * @remarks
@@ -1984,6 +2118,11 @@ export declare type InferUnion<V extends readonly ContractShape[]> = V extends R
1984
2118
  * Verifies that `ctor` is a real constructor (through {@link isConstructor}) first,
1985
2119
  * so passing an arrow function does not silently produce a broken guard.
1986
2120
  *
2121
+ * A callable instance passes. The exclusion is a bad constructor, never a callable
2122
+ * value: an `isObject` pre-filter made `instanceOf(Function)(() => {})` answer `false`
2123
+ * while {@link isInstance}, the helper this is built on, answered `true` for the same
2124
+ * pair.
2125
+ *
1987
2126
  * @param ctor - The constructor whose instances the guard accepts
1988
2127
  * @returns A guard narrowing to that constructor's instance type
1989
2128
  *
@@ -2016,6 +2155,10 @@ export declare type IntersectionFromGuards<Gs extends ReadonlyArray<Guard<unknow
2016
2155
  * Builds a guard that accepts values matching ALL of the provided guards — the
2017
2156
  * variadic form of {@link andOf}.
2018
2157
  *
2158
+ * @remarks
2159
+ * Zero guards yield a guard that always answers `true`, the identity of an
2160
+ * intersection.
2161
+ *
2019
2162
  * @param guards - The guards every accepted value must satisfy
2020
2163
  * @returns A guard accepting a value every guard accepts
2021
2164
  *
@@ -2265,6 +2408,10 @@ export declare const INTRINSICS: Readonly<{
2265
2408
  }>;
2266
2409
 
2267
2410
  /** Determines whether a value is an array.
2411
+ *
2412
+ * @remarks
2413
+ * Checks the container alone — no element is inspected. Use {@link arrayOf} to check
2414
+ * every element against a guard.
2268
2415
  *
2269
2416
  * @param value - The value to inspect
2270
2417
  * @returns True if the value is an array; false otherwise
@@ -3144,6 +3291,11 @@ export declare function isPromiseLike<T = unknown>(value: unknown): value is Pro
3144
3291
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
3145
3292
 
3146
3293
  /** Determines whether a value is a `RegExp`.
3294
+ *
3295
+ * @remarks
3296
+ * A total native internal-slot brand check rather than a property read: it accepts a
3297
+ * genuine pattern from this realm and from another, and refuses a proxy or a hand-built
3298
+ * forgery without reading an advertised field.
3147
3299
  *
3148
3300
  * @param value - The value to inspect
3149
3301
  * @returns True if the value is a `RegExp`; false otherwise
@@ -3425,7 +3577,7 @@ export declare class JSONCloner implements JSONClonerInterface {
3425
3577
  }
3426
3578
 
3427
3579
  /**
3428
- * Owns the state of one exact JSON snapshot operation.
3580
+ * Settles one exact JSON snapshot of a retained source, then replays it.
3429
3581
  *
3430
3582
  * @remarks
3431
3583
  * Construction retains the source without observing it. The first
@@ -3437,6 +3589,16 @@ export declare interface JSONClonerInterface {
3437
3589
  /**
3438
3590
  * Clones the retained source into exact, deeply frozen JSON data.
3439
3591
  *
3592
+ * @remarks
3593
+ * Executes once and replays the terminal result. Success returns the exact same deeply
3594
+ * frozen root without another source read; failure releases partial traversal working
3595
+ * state while retaining the source and the exact same class-owned {@link
3596
+ * ContractError}. Both outcomes publish through intrinsics captured while the module
3597
+ * loaded and read every diagnostic option as an own property, so terminal settlement
3598
+ * stays nonredirectable against a replaced intrinsic and against a polluted prototype
3599
+ * alike. Active reentry permanently settles the instance with one exact cause-free
3600
+ * `clone` poison shared by the nested call, the outer call, and every later call.
3601
+ *
3440
3602
  * @returns The settled JSON snapshot
3441
3603
  * @throws {ContractError} When the source is inexact, cyclic, unreadable, or cloning is reentered
3442
3604
  */
@@ -3535,6 +3697,9 @@ export declare interface JSONShape {
3535
3697
  * the compiled guard accepts — `NaN`, a `Map`, and a class instance all satisfy
3536
3698
  * `{}` and all fail `isJSONValue`.
3537
3699
  *
3700
+ * This is the shape an author writes to mean "any JSON value". Inference never produces
3701
+ * it: {@link schemaToShape} widening always lands on {@link RawShape} instead.
3702
+ *
3538
3703
  * @param options - Optional `description`
3539
3704
  * @returns A JSON passthrough shape
3540
3705
  *
@@ -3693,7 +3858,15 @@ export declare interface LiteralShapeOptions {
3693
3858
  readonly description?: string;
3694
3859
  }
3695
3860
 
3696
- /** Represents a string, number, or boolean literal. */
3861
+ /**
3862
+ * Represents a string, number, or boolean literal.
3863
+ *
3864
+ * @remarks
3865
+ * The shared structural literal domain behind `JSONSchema.enum`, {@link LiteralShape},
3866
+ * {@link literalOf}, {@link parseEnum}, and shape compilation. It deliberately admits
3867
+ * every JavaScript number, including `NaN` and `±Infinity`; finite-schema policy is
3868
+ * applied separately where a contract requires it.
3869
+ */
3697
3870
  export declare type LiteralValue = string | number | boolean;
3698
3871
 
3699
3872
  /**
@@ -3809,6 +3982,13 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
3809
3982
  * Determines whether a value is a member of a collected vocabulary, by
3810
3983
  * SameValueZero.
3811
3984
  *
3985
+ * @remarks
3986
+ * Dispatched through the captured `Set.prototype.has` onto a collection no caller
3987
+ * holds, and asked as a module binding rather than as a property: `set.has(value)` asks
3988
+ * a member every caller can rewrite, and moving that read onto an exported class's
3989
+ * `has` method reproduced the identical defect one prototype higher, because every
3990
+ * public class method is dispatched through a reachable prototype.
3991
+ *
3812
3992
  * @param members - The vocabulary to ask, built by {@link collectMembers}
3813
3993
  * @param value - The value to test for membership
3814
3994
  * @returns True if the value was collected; false otherwise
@@ -3962,6 +4142,10 @@ export declare function matchOf(pattern: RegExp): Guard<string>;
3962
4142
  * Typed as `Guard<unknown>` because `Exclude<unknown, T>` is not useful; use
3963
4143
  * {@link complementOf} when you need the narrowed `Exclude<TBase, TExcluded>`.
3964
4144
  *
4145
+ * The negation applies to the contained verdict, so a throwing guard is a non-match and
4146
+ * its negation passes. Containing the negation instead made a guard and its `notOf`
4147
+ * both reject the same value, which broke `orOf(g, notOf(g))` as a tautology.
4148
+ *
3965
4149
  * @param guard - The guard or predicate to negate
3966
4150
  * @returns A guard accepting exactly the values `guard` rejects
3967
4151
  *
@@ -4044,6 +4228,11 @@ export declare interface NumberShape {
4044
4228
  /**
4045
4229
  * Builds a numeric {@link NumberShape}.
4046
4230
  *
4231
+ * @remarks
4232
+ * A present `min` or `max` must be finite. `NaN` and `±Infinity` throw a `bound` {@link
4233
+ * ContractError} at construction, because no finite value satisfies them and no JSON
4234
+ * Schema keyword expresses them.
4235
+ *
4047
4236
  * @param options - Optional bounds (`min` / `max`), `integer`, and `description`
4048
4237
  * @returns A number shape
4049
4238
  * @throws {ContractError} When a present bound is not finite
@@ -4110,6 +4299,9 @@ export declare function objectOf<S extends GuardsShape>(shape: S, optional: true
4110
4299
  * `additionalProperties: false` — while the compiled parser drops the key and
4111
4300
  * the compiled reporter stays silent, mirroring that parser. `true` accepts
4112
4301
  * unknown keys as-is, and a `ContractShape` validates them, in every artifact.
4302
+ *
4303
+ * The `A` parameter carries the open-value shape into {@link Infer}, so a constrained
4304
+ * tail keeps its type in the inferred index signature.
4113
4305
  */
4114
4306
  export declare interface ObjectShape<P extends Readonly<Record<string, ContractShape>> = Readonly<Record<string, ContractShape>>, A extends boolean | ContractShape = boolean | ContractShape> {
4115
4307
  readonly category: 'object';
@@ -4158,6 +4350,10 @@ export declare interface ObjectShapeOptions<A extends boolean | ContractShape =
4158
4350
  * Builds a new guard shape by removing the listed keys — the structural
4159
4351
  * equivalent of `Omit<T, K>`. Produces a shape for {@link recordOf}, not a guard.
4160
4352
  *
4353
+ * @remarks
4354
+ * An unreadable `keys` list and an unreadable `shape` are refused separately, each
4355
+ * under its own name, for the reason {@link pickOf} states.
4356
+ *
4161
4357
  * @param shape - The guard shape to narrow
4162
4358
  * @param keys - The keys to remove
4163
4359
  * @returns A guard shape carrying every key except the removed ones
@@ -4174,6 +4370,10 @@ export declare function omitOf<S extends GuardsShape, K extends ReadonlyArray<ke
4174
4370
  /**
4175
4371
  * Records an object as exited from a traversal's active path.
4176
4372
  *
4373
+ * @remarks
4374
+ * Records through the captured `WeakSet.prototype.delete`, on the same terms {@link
4375
+ * matchesVisited} states for the membership answer.
4376
+ *
4177
4377
  * @param visited - The active-path set this traversal owns
4178
4378
  * @param value - The object being exited
4179
4379
  *
@@ -4275,6 +4475,11 @@ export declare function optionalShape<S extends ContractShape>(inner: S): Option
4275
4475
  * Combines `left` and `right` with logical OR — passes when at least one passes.
4276
4476
  * Prefer {@link unionOf} for a wider set of variants.
4277
4477
  *
4478
+ * @remarks
4479
+ * Each member is contained on its own, so a throwing member is a non-match rather than
4480
+ * a veto over its sibling. One containment around the whole disjunction made `orOf(a,
4481
+ * b)` and `orOf(b, a)` answer differently for one value.
4482
+ *
4278
4483
  * @param left - The guard tested first
4279
4484
  * @param right - The guard tested only after `left` fails
4280
4485
  * @returns A guard accepting a value either accepts
@@ -4645,6 +4850,12 @@ export declare type Parser<T> = (value: unknown) => T | undefined;
4645
4850
  /**
4646
4851
  * Parses an unknown value to a plain record — the input reference, never cloned.
4647
4852
  *
4853
+ * @remarks
4854
+ * Probes the record's own enumerable values before returning the reference, so a
4855
+ * hostile getter is met here rather than at the caller. A failed probe throws
4856
+ * `ContractError { code: 'structure' }` carrying `parseRecord: value could not be
4857
+ * read`; a readable non-record answers `undefined`.
4858
+ *
4648
4859
  * @param value - The value to parse
4649
4860
  * @returns The record, or `undefined`
4650
4861
  * @throws {ContractError} When an object value cannot be read
@@ -4720,6 +4931,10 @@ export declare function pathOf(path: readonly string[], ...segments: ReadonlyArr
4720
4931
  * Builds a new guard shape by keeping only the listed keys — the structural
4721
4932
  * equivalent of `Pick<T, K>`. Produces a shape for {@link recordOf}, not a guard.
4722
4933
  *
4934
+ * @remarks
4935
+ * An unreadable `keys` list and an unreadable `shape` are refused separately, each
4936
+ * under its own name, so a caller reads which argument failed.
4937
+ *
4723
4938
  * @param shape - The guard shape to narrow
4724
4939
  * @param keys - The keys to keep
4725
4940
  * @returns A guard shape carrying only the kept keys
@@ -4779,7 +4994,7 @@ export declare function pickOf<S extends GuardsShape, K extends ReadonlyArray<ke
4779
4994
  export declare function pinMembers(prototype: object, owner: string): void;
4780
4995
 
4781
4996
  /**
4782
- * Caps the number of object keys one compiled presence mask carries, frozen.
4997
+ * Caps at `31` the number of object keys one compiled presence mask carries, frozen.
4783
4998
  *
4784
4999
  * @remarks
4785
5000
  * A compiled object plan decides which declared keys a value carries. The keys
@@ -4804,7 +5019,7 @@ export declare function pinMembers(prototype: object, owner: string): void;
4804
5019
  export declare const PRESENCE_MASK_LIMIT = 31;
4805
5020
 
4806
5021
  /**
4807
- * Renders a short, safe, TOTAL preview of an unknown value for a {@link Fault}'s
5022
+ * Renders an unknown value as a short, safe, TOTAL string for a {@link Fault}'s
4808
5023
  * `received` field.
4809
5024
  *
4810
5025
  * @remarks
@@ -4852,7 +5067,7 @@ export declare const PRESENCE_MASK_LIMIT = 31;
4852
5067
  export declare function preview(value: unknown): string;
4853
5068
 
4854
5069
  /**
4855
- * Caps the character length of a {@link preview}-rendered string, frozen.
5070
+ * Caps at `64` the character length of a {@link preview}-rendered string, frozen.
4856
5071
  *
4857
5072
  * @remarks
4858
5073
  * A previewed string longer than this is clipped with a trailing `…` so a
@@ -4861,7 +5076,14 @@ export declare function preview(value: unknown): string;
4861
5076
  */
4862
5077
  export declare const PREVIEW_LIMIT = 64;
4863
5078
 
4864
- /** Represents a deterministic random source returning a value in `[0, 1)`. */
5079
+ /**
5080
+ * Represents a deterministic random source returning a value in `[0, 1)`.
5081
+ *
5082
+ * @remarks
5083
+ * The seed source `generate` draws from. A source that throws, or returns a value
5084
+ * outside `[0, 1)`, fails as a `random` {@link ContractError} raised by {@link
5085
+ * drawRandom}, never as a silently skewed value.
5086
+ */
4865
5087
  export declare type RandomFunction = () => number;
4866
5088
 
4867
5089
  /**
@@ -5042,6 +5264,10 @@ export declare function readPattern(pattern: RegExp): RegExp;
5042
5264
  /**
5043
5265
  * Reads a regular expression's flag text through the captured accessor.
5044
5266
  *
5267
+ * @remarks
5268
+ * The flags half of {@link readPatternSource}, on the same captured-accessor terms and
5269
+ * for the same reason.
5270
+ *
5045
5271
  * @param pattern - The candidate regular expression to read
5046
5272
  * @returns The pattern's flag text, or `undefined` when it cannot be read as a string
5047
5273
  * @throws The exact value the captured accessor throws for a receiver that is not a pattern
@@ -5506,7 +5732,7 @@ export declare class SchemaCloner implements SchemaClonerInterface {
5506
5732
  }
5507
5733
 
5508
5734
  /**
5509
- * Owns the state of one JSON Schema snapshot operation.
5735
+ * Settles one JSON Schema snapshot of a retained schema, then replays it.
5510
5736
  *
5511
5737
  * @remarks
5512
5738
  * Construction retains the schema without observing it. The first
@@ -5519,6 +5745,16 @@ export declare interface SchemaClonerInterface {
5519
5745
  /**
5520
5746
  * Clones the retained schema into a deeply frozen identity-preserving graph.
5521
5747
  *
5748
+ * @remarks
5749
+ * Executes one identity-memoized schema snapshot and replays the terminal result.
5750
+ * Success returns the exact same deeply frozen graph without another source read.
5751
+ * Success and failure both release traversal frames and the active memo through
5752
+ * preconstructed references before nonredirectable terminal publication, while
5753
+ * retaining the source and the exact root or class-owned error. Active reentry
5754
+ * permanently settles the instance with one exact cause-free `clone` poison shared by
5755
+ * the nested call, the outer call, and every later call, and a property-read cause
5756
+ * stays exact.
5757
+ *
5522
5758
  * @returns The settled JSON Schema snapshot
5523
5759
  * @throws {ContractError} When traversal is unreadable or cloning is reentered
5524
5760
  */
@@ -5784,7 +6020,7 @@ export declare class ShapeCloner implements ShapeClonerInterface {
5784
6020
  }
5785
6021
 
5786
6022
  /**
5787
- * Owns the state of one contract-shape snapshot operation.
6023
+ * Settles one contract-shape snapshot of a retained shape, then replays it.
5788
6024
  *
5789
6025
  * @remarks
5790
6026
  * Construction retains the shape without observing it. The first
@@ -5798,6 +6034,17 @@ export declare interface ShapeClonerInterface {
5798
6034
  /**
5799
6035
  * Clones the retained shape into a deeply frozen identity-preserving graph.
5800
6036
  *
6037
+ * @remarks
6038
+ * Executes once and replays the terminal result. Each node's plain-record brand is
6039
+ * required before discriminant observation; the retained declaration is captured and
6040
+ * wired through descriptor-first stable reads and primitive `RegExp` scalar ownership,
6041
+ * raw schemas are composed directly, the completed root is frozen and validated, and
6042
+ * deferred fidelity is applied last. Success returns the exact deeply frozen root;
6043
+ * failure rethrows the exact class-owned or adopted {@link ContractError}. Both
6044
+ * release graph-working state through preconstructed references before nonredirectable
6045
+ * terminal publication. Active reentry permanently settles the instance with one exact
6046
+ * cause-free poison shared by the nested call, the outer call, and every later call.
6047
+ *
5801
6048
  * @returns The settled contract-shape snapshot
5802
6049
  * @throws {ContractError} When the declaration is malformed, unreadable, cyclic, too deep, or cloning is reentered
5803
6050
  */
@@ -5911,6 +6158,10 @@ export declare class ShapeValidator implements ShapeValidatorInterface {
5911
6158
  * @remarks
5912
6159
  * Construction does not observe the source. Every {@link validate} call is an
5913
6160
  * independent live validation pass over its current state.
6161
+ *
6162
+ * Its one readonly data property is {@link expansion}. {@link validateShape} reads it
6163
+ * to apply {@link COMPILE_NODE_LIMIT}, and `refuseExpansion` refuses an absent
6164
+ * measurement rather than reading it as a small count.
5914
6165
  */
5915
6166
  export declare interface ShapeValidatorInterface {
5916
6167
  /**
@@ -5925,6 +6176,12 @@ export declare interface ShapeValidatorInterface {
5925
6176
  /**
5926
6177
  * Validates the retained shape declaration.
5927
6178
  *
6179
+ * @remarks
6180
+ * Runs one fresh live declaration pass over the source's current state; construction
6181
+ * observed nothing. A malformed declaration throws a coded {@link ContractError}, and
6182
+ * reentry throws `ShapeValidator.validate: shape validation may not be reentered` with
6183
+ * code `structure` at the root path.
6184
+ *
5928
6185
  * @returns Nothing when the declaration is valid
5929
6186
  * @throws {ContractError} When the declaration is malformed, cyclic, or too deep
5930
6187
  */
@@ -6173,6 +6430,11 @@ export declare function unifySchemas(schemas: readonly JSONSchema[]): JSONSchema
6173
6430
  * Builds a guard that accepts values matching at least one of the provided
6174
6431
  * guards — the variadic form of {@link orOf}.
6175
6432
  *
6433
+ * @remarks
6434
+ * Zero guards yield a guard that always answers `false`. Each member is contained
6435
+ * separately, exactly as {@link orOf} contains its two, so a throwing member cannot
6436
+ * erase a later passing one and the answer does not depend on argument order.
6437
+ *
6176
6438
  * @param guards - The guards tried in order
6177
6439
  * @returns A guard accepting a value at least one guard accepts
6178
6440
  *