@orkestrel/contract 0.0.23 → 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
  *
@@ -588,7 +626,9 @@ export declare const CLONE_NODE_LIMIT = 262144;
588
626
  *
589
627
  * @param value - The unknown record value to validate and snapshot
590
628
  * @returns A deeply cloned and frozen JSON record
591
- * @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
592
632
  *
593
633
  * @example
594
634
  * ```ts
@@ -616,7 +656,10 @@ export declare function cloneJSONRecord(value: unknown): JSONRecord;
616
656
  *
617
657
  * @param value - The unknown value to validate and snapshot
618
658
  * @returns The primitive unchanged, or a deeply cloned and frozen JSON graph
619
- * @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
620
663
  *
621
664
  * @example
622
665
  * ```ts
@@ -694,6 +737,38 @@ export declare function cloneShape(shape: StringShape): StringShape;
694
737
 
695
738
  export declare function cloneShape(shape: ContractShape): ContractShape;
696
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
+
697
772
  /**
698
773
  * Builds the collector a captured `forEach` sweep appends through.
699
774
  *
@@ -909,7 +984,12 @@ export declare function compileGenerator(shape: ContractShape, random?: RandomFu
909
984
  * observe own enumerable string keys through {@link enumerableKeys}, the same
910
985
  * key view their parser, reporter, auditor, and inference use for both open and
911
986
  * closed objects — the view is shared, the verdict on an undeclared key is not
912
- * (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.
913
993
  * Like every guard it is total — it never throws, as `.claude/rules/patterns.md`
914
994
  * § Validation and contracts requires. It requests
915
995
  * exactly the `guard` root of a fresh {@link ContractCompiler}, which owns the
@@ -1202,22 +1282,6 @@ export declare const CONTRACT_CODES: readonly ContractCode[];
1202
1282
  */
1203
1283
  export declare const CONTRACT_ERROR_BRAND: unique symbol;
1204
1284
 
1205
- /**
1206
- * Carries an admitted value and the lossless repairs made while parsing it.
1207
- *
1208
- * @remarks
1209
- * The value keeps the parser's ownership: a union may return the caller's input by identity.
1210
- *
1211
- * @example
1212
- * ```ts
1213
- * const admitted: ContractAdmission<number> = { value: 3, repairs: [] }
1214
- * ```
1215
- */
1216
- export declare interface ContractAdmission<T> {
1217
- readonly value: T;
1218
- readonly repairs: readonly AuditFault[];
1219
- }
1220
-
1221
1285
  /**
1222
1286
  * Names the machine-readable category carried by a {@link ContractError}.
1223
1287
  *
@@ -1528,7 +1592,10 @@ export declare interface ContractInterface<T> {
1528
1592
  * stable across calls (see the read-stability precondition on
1529
1593
  * {@link ContractInterface}). It is the report for the stricter of the two
1530
1594
  * domains, so a coercible leaf and a closed object's undeclared key both
1531
- * 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'`.
1532
1599
  *
1533
1600
  * @param value - The value to check
1534
1601
  * @returns The faults found, empty when the value is strictly valid
@@ -1577,6 +1644,22 @@ export declare interface ContractRefusal {
1577
1644
  readonly cause?: unknown;
1578
1645
  }
1579
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
+
1580
1663
  /**
1581
1664
  * Describes a value declaratively — a declaration the shape builders build and
1582
1665
  * the compilers turn into a guard, a parser, a JSON Schema, and a generator.
@@ -1586,7 +1669,7 @@ export declare interface ContractRefusal {
1586
1669
  * element shape, an `ObjectShape` a map of them). {@link validateShape}
1587
1670
  * enforces an acyclic graph within {@link COMPILE_DEPTH_LIMIT}.
1588
1671
  */
1589
- 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;
1590
1673
 
1591
1674
  /**
1592
1675
  * Compiles a {@link ContractShape} into a {@link ContractInterface} — the
@@ -1740,8 +1823,10 @@ export declare function deriveRangeBounds(min: unknown, max: unknown): BoundsRea
1740
1823
  * says.
1741
1824
  *
1742
1825
  * @remarks
1743
- * Each line opens with the fault's path (or `value` at the root) and reason. An `extra` fault lists
1744
- * 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
1745
1830
  * the declarations agree; lists are deduplicated and bounded. A received preview stays as written
1746
1831
  * within PREVIEW_LIMIT and without control or line-separator characters; otherwise it is encoded
1747
1832
  * through preview. Received, constraint, and limit details read only own fields. A `variant` or
@@ -2024,15 +2109,18 @@ export declare function extractPath(fault: AuditFault): readonly string[];
2024
2109
  export declare function extractSchema(schema: JSONSchema, path: readonly string[]): JSONSchema | undefined;
2025
2110
 
2026
2111
  /**
2027
- * 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.
2028
2114
  *
2029
2115
  * @remarks
2030
- * The final path segment is the offending key, and no value is read or carried — an
2031
- * 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.
2032
2119
  */
2033
2120
  export declare interface ExtraFault {
2034
2121
  readonly reason: 'extra';
2035
2122
  readonly path: FieldPath;
2123
+ readonly symbol?: string;
2036
2124
  }
2037
2125
 
2038
2126
  /**
@@ -2173,9 +2261,9 @@ export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'inte
2173
2261
  *
2174
2262
  * @remarks
2175
2263
  * The vocabulary is `'string'`, `'date'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2176
- * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, and `'shape'`.
2264
+ * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, `'shape'`, and `'function'`.
2177
2265
  */
2178
- export declare type FaultKind = 'string' | 'date' | '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';
2179
2267
 
2180
2268
  /**
2181
2269
  * Retains a lazily built fault declaration without building shapes during module evaluation.
@@ -2236,6 +2324,13 @@ declare class FaultShaper {
2236
2324
  }, false>, ObjectShape< {
2237
2325
  reason: LiteralShape<readonly ["extra"]>;
2238
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>]>;
2239
2334
  }, false>]>;
2240
2335
  }
2241
2336
 
@@ -2266,6 +2361,28 @@ export declare interface FaultTextOptions {
2266
2361
  */
2267
2362
  export declare type FieldPath = string | readonly string[];
2268
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
+
2269
2386
  /**
2270
2387
  * Caps at `128` the string length {@link stringToFormat} attempts to classify, frozen.
2271
2388
  *
@@ -2295,6 +2412,60 @@ export declare type FromGuards<G extends GuardsShape> = Readonly<{
2295
2412
  [K in keyof G]: GuardType<G[K]>;
2296
2413
  }>;
2297
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
+
2298
2469
  /**
2299
2470
  * Caps at `32` the number of candidate-generation attempts for a constrained generated
2300
2471
  * value, frozen.
@@ -2362,6 +2533,20 @@ export declare type GuardsShape = Readonly<Record<string, Guard<unknown>>>;
2362
2533
  /** Extracts the guarded type `T` from a `Guard<T>`. */
2363
2534
  export declare type GuardType<G> = G extends Guard<infer T> ? T : never;
2364
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
+
2365
2550
  /**
2366
2551
  * Invokes a predicate through the sanctioned never-throw boundary.
2367
2552
  *
@@ -2405,7 +2590,7 @@ export declare function holds(callback: () => boolean): boolean;
2405
2590
  * nesting. {@link InferIndex} and {@link InferOpenIndex} apply the identical
2406
2591
  * tuple guard to their own `A` parameter for the same reason.
2407
2592
  */
2408
- 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 {
2409
2594
  readonly category: 'literal';
2410
2595
  readonly values: infer V;
2411
2596
  } ? V extends ReadonlyArray<infer L> ? L : never : S extends {
@@ -2758,6 +2943,8 @@ export declare const INTRINSICS: Readonly<{
2758
2943
  prototype: (o: any) => any;
2759
2944
  /** Captures `Object.getOwnPropertySymbols` — the own-symbol population. */
2760
2945
  symbols: (o: any) => symbol[];
2946
+ /** Captures `Object.getOwnPropertyNames` — the own string-key population, enumerable or not. */
2947
+ names: (o: any) => string[];
2761
2948
  /** Captures `Object.prototype` — the realm-local plain-record prototype identity. */
2762
2949
  base: Object;
2763
2950
  /**
@@ -2848,6 +3035,11 @@ export declare const INTRINSICS: Readonly<{
2848
3035
  order: (compareFn?: ((a: any, b: any) => number) | undefined) => any[];
2849
3036
  /** Captures `Array.prototype.some` for short-circuit membership checks. */
2850
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
+ };
2851
3043
  /** Captures `Array.prototype.findIndex`, including reads of sparse positions. */
2852
3044
  find: (predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any) => number;
2853
3045
  /** Captures `Array.prototype.forEach` for indexed visits of owned arrays. */
@@ -3040,15 +3232,19 @@ export declare function isAsyncIterable<T = unknown>(value: unknown): value is A
3040
3232
  * Determines whether a value is exactly one {@link AuditFault}.
3041
3233
  *
3042
3234
  * @remarks
3043
- * 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`.
3044
3238
  *
3045
3239
  * @param value - The value to inspect
3046
3240
  * @returns True if the value is a well-formed audit fault; false otherwise
3047
3241
  *
3048
3242
  * @example
3049
3243
  * ```ts
3050
- * isAuditFault({ reason: 'extra', path: ['a'] }) // true
3051
- * 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
3052
3248
  * ```
3053
3249
  */
3054
3250
  export declare function isAuditFault(value: unknown): value is AuditFault;
@@ -4296,9 +4492,11 @@ export declare type JSONRecord = {
4296
4492
  *
4297
4493
  * @remarks
4298
4494
  * Intentionally lean (not the full ~50-keyword vocabulary): it carries only the
4299
- * keywords {@link Infer}-driven `compileSchema` produces, plus `format` —
4300
- * emitted by the {@link stringToFormat} / {@link samplesToFormat} inference
4301
- * 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.
4302
4500
  * Recursive through `items` / `properties` / `additionalProperties` / `anyOf` /
4303
4501
  * `oneOf`. {@link createContract} owns and validates developer-authored shape
4304
4502
  * graphs; cycles and nesting past {@link COMPILE_DEPTH_LIMIT} fail with a coded
@@ -4323,6 +4521,7 @@ export declare interface JSONSchema {
4323
4521
  readonly additionalProperties?: boolean | JSONSchema;
4324
4522
  readonly anyOf?: readonly JSONSchema[];
4325
4523
  readonly oneOf?: readonly JSONSchema[];
4524
+ readonly not?: JSONSchema;
4326
4525
  }
4327
4526
 
4328
4527
  /** Lists the seven standard JSON Schema `type` names. */
@@ -4387,6 +4586,26 @@ export declare interface JSONShapeOptions {
4387
4586
  */
4388
4587
  export declare type JSONValue = JSONPrimitive | readonly JSONValue[] | JSONRecord;
4389
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
+
4390
4609
  /**
4391
4610
  * Builds a guard that accepts values that are own keys of the provided object.
4392
4611
  *
@@ -4409,6 +4628,22 @@ export declare type JSONValue = JSONPrimitive | readonly JSONValue[] | JSONRecor
4409
4628
  */
4410
4629
  export declare function keyOf<const O extends Readonly<Record<PropertyKey, unknown>>>(value: O): Guard<keyof O>;
4411
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
+
4412
4647
  /**
4413
4648
  * Defers guard creation until first use by calling `thunk()` on every
4414
4649
  * invocation.
@@ -4570,6 +4805,27 @@ export declare function mapOf(keyPredicate: (value: unknown) => boolean, valuePr
4570
4805
  */
4571
4806
  export declare function matchesCalendarDate(value: string): boolean;
4572
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
+
4573
4829
  /**
4574
4830
  * Determines whether an object holds exactly the named own keys.
4575
4831
  *
@@ -4686,6 +4942,24 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
4686
4942
  left: number;
4687
4943
  }): entry is JSONValue;
4688
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
+
4689
4963
  /**
4690
4964
  * Determines whether a repair `parse` made kept everything the value said.
4691
4965
  *
@@ -4698,7 +4972,7 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
4698
4972
  * Only a `type` fault is a repair. A number needs a string whose trim is the number's own
4699
4973
  * text, so `'30'` and `' 30 '` pass while `'30.0'`, `'007'`, `'0x10'`, `'1e3'`, `'+5'`,
4700
4974
  * `'.5'`, `'-0'`, and `'9007199254740993'` do not. A boolean needs `'true'` or `'false'`,
4701
- * 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.
4702
4976
  *
4703
4977
  * @param fault - A fault `audit` reported
4704
4978
  * @param input - The value as it arrived
@@ -4827,6 +5101,40 @@ export declare function matchesPattern(pattern: RegExp, value: string): boolean;
4827
5101
  */
4828
5102
  export declare function matchesRecordBrand(value: unknown): boolean;
4829
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
+
4830
5138
  /**
4831
5139
  * Checks whether a string's length in code points falls within optional bounds.
4832
5140
  *
@@ -5102,6 +5410,18 @@ export declare function objectOf<S extends GuardsShape>(shape: S, optional: true
5102
5410
  * the compiled reporter stays silent, mirroring that parser. `true` accepts
5103
5411
  * unknown keys as-is, and a `ContractShape` validates them, in every artifact.
5104
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
+ *
5105
5425
  * The `A` parameter carries the open-value shape into {@link Infer}, so a constrained
5106
5426
  * tail keeps its type in the inferred index signature.
5107
5427
  */
@@ -5196,7 +5516,8 @@ export declare function omitVisited(visited: WeakSet<object>, value: object): vo
5196
5516
  * - **Guard**: accepts the value only when exactly one variant's guard
5197
5517
  * accepts it. A value matching two-or-more variants — which would violate
5198
5518
  * the emitted `oneOf` schema — is rejected, even though it would pass
5199
- * {@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.
5200
5521
  * - **Parser**: judged on the RAW input's guard matches only, with NO
5201
5522
  * coercion fallback for an ambiguous input. When exactly one variant's
5202
5523
  * guard accepts the raw value, the input itself is returned. Zero matches or
@@ -5456,9 +5777,11 @@ export declare function parseBooleanField(record: Record<string, unknown>, path:
5456
5777
  * `parseEnum ↔ literalOf(...allowed)` pairing covers every literal primitive
5457
5778
  * (string, number, or boolean), not only strings. Matching is identity, never
5458
5779
  * cross-type coercion: `parseEnum('1', [1])` stays `undefined`. The allowed
5459
- * values are captured through their dense own-index view and copied into an
5460
- * owned `Set`; caller-defined iteration is ignored and unreadability returns
5461
- * `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.
5462
5785
  *
5463
5786
  * @param value - The value to parse
5464
5787
  * @param allowed - The permitted literal values
@@ -5862,41 +6185,51 @@ export declare function pinMembers(prototype: object, owner: string): void;
5862
6185
  export declare const PRESENCE_MASK_LIMIT = 31;
5863
6186
 
5864
6187
  /**
5865
- * Renders an unknown value as a short, safe, TOTAL string for a {@link Fault}'s
5866
- * `received` field.
5867
- *
5868
- * @remarks
5869
- * A primitive renders as printable text: a string retains its quoted JSON
5870
- * representation, while a narrowed symbol renders through intrinsic `String`
5871
- * and receives the same escaping without outer quotes. A string of at most
5872
- * {@link PREVIEW_LIMIT} code units takes its answer from one whole-string
5873
- * encode when that encode fits the same limit, and the length predicate
5874
- * deciding it is exact rather than approximate. Every other string and every
5875
- * symbol renders through one bounded indexed encoder that appends only
5876
- * complete escaped code-point tokens within {@link PREVIEW_LIMIT}; clipping
5877
- * therefore never retrieves the mutable string iterator or splits an
5878
- * escape/surrogate pair before its trailing `…`, and enormous primitive text
5879
- * is not fully traversed. A number / boolean / bigint renders through `String`;
5880
- * `null` and `undefined` render as their own name. An array renders as
5881
- * `'array'`. Every other host — a plain object, a function, a class instance,
5882
- * a `Map` — is NEVER traversed or stringified; it renders as its bare
5883
- * `typeof` tag (`'object'` / `'function'`).
5884
- *
5885
- * The indexed encoder appends every token and closes with the quote exactly
5886
- * when the escaped inner length is at most `PREVIEW_LIMIT - 2`, which is
5887
- * character for character what one `JSON.stringify` call returns. At an inner
5888
- * length of `PREVIEW_LIMIT - 1` the indexed encoder appends every token and
5889
- * closes with `…` instead, while one `JSON.stringify` call over that same
5890
- * string measures `PREVIEW_LIMIT + 1` — so the predicate refuses that string
5891
- * and every longer one, and each of them renders through the indexed encoder.
5892
- * Escaping never shrinks text, so the leading `source.length` gate admits
5893
- * every string the predicate could accept while keeping enormous primitive
5894
- * text out of the whole-string encode. A symbol renders through the indexed
5895
- * encoder because its unquoted text is not what a `JSON.stringify` call
5896
- * 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.
5897
6229
  *
5898
6230
  * @param value - The value to preview
5899
- * @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
5900
6233
  *
5901
6234
  * @example
5902
6235
  * ```ts
@@ -5904,27 +6237,35 @@ export declare const PRESENCE_MASK_LIMIT = 31;
5904
6237
  * preview(42) // '42'
5905
6238
  * preview(null) // 'null'
5906
6239
  * preview({ a: 1 }) // 'object'
6240
+ * preview(new Map()) // 'instance'
5907
6241
  * preview([1, 2, 3]) // 'array'
5908
6242
  * ```
5909
6243
  */
5910
6244
  export declare function preview(value: unknown): string;
5911
6245
 
5912
6246
  /**
5913
- * 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.
5914
6248
  *
5915
6249
  * @remarks
5916
- * 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
5917
6252
  * {@link Fault}'s `received` field never embeds an unbounded amount of
5918
- * untrusted text.
6253
+ * untrusted text, and the {@link describeFaultLine} function prints it as
6254
+ * written.
5919
6255
  */
5920
6256
  export declare const PREVIEW_LIMIT = 64;
5921
6257
 
5922
6258
  /**
5923
6259
  * Builds bounded escaped preview parts without splitting a surrogate pair.
5924
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
+ *
5925
6266
  * @param source - The source text
5926
6267
  * @param index - The next UTF-16 offset
5927
- * @param capacity - The unused preview width
6268
+ * @param capacity - The UTF-16 code units left for tokens; the closing quote or `…` takes one more
5928
6269
  * @param quoted - Whether the final part closes a string quote
5929
6270
  * @returns The escaped parts with their closing quote or truncation mark
5930
6271
  *
@@ -6002,28 +6343,18 @@ export declare function rawShape(schema: JSONSchema): RawShape;
6002
6343
  * Snapshots an array through its reflected own-index population.
6003
6344
  *
6004
6345
  * @remarks
6005
- * Reads `length` once and one reflected own-key population, then corroborates
6006
- * and reads only those reflected canonical indices in ascending order. The
6007
- * frozen native snapshot retains actual holes: reading one yields `undefined`,
6008
- * while own membership remains absent. Its work is proportional to the
6009
- * reflected population, so a length-driven consumer must require `dense` or
6010
- * carry an independent bound. A population that is exactly the canonical
6011
- * indices in ascending order followed by `length` is copied straight by index
6012
- * under the same per-index corroboration, and answers with the same entries,
6013
- * the same `dense` fact, and the same refusals as the walk. Caller-defined
6014
- * iteration is ignored. A descriptor-only index omitted from reflection is
6015
- * deliberately outside this lens and remains a hole. Failure retains the exact
6016
- * thrown value when length, reflection, membership, or indexed value
6017
- * observation throws; a non-native length or view disagreement is also
6018
- * 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.
6019
6350
  *
6020
6351
  * @param value - The array whose reflected indexed entries to read
6021
- * @returns A successful frozen entry snapshot with its dense fact, or a
6022
- * 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`
6023
6354
  *
6024
6355
  * @example
6025
6356
  * ```ts
6026
- * 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 } }
6027
6358
  * ```
6028
6359
  */
6029
6360
  export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>>;
@@ -6186,6 +6517,11 @@ export declare function readPatternSource(pattern: unknown): string | undefined;
6186
6517
  /**
6187
6518
  * Derives the bit mask of names present in an indexed lookup.
6188
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
+ *
6189
6525
  * @param names - Names to observe in order
6190
6526
  * @param positions - The bit position of each declared name
6191
6527
  * @returns The combined signed 32-bit mask
@@ -6399,6 +6735,8 @@ export declare function refuseOptionKeys(source: object | undefined, keys: reado
6399
6735
  * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and
6400
6736
  * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past
6401
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.
6402
6740
  *
6403
6741
  * @param schema - The schema to summarize
6404
6742
  * @param room - The characters the summary can take. Default: `FAULT_SCHEMA_LIMIT`
@@ -6449,6 +6787,28 @@ export declare function renderList(entries: readonly string[]): string;
6449
6787
  */
6450
6788
  export declare function renderPath(path: readonly string[]): string;
6451
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
+
6452
6812
  /**
6453
6813
  * Represents a compiled coercive-domain diagnostic — the shape of
6454
6814
  * `compileReporter` bound to one shape.
@@ -6585,7 +6945,10 @@ export declare function samplesToFormat(values: readonly unknown[]): SchemaForma
6585
6945
  * An empty `samples` array infers the empty accept-anything schema `{}`.
6586
6946
  * When every sample is a plain record, properties/required are unified
6587
6947
  * per-key across all samples — a key
6588
- * 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
6589
6952
  * slot is inferred one value at a time (independent {@link valueToSchema}
6590
6953
  * per sample, unified with {@link unifySchemas} — the same de-duplication and
6591
6954
  * `anyOf` ordering an array's element schemas receive). `format`
@@ -6673,6 +7036,22 @@ export declare function sanitizeBudget(value: number | undefined, fallback: numb
6673
7036
  */
6674
7037
  export declare function sanitizeDepth(value: number | undefined): number;
6675
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
+
6676
7055
  /**
6677
7056
  * Owns the state of one JSON Schema snapshot operation.
6678
7057
  *
@@ -6879,7 +7258,8 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
6879
7258
  *
6880
7259
  * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with
6881
7260
  * code `structure`, every node the lenient walk would widen, every keyword it
6882
- * would ignore (`pattern`, every `format` but `'date'` on a string node, `nullable`,
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`,
6883
7263
  * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside
6884
7264
  * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry
6885
7265
  * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose
@@ -6890,7 +7270,9 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
6890
7270
  * every keyword that could keep two arms apart. Below a `oneOf` that object refuses
6891
7271
  * instead, since closing it could change which arms match. A strict conversion is the
6892
7272
  * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a
6893
- * date string shape, so a compiled {@link dateShape} round-trips.
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.
6894
7276
  *
6895
7277
  * @param schema - The JSON Schema value to convert
6896
7278
  * @param options - Optional `strict`, default `false`
@@ -7160,6 +7542,7 @@ export declare interface ShapeShapeOptions {
7160
7542
  * `'date'` when `date: true`, else `'string'`); `optionalShape` /
7161
7543
  * `nullableShape` project through to their inner shape's kind, and `rawShape`
7162
7544
  * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.
7545
+ * `functionShape` projects to `'function'`.
7163
7546
  *
7164
7547
  * A hand-authored node carrying an unrecognized discriminant is REFUSED rather
7165
7548
  * than answered out of type, which keeps the declared non-optional
@@ -7296,13 +7679,12 @@ export declare function sortValues<T extends string | number>(values: readonly T
7296
7679
  * Lists the JSON Schema keywords a strict `schemaToShape` conversion reads, frozen.
7297
7680
  *
7298
7681
  * @remarks
7299
- * The keywords a shape can honour, plus the annotations that assert nothing and so
7300
- * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,
7301
- * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.
7302
- * `pattern` and `format` are absent because no compiled shape asserts them, so a
7303
- * schema holding one would convert to a shape wider than the schema it came from. The
7304
- * one exception is `format: 'date'` on a string node, which a strict conversion reads
7305
- * as a date string shape.
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.
7306
7688
  *
7307
7689
  * @example
7308
7690
  * ```ts
@@ -7617,7 +7999,10 @@ export declare function unionOf(...predicates: ReadonlyArray<(value: unknown) =>
7617
7999
  * @remarks
7618
8000
  * `mode` selects the emitted JSON Schema keyword and runtime matching rule:
7619
8001
  * `'anyOf'` (default) accepts the first matching variant, while `'oneOf'`
7620
- * 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.
7621
8006
  */
7622
8007
  export declare interface UnionShape<V extends readonly ContractShape[] = readonly ContractShape[]> {
7623
8008
  readonly category: 'union';
@@ -7632,9 +8017,9 @@ export declare interface UnionShape<V extends readonly ContractShape[] = readonl
7632
8017
  * @remarks
7633
8018
  * When every arm is an object declaring one required literal property, and a value's
7634
8019
  * own property exactly equals a literal only one arm holds, that arm answers: `explain`
7635
- * and `audit` report its faults at their real paths, and `parse` repairs through it
7636
- * alone. Any other value reports `variant`, with `key` and `expected` saying what would
7637
- * 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.
7638
8023
  *
7639
8024
  * @param variants - The candidate shapes; the first match wins at runtime
7640
8025
  * @returns A union shape whose `Infer` is the union of the variants
@@ -7712,7 +8097,11 @@ export declare function validateShape(shape: unknown): void;
7712
8097
  * throws a `structure`
7713
8098
  * {@link ContractError}; it never becomes `{}` or another permissive schema. Nested
7714
8099
  * objects close to unknown keys (`additionalProperties: false`) by default;
7715
- * 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
7716
8105
  * string/`Date` leaf into the `format` keyword. Structurally-equal inputs
7717
8106
  * infer byte-identical schemas (object keys and `anyOf` members are sorted).
7718
8107
  *