Skip to content

Commit d791baa

Browse files
authored
Merge pull request #117 from kinode-dao/develop
v0.10.0
2 parents 746a1f5 + 9479e1a commit d791baa

File tree

16 files changed

+1606
-653
lines changed

16 files changed

+1606
-653
lines changed

Cargo.lock

Lines changed: 867 additions & 384 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
[package]
22
name = "kinode_process_lib"
3-
description = "A library for writing Kinode processes in Rust."
4-
version = "0.9.7"
3+
authors = ["Sybil Technologies AG"]
4+
version = "0.10.0"
55
edition = "2021"
6-
license-file = "LICENSE"
6+
description = "A library for writing Kinode processes in Rust."
77
homepage = "https://kinode.org"
88
repository = "https://github.com/kinode-dao/process_lib"
9+
license = "Apache-2.0"
910

1011
[features]
1112
logging = ["dep:color-eyre", "dep:tracing", "dep:tracing-error", "dep:tracing-subscriber"]
1213

1314
[dependencies]
14-
alloy-primitives = "0.7.6"
15-
alloy-sol-macro = "0.7.6"
16-
alloy-sol-types = "0.7.6"
17-
alloy = { version = "0.1.3", features = [
15+
alloy-primitives = "0.8.15"
16+
alloy-sol-macro = "0.8.15"
17+
alloy-sol-types = "0.8.15"
18+
alloy = { version = "0.8.1", features = [
1819
"json-rpc",
1920
"rpc-types",
2021
] }
@@ -32,4 +33,4 @@ tracing = { version = "0.1", optional = true }
3233
tracing-error = { version = "0.2", optional = true }
3334
tracing-subscriber = { version = "0.3", features = ["env-filter", "json", "std"], optional = true }
3435
url = "2.4.1"
35-
wit-bindgen = "0.24.0"
36+
wit-bindgen = "0.36.0"

kinode-wit/kinode.wit

Lines changed: 75 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
//
2-
// kinode.wit, copied from https://github.com/kinode-dao/kinode-wit/tree/v0.8
2+
// kinode.wit, copied from https://github.com/kinode-dao/kinode-wit
3+
// https://raw.githubusercontent.com/kinode-dao/kinode-wit/v1.0.0/kinode.wit
34
//
45

5-
package kinode:process@0.8.0;
6+
package kinode:process@1.0.0;
67

78
interface standard {
8-
//
9-
// System types:
10-
//
119

12-
// JSON is passed over WASM boundary as a string.
10+
// ˗ˏˋ ♡ ˎˊ˗
11+
// System Types
12+
// ˗ˏˋ ♡ ˎˊ˗
13+
14+
/// JSON is passed over Wasm boundary as a string.
1315
type json = string;
1416

17+
/// In types passed from kernel, node-id will be a valid Kimap entry.
1518
type node-id = string;
1619

17-
// Context, like a message body, is a protocol-defined serialized byte
18-
// array. It is used when building a Request to save information that
19-
// will not be part of a Response, in order to more easily handle
20-
// ("contextualize") that Response.
20+
/// Context, like a message body, is a protocol-defined serialized byte
21+
/// array. It is used when building a Request to save information that
22+
/// will not be part of a Response, in order to more easily handle
23+
/// ("contextualize") that Response.
2124
type context = list<u8>;
2225

2326
record process-id {
@@ -45,7 +48,8 @@ interface standard {
4548
// set in order to inherit lazy-load-blob from parent message, and if
4649
// expects-response is none, direct response to source of parent.
4750
// also carries forward certain aspects of parent message in kernel,
48-
// see documentation for formal spec and examples.
51+
// see documentation for formal spec and examples:
52+
// https://docs.rs/kinode_process_lib/latest/kinode_process_lib/struct.Request.html
4953
inherit: bool,
5054
// if some, request expects a response in the given number of seconds
5155
expects-response: option<u64>,
@@ -63,10 +67,10 @@ interface standard {
6367
// to grab lazy-load-blob, use get_blob()
6468
}
6569

66-
// A message can be a request or a response. within a response, there is
67-
// a result which surfaces any error that happened because of a request.
68-
// A successful response will contain the context of the request it
69-
// matches, if any was set.
70+
/// A message can be a request or a response. Within a response, there is
71+
/// a result which surfaces any error that happened because of a request.
72+
/// A successful response will contain the context of the request it
73+
/// matches, if any was set.
7074
variant message {
7175
request(request),
7276
response(tuple<response, option<context>>),
@@ -77,21 +81,24 @@ interface standard {
7781
params: json,
7882
}
7983

80-
// On-exit is a setting that determines what happens when a process
81-
// panics, completes, or otherwise "ends". NOTE: requests should have
82-
// expects-response set to false, will always be set to that by kernel.
84+
/// On-exit is a setting that determines what happens when a process
85+
/// panics, completes, or otherwise "ends".
86+
/// NOTE: requests will always have expects-response set to false by kernel.
8387
variant on-exit {
8488
none,
8589
restart,
8690
requests(list<tuple<address, request, option<lazy-load-blob>>>),
8791
}
8892

89-
// Network errors come from trying to send a message to another node.
90-
// A message can fail by timing out, or by the node being entirely
91-
// unreachable (offline). In either case, the message is not delivered
92-
// and the process that sent it receives that message along with any
93-
// assigned context and/or lazy-load-blob, and is free to handle it as it
94-
// sees fit.
93+
/// Send errors come from trying to send a message to another process,
94+
/// either locally or on another node.
95+
/// A message can fail by timing out, or by the node being entirely
96+
/// unreachable (offline or can't be found in PKI). In either case,
97+
/// the message is not delivered and the process that sent it receives
98+
/// that message back along with any assigned context and/or lazy-load-blob,
99+
/// and is free to handle it as it sees fit.
100+
/// In the local case, only timeout errors are possible and also cover the case
101+
/// in which a process is not running or does not exist.
95102
record send-error {
96103
kind: send-error-kind,
97104
target: address,
@@ -109,84 +116,101 @@ interface standard {
109116
no-file-at-path,
110117
}
111118

112-
//
113-
// System utils:
114-
//
119+
// ˗ˏˋ ♡ ˎˊ˗
120+
// System Utils
121+
// ˗ˏˋ ♡ ˎˊ˗
115122

123+
/// Prints to the terminal at a given verbosity level.
124+
/// Higher verbosity levels print more information.
125+
/// Level 0 is always printed -- use sparingly.
116126
print-to-terminal: func(verbosity: u8, message: string);
117127

118-
//
119-
// Process management:
120-
//
128+
/// Returns the address of the process.
129+
our: func() -> address;
121130

122-
set-on-exit: func(on-exit: on-exit);
131+
// ˗ˏˋ ♡ ˎˊ˗
132+
// Process Management
133+
// ˗ˏˋ ♡ ˎˊ˗
123134

124135
get-on-exit: func() -> on-exit;
125136

137+
set-on-exit: func(on-exit: on-exit);
138+
126139
get-state: func() -> option<list<u8>>;
127140

128141
set-state: func(bytes: list<u8>);
129142

130143
clear-state: func();
131144

132145
spawn: func(
146+
// name is optional. if not provided, name will be a random u64.
133147
name: option<string>,
134-
wasm-path: string, // must be located within package's drive
148+
// wasm-path must be located within package's drive
149+
wasm-path: string,
135150
on-exit: on-exit,
151+
// requested capabilities must be owned by the caller
136152
request-capabilities: list<capability>,
137-
// note that we are restricting granting to just messaging the
138-
// newly spawned process
139-
grant-capabilities: list<process-id>,
153+
// granted capabilities will be generated by the child process
154+
// and handed out to the indicated process-id.
155+
grant-capabilities: list<tuple<process-id, json>>,
140156
public: bool
141157
) -> result<process-id, spawn-error>;
142158

143-
//
144-
// Capabilities management:
145-
//
159+
// ˗ˏˋ ♡ ˎˊ˗
160+
// Capabilities Management
161+
// ˗ˏˋ ♡ ˎˊ˗
146162

147-
// Saves the capabilities to persisted process state.
163+
/// Saves the capabilities to persisted process state.
148164
save-capabilities: func(caps: list<capability>);
149165

150-
// Deletes the capabilities from persisted process state.
166+
/// Deletes the capabilities from persisted process state.
151167
drop-capabilities: func(caps: list<capability>);
152168

153-
// Gets all capabilities from persisted process state.
169+
/// Gets all capabilities from persisted process state.
154170
our-capabilities: func() -> list<capability>;
155171

156-
//
157-
// Message I/O:
158-
//
172+
// ˗ˏˋ ♡ ˎˊ˗
173+
// Message I/O
174+
// ˗ˏˋ ♡ ˎˊ˗
159175

160-
// Ingest next message when it arrives along with its source.
161-
// Almost all long-running processes will call this in a loop.
176+
/// Ingest next message when it arrives along with its source.
177+
/// Almost all long-running processes will call this in a loop.
162178
receive: func() ->
163179
result<tuple<address, message>, tuple<send-error, option<context>>>;
164180

165-
// Gets lazy-load-blob, if any, of the message we most recently received.
181+
/// Returns whether or not the current message has a blob.
182+
has-blob: func() -> bool;
183+
184+
/// Returns the blob of the current message, if any.
166185
get-blob: func() -> option<lazy-load-blob>;
167186

168-
// Send message(s) to target(s).
187+
/// Returns the last blob this process received.
188+
last-blob: func() -> option<lazy-load-blob>;
189+
190+
/// Send request to target.
169191
send-request: func(
170192
target: address,
171193
request: request,
172194
context: option<context>,
173195
lazy-load-blob: option<lazy-load-blob>
174196
);
175197

198+
/// Send requests to targets.
176199
send-requests: func(
177200
requests: list<tuple<address,
178201
request,
179202
option<context>,
180203
option<lazy-load-blob>>>
181204
);
182205

206+
/// Send response to the request currently being handled.
183207
send-response: func(
184208
response: response,
185209
lazy-load-blob: option<lazy-load-blob>
186210
);
187211

188-
// Send a single request, then block (internally) until its response. The
189-
// type returned is Message but will always contain Response.
212+
/// Send a single request, then block (internally) until its response. The
213+
/// type returned is Message but will always contain Response.
190214
send-and-await-response: func(
191215
target: address,
192216
request: request,
@@ -198,7 +222,7 @@ world lib {
198222
import standard;
199223
}
200224

201-
world process-v0 {
225+
world process-v1 {
202226
include lib;
203227

204228
export init: func(our: string);

0 commit comments

Comments
 (0)