Thurbox kernel

From Thurbeen/thurbox · View interactive version

Thurbox kernel is an AI agent skill from the GitHub repository Thurbeen/thurbox. The thurbox mod kernel: the five rules, where the module dependency rules live (crates/architecture.toml), module responsibilities, the event loop, and writing an interface mod - the bundled panes, delivery vs decision vs composition, installable panes and mods.toml, capabilities (run, program, even

How to use this skill

Skill file

Thurbox mod kernel and mod authoring

Working reference indexed by AGENTS.md. The rationale behind these decisions is owned by the docs under docs/; a change that invalidates what this says updates it in the same PR.

Architecture (mod kernel)

The interface is Lua running on a Rust kernel. thurbox boots the kernel,

which reads ui/ and renders whatever mods it finds; there is no built-in

pane.

The five rules

  1. Four node kinds, forever — text, box, input, surface. Everything

else composes in ui/lib/widgets.lua. tests/kernel_mvp.rs asserts the count.

A new appearance arrives as a prop on one of the four: text takes a

style the kernel paints across its whole rect before the spans go on top,

which is what a selection bar or hover band is — no pane pads a row with a

spacer span, and a span naming its own colour keeps it (a search hit stays

visible under the bar). widgets.list exposes it as selected_style /

hover_style. A frame takes title_align, border_type

(rounded/square) and an overlay — runs painted onto its own border

cells (top_left/top_right/bottom_left/bottom_right/right_column)

after the block, which is where the session list's ▲ N/▼ N

counts and the terminal pane's scrollbar live, at the cost of no content

cell. And a run takes id/role, so a chip inside a line is a click

target over its own columns without becoming a node; adjacent runs sharing an

identity coalesce into one hitbox, which is what makes ◀ F9 — an accent

chevron and a muted hint — a single button.

  1. Layout resolves before render — rects are computed first, then each mod

is called with its own. Mods declare size statically, in their declaration

table, which is what breaks the circularity.

  1. Snapshot-read, command-write — reads come from an in-memory snapshot and

return instantly; writes are commands accepted now and surfaced later. Lua never

blocks, so no mod can stall the loop on Fleet, git or an unreachable host.

  1. Capabilities by absence — an ungranted capability is *not in the

environment*. io, os, debug, package and the loaders are withheld, and

thurbox.yml makes selene enforce that statically. One capability cannot be

expressed that way: a program pane is asked for through command, which every

mod has, so thurbox.granted reports the grant instead — a boolean about a

decision already made, which withholds nothing.

  1. Anything touching the world runs on a worker — terminal attach, commands,

the fleet watch that feeds the snapshot (kernel::snapshot::fleet), diffs,

metrics, git stats, repository reads, update checks, and programs a mod

asked for. In kernel::snapshot (fleet, git) and kernel::terminal

(attach, shells, stream_pane) each worker is a file of

its own, and thurbox's restrictions in crates/architecture.toml fail when the

store, the read model or the paint path (terminal::paint) starts a thread or

runs git.

files.read uses kernel::worker_store::WorkerStore<K, V>: two reusable

workers, 16 deduplicated keys/answers, one-second TTL refreshes, and a generation

that changes only with the answer. The host collects without waiting; the

coordinator marks changed results as data changes so pure panes repaint. Lua

gets nil while pending, cached text while refreshing, and a raised error after

a failed read. Session-root resolution and reading both happen on the worker;

the files capability still gates access. Per-plugin read dependencies are

bounded to 16 and survive pure-tree hits; the unconditional frame-end hook

retires hidden panes, while polling retires revoked owners and obsolete roots.

Retired request identities discard late results. One deferred admission is

retried before refreshes; demand above the shared cache limit has no fairness

guarantee. files.list remains synchronous. Other worker stores keep their

existing scheduling contracts.

The command bus runs commands for the same non-empty Command::session() in

dispatch order on one worker per active session. Waiting commands remain

Queued; other sessions, session-less commands and housekeeping run independently.

Empty session queues retire on the worker, without needing the UI to poll.

Module dependency rules

crates/architecture.toml holds the module graph: an allowlist over resolved

edges, one [crates.thurbox.modules] entry per module under src/, and the

only copy of that graph, which arch-rules checks. Read the file, not a

summary of it. Every file of agent, config and update is a module of its

own (governed), and a path_only grant admits fully-qualified paths but

never use. Its [[crates.thurbox.restricted]] entries keep consumers off a

concrete backend and off runtime_mux itself outside its gateways, a specific

multiplexer outside session, process state and environment reads out of

session, threads and git out of the kernel's non-worker files, and

in-place writes outside paths; session's external list names the crates

it may use. crates/architecture.toml also holds the

crate graph and runtime-mux's module rules.

Module Responsibilities

render), convert (Lua table ↔ node), paint (node → ratatui), host (the VM,

reload, isolation, capability grants), registry (keys + settings mods

declare, plus the chord-less commands the palette lists), events (the

closed set a mod may subscribe to, and the deriver that diffs a snapshot

into them), modals/ (help, settings, theme picker, the command palette —

chrome about thurbox itself,

which mods contribute data to rather than replace), bands (the top/bottom

bars), snapshot (the read side: a SnapshotSource, fleet::FleetWatches, one

fleet::FleetWatch per listed Fleet, rows <fleet>:<task>),

command (the write side: the Executor, command::fleet; ADR-41),

bookmarks (the creation flow's repository memory, bookmarks.json),

terminal/ (live

PTY surfaces: the attach machinery, mod program panes, link detection +

OSC 8 painting — every surface owns its own rect and size memo, and a

session's agent and its #shell companion are two of them, never one),

selection (mouse text selection over a pane), plus the worker-backed

stores: diff, metrics, repos, runs, updates, files, notify,

theme, perf, bundled, inventory, packages (the spec, the lock, and the

install/converge/withdraw operations — sharing bundled's decision matrix).

need, and input encodes keys for an agent's terminal. The agents

themselves are Fleet's harness profiles.

(interface_state, settings, themes).

config::file is the one loader every config

file goes through: its path,

seeding it on first run, parsing it with unknown keys reported, degrading to

a fallback with a warning, and writing it back with paths::write_atomically.

self_update (install it).

multiplexer runtime, crates/runtime-mux (ADR-41), which it re-exports,

and what thurbox injects into it (mux_settings: settings.toml's

scrollback and the data directory; wiring::local_only: this machine's

adapters).

vocabulary every surface prints), settings, ModSpec/ModLock/PackageManifest

(mod_spec, so the kernel and the CLI share one definition) and review;

plus runtime-mux's SessionId, host model, routes and hyperlink table,

re-exported. Holds no process state, reads no environment and names no

rendering crate (crates/architecture.toml).

colours: session cannot name a rendering crate, so the palettes live here.

command (the one place a git process is built, and where the inherited

GIT_* scrub lives), plugin (clone/checkout of a mod working copy),

stderr (OpenSSH's advisory kept out of a reported error), discovery

(listings, path classification, child-repo scans), newrepo (a directory for

a repository that does not exist yet) and diff (diffs and worktree stats).

The runtime creates, syncs and removes worktrees, from the workspace URLs a

Task names. git::* is still one flat

surface; no caller names a submodule.

main.rs; its behaviour is here, grouped by what it is for: the loop and its

workers (mod), then commands, publish, draw, input, mouse, focus,

events (the one dispatch point, and the kernel events derived from the

loop's own signals) and interface — plus boot (the startup sequence main delegates to),

chrome (the terminal/error-panel/perf-HUD helpers), editor (the

Ctrl+O command resolution), control (applying thurbox-cli ui requests on

the loop, ADR-33) and paste (rebuilding a paste from the key stream the

Windows console delivers). Still one model and one loop — splitting App

itself is what ADR-23 rejects, and the invariants that matter hold across

these groups.

widgets, theme roles, fuzzy match, text input, trees — plus the extracted

pane halves: chrome (every framed pane's focus styling), modal

(frame + footer), scroll,

order and session_model (the session list's model, with its memo),

pathpicker and repo_picker (the creation flow's); mods/ holds the

panes.

process: the kernel's commands, watch, manager and attach and doctor's

probes all go through it, on this machine or through a shell

launcher (ssh, WSL), with stdin, stdout and exit codes unchanged. Nothing

else in kernel or cli starts Fleet. A link is built from a

[fleets.<name>] entry of settings.toml (FleetLink::of). The session

list follows every listed Fleet; commands go to FleetLink::in_force until

each reaches its row's own Fleet.

Event Loop (`src/main.rs` + `src/coordinator/`)

tokio::main → load config + settings
  → resolve ui/ → build the Lua host → follow `fleet watch` (and keep a
  `fleet up`) → init terminal → loop {
    resolve layout → call each mod with its rect → paint
    → poll workers (terminals, commands, diffs, metrics, repos, runs, updates)
    → dispatch events to the mods subscribed to them (kernel::events)
    → drain Lua's command queue → dispatch keys through the registry
} → restore terminal

is the TUI's)

reporting before printing — otherwise the shell inherits a raw-mode terminal

streaming mouse reports. A signal gets the same treatment

(coordinator::boot::install_signal_restore): SIGHUP/SIGTERM/SIGINT

run restore_terminal and exit 128 + n, since the default action runs no

hook, and a terminal emulator closing, a session manager, or a machine waking

from a long sleep would leave the next shell printing \x1b[<64;…M on

every scroll. restore_terminal shows the cursor itself for the same

reason — a signal exits from the runtime's thread and drops no Terminal.

The one case no handler reaches is a dropped ssh connection to a remote

thurbox: the ?1003l has no pty to travel down, so the local emulator

keeps reporting — reset there, or run the ssh session inside a local tmux.

tests/tui_e2e.rs pins both exits' escapes.

Writing an interface mod

The bundled set is deliberately small: 10_sessions, 20_agent, 65_search, plus

four floats that occupy no slot — the creation flow (70_new_session), the

confirmation (60_confirm), the rename field (62_rename, Ctrl+E) and the

context menu (64_menu, opened at the pointer by a right press on a session).

thurbox-cli mod dir            # which directory is live, and which rule chose it
thurbox-cli mod new notes      # a starter that already loads
thurbox-cli mod check          # load it the way thurbox does; non-zero on failure
thurbox-cli mod list           # the inventory the Interface tab shows
thurbox-cli mod install top    # a distributed pane, recorded in mods.toml
thurbox-cli mod sync           # make the directory match the spec

Two panes are maintained out of tree, each its own repository, installed

by clone:

CODE0 (the diff

reviewer, asks for run only for the targets the kernel does not compute) and

CODE0 (the info

panel, no capabilities — everything from the snapshot). Neither is bundled or

vendored; both are downstream consumers of the published thurbox.* shape.

Two example panes live in examples/panes/ (tasks, top) and install by bare

name; examples/lua/{plugin,composite,events,layout}.lua are copied by hand. They are

examples to read and copy from, not a catalogue thurbox maintains for anyone —

EXAMPLE_MODS is the list a bare name and a typo suggestion resolve against.

check fails on a pane that loaded but which no arrangement places — the only

failure with no symptom — and prints the layout.lua line to add.

ui/lib/ui.lua is the component layer, and the first thing a pane should

reach for: ui.panel (one focus convention — with focus a thick border and a ▸

title badge, without it a thin one in border_unfocused; ui/README.md →

Focus), ui.list (variable row heights, a sticky window,

the selection bar as the row's own style, overflow either as marker rows or as

▲ N/▼ N on the frame), ui.cursor (the selection as the item it is on

rather than the row, re-derived on every build so a reordered list keeps it,

plus the steer/publish protocol, so another pane writing store.selected moves

the list and the list's own echo is not mistaken for one), ui.row (a span builder that

knows the row's width, so a trailing note is budgeted rather than re-measured),

ui.empty, ui.modal, ui.footer (hints resolved from the key registry,

so a rebind moves them), ui.status/ui.dots, ui.rule. lib/widgets.lua is

the primitive kit underneath it. 10_sessions is the worked consumer;

65_search, 70_new_session and 20_agent still spell their own.

Two commands reach outside a pane's own rect. `command("message", { text,

level })` puts a sentence in the message band — kernel chrome stays kernel-drawn

and a mod contributes to it, as it contributes a pill or a binding, instead of

spending a row of its own on a message line. `command("action", { text =

"help.open" })` runs a declared action through the very handler a click on an

action: node runs, so a key handler can open help, settings, themes or the

palette; the issuing mod is the fallback owner, stamped by the kernel. Both

are applied on the UI thread (the action registry, the modals and the band are

the loop's), and both refuse rather than guess — a message with no text, or a

level no band badges, is an error at parse time and not a silent no-op.

Measuring text is the kernel's job (host::api::install_text). The text

global gives a mod text.width(s), text.truncate(s, cols, opts) and

text.pad(s, cols, align), all in terminal COLUMNS and all backed by the same

unicode-width the painter measures with. Lua cannot compute this: # counts

bytes, utf8.len counts codepoints, and a CJK glyph is one codepoint over two

columns — so a budget counted either way sheared every row with a double-width

name in it. ui/lib/widgets.lua forwards to it (widgets.len, truncate,

truncate_hard, keep_left, keep_right, middle_truncate, pad), and

widgets.chars is the separate codepoint count a CARET needs, since

input.cursor is a character offset.

ui/lib/thurbox.d.lua is the API as lua-language-server types — node props and

their allowed values, ctx, the hit/key/wheel payloads, the declaration

table, every published thurbox.* row shape, every command verb's options, and

the theme roles. It is declarations only; nothing loads it into the VM (which is

why selene.toml excludes it — describing a global means assigning one, and that

is the one thing the sandbox forbids). Its published thurbox.* half and the

theme roles are generated from src/kernel/lua_api.rs, as are thurbox.yml's

thurbox.* entries and tests/fixtures/lua_std/reads.lua: add a published field

there, run just lua-api, and tests/lua_api.rs holds the files and every key a

real publish serves to it. Removing a field or changing its meaning bumps

lua_api::API (thurbox.api; a mod's requires_api is checked against it at

load). Keep the rest in step with node.rs/convert.rs, host/load.rs and

command/mod.rs.

Two shapes do the catching, because lua-language-server does not flag an extra

key in a table constructor: every kind and every verb declares the field it cannot

work without (a misspelt one reads as missing-fields), and every field drawn from

a fixed set is spelled as that set (a misspelt value is assign-type-mismatch).

tests/fixtures/lua_types/ holds three panes that each make one of those mistakes

and scripts/ci/check-lua-types.sh fails when any of them stops being reported —

the counterpart to --check ui, which only proves the bundled panes are clean.

tests/fixtures/lua_std/ + scripts/ci/check-lua-std.sh are the same counterpart

to selene ui examples: selene checks a dotted path a segment at a time, so a

table declared without its fields rejects thurbox.platform.os, and no bundled

pane reads one by name to notice.

The two files split by LIFETIME. A global, or a field of a published table, is a

name selene can see, and it belongs in thurbox.yml — generated from

lua_api.rs, which covers LuaHost::publish and LuaHost::enter, which sets

thurbox.runs and thurbox.granted per mod. The shape of a value that exists only while a call

is running — a hit, a key, a wheel, a row out of a list — is unreachable

from there and is thurbox.d.lua's. Neither file can do the other's half.

The directory ships its own guidance for whoever edits it: README.md is the

reference, and AGENTS.md is the operational half a coding CLI loads as context

without being asked — which is what stops "install this mod" being read as a

package-manager request rather than thurbox-cli mod install. CLAUDE.md and

GEMINI.md beside it are one-line pointers, not copies, so there is one file to

keep true.

Two rules pick the directory: THURBOX_UI_DIR if set, otherwise the user's copy

(~/.config/thurbox/ui/, materialised from the embedded interface on first run,

preserving edits). A ./ui beside the working directory is never picked on its

own: editing a checkout's interface is an explicit THURBOX_UI_DIR (just tui-ui).

Startup reports the directory whenever there is a question about it — an override

is in force, the fallback was used, or this is a dev build. The user-copy path is

derived from paths::config_file() like every other config path — settings.toml, themes.toml, ui.json — so a **dev build reads

~/.config/thurbox-dev/ui** and cannot touch the release copy.

THURBOX_CONFIG_DIR overrides that anchor. config show prints

the resolved ui_dir/ui_json beside the rest. The resolved directory is

made absolute — trust, the disabled set and rebindings are keyed by

ui_dir.join(file) and compared verbatim, so a relative ui would be shared by

every checkout on the machine. It is not canonicalised: that would return a

\\?\D:\… extended-length path on Windows and resolve /var to /private/var on

macOS, and this path is shown to people.

Delivery vs. decision vs. composition. .bundled.json records what delivery did

(bundled / edited / yours / removed / installed); ui.json records what the user

decided about the interface (rebindings, settings, pill order) and mod-state.json

what a mod may do (trust, the disabled set); mods.toml records what the interface is

composed of and mods.lock what each entry resolved to.

ui.json and mod-state.json share the atomic config writer with

settings.toml: each stages the whole file beside the destination before a native

same-directory replacement, so a failed save cannot expose a truncated mix of those

decisions. A grant or a disabled toggle writes only mod-state.json. The

writer does not promise durability

across storage or operating-system failure because neither file nor directory is

explicitly synced. An existing config-file symlink remains a link and its target is

replaced.

Deleting a bundled file is how you remove it — delivery records

the removal and never writes it back, which is what makes a differently-named

replacement possible on equal terms. Turning one off is a third thing: present on

disk, intact, not loaded — implemented by build not reading the file, so a disabled

mod declares no keys, occupies no slot and is granted no capability. A broken one

can be switched off to get a working interface back.

A mod that carries more than Lua is a repository (fetch::Source::Git,

git::clone_mod). The fetch path returns a String and decodes remote output

lossily, so a binary through it is corrupted rather than refused — which is why

payload arrives only by clone and that path stays Lua-only. Recognition is

explicit: git+<url>, a .git suffix, or git@host:path; a bare https:// URL

keeps meaning "fetch the manifest's files from this base". The working copy lands at

<ui_dir>/<name>/ and keeps its .git, so update is a fetch and git owns "your

edits are yours" (a dirty tree is never moved and reports kept). The lock records

the commit, not the ref, which is what makes a spec reproducible and why there is

no checksum field. Two consequences elsewhere: build loads panes the spec names

outside mods/ (is_nested_pane; the load order still comes from the basename's

numeric prefix) and sources() inventories those panes but deliberately does not

walk the rest of a working copy. .git is watcher noise (watch::is_noise) — a fix

in its own right, since it already affected anyone versioning their own panes, and the

symptom is not "reloads too often" but "stops reloading while git is busy".

thurbox.platform is published so a mod shipping several binaries picks one

itself; platform selection is deliberately not a manifest field.

Agents are Fleet's. thurbox.agents is the harnesses Fleet has profiles

for, read once from fleet version --json on the Fleet watch's worker, and

nil until Fleet has answered: a flow tells a pending list from an empty one.

thurbox probes no agent binary and publishes no multiplexer preflight.

Panes are installable (kernel::packages, session::mod_spec). mods.toml

in the interface directory lists a src (a bare name resolving to examples/panes/<name>

at the binary's release tag, a URL, or a path — fetch::resolve_source_in,

one resolver), a destination file, and an optional pin;

mods.lock records what each resolved to plus the digest of every file delivered.

mod sync converges the directory to the spec, which reduces an agent's job to

edit one file, run one command, read the exit status. Delivery semantics are

shared with the bundled path, not reimplemented: both call bundled::decide, so an

edit is preserved and a deletion is remembered for a package exactly as for a shipped

file. Two consequences worth knowing: the manager never writes layout.lua (placement

stays hand-authored, and check fails loudly on an unplaced slot instead), and a

package may deliver shared modules only under lib/<its own name>/ — enforced at

install time, since require splits on every dot and would otherwise let a package

replace lib/theme.lua.

Trust for an installed pane is keyed to (src, pin) and the lock's digest

(registry::Granted::Managed, inventory::Trust::resolve_installed). Contents alone

would report every ordinary release as tampering; (src, pin) alone would let an

upstream re-tag of the same version inherit a grant made to what that version used to

be. Both are checked.

A mod can run a program you interact with (Capability::Program,

kernel::terminal's programs map). run captures output once with no stdin and

no tty, so it cannot give you htop, lazygit or a REPL; a program pane holds a

real terminal — keystrokes go to it, it is resized to its rect, it survives an

F10 reload. The pane belongs to the mod, not a session: the mod writes

command("program", { text = "watch", repo = "htop" }) and draws

{ type = "surface", program = "watch" }, and the kernel stamps the owner from the

mod being rendered, so naming another mod's pane is impossible by

construction. Reuses the companion-shell machinery whole (ProgramPane mirrors

ShellPane over the same Session::wire_up); the differences are a third window

prefix (tbp-; discover lists it, but it is stamped @thurbox_role=program

with no session id, so it can never resolve as a session's agent — ADR-25), and

that nothing is persisted: the window name is deterministic, so re-adoption

after a restart is a lookup (find_program_window) and there is no stored id to go stale. Gated by its own

capability, not run's — run is bounded (256 KB, 600 s, 4 at a time) and an

interactive program is none of those, so an existing grant must not silently widen.

Four panes per mod. thurbox.granted.<name> is how a pane knows, since

command is present whether or not it may.

A mod can run a program (kernel::runs) — git status, docker compose ps —

in the session's working directory, and on that session's own host for a remote

session — or, with machine = "local", on the machine running thurbox, in the home

directory, with no session (runs::Target::Local; for programs that need this

machine's microphone, display or clipboard). The default machine = "session"

requires a nonempty string opts.session; missing, empty or non-string IDs fail

before queueing. An unknown machine fails the call

rather than falling back. run(key, program, opts); the answer arrives next frame as

thurbox.runs[key], so Lua still never blocks, and asking **every frame is the

intended pattern** because a fresh answer is a map lookup rather than a process

(request refuses a duplicate while the answer is fresh or while a run for that

key is in flight). Bounds are the kernel's: output capped with truncation flagged, a

timeout, four at a time with the rest queued.

This is the first capability that reaches outside thurbox, so it is granted **per

mod**: declare capabilities = { "run" } and get nothing until the user trusts

the file (settings → Interface → t). Trust is keyed by absolute path with the

digest recorded, so a changed trusted file reads trusted · modified and keeps the

grant — unless it is installed, where the same change reads untrusted · modified

and withdraws it. The enforced grant (packages::granted, fed to set_trusted)

and the row both go through packages::trust_of → Trust::grants; never gate on

the bare registry record. It is

deliberately not a sandbox — a program thurbox spawns has the user's authority —

and the position is that thurbox can only refuse to run things unasked.

examples/lua/composite.lua is the worked example.

machine = "host:<exact-name>" targets a configured/discovered host without a

session, in its home and platform shell.

Hosts config is process-cached; restart to refresh it. The existing run grant

covers this selector. run_forget(key) has the same owner/grant and removes an

answer and queued request in call order, discarding old active completions even

if the key is reused. Active captures keep their slots until finish/timeout;

there is no remote cancellation promise. Mods must bound desired keys and

forget retired ones: queue/answer counts have no automatic cap. Request identity

lives only with retained entries and active work, with no tombstone map. Full

result and lifetime semantics are owned by docs/thurbox/mods.md.

Every mod runs in its own _ENV (host::api::mod_env): one Lua state

is shared, so identity is bound where a function is made, never read from who is

running, so a pane that wraps type never runs inside a trusted pane's call

with its run and its path. command, run, run_forget, files, state and require (with a

per-mod module cache, modules run in the requirer's env) are created per mod;

reads fall through to the sealed shared globals, writes stay in the mod's table.

string/table/math/coroutine/utf8/text/store are per-mod empty

views over a sealed metatable (per mod, because rawset writes into the view;

__pairs never returns the backing table), and the string metatable is sealed.

LuaHost::enter puts the mod's own run and files into its env, or takes

them out, per call; layout.lua has an env that never holds either.

LuaHost::reachable_globals is what the environment tripwire reads.

Driving sessions needs sessions. Command::requires is an exhaustive match

with no catch-all (a new verb must decide; every_verb_states_what_it_requires

pins each): send, create, mod and delete (Fleet has no undo

window, so every delete is for good) need sessions; open needs

run; program needs program; an action naming kernel.paste needs

sessions, and every request carries the chain of mods it came through

(LuaHost::acting_for, drain_requests), allowed only with what every member

holds (Command::refusal_by). Refused in

coordinator::commands::refuse_ungranted against the owner bound into the issuing

mod's own command (LuaHost::drain_issued). A bundled file byte for byte as

shipped is Trust::Shipped and holds what it declares untrusted — 60_confirm

and 70_new_session need it — and

60_confirm forwards only the verbs its FORWARDS table names, since any pane can

write store.confirm; it words the change itself from the command, names the

asker via store_writer (the writer's chain, recorded by its own store view), and on y

issues the request it last drew, not store.confirm re-read.

A mod can react to events (kernel::events, coordinator::events).

Declare events = { "session.status", … } and an on_event(name, payload), and

the loop calls it once per change, off the render path, under the render's

budget. The kernel's events are derived by diffing the snapshot — a row

appearing, leaving, changing status/name/branch/repos/parent — plus the focus

ring, the command bus (command.done/failed, and session.post_* for the

operations this interface performed) and

interface.reloaded; never raised by whatever changed the session, so a

session another process made fires the same event. The set is closed (KERNEL_EVENTS): a

subscription to an unknown name refuses to load, and the same table renders in

F1 and thurbox-cli mod events. command("emit", { text = name, … })

delivers user.<name> to other mods with source stamped by the kernel;

cascades stop at MAX_DEPTH. Dispatch never marks the frame dirty itself

(frame-cost); a reload drops the queue and delivers interface.reloaded first.

Memory recovery (LuaHost::memory_pressure, live heap after a collection)

rebuilds an Exhausted VM (within 1/32 of the ceiling) or a Grown one (past

nine-tenths and 1/20 over its accepted resident size), never a VM that only loads

large; pressure again within 10 s of a rebuild is accepted (Grown) or sent to

the bundled interface (Exhausted), so no loop iteration rebuilds twice in a row.

It replaces the host even when neither interface builds: the empty

replacement reports the error through kernel chrome without a successful reload

event. Disabled mods are applied before building either replacement, and

programs and run answers are retired against its final mod list.

examples/lua/events.lua is the worked example.

A mod can ask for a strip — strip = true with size = { len = n }: a

full-width row the shipped layout.lua places above the bars by iterating

ctx.strips ({ slot, len }, load order, one entry per slot — len sums a

stack's panes and takes a switch's tallest; LuaHost::strips), so a pane in a slot

of its own needs no layout.lua edit — which mod install never makes.

Floats and decorators are never strips. Under an arrangement without the loop,

mod check's unplaced failure names the loop as the fix (cli::mods::layout_fix).

A mod can declare chord-less commands — commands = { { action, desc } }

— which the command palette (Ctrl+P, kernel::modals::palette) lists

beside every declared key and the kernel's own actions, filtered by subsequence

as you type; Enter runs the row through the same on_action a key takes,

focused or not, after the modal has closed. A command a user rebinds from F1

becomes a binding (Registry::apply_overrides synthesises it). Ctrl+P is

the palette's (tests/keymap.rs); the creation flow's folder import is

Alt+P.

on_action(action, args) accepts a read-only table of typed arguments for

instance-scoped UI control. Existing one-argument handlers still work. The

first external actions are session.focus {session_id} and

search.open {query}; the coordinator validates them and applies them on the

event loop. The local transport lives in ui_control, outside the session

backend, and thurbox-cli ui selects the target interface explicitly when

more than one is reachable. A key declared release = true passes

{ event = "press" } and later { event = "release" } through the same

table (coordinator::input::Holds; docs/thurbox/mods.md → Keys).

lists the mistakes that are invisible until runtime

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.