Skip to content

Latest commit

 

History

History
247 lines (197 loc) · 11.8 KB

intent-kernel.adoc

File metadata and controls

247 lines (197 loc) · 11.8 KB

The intent kernel: a reference for client authors

Abstract

This is an orientation for anyone building a client on mise — a web console, an agent, a script, or a service — rather than using the shell. It describes what mise offers a client: a single contract in which you express intent and receive a structured receipt, so that no client ever has to speak ChRIS’s raw Collection+JSON. It states what exists today and what is still forward work, and marks the two plainly, so a client author knows what to build against now and what to design toward.

Note
Parts of this document describe a direction of travel, not a shipped API. Sections and paragraphs that describe forward work are marked (forward). Everything else describes the engine as it stands.

1. What mise offers a client

ChRIS exposes its platform (CUBE) as a Collection+JSON hypermedia API: it models resources and their relationships, not operations. That is resilient and self-describing, but it means every client must re-derive intent from many low-level calls. mise pays that cost once, in one layer (cumin), and offers clients an intent kernel instead: you say what you want as a command, and the kernel compiles it into validated, deterministic action over ChRIS and returns a receipt of what actually happened. The kernel executes only a bounded vocabulary of validated intents — never arbitrary API sequences — and its result is produced by the engine, not asserted by the caller.

For the story of how this came to be, see history.adoc; for the formal argument that a platform like ChRIS needs such a layer, see the companion paper Completing the ChRIS Architecture: An Intent-Action Service.

2. The contract

A client submits a command line and receives one CommandEnvelope per command in that line:

const envelopes: CommandEnvelope[] = await engine.line_execute('feed list --mine');

The envelope is the entire contract surface. Its fields (defined in cumin):

Field Meaning for a client

status

The engine’s ground truth: 'ok' or 'error'. Not a claim — the outcome the engine actually observed.

rendered

Printable output, a terminal view. A GUI or agent normally ignores this in favour of model.

renderedErr

Printable error-stream output, when present.

model

The typed result — { kind, data }, the object a GUI or agent consumes. The source of truth from which rendered is derived.

errors

Structured error detail for machine consumers.

trace

Present when the command came from intent resolution: what the user said, what was proposed, whether it validated, and what ran.

The model slot and the "rendered is a view of the model" rule are specified in envelope-model.adoc. (Forward: today most commands populate only rendered; filling model for every command is the active work that makes a data-consuming client fully possible.)

3. Two front doors

The same kernel is reachable two ways. A client picks by whether it needs an interactive, stateful session or a one-shot call, and by whether it runs in the same process as the engine.

3.1. In-process: brasa as a library

Any Node process can embed the engine directly:

import { engine_create } from '@fnndsc/brasa';

const engine = engine_create(/* host sink, surface, config */);
const envelopes = await engine.line_execute('ls /home/chris/uploads');

This is the purest form of the kernel: no wire, no daemon, structured results in hand. It suits a backend-for-frontend, a test harness, a batch script, or a one-shot intent handler.

Important

The engine runs in Node, not the browser: it transitively depends on the ChRIS client, authentication, and HTTP. "A web app uses brasa as a library" therefore means a Node backend uses brasa; the browser talks to that backend. A browser never imports the engine.

3.2. Hosted: the calypso session over the wire

For interactive, stateful, or remote use, calypso hosts a brasa engine as a daemon and serves it over a WebSocket. The session — current directory, ChRIS context, connection, the running-process view — lives in the daemon and outlives any single client; several surfaces can attach to one live session. This is the Jupyter-kernel shape: one engine, addressable over a wire, serving many frontends. The wire contract is described in calypso.adoc.

(Forward) The intended client of the wire is a typed client SDK that speaks the protocol and hands a GUI first-class objects (the model), so a web console is a pure kernel client. That SDK is the natural next surface after model-completeness.

3.3. One-shot HTTP (forward)

For machine integration — webhooks, other services, serverless, a single agent call — a thin stateless HTTP facade can wrap the in-process engine: one request builds an intent, drives a short-lived engine, and returns the envelope as JSON. This is the task-oriented, POST /intents/…​ shape argued for in the companion paper. It is a secondary, integration surface: mise is fundamentally a shell and therefore stateful, so the interactive path is the session (calypso), and the stateless facade is reserved for callers that genuinely want one-shot, context-free execution.

4. How each kind of client consumes the kernel

Client What it reads

Terminal (chell)

rendered / renderedErr — the text views, verbatim.

Web console

model (typed objects) and status; renders natively, and never parses a terminal string or a Collection+JSON response.

Agent

model + status + trace — its receipt. It selects among the kernel’s bounded intents; it does not construct API calls.

Machine / one-shot

A single envelope as JSON from the HTTP facade (forward).

5. The ChELL shell boundary

ChELL is a domain shell and a Unix-composable command surface over ChRIS. It is not a second general-purpose shell language. It owns the grammar and execution of ChRIS intents: VFS navigation, plugin and pipeline invocation, resource operations, command sequencing, pipes, redirection, wildcard expansion, environment substitution, and variables that name what a command answered (A=$(cmd), ${A.field}). A .chell script is a manifest (docs/manifest.adoc): a linear, reproducible sequence of those intents, played by play, stopping at its first refused line.

General programming stays above that boundary (the manifest’s law: a decision is a data state, never a branch). Iteration, conditionals, functions, arithmetic, process concurrency, and policy about whether to retry or branch belong to Bash, another shell, Python, or a program embedding Brasa. ChELL must not acquire for, if/then/else, or domain-specific repetition flags merely because one use case happens to involve a pipeline. Repeating a pipeline over parameter files and repeating a plugin over input files are the same orchestration problem.

This division follows the Unix composition rule: ChELL should do the ChRIS-specific job well and remain callable from tools that already program processes well. For example, a caller may iterate over serialized pipeline invocations without ChELL knowing that the larger activity is a numerical experiment:

for params in parameters/*.yaml; do
  chell -c "brain-preprocessing --paramFile '$params'"
done

The exact quoting and file location are caller concerns; the architectural point is that one ChELL command performs one declared platform operation and reports its result. ChELL may execute a linear sequence of such commands, but it does not decide dynamically which commands to issue or how many times to issue them. A caller that wants a single warm engine can use the hosted CALYPSO session rather than moving its control flow into the engine. A Node program that needs structured in-process composition can call Brasa directly.

Being subordinate to a general shell creates obligations for ChELL:

  • return reliable exit status for every command;

  • keep data and diagnostics on the correct stdout/stderr channels;

  • keep pipes and redirects free of terminal decoration;

  • make one-shot -c and remote one-shot execution predictable;

  • expose typed or stable machine-readable receipts so callers do not parse presentation text; and

  • preserve non-interactive authentication and explicit context selection.

Some of these obligations are complete and some, especially model-complete machine-readable output, remain forward work. Performance does not move the boundary: if repeated startup or authentication is expensive, improve the one-shot/daemon transport rather than grow a partial programming language inside ChELL.

The decision rule is: configuring and linearly sequencing ChRIS operations belongs below the boundary; iteration, conditional selection, and concurrent scheduling belong to the caller. Thus per-node parameters and a parameter file are part of one pipeline invocation, while a parameter sweep is not.

6. The determinism boundary

The kernel draws a hard line, and a client should respect it:

  • Above the line — interpretation. A human types a command, or (forward) a language model translates a natural-language request into a proposed command. This side is fuzzy: humans mistype, models are probabilistic.

  • Below the line — execution. The engine parses the command, validates it against the live command vocabulary, executes it deterministically, and materializes the result as a receipt.

The boundary is the surface/engine seam. For a language-model client this is not a convenience but a safety property, and it is the forward horizon rather than a shipped feature: a generative model must be used only to choose an intent, never to assemble a workflow. The kernel supports exactly that — a bounded set of validated intents to choose from, and a receipt (status + model) the model can read but cannot invent, so a client can show "you asked X, I proposed feed list --mine, it ran, here is what is actually there," all vetoable in the same grammar.

7. The invariant a client can rely on

A client never speaks Collection+JSON. It speaks intent to mise, and only mise (specifically cumin) speaks to CUBE. One precision so the invariant is honest: a client may still fetch a file’s raw bytes directly from a URL — but it obtains that URL from an envelope’s model, never by traversing a hypermedia link. mise mediates intent and navigation; direct bulk transfer to URLs the kernel hands you is consistent with never consuming the API.

8. Status at a glance

Capability State Notes

Every command returns a CommandEnvelope

Available

Console removed from the engine end to end.

In-process engine (engine_create / line_execute)

Available

Node only.

Calypso session over the wire

Available

WebSocket, stateful, multi-surface.

Typed model on every command

Partial

A minority of commands today; see envelope-model.adoc.

Models shipped over the wire + typed SDK

Forward

The web-console client.

Stateless HTTP / intent facade

Forward

Machine integration.

Language-assist (NL → intent) in calypso

Forward

The HARBOR horizon; determinism boundary above.

9. See also