@orkestrel/contract 0.0.22 → 0.0.24

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.
@@ -18,24 +18,22 @@
18
18
  export declare function admitMember(members: Set<unknown>, value: unknown): void;
19
19
 
20
20
  /**
21
- * Admits a stable readable value with only lossless repairs and returns the parser's value.
21
+ * Admits a readable value exactly where `is` holds and returns the parser's value.
22
22
  *
23
23
  * @remarks
24
- * Reads must remain stable across artifacts. Guard-valid input skips both reports and parses
25
- * once. Repairs use audit, parse once, and explain only on parse failure. Unresolved unions,
26
- * extras, lossy repairs, and a capped audit refuse. An own optional undefined field omitted or
27
- * filled by its declared default is not a repair. The result preserves parser ownership, including union input identity.
28
- * A read failure returns its cause rather than throwing.
29
- * Snapshot a foreign object before admission, as Tool.execute does. A getter changing between
30
- * is and parse can publish a value that no recorded repair describes. A shallow snapshot only
31
- * stabilizes its own level; nested foreign values must also provide stable reads.
24
+ * Guard-valid input parses once. Any other input refuses with every fault `audit` reports
25
+ * after {@link filterUncoveredFaults} prunes the faults a union fault covers, bounded at
26
+ * {@link FAULT_LIMIT}. A parse that returns `undefined` for a value other than `undefined`
27
+ * refuses with no fault, and a read failure refuses with its cause rather than throwing.
28
+ * Repair a lossless leaf through {@link repairValue}.
32
29
  *
33
30
  * @example
34
31
  * ```ts
35
- * admitValue(createContract(numberShape()), '3') // success carrying 3 and its type repair
32
+ * admitValue(createContract(numberShape()), 3) // success carrying 3
33
+ * admitValue(createContract(numberShape()), '3') // refusal carrying the type fault
36
34
  * ```
37
35
  */
38
- export declare function admitValue<T>(contract: ContractInterface<T>, value: unknown): Result<ContractAdmission<T>, ContractRefusal>;
36
+ export declare function admitValue<T>(contract: ContractInterface<T>, value: unknown): Result<T, ContractRefusal>;
39
37
 
40
38
  /**
41
39
  * Records an object as entered on a traversal's active path.
@@ -147,17 +145,20 @@ export declare function arrayOf(elementGuard: (value: unknown) => boolean): Guar
147
145
  * Represents the owned result of reading one array through its reflected own-index lens.
148
146
  *
149
147
  * @remarks
150
- * {@link entries} is a frozen native array with actual holes: reading a hole
148
+ * {@link entries} is a native array with actual holes: reading a hole
151
149
  * yields `undefined`, while own membership remains absent. A length-driven
152
150
  * consumer must first require {@link dense} or carry an independent work bound.
153
151
  *
154
- * {@link readArrayEntries} returns it.
152
+ * {@link collectArrayEntries} returns a fresh unfrozen read on every call, and
153
+ * {@link readArrayEntries} freezes the read and its entries.
155
154
  */
156
155
  export declare interface ArrayRead<T = unknown> {
157
- /** Holds the frozen native entries in index order, retaining sparse positions as holes. */
156
+ /** Holds the native entries in index order, retaining sparse positions as holes. */
158
157
  readonly entries: ReadonlyArray<T | undefined>;
159
158
  /** Reports whether every index from zero through length minus one was reflected. */
160
159
  readonly dense: boolean;
160
+ /** Reports whether every own key is a canonical index or `length`, symbols included. */
161
+ readonly exact: boolean;
161
162
  }
162
163
 
163
164
  /** Describes an array with an element shape and optional length bounds. */
@@ -224,8 +225,8 @@ export declare interface ArrayShapeOptions {
224
225
  */
225
226
  export declare function attempt<T>(callback: () => T): Result<T>;
226
227
 
227
- /** Covers every fault an audit reports — the parse faults plus undeclared keys. */
228
- export declare type AuditFault = Fault | ExtraFault;
228
+ /** Covers every fault an audit reports — the parse faults plus undeclared and hidden keys. */
229
+ export declare type AuditFault = Fault | ExtraFault | HiddenFault;
229
230
 
230
231
  /** Describes the closed shape built for audit faults, including paired discriminator hints. */
231
232
  export declare type AuditFaultShape = ReturnType<FaultShaper['build']>;
@@ -352,6 +353,25 @@ export declare interface BoundsRead {
352
353
  */
353
354
  export declare function buildArrayFaults(shape: ArrayShape, length: number, path: readonly string[]): readonly Fault[];
354
355
 
356
+ /**
357
+ * Builds the key plan that answers one key order from the declared member guards.
358
+ *
359
+ * @remarks
360
+ * One {@link KeyStep} per key, in the order given, each holding the key and its declared guard.
361
+ * The plan and its steps are fresh and unfrozen.
362
+ *
363
+ * @param keys - The key order the plan answers
364
+ * @param guards - The declared member guards, keyed by own string key
365
+ * @returns The plan, or `undefined` when any key is undeclared
366
+ *
367
+ * @example
368
+ * ```ts
369
+ * buildKeyPlan(['id'], { id: isString }) // [{ key: 'id', guard: isString }]
370
+ * buildKeyPlan(['other'], { id: isString }) // undefined
371
+ * ```
372
+ */
373
+ export declare function buildKeyPlan(keys: readonly string[], guards: Readonly<Record<string, Guard<unknown> | undefined>>): readonly KeyStep[] | undefined;
374
+
355
375
  /**
356
376
  * Builds the refinement faults a number value has against a {@link NumberShape}.
357
377
  *
@@ -377,6 +397,24 @@ export declare function buildArrayFaults(shape: ArrayShape, length: number, path
377
397
  */
378
398
  export declare function buildNumberFaults(shape: NumberShape, value: number, path: readonly string[]): readonly Fault[];
379
399
 
400
+ /**
401
+ * Builds a map key from the leading segments of a path, without dispatching through array serialization.
402
+ *
403
+ * @remarks
404
+ * Each segment is encoded as a quoted string and the encodings are joined by a captured `join`,
405
+ * so a caller-installed `Array.prototype.toJSON` cannot reach the key and two paths never share one.
406
+ *
407
+ * @param path - The path whose leading segments form the key
408
+ * @param length - The number of leading segments to keep; default: every segment
409
+ * @returns The key text, empty for no segment
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * buildPathKey(['a', 'b'], 1) // '"a"'
414
+ * ```
415
+ */
416
+ export declare function buildPathKey(path: readonly string[], length?: number): string;
417
+
380
418
  /**
381
419
  * Builds a null-prototype lookup from names to their last index.
382
420
  *
@@ -418,8 +456,10 @@ export declare function buildSampleMemo(): SampleMemo;
418
456
  * OBTAIN the string — the reporter coerces through `parseString`, the auditor
419
457
  * demands a primitive string — and share every constraint afterwards through
420
458
  * this helper, so a constraint cannot drift between them.
421
- * Faults come out in declaration order — `min`, then `max`, then
459
+ * Faults come out in declaration order — `date`, then `min`, then `max`, then
422
460
  * `pattern` — because a report is read top to bottom and its order is public.
461
+ * `expected` is `'date'` on a date string shape and `'string'` otherwise, as
462
+ * {@link buildNumberFaults} names `'integer'`.
423
463
  *
424
464
  * The declaration's pattern is applied through an OWNED stateless rebuild
425
465
  * ({@link readPattern}) asked through {@link matchesPattern}, so the shape's own
@@ -586,7 +626,9 @@ export declare const CLONE_NODE_LIMIT = 262144;
586
626
  *
587
627
  * @param value - The unknown record value to validate and snapshot
588
628
  * @returns A deeply cloned and frozen JSON record
589
- * @throws {ContractError} When the root is not a record, nested data is inexact, or traversal fails
629
+ * @throws {ContractError} When the root is not a record, nested data is inexact, or traversal
630
+ * fails; a nested refusal is the one {@link cloneJSONValue} raises, `cloneJSONValue:` prefix and path
631
+ * included
590
632
  *
591
633
  * @example
592
634
  * ```ts
@@ -614,7 +656,10 @@ export declare function cloneJSONRecord(value: unknown): JSONRecord;
614
656
  *
615
657
  * @param value - The unknown value to validate and snapshot
616
658
  * @returns The primitive unchanged, or a deeply cloned and frozen JSON graph
617
- * @throws {ContractError} When the value is not exact acyclic JSON data or traversal fails
659
+ * @throws {ContractError} When the value is not exact acyclic JSON data or traversal fails; a
660
+ * refusal that names a member or a container carries its `path` and `received`, and its message
661
+ * ends with ` at ` and the rendered path, except at the root, where the path is `[]` and the
662
+ * message has no suffix
618
663
  *
619
664
  * @example
620
665
  * ```ts
@@ -692,6 +737,38 @@ export declare function cloneShape(shape: StringShape): StringShape;
692
737
 
693
738
  export declare function cloneShape(shape: ContractShape): ContractShape;
694
739
 
740
+ /**
741
+ * Collects an array's entries through its reflected own-index population.
742
+ *
743
+ * @remarks
744
+ * Reads `length` once and one reflected own-key population, then corroborates
745
+ * and reads only those reflected canonical indices in ascending order. The
746
+ * native entries retain actual holes: reading one yields `undefined`, while
747
+ * own membership remains absent. Its work is proportional to the reflected
748
+ * population, so a length-driven consumer must require `dense` or carry an
749
+ * independent bound. `exact` is false when the population holds any key other
750
+ * than a canonical index or `length`, a symbol key included. A population that
751
+ * is exactly the canonical indices in ascending order followed by `length` is
752
+ * copied straight by index under the same per-index corroboration, and answers
753
+ * with the same entries, the same `dense` and `exact` facts, and the same
754
+ * refusals as the walk. Caller-defined iteration is ignored. A descriptor-only
755
+ * index omitted from reflection is deliberately outside this lens and remains a
756
+ * hole. `4294967295` is metadata rather than an array index. Every call returns
757
+ * a fresh unfrozen read; {@link readArrayEntries} freezes it.
758
+ *
759
+ * @param value - The array whose reflected indexed entries to collect
760
+ * @returns The entries with their `dense` and `exact` facts
761
+ * @throws The exact thrown value when length, reflection, membership, or
762
+ * indexed value observation throws, and an `Error` on a non-native
763
+ * length or a view disagreement
764
+ *
765
+ * @example
766
+ * ```ts
767
+ * collectArrayEntries([1, 2]) // { entries: [1, 2], dense: true, exact: true }
768
+ * ```
769
+ */
770
+ export declare function collectArrayEntries<T>(value: readonly T[]): ArrayRead<T>;
771
+
695
772
  /**
696
773
  * Builds the collector a captured `forEach` sweep appends through.
697
774
  *
@@ -907,7 +984,12 @@ export declare function compileGenerator(shape: ContractShape, random?: RandomFu
907
984
  * observe own enumerable string keys through {@link enumerableKeys}, the same
908
985
  * key view their parser, reporter, auditor, and inference use for both open and
909
986
  * closed objects — the view is shared, the verdict on an undeclared key is not
910
- * (this guard rejects the object; the parser drops the key).
987
+ * (this guard rejects the object; the parser drops the key). A closed or
988
+ * tail-shaped object also refuses an own member outside that view, a
989
+ * non-enumerable string key or a symbol key. An object with
990
+ * `additionalProperties: true` runs no own-key count: it admits an undeclared
991
+ * non-enumerable or symbol member, while a declared member outside the enumerable
992
+ * view still reads as absent.
911
993
  * Like every guard it is total — it never throws, as `.claude/rules/patterns.md`
912
994
  * § Validation and contracts requires. It requests
913
995
  * exactly the `guard` root of a fresh {@link ContractCompiler}, which owns the
@@ -1066,6 +1148,25 @@ export declare function compileSchema(shape: ContractShape): JSONSchema;
1066
1148
  */
1067
1149
  export declare function complementOf<TBase, TExcluded extends TBase>(base: Guard<TBase>, excluded: Guard<TExcluded> | ((value: TBase) => value is TExcluded)): Guard<Exclude<TBase, TExcluded>>;
1068
1150
 
1151
+ /**
1152
+ * Computes the number of days in a month of the Gregorian calendar.
1153
+ *
1154
+ * @remarks
1155
+ * February has 29 days in a year divisible by 4, except a century year not divisible
1156
+ * by 400. The caller supplies a month from 1 to 12.
1157
+ *
1158
+ * @param year - The calendar year
1159
+ * @param month - The month, from 1 for January to 12 for December
1160
+ * @returns The days in that month, from 28 to 31
1161
+ *
1162
+ * @example
1163
+ * ```ts
1164
+ * computeMonthLength(2024, 2) // 29
1165
+ * computeMonthLength(1900, 2) // 28
1166
+ * ```
1167
+ */
1168
+ export declare function computeMonthLength(year: number, month: number): number;
1169
+
1069
1170
  /**
1070
1171
  * Counts the surrogate pairs in a string, stopping at a limit.
1071
1172
  *
@@ -1181,22 +1282,6 @@ export declare const CONTRACT_CODES: readonly ContractCode[];
1181
1282
  */
1182
1283
  export declare const CONTRACT_ERROR_BRAND: unique symbol;
1183
1284
 
1184
- /**
1185
- * Carries an admitted value and the lossless repairs made while parsing it.
1186
- *
1187
- * @remarks
1188
- * The value keeps the parser's ownership: a union may return the caller's input by identity.
1189
- *
1190
- * @example
1191
- * ```ts
1192
- * const admitted: ContractAdmission<number> = { value: 3, repairs: [] }
1193
- * ```
1194
- */
1195
- export declare interface ContractAdmission<T> {
1196
- readonly value: T;
1197
- readonly repairs: readonly AuditFault[];
1198
- }
1199
-
1200
1285
  /**
1201
1286
  * Names the machine-readable category carried by a {@link ContractError}.
1202
1287
  *
@@ -1507,7 +1592,10 @@ export declare interface ContractInterface<T> {
1507
1592
  * stable across calls (see the read-stability precondition on
1508
1593
  * {@link ContractInterface}). It is the report for the stricter of the two
1509
1594
  * domains, so a coercible leaf and a closed object's undeclared key both
1510
- * fault here and neither faults in `explain`.
1595
+ * fault here and neither faults in `explain`. An own member outside the
1596
+ * enumerable view of a closed or tail-shaped object faults here as `'hidden'`
1597
+ * or `'extra'`, while `explain` reads the enumerable view and reports a
1598
+ * declared such member as `'missing'`.
1511
1599
  *
1512
1600
  * @param value - The value to check
1513
1601
  * @returns The faults found, empty when the value is strictly valid
@@ -1556,6 +1644,22 @@ export declare interface ContractRefusal {
1556
1644
  readonly cause?: unknown;
1557
1645
  }
1558
1646
 
1647
+ /**
1648
+ * Carries a repaired value and the lossless repairs made while parsing it.
1649
+ *
1650
+ * @remarks
1651
+ * The value keeps the parser's ownership: a union may return the caller's input by identity.
1652
+ *
1653
+ * @example
1654
+ * ```ts
1655
+ * const repaired: ContractRepair<number> = { value: 3, repairs: [] }
1656
+ * ```
1657
+ */
1658
+ export declare interface ContractRepair<T> {
1659
+ readonly value: T;
1660
+ readonly repairs: readonly AuditFault[];
1661
+ }
1662
+
1559
1663
  /**
1560
1664
  * Describes a value declaratively — a declaration the shape builders build and
1561
1665
  * the compilers turn into a guard, a parser, a JSON Schema, and a generator.
@@ -1565,7 +1669,7 @@ export declare interface ContractRefusal {
1565
1669
  * element shape, an `ObjectShape` a map of them). {@link validateShape}
1566
1670
  * enforces an acyclic graph within {@link COMPILE_DEPTH_LIMIT}.
1567
1671
  */
1568
- export declare type ContractShape = StringShape | NumberShape | BooleanShape | NullShape | LiteralShape | ArrayShape | ObjectShape | UnionShape | OptionalShape | NullableShape | JSONShape | ShapeShape | RawShape;
1672
+ export declare type ContractShape = StringShape | NumberShape | BooleanShape | NullShape | LiteralShape | ArrayShape | ObjectShape | UnionShape | OptionalShape | NullableShape | JSONShape | ShapeShape | FunctionShape | RawShape;
1569
1673
 
1570
1674
  /**
1571
1675
  * Compiles a {@link ContractShape} into a {@link ContractInterface} — the
@@ -1633,6 +1737,40 @@ export declare function createContract<S extends ContractShape>(shape: S): Contr
1633
1737
 
1634
1738
  export declare function createContract(shape: ContractShape): ContractInterface<unknown>;
1635
1739
 
1740
+ /**
1741
+ * Holds `10`, the length of every `YYYY-MM-DD` date a date string shape admits.
1742
+ *
1743
+ * @remarks
1744
+ * A date string shape whose `min` or `max` excludes this length admits no value, so
1745
+ * building one refuses with code `range`.
1746
+ *
1747
+ * @example
1748
+ * ```ts
1749
+ * DATE_LENGTH // 10
1750
+ * ```
1751
+ */
1752
+ export declare const DATE_LENGTH = 10;
1753
+
1754
+ /**
1755
+ * Builds a calendar-date {@link StringShape} — forces `date: true`.
1756
+ *
1757
+ * @remarks
1758
+ * The guard and the parser admit exactly a calendar-valid `YYYY-MM-DD` and coerce
1759
+ * nothing, so `2026-02-30`, `2026-1-10`, and a date-time all refuse. The emitted JSON
1760
+ * Schema carries `"format": "date"`. Options other than `min`, `max`, and `description`
1761
+ * refuse, because a dropped `pattern` would widen the shape.
1762
+ *
1763
+ * @param options - Optional length bounds and `description` (no `date` or `pattern` key)
1764
+ * @returns A date string shape
1765
+ * @throws {ContractError} When an option key is unknown, or a present bound is invalid or excludes length 10
1766
+ *
1767
+ * @example
1768
+ * ```ts
1769
+ * createContract(dateShape()).is('2024-02-29') // true
1770
+ * ```
1771
+ */
1772
+ export declare function dateShape(options?: Omit<StringShapeOptions, 'date' | 'pattern'>): StringShape;
1773
+
1636
1774
  /**
1637
1775
  * Derives `min`/`max` shape bounds from a pair of non-negative-integer JSON
1638
1776
  * Schema length keywords (`minLength`/`maxLength`, `minItems`/`maxItems`).
@@ -1685,8 +1823,10 @@ export declare function deriveRangeBounds(min: unknown, max: unknown): BoundsRea
1685
1823
  * says.
1686
1824
  *
1687
1825
  * @remarks
1688
- * Each line opens with the fault's path (or `value` at the root) and reason. An `extra` fault lists
1689
- * its parent's keys only when the declaring arms agree. A literal names candidates only where
1826
+ * Each line opens with the fault's path (or `value` at the root) and reason. A `hidden` fault says
1827
+ * the member is not enumerable and to send it as a plain data member. An `extra` fault carrying
1828
+ * `symbol` names the symbol key and lists no declared key; another `extra` fault lists its
1829
+ * parent's keys only when no array form sits at the parent and the declaring arms agree. A literal names candidates only where
1690
1830
  * the declarations agree; lists are deduplicated and bounded. A received preview stays as written
1691
1831
  * within PREVIEW_LIMIT and without control or line-separator characters; otherwise it is encoded
1692
1832
  * through preview. Received, constraint, and limit details read only own fields. A `variant` or
@@ -1969,15 +2109,18 @@ export declare function extractPath(fault: AuditFault): readonly string[];
1969
2109
  export declare function extractSchema(schema: JSONSchema, path: readonly string[]): JSONSchema | undefined;
1970
2110
 
1971
2111
  /**
1972
- * Represents a key present on a value that its closed object shape does not declare.
2112
+ * Represents a key present on a value that its closed object shape does not declare, or an own
2113
+ * key other than an index or `length` on a value its array shape describes.
1973
2114
  *
1974
2115
  * @remarks
1975
- * The final path segment is the offending key, and no value is read or carried — an
1976
- * undeclared key faults on its presence alone.
2116
+ * The final path segment is the offending key, or `symbol` names it: a symbol key adds no
2117
+ * segment, so its fault sits at the object or the array and `symbol` holds the key's preview. No value is
2118
+ * read or carried — an undeclared key faults on its presence alone.
1977
2119
  */
1978
2120
  export declare interface ExtraFault {
1979
2121
  readonly reason: 'extra';
1980
2122
  readonly path: FieldPath;
2123
+ readonly symbol?: string;
1981
2124
  }
1982
2125
 
1983
2126
  /**
@@ -2013,7 +2156,7 @@ export declare function failure<E>(error: E): Failure<E>;
2013
2156
  * - `'type'` — the value could not coerce to `expected` at all.
2014
2157
  * - `'missing'` — a required object property was absent.
2015
2158
  * - `'constraint'` — the value coerced to `expected` but violated one
2016
- * refinement (`min` / `max` / `pattern` / `integer`); `limit` carries the
2159
+ * refinement (`min` / `max` / `pattern` / `date` / `integer`); `limit` carries the
2017
2160
  * violated bound/pattern when applicable.
2018
2161
  * - `'variant'` — an `anyOf`-mode union matched no variant; `variants` is the
2019
2162
  * variant count, followed (in the report) by the closest variant's own faults.
@@ -2108,19 +2251,19 @@ export declare const FAULT_TEXT_LIMIT = 2048;
2108
2251
  * Names the refinement a {@link Fault} of reason `'constraint'` violates.
2109
2252
  *
2110
2253
  * @remarks
2111
- * The vocabulary is `'min'`, `'max'`, `'pattern'`, and `'integer'`.
2254
+ * The vocabulary is `'min'`, `'max'`, `'pattern'`, `'date'`, and `'integer'`.
2112
2255
  */
2113
- export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'integer';
2256
+ export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'integer';
2114
2257
 
2115
2258
  /**
2116
2259
  * Names the kind of value a {@link Fault} expected — the shape-projected counterpart of
2117
2260
  * a `ContractShape`'s `category`.
2118
2261
  *
2119
2262
  * @remarks
2120
- * The vocabulary is `'string'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2121
- * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, and `'shape'`.
2263
+ * The vocabulary is `'string'`, `'date'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2264
+ * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, `'shape'`, and `'function'`.
2122
2265
  */
2123
- export declare type FaultKind = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape';
2266
+ export declare type FaultKind = 'string' | 'date' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape' | 'function';
2124
2267
 
2125
2268
  /**
2126
2269
  * Retains a lazily built fault declaration without building shapes during module evaluation.
@@ -2181,6 +2324,13 @@ declare class FaultShaper {
2181
2324
  }, false>, ObjectShape< {
2182
2325
  reason: LiteralShape<readonly ["extra"]>;
2183
2326
  path: UnionShape<readonly [StringShape, ArrayShape<StringShape>]>;
2327
+ }, false>, ObjectShape< {
2328
+ reason: LiteralShape<readonly ["extra"]>;
2329
+ path: UnionShape<readonly [StringShape, ArrayShape<StringShape>]>;
2330
+ symbol: StringShape;
2331
+ }, false>, ObjectShape< {
2332
+ reason: LiteralShape<readonly ["hidden"]>;
2333
+ path: UnionShape<readonly [StringShape, ArrayShape<StringShape>]>;
2184
2334
  }, false>]>;
2185
2335
  }
2186
2336
 
@@ -2211,6 +2361,28 @@ export declare interface FaultTextOptions {
2211
2361
  */
2212
2362
  export declare type FieldPath = string | readonly string[];
2213
2363
 
2364
+ /**
2365
+ * Filters out the faults a union fault covers, keeping every fault that states a fact no form shows.
2366
+ *
2367
+ * @remarks
2368
+ * A `variant` or `oneOf` fault covers every fault beneath its path and every non-union fault at
2369
+ * its path, and never itself. A `hidden` fault and an `extra` fault carrying `symbol` are kept
2370
+ * whatever covers them, because each reports a member outside the enumerable view that no
2371
+ * form summary names.
2372
+ *
2373
+ * @param faults - The faults an audit reported
2374
+ * @returns The faults no cover prunes, in their order
2375
+ *
2376
+ * @example
2377
+ * ```ts
2378
+ * filterUncoveredFaults([
2379
+ * { reason: 'variant', path: [], variants: 2 },
2380
+ * { reason: 'extra', path: ['typo'] },
2381
+ * ]) // [{ reason: 'variant', path: [], variants: 2 }]
2382
+ * ```
2383
+ */
2384
+ export declare function filterUncoveredFaults(faults: readonly AuditFault[]): readonly AuditFault[];
2385
+
2214
2386
  /**
2215
2387
  * Caps at `128` the string length {@link stringToFormat} attempts to classify, frozen.
2216
2388
  *
@@ -2240,6 +2412,60 @@ export declare type FromGuards<G extends GuardsShape> = Readonly<{
2240
2412
  [K in keyof G]: GuardType<G[K]>;
2241
2413
  }>;
2242
2414
 
2415
+ /**
2416
+ * Describes a callable value — accepts every function, a class constructor included.
2417
+ *
2418
+ * @remarks
2419
+ * The compiled guard is `isFunction` and the parser returns the value by identity. JSON
2420
+ * carries no function, so the emitted schema `{ not: {}, format: 'function' }` admits no
2421
+ * JSON instance; `format` names the member for a reader, and `description` appears only
2422
+ * when one is authored. The generator returns one frozen function that returns
2423
+ * `undefined`. {@link Infer} resolves the shape to `(...args: never[]) => unknown`, which
2424
+ * accepts every function and refuses a call that passes an argument; a call with no
2425
+ * argument still typechecks.
2426
+ *
2427
+ * @example
2428
+ * ```ts
2429
+ * const declaration: FunctionShape = { category: 'function' }
2430
+ * createContract(declaration).is(encodeURI) // true
2431
+ * ```
2432
+ */
2433
+ export declare interface FunctionShape {
2434
+ readonly category: 'function';
2435
+ readonly description?: string;
2436
+ }
2437
+
2438
+ /**
2439
+ * Builds a {@link FunctionShape}.
2440
+ *
2441
+ * @remarks
2442
+ * The guard accepts every callable and checks no arity: TypeScript admits a callback that
2443
+ * declares fewer parameters than its type, and `Function.length` undercounts rest and
2444
+ * defaulted parameters.
2445
+ *
2446
+ * @param options - Optional description
2447
+ * @returns A function-valued declaration
2448
+ *
2449
+ * @example
2450
+ * ```ts
2451
+ * const options = objectShape({ upgrade: optionalShape(functionShape()) })
2452
+ * ```
2453
+ */
2454
+ export declare function functionShape(options?: FunctionShapeOptions): FunctionShape;
2455
+
2456
+ /**
2457
+ * Configures the description of a function-valued declaration.
2458
+ *
2459
+ * @example
2460
+ * ```ts
2461
+ * const options: FunctionShapeOptions = { description: 'Runs the schema migration' }
2462
+ * functionShape(options).description // 'Runs the schema migration'
2463
+ * ```
2464
+ */
2465
+ export declare interface FunctionShapeOptions {
2466
+ readonly description?: string;
2467
+ }
2468
+
2243
2469
  /**
2244
2470
  * Caps at `32` the number of candidate-generation attempts for a constrained generated
2245
2471
  * value, frozen.
@@ -2307,6 +2533,20 @@ export declare type GuardsShape = Readonly<Record<string, Guard<unknown>>>;
2307
2533
  /** Extracts the guarded type `T` from a `Guard<T>`. */
2308
2534
  export declare type GuardType<G> = G extends Guard<infer T> ? T : never;
2309
2535
 
2536
+ /**
2537
+ * Represents an own member outside the enumerable view that a closed or tail-shaped object
2538
+ * refuses.
2539
+ *
2540
+ * @remarks
2541
+ * The final path segment is the non-enumerable string key. A declared member reports this
2542
+ * fault in place of `missing`, and a tail-shaped object reports it for an undeclared one. The
2543
+ * correction is always to send the member as plain data; no value is read or carried.
2544
+ */
2545
+ export declare interface HiddenFault {
2546
+ readonly reason: 'hidden';
2547
+ readonly path: FieldPath;
2548
+ }
2549
+
2310
2550
  /**
2311
2551
  * Invokes a predicate through the sanctioned never-throw boundary.
2312
2552
  *
@@ -2350,7 +2590,7 @@ export declare function holds(callback: () => boolean): boolean;
2350
2590
  * nesting. {@link InferIndex} and {@link InferOpenIndex} apply the identical
2351
2591
  * tuple guard to their own `A` parameter for the same reason.
2352
2592
  */
2353
- export declare type Infer<S extends ContractShape> = [ContractShape] extends [S] ? unknown : S extends ShapeShape ? ContractShape : S extends StringShape ? string : S extends NumberShape ? number : S extends BooleanShape ? boolean : S extends NullShape ? null : S extends {
2593
+ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S] ? unknown : S extends ShapeShape ? ContractShape : S extends FunctionShape ? (...args: never[]) => unknown : S extends StringShape ? string : S extends NumberShape ? number : S extends BooleanShape ? boolean : S extends NullShape ? null : S extends {
2354
2594
  readonly category: 'literal';
2355
2595
  readonly values: infer V;
2356
2596
  } ? V extends ReadonlyArray<infer L> ? L : never : S extends {
@@ -2703,6 +2943,8 @@ export declare const INTRINSICS: Readonly<{
2703
2943
  prototype: (o: any) => any;
2704
2944
  /** Captures `Object.getOwnPropertySymbols` — the own-symbol population. */
2705
2945
  symbols: (o: any) => symbol[];
2946
+ /** Captures `Object.getOwnPropertyNames` — the own string-key population, enumerable or not. */
2947
+ names: (o: any) => string[];
2706
2948
  /** Captures `Object.prototype` — the realm-local plain-record prototype identity. */
2707
2949
  base: Object;
2708
2950
  /**
@@ -2793,6 +3035,11 @@ export declare const INTRINSICS: Readonly<{
2793
3035
  order: (compareFn?: ((a: any, b: any) => number) | undefined) => any[];
2794
3036
  /** Captures `Array.prototype.some` for short-circuit membership checks. */
2795
3037
  some: (predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean;
3038
+ /** Captures `Array.prototype.every` for short-circuit checks that every entry passes. */
3039
+ every: {
3040
+ <S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): this is S[];
3041
+ (predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
3042
+ };
2796
3043
  /** Captures `Array.prototype.findIndex`, including reads of sparse positions. */
2797
3044
  find: (predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any) => number;
2798
3045
  /** Captures `Array.prototype.forEach` for indexed visits of owned arrays. */
@@ -2985,15 +3232,19 @@ export declare function isAsyncIterable<T = unknown>(value: unknown): value is A
2985
3232
  * Determines whether a value is exactly one {@link AuditFault}.
2986
3233
  *
2987
3234
  * @remarks
2988
- * Every {@link Fault}, and the undeclared-key fault an audit adds.
3235
+ * Every {@link Fault}, and the undeclared-key and hidden-key faults an audit adds: `extra` with
3236
+ * exactly `reason` and `path`, or with a string `symbol` beside them, and `hidden` with exactly
3237
+ * `reason` and `path`.
2989
3238
  *
2990
3239
  * @param value - The value to inspect
2991
3240
  * @returns True if the value is a well-formed audit fault; false otherwise
2992
3241
  *
2993
3242
  * @example
2994
3243
  * ```ts
2995
- * isAuditFault({ reason: 'extra', path: ['a'] }) // true
2996
- * isAuditFault({}) // false
3244
+ * isAuditFault({ reason: 'extra', path: ['a'] }) // true
3245
+ * isAuditFault({ reason: 'extra', path: [], symbol: 'Symbol(tag)' }) // true
3246
+ * isAuditFault({ reason: 'hidden', path: ['note'] }) // true
3247
+ * isAuditFault({}) // false
2997
3248
  * ```
2998
3249
  */
2999
3250
  export declare function isAuditFault(value: unknown): value is AuditFault;
@@ -4241,9 +4492,11 @@ export declare type JSONRecord = {
4241
4492
  *
4242
4493
  * @remarks
4243
4494
  * Intentionally lean (not the full ~50-keyword vocabulary): it carries only the
4244
- * keywords {@link Infer}-driven `compileSchema` produces, plus `format` —
4245
- * emitted by the {@link stringToFormat} / {@link samplesToFormat} inference
4246
- * heuristics (`valueToSchema` / `samplesToSchema`), never by `compileSchema`.
4495
+ * keywords `compileSchema` emits and the `format` the {@link stringToFormat} /
4496
+ * {@link samplesToFormat} inference heuristics (`valueToSchema` / `samplesToSchema`)
4497
+ * emit. `compileSchema` emits `format` for a date string (`'date'`) and a function
4498
+ * shape (`'function'`), and `not` only as the empty schema `{}`, which no JSON
4499
+ * instance satisfies; {@link RawShape} admits `not` in that form alone.
4247
4500
  * Recursive through `items` / `properties` / `additionalProperties` / `anyOf` /
4248
4501
  * `oneOf`. {@link createContract} owns and validates developer-authored shape
4249
4502
  * graphs; cycles and nesting past {@link COMPILE_DEPTH_LIMIT} fail with a coded
@@ -4268,6 +4521,7 @@ export declare interface JSONSchema {
4268
4521
  readonly additionalProperties?: boolean | JSONSchema;
4269
4522
  readonly anyOf?: readonly JSONSchema[];
4270
4523
  readonly oneOf?: readonly JSONSchema[];
4524
+ readonly not?: JSONSchema;
4271
4525
  }
4272
4526
 
4273
4527
  /** Lists the seven standard JSON Schema `type` names. */
@@ -4332,6 +4586,26 @@ export declare interface JSONShapeOptions {
4332
4586
  */
4333
4587
  export declare type JSONValue = JSONPrimitive | readonly JSONValue[] | JSONRecord;
4334
4588
 
4589
+ /**
4590
+ * Caps at `4` the number of key plans one compiled closed-object guard keeps, frozen.
4591
+ *
4592
+ * @remarks
4593
+ * A compiled closed-object guard answers a value through the full key walk and,
4594
+ * after a walk that accepts, keeps that value's key order as a plan: one
4595
+ * {@link KeyStep} entry per key, in order. A later value whose own enumerable keys
4596
+ * arrive in a kept order is answered by asking each step's guard in turn, with
4597
+ * no presence or vocabulary question. The guard learns only from an accepted
4598
+ * walk, never evicts, and stops learning at this count, so the plans it keeps
4599
+ * are those of the earliest accepted key orders. Every other key order takes the
4600
+ * full walk. Both paths answer identically; only the cost differs.
4601
+ *
4602
+ * @example
4603
+ * ```ts
4604
+ * KEY_PLAN_LIMIT // 4
4605
+ * ```
4606
+ */
4607
+ export declare const KEY_PLAN_LIMIT = 4;
4608
+
4335
4609
  /**
4336
4610
  * Builds a guard that accepts values that are own keys of the provided object.
4337
4611
  *
@@ -4354,6 +4628,22 @@ export declare type JSONValue = JSONPrimitive | readonly JSONValue[] | JSONRecor
4354
4628
  */
4355
4629
  export declare function keyOf<const O extends Readonly<Record<PropertyKey, unknown>>>(value: O): Guard<keyof O>;
4356
4630
 
4631
+ /**
4632
+ * Represents one step of a key plan: a declared key and the compiled guard its member answers to.
4633
+ *
4634
+ * @remarks
4635
+ * A compiled closed-object guard keeps one plan per accepted key order, one step per key in that
4636
+ * order, and answers a later value in the same order by asking each step's guard.
4637
+ *
4638
+ * {@link buildKeyPlan} returns a plan of these.
4639
+ */
4640
+ export declare interface KeyStep {
4641
+ /** Holds the declared key the step reads. */
4642
+ readonly key: string;
4643
+ /** Holds the compiled guard the member under the key must satisfy. */
4644
+ readonly guard: Guard<unknown>;
4645
+ }
4646
+
4357
4647
  /**
4358
4648
  * Defers guard creation until first use by calling `thunk()` on every
4359
4649
  * invocation.
@@ -4495,6 +4785,47 @@ export declare function mapOf<K, V>(keyGuard: Guard<K>, valueGuard: Guard<V>): G
4495
4785
 
4496
4786
  export declare function mapOf(keyPredicate: (value: unknown) => boolean, valuePredicate: (value: unknown) => boolean): Guard<ReadonlyMap<unknown, unknown>>;
4497
4787
 
4788
+ /**
4789
+ * Checks whether a string is exactly a calendar-valid `YYYY-MM-DD` date.
4790
+ *
4791
+ * @remarks
4792
+ * Refuses a date-time, surrounding whitespace, and a date the Gregorian calendar
4793
+ * lacks, such as `2026-02-29`. Backs a date string shape and {@link classifyFormat}'s
4794
+ * `date`.
4795
+ *
4796
+ * @param value - The candidate string
4797
+ * @returns True if `value` is a calendar-valid `YYYY-MM-DD`; false otherwise
4798
+ * @throws The exact value thrown by a redirected pattern dispatch
4799
+ *
4800
+ * @example
4801
+ * ```ts
4802
+ * matchesCalendarDate('2024-02-29') // true
4803
+ * matchesCalendarDate('2026-02-29') // false
4804
+ * ```
4805
+ */
4806
+ export declare function matchesCalendarDate(value: string): boolean;
4807
+
4808
+ /**
4809
+ * Checks whether an object owns no key outside the enumerable string keys already read from it.
4810
+ *
4811
+ * @remarks
4812
+ * Counts the own string keys, enumerable or not, against the key list and requires no own
4813
+ * symbol key. A key a `Proxy` lists among its own keys with no descriptor counts as own.
4814
+ * Thrown when the object's own-key reflection throws, so call it inside a boundary.
4815
+ *
4816
+ * @param value - The object whose own keys to count
4817
+ * @param keys - The object's own enumerable string keys, as `Object.keys` returned them
4818
+ * @returns True if the object owns no other key; false otherwise
4819
+ *
4820
+ * @example
4821
+ * ```ts
4822
+ * const value = { id: 'a' }
4823
+ * matchesEnumerableKeys(value, Object.keys(value)) // true
4824
+ * matchesEnumerableKeys(Object.defineProperty(value, 'secret', { value: 1 }), ['id']) // false
4825
+ * ```
4826
+ */
4827
+ export declare function matchesEnumerableKeys(value: object, keys: readonly string[]): boolean;
4828
+
4498
4829
  /**
4499
4830
  * Determines whether an object holds exactly the named own keys.
4500
4831
  *
@@ -4611,6 +4942,24 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
4611
4942
  left: number;
4612
4943
  }): entry is JSONValue;
4613
4944
 
4945
+ /**
4946
+ * Checks whether a key plan answers the key list bound as `this`.
4947
+ *
4948
+ * @remarks
4949
+ * Passed with the key list as the `thisArg` argument to the captured `findIndex` member over a list of
4950
+ * plans. A plan answers a key list holding the same keys in the same order, so a prefix and a
4951
+ * reordering both miss.
4952
+ *
4953
+ * @param plan - The key plan to compare
4954
+ * @returns True if the plan's keys equal the bound list in order; false otherwise
4955
+ *
4956
+ * @example
4957
+ * ```ts
4958
+ * matchesKeyPlan.call(['id'], [{ key: 'id', guard: isString }]) // true
4959
+ * ```
4960
+ */
4961
+ export declare function matchesKeyPlan(this: readonly string[], plan: readonly KeyStep[]): boolean;
4962
+
4614
4963
  /**
4615
4964
  * Determines whether a repair `parse` made kept everything the value said.
4616
4965
  *
@@ -4623,7 +4972,7 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
4623
4972
  * Only a `type` fault is a repair. A number needs a string whose trim is the number's own
4624
4973
  * text, so `'30'` and `' 30 '` pass while `'30.0'`, `'007'`, `'0x10'`, `'1e3'`, `'+5'`,
4625
4974
  * `'.5'`, `'-0'`, and `'9007199254740993'` do not. A boolean needs `'true'` or `'false'`,
4626
- * a literal its trimmed text, and a string a finite number. Anything else refuses.
4975
+ * a literal its trimmed text, and a string a finite number other than `-0`. Anything else refuses.
4627
4976
  *
4628
4977
  * @param fault - A fault `audit` reported
4629
4978
  * @param input - The value as it arrived
@@ -4752,6 +5101,40 @@ export declare function matchesPattern(pattern: RegExp, value: string): boolean;
4752
5101
  */
4753
5102
  export declare function matchesRecordBrand(value: unknown): boolean;
4754
5103
 
5104
+ /**
5105
+ * Checks whether the member of the record bound as `this` passes a key-plan step's guard.
5106
+ *
5107
+ * @remarks
5108
+ * Passed with the record as the `thisArg` argument to the captured `every` member over a key plan, so the
5109
+ * walk reads each member once, in the plan's order, and stops at the first refusal.
5110
+ *
5111
+ * @param step - The step whose member to read and guard
5112
+ * @returns True if the member under the step's key passes its guard; false otherwise
5113
+ *
5114
+ * @example
5115
+ * ```ts
5116
+ * matchesStepGuard.call({ id: 'a' }, { key: 'id', guard: isString }) // true
5117
+ * ```
5118
+ */
5119
+ export declare function matchesStepGuard(this: Readonly<Record<string, unknown>>, step: KeyStep): boolean;
5120
+
5121
+ /**
5122
+ * Checks whether a key-plan step names the key at its index in the list bound as `this`.
5123
+ *
5124
+ * @remarks
5125
+ * Passed with the key list as the `thisArg` argument to the captured `every` member over a key plan.
5126
+ *
5127
+ * @param step - The step to compare
5128
+ * @param index - The step's position in its plan
5129
+ * @returns True if the step's key equals the bound list's key at that index; false otherwise
5130
+ *
5131
+ * @example
5132
+ * ```ts
5133
+ * matchesStepKey.call(['id'], { key: 'id', guard: isString }, 0) // true
5134
+ * ```
5135
+ */
5136
+ export declare function matchesStepKey(this: readonly string[], step: KeyStep, index: number): boolean;
5137
+
4755
5138
  /**
4756
5139
  * Checks whether a string's length in code points falls within optional bounds.
4757
5140
  *
@@ -5027,6 +5410,18 @@ export declare function objectOf<S extends GuardsShape>(shape: S, optional: true
5027
5410
  * the compiled reporter stays silent, mirroring that parser. `true` accepts
5028
5411
  * unknown keys as-is, and a `ContractShape` validates them, in every artifact.
5029
5412
  *
5413
+ * A closed object, and one whose `additionalProperties` is a `ContractShape`, also
5414
+ * refuses an own member outside the enumerable view: a non-enumerable string key or
5415
+ * a symbol key. The guard answers `false`; the auditor reports a declared such member
5416
+ * as `'hidden'` in place of `'missing'`, an undeclared one as `'extra'` when closed and
5417
+ * `'hidden'` under a tail shape, and each symbol key as `'extra'` at the object with
5418
+ * its preview in `symbol`. The parser and the reporter keep the enumerable view, so
5419
+ * `explain` reports `'missing'` where `audit` reports `'hidden'`. An object with
5420
+ * `additionalProperties: true` runs no own-key count: it admits an undeclared
5421
+ * non-enumerable or symbol member, while a declared member outside the enumerable
5422
+ * view still reads as absent, so `is` answers `false` for a required one and `audit`
5423
+ * and `explain` report it `'missing'`.
5424
+ *
5030
5425
  * The `A` parameter carries the open-value shape into {@link Infer}, so a constrained
5031
5426
  * tail keeps its type in the inferred index signature.
5032
5427
  */
@@ -5121,7 +5516,8 @@ export declare function omitVisited(visited: WeakSet<object>, value: object): vo
5121
5516
  * - **Guard**: accepts the value only when exactly one variant's guard
5122
5517
  * accepts it. A value matching two-or-more variants — which would violate
5123
5518
  * the emitted `oneOf` schema — is rejected, even though it would pass
5124
- * {@link unionShape}'s guard.
5519
+ * {@link unionShape}'s guard. A value that names one arm through a required
5520
+ * literal is answered by that arm's guard alone.
5125
5521
  * - **Parser**: judged on the RAW input's guard matches only, with NO
5126
5522
  * coercion fallback for an ambiguous input. When exactly one variant's
5127
5523
  * guard accepts the raw value, the input itself is returned. Zero matches or
@@ -5381,9 +5777,11 @@ export declare function parseBooleanField(record: Record<string, unknown>, path:
5381
5777
  * `parseEnum ↔ literalOf(...allowed)` pairing covers every literal primitive
5382
5778
  * (string, number, or boolean), not only strings. Matching is identity, never
5383
5779
  * cross-type coercion: `parseEnum('1', [1])` stays `undefined`. The allowed
5384
- * values are captured through their dense own-index view and copied into an
5385
- * owned `Set`; caller-defined iteration is ignored and unreadability returns
5386
- * `undefined` rather than escaping.
5780
+ * values are captured through their dense own-index view into a frozen snapshot
5781
+ * that one SameValueZero pass reads; caller-defined iteration is ignored and
5782
+ * unreadability returns `undefined` rather than escaping. A call costs one
5783
+ * snapshot and one pass over it, so a vocabulary checked often is cheaper
5784
+ * through a `literalOf` guard built once.
5387
5785
  *
5388
5786
  * @param value - The value to parse
5389
5787
  * @param allowed - The permitted literal values
@@ -5787,41 +6185,51 @@ export declare function pinMembers(prototype: object, owner: string): void;
5787
6185
  export declare const PRESENCE_MASK_LIMIT = 31;
5788
6186
 
5789
6187
  /**
5790
- * Renders an unknown value as a short, safe, TOTAL string for a {@link Fault}'s
5791
- * `received` field.
5792
- *
5793
- * @remarks
5794
- * A primitive renders as printable text: a string retains its quoted JSON
5795
- * representation, while a narrowed symbol renders through intrinsic `String`
5796
- * and receives the same escaping without outer quotes. A string of at most
5797
- * {@link PREVIEW_LIMIT} code units takes its answer from one whole-string
5798
- * encode when that encode fits the same limit, and the length predicate
5799
- * deciding it is exact rather than approximate. Every other string and every
5800
- * symbol renders through one bounded indexed encoder that appends only
5801
- * complete escaped code-point tokens within {@link PREVIEW_LIMIT}; clipping
5802
- * therefore never retrieves the mutable string iterator or splits an
5803
- * escape/surrogate pair before its trailing `…`, and enormous primitive text
5804
- * is not fully traversed. A number / boolean / bigint renders through `String`;
5805
- * `null` and `undefined` render as their own name. An array renders as
5806
- * `'array'`. Every other host — a plain object, a function, a class instance,
5807
- * a `Map` — is NEVER traversed or stringified; it renders as its bare
5808
- * `typeof` tag (`'object'` / `'function'`).
5809
- *
5810
- * The indexed encoder appends every token and closes with the quote exactly
5811
- * when the escaped inner length is at most `PREVIEW_LIMIT - 2`, which is
5812
- * character for character what one `JSON.stringify` call returns. At an inner
5813
- * length of `PREVIEW_LIMIT - 1` the indexed encoder appends every token and
5814
- * closes with `…` instead, while one `JSON.stringify` call over that same
5815
- * string measures `PREVIEW_LIMIT + 1` — so the predicate refuses that string
5816
- * and every longer one, and each of them renders through the indexed encoder.
5817
- * Escaping never shrinks text, so the leading `source.length` gate admits
5818
- * every string the predicate could accept while keeping enormous primitive
5819
- * text out of the whole-string encode. A symbol renders through the indexed
5820
- * encoder because its unquoted text is not what a `JSON.stringify` call
5821
- * returns.
6188
+ * Renders a value as a bounded single-line string for a {@link Fault}'s `received` field, running
6189
+ * a `Proxy` object's `getPrototypeOf` trap.
6190
+ *
6191
+ * @remarks
6192
+ * Every preview, its quotes and its `…` included, is at most
6193
+ * {@link PREVIEW_LIMIT} UTF-16 code units long and holds no control character
6194
+ * and no line terminator.
6195
+ *
6196
+ * A string renders as its quoted JSON representation, and a narrowed symbol
6197
+ * through intrinsic `String` with the same escaping and no outer quotes. DEL
6198
+ * (U+007F), the C1 controls (U+0080 to U+009F), U+2028, and U+2029, which a
6199
+ * `JSON.stringify` call leaves raw, render as `\u` sequences. A string of at
6200
+ * most {@link PREVIEW_LIMIT} UTF-16 code units that holds none of those raw
6201
+ * characters takes its answer from one whole-string encode when that encode
6202
+ * fits the same limit. Every other string and every symbol renders through one
6203
+ * bounded indexed encoder that appends only complete escaped code-point tokens,
6204
+ * at most `PREVIEW_LIMIT - 2` UTF-16 code units between a string's quotes and
6205
+ * `PREVIEW_LIMIT - 1` of a symbol, and then closes with the quote when every
6206
+ * token fit and with `…` otherwise. Clipping therefore never retrieves the
6207
+ * mutable string iterator or splits an escape or a surrogate pair, and
6208
+ * enormous primitive text is not fully traversed. The two paths agree: one
6209
+ * `JSON.stringify` call fits the limit exactly when the escaped inner length
6210
+ * is at most `PREVIEW_LIMIT - 2`, which is when the indexed encoder closes
6211
+ * with the quote.
6212
+ *
6213
+ * A number or a boolean renders through `String`. A bigint renders through
6214
+ * `String` with a trailing `n`; when its text reaches {@link PREVIEW_LIMIT}
6215
+ * UTF-16 code units, the preview keeps the leading `PREVIEW_LIMIT - 2`, then
6216
+ * `…`, then `n`. `null` and `undefined` render as their own name.
6217
+ *
6218
+ * An array renders as `'array'`, a function as `'function'`, a plain or
6219
+ * null-prototype record as `'object'`, and every other object, such as a class
6220
+ * instance, a `Map`, a `Date`, or a revoked `Proxy`, as `'instance'`. To tell a
6221
+ * record from an instance, the {@link isRecord} guard reads the object's
6222
+ * prototype, that prototype's prototype, and, when the second is `null`, the
6223
+ * first one's own property descriptors. A `Proxy` object's `getPrototypeOf`
6224
+ * trap therefore runs, and so do the `getPrototypeOf` and
6225
+ * `getOwnPropertyDescriptor` traps of a `Proxy` object that stands as the
6226
+ * prototype; a trap that throws yields `'instance'`. Every read is a prototype
6227
+ * or descriptor read, so no accessor on the object or its prototype runs, and
6228
+ * no object is stringified.
5822
6229
  *
5823
6230
  * @param value - The value to preview
5824
- * @returns A short descriptive string, always safe to embed in a diagnostic
6231
+ * @returns A string of at most {@link PREVIEW_LIMIT} UTF-16 code units with no
6232
+ * control character and no line terminator
5825
6233
  *
5826
6234
  * @example
5827
6235
  * ```ts
@@ -5829,27 +6237,35 @@ export declare const PRESENCE_MASK_LIMIT = 31;
5829
6237
  * preview(42) // '42'
5830
6238
  * preview(null) // 'null'
5831
6239
  * preview({ a: 1 }) // 'object'
6240
+ * preview(new Map()) // 'instance'
5832
6241
  * preview([1, 2, 3]) // 'array'
5833
6242
  * ```
5834
6243
  */
5835
6244
  export declare function preview(value: unknown): string;
5836
6245
 
5837
6246
  /**
5838
- * Caps at `64` the character length of a {@link preview}-rendered string, frozen.
6247
+ * Caps at `64` the length in UTF-16 code units of every {@link preview} result, frozen.
5839
6248
  *
5840
6249
  * @remarks
5841
- * A previewed string longer than this is clipped with a trailing `…` so a
6250
+ * The cap covers the whole preview, its quotes, its trailing `…`, and a
6251
+ * bigint's `n` included, for every input. A longer rendering is clipped with `…`, so a
5842
6252
  * {@link Fault}'s `received` field never embeds an unbounded amount of
5843
- * untrusted text.
6253
+ * untrusted text, and the {@link describeFaultLine} function prints it as
6254
+ * written.
5844
6255
  */
5845
6256
  export declare const PREVIEW_LIMIT = 64;
5846
6257
 
5847
6258
  /**
5848
6259
  * Builds bounded escaped preview parts without splitting a surrogate pair.
5849
6260
  *
6261
+ * @remarks
6262
+ * Each token is one code point's escape: its `JSON.stringify` form, or a `\u` sequence for DEL
6263
+ * (U+007F), a C1 control (U+0080 to U+009F), U+2028, or U+2029. The parts end with `…` when a
6264
+ * token does not fit, and otherwise with the closing quote of a quoted source.
6265
+ *
5850
6266
  * @param source - The source text
5851
6267
  * @param index - The next UTF-16 offset
5852
- * @param capacity - The unused preview width
6268
+ * @param capacity - The UTF-16 code units left for tokens; the closing quote or `…` takes one more
5853
6269
  * @param quoted - Whether the final part closes a string quote
5854
6270
  * @returns The escaped parts with their closing quote or truncation mark
5855
6271
  *
@@ -5927,28 +6343,18 @@ export declare function rawShape(schema: JSONSchema): RawShape;
5927
6343
  * Snapshots an array through its reflected own-index population.
5928
6344
  *
5929
6345
  * @remarks
5930
- * Reads `length` once and one reflected own-key population, then corroborates
5931
- * and reads only those reflected canonical indices in ascending order. The
5932
- * frozen native snapshot retains actual holes: reading one yields `undefined`,
5933
- * while own membership remains absent. Its work is proportional to the
5934
- * reflected population, so a length-driven consumer must require `dense` or
5935
- * carry an independent bound. A population that is exactly the canonical
5936
- * indices in ascending order followed by `length` is copied straight by index
5937
- * under the same per-index corroboration, and answers with the same entries,
5938
- * the same `dense` fact, and the same refusals as the walk. Caller-defined
5939
- * iteration is ignored. A descriptor-only index omitted from reflection is
5940
- * deliberately outside this lens and remains a hole. Failure retains the exact
5941
- * thrown value when length, reflection, membership, or indexed value
5942
- * observation throws; a non-native length or view disagreement is also
5943
- * failure. `4294967295` is metadata rather than an array index.
6346
+ * Answers what {@link collectArrayEntries} answers, as a frozen read whose
6347
+ * entries are frozen too. Failure retains the exact thrown value when length,
6348
+ * reflection, membership, or indexed value observation throws; a non-native
6349
+ * length or view disagreement is also failure.
5944
6350
  *
5945
6351
  * @param value - The array whose reflected indexed entries to read
5946
- * @returns A successful frozen entry snapshot with its dense fact, or a
5947
- * failure carrying the exact thrown value as `unknown`
6352
+ * @returns A successful frozen entry snapshot with its `dense` and `exact`
6353
+ * facts, or a failure carrying the exact thrown value as `unknown`
5948
6354
  *
5949
6355
  * @example
5950
6356
  * ```ts
5951
- * readArrayEntries([1, 2]) // { success: true, value: { entries: [1, 2], dense: true } }
6357
+ * readArrayEntries([1, 2]) // { success: true, value: { entries: [1, 2], dense: true, exact: true } }
5952
6358
  * ```
5953
6359
  */
5954
6360
  export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>>;
@@ -6111,6 +6517,11 @@ export declare function readPatternSource(pattern: unknown): string | undefined;
6111
6517
  /**
6112
6518
  * Derives the bit mask of names present in an indexed lookup.
6113
6519
  *
6520
+ * @remarks
6521
+ * Takes `names` as the array it declares and reads each present index once, in order,
6522
+ * through the captured fold, so a hole adds no bit. An array-like that is not an array
6523
+ * is outside this contract.
6524
+ *
6114
6525
  * @param names - Names to observe in order
6115
6526
  * @param positions - The bit position of each declared name
6116
6527
  * @returns The combined signed 32-bit mask
@@ -6320,10 +6731,12 @@ export declare function refuseOptionKeys(source: object | undefined, keys: reado
6320
6731
  *
6321
6732
  * @remarks
6322
6733
  * An object lists its required keys first and marks the rest with `?`, at most `FAULT_LIST_LIMIT`
6323
- * of them. A leaf or array keeps its numeric bounds and pattern, a union joins its forms with ` | `,
6734
+ * of them. A leaf or array keeps its numeric bounds, pattern, and format, a union joins its forms with ` | `,
6324
6735
  * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and
6325
6736
  * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past
6326
6737
  * `room` is cut and closes with `…`. A type word outside JSON Schema's vocabulary is encoded.
6738
+ * A schema with an own `not` reads `function` when its `format` is `'function'` and `never`
6739
+ * otherwise.
6327
6740
  *
6328
6741
  * @param schema - The schema to summarize
6329
6742
  * @param room - The characters the summary can take. Default: `FAULT_SCHEMA_LIMIT`
@@ -6374,6 +6787,28 @@ export declare function renderList(entries: readonly string[]): string;
6374
6787
  */
6375
6788
  export declare function renderPath(path: readonly string[]): string;
6376
6789
 
6790
+ /**
6791
+ * Repairs a stable readable value with only lossless repairs and returns the parser's value.
6792
+ *
6793
+ * @remarks
6794
+ * Reads must remain stable across artifacts. Guard-valid input skips both reports and parses
6795
+ * once. Repairs use audit, parse once, and explain only on parse failure. Unresolved unions,
6796
+ * extras, lossy repairs, and a capped audit refuse. An own optional undefined field omitted or
6797
+ * filled by its declared default is not a repair. The merge of explain and audit faults keys on
6798
+ * reason and path, and keeps every `extra` fault carrying `symbol`, so two symbol keys of
6799
+ * one description stay two faults. The result preserves parser ownership, including union input identity.
6800
+ * A read failure returns its cause rather than throwing.
6801
+ * Snapshot a foreign object before repair, as Tool.execute does. A getter changing between
6802
+ * is and parse can publish a value that no recorded repair describes. A shallow snapshot only
6803
+ * stabilizes its own level; nested foreign values must also provide stable reads.
6804
+ *
6805
+ * @example
6806
+ * ```ts
6807
+ * repairValue(createContract(numberShape()), '3') // success carrying 3 and its type repair
6808
+ * ```
6809
+ */
6810
+ export declare function repairValue<T>(contract: ContractInterface<T>, value: unknown): Result<ContractRepair<T>, ContractRefusal>;
6811
+
6377
6812
  /**
6378
6813
  * Represents a compiled coercive-domain diagnostic — the shape of
6379
6814
  * `compileReporter` bound to one shape.
@@ -6510,7 +6945,10 @@ export declare function samplesToFormat(values: readonly unknown[]): SchemaForma
6510
6945
  * An empty `samples` array infers the empty accept-anything schema `{}`.
6511
6946
  * When every sample is a plain record, properties/required are unified
6512
6947
  * per-key across all samples — a key
6513
- * required iff present and non-`undefined` in every sample. Otherwise the
6948
+ * required iff present and non-`undefined` in every sample. The unified object
6949
+ * stays open whatever `closed` says when the key union is truncated, or when any
6950
+ * sample holds a member that is `undefined`, a non-enumerable string key, or a
6951
+ * symbol key. When any sample is not a plain record, the
6514
6952
  * slot is inferred one value at a time (independent {@link valueToSchema}
6515
6953
  * per sample, unified with {@link unifySchemas} — the same de-duplication and
6516
6954
  * `anyOf` ordering an array's element schemas receive). `format`
@@ -6598,6 +7036,22 @@ export declare function sanitizeBudget(value: number | undefined, fallback: numb
6598
7036
  */
6599
7037
  export declare function sanitizeDepth(value: number | undefined): number;
6600
7038
 
7039
+ /**
7040
+ * Lists the JSON Schema annotations a strict `schemaToShape` conversion admits on any node, frozen.
7041
+ *
7042
+ * @remarks
7043
+ * Each asserts nothing about a value, so a converted shape drops it without loss, except
7044
+ * `description`, which the shape keeps. A strict conversion admits them beside every
7045
+ * keyword it reads, the function leaf `{ not: {}, format: 'function' }` included.
7046
+ *
7047
+ * @example
7048
+ * ```ts
7049
+ * SCHEMA_ANNOTATIONS.includes('title') // true
7050
+ * SCHEMA_ANNOTATIONS.at(-1) // 'examples'
7051
+ * ```
7052
+ */
7053
+ export declare const SCHEMA_ANNOTATIONS: readonly ["title", "description", "$schema", "$id", "$comment", "deprecated", "readOnly", "writeOnly", "examples"];
7054
+
6601
7055
  /**
6602
7056
  * Owns the state of one JSON Schema snapshot operation.
6603
7057
  *
@@ -6804,15 +7258,21 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
6804
7258
  *
6805
7259
  * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with
6806
7260
  * code `structure`, every node the lenient walk would widen, every keyword it
6807
- * would ignore (`pattern`, `format`, `nullable`, `patternProperties`,
6808
- * `propertyNames`, `prefixItems`, and anything else outside
7261
+ * would ignore (`pattern`, every `format` but `'date'` on a string node and `'function'` in
7262
+ * the function leaf, every `not` outside that leaf, `nullable`,
7263
+ * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside
6809
7264
  * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry
6810
- * that is neither a finite primitive nor `null`, a contradictory bound, a `required` name not in
7265
+ * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose
7266
+ * length bounds exclude length 10, a `required` name not in
6811
7267
  * `properties`, breadth past {@link INFER_BREADTH_LIMIT}, and a `default` with no
6812
7268
  * optional property to fill. An object with no `additionalProperties` closes
6813
7269
  * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads
6814
7270
  * every keyword that could keep two arms apart. Below a `oneOf` that object refuses
6815
- * instead, since closing it could change which arms match.
7271
+ * instead, since closing it could change which arms match. A strict conversion is the
7272
+ * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a
7273
+ * date string shape, so a compiled {@link dateShape} round-trips, and it reads the function
7274
+ * leaf `{ not: {}, format: 'function' }` back as {@link functionShape}, so a compiled
7275
+ * function shape round-trips too.
6816
7276
  *
6817
7277
  * @param schema - The JSON Schema value to convert
6818
7278
  * @param options - Optional `strict`, default `false`
@@ -7078,9 +7538,11 @@ export declare interface ShapeShapeOptions {
7078
7538
  * A structural mapping used by {@link compileReporter} to fill a `Fault`'s
7079
7539
  * `expected` field and by {@link compileAuditor} to fill an `AuditFault`'s:
7080
7540
  * most shapes map to their own `category` (`numberShape` maps to
7081
- * `'integer'` when `integer: true`, else `'number'`); `optionalShape` /
7541
+ * `'integer'` when `integer: true`, else `'number'`, and `stringShape` maps to
7542
+ * `'date'` when `date: true`, else `'string'`); `optionalShape` /
7082
7543
  * `nullableShape` project through to their inner shape's kind, and `rawShape`
7083
7544
  * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.
7545
+ * `functionShape` projects to `'function'`.
7084
7546
  *
7085
7547
  * A hand-authored node carrying an unrecognized discriminant is REFUSED rather
7086
7548
  * than answered out of type, which keeps the declared non-optional
@@ -7217,11 +7679,12 @@ export declare function sortValues<T extends string | number>(values: readonly T
7217
7679
  * Lists the JSON Schema keywords a strict `schemaToShape` conversion reads, frozen.
7218
7680
  *
7219
7681
  * @remarks
7220
- * The keywords a shape can honour, plus the annotations that assert nothing and so
7221
- * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,
7222
- * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.
7223
- * `pattern` and `format` are absent because no compiled shape asserts them, so a
7224
- * schema holding one would convert to a shape wider than the schema it came from.
7682
+ * The keywords a shape can honour, plus {@link SCHEMA_ANNOTATIONS}. Every other keyword
7683
+ * refuses. `pattern`, `format`, and `not` are absent because no compiled shape asserts
7684
+ * them, so a schema holding one would convert to a shape wider than the schema it came
7685
+ * from. The exceptions are `format: 'date'` on a string node, which a strict conversion
7686
+ * reads as a date string shape, and the function leaf `{ not: {}, format: 'function' }`,
7687
+ * which it reads as a function shape.
7225
7688
  *
7226
7689
  * @example
7227
7690
  * ```ts
@@ -7250,9 +7713,9 @@ export declare const STRING_LIMIT = 65536;
7250
7713
  *
7251
7714
  * @remarks
7252
7715
  * The refinement half of {@link StringShapeOptions}: the same `min`, `max`, and
7253
- * `pattern` members, without the `description` a shape carries for its emitted
7254
- * schema. A guard publishes no description, so the two surfaces share the
7255
- * refinements and nothing else.
7716
+ * `pattern` members, without the `date` flag and the `description` a shape
7717
+ * carries for its emitted schema. A compiled date shape composes this guard with
7718
+ * {@link matchesCalendarDate}.
7256
7719
  */
7257
7720
  export declare interface StringGuardOptions {
7258
7721
  readonly min?: number;
@@ -7290,11 +7753,13 @@ export declare interface StringGuardOptions {
7290
7753
  export declare function stringOf(options?: StringGuardOptions): Guard<string>;
7291
7754
 
7292
7755
  /**
7293
- * Describes a string with optional length and pattern constraints.
7756
+ * Describes a string with optional length, pattern, and calendar-date constraints.
7294
7757
  *
7295
7758
  * @remarks
7296
7759
  * `min` and `max` count code points, as the `minLength` and `maxLength` the shape
7297
- * emits do, so one astral character has a length of one.
7760
+ * emits do, so one astral character has a length of one. `date` restricts the string
7761
+ * to a calendar-valid `YYYY-MM-DD` and emits `format: 'date'`; a shape that declares
7762
+ * `date` declares no `pattern`.
7298
7763
  */
7299
7764
  export declare interface StringShape {
7300
7765
  readonly category: 'string';
@@ -7305,6 +7770,7 @@ export declare interface StringShape {
7305
7770
  * Builders and cloners expose an owned fresh frozen zero-state copy per read.
7306
7771
  */
7307
7772
  readonly pattern?: RegExp;
7773
+ readonly date?: boolean;
7308
7774
  readonly description?: string;
7309
7775
  }
7310
7776
 
@@ -7315,10 +7781,12 @@ export declare interface StringShape {
7315
7781
  * A supplied pattern is captured by source and flags. The shape exposes a fresh
7316
7782
  * frozen zero-state `RegExp` on every `pattern` read, so neither the caller's
7317
7783
  * original nor a value read from the shape can drift later compiled artifacts.
7784
+ * `date: true` restricts the string to a calendar-valid `YYYY-MM-DD`, as
7785
+ * {@link dateShape} builds it.
7318
7786
  *
7319
- * @param options - Optional length (`min` / `max`), `pattern`, and `description`
7787
+ * @param options - Optional length (`min` / `max`), `pattern`, `date`, and `description`
7320
7788
  * @returns A string shape
7321
- * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, or `pattern` has flags
7789
+ * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, `pattern` has flags, `date` is not a boolean, or `date` meets `pattern` or a bound that excludes length 10
7322
7790
  *
7323
7791
  * @example
7324
7792
  * ```ts
@@ -7332,6 +7800,7 @@ export declare interface StringShapeOptions {
7332
7800
  readonly min?: number;
7333
7801
  readonly max?: number;
7334
7802
  readonly pattern?: RegExp;
7803
+ readonly date?: boolean;
7335
7804
  readonly description?: string;
7336
7805
  }
7337
7806
 
@@ -7530,7 +7999,10 @@ export declare function unionOf(...predicates: ReadonlyArray<(value: unknown) =>
7530
7999
  * @remarks
7531
8000
  * `mode` selects the emitted JSON Schema keyword and runtime matching rule:
7532
8001
  * `'anyOf'` (default) accepts the first matching variant, while `'oneOf'`
7533
- * requires exactly one variant to match.
8002
+ * requires exactly one variant to match. When every variant is an object
8003
+ * declaring one required literal property and a value's own data property
8004
+ * equals a literal only one variant holds, that variant answers alone in both
8005
+ * modes, at the guard as at the parser, the auditor, and the reporter.
7534
8006
  */
7535
8007
  export declare interface UnionShape<V extends readonly ContractShape[] = readonly ContractShape[]> {
7536
8008
  readonly category: 'union';
@@ -7545,9 +8017,9 @@ export declare interface UnionShape<V extends readonly ContractShape[] = readonl
7545
8017
  * @remarks
7546
8018
  * When every arm is an object declaring one required literal property, and a value's
7547
8019
  * own property exactly equals a literal only one arm holds, that arm answers: `explain`
7548
- * and `audit` report its faults at their real paths, and `parse` repairs through it
7549
- * alone. Any other value reports `variant`, with `key` and `expected` saying what would
7550
- * have named an arm. `is` does not change.
8020
+ * and `audit` report its faults at their real paths, `parse` repairs through it
8021
+ * alone, and `is` answers from it alone. Any other value reports `variant`, with `key`
8022
+ * and `expected` saying what would have named an arm.
7551
8023
  *
7552
8024
  * @param variants - The candidate shapes; the first match wins at runtime
7553
8025
  * @returns A union shape whose `Infer` is the union of the variants
@@ -7625,7 +8097,11 @@ export declare function validateShape(shape: unknown): void;
7625
8097
  * throws a `structure`
7626
8098
  * {@link ContractError}; it never becomes `{}` or another permissive schema. Nested
7627
8099
  * objects close to unknown keys (`additionalProperties: false`) by default;
7628
- * pass `closed: false` to open them. `format` (default `false`) opts a
8100
+ * pass `closed: false` to open them. A record whose sampled keys are not every
8101
+ * key it owns stays open whatever `closed` says: one truncated by the breadth
8102
+ * budget, one holding a member that is `undefined`, and one holding a
8103
+ * non-enumerable string key or a symbol key, because a closed schema would refuse
8104
+ * the record it was inferred from. `format` (default `false`) opts a
7629
8105
  * string/`Date` leaf into the `format` keyword. Structurally-equal inputs
7630
8106
  * infer byte-identical schemas (object keys and `anyOf` members are sorted).
7631
8107
  *