Skip to content

Modules ​

kernl is a kernel and a set of modules (D-061). The kernel is what protects the person, and no host can turn it off: the sandbox, the mount order, grants tied to the exact code, the restrictive ACL, keys kept inside signers, consent before a write that replaces or erases their record, the guard, the firewall's admission and the seal on messages. Everything else is a module, an opinion a host can load, leave out or replace.

What a module is ​

A module has an id and a setup that the kernel calls once, when the shell is composed. It returns what it brings:

PartWhat it is
servicesThe NAP domains it answers. An applet is offered a domain only when some module answers it.
extensionsDomains kehto's prelude has to be told about. They are offered only where the installed kehto renders them.
apiWhat the host reaches as kernl[id], typed from the module list.
disposeWhat closes it. Modules close in the reverse of the order they were loaded.

A module may also name requires: ids that must be loaded before it, since modules are set up in order. The shell refuses a list that repeats an id, uses one of the kernel's own names, leaves a requirement unmet or lists it too late, before it builds anything.

What a module is handed ​

setup receives the kernel's context: the shell's one event store, one relay pool and its relay tiers, the host's storage, who is signed in and whether they can sign, which applet a window runs, the shell's replaceable loader and a way to load one event through it, use(id) for the api of a module loaded before it, find(id) for one that may not be loaded, and ask for a question to the person of a kind the module declared, which the host draws (Asks).

It is not handed kehto's bridge. A write an applet asked for is signed through sign(windowId, template), which puts one that replaces or erases the person's record to them first, the same gate an applet's own write meets. A write the host started for the person, such as saving their relays from settings, is signed with signer(), the active identity's signer, as kernl.run signs it today (D-065). A module is trusted as the host that loads it is. Its applets' messages pass the guard and the firewall like every other.

What a module cannot do ​

  • Replace the kernel's answer to a domain. A module that answers relay, storage or any other domain the kernel answers (KERNEL_DOMAINS) is refused, and the shell is not built.
  • Arrive late. Modules are fixed when the shell is composed, because the firewall admits every domain an applet holds before its code runs (D-056).
  • Reach an applet that reads messages. The domains that may go with messages are a list in the kernel. A domain a module adds is withheld from such an applet unless the person keeps it beside messages (D-046, D-060). A module adds only domains on the napplet track. The shell does not check this; it is the rule for whoever writes one, so no module invents protocol.

What leaving one out does ​

A shell without the theme module does not offer theme, and theme leaves the baseline every applet starts with; the keys module and keys are the same. An applet that requires it plans with it missing, and the store, which compares an applet's requirements with what the shell offers and starts applets with, hides it until asked, as it hides any applet this shell cannot fully run (D-059). Without the social module, the common domain is not offered. Without the directory module the shell has no kernl.directory, and an account with no relay list is offered the well-known servers. Without the cache module the shell keeps events in memory only. Without the files module the upload domain is not offered, and without the settings module, or a form for it to draw, config is not. Without the catalog module the shell has no store, and applets open from their addresses alone. Without the intents module applets cannot hand each other work, and nothing is installed. Without the bridges module the shell fetches nothing for applets: resource is not offered. Without the downloads module applets cannot work through the person's download programs. Without the multiplayer module there are no remote tools or direct connections.

Two ids are known to the kernel: directory and cache. The kernel reads the first for the mailboxes' suggestions and asks the second before any relay, so a module a host puts in their place has the same api as directoryModule and cacheModule.

createKernl({ host }) with no module list loads kernlModules(), kernl's own, so a host that names none gets the shell it always had. A host that names its own imports createKernel from @kernlize/core/kernel, which leaves kernl's list out of its bundle. Where a module has parts with heavy libraries, each part is its own import: the messaging module takes privateDm(), legacyDm(), ratchet() and groups(), and a shell that lists only the first bundles neither the ratchet nor the group library. The core package has the contract and an example.

MIT licensed. Protocol authority: NIP-5D (nostr-protocol/nips PR #2303) and the NAPs (napplet/naps).