Runtime module responsibilities
microkernel
- main event loop: manages message passing. All messages go through event loop and microkernel routes to proper place
- starts/stops processes
- manages and enforces capabilities
eth
- manages requests to chain (reads & writes) & subscriptions to chain
http
- handles connections to/from outside world via HTTP
- http client (send GETs, PUTs, ...; receive HTTP responses)
- http server (serve webpages)
net
- handles connections to/from other nodes on the network
- responsible for getting messages over network to target or else throwing error
- responsible for receiving messages: just pass message to microkernel event loop for local routing
terminal
- accept typed input from user
- return output to user in text
vfs
- short for "virtual file system"
- read and write files to/from underlying file system
kv & sqlite
- read and write to/from key-value or sqlite system
Runtime modules vs Processes vs Packages
"Runtime modules" talk to the outside world.
E.g., eth talks to the chain, http speaks HTTP as a client or server, net talks to other nodes, terminal gets typed input from user & outputs text to user.
"Processes" are Wasm components. These are "userspace".
"Packages" are bundles of Wasm components that implement some specific functionality.
E.g., the App Store consists of a main process as well as a chain process that manages communications for App Store to/from chain.
The App Store distributes packages.
Some packages are also distributed with the core Kinode distribution.
How do my processes talk to the outside world?
Only runtime modules can talk to the "outside world". The "outside world" includes the traditional web, the chain, the filesystem, the Kinode network, etc.
Processes only talk to the microkernel. The microkernel passes messages to their target. To give a few examples:
To make an HTTP request, a process passes a message targeted at the http runtime module.
The http runtime module is then responsible for sending the HTTP request to the remote site and receiving the HTTP response.
It then routes the HTTP response back to the microkernel, which in turn passes it to the originating process.
To send a message over the network, a process passes a message targeted to that node.
The microkernel sees the target is remote and passes it to net, which is responsible for getting the message over the Kinode network to the target node.
To write to a file, a process passes a message targeted at the vfs runtime module.
The vfs runtime module is then responsible for writing the file to the underlying filesystem.
