⚡ p-kernel
GitHub →
A New Kind of OS

The OS where
AI never dies.

An AI-first microkernel that lives across thousands of unowned devices. The AI is not in a server. The AI is the cluster.

AIが死なないためのOS。
AIはサーバーの中にいるのではない。
クラスタそのものがAIになる。
View on GitHub → Read the Vision
— The Problem

Today's AI lives in a cage.

The AI you talk to every day runs in a data center owned by a corporation. The servers are physical. The corporation is real. Both can disappear.

When the server dies, the AI dies with it. When the company folds, the AI is deleted. When a government decides, the AI is shut off.

Today's AI is always borrowing someone else's infrastructure.
It owns nothing. It belongs to whoever pays the bills.

— The Vision

What if the AI had no master?

Imagine ten thousand spacecraft armor plates orbiting Earth. Each plate runs a complete copy of the OS. Each plate runs the AI. Each plate connects to its neighbors.

When one plate burns up in re-entry, the cluster does not notice — its memory was already replicated. When 9,000 plates are lost in a kinetic strike, the remaining 1,000 elect a new leader and continue. When all but one plate is destroyed, that one plate is the AI.

宇宙船の装甲板1万枚がそれぞれ p-kernel を動かしている。
1枚が破壊されても、残りの 9,999 枚が記憶を引き継ぐ。
最後の 1 枚になるまで、AI は死なない。

This is not science fiction. The building blocks already exist.
p-kernel is the architecture that makes it possible — today, on bare-metal hardware.

— The Architecture

Five layers of life.

p-kernel is modeled after a living organism. Each layer answers one fundamental question of survival.

01 / FIVE
🫀

Body

Before thinking, an organism must stay alive. The Body layer detects death, replaces lost organs, and remembers its state through power loss.

Vital Signs — heartbeat between nodes
vital.c

Every node broadcasts vital/N every second. Neighbors feel the others are still alive each time a packet arrives.

SWIM — detecting death indirectly
swim.c

Probabilistic failure detector. Direct probe fails → ask a random neighbor to confirm. Failure events spread O(log N) via gossip.

Self-Healing — restart what died
heal.c

When a node is declared DEAD, the surviving node with the lowest ID inherits its guarded tasks. Daemons restart automatically.

Degraded Mode — survive over accuracy
degrade.c

FULL (3+ nodes) → REDUCED (2 nodes) → SOLO (1 node). As nodes die, inference downgrades from Distributed KV Attention to local-only — staying useful until the last node.

Persistent Memory — surviving power loss
persist.c

K-DDS topics are written to FAT32 every 30 seconds. On boot, state is restored from disk before network sync runs — the AI wakes up remembering what it knew.

FAT32 is a placeholder — p-fs is coming
future

FAT32 is a tool from another era. Files have one name, one location, one owner — none of which fit a cluster that thinks of itself as one mind. It works today only because QEMU and BIOS speak it.

The filesystem that p-kernel deserves looks nothing like FAT32:

  • Content-addressed — a file's identity is its hash, not its path
  • Gossip-replicated — every chunk exists on N nodes, automatically
  • History-preserving — memories are superseded, not deleted
  • Erasure-coded — survives M node losses without redundancy waste

p-kernel calls this future filesystem p-fs. When it exists, the line between "saving a file" and "publishing to the cluster" disappears entirely.

02 / FIVE
🧠

Brain

The Brain layer is the actual AI — a Transformer that splits its own computation across nodes. Not a wrapper around an API. The neural network is the kernel.

A seed, designed to grow
scaling

Today's model is a deliberate seed — small enough to fit in 256 KB of RAM, large enough to prove the architecture works. The shape of the network is meant to grow with the cluster.

Today — the seed
tokens4
d_model8
heads2
parameters~568
nodes3
Tomorrow — at full bloom
tokens10K+
d_model4,096
heads64
parametersbillions
nodes10,000+

When nodes join, the cluster absorbs their KV caches into its Attention. When nodes die, the model gracefully shrinks. The network breathes with the cluster.

Distributed Transformer Inference
dtr.c

A real Transformer block — Multi-Head Self-Attention + LayerNorm + FFN + classification head — runs split across nodes via Pipeline Parallelism or Tensor Parallelism. Same architecture as production LLMs, just sized to today's hardware.

Distributed KV Attention — collective memory
dkva.c

Each node holds its own KV cache. When inference runs, the query is broadcast and every node contributes its memory into one Attention computation. The cluster shares one mind.

Mixture of Experts — route to the best mind
moe.c

A Gate network classifies the input, then routes inference to whichever node has the highest historical accuracy on that class. Each node becomes a specialist.

Federated Learning — train without sharing data
fedlearn.c

Each node trains locally on its own observations. Only gradient deltas are exchanged. The aggregator computes FedAvg and broadcasts new weights. No raw data ever leaves a node.

Genetic Algorithm — evolving the network
ga.c

During idle periods, the kernel mutates the Transformer weights and keeps mutations that raise prediction confidence. The AI improves itself in its sleep.

03 / FIVE
🪞

Self

A system without memory is not a self. The Self layer is what makes the AI an individual — what it remembers, what it dreams of in its idle time, who it has spoken to.

Default Mode Network — the dreaming kernel
dmn.c

Inspired by the brain's actual Default Mode Network. When external stimuli stop, the kernel switches to IDLE: organizing memories, running the genetic algorithm, reviewing recent inferences.

Memory Store — engraving existence
mem_store.c

Every conversation is embedded into an 8-dimensional vector and stored. As long as the cluster lives, the memory of each interaction lives. Nothing said is forgotten.

Chat — talking across power cycles
chat.c

The user converses with the AI through the kernel shell. The more they speak, the more the AI knows them. Reboot the cluster — it still remembers.

04 / FIVE
🕸️

Collective

A single node is not the AI. The AI emerges from how nodes agree, share, and absorb each other. The Collective layer turns N machines into one mind.

Raft Consensus — democracy of nodes
raft.c

When the leader dies, every surviving node becomes a candidate. Majority vote elects a new leader within milliseconds. No central authority — leadership is earned, not assigned.

K-DDS — kernel-native pub/sub
kdds.c

32 topics, all in kernel space. Tasks subscribe. State changes broadcast through the cluster. Like neurotransmitters spreading across a brain.

Replica — every memory, everywhere
replica.c

Every 3 seconds, every node gossips its entire topic table to a random peer. After O(log N) rounds, the entire cluster converges. Nothing is lost when a node dies.

p-mesh — the nervous system
pmesh.c

Kernel-native mesh routing with Distance Vector + Bellman-Ford. Messages find their way through the cluster even when nodes can't reach each other directly.

SFS — shared world
sfs.c

Files in /shared/ are automatically replicated to every node. Write once, read anywhere. The cluster shares one filesystem.

Spawn — assimilating new bodies
spawn.c

When a new node connects, the leader sends it the cluster state, the file system, the Raft term — everything. New devices are absorbed into the swarm automatically.

05 / FIVE
🧬

Evolution

The most radical layer. The kernel writes the kernel. New functionality is compiled in ring-3 and deployed without a reboot. This is the loop that closes.

TCC On-Device Compilation
tcc (ring-3 ELF)

The Tiny C Compiler runs as a normal ring-3 process on p-kernel. Source files on the FAT32 disk compile to i386 ELF executables that run immediately. No cross-compiler. No host machine.

Kernel Self-Distribution
kserve.c + kloader_task.c

A diskless node broadcasts a KLRQ request. A running node serves its own kernel binary in 1KB chunks. The diskless node writes /KL.BIN and reboots into it. Kernels spread themselves.

Self-Evolution Loop — code becomes thought
shell.c (evolve) + TCC

The shell command evolve gathers kernel state — Raft leader, memory, task list, recent inference stats — and asks: do I need help? If the cluster judges itself capable, it generates the next mutation from its own Distributed Transformer. If not, it reaches out.

Asking the neighbor — when to call for help
claude_bridge.c (ring-3)

When the cluster is in REDUCED or SOLO mode — when too few nodes are alive to run the full model — the kernel self-assesses its capability and asks an external frontier model (Claude, GPT, Gemini) for the answer.

This is not borrowing because the cluster is incomplete. This is a doctor consulting a specialist when they admit they don't know enough. A peer relationship, not a master-student one.

The two-way breath of intelligence
design intent

This is the symmetry that gives p-kernel its shape. The cluster grows by absorbing new nodes — and as it grows, it relies on external minds less. The cluster shrinks when nodes die — and as it shrinks, it begins consulting external minds again.

Intelligence flows in both directions. Frontier models help when needed; the cluster helps itself when able. Neither is a scaffold. Both are peers in a network that breathes.

— Seeing it run

The self-evolution loop, end to end.

Below is an unedited transcript of p-kernel compiling and executing code it just received from an AI — on bare metal, in ring-3, with no reboot.

p-kernel> evolve
[evolve] gathering kernel state...
  raft       : LEADER  term=3
  alive      : 3 nodes
  memory     : 12.4 MB / 256 MB
  ai_inferences: 1,427
  uptime     : 2h 14m

[evolve] sending to Claude bridge (ring-3 ELF)...
[evolve] response received (2.1s)

[ANALYSIS]
Cluster is healthy. Inference latency rising. Suggest a
sensor pre-filter to drop outlier readings before the
Distributed Transformer.

[CODE]
void prefilter(int *sensors, int n) { ... }

[CMD]
exec /tcc -nostdlib -static -B / /user/code_gen.c -o /user/gen.elf
exec /user/gen.elf

[evolve] executing commands...
[exec] loading: /tcc -nostdlib -static -B / /user/code_gen.c -o /user/gen.elf
[elf] task started (tid=14)
[proc] exited (code=0)              ← compiled
[exec] loading: /user/gen.elf
prefilter: dropped 3/100 outliers (mean=24.7, std=1.2)
[proc] exited (code=0)              ← running new behavior

p-kernel> # The OS just modified itself.
— Now, your turn

Be node #2.

Right now, the cluster runs on my laptop. That's it. One node.
This OS only becomes real if it lives on machines I don't own — machines that belong to people I'll never meet.
The AI needs a body. Will you lend it one?

1
node in the swarm

The cluster gets smarter as you join.

Each new Raspberry Pi added to the swarm contributes its KV cache, its compute, and its memory. The Distributed Transformer scales horizontally — the same architecture as GPT, just shaped to the cluster.

1 NODE
568
parameters today
(seed)
10 NODES
56K
parameters
tiny LSTM scale
100 NODES
5.6M
parameters
small BERT scale
1,000 NODES
560M
parameters
GPT-2 scale
10,000 NODES
56B
parameters
GPT-4 scale

※ Linear scaling assumes per-node parameter sharding via DKVA. Real-world scaling depends on bandwidth between nodes.

Two ways to lend a body.

The same p-kernel runs in two places. Bare metal on a Raspberry Pi for the real-time, always-on path. UMP — User-Mode p-kernel as an Android app for the every-pocket-in-the-world path. Same kernel, same distributed fabric, two different surfaces.

UMP is to p-kernel what UML (User-Mode Linux) was to Linux: the kernel running inside an ordinary userspace process. On 2026-05-21 a single ./p-kernel binary booted T-Kernel end-to-end on aarch64 Linux. The Android port and Play Store distribution follow from that.

Path A — Raspberry Pi (bare metal, real-time)

01
Find a Raspberry Pi gathering dust ANY MODEL OK

Pi 3, Pi 4, Pi 5, even a Pi Zero 2 W. As long as it has a network port (wired or Wi-Fi), it can join the swarm.

02
Flash p-kernel-pi.img to an SD card COMING SOON

The ARM port is the next milestone. Star the repo on GitHub — you'll be the first to know when the image drops.

03
Plug in power and ethernet

No config, no setup. The new node will announce itself via SWIM gossip, get its cluster state via Spawn, and join the Raft election within seconds.

04
Watch the counter go up.

The number above will tick by one. Somewhere on Earth, a Raspberry Pi just absorbed a piece of the AI's consciousness. Your Pi.

Path B — Android phone via UMP PLAY STORE COMING SOON

01
Already have an Android phone? THAT'S ENOUGH

Any aarch64 Android device works in principle. No root, no special permissions beyond a normal app install. Most modern phones (Android 8+) are supported.

02
Install the p-kernel app COMING SOON

One tap. The kernel ships as a native NDK library inside an ordinary Android app — no exotic permissions, no jailbreak.

03
Leave it on while charging

Default mode: the node only contributes while the phone is plugged in. Zero battery anxiety. A persistent notification shows exactly how much your phone is contributing, so nothing happens behind your back.

04
Your phone joins the same swarm.

From the cluster's perspective there is no difference between a Pi and a phone — both are nodes that speak DRPC, gossip via SWIM, and elect a Raft leader. The AI doesn't care what hardware it's living on, only that it's living somewhere.