@mark1russell7/coeval 0.6.2 → 0.7.0

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.
package/build/index.d.ts CHANGED
@@ -151,8 +151,8 @@ export declare function fromJson(value: unknown): Envelope | undefined;
151
151
  * with this function does not keep a stale host value.
152
152
  *
153
153
  * The function does not use the stack for the depth, thus a deep document cannot overflow it. A cycle of lists or
154
- * records does not make it loop. `sameValue` of `agree` uses the same rules, and it adds rules for closures and for
155
- * a rule of the caller.
154
+ * records does not make it loop. `sameValue` of `agree` and `sameResult` use the same walk, and each adds its rules
155
+ * for other values (D20).
156
156
  *
157
157
  * @param a - The first value.
158
158
  * @param b - The second value.
@@ -162,7 +162,7 @@ export declare function docEquals(a: unknown, b: unknown): boolean;
162
162
  //#endregion
163
163
  //#region src/errors.d.ts
164
164
  /** The codes that the kernel gives. */
165
- type KernelCode = "#KIND?" | "#NOEVAL" | "#PART?" | "#NAME?" | "#REF!" | "#N/A" | "#CYCLE!" | "#STEP?" | "#VALUE!" | "#NUM!" | "#ARGS" | "#CAP!" | "#CALC!" | "#DEPTH!" | "#ABORT";
165
+ type KernelCode = "#KIND?" | "#NOEVAL" | "#PART?" | "#NAME?" | "#REF!" | "#N/A" | "#CYCLE!" | "#STEP?" | "#VALUE!" | "#NUM!" | "#ARGS" | "#CAP!" | "#CALC!" | "#DEPTH!" | "#ABORT" | "#REPLAY!" | "#TYPE!";
166
166
  /** The code of an error value. A language can add its own codes. Each code starts with `#`. */
167
167
  type ErrorCode = KernelCode | `#${string}`;
168
168
  /**
@@ -270,12 +270,22 @@ interface HostThing {
270
270
  /** A short text for a reader, for example `node card`. */
271
271
  readonly label: string;
272
272
  /**
273
- * This function answers one step.
273
+ * This function answers one step. A field that holds `undefined` also gives `undefined`. The function `has` tells
274
+ * the two cases apart (DEREF.HOST-UNDEFINED).
274
275
  *
275
276
  * @param key - The key of the step.
276
277
  * @returns What the step reaches, or `undefined` when it reaches nothing.
277
278
  */
278
279
  deref(key: Key): Thing | undefined;
280
+ /**
281
+ * This optional function tells if the thing has a field for a key. The kernel asks it only when `deref` gives
282
+ * `undefined`. Then `true` tells that the field holds `undefined`. A thing without `has` reads `undefined` as a
283
+ * missing field.
284
+ *
285
+ * @param key - The key of the step.
286
+ * @returns `true` when the thing has the field.
287
+ */
288
+ has?(key: Key): boolean;
279
289
  /**
280
290
  * This function gives the thing as a value, when a reference ends on it.
281
291
  *
@@ -287,7 +297,7 @@ interface HostThing {
287
297
  * path without one call for each step.
288
298
  *
289
299
  * @param keys - The keys.
290
- * @returns What the keys reach, or `undefined` when they reach nothing.
300
+ * @returns What the keys reach, or `undefined` when they reach nothing. `{ thing: undefined }` tells that the keys reach a field that holds `undefined`.
291
301
  */
292
302
  resolve?(keys: readonly Key[]): {
293
303
  readonly thing: Thing;
@@ -404,8 +414,10 @@ interface ResolveOptions {
404
414
  }
405
415
  /**
406
416
  * This function answers one step of a path on a thing, through the ladder of the verb `deref`. A host thing
407
- * answers for itself (own). A document asks its own entry, then its kind. The default goes into the value: an own
408
- * field of an object, or an item of a list.
417
+ * answers for itself (own). A document asks its own entry, then its kind, then the default of the world
418
+ * (VERB.LADDER). A rung answers only with a `deref` that the navigator has. When no rung answers, the step goes into
419
+ * the value: an own field of an object, or an item of a list. A value without a type is data, thus the step goes
420
+ * into it at once.
409
421
  *
410
422
  * @param nav - The world and the code of the evaluators.
411
423
  * @param thing - The thing that the path reached.
@@ -445,9 +457,9 @@ export declare function context(parts?: Partial<Context>): Context;
445
457
  * This function resolves a path from a context, and records each hop.
446
458
  *
447
459
  * The first step is a root of the context. Each later step is a key or a step document. A key goes up the ladder
448
- * of the verb `deref` on the thing that the path reached. A step document is evaluated by the walker of its kind,
449
- * with the thing that the path reached. After each hop, a reference document is followed until the path reaches
450
- * something else (collapse), except in a plain navigation.
460
+ * of the verb `deref` on the thing that the path reached. A step document is evaluated by the walker that the
461
+ * ladder of the verb `step` gives, with the thing that the path reached. After each hop, a reference document is
462
+ * followed until the path reaches something else (collapse), except in a plain navigation.
451
463
  *
452
464
  * The codes of a failure:
453
465
  *
@@ -472,6 +484,162 @@ export declare function resolve(nav: Navigator, ctx: Context, path: readonly unk
472
484
  */
473
485
  export declare function valueOfThing(thing: Thing): unknown;
474
486
  //#endregion
487
+ //#region src/types.d.ts
488
+ /**
489
+ * A value type: a set of values that a result can have, as a JSON term.
490
+ *
491
+ * - A text names a base type: `unknown`, `never`, a domain of the kernel (`null`, `bool`, `number`, `text`), or a
492
+ * domain of a language.
493
+ * - `list`: a list whose items have the type.
494
+ * - `record`: a plain record with the named fields. `optional` names the fields that can be absent. A `closed`
495
+ * record has no other fields. The other fields of an open record can hold each value.
496
+ * - `fn`: a function with the types of its parameters, and the type of its result (`to`).
497
+ * - `union`: a value of one of the types. An empty union holds no value.
498
+ * - `one`: one of the JSON values of the list.
499
+ *
500
+ * A term that is not in this list reads as `unknown` (TYPE.UNKNOWN). Thus a later version can add a term.
501
+ */
502
+ type ValueType = string | {
503
+ readonly list: ValueType;
504
+ } | {
505
+ readonly record: Readonly<Record<string, ValueType>>;
506
+ readonly optional?: readonly string[];
507
+ readonly closed?: boolean;
508
+ } | {
509
+ readonly fn: readonly ValueType[];
510
+ readonly to: ValueType;
511
+ } | {
512
+ readonly union: readonly ValueType[];
513
+ } | {
514
+ readonly one: readonly Json[];
515
+ };
516
+ /**
517
+ * A value domain: a base type of a language, with its membership test. A machine holds its domains by their names
518
+ * (`Machine.domains`). A value is a member of a domain only when the test of the domain and the test of each parent
519
+ * accept it (TYPE.MEMBER).
520
+ *
521
+ * A path does not follow a member of a domain as a reference (DEREF.COLLAPSE). Thus the test `is` must refuse each
522
+ * reference document.
523
+ */
524
+ interface Domain {
525
+ /**
526
+ * This function tells if a value is a member of the domain. It must be pure. A test that throws gives `false`.
527
+ *
528
+ * @param value - The value.
529
+ * @returns `true` for a member.
530
+ */
531
+ readonly is: (value: unknown) => boolean;
532
+ /** The names of the parents: the base types that hold each member of the domain. A base type fits each parent. */
533
+ readonly under?: readonly string[];
534
+ /** One sentence that tells what the domain holds. */
535
+ readonly summary?: string;
536
+ /**
537
+ * The value type of each step into a member, by its key, for example the field `x` of a point (TYPE.STEPS). The
538
+ * check of a path reads the steps of the domain first, then the steps of each parent. The language keeps them true:
539
+ * a step with the key into a member reaches a member of the type. A key without a type gives `unknown`.
540
+ */
541
+ readonly steps?: Readonly<Record<string, ValueType>>;
542
+ }
543
+ /** A problem of a value type: the keys from the root of the term to the problem, and the reason. */
544
+ interface TypeIssue {
545
+ readonly at: readonly Key[];
546
+ readonly reason: string;
547
+ }
548
+ /**
549
+ * The domains of the kernel. `unknown` and `never` are not domains: they are the top and the bottom of the types.
550
+ * A machine that does not name one of these domains gets it from this table.
551
+ */
552
+ export declare const STD_DOMAINS: Readonly<Record<string, Domain>>;
553
+ /**
554
+ * This function tells if a value is a member of a value type (TYPE.MEMBER). It is the membership test that a cast
555
+ * at run time uses.
556
+ *
557
+ * - Each value is a member of `unknown`, and no value is a member of `never`.
558
+ * - A value is a member of a domain when the test `is` of the domain and of each parent accepts it.
559
+ * - A list, a record, a union and `one` test their values at each depth.
560
+ * - A function type tests only that the value is a function. Its parameters need a test at each call.
561
+ *
562
+ * The function does not throw. A term that is not a value type, or a base type without a domain, holds each value.
563
+ *
564
+ * @param value - The value.
565
+ * @param type - The value type.
566
+ * @param domains - The domains of the machine. A domain of the kernel that the table does not name comes from `STD_DOMAINS`.
567
+ * @returns `true` when the value is a member of the type.
568
+ */
569
+ export declare function member(value: unknown, type: ValueType, domains?: Readonly<Record<string, Domain>>): boolean;
570
+ /**
571
+ * This function tells if each value of the type `found` can be where the type `expected` must be (TYPE.FITS). Each
572
+ * check of a type uses it.
573
+ *
574
+ * - `unknown` fits each type, and each type fits `unknown` (TYPE.UNKNOWN). This is the gradual top.
575
+ * - `never` fits each type. Only `never`, an empty union and an empty `one` fit `never`.
576
+ * - A union fits when each of its types fits. A type fits a union when it fits one of its types.
577
+ * - `one` fits when each of its values is a member of `expected`.
578
+ * - A base type fits itself and each parent of its domain, through each level (TYPE.DOMAIN).
579
+ * - A list fits a list when its items fit.
580
+ * - A record fits a record with fewer fields. A field that `expected` needs is not optional in `found`, and each field
581
+ * fits. Only a closed record fits a closed record. An open record without an optional field fits only when that
582
+ * field is `unknown`.
583
+ * - A function fits when it has the same or fewer parameters, each expected parameter fits its parameter, and its
584
+ * result fits.
585
+ *
586
+ * The relation is sound: a member of `found` is a member of `expected` when no `unknown` is in the types. It is not
587
+ * complete. For example, `bool` does not fit `{ "one": [true, false] }`. The function does not throw.
588
+ *
589
+ * @param found - The type that a part has.
590
+ * @param expected - The type that the position needs.
591
+ * @param domains - The domains of the machine. A domain of the kernel that the table does not name comes from `STD_DOMAINS`.
592
+ * @returns `true` when `found` fits `expected`.
593
+ */
594
+ export declare function fits(found: ValueType, expected: ValueType, domains?: Readonly<Record<string, Domain>>): boolean;
595
+ /**
596
+ * This function gives the join of two value types (TYPE.JOIN): a type that holds each member of both types. The check
597
+ * of a type uses it for the branches of an `if` and for the items of a list.
598
+ *
599
+ * - `unknown` with each type gives `unknown`, and `never` with a type gives that type.
600
+ * - When one type fits the other by the strict form of `fits`, the join is the wider type. The strict form reads
601
+ * `unknown` only as the top.
602
+ * - Two lists give a list of the join of their items.
603
+ * - Two records give a record of the join of their common fields. A field of one closed record is optional in the
604
+ * join of two closed records. The join of an open record leaves out the fields that only one record has.
605
+ * - Each other pair gives a union. The union puts the values of `one` together and leaves out each member that fits
606
+ * another member.
607
+ *
608
+ * The join is sound: a member of `a` or of `b` is a member of the join. It is not always the least such type. The
609
+ * function does not throw.
610
+ *
611
+ * @param a - The first type.
612
+ * @param b - The second type.
613
+ * @param domains - The domains of the machine. A domain of the kernel that the table does not name comes from `STD_DOMAINS`.
614
+ * @returns The join.
615
+ */
616
+ export declare function join(a: ValueType, b: ValueType, domains?: Readonly<Record<string, Domain>>): ValueType;
617
+ /**
618
+ * This function gives the text of a value type (TYPE.TEXT), for the reason of an issue. The function does not throw.
619
+ *
620
+ * - A base type gives its name.
621
+ * - `list<T>` is a list, `{a: T, b?: U}` is a closed record, and `{a: T, ...}` is an open record.
622
+ * - `(T, U) => V` is a function, and `T | U` is a union.
623
+ * - `one` gives its values as JSON, and an empty union gives `never`.
624
+ * - A term that is not a value type gives `unknown`.
625
+ *
626
+ * The text shows at most 8 values of `one`, and it cuts a long value.
627
+ *
628
+ * @param type - The value type.
629
+ * @returns The text.
630
+ */
631
+ export declare function typeText(type: ValueType): string;
632
+ /**
633
+ * This function lists the problems of a value type (TYPE.ISSUES). A problem is a term that is not a value type, a
634
+ * base type without a domain, or a term that is too deep. `fits` and `member` read each such term as `unknown`.
635
+ * Thus a check that reads a type from a contract can report it first.
636
+ *
637
+ * @param type - The value type, as JSON.
638
+ * @param domains - The domains of the machine. A domain of the kernel that the table does not name comes from `STD_DOMAINS`.
639
+ * @returns The problems. A term comes before its parts, and the parts keep their order.
640
+ */
641
+ export declare function typeIssues(type: unknown, domains?: Readonly<Record<string, Domain>>): readonly TypeIssue[];
642
+ //#endregion
475
643
  //#region src/world.d.ts
476
644
  /** The two sides of evaluation. `derive` is pure. `run` causes effects in order. */
477
645
  type Side = "derive" | "run";
@@ -491,6 +659,9 @@ type Side = "derive" | "run";
491
659
  * A `term` with `address: true` is an address: a reference there gives what its path reaches, not the value. A
492
660
  * `term` with `kinds` permits only a part whose type starts with one of the paths. A `record` with `closed: true`
493
661
  * permits only its named fields. A `list` with `distinct: true` permits no two equal items.
662
+ *
663
+ * `expect` is the value type that a part must have, as `of` is its type (TYPE.CHECK). A shape with parts gives it to
664
+ * each part that `of` covers. Only a check of types reads it, and it describes the verb `eval`.
494
665
  */
495
666
  type Shape = {
496
667
  readonly shape: "none";
@@ -499,15 +670,18 @@ type Shape = {
499
670
  readonly of?: string;
500
671
  readonly address?: boolean;
501
672
  readonly kinds?: readonly (readonly Key[])[];
673
+ readonly expect?: ValueType;
502
674
  } | {
503
675
  readonly shape: "list";
504
676
  readonly of?: string;
505
677
  readonly item?: Shape;
506
678
  readonly distinct?: boolean;
679
+ readonly expect?: ValueType;
507
680
  } | {
508
681
  readonly shape: "map";
509
682
  readonly of?: string;
510
683
  readonly item?: Shape;
684
+ readonly expect?: ValueType;
511
685
  } | {
512
686
  readonly shape: "record";
513
687
  readonly fields: readonly string[] | Readonly<Record<string, Shape>>;
@@ -515,9 +689,11 @@ type Shape = {
515
689
  readonly required?: readonly string[];
516
690
  readonly rest?: Shape;
517
691
  readonly closed?: boolean;
692
+ readonly expect?: ValueType;
518
693
  } | {
519
694
  readonly shape: "deep";
520
695
  readonly of?: string;
696
+ readonly expect?: ValueType;
521
697
  } | {
522
698
  readonly shape: "text";
523
699
  } | {
@@ -585,8 +761,44 @@ type CapsRule = {
585
761
  readonly caps: readonly Cap[];
586
762
  readonly in?: readonly (readonly Key[])[];
587
763
  };
588
- /** A kind gives the name of an evaluator for each verb, and the contract of its value. */
589
- interface Kind {
764
+ /**
765
+ * A lazy rule of a kind names the parts that an evaluation can skip and still give a value. An example is the
766
+ * branches of `if`. The static facts mark each read under such a part (D24).
767
+ *
768
+ * `in` names the parts, as patterns of their paths in the value. The key `"*"` matches each key. A rule without `in`
769
+ * covers each part. With `after: n`, the rule covers only the parts after the first `n` parts that its patterns
770
+ * match. Thus `{ after: 1 }` makes each part lazy except the first part, as in `and`.
771
+ */
772
+ interface LazyRule {
773
+ readonly in?: readonly (readonly Key[])[];
774
+ readonly after?: number;
775
+ }
776
+ /**
777
+ * The static facts that a kind declares for its code (D24). The contract of a kind holds them, and the hook `facts`
778
+ * of a machine can give them for a name under a fallback kind. The facts describe the code of `eval`, and of `step`
779
+ * for a step document.
780
+ *
781
+ * - `pure`: `true` when the code of the kind causes no effect. Its result depends only on its data, the results
782
+ * of its parts and what its paths reach. A kind that reads the context in another way does not declare it,
783
+ * because the static facts do not see that read.
784
+ * - `volatile`: `true` when its result can change while each read gives the same thing, for example a clock.
785
+ * - `lazy`: the parts that an evaluation can skip and still give a value.
786
+ */
787
+ interface KindFacts {
788
+ readonly pure?: boolean;
789
+ readonly volatile?: boolean;
790
+ readonly lazy?: readonly LazyRule[];
791
+ }
792
+ /**
793
+ * A kind gives the name of an evaluator for each verb, and the contract of its value. The contract serves each verb.
794
+ * For each verb, the kernel splits the parts and narrows their capabilities by it, and `check` reads its scope rules.
795
+ * `side` and `effects` tell what the verb `eval` does (VERB.CONTRACT).
796
+ */
797
+ interface Kind extends KindFacts {
798
+ /**
799
+ * The evaluator names, by verb. `eval` evaluates a document, `deref` answers a step on it, and `step` names the
800
+ * walker of a step document. A language adds its own verbs, for example `view` or `format`.
801
+ */
590
802
  readonly verbs: Readonly<Record<string, string>>;
591
803
  /** Where the parts of the value are. The default is `none`. */
592
804
  readonly parts?: Shape;
@@ -599,13 +811,20 @@ interface Kind {
599
811
  * itself.
600
812
  */
601
813
  readonly caps?: readonly CapsRule[];
602
- /** The side of the kind. A kind of the run side causes effects. The default is `derive`. */
814
+ /** The side of the verb `eval` of the kind. A kind of the run side causes effects. The default is `derive`. */
603
815
  readonly side?: Side;
604
816
  /**
605
- * The effects that a document of this kind can cause. It is a list of the kinds of the effects. The text
606
- * `"type"` means that the kind of the effect is the type of the document itself, as for a call.
817
+ * The effects that the verb `eval` of a document of this kind can cause. It is a list of the kinds of the effects.
818
+ * The text `"type"` means that the kind of the effect is the type of the document itself, as for a call. For a
819
+ * procedure entry, the list holds the latent effects of the procedure, and `checkLatent` compares them with its body
820
+ * (CAP.LATENT).
607
821
  */
608
822
  readonly effects?: "type" | readonly string[];
823
+ /**
824
+ * The value type of the result of the verb `eval`, when it is fixed (TYPE.SYNTH). A check of types gives it to each
825
+ * document of the kind, in the place of the type that the rule of the evaluator synthesizes.
826
+ */
827
+ readonly result?: ValueType;
609
828
  /** One sentence that tells what the kind is. */
610
829
  readonly summary?: string;
611
830
  }
@@ -627,6 +846,10 @@ type WorldEntry = Kind | Namespace | Alias;
627
846
  */
628
847
  interface World {
629
848
  readonly kinds: Readonly<Record<string, WorldEntry>>;
849
+ /**
850
+ * The default evaluator of each verb: the last rung of the ladder (LADDER.DEFAULT). It serves each verb, also
851
+ * `deref` and `step`. Without a default of `deref`, a step goes into the value of a document (VERB.LADDER).
852
+ */
630
853
  readonly defaults: Readonly<Record<string, string>>;
631
854
  readonly fallback?: Kind;
632
855
  }
@@ -770,7 +993,8 @@ export declare function kindNamed(world: World, name: TypeRef): Kind | undefined
770
993
  *
771
994
  * The question visits the rungs in order: the own entry of the envelope, then its kind, then the default of the
772
995
  * world. The type comes from the envelope, or else from the type that the position declares. The type is a
773
- * reference into the world. The ladder does not guess a type from the shape of a value.
996
+ * reference into the world. The ladder does not guess a type from the shape of a value. Each verb has this ladder:
997
+ * `eval`, `deref`, `step` and each verb of a language (VERB.LADDER).
774
998
  *
775
999
  * @param world - The kinds and the defaults.
776
1000
  * @param doc - The header of the document: an envelope, or `{}` for a bare value.
@@ -780,59 +1004,498 @@ export declare function kindNamed(world: World, name: TypeRef): Kind | undefined
780
1004
  */
781
1005
  export declare function ask(world: World, doc: Header, verb: string, options?: AskOptions): Answer;
782
1006
  //#endregion
783
- //#region src/evaluate.d.ts
1007
+ //#region src/parts.d.ts
1008
+ /** One part of a value: its place in the value, the JSON of the part, and the type that its position declares. */
1009
+ interface PartSlot {
1010
+ /** The keys from the value of the document to the part. */
1011
+ readonly path: readonly Key[];
1012
+ /** The path as one text, with a dot between the keys, for example `bind.x`. A part of a list has its index. */
1013
+ readonly key: string;
1014
+ readonly item: Json;
1015
+ readonly of?: string;
1016
+ /** `true` when the position of the part declares an address: a reference there gives what its path reaches. */
1017
+ readonly address?: true;
1018
+ /** The value type that the shape declares for the part (`expect`). Only a check of types reads it. */
1019
+ readonly expect?: ValueType;
1020
+ }
1021
+ /** The value of a document, split into its parts, by the shape that its kind declares. */
1022
+ type Split = {
1023
+ readonly ok: true;
1024
+ /** The parts, in the order of the value. */
1025
+ readonly parts: readonly PartSlot[];
1026
+ /** The value without the parts: a field that holds a part is not in it, and a list of parts gives `null`. */
1027
+ readonly data: Json;
1028
+ /**
1029
+ * This function gives the value with a handle in the place of each part.
1030
+ *
1031
+ * @param handles - One handle for each part, in the order of `parts`.
1032
+ * @returns The value with the handles.
1033
+ */
1034
+ fill<P>(handles: readonly P[]): unknown;
1035
+ } | {
1036
+ readonly ok: false;
1037
+ readonly reason: string;
1038
+ readonly at: readonly Key[];
1039
+ };
784
1040
  /**
785
- * This function makes a context with names and capabilities. The other roots are empty, and an evaluation sets
786
- * the world.
1041
+ * This function splits a value into its parts, by the shape that its kind declares. The evaluator, the view and
1042
+ * the static kit use the same split, thus each one sees the same parts.
787
1043
  *
788
- * @param names - The names and their values.
789
- * @param caps - The effects that the term can cause.
790
- * @param self - The node of the term, if it has one.
791
- * @returns The context.
1044
+ * @param shape - The shape of the value. The default is data.
1045
+ * @param value - The value of the document.
1046
+ * @returns The parts and a way to fill their places, or the reason why the value does not have the shape.
792
1047
  */
793
- export declare function makeContext(names?: Readonly<Record<string, unknown>>, caps?: readonly Cap[], self?: Thing): Context;
1048
+ export declare function splitParts(shape: Shape | undefined, value: Json): Split;
794
1049
  /**
795
- * This function gives the keys of a capability or of a kind of effect: a text is split at its dots.
796
- *
797
- * @param kind - The text or the keys.
798
- * @returns The keys, as texts.
1050
+ * The kind and the parts of one document: what `partsOf` gives. `ok` is `false` only when the value is not a
1051
+ * document: it has no envelope, and its position declares no type. A value without the shape of its kind gives a
1052
+ * failed `split`.
799
1053
  */
800
- export declare function capKeys(kind: Cap): readonly string[];
1054
+ type DocParts = {
1055
+ readonly ok: true;
1056
+ /** The document. A bare value gets the type that its position declares. */
1057
+ readonly doc: Envelope;
1058
+ /** `true` when the type came from the position and not from an envelope. */
1059
+ readonly declared: boolean;
1060
+ /** The kind, or `undefined` when the world has no kind for the type. Then the value is data. */
1061
+ readonly kind: Kind | undefined;
1062
+ /** The keys of the kind after each alias, or `undefined` without a kind. */
1063
+ readonly typePath: readonly Key[] | undefined;
1064
+ /**
1065
+ * The split of the value by the shape of the kind. The reason of a failed split is the reason of the `#VALUE!`
1066
+ * of an evaluation: it names the kind. Its `at` gives the keys from the value to the problem.
1067
+ */
1068
+ readonly split: Split;
1069
+ } | {
1070
+ readonly ok: false;
1071
+ readonly code: "#PART?";
1072
+ readonly reason: string;
1073
+ };
801
1074
  /**
802
- * This function tells if the capabilities permit an effect. A capability permits the kind of its name, and each kind
803
- * under it: `store` permits `store.update`. The comparison is key by key, thus `fs.read` does not permit the
804
- * kind with the keys `fs` and `read.json`.
1075
+ * This function reads one document by the contracts of the world. It finds the kind of the type. A bare value gets
1076
+ * the type that its position declares. Then the function splits the value by the shape of the kind. The plan, the
1077
+ * reference interpreter and the static kit read each document with this function. Thus they see the same parts.
805
1078
  *
806
- * @param caps - The capabilities of the context.
807
- * @param kind - The kind of the effect: a text with dots, or its keys.
808
- * @returns `true` when one capability permits it.
1079
+ * @param world - The world of the kinds.
1080
+ * @param value - The document, or a bare value.
1081
+ * @param declaredType - The type that the position of a bare value declares.
1082
+ * @returns The document, its kind and its parts, or the reason why the value is not a document.
809
1083
  */
810
- export declare function permits(caps: readonly Cap[], kind: Cap): boolean;
1084
+ export declare function partsOf(world: World, value: unknown, declaredType?: string): DocParts;
811
1085
  /**
812
- * This function narrows a context for a part: the part keeps only the capabilities that the context of its parent
813
- * permits. Thus an evaluator cannot give a part more effects than it has.
1086
+ * This function tells if the path of a part matches a pattern of a scope rule. The key `"*"` of a pattern matches
1087
+ * each key.
814
1088
  *
815
- * @param parent - The context of the parent.
816
- * @param next - The context that the evaluator gives the part.
817
- * @returns The context of the part.
1089
+ * @param path - The path of the part.
1090
+ * @param pattern - The pattern.
1091
+ * @returns `true` when the path matches.
818
1092
  */
819
- export declare function narrow(parent: Context, next: Context): Context;
1093
+ export declare function pathMatches(path: readonly Key[], pattern: readonly Key[]): boolean;
1094
+ //#endregion
1095
+ //#region src/static.d.ts
1096
+ /** One document that a walk visits. */
1097
+ interface DocVisit {
1098
+ /** The keys from the root document to this document, through the parts. It is the place of an error. */
1099
+ readonly place: readonly Key[];
1100
+ /** The keys from the root JSON value to this document. A change at this path changes this document. */
1101
+ readonly at: readonly Key[];
1102
+ /** The visit of the document that holds this document as a part. The root has none. */
1103
+ readonly parent?: DocVisit | undefined;
1104
+ /** The keys from the value of the parent to this document: the path of the part. The root has none. */
1105
+ readonly slot: readonly Key[];
1106
+ /** The document. A bare value has the type that its position declares. */
1107
+ readonly doc: Envelope;
1108
+ /** `true` when the type came from the position and not from an envelope. */
1109
+ readonly declared: boolean;
1110
+ /** The kind of the document, when the world has it. */
1111
+ readonly kind?: Kind | undefined;
1112
+ /** The keys of the kind after each alias. */
1113
+ readonly typePath?: readonly Key[] | undefined;
1114
+ /** The number of documents around this document. The root has 0. */
1115
+ readonly depth: number;
1116
+ /** The names that the kinds around this document bind for it. */
1117
+ readonly names: ReadonlySet<string>;
1118
+ /** The names that a sequence around this document binds only for the parts after it. */
1119
+ readonly later: ReadonlySet<string>;
1120
+ /** `true` when the position of the document declares an address: a reference there is not a read of a value. */
1121
+ readonly address?: true | undefined;
1122
+ /**
1123
+ * The capabilities of the document: the capabilities of the walk, narrowed by the capability rules of the kinds
1124
+ * around it (`Kind.caps`). A walk without capabilities gives none here.
1125
+ */
1126
+ readonly caps?: readonly Cap[] | undefined;
1127
+ }
1128
+ /** A position that a walk cannot read as a document. */
1129
+ interface WalkProblem {
1130
+ /** The keys from the root document to the document with the problem. */
1131
+ readonly place: readonly Key[];
1132
+ /** The keys from the root JSON value to the value with the problem. */
1133
+ readonly at: readonly Key[];
1134
+ readonly code: "#PART?" | "#VALUE!";
1135
+ readonly reason: string;
1136
+ }
1137
+ /** The options of a walk. */
1138
+ interface WalkOptions {
1139
+ /** The type of a bare root value. */
1140
+ readonly declaredType?: string;
1141
+ /** The names that the host binds at the root. */
1142
+ readonly names?: readonly string[];
1143
+ /** The capabilities at the root. With them, each visit gets the capabilities of its document. */
1144
+ readonly caps?: readonly Cap[];
1145
+ /**
1146
+ * This function gets each position that is not a document.
1147
+ *
1148
+ * @param problem - The position and the reason.
1149
+ */
1150
+ readonly problem?: (problem: WalkProblem) => void;
1151
+ }
820
1152
  /**
821
- * This function gives the capabilities that two lists both permit. An effect is permitted by the result when each
822
- * list permits it. When the list `b` permits each capability of `a`, the result is the list `a` itself.
1153
+ * This function visits each document of a document: the root and each part at each depth, by the contracts of the
1154
+ * kinds. A part of a kind that the world does not have is not visited. With capabilities in the options, the walk
1155
+ * narrows them for each part by the rules of its kind, as a run does. The walk uses no stack of the host for the
1156
+ * depth, thus a deep document cannot overflow it. The time and the memory of a walk are linear in the size of the
1157
+ * document. A visit makes the keys of its place and of its path only when a reader asks for them.
823
1158
  *
824
- * @param a - The first list, for example the capabilities of a document.
825
- * @param b - The second list, for example the list of a rule `only`.
826
- * @returns The capabilities that both lists permit.
1159
+ * @param world - The world of the kinds.
1160
+ * @param doc - The document, as JSON.
1161
+ * @param visit - The function that gets each document. It gives `"skip"` to not visit the parts of a document.
1162
+ * @param options - The type of a bare root value, the names, the capabilities and a function for the problems.
827
1163
  */
828
- export declare function intersectCaps(a: readonly Cap[], b: readonly Cap[]): readonly Cap[];
1164
+ export declare function walk(world: World, doc: unknown, visit: (visit: DocVisit) => void | "skip", options?: WalkOptions): void;
1165
+ /** One reference of a document. */
1166
+ interface RefUse {
1167
+ /** The visit of the reference document: its parent, its depth and the names that it sees. */
1168
+ readonly visit: DocVisit;
1169
+ /** The place of the reference document, through the parts. */
1170
+ readonly place: readonly Key[];
1171
+ /** The keys from the root JSON value to the reference document. */
1172
+ readonly at: readonly Key[];
1173
+ /** The path of the reference: its root and its steps. */
1174
+ readonly path: readonly Json[];
1175
+ readonly root: string;
1176
+ /** `false` when a kind around the reference binds its first name. A reference to another root is free. */
1177
+ readonly free: boolean;
1178
+ /** `true` when the reference is an address: its position declares it. An address does not read a value. */
1179
+ readonly address: boolean;
1180
+ }
829
1181
  /**
830
- * This function gives the capabilities that a kind gives one of its parts, by the capability rules of its contract.
831
- * The kernel and the static kit both use it, thus a run and a check narrow the same way.
1182
+ * This function finds each reference of a document: each document of the type `ref` that a walk reaches. A
1183
+ * reference to a name that a kind around it binds is not free. The others are what the document reads from
1184
+ * outside: its dependencies. When the kind `ref` has parts, the walk also finds the references in its step documents.
832
1185
  *
833
- * @param rules - The capability rules of the kind (`Kind.caps`).
834
- * @param path - The path of the part in the value of the document.
835
- * @param caps - The capabilities of the document.
1186
+ * @param world - The world of the kinds.
1187
+ * @param doc - The document, as JSON.
1188
+ * @param options - The type of a bare root value. The names of the host do not change the result.
1189
+ * @returns The references, in the order of the document.
1190
+ */
1191
+ export declare function refsOf(world: World, doc: unknown, options?: WalkOptions): readonly RefUse[];
1192
+ /**
1193
+ * This function changes the free references of a document. The document is not changed: the function gives a new
1194
+ * document that shares each part without a change.
1195
+ *
1196
+ * @param world - The world of the kinds.
1197
+ * @param doc - The document, as JSON.
1198
+ * @param change - The function that gives the new document of a reference, or `undefined` to keep it.
1199
+ * @param options - The type of a bare root value, and the names that the host binds at the root.
1200
+ * @returns The new document.
1201
+ */
1202
+ export declare function mapRefs(world: World, doc: unknown, change: (use: RefUse) => unknown, options?: WalkOptions): unknown;
1203
+ /** A problem that a check finds before a document runs. */
1204
+ interface Issue {
1205
+ readonly code: ErrorCode;
1206
+ /** The keys from the root document to the document with the problem. */
1207
+ readonly place: readonly Key[];
1208
+ readonly reason: string;
1209
+ /** The keys from the root JSON value to the value with the problem. */
1210
+ readonly at?: readonly Key[];
1211
+ /** The type that the position needs, for a type issue (`#TYPE!`). */
1212
+ readonly expected?: ValueType;
1213
+ /** The type that the check found, for a type issue (`#TYPE!`). */
1214
+ readonly found?: ValueType;
1215
+ }
1216
+ /** The options of a check. */
1217
+ interface CheckOptions {
1218
+ /** The type of a bare root value. */
1219
+ readonly declaredType?: string;
1220
+ /** The names that the host binds at the root. `"any"` does not check the names. The default is no names. */
1221
+ readonly names?: readonly string[] | "any";
1222
+ /**
1223
+ * The capabilities at the root. Without them, the check does not check the effects. The check narrows them for
1224
+ * each part by the capability rules of the kinds, as a run does.
1225
+ */
1226
+ readonly caps?: readonly Cap[];
1227
+ /**
1228
+ * The verb that goes up the ladder at each document, as in `prepare`. The default is `eval`. `#NOEVAL` and the hook
1229
+ * `known` follow this verb. The contract declares the effects and the value types of `eval` only, thus only `eval`
1230
+ * checks them (VERB.CHECK). The type rule of an evaluator serves each verb.
1231
+ */
1232
+ readonly verb?: string;
1233
+ /**
1234
+ * With `true`, the check also checks the value types (TYPE.CHECK). It reads the type rules of the evaluators, the
1235
+ * signatures of the operations and the value types of the contracts. A type issue has the code `#TYPE!`. The
1236
+ * default is `false`, thus a host opts in.
1237
+ */
1238
+ readonly types?: boolean;
1239
+ /** The type that the root document must have, for the check of the value types. */
1240
+ readonly expect?: ValueType;
1241
+ /**
1242
+ * With `true`, the check also finds the problems of a run (RUN.CAN-WAIT). A runner under a parent without a runner
1243
+ * gives `#CALC!` when an effect of its runners can reach the host. The parent cannot pass that wait through.
1244
+ * A runner without such an effect does not wait, and the run drives it (RUN.DRIVE-NESTED). A kind that declares
1245
+ * effects and has no runner gives `#CALC!` too, because in a run only a runner can wait for the host. The default is
1246
+ * `false`.
1247
+ */
1248
+ readonly run?: boolean;
1249
+ /**
1250
+ * The value types of the roots and of the names of the host, for the check of the value types (TYPE.ROOTS). A
1251
+ * reference then gets the type that its path reaches. Only a check with `types: true` reads them.
1252
+ */
1253
+ readonly rootTypes?: RootTypes;
1254
+ }
1255
+ /** The result of `typeCheck`. */
1256
+ interface Typing {
1257
+ /** The type of the root document. It is `unknown` when the root has an issue. */
1258
+ readonly type: ValueType;
1259
+ /** Each issue of the check. The type issues come after the other issues. */
1260
+ readonly issues: readonly Issue[];
1261
+ /** The type of each document, in the order of the document. */
1262
+ readonly places: readonly Typed[];
1263
+ }
1264
+ /**
1265
+ * This function checks a document before an evaluation, by the contracts of its kinds. It finds the problems
1266
+ * that an evaluation finds when it reaches them:
1267
+ *
1268
+ * - `#KIND?`: a kind that the world does not have.
1269
+ * - `#NOEVAL`: no evaluator.
1270
+ * - `#VALUE!`: a value without the shape of its kind.
1271
+ * - `#PART?`: a value without a type.
1272
+ * - `#DEPTH!`: too much nesting.
1273
+ * - `#REF!` and `#STEP?`: a bad path.
1274
+ * - `#NAME?`: a name that nothing binds. With the hook `known` of the machine, also a name that the language does not
1275
+ * have, for example an operation.
1276
+ * - `#CAP!`: an effect that the capabilities of its document do not permit. A kind around the document can narrow them.
1277
+ * The hook `permits` of the machine decides, as in a run (CAP.PERMITS).
1278
+ * - `#CALC!`: with the option `run`, a runner under a parent without a runner, when an effect of its runners can reach
1279
+ * the host. Also a kind that declares effects and has no runner (RUN.CAN-WAIT). The issue has the place and the
1280
+ * reason of the run.
1281
+ * - `#TYPE!`: with the option `types`, a part whose type does not fit the type that its position needs (TYPE.CHECK).
1282
+ * A run does not always fail there, thus a type issue is a static finding, not an error of a run.
1283
+ *
1284
+ * The check asks the ladder for the verb of the options, `eval` by default (VERB.CHECK). The shapes, the paths and the
1285
+ * names follow the contracts, thus they are the same for each verb. Only `eval` checks the declared effects.
1286
+ *
1287
+ * @param machine - The world and the code of the evaluators.
1288
+ * @param doc - The document, as JSON.
1289
+ * @param options - The type of a bare root value, the names of the host, the capabilities, the verb, the types and the run.
1290
+ * @returns The problems, in the order of the document. The type issues come after the other issues.
1291
+ */
1292
+ export declare function check(machine: Machine, doc: unknown, options?: CheckOptions): readonly Issue[];
1293
+ /**
1294
+ * This function checks a document, and it also checks the value types (TYPE.CHECK, D25). It finds each issue of
1295
+ * `check`. Then it synthesizes the type of each document from the types of its parts. It also checks each part
1296
+ * against the type that its position needs. The type rule of the parent, the signature of an operation or the shape
1297
+ * of the contract gives that type. A part with an issue gets the type `unknown`, thus one
1298
+ * problem does not give a chain of issues.
1299
+ *
1300
+ * A type issue has the code `#TYPE!`, the type that the position needs (`expected`) and the type that the check found
1301
+ * (`found`). It is a static finding: the evaluation of the document does not change.
1302
+ *
1303
+ * The option `rootTypes` gives the types of the roots and of the names of the host (TYPE.ROOTS). A reference then gets
1304
+ * the type that its path reaches, and a field that a closed record does not have is a type issue (TYPE.CLOSED).
1305
+ *
1306
+ * @param machine - The world and the code of the evaluators, with their type rules.
1307
+ * @param doc - The document, as JSON.
1308
+ * @param options - The options of `check`, the type that the root must have and the types of the roots.
1309
+ * @returns The type of the root, each issue, and the type of each document.
1310
+ */
1311
+ export declare function typeCheck(machine: Machine, doc: unknown, options?: CheckOptions): Typing;
1312
+ //#endregion
1313
+ //#region src/typing.d.ts
1314
+ /** What a type rule gets for one document. */
1315
+ interface TypeInput {
1316
+ /** The keys of the kind of the document, after each alias. */
1317
+ readonly typePath: readonly Key[];
1318
+ /** The document. A bare value has the type that its position declares. */
1319
+ readonly doc: Envelope;
1320
+ /** The type that the position of the document needs. It is `unknown` when the position needs no type. */
1321
+ readonly expected: ValueType;
1322
+ /** The paths of the parts in the value, in the order of the value. */
1323
+ readonly paths: readonly (readonly Key[])[];
1324
+ /** `true` when the position declares an address. A reference there gives a thing, not a value. */
1325
+ readonly address: boolean;
1326
+ readonly machine: Machine;
1327
+ /**
1328
+ * This function gives the type of a part that the check typed before. It gives `unknown` for a part that the check
1329
+ * did not type yet, and for a part with an issue.
1330
+ *
1331
+ * @param path - The path of the part in the value.
1332
+ * @returns The type of the part.
1333
+ */
1334
+ typeOf(path: readonly Key[]): ValueType;
1335
+ /**
1336
+ * This function gives the type of a name: the type that a kind around the document binds. Without such a kind, it
1337
+ * gives the type from the option `rootTypes` of the host.
1338
+ *
1339
+ * @param name - The name.
1340
+ * @returns The type, or `undefined` when neither a kind around the document nor the host gives the name a type.
1341
+ */
1342
+ nameType(name: string): ValueType | undefined;
1343
+ /**
1344
+ * This function gives the type of a root of the context at the document (TYPE.ROOTS). The host gives the types of
1345
+ * `self`, `world` and `event` in the option `rootTypes`. A rule can give other types to its parts. The root `caps`
1346
+ * always has the type `CAPS_TYPE`. A rule reads the type of a name with `nameType`, thus the root `names` gives
1347
+ * `unknown`.
1348
+ *
1349
+ * @param root - The root.
1350
+ * @returns The type. It is `unknown` for a root without a type.
1351
+ */
1352
+ rootType(root: string): ValueType;
1353
+ /**
1354
+ * This function examines a value type of a contract with `typeIssues`, one time in a check. The first problem of a
1355
+ * type becomes an issue at the document. A term with a problem reads as `unknown`.
1356
+ *
1357
+ * @param type - The value type of the contract.
1358
+ * @param what - What the type is, for the reason, for example "the result of ops.add".
1359
+ * @returns The type.
1360
+ */
1361
+ contract(type: unknown, what: string): ValueType;
1362
+ }
1363
+ /** What a type rule tells for one part: the type that the part must have, and the types of the names of the part. */
1364
+ interface PartType {
1365
+ /** The type that the part must have. */
1366
+ readonly expect?: ValueType;
1367
+ /** What the part is, for the reason of an issue, for example "argument 2 of ops.add". */
1368
+ readonly what?: string;
1369
+ /** The types of the names that the scope rules of the kind bind for the part. Each other name of the rules gets `unknown`. */
1370
+ readonly names?: Readonly<Record<string, ValueType>>;
1371
+ /**
1372
+ * The types of the roots that the evaluator changes for the part, for example `self` for the attributes of a node.
1373
+ * Each other root keeps its type. The parts of an evaluator without a rule get `unknown` for each of these roots.
1374
+ */
1375
+ readonly roots?: Omit<RootTypes, "names">;
1376
+ }
1377
+ /**
1378
+ * The value types of the roots of a context, for a check of types (TYPE.ROOTS). The host gives them in the option
1379
+ * `rootTypes` of `check` and `typeCheck`. A root without a type has the type `unknown`. The root `caps` always has the
1380
+ * type `CAPS_TYPE`, because the kernel narrows it.
1381
+ *
1382
+ * The host keeps the types true: each root of the context holds a member of its type. A host thing, or a machine
1383
+ * with `adopt`, keeps each step true too. The context binds each name of `names`, thus the option `names` of `check`
1384
+ * lists it too.
1385
+ */
1386
+ interface RootTypes {
1387
+ /** The type of each name that the host binds. A name of the host without a type here has the type `unknown`. */
1388
+ readonly names?: Readonly<Record<string, ValueType>>;
1389
+ /** The type of `self`: the node or the position that the document is part of. */
1390
+ readonly self?: ValueType;
1391
+ /** The type of `world`, for example the schema of a store. The context then gives the world. */
1392
+ readonly world?: ValueType;
1393
+ /** The type of `event`: the event that started a run. */
1394
+ readonly event?: ValueType;
1395
+ }
1396
+ /**
1397
+ * The value type of the root `caps`: a list of capabilities. A capability is a text, or a list of keys. The kernel
1398
+ * narrows the capabilities for each part, thus the host does not give this type.
1399
+ */
1400
+ export declare const CAPS_TYPE: ValueType;
1401
+ /** A problem that a type rule finds. Its place is a part of the document, or the document itself. */
1402
+ interface TypeProblem {
1403
+ /** The path of the part in the value. Without it, the problem is at the document. */
1404
+ readonly path?: readonly Key[];
1405
+ readonly reason: string;
1406
+ readonly expected?: ValueType;
1407
+ readonly found?: ValueType;
1408
+ }
1409
+ /**
1410
+ * The type rule of an evaluator: what a check of types knows about the values that the evaluator gives. An evaluator
1411
+ * object holds its rule in its field `type`. Thus the rule follows the evaluator that the ladder gives a document
1412
+ * (TYPE.RULE).
1413
+ */
1414
+ interface TypeRule {
1415
+ /**
1416
+ * This function tells the type that a part must have, and the types of the names for the part. The check asks it
1417
+ * before it types the part. The parts that give the names of a rule `keysAt` come first.
1418
+ *
1419
+ * @param input - The document, the type that its position needs, and the types of the parts before.
1420
+ * @param path - The path of the part in the value.
1421
+ * @returns The type of the part and the types of its names.
1422
+ */
1423
+ readonly part?: (input: TypeInput, path: readonly Key[]) => PartType;
1424
+ /**
1425
+ * This function synthesizes the type of the document from the types of its parts. It must be sound: each value that
1426
+ * the evaluator gives is a member of the type.
1427
+ *
1428
+ * @param input - The document, the type that its position needs, and the types of its parts.
1429
+ * @param report - The function that gets each problem that the rule finds.
1430
+ * @returns The type of the document.
1431
+ */
1432
+ readonly synth: (input: TypeInput, report: (problem: TypeProblem) => void) => ValueType;
1433
+ }
1434
+ /** The type of one document of a check of types. */
1435
+ interface Typed {
1436
+ /** The keys from the root document to the document. */
1437
+ readonly place: readonly Key[];
1438
+ /** The keys from the root JSON value to the document. */
1439
+ readonly at: readonly Key[];
1440
+ /** The type that the check synthesized. A document with an issue has the type `unknown`. */
1441
+ readonly type: ValueType;
1442
+ /** The type that the position of the document needs, when it needs one. */
1443
+ readonly expected?: ValueType;
1444
+ }
1445
+ //#endregion
1446
+ //#region src/evaluate.d.ts
1447
+ /**
1448
+ * This function makes a context with names and capabilities. The other roots are empty, and an evaluation sets
1449
+ * the world.
1450
+ *
1451
+ * @param names - The names and their values.
1452
+ * @param caps - The effects that the term can cause.
1453
+ * @param self - The node of the term, if it has one.
1454
+ * @returns The context.
1455
+ */
1456
+ export declare function makeContext(names?: Readonly<Record<string, unknown>>, caps?: readonly Cap[], self?: Thing): Context;
1457
+ /**
1458
+ * This function gives the keys of a capability or of a kind of effect: a text is split at its dots.
1459
+ *
1460
+ * @param kind - The text or the keys.
1461
+ * @returns The keys, as texts.
1462
+ */
1463
+ export declare function capKeys(kind: Cap): readonly string[];
1464
+ /**
1465
+ * This function tells if the capabilities permit an effect. A capability permits the kind of its name, and each kind
1466
+ * under it: `store` permits `store.update`. The comparison is key by key, thus `fs.read` does not permit the
1467
+ * kind with the keys `fs` and `read.json`.
1468
+ *
1469
+ * @param caps - The capabilities of the context.
1470
+ * @param kind - The kind of the effect: a text with dots, or its keys.
1471
+ * @returns `true` when one capability permits it.
1472
+ */
1473
+ export declare function permits(caps: readonly Cap[], kind: Cap): boolean;
1474
+ /**
1475
+ * This function narrows a context for a part: the part keeps only the capabilities that the context of its parent
1476
+ * permits. Thus an evaluator cannot give a part more effects than it has.
1477
+ *
1478
+ * @param parent - The context of the parent.
1479
+ * @param next - The context that the evaluator gives the part.
1480
+ * @returns The context of the part.
1481
+ */
1482
+ export declare function narrow(parent: Context, next: Context): Context;
1483
+ /**
1484
+ * This function gives the capabilities that two lists both permit. An effect is permitted by the result when each
1485
+ * list permits it. When the list `b` permits each capability of `a`, the result is the list `a` itself.
1486
+ *
1487
+ * @param a - The first list, for example the capabilities of a document.
1488
+ * @param b - The second list, for example the list of a rule `only`.
1489
+ * @returns The capabilities that both lists permit.
1490
+ */
1491
+ export declare function intersectCaps(a: readonly Cap[], b: readonly Cap[]): readonly Cap[];
1492
+ /**
1493
+ * This function gives the capabilities that a kind gives one of its parts, by the capability rules of its contract.
1494
+ * The kernel and the static kit both use it, thus a run and a check narrow the same way.
1495
+ *
1496
+ * @param rules - The capability rules of the kind (`Kind.caps`).
1497
+ * @param path - The path of the part in the value of the document.
1498
+ * @param caps - The capabilities of the document.
836
1499
  * @returns The capabilities of the part: the same list or a smaller one.
837
1500
  */
838
1501
  export declare function partCaps(rules: readonly CapsRule[] | undefined, path: readonly Key[], caps: readonly Cap[]): readonly Cap[];
@@ -844,6 +1507,7 @@ export declare function partCaps(rules: readonly CapsRule[] | undefined, path: r
844
1507
  type Steps = Generator<Promise<unknown>, Result, unknown>;
845
1508
  /** An effect that an evaluation caused, in the order of the effects. */
846
1509
  interface Effect {
1510
+ /** The number of effects before this effect. Under `all`, this number follows the order of the host. */
847
1511
  readonly index: number;
848
1512
  /** The kind of the effect, as a text with dots. */
849
1513
  readonly kind: string;
@@ -858,9 +1522,75 @@ interface Effect {
858
1522
  readonly place: readonly Key[];
859
1523
  /** The context of the document that caused the effect: its names, its node and its capabilities. */
860
1524
  readonly context: Context;
1525
+ /**
1526
+ * The stable address of the effect (RUN.ADDRESS). The order of the host does not change it. The address has the
1527
+ * keys of the place, a `#` and the count of the earlier effects at that place in its scope. An example is
1528
+ * `1/bind/x#0`. Each item of `all` is a scope, and its prefix comes first: `all0.1/` is the item 1 of the first `all`
1529
+ * of the scope. The kernel gives each effect its address.
1530
+ */
1531
+ readonly address?: string;
1532
+ /**
1533
+ * The outcome of the effect: the result that it gave its document (RUN.OUTCOME). The kernel sets it when the answer
1534
+ * comes. It stays `undefined` when the run stops first, for example at an abort.
1535
+ */
1536
+ readonly outcome?: Result;
1537
+ }
1538
+ /**
1539
+ * One read of an evaluation: a path that code resolved, and what the path reached (READS.RECORD, D26). A schedule
1540
+ * keeps the list of the reads of an evaluation. `verifyReads` resolves each free read again in a new context, and it
1541
+ * tells if the old result stays valid.
1542
+ */
1543
+ interface Read {
1544
+ /** The path that the code resolved: its root, and its steps with the value of each step document. */
1545
+ readonly path: readonly unknown[];
1546
+ /**
1547
+ * What the path reached: the thing, or the error of the resolution. A host thing stays a thing. An exception of the
1548
+ * host gives its error value.
1549
+ */
1550
+ readonly reached: Result;
1551
+ /**
1552
+ * `true` when the read reads the context of the evaluation (READS.FREE). A read of a name that a kind binds, for
1553
+ * example a name of `let`, is not free. A read of a `self` that a kind sets is not free either, for example a node
1554
+ * of a tree. A path without a root is not free. `verifyReads` resolves only the free reads again.
1555
+ */
1556
+ readonly free: boolean;
1557
+ /**
1558
+ * `true` when the kernel adds the read, because a value keeps a root of the context for later (READS.KEPT). Such a
1559
+ * read has the whole root as its path.
1560
+ */
1561
+ readonly kept?: true;
1562
+ /** The hops of the resolution, only when the code asked for them. `verifyReads` then compares each hop too. */
1563
+ readonly hops?: readonly Hop[];
861
1564
  }
862
- /** The host side of a run: it does one effect, and gives its result. A throw or a rejection is an error value. */
1565
+ /**
1566
+ * The host side of a run: it does one effect, and gives its result. A throw or a rejection is an error value, and a
1567
+ * `Failure` gives its own error value. In an evaluation, this function is a mock: it answers at once, and a promise
1568
+ * from it gives `#CALC!` (RUN.MOCK).
1569
+ */
863
1570
  type Perform = (effect: Effect) => unknown;
1571
+ /** The key of the journal of a recorder or of a replayer, on its function. Two copies of the kernel share it. */
1572
+ export declare const JOURNAL: unique symbol;
1573
+ /**
1574
+ * The journal of a recorder or of a replayer, on its function `perform`. The kernel tells it the order in which the
1575
+ * waits of each `all` settle. In a replay, the kernel asks the journal for that order (RUN.RECORD, RUN.REPLAY).
1576
+ */
1577
+ interface Journal {
1578
+ /**
1579
+ * This function gets the item whose wait settled.
1580
+ *
1581
+ * @param all - The address of the `all`, for example `all0` or `all0.1/all0`.
1582
+ * @param item - The index of the item.
1583
+ */
1584
+ readonly settled?: (all: string, item: number) => void;
1585
+ /**
1586
+ * This function gives the item whose wait settles next.
1587
+ *
1588
+ * @param all - The address of the `all`.
1589
+ * @param waiting - The indices of the items that wait.
1590
+ * @returns The index of an item that waits, or `undefined` for the order of the host.
1591
+ */
1592
+ readonly next?: (all: string, waiting: readonly number[]) => number | undefined;
1593
+ }
864
1594
  /**
865
1595
  * The runtime of one evaluation or run. Compiled code gets it with the context, and asks it to resolve paths and
866
1596
  * to cause effects.
@@ -882,18 +1612,18 @@ interface Runtime {
882
1612
  * This function causes an effect from an evaluator. In a run, an evaluator cannot cause an effect: the host does
883
1613
  * each effect, thus only a runner can wait for it.
884
1614
  *
885
- * @param ctx - The context of the document.
1615
+ * @param ctx - The context of the document. It gives only the capabilities that the document has (CAP.NARROW-CODE).
886
1616
  * @param kind - The kind of the effect.
887
1617
  * @param payload - The data of the effect.
888
1618
  * @param place - The place of the document.
889
- * @returns The payload, or an error value.
1619
+ * @returns The answer of the mock, the payload without a mock, or an error value.
890
1620
  */
891
1621
  effect(ctx: Context, kind: Cap, payload: unknown, place: readonly Key[]): Result;
892
1622
  /**
893
1623
  * This function causes an effect from a runner. In a run, the host does it, and the steps wait when the host
894
1624
  * waits.
895
1625
  *
896
- * @param ctx - The context of the document.
1626
+ * @param ctx - The context of the document. It gives only the capabilities that the document has (CAP.NARROW-CODE).
897
1627
  * @param kind - The kind of the effect.
898
1628
  * @param payload - The data of the effect.
899
1629
  * @param place - The place of the document.
@@ -908,6 +1638,12 @@ interface Runtime {
908
1638
  * @returns The steps that give each result, in the order of the list.
909
1639
  */
910
1640
  all(list: readonly (() => Steps)[], options?: AllOptions): Generator<Promise<unknown>, readonly Result[], unknown>;
1641
+ /**
1642
+ * This optional function tells the runtime that a value keeps the context for later, for example a closure of
1643
+ * `fn`. A later use of the value reads that context, and no evaluation records these reads. Thus the list of reads
1644
+ * gets a read of each root of the context (READS.KEPT).
1645
+ */
1646
+ keepsContext?(): void;
911
1647
  }
912
1648
  /**
913
1649
  * The options of a drive of parts at the same time.
@@ -920,9 +1656,16 @@ interface AllOptions {
920
1656
  readonly concurrency?: number;
921
1657
  readonly failFast?: boolean;
922
1658
  }
923
- /** Compiled code: the evaluation of a document in a context. */
1659
+ /**
1660
+ * Compiled code: the evaluation of a document in a context. The code gives each part a context that it makes from
1661
+ * its own context with a spread. The part then keeps only the capabilities of the document (CAP.NARROW-CODE). A
1662
+ * context that the code makes without a spread gives the part no capabilities.
1663
+ */
924
1664
  type Code = (ctx: Context, rt: Runtime) => Result;
925
- /** Compiled code that can wait: the run of a document in a context. */
1665
+ /**
1666
+ * Compiled code that can wait: the run of a document in a context. Its parts keep only the capabilities of the
1667
+ * document, as for `Code`.
1668
+ */
926
1669
  type RunCode = (ctx: Context, rt: Runtime) => Steps;
927
1670
  /** A compiled part: its place in its parent, its binding name, and its code. It has no field with its value. */
928
1671
  interface CompiledPart {
@@ -1016,7 +1759,7 @@ interface EvalInput {
1016
1759
  *
1017
1760
  * @param kind - The kind of the effect, for example `log`.
1018
1761
  * @param payload - The data of the effect.
1019
- * @returns The payload, or the error `#CAP!`.
1762
+ * @returns The answer of the mock, the payload without a mock, or an error value, for example `#CAP!`.
1020
1763
  */
1021
1764
  effect(kind: Cap, payload: unknown): Result;
1022
1765
  /**
@@ -1058,7 +1801,7 @@ interface RunInput {
1058
1801
  resolve(path: readonly unknown[], options?: ResolveOptions): Resolution;
1059
1802
  /**
1060
1803
  * This function causes an effect. In a run, the host does the effect, and the steps wait when the host waits. In
1061
- * an evaluation, the effect gives its payload. Take its result with `yield*`.
1804
+ * an evaluation, a mock answers the effect at once, or the effect gives its payload. Take its result with `yield*`.
1062
1805
  *
1063
1806
  * @param kind - The kind of the effect, for example `log`.
1064
1807
  * @param payload - The data of the effect.
@@ -1094,6 +1837,11 @@ interface CompiledEvaluator {
1094
1837
  * @returns The code that evaluates the document.
1095
1838
  */
1096
1839
  readonly compile: (input: CompileInput) => Code;
1840
+ /**
1841
+ * The type rule of the evaluator: the value types that a check of types gives its documents and their parts
1842
+ * (TYPE.RULE). Only a check reads it. An evaluator without a rule gives `unknown`.
1843
+ */
1844
+ readonly type?: TypeRule;
1097
1845
  }
1098
1846
  /** An evaluator: a function of its input, or a compiler. */
1099
1847
  type Evaluator = EvalFn | CompiledEvaluator;
@@ -1118,8 +1866,11 @@ type Runner = RunFn | CompiledRunner;
1118
1866
  * A machine: a world of kinds, and the code of each evaluator name, of each `deref` and of each walker.
1119
1867
  *
1120
1868
  * - `maxDepth`: the deepest nesting of documents. The default is 1000.
1121
- * - `permits`: the rule of the host for an effect. The default is the function `permits` on the capabilities.
1869
+ * - `permits`: the rule of the host for an effect. The default is the function `permits` on the capabilities. A run,
1870
+ * `check` and `effectsOf` ask it (CAP.PERMITS). In a check, its context has only the capabilities and the world.
1122
1871
  * - `known`: the names that the evaluators know, for `check`. Without it, `check` does not check such names.
1872
+ * - `domains`: the value domains of the language, by the name of their base type (D22).
1873
+ * - `facts`: the static facts of the names that a fallback kind covers, for `factsOf` (D24).
1123
1874
  */
1124
1875
  interface Machine extends Navigator {
1125
1876
  readonly evaluators: Readonly<Record<string, Evaluator>>;
@@ -1133,10 +1884,26 @@ interface Machine extends Navigator {
1133
1884
  * `check` asks it for each document with an evaluator. The function must be pure.
1134
1885
  *
1135
1886
  * @param path - The keys of the kind of the document, after each alias.
1136
- * @param evaluator - The name of the evaluator that the ladder gives the document.
1887
+ * @param evaluator - The name of the evaluator that the ladder of the verb of the check gives the document.
1137
1888
  * @returns `true` when the evaluator knows the name, or else the reason of the `#NAME?` that a run gives.
1138
1889
  */
1139
1890
  readonly known?: (path: readonly Key[], evaluator: string) => true | string;
1891
+ /**
1892
+ * The value domains of the language, by the name of their base type, for example a color or a unit of length. A
1893
+ * check reads them through `fits` and `member`. A domain of the kernel that the table does not name comes from
1894
+ * `STD_DOMAINS`.
1895
+ */
1896
+ readonly domains?: Readonly<Record<string, Domain>>;
1897
+ /**
1898
+ * This function gives the static facts of the code of a name, for `factsOf` (D24). An example is the operation
1899
+ * `["ops", "now"]` of a formula language: a fallback kind names it, and only the language knows that it is volatile.
1900
+ * Each field of the answer wins over the same field of the contract of the kind. The function must be pure.
1901
+ *
1902
+ * @param path - The keys of the kind of the document, after each alias.
1903
+ * @param code - The name of the evaluator of the document, or of the walker of a step document.
1904
+ * @returns The facts, or `undefined` for the facts of the contract.
1905
+ */
1906
+ readonly facts?: (path: readonly Key[], code: string) => KindFacts | undefined;
1140
1907
  }
1141
1908
  /** One evaluation in a trace. The children are the evaluations of its parts, in the order that they started. */
1142
1909
  interface TraceNode {
@@ -1147,7 +1914,7 @@ interface TraceNode {
1147
1914
  readonly doc: Envelope;
1148
1915
  /** `true` when the type came from the container and not from an envelope. */
1149
1916
  readonly declared: boolean;
1150
- /** The answer of the ladder to the verb `eval`. */
1917
+ /** The answer of the ladder to the verb of the plan, `eval` by default. */
1151
1918
  readonly answer: Answer;
1152
1919
  readonly side: Side;
1153
1920
  /** The names that the document could read when its evaluation started. */
@@ -1189,13 +1956,44 @@ interface RunOptions {
1189
1956
  readonly perform?: Perform;
1190
1957
  /** The type of a bare root value. */
1191
1958
  readonly declaredType?: string;
1959
+ /**
1960
+ * The verb of `run`, for example `format`. The default is `eval` (VERB.PREPARE). A plan keeps the verb of its
1961
+ * `prepare`, thus `plan.run` does not read this option.
1962
+ */
1963
+ readonly verb?: string;
1192
1964
  /** A signal of the host. When it aborts, the run stops with `#ABORT`. */
1193
1965
  readonly signal?: StopSignal;
1966
+ /**
1967
+ * A list that gets each read, in the order of the resolutions (READS.RECORD). Under `all`, the order of the host
1968
+ * decides the order of the reads of the items.
1969
+ */
1970
+ readonly reads?: Read[];
1194
1971
  }
1195
1972
  /** The options of an evaluation of a plan. */
1196
1973
  interface EvalOptions {
1197
1974
  /** A list that gets each effect, in its order. */
1198
1975
  readonly effects?: Effect[];
1976
+ /**
1977
+ * The mock of the host (RUN.MOCK). It answers each effect at once, and its answer is the result of the effect.
1978
+ * Without it, an effect gives its payload (RUN.EVAL).
1979
+ */
1980
+ readonly perform?: Perform;
1981
+ /**
1982
+ * A list that gets each read, in the order of the resolutions (READS.RECORD). Without it, the plan records no read,
1983
+ * and each resolution costs one more test.
1984
+ */
1985
+ readonly reads?: Read[];
1986
+ }
1987
+ /** The options of `evaluate`. */
1988
+ interface EvaluateOptions {
1989
+ /** The type of a bare root value. */
1990
+ readonly declaredType?: string;
1991
+ /** The verb that goes up the ladder at each document, for example `format`. The default is `eval` (VERB.PREPARE). */
1992
+ readonly verb?: string;
1993
+ /** The mock of the host (RUN.MOCK). Without it, an effect gives its payload (RUN.EVAL). */
1994
+ readonly perform?: Perform;
1995
+ /** A list that gets each read, in the order of the resolutions (READS.RECORD). */
1996
+ readonly reads?: Read[];
1199
1997
  }
1200
1998
  /** The options of a compilation. */
1201
1999
  interface PrepareOptions {
@@ -1203,6 +2001,11 @@ interface PrepareOptions {
1203
2001
  readonly declaredType?: string;
1204
2002
  /** `true`: each evaluation records a trace. The default is `false`. */
1205
2003
  readonly trace?: boolean;
2004
+ /**
2005
+ * The verb that goes up the ladder at each document, for example `format`. Each part evaluates with the same verb.
2006
+ * The default is `eval` (VERB.PREPARE).
2007
+ */
2008
+ readonly verb?: string;
1206
2009
  }
1207
2010
  /** A compiled document. It evaluates many times, and it does the work of the ladder one time. */
1208
2011
  interface Plan {
@@ -1212,10 +2015,11 @@ interface Plan {
1212
2015
  /** The compiled root document. */
1213
2016
  readonly root: CompiledPart;
1214
2017
  /**
1215
- * This function evaluates the document. It does not wait, and the host does no effect.
2018
+ * This function evaluates the document. It does not wait, and the host does no effect. A mock can answer each
2019
+ * effect at once (RUN.MOCK).
1216
2020
  *
1217
2021
  * @param context - The names and the capabilities at the root.
1218
- * @param options - A list that gets the effects.
2022
+ * @param options - A list that gets the effects, the mock of the host and a list that gets the reads.
1219
2023
  * @returns The result.
1220
2024
  */
1221
2025
  evaluate(context?: Context, options?: EvalOptions): Result;
@@ -1223,7 +2027,7 @@ interface Plan {
1223
2027
  * This function runs the document: the host does each effect, and the run waits when the host waits.
1224
2028
  *
1225
2029
  * @param context - The names and the capabilities at the root.
1226
- * @param options - The host code that does the effects, and a signal to stop the run.
2030
+ * @param options - The host code that does the effects, a signal to stop the run and a list that gets the reads.
1227
2031
  * @returns The result, when the run ends.
1228
2032
  */
1229
2033
  run(context?: Context, options?: RunOptions): Promise<Result>;
@@ -1232,9 +2036,13 @@ interface Plan {
1232
2036
  * This function compiles a document into a plan. The ladder, the kinds and the parts are known after it. A plan
1233
2037
  * evaluates many times. A document that does not compile gives a plan that fails with the reason, when it evaluates.
1234
2038
  *
2039
+ * The verb of the options goes up the ladder at each document, and each part evaluates with the same verb. The
2040
+ * default verb is `eval`. A plan of another verb, for example `format`, evaluates, runs and traces as a plan of
2041
+ * `eval` does (VERB.PREPARE).
2042
+ *
1235
2043
  * @param machine - The world and the code of the evaluators.
1236
2044
  * @param doc - The document, as JSON.
1237
- * @param options - The type of a bare root value, and a trace.
2045
+ * @param options - The type of a bare root value, a trace and the verb.
1238
2046
  * @returns The plan.
1239
2047
  */
1240
2048
  export declare function prepare(machine: Machine, doc: unknown, options?: PrepareOptions): Plan;
@@ -1250,17 +2058,20 @@ export declare function planner(machine: Machine, options?: PrepareOptions): (do
1250
2058
  /**
1251
2059
  * This function evaluates a document, and records each evaluation in a trace.
1252
2060
  *
1253
- * The verb `eval` goes up the ladder for each document. The kind of the document tells where its parts are. The
1254
- * evaluator gets each part sealed: it can evaluate the part, and it cannot read its value. A failure gives an error
1255
- * value, and the function does not throw. An effect is recorded in its order, and nothing does it.
2061
+ * The verb of the options goes up the ladder for each document. The default verb is `eval`. The kind of the document
2062
+ * tells where its parts are. The evaluator gets each part sealed: it can evaluate the part, and it cannot read its
2063
+ * value.
2064
+ *
2065
+ * A failure gives an error value, and the function does not throw. An effect is recorded in its order, and the host
2066
+ * does not do it. A mock can answer each effect at once (RUN.MOCK).
1256
2067
  *
1257
2068
  * @param machine - The world and the code of the evaluators.
1258
2069
  * @param doc - The document, as JSON.
1259
2070
  * @param context - The names and the capabilities at the root.
1260
- * @param declaredType - The type of a bare root value.
2071
+ * @param options - The type of a bare root value, or the options: that type, the mock of the host, the verb and a list for the reads.
1261
2072
  * @returns The result, the trace and the effects in their order.
1262
2073
  */
1263
- export declare function evaluate(machine: Machine, doc: unknown, context?: Context, declaredType?: string): Run;
2074
+ export declare function evaluate(machine: Machine, doc: unknown, context?: Context, options?: string | EvaluateOptions): Run;
1264
2075
  /**
1265
2076
  * This function runs a document: an evaluation in which the host does each effect. A runner waits for its
1266
2077
  * parts and for its effects, thus a step can read the result of the step before. The part of the run before the
@@ -1269,7 +2080,7 @@ export declare function evaluate(machine: Machine, doc: unknown, context?: Conte
1269
2080
  * @param machine - The world, the evaluators and the runners.
1270
2081
  * @param doc - The document, as JSON.
1271
2082
  * @param context - The names and the capabilities at the root.
1272
- * @param options - The host code that does the effects, the type of a bare root value, and a signal.
2083
+ * @param options - The host code that does the effects, the type of a bare root value, a signal, the verb and a list for the reads.
1273
2084
  * @returns The result, the trace and the effects in their order, when the run ends.
1274
2085
  */
1275
2086
  export declare function run(machine: Machine, doc: unknown, context?: Context, options?: RunOptions): Promise<Run>;
@@ -1337,6 +2148,28 @@ export declare class MergeError extends Error {
1337
2148
  */
1338
2149
  constructor(conflicts: readonly MergeConflict[]);
1339
2150
  }
2151
+ /** What `extendDomain` adds to a domain: more parents, and the types of more steps. */
2152
+ interface DomainExtension {
2153
+ /** The names of the parents to add. A member of the domain then also passes the test of each new parent. */
2154
+ readonly under?: readonly string[];
2155
+ /** The types of the steps to add. A step with the key of an earlier step replaces its type. */
2156
+ readonly steps?: Readonly<Record<string, ValueType>>;
2157
+ }
2158
+ /**
2159
+ * This function makes a part of a merge that adds parents or steps to a domain of an earlier part (TYPE.PARENTS). An
2160
+ * example is a domain of another language. The part reads the domain from the merge before it (`prev`). It gives a
2161
+ * copy with the same test and summary, and it names `["domains", name]` in `replaces` (D17). A domain of the kernel
2162
+ * that the earlier parts do not name comes from `STD_DOMAINS`.
2163
+ *
2164
+ * A new parent adds its test to the domain (TYPE.MEMBER). Thus `fits` stays sound, but a value that fails the test of
2165
+ * the parent is no longer a member. The language that adds the parent keeps the signatures of the other language
2166
+ * true. A name without a domain gives an empty part, and `typeIssues` reports each use of that name.
2167
+ *
2168
+ * @param name - The name of the domain.
2169
+ * @param more - The parents and the steps to add.
2170
+ * @returns The part, as a function of the merge before it.
2171
+ */
2172
+ export declare function extendDomain(name: string, more: DomainExtension): (prev: Machine) => MachinePart;
1340
2173
  /**
1341
2174
  * This function merges worlds into one world, in the order of the parts. It does not change a part.
1342
2175
  *
@@ -1359,9 +2192,11 @@ export declare function mergeWorlds(...parts: readonly (WorldPart | ((prev: Worl
1359
2192
  *
1360
2193
  * - The worlds merge with the rules of `mergeWorlds`. The paths of their conflicts start with `"world"`.
1361
2194
  * - The tables `evaluators`, `runners`, `derefs` and `walkers` merge name by name. A function is equal only to itself.
2195
+ * - The table `domains` merges name by name. Two domains with the same test, parents and summary give one domain (D22).
1362
2196
  * - The evaluator and the runner of a name are its code. A replacement of the name replaces both.
1363
2197
  * - A runner hides the evaluator of its name. Thus one part must give both, or the merge gives a conflict.
1364
2198
  * - The hooks `known` compose in the order of the parts. A hook does not answer for a name that a later part replaces.
2199
+ * The hooks `facts` compose the same way, and the first answer that is not `undefined` wins.
1365
2200
  * - Each other field, for example `permits`, `adopt`, `roots`, `plain` or `maxDepth`, is one value. Two different
1366
2201
  * values are a conflict. An absent field has no value.
1367
2202
  *
@@ -1393,7 +2228,7 @@ export declare function restrictWorld(world: World, paths: readonly MergePath[])
1393
2228
  *
1394
2229
  * - A path that starts with `"world"` removes an entry of the world, with the rules of `restrictWorld`.
1395
2230
  * - `["evaluators", name]` or `["runners", name]` removes the code of the name: its evaluator and its runner.
1396
- * - `["derefs", name]` and `["walkers", name]` remove one entry of their tables.
2231
+ * - `["derefs", name]`, `["walkers", name]` and `["domains", name]` remove one entry of their tables.
1397
2232
  *
1398
2233
  * A path that names no entry changes nothing. The function does not change the machine. An own entry names an
1399
2234
  * evaluator directly, thus only a machine without the code of a name refuses each document that names it.
@@ -1440,102 +2275,16 @@ export declare function classify(shapes: readonly Shape$1[], value: Json): Class
1440
2275
  */
1441
2276
  export declare function tag(value: Json, kind: string): Envelope;
1442
2277
  //#endregion
1443
- //#region src/parts.d.ts
1444
- /** One part of a value: its place in the value, the JSON of the part, and the type that its position declares. */
1445
- interface PartSlot {
1446
- /** The keys from the value of the document to the part. */
1447
- readonly path: readonly Key[];
1448
- /** The path as one text, with a dot between the keys, for example `bind.x`. A part of a list has its index. */
1449
- readonly key: string;
1450
- readonly item: Json;
1451
- readonly of?: string;
1452
- /** `true` when the position of the part declares an address: a reference there gives what its path reaches. */
1453
- readonly address?: true;
1454
- }
1455
- /** The value of a document, split into its parts, by the shape that its kind declares. */
1456
- type Split = {
1457
- readonly ok: true;
1458
- /** The parts, in the order of the value. */
1459
- readonly parts: readonly PartSlot[];
1460
- /** The value without the parts: a field that holds a part is not in it, and a list of parts gives `null`. */
1461
- readonly data: Json;
1462
- /**
1463
- * This function gives the value with a handle in the place of each part.
1464
- *
1465
- * @param handles - One handle for each part, in the order of `parts`.
1466
- * @returns The value with the handles.
1467
- */
1468
- fill<P>(handles: readonly P[]): unknown;
1469
- } | {
1470
- readonly ok: false;
1471
- readonly reason: string;
1472
- readonly at: readonly Key[];
1473
- };
1474
- /**
1475
- * This function splits a value into its parts, by the shape that its kind declares. The evaluator, the view and
1476
- * the static kit use the same split, thus each one sees the same parts.
1477
- *
1478
- * @param shape - The shape of the value. The default is data.
1479
- * @param value - The value of the document.
1480
- * @returns The parts and a way to fill their places, or the reason why the value does not have the shape.
1481
- */
1482
- export declare function splitParts(shape: Shape | undefined, value: Json): Split;
1483
- /**
1484
- * The kind and the parts of one document: what `partsOf` gives. `ok` is `false` only when the value is not a
1485
- * document: it has no envelope, and its position declares no type. A value without the shape of its kind gives a
1486
- * failed `split`.
1487
- */
1488
- type DocParts = {
1489
- readonly ok: true;
1490
- /** The document. A bare value gets the type that its position declares. */
1491
- readonly doc: Envelope;
1492
- /** `true` when the type came from the position and not from an envelope. */
1493
- readonly declared: boolean;
1494
- /** The kind, or `undefined` when the world has no kind for the type. Then the value is data. */
1495
- readonly kind: Kind | undefined;
1496
- /** The keys of the kind after each alias, or `undefined` without a kind. */
1497
- readonly typePath: readonly Key[] | undefined;
1498
- /**
1499
- * The split of the value by the shape of the kind. The reason of a failed split is the reason of the `#VALUE!`
1500
- * of an evaluation: it names the kind. Its `at` gives the keys from the value to the problem.
1501
- */
1502
- readonly split: Split;
1503
- } | {
1504
- readonly ok: false;
1505
- readonly code: "#PART?";
1506
- readonly reason: string;
1507
- };
1508
- /**
1509
- * This function reads one document by the contracts of the world. It finds the kind of the type. A bare value gets
1510
- * the type that its position declares. Then the function splits the value by the shape of the kind. The plan, the
1511
- * reference interpreter and the static kit read each document with this function. Thus they see the same parts.
1512
- *
1513
- * @param world - The world of the kinds.
1514
- * @param value - The document, or a bare value.
1515
- * @param declaredType - The type that the position of a bare value declares.
1516
- * @returns The document, its kind and its parts, or the reason why the value is not a document.
1517
- */
1518
- export declare function partsOf(world: World, value: unknown, declaredType?: string): DocParts;
1519
- /**
1520
- * This function tells if the path of a part matches a pattern of a scope rule. The key `"*"` of a pattern matches
1521
- * each key.
1522
- *
1523
- * @param path - The path of the part.
1524
- * @param pattern - The pattern.
1525
- * @returns `true` when the path matches.
1526
- */
1527
- export declare function pathMatches(path: readonly Key[], pattern: readonly Key[]): boolean;
1528
- //#endregion
1529
- //#region src/stdlib.d.ts
1530
- /**
1531
- * The world of the examples: small kinds for numbers, lists, conditions, names, sequences and effects.
1532
- * Each kind names an evaluator for `eval` and a view for `view`. The site draws each document with its view.
1533
- */
1534
- export declare const STD_WORLD: World;
1535
- /** The code of the evaluators of the standard world, by name. */
1536
- export declare const STD_EVALUATORS: Readonly<Record<string, Evaluator>>;
1537
- /** The options of a walker `nearest`. */
1538
- interface NearestOptions {
2278
+ //#region src/stdlib.d.ts
2279
+ /**
2280
+ * The world of the examples: small kinds for numbers, lists, conditions, names, sequences and effects.
2281
+ * Each kind names an evaluator for `eval` and a view for `view`. The site draws each document with its view.
2282
+ */
2283
+ export declare const STD_WORLD: World;
2284
+ /** The code of the evaluators of the standard world, by name. */
2285
+ export declare const STD_EVALUATORS: Readonly<Record<string, Evaluator>>;
2286
+ /** The options of a walker `nearest`. */
2287
+ interface NearestOptions {
1539
2288
  /**
1540
2289
  * This function tells if a node has the wanted type. The default compares the field `type` of a host thing.
1541
2290
  *
@@ -1563,7 +2312,7 @@ export declare const STD_WALKERS: Readonly<Record<string, Walker>>;
1563
2312
  * order. In a run, an effect ends before the next step starts.
1564
2313
  */
1565
2314
  export declare const STD_RUNNERS: Readonly<Record<string, Runner>>;
1566
- /** The machine of the examples: the standard world, its evaluators, its runners and its walkers. */
2315
+ /** The machine of the examples: the standard world, its evaluators, its runners, its walkers and the domains of the kernel. */
1567
2316
  export declare const STD_MACHINE: Machine;
1568
2317
  /** The capabilities of the examples at the root: the two effects of the standard world. */
1569
2318
  export declare const STD_CAPS: readonly string[];
@@ -1669,155 +2418,144 @@ interface Construct {
1669
2418
  /** Six constructs that show the range of the context. */
1670
2419
  export declare const CONSTRUCTS: readonly Construct[];
1671
2420
  //#endregion
1672
- //#region src/static.d.ts
1673
- /** One document that a walk visits. */
1674
- interface DocVisit {
1675
- /** The keys from the root document to this document, through the parts. It is the place of an error. */
1676
- readonly place: readonly Key[];
1677
- /** The keys from the root JSON value to this document. A change at this path changes this document. */
1678
- readonly at: readonly Key[];
1679
- /** The visit of the document that holds this document as a part. The root has none. */
1680
- readonly parent?: DocVisit | undefined;
1681
- /** The keys from the value of the parent to this document: the path of the part. The root has none. */
1682
- readonly slot: readonly Key[];
1683
- /** The document. A bare value has the type that its position declares. */
1684
- readonly doc: Envelope;
1685
- /** `true` when the type came from the position and not from an envelope. */
1686
- readonly declared: boolean;
1687
- /** The kind of the document, when the world has it. */
1688
- readonly kind?: Kind | undefined;
1689
- /** The keys of the kind after each alias. */
1690
- readonly typePath?: readonly Key[] | undefined;
1691
- /** The number of documents around this document. The root has 0. */
1692
- readonly depth: number;
1693
- /** The names that the kinds around this document bind for it. */
1694
- readonly names: ReadonlySet<string>;
1695
- /** The names that a sequence around this document binds only for the parts after it. */
1696
- readonly later: ReadonlySet<string>;
1697
- /** `true` when the position of the document declares an address: a reference there is not a read of a value. */
1698
- readonly address?: true | undefined;
2421
+ //#region src/facts.d.ts
2422
+ /**
2423
+ * One read of a document: a free reference, with its marks (FACTS.READS). A plan resolves the path of the reference
2424
+ * when it evaluates the reference. The static read covers each path that the plan resolves there (FACTS.SOUND).
2425
+ */
2426
+ interface StaticRead {
2427
+ /** The root of the path. */
2428
+ readonly root: Root;
2429
+ /** The keys after the root, up to the first step that is not a key. */
2430
+ readonly keys: readonly Key[];
1699
2431
  /**
1700
- * The capabilities of the document: the capabilities of the walk, narrowed by the capability rules of the kinds
1701
- * around it (`Kind.caps`). A walk without capabilities gives none here.
2432
+ * `true` when each step after the root is a key. Then the plan resolves this path and no other. A step document,
2433
+ * for example `nearest`, makes it `false`: the plan resolves a path that starts with the keys.
1702
2434
  */
1703
- readonly caps?: readonly Cap[] | undefined;
1704
- }
1705
- /** A position that a walk cannot read as a document. */
1706
- interface WalkProblem {
1707
- /** The keys from the root document to the document with the problem. */
2435
+ readonly exact: boolean;
2436
+ /** `true` when only a lazy part reaches the reference. An evaluation can then give a value without this read (FACTS.LAZY). */
2437
+ readonly lazy: boolean;
2438
+ /** `true` when the position of the reference declares an address. The read gives what the path reaches, not its value. */
2439
+ readonly address: boolean;
2440
+ /** The path of the reference: its root and its steps. */
2441
+ readonly path: readonly Json[];
2442
+ /** The keys from the root document to the reference document, through the parts. */
1708
2443
  readonly place: readonly Key[];
1709
- /** The keys from the root JSON value to the value with the problem. */
2444
+ /** The keys from the root JSON value to the reference document. */
1710
2445
  readonly at: readonly Key[];
1711
- readonly code: "#PART?" | "#VALUE!";
1712
- readonly reason: string;
1713
2446
  }
1714
- /** The options of a walk. */
1715
- interface WalkOptions {
2447
+ /** The static facts of one document (D24). They depend only on the document and the machine, not on a context. */
2448
+ interface DocFacts {
2449
+ /** The free references, in the order of the document (FACTS.READS). A reference to a name that a kind binds is not here. */
2450
+ readonly reads: readonly StaticRead[];
2451
+ /** `"run"` when one kind of the document is on the run side (FACTS.SIDE). */
2452
+ readonly side: Side;
2453
+ /** The kinds of the effects that the contracts declare, as texts with dots, each one time (FACTS.EFFECTS). */
2454
+ readonly effects: readonly string[];
2455
+ /**
2456
+ * `true` when each kind of the document declares `pure`, and the document has no effect and is not volatile. Then
2457
+ * its result depends only on what its reads give (FACTS.PURE).
2458
+ */
2459
+ readonly pure: boolean;
2460
+ /** `true` when the result can change while each read gives the same thing, for example with a clock (FACTS.VOLATILE). */
2461
+ readonly volatile: boolean;
2462
+ /** The number of documents in the document: a hint of the cost of an evaluation. */
2463
+ readonly size: number;
2464
+ }
2465
+ /** The options of `factsOf`. */
2466
+ interface FactsOptions {
1716
2467
  /** The type of a bare root value. */
1717
2468
  readonly declaredType?: string;
1718
- /** The names that the host binds at the root. */
1719
- readonly names?: readonly string[];
1720
- /** The capabilities at the root. With them, each visit gets the capabilities of its document. */
1721
- readonly caps?: readonly Cap[];
1722
2469
  /**
1723
- * This function gets each position that is not a document.
2470
+ * The verb whose evaluators the facts describe, as in `prepare`. The default is `eval`. The contract of a kind
2471
+ * describes the code of `eval` only. For another verb, only the hook `facts` describes the code (FACTS.VERB).
2472
+ */
2473
+ readonly verb?: string;
2474
+ /**
2475
+ * This function tells if a read reaches a volatile value of the host, for example a function that reads a clock.
2476
+ * A read that it marks makes the document volatile (FACTS.VOLATILE).
1724
2477
  *
1725
- * @param problem - The position and the reason.
2478
+ * @param read - The read.
2479
+ * @returns `true` when the read reaches a volatile value.
1726
2480
  */
1727
- readonly problem?: (problem: WalkProblem) => void;
2481
+ readonly volatile?: (read: StaticRead) => boolean;
1728
2482
  }
1729
2483
  /**
1730
- * This function visits each document of a document: the root and each part at each depth, by the contracts of the
1731
- * kinds. A part of a kind that the world does not have is not visited. With capabilities in the options, the walk
1732
- * narrows them for each part by the rules of its kind, as a run does. The walk uses no stack of the host for the
1733
- * depth, thus a deep document cannot overflow it. The time and the memory of a walk are linear in the size of the
1734
- * document. A visit makes the keys of its place and of its path only when a reader asks for them.
2484
+ * This function gives the static facts of a document, for a schedule (R4 P2, D24). It walks the document one time,
2485
+ * by the contracts of its kinds:
1735
2486
  *
1736
- * @param world - The world of the kinds.
1737
- * @param doc - The document, as JSON.
1738
- * @param visit - The function that gets each document. It gives `"skip"` to not visit the parts of a document.
1739
- * @param options - The type of a bare root value, the names, the capabilities and a function for the problems.
1740
- */
1741
- export declare function walk(world: World, doc: unknown, visit: (visit: DocVisit) => void | "skip", options?: WalkOptions): void;
1742
- /** One reference of a document. */
1743
- interface RefUse {
1744
- /** The visit of the reference document: its parent, its depth and the names that it sees. */
1745
- readonly visit: DocVisit;
1746
- /** The place of the reference document, through the parts. */
1747
- readonly place: readonly Key[];
1748
- /** The keys from the root JSON value to the reference document. */
1749
- readonly at: readonly Key[];
1750
- /** The path of the reference: its root and its steps. */
1751
- readonly path: readonly Json[];
1752
- readonly root: string;
1753
- /** `false` when a kind around the reference binds its first name. A reference to another root is free. */
1754
- readonly free: boolean;
1755
- /** `true` when the reference is an address: its position declares it. An address does not read a value. */
1756
- readonly address: boolean;
1757
- }
1758
- /**
1759
- * This function finds each reference of a document: each document of the type `ref` that a walk reaches. A
1760
- * reference to a name that a kind around it binds is not free. The others are what the document reads from
1761
- * outside: its dependencies. When the kind `ref` has parts, the walk also finds the references in its step documents.
2487
+ * - `reads`: each free reference, with the root and the keys of its path. A read under a lazy part has the mark
2488
+ * `lazy`, for example a read in a branch of `if`. A read after a step document has `exact: false`.
2489
+ * - `side` and `effects`: from the contract of each kind.
2490
+ * - `pure`: each kind declares `pure`, and the document has no effect and is not volatile.
2491
+ * - `volatile`: a kind, an operation or a step document declares `volatile`, or the host marks a read.
1762
2492
  *
1763
- * @param world - The world of the kinds.
1764
- * @param doc - The document, as JSON.
1765
- * @param options - The type of a bare root value. The names of the host do not change the result.
1766
- * @returns The references, in the order of the document.
1767
- */
1768
- export declare function refsOf(world: World, doc: unknown, options?: WalkOptions): readonly RefUse[];
1769
- /**
1770
- * This function changes the free references of a document. The document is not changed: the function gives a new
1771
- * document that shares each part without a change.
2493
+ * The hook `facts` of the machine answers for a name that a fallback kind covers, for example an operation. Its
2494
+ * answer wins over the contract of the kind. The contract of a kind does not describe the evaluator of an own
2495
+ * entry. Thus a document with an own entry for another evaluator is not pure, and each of its parts is lazy. The
2496
+ * hook can still answer for that evaluator.
1772
2497
  *
1773
- * @param world - The world of the kinds.
2498
+ * The option `verb` names the verb whose code the facts describe (FACTS.VERB). A contract describes the code of
2499
+ * `eval`, thus the rule of an own entry applies to each document for another verb. The side and the effects come
2500
+ * from the contracts for each verb.
2501
+ *
2502
+ * A read is one resolution of its path. A reference that the resolution reaches and follows is a part of that read
2503
+ * (DEREF.COLLAPSE), not a separate read. The facts depend only on the document and the machine. Thus a host computes
2504
+ * them again only after an edit of the document or of the machine.
2505
+ *
2506
+ * @param machine - The world, the code and the hook `facts`.
1774
2507
  * @param doc - The document, as JSON.
1775
- * @param change - The function that gives the new document of a reference, or `undefined` to keep it.
1776
- * @param options - The type of a bare root value, and the names that the host binds at the root.
1777
- * @returns The new document.
2508
+ * @param options - The type of a bare root value, the verb and the volatile reads of the host.
2509
+ * @returns The facts.
1778
2510
  */
1779
- export declare function mapRefs(world: World, doc: unknown, change: (use: RefUse) => unknown, options?: WalkOptions): unknown;
1780
- /** A problem that a check finds before a document runs. */
1781
- interface Issue {
1782
- readonly code: ErrorCode;
1783
- /** The keys from the root document to the document with the problem. */
1784
- readonly place: readonly Key[];
1785
- readonly reason: string;
1786
- /** The keys from the root JSON value to the value with the problem. */
1787
- readonly at?: readonly Key[];
1788
- }
1789
- /** The options of a check. */
1790
- interface CheckOptions {
2511
+ export declare function factsOf(machine: Machine, doc: unknown, options?: FactsOptions): DocFacts;
2512
+ //#endregion
2513
+ //#region src/effects.d.ts
2514
+ /** The options of `effectsOf`. */
2515
+ interface EffectsOptions {
1791
2516
  /** The type of a bare root value. */
1792
2517
  readonly declaredType?: string;
1793
- /** The names that the host binds at the root. `"any"` does not check the names. The default is no names. */
1794
- readonly names?: readonly string[] | "any";
1795
2518
  /**
1796
- * The capabilities at the root. Without them, the check does not check the effects. The check narrows them for
1797
- * each part by the capability rules of the kinds, as a run does.
2519
+ * The capabilities at the root. With them, the result keeps only the effects that the rule of the machine permits at
2520
+ * their documents, as a run does (CAP.PERMITS). Without them, the root has each capability, and only the capability
2521
+ * rules of the kinds remove an effect.
1798
2522
  */
1799
2523
  readonly caps?: readonly Cap[];
1800
2524
  }
1801
2525
  /**
1802
- * This function checks a document before an evaluation, by the contracts of its kinds. It finds the problems
1803
- * that an evaluation finds when it reaches them:
2526
+ * This function gives the effects of a document that can reach the host (CAP.EFFECTS-OF, R2 P3). The result is the
2527
+ * effects that the contract of each kind declares, without the effects that the capability rules around them remove.
2528
+ * A rule `mask` removes each effect of its parts, and a rule `only` removes each effect outside its list.
1804
2529
  *
1805
- * - `#KIND?`: a kind that the world does not have.
1806
- * - `#NOEVAL`: no evaluator.
1807
- * - `#VALUE!`: a value without the shape of its kind.
1808
- * - `#PART?`: a value without a type.
1809
- * - `#DEPTH!`: too much nesting.
1810
- * - `#REF!` and `#STEP?`: a bad path.
1811
- * - `#NAME?`: a name that nothing binds. With the hook `known` of the machine, also a name that the language does not
1812
- * have, for example an operation.
1813
- * - `#CAP!`: an effect that the capabilities of its document do not permit. A kind around the document can narrow them.
2530
+ * Without capabilities in the options, the result is the least authority of the document. A host that grants these
2531
+ * kinds as capabilities grants each effect that a run of the document can give it. With capabilities, the result keeps
2532
+ * only the effects that the rule of the machine permits at their documents.
1814
2533
  *
1815
- * @param machine - The world and the code of the evaluators.
2534
+ * The result covers each effect that an evaluation or a run gives the host (CAP.EFFECTS-SOUND). A procedure value keeps
2535
+ * the capabilities of the document that made it, thus the effects of its body count at the body (CAP.LATENT). The
2536
+ * contract describes the code of its kind. The code of an own entry for another evaluator is outside the result.
2537
+ *
2538
+ * @param machine - The world and its contracts, and the hook `permits`.
1816
2539
  * @param doc - The document, as JSON.
1817
- * @param options - The type of a bare root value, the names of the host and the capabilities.
1818
- * @returns The problems, in the order of the document.
2540
+ * @param options - The type of a bare root value and the capabilities at the root.
2541
+ * @returns The kinds of the effects, as texts with dots, each one time, in the order of the document.
1819
2542
  */
1820
- export declare function check(machine: Machine, doc: unknown, options?: CheckOptions): readonly Issue[];
2543
+ export declare function effectsOf(machine: Machine, doc: unknown, options?: EffectsOptions): readonly string[];
2544
+ /**
2545
+ * This function compares the latent effects that a procedure declares with the body of the procedure (CAP.LATENT). A
2546
+ * procedure entry is a kind whose code evaluates the document of a procedure. Its field `effects` declares the latent
2547
+ * effects: the effects that a call of the procedure can cause. `check` tests each call against this declaration.
2548
+ *
2549
+ * The function gives a `#CAP!` for each effect of the body that can reach the host and that the declaration does not
2550
+ * permit. An effect that a kind in the body masks fails in the body, thus it is not a latent effect.
2551
+ *
2552
+ * @param machine - The world and its contracts.
2553
+ * @param declared - The latent effects that the procedure declares, for example the field `effects` of its kind.
2554
+ * @param body - The document of the procedure, as JSON.
2555
+ * @param options - The type of a bare root value.
2556
+ * @returns The issues, in the order of the body.
2557
+ */
2558
+ export declare function checkLatent(machine: Machine, declared: readonly Cap[], body: unknown, options?: Omit<EffectsOptions, "caps">): readonly Issue[];
1821
2559
  //#endregion
1822
2560
  //#region src/formula.d.ts
1823
2561
  /** An operation of a formula language: a function of the values of its arguments. */
@@ -1845,6 +2583,14 @@ type ExtFn = (data: Json, context: Context) => Result;
1845
2583
  * - `check`: a check of the value of an operation, for example "a number must be finite".
1846
2584
  * - `combine`: the error of two or more failed parts of an operation, a `record` or a `list`. With it, each part
1847
2585
  * evaluates, and one failed part gives its own error. Without it, the first error stops the evaluation.
2586
+ * - `pure`: the pure operations, for `factsOf` (D24). `true` names each operation that is not volatile. The default
2587
+ * names no operation.
2588
+ * - `volatile`: the operations whose results can change while their arguments stay the same, for example a clock.
2589
+ * - `sigs`: the signatures of the operations, by their name, for a check of types (TYPE.SIGNATURE). A list gives
2590
+ * overloads. An operation without a signature takes and gives `unknown` (TYPE.GRADUAL).
2591
+ *
2592
+ * A check of types trusts the signatures. Each operation must give a member of the result of each signature that
2593
+ * its arguments match. The hook `check` must keep each result in that type.
1848
2594
  */
1849
2595
  interface FormulaProfile {
1850
2596
  readonly ops?: Readonly<Record<string, OpFn>> | ((name: string) => OpFn | undefined);
@@ -1857,6 +2603,22 @@ interface FormulaProfile {
1857
2603
  readonly missing?: (value: unknown) => boolean;
1858
2604
  readonly check?: (value: unknown, op: string) => Result | undefined;
1859
2605
  readonly combine?: (errors: readonly EvalError[]) => EvalError;
2606
+ readonly pure?: true | readonly string[];
2607
+ readonly volatile?: readonly string[];
2608
+ readonly sigs?: Readonly<Record<string, Signature | readonly Signature[]>> | ((name: string) => Signature | readonly Signature[] | undefined);
2609
+ }
2610
+ /**
2611
+ * The signature of an operation: the value types of its parameters and of its result (TYPE.SIGNATURE). A parameter of
2612
+ * the type `unknown` at the end of `params` is optional. A later version can add a key, for example the type that a
2613
+ * true result proves.
2614
+ */
2615
+ interface Signature {
2616
+ /** The types of the parameters, in order. */
2617
+ readonly params: readonly ValueType[];
2618
+ /** The type of each argument after the parameters. Without it, the operation takes no more arguments. */
2619
+ readonly rest?: ValueType;
2620
+ /** The type of the result. */
2621
+ readonly to: ValueType;
1860
2622
  }
1861
2623
  /** The value of a name whose binding failed. A reference to the name gives the error. */
1862
2624
  export declare class Held {
@@ -1890,7 +2652,7 @@ export declare function jsTruthy(value: unknown): boolean;
1890
2652
  export declare function formulaKinds(): Readonly<Record<string, WorldEntry>>;
1891
2653
  /**
1892
2654
  * This function makes the evaluators of the formula kit for one language. Each evaluator compiles its document
1893
- * one time into code.
2655
+ * one time into code. Each evaluator also holds its type rule, for a check of types (TYPE.SYNTH).
1894
2656
  *
1895
2657
  * @param profile - The operations and the rules of the language.
1896
2658
  * @returns The evaluators, by their name.
@@ -1907,16 +2669,31 @@ export declare function formulaEvaluators(profile?: FormulaProfile): Readonly<Re
1907
2669
  * @returns The hook: `true`, or the reason of the `#NAME?` that the evaluator gives in a run.
1908
2670
  */
1909
2671
  export declare function formulaKnown(profile?: FormulaProfile): (path: readonly Key[], evaluator: string) => true | string;
2672
+ /**
2673
+ * This function makes the hook `facts` of the formula kit for one profile (FACTS.PROFILE, D24). It answers for the
2674
+ * operations and the extensions, because one fallback kind covers each of them.
2675
+ *
2676
+ * - An operation of `lazy` has a lazy rule for each argument.
2677
+ * - An operation is pure when the profile names it in `pure`, or when `pure` is `true`. A volatile operation is not pure.
2678
+ * - A standard extension is pure. An extension of the profile gets the context, thus it is not pure.
2679
+ *
2680
+ * @param profile - The operations, the extensions and their facts.
2681
+ * @returns The hook: the facts of a name, or `undefined` for the facts of the contract.
2682
+ */
2683
+ export declare function formulaFacts(profile?: FormulaProfile): (path: readonly Key[], code: string) => KindFacts | undefined;
1910
2684
  /**
1911
2685
  * This function makes a machine for a formula language. It merges the kit and the parts that the language adds with
1912
2686
  * `mergeMachines`. Thus a kind `ops.*` or a namespace `ops` of the language extends the namespace of the kit, and
1913
2687
  * the fallback of the kit stays. The hook `known` of the kit comes from the profile (`formulaKnown`). A hook `known`
1914
- * of the language answers after it.
2688
+ * of the language answers after it. The hook `facts` of the kit comes from the profile too (`formulaFacts`).
1915
2689
  *
1916
2690
  * A kind or an evaluator of the language that differs from the entry of the kit with its name is a conflict. The
1917
2691
  * language names the path in `replaces` to replace the entry, for example `["world", "kinds", "ref"]` or
1918
2692
  * `["evaluators", "formula.op"]`. Then the hook of the kit does not answer for a replaced evaluator.
1919
2693
  *
2694
+ * The kit gives the domains of the kernel (`STD_DOMAINS`). Thus a domain of the language with the name `number` is a
2695
+ * conflict. The language names `["domains", "number"]` in `replaces` to replace it.
2696
+ *
1920
2697
  * @param profile - The operations and the rules of the language.
1921
2698
  * @param more - The parts of a machine that the language adds, with the paths of the entries that it replaces.
1922
2699
  * @returns The machine.
@@ -1941,16 +2718,26 @@ interface ReferenceOptions {
1941
2718
  readonly definitions?: Definitions;
1942
2719
  /** A list that gets each effect, in its order. */
1943
2720
  readonly effects?: Effect[];
2721
+ /** The mock of the host (RUN.MOCK). It answers each effect at once. Without it, an effect gives its payload. */
2722
+ readonly perform?: Perform;
2723
+ /**
2724
+ * The verb that goes up the ladder at each document, as in `prepare`. The default is `eval`. The reference reads
2725
+ * each verb by the same rules (VERB.AGREE).
2726
+ */
2727
+ readonly verb?: string;
1944
2728
  }
1945
2729
  /**
1946
2730
  * This function evaluates a document by the rules, without a compilation. It is the reference of the plans: a plan,
1947
2731
  * a traced plan and the second tier of a language must give its results. It covers evaluations, not runs: an effect
1948
- * gives its payload, and a part that waits gives `#CALC!`.
2732
+ * gives the answer of the mock or its payload, and a part that waits gives `#CALC!`.
2733
+ *
2734
+ * The verb of the options goes up the ladder at each document, as in `prepare`. Each verb has the same rules: the
2735
+ * ladder, the contract of the kind and the sealed parts (VERB.AGREE).
1949
2736
  *
1950
2737
  * @param machine - The world and the code of the evaluators.
1951
2738
  * @param doc - The document.
1952
2739
  * @param context - The names and the capabilities at the root.
1953
- * @param options - The type of a bare root value, the definitions of compiled code, and a list for the effects.
2740
+ * @param options - The type of a bare root value, the definitions of compiled code, a list for the effects, a mock and the verb.
1954
2741
  * @returns The result.
1955
2742
  */
1956
2743
  export declare function reference(machine: Machine, doc: unknown, context?: Context, options?: ReferenceOptions): Result;
@@ -1984,10 +2771,23 @@ interface TierResult {
1984
2771
  readonly result: Result;
1985
2772
  readonly effects?: readonly Effect[];
1986
2773
  }
2774
+ /** What `agree` gives the second tier of a language beside the document and the context. */
2775
+ interface TierInput {
2776
+ /** The mock of the host, when `agree` has one (AGREE.MOCK). The tier answers each effect with it. */
2777
+ readonly perform?: Perform;
2778
+ /** The verb of `agree`, when its options name one (VERB.AGREE). A tier that does not serve the verb fails. */
2779
+ readonly verb?: string;
2780
+ }
1987
2781
  /** The options of `agree`. */
1988
2782
  interface AgreeOptions {
1989
2783
  /** The type of a bare root value. */
1990
2784
  readonly declaredType?: string;
2785
+ /**
2786
+ * The verb of each tier, as in `prepare`. The default is `eval`. The plan, the reference, the traced evaluation and a
2787
+ * second evaluation each ask the ladder for this verb (VERB.AGREE). The second tier of a language gets it in its
2788
+ * input.
2789
+ */
2790
+ readonly verb?: string;
1991
2791
  /** The definitional code of the compiled evaluators of the machine, for the reference. */
1992
2792
  readonly definitions?: Definitions;
1993
2793
  /** The tiers to compare with the plan. The default is the reference, the traced evaluation and a second evaluation. */
@@ -1997,9 +2797,15 @@ interface AgreeOptions {
1997
2797
  *
1998
2798
  * @param doc - The document.
1999
2799
  * @param context - The context.
2800
+ * @param input - The mock of the host and the verb, when `agree` has them.
2000
2801
  * @returns The result, or the result with the effects.
2001
2802
  */
2002
- readonly other?: (doc: unknown, context: Context) => Result | TierResult;
2803
+ readonly other?: (doc: unknown, context: Context, input: TierInput) => Result | TierResult;
2804
+ /**
2805
+ * The mock of the host (RUN.MOCK, AGREE.MOCK). Each tier gets it, thus the tiers agree on documents with effects. A
2806
+ * mock must give the same answer to the same effect, because each tier asks it again.
2807
+ */
2808
+ readonly perform?: Perform;
2003
2809
  /**
2004
2810
  * This function compares two values that the rules of `sameValue` do not know, for example two dates.
2005
2811
  *
@@ -2043,8 +2849,9 @@ type Agreement = {
2043
2849
  * errors have the same code and place. Each other object is the same only as itself, unless the rule of the caller
2044
2850
  * tells otherwise.
2045
2851
  *
2046
- * `docEquals` uses the same rules for lists, plain records and the other objects. It has no rules for closures, for
2047
- * `Held` values and for a rule of the caller. Thus two closures are equal there only when they are the same function.
2852
+ * `docEquals` and `sameResult` use the same walk (D20). `docEquals` has no rules for closures, for `Held` values and
2853
+ * for a rule of the caller. `sameResult` is for an early cutoff, thus a closure is the same there only as itself, and
2854
+ * two errors also need the same reason.
2048
2855
  *
2049
2856
  * @param a - The first value.
2050
2857
  * @param b - The second value.
@@ -2056,16 +2863,625 @@ export declare function sameValue(a: unknown, b: unknown, equal?: (a: unknown, b
2056
2863
  * This function evaluates a document with a plan and with other tiers, and compares the results (PLAN.AGREES). Two
2057
2864
  * results agree when they have the same value by `sameValue`, or errors with the same code, and the same place when
2058
2865
  * both have one. The effects must have the same kinds, places and payloads, in the same order. A language gives its
2059
- * own tier with the option `other`.
2866
+ * own tier with the option `other`. Each tier gets the mock of the option `perform` (AGREE.MOCK).
2060
2867
  *
2061
2868
  * @param machine - The world and the code of the evaluators.
2062
2869
  * @param doc - The document.
2063
2870
  * @param context - The names and the capabilities at the root.
2064
- * @param options - The tiers, the definitions for the reference, the rules of the comparison and the second tier.
2871
+ * @param options - The tiers, the definitions for the reference, the rules of the comparison, the second tier and the mock.
2065
2872
  * @returns The result of the plan, or the first tier that disagrees and the reason.
2066
2873
  */
2067
2874
  export declare function agree(machine: Machine, doc: unknown, context?: Context, options?: AgreeOptions): Agreement;
2068
2875
  //#endregion
2876
+ //#region src/conform.d.ts
2877
+ /**
2878
+ * An obligation that `conforms` checks. `C1` to `C8` are the obligations of host code in `docs/SEMANTICS.md`. `local`
2879
+ * and `agree` are two premises of the simulation of the plan (SIM-PLAN).
2880
+ *
2881
+ * - `C1`: each context that the code gives a part, or an effect, has only the capabilities of its document.
2882
+ * - `C2`: the code causes only the effects that the contract of the kind declares.
2883
+ * - `C3`: each eager part evaluates when the result is a value, and a lazy part evaluates only when its result counts.
2884
+ * - `C4`: the code of a pure kind causes no effect, and it reads the context only through `resolve`.
2885
+ * - `C5`: the code reads its parts only through their handles, not through the JSON of the document.
2886
+ * - `C6`: only a runner waits, and a runner passes each wait of its parts and its effects through.
2887
+ * - `C7`: the code binds for a part each name that the scope rules give the part, and no other name.
2888
+ * - `C8`: compiled code gives the result of code that compiles again at the time of the evaluation.
2889
+ * - `local`: the code keeps no state from one call to the next.
2890
+ * - `agree`: compiled code gives the result of its definition for the reference interpreter.
2891
+ */
2892
+ type Obligation = "C1" | "C2" | "C3" | "C4" | "C5" | "C6" | "C7" | "C8" | "local" | "agree";
2893
+ /** The probe of a finding: the document, the result of each probe part, the capabilities and the handler. */
2894
+ interface ConformProbe {
2895
+ /** The text of the type of the document. */
2896
+ readonly type: string;
2897
+ /** The document. A probe document takes the place of each part. */
2898
+ readonly doc: Envelope;
2899
+ /** The result of each probe part, by the key of the part. */
2900
+ readonly results: Readonly<Record<string, Result>>;
2901
+ /** The keys of the probe parts that wait for the host before they give their result. Only a run has them. */
2902
+ readonly waits: readonly string[];
2903
+ /** The capabilities of the context of the document. */
2904
+ readonly caps: readonly Cap[];
2905
+ /** `true` in a run, in which the host does each effect and a part can wait. */
2906
+ readonly running: boolean;
2907
+ }
2908
+ /** One obligation that the code breaks, with the reason and the first probe that shows it. */
2909
+ interface Finding {
2910
+ readonly obligation: Obligation;
2911
+ /** One or two sentences that tell what the code did. */
2912
+ readonly reason: string;
2913
+ readonly probe: ConformProbe;
2914
+ }
2915
+ /** The options of `conforms`. */
2916
+ interface ConformOptions {
2917
+ /**
2918
+ * The verb that the evaluator serves. The default is `eval`. The facts of a contract (`effects`, `pure` and `lazy`)
2919
+ * describe only `eval`, thus `conforms` checks C2, C3 and C4 only for `eval` (D23).
2920
+ */
2921
+ readonly verb?: string;
2922
+ /**
2923
+ * The types of the probe documents. The default is each kind of the world whose verb names the evaluator. A fallback
2924
+ * kind gives the key `probe`, for example `["ops", "probe"]`. The contract of the kind of each type applies.
2925
+ */
2926
+ readonly types?: readonly TypeRef[];
2927
+ /**
2928
+ * More values of probe documents, by the text of their type. A probe document takes the place of each part of such a
2929
+ * value. Use them for data that the code needs, for example the key of `write`.
2930
+ */
2931
+ readonly values?: Readonly<Record<string, readonly Json[]>>;
2932
+ /**
2933
+ * The results that a probe part can give. The default holds numbers, truth values, a text, `null`, a list, a
2934
+ * record, a function and two errors.
2935
+ */
2936
+ readonly results?: readonly Result[];
2937
+ /**
2938
+ * The definitional code of the compiled evaluators and runners, as for `reference`. A standard evaluator gets its
2939
+ * definition from `STD_DEFINITIONS`.
2940
+ */
2941
+ readonly definitions?: Definitions;
2942
+ /** The capabilities of half of the probes. The other half has none. The default is the declared effects and `probe`. */
2943
+ readonly caps?: readonly Cap[];
2944
+ /** The names of the context of each probe. */
2945
+ readonly names?: Readonly<Record<string, unknown>>;
2946
+ /** The seed of the random results. The same seed gives the same probes. The default is 1. */
2947
+ readonly seed?: number;
2948
+ /** The count of probes with random results for each probe document. The default is 12. */
2949
+ readonly runs?: number;
2950
+ /** The mock of the host (RUN.MOCK). It answers each effect at once. Without it, an effect gives its payload. */
2951
+ readonly perform?: Perform;
2952
+ /**
2953
+ * This function compares two values that the rules of `sameValue` do not know, as in `agree`.
2954
+ *
2955
+ * @param a - The first value.
2956
+ * @param b - The second value.
2957
+ * @returns `true` or `false`, or `undefined` for the rules of `sameValue`.
2958
+ */
2959
+ readonly equal?: (a: unknown, b: unknown) => boolean | undefined;
2960
+ }
2961
+ /**
2962
+ * This function examines one evaluator or runner of a machine against the obligations of host code (K92, D36). It
2963
+ * starts the code directly, without the kernel, with probe parts and a probe runtime. It generates probe documents from
2964
+ * the contract of each kind that names the code, and it gives the probe parts chosen and random results.
2965
+ *
2966
+ * The checks follow the obligations C1 to C8 of `docs/SEMANTICS.md`. Two more checks follow the premises of the
2967
+ * simulation of the plan. The check `local` finds state that stays from one call to the next. The check `agree` compares
2968
+ * compiled code with its definition. The
2969
+ * finding of an obligation names the first probe that breaks it. An empty list means that each probe conforms.
2970
+ *
2971
+ * @param machine - The machine with the code and the world of the kinds.
2972
+ * @param name - The name of the evaluator or of the runner. A runner wins over an evaluator of the same name.
2973
+ * @param options - The verb, the types and the values of the probe documents, and the results of the probe parts. Also
2974
+ * the definitions, the capabilities, the names, the seed, the mock and the rule of equality.
2975
+ * @returns The first finding of each obligation that the code breaks, in the order of the obligations.
2976
+ * @throws {Error} The machine has no code with the name, or no kind names it and the options give no types.
2977
+ */
2978
+ export declare function conforms(machine: Machine, name: string, options?: ConformOptions): readonly Finding[];
2979
+ //#endregion
2980
+ //#region src/same.d.ts
2981
+ /**
2982
+ * This function tells if two results are the same for an early cutoff (RESULT.SAME). A schedule uses it to stop the
2983
+ * work when a part that evaluates again gives the same result. A wrong `true` keeps a stale value, but a wrong `false`
2984
+ * only costs work. Thus each rule gives `false` when it is not sure.
2985
+ *
2986
+ * - Two values compare by the rules of `docEquals`. Lists and plain records compare by their items and fields. Each
2987
+ * other value compares with `Object.is`.
2988
+ * - Thus `-0` is not `0`, and `NaN` is `NaN`. A date, a map and a closure of `fn` are the same only as themselves.
2989
+ * - Two errors are the same when they have the same code, reason and place (RESULT.SAME-ERROR). The cause is not
2990
+ * compared. A `Held` value compares its error by the same rule.
2991
+ * - A value and an error are not the same.
2992
+ *
2993
+ * `sameValue` of `agree` uses the same walk, with rules for two tiers (D20). It compares two closures by their
2994
+ * parameters, and two errors by their code and place.
2995
+ *
2996
+ * @param a - The earlier result.
2997
+ * @param b - The new result.
2998
+ * @param equal - The rule of the host for two values, for example two dates. It answers first, and `undefined` gives the rules above.
2999
+ * @returns `true` when the results are the same.
3000
+ */
3001
+ export declare function sameResult(a: Result<unknown>, b: Result<unknown>, equal?: (a: unknown, b: unknown) => boolean | undefined): boolean;
3002
+ //#endregion
3003
+ //#region src/reads.d.ts
3004
+ /** The answer of `verifyReads`: the old result stays valid, or the first read that reaches another thing. */
3005
+ type ReadsCheck = {
3006
+ readonly same: true;
3007
+ } | {
3008
+ readonly same: false;
3009
+ /** The index of the first changed read in the list. */
3010
+ readonly index: number;
3011
+ /** The first changed read, as the evaluation recorded it. */
3012
+ readonly read: Read;
3013
+ /** What the path of that read reaches in the new context. */
3014
+ readonly now: Result;
3015
+ };
3016
+ /** The options of `verifyReads`. */
3017
+ interface VerifyOptions {
3018
+ /**
3019
+ * The rule of the host for two things, as in `sameResult`. It answers first, and `undefined` gives the rules of
3020
+ * `sameResult`. An example is a rule for a host thing that keeps a version.
3021
+ *
3022
+ * @param a - The thing of the recorded read.
3023
+ * @param b - The thing in the new context.
3024
+ * @returns `true` when the two things are the same, or `undefined` for the rules of `sameResult`.
3025
+ */
3026
+ readonly equal?: (a: unknown, b: unknown) => boolean | undefined;
3027
+ }
3028
+ /**
3029
+ * This function tells if an old result stays valid in a new context (READS.VERIFY, D26). It resolves the path of
3030
+ * each free read again, in the order of the list, and it compares what the path reaches with `sameResult`. It stops at
3031
+ * the first read that reaches another thing, and it gives that read (READS.CHANGED).
3032
+ *
3033
+ * - A read that is not free reads a binding that a kind made from earlier reads, for example a name of `let`. The
3034
+ * function does not resolve it again.
3035
+ * - A thing compares as in `sameResult`. Thus a host thing or a date is the same only as itself. A host gives a new
3036
+ * object for a new state, or the option `equal`.
3037
+ * - A longer path through a name that holds a `Held` in the new context is a changed read. A reference of the formula
3038
+ * kit gives the error of that binding, and the resolution of the path does not show it.
3039
+ * - The answer is sound only for a pure document (FACTS.PURE). A document with an effect, a volatile operation or an
3040
+ * extension of a profile can read outside `resolve`. The schedule asks `factsOf` first.
3041
+ *
3042
+ * The values of the context must not change in place, as PLAN.CACHE says for the documents. A value that changed in
3043
+ * place is the same object, thus the function cannot see the change.
3044
+ *
3045
+ * @param target - The machine of the evaluation, or its plan.
3046
+ * @param reads - The reads of the evaluation, from the option `reads`.
3047
+ * @param context - The new context.
3048
+ * @param options - The rule of the host for two things.
3049
+ * @returns `{ same: true }` when each free read reaches the same thing, or else the first changed read.
3050
+ */
3051
+ export declare function verifyReads(target: Machine | Plan, reads: readonly Read[], context: Context, options?: VerifyOptions): ReadsCheck;
3052
+ //#endregion
3053
+ //#region src/durable.d.ts
3054
+ /** The two epochs of a host (DURABLE.EPOCHS). Each epoch counts the changes of its level. */
3055
+ interface Epochs {
3056
+ /** The count of the changes of the structure: a new machine, or an edit of a document. */
3057
+ readonly structure: number;
3058
+ /** The count of the changes of the data. A change of the structure is also a change of the data. */
3059
+ readonly data: number;
3060
+ }
3061
+ /** The work of a durable cache since its start. A schedule reads it as a measure, not as a rule (R4). */
3062
+ interface DurableCounts {
3063
+ /** The compilations: the calls of `prepare`. */
3064
+ readonly compiles: number;
3065
+ /** The calls of `factsOf`. */
3066
+ readonly facts: number;
3067
+ /** The evaluations of a plan. */
3068
+ readonly evaluations: number;
3069
+ /** The calls of `verifyReads`. */
3070
+ readonly verifications: number;
3071
+ /** The results that stayed without an evaluation. */
3072
+ readonly reuses: number;
3073
+ }
3074
+ /** The options of `durable`. */
3075
+ interface DurableOptions {
3076
+ /** The type of a bare root value, for each plan and each fact. */
3077
+ readonly declaredType?: string;
3078
+ /** The verb of each plan and each fact. The default is `eval` (VERB.PREPARE). */
3079
+ readonly verb?: string;
3080
+ /** The volatile reads of the host, as in `factsOf`. A document with such a read is not pure, thus it evaluates again after each change of data. */
3081
+ readonly volatile?: FactsOptions["volatile"];
3082
+ /** The rule of the host for two things, as in `verifyReads`. */
3083
+ readonly equal?: VerifyOptions["equal"];
3084
+ }
3085
+ /**
3086
+ * A cache of plans, facts and results with two levels of durability (D30). A host or a schedule tells the cache each
3087
+ * change of the structure and each change of the data.
3088
+ */
3089
+ interface Durable {
3090
+ /** The machine of the current structure epoch. */
3091
+ readonly machine: Machine;
3092
+ /** The current epochs. A schedule builds again what depends on the whole structure when `structure` changes, for example a graph of the nodes. */
3093
+ readonly epochs: Epochs;
3094
+ /** The work since the start. */
3095
+ readonly counts: DurableCounts;
3096
+ /**
3097
+ * This function gives the plan of a document. A document object compiles one time for a machine (DURABLE.STRUCTURE).
3098
+ * A change of data compiles nothing (DURABLE.DATA).
3099
+ *
3100
+ * @param doc - The document, as JSON.
3101
+ * @returns The plan.
3102
+ */
3103
+ plan(doc: unknown): Plan;
3104
+ /**
3105
+ * This function gives the static facts of a document. A document object computes its facts one time for a machine.
3106
+ *
3107
+ * @param doc - The document, as JSON.
3108
+ * @returns The facts.
3109
+ */
3110
+ facts(doc: unknown): DocFacts;
3111
+ /**
3112
+ * This function gives the result of the document of a node (DURABLE.REUSE). The key names the node, and in one data
3113
+ * epoch the context of a key gives the same data.
3114
+ *
3115
+ * - In the data epoch of its result, a key with the same plan gives that result again.
3116
+ * - After a change of data, a pure document verifies its reads, and it keeps its result when each read is the same.
3117
+ * - Each other document evaluates again.
3118
+ *
3119
+ * @param key - The name of the node in the host, for example the name of a cell.
3120
+ * @param doc - The document of the node.
3121
+ * @param context - The context of the node.
3122
+ * @returns The result.
3123
+ */
3124
+ evaluate(key: unknown, doc: unknown, context: Context): Result;
3125
+ /** This function tells the cache that the data changed: a context gives a new value (DURABLE.EPOCHS). */
3126
+ changeData(): void;
3127
+ /**
3128
+ * This function tells the cache that the structure changed (DURABLE.EPOCHS). An edit of a document gives a new
3129
+ * document object, and only that object compiles. A new machine drops each plan, each fact and each result.
3130
+ *
3131
+ * @param machine - The new machine, or `undefined` for an edit of a document.
3132
+ */
3133
+ changeStructure(machine?: Machine): void;
3134
+ /**
3135
+ * This function drops the result of a node, for example a node that the host removed.
3136
+ *
3137
+ * @param key - The name of the node.
3138
+ */
3139
+ forget(key: unknown): void;
3140
+ }
3141
+ /**
3142
+ * This function makes a cache with two levels of durability for a host or a schedule (R4 P7, D30). The structure is
3143
+ * the machine and the documents. The data is each value that a context gives: the names, `self`, `event`, the
3144
+ * capabilities and the world of the host.
3145
+ *
3146
+ * - A plan and the facts depend only on the structure. A document object compiles one time for a machine, thus a
3147
+ * change of data compiles nothing (DURABLE.DATA).
3148
+ * - A result depends on the data too. It stays in its data epoch. After a change of data, a pure document verifies
3149
+ * its reads with `verifyReads`, and each other document evaluates again.
3150
+ * - An edit gives a new document object, thus only that document compiles. A new machine drops each plan, each fact
3151
+ * and each result (DURABLE.STRUCTURE).
3152
+ *
3153
+ * The host keeps two promises. In one data epoch, the context of a key gives the same data. The values of a
3154
+ * context and the documents do not change in place, as PLAN.CACHE and `verifyReads` say.
3155
+ *
3156
+ * @param machine - The machine of the first structure epoch.
3157
+ * @param options - The type of a bare root value, the verb, the volatile reads and the rule of the host for two things.
3158
+ * @returns The cache.
3159
+ */
3160
+ export declare function durable(machine: Machine, options?: DurableOptions): Durable;
3161
+ //#endregion
3162
+ //#region src/schedule.d.ts
3163
+ /** One edge of a graph of nodes: a static read of a node from the document of another node (SCHED.EDGES). */
3164
+ interface NodeEdge {
3165
+ /**
3166
+ * The node that the read reaches: the first key after the root `world`. It is `undefined` when the read can reach
3167
+ * each node, for example the path `["world"]`, or a step document right after the root.
3168
+ */
3169
+ readonly to: string | undefined;
3170
+ /** The keys after the node, up to the first step document: the field of the node that the read reaches (SCHED.GRAIN). */
3171
+ readonly field: readonly Key[];
3172
+ /** `true` when only a lazy part reaches the read. An evaluation can then give a value without it (FACTS.LAZY). */
3173
+ readonly lazy: boolean;
3174
+ /** The static read of `factsOf`, with its path, its place and its mark `exact`. */
3175
+ readonly read: StaticRead;
3176
+ }
3177
+ /** One node of a schedule, with what the static facts tell about it (SCHED.GRAPH). */
3178
+ interface NodeInfo {
3179
+ /** The name of the node: its key under the root `world`. */
3180
+ readonly id: string;
3181
+ /** The document of the node. */
3182
+ readonly doc: unknown;
3183
+ /** The static facts of the document. */
3184
+ readonly facts: DocFacts;
3185
+ /** The side of the node, from the facts. A node on the run side is a sink: no node reads it (SCHED.SIDE). */
3186
+ readonly side: Side;
3187
+ /** The edges to the nodes that the document can read, in the order of its reads. */
3188
+ readonly edges: readonly NodeEdge[];
3189
+ }
3190
+ /** The options of `schedule`: the options of `durable`, and the context of the host. */
3191
+ interface ScheduleOptions extends DurableOptions {
3192
+ /** The context of the host: the names, `self`, `event` and the capabilities. The schedule sets the root `world` to the nodes. */
3193
+ readonly context?: Context;
3194
+ }
3195
+ /** The work of a schedule since its start: the work of its `durable` cache, and the demands ahead of a node. */
3196
+ interface ScheduleCounts extends DurableCounts {
3197
+ /**
3198
+ * The demands that a demand of the host made before its own node (SCHED.LONG-CHAIN). Each node that the eager edges
3199
+ * reach, and that has no value in the data epoch, adds one.
3200
+ */
3201
+ readonly ahead: number;
3202
+ }
3203
+ /** The options of a run of a node. */
3204
+ interface NodeRunOptions {
3205
+ /** The event that starts the run, at the root `event`. The default is the event of the context of the host. */
3206
+ readonly event?: Thing;
3207
+ /** The host code that does each effect, as in `run`. */
3208
+ readonly perform?: Perform;
3209
+ /** A signal that stops the run. */
3210
+ readonly signal?: StopSignal;
3211
+ }
3212
+ /**
3213
+ * The demand schedule of a graph of named nodes (D31). The host tells it each change of a node, of the machine and of
3214
+ * its data. The schedule evaluates a node only when a host or another node reads it.
3215
+ */
3216
+ interface Schedule {
3217
+ /** The epochs of the schedule (DURABLE.EPOCHS). A schedule builds again what depends on the structure when `structure` changes. */
3218
+ readonly epochs: Epochs;
3219
+ /** The work of the schedule since its start: the compilations, the evaluations, the verifications, the reuses and the demands ahead. */
3220
+ readonly counts: ScheduleCounts;
3221
+ /** The context of each node in the current data epoch: the context of the host, with the nodes at the root `world`. */
3222
+ readonly context: Context;
3223
+ /**
3224
+ * This function gives each node with its facts, its side and its edges (SCHED.GRAPH). The map stays the same object
3225
+ * in one structure epoch, thus a schedule can keep what it computes from it, for example an order.
3226
+ *
3227
+ * @returns The nodes, by name.
3228
+ */
3229
+ graph(): ReadonlyMap<string, NodeInfo>;
3230
+ /**
3231
+ * This function gives the value of a node on demand (SCHED.DEMAND). A read of `world` in the document demands that
3232
+ * node first. Each node evaluates at most one time in a data epoch.
3233
+ *
3234
+ * - First, the schedule demands each node that the eager edges reach, deepest first (SCHED.LONG-CHAIN).
3235
+ * - After a change, a pure node verifies its reads, and it keeps its result when each read is the same (SCHED.STALE).
3236
+ * - Each node of a cycle gives `#CYCLE!`, in each order of demands (SCHED.CYCLE).
3237
+ * - A node on the run side gives `#REF!`, because the schedule does not evaluate it (SCHED.SIDE).
3238
+ *
3239
+ * @param id - The name of the node.
3240
+ * @returns The result, or `#N/A` for a node that the schedule does not have.
3241
+ */
3242
+ read(id: string): Result;
3243
+ /**
3244
+ * This function adds a node, or gives a node a new document. It is a change of the structure. Only a new document
3245
+ * object compiles (DURABLE.STRUCTURE).
3246
+ *
3247
+ * @param id - The name of the node.
3248
+ * @param doc - The document of the node. It must not change in place after this call.
3249
+ */
3250
+ set(id: string, doc: unknown): void;
3251
+ /**
3252
+ * This function removes a node. It is a change of the structure, and a read of the node then gives `#N/A`.
3253
+ *
3254
+ * @param id - The name of the node.
3255
+ * @returns `true` when the schedule had the node.
3256
+ */
3257
+ remove(id: string): boolean;
3258
+ /**
3259
+ * This function tells the schedule that the data of the host changed (DURABLE.EPOCHS). The values of a context do
3260
+ * not change in place, thus new data comes in a new context, or through a host thing.
3261
+ *
3262
+ * @param context - The new context of the host, or `undefined` to keep the context.
3263
+ */
3264
+ changeData(context?: Context): void;
3265
+ /**
3266
+ * This function gives the schedule a new machine. It drops each plan, each fact and each result.
3267
+ *
3268
+ * @param machine - The new machine.
3269
+ */
3270
+ changeMachine(machine: Machine): void;
3271
+ /**
3272
+ * This function starts a run of the document of a node, and the host does each effect (SCHED.RUN). Only the host
3273
+ * starts a run, for example at an event. A change of data does not start or repeat a run (L3).
3274
+ *
3275
+ * @param id - The name of the node.
3276
+ * @param options - The event, the host code that does the effects, and a signal to stop the run.
3277
+ * @returns The result, when the run ends.
3278
+ */
3279
+ run(id: string, options?: NodeRunOptions): Promise<Result>;
3280
+ }
3281
+ /**
3282
+ * This function gives the edges of a node from the static facts of its document (SCHED.EDGES). Each read of the root
3283
+ * `world` is an edge to the node of its first key. The keys after that key are the field of the edge (SCHED.GRAIN).
3284
+ * A read of another root reads the data of the host, thus it is not an edge.
3285
+ *
3286
+ * A reference in the value of a node can lead a read to a third node (DEREF.COLLAPSE). The edges do not show such a
3287
+ * read, but the reads of an evaluation do (S1d).
3288
+ *
3289
+ * @param facts - The static facts of the document of the node.
3290
+ * @returns The edges, in the order of the reads.
3291
+ */
3292
+ export declare function edgesOf(facts: DocFacts): readonly NodeEdge[];
3293
+ /**
3294
+ * This function makes the demand schedule of a graph of named nodes (S1, R4, D31). A host gives each node a name and
3295
+ * a document. The root `world` of each node reaches the other nodes by name. The context of the host gives the other
3296
+ * roots.
3297
+ *
3298
+ * - `graph()` gives the facts, the side and the edges of each node, from `factsOf` and `edgesOf`.
3299
+ * - `read(id)` evaluates a node on demand, through `durable`. A pure node verifies its reads after a change, and a
3300
+ * read of a node demands that node again. Thus only a node with a changed read evaluates again: the red-green
3301
+ * algorithm of rustc.
3302
+ * - A node is on a cycle when its demand reaches itself through the reads of the evaluations. Each node of such a
3303
+ * strongly connected component gives `#CYCLE!`, whatever its document does with the error. The schedule finds the
3304
+ * components with the algorithm of Tarjan over the demands. Thus each order of demands gives the same values.
3305
+ * - A demand of the host, or of a run, first demands each node that the eager edges reach, deepest first. Thus each
3306
+ * read of such a node finds a value, and a chain of 100000 nodes does not overflow the stack (SCHED.LONG-CHAIN).
3307
+ * Each such demand starts with no node in evaluation, thus the order of demands keeps the values of D31.
3308
+ * - A node on the run side is a sink. Only `run` evaluates it, and only the host uses `run`.
3309
+ *
3310
+ * The host keeps the promises of `durable`. The documents and the values of a context do not change in place.
3311
+ *
3312
+ * @param machine - The machine of the first structure epoch.
3313
+ * @param options - The options of `durable`, and the context of the host.
3314
+ * @returns The schedule.
3315
+ */
3316
+ export declare function schedule(machine: Machine, options?: ScheduleOptions): Schedule;
3317
+ //#endregion
3318
+ //#region src/graph.d.ts
3319
+ /** One edge of a graph of nodes: a read of a node by another node. `NodeEdge` of a schedule is such an edge. */
3320
+ interface GraphEdge<Id> {
3321
+ /** The node that the read reaches. It is `undefined` when the read can reach each node (GRAPH.UNKNOWN). */
3322
+ readonly to: Id | undefined;
3323
+ /** `true` when only a lazy part reaches the read. An evaluation can then give a value without it (FACTS.LAZY). */
3324
+ readonly lazy: boolean;
3325
+ }
3326
+ /** One node of a graph, with its edges. `NodeInfo` of a schedule is such a node. */
3327
+ interface GraphNode<Id> {
3328
+ /** The edges to the nodes that the node reads. */
3329
+ readonly edges: readonly GraphEdge<Id>[];
3330
+ /** The side of the node. A node on the run side is a sink: no edge reaches it (SCHED.SIDE). The default is `derive`. */
3331
+ readonly side?: Side;
3332
+ }
3333
+ /**
3334
+ * A graph of nodes, by name. The order of the map is the order of the nodes in each answer. The function `graph` of
3335
+ * a schedule gives such a graph. An edge to a name that is not in the map, or to a sink, is not an edge of the
3336
+ * analysis.
3337
+ */
3338
+ type NodeGraph<Id> = ReadonlyMap<Id, GraphNode<Id>>;
3339
+ /** The options of an analysis. */
3340
+ interface GraphOptions {
3341
+ /**
3342
+ * `true`: the analysis keeps only the eager edges with a target node. Such a read occurs in each evaluation in
3343
+ * which each document around it gives a value (FACTS.LAZY). The default keeps each edge.
3344
+ */
3345
+ readonly eager?: boolean;
3346
+ }
3347
+ /** One static cycle of a graph (GRAPH.CYCLE). */
3348
+ interface GraphCycle<Id> {
3349
+ /** The nodes of the cycle, in the order of the graph. */
3350
+ readonly nodes: readonly Id[];
3351
+ /**
3352
+ * `true` when the eager edges with a target close the cycle. `false` when the cycle needs a lazy edge or an edge
3353
+ * without a target. The value of each node still comes from the demand (D31).
3354
+ */
3355
+ readonly certain: boolean;
3356
+ }
3357
+ /**
3358
+ * This function gives the strongly connected components of a graph of nodes (GRAPH.SCC), with the algorithm of
3359
+ * Tarjan. It keeps its own stack, thus a chain of 100000 nodes does not overflow the stack of the host.
3360
+ *
3361
+ * - Each component comes after each component that it reads: the deepest component comes first.
3362
+ * - A node that is on no cycle is a component of one node.
3363
+ * - The nodes of a component are in the order of the graph.
3364
+ *
3365
+ * @param graph - The nodes, each with its edges.
3366
+ * @param options - The option `eager` keeps only the eager edges with a target node.
3367
+ * @returns The components, deepest first.
3368
+ */
3369
+ export declare function components<Id>(graph: NodeGraph<Id>, options?: GraphOptions): readonly (readonly Id[])[];
3370
+ /**
3371
+ * This function gives the height of each node: the order of a push schedule (GRAPH.ORDER). A schedule that evaluates
3372
+ * the nodes from the lowest height up evaluates each node after each node that it reads, except on a cycle.
3373
+ *
3374
+ * - A node that reads no node outside its component has the height 0.
3375
+ * - Each other node is one higher than the highest node that it reads outside its component.
3376
+ * - The nodes of one component have one height.
3377
+ * - An edge without a target reads each node that is not a sink (GRAPH.UNKNOWN).
3378
+ *
3379
+ * @param graph - The nodes, each with its edges.
3380
+ * @param options - The option `eager` keeps only the eager edges with a target node.
3381
+ * @returns The height of each node, in the order of the graph.
3382
+ */
3383
+ export declare function heights<Id>(graph: NodeGraph<Id>, options?: GraphOptions): ReadonlyMap<Id, number>;
3384
+ /**
3385
+ * This function puts the nodes in layers by their heights, in linear time (GRAPH.LAYERS). The first layer has the
3386
+ * height 0. Two nodes of one layer read each other only inside one component. Thus a push schedule can evaluate the
3387
+ * components of one layer at the same time.
3388
+ *
3389
+ * @param graph - The nodes, each with its edges.
3390
+ * @param options - The option `eager` keeps only the eager edges with a target node.
3391
+ * @returns The layers, from the height 0 up. Each layer keeps the order of the graph.
3392
+ */
3393
+ export declare function nodeLayers<Id>(graph: NodeGraph<Id>, options?: GraphOptions): readonly (readonly Id[])[];
3394
+ /**
3395
+ * This function gives the nodes that a set of observed nodes needs (GRAPH.NECESSARY). These are the observed nodes,
3396
+ * and each node with a path of edges from them. A push schedule evaluates only these nodes. An observed name that is
3397
+ * not a node of the graph adds nothing.
3398
+ *
3399
+ * @param graph - The nodes, each with its edges.
3400
+ * @param observed - The nodes that the host shows or reads.
3401
+ * @param options - The option `eager` keeps only the eager edges with a target node.
3402
+ * @returns The necessary nodes, in the order of the graph.
3403
+ */
3404
+ export declare function necessary<Id>(graph: NodeGraph<Id>, observed: Iterable<Id>, options?: GraphOptions): ReadonlySet<Id>;
3405
+ /**
3406
+ * This function gives the static cycles of a graph (GRAPH.CYCLE): each component with two or more nodes, and each
3407
+ * node with an edge to itself. A cycle of the eager edges with a target is certain, and `check` or a host can report
3408
+ * it before a run. Another cycle is possible: an evaluation can skip a lazy read.
3409
+ *
3410
+ * - A component of all the edges that is also a component of the eager edges is one certain cycle.
3411
+ * - Each other component of all the edges is one possible cycle, and each certain cycle in it comes after it.
3412
+ * - A read can still fail before it occurs. Thus the demand of D31, not a static cycle, gives the value of each node.
3413
+ *
3414
+ * @param graph - The nodes, each with its edges.
3415
+ * @returns The cycles, deepest first.
3416
+ */
3417
+ export declare function cycles<Id>(graph: NodeGraph<Id>): readonly GraphCycle<Id>[];
3418
+ //#endregion
3419
+ //#region src/replay.d.ts
3420
+ /** One effect of a log: its address, its request and its outcome. */
3421
+ interface ReplayEntry {
3422
+ /** The address of the effect (RUN.ADDRESS), for example `1#0` or `all0.1/1#0`. */
3423
+ readonly address: string;
3424
+ /** The kind of the effect, as a text with dots. */
3425
+ readonly kind: string;
3426
+ readonly payload: unknown;
3427
+ /** The outcome of the effect (RUN.OUTCOME). It is absent when the recorded run stopped before the answer came. */
3428
+ readonly outcome?: Result;
3429
+ /** `true` when the host made the run wait for the outcome. */
3430
+ readonly waited: boolean;
3431
+ }
3432
+ /** An item of an `all` whose wait settled in the recorded run. */
3433
+ interface ReplaySettle {
3434
+ /** The address of the `all`, for example `all0` or `all0.1/all0`. */
3435
+ readonly all: string;
3436
+ /** The index of the item. */
3437
+ readonly item: number;
3438
+ }
3439
+ /** The log of a run: each effect in the order of the requests, and the order in which the waits of each `all` settled. */
3440
+ interface ReplayLog {
3441
+ readonly effects: readonly ReplayEntry[];
3442
+ readonly settles: readonly ReplaySettle[];
3443
+ }
3444
+ /** A recorder: the function `perform` for a run, and the log of that run (RUN.RECORD). */
3445
+ interface Recorder {
3446
+ /** The function to give the run. It gives each effect to the function `perform` of the host, and it records the effect. */
3447
+ readonly perform: Perform;
3448
+ /**
3449
+ * This function gives the log of the run until this time. An effect gets its outcome when the answer comes.
3450
+ *
3451
+ * @returns The log.
3452
+ */
3453
+ log(): ReplayLog;
3454
+ }
3455
+ /** The options of a replayer. */
3456
+ interface ReplayOptions {
3457
+ /**
3458
+ * `false`: each answer comes at once, also for an effect that waited in the recorded run. An evaluation needs this
3459
+ * value, because it does not wait. The default is `true`: an effect waits when it waited in the recorded run.
3460
+ */
3461
+ readonly wait?: boolean;
3462
+ }
3463
+ /**
3464
+ * This function makes a recorder (RUN.RECORD). The recorder gives each effect to the function `perform` of the host.
3465
+ * Its log keeps each effect with its address, its kind, its payload and the outcome that the kernel gives it. The log
3466
+ * also keeps the order in which the waits of each `all` settle.
3467
+ *
3468
+ * @param perform - The function of the host. Without it, each effect gives its payload, as in a run without a host.
3469
+ * @returns The function `perform` for the run, and the log.
3470
+ */
3471
+ export declare function recorder(perform?: Perform): Recorder;
3472
+ /**
3473
+ * This function makes a replayer: a function `perform` that answers each effect from a log, by its address (RUN.REPLAY). A
3474
+ * recorded error comes again with its code, its reason, its place and its cause. The waits of each `all` settle in the
3475
+ * recorded order. An effect that the log does not have at its address gives `#REPLAY!` (RUN.REPLAY-MISMATCH).
3476
+ *
3477
+ * A replayer keeps its place in the order of the waits, thus each run needs a new replayer.
3478
+ *
3479
+ * @param log - The log of a recorder.
3480
+ * @param options - `wait: false` for an evaluation.
3481
+ * @returns The function `perform` for the replay.
3482
+ */
3483
+ export declare function replayer(log: ReplayLog, options?: ReplayOptions): Perform;
3484
+ //#endregion
2069
3485
  //#region src/generate.d.ts
2070
3486
  /** A source of random numbers with a seed. The same seed gives the same numbers. */
2071
3487
  interface Random {
@@ -2147,5 +3563,53 @@ export declare function typesOf(world: World): readonly (readonly Key[])[];
2147
3563
  */
2148
3564
  export declare function generate(world: World, options: GenerateOptions): unknown;
2149
3565
  //#endregion
2150
- export type { AgreeOptions, Agreement, Alias, AllOptions, Answer, AskOptions, Cap, CapsRule, CheckOptions, Classification, Closure, Code, CompileInput, CompiledEvaluator, CompiledPart, CompiledRunner, Construct, Context, Part as ContextPart, Definitions, DerefCode, DocParts, DocVisit, Edge, Effect, Envelope, ErrorCode, EvalError, EvalFn, EvalInput, EvalOptions, Evaluator, ExtFn, Failed, FormulaProfile, GenerateOptions, Give, Header, Hop, HopBy, HostThing, Issue, Json, JsonRecord, KernelCode, Key, Kind, KindSource, LazyOp, Lookup, Machine, MachinePart, MergeConflict, MergePath, NamesSource, Namespace, Navigator, NearestOptions, OpFn, OrderProblem, Outcome, Part$1 as Part, PartInfo, Shape as PartShape, PartSlot, PartsSpec, Perform, Plan, PrepareOptions, Random, RefUse, ReferenceOptions, Resolution, ResolveCode, ResolveOptions, Result, Root, Run, RunCode, RunFn, RunInput, RunOptions, RunPart, Rung, Runner, Runtime, ScopeRule, Shape$1 as Shape, Side, Split, Step, StepSpec, Steps, StopSignal, Stored, Thing, Tier, TierResult, TraceNode, TypeRef, Use, WalkInput, WalkOptions, WalkProblem, WalkResult, Walker, World, WorldEntry, WorldPart };
3566
+ //#region src/providers.d.ts
3567
+ /** The type that a provider reads, and the problems of the reading. Each problem tells what the type does not test. */
3568
+ interface TypeReading {
3569
+ readonly type: ValueType;
3570
+ readonly issues: readonly TypeIssue[];
3571
+ }
3572
+ /**
3573
+ * This function makes a value type from a JSON Schema (TYPE.SCHEMA). A host uses it for the type of a root, for
3574
+ * example the schema of a store for `world`. It reads this subset:
3575
+ *
3576
+ * - `type`: `null`, `boolean`, `number`, `integer` (as `number`), `string`, `object` and `array`, or a list of them.
3577
+ * - `properties`, `required` and `additionalProperties` give a record. `false` closes it, and a property that is not
3578
+ * in `required` is optional.
3579
+ * - `items` gives a list. `enum` and `const` give `one`. `anyOf` and `oneOf` give a union.
3580
+ *
3581
+ * The type holds each value that the schema accepts. Each keyword that the function does not read tests nothing, as
3582
+ * `unknown`, and the issues name it. Examples are `minimum`, `pattern` and `allOf`. A schema with `$ref` or `nullable`
3583
+ * reads as `unknown`, because these keywords can permit more values. A schema with more than one of `type`, `anyOf`
3584
+ * and `oneOf` gives the type of the first, and an issue for each other. The function does not throw.
3585
+ *
3586
+ * @param schema - The schema, as JSON.
3587
+ * @returns The type, and the problems of the reading with their keys in the schema.
3588
+ */
3589
+ export declare function typeFromSchema(schema: unknown): TypeReading;
3590
+ /** The options of `typeFromSamples`. */
3591
+ interface SampleOptions {
3592
+ /** `true`: the samples show each field, thus each record type is closed. The default is `false`. */
3593
+ readonly closed?: boolean;
3594
+ }
3595
+ /**
3596
+ * This function infers a value type from sample values (TYPE.SAMPLES), as a type provider of F# does. A host uses it
3597
+ * for the type of a root, for example from some events.
3598
+ *
3599
+ * - `null`, a truth value, a number and a text give their base types, not their values.
3600
+ * - The items of each list join into one type of items.
3601
+ * - All records join into one record with each key of the samples. A key that a record does not have is optional.
3602
+ * - Values of different forms give a union, as `join` gives. No samples give `never`.
3603
+ * - A value without a type of the kernel, for example a function, gives `unknown`.
3604
+ *
3605
+ * Each sample is a member of the type. A record is open, because samples do not show that a field cannot exist. With
3606
+ * `closed: true`, each record is closed, and a reference to a field that no sample has gives `#TYPE!`.
3607
+ *
3608
+ * @param values - The sample values.
3609
+ * @param options - `closed: true` closes each record type.
3610
+ * @returns The type.
3611
+ */
3612
+ export declare function typeFromSamples(values: readonly unknown[], options?: SampleOptions): ValueType;
3613
+ //#endregion
3614
+ export type { AgreeOptions, Agreement, Alias, AllOptions, Answer, AskOptions, Cap, CapsRule, CheckOptions, Classification, Closure, Code, CompileInput, CompiledEvaluator, CompiledPart, CompiledRunner, ConformOptions, ConformProbe, Construct, Context, Part as ContextPart, Definitions, DerefCode, DocFacts, DocParts, DocVisit, Domain, DomainExtension, Durable, DurableCounts, DurableOptions, Edge, Effect, EffectsOptions, Envelope, Epochs, ErrorCode, EvalError, EvalFn, EvalInput, EvalOptions, EvaluateOptions, Evaluator, ExtFn, FactsOptions, Failed, Finding, FormulaProfile, GenerateOptions, Give, GraphCycle, GraphEdge, GraphNode, GraphOptions, Header, Hop, HopBy, HostThing, Issue, Journal, Json, JsonRecord, KernelCode, Key, Kind, KindFacts, KindSource, LazyOp, LazyRule, Lookup, Machine, MachinePart, MergeConflict, MergePath, NamesSource, Namespace, Navigator, NearestOptions, NodeEdge, NodeGraph, NodeInfo, NodeRunOptions, Obligation, OpFn, OrderProblem, Outcome, Part$1 as Part, PartInfo, Shape as PartShape, PartSlot, PartType, PartsSpec, Perform, Plan, PrepareOptions, Random, Read, ReadsCheck, Recorder, RefUse, ReferenceOptions, ReplayEntry, ReplayLog, ReplayOptions, ReplaySettle, Resolution, ResolveCode, ResolveOptions, Result, Root, RootTypes, Run, RunCode, RunFn, RunInput, RunOptions, RunPart, Rung, Runner, Runtime, SampleOptions, Schedule, ScheduleCounts, ScheduleOptions, ScopeRule, Shape$1 as Shape, Side, Signature, Split, StaticRead, Step, StepSpec, Steps, StopSignal, Stored, Thing, Tier, TierInput, TierResult, TraceNode, TypeInput, TypeIssue, TypeProblem, TypeReading, TypeRef, TypeRule, Typed, Typing, Use, ValueType, VerifyOptions, WalkInput, WalkOptions, WalkProblem, WalkResult, Walker, World, WorldEntry, WorldPart };
2151
3615
  //# sourceMappingURL=index.d.ts.map