Reintent

Understanding Reintent

The concepts of Reintent: choices, intents, effects and the loop.

Reintent

λ⏟Realization=I⏟Intent(C⏟Choices)\underbrace{\lambda}_{\text{Realization}} = \underbrace{I}_{\text{Intent}}(\underbrace{C}_{\text{Choices}})

The way React has UI = f(state), Reintent has World = f(choices). The line joins two steps:

λt=It(Ct),Wt+1=execute(Wt,λt)\lambda_t = I_t(C_t), \qquad W_{t+1} = \mathit{execute}(W_t, \lambda_t)
  • Intent II: what someone wants, written as a program with questions left open. Pure.
  • Choices CC: the answers to those questions.
  • Realization λ\lambda: the computation the host runs. It can be a tree of data (host nodes, React elements) or plain code and function calls.
  • World WW: where the host executes λ\lambda, and where events come from. WtW_t is how it is at time tt.

Reintent takes you from probabilistic choices to a deterministic computation. When the choices change, the intent is realized again, and only what they affect is evaluated again (reactive computing). When a set of choices cannot be realized, Reintent treats it as a request to handle: use a default, ask a person, or escalate to reprogram the intent.

Choices

K=k1+k2+⋯+kn,Ct∈D(K)K = k_1 + k_2 + \cdots + k_n, \qquad C_t \in \mathcal{D}(K)

At any moment, the choices are one complete probability distribution over a defined space of possibilities. KK is a sum type that defines the space. Each possibility kik_i is a variant, and it can carry data. D(K)\mathcal{D}(K) is the set of finite-support distributions over KK:

∑x∈KCt(x)=1\sum_{x \in K} C_t(x) = 1

All the uncertainty lives in the choices, so the intent can stay pure.

A deterministic state is a degenerate distribution. A person's decision makes a choice δx\delta_x:

State(x)=δx\mathsf{State}(x) = \delta_x
LevelNotationTypeScript
Possible valuesKKtype Layout = ...
Distribution typeD(K)\mathcal{D}(K)Choices<Layout>
Current distributionCt∈D(K)C_t \in \mathcal{D}(K)const layouts = ...
type Layout =
  | { kind: 'grid'; columns: number }
  | { kind: 'list' }
  | { kind: 'carousel'; snap: boolean };

const layouts = choices<Layout>([
  { value: { kind: 'grid', columns: 3 }, weight: 0.6 },
  { value: { kind: 'list' }, weight: 0.3 },
  { value: { kind: 'carousel', snap: true }, weight: 0.1 },
]);

const grid = state<Layout>({ kind: 'grid', columns: 3 });
  • An open world with a fixed type. KK does not list every value the world could hold, but at any moment it is a fixed type. Reintent grows KK by reprogramming the program, so D(K)\mathcal{D}(K) stays type-safe.
  • Dependent. D\mathcal{D} is a monad, and a choice that depends on another's answer is flatMap\mathit{flatMap}.
  • Layered. Each writer has its own say: the code's prior, a System One model's belief, and a person's preferences, constraints and decision. The intent keeps every layer and cascades them into the effective CtC_t, so forgetting a decision brings the belief back.

Intent

An intent reads the choices and produces a realization λ∈Λ\lambda \in \Lambda. Reintent gives you the primitives to write II. JSX composes the computation, and effects come in through hooks.

Pure. The simplest intent has no effects. Each choice gives one value in a computation, and when every choice is a state, the intent is a plain pure function.

I:D(K)→ΛI : \mathcal{D}(K) \to \Lambda

Effect

An intent asks for values through algebraic effects. Hooks fire them, and a component around a subtree is their handler. Firing an effect and answering it make the Loop: within one evaluation a handler answers with the distribution a choice has now, and the answers still missing come from Actors over time.

Choose. The intent has one effect: it asks for a value of a choice.

choose:D(K)⇝K,I:D(K)→⟨choose⟩ Λ\mathsf{choose} : \mathcal{D}(K) \rightsquigarrow K, \qquad I : \mathcal{D}(K) \to \langle \mathsf{choose} \rangle\, \Lambda

choose\mathsf{choose} is do in D\mathcal{D}. The program gives a choice's prior and question where it reads it. The effect is a request: in this evaluation, a handler answers it with the distribution the choice has now, and the answers still missing come from Actors outside II, in the Loop. They are written into the choice and the intent is realized again, so II stays pure. The formula leaves out the choice's identity: reading the same choice twice on one path gives the same value.

Handlers. A handler gets the continuation κ:K→Λ\kappa : K \to \Lambda. There is one kind of handler, with parallel strategies:

  • collapse calls κ(k∗)\kappa(k^\ast) with the likeliest value once it is sure enough, and is the default;
  • each calls κ\kappa for every possibility, and each path in λ\lambda records the values it took;
  • as calls κ\kappa with a given value and writes nothing back (a preview), a counterfactual inside this subtree;
  • reprogram does not resume. It hands this part of the intent to the Loop's Reprogram.

Writing one case per variant is pattern matching: it reads the choice once and evaluates the case it got. Inside each, every case is evaluated once.

Unresolved. A collapse gives something like a Result, a value or a reason:

collapse:D(K)→K+Unresolved,Unresolved=unsure∣none∣unmet\mathit{collapse} : \mathcal{D}(K) \to K + \mathsf{Unresolved}, \qquad \mathsf{Unresolved} = \mathsf{unsure} \mid \mathsf{none} \mid \mathsf{unmet}

unsure means the leading candidate is not far enough ahead. none means the current candidates have all been excluded; the type KK may still contain other admissible values. An open string choice can generate another greeting after its current candidates are rejected. unmet means the requested value cannot be represented by KK. Recovery policy chooses whether to request new candidates, revise constraints where permitted, forward, or propose a reprogram. The formula abbreviates the available-candidate case, leaving constraints, the requested value, and policy implicit.

Evaluation outcome and waiting for Actors are separate: a choice can be unsure while waiting for a Human, or have a usable value while waiting for a new judgment. On the first generation there may be no candidate or fallback value yet. In that case the computation remains incomplete, with its requests recorded; the handler does not call κ\kappa without a value. A boundary or host can show a placeholder or the previous realization. A single request can be described by a Promise; changing inputs can make the choice request answers and evaluate again.

A handler handles an unresolved result by its reason and policy: it calls κ\kappa with an available fallback; forwards the same choose\mathsf{choose} with κ\kappa and the reason to an outer handler (an escalation); or proposes a reprogram. At the root, absence of a usable value remains an incomplete result for the host. The result of evaluation stays deterministic.

The value a handler picks serves this evaluation alone: a person's decision reaches the choice only through Decide, and the world changes only when the host executes λ.

Loop

(It,Ct)→Feedback / Judgment(It+1,Ct+1)(I_t, C_t) \xrightarrow{\text{Feedback / Judgment}} (I_{t+1}, C_{t+1})

Actors change the choices or the intent:

Actor=Code∣Model∣Human,Model≈SystemOne∣SystemTwo\mathit{Actor} = \mathsf{Code} \mid \mathsf{Model} \mid \mathsf{Human}, \qquad \mathsf{Model} \approx \mathsf{SystemOne} \mid \mathsf{SystemTwo}
  • Code: the program a developer wrote. It gives priors and reduces events into new choices.
  • Model: split loosely by strategy. System One weighs the possibilities in KK quickly. System Two reasons, writes values KK has not listed, and proposes new programs. One model can work in both ways, and an app can connect a single model. Prior Arts traces the names and the models that fit each.
  • Human: makes decisions, says what they want, and confirms a reprogram.
Changes CCChanges II
Codepriors, Reducea developer edits the source, outside the runtime
ModelSystem One weighs (Judge); System Two writes new valuesSystem Two proposes a new program (Reprogram)
Humandecisions, written into the choices by the host's codeprompts, and confirming a proposal

The answers a choice is missing come from Actors, each into one of its layers. Code gives the prior. System One weighs the possibilities KK lists. System Two writes candidates in a type VV the program fixes, generate:q↦D(V)\mathsf{generate} : q \mapsto \mathcal{D}(V), and they become the choice's possibilities. A Human decides, δx\delta_x. The choice says whom to ask, in order; the layers say who prevails, a Human's decision on top. Every choice has a stable identity: answers are written back by it, and a reprogrammed intent finds its choices by it.

λt=It(Ct)Wt+1=execute(Wt,λt)HostCt+1=Reduce(Ct,et)ReduceCt+1=Judge(It,Ct,et)JudgeCt+1=Decide(Ct,et)Decide(It+1,Ct+1)=Reprogram(It,Ct,pt)Reprogram\begin{aligned} \lambda_t &= I_t(C_t) \\ W_{t+1} &= \mathit{execute}(W_t, \lambda_t) && \text{Host} \\ C_{t+1} &= \mathit{Reduce}(C_t, e_t) && \text{Reduce} \\ C_{t+1} &= \mathit{Judge}(I_t, C_t, e_t) && \text{Judge} \\ C_{t+1} &= \mathit{Decide}(C_t, e_t) && \text{Decide} \\ (I_{t+1}, C_{t+1}) &= \mathit{Reprogram}(I_t, C_t, p_t) && \text{Reprogram} \end{aligned}
  • Reduce. An event changes the choices through the code, and the intent is realized again. This is the symbolic path, a React loop. Judge and Reprogram make up the neural path, a ReAct loop.
  • Judge. A System One model quickly weighs the possibilities in the current KK, or a System Two model writes candidates for an open choice. The program stays as it is.
  • Decide. A person's decision goes into the top layer, through the host's code.
  • Reprogram. A reasoning model changes the intent, and with it which choices are possible. Judge works inside the space of possibilities, and Reprogram changes the space. Reprogram sits above the intent. A prompt or an escalation starts it, and a person confirms its proposal before it is committed.

Last updated on

Edit on GitHub