kobako 0.30.0 → 0.31.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 (266) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/CHANGELOG.md +335 -0
  4. data/Cargo.lock +469 -11
  5. data/README.md +43 -3
  6. data/ROADMAP.md +1 -1
  7. data/crates/kobako-runtime/CHANGELOG.md +219 -0
  8. data/crates/kobako-runtime/Cargo.toml +51 -3
  9. data/crates/kobako-runtime/README.md +7 -4
  10. data/crates/kobako-runtime/src/cred.rs +124 -0
  11. data/crates/kobako-runtime/src/dispatch.rs +4 -5
  12. data/crates/kobako-runtime/src/endpoint/buffer.rs +153 -44
  13. data/crates/kobako-runtime/src/endpoint/dispatch.rs +80 -41
  14. data/crates/kobako-runtime/src/endpoint/invoke.rs +23 -36
  15. data/crates/kobako-runtime/src/endpoint.rs +137 -36
  16. data/crates/kobako-runtime/src/errno.rs +391 -0
  17. data/crates/kobako-runtime/src/error.rs +31 -10
  18. data/crates/kobako-runtime/src/filesystem/anon_inodes.rs +52 -0
  19. data/crates/kobako-runtime/src/filesystem/bind/lookup.rs +52 -14
  20. data/crates/kobako-runtime/src/filesystem/bind/walk.rs +19 -20
  21. data/crates/kobako-runtime/src/filesystem/bind.rs +437 -245
  22. data/crates/kobako-runtime/src/filesystem/overlay/file.rs +6 -6
  23. data/crates/kobako-runtime/src/filesystem/overlay/path.rs +43 -65
  24. data/crates/kobako-runtime/src/filesystem/overlay/stack/copy_up.rs +9 -16
  25. data/crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs +47 -72
  26. data/crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs +12 -12
  27. data/crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs +4 -7
  28. data/crates/kobako-runtime/src/filesystem/overlay/stack.rs +121 -37
  29. data/crates/kobako-runtime/src/filesystem/overlay.rs +302 -343
  30. data/crates/kobako-runtime/src/filesystem/pipe.rs +12 -9
  31. data/crates/kobako-runtime/src/filesystem/rdir.rs +15 -32
  32. data/crates/kobako-runtime/src/filesystem/tmpfs/seed.rs +32 -0
  33. data/crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs +3 -3
  34. data/crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs +57 -35
  35. data/crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs +2 -2
  36. data/crates/kobako-runtime/src/filesystem/tmpfs.rs +172 -160
  37. data/crates/kobako-runtime/src/filesystem/wrap.rs +36 -52
  38. data/crates/kobako-runtime/src/filesystem.rs +6 -3
  39. data/crates/kobako-runtime/src/fork.rs +96 -0
  40. data/crates/kobako-runtime/src/grant.rs +3 -0
  41. data/crates/kobako-runtime/src/hashtable.rs +4 -2
  42. data/crates/kobako-runtime/src/lib.rs +18 -7
  43. data/crates/kobako-runtime/src/limits.rs +195 -0
  44. data/crates/kobako-runtime/src/locking.rs +10 -0
  45. data/crates/kobako-runtime/src/memcg.rs +383 -0
  46. data/crates/kobako-runtime/src/mount.rs +67 -9
  47. data/crates/kobako-runtime/src/net/backends.rs +43 -0
  48. data/crates/kobako-runtime/src/net/connections.rs +179 -0
  49. data/crates/kobako-runtime/src/net/credential.rs +125 -0
  50. data/crates/kobako-runtime/src/net/egress.rs +160 -0
  51. data/crates/kobako-runtime/src/net/family.rs +181 -0
  52. data/crates/kobako-runtime/src/net/http.rs +2733 -0
  53. data/crates/kobako-runtime/src/net/lookup.rs +285 -0
  54. data/crates/kobako-runtime/src/net/mock.rs +251 -0
  55. data/crates/kobako-runtime/src/net/namespace.rs +1366 -0
  56. data/crates/kobako-runtime/src/net/reactor.rs +531 -0
  57. data/crates/kobako-runtime/src/net/resolv/darwin.rs +275 -0
  58. data/crates/kobako-runtime/src/net/resolv/stub/tests.rs +469 -0
  59. data/crates/kobako-runtime/src/net/resolv/stub.rs +536 -0
  60. data/crates/kobako-runtime/src/net/resolv/windows.rs +248 -0
  61. data/crates/kobako-runtime/src/net/resolv.rs +227 -0
  62. data/crates/kobako-runtime/src/net/socket.rs +870 -0
  63. data/crates/kobako-runtime/src/net/tcp.rs +1588 -0
  64. data/crates/kobako-runtime/src/net/tls.rs +58 -0
  65. data/crates/kobako-runtime/src/net/transport.rs +279 -0
  66. data/crates/kobako-runtime/src/net/udp.rs +1003 -0
  67. data/crates/kobako-runtime/src/net.rs +42 -0
  68. data/crates/kobako-runtime/src/network/builder.rs +177 -0
  69. data/crates/kobako-runtime/src/network/ruleset.rs +777 -0
  70. data/crates/kobako-runtime/src/network.rs +551 -0
  71. data/crates/kobako-runtime/src/policy.rs +16 -0
  72. data/crates/kobako-runtime/src/profile.rs +29 -144
  73. data/crates/kobako-runtime/src/runtime.rs +3 -5
  74. data/crates/kobako-runtime/src/sched.rs +130 -29
  75. data/crates/kobako-runtime/src/security/entry_policy.rs +22 -0
  76. data/crates/kobako-runtime/src/{vfs/cred.rs → security/hooks.rs} +52 -144
  77. data/crates/kobako-runtime/src/security/mount_policy.rs +158 -0
  78. data/crates/kobako-runtime/src/security.rs +101 -196
  79. data/crates/kobako-runtime/src/snapshot.rs +121 -2
  80. data/crates/kobako-runtime/src/vfs/attr.rs +5 -5
  81. data/crates/kobako-runtime/src/vfs/dentry.rs +143 -89
  82. data/crates/kobako-runtime/src/vfs/file.rs +199 -203
  83. data/crates/kobako-runtime/src/vfs/inode.rs +41 -45
  84. data/crates/kobako-runtime/src/vfs/kern_path.rs +38 -42
  85. data/crates/kobako-runtime/src/vfs/mount.rs +10 -9
  86. data/crates/kobako-runtime/src/vfs/namei.rs +829 -700
  87. data/crates/kobako-runtime/src/vfs/namespace.rs +162 -0
  88. data/crates/kobako-runtime/src/vfs/open_files.rs +69 -0
  89. data/crates/kobako-runtime/src/vfs/openat2.rs +3 -3
  90. data/crates/kobako-runtime/src/vfs/path.rs +6 -6
  91. data/crates/kobako-runtime/src/vfs/readdir.rs +6 -6
  92. data/crates/kobako-runtime/src/vfs/stat.rs +159 -23
  93. data/crates/kobako-runtime/src/vfs/super_block.rs +18 -14
  94. data/crates/kobako-runtime/src/vfs/utimes.rs +37 -27
  95. data/crates/kobako-runtime/src/vfs.rs +9 -6
  96. data/crates/kobako-runtime/src/wait.rs +356 -0
  97. data/crates/kobako-transport/CHANGELOG.md +31 -0
  98. data/crates/kobako-transport/Cargo.toml +1 -1
  99. data/crates/kobako-transport/README.md +3 -4
  100. data/crates/kobako-transport/src/abi.rs +78 -72
  101. data/crates/kobako-transport/src/envelope/bytes.rs +17 -6
  102. data/crates/kobako-transport/src/envelope/call.rs +32 -4
  103. data/crates/kobako-transport/src/envelope/error_record.rs +21 -0
  104. data/crates/kobako-transport/src/envelope/name.rs +99 -0
  105. data/crates/kobako-transport/src/envelope/outcome.rs +9 -9
  106. data/crates/kobako-transport/src/envelope/preamble.rs +24 -21
  107. data/crates/kobako-transport/src/envelope/reply.rs +27 -27
  108. data/crates/kobako-transport/src/envelope/unsupported.rs +10 -10
  109. data/crates/kobako-transport/src/envelope.rs +13 -8
  110. data/crates/kobako-wasmtime/CHANGELOG.md +161 -0
  111. data/crates/kobako-wasmtime/Cargo.toml +26 -7
  112. data/crates/kobako-wasmtime/README.md +3 -2
  113. data/crates/kobako-wasmtime/build/preview2.rs +1339 -0
  114. data/crates/kobako-wasmtime/build.rs +16 -0
  115. data/crates/kobako-wasmtime/src/abi.rs +17 -37
  116. data/crates/kobako-wasmtime/src/ambient.rs +33 -18
  117. data/crates/kobako-wasmtime/src/cache.rs +23 -15
  118. data/crates/kobako-wasmtime/src/config.rs +52 -68
  119. data/crates/kobako-wasmtime/src/driver.rs +48 -63
  120. data/crates/kobako-wasmtime/src/exports.rs +143 -17
  121. data/crates/kobako-wasmtime/src/guest.rs +12 -6
  122. data/crates/kobako-wasmtime/src/guest_binary.rs +14 -0
  123. data/crates/kobako-wasmtime/src/imports.rs +42 -18
  124. data/crates/kobako-wasmtime/src/instance_pre.rs +4 -4
  125. data/crates/kobako-wasmtime/src/invocation.rs +74 -12
  126. data/crates/kobako-wasmtime/src/lib.rs +5 -3
  127. data/crates/kobako-wasmtime/src/limiter.rs +70 -5
  128. data/crates/kobako-wasmtime/src/preview1/descriptors.rs +309 -0
  129. data/crates/kobako-wasmtime/src/preview1/differential/mount.rs +5 -15
  130. data/crates/kobako-wasmtime/src/preview1/differential.rs +27 -31
  131. data/crates/kobako-wasmtime/src/preview1/errno.rs +55 -66
  132. data/crates/kobako-wasmtime/src/preview1/fd.rs +327 -296
  133. data/crates/kobako-wasmtime/src/preview1/memory.rs +21 -12
  134. data/crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs +34 -53
  135. data/crates/kobako-wasmtime/src/preview1/mount_view.rs +231 -217
  136. data/crates/kobako-wasmtime/src/preview1/path.rs +56 -121
  137. data/crates/kobako-wasmtime/src/preview1/poll.rs +244 -120
  138. data/crates/kobako-wasmtime/src/preview1/sock.rs +10 -8
  139. data/crates/kobako-wasmtime/src/preview1/testsuite.rs +5 -15
  140. data/crates/kobako-wasmtime/src/preview1.rs +46 -42
  141. data/crates/kobako-wasmtime/src/preview2/abi.rs +227 -0
  142. data/crates/kobako-wasmtime/src/preview2/error.rs +118 -0
  143. data/crates/kobako-wasmtime/src/preview2/filesystem.rs +122 -0
  144. data/crates/kobako-wasmtime/src/preview2/host.rs +3959 -0
  145. data/crates/kobako-wasmtime/src/preview2/http.rs +1503 -0
  146. data/crates/kobako-wasmtime/src/preview2/io.rs +315 -0
  147. data/crates/kobako-wasmtime/src/preview2/sockets.rs +379 -0
  148. data/crates/kobako-wasmtime/src/preview2/table.rs +305 -0
  149. data/crates/kobako-wasmtime/src/preview2.rs +57 -0
  150. data/crates/kobako-wasmtime/src/trap.rs +24 -9
  151. data/crates/kobako-wasmtime/src/wasi.rs +210 -81
  152. data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
  153. data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
  154. data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
  155. data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
  156. data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
  157. data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
  158. data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
  159. data/data/kobako.wasm +0 -0
  160. data/ext/kobako/Cargo.toml +1 -1
  161. data/ext/kobako/src/{runtime/errors.rs → errors.rs} +34 -26
  162. data/ext/kobako/src/{runtime/escape.rs → escape.rs} +42 -11
  163. data/ext/kobako/src/{runtime/filesystem → filesystem}/grants.rs +30 -26
  164. data/ext/kobako/src/{runtime/filesystem → filesystem}/ruby.rs +149 -168
  165. data/ext/kobako/src/{runtime/filesystem.rs → filesystem.rs} +24 -15
  166. data/ext/kobako/src/gvl.rs +306 -0
  167. data/ext/kobako/src/lib.rs +64 -3
  168. data/ext/kobako/src/network/mock.rs +187 -0
  169. data/ext/kobako/src/network.rs +591 -0
  170. data/ext/kobako/src/runtime/bridge.rs +30 -29
  171. data/ext/kobako/src/runtime/snapshot.rs +4 -4
  172. data/ext/kobako/src/runtime.rs +221 -143
  173. data/ext/kobako/src/wire.rs +42 -0
  174. data/lib/kobako/catalog/extensions.rb +14 -2
  175. data/lib/kobako/catalog/flags.rb +3 -5
  176. data/lib/kobako/catalog/grants.rb +5 -4
  177. data/lib/kobako/catalog/handles.rb +5 -27
  178. data/lib/kobako/catalog/mount.rb +11 -3
  179. data/lib/kobako/catalog/network.rb +35 -0
  180. data/lib/kobako/catalog/replacements.rb +28 -0
  181. data/lib/kobako/catalog/services.rb +5 -19
  182. data/lib/kobako/catalog/snippets.rb +3 -18
  183. data/lib/kobako/catalog.rb +3 -0
  184. data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
  185. data/lib/kobako/codec/decoder.rb +4 -4
  186. data/lib/kobako/codec/ext_types.rb +3 -3
  187. data/lib/kobako/codec/handle_walk.rb +3 -43
  188. data/lib/kobako/codec/value_budget.rb +132 -40
  189. data/lib/kobako/codec.rb +1 -1
  190. data/lib/kobako/context.rb +24 -11
  191. data/lib/kobako/errors.rb +15 -12
  192. data/lib/kobako/extension.rb +3 -2
  193. data/lib/kobako/filesystem.rb +9 -2
  194. data/lib/kobako/handle.rb +2 -2
  195. data/lib/kobako/names.rb +28 -0
  196. data/lib/kobako/network.rb +210 -0
  197. data/lib/kobako/outcome.rb +7 -7
  198. data/lib/kobako/pool.rb +45 -23
  199. data/lib/kobako/runtime.rb +3 -2
  200. data/lib/kobako/sandbox.rb +92 -35
  201. data/lib/kobako/sandbox_options.rb +41 -106
  202. data/lib/kobako/transport/argument_wrap.rb +64 -0
  203. data/lib/kobako/transport/block_failure.rb +1 -1
  204. data/lib/kobako/transport/dispatcher.rb +6 -6
  205. data/lib/kobako/transport/exposure.rb +26 -15
  206. data/lib/kobako/transport/reflection.rb +21 -4
  207. data/lib/kobako/transport/run.rb +8 -23
  208. data/lib/kobako/transport/yielder.rb +2 -9
  209. data/lib/kobako/transport.rb +1 -0
  210. data/lib/kobako/version.rb +1 -1
  211. data/lib/kobako.rb +6 -2
  212. data/release-please-config.json +15 -0
  213. data/sig/core/thread.rbs +6 -0
  214. data/sig/kobako/catalog/extensions.rbs +2 -0
  215. data/sig/kobako/catalog/grants.rbs +7 -4
  216. data/sig/kobako/catalog/handles.rbs +0 -2
  217. data/sig/kobako/catalog/mount.rbs +3 -1
  218. data/sig/kobako/catalog/network.rbs +20 -0
  219. data/sig/kobako/catalog/replacements.rbs +14 -0
  220. data/sig/kobako/catalog/services.rbs +0 -4
  221. data/sig/kobako/catalog/snippets.rbs +0 -2
  222. data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
  223. data/sig/kobako/codec/handle_walk.rbs +0 -6
  224. data/sig/kobako/codec/value_budget.rbs +47 -4
  225. data/sig/kobako/context.rbs +3 -1
  226. data/sig/kobako/errors.rbs +4 -4
  227. data/sig/kobako/filesystem.rbs +21 -3
  228. data/sig/kobako/network.rbs +115 -0
  229. data/sig/kobako/outcome.rbs +1 -1
  230. data/sig/kobako/pool.rbs +7 -3
  231. data/sig/kobako/runtime.rbs +32 -3
  232. data/sig/kobako/sandbox.rbs +19 -2
  233. data/sig/kobako/sandbox_options.rbs +29 -38
  234. data/sig/kobako/transport/argument_wrap.rbs +15 -0
  235. data/sig/kobako/transport/error.rbs +1 -1
  236. data/sig/kobako/transport/exposure.rbs +2 -4
  237. data/sig/kobako/transport/reflection.rbs +10 -0
  238. data/sig/kobako/transport/run.rbs +0 -2
  239. data/sig/kobako/transport/yielder.rbs +0 -3
  240. data/sig/kobako/transport.rbs +1 -1
  241. data/sig/kobako.rbs +13 -0
  242. metadata +84 -35
  243. data/crates/kobako-runtime/src/endpoint/capture.rs +0 -115
  244. data/crates/kobako-runtime/src/endpoint/memory_cap.rs +0 -238
  245. data/crates/kobako-runtime/src/filesystem/path.rs +0 -21
  246. data/crates/kobako-runtime/src/vfs/errno.rs +0 -153
  247. data/crates/kobako-runtime/tests/linux_baseline/calls.rs +0 -171
  248. data/crates/kobako-runtime/tests/linux_baseline/concurrent.rs +0 -276
  249. data/crates/kobako-runtime/tests/linux_baseline/kobako.rs +0 -323
  250. data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
  251. data/crates/kobako-runtime/tests/linux_baseline/linux.rs +0 -449
  252. data/crates/kobako-runtime/tests/linux_baseline/main.rs +0 -611
  253. data/crates/kobako-runtime/tests/linux_baseline/permissions.rs +0 -236
  254. data/crates/kobako-wasmtime/src/descriptors.rs +0 -200
  255. data/crates/kobako-wasmtime/tests/integration/compile_posture.rs +0 -43
  256. data/crates/kobako-wasmtime/tests/integration/guest_file.rs +0 -1085
  257. data/crates/kobako-wasmtime/tests/integration/main.rs +0 -29
  258. data/crates/kobako-wasmtime/tests/integration/preamble_flags.rs +0 -70
  259. data/crates/kobako-wasmtime/tests/integration/snippet_compile.rs +0 -95
  260. data/crates/kobako-wasmtime/tests/integration/support/mod.rs +0 -30
  261. data/crates/kobako-wasmtime/tests/integration/unanswered_call.rs +0 -86
  262. data/crates/kobako-wasmtime/tests/integration/unsupported_call.rs +0 -51
  263. data/ext/kobako/src/runtime/gvl.rs +0 -147
  264. data/lib/kobako/constant_name.rb +0 -8
  265. data/sig/kobako/constant_name.rbs +0 -3
  266. /data/ext/kobako/src/{runtime/pinned_value.rs → pinned_value.rs} +0 -0
@@ -1,88 +1,94 @@
1
- //! The ABI's fixed values — the numbers and layouts a host and a guest
2
- //! must already agree on before either can read the other's bytes.
1
+ //! The ABI's fixed values — the names and limits a host and a guest must
2
+ //! already agree on before either can read the other's bytes.
3
3
  //!
4
4
  //! The symbols that carry the ABI are declared where they are
5
5
  //! implemented: the guest contract crate emits the exports, the driver
6
- //! resolves them and provides the import. What lives here is what both sides must spell the
7
- //! same way, and each value is spelled once.
6
+ //! resolves them and provides the imports. What lives here is what both
7
+ //! sides must spell the same way.
8
8
 
9
- /// The Guest ABI version. A host accepts a Guest Binary only when the
10
- /// version it reports equals this one, so a framing or symbol change is
11
- /// an increment rather than a negotiation. A new request tag needs
12
- /// neither, but a new answer arm is an increment.
13
- pub const ABI_VERSION: u32 = 5;
9
+ /// Spell an ABI name as a literal, for the attributes that accept no
10
+ /// constant: a guest's `export_name`, and its `wasm_import_module` through
11
+ /// `(host => $then)`, which hands the host interface to `$then!`.
12
+ ///
13
+ /// `wasm_import_module` takes no macro, so the host interface is spelled
14
+ /// once more there; a build whose spelling no longer matches
15
+ /// `HOST_INTERFACE` fails.
16
+ #[doc(hidden)]
17
+ #[macro_export]
18
+ macro_rules! abi_name {
19
+ (version) => {
20
+ "0.6.0"
21
+ };
22
+ (guest) => {
23
+ concat!("kobako:abi/guest@", $crate::abi_name!(version))
24
+ };
25
+ (host) => {
26
+ concat!("kobako:abi/host@", $crate::abi_name!(version))
27
+ };
28
+ (host => $then:ident) => {
29
+ $crate::abi_name!(@import $then "kobako:abi/host@0.6.0");
30
+ };
31
+ (@import $then:ident $module:literal) => {
32
+ $then!($module);
33
+ const _: () = assert!($crate::abi::is_host_interface($module));
34
+ };
35
+ (downcall) => {
36
+ "downcall"
37
+ };
38
+ (downcall_export) => {
39
+ concat!($crate::abi_name!(guest), "#", $crate::abi_name!(downcall))
40
+ };
41
+ (upcall) => {
42
+ "upcall"
43
+ };
44
+ (preamble) => {
45
+ "preamble"
46
+ };
47
+ }
14
48
 
15
- /// Width in bytes of the length prefix that frames a message on WASI
16
- /// stdin, such as the Preamble.
17
- pub const FRAME_LEN_SIZE: usize = 4;
49
+ /// The Guest ABI version, as the semver every ABI name carries. A host
50
+ /// accepts a Guest Binary only when its names carry this one, so a framing
51
+ /// or symbol change is an increment rather than a negotiation. A new request
52
+ /// tag needs neither, but a new answer arm is an increment.
53
+ pub const ABI_VERSION: &str = abi_name!(version);
18
54
 
19
- /// Single-dispatch size cap: 16 MiB in either direction, applied to the
20
- /// whole envelope rather than the payload alone. A larger transfer is a
21
- /// wire violation the receiving side refuses before allocating for it.
22
- pub const MAX_DISPATCH_PAYLOAD: usize = 16 * 1024 * 1024;
55
+ /// The interface a Guest Binary exports its downcall under.
56
+ pub const GUEST_INTERFACE: &str = abi_name!(guest);
23
57
 
24
- /// Allocation ceiling on a length-prefixed frame. A reader learns a frame's
25
- /// length before it can check anything else about it, so this bounds what a
26
- /// declared length may make it allocate. It sits above
27
- /// `MAX_DISPATCH_PAYLOAD` because it guards the read rather than enforcing
28
- /// the contract: the host enforces the 16 MiB cap before it sends a frame.
29
- pub const MAX_FRAME_LEN: usize = 64 * 1024 * 1024;
58
+ /// The interface a Guest Binary imports the upcall and the Preamble from.
59
+ pub const HOST_INTERFACE: &str = abi_name!(host);
30
60
 
31
- // The read guard must admit every frame the contract allows, so a refusal
32
- // names the cap rather than the allocation ceiling.
33
- const _: () = assert!(MAX_FRAME_LEN > MAX_DISPATCH_PAYLOAD);
61
+ /// The guest function a host calls with each request.
62
+ pub const DOWNCALL: &str = abi_name!(downcall);
34
63
 
35
- /// Pack `(ptr, len)` into the u64 the downcall and the upcall answer with: the high 32 bits carry the linear-memory pointer,
36
- /// the low 32 the byte length. A `len` of zero is the failure signal.
37
- ///
38
- /// ```text
39
- /// 63 32 31 0
40
- /// ┌──────────┬────────────┐
41
- /// │ ptr │ len │
42
- /// └──────────┴────────────┘
43
- /// ```
44
- #[inline]
45
- pub fn pack_ptr_len(ptr: u32, len: u32) -> u64 {
46
- ((ptr as u64) << 32) | (len as u64)
47
- }
64
+ /// The core export the downcall stands under: its interface, `#`, then the
65
+ /// function, as the Canonical ABI's legacy core naming spells it.
66
+ pub const DOWNCALL_EXPORT: &str = abi_name!(downcall_export);
48
67
 
49
- /// Read a packed u64 back into `(ptr, len)`.
50
- #[inline]
51
- pub fn unpack_ptr_len(packed: u64) -> (u32, u32) {
52
- ((packed >> 32) as u32, packed as u32)
53
- }
68
+ /// The host function a guest calls with each Call.
69
+ pub const UPCALL: &str = abi_name!(upcall);
54
70
 
55
- #[cfg(test)]
56
- mod tests {
57
- use super::*;
71
+ /// The host function a guest calls for the Preamble of its Invocation.
72
+ pub const PREAMBLE: &str = abi_name!(preamble);
58
73
 
59
- // @behavior WE-001
60
- #[test]
61
- fn the_layout_is_high_ptr_low_len() {
62
- let packed = pack_ptr_len(0xAABB_CCDD, 0x1122_3344);
63
- assert_eq!(
64
- packed, 0xAABB_CCDD_1122_3344,
65
- "the packed u64 must carry ptr in the high half and len in the low half"
66
- );
74
+ /// Whether `module` spells `HOST_INTERFACE`, readable in a const context.
75
+ #[doc(hidden)]
76
+ pub const fn is_host_interface(module: &str) -> bool {
77
+ let (module, host) = (module.as_bytes(), HOST_INTERFACE.as_bytes());
78
+ if module.len() != host.len() {
79
+ return false;
67
80
  }
68
-
69
- // @behavior WE-002
70
- #[test]
71
- fn every_pair_round_trips() {
72
- for &(ptr, len) in &[
73
- (0u32, 0u32),
74
- (0x1000, 1024),
75
- (0x0001_0000, 4),
76
- (0x7fff_ffff, 0xffff),
77
- (1, u32::MAX),
78
- (u32::MAX, 1),
79
- (u32::MAX, u32::MAX),
80
- ] {
81
- assert_eq!(
82
- unpack_ptr_len(pack_ptr_len(ptr, len)),
83
- (ptr, len),
84
- "a ({ptr:#x}, {len:#x}) pair must survive the pack the ABI returns"
85
- );
81
+ let mut i = 0;
82
+ while i < host.len() {
83
+ if module[i] != host[i] {
84
+ return false;
86
85
  }
86
+ i += 1;
87
87
  }
88
+ true
88
89
  }
90
+
91
+ /// The largest message either side sends: 16 MiB, the whole Envelope
92
+ /// rather than the payload alone. A larger one is a wire violation the
93
+ /// receiving side refuses before allocating for it.
94
+ pub const MAX_MESSAGE_LEN: usize = 16 * 1024 * 1024;
@@ -68,16 +68,27 @@ impl<'a> Reader<'a> {
68
68
  self.read_list(|reader| Ok(reader.read_bytes()?.to_vec()))
69
69
  }
70
70
 
71
+ /// A `u32` count of items each at least `min_len` bytes long. A count
72
+ /// past what the bytes left can hold can never be satisfied, so it is
73
+ /// refused with `too_many` before it sizes an allocation or bounds work.
74
+ pub(crate) fn read_count(
75
+ &mut self,
76
+ min_len: usize,
77
+ too_many: DecodeError,
78
+ ) -> Result<usize, DecodeError> {
79
+ let count = self.read_u32()? as usize;
80
+ if count > self.remaining().len() / min_len {
81
+ return Err(too_many);
82
+ }
83
+ Ok(count)
84
+ }
85
+
71
86
  fn read_list<T>(
72
87
  &mut self,
73
88
  mut element: impl FnMut(&mut Self) -> Result<T, DecodeError>,
74
89
  ) -> Result<Vec<T>, DecodeError> {
75
- let count = self.read_u32()? as usize;
76
- // Every element opens with a `u32` length, so a count past what the
77
- // bytes left can hold is refused before it sizes the allocation.
78
- if count > self.remaining().len() / size_of::<u32>() {
79
- return Err(MALFORMED);
80
- }
90
+ // Every element opens with a `u32` length.
91
+ let count = self.read_count(size_of::<u32>(), MALFORMED)?;
81
92
  let mut out = Vec::with_capacity(count);
82
93
  for _ in 0..count {
83
94
  out.push(element(self)?);
@@ -13,6 +13,10 @@ use super::DecodeError;
13
13
  const KIND_PATH: u8 = 0;
14
14
  const KIND_HANDLE: u8 = 1;
15
15
 
16
+ /// The most a Capability Handle id may be: the wire pins ids to the positive
17
+ /// i32 range, so no table issues one past it and no side takes one.
18
+ pub const MAX_HANDLE_ID: u32 = 0x7fff_ffff;
19
+
16
20
  /// The object a Call is addressed to.
17
21
  #[derive(Debug, Clone, Copy, PartialEq, Eq)]
18
22
  pub enum Target<'a> {
@@ -41,10 +45,18 @@ impl<'a> Call<'a> {
41
45
  KIND_HANDLE => Target::Handle(reader.read_u32()?),
42
46
  _ => return Err(DecodeError::new("Call kind must be 0 (path) or 1 (handle)")),
43
47
  };
44
- if let Target::Handle(0) = target {
45
- return Err(DecodeError::new(
46
- "Call target Handle id 0 is the invalid sentinel",
47
- ));
48
+ match target {
49
+ Target::Handle(0) => {
50
+ return Err(DecodeError::new(
51
+ "Call target Handle id 0 is the invalid sentinel",
52
+ ))
53
+ }
54
+ Target::Handle(id) if id > MAX_HANDLE_ID => {
55
+ return Err(DecodeError::new(
56
+ "Call target Handle id must be at most 0x7fff_ffff",
57
+ ))
58
+ }
59
+ _ => {}
48
60
  }
49
61
  let method = reader.read_text()?;
50
62
  let block_given = match reader.read_u8()? {
@@ -205,6 +217,22 @@ mod tests {
205
217
  );
206
218
  }
207
219
 
220
+ // @behavior WE-091
221
+ #[test]
222
+ fn a_handle_id_past_the_wire_range_is_refused() {
223
+ let call_of = |id: u32| {
224
+ let mut w = Writer::new();
225
+ w.u8(KIND_HANDLE).u32(id).bytes(b"m").u8(0);
226
+ w.into_bytes()
227
+ };
228
+ assert!(
229
+ Call::decode(&call_of(0x7fff_ffff)).is_ok()
230
+ && Call::decode(&call_of(0x8000_0000)).is_err(),
231
+ "Call::decode must take a Handle id of 0x7fff_ffff in the target position and refuse \
232
+ 0x8000_0000"
233
+ );
234
+ }
235
+
208
236
  // @behavior WE-016
209
237
  #[test]
210
238
  fn a_non_boolean_block_flag_is_refused() {
@@ -8,6 +8,27 @@
8
8
  use super::bytes::{Reader, Writer};
9
9
  use super::DecodeError;
10
10
 
11
+ /// The name a wire violation carries: an exchange that did not complete.
12
+ pub const TRANSPORT_ERROR: &str = "Kobako::Transport::Error";
13
+ /// The name a guest that could not start the Sandbox carries.
14
+ pub const BOOT_ERROR: &str = "Kobako::BootError";
15
+ /// The name a failure the guest's own flow detected carries, where no script
16
+ /// error names one.
17
+ pub const SANDBOX_ERROR: &str = "Kobako::SandboxError";
18
+ /// The name a Snippet the guest could not load carries.
19
+ pub const BYTECODE_ERROR: &str = "Kobako::BytecodeError";
20
+ /// The name a critical Preamble flag the guest does not know carries.
21
+ pub const UNSUPPORTED_FLAG_ERROR: &str = "Kobako::UnsupportedFlagError";
22
+ /// The name a Run whose entrypoint the guest cannot resolve carries.
23
+ pub const UNDEFINED_ENTRYPOINT_ERROR: &str = "Kobako::UndefinedEntrypointError";
24
+ /// The name a Service call that failed carries, where no Fault category
25
+ /// narrows it.
26
+ pub const SERVICE_ERROR: &str = "Kobako::ServiceError";
27
+ /// The name a call to a Service the host does not hold carries.
28
+ pub const NO_SERVICE_ERROR: &str = "Kobako::NoServiceError";
29
+ /// The name a Service call the host refused for its arguments carries.
30
+ pub const SERVICE_ARGUMENT_ERROR: &str = "Kobako::ServiceArgumentError";
31
+
11
32
  /// The error's name, message, and backtrace as the guest saw them. `name`
12
33
  /// rather than `class` because a guest need not be object-oriented to have
13
34
  /// named the error it is reporting.
@@ -0,0 +1,99 @@
1
+ //! The form every name a guest interns takes: a Snippet's name, a Run's
2
+ //! entrypoint, and each segment of a Binding's path. The guest reaches each
3
+ //! one as a Ruby constant, so every side refuses one outside that form
4
+ //! before it is written.
5
+
6
+ /// The module the guest keeps for itself, where no Binding may stand.
7
+ pub const RESERVED_NAMESPACE: &str = "Kobako";
8
+
9
+ /// The guest interns every constant name, and mruby holds a symbol of at
10
+ /// most this many bytes.
11
+ const MAX_SYMBOL_LEN: usize = 65_534;
12
+
13
+ /// Whether `name` is a Ruby constant name the guest can intern: an ASCII
14
+ /// capital, then ASCII letters, digits, or `_`, within mruby's symbol length.
15
+ pub fn is_constant_name(name: &str) -> bool {
16
+ let mut chars = name.chars();
17
+ name.len() <= MAX_SYMBOL_LEN
18
+ && chars.next().is_some_and(|c| c.is_ascii_uppercase())
19
+ && chars.all(|c| c.is_ascii_alphanumeric() || c == '_')
20
+ }
21
+
22
+ /// Whether `path` is constant names joined by `::`.
23
+ pub fn is_constant_path(path: &str) -> bool {
24
+ path.split("::").all(is_constant_name)
25
+ }
26
+
27
+ /// Whether `path` stands in the guest's own `RESERVED_NAMESPACE`.
28
+ pub fn is_reserved(path: &str) -> bool {
29
+ path.split("::").next() == Some(RESERVED_NAMESPACE)
30
+ }
31
+
32
+ /// Whether `path` and `bound` cannot both be bound: they name one constant,
33
+ /// or one stands as the other's namespace, so the guest could not tell a
34
+ /// Service from a grouping module.
35
+ pub fn collides(path: &str, bound: &str) -> bool {
36
+ let within = |inner: &str, outer: &str| {
37
+ inner
38
+ .strip_prefix(outer)
39
+ .is_some_and(|rest| rest.starts_with("::"))
40
+ };
41
+ path == bound || within(path, bound) || within(bound, path)
42
+ }
43
+
44
+ #[cfg(test)]
45
+ mod tests {
46
+ use super::*;
47
+
48
+ #[test]
49
+ fn a_constant_name_is_an_ascii_capital_then_word_characters_within_a_symbol() {
50
+ let longest = format!("A{}", "b".repeat(MAX_SYMBOL_LEN - 1));
51
+ assert_eq!(
52
+ [
53
+ is_constant_name(&longest),
54
+ is_constant_name(&format!("{longest}b")),
55
+ is_constant_name("Aé"),
56
+ is_constant_name("A\n"),
57
+ is_constant_name("lower"),
58
+ is_constant_name(""),
59
+ ],
60
+ [true, false, false, false, false, false],
61
+ "is_constant_name must take an ASCII capital and word characters up to 65534 bytes, \
62
+ and refuse a longer name, a non-ASCII or newline character, a lowercase start, \
63
+ and an empty name"
64
+ );
65
+ }
66
+
67
+ #[test]
68
+ fn a_path_is_constant_names_joined_and_the_guests_own_namespace_is_reserved() {
69
+ assert_eq!(
70
+ [
71
+ is_constant_path("MyService::KV"),
72
+ is_constant_path("MyService::"),
73
+ is_constant_path("MyService:KV"),
74
+ is_reserved("Kobako"),
75
+ is_reserved("Kobako::KV"),
76
+ is_reserved("KobakoKV"),
77
+ ],
78
+ [true, false, false, true, true, false],
79
+ "is_constant_path must join constant names by '::' only, and is_reserved must hold \
80
+ a path whose first segment is Kobako and no other"
81
+ );
82
+ }
83
+
84
+ #[test]
85
+ fn a_path_collides_with_itself_and_with_either_side_of_a_namespace() {
86
+ assert_eq!(
87
+ [
88
+ collides("KV", "KV"),
89
+ collides("KV::Store", "KV"),
90
+ collides("KV", "KV::Store"),
91
+ collides("KVStore", "KV"),
92
+ collides("KV", "Cache"),
93
+ ],
94
+ [true, true, true, false, false],
95
+ "collides must hold for one path and for a path inside another's namespace, and \
96
+ not for a path that only shares a prefix"
97
+ );
98
+ }
99
+ }
@@ -11,9 +11,9 @@ use super::{tag, DecodeError, ErrorRecord, Unsupported};
11
11
  ///
12
12
  /// The wire field is an open set of byte strings, but only two values
13
13
  /// carry meaning — so both sides read and write it through this type and
14
- /// cannot come to spell either one differently. The fallback rule lives in
15
- /// `from_name`: an unrecognised value attributes to the sandbox rather
16
- /// than widening what a Service can claim.
14
+ /// cannot come to spell either one differently. An Outcome whose value no
15
+ /// origin spells attributes to the sandbox rather than widening what a
16
+ /// Service can claim.
17
17
  #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
18
18
  pub enum Origin {
19
19
  /// The guest script raised, or a boot step faulted.
@@ -32,12 +32,12 @@ impl Origin {
32
32
  }
33
33
  }
34
34
 
35
- /// Read a wire spelling back. Everything other than `"service"`,
36
- /// recognised or not, attributes to the sandbox.
37
- pub fn from_name(name: &str) -> Self {
35
+ /// Read a wire spelling back, `None` for one no origin spells.
36
+ pub(crate) fn from_name(name: &str) -> Option<Self> {
38
37
  match name {
39
- "service" => Origin::Service,
40
- _ => Origin::Sandbox,
38
+ "sandbox" => Some(Origin::Sandbox),
39
+ "service" => Some(Origin::Service),
40
+ _ => None,
41
41
  }
42
42
  }
43
43
  }
@@ -69,7 +69,7 @@ impl Outcome {
69
69
  match reader.read_u8()? {
70
70
  tag::OK => Ok(Outcome::Ok(reader.remaining().to_vec())),
71
71
  tag::PANIC => {
72
- let origin = Origin::from_name(reader.read_text()?);
72
+ let origin = Origin::from_name(reader.read_text()?).unwrap_or(Origin::Sandbox);
73
73
  let error = ErrorRecord::read(&mut reader)?;
74
74
  let available = reader.read_text_list()?;
75
75
  reader.finish()?;
@@ -66,15 +66,11 @@ impl Preamble {
66
66
  /// appear at most once; an absent one reads as empty.
67
67
  pub fn decode(bytes: &[u8]) -> Result<Self, DecodeError> {
68
68
  let mut reader = Reader::new(bytes);
69
- let count = reader.read_u32()? as usize;
70
- // Each record costs at least six bytes, its two leading bytes and a
71
- // body length, so a count past the bytes left can never be
72
- // satisfied; refusing it bounds the work.
73
- if count > reader.remaining().len() {
74
- return Err(DecodeError::new(
75
- "Preamble declares more records than it holds",
76
- ));
77
- }
69
+ // Each record costs at least its two leading bytes and a body length.
70
+ let count = reader.read_count(
71
+ 2 + size_of::<u32>(),
72
+ DecodeError::new("Preamble declares more records than it holds"),
73
+ )?;
78
74
  let mut bindings = None;
79
75
  let mut snippets = None;
80
76
  let mut flags = Vec::new();
@@ -160,15 +156,11 @@ fn encode_bindings(bindings: &Bindings) -> Vec<u8> {
160
156
 
161
157
  fn decode_snippets(bytes: &[u8]) -> Result<Snippets, DecodeError> {
162
158
  let mut reader = Reader::new(bytes);
163
- let count = reader.read_u32()? as usize;
164
- // Each entry costs at least a kind byte and a `u32` length, so a count
165
- // past what the bytes left can hold is refused before it sizes the
166
- // allocation.
167
- if count > reader.remaining().len() / (1 + size_of::<u32>()) {
168
- return Err(DecodeError::new(
169
- "Preamble snippets declare more entries than they hold",
170
- ));
171
- }
159
+ // Each entry costs at least a kind byte and a `u32` length.
160
+ let count = reader.read_count(
161
+ 1 + size_of::<u32>(),
162
+ DecodeError::new("Preamble snippets declare more entries than they hold"),
163
+ )?;
172
164
  let mut entries = Vec::with_capacity(count);
173
165
  for _ in 0..count {
174
166
  entries.push(match reader.read_u8()? {
@@ -388,10 +380,21 @@ mod tests {
388
380
  fn a_count_the_preamble_cannot_satisfy_is_refused() {
389
381
  let records = [0xff, 0xff, 0xff, 0xff];
390
382
  let snippets = preamble_with(&[record(1, 0x06, &[0xff, 0xff, 0xff, 0xff])]);
391
- assert!(
392
- Preamble::decode(&records).is_err() && Preamble::decode(&snippets).is_err(),
383
+ // The count's own refusal, not a later read running out of bytes,
384
+ // is what shows nothing was taken for it.
385
+ let refusal = |bytes: &[u8]| {
386
+ Preamble::decode(bytes)
387
+ .err()
388
+ .map(|err| err.message().to_owned())
389
+ };
390
+ assert_eq!(
391
+ (refusal(&records), refusal(&snippets)),
392
+ (
393
+ Some("Preamble declares more records than it holds".to_owned()),
394
+ Some("Preamble snippets declare more entries than they hold".to_owned())
395
+ ),
393
396
  "a record or snippet count larger than what follows through Preamble::decode must \
394
- be refused before anything is allocated for it"
397
+ be refused for its count, before anything is allocated for it"
395
398
  );
396
399
  }
397
400
 
@@ -10,7 +10,7 @@ use super::{tag, DecodeError, ErrorRecord, Fault, Unsupported};
10
10
 
11
11
  /// The answer to one dispatch Call.
12
12
  #[derive(Debug, Clone, PartialEq, Eq)]
13
- pub enum Reply {
13
+ pub enum CallReply {
14
14
  /// The method returned; the bytes are the value, codec-encoded.
15
15
  Ok(Vec<u8>),
16
16
  /// The method refused or failed. Typed rather than codec-encoded:
@@ -24,19 +24,19 @@ pub enum Reply {
24
24
  Unsupported(Unsupported),
25
25
  }
26
26
 
27
- impl Reply {
27
+ impl CallReply {
28
28
  pub fn decode(bytes: &[u8]) -> Result<Self, DecodeError> {
29
29
  let mut reader = Reader::new(bytes);
30
30
  match reader.read_u8()? {
31
- tag::OK => Ok(Reply::Ok(reader.remaining().to_vec())),
31
+ tag::OK => Ok(CallReply::Ok(reader.remaining().to_vec())),
32
32
  // No `finish` here: a Fault owns everything after the tag,
33
33
  // including the fields a later contract version appends.
34
- tag::FAULT => Ok(Reply::Fault(Fault::read(&mut reader)?)),
34
+ tag::FAULT => Ok(CallReply::Fault(Fault::read(&mut reader)?)),
35
35
  tag::BREAK => {
36
36
  reader.finish()?;
37
- Ok(Reply::Break)
37
+ Ok(CallReply::Break)
38
38
  }
39
- tag::UNSUPPORTED => Ok(Reply::Unsupported(Unsupported::read(&mut reader)?)),
39
+ tag::UNSUPPORTED => Ok(CallReply::Unsupported(Unsupported::read(&mut reader)?)),
40
40
  _ => Err(DecodeError::new(
41
41
  "Reply tag must be 0x10 (ok), 0x11 (fault), 0x12 (break), or 0x15 (unsupported)",
42
42
  )),
@@ -46,17 +46,17 @@ impl Reply {
46
46
  pub fn encode(&self) -> Vec<u8> {
47
47
  let mut writer = Writer::new();
48
48
  match self {
49
- Reply::Ok(body) => {
49
+ CallReply::Ok(body) => {
50
50
  writer.u8(tag::OK).remainder(body);
51
51
  }
52
- Reply::Fault(fault) => {
52
+ CallReply::Fault(fault) => {
53
53
  writer.u8(tag::FAULT);
54
54
  fault.write(&mut writer);
55
55
  }
56
- Reply::Break => {
56
+ CallReply::Break => {
57
57
  writer.u8(tag::BREAK);
58
58
  }
59
- Reply::Unsupported(refusal) => return refusal.encode(),
59
+ CallReply::Unsupported(refusal) => return refusal.encode(),
60
60
  }
61
61
  writer.into_bytes()
62
62
  }
@@ -73,7 +73,7 @@ pub enum YieldReply {
73
73
  /// The block raised, or failed in a way the host re-raises at the
74
74
  /// yield site.
75
75
  Error(ErrorRecord),
76
- /// The guest serves no block.
76
+ /// The guest supports no block.
77
77
  Unsupported(Unsupported),
78
78
  }
79
79
 
@@ -123,17 +123,17 @@ mod tests {
123
123
  #[test]
124
124
  fn every_reply_arm_round_trips() {
125
125
  for reply in [
126
- Reply::Ok(vec![0x2a]),
127
- Reply::Fault(Fault::new(
126
+ CallReply::Ok(vec![0x2a]),
127
+ CallReply::Fault(Fault::new(
128
128
  super::super::FaultKind::Undefined,
129
129
  "no such method",
130
130
  )),
131
- Reply::Break,
132
- Reply::Unsupported(Unsupported::new("no such operation")),
131
+ CallReply::Break,
132
+ CallReply::Unsupported(Unsupported::new("no such operation")),
133
133
  ] {
134
134
  let encoded = reply.encode();
135
135
  assert_eq!(
136
- Reply::decode(&encoded),
136
+ CallReply::decode(&encoded),
137
137
  Ok(reply),
138
138
  "a Reply must survive a host encode and decode on every arm"
139
139
  );
@@ -143,10 +143,10 @@ mod tests {
143
143
  // @behavior WE-019
144
144
  #[test]
145
145
  fn an_empty_ok_body_round_trips() {
146
- let encoded = Reply::Ok(Vec::new()).encode();
146
+ let encoded = CallReply::Ok(Vec::new()).encode();
147
147
  assert_eq!(
148
- Reply::decode(&encoded),
149
- Ok(Reply::Ok(Vec::new())),
148
+ CallReply::decode(&encoded),
149
+ Ok(CallReply::Ok(Vec::new())),
150
150
  "a Reply whose payload is empty must decode as an empty value, not a truncation"
151
151
  );
152
152
  }
@@ -155,7 +155,7 @@ mod tests {
155
155
  #[test]
156
156
  fn an_unknown_reply_tag_is_refused() {
157
157
  assert!(
158
- Reply::decode(&[0x13, 0]).is_err(),
158
+ CallReply::decode(&[0x13, 0]).is_err(),
159
159
  "a Reply tag outside its arms must be rejected as a wire violation"
160
160
  );
161
161
  }
@@ -164,7 +164,7 @@ mod tests {
164
164
  #[test]
165
165
  fn a_zero_length_reply_is_refused() {
166
166
  assert!(
167
- Reply::decode(&[]).is_err(),
167
+ CallReply::decode(&[]).is_err(),
168
168
  "a zero-length Reply must be rejected rather than read as a missing tag"
169
169
  );
170
170
  }
@@ -211,24 +211,24 @@ mod tests {
211
211
  // this" from "the Service failed with this" is the tag alone, which
212
212
  // is what lets a side read the outcome without a payload codec.
213
213
  assert_eq!(
214
- Reply::Ok(vec![0x2a]).encode(),
214
+ CallReply::Ok(vec![0x2a]).encode(),
215
215
  vec![0x10, 0x2a],
216
216
  "a successful Reply must encode as tag byte 0x10 followed by the body alone"
217
217
  );
218
218
  assert_eq!(
219
- Reply::Fault(Fault::new(super::super::FaultKind::Runtime, "x")).encode(),
219
+ CallReply::Fault(Fault::new(super::super::FaultKind::Runtime, "x")).encode(),
220
220
  vec![0x11, 0, 0, 0, 0, 1, b'x'],
221
221
  "a fault Reply must encode as tag byte 0x11 followed by the Fault's own fixed \
222
222
  layout, so a guest reads a refusal without reaching a payload codec"
223
223
  );
224
224
  assert_eq!(
225
- Reply::Unsupported(Unsupported::new("x")).encode(),
225
+ CallReply::Unsupported(Unsupported::new("x")).encode(),
226
226
  vec![0x15, 0, 0, 0, 0, 1, b'x'],
227
227
  "an unsupported Reply must encode as tag byte 0x15 followed by kind 0 and the \
228
228
  message"
229
229
  );
230
230
  assert_eq!(
231
- Reply::Break.encode(),
231
+ CallReply::Break.encode(),
232
232
  vec![0x12],
233
233
  "a break Reply must encode as tag byte 0x12 alone, since the guest keeps the exit"
234
234
  );
@@ -240,7 +240,7 @@ mod tests {
240
240
  let body = vec![0x2a];
241
241
  assert_eq!(
242
242
  [
243
- Reply::Ok(body.clone()).encode()[0],
243
+ CallReply::Ok(body.clone()).encode()[0],
244
244
  YieldReply::Ok(body.clone()).encode()[0],
245
245
  super::super::CompileReply::Ok(vec![body.clone()]).encode()[0],
246
246
  super::super::Outcome::Ok(body).encode()[0],
@@ -267,7 +267,7 @@ mod tests {
267
267
  assert_eq!(
268
268
  YieldReply::Unsupported(Unsupported::new("x")).encode(),
269
269
  vec![0x15, 0, 0, 0, 0, 1, b'x'],
270
- "a Yield Reply from a guest serving no block must encode as tag byte 0x15"
270
+ "a Yield Reply from a guest supporting no block must encode as tag byte 0x15"
271
271
  );
272
272
  assert_eq!(
273
273
  YieldReply::Error(ErrorRecord {