pico-engine 1.9.5 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +11 -5
  2. package/demos/bootstrap/com.example.visitors.bootstrap.krl +9 -5
  3. package/demos/child_tasks/com.example.task_runner.bootstrap.krl +10 -7
  4. package/demos/echo/com.example.echo.bootstrap.krl +10 -7
  5. package/demos/guard_rules/com.example.archive.bootstrap.krl +10 -7
  6. package/demos/json_query/README.md +11 -0
  7. package/demos/json_query/com.example.json_query.bootstrap.krl +84 -0
  8. package/demos/json_query/com.example.json_query.krl +162 -0
  9. package/demos/json_query/try-it.md +5 -0
  10. package/demos/kblog/com.example.kblog.bootstrap.krl +10 -7
  11. package/demos/layered_rulesets/com.example.invitations.bootstrap.krl +10 -7
  12. package/demos/score_tracker/com.example.score_tracker.bootstrap.krl +10 -7
  13. package/demos/secrets/com.example.notifier.bootstrap.krl +10 -7
  14. package/demos/try-it-order.json +1 -1
  15. package/demos/two_picos/com.example.two_picos.bootstrap.krl +5 -2
  16. package/demos/xmlui/com.example.thermostat.bootstrap.krl +10 -7
  17. package/dist/cli.js +5 -1
  18. package/dist/engineConfig.js +1 -1
  19. package/dist/identity/portableMove.js +5 -1
  20. package/dist/index.js +44 -12
  21. package/dist/internalAccess.js +110 -0
  22. package/dist/oauth/OAuthService.js +172 -10
  23. package/dist/oauth/acg.js +194 -24
  24. package/dist/oauth/cimd.js +381 -0
  25. package/dist/oauth/discovery.js +175 -0
  26. package/dist/runMcp.js +1 -1
  27. package/dist/server.js +197 -48
  28. package/dist/subtreeWrangler.js +8 -5
  29. package/dist/uiChannelPolicies.js +2 -0
  30. package/krl/io.picolabs.pds.krl +109 -21
  31. package/krl/io.picolabs.pico-engine-ui.krl +13 -7
  32. package/krl/io.picolabs.wrangler.krl +21 -9
  33. package/mcp/devResources.js +52 -0
  34. package/mcp/devTools.js +40 -9
  35. package/mcp/docs/CLAUDE.md +3 -2
  36. package/mcp/docs/cookbook/README.md +23 -0
  37. package/mcp/docs/cookbook/bootstrap/README.md +23 -0
  38. package/mcp/docs/cookbook/bootstrap/instructions.md +75 -0
  39. package/mcp/docs/cookbook/child_tasks/README.md +20 -0
  40. package/mcp/docs/cookbook/child_tasks/instructions.md +60 -0
  41. package/mcp/docs/cookbook/collection/README.md +21 -0
  42. package/mcp/docs/cookbook/collection/instructions.md +93 -0
  43. package/mcp/docs/cookbook/echo/README.md +19 -0
  44. package/mcp/docs/cookbook/echo/instructions.md +59 -0
  45. package/mcp/docs/cookbook/guard_rules/README.md +22 -0
  46. package/mcp/docs/cookbook/guard_rules/instructions.md +73 -0
  47. package/mcp/docs/cookbook/json_query/README.md +26 -0
  48. package/mcp/docs/cookbook/json_query/instructions.md +64 -0
  49. package/mcp/docs/cookbook/kblog/README.md +60 -0
  50. package/mcp/docs/cookbook/kblog/instructions.md +102 -0
  51. package/mcp/docs/cookbook/layered_rulesets/README.md +24 -0
  52. package/mcp/docs/cookbook/layered_rulesets/instructions.md +87 -0
  53. package/mcp/docs/cookbook/moving_picos/README.md +44 -0
  54. package/mcp/docs/cookbook/moving_picos/instructions.md +150 -0
  55. package/mcp/docs/cookbook/score_tracker/README.md +19 -0
  56. package/mcp/docs/cookbook/score_tracker/instructions.md +73 -0
  57. package/mcp/docs/cookbook/secrets/README.md +25 -0
  58. package/mcp/docs/cookbook/secrets/instructions.md +98 -0
  59. package/mcp/docs/cookbook/two_picos/README.md +20 -0
  60. package/mcp/docs/cookbook/two_picos/instructions.md +88 -0
  61. package/mcp/docs/cookbook/xmlui/README.md +23 -0
  62. package/mcp/docs/cookbook/xmlui/instructions.md +84 -0
  63. package/mcp/docs/developing/README.md +28 -0
  64. package/mcp/docs/developing/accepting-relationship-requests.md +65 -0
  65. package/mcp/docs/developing/arrays-and-maps.md +77 -0
  66. package/mcp/docs/developing/converting-time-formats.md +28 -0
  67. package/mcp/docs/developing/cookies-and-redirects.md +81 -0
  68. package/mcp/docs/developing/decoding-form-data.md +67 -0
  69. package/mcp/docs/developing/engine-log-files.md +34 -0
  70. package/mcp/docs/developing/event-loop.md +77 -0
  71. package/mcp/docs/developing/events-from-email.md +80 -0
  72. package/mcp/docs/developing/initializing-entity-variables.md +83 -0
  73. package/mcp/docs/developing/mcp-ai-tools.md +98 -0
  74. package/mcp/docs/developing/misconceptions.md +467 -0
  75. package/mcp/docs/developing/names-and-scope.md +44 -0
  76. package/mcp/docs/developing/postman.md +159 -0
  77. package/mcp/docs/developing/querying-another-pico.md +47 -0
  78. package/mcp/docs/developing/singleton-picos.md +36 -0
  79. package/mcp/docs/developing/tabular-data.md +67 -0
  80. package/mcp/docs/developing/tips.md +251 -0
  81. package/mcp/docs/developing/webhook-signatures.md +56 -0
  82. package/mcp/docs/developing/workflow.md +106 -0
  83. package/mcp/docs/exp/README.md +46 -0
  84. package/mcp/docs/exp/event.md +110 -0
  85. package/mcp/docs/exp/query.md +94 -0
  86. package/mcp/docs/lessons/README.md +59 -0
  87. package/mcp/docs/lessons/events-and-queries.md +247 -0
  88. package/mcp/docs/lessons/gossip.md +28 -0
  89. package/mcp/docs/lessons/modules-and-apis.md +270 -0
  90. package/mcp/docs/lessons/pico-based-systems.md +470 -0
  91. package/mcp/docs/lessons/pico-state.md +267 -0
  92. package/mcp/docs/lessons/pico-views.md +290 -0
  93. package/mcp/docs/lessons/quickstart.md +157 -0
  94. package/mcp/docs/lessons/relationships.md +530 -0
  95. package/mcp/docs/lessons/scatter-gather.md +362 -0
  96. package/mcp/docs/pico-engine.md +7 -5
  97. package/mcp/docs/pico-overview.md +3 -3
  98. package/mcp/docs/wrangler/README.md +47 -0
  99. package/mcp/docs/wrangler/channels.md +235 -0
  100. package/mcp/docs/wrangler/oauth.md +56 -0
  101. package/mcp/docs/wrangler/pds.md +423 -0
  102. package/mcp/docs/wrangler/portable-subtree.md +44 -0
  103. package/mcp/docs/wrangler/relationships.md +297 -0
  104. package/mcp/docs/wrangler/wrangler.md +253 -0
  105. package/mcp/docs/wrangler/xmlui.md +60 -0
  106. package/mcp/engineClient.js +57 -5
  107. package/mcp/mcpScopes.js +118 -0
  108. package/mcp/meshHttp.js +151 -45
  109. package/mcp/runStdio.js +2 -0
  110. package/mcp/subtreeTools.js +184 -0
  111. package/mcp/tryItTools.js +202 -0
  112. package/package.json +14 -8
  113. package/public/pico-engine-ui.js +26 -26
  114. package/src/cli.ts +6 -2
  115. package/src/engineConfig.ts +5 -2
  116. package/src/identity/portableMove.ts +6 -1
  117. package/src/index.ts +469 -430
  118. package/src/internalAccess.ts +127 -0
  119. package/src/oauth/OAuthService.ts +243 -11
  120. package/src/oauth/acg.ts +289 -25
  121. package/src/oauth/cimd.ts +508 -0
  122. package/src/oauth/discovery.ts +233 -0
  123. package/src/runMcp.ts +3 -1
  124. package/src/server.ts +252 -52
  125. package/src/subtreeWrangler.ts +17 -5
  126. package/src/uiChannelPolicies.ts +2 -0
@@ -0,0 +1,102 @@
1
+ # KBlog: instructions
2
+
3
+ These steps use the developer UI of a running engine at `http://localhost:3000`. Replace that with your engine's URL. See the [overview](/cookbook/kblog/) for what the demo shows and how it differs from the 2011 KBlog.
4
+
5
+ ## The quick way: Try It!
6
+
7
+ On the root pico in the developer UI, open the **Try It!** tab, click **KBlog**, then **Run in a new child pico**. The bootstrap installs the rulesets and submits three posts. When it shows **ready**, it has two links:
8
+
9
+ - **Read the blog (reader channel)**: Home and Contact. There is no Post page.
10
+ - **Write a post (author channel)**: Home, Contact, and Post.
11
+
12
+ ## By hand
13
+
14
+ 1. Create a child pico and open its **Rulesets** tab.
15
+ 2. Install these from the engine, in this order. Each one after the first uses an earlier one as a module.
16
+ - `http://localhost:3000/krl/io.picolabs.xmlui.krl`
17
+ - `http://localhost:3000/krl/demos/kblog/com.example.kblog.config.krl`
18
+ - `http://localhost:3000/krl/demos/kblog/com.example.kblog.data.krl`
19
+ - `http://localhost:3000/krl/demos/kblog/com.example.kblog.krl`, which creates the `kblog, reader` channel
20
+ - `http://localhost:3000/krl/demos/kblog/com.example.kblog.posting.krl`, which creates the `kblog, author` channel
21
+ 3. Click **View** next to `com.example.kblog` and open it on either channel.
22
+
23
+ ## Try it
24
+
25
+ - On the author channel, open **Post**, write a post, and click **Post**. The **Event path** card reads `handle_submit → add_article → show_new_article`: one rule in each of three rulesets. Open **Home**: your post is first, marked **New**.
26
+ - Submit a post without a title. The path is `reject_submit`, and nothing is added.
27
+ - Click an article's title. Its page is at `#/post/<id>`, so you can bookmark it, and the browser's back button returns to Home.
28
+ - On the reader channel, try to post anyway. Replace `<reader eci>` with the id in the reader page's URL:
29
+
30
+ ```sh
31
+ curl -X POST "http://localhost:3000/sky/event/<reader eci>/demo/kblog/post_submitted" \
32
+ -H 'content-type: application/json' -d '{"author": "Mallory", "title": "Hi"}'
33
+ ```
34
+
35
+ The answer is `{"error":"Error: Not allowed by channel policy"}`.
36
+ - On the author channel, try to skip the check by raising the internal event yourself: `kblog/new_article_available` instead of `kblog/post_submitted`. The author channel refuses it too. It allows `post_submitted` and `clear_requested` and nothing else.
37
+ - **Clear the blog** on the Post page deletes every article. The path is `clear_articles → show_empty_blog`.
38
+
39
+ ## How it works
40
+
41
+ **Posting** checks a post and passes it on. It doesn't store anything:
42
+
43
+ ```krl
44
+ rule handle_submit {
45
+ select when kblog post_submitted
46
+ author re#(\S.*)#
47
+ title re#(\S.*)#
48
+ setting(author, title)
49
+ send_directive("handle_submit", {"title": title})
50
+ fired {
51
+ raise kblog event "new_article_available" attributes
52
+ {"author": author, "title": title, "body": event:attr("body") || ""}
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Data** stores the article and says so:
58
+
59
+ ```krl
60
+ rule add_article {
61
+ select when kblog new_article_available
62
+ pre {
63
+ id = ent:next_id.defaultsTo(1)
64
+ entry = {"id": id, "author": event:attr("author"), "title": event:attr("title"),
65
+ "body": event:attr("body") || "", "time": time:now()}
66
+ }
67
+ send_directive("add_article", {"id": id})
68
+ fired {
69
+ ent:next_id := id + 1
70
+ ent:articles{id.as("String")} := entry
71
+ raise kblog event "new_article_added" attributes entry
72
+ }
73
+ }
74
+ ```
75
+
76
+ **Pages** marks the newest article and raises `kblog:front_page_updated`. The Home page reloads its articles every five seconds, so readers see new posts without reloading.
77
+
78
+ Each rule answers with a directive named after itself. A raised event is handled in the same transaction as the event that raised it, after that event's rules finish. So the response to `post_submitted` holds the directives of every rule that ran, in order. The Post page joins their names into the event path.
79
+
80
+ **Who can post** is the author channel's policy:
81
+
82
+ ```krl
83
+ wrangler:createChannel(
84
+ ["kblog", "author"],
85
+ {"allow": [{"domain": "kblog", "name": "post_submitted"}, {"domain": "kblog", "name": "clear_requested"}], "deny": []},
86
+ authorQueryPolicy()
87
+ )
88
+ ```
89
+
90
+ Its query policy allows every page, including Post, plus the posting ruleset's `PostForm` component. The reader channel, made by `ui:create_app_channel` in the pages ruleset, allows the other pages and no events. The navigation shows only the pages a channel allows, so readers never see Post.
91
+
92
+ **The Post page** is in the pages ruleset, but its form is the `PostForm` component from the posting ruleset. The engine finds a component in the app's ruleset, then in `io.picolabs.xmlui`, then in one other installed ruleset that defines it.
93
+
94
+ **Article text** is Markdown from whoever posted it, so the pages render it with `<Markdown content="{$item.body}" allowHtml="false" interpolateBindings="false" />`. HTML in a post shows as text, and nothing in it is evaluated.
95
+
96
+ ## Change it and watch
97
+
98
+ The **Try It!** window lists each file with its path on disk. Edit a file there, click **Flush**, and reload the page.
99
+
100
+ - Rename the blog: change the string `blogtitle` returns in `com.example.kblog.config.krl`, flush it, and reload. The pages call the configuration module each time they are generated, so only the module needs flushing.
101
+ - Put back the tweeter as a new ruleset whose rule selects `kblog:new_article_added`, records each title, and sends a directive named after itself. Install it from a `file://` URL and post: the event path gets a fourth name, with no change to the other rulesets.
102
+ - Add a word limit: a rule in `com.example.kblog.posting.krl` that rejects bodies over 200 words. Make `handle_submit` skip them too, so only one of the two rules runs.
@@ -0,0 +1,24 @@
1
+ # Layered rulesets
2
+
3
+ A pico does what its installed rulesets do, so installing another ruleset is how you change it. That works best when the rulesets already there leave room. Two habits make room:
4
+
5
+ - **Each rule does one thing.** When reacting to an event takes several steps, one rule raises an event that starts the next.
6
+ - **No rule ends the chain.** A rule that finishes its work raises an event saying so, even if nothing listens yet. Later, another ruleset can.
7
+
8
+ This demo's base ruleset accepts invitations: URLs with a `c_i` parameter that encodes who is inviting. Two add-on rulesets layer on top without changing it. One accepts short links the base doesn't recognize. It selects the same event with its own URL pattern, expands the link, and raises the event again with the full invitation. The other welcomes each new connection by reacting to the event the base raises when it is done.
9
+
10
+ To run it, follow the [instructions](/cookbook/layered_rulesets/instructions).
11
+
12
+ ## The rulesets
13
+
14
+ | Ruleset | File | What it shows |
15
+ |---------|------|---------------|
16
+ | Invitations (base) | [`com.example.invitations.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/layered_rulesets/com.example.invitations.krl) | A rule selected by an attribute regex that records the connection and raises `invite:connection_made`. Has an Invitations `@view` that walks through adding the add-ons one at a time, says what to expect at each step, and lists every directive in the reply |
17
+ | Short links (add-on) | [`com.example.invitations.short_links.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/layered_rulesets/com.example.invitations.short_links.krl) | Selecting the same event with a different pattern, and raising it again with new attributes |
18
+ | Welcome (add-on) | [`com.example.invitations.welcome.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/layered_rulesets/com.example.invitations.welcome.krl) | Reacting to the event another ruleset raises when it finishes |
19
+ | Bootstrap | [`com.example.invitations.bootstrap.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/layered_rulesets/com.example.invitations.bootstrap.krl) | Installs only the base ruleset; the page adds the layers. The developer UI's **Try It!** tab runs it |
20
+
21
+ ## What you need
22
+
23
+ - A running pico engine (1.9.4 or later for the page, which uses the shared `PicoTheme` component).
24
+ - `io.picolabs.xmlui` on the pico for the page. The bootstrap installs it.
@@ -0,0 +1,87 @@
1
+ # Layered rulesets: instructions
2
+
3
+ These steps use the developer UI of a running engine at `http://localhost:3000`. Replace that with your engine's URL. See the [overview](/cookbook/layered_rulesets/) for what the demo shows.
4
+
5
+ ## The quick way: Try It!
6
+
7
+ On the root pico in the developer UI, open the **Try It!** tab, click **Layered rulesets**, then **Run in a new child pico**. The bootstrap installs only the base ruleset. When it shows **ready**, open **Invitations**. The page walks you through three steps, adding one layer at a time.
8
+
9
+ ## Try it
10
+
11
+ The **The pico answered** card lists the name of every directive in the reply, from every rule that ran, in order. At each step, click **Try the full invitation** and **Try the short link**, compare the answers with what the step card says to expect, then click **Add the next layer**.
12
+
13
+ | Step | Installed | Full invitation | Short link |
14
+ |------|-----------|-----------------|------------|
15
+ | 1 | The base ruleset | `connected` | `nothing`: no rule selects it |
16
+ | 2 | + `com.example.invitations.short_links` | `connected` | `expanded, connected` |
17
+ | 3 | + `com.example.invitations.welcome` | `connected, welcome` | `expanded, connected, welcome` |
18
+
19
+ The base ruleset is the same file at every step. Then:
20
+
21
+ - Paste `https://short.example/nobody` and click **Accept**. The answer is `nothing`: the short links add-on selected it but has no such link, and the base never saw a full invitation.
22
+ - On the **Rulesets** tab, uninstall `com.example.invitations.short_links`. The page goes back a step: the **Layer** table shows it is gone, short links get `nothing` again, and full invitations still get `connected, welcome`. **Add the next layer** puts it back.
23
+
24
+ **Add the next layer** raises `layers:next_layer_requested`, and a rule in the base ruleset installs the next add-on from the same folder. That rule is scaffolding for the demo, and it installs only the two add-ons the base ruleset lists. On a real pico, the operator installs rulesets, and a page can't.
25
+
26
+ ## By hand
27
+
28
+ 1. Create a child pico and open its **Rulesets** tab.
29
+ 2. Install `io.picolabs.xmlui` from the engine: `http://localhost:3000/krl/io.picolabs.xmlui.krl`.
30
+ 3. Install the base: `http://localhost:3000/krl/demos/layered_rulesets/com.example.invitations.krl`. It creates a channel tagged `invitations, app`. Open the page on it (**View** next to `com.example.invitations`).
31
+ 4. Follow the steps above. To add a layer yourself instead of with the button, install `.../layered_rulesets/com.example.invitations.short_links.krl`, then `.../layered_rulesets/com.example.invitations.welcome.krl`, on the **Rulesets** tab.
32
+
33
+ ## How it works
34
+
35
+ **The base rule** selects `invite:new_invitation` only when the `url` attribute is a full invitation, and captures the `c_i` code:
36
+
37
+ ```krl
38
+ rule accept_invitation {
39
+ select when invite new_invitation
40
+ url re#^(https?://[^?]+[?](?:.*&)?c_i=([A-Za-z0-9+/_=-]+).*)$#
41
+ setting(url, code)
42
+ pre {
43
+ label = labelOf(code)
44
+ }
45
+ send_directive("connected", {"label": label})
46
+ fired {
47
+ ent:connections := connections().append({"label": label, "url": url, "time": time:now()})
48
+ raise invite event "connection_made" attributes {"label": label, "url": url}
49
+ }
50
+ }
51
+ ```
52
+
53
+ It raises `invite:connection_made` after recording the connection. Nothing in the base listens for that event. It is there for other rulesets.
54
+
55
+ **The short links add-on** selects the same event with a pattern only short links match. It doesn't touch the base. It expands the link and raises the event again, with the full invitation as the `url`:
56
+
57
+ ```krl
58
+ rule expand_short_link {
59
+ select when invite new_invitation
60
+ url re#^https://short[.]example/(\w+)$#
61
+ setting(code)
62
+ pre {
63
+ full = links{code}
64
+ }
65
+ if full then send_directive("expanded", {"from": event:attr("url"), "to": full})
66
+ fired {
67
+ raise invite event "new_invitation" attributes event:attrs.put("url", full)
68
+ }
69
+ else {
70
+ raise invite event "unknown_short_link" attributes event:attrs
71
+ }
72
+ }
73
+ ```
74
+
75
+ The second time around, the base's pattern matches and the add-on's doesn't. A real short link service would be expanded with `http:get` and its redirect. This one uses a table so the demo works offline.
76
+
77
+ **The welcome add-on** selects `invite:connection_made`. It runs after every connection, however it was made.
78
+
79
+ A raised event is handled in the same transaction, after the rules for the current event finish. So the reply to a short link has the directives of all three rulesets, in the order the rules ran.
80
+
81
+ ## Change it and watch
82
+
83
+ The **Try It!** window lists each file with its path on disk. Edit a file there, click **Flush**, and use the page again.
84
+
85
+ - Add a short link: put `"ada": "https://agents.example/invite?c_i=eyJsYWJlbCI6IkFkYSBMb3ZlbGFjZSJ9"` in the `links` table in `com.example.invitations.short_links.krl`, then accept `https://short.example/ada`.
86
+ - Change the welcome message in `com.example.invitations.welcome.krl`.
87
+ - Write a third add-on that selects `invite:unknown_short_link` (the short links add-on raises it whether or not anything listens) and records the links nobody could expand. Install it from a `file://` URL.
@@ -0,0 +1,44 @@
1
+ # Moving picos
2
+
3
+ A pico and its children move from one pico engine to another. The pico keeps its did:webvh identity, and its relationships keep working on the new engine. Follow the [instructions](/cookbook/moving_picos/instructions) to run it.
4
+
5
+ ## The scenario
6
+
7
+ A bike club owns bikes that members borrow, and uses communities to coordinate rides. A ride coordinator runs her own mesh. The club sells **Gravel Bike #7**, so the bike moves from the club's mesh to the new owner's mesh.
8
+
9
+ Three meshes on two engines, all running [Manifold](https://github.com/Picolab/manifold-api):
10
+
11
+ | Mesh | Engine | What's there |
12
+ |------|--------|--------------|
13
+ | Club gear | A, `http://localhost:3001` | Trail Ride Community, Gravel Bike #7 (with a Bike #7 Computer child), and Gravel Bike #3 |
14
+ | Ride coordinator | B, `http://localhost:3002` | A coordinator with a Layer 2 relationship to Bike #7 (optional) |
15
+ | New owner | B | The Manifold that imports Bike #7 |
16
+
17
+ Bike #7 and its computer move. Bike #3 and the community stay on A.
18
+
19
+ ## What it shows
20
+
21
+ - **Portable identity.** The did:webvh SCID survives the move. The host in the DID changes to the new engine's.
22
+ - **Subtree move.** Export produces a portable blob of state and identity, not a copy of the engine's database.
23
+ - **Manifold.** The new owner's Manifold makes its own relationship to the bike.
24
+ - **Communities.** A community can stay on the old engine while one of its things moves.
25
+ - **Layer 2.** A DID relationship made before the export (coordinator and bike) still works after the import.
26
+
27
+ ## The rulesets
28
+
29
+ | Ruleset | File | Install on |
30
+ |---------|------|------------|
31
+ | `io.picolabs.club_gear_demo` | [`io.picolabs.club_gear_demo.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/moving_picos/io.picolabs.club_gear_demo.krl) | Engine A, the Manifold app pico. Builds the club, the bikes, and the community; releases Bike #7 after the move |
32
+ | `io.picolabs.ride_coordinator_demo` | [`io.picolabs.ride_coordinator_demo.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/moving_picos/io.picolabs.ride_coordinator_demo.krl) | Engine B, the mesh root. Optional; sets up the coordinator's relationship to Bike #7 |
33
+
34
+ Export and import use `io.picolabs.portable_subtree` (bundled with the engine) and `io.picolabs.manifold_portable_thing` from manifold-api.
35
+
36
+ ## What you need
37
+
38
+ - Docker, to run both engines with `docker-compose.cross-engine.yml` from the repository root. It mounts `demos/` at `/var/pico-demos`, so the rulesets install from `file:///var/pico-demos/moving_picos/…`.
39
+ - The current manifold-api rulesets, including `io.picolabs.manifold_portable_thing`.
40
+ - About 10 to 14 minutes for the full story, or 7 to 9 without the coordinator.
41
+
42
+ ## Known exception
43
+
44
+ Both demo rulesets call `ctx:newChannel`, and `club_gear_demo` calls `ctx:query`. Application rulesets should use wrangler instead. Setup needs a channel to exist before Manifold raises its events, and wrangler's `new_channel_request` doesn't yet return one in time. A wrangler-based setup is the intended fix.
@@ -0,0 +1,150 @@
1
+ # Moving picos: instructions
2
+
3
+ Engine **A** is the club's mesh at `http://localhost:3001`. Engine **B** is the recipient at `http://localhost:3002`. The move target is **Gravel Bike #7** and its child, **Bike #7 Computer**. **Bike #3** and **Trail Ride Community** stay on A. See the [overview](/cookbook/moving_picos/) for the scenario.
4
+
5
+ ## Prepare
6
+
7
+ 1. From the repository root, start both engines and wait until they are healthy:
8
+
9
+ ```sh
10
+ docker compose -f docker-compose.cross-engine.yml up -d
11
+ ```
12
+
13
+ 2. Optional: start from fresh engine data, or run `cleanup` (Act 7) on the demo picos from a previous run.
14
+ 3. **Engine A, Manifold app pico:**
15
+ - Install `io.picolabs.club_gear_demo` from `file:///var/pico-demos/moving_picos/io.picolabs.club_gear_demo.krl`.
16
+ - Install `io.picolabs.portable_subtree` from the KRL directory on the Rulesets tab.
17
+ - Flush the current manifold-api rulesets: `manifold_pico`, `manifold_portable_thing`, `community`, and their dependencies. For example, `https://raw.githubusercontent.com/Picolab/manifold-api/refs/heads/main/io.picolabs.manifold_portable_thing.krl`.
18
+ 4. **Engine B, mesh root (owner):** install `io.picolabs.ride_coordinator_demo` from `file:///var/pico-demos/moving_picos/io.picolabs.ride_coordinator_demo.krl`. Optional, but needed for the Layer 2 part of the story.
19
+ 5. **Engine B, Manifold app pico:** flush the same manifold-api rulesets as on A.
20
+ 6. Sign in on both engines.
21
+ 7. Pick an export secret, such as `demo-secret-iiw`, and keep it handy.
22
+
23
+ ## Act 1: build the club on Engine A (2 to 3 minutes)
24
+
25
+ On **3001**, open Manifold and the pico with `club_gear_demo` installed.
26
+
27
+ 1. On the **Testing** tab, raise `club_gear_demo` `setup` with no attributes.
28
+ 2. Query `demoState` until it returns `ready: true` and `stage: "done"`.
29
+ 3. In Manifold, show the children: **Trail Ride Community**, **Gravel Bike #7**, and **Gravel Bike #3**. Expand Bike #7 to show **Bike #7 Computer**.
30
+ 4. Open **Gravel Bike #7**, then its **Relationships** tab. Expect `Manifold:Gravel Bike #7` and `Trail Ride Community:Gravel Bike #7`.
31
+ 5. From `demoState`, copy these for later:
32
+ - `bikePicoId` or `bikeEci`
33
+ - `bikeDid`
34
+ - `bikeManifoldKey` (the registry id), optional
35
+ - `communityPicoId` and the names, optional
36
+
37
+ The community and two bikes are on A. Only Bike #7 will move.
38
+
39
+ ## Act 2: Layer 2 coordinator on B, before the export (optional, 2 minutes)
40
+
41
+ Skip this act if you only want to show the Manifold import. Run it to show that a did:webvh Layer 2 relationship survives the move.
42
+
43
+ On **3002**, open the mesh root pico with `ride_coordinator_demo`.
44
+
45
+ 1. Query `demoState` and note `demoEci`, the demo channel. Use this ECI for the coordinator's events, not the root's default channel.
46
+ 2. On `demoEci`, raise `ride_coordinator_demo` `setup` with `bikeDid` set to A's `demoState().bikeDid` and `bikeName` set to `"Gravel Bike #7"`.
47
+ 3. Wait until `demoState().stage` is `connecting`. Setup stops there on purpose.
48
+
49
+ Back on **3001**, open **Gravel Bike #7** (its ECI is in A's `demoState().bikeEci`).
50
+
51
+ 4. Query `io.picolabs.subscription` `inbound` and find the pending `Ride Participants:Gravel Bike #7`.
52
+ 5. Raise `wrangler` `pending_subscription_approval` with `Id` set to that pending relationship's id.
53
+
54
+ On **3002**, on `demoEci`:
55
+
56
+ 6. Raise `ride_coordinator_demo` `sync`. It is an internal checkpoint and isn't listed on the Testing tab, so send it from the Events view on the demo channel.
57
+ 7. Optional: query `demoState` until `ready: true`.
58
+
59
+ Thing picos don't accept inbound relationships on their own: the owner approves on the bike. The introduction between engines uses did:webvh, not an ECI.
60
+
61
+ ## Act 3: export Bike #7 on A (1 to 2 minutes)
62
+
63
+ On **3001**, use the **Manifold app** channel. That is not the `club_gear_demo` pico unless Manifold lives there in your tree.
64
+
65
+ 1. Raise `manifold` `enable_portable_thing`, once per Manifold, if it isn't already enabled.
66
+ 2. Query `io.picolabs.manifold_portable_thing` `exportPortableThing` with:
67
+ - the first argument: `bikePicoId` or `bikeEci` from A's `demoState`
68
+ - the second argument: your secret
69
+ 3. Save the result's `blob`, `name`, and `donorQueryEci`. Copy the blob to a file or the clipboard.
70
+ 4. Optional: show Bike #7's did:webvh on A, unchanged before the import.
71
+
72
+ The export is a portable subtree, a snapshot of state and identity, not a copy of the database.
73
+
74
+ ## Act 4: import on Engine B (2 minutes)
75
+
76
+ On **3002**, open the **Manifold app** pico.
77
+
78
+ 1. Raise `manifold` `enable_portable_thing` if needed.
79
+ 2. Raise `manifold` `import_portable_thing` with:
80
+ - `blob`
81
+ - `secret`, the same one you exported with
82
+ - `name`, from the export result
83
+ - `donorQueryEci`, from the export result
84
+ - `renewIngress`: `true`
85
+ 3. Wait for `import_portable_thing_done`, or refresh the UI.
86
+ 4. Show that **Gravel Bike #7** is in B's Manifold (`getThings`, or the UI), with **Bike #7 Computer** under it.
87
+ 5. Open the imported bike's **Relationships** tab. It has a Manifold relationship. The community relationship may stay on A, depending on the export: say what the audience should see.
88
+
89
+ The did:webvh SCID is the same on B. B's Manifold has a new relationship to the bike.
90
+
91
+ ## Act 5: show it works across meshes (2 minutes)
92
+
93
+ If you ran Act 2:
94
+
95
+ 1. On **3002**, on `demoEci`, query `demoState`. The relationship should reach `done` without running `setup` again. If it doesn't, approve again and raise `sync` on B, and mention reconciliation.
96
+ 2. On B, open **Gravel Bike #7** → **Relationships**. The coordinator's DID relationship is there.
97
+
98
+ Either way:
99
+
100
+ 3. On **3001**, the community still has Bike #3. Bike #7 may still appear until Act 6.
101
+ 4. Optional: compare the `communities` query on Bike #7 on B with the community on A. The community stayed on A; the bike moved.
102
+
103
+ On B, local peer reconciliation updates other picos that still pointed at the bike's old ECI or DID.
104
+
105
+ ## Act 6: clean up on A (1 minute)
106
+
107
+ On **3001**, open the `club_gear_demo` pico.
108
+
109
+ 1. Raise `club_gear_demo` `release_bike7`. It removes the old bike from Manifold and from the community on A.
110
+ 2. Check that A's Manifold no longer lists Bike #7, and that Bike #3 and the community remain.
111
+
112
+ The old engine can let go of the moved bike. B is now authoritative for it.
113
+
114
+ ## Act 7: reset (optional)
115
+
116
+ - On A, raise `club_gear_demo` `cleanup`, then query `demoState` until `stage: "idle"`.
117
+ - On B, raise `ride_coordinator_demo` `cleanup` on `demoEci`.
118
+ - On B, remove the imported thing through Manifold if you want an empty Manifold for another run.
119
+
120
+ ## If something fails
121
+
122
+ | Symptom | Check |
123
+ |---------|-------|
124
+ | `setup` never reaches `ready` | A's Manifold logs and `demoState().stage`; flush `community` and `manifold_pico` |
125
+ | The export query is missing | Raise `enable_portable_thing` on A's Manifold; flush `manifold_portable_thing` |
126
+ | The import has no child | The secret and blob match; flush the portable rulesets on B; watch for `import_portable_thing_done` |
127
+ | The coordinator is stuck | Approve `pending_subscription_approval` on the **bike's** ECI, then raise `sync` on B's `demoEci` |
128
+ | `cleanup` fails | Flush `club_gear_demo` again; cleanup uses Manifold registry keys (`manifoldKey`) |
129
+
130
+ ## Talking points
131
+
132
+ Pick three to five:
133
+
134
+ 1. **Portable identity.** The did:webvh SCID survives. The host and path in the DID change with the engine's URL.
135
+ 2. **Subtree move.** An export and import blob, not a federation of whole engines.
136
+ 3. **Manifold.** The new owner's Manifold makes a new relationship to the bike, named Manifold on the Relationships tab.
137
+ 4. **Communities.** A community can stay on the old engine while its thing moves.
138
+ 5. **Layer 2.** The coordinator and bike relationship uses DIDs; the bike's owner approves it; it survives the move when made before the export.
139
+ 6. **Operators.** Passkeys, two engines on localhost, rulesets installed from manifold-api and this repository.
140
+ 7. **Autonomy.** Picos are persistent objects with relationships, not app session tokens.
141
+
142
+ The developer UI in this demo is for developers to observe and change picos. It is not an end-user interface.
143
+
144
+ ## Timing
145
+
146
+ | Run | Time |
147
+ |-----|------|
148
+ | The full story (Acts 1 to 6) | 10 to 14 minutes |
149
+ | Manifold only (skip Act 2 and the coordinator part of Act 5) | 7 to 9 minutes |
150
+ | Preparation and reset, off camera | 5 more minutes |
@@ -0,0 +1,19 @@
1
+ # Score tracker
2
+
3
+ A pico that runs a contest. Contestants register with a first and last name and get a participant id. Then they send points with a description of what they are for, and a leaderboard ranks everyone by total.
4
+
5
+ The demo is also about **channel policy**. The pico's app channel allows only `score` events and the leaderboard's queries. A contestant holding that channel can register and add points, but cannot create child picos, install rulesets, or raise any other event. Hand out the channel, not the pico.
6
+
7
+ To run it, follow the [instructions](/cookbook/score_tracker/instructions).
8
+
9
+ ## The rulesets
10
+
11
+ | Ruleset | File | What it shows |
12
+ |---------|------|---------------|
13
+ | Score tracker | [`com.example.score_tracker.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/score_tracker/com.example.score_tracker.krl) | Entity variables keyed by participant id, attribute regexes in `select when`, directives that return the new id, a sorted `currentRanks` query, and a leaderboard `@view` |
14
+ | Score tracker bootstrap | [`com.example.score_tracker.bootstrap.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/score_tracker/com.example.score_tracker.bootstrap.krl) | Sets up the demo on a new pico and seeds Ada Lovelace, Grace Hopper, and Alan Turing with points. The developer UI's **Try It!** tab runs it |
15
+
16
+ ## What you need
17
+
18
+ - A running pico engine (1.9.4 or later for the page, which uses the shared `PicoTheme` component).
19
+ - `io.picolabs.xmlui` on the pico for the page. The bootstrap installs it.
@@ -0,0 +1,73 @@
1
+ # Score tracker: instructions
2
+
3
+ These steps use the developer UI of a running engine at `http://localhost:3000`. Replace that with your engine's URL. See the [overview](/cookbook/score_tracker/) for what the demo shows.
4
+
5
+ ## The quick way: Try It!
6
+
7
+ On the root pico in the developer UI, open the **Try It!** tab, click **Score tracker**, then **Run in a new child pico**. The bootstrap installs the ruleset and seeds three contestants: Ada Lovelace (45 points), Grace Hopper (40), and Alan Turing (25). When it shows **ready**, open **Leaderboard**.
8
+
9
+ ## By hand
10
+
11
+ 1. Create a child pico and open its **Rulesets** tab.
12
+ 2. Install `io.picolabs.xmlui` from the engine: `http://localhost:3000/krl/io.picolabs.xmlui.krl`.
13
+ 3. Install the score tracker: `http://localhost:3000/krl/demos/score_tracker/com.example.score_tracker.krl`.
14
+ 4. Installing it creates a channel tagged `score_tracker, app`. Click **View** next to `com.example.score_tracker` and open it on that channel. The leaderboard is empty until someone registers.
15
+
16
+ ## Try it
17
+
18
+ - Register with your name. The subtitle changes to "You are …", and the form becomes **Add points**. The page keeps your participant id in the browser tab's session storage.
19
+ - Add points a few times and watch your rank change. Negative points work too.
20
+ - Open the leaderboard in a second browser window and register as someone else. Both windows share one pico.
21
+ - In another window, register under a name that is already on the board. You get that contestant's id back, not a second entry.
22
+ - Send events from a terminal on the app channel. Replace `<eci>` with its id (shown in the page URL after `/ui/`):
23
+
24
+ ```sh
25
+ curl "http://localhost:3000/sky/event/<eci>/demo/score/new_participant?first=Katherine&last=Johnson"
26
+ curl "http://localhost:3000/sky/cloud/<eci>/com.example.score_tracker/currentRanks"
27
+ ```
28
+
29
+ - Try something the channel does not allow:
30
+
31
+ ```sh
32
+ curl "http://localhost:3000/sky/event/<eci>/demo/wrangler/new_child_request?name=intruder"
33
+ ```
34
+
35
+ The engine answers `{"error":"Error: Not allowed by channel policy"}`.
36
+
37
+ ## How it works
38
+
39
+ Each contestant is one entry in the entity variable `ent:participants`, keyed by participant id. `new_participant` requires both names, through attribute regexes in `select when`. It returns the id in a directive, so whoever registered learns their id from the response:
40
+
41
+ ```krl
42
+ rule new_participant {
43
+ select when score new_participant
44
+ first re#(.+)#
45
+ last re#(.+)#
46
+ setting(first, last)
47
+ pre {
48
+ existing = findByName(first, last)
49
+ pid = existing => existing{"pid"} | event:attr("pid") || random:uuid()
50
+ }
51
+ send_directive("registered", {"pid": pid, "name": first + " " + last, "new": existing => false | true})
52
+ always {
53
+ ent:participants{pid} := {"pid": pid, "first": first, "last": last, "points": []}
54
+ if not existing
55
+ }
56
+ }
57
+ ```
58
+
59
+ `new_points` adds an entry to that participant's list with a path assignment, `ent:participants{[pid, "points"]} := …`. It does nothing (and logs a warning) when the id is unknown.
60
+
61
+ `currentRanks` is a function the ruleset `shares`. It totals each contestant's points, sorts with `<=>`, and adds a rank. The leaderboard page reads it with a `DataSource`. After registering or adding points, the page refetches it.
62
+
63
+ The policy is set on install by `ui:create_app_channel(channel_tags, ["score"], ["currentRanks", "participant", "leaderboard"], meta:rid)`. Its event policy allows the `score` domain, and its query policy allows those three functions. That policy, not anything in the page, is what keeps contestants out of the rest of the pico.
64
+
65
+ The bootstrap registers the seed contestants with one `foreach` rule. When the last one is done (`on final`), it raises an event that starts the rule adding the seed points.
66
+
67
+ ## Change it and watch
68
+
69
+ The **Try It!** window lists each file with its path on disk. Edit `com.example.score_tracker.krl` there, click **Flush**, and reload the leaderboard.
70
+
71
+ - Change `initialValue="10"` on the **Points** field to `100`.
72
+ - Add a column. `currentRanks` already returns `pid`, so add `<Column bindTo="pid" header="Id" />` to the table.
73
+ - Cap a single award: in `new_points`, make the condition `if p && points.as("Number") <= 50 then …`. Larger awards are skipped, so change the `else` warning to say why.
@@ -0,0 +1,25 @@
1
+ # Configuration and secrets
2
+
3
+ Rulesets that use outside services need secrets: API keys, passwords, webhook URLs with tokens in them. Those don't belong in KRL source, which ends up in repositories and on web servers. There are two ways to get a secret into a ruleset instead:
4
+
5
+ - **Install configuration.** `wrangler:install_ruleset_request` takes a `config` map, and the ruleset reads it as `meta:rulesetConfig`.
6
+ - **An event.** A rule selects an event the operator sends, and keeps the secret in an entity variable.
7
+
8
+ Either way, the secret is not as hidden as it might seem. This demo shows both ways and where the secret can still be seen.
9
+
10
+ The demo has two picos. The **hook service** stands in for an outside service, such as a chat app, that accepts posts at a webhook URL with a token in it. It gets its token from install configuration. The **notifier** posts messages to that webhook. It gets the URL in an event, and until then the rule that posts is not selected, so it can be installed on a working pico and does nothing until it is configured.
11
+
12
+ To run it, follow the [instructions](/cookbook/secrets/instructions).
13
+
14
+ ## The rulesets
15
+
16
+ | Ruleset | File | What it shows |
17
+ |---------|------|---------------|
18
+ | Notifier | [`com.example.notifier.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/secrets/com.example.notifier.krl) | A secret from an event, kept in an entity variable; a rule guarded by `where ent:webhook_url`; `http:post`; an operator event in its own domain, so the app channel can't reach it; a status that hides the token |
19
+ | Hook service | [`com.example.hook_service.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/secrets/com.example.hook_service.krl) | A secret from `meta:rulesetConfig`, a channel that takes only `hook:post`, and rules that accept or refuse a post by its token |
20
+ | Bootstrap | [`com.example.notifier.bootstrap.krl`](https://github.com/Picolab/pico-engine/blob/master/demos/secrets/com.example.notifier.bootstrap.krl) | Installs the notifier, creates the hook service with a random token in its configuration, and sends messages before and after configuring the notifier. The developer UI's **Try It!** tab runs it |
21
+
22
+ ## What you need
23
+
24
+ - A running pico engine (1.9.4 or later for the pages, which use the shared `PicoTheme` component).
25
+ - `io.picolabs.xmlui` on both picos for the pages. The bootstrap installs it.
@@ -0,0 +1,98 @@
1
+ # Configuration and secrets: instructions
2
+
3
+ These steps use the developer UI of a running engine at `http://localhost:3000`. Replace that with your engine's URL. See the [overview](/cookbook/secrets/) for what the demo shows.
4
+
5
+ ## The quick way: Try It!
6
+
7
+ On the root pico in the developer UI, open the **Try It!** tab, click **Configuration and secrets**, then **Run in a new child pico**. When it shows **ready**, open **Notifier** and **Hook service inbox**.
8
+
9
+ - The Notifier page says where it posts, with the token hidden. One message was not sent, because it came before the webhook was set. One was delivered, with HTTP status 200.
10
+ - The inbox has the delivered message, and no refused posts.
11
+
12
+ ## By hand
13
+
14
+ 1. Create a pico for the hook service. On its **Rulesets** tab, install `http://localhost:3000/krl/io.picolabs.xmlui.krl`. Then install `http://localhost:3000/krl/demos/secrets/com.example.hook_service.krl` with a configuration, such as `{"token": "pick-a-long-random-string"}` (the **Rulesets** tab has a box for it).
15
+ 2. The hook service sends its webhook URL to its parent pico as `hook_service:webhook_url_issued`. Find it in the parent's **Logging** tab, or build it yourself: `http://localhost:3000/sky/event/<eci>/webhook/hook/post?token=<token>`, where `<eci>` is the hook service's channel tagged `hook_service, webhook`.
16
+ 3. Create a pico for the notifier and install `io.picolabs.xmlui` and `http://localhost:3000/krl/demos/secrets/com.example.notifier.krl` on it. Open its page on the `notifier, app` channel and send a message: it is not sent.
17
+ 4. On the notifier's **Testing** tab, raise `notifier_config` `new_webhook` with `webhook_url` set to the URL from step 2. Send a message from the page again: it is delivered.
18
+
19
+ ## Try it
20
+
21
+ - On the Notifier page, send a few messages. Each appears in the inbox and in the Notifier's list with status 200.
22
+ - Post to the webhook with the wrong token. Take the URL the Notifier page shows, replace `(hidden)` with anything, and `curl -X POST` it. The hook service answers with a `refused` directive, and its **Refused** count goes up.
23
+ - On the Notifier's **Testing** tab, raise `notifier_config` `webhook_forgotten`. Messages from the page are counted as not sent again.
24
+
25
+ ## Where the secrets are visible
26
+
27
+ Neither secret is in a ruleset file. That is the point of both methods. But both can still be seen, by anyone who can see the developer UI or the engine's files:
28
+
29
+ | Where | What shows |
30
+ |-------|------------|
31
+ | **Rulesets** tab, on the hook service | The install configuration, with the token, for as long as the ruleset is installed. `wrangler:rulesetConfig` returns it too, to anyone with a channel that allows that query |
32
+ | **Logging** tab | Every event's attributes: the install request with its `config`, the `webhook_url_issued` and `new_webhook` events with the URL, and every `hook:post`, because the token is in the URL |
33
+ | `pico-engine.log` in the engine's home directory | The same events, until the log files rotate away |
34
+ | The pico's database | The entity variables: the notifier's `ent:webhook_url` |
35
+
36
+ The **Testing** tab hides the values of attributes named like `password`, `secret`, `token`, or `apikey` in its own saved history. The engine's logs don't.
37
+
38
+ What the rulesets do to help:
39
+
40
+ - The notifier shares `status()`, which hides the token, and never shares the URL itself.
41
+ - `notifier_config:new_webhook` is in its own domain, and the app channel allows only `notifier` events. The page can send messages but can't change where they go. Put operator events in a domain the app channel doesn't allow.
42
+ - The rule that posts is selected only `where ent:webhook_url`, so the notifier is idle, not failing, until it has a URL.
43
+
44
+ ## How it works
45
+
46
+ **From install configuration.** The hook service reads its token from the configuration it was installed with:
47
+
48
+ ```krl
49
+ token = function() {
50
+ meta:rulesetConfig{"token"}
51
+ }
52
+ ```
53
+
54
+ The bootstrap installs it with `"config": {"token": random:uuid()}`, so each run gets a new token.
55
+
56
+ **From an event.** The notifier keeps the URL it is sent:
57
+
58
+ ```krl
59
+ rule set_webhook {
60
+ select when notifier_config new_webhook
61
+ webhook_url re#^(https?://.+)$#
62
+ setting(url)
63
+ always {
64
+ ent:webhook_url := url
65
+ ent:configured_at := time:now()
66
+ }
67
+ }
68
+ ```
69
+
70
+ **Idle until configured.** Two rules select `notifier:message`, and their `where` clauses decide which one runs:
71
+
72
+ ```krl
73
+ rule notify {
74
+ select when notifier message where ent:webhook_url
75
+ pre {
76
+ text = event:attr("text") || "Hello from a pico"
77
+ }
78
+ http:post(ent:webhook_url, json = {"text": text}) setting(response)
79
+ fired {
80
+ ent:deliveries := deliveries().append({"text": text, "status": response{"status_code"}, "time": time:now()})
81
+ }
82
+ }
83
+
84
+ rule not_configured {
85
+ select when notifier message where not ent:webhook_url
86
+ ...
87
+ }
88
+ ```
89
+
90
+ **Accepting or refusing.** The hook service's webhook channel allows only `hook:post`. Its `receive` rule selects posts `where event:attr("token") == token()`, and `refuse` selects the rest.
91
+
92
+ ## Change it and watch
93
+
94
+ The **Try It!** window lists each file with its path on disk. Edit a file there, click **Flush**, and use the pages.
95
+
96
+ - Show less: in `com.example.notifier.krl`, make `masked` hide everything after the host, not just the token.
97
+ - Use configuration for the notifier too: read the URL from `meta:rulesetConfig{"webhook_url"}` when `ent:webhook_url` is not set, and reinstall it with a configuration on the **Rulesets** tab. Then look at where the URL shows.
98
+ - Rotate the token: on the hook service's **Rulesets** tab, install `com.example.hook_service` again from the same URL with a new configuration. Messages from the notifier now raise the inbox's **Refused** count. The Notifier still records status 200, because the hook service answers every post and says "refused" in a directive. Make `notify` record the directive's name, or send the notifier the new URL with `notifier_config` `new_webhook`.