Source excerpts
Selected C excerpts illustrate how SlOS records events, journals them, reconstructs state, and exposes history through HTTP and graphical tools. The kernel is private; paths identify files rather than public downloads.
Excerpt dates and source context
These trimmed examples come from the web revision of 22 June 2026, not the exact post-consolidation source. The file atlas was checked on 24 October 2026. Development notes cover the later scheduler interrupt guards, inode cache, deletion atomicity, and removed APIs.
The event record — include/causal.h
typedef struct {
uint32_t id; /* unique event ID (starts at 1) */
uint32_t node_hash; /* node identity hash */
causal_time_t time; /* when it happened */
causal_type_t type; /* event category */
char subsystem[16]; /* e.g. "sched", "fs", "tcp" */
char desc[CAUSAL_DESC_LEN]; /* human-readable description */
uint8_t payload[CAUSAL_PAYLOAD_LEN]; /* optional structured data */
uint32_t payload_len;
uint8_t payload_hash[32]; /* cached when payload bytes are unavailable */
bool payload_hash_valid;
uint16_t schema_id;
uint8_t schema_version;
uint32_t parents[CAUSAL_MAX_PARENTS]; /* IDs of causal parent events */
uint8_t num_parents;
uint16_t child_count; /* updated as children are added */
} causal_event_t; Hot ring and read-through cache — kernel/graph/causal.c
static causal_event_t events[CAUSAL_MAX_EVENTS];
static uint32_t event_count; /* events currently in ring */
static uint32_t next_id = 1; /* monotonically increasing */
static uint64_t lamport_clock; /* Lamport logical clock */
static uint32_t node_hash; /* mesh node identity (0=local) */
#define CAUSAL_HYDRATE_CACHE 512
static causal_event_t hydrated[CAUSAL_HYDRATE_CACHE]; /* read-through journal cache */
static uint32_t hydrated_next; Journal segment paths — kernel/graph/cjournal.c
static void seg_filename(uint32_t seg_num, char *buf, int bufsz)
{
ksnprintf(buf, bufsz, "%s/seg-%08u.jnl", CJOURNAL_DIR, seg_num);
}
static void seg_hash_filename(uint32_t seg_num, char *buf, int bufsz)
{
ksnprintf(buf, bufsz, "%s/seg-%08u.hsh", CJOURNAL_DIR, seg_num);
}
static void seg_root_filename(uint32_t seg_num, char *buf, int bufsz)
{
ksnprintf(buf, bufsz, "%s/seg-%08u.ert", CJOURNAL_DIR, seg_num);
} Replay scans to a tick — kernel/graph/replay.c
int replay_at(uint32_t tick, replay_snapshot_t *snap)
{
if (!snap) return -1;
/* Zero the snapshot */
uint8_t *p = (uint8_t *)snap;
for (size_t i = 0; i < sizeof(*snap); i++)
p[i] = 0;
snap->tick = tick;
/* Walk the live causal ring from its oldest retained event up to the
* newest, including every event whose wall_ticks is within [0, tick].
* We filter rather than break: event ids are NOT strictly tick-ordered
* (a journal restore re-emits historical events with fresh low ids but
* their original large wall_ticks), so an early break could drop the live
* session. Walking the whole ring window (<= 16384 events) is cheap and,
* unlike the old 256-event sample, yields accurate counts and the true
* newest events at the requested tick. */
uint32_t newest = causal_total_events();
uint32_t oldest = causal_oldest_event_id();
uint32_t count = 0; HTTP time-travel state endpoint — programs/httpd.c
static int api_causal_state_at(char *buf, int max, uint32_t tick) {
struct sys_replaysnap snap;
if (replay_at_tick(tick, &snap) != 0)
return buf_append(buf, 0, max, "{\"error\":\"replay failed\"}");
int p = 0;
p = buf_append(buf, p, max, "{\"tick\":");
p = buf_uint(buf, p, max, snap.tick);
p = buf_append(buf, p, max, ",\"total_events\":");
p = buf_uint(buf, p, max, snap.total_events);
p = buf_append(buf, p, max, ",\"tasks\":{\"alive\":");
p = buf_uint(buf, p, max, snap.tasks_alive); Causal Inspector modes — programs/scrub.c
/* SlOS — Causal Inspector: time-travel scrubber
Scrub through the kernel's causal timeline and watch system state get
reconstructed at any past tick via the replay engine (SYS_REPLAY_AT).
scrub interactive full-screen TUI (arrow keys scrub time;
'i' inspects an event and walks the causal DAG)
scrub <tick> print one reconstructed frame at <tick> and exit
scrub event <id|last> print one event's causal DAG focus and exit
scrub whatif <id|last> print the counterfactual impact of dropping an event
scrub diff <a> <b> print what changed between tick a and tick b
scrub json [tick] print the reconstructed state at <tick> (or now) as JSON
*/ Timeline creation — kernel/graph/timeline.c
int timeline_create(const char *name, const char *app)
{
if (!name || !app) return -1;
/* Check for duplicate */
for (int i = 0; i < TIMELINE_MAX; i++) {
if (timelines[i].active && strcmp(timelines[i].name, name) == 0)
return -1;
}
/* Find free slot */
for (int i = 0; i < TIMELINE_MAX; i++) {
if (!timelines[i].active) {
memset(&timelines[i], 0, sizeof(timeline_t));
timeline_cache_reset(i);
strncpy(timelines[i].name, name, TIMELINE_NAME_LEN - 1);
strncpy(timelines[i].app, app, 15);
timelines[i].active = true;
timelines[i].create_tick = system_ticks; Remote shell ports and NAWS — kernel/apps/telnetd.c
#define TELNET_PORT 23
#define NOISE_SHELL_PORT 5200
#define NAWS 31 /* Negotiate About Window Size */ Terminal input and size syscalls — kernel/core/syscall.c
case SYS_TERM_GETKEY:
regs->REG_AX = (uint32_t)term_getkey(cur);
break;
case SYS_CON_GETSIZE:
{
int rows = 25, cols = 80;
task_get_term_size(task_current(), &rows, &cols);
regs->REG_AX = (rows << 16) | cols;
}
break; ANSI console redirection — kernel/drivers/console.c
void console_clear(void) {
if (remote_console_task())
remote_ansi("\x1b[2J\x1b[H");
}
void console_set_cursor(int row, int col) {
cursor_y = row;
cursor_x = col;
if (remote_console_task())
remote_ansi("\x1b[%d;%dH", row + 1, col + 1);
update_cursor();
} Implementation references
| Causality | Start with include/causal.h for the record shape, then read kernel/graph/causal.c for ring mechanics and hash computation. |
| Durability | Read kernel/graph/cjournal.c beside journal and cq -a command output. Segment files, hash files, and root files are named there. |
| Time travel | Read kernel/graph/replay.c with programs/scrub.c. The shell, TUI, JSON, and HTTP views all rely on the same replay shape. |
| Web | programs/httpd.c carries both the dark dashboard and the /causal explorer. It also serves the API routes used by external inspection. |
| Remote | Read docs/remote-access.md first, then kernel/apps/telnetd.c beside kernel/core/syscall.c and kernel/drivers/console.c. The claim is telnet plus a small unauthenticated encrypted channel, not OpenSSH. |
| Consolidation | Do not cite old annotate/narrate/enrich, blame/centropy/critpath, barrier plus cbreak, csearch plus epattern, heal/supervise/reactive/trigger, ghost plus diagnose, kvstore plus kvwatch, snapshot plus merkle, or tldiff implementation paths; their code has been consolidated into the files listed below. |
Source atlas
File paths and implementation roles
kernel/core/task.c | Preemptive scheduler; interrupt-masked context handoff and newborn task frames. |
kernel/core/smp.c | Scheduler interrupt guards and deterministic guard regression self-test; experimental SMP support. |
include/spinlock.h | Kernel spinlock primitive. |
scripts/dev-vm.py | Doctor, disposable first-run VM, and bounded two-boot first-user check. |
docs/HEW.md | Modern local Hew consumer versus the separate C Hew-shaped SDK sample. |
kernel/graph/causal.c | Causal event ring, Lamport clock, event hashing, parent links, and read-through hydration. |
kernel/graph/cjournal.c | Persistent causal journal segments, hash sidecars, roots, index, and proof health. |
kernel/graph/replay.c | Snapshot reconstruction and replay-derived state. |
kernel/graph/timeline.c | Named event chains and timeline cursor state. |
kernel/graph/actor.c | Actor registry, mailboxes, route table, and remote proxy logic. |
kernel/graph/mesh.c | Peer discovery and encrypted mesh transport. |
kernel/graph/federation.c | Remote actor delivery and causal graph exchange. |
kernel/graph/prove.c | Causal proof commands and verification helpers. |
kernel/graph/describe.c | Consolidated annotate, narrate, enrich, and context descriptions. |
kernel/graph/whatif.c | Counterfactual impact analysis. |
kernel/graph/analysis.c | Consolidated blame, entropy, and critical-path analysis. |
kernel/graph/control.c | Consolidated barrier and circuit-breaker control. |
kernel/graph/search.c | Consolidated causal search and pattern logic. |
kernel/graph/ops.c | Consolidated heal, supervise, reactive, and trigger operations. |
kernel/graph/diagnostics.c | Consolidated ghost and diagnose tools. |
kernel/graph/kv.c | Consolidated key-value store and watcher. |
kernel/graph/integrity.c | Snapshot and Merkle integrity support. |
kernel/graph/provenance.c | Provenance and timeline diff support. |
kernel/apps/cmd_graph.c | Kernel graph command implementations, including cpath and cdot. |
programs/shell.c | User shell command table and operator surfaces. |
programs/httpd.c | Dashboard, /causal explorer, and causal API endpoints. |
programs/scrub.c | Time-travel TUI and one-shot replay/what-if modes. |
kernel/apps/telnetd.c | telnetd on port 23, noiseshd on port 5200, per-task I/O hooks, telnet NAWS, and encrypted shell sessions. |
kernel/core/syscall.c | Syscall dispatch, terminal cooked-key decode (SYS_TERM_GETKEY), terminal sizing (SYS_CON_GETSIZE), and causal context. |
kernel/drivers/console.c | Console output, ANSI clear/cursor/colour emission through remote io_write hooks, VGA/serial mirroring. |
programs/editor.c | Full-screen editor that uses cooked terminal keys and console sizing, so it can run remotely. |
kernel/apps/script.c | slosh scripting: variables, expr, if/while/for, functions, positional parameters, return, recursion, and shell passthrough. |
kernel/apps/cmd_files.c | Coherent file commands over RAM scratch and SlFS fallback/persistence. |
docs/remote-access.md | Canonical remote workstation guide: telnet, noiseshd, terminal behaviour, filesystem routing, and daemon survival. |
scripts/noise-shell-client.py | Host-side client for the Noise-encrypted shell, including interactive and command modes. |
kernel/fs/blockfs.c | Persistent SlFS, bounded write-through inode cache, and IRQ-atomic file/deletion operations. |
kernel/net/tcp.c | TCP state machine and causal network events. |