Installing a KRL application
When picos were first conceived, about ten years ago, they were called “personal clouds,” or “personal event networks.” Each pico running on the Internet is like a personal computer running in the cloud. Like a personal computer, it needs applications. Such applications are written in KRL, as rulesets. Just as applications for a personal computer have to be installed before they can be used, so KRL applications need to be installed into a pico.
If the KRL application fits into a single ruleset, it can easily be installed through the developer UI (in the Rulesets tab) or by a program using the wrangler:install_ruleset_request
event. But when a KRL application is more involved, with multiple rulesets, it becomes more difficult to install manually, and more tedious to install programmatically.
The idea here is to write a ruleset (that, conceptually, is part of the KRL application) which installs the other rulesets. After a successful installation, it could even delete itself from the pico because its work is finished.
Instructions
This is how you could go about it:
Write the multiple rulesets that are to be installed in a single pico, and be sure that, working together, they allow the pico to perform as intended.
Consider which rulesets, or which combinations of rulesets will be needed in a pico.
Write an installation ruleset, such as the one shown in the example below.
Example
- 1 Instructions
- 2 Example
- 2.1 A real KRL application
- 2.2 A literate programming presentation
- 2.2.1 The ruleset name, and description
- 2.2.2 Lists of RIDs
- 2.2.3 For the Testing tab
- 2.2.4 Channel policies
- 2.2.5 A defined action to install a ruleset if needed
- 2.2.6 Creating the channel
- 2.2.7 Starting the installation process
- 2.2.8 Doing the installation
- 2.2.9 Installing base rulesets
- 2.2.10 Installing connections rulesets
- 2.2.11 Installing the trust_ping ruleset
- 2.2.12 Installing the basicmessage ruleset
- 2.2.13 Installing the discover-features ruleset
- 2.2.14 Cleaning up after the installation ruleset
- 2.3 Screenshots
- 2.4 Discussion
A real KRL application
Here we will consider a real KRL application, called the ACA-Pico, which when installed in a pico makes that pico an Aries cloud agent, which can perform self-sovereign identity operations, connecting with other agents to communicate securely (with signed and encrypted messages), as well as issue, hold, and verify credentials, etc. This application consists of a dozen or so rulesets, most of which need to be installed in the pico to give it the desired functionality.
Our point here is not to talk about Aries agents per se, but to show an example of a ruleset which installs other rulesets.
A literate programming presentation
The presentation of the installation ruleset will borrow concepts from the Literate Programming idea, interleaving English explanation with snippets of KRL code. If a reader were to simply concatenate all of the program snippets together, in order, she would have the entire source code of this ruleset (for convenience, available here as a single file).
The ruleset name, and description
ruleset io.picolabs.aca.installer {
meta {
description <<
Ruleset to install rulesets to make a pico
into an Aries cloud agent
>>