@orkestrel/contract 0.0.10 → 0.0.12

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.
@@ -118,7 +118,7 @@ export declare function arrayOf(elementGuard: (value: unknown) => boolean): Guar
118
118
  */
119
119
  export declare interface ArrayRead<T = unknown> {
120
120
  /** Frozen native entries in index order, retaining sparse positions as holes. */
121
- readonly entries: readonly (T | undefined)[];
121
+ readonly entries: ReadonlyArray<T | undefined>;
122
122
  /** Whether every index from zero through length minus one was reflected. */
123
123
  readonly dense: boolean;
124
124
  }
@@ -1890,10 +1890,10 @@ export declare function holds(callback: () => boolean): boolean;
1890
1890
  export declare type Infer<S extends ContractShape> = [ContractShape] extends [S] ? unknown : S extends StringShape ? string : S extends NumberShape ? number : S extends BooleanShape ? boolean : S extends NullShape ? null : S extends {
1891
1891
  readonly type: 'literal';
1892
1892
  readonly values: infer V;
1893
- } ? V extends readonly (infer L)[] ? L : never : S extends {
1893
+ } ? V extends ReadonlyArray<infer L> ? L : never : S extends {
1894
1894
  readonly type: 'array';
1895
1895
  readonly items: infer I;
1896
- } ? I extends ContractShape ? readonly Infer<I>[] : never : S extends ObjectShape<infer P, infer A> ? P extends Readonly<Record<string, ContractShape>> ? [A] extends [boolean | ContractShape] ? InferObject<P, A> : never : never : S extends {
1896
+ } ? I extends ContractShape ? ReadonlyArray<Infer<I>> : never : S extends ObjectShape<infer P, infer A> ? P extends Readonly<Record<string, ContractShape>> ? [A] extends [boolean | ContractShape] ? InferObject<P, A> : never : never : S extends {
1897
1897
  readonly type: 'union';
1898
1898
  readonly variants: infer V;
1899
1899
  } ? V extends readonly ContractShape[] ? InferUnion<V> : never : S extends {
@@ -1916,14 +1916,21 @@ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S]
1916
1916
  export declare const INFER_BREADTH_LIMIT = 256;
1917
1917
 
1918
1918
  /**
1919
- * The default maximum object/array nesting depth {@link valueToSchema} walks,
1920
- * frozen.
1919
+ * The maximum object/array nesting depth {@link valueToSchema} walks, frozen.
1921
1920
  *
1922
1921
  * @remarks
1923
1922
  * Bounds inference against adversarial or cyclic runtime input — once the
1924
1923
  * remaining depth budget reaches zero, inference stops descending and emits
1925
1924
  * the empty accept-anything schema `{}` for that branch instead of recursing
1926
- * further. Overridable per call via {@link ValueToSchemaOptions.maxDepth}.
1925
+ * further. LOWERABLE per call via {@link ValueToSchemaOptions.maxDepth}; a
1926
+ * higher value is held here.
1927
+ *
1928
+ * A ceiling rather than a default, because the walk recurses: what a deeper
1929
+ * walk spends is the JavaScript call stack rather than this budget, and that
1930
+ * stack is not a fixed quantity. The survivable depth measured on one host rose
1931
+ * across repeated calls within a single process as the engine optimized, and
1932
+ * fell to roughly this number under a reduced stack size. Any larger constant
1933
+ * therefore has a host where it fails, which is why none is published.
1927
1934
  */
1928
1935
  export declare const INFER_DEPTH_LIMIT = 32;
1929
1936
 
@@ -2204,7 +2211,7 @@ export declare function inferPrimitiveEnum(values: readonly unknown[], limit: nu
2204
2211
  * // required: ['id'], additionalProperties: false }
2205
2212
  * ```
2206
2213
  */
2207
- export declare function inferRecordSamples(samples: readonly Record<string, unknown>[], depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2214
+ export declare function inferRecordSamples(samples: ReadonlyArray<Record<string, unknown>>, depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2208
2215
 
2209
2216
  /**
2210
2217
  * Infer a `JSONSchema` for a collected slot of sample values — the shared
@@ -2245,7 +2252,7 @@ export declare function inferRecordSamples(samples: readonly Record<string, unkn
2245
2252
  export declare function inferSamples(samples: readonly unknown[], depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2246
2253
 
2247
2254
  /** {@link Infer} of a union shape's `variants` — the union of each variant's inferred type. */
2248
- export declare type InferUnion<V extends readonly ContractShape[]> = V extends readonly (infer U)[] ? U extends ContractShape ? Infer<U> : never : never;
2255
+ export declare type InferUnion<V extends readonly ContractShape[]> = V extends ReadonlyArray<infer U> ? (U extends ContractShape ? Infer<U> : never) : never;
2249
2256
 
2250
2257
  /**
2251
2258
  * Infer a `JSONSchema` fragment for one runtime value — the recursive spine
@@ -3789,9 +3796,9 @@ export declare function limitEntries<T>(entries: readonly T[], limit: number): r
3789
3796
  * const isSameRole = literalOf(['admin', 'member', 'guest']) // the same guard, from an array
3790
3797
  * ```
3791
3798
  */
3792
- export declare function literalOf<const Literals extends ReadonlyArray<LiteralValue>>(literals: Literals): Guard<Literals[number]>;
3799
+ export declare function literalOf<const Literals extends readonly LiteralValue[]>(literals: Literals): Guard<Literals[number]>;
3793
3800
 
3794
- export declare function literalOf<const Literals extends ReadonlyArray<LiteralValue>>(...literals: Literals): Guard<Literals[number]>;
3801
+ export declare function literalOf<const Literals extends readonly LiteralValue[]>(...literals: Literals): Guard<Literals[number]>;
3795
3802
 
3796
3803
  /** A literal shape — accepts exactly one of a fixed set of primitive values. */
3797
3804
  export declare interface LiteralShape<T extends readonly LiteralValue[] = readonly LiteralValue[]> {
@@ -3924,7 +3931,7 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
3924
3931
  * matchesMember(collectMembers([Number.NaN]), Number.NaN) // true — SameValueZero
3925
3932
  * ```
3926
3933
  */
3927
- export declare function matchesMember(members: Set<unknown>, value: unknown): boolean;
3934
+ export declare function matchesMember(members: ReadonlySet<unknown>, value: unknown): boolean;
3928
3935
 
3929
3936
  /**
3930
3937
  * Determine whether a string is in the language of a pattern this package owns.
@@ -4163,6 +4170,14 @@ export declare interface NumberShapeOptions {
4163
4170
  readonly description?: string;
4164
4171
  }
4165
4172
 
4173
+ export declare function objectOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>;
4174
+
4175
+ export declare function objectOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(shape: S, optional: K): Guard<OptionalFromGuards<S, K>>;
4176
+
4177
+ export declare function objectOf<S extends GuardsShape>(shape: S, optional: true): Guard<Readonly<{
4178
+ [P in keyof S]?: FromGuards<S>[P];
4179
+ }>>;
4180
+
4166
4181
  /**
4167
4182
  * An object shape — a map of property names to child shapes.
4168
4183
  *
@@ -4733,7 +4748,7 @@ export declare function parseStringField(record: Record<string, unknown>, path:
4733
4748
  * pathOf(path) // an owned copy
4734
4749
  * ```
4735
4750
  */
4736
- export declare function pathOf(path: readonly string[], ...segments: readonly (string | undefined)[]): readonly string[];
4751
+ export declare function pathOf(path: readonly string[], ...segments: ReadonlyArray<string | undefined>): readonly string[];
4737
4752
 
4738
4753
  /**
4739
4754
  * Build a new guard shape by keeping only the listed keys — the structural
@@ -4909,6 +4924,34 @@ export declare function rawShape(schema: JSONSchema): RawShape;
4909
4924
  */
4910
4925
  export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>>;
4911
4926
 
4927
+ /**
4928
+ * Snapshot a guard shape and its optional-key mode for a shape combinator.
4929
+ *
4930
+ * @remarks
4931
+ * A null-prototype record plus its own key list is used instead of a `Map`.
4932
+ * The declared-key population decides the guard's answer, and
4933
+ * `Map.prototype.has`, `Map.prototype.get`, and map iteration are three
4934
+ * caller-writable members on that path. An own data key read by index
4935
+ * dispatches through nothing.
4936
+ *
4937
+ * @param shape - The guard shape whose own string declarations to snapshot
4938
+ * @param optional - The optional-key list, `true` for every key, or `undefined`
4939
+ * @param reader - The public combinator name used in read refusals
4940
+ * @returns The owned guards and names plus the collected optional-key membership
4941
+ * @throws {ContractError} When the shape or optional-key list cannot be read
4942
+ *
4943
+ * @example
4944
+ * ```ts
4945
+ * readGuardShape({ id: isString }, undefined, 'recordOf')
4946
+ * ```
4947
+ */
4948
+ export declare function readGuardShape(shape: GuardsShape, optional: readonly string[] | true | undefined, reader: string): Readonly<{
4949
+ readonly guards: Readonly<Record<string, Guard<unknown> | undefined>>;
4950
+ readonly names: readonly string[];
4951
+ readonly optional: ReadonlySet<unknown>;
4952
+ readonly vocabulary: ReadonlySet<unknown>;
4953
+ }>;
4954
+
4912
4955
  /**
4913
4956
  * Snapshot the genuine entries of a caller's `Map` without running an iterator.
4914
4957
  *
@@ -4928,7 +4971,7 @@ export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRe
4928
4971
  * readMapEntries(new Map([['a', 1]])) // { success: true, value: [['a', 1]] }
4929
4972
  * ```
4930
4973
  */
4931
- export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Result<readonly (readonly unknown[])[]>;
4974
+ export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Result<ReadonlyArray<readonly unknown[]>>;
4932
4975
 
4933
4976
  /**
4934
4977
  * Validate and snapshot a shape-builder options record through every reflective
@@ -4956,7 +4999,7 @@ export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Re
4956
4999
  * const options = readOptions(source, ['min', 'max'], 'numberShape', 'number')
4957
5000
  * ```
4958
5001
  */
4959
- export declare function readOptions<T extends object>(source: T | undefined, keys: readonly (keyof T & string)[], builder: string, shape: string): T | undefined;
5002
+ export declare function readOptions<T extends object>(source: T | undefined, keys: ReadonlyArray<keyof T & string>, builder: string, shape: string): T | undefined;
4960
5003
 
4961
5004
  /**
4962
5005
  * Rebuild a caller's regular expression as a stateless pattern this package
@@ -5301,8 +5344,9 @@ export declare function samplesToFormat(values: readonly unknown[]): SchemaForma
5301
5344
  * and `enum` (both default `false`) opt a low-cardinality/unanimous-format
5302
5345
  * slot into the corresponding keyword — see {@link inferSamples} for the
5303
5346
  * precedence and the multi-sample format-disabling seam. `maxDepth` /
5304
- * `maxProperties` are sanitized via {@link sanitizeBudget} the same way
5305
- * {@link valueToSchema} sanitizes them — see there for why.
5347
+ * `maxProperties` are resolved exactly as {@link valueToSchema} resolves them —
5348
+ * breadth through {@link sanitizeBudget}, depth through {@link sanitizeDepth},
5349
+ * which also caps at {@link INFER_DEPTH_LIMIT}; see there for why.
5306
5350
  *
5307
5351
  * @param samples - The example values to infer a schema from
5308
5352
  * @param options - Optional `maxDepth` / `maxProperties` / `closed` / `format` / `enum` bounds
@@ -5352,6 +5396,34 @@ export declare function samplesToSchema(samples: readonly unknown[], options?: V
5352
5396
  */
5353
5397
  export declare function sanitizeBudget(value: number | undefined, fallback: number): number;
5354
5398
 
5399
+ /**
5400
+ * Resolve a caller's depth budget to one the traversal can actually survive.
5401
+ *
5402
+ * @remarks
5403
+ * {@link sanitizeBudget} decides the SHAPE of a budget and deliberately lets any
5404
+ * finite non-negative integer through, because it must never read a fallback a
5405
+ * hostile caller supplied. That left the depth axis unbounded from above, and
5406
+ * depth is the axis that recurses: `1e9` is a valid integer, so the walk descended
5407
+ * until the call STACK failed, at a depth that varied between runs, and the
5408
+ * refusal surfaced as an unreadable value rather than as the exhaustion the guard
5409
+ * promises. Breadth needs no such ceiling — its loop is already bounded by the
5410
+ * entries actually present.
5411
+ *
5412
+ * So {@link INFER_DEPTH_LIMIT} is the ceiling as well as the default, and
5413
+ * `maxDepth` narrows the walk rather than widening it. One bound, and the same
5414
+ * answer on every host.
5415
+ *
5416
+ * @param value - The candidate depth budget
5417
+ * @returns A finite non-negative integer no greater than `INFER_DEPTH_LIMIT`
5418
+ *
5419
+ * @example
5420
+ * ```ts
5421
+ * sanitizeDepth(4) // 4
5422
+ * sanitizeDepth(1e9) // 32
5423
+ * ```
5424
+ */
5425
+ export declare function sanitizeDepth(value: number | undefined): number;
5426
+
5355
5427
  /**
5356
5428
  * Stateful owner of one JSON Schema snapshot operation.
5357
5429
  *
@@ -5649,7 +5721,7 @@ export declare type SeederFunction<T> = (random?: RandomFunction) => T;
5649
5721
  * selectClosestFaults([]) // []
5650
5722
  * ```
5651
5723
  */
5652
- export declare function selectClosestFaults<T extends AuditFault>(reports: readonly (readonly T[])[]): readonly T[];
5724
+ export declare function selectClosestFaults<T extends AuditFault>(reports: ReadonlyArray<readonly T[]>): readonly T[];
5653
5725
 
5654
5726
  /**
5655
5727
  * Build a guard that accepts `Set` instances whose every element satisfies
@@ -6176,11 +6248,16 @@ export declare function validateShapeDepth(shape: ContractShape): void;
6176
6248
  * expect an object-shaped `inputSchema`; wrap a non-object payload with
6177
6249
  * {@link schemaToObject} before advertising it as a tool's parameters.
6178
6250
  *
6179
- * `maxDepth` / `maxProperties` are sanitized via {@link sanitizeBudget} to a
6180
- * finite non-negative integer, falling back to {@link INFER_DEPTH_LIMIT} /
6181
- * {@link INFER_BREADTH_LIMIT} for anything else (`NaN`, `Infinity`, negative,
6182
- * fractional) — a hostile or malformed budget can never defeat the depth
6183
- * guard or corrupt the sampled key/element list.
6251
+ * `maxProperties` is sanitized via {@link sanitizeBudget} to a finite
6252
+ * non-negative integer, falling back to {@link INFER_BREADTH_LIMIT} for anything
6253
+ * else (`NaN`, `Infinity`, negative, fractional), so a malformed breadth cannot
6254
+ * corrupt the sampled key/element list.
6255
+ *
6256
+ * `maxDepth` goes through {@link sanitizeDepth}, which does the same and then caps
6257
+ * at {@link INFER_DEPTH_LIMIT}, so the option NARROWS the walk and cannot widen
6258
+ * it. The cap is what makes the depth guard unbreakable: depth is the recursing
6259
+ * axis, and a large-but-valid budget used to descend until the call STACK failed
6260
+ * rather than until the guard said stop.
6184
6261
  *
6185
6262
  * @param value - The value to infer a schema from
6186
6263
  * @param options - Optional `maxDepth` / `maxProperties` / `closed` / `format` bounds
@@ -118,7 +118,7 @@ export declare function arrayOf(elementGuard: (value: unknown) => boolean): Guar
118
118
  */
119
119
  export declare interface ArrayRead<T = unknown> {
120
120
  /** Frozen native entries in index order, retaining sparse positions as holes. */
121
- readonly entries: readonly (T | undefined)[];
121
+ readonly entries: ReadonlyArray<T | undefined>;
122
122
  /** Whether every index from zero through length minus one was reflected. */
123
123
  readonly dense: boolean;
124
124
  }
@@ -1890,10 +1890,10 @@ export declare function holds(callback: () => boolean): boolean;
1890
1890
  export declare type Infer<S extends ContractShape> = [ContractShape] extends [S] ? unknown : S extends StringShape ? string : S extends NumberShape ? number : S extends BooleanShape ? boolean : S extends NullShape ? null : S extends {
1891
1891
  readonly type: 'literal';
1892
1892
  readonly values: infer V;
1893
- } ? V extends readonly (infer L)[] ? L : never : S extends {
1893
+ } ? V extends ReadonlyArray<infer L> ? L : never : S extends {
1894
1894
  readonly type: 'array';
1895
1895
  readonly items: infer I;
1896
- } ? I extends ContractShape ? readonly Infer<I>[] : never : S extends ObjectShape<infer P, infer A> ? P extends Readonly<Record<string, ContractShape>> ? [A] extends [boolean | ContractShape] ? InferObject<P, A> : never : never : S extends {
1896
+ } ? I extends ContractShape ? ReadonlyArray<Infer<I>> : never : S extends ObjectShape<infer P, infer A> ? P extends Readonly<Record<string, ContractShape>> ? [A] extends [boolean | ContractShape] ? InferObject<P, A> : never : never : S extends {
1897
1897
  readonly type: 'union';
1898
1898
  readonly variants: infer V;
1899
1899
  } ? V extends readonly ContractShape[] ? InferUnion<V> : never : S extends {
@@ -1916,14 +1916,21 @@ export declare type Infer<S extends ContractShape> = [ContractShape] extends [S]
1916
1916
  export declare const INFER_BREADTH_LIMIT = 256;
1917
1917
 
1918
1918
  /**
1919
- * The default maximum object/array nesting depth {@link valueToSchema} walks,
1920
- * frozen.
1919
+ * The maximum object/array nesting depth {@link valueToSchema} walks, frozen.
1921
1920
  *
1922
1921
  * @remarks
1923
1922
  * Bounds inference against adversarial or cyclic runtime input — once the
1924
1923
  * remaining depth budget reaches zero, inference stops descending and emits
1925
1924
  * the empty accept-anything schema `{}` for that branch instead of recursing
1926
- * further. Overridable per call via {@link ValueToSchemaOptions.maxDepth}.
1925
+ * further. LOWERABLE per call via {@link ValueToSchemaOptions.maxDepth}; a
1926
+ * higher value is held here.
1927
+ *
1928
+ * A ceiling rather than a default, because the walk recurses: what a deeper
1929
+ * walk spends is the JavaScript call stack rather than this budget, and that
1930
+ * stack is not a fixed quantity. The survivable depth measured on one host rose
1931
+ * across repeated calls within a single process as the engine optimized, and
1932
+ * fell to roughly this number under a reduced stack size. Any larger constant
1933
+ * therefore has a host where it fails, which is why none is published.
1927
1934
  */
1928
1935
  export declare const INFER_DEPTH_LIMIT = 32;
1929
1936
 
@@ -2204,7 +2211,7 @@ export declare function inferPrimitiveEnum(values: readonly unknown[], limit: nu
2204
2211
  * // required: ['id'], additionalProperties: false }
2205
2212
  * ```
2206
2213
  */
2207
- export declare function inferRecordSamples(samples: readonly Record<string, unknown>[], depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2214
+ export declare function inferRecordSamples(samples: ReadonlyArray<Record<string, unknown>>, depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2208
2215
 
2209
2216
  /**
2210
2217
  * Infer a `JSONSchema` for a collected slot of sample values — the shared
@@ -2245,7 +2252,7 @@ export declare function inferRecordSamples(samples: readonly Record<string, unkn
2245
2252
  export declare function inferSamples(samples: readonly unknown[], depth: number, breadth: number, closed: boolean, format: boolean, enumOn: boolean, memo: SampleMemo): JSONSchema;
2246
2253
 
2247
2254
  /** {@link Infer} of a union shape's `variants` — the union of each variant's inferred type. */
2248
- export declare type InferUnion<V extends readonly ContractShape[]> = V extends readonly (infer U)[] ? U extends ContractShape ? Infer<U> : never : never;
2255
+ export declare type InferUnion<V extends readonly ContractShape[]> = V extends ReadonlyArray<infer U> ? (U extends ContractShape ? Infer<U> : never) : never;
2249
2256
 
2250
2257
  /**
2251
2258
  * Infer a `JSONSchema` fragment for one runtime value — the recursive spine
@@ -3789,9 +3796,9 @@ export declare function limitEntries<T>(entries: readonly T[], limit: number): r
3789
3796
  * const isSameRole = literalOf(['admin', 'member', 'guest']) // the same guard, from an array
3790
3797
  * ```
3791
3798
  */
3792
- export declare function literalOf<const Literals extends ReadonlyArray<LiteralValue>>(literals: Literals): Guard<Literals[number]>;
3799
+ export declare function literalOf<const Literals extends readonly LiteralValue[]>(literals: Literals): Guard<Literals[number]>;
3793
3800
 
3794
- export declare function literalOf<const Literals extends ReadonlyArray<LiteralValue>>(...literals: Literals): Guard<Literals[number]>;
3801
+ export declare function literalOf<const Literals extends readonly LiteralValue[]>(...literals: Literals): Guard<Literals[number]>;
3795
3802
 
3796
3803
  /** A literal shape — accepts exactly one of a fixed set of primitive values. */
3797
3804
  export declare interface LiteralShape<T extends readonly LiteralValue[] = readonly LiteralValue[]> {
@@ -3924,7 +3931,7 @@ export declare function matchesJSONValue(entry: unknown, ancestors: WeakSet<obje
3924
3931
  * matchesMember(collectMembers([Number.NaN]), Number.NaN) // true — SameValueZero
3925
3932
  * ```
3926
3933
  */
3927
- export declare function matchesMember(members: Set<unknown>, value: unknown): boolean;
3934
+ export declare function matchesMember(members: ReadonlySet<unknown>, value: unknown): boolean;
3928
3935
 
3929
3936
  /**
3930
3937
  * Determine whether a string is in the language of a pattern this package owns.
@@ -4163,6 +4170,14 @@ export declare interface NumberShapeOptions {
4163
4170
  readonly description?: string;
4164
4171
  }
4165
4172
 
4173
+ export declare function objectOf<S extends GuardsShape>(shape: S): Guard<FromGuards<S>>;
4174
+
4175
+ export declare function objectOf<S extends GuardsShape, K extends ReadonlyArray<keyof S & string>>(shape: S, optional: K): Guard<OptionalFromGuards<S, K>>;
4176
+
4177
+ export declare function objectOf<S extends GuardsShape>(shape: S, optional: true): Guard<Readonly<{
4178
+ [P in keyof S]?: FromGuards<S>[P];
4179
+ }>>;
4180
+
4166
4181
  /**
4167
4182
  * An object shape — a map of property names to child shapes.
4168
4183
  *
@@ -4733,7 +4748,7 @@ export declare function parseStringField(record: Record<string, unknown>, path:
4733
4748
  * pathOf(path) // an owned copy
4734
4749
  * ```
4735
4750
  */
4736
- export declare function pathOf(path: readonly string[], ...segments: readonly (string | undefined)[]): readonly string[];
4751
+ export declare function pathOf(path: readonly string[], ...segments: ReadonlyArray<string | undefined>): readonly string[];
4737
4752
 
4738
4753
  /**
4739
4754
  * Build a new guard shape by keeping only the listed keys — the structural
@@ -4909,6 +4924,34 @@ export declare function rawShape(schema: JSONSchema): RawShape;
4909
4924
  */
4910
4925
  export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRead<T>>;
4911
4926
 
4927
+ /**
4928
+ * Snapshot a guard shape and its optional-key mode for a shape combinator.
4929
+ *
4930
+ * @remarks
4931
+ * A null-prototype record plus its own key list is used instead of a `Map`.
4932
+ * The declared-key population decides the guard's answer, and
4933
+ * `Map.prototype.has`, `Map.prototype.get`, and map iteration are three
4934
+ * caller-writable members on that path. An own data key read by index
4935
+ * dispatches through nothing.
4936
+ *
4937
+ * @param shape - The guard shape whose own string declarations to snapshot
4938
+ * @param optional - The optional-key list, `true` for every key, or `undefined`
4939
+ * @param reader - The public combinator name used in read refusals
4940
+ * @returns The owned guards and names plus the collected optional-key membership
4941
+ * @throws {ContractError} When the shape or optional-key list cannot be read
4942
+ *
4943
+ * @example
4944
+ * ```ts
4945
+ * readGuardShape({ id: isString }, undefined, 'recordOf')
4946
+ * ```
4947
+ */
4948
+ export declare function readGuardShape(shape: GuardsShape, optional: readonly string[] | true | undefined, reader: string): Readonly<{
4949
+ readonly guards: Readonly<Record<string, Guard<unknown> | undefined>>;
4950
+ readonly names: readonly string[];
4951
+ readonly optional: ReadonlySet<unknown>;
4952
+ readonly vocabulary: ReadonlySet<unknown>;
4953
+ }>;
4954
+
4912
4955
  /**
4913
4956
  * Snapshot the genuine entries of a caller's `Map` without running an iterator.
4914
4957
  *
@@ -4928,7 +4971,7 @@ export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRe
4928
4971
  * readMapEntries(new Map([['a', 1]])) // { success: true, value: [['a', 1]] }
4929
4972
  * ```
4930
4973
  */
4931
- export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Result<readonly (readonly unknown[])[]>;
4974
+ export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Result<ReadonlyArray<readonly unknown[]>>;
4932
4975
 
4933
4976
  /**
4934
4977
  * Validate and snapshot a shape-builder options record through every reflective
@@ -4956,7 +4999,7 @@ export declare function readMapEntries(value: ReadonlyMap<unknown, unknown>): Re
4956
4999
  * const options = readOptions(source, ['min', 'max'], 'numberShape', 'number')
4957
5000
  * ```
4958
5001
  */
4959
- export declare function readOptions<T extends object>(source: T | undefined, keys: readonly (keyof T & string)[], builder: string, shape: string): T | undefined;
5002
+ export declare function readOptions<T extends object>(source: T | undefined, keys: ReadonlyArray<keyof T & string>, builder: string, shape: string): T | undefined;
4960
5003
 
4961
5004
  /**
4962
5005
  * Rebuild a caller's regular expression as a stateless pattern this package
@@ -5301,8 +5344,9 @@ export declare function samplesToFormat(values: readonly unknown[]): SchemaForma
5301
5344
  * and `enum` (both default `false`) opt a low-cardinality/unanimous-format
5302
5345
  * slot into the corresponding keyword — see {@link inferSamples} for the
5303
5346
  * precedence and the multi-sample format-disabling seam. `maxDepth` /
5304
- * `maxProperties` are sanitized via {@link sanitizeBudget} the same way
5305
- * {@link valueToSchema} sanitizes them — see there for why.
5347
+ * `maxProperties` are resolved exactly as {@link valueToSchema} resolves them —
5348
+ * breadth through {@link sanitizeBudget}, depth through {@link sanitizeDepth},
5349
+ * which also caps at {@link INFER_DEPTH_LIMIT}; see there for why.
5306
5350
  *
5307
5351
  * @param samples - The example values to infer a schema from
5308
5352
  * @param options - Optional `maxDepth` / `maxProperties` / `closed` / `format` / `enum` bounds
@@ -5352,6 +5396,34 @@ export declare function samplesToSchema(samples: readonly unknown[], options?: V
5352
5396
  */
5353
5397
  export declare function sanitizeBudget(value: number | undefined, fallback: number): number;
5354
5398
 
5399
+ /**
5400
+ * Resolve a caller's depth budget to one the traversal can actually survive.
5401
+ *
5402
+ * @remarks
5403
+ * {@link sanitizeBudget} decides the SHAPE of a budget and deliberately lets any
5404
+ * finite non-negative integer through, because it must never read a fallback a
5405
+ * hostile caller supplied. That left the depth axis unbounded from above, and
5406
+ * depth is the axis that recurses: `1e9` is a valid integer, so the walk descended
5407
+ * until the call STACK failed, at a depth that varied between runs, and the
5408
+ * refusal surfaced as an unreadable value rather than as the exhaustion the guard
5409
+ * promises. Breadth needs no such ceiling — its loop is already bounded by the
5410
+ * entries actually present.
5411
+ *
5412
+ * So {@link INFER_DEPTH_LIMIT} is the ceiling as well as the default, and
5413
+ * `maxDepth` narrows the walk rather than widening it. One bound, and the same
5414
+ * answer on every host.
5415
+ *
5416
+ * @param value - The candidate depth budget
5417
+ * @returns A finite non-negative integer no greater than `INFER_DEPTH_LIMIT`
5418
+ *
5419
+ * @example
5420
+ * ```ts
5421
+ * sanitizeDepth(4) // 4
5422
+ * sanitizeDepth(1e9) // 32
5423
+ * ```
5424
+ */
5425
+ export declare function sanitizeDepth(value: number | undefined): number;
5426
+
5355
5427
  /**
5356
5428
  * Stateful owner of one JSON Schema snapshot operation.
5357
5429
  *
@@ -5649,7 +5721,7 @@ export declare type SeederFunction<T> = (random?: RandomFunction) => T;
5649
5721
  * selectClosestFaults([]) // []
5650
5722
  * ```
5651
5723
  */
5652
- export declare function selectClosestFaults<T extends AuditFault>(reports: readonly (readonly T[])[]): readonly T[];
5724
+ export declare function selectClosestFaults<T extends AuditFault>(reports: ReadonlyArray<readonly T[]>): readonly T[];
5653
5725
 
5654
5726
  /**
5655
5727
  * Build a guard that accepts `Set` instances whose every element satisfies
@@ -6176,11 +6248,16 @@ export declare function validateShapeDepth(shape: ContractShape): void;
6176
6248
  * expect an object-shaped `inputSchema`; wrap a non-object payload with
6177
6249
  * {@link schemaToObject} before advertising it as a tool's parameters.
6178
6250
  *
6179
- * `maxDepth` / `maxProperties` are sanitized via {@link sanitizeBudget} to a
6180
- * finite non-negative integer, falling back to {@link INFER_DEPTH_LIMIT} /
6181
- * {@link INFER_BREADTH_LIMIT} for anything else (`NaN`, `Infinity`, negative,
6182
- * fractional) — a hostile or malformed budget can never defeat the depth
6183
- * guard or corrupt the sampled key/element list.
6251
+ * `maxProperties` is sanitized via {@link sanitizeBudget} to a finite
6252
+ * non-negative integer, falling back to {@link INFER_BREADTH_LIMIT} for anything
6253
+ * else (`NaN`, `Infinity`, negative, fractional), so a malformed breadth cannot
6254
+ * corrupt the sampled key/element list.
6255
+ *
6256
+ * `maxDepth` goes through {@link sanitizeDepth}, which does the same and then caps
6257
+ * at {@link INFER_DEPTH_LIMIT}, so the option NARROWS the walk and cannot widen
6258
+ * it. The cap is what makes the depth guard unbreakable: depth is the recursing
6259
+ * axis, and a large-but-valid budget used to descend until the call STACK failed
6260
+ * rather than until the guard said stop.
6184
6261
  *
6185
6262
  * @param value - The value to infer a schema from
6186
6263
  * @param options - Optional `maxDepth` / `maxProperties` / `closed` / `format` bounds