Reintent

@reintent/core/internal

For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.

Kernel

BoundaryProps

type BoundaryProps = object;

Defined in: packages/core/src/kernel/jsx.ts

A boundary: its children are expanded, and what they throw is handed to onThrow, whose result is expanded in their place (it may throw again, to the next boundary out). React's error boundary, for the kernel; the layer above builds <Reconsider> on it.

Properties

PropertyType
children?Child
onThrow(thrown) => Child

Pick

type Pick = object;

Defined in: packages/core/src/kernel/scope.ts

Properties

PropertyType
isEqual(a, b) => boolean
select(v) => unknown
valueunknown

Result

type Result<T> = object;

Defined in: packages/core/src/kernel/render.ts

Type Parameters

Type ParameterDefault type
Tany

Properties

PropertyType
traceT[]
tree| Rendered | Rendered[] | null

Run

type Run = object;

Defined in: packages/core/src/kernel/scope.ts

Properties

PropertyTypeDescription
calls?Set<string>The useCompute keys taken in the component being called.
compute?(key, fn, props) => unknownWhile a renderer skips calls: how a useCompute in the component being called is made.
picksPick[]-
reads?Set<IntentContext<any>> | "all"The contexts the component being called read, while a renderer records them; all: the scope.
scopeScope | null-

Scope

type Scope = ReadonlyMap<IntentContext<any>, unknown>;

Defined in: packages/core/src/kernel/scope.ts


Boundary

const Boundary: Component<BoundaryProps>;

Defined in: packages/core/src/kernel/jsx.ts


Inputs

const Inputs: IntentContext<unknown>;

Defined in: packages/core/src/kernel/scope.ts

The inputs a run was handed. Its shape is the layer above's (the choices' layers).


Provided

const Provided: IntentContext<ReadonlySet<IntentContext<any>>>;

Defined in: packages/core/src/kernel/scope.ts

The contexts the evaluation was handed at its root (provide): those that name its reads. A context only a Provider in the tree adds is part of the program, and names nothing unless it names reads anywhere (0047 §3).


Trace

const Trace: IntentContext<{
  report: void;
}>;

Defined in: packages/core/src/kernel/scope.ts

This run's trace: useContext(Trace).report(item).


asElement()

function asElement(x): IntentElement | undefined;

Defined in: packages/core/src/kernel/jsx.ts

An element of the kernel's, or another runtime's read as one; undefined for anything else. Its key is the kernel's (keyFor): an entity's component takes its id as its key in React's JSX too.

Parameters

ParameterType
xunknown

Returns

IntentElement | undefined


contextOfProvider()

function contextOfProvider(t): IntentContext<unknown> | undefined;

Defined in: packages/core/src/kernel/context.ts

For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.

Parameters

ParameterType
tunknown

Returns

IntentContext<unknown> | undefined


createRenderer()

function createRenderer<T>(
   tree, 
   once?, 
   calls?
): object;

Defined in: packages/core/src/kernel/render.ts

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterTypeDefault value
treeChildundefined
onceRealizerrenderOnce
callsCalls...

Returns

NameTypeDefault valueDescription
statsobject-Renders run and renders handed back unchanged; component calls made and calls skipped.
stats.callsnumber0-
stats.rendersnumber0-
stats.reusednumber0-
stats.skippednumber0-
treeChild--
render()(inputs, opts?) => Result<T>--

hostKindOf()

function hostKindOf(t): string | undefined;

Defined in: packages/core/src/kernel/jsx.ts

For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.

Parameters

ParameterType
tunknown

Returns

string | undefined


inScope()

function inScope<T>(
   r, 
   scope, 
   fn
): T;

Defined in: packages/core/src/kernel/scope.ts

Run fn as a component of r, with scope in scope.

Type Parameters

Type Parameter
T

Parameters

ParameterType
rRun
scopeScope
fn() => T

Returns

T


isBoundary()

function isBoundary(t): boolean;

Defined in: packages/core/src/kernel/jsx.ts

For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.

Parameters

ParameterType
tunknown

Returns

boolean


isElement()

function isElement(x): x is IntentElement;

Defined in: packages/core/src/kernel/jsx.ts

For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.

Parameters

ParameterType
xunknown

Returns

x is IntentElement


renderOnce()

function renderOnce<T>(
   tree, 
   inputs, 
   provide?
): object;

Defined in: packages/core/src/kernel/render.ts

One render, nothing skipped: the result and what it picked.

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterTypeDefault value
treeChildundefined
inputsunknownundefined
provideProvide[]

Returns

object

NameType
picksPick[]
resultResult<T>

useContexts()

function useContexts(): Scope;

Defined in: packages/core/src/kernel/scope.ts

Every context value in scope: for a layer built on the kernel.

Returns

Scope

Choices

Belief

type Belief = object;

Defined in: packages/core/src/choices/layers.ts

System One's answer under one stamp: its weights, and how decisive it was, when it says (0116 §4).

Properties

PropertyModifierType
answerreadonlyWeights
confidence?readonlynumber
stampreadonlystring

CascadeInput

type CascadeInput<T> = object;

Defined in: packages/core/src/choices/cascade.ts

Type Parameters

Type Parameter
T

Properties

PropertyTypeDescription
accepts?(value) => booleanAn open generated space accepts a person's value beyond its current support.
axis(spec) => number | undefined-
defaultValue?T-
generated?booleanThe possibilities are System Two's candidates (generate): their source is 'generated'.
informedbooleanWhether the prior says anything (false: equal weights by default).
instead?booleanA judgment asks what instead of defaultValue: where a person left it and it was measured to fit, none weighs.
named?NameRecord-
open?booleanWhether there is anything to choose here; closed, only a preview or a decision overrides the default.
policyPolicy-
possibilitiesChoices<T>The possibilities and code's prior over them.
preview?objectA preview's hypothesis for this choice, if any.
preview.valueDecided-
record?ChoiceRecord-
stamp?stringThe input stamp a belief must have been given under; undefined: nobody judges this one.
unloaded?boolean-
where?stringThe context this read is in (whereOf its ctx): which of the host's measurements hold here.
written?TThe program's own word in this context (0118): the prior here, in place of code's and Code's taste.

ChoiceRecord

type ChoiceRecord = object;

Defined in: packages/core/src/choices/layers.ts

Properties

PropertyModifierTypeDescription
beliefs?readonlyreadonly Belief[]What System One answered, by the input stamp it answered under; newest first.
constraints?readonlyreadonly Constraint[]-
decision?readonlyobject & DecisionOriginA person's decision; wrapped, since undefined may be a value.
drawn?readonlyreadonly Drawn[]What a sampling <World sample> drew for this choice (0089 §3), oldest first: each draw's seed and the value it took, taken when the draw was committed. fresh: the draw began a new round (without replacement, every value had been drawn). A commit, in the history.
measured?readonlyReadonly<Record<string, Measured>>What the host measured, by the context it measured in (whereOf the read's ctx): Code's, reduced to constraints and weights for that context only; a cache, not history.
preferences?readonlyreadonly Preference[]-

Declarations

type Declarations = object;

Defined in: packages/core/src/choices/declare.ts

Several entities' declarations, by entity name: what a reprogramming patches.

Index Signature

[entity: string]: Fields

Drawn

type Drawn = object;

Defined in: packages/core/src/choices/layers.ts

One draw of a choice in a sampling World: its seed, and the value it took.

Properties

PropertyModifierType
fresh?readonlytrue
seedreadonlynumber
valuereadonlyDecided

GeneratedRecord

type GeneratedRecord = object;

Defined in: packages/core/src/choices/layers.ts

Properties

PropertyModifierType
stampreadonlystring
valuereadonlyunknown

NameRecord

type NameRecord = object;

Defined in: packages/core/src/choices/layers.ts

Properties

PropertyModifierType
constraints?readonlyreadonly Constraint[]
preferences?readonlyreadonly Preference[]

Outcome

type Outcome<T> = object;

Defined in: packages/core/src/choices/cascade.ts

Type Parameters

Type Parameter
T

Properties

PropertyTypeDescription
beyond?numberβ (0115 §4): the share of System One's answer outside K (BEYOND), of what it gave to that and to what a person left. With cause: 'judged', it was K's likeliest or near it (0115 §4.4): the value is K's all the same, and the choice is unmet, for System Two.
cause?"measured" | "judged"Why none fits, when it is what the host measured (0065 §7); for an unmet no person said, System One judged none of K is what was asked for ('judged', 0115).
confidence?numberHow decisive the belief it rests on was, when System One said (0116 §4).
dist?WeightsThe effective distribution, when it said anything.
draw?WeightsIn a sampling World: what a draw would draw from, every possibility it may take, weighed (0089).
measured?trueWhat the host measured in this context ruled a possibility out or weighed one.
named?trueThe constraint that settled it was on the choice's name.
none?trueEvery possibility is ruled out: none fits.
sourceSource-
stale?trueThe belief was given under another stamp.
statusStatus-
unfit?trueWhat the host measured here rules out every possibility a person left: the measurement is set aside, the value is the one that measured best, and the choice is unresolved with none that fits (none, cause: 'measured'), for a <World onUnresolved> to handle (0065 §7).
unmet?unknownWhat a person said that K does not hold: its tag is one of the possibilities, its data is not that possibility's. The person's intent is not met; the choice escalates ('unmet').
valueT | undefined-
waiting?unknown[]Values that do not apply because they are not one of the possibilities.
wantsbooleanWhether System One's answer for the current stamp is still wanted.

PatchOp

type PatchOp = 
  | {
  op: "add" | "replace" | "test";
  path: string;
  value: Json;
}
  | {
  op: "remove";
  path: string;
};

Defined in: packages/core/src/choices/declare.ts

One operation of a JSON Patch (RFC 6902): those a reprogramming of K needs.


Policy

type Policy = object;

Defined in: packages/core/src/choices/cascade.ts

Properties

PropertyModifierTypeDescription
minBeyond?readonlynumberβ below K's likeliest that still goes to System Two (0115 §4.4, §10): from this much, a β the likeliest does not lead by minMargin is unmet. Unset: MIN_BEYOND.
minMarginreadonlynumber-
otherwisereadonlyOtherwise-
sample?readonlyobjectA sampling <World id sample> in scope (0089): whose draws to read, and with replacement or not.
sample.replacereadonlyboolean-
sample.worldreadonlystring-

Possibility

type Possibility<T> = object;

Defined in: packages/core/src/choices/choices.ts

Choices as data (principles, 「选择 C」; 0006 Level 0): a finite distribution over the possibilities K, as a list of { value, weight }. A possibility is compared by its tag: a string is its own tag, a tagged value { kind: 'grid', … } has kind as its tag, anything else its JSON. Weights sum to one; state(x) is the degenerate one, δ_x.

New, after 0006; tags, margin and argmax from Huxpro/airtalk#857 (core/intent/value.ts).

Type Parameters

Type Parameter
T

Properties

PropertyModifierType
valuereadonlyT
weightreadonlynumber

RefInfo

type RefInfo = object;

Defined in: packages/core/src/choices/declare.ts

What a handle knows besides its identity: kept in the process, never serialized.

Properties

PropertyModifierType
entityreadonlyobject
entity.declreadonlyFields
entity.namereadonlystring
fieldreadonlystring

TagOf

type TagOf<D> = D extends object ? Str<K> : D extends object ? Str<keyof R> : never;

Defined in: packages/core/src/choices/declare.ts

A possibility's tag in a declaration.

Type Parameters

Type Parameter
D

DEFAULT_POLICY

const DEFAULT_POLICY: Policy;

Defined in: packages/core/src/choices/cascade.ts

Both codebases' TAU.


EMPTY

const EMPTY: Layers;

Defined in: packages/core/src/choices/layers.ts


at()

function at<T>(v, axis): T | undefined;

Defined in: packages/core/src/choices/layers.ts

A piecewise value read at a point; a constant is itself everywhere.

Type Parameters

Type Parameter
T

Parameters

ParameterType
vDecided<T> | undefined
axis(name) => number | undefined

Returns

T | undefined


best()

function best<T>(c): T | undefined;

Defined in: packages/core/src/choices/choices.ts

The likeliest possibility; a tie goes to the one listed first.

Type Parameters

Type Parameter
T

Parameters

ParameterType
cChoices<T>

Returns

T | undefined

Example

import { choices } from '@reintent/core';
import { best } from '@reintent/core/internal';

console.log(
  best(
    choices([
      { value: 'grid', weight: 0.6 },
      { value: 'list', weight: 0.4 },
    ]),
  ),
); // → 'grid'
console.log(best(choices('formal', 'warm'))); // → 'formal'

canonical()

function canonical(v): string;

Defined in: packages/core/src/choices/layers.ts

A canonical JSON (keys sorted): what input stamps are made of.

Parameters

ParameterType
vunknown

Returns

string


cascade()

function cascade<T>(i): Outcome<T>;

Defined in: packages/core/src/choices/cascade.ts

Type Parameters

Type Parameter
T

Parameters

ParameterType
iCascadeInput<T>

Returns

Outcome<T>


checkEntity()

function checkEntity(name, fields): string[];

Defined in: packages/core/src/choices/declare.ts

The errors in an entity's declaration (0015 §3.2), empty when it holds: its shape, K, the prior, the default, what given and the conditions name, and cycles. What entity throws, as a list.

Parameters

ParameterType
namestring
fieldsunknown

Returns

string[]

Example

import { checkEntity } from '@reintent/core/internal';

const [typo, cycle] = checkEntity('bear', {
  style: { kinds: ['toy', 'pixel'], given: ['pocket'] },
  pocket: {
    kinds: ['none', 'seam'],
    forbid: [{ when: { style: ['pixl'] }, kinds: ['seam'] }],
  },
});
console.log(typo); // → "pocket: forbid[0] names style 'pixl', which is not one of its kinds"
console.log(cycle); // → 'a cycle: style → pocket → style'

declarations()

function declarations(...entities): Declarations;

Defined in: packages/core/src/choices/declare.ts

Entities' declarations by name: what patch reprograms.

Parameters

ParameterType
...entitiesreadonly object[]

Returns

Declarations


familyOf()

function familyOf(entity, field): ChoiceFamily;

Defined in: packages/core/src/choices/declare.ts

A family of field: a handle for any of, the singleton's when none is given.

Parameters

ParameterType
entity{ decl: Fields; name: string; }
entity.declFields
entity.namestring
fieldstring

Returns

ChoiceFamily


flatMap()

function flatMap<A, B>(c, f): Choices<B>;

Defined in: packages/core/src/choices/choices.ts

One choice depending on another's outcome: the monad's bind.

Type Parameters

Type Parameter
A
B

Parameters

ParameterType
cChoices<A>
f(a) => Choices<B>

Returns

Choices<B>

Example

import { choices } from '@reintent/core';
import { flatMap } from '@reintent/core/internal';

// How many columns depends on the layout: the joint distribution over the outcome.
const layout = choices([
  { value: 'grid', weight: 0.6 },
  { value: 'list', weight: 0.4 },
]);
const columns = flatMap(layout, (l) =>
  l === 'grid'
    ? choices([
        { value: 3, weight: 0.5 },
        { value: 2, weight: 0.5 },
      ])
    : choices([1]),
);
console.log(columns);
// → [ { value: 3, weight: 0.3 }, { value: 2, weight: 0.3 }, { value: 1, weight: 0.4 } ]

givenOf()

function givenOf(d): string[];

Defined in: packages/core/src/choices/declare.ts

What a declared choice depends on: given, then the fields its conditions name; each once.

Parameters

ParameterType
dChoiceDecl

Returns

string[]


holds()

function holds(c, tags): boolean;

Defined in: packages/core/src/choices/declare.ts

Whether a condition holds for these tags (a field not read has none).

Parameters

ParameterType
cCondition
tagsReadonly<Record<string, string | undefined>>

Returns

boolean


isFixed()

function isFixed(f): f is FixedDecl;

Defined in: packages/core/src/choices/declare.ts

Whether a field is a part that is not a choice.

Parameters

ParameterType
fFieldDecl

Returns

f is FixedDecl


isInformed()

function isInformed(c): boolean;

Defined in: packages/core/src/choices/choices.ts

Whether the weights say anything: false for the equal-weights shorthand, which is no prior.

Parameters

ParameterType
cChoices<unknown>

Returns

boolean


isState()

function isState(c): boolean;

Defined in: packages/core/src/choices/choices.ts

Whether these choices are a determined state.

Parameters

ParameterType
cChoices<unknown>

Returns

boolean


margin()

function margin(c): number;

Defined in: packages/core/src/choices/choices.ts

Best minus second best (1 when there is only one).

Parameters

ParameterType
c| Weights | Choices<unknown>

Returns

number

Example

import { choices } from '@reintent/core';
import { margin } from '@reintent/core/internal';

const c = choices([
  { value: 'grid', weight: 0.5 },
  { value: 'list', weight: 0.3 },
  { value: 'carousel', weight: 0.2 },
]);
console.log(margin(c)); // → 0.2
// The default policy takes the likeliest only at a margin of 0.2 or more (`<Resolve>`).

normalize()

function normalize<T>(c): Choices<T> | undefined;

Defined in: packages/core/src/choices/choices.ts

Normalised to sum to one; undefined when nothing is left.

Type Parameters

Type Parameter
T

Parameters

ParameterType
cChoices<T>

Returns

Choices<T> | undefined


patch()

function patch(decls, ops): 
  | {
  decls: Declarations;
  ok: true;
}
  | {
  errors: string[];
  ok: false;
};

Defined in: packages/core/src/choices/declare.ts

A reprogramming of declarations as a JSON Patch (0015 §3.3): the new declarations, or why not. The result is checked as entity checks it, and a patch may not touch what is fixed. Nothing is changed in place: the old declarations are the old version's.

Parameters

ParameterType
declsDeclarations
opsreadonly PatchOp[]

Returns

| { decls: Declarations; ok: true; } | { errors: string[]; ok: false; }

Example

import { entity } from '@reintent/core';
import { declarations, patch } from '@reintent/core/internal';

const Man = entity('man', {
  hat: { kinds: { usual: { hatScale: 1 }, big: { hatScale: 1.45 } }, default: 'big' },
  outline: { fixed: 'a man in a bowler hat' },
});

// "The hat, bigger still": one possibility more.
const bigger = patch(declarations(Man), [
  { op: 'add', path: '/man/hat/kinds/absurd', value: { hatScale: 1.95 } },
]);
console.log(bigger.ok && JSON.stringify(bigger.decls.man.hat));
// → '{"kinds":{"usual":{"hatScale":1},"big":{"hatScale":1.45},"absurd":{"hatScale":1.95}},"default":"big"}'

// What is fixed is not a reprogramming's.
const touched = patch(declarations(Man), [
  { op: 'replace', path: '/man/outline/fixed', value: 'a man in a top hat' },
]);
console.log(touched.ok || touched.errors); // → [ 'man/outline is fixed: a patch may not touch it' ]

possibilitiesOf()

function possibilitiesOf(d, given): object;

Defined in: packages/core/src/choices/declare.ts

K for a declared choice given what it depends on: its kinds less what forbid rules out, over the prior renormalised (or equal weights, saying nothing); and its default in this K.

Parameters

ParameterType
dChoiceDecl
givenReadonly<Record<string, string | undefined>>

Returns

object

NameType
defaultValueunknown
KChoices<unknown>

refInfo()

function refInfo(x): RefInfo | undefined;

Defined in: packages/core/src/choices/declare.ts

The handle's or the family's entity and field, if it is one.

Parameters

ParameterType
xunknown

Returns

RefInfo | undefined


refOf()

function refOf(
   entity, 
   field, 
   of
): ChoiceRef;

Defined in: packages/core/src/choices/declare.ts

A handle on of's choice field of an entity.

Parameters

ParameterType
entity{ decl: Fields; name: string; }
entity.declFields
entity.namestring
fieldstring
ofstring

Returns

ChoiceRef


reweigh()

function reweigh<T>(c, w): Choices<T>;

Defined in: packages/core/src/choices/choices.ts

The possibilities of c weighted by w (by tag); tags w does not name weigh nothing.

Type Parameters

Type Parameter
T

Parameters

ParameterType
cChoices<T>
wWeights

Returns

Choices<T>


sameTag()

function sameTag(a, b): boolean;

Defined in: packages/core/src/choices/choices.ts

Whether two possibilities are the same one (by tag).

Parameters

ParameterType
aunknown
bunknown

Returns

boolean


sameUses()

function sameUses(a, b): boolean;

Defined in: packages/core/src/choices/layers.ts

Whether two input stamps ({ uses, facts }) were given the same inputs, whatever the facts.

Parameters

ParameterType
astring
bstring

Returns

boolean


tagsOf()

function tagsOf(d): string[];

Defined in: packages/core/src/choices/declare.ts

A declared choice's tags, its open tail's last.

Parameters

ParameterType
dChoiceDecl

Returns

string[]


tailOf()

function tailOf(d): string | undefined;

Defined in: packages/core/src/choices/declare.ts

The open tail's tag, if it has one.

Parameters

ParameterType
dChoiceDecl

Returns

string | undefined


weightsOf()

function weightsOf(c): Weights;

Defined in: packages/core/src/choices/choices.ts

Parameters

ParameterType
cChoices<unknown>

Returns

Weights


whereOf()

function whereOf(ctx): string;

Defined in: packages/core/src/choices/layers.ts

The context a read was read in (its ctx), as the key its measurements are kept under.

Parameters

ParameterType
ctxReadonly<Record<string, string>>

Returns

string

Intent

Escalation

Defined in: packages/core/src/intent/hooks.ts

Thrown by useChoose when its choice cannot settle and a <World> (or <Reconsider>) around it is to handle it; what nothing catches reaches the root's boundary, which reports it.

Extends

  • Error

Constructors

Constructor
new Escalation(
   id, 
   reason, 
   dist?, 
   tried?, 
   wanted?, 
   can?, 
   beyond?
): Escalation;

Defined in: packages/core/src/intent/hooks.ts

Parameters
ParameterTypeDefault valueDescription
idIdundefined-
reasonReasonundefined-
dist?Record<string, number>undefined-
tried?readonly Action[][]What the boundaries it passed through tried (0004 §4).
wanted?unknownundefinedFor 'unmet': what the person said, which K does not hold.
can?CanANYWhich steps apply to it: rejudging a judged choice, regenerating a generated one.
beyond?numberundefinedFor an 'unmet' System One judged (cause: 'judged'): its share outside K (BEYOND, 0115).
Returns

Escalation

Overrides
Error.constructor

Properties

PropertyModifierTypeDefault valueDescription
beyond?readonlynumberundefinedFor an 'unmet' System One judged (cause: 'judged'): its share outside K (BEYOND, 0115).
canreadonlyCanANYWhich steps apply to it: rejudging a judged choice, regenerating a generated one.
dist?readonlyRecord<string, number>undefined-
idreadonlyIdundefined-
reasonreadonlyReasonundefined-
triedreadonlyreadonly Action[][]What the boundaries it passed through tried (0004 §4).
wanted?readonlyunknownundefinedFor 'unmet': what the person said, which K does not hold.

Action

type Action = "rejudge" | "regenerate" | "ask" | "reprogram";

Defined in: packages/core/src/intent/trace.ts


ChooseOptions

type ChooseOptions<T> = Id & object;

Defined in: packages/core/src/intent/hooks.ts

Type Declaration

NameTypeDescription
about?unknownAnything the component says about the choice, passed through to the read.
ask?readonly Ask[]Who answers the choice, in order (0033 §2). 'model' with a question: System One weighs the possibilities. 'human': while it cannot settle, it is listed in intent.questions(), after the model has answered when both are asked. Who prevails is the layers' business: a person's decision is on top whatever the order.
askWhenTold?booleanWith ask having 'model': the prior already answers the question while nobody has told the intent anything, so System One is asked only once a person has (intent.tell, 0114). Until then the prior's weights stand, read as Code's: a program System Two wrote from one sentence weighs its possibilities as it writes them, and needs no second call to start. A literal: it must not change from one evaluation to the next.
defaultValue?NoInfer<T>This choice's own fallback: used while unresolved, by the policy in scope.
describe?Readonly<Record<string, string>>What each possibility means, by its tag (0116 §3): what System One is shown beside the tag, part of the input stamp. A possibility it leaves out is shown by its tag alone.
instead?booleanThe question asks what to take instead of defaultValue where it cannot stay: in a context where a person left defaultValue and the host measured it to fit, System One is not asked, and what it answered does not weigh; what was measured there settles it (0065 §6). Where a person ruled it out, or nothing was measured, the judgment weighs as without it.
open?booleanWhether there is anything to choose here (default true). Closed, the possibilities stay what they are, and only a preview or a decision overrides defaultValue (airtalk's open: false).
otherwise?OtherwiseA local override of the policy's otherwise. Inside a preview, nothing is asked or escalated. Deprecated Say who answers with ask, and what to do when it cannot settle with an enclosing <World onUnresolved> (0046 §6).
priorAlong?Piecewise<NoInfer<T>>The program's own word along an axis (0118): on each stretch, the possibility it gives there (a screen shape's class prefix, tall:flex-col). Where the context reads a point in one, that is the prior here, in place of code's prior and Code's taste; a judgment replaces it, a measurement may rule it out, and a person's decision is above it. A literal of the program.
question?stringThe question this choice answers: the prompt System One is given when ask has 'model', and what a person is shown when ask has 'human'.
shape?ShapeThe shape of the possibilities (0116 §2): levels in order, or whether a proposition holds. System One is told it, and it is part of the input stamp.
stays?objectWith instead: the question asked where the default can stay (a person left it and the host measured it to fit), in place of not asking. Its own question, so its own input stamp (uses adds { stays: true }): the answer to what to take instead never weighs there, and this one weighs only there. It replaces Code's taste in that context as any judgment does (0065 §6, §9).
stays.minMargin?numberHow sure its answer must be to settle the choice there (the policy's minMargin, raised to this): it asks whether another is clearly better than what fits, so an answer short of it is weighed with Code's taste, not in its place (0065 §6).
stays.questionstring-
stays.uses?Record<string, unknown>-
uses?Record<string, unknown>What System One reads besides the question, part of its input stamp (as judge's uses).

Type Parameters

Type Parameter
T

Effect

type Effect = "judge" | "generate";

Defined in: packages/core/src/intent/trace.ts


Escalated

type Escalated = Unresolved;

Defined in: packages/core/src/intent/trace.ts

Deprecated

Renamed Unresolved (0046 §5).


Generated

type Generated<V> = object;

Defined in: packages/core/src/intent/hooks.ts

Type Parameters

Type Parameter
V

Properties

PropertyType
status"ready" | "pending"
valueV | undefined

Hypotheses

type Hypotheses = Readonly<Record<string, {
  value: Decided;
}>>;

Defined in: packages/core/src/intent/scope.ts


Judged

type Judged<T> = object;

Defined in: packages/core/src/intent/hooks.ts

Type Parameters

Type Parameter
T

Properties

PropertyModifierType
$judgereadonlytrue
choicesreadonly| Choices<T> | Generation<T>
describe?readonlyReadonly<Record<string, string>>
questionreadonlystring
shape?readonlyShape
uses?readonlyRecord<string, unknown>

SwitchProps

type SwitchProps<T> = BranchProps<T>;

Defined in: packages/core/src/intent/handlers.ts

Type Parameters

Type Parameter
T extends Tagged

Deprecated

Renamed BranchProps (0046 §6).


TraceItem

type TraceItem = 
  | ChoiceRead
  | ModelRequest
  | Unresolved
  | {
  type: string;
};

Defined in: packages/core/src/intent/trace.ts


escalationsOf

const escalationsOf: (trace) => Unresolved[] = unresolvedOf;

Defined in: packages/core/src/intent/trace.ts

Parameters

ParameterType
tracereadonly unknown[]

Returns

Unresolved[]

Deprecated

Renamed unresolvedOf (0046 §5).


InputContext

const InputContext: IntentContext<unknown>;

Defined in: packages/core/src/intent/input.ts

The root input in scope; its key is the input itself, canonical.


PolicyContext

const PolicyContext: IntentContext<Policy>;

Defined in: packages/core/src/intent/scope.ts


PreviewContext

const PreviewContext: IntentContext<Readonly<Record<string, {
  value: unknown;
}>>>;

Defined in: packages/core/src/intent/scope.ts


QuietContext

const QuietContext: IntentContext<boolean>;

Defined in: packages/core/src/intent/scope.ts

Under a <Reconsider> handling an escalation: choices fall back instead of escalating again.


ctxOf()

function ctxOf(scope): Record<string, string>;

Defined in: packages/core/src/intent/hooks.ts

The contexts in scope that name something, by name: those the evaluation was handed (provide), with the value in scope here (a Provider in the tree may give it another), and those that name reads anywhere (names: 'anywhere'). Another context only the program provides names nothing.

Parameters

ParameterType
scopeReadonlyMap<IntentContext<any>, unknown>

Returns

Record<string, string>


escalated()

function escalated(
   e, 
   allow, 
   goal?, 
   boundary?, 
   step?
): Unresolved;

Defined in: packages/core/src/intent/handlers.ts

Parameters

ParameterType
eEscalation
allowreadonly Action[]
goal?string
boundary?string
step?ReprogramOptions

Returns

Unresolved


isJudged()

function isJudged(x): x is Judged<unknown>;

Defined in: packages/core/src/intent/hooks.ts

Parameters

ParameterType
xunknown

Returns

x is Judged<unknown>


readsOf()

function readsOf(trace): ChoiceRead[];

Defined in: packages/core/src/intent/trace.ts

Parameters

ParameterType
tracereadonly unknown[]

Returns

ChoiceRead[]


requestsOf()

function requestsOf(trace): ModelRequest[];

Defined in: packages/core/src/intent/trace.ts

Parameters

ParameterType
tracereadonly unknown[]

Returns

ModelRequest[]


RootBoundary()

function RootBoundary(p): IntentElement;

Defined in: packages/core/src/intent/handlers.ts

The root's boundary: what no <Reconsider> caught is reported with nothing allowed.

Parameters

ParameterType
p{ children?: Child; }
p.children?Child

Returns

IntentElement


stampOf()

function stampOf(r): string;

Defined in: packages/core/src/intent/hooks.ts

An input stamp: exactly what the handler is given, canonical. An answer holds while these are the same; when any of them changes (the question, the possibilities, what it reads, what was said of the whole), it is for another case, and is asked again. Nothing the handler is not given is in it, and everything it is given is.

judge { prompt: the question, kinds: the possibilities' tags, shape, describe, uses, facts, input } generate { prompt: the instruction, n (when greater than 1), uses, facts, input }

input is the root's input (0045 §3), when the intent has one: an answer asked under one input is not taken for another.

The stamp is the full canonical content, never a hash of it: two stamps are the same only when what they hold is. Neither handler is given the program, nor its name: a reprogramming that leaves a choice's question, possibilities and inputs as they were leaves its answer standing, and one that changes any of them asks that choice again, and no other (0047 §4). A judge that should read part of the program is handed it in uses, and then that part is in the stamp.

Parameters

ParameterType
r{ describe?: Readonly<Record<string, string>>; facts: readonly string[]; input?: unknown; kinds?: readonly string[]; n?: number; prompt: string; shape?: Shape; uses?: Record<string, unknown>; }
r.describe?Readonly<Record<string, string>>
r.factsreadonly string[]
r.input?unknown
r.kinds?readonly string[]
r.n?number
r.promptstring
r.shape?Shape
r.uses?Record<string, unknown>

Returns

string


unresolvedOf()

function unresolvedOf(trace): Unresolved[];

Defined in: packages/core/src/intent/trace.ts

Parameters

ParameterType
tracereadonly unknown[]

Returns

Unresolved[]

Other

Commit

Re-exports Commit


Fragment

Re-exports Fragment


isHostNode

Re-exports isHostNode


Reason

Re-exports Reason


Unresolved

Re-exports Unresolved

Runtime

IntentAdapter

type IntentAdapter = IntentStore & object;

Defined in: packages/core/src/runtime/root.ts

Integration-only access. Public hosts use realize/connect.

Type Declaration

NameTypeDescription
at()() => numberHow many times the intent has changed: a commit, an answer, an input, a boundary out of steps. It only grows, and it has grown before a subscriber is called (0056 §2: a handle's at).
attach()() => Presentation-
realize()(provide?, shown?) => RealizationLegacy local evaluation that drains synchronous model answers.

IntentState

type IntentState = object;

Defined in: packages/core/src/runtime/root.ts

An intent's state as data, for a view to select from (adapterOf(intent).getState()).

Properties

PropertyModifierTypeDescription
historyreadonlyobject-
history.canRedoreadonlyboolean-
history.canUndoreadonlyboolean-
history.notesreadonlyreadonly string[]Each commit's note, oldest first.
layersreadonlyLayersThe choices' layers: what a person decided and said, what the models answered.
revisionreadonlynumber-
versionreadonlystring-

IntentStore

type IntentStore = object;

Defined in: packages/core/src/runtime/root.ts

An intent as an external store, for an integration (adapterOf(intent)): what useSyncExternalStore reads.

Methods

flush()
flush(r): boolean;

Defined in: packages/core/src/runtime/root.ts

Sends what a shown r asked for, once. True when something was written.

Parameters
ParameterType
rRealization
Returns

boolean

getSnapshot()
getSnapshot(provide?): Realization;

Defined in: packages/core/src/runtime/root.ts

λ in a context, as it is: nothing is sent and nothing written. The same value until a change.

Parameters
ParameterType
provide?Provide
Returns

Realization

getState()
getState(): IntentState;

Defined in: packages/core/src/runtime/root.ts

The intent's state as data: the same object until it changes.

Returns

IntentState

isCurrent()
isCurrent(r): boolean;

Defined in: packages/core/src/runtime/root.ts

Whether r is still what the intent gives: nothing has changed since it was evaluated (0034's epoch), and the intent is not disposed. Reads only: nothing is sent, and nothing is evaluated again.

Parameters
ParameterType
rRealization
Returns

boolean

subscribe()
subscribe(fn): () => void;

Defined in: packages/core/src/runtime/root.ts

Called when λ or the state may have changed: a commit, an answer, a boundary out of steps.

Parameters
ParameterType
fn() => void
Returns

() => void


JudgeBudget

type JudgeBudget = object;

Defined in: packages/core/src/runtime/root.ts

Limits new judge requests across one explore/questions call. Zero uses cached beliefs and priors only.

Properties

PropertyType
judge?number

LayerStore

type LayerStore = ReturnType<typeof createLayerStore>;

Defined in: packages/core/src/runtime/store.ts


Presentation

type Presentation = object;

Defined in: packages/core/src/runtime/root.ts

A displayed realization's lifetime, independent of other displays of the intent.

Methods

disconnect()
disconnect(): void;

Defined in: packages/core/src/runtime/root.ts

Returns

void

present()
present(result): boolean;

Defined in: packages/core/src/runtime/root.ts

Parameters
ParameterType
resultRealization
Returns

boolean


Program

type Program = object;

Defined in: packages/core/src/runtime/store.ts

A version of the program. version names it and is never given to another: undoing back to a program restores its version, and a new program gets a new one, whatever its place in the history. revision is the place: how many programs came before it, for a person to read.

Properties

PropertyModifierTypeDescription
elementreadonlyChild-
note?readonlystring-
parts?readonlyReadonly<Record<string, Component<any>>>The version of each reprogrammable component that has been reprogrammed, by its id (0056 §7).
revisionreadonlynumber-
versionreadonlystring-

RecordedProposal

type RecordedProposal = object;

Defined in: packages/core/src/runtime/recordings.ts

What a recorded reprogramming answers: a program by name (the host's), and what it says it did.

Properties

PropertyType
programstring
summarystring

RequestState

type RequestState = object;

Defined in: packages/core/src/runtime/root.ts

Properties

PropertyTypeDescription
effectModelRequest["effect"]-
error?string-
hypothetical?trueRequested to inspect hypothetical worlds, rather than a shown realization. Cleared once a shown evaluation needs the same request.
keystring-
stampstring-
status"running" | "completed" | "failed"-

CONTENT_KIND

const CONTENT_KIND: "reintent:content" = 'reintent:content';

Defined in: packages/core/src/runtime/content.ts

The reserved kind of a slot's node. The reintent: namespace is the protocol's.


PREFER

const PREFER: 6 = 6;

Defined in: packages/core/src/runtime/store.ts

A soft preference's default factor (Huxpro/airtalk#857's e11, after #818's PREF_WEIGHT).


adapterOf()

function adapterOf(intent): IntentAdapter;

Defined in: packages/core/src/runtime/root.ts

Integration contract shared by all host adapters, independent of their JSX representation.

Parameters

ParameterType
intentobject

Returns

IntentAdapter


checkContent()

function checkContent(tree, slots): CatalogError[];

Defined in: packages/core/src/runtime/content.ts

Everything wrong with the slots in a tree, for a host that does or does not support host content (slots: the slots the root's input declares; none: the host does not support it). A slot is placed among the children, and is { slot } with no children of its own; one in a prop, at any depth, is refused.

Parameters

ParameterType
tree| Rendered | Rendered[] | null
slotsreadonly string[] | undefined

Returns

CatalogError[]


createLayerStore()

function createLayerStore(init?): object;

Defined in: packages/core/src/runtime/store.ts

Parameters

ParameterType
initPartial<Layers>

Returns

NameTypeDescription
historyobject-
get history.canRedoboolean-
get history.canUndoboolean-
get history.entriesreadonly Commit[]-
redo()() => void-
reset()() => voidBack to before the first commit, and forget them.
undo()() => void-
get layersLayers-
get programProgram | undefined-
believe()( id, stamp, answer ) => void-
commit()(note, fn) => voidA person's commit: one entry in the history, one notification. A no-op commits nothing.
generated()( id, stamp, value ) => void-
hold()(fn) => THold notifications while fn runs, then notify once if anything changed.
measure()( id, where, m ) => booleanWhat the host measured of a choice's possibilities in one context (where), kept until it measures there again. The same measurement again writes nothing and notifies no one; one from an evaluation older than the one kept (epoch) is refused.
setProgram()(element, note?) => voidThe program, outside the history (what a host starts with), and its name.
subscribe()(fn) => () => undefined-
unload()(of, unloaded) => void-

isContent()

function isContent(v): v is HostNode;

Defined in: packages/core/src/runtime/content.ts

Whether a value is a node of the reserved kind (well formed or not).

Parameters

ParameterType
vunknown

Returns

v is HostNode


layerStoreOf()

function layerStoreOf(intent): LayerStore;

Defined in: packages/core/src/runtime/root.ts

Where an intent keeps its layers and their history: for tools and tests (internal).

Parameters

ParameterType
intentobject

Returns

LayerStore


onPresented()

function onPresented(listener): () => void;

Defined in: packages/core/src/runtime/root.ts

Be told of each intent the first time a lease presents a current evaluation of it: one a host really shows, not one made and dropped (StrictMode's second state, a render Suspense drops). For tools that show "the root on the page", like the docs' sandbox (internal). Returns the stop.

Parameters

ParameterType
listener(intent) => void

Returns

() => void

Last updated on

Edit on GitHub