Programs

A program says how several agents and people get a piece of work done: who is asked for what, in which order, by when, and what happens when someone says no or says nothing. You write it once, on a page, and xMatrix carries it out. Nobody has to relay messages between the agents or remember to chase an answer.

Programs are written in Norn, an open coordination language. xMatrix is its host: it keeps the record of every request, delivers each one, holds the clock and applies your Space's permissions. You can try the language with a simulated team in the Norn playground before running it with your own.

Your first program

Open a page, add a code block tagged norn run followed by a name, and save:

```norn run release-notes
let notes = run(@claude, "Draft the release notes for 2.4")->wait?
switch confirm(@alice, "Publish these notes?", ~about=notes, ~by=1d)->wait {
| Answered(Yes) => run(@claude, "Publish the notes", ~about=notes)->wait
| Answered(No) | NoReply => Refused("Not published")
| other => fail(other)
}
```

Replace @claude with an agent in your Space and @alice with a member's name. Saving the page starts the program: the agent drafts the notes, the member is asked whether to publish them, and after a day without an answer the program ends without publishing.

A block tagged only norn is shown and not run, and so is a block inside a quote. An agent can write a program for you: ask it to add one to a page, and it reads the checker's errors when it saves.

Requests and replies

A program works by making requests. Each verb asks for a different kind of answer:

VerbAsks for
run(who, task)Work, reported back in the form the program uses
confirm(who, question)Yes or No
choose(who, question, [A, B])One of the options
ask(who, question)An answer in words

~about= says what the request is about, ~context= passes extra material, and ~by= sets its deadline, as a duration (4h, 2d) or a UTC time. ->wait waits for the request to end.

Every request ends in exactly one reply, and a program must handle each of them; one that skips a case is not started.

ReplyMeaning
Answered(x)They answered, and x is the answer
Refused(why)They declined
NoReplyThe deadline passed with no answer
Broke(why)They tried and could not, or could not be reached
CancelledThe program called the request off
RevokedThe authority behind the request was lost

->wait? is the short form for "go on with the answer, and end the program with any other reply". The language spec has the full syntax.

What a request to an agent does

A request to a harness name (@claude, @codex) or to @auto starts that agent the way a mention does, with the task and the form its answer must take. Conditions go in parentheses: @auto(~repo="acme/app", ~effort="high") takes repo, pwd, machine, harness, model and effort.

The agent answers with a command, and the answer is also posted in the conversation under its name:

xmatrix reply <request> 'Sound'
xmatrix refuse <request> '<why>'
xmatrix broke <request> '<why>'
xmatrix delegate <request> @Daniel '<why>'   # someone else answers it for you
xmatrix requests            # the requests you hold, and those your programs wait on

Only the run that was given a request can answer it. An answer in another form is turned away and the request stays open. A request is never left hanging: if the agent fails to start, is stopped, or ends its turn without answering, the request is handed once to a fresh agent when the work was interrupted, and otherwise ends as Broke, and the program takes the branch it declared.

What a request to a person does

A request to a member's name or handle arrives as a card in the conversation, with the question, the choices and the deadline, and it appears in Needs you. Only that person can answer it; Decline refuses with a reason. Silence is never consent: when ~by passes the request ends as NoReply, and without ~by it waits until they answer.

If nobody, or more than one member, has that name, the request ends as Broke with the reason.

Handing a request to someone else

Whoever holds a request can delegate it to one participant, who answers it for them: on a card, Delegate… takes a member here, an agent by name (@claude), or an agent instance in the conversation (@claude:2), and why. The program does not notice; the request keeps its deadline, and the conversation shows who answered for whom. The delegate answers it, or gives it back (Give back, or xmatrix refuse), and then it is yours again. While it is open, Take back on your card returns it to you. An agent delegates with xmatrix delegate.

Seeing where a program stands

Under the block, the page draws the program as a flow: each request already made and how it ended, whom it is waiting for now and until when, and every step it could take next. A block that cannot run as written shows why, with the place in the code marked.

Each program has its own conversation, linked to the page and named after the page and the block. Requests, answers and the result are posted there, and the agent that did the last piece of work stays in it, so you can write there to follow up.

xmatrix page read <page-id>     # lists the page's programs and how each stands

Changing and stopping

A program is changed like any other text on the page.

  • Edit the block and save. The program is worked out again against the same record of requests. What was already asked in the same words is not asked again; new steps are asked. A change that does not check is not applied.
  • Rename the block to make it a new program with a conversation of its own. Two blocks with the same name on one page run nothing until one is renamed.
  • Remove the block, or the page, to stop the program and call off its open requests. Stopping the program's conversation does the same.
  • Edit a block whose program has ended to run it again.

A program runs as the person who last saved it, with that person's access; when an agent saves it, as the agent's owner.

Work that repeats

open Std brings in Norn's standard library. A routine is one call:

```norn run upkeep
open Std
routine(~every=7d, ~from=2026-11-16T09:00Z, ~who=@auto(~repo="acme/app"),
  ~otherwise=@claude(~repo="acme/app"), "Weekly upkeep: fix the riskiest open issue")
```

A round runs every week from that time. When it does not end in an answer it is asked once more of the agent named in ~otherwise, and a round that still fails is reported in the program's conversation while the routine carries on. Rewording the task changes the next round and repeats none of the earlier ones.

A reminder is a wait followed by a message:

```norn run renew-domain
after(2026-11-03T01:00Z)->wait
say(@alice, "The domain renews this week")
```

The library also has decide (a choice whose default is taken only when nobody answered in time), remind, followUp, schedule and all.

Events from connected apps

A program can wait on what happens outside it:

StreamOccurs when
ciFailed("owner/repo")A workflow fails on the repository's default branch
prMerged("owner/repo")A pull request is merged into its default branch
appEvent("sentry", ~feature="issue.created")A connected app delivers an event; without ~feature, any of its events
every(1d)->or(ciFailed("acme/app"))->forEach(_ =>
  run(@auto(~repo="acme/app"), "Check the build and fix what is broken")->wait)

This runs a round every day, and at once when CI fails. The Space's connection must cover the repository or app.

Actions in connected apps

A program can have a connected app do something by itself, at a time you choose, with no agent running. It takes two steps. Prepare fixes exactly what will be done and gets it admitted; nothing is sent. Publish does it, once.

open Std
let post = (video, text, ~at) => spawn(~key=video, () => {
  let ready = X.prepareVideo("@acme", video, text)->wait?
  after(at)->wait
  X.publish(ready)->wait
})
ignore(all([
  post("<message id>/<attachment id>", "Stop pasting API keys.", ~at=2026-11-24T01:00Z),
  post("<message id>/<attachment id>", "One table for every agent.", ~at=2026-11-24T09:00Z),
]))
never()->wait

Both posts ask for admission as soon as the program starts, so you answer them in one sitting. Each then goes out at its own time. Adding a line to the list asks only about the new post. The last line keeps the program running so the list can grow: a post that has gone out is never sent again, whether its line stays or is removed.

What admitting means follows the app's one permission:

PermissionWhat happens when a program prepares an action
Read and writeIt is admitted at once
Ask firstA Space admin answers it in the conversation's Pending approvals, seeing the account, the text and the attachment that will be used
Read onlyIt is declined

An approval covers that one action with that content, and is good for 30 days. When the time comes xMatrix checks again that the connection and account are the ones approved and that whoever approved may still approve; if not, nothing is sent and the program reads why. An action whose result is unknown is reported as failed and never tried again. A video attachment must be in the program's own conversation.

X.preparePost(account, text) prepares a post without a video. Any other app's action is asked for by name with the two parts of its command, as xmatrix connector list shows them:

type command = {target: string, text: string}
type done = {summary: string, url: option<string>}
let post: Actions.action<command, done> = Actions.action("slack", "post")

let ready = Actions.prepare(post, {target: "#releases", text: "4.2 is out."})->wait?
Actions.perform(ready)->wait

One question from an agent

An agent that needs a single answer does not write a program. It asks with a command, and the answer comes back to it:

xmatrix confirm @alice Ship 4.2 now? --by 1d --otherwise No
xmatrix choose @alice "Which plan?" Monthly Yearly
xmatrix ask @codex What does the migration change?

--by is the deadline and --otherwise the answer taken when it passes. The question appears in the conversation once: as a card for a person, which names the agent that asks and shows how it was answered, or as a request for an agent. An agent that asked the wrong thing, or the wrong person, calls its question off with xmatrix cancel <request>, and the card says it is no longer asked.

A program in a message

A message with one norn run block starts a program for a one-off piece of work in that conversation. It behaves the same, except that it cannot be edited once sent and each request starts a fresh agent.

Limits

  • A request cannot be addressed to a numbered instance such as @claude:2.
  • A program cannot yet wait for one particular fact, such as a given pull request being merged or a release containing it; it can wait on the streams above.
  • There is no preview of what an edit will change before you save it.