interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / ALLEN_CANVAS.md

161 lines · 11449 bytes Raw Blame History Rendered
1# Allen's canvas: the model paints the screen
2
3Drake's words: "It all will be on a screen that isn't being processed. It is literally being painted on by
4the model." Until this branch, the language model behind Allen could only hand back one plain line of text,
5and the kernel decided everything else. Allen's canvas is the first step past that: the model now decides
6*what is shown*, in a small language of its own, and the kernel paints it in Allen's style. This document is
7the grammar and the reasons for it.
8
9Code: `native/kernel/svc/allen_scene.{h,c}` (the parser), `native/kernel/ui/canvas.{h,c}` (the painter),
10small hooks in `native/kernel/ui/allen_ui.c` (`ck_allen_ui_scene`). The prompt the model is given:
11`crates/allen-courier/scene_prompt.txt`. Tests: `scripts/ck_allen_canvas_test.sh` (add `--live` to ask the
12real model). Evidence: `evidence/allen-canvas/`.
13
14## 1. Why a language, and why this one
15
16The model must not draw pixels. Three reasons, each measured or physical:
17
181. **Safety.** Whatever the model writes, the kernel has to survive it. A small line grammar with fixed limits
19 can be parsed in a few hundred lines of integer C with every byte bounds-checked and fuzzed (300,000
20 random and mutated replies per test run, under AddressSanitizer and UndefinedBehaviorSanitizer). Pixel
21 commands or a general layout language (HTML, SVG, a display list) cannot be checked that cheaply, and would
22 let one reply clutter or break the screen.
232. **Calm.** The design rule is one thing in the centre, the rest at the edge, every change eased in
24 (`docs/ALLEN_PRESENCE_RESEARCH.md` section 3). If the model chose coordinates and colours it could break
25 that rule on any answer. In this language it can only say *what* (a number, a list, a person) and *roughly
26 where* (left, right, above); the look, the motion and the palette stay the kernel's.
273. **Reliability of a mid-size model.** A model writes keyword lines far more reliably than nested JSON
28 (the inference-server notes record Qwen3 dropping a closing bracket and running on past the end of an
29 array). A line it gets wrong is dropped on its own; the rest of the scene still shows.
30
31The vocabulary is the smallest set that covers what people ask a computer for most of the day: an answer
32(a number, a note), steps or choices (a list), time (a timer), people (a person and a message), something to
33look at (a picture, a video, a quote), and the feeling of the room (a mood). The same lines will later carry a
34friend's message arriving (`person from`) or a video playing in its place (`video`) without a single window:
35the thing the line names is what appears, in the sky beside Allen.
36
37## 2. The grammar
38
39A scene is plain ASCII, at most **12 lines** that count and at most **2048 bytes**; anything after is not read.
40
41```
42scene = { line "\n" }
43line = mood | say | thing | (blank, a code fence, or the model's <think> block: skipped)
44mood = "mood" { tone | water }
45tone = "night" | "dawn" | "deep" | "clear"
46water = "still" | "slow" | "lively"
47say = "say" [":"] text (exactly one; Allen speaks it; at most 159 characters)
48thing = kind { word } ":" field { "|" field } (at most 4 things on screen at once)
49kind = "note" | "list" | "number" | "quote" | "person" | "timer" | "picture" | "video"
50word = "left" | "right" | "above" (where it sits; otherwise the kernel chooses)
51 | "warm" | "quiet" (lit warm to stand out, or held back)
52 | "bloom" | "rise" | "fade" (how it arrives; bloom is the default)
53 | "to" | "from" (a person's message: going to them or come from them)
54```
55
56The fields of each kind, with the room each one has (longer text is cut at a word and ends in "..."):
57
58| kind | fields | room (characters) | needs |
59|---------|--------------------------------|-----------------------------|-------|
60| note | title, text (or just text) | 48, 240 | 1 |
61| list | title, item, item, ... | 48, then 64 each (5 items) | 1 |
62| number | value, caption | 16, 64 (value has a digit) | 1 |
63| quote | text, who | 220, 48 | 1 |
64| person | name, message | 32, 200 | 2 |
65| timer | when, label | 24, 64 | 1 |
66| picture | what it shows, where from | 120, 64 | 1 |
67| video | what it shows, where from | 120, 64 | 1 |
68
69A timer's `when` is a length (`25m`, `1h 30m`, `90 seconds`, `in 10 minutes`, up to 24 hours) and then the
70ring of light empties as the time runs out; anything else (`6:00 pm`) is shown as written, in a full ring.
71
72Example (a real reply shape):
73
74```
75mood calm
76say Seventeen percent of 240 is 40.8.
77number right: 40.8 | 17% of 240
78note left quiet: How | 240 x 0.17 = 40.8
79```
80
81### What the parser forgives, and what it counts
82
83The kernel never shows a line it does not understand, and never complains on screen. Every reply gets a report
84(`ck_scene_stats`): lines read, kept, **rejected** (an unknown first word, or a thing with nothing in it),
85**tidied** (understood after taking off a list mark, numbering, bold stars or a code fence the grammar does
86not use), **cut** (a field too long, or bytes outside printable ASCII left out), **over** (past 12 lines, past
874 things, a second say or mood) and **truncated** (past 2 KiB). A reply is **clean** when nothing was
88rejected, tidied, over or truncated and it has its say line; that is the number reported for the real model.
89A reply with no scene lines at all is still spoken: its first line becomes the say.
90
91On the courier's one-line wire a scene travels with its newlines written as `\n`;
92`ck_scene_unwire()` turns it back into lines before `ck_allen_ui_scene()`.
93
94## 3. How it is painted (ui/canvas.c)
95
96Everything is drawn into the same night as Allen, in the palette of `ui/allen_ui.c` and nothing else: night
97rgb(6 8 18), text rgb(236 240 252), hint rgb(150 160 196), glow rgb(150 170 255), mist rgb(200 210 255), ink
98rgb(64 86 196), warm rgb(255 212 150) and rgb(255 222 180). The type is Allen's own stroke face.
99
100- **Nothing is a window.** No box has an edge. Words rest in a soft pool of shade that fades out over about
101 80 px, so stars never show through text and no rectangle is ever drawn. Text things have one thread of
102 light down their side (warm for a quotation). A number is large, thin strokes over a faint glow. A timer is
103 a ring of light that empties, its moving end a warm point. A person is a ring round their initial. A
104 picture or video not yet here is a soft field of deep blue light with a brighter light drifting slowly
105 across it, and "not here yet" under it; a video adds a play mark drawn in light.
106- **Allen stays alone in the centre.** Things sit in two columns beside him (each at most two things, kept
107 above his spoken words) or in one place above him; at most four things at once. The kernel chooses when the
108 model does not say, and moves a thing to where there is room when the asked-for place is full.
109- **Every change eases in.** A thing blooms: a spark leaves Allen's heart, flies on a curve to its place,
110 touches the water there (a drop of ink in the fluid), and the thing opens line by line (each line eases up
111 10 px and in over 0.7 s, 70 ms after the one before). Things come one after another, 260 ms apart, as Allen
112 starts to speak. A new line from the person sends them away over 0.7 s; a new scene replaces them the same
113 way; left alone they go after 90 s (a running timer stays). The mood's tone blends over 0.7 s: `dawn` warms
114 the low sky, `clear` lifts the high sky with mist, `deep` darkens the night; `lively` water gets a gentle
115 current pushed round Allen now and then.
116- **The kernel's rules hold.** Integer only (1/256 and 16ths of a pixel), no floating point (the test
117 compiles both files `-ffreestanding -mgeneral-regs-only` and checks they call nothing outside the kernel but
118 memset/memcpy/memmove), no allocation (one static 384 KiB pool for the large digits, rasterized at start so
119 drawing never writes to it), and drawing only reads, so the other cores can share a frame. Only the parts
120 of the screen that change are redrawn; the test checks that drawing those parts gives the same frame as
121 drawing everything.
122
123## 4. The prompt
124
125`crates/allen-courier/scene_prompt.txt` is the system prompt. It names the lines, gives the rules (plain
126ASCII, at most three things, be honest about what Allen cannot do yet: no weather, clock, internet, messages or
127media of his own) and three short examples that are not the test questions. `allen-scene`
128(`crates/allen-courier/src/bin/allen-scene.rs`) builds it in with `include_str!`, so the relay can use the
129same file the same way. The live test asks the model one question at a time and waits out the server's 503
130(busy) answers, waiting as its Retry-After asks (1 to 15 s), for up to thirty minutes per question.
131
132## 5. Measured
133
134All on the Spark (GB10 host CPU, one core, 3840 x 2160), evidence in `evidence/allen-canvas/`.
135
136- **Real model replies** (Qwen3.8-27B FP8 on my own server, 127.0.0.1:18091, temperature 0.3, ten questions
137 in `questions.txt`, raw replies kept as written): round 1, prompt v1: **10 of 10 parsed cleanly** and 10 of
138 10 used the canvas (`round-1/parse-report.txt`). Round 2, prompt v2 (one more rule: watch or play means a
139 video line, see means a picture line): **3 of 4 clean**; the fourth wrote two say lines (the second is
140 dropped, the first is spoken), and the round was stopped after four questions when other jobs held the GPU
141 lock for good (`round-2/run.log`). Together: **13 of 14 real replies clean**, every one of them understood
142 and painted. The server is shared and answers one request at a time; a reply took 1.5 to 14 minutes of
143 waiting (Retry-After honoured, never two requests at once).
144- **Fuzz**: 300,000 replies per run (random bytes, mutated scenes, word soup), each in a buffer of exactly its
145 length, under AddressSanitizer and UndefinedBehaviorSanitizer: no overrun, no undefined behaviour, no scene
146 outside its limits. It found one real bug outside the parser: `ck_atan2` in `ui/paint.c` shifted a negative
147 number left (undefined in C); fixed by multiplying.
148- **Frame cost** (`frame-times-final.txt`, held under the quiet lock): the existing window test averages
149 19.8 and 19.1 ms per frame on the base commit and 20.9 and 18.3 ms with the canvas hooked in (two pairs, the
150 machine's load fell from 43 to 9 during the run): no cost that rises above the noise. In the canvas test, frames
151 while plain answers are spoken average 19.2 ms and frames while scenes arrive and rest average 24.1 ms (worst
152 45 ms, during an arrival, when the spark and a whole thing are redrawn).
153- **Image size**: IMACKERN.EFI 307,200 bytes (274,432 before); the zeroed memory grows by the 384 KiB pool.
154
155## 6. What is not done
156
157- The courier does not carry scenes to the iMac yet: the relay (`crates/allen-courier/src/main.rs`) and the
158 kernel's answer path belong to the "Allen through the model" branch; the hook they need is
159 `ck_allen_ui_scene()` plus `ck_scene_unwire()`.
160- Pictures and videos are places only; nothing fetches or decodes them.
161- None of this has run on the real iMac.