@orkestrel/contract 0.0.24 → 0.0.26

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.
@@ -380,7 +380,7 @@ export declare function buildKeyPlan(keys: readonly string[], guards: Readonly<R
380
380
  * doors for the same reason. `expected` is the shape's own kind — `'integer'`
381
381
  * when `integer: true`, otherwise `'number'` — so a caller reading the report
382
382
  * sees the declaration's vocabulary rather than the value's. Order is
383
- * `integer`, then `min`, then `max`. It refuses an unreadable shape through the
383
+ * `integer`, `min`, `over`, `max`, then `under`. It refuses an unreadable shape through the
384
384
  * same boundary and for the same reason {@link buildStringFaults} does.
385
385
  *
386
386
  * @param shape - The number shape whose refinements are checked
@@ -526,8 +526,8 @@ export declare function buildStringFaults(shape: StringShape, value: string, pat
526
526
  * - cyclic input, tracked with the same ancestor-{@link WeakSet} discipline
527
527
  * the container branches of value inference use, so a shared (non-cyclic)
528
528
  * reference reached twice through different paths still encodes;
529
- * A hostile traversal is categorically different: a throwing own-getter,
530
- * hostile `ownKeys` trap, or revoked `Proxy` throws a `structure`
529
+ * An untrusted traversal is categorically different: a throwing own-getter,
530
+ * untrusted `ownKeys` trap, or revoked `Proxy` throws a `structure`
531
531
  * {@link ContractError} through {@link readValue}. A caller can therefore
532
532
  * distinguish "not JSON-encodable" from "could not be read".
533
533
  *
@@ -553,6 +553,33 @@ export declare function buildStringFaults(shape: StringShape, value: string, pat
553
553
  */
554
554
  export declare function canonicalStringify(value: unknown): string | undefined;
555
555
 
556
+ /**
557
+ * Represents where an owned snapshot holds a value by identity instead of copying it.
558
+ *
559
+ * @remarks
560
+ * A compiler derives one plan per declaration node below which an interface sits; absence means
561
+ * that no interface sits below the position, so every plain record and array there is copied.
562
+ * `held` marks an interface position. `properties` holds every declared object key, each with
563
+ * its plan or `undefined`, `tail` the plan of an undeclared key, and `items` the plan of an array
564
+ * element.
565
+ *
566
+ * @example
567
+ * ```ts
568
+ * const plan: CapturePlan = {
569
+ * held: false,
570
+ * properties: { store: { held: true, properties: {}, tail: undefined, items: undefined } },
571
+ * tail: undefined,
572
+ * items: undefined,
573
+ * }
574
+ * ```
575
+ */
576
+ export declare interface CapturePlan {
577
+ readonly held: boolean;
578
+ readonly properties: Readonly<Record<string, CapturePlan | undefined>>;
579
+ readonly tail: CapturePlan | undefined;
580
+ readonly items: CapturePlan | undefined;
581
+ }
582
+
556
583
  /**
557
584
  * Caps at `1024` the number of choices one schema field may offer, frozen.
558
585
  *
@@ -649,7 +676,7 @@ export declare function cloneJSONRecord(value: unknown): JSONRecord;
649
676
  * wired. Array keys must be exactly `length` plus every canonical index.
650
677
  * Writable and configurable index flags are normalized rather than treated as
651
678
  * JSON data, so frozen arrays remain valid. Property descriptors are inspected
652
- * without reading values through accessors, and every hostile reflective
679
+ * without reading values through accessors, and every untrusted reflective
653
680
  * operation is contained before a new clone-coded error is exposed.
654
681
  * Each call creates a fresh {@link JSONCloner}; use the class directly when
655
682
  * terminal success or failure identity must be replayed without another read.
@@ -679,14 +706,14 @@ export declare function cloneJSONValue(value: unknown): JSONValue;
679
706
  * references and closing cyclic edges onto their cloned nodes. Primitive
680
707
  * values and own enumerable string-keyed edges are copied; record nodes use
681
708
  * null prototypes, arrays retain only their intrinsic array prototype, and
682
- * every produced object is frozen after its edges are wired. Hostile traversal
709
+ * every produced object is frozen after its edges are wired. Untrusted traversal
683
710
  * throws a clone-coded {@link ContractError}, never a caller-owned raw error.
684
711
  * Each call creates a fresh {@link SchemaCloner}; use the class directly when
685
712
  * terminal success or failure identity must be replayed without another read.
686
713
  *
687
714
  * @param schema - The JSON Schema graph to snapshot
688
715
  * @returns A deeply cloned and frozen JSON Schema graph
689
- * @throws {ContractError} When hostile schema traversal prevents ownership
716
+ * @throws {ContractError} When untrusted schema traversal prevents ownership
690
717
  *
691
718
  * @example
692
719
  * ```ts
@@ -703,7 +730,7 @@ export declare function cloneSchema(schema: JSONSchema): JSONSchema;
703
730
  * @remarks
704
731
  * A fresh public {@link ShapeCloner} preserves shared-child identity while
705
732
  * building the candidate snapshot, owns raw schemas, validates the exact
706
- * completed root, applies deferred fidelity, and translates unexpected hostile
733
+ * completed root, applies deferred fidelity, and translates unexpected untrusted
707
734
  * failures. Inside the engine, each node's own data discriminant and every
708
735
  * declared field are captured descriptor-first from two agreeing reads, and the
709
736
  * carried population alone supplies its shallow shell, semantic checks, child
@@ -719,12 +746,12 @@ export declare function cloneSchema(schema: JSONSchema): JSONSchema;
719
746
  * {@link cloneSchema}. Before return, a fresh {@link ShapeValidator} independently
720
747
  * validates the exact cloned root. Ownership never erases a structural edge or
721
748
  * normalizes an invalid scalar/bound into a plausible declaration: those
722
- * inputs throw their coded structure/bound error. Hostile traversal remains
749
+ * inputs throw their coded structure/bound error. Untrusted traversal remains
723
750
  * distinct and throws a clone-coded {@link ContractError}.
724
751
  *
725
752
  * @param shape - The contract shape graph to snapshot
726
753
  * @returns A deeply cloned and frozen shape graph
727
- * @throws {ContractError} When the declaration cannot be copied faithfully or hostile shape or raw-schema traversal prevents ownership
754
+ * @throws {ContractError} When the declaration cannot be copied faithfully or untrusted shape or raw-schema traversal prevents ownership
728
755
  *
729
756
  * @example
730
757
  * ```ts
@@ -891,7 +918,7 @@ export declare const COMPILE_DEPTH_LIMIT = 512;
891
918
  *
892
919
  * This cap does not bound compilation, because the compilers do not expand a
893
920
  * DAG. Every artifact family is one entry per unique node, so the boundary
894
- * declaration above compiles its unique nodes in about a millisecond.
921
+ * preceding declaration compiles its unique nodes in about a millisecond.
895
922
  * What does expand is what a CONSUMER materializes from the artifacts: the
896
923
  * value `generate` builds, and the document a compiled schema serializes to,
897
924
  * are trees of exactly this size. The cap survives as a bound on what a caller
@@ -920,7 +947,7 @@ export declare const COMPILE_NODE_LIMIT = 16384;
920
947
  * evaluated for a valid declaration. The invariant relates two
921
948
  * separate calls, so it holds for a value whose reads are stable across calls;
922
949
  * see the read-stability precondition on {@link ContractInterface}. Every
923
- * recursive call returns at most {@link FAULT_LIMIT} entries. Hostile property
950
+ * recursive call returns at most {@link FAULT_LIMIT} entries. Untrusted property
924
951
  * access raises the shared coded read refusal with the current container path
925
952
  * and shape, so unreadability never masquerades as a type mismatch.
926
953
  * It requests exactly the `auditor` root of a fresh {@link ContractCompiler}
@@ -1075,12 +1102,12 @@ export declare function compileParser(shape: ContractShape): Parser<unknown>;
1075
1102
  * match" / "no consensus" summary fault prepended to its closest variant's
1076
1103
  * faults — slices its return to at most {@link FAULT_LIMIT} entries, so the
1077
1104
  * bound holds at every level of nesting rather than at the outermost container alone, on
1078
- * adversarial input (a huge array, a wide record, a wide union of wide
1105
+ * untrusted input (a huge array, a wide record, a wide union of wide
1079
1106
  * records). A closed object's extra keys never
1080
1107
  * fault — `parse` silently drops them, so `explain` mirrors that leniency, and
1081
1108
  * {@link compileAuditor} is where they do fault; an open object with a
1082
1109
  * constraining `additionalProperties` shape recurses extras against it instead.
1083
- * A hostile getter or throwing `Proxy` trap is contained through {@link attempt}
1110
+ * An untrusted getter or throwing `Proxy` trap is contained through {@link attempt}
1084
1111
  * and surfaces as a single top-level type fault, never a throw, as
1085
1112
  * `.claude/rules/patterns.md` § Validation and contracts requires.
1086
1113
  * It requests exactly the `reporter` root of a fresh {@link ContractCompiler}
@@ -1349,14 +1376,16 @@ export declare type ContractCode =
1349
1376
  * holds a union, because a union's membership question IS a guard question in
1350
1377
  * all three, and every getter builds it when the graph holds a default, because
1351
1378
  * a default that its inner shape refuses refuses at whichever artifact is read
1352
- * first.
1379
+ * first. The `guard`, `parser` and `reporter` plan the audits when the graph holds
1380
+ * an interface, because an interface node answers each of the three from its audit.
1381
+ * The `owner` builds the guard, the auditor, and the parser, because it judges with all three.
1353
1382
  *
1354
1383
  * One terminal lifecycle covers preparation and every family. A failure settles
1355
1384
  * the compiler: later getters rethrow that exact error, while an artifact
1356
1385
  * already handed out keeps working, because each compiled artifact is
1357
1386
  * self-contained. Reentry — reachable only through a caller accessor the
1358
- * declaration itself exposes, since a `pattern` getter is the one accessor
1359
- * ownership invokes — poisons the nested read, the interrupted outer read, and
1387
+ * declaration itself exposes, because a `pattern` getter is the one accessor
1388
+ * ownership invokes — invalidates the nested read, the interrupted outer read, and
1360
1389
  * every later read with one shared cause-free error.
1361
1390
  *
1362
1391
  * @typeParam S - The declaration's shape type, which types the published artifacts
@@ -1395,13 +1424,15 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
1395
1424
  get reporter(): ReporterFunction;
1396
1425
  /** Returns the compiled seed-data source for the owned declaration. */
1397
1426
  get generator(): SeederFunction<Infer<S>>;
1427
+ /** Returns the compiled owning admission for the owned declaration. */
1428
+ get owner(): OwnerFunction<Infer<S>>;
1398
1429
  /**
1399
1430
  * Returns the frozen bundle of this compiler's artifacts.
1400
1431
  *
1401
1432
  * @remarks
1402
1433
  * Own enumerable keys `schema`, `is`, `parse`, `audit`, `explain`,
1403
- * `generate`, in that order, each holding the exact value the corresponding
1404
- * getter publishes.
1434
+ * `generate`, `own`, in that order, each holding the exact value the
1435
+ * corresponding getter publishes.
1405
1436
  */
1406
1437
  get contract(): ContractInterface<Infer<S>>;
1407
1438
  }
@@ -1415,9 +1446,12 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
1415
1446
  * structural edge once into children-before-parent order; every artifact family
1416
1447
  * is then one postorder pass over that index, so a shared child costs its
1417
1448
  * authored nodes rather than its paths. A getter builds its own family and no
1418
- * other, except where an artifact genuinely consumes the compiled guard —
1419
- * `parser`, `reporter` and `generator` resolve union membership through it, so
1420
- * they build it too. `contract` requests every root in getter order.
1449
+ * other, except where an artifact genuinely consumes another — `parser`,
1450
+ * `reporter` and `generator` resolve union membership through the compiled
1451
+ * guard, so they build it too, and `guard`, `parser` and `reporter` answer an
1452
+ * interface node from its audit, so they plan the audits when the graph holds
1453
+ * one, and `owner` builds the guard, the auditor, and the parser it judges with. `contract`
1454
+ * requests every root in getter order.
1421
1455
  *
1422
1456
  * Every getter REPLAYS its exact artifact: reading one twice returns the same
1423
1457
  * function or graph by identity, and {@link contract}'s members are those
@@ -1425,7 +1459,7 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
1425
1459
  * a failure anywhere settles the compiler permanently — later getters rethrow
1426
1460
  * that exact error while an artifact already handed out stays usable, because
1427
1461
  * each one is self-contained. Cross-getter reentry (only reachable through a
1428
- * caller accessor the declaration exposes) poisons the nested read, the
1462
+ * caller accessor the declaration exposes) invalidates the nested read, the
1429
1463
  * interrupted outer read, and every later read with one shared cause-free
1430
1464
  * error.
1431
1465
  *
@@ -1440,11 +1474,11 @@ export declare class ContractCompiler<S extends ContractShape = ContractShape> i
1440
1474
  * It declares no call-signature member, so its whole surface is the readonly data
1441
1475
  * properties: `schema` (a {@link JSONSchema}), `guard` (a `Guard<Infer<S>>`), `parser`
1442
1476
  * (a `Parser<Infer<S>>`), `auditor` (an {@link AuditorFunction}), `reporter` (a {@link
1443
- * ReporterFunction}), `generator` (a `SeederFunction<Infer<S>>`), and `contract` (a
1444
- * `ContractInterface<Infer<S>>`). `contract` is the frozen bundle whose own enumerable
1445
- * keys are `schema`, `is`, `parse`, `audit`, `explain`, and `generate` in that order,
1446
- * each holding the exact value the corresponding getter publishes — `contract.is` is
1447
- * exactly `compiler.guard`, by identity rather than as a copy.
1477
+ * ReporterFunction}), `generator` (a `SeederFunction<Infer<S>>`), `owner` (an {@link
1478
+ * OwnerFunction}), and `contract` (a `ContractInterface<Infer<S>>`). `contract` is the frozen
1479
+ * bundle whose own enumerable keys are `schema`, `is`, `parse`, `audit`, `explain`,
1480
+ * `generate`, and `own` in that order, each holding the exact value the corresponding getter
1481
+ * publishes — `contract.is` is exactly `compiler.guard`, by identity rather than as a copy.
1448
1482
  *
1449
1483
  * @example
1450
1484
  * ```ts
@@ -1465,6 +1499,8 @@ export declare interface ContractCompilerInterface<S extends ContractShape> {
1465
1499
  readonly reporter: ReporterFunction;
1466
1500
  /** Returns the compiled seed-data source. */
1467
1501
  readonly generator: SeederFunction<Infer<S>>;
1502
+ /** Returns the compiled owning admission. */
1503
+ readonly owner: OwnerFunction<Infer<S>>;
1468
1504
  /** Returns the frozen bundle whose values are the artifacts declared earlier. */
1469
1505
  readonly contract: ContractInterface<Infer<S>>;
1470
1506
  }
@@ -1517,6 +1553,13 @@ export declare interface ContractErrorContext {
1517
1553
  readonly limit?: number | string;
1518
1554
  /** Holds the received-value description associated with the error. */
1519
1555
  readonly received?: string;
1556
+ /**
1557
+ * Holds the audit faults of the refused value, each located by its own path.
1558
+ *
1559
+ * @remarks
1560
+ * A refusal that carries `faults` reports every fault it found, where `path` locates the first.
1561
+ */
1562
+ readonly faults?: readonly AuditFault[];
1520
1563
  }
1521
1564
 
1522
1565
  /**
@@ -1542,9 +1585,9 @@ export declare interface ContractErrorOptions {
1542
1585
  * Built by `createContract`: `is` narrows, `audit` diagnoses strict rejection,
1543
1586
  * `parse` coerces (returning the typed value or `undefined`), `schema` is an
1544
1587
  * owned deeply frozen emitted JSON Schema, `explain` reports the structured
1545
- * faults behind a failed `parse`, and `generate` produces deterministic seed
1588
+ * faults behind a failed `parse`, `generate` produces deterministic seed
1546
1589
  * data from a {@link RandomFunction} (defaulting to a wall-clock-seeded source
1547
- * when none is supplied).
1590
+ * when none is supplied), and `own` admits an owned snapshot of a value.
1548
1591
  *
1549
1592
  * LOCKSTEP means derived from one owned snapshot of the shape, not agreeing on
1550
1593
  * which values to accept: `is` and `schema` describe the contract's canonical
@@ -1575,8 +1618,8 @@ export declare interface ContractInterface<T> {
1575
1618
  * Coercion (`'36'` → `36`) and every leaf refinement (`min` / `max` /
1576
1619
  * `pattern`) both apply, so every non-`undefined` result satisfies `is`.
1577
1620
  * Honest invalidity answers `undefined`, while a failed required object,
1578
- * JSON, or dense-array index read throws the shared coded refusal — the two
1579
- * outcomes stay distinguishable.
1621
+ * interface member, JSON, or dense-array index read throws the shared coded
1622
+ * refusal — the two outcomes stay distinguishable.
1580
1623
  *
1581
1624
  * @param value - The value to coerce
1582
1625
  * @returns The typed value, or `undefined` when the value is readable and invalid
@@ -1610,7 +1653,8 @@ export declare interface ContractInterface<T> {
1610
1653
  * value whose reads are stable across calls (see the read-stability
1611
1654
  * precondition on {@link ContractInterface}) — explain mirrors `parse`'s
1612
1655
  * coercion, not the stricter `is`, and `audit` is the report that mirrors
1613
- * `is`. Faults are listed in stable pre-order (declared key/index order).
1656
+ * `is`. An `undefined` that `is` admits parses to itself, so its report is
1657
+ * empty. Faults are listed in stable pre-order (declared key/index order).
1614
1658
  *
1615
1659
  * @param value - The value to check
1616
1660
  * @returns The faults found, empty when the value parses successfully
@@ -1629,6 +1673,19 @@ export declare interface ContractInterface<T> {
1629
1673
  * @throws {ContractError} When the declaration cannot be satisfied, or when the sample source fails
1630
1674
  */
1631
1675
  generate(random?: RandomFunction): T;
1676
+ /**
1677
+ * Admits an owned snapshot of a value and returns the parser's value, at the argument's static type.
1678
+ *
1679
+ * @remarks
1680
+ * Reads each own enumerable string member and each present index of a plain record or array one
1681
+ * time, into a frozen copy, and admits that copy as {@link admitValue} would. A value at an
1682
+ * interface position, any other object, and every function are held by identity.
1683
+ *
1684
+ * @param value - The value to own
1685
+ * @returns The parser's value over the snapshot, or the refusal
1686
+ */
1687
+ own<V extends T>(value: V): Result<V, ContractRefusal>;
1688
+ own(value: unknown): Result<T, ContractRefusal>;
1632
1689
  }
1633
1690
 
1634
1691
  /**
@@ -1669,7 +1726,7 @@ export declare interface ContractRepair<T> {
1669
1726
  * element shape, an `ObjectShape` a map of them). {@link validateShape}
1670
1727
  * enforces an acyclic graph within {@link COMPILE_DEPTH_LIMIT}.
1671
1728
  */
1672
- export declare type ContractShape = StringShape | NumberShape | BooleanShape | NullShape | LiteralShape | ArrayShape | ObjectShape | UnionShape | OptionalShape | NullableShape | JSONShape | ShapeShape | FunctionShape | RawShape;
1729
+ export declare type ContractShape = StringShape | NumberShape | BooleanShape | NullShape | LiteralShape | ArrayShape | ObjectShape | UnionShape | OptionalShape | NullableShape | JSONShape | ShapeShape | FunctionShape | UndefinedShape | InterfaceShape | RawShape;
1673
1730
 
1674
1731
  /**
1675
1732
  * Compiles a {@link ContractShape} into a {@link ContractInterface} — the
@@ -1701,7 +1758,7 @@ export declare type ContractShape = StringShape | NumberShape | BooleanShape | N
1701
1758
  * to touch, so the failure arrives at the call the caller made — carrying the
1702
1759
  * authoring door's own diagnosis, which this door adopts rather than rewraps.
1703
1760
  * Every compiled member is self-contained, and the compiler this call builds
1704
- * releases its working set once every member has compiled. The contract keeps
1761
+ * releases its working set after every member has compiled. The contract keeps
1705
1762
  * part of the declaration even so: the auditor and reporter plans close over the
1706
1763
  * leaf and array nodes they read their bounds from, and a contract with deferred
1707
1764
  * members retains its declaration. Nothing the caller keeps reaches back into the
@@ -1711,7 +1768,7 @@ export declare type ContractShape = StringShape | NumberShape | BooleanShape | N
1711
1768
  * diagnostics and generator refuse.
1712
1769
  *
1713
1770
  * @param shape - The shape to compile
1714
- * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate`
1771
+ * @returns A contract bundling `schema` / `is` / `parse` / `audit` / `explain` / `generate` / `own`
1715
1772
  *
1716
1773
  * @example Compiling a contract
1717
1774
  * ```ts
@@ -1871,7 +1928,7 @@ export declare function describeFaults(faults: readonly AuditFault[], schema?: J
1871
1928
  * carries code `random` and never the `generate` code, and {@link compileGenerator}
1872
1929
  * rethrows it at whatever draw depth it happened instead of rotating to the next union
1873
1930
  * variant. The diagnostic names the consuming shape category, the `[0, 1)` limit, and a
1874
- * total non-coercing {@link preview} of the offending sample (or `threw`), so a hostile
1931
+ * total non-coercing {@link preview} of the offending sample (or `threw`), so an untrusted
1875
1932
  * object runs no conversion hook while the diagnostic is built and a primitive symbol
1876
1933
  * renders without consulting mutable `Symbol.prototype.toString`.
1877
1934
  *
@@ -1944,7 +2001,7 @@ export declare type EntryCollectorFunction = (value: unknown, key: unknown) => v
1944
2001
  * This is the package-wide runtime property view used by compiled object
1945
2002
  * guards, parsers, reporters, schema inference, and owned schema cloning. It
1946
2003
  * matches the object-key view serialized by `JSON.stringify`: inherited,
1947
- * symbol, and non-enumerable properties are excluded. A hostile Proxy trap
2004
+ * symbol, and non-enumerable properties are excluded. An untrusted Proxy trap
1948
2005
  * returns `undefined` rather than escaping.
1949
2006
  *
1950
2007
  * @param value - The object whose keys to snapshot
@@ -2027,6 +2084,19 @@ export declare function enumOf<const E extends Record<string, string | number>>(
2027
2084
  */
2028
2085
  export declare function errorToMessage(error: unknown): string;
2029
2086
 
2087
+ /**
2088
+ * Replaces each DEL, C1 control, U+2028, and U+2029 in a text with its `\u` sequence.
2089
+ *
2090
+ * @param text - The text to rewrite
2091
+ * @returns The text with those characters as lowercase `\u` sequences
2092
+ *
2093
+ * @example
2094
+ * ```ts
2095
+ * escapeControls('a\u2028b') // 'a\\u2028b'
2096
+ * ```
2097
+ */
2098
+ export declare function escapeControls(text: string): string;
2099
+
2030
2100
  /**
2031
2101
  * Escapes every regular-expression metacharacter in a text, so the text
2032
2102
  * matches literally inside a larger `RegExp` source.
@@ -2154,7 +2224,8 @@ export declare function failure<E>(error: E): Failure<E>;
2154
2224
  * @remarks
2155
2225
  * A discriminated union on `reason`:
2156
2226
  * - `'type'` — the value could not coerce to `expected` at all.
2157
- * - `'missing'` — a required object property was absent.
2227
+ * - `'missing'` — a required object property was absent, a required interface member
2228
+ * read `undefined`, or an array held a hole where its element shape admits `undefined`.
2158
2229
  * - `'constraint'` — the value coerced to `expected` but violated one
2159
2230
  * refinement (`min` / `max` / `pattern` / `date` / `integer`); `limit` carries the
2160
2231
  * violated bound/pattern when applicable.
@@ -2228,9 +2299,9 @@ export declare const FAULT_KINDS: readonly FaultKind[];
2228
2299
  * `explain` or `audit` report ever returns, frozen.
2229
2300
  *
2230
2301
  * @remarks
2231
- * Bounds BOTH reports against adversarial input (a giant array, a wide record)
2302
+ * Bounds BOTH reports against untrusted input (a giant array, a wide record)
2232
2303
  * — `compileReporter` and `compileAuditor` each collect faults in stable
2233
- * pre-order and stop once this cap is reached, and every recursive call slices
2304
+ * pre-order and stop after this cap is reached, and every recursive call slices
2234
2305
  * to it, so the report size (and the work to build it) stays finite and
2235
2306
  * deterministic at every nesting level regardless of the input's size. Size a
2236
2307
  * diagnostic surface off this constant and it bounds `audit` exactly as it
@@ -2251,9 +2322,9 @@ export declare const FAULT_TEXT_LIMIT = 2048;
2251
2322
  * Names the refinement a {@link Fault} of reason `'constraint'` violates.
2252
2323
  *
2253
2324
  * @remarks
2254
- * The vocabulary is `'min'`, `'max'`, `'pattern'`, `'date'`, and `'integer'`.
2325
+ * The vocabulary is `'min'`, `'over'`, `'max'`, `'under'`, `'pattern'`, `'date'`, and `'integer'`.
2255
2326
  */
2256
- export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'integer';
2327
+ export declare type FaultConstraint = 'min' | 'over' | 'max' | 'under' | 'pattern' | 'date' | 'integer';
2257
2328
 
2258
2329
  /**
2259
2330
  * Names the kind of value a {@link Fault} expected — the shape-projected counterpart of
@@ -2261,9 +2332,10 @@ export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'inte
2261
2332
  *
2262
2333
  * @remarks
2263
2334
  * The vocabulary is `'string'`, `'date'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2264
- * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, `'shape'`, and `'function'`.
2335
+ * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, `'shape'`, `'function'`, and
2336
+ * `'undefined'`.
2265
2337
  */
2266
- export declare type FaultKind = 'string' | 'date' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape' | 'function';
2338
+ export declare type FaultKind = 'string' | 'date' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape' | 'function' | 'undefined';
2267
2339
 
2268
2340
  /**
2269
2341
  * Retains a lazily built fault declaration without building shapes during module evaluation.
@@ -2579,7 +2651,7 @@ export declare function holds(callback: () => boolean): boolean;
2579
2651
  * full union is a fixed point that can never shrink — the compiler would fan
2580
2652
  * out until it aborts with TS2589. Bailing out lazily short-circuits that
2581
2653
  * fixed point (the untaken branch is never instantiated) while every narrow
2582
- * shape and every partial union still flows through the exact chain below.
2654
+ * shape and every partial union still flows through the exact following chain.
2583
2655
  *
2584
2656
  * The `ObjectShape` branch's `additionalProperties` guard (`[A] extends
2585
2657
  * [boolean | ContractShape]`) is likewise wrapped in a tuple to stay
@@ -2605,7 +2677,18 @@ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S]
2605
2677
  } ? I extends ContractShape ? Infer<I> | undefined : never : S extends {
2606
2678
  readonly category: 'nullable';
2607
2679
  readonly inner: infer I;
2608
- } ? I extends ContractShape ? Infer<I> | null : never : S extends JSONShape ? JSONValue : unknown;
2680
+ } ? I extends ContractShape ? Infer<I> | null : never : S extends JSONShape ? JSONValue : S extends UndefinedShape ? undefined : S extends InterfaceShape<infer P> ? Readonly<{
2681
+ [K in keyof P as P[K] extends {
2682
+ readonly category: 'optional';
2683
+ } ? never : K]: Infer<P[K]>;
2684
+ } & {
2685
+ [K in keyof P as P[K] extends {
2686
+ readonly category: 'optional';
2687
+ } ? K : never]?: P[K] extends {
2688
+ readonly category: 'optional';
2689
+ readonly inner: infer I;
2690
+ } ? I extends ContractShape ? Infer<I> | undefined : never : never;
2691
+ }> : unknown;
2609
2692
 
2610
2693
  /**
2611
2694
  * Caps by default at `256` the number of object properties / array elements {@link
@@ -2622,7 +2705,7 @@ export declare const INFER_BREADTH_LIMIT = 256;
2622
2705
  * Caps at `32` the object/array nesting depth {@link valueToSchema} walks, frozen.
2623
2706
  *
2624
2707
  * @remarks
2625
- * Bounds inference against adversarial or cyclic runtime input — once the
2708
+ * Bounds inference against untrusted or cyclic runtime input — after the
2626
2709
  * remaining depth budget reaches zero, inference stops descending and emits
2627
2710
  * the empty accept-anything schema `{}` for that branch instead of recursing
2628
2711
  * further. LOWERABLE per call through {@link ValueToSchemaLimits.depth}; a
@@ -2742,7 +2825,7 @@ export declare type InferOpenIndex<A extends boolean | ContractShape> = [A] exte
2742
2825
  * Fires only when ALL of: every value is the same primitive kind (all string
2743
2826
  * or all FINITE number through {@link isFiniteNumber} — any `null`/boolean/mixed
2744
2827
  * slot never qualifies, and a slot containing `NaN` / `±Infinity` never
2745
- * qualifies either, since {@link canonicalStringify} collapses `NaN` to
2828
+ * qualifies either, because {@link canonicalStringify} collapses `NaN` to
2746
2829
  * `'null'` and would otherwise risk an invalid-JSON `enum`); at least 2
2747
2830
  * values are given; the distinct-by-{@link canonicalStringify} count is LESS
2748
2831
  * than the value count (repetition required — separates a categorical column
@@ -2806,10 +2889,76 @@ export declare function instanceOf<C extends abstract new (...args: never) => ob
2806
2889
  *
2807
2890
  * @param options - Optional bounds and `description` (no `integer` key)
2808
2891
  * @returns An integer number shape
2809
- * @throws {ContractError} When a present bound is not finite
2892
+ * @throws {ContractError} When an option key is unknown, a present bound is not finite, or no whole number satisfies the bounds
2810
2893
  */
2811
2894
  export declare function integerShape(options?: Omit<NumberShapeOptions, 'integer'>): NumberShape;
2812
2895
 
2896
+ /**
2897
+ * Describes an implementation — a non-array object or a function that carries each declared member.
2898
+ *
2899
+ * @remarks
2900
+ * The compiled walk reads each declared member one time through `Reflect.get`, so an inherited
2901
+ * member and a prototype accessor satisfy the shape, and it never enumerates an undeclared
2902
+ * member. A member wrapped in {@link OptionalShape} passes when it reads `undefined`; every
2903
+ * other member that reads `undefined` faults `'missing'` unless its shape admits `undefined`.
2904
+ * The guard is the audit returning no fault, and the parser returns the value by identity when
2905
+ * the guard holds, so no member is copied, coerced, or filled. The emitted schema is
2906
+ * `{ type: 'object', format: 'interface', properties, required, additionalProperties: true }`.
2907
+ * The generator returns a frozen plain record of generated members. A member may not carry a
2908
+ * `default`, and the shape may not sit under a union at any depth; both refuse with code
2909
+ * `placement`.
2910
+ *
2911
+ * @example
2912
+ * ```ts
2913
+ * const declaration: InterfaceShape = {
2914
+ * category: 'interface',
2915
+ * members: { get: { category: 'function' } },
2916
+ * }
2917
+ * createContract(declaration).is(new Map()) // true
2918
+ * ```
2919
+ */
2920
+ export declare interface InterfaceShape<P extends Readonly<Record<string, ContractShape>> = Readonly<Record<string, ContractShape>>> {
2921
+ readonly category: 'interface';
2922
+ readonly members: P;
2923
+ readonly description?: string;
2924
+ }
2925
+
2926
+ /**
2927
+ * Builds an {@link InterfaceShape} from a member map.
2928
+ *
2929
+ * @remarks
2930
+ * Declare the members a consumer calls or reads on an implementation it does not own, such as a
2931
+ * store or a signal: a class instance, a function, or an object whose prototype carries the
2932
+ * members passes, and an undeclared member is never read. Wrap a member in
2933
+ * {@link optionalShape} to let it read `undefined`. Take {@link objectShape} for a plain data
2934
+ * record.
2935
+ *
2936
+ * @param members - Map of member names to child shapes
2937
+ * @param options - Optional description
2938
+ * @returns An interface shape
2939
+ * @throws {ContractError} When `members` is not a plain record, a member carries a default, or an option key is unread
2940
+ *
2941
+ * @example
2942
+ * ```ts
2943
+ * const store = interfaceShape({ get: functionShape(), set: functionShape(), delete: functionShape() })
2944
+ * createContract(store).is(new Map()) // true
2945
+ * ```
2946
+ */
2947
+ export declare function interfaceShape<P extends Readonly<Record<string, ContractShape>>>(members: P, options?: InterfaceShapeOptions): InterfaceShape<P>;
2948
+
2949
+ /**
2950
+ * Configures the description of an implementation declaration.
2951
+ *
2952
+ * @example
2953
+ * ```ts
2954
+ * const options: InterfaceShapeOptions = { description: 'The session store' }
2955
+ * interfaceShape({}, options).description // 'The session store'
2956
+ * ```
2957
+ */
2958
+ export declare interface InterfaceShapeOptions {
2959
+ readonly description?: string;
2960
+ }
2961
+
2813
2962
  /** Intersects the types guarded by a tuple of guards — backs `intersectionOf`. */
2814
2963
  export declare type IntersectionFromGuards<Gs extends ReadonlyArray<Guard<unknown>>> = UnionToIntersection<GuardType<Gs[number]>>;
2815
2964
 
@@ -2852,7 +3001,7 @@ export declare function intersectionOf(...predicates: ReadonlyArray<(value: unkn
2852
3001
  * installed at the moment THIS module evaluated, and reading it later, at the
2853
3002
  * call site, is reading whatever the caller most recently installed. "Before any
2854
3003
  * caller code runs" is the tempting phrasing and it is false in exactly the case
2855
- * the limit below names, so it is not used.
3004
+ * the following limit names, so it is not used.
2856
3005
  *
2857
3006
  * The limit that follows, stated as a limit rather than as a guarantee: capture
2858
3007
  * is only as early as this package's own evaluation. A consumer module that
@@ -2863,7 +3012,7 @@ export declare function intersectionOf(...predicates: ReadonlyArray<(value: unkn
2863
3012
  * package wholesale rather than bother with the table, so it is named here
2864
3013
  * instead of defended.
2865
3014
  *
2866
- * Membership rule, stated so a reviewer can apply it and a new call site knows
3015
+ * Membership rule, stated so a reviewer can apply it and an added call site knows
2867
3016
  * where to go: **every host operation this package dispatches by name whose
2868
3017
  * result a published answer depends on.** That admits statics, constructors and
2869
3018
  * namespaces, and — this is the part the earlier wording got wrong by writing
@@ -2949,7 +3098,7 @@ export declare const INTRINSICS: Readonly<{
2949
3098
  base: Object;
2950
3099
  /**
2951
3100
  * Captures the proxy-visible operations, grouped because that is what separates them:
2952
- * each reports the trap's exact answer where `Object`'s flat peer above
3101
+ * each reports the trap's exact answer where `Object`'s preceding flat peer
2953
3102
  * reports the target's.
2954
3103
  *
2955
3104
  * @remarks
@@ -3080,6 +3229,8 @@ export declare const INTRINSICS: Readonly<{
3080
3229
  indices: () => ArrayIterator<number>;
3081
3230
  /** Captures the native array iterator advance operation. */
3082
3231
  advance: any;
3232
+ /** Captures `String.prototype.slice` — the window a preview encodes, dispatched through `apply`. */
3233
+ slice: (start?: number, end?: number) => string;
3083
3234
  /** Captures `Array.prototype.join` — text assembly from derived parts. */
3084
3235
  join: (separator?: string) => string;
3085
3236
  /** Captures `Function.prototype.bind` for a receiver-bound host operation. */
@@ -3249,6 +3400,26 @@ export declare function isAsyncIterable<T = unknown>(value: unknown): value is A
3249
3400
  */
3250
3401
  export declare function isAuditFault(value: unknown): value is AuditFault;
3251
3402
 
3403
+ /**
3404
+ * Determines whether a value is a dense list of {@link AuditFault} values.
3405
+ *
3406
+ * @remarks
3407
+ * Reads each index as an own member, in order, and stops at the first hole or the first entry
3408
+ * that `isAuditFault` refuses. An empty list passes.
3409
+ *
3410
+ * @param value - The value to inspect
3411
+ * @returns True if the value is a dense array whose every entry is an audit fault; false otherwise
3412
+ *
3413
+ * @example
3414
+ * ```ts
3415
+ * isAuditFaults([{ reason: 'hidden', path: ['note'] }]) // true
3416
+ * isAuditFaults([]) // true
3417
+ * isAuditFaults([{ reason: 'hidden' }]) // false
3418
+ * isAuditFaults('hidden') // false
3419
+ * ```
3420
+ */
3421
+ export declare function isAuditFaults(value: unknown): value is readonly AuditFault[];
3422
+
3252
3423
  /** Determines whether a value is a bigint.
3253
3424
  *
3254
3425
  * @param value - The value to inspect
@@ -3348,6 +3519,26 @@ export declare function isBoundedJSONRecord(value: unknown): value is JSONRecord
3348
3519
  */
3349
3520
  export declare function isBoundedJSONValue(value: unknown): value is JSONValue;
3350
3521
 
3522
+ /**
3523
+ * Determines whether a value is an `Error` whose `code` is a string.
3524
+ *
3525
+ * @remarks
3526
+ * Reads `code` through one `Reflect.get` call inside {@link holds}, so a throwing getter answers
3527
+ * false and no member is read twice.
3528
+ *
3529
+ * @param value - The value to inspect
3530
+ * @returns True if the value is an `Error` and its `code` reads as a string; false otherwise
3531
+ *
3532
+ * @example
3533
+ * ```ts
3534
+ * isCodedError(Object.assign(new Error('missing'), { code: 'ENOENT' })) // true
3535
+ * isCodedError(new Error('plain')) // false
3536
+ * ```
3537
+ */
3538
+ export declare function isCodedError(value: unknown): value is Error & {
3539
+ readonly code: string;
3540
+ };
3541
+
3351
3542
  /**
3352
3543
  * Determines whether a value can be used as a `new`-target constructor.
3353
3544
  *
@@ -3795,7 +3986,7 @@ export declare function isJSONPrimitive(value: unknown): value is JSONPrimitive;
3795
3986
  * instances, class instances, `NaN`, and `±Infinity`. Arrays and plain records
3796
3987
  * are walked with an ancestor set so recursive input fails instead of hanging.
3797
3988
  * The whole walk runs inside `holds`, as `.claude/rules/patterns.md`
3798
- * § Validation and contracts requires: a hostile getter on a
3989
+ * § Validation and contracts requires: an untrusted getter on a
3799
3990
  * record property, or a revoked `Proxy` anywhere in the structure, is caught
3800
3991
  * and yields `false` instead of escaping as a thrown error.
3801
3992
  *
@@ -4086,12 +4277,14 @@ export declare function isPromiseLike<T = unknown>(value: unknown): value is Pro
4086
4277
  * The total form of the shared {@link matchesRecordBrand} rule, and the only
4087
4278
  * one a guard may use: the whole brand runs inside `holds`, as
4088
4279
  * `.claude/rules/patterns.md` § Validation and contracts requires, so a
4089
- * revoked `Proxy` or a hostile `getPrototypeOf` trap answers `false` instead of
4280
+ * revoked `Proxy` or an untrusted `getPrototypeOf` trap answers `false` instead of
4090
4281
  * escaping as a thrown error. Use instead of {@link isObject} to distinguish a
4091
4282
  * plain `{}` / `Object.create(null)` — or a plain object from another realm,
4092
4283
  * whose prototype is that realm's `Object.prototype` — from arrays, `Date`,
4093
4284
  * `Map`, and class instances, including a class whose prototype a caller
4094
- * reparented to `null`.
4285
+ * reparented to `null`. For a value another package or the host returns, such as a
4286
+ * socket or a store, guard the members you read with {@link objectOf} or declare them
4287
+ * with {@link interfaceShape}.
4095
4288
  *
4096
4289
  * @param value - The value to inspect
4097
4290
  * @returns True if the value is a plain record; false otherwise
@@ -4111,7 +4304,7 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
4111
4304
  * @remarks
4112
4305
  * A total native internal-slot brand check rather than a property read: it accepts a
4113
4306
  * genuine pattern from this realm and from another, and refuses a proxy or a hand-built
4114
- * forgery without reading an advertised field.
4307
+ * fake without reading an advertised field.
4115
4308
  *
4116
4309
  * @param value - The value to inspect
4117
4310
  * @returns True if the value is a `RegExp`; false otherwise
@@ -4124,6 +4317,23 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
4124
4317
  */
4125
4318
  export declare function isRegExp(value: unknown): value is RegExp;
4126
4319
 
4320
+ /**
4321
+ * Determines whether a value is a primitive number that is an integer within the safe range.
4322
+ *
4323
+ * @remarks
4324
+ * Answers `Number.isSafeInteger`: `-0` passes, and no value is coerced.
4325
+ *
4326
+ * @param value - The value to inspect
4327
+ * @returns True if the value is an integer from `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`; false otherwise
4328
+ *
4329
+ * @example
4330
+ * ```ts
4331
+ * isSafeInteger(42) // true
4332
+ * isSafeInteger(Number.MAX_SAFE_INTEGER + 1) // false
4333
+ * ```
4334
+ */
4335
+ export declare function isSafeInteger(value: unknown): value is number;
4336
+
4127
4337
  /** Determines whether a value is a `Set`.
4128
4338
  *
4129
4339
  * @param value - The value to inspect
@@ -4396,7 +4606,7 @@ export declare const JSON_SCHEMA_TYPES: readonly JSONSchemaType[];
4396
4606
  * permanently. Success replays the exact frozen root; failure rethrows the
4397
4607
  * exact class-owned error. Nonredirectable terminal failure releases partial
4398
4608
  * traversal working state while retaining the source and exact error. Reentry
4399
- * poisons the active operation and every later call with one shared cause-free
4609
+ * invalidates the active operation and every later call with one shared cause-free
4400
4610
  * error.
4401
4611
  *
4402
4612
  * @param value - The unknown value to retain for cloning
@@ -4446,7 +4656,7 @@ export declare interface JSONClonerInterface {
4446
4656
  * loaded and read every diagnostic option as an own property, so terminal settlement
4447
4657
  * stays nonredirectable against a replaced intrinsic and against a polluted prototype
4448
4658
  * alike. Active reentry permanently settles the instance with one exact cause-free
4449
- * `clone` poison shared by the nested call, the outer call, and every later call.
4659
+ * `clone` refusal shared by the nested call, the outer call, and every later call.
4450
4660
  *
4451
4661
  * @param budget - Remaining nodes shared with an enclosing ownership operation; omitted for an independent snapshot
4452
4662
  * @returns The settled JSON snapshot
@@ -4513,6 +4723,8 @@ export declare interface JSONSchema {
4513
4723
  readonly format?: string;
4514
4724
  readonly minimum?: number;
4515
4725
  readonly maximum?: number;
4726
+ readonly exclusiveMinimum?: number;
4727
+ readonly exclusiveMaximum?: number;
4516
4728
  readonly minItems?: number;
4517
4729
  readonly maxItems?: number;
4518
4730
  readonly items?: JSONSchema;
@@ -4576,7 +4788,7 @@ export declare interface JSONShapeOptions {
4576
4788
  *
4577
4789
  * @remarks
4578
4790
  * The static type admits any `number` because TypeScript cannot express
4579
- * finiteness. The {@link isJSONValue} guard rejects `NaN` and `±Infinity` since
4791
+ * finiteness. The {@link isJSONValue} guard rejects `NaN` and `±Infinity` because
4580
4792
  * they have no JSON representation.
4581
4793
  *
4582
4794
  * @example
@@ -4658,7 +4870,7 @@ export declare interface KeyStep {
4658
4870
  * Each lazy guard tracks its active invocation depth. An invocation that would
4659
4871
  * exceed {@link GUARD_DEPTH_LIMIT} returns `false` before resolving `thunk`; the
4660
4872
  * counter always unwinds after the contained call, so one deep or cyclic input
4661
- * cannot poison later guard calls.
4873
+ * cannot corrupt later guard calls.
4662
4874
  *
4663
4875
  * @param thunk - The factory producing the guard to apply, called on every invocation
4664
4876
  * @returns A guard deferring each call to the thunk's guard
@@ -4805,6 +5017,26 @@ export declare function mapOf(keyPredicate: (value: unknown) => boolean, valuePr
4805
5017
  */
4806
5018
  export declare function matchesCalendarDate(value: string): boolean;
4807
5019
 
5020
+ /**
5021
+ * Checks whether no number satisfies a set of number bounds.
5022
+ *
5023
+ * @remarks
5024
+ * Compares the bounds as real numbers: `min` and `max` admit their own value, and `over` and
5025
+ * `under` admit only a value beyond theirs. With `integer: true` a whole number must also lie
5026
+ * between them. An absent bound constrains nothing.
5027
+ *
5028
+ * @param bounds - The bounds to check
5029
+ * @returns True if no number satisfies the bounds; false otherwise
5030
+ *
5031
+ * @example
5032
+ * ```ts
5033
+ * matchesEmptyRange({ over: 1, under: 1 }) // true
5034
+ * matchesEmptyRange({ min: 1, max: 1 }) // false
5035
+ * matchesEmptyRange({ over: 0, under: 1, integer: true }) // true
5036
+ * ```
5037
+ */
5038
+ export declare function matchesEmptyRange(bounds: NumberShapeOptions): boolean;
5039
+
4808
5040
  /**
4809
5041
  * Checks whether an object owns no key outside the enumerable string keys already read from it.
4810
5042
  *
@@ -4879,7 +5111,7 @@ export declare function matchesISOInstant(value: string): boolean;
4879
5111
  * the alias already fit. Arrays are traversed through their reflected
4880
5112
  * own-index population, so sparse work is proportional to populated entries
4881
5113
  * rather than advertised length. Every observable operation is contained;
4882
- * hostile or contradictory reads return `false`.
5114
+ * untrusted or contradictory reads return `false`.
4883
5115
  *
4884
5116
  * The walk carries a settled-depth memo beside its active-path set: a
4885
5117
  * container that fit at depth `d` also fits at any depth `<= d`, because every
@@ -4967,7 +5199,7 @@ export declare function matchesKeyPlan(this: readonly string[], plan: readonly K
4967
5199
  * `parse`'s coercions are published and form input relies on them, but some change what
4968
5200
  * a value means: `1` to `true`, `'9007199254740993'` to `...992`, `'1e-400'` to `0`,
4969
5201
  * `'0x10'` to `16`. A door that must not guess asks this about each fault `audit` reported,
4970
- * since `audit` already names every nested repair with its path and the kind it wanted.
5202
+ * because `audit` already names every nested repair with its path and the kind it wanted.
4971
5203
  *
4972
5204
  * Only a `type` fault is a repair. A number needs a string whose trim is the number's own
4973
5205
  * text, so `'30'` and `' 30 '` pass while `'30.0'`, `'007'`, `'0x10'`, `'1e3'`, `'+5'`,
@@ -5035,7 +5267,7 @@ export declare function matchesMember(members: ReadonlySet<unknown>, value: unkn
5035
5267
  export declare function matchesPattern(pattern: RegExp, value: string): boolean;
5036
5268
 
5037
5269
  /**
5038
- * Determines whether a value carries the plain-record brand, raising a hostile
5270
+ * Determines whether a value carries the plain-record brand, raising an untrusted
5039
5271
  * prototype observation instead of answering it.
5040
5272
  *
5041
5273
  * @remarks
@@ -5051,14 +5283,14 @@ export declare function matchesPattern(pattern: RegExp, value: string): boolean;
5051
5283
  * therefore identified by the own members ECMAScript requires every realm to
5052
5284
  * put on it (`constructor`, `hasOwnProperty`, `isPrototypeOf`,
5053
5285
  * `propertyIsEnumerable`, `toLocaleString`, `toString`, `valueOf`), each read
5054
- * through its own DESCRIPTOR so no accessor on a hostile prototype ever runs.
5286
+ * through its own DESCRIPTOR so no accessor on an untrusted prototype ever runs.
5055
5287
  * Each must be an own DATA property whose value is a FUNCTION — true of every
5056
5288
  * conformant realm, so the requirement costs a genuine foreign record nothing,
5057
- * and it refuses the cheapest forgery (stamping the mandated names with
5289
+ * and it refuses the cheapest fake (stamping the mandated names with
5058
5290
  * `undefined`) for free.
5059
5291
  *
5060
5292
  * That is a structural test, not a provenance one, and the residual is stated
5061
- * as exactly what it is: a FUNCTION-VALUED forgery passes, and this realm's own
5293
+ * as exactly what it is: a FUNCTION-VALUED fake passes, and this realm's own
5062
5294
  * `Object.prototype` supplies those functions to stamp, so the price is a
5063
5295
  * few lines rather than nothing. Reparenting a class prototype to `null` and
5064
5296
  * stamping the mandated names with real functions passes; so does leaving the
@@ -5066,31 +5298,31 @@ export declare function matchesPattern(pattern: RegExp, value: string): boolean;
5066
5298
  * `null` as its own prototype and answers those descriptor reads with
5067
5299
  * functions. In both cases the value is a live class instance whose methods are
5068
5300
  * still reachable on it. A further own-key SUBSET rule buys even less: it
5069
- * refuses a forgery that left methods on its prototype and accepts the same
5301
+ * refuses a fake that left methods on its prototype and accepts the same
5070
5302
  * class with those methods moved onto the instance, where they are
5071
5303
  * indistinguishable from a plain record's function
5072
- * properties — so it raises the forgery's price and narrows the realm-agnostic
5304
+ * properties — so it raises the fake's price and narrows the realm-agnostic
5073
5305
  * arm this rule exists to keep open. What the pass buys is acceptance at
5074
5306
  * brand-governed doors and nothing after it: every ownership engine publishes a
5075
5307
  * frozen plain record built only from captured data, so no class instance,
5076
- * class behavior, or forged prototype survives into a snapshot.
5308
+ * class behavior, or fabricated prototype survives into a snapshot.
5077
5309
  *
5078
5310
  * `Object.create(<null-prototype object>)` is refused, and NOT because it is
5079
- * structurally identical to a reparented class instance — it is not, since a
5311
+ * structurally identical to a reparented class instance — it is not, because a
5080
5312
  * class prototype always owns `constructor` and a bare `Object.create(null)`
5081
5313
  * owns nothing. It is refused as policy: no realm produces that chain for a
5082
5314
  * plain object, no consumer of it has been named, and a caller erases the
5083
5315
  * difference by deleting `constructor`.
5084
5316
  *
5085
5317
  * This is the diagnosing form, deliberately NOT total: a revoked `Proxy` or a
5086
- * hostile `getPrototypeOf` trap throws out of it, so an ownership engine can
5318
+ * untrusted `getPrototypeOf` trap throws out of it, so an ownership engine can
5087
5319
  * report an unreadable value as a failed read with the exact cause rather than
5088
5320
  * as a well-formed structural refusal. {@link isRecord} is the total form for
5089
5321
  * every guard consumer and contains that throw as `false`.
5090
5322
  *
5091
5323
  * @param value - The value whose record brand to inspect
5092
5324
  * @returns True if the value is a plain record; false otherwise
5093
- * @throws The exact value thrown by a hostile brand observation
5325
+ * @throws The exact value thrown by an untrusted brand observation
5094
5326
  *
5095
5327
  * @example
5096
5328
  * ```ts
@@ -5173,6 +5405,30 @@ export declare function matchesStringLength(value: string, min: number | undefin
5173
5405
  */
5174
5406
  export declare function matchesUndefinedField(fault: AuditFault, value: unknown, parsed: unknown): boolean;
5175
5407
 
5408
+ /**
5409
+ * Checks whether a shape node admits `undefined`, from its category, its union mode, and its
5410
+ * children's answers.
5411
+ *
5412
+ * @remarks
5413
+ * The `undefined` leaf admits it. A nullable node admits it when its inner shape does, an
5414
+ * `anyOf` union when an arm does, and a `oneOf` union when exactly one arm does. Every other
5415
+ * node refuses it. For a node a contract compiles at its root, the answer equals what that
5416
+ * contract's `is` answers for `undefined`.
5417
+ *
5418
+ * @param category - The node's category
5419
+ * @param mode - The node's union mode, `'oneOf'` or anything else for `anyOf`
5420
+ * @param children - Each structural child's answer, in slot order
5421
+ * @returns True if the node admits `undefined`; false otherwise
5422
+ *
5423
+ * @example
5424
+ * ```ts
5425
+ * matchesUndefinedNode('undefined', undefined, []) // true
5426
+ * matchesUndefinedNode('union', 'anyOf', [false, true]) // true
5427
+ * matchesUndefinedNode('union', 'oneOf', [true, true]) // false
5428
+ * ```
5429
+ */
5430
+ export declare function matchesUndefinedNode(category: unknown, mode: unknown, children: readonly boolean[]): boolean;
5431
+
5176
5432
  /**
5177
5433
  * Determines whether an object is already on a traversal's active path.
5178
5434
  *
@@ -5254,7 +5510,7 @@ export declare const NODE_LIMIT = 16384;
5254
5510
  *
5255
5511
  * The negation applies to the contained verdict, so a throwing guard is a non-match and
5256
5512
  * its negation passes. Containing the negation instead made a guard and its `notOf`
5257
- * both reject the same value, which broke `orOf(g, notOf(g))` as a tautology.
5513
+ * both reject the same value, which falsified `orOf(g, notOf(g))` as a tautology.
5258
5514
  *
5259
5515
  * @param guard - The guard or predicate to negate
5260
5516
  * @returns A guard accepting exactly the values `guard` rejects
@@ -5326,11 +5582,20 @@ export declare interface NullShapeOptions {
5326
5582
  readonly description?: string;
5327
5583
  }
5328
5584
 
5329
- /** Describes a number with optional bounds; `integer` restricts to whole numbers. */
5585
+ /**
5586
+ * Describes a number with optional bounds; `integer` restricts to whole numbers.
5587
+ *
5588
+ * @remarks
5589
+ * `min` and `max` are inclusive and emit `minimum` and `maximum`; `over` and `under` are
5590
+ * exclusive and emit `exclusiveMinimum` and `exclusiveMaximum`. Every bound is finite, and
5591
+ * bounds that no number satisfies refuse with code `range`.
5592
+ */
5330
5593
  export declare interface NumberShape {
5331
5594
  readonly category: 'number';
5332
5595
  readonly min?: number;
5596
+ readonly over?: number;
5333
5597
  readonly max?: number;
5598
+ readonly under?: number;
5334
5599
  readonly integer?: boolean;
5335
5600
  readonly description?: string;
5336
5601
  }
@@ -5339,13 +5604,13 @@ export declare interface NumberShape {
5339
5604
  * Builds a numeric {@link NumberShape}.
5340
5605
  *
5341
5606
  * @remarks
5342
- * A present `min` or `max` must be finite. `NaN` and `±Infinity` throw a `bound` {@link
5343
- * ContractError} at construction, because no finite value satisfies them and no JSON
5344
- * Schema keyword expresses them.
5607
+ * `min` and `max` are inclusive; `over` and `under` are exclusive. A present bound must be
5608
+ * finite. `NaN` and `±Infinity` throw a `bound` {@link ContractError} at construction,
5609
+ * because no finite value satisfies them and no JSON Schema keyword expresses them.
5345
5610
  *
5346
- * @param options - Optional bounds (`min` / `max`), `integer`, and `description`
5611
+ * @param options - Optional bounds (`min` / `over` / `max` / `under`), `integer`, and `description`
5347
5612
  * @returns A number shape
5348
- * @throws {ContractError} When a present bound is not finite
5613
+ * @throws {ContractError} When an option key is unknown, a present bound is not finite, or no number satisfies the bounds
5349
5614
  *
5350
5615
  * @example
5351
5616
  * ```ts
@@ -5354,10 +5619,18 @@ export declare interface NumberShape {
5354
5619
  */
5355
5620
  export declare function numberShape(options?: NumberShapeOptions): NumberShape;
5356
5621
 
5357
- /** Groups the options for {@link NumberShape} (through `numberShape` / `integerShape`). */
5622
+ /**
5623
+ * Groups the options for {@link NumberShape} (through `numberShape` / `integerShape`).
5624
+ *
5625
+ * @remarks
5626
+ * `min` and `max` admit their own value; `over` admits a value greater than it and `under` a
5627
+ * value less than it.
5628
+ */
5358
5629
  export declare interface NumberShapeOptions {
5359
5630
  readonly min?: number;
5631
+ readonly over?: number;
5360
5632
  readonly max?: number;
5633
+ readonly under?: number;
5361
5634
  readonly integer?: boolean;
5362
5635
  readonly description?: string;
5363
5636
  }
@@ -5375,7 +5648,7 @@ export declare interface NumberShapeOptions {
5375
5648
  * prototype accessors can satisfy the shape. An optional member passes when its
5376
5649
  * read value is `undefined`; otherwise its guard must accept the value. Unknown
5377
5650
  * members are never enumerated or inspected. Member-carrying functions are
5378
- * accepted. Arrays, `null`, and primitives are rejected. Hostile reads return
5651
+ * accepted. Arrays, `null`, and primitives are rejected. Untrusted reads return
5379
5652
  * `false` rather than throwing.
5380
5653
  *
5381
5654
  * @param shape - The guard shape whose declared members the object must satisfy
@@ -5585,7 +5858,8 @@ export declare function optionalOf<T>(guard: Guard<T>): Guard<T | undefined>;
5585
5858
  * `default` holds the JSON value the compiled parser fills when the property is
5586
5859
  * absent or `undefined`. It leaves `is`, `audit`, `explain`, and `generate`
5587
5860
  * unchanged, because an absent optional stays canonical. It must satisfy `inner`,
5588
- * and it may sit only on a property of a closed object with no union ancestor.
5861
+ * and it may sit only on a property of a closed object with no union or interface
5862
+ * ancestor, over an `inner` that refuses `undefined`.
5589
5863
  */
5590
5864
  export declare interface OptionalShape<S extends ContractShape = ContractShape> {
5591
5865
  readonly category: 'optional';
@@ -5598,11 +5872,12 @@ export declare interface OptionalShape<S extends ContractShape = ContractShape>
5598
5872
  *
5599
5873
  * @remarks
5600
5874
  * As an {@link objectShape} property, the field becomes a true optional property
5601
- * in the inferred type. A `default` is captured as an owned frozen copy, and the
5875
+ * in the inferred type, and as an {@link interfaceShape} member, one that may read
5876
+ * `undefined`. A `default` is captured as an owned frozen copy, and the
5602
5877
  * compiled parser fills it where the property is absent or `undefined`; the guard,
5603
5878
  * the audit, the report, and the generator keep treating the property as optional.
5604
- * The compilers refuse a default `inner` refuses, a default under a union, and a
5605
- * default on a property of an open object.
5879
+ * The compilers refuse a default `inner` refuses, a default under a union or below
5880
+ * an interface, and a default on a property of an open object.
5606
5881
  *
5607
5882
  * @param inner - The wrapped shape
5608
5883
  * @param options - Optional `default`, a JSON value
@@ -5643,6 +5918,18 @@ export declare function orOf<A, B>(left: Guard<A>, right: Guard<B>): Guard<A | B
5643
5918
 
5644
5919
  export declare function orOf(left: (value: unknown) => boolean, right: (value: unknown) => boolean): Guard<unknown>;
5645
5920
 
5921
+ /**
5922
+ * Represents a compiled owning admission — the `own` member of a {@link ContractInterface}.
5923
+ *
5924
+ * @remarks
5925
+ * The generic call returns the owned value at the argument's static type, because `Infer` types a
5926
+ * function member as `(...args: never[]) => unknown`; the unannotated call returns the contract's type.
5927
+ */
5928
+ export declare interface OwnerFunction<T> {
5929
+ <V extends T>(value: V): Result<V, ContractRefusal>;
5930
+ (value: unknown): Result<T, ContractRefusal>;
5931
+ }
5932
+
5646
5933
  /**
5647
5934
  * Rebuilds a declaration's regular expression as a stateless pattern this
5648
5935
  * package owns, and refuses an unreadable one under the reader's own name.
@@ -5687,7 +5974,7 @@ export declare function ownPattern(pattern: RegExp, reader: string): RegExp;
5687
5974
  *
5688
5975
  * @param shape - The contract shape to own
5689
5976
  * @returns A deeply cloned frozen snapshot
5690
- * @throws {ContractError} When the declaration cannot be copied faithfully, when hostile shape or raw-schema traversal prevents ownership, or when a frozen root fails validation
5977
+ * @throws {ContractError} When the declaration cannot be copied faithfully, when untrusted shape or raw-schema traversal prevents ownership, or when a frozen root fails validation
5691
5978
  *
5692
5979
  * @example
5693
5980
  * ```ts
@@ -6018,7 +6305,7 @@ export declare type Parser<T> = (value: unknown) => T | undefined;
6018
6305
  *
6019
6306
  * @remarks
6020
6307
  * Probes the record's own enumerable values before returning the reference, so a
6021
- * hostile getter is met here rather than at the caller. A failed probe throws
6308
+ * untrusted getter is met here rather than at the caller. A failed probe throws
6022
6309
  * `ContractError { code: 'structure' }` carrying `parseRecord: value could not be
6023
6310
  * read`; a readable non-record answers `undefined`.
6024
6311
  *
@@ -6276,6 +6563,29 @@ export declare const PREVIEW_LIMIT = 64;
6276
6563
  */
6277
6564
  export declare function previewParts(source: string, index: number, capacity: number, quoted: boolean): readonly string[];
6278
6565
 
6566
+ /**
6567
+ * Encodes a bounded window of a source text as preview tokens in one pass.
6568
+ *
6569
+ * @remarks
6570
+ * Gives the answer `previewParts` gives, joined, with a quoted source's opening quote: the first
6571
+ * `capacity` UTF-16 code units are encoded through one `JSON.stringify` call, DEL, the C1
6572
+ * controls, U+2028, and U+2029 take their `\u` sequences, and the encoded text is cut at
6573
+ * `capacity` to its longest prefix of complete tokens. No token the recursion keeps lies outside
6574
+ * the window, and a surrogate pair the window splits encodes as a 6-unit sequence that cannot fit.
6575
+ *
6576
+ * @param source - The source text
6577
+ * @param capacity - The UTF-16 code units left for tokens; the closing quote or `…` takes one more
6578
+ * @param quoted - If `true`, the text opens with a string quote and closes with one when the
6579
+ * source fits; if `false`, the text carries no quote
6580
+ * @returns The encoded text, closed by `…` when the source does not fit
6581
+ *
6582
+ * @example
6583
+ * ```ts
6584
+ * previewText('abc', 2, false) // 'ab…'
6585
+ * ```
6586
+ */
6587
+ export declare function previewText(source: string, capacity: number, quoted: boolean): string;
6588
+
6279
6589
  /**
6280
6590
  * Represents a deterministic random source returning a value in `[0, 1)`.
6281
6591
  *
@@ -6326,7 +6636,7 @@ export declare interface RawShape {
6326
6636
  * structurally verbatim, so here the schema claims LESS than the compiled guard
6327
6637
  * accepts — `rawShape({ type: 'string' })` emits `{ type: 'string' }` and its
6328
6638
  * guard still accepts `42`, the mirror of {@link jsonShape}'s looseness.
6329
- * `compileGenerator` throws, since an arbitrary embedded schema has no
6639
+ * `compileGenerator` throws, because an arbitrary embedded schema has no
6330
6640
  * auto-generatable sample.
6331
6641
  *
6332
6642
  * @param schema - The JSON Schema fragment to embed
@@ -6434,7 +6744,7 @@ export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Re
6434
6744
  * consumed key is read exactly once, checked for presence, and inspected for an
6435
6745
  * own descriptor while the container is enumerated once. Every successfully
6436
6746
  * read non-`undefined` consumed value enters the fresh own-enumerable snapshot,
6437
- * including an inherited or non-enumerable option. A hostile host is reported
6747
+ * including an inherited or non-enumerable option. An untrusted host is reported
6438
6748
  * uniformly as an unreadable options record, while a readable array or class
6439
6749
  * instance retains the plain-record diagnostic.
6440
6750
  *
@@ -6579,6 +6889,28 @@ export declare function readSampleMemo(memo: SampleMemo, reader: string): Sample
6579
6889
  */
6580
6890
  export declare function readSetEntries(value: ReadonlySet<unknown>): Result<readonly unknown[]>;
6581
6891
 
6892
+ /**
6893
+ * Reads a shape builder's map of child shapes into a frozen null-prototype snapshot.
6894
+ *
6895
+ * @remarks
6896
+ * Reads each own enumerable string key one time, so a key named `__proto__` lands as an own
6897
+ * member and a later edit to the caller's map cannot reach the snapshot. The children are kept
6898
+ * by identity.
6899
+ *
6900
+ * @param map - The caller's map of child shapes
6901
+ * @param door - The builder the refusal names
6902
+ * @param field - The builder field that holds the map
6903
+ * @param shape - The shape category the refusal names
6904
+ * @returns The frozen snapshot
6905
+ * @throws {ContractError} When a read fails, or when the map is not a plain record
6906
+ *
6907
+ * @example
6908
+ * ```ts
6909
+ * readShapeMap({ city: stringShape() }, 'objectShape', 'properties', 'object').city // the same string shape
6910
+ * ```
6911
+ */
6912
+ export declare function readShapeMap<P extends Readonly<Record<string, ContractShape>>>(map: P, door: string, field: string, shape: string): P;
6913
+
6582
6914
  /**
6583
6915
  * Reads a value through the shared containment boundary or refuses it with the
6584
6916
  * contract module's uniform read diagnostic.
@@ -6676,6 +7008,27 @@ export declare interface RecordShapeOptions {
6676
7008
  readonly description?: string;
6677
7009
  }
6678
7010
 
7011
+ /**
7012
+ * Builds the {@link ContractError} that reports an admission refusal.
7013
+ *
7014
+ * @remarks
7015
+ * The message is `<door>: ` followed by {@link describeFaults} over the refusal's faults with the
7016
+ * optional schema, or `<door>: value could not be read` when the refusal holds no fault. The code
7017
+ * is `structure`, the context carries the first fault's path and every fault, and the cause is the
7018
+ * refusal's own `cause` when it has one.
7019
+ *
7020
+ * @param refusal - The refusal an admission door answered
7021
+ * @param door - The public door name used in the diagnostic
7022
+ * @param schema - The optional schema whose keys the summary names
7023
+ * @returns The error, ready to throw
7024
+ *
7025
+ * @example
7026
+ * ```ts
7027
+ * throw refusalToError({ faults: [{ reason: 'extra', path: ['typo'] }] }, 'openStore')
7028
+ * ```
7029
+ */
7030
+ export declare function refusalToError(refusal: ContractRefusal, door: string, schema?: JSONSchema): ContractError;
7031
+
6679
7032
  /**
6680
7033
  * Refuses a validated declaration whose compiled expansion exceeds
6681
7034
  * {@link COMPILE_NODE_LIMIT}.
@@ -6726,6 +7079,41 @@ export declare function refuseExpansion(expansion: number | undefined): void;
6726
7079
  */
6727
7080
  export declare function refuseOptionKeys(source: object | undefined, keys: readonly string[], builder: string, shape: string): void;
6728
7081
 
7082
+ /**
7083
+ * Refuses a value that fails a guard with a located, uniform diagnostic, and narrows it when the
7084
+ * guard holds.
7085
+ *
7086
+ * @remarks
7087
+ * Runs the guard inside {@link holds}, so a guard that throws refuses. The refusal reads
7088
+ * `<door>: <path> must be <limit>` and carries `path`, `limit`, and the {@link preview} of the
7089
+ * value as context. The code defaults to `bound`.
7090
+ *
7091
+ * @param value - The value to check
7092
+ * @param guard - The predicate that decides whether the value is acceptable
7093
+ * @param door - The public door name used in the diagnostic
7094
+ * @param options - The location, the limit text, and an optional code
7095
+ * @throws {ContractError} When the guard refuses or throws
7096
+ *
7097
+ * @example
7098
+ * ```ts
7099
+ * refuseValue(options.size, isSafeInteger, 'openStore', { path: ['size'], limit: 'a safe integer' })
7100
+ * ```
7101
+ */
7102
+ export declare function refuseValue<T>(value: unknown, guard: Guard<T>, door: string, options: RefuseValueOptions): asserts value is T;
7103
+
7104
+ /**
7105
+ * Groups the options for `refuseValue`.
7106
+ *
7107
+ * @remarks
7108
+ * `path` locates the refused value, `limit` states what the value must be, and `code` names the
7109
+ * error category and defaults to `bound`.
7110
+ */
7111
+ export declare interface RefuseValueOptions {
7112
+ readonly path: FieldPath;
7113
+ readonly limit: string;
7114
+ readonly code?: ContractCode;
7115
+ }
7116
+
6729
7117
  /**
6730
7118
  * Renders a schema as a short summary of what to send, such as `{"city": string, "note"?: string}`.
6731
7119
  *
@@ -6735,8 +7123,8 @@ export declare function refuseOptionKeys(source: object | undefined, keys: reado
6735
7123
  * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and
6736
7124
  * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past
6737
7125
  * `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.
7126
+ * A schema with an own `not` reads `function` when its `format` is `'function'`, `undefined`
7127
+ * when its `format` is `'undefined'`, and `never` otherwise.
6740
7128
  *
6741
7129
  * @param schema - The schema to summarize
6742
7130
  * @param room - The characters the summary can take. Default: `FAULT_SCHEMA_LIMIT`
@@ -6829,7 +7217,7 @@ export declare type ReporterFunction = (value: unknown, path?: readonly string[]
6829
7217
  * The root must satisfy {@link isRecord}; inherited properties are never fields.
6830
7218
  * Intermediates may be objects or arrays indexed by string. Returns `undefined`
6831
7219
  * the moment a segment is missing or lands on a non-object, so the lookup is
6832
- * total — even against a hostile getter or Proxy trap that throws on read,
7220
+ * total — even against an untrusted getter or Proxy trap that throws on read,
6833
7221
  * contained through {@link attempt} so the throw never escapes.
6834
7222
  *
6835
7223
  * @param record - The source record
@@ -6980,13 +7368,13 @@ export declare function samplesToSchema(samples: readonly unknown[], options?: V
6980
7368
  * a finite non-negative integer, selecting a valid fallback for anything else.
6981
7369
  *
6982
7370
  * @remarks
6983
- * Guards {@link valueToSchema} / {@link samplesToSchema} against a hostile or
7371
+ * Guards {@link valueToSchema} / {@link samplesToSchema} against an untrusted or
6984
7372
  * malformed budget: an unclamped `NaN` defeats every `depth <= 0` guard
6985
7373
  * (`NaN <= 0` is `false`, so recursion never halts), and a negative
6986
7374
  * `limits.properties` makes `slice(0, -1)` silently drop the LAST sorted key
6987
7375
  * instead of capping the list (a fractional value has a similarly undefined
6988
7376
  * `slice` bound). `Infinity` is rejected too — `Number.isInteger(Infinity)`
6989
- * is `false` — since an unbounded budget is exactly the adversarial case the
7377
+ * is `false` — because an unbounded budget is exactly the untrusted case the
6990
7378
  * caps exist to prevent. A valid candidate passes through unchanged without
6991
7379
  * inspecting the fallback. When the candidate is invalid, the fallback must
6992
7380
  * satisfy the same finite non-negative-integer contract or this boundary
@@ -7014,7 +7402,7 @@ export declare function sanitizeBudget(value: number | undefined, fallback: numb
7014
7402
  * @remarks
7015
7403
  * {@link sanitizeBudget} decides the SHAPE of a budget and deliberately lets any
7016
7404
  * finite non-negative integer through, because it must never read a fallback a
7017
- * hostile caller supplied. That left the depth axis unbounded from above, and
7405
+ * untrusted caller supplied. That left the depth axis unbounded from above, and
7018
7406
  * depth is the axis that recurses: `1e9` is a valid integer, so the walk descended
7019
7407
  * until the call STACK failed, at a depth that varied between runs, and the
7020
7408
  * refusal surfaced as an unreadable value rather than as the exhaustion the guard
@@ -7042,7 +7430,8 @@ export declare function sanitizeDepth(value: number | undefined): number;
7042
7430
  * @remarks
7043
7431
  * Each asserts nothing about a value, so a converted shape drops it without loss, except
7044
7432
  * `description`, which the shape keeps. A strict conversion admits them beside every
7045
- * keyword it reads, the function leaf `{ not: {}, format: 'function' }` included.
7433
+ * keyword it reads, the function leaf `{ not: {}, format: 'function' }` and the undefined
7434
+ * leaf `{ not: {}, format: 'undefined' }` included.
7046
7435
  *
7047
7436
  * @example
7048
7437
  * ```ts
@@ -7061,7 +7450,7 @@ export declare const SCHEMA_ANNOTATIONS: readonly ["title", "description", "$sch
7061
7450
  * permanently. Success replays the exact frozen root; failure rethrows the
7062
7451
  * exact class-owned error. Nonredirectable terminal settlement releases
7063
7452
  * populated traversal state before publishing that result, while retaining
7064
- * the source and exact result afterward. Reentry poisons the active operation
7453
+ * the source and exact result afterward. Reentry invalidates the active operation
7065
7454
  * and every later call with one shared cause-free error.
7066
7455
  *
7067
7456
  * @param schema - The JSON Schema graph to retain for cloning
@@ -7107,7 +7496,7 @@ export declare interface SchemaClonerInterface {
7107
7496
  * Success and failure both release traversal frames and the active memo through
7108
7497
  * preconstructed references before nonredirectable terminal publication, while
7109
7498
  * retaining the source and the exact root or class-owned error. Active reentry
7110
- * permanently settles the instance with one exact cause-free `clone` poison shared by
7499
+ * permanently settles the instance with one exact cause-free `clone` refusal shared by
7111
7500
  * the nested call, the outer call, and every later call, and a property-read cause
7112
7501
  * stays exact.
7113
7502
  *
@@ -7216,7 +7605,7 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
7216
7605
  * `Set`, a class instance, a function, a symbol, a bigint, and readable cyclic
7217
7606
  * hosts), which infer `{}` and widen back to an accept-anything
7218
7607
  * {@link rawShape}. An unreadable host is refused by {@link valueToSchema}
7219
- * before this law produces a schema; direct hostile input to
7608
+ * before this law produces a schema; direct untrusted input to
7220
7609
  * {@link schemaToShape} receives the same coded refusal.
7221
7610
  * Widening is the only source of looseness. The law has three explicit host
7222
7611
  * limits:
@@ -7258,8 +7647,9 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
7258
7647
  *
7259
7648
  * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with
7260
7649
  * code `structure`, every node the lenient walk would widen, every keyword it
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`,
7650
+ * would ignore (`pattern`, every `format` but `'date'` on a string node, `'interface'` on an
7651
+ * object node, and `'function'` or `'undefined'` in its leaf, every `not` outside those two
7652
+ * leaves, `nullable`,
7263
7653
  * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside
7264
7654
  * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry
7265
7655
  * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose
@@ -7268,11 +7658,16 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
7268
7658
  * optional property to fill. An object with no `additionalProperties` closes
7269
7659
  * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads
7270
7660
  * every keyword that could keep two arms apart. Below a `oneOf` that object refuses
7271
- * instead, since closing it could change which arms match. A strict conversion is the
7661
+ * instead, because closing it could change which arms match. A strict conversion is the
7272
7662
  * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a
7273
7663
  * 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.
7664
+ * leaf `{ not: {}, format: 'function' }` back as {@link functionShape} and the undefined
7665
+ * leaf `{ not: {}, format: 'undefined' }` back as {@link undefinedShape}, so a compiled
7666
+ * function or undefined shape round-trips too. It reads an object node with
7667
+ * `format: 'interface'` back as {@link interfaceShape}, each property outside `required` an
7668
+ * optional member, and refuses one without `additionalProperties: true` with code
7669
+ * `structure`, and one under a union or with a member `default` with code `placement`. A
7670
+ * lenient conversion reads that node as an open object.
7276
7671
  *
7277
7672
  * @param schema - The JSON Schema value to convert
7278
7673
  * @param options - Optional `strict`, default `false`
@@ -7387,6 +7782,24 @@ export declare function setOf<T>(elementGuard: Guard<T>): Guard<ReadonlySet<T>>;
7387
7782
 
7388
7783
  export declare function setOf(elementGuard: (value: unknown) => boolean): Guard<ReadonlySet<unknown>>;
7389
7784
 
7785
+ /**
7786
+ * Settles a callback's outcome, synchronous or awaited, as a {@link Result}.
7787
+ *
7788
+ * @remarks
7789
+ * Runs the callback one time. A synchronous throw, a rejection, and a thenable whose `then`
7790
+ * throws each answer a `Failure` carrying the exact thrown value, and the returned promise never
7791
+ * rejects. Use {@link attempt} where the callback is synchronous.
7792
+ *
7793
+ * @param callback - The callback to invoke with no arguments
7794
+ * @returns A `Success` carrying the awaited value, or a `Failure` carrying the exact thrown value
7795
+ *
7796
+ * @example
7797
+ * ```ts
7798
+ * const outcome = await settle(async () => readFile(path))
7799
+ * ```
7800
+ */
7801
+ export declare function settle<T>(callback: () => T | PromiseLike<T>): Promise<Result<T>>;
7802
+
7390
7803
  /**
7391
7804
  * Lists the fields recognized for every contract declaration category, frozen.
7392
7805
  *
@@ -7406,7 +7819,7 @@ export declare const SHAPE_FIELDS: Readonly<Record<string, readonly string[]>>;
7406
7819
  * permanently. Success replays the exact frozen root; failure rethrows the
7407
7820
  * exact class-owned or directly adopted error. Nonredirectable settlement
7408
7821
  * releases populated traversal state before publishing that result. Reentry
7409
- * poisons the active operation and every later call with one shared cause-free
7822
+ * invalidates the active operation and every later call with one shared cause-free
7410
7823
  * error.
7411
7824
  *
7412
7825
  * @param shape - The contract-shape graph to retain for cloning
@@ -7439,7 +7852,7 @@ export declare class ShapeCloner implements ShapeClonerInterface {
7439
7852
  * shape or exact same owned {@link ContractError}. Nonredirectable terminal
7440
7853
  * settlement releases populated traversal state before publishing that exact
7441
7854
  * result, while retaining the source and result afterward.
7442
- * Reentry permanently poisons the active operation with one shared error.
7855
+ * Reentry permanently invalidates the active operation with one shared error.
7443
7856
  */
7444
7857
  export declare interface ShapeClonerInterface {
7445
7858
  /**
@@ -7454,7 +7867,7 @@ export declare interface ShapeClonerInterface {
7454
7867
  * failure rethrows the exact class-owned or adopted {@link ContractError}. Both
7455
7868
  * release graph-working state through preconstructed references before nonredirectable
7456
7869
  * terminal publication. Active reentry permanently settles the instance with one exact
7457
- * cause-free poison shared by the nested call, the outer call, and every later call.
7870
+ * cause-free refusal shared by the nested call, the outer call, and every later call.
7458
7871
  *
7459
7872
  * @returns The settled contract-shape snapshot
7460
7873
  * @throws {ContractError} When the declaration is malformed, unreadable, cyclic, too deep, or cloning is reentered
@@ -7542,7 +7955,8 @@ export declare interface ShapeShapeOptions {
7542
7955
  * `'date'` when `date: true`, else `'string'`); `optionalShape` /
7543
7956
  * `nullableShape` project through to their inner shape's kind, and `rawShape`
7544
7957
  * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.
7545
- * `functionShape` projects to `'function'`.
7958
+ * `functionShape` projects to `'function'`, `undefinedShape` to `'undefined'`, and
7959
+ * `interfaceShape` to `'object'`.
7546
7960
  *
7547
7961
  * A hand-authored node carrying an unrecognized discriminant is REFUSED rather
7548
7962
  * than answered out of type, which keeps the declared non-optional
@@ -7568,7 +7982,7 @@ export declare function shapeToKind(shape: ContractShape): FaultKind;
7568
7982
  * @remarks
7569
7983
  * Construction performs no source observation. Every non-overlapping
7570
7984
  * {@link validate} call starts a fresh pass over the source's current state.
7571
- * Reentry poisons the active pass with one shared cause-free structure error;
7985
+ * Reentry invalidates the active pass with one shared cause-free structure error;
7572
7986
  * cleanup always restores an idle validator for the next independent call.
7573
7987
  *
7574
7988
  * @example
@@ -7683,8 +8097,10 @@ export declare function sortValues<T extends string | number>(values: readonly T
7683
8097
  * refuses. `pattern`, `format`, and `not` are absent because no compiled shape asserts
7684
8098
  * them, so a schema holding one would convert to a shape wider than the schema it came
7685
8099
  * 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.
8100
+ * reads as a date string shape, `format: 'interface'` on an object node, which it reads
8101
+ * as an interface shape, the function leaf `{ not: {}, format: 'function' }`,
8102
+ * which it reads as a function shape, and the undefined leaf
8103
+ * `{ not: {}, format: 'undefined' }`, which it reads as an undefined shape.
7688
8104
  *
7689
8105
  * @example
7690
8106
  * ```ts
@@ -7935,6 +8351,58 @@ export declare function tupleOf<const Gs extends ReadonlyArray<Guard<unknown>>>(
7935
8351
 
7936
8352
  export declare function tupleOf(...predicates: ReadonlyArray<(value: unknown) => boolean>): Guard<readonly unknown[]>;
7937
8353
 
8354
+ /**
8355
+ * Describes the `undefined` value — accepts only `undefined`.
8356
+ *
8357
+ * @remarks
8358
+ * The compiled guard is `isUndefined`. A container keeps a present `undefined` member wherever
8359
+ * its child admits `undefined`: this leaf, a union with such an arm, or a nullable over such an
8360
+ * inner. An object property present as `undefined` keeps its key in the parsed record, and an
8361
+ * absent one stays absent. JSON carries no `undefined`, so the emitted schema
8362
+ * `{ not: {}, format: 'undefined' }` admits no JSON instance. The generator returns `undefined`.
8363
+ *
8364
+ * @example
8365
+ * ```ts
8366
+ * const declaration: UndefinedShape = { category: 'undefined' }
8367
+ * createContract(declaration).is(undefined) // true
8368
+ * ```
8369
+ */
8370
+ export declare interface UndefinedShape {
8371
+ readonly category: 'undefined';
8372
+ readonly description?: string;
8373
+ }
8374
+
8375
+ /**
8376
+ * Builds an {@link UndefinedShape}.
8377
+ *
8378
+ * @remarks
8379
+ * Compose it as a union arm to declare a member that may be `undefined`: an object property
8380
+ * present as `undefined` keeps its key, while `optionalShape` keeps declaring a property that may
8381
+ * be absent.
8382
+ *
8383
+ * @param options - Optional description
8384
+ * @returns An `undefined`-valued declaration
8385
+ *
8386
+ * @example
8387
+ * ```ts
8388
+ * const limits = objectShape({ max: unionShape(numberShape(), undefinedShape()) })
8389
+ * ```
8390
+ */
8391
+ export declare function undefinedShape(options?: UndefinedShapeOptions): UndefinedShape;
8392
+
8393
+ /**
8394
+ * Configures the description of an `undefined`-valued declaration.
8395
+ *
8396
+ * @example
8397
+ * ```ts
8398
+ * const options: UndefinedShapeOptions = { description: 'No limit set' }
8399
+ * undefinedShape(options).description // 'No limit set'
8400
+ * ```
8401
+ */
8402
+ export declare interface UndefinedShapeOptions {
8403
+ readonly description?: string;
8404
+ }
8405
+
7938
8406
  /**
7939
8407
  * Unifies a list of inferred `JSONSchema` fragments into one schema.
7940
8408
  *
@@ -7953,7 +8421,7 @@ export declare function tupleOf(...predicates: ReadonlyArray<(value: unknown) =>
7953
8421
  *
7954
8422
  * A readable member {@link canonicalStringify} cannot key — a cyclic or
7955
8423
  * otherwise JSON-inexpressible fragment, which only a direct caller can supply
7956
- * since the inferers always build plain encodable fragments — has NO
8424
+ * because the inferers always build plain encodable fragments — has NO
7957
8425
  * de-duplication key, so it can participate in neither de-duplication nor the
7958
8426
  * canonical-key ordering. It is KEPT (dropping a variant would narrow the
7959
8427
  * union, and unification only ever widens), appended in input order after the