kobako 0.13.0-aarch64-linux → 0.15.0-aarch64-linux

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/CHANGELOG.md +81 -0
  4. data/README.md +107 -32
  5. data/ROADMAP.md +25 -0
  6. data/SECURITY.md +1 -1
  7. data/crates/kobako-runtime/CHANGELOG.md +14 -0
  8. data/crates/kobako-runtime/README.md +1 -1
  9. data/crates/kobako-wasmtime/CHANGELOG.md +14 -0
  10. data/crates/kobako-wasmtime/README.md +1 -1
  11. data/data/kobako.wasm +0 -0
  12. data/lib/kobako/3.3/kobako.so +0 -0
  13. data/lib/kobako/3.4/kobako.so +0 -0
  14. data/lib/kobako/4.0/kobako.so +0 -0
  15. data/lib/kobako/catalog/handles.rb +3 -3
  16. data/lib/kobako/catalog/services.rb +123 -0
  17. data/lib/kobako/catalog/snippets.rb +2 -2
  18. data/lib/kobako/catalog.rb +2 -2
  19. data/lib/kobako/codec/decoder.rb +10 -10
  20. data/lib/kobako/codec/encoder.rb +5 -5
  21. data/lib/kobako/codec/error.rb +3 -3
  22. data/lib/kobako/codec/ext_types.rb +169 -0
  23. data/lib/kobako/codec/handle_walk.rb +17 -21
  24. data/lib/kobako/codec/state.rb +98 -0
  25. data/lib/kobako/codec/utils.rb +9 -9
  26. data/lib/kobako/codec.rb +23 -6
  27. data/lib/kobako/errors.rb +14 -39
  28. data/lib/kobako/fault.rb +1 -1
  29. data/lib/kobako/handle.rb +6 -3
  30. data/lib/kobako/outcome.rb +14 -7
  31. data/lib/kobako/pool.rb +1 -1
  32. data/lib/kobako/sandbox.rb +30 -25
  33. data/lib/kobako/transport/dispatcher.rb +41 -31
  34. data/lib/kobako/transport/request.rb +16 -11
  35. data/lib/kobako/transport/response.rb +11 -4
  36. data/lib/kobako/transport/run.rb +1 -1
  37. data/lib/kobako/transport/yield.rb +7 -4
  38. data/lib/kobako/transport/yielder.rb +20 -12
  39. data/lib/kobako/version.rb +1 -1
  40. data/release-please-config.json +37 -7
  41. data/sig/kobako/catalog/services.rbs +25 -0
  42. data/sig/kobako/codec/ext_types.rbs +31 -0
  43. data/sig/kobako/codec/handle_walk.rbs +2 -2
  44. data/sig/kobako/codec/state.rbs +20 -0
  45. data/sig/kobako/codec.rbs +14 -0
  46. data/sig/kobako/handle.rbs +0 -2
  47. data/sig/kobako/sandbox.rbs +1 -1
  48. data/sig/kobako/transport/dispatcher.rbs +8 -8
  49. data/sig/kobako/transport/run.rbs +1 -1
  50. data/sig/kobako/transport/yielder.rbs +3 -3
  51. data/sig/kobako/transport.rbs +8 -0
  52. metadata +9 -8
  53. data/lib/kobako/catalog/namespaces.rb +0 -115
  54. data/lib/kobako/codec/factory.rb +0 -187
  55. data/lib/kobako/namespace.rb +0 -78
  56. data/sig/kobako/catalog/namespaces.rbs +0 -17
  57. data/sig/kobako/codec/factory.rbs +0 -34
  58. data/sig/kobako/namespace.rbs +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a1b4ccd9f4e1debe32912b925847390d00fbf09e798b41eb54ac0756ef4ab3
4
- data.tar.gz: 4819002a95e4407ebacb91d1ae77cd8a7c52d80a1eb0511dcc01ac405d6b7459
3
+ metadata.gz: 00df75af1fd85b3c4d3729d456148a282ab904f26162e6930ecd8ad003bcd9df
4
+ data.tar.gz: 34533660556ce44eddbc76831b973ed10217e5a3801affbb5b7a991e15069c3a
5
5
  SHA512:
6
- metadata.gz: 902954ca6a47611ab670ea52dbe5edc2268428128ffaac0dd9d55e309af6d5b4a70fc47d07eed4f31261bdcdc7158cbdd91fbfad32d56098c8a2c84077db2855
7
- data.tar.gz: 53174e7d4e921b558bca17b3683c0865954ff73219a0c07d86d11e18e6e812506aece5d5dc0626ce021fe9342a63d8d3b5ab612f513d7349e939e0e6e08ed063
6
+ metadata.gz: 34250f5db8642efbab2654993df69316be3cdb581bafacc07ac6993e072ea5addf3c04bae86d41ad5412c182b3f22e9aa158b9e9cb27d86571a7cf01ad38a674
7
+ data.tar.gz: ac5d4d68b447714f78412acd554c842cbd52f8bfab46794ffa7fabe1dcc6a169bb4d04a3caf10e88bf16ff41b4312ab30626687ee46b31530514b5fa4ac93242
@@ -1 +1 @@
1
- {".":"0.13.0","wasm/kobako-core":"0.7.0","wasm/kobako":"0.7.0","wasm/kobako-io":"0.7.0","wasm/kobako-json":"0.7.0","wasm/kobako-regexp":"0.7.0","wasm/kobako-baker":"0.7.0","crates/kobako-codec":"0.7.0","crates/kobako-runtime":"0.7.0","crates/kobako-wasmtime":"0.7.0"}
1
+ {".":"0.15.0","wasm/kobako-core":"0.9.0","wasm/kobako-mruby":"0.9.0","wasm/kobako-io":"0.9.0","wasm/kobako-json":"0.9.0","wasm/kobako-regexp":"0.9.0","wasm/kobako-baker":"0.9.0","crates/kobako-codec":"0.9.0","crates/kobako-runtime":"0.9.0","crates/kobako-wasmtime":"0.9.0","crates/kobako":"0.9.0"}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.0](https://github.com/elct9620/kobako/compare/v0.14.0...v0.15.0) (2026-07-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * **claude:** cover rake files in the post-edit rubocop hook ([416cd42](https://github.com/elct9620/kobako/commit/416cd42009e7888fb0662e91719f4d7d61713cf8))
9
+ * **examples:** add plugin-rs, a Rust SDK narrative example ([8263096](https://github.com/elct9620/kobako/commit/8263096876900aa2c3ffeebbd24f7cca3571b893))
10
+ * **examples:** add wire-rs, a low-level host without the SDK ([d9edea8](https://github.com/elct9620/kobako/commit/d9edea8ed025e4b7ffe58be8c376c7fb0a65ac04))
11
+ * **sandbox:** flatten Service registration to path-valued bind ([0876006](https://github.com/elct9620/kobako/commit/0876006455544fd82eb7555ee80c149d98843719))
12
+ * **tasks:** add grouped test:tasks / test:bench runs ([1153c43](https://github.com/elct9620/kobako/commit/1153c43416363d7cc03b696eb2762b7281a68e93))
13
+ * **tasks:** compare the wire-symmetric peer inventories mechanically ([50d4fe5](https://github.com/elct9620/kobako/commit/50d4fe523bf85406931fa9611b6528c3de1a3f50))
14
+ * **tasks:** flag stale ledger entries in the surface and symmetry instruments ([d18054f](https://github.com/elct9620/kobako/commit/d18054f5daa6ce277154c288d5c3085133f441b4))
15
+ * **tasks:** hold the pub-surface crate map to the repo's crate roster ([4f65e79](https://github.com/elct9620/kobako/commit/4f65e79c3aa37ed1fc47a5002c8a567c3df8cc84))
16
+ * **tasks:** hold the tier roster to the repo and share it across instruments ([9a75586](https://github.com/elct9620/kobako/commit/9a755866236c134ea7601006211338eefae0a348))
17
+ * **tasks:** inventory exported macros in the pub-surface scan ([e4457ea](https://github.com/elct9620/kobako/commit/e4457eafecfa24eb5fc9aade086f2be9b0862818))
18
+ * **tasks:** measure the tooling tiers in stats and hotspots ([8def9ff](https://github.com/elct9620/kobako/commit/8def9ff96d36c2020e04d7e9bb0d9cd3fdad3e43))
19
+ * **tasks:** pin the tier roster to the repo from both sides ([3b7a154](https://github.com/elct9620/kobako/commit/3b7a154ebbfe8629392a81599df37d136a0eec99))
20
+ * **tasks:** rank churn x size x fan-in hotspots since the last release ([73b3bc8](https://github.com/elct9620/kobako/commit/73b3bc8fdee19f8c09a91ccf96348688ea3ccd1c))
21
+ * **tasks:** read the anchor citation profile back as an instrument ([47961cb](https://github.com/elct9620/kobako/commit/47961cb689d9c681f5c697af7e6bca52a4c7817f))
22
+ * **tasks:** report pub items no in-repo downstream consumes ([3eb0481](https://github.com/elct9620/kobako/commit/3eb048199a0e2e41509513750bec4fcbc6b7cc69))
23
+ * **tasks:** resolve the SPEC-local F/J/N families in the anchors gate ([33d3118](https://github.com/elct9620/kobako/commit/33d31181be3a800a4cc3d4eb32324d840473401f))
24
+ * **tasks:** scan pub statics in the pub-surface instrument ([72cff5e](https://github.com/elct9620/kobako/commit/72cff5ef369a73c353ecdd25c1d4688ec8dd2f82))
25
+ * **tasks:** score hotspots on impl-only lines for Rust files ([704b419](https://github.com/elct9620/kobako/commit/704b41971eac9e284b570bd0ac2fdd9af656bbca))
26
+ * **tasks:** seat anchors:coverage and wire:symmetry in the release gate ([ab035bb](https://github.com/elct9620/kobako/commit/ab035bb3c4e049e6319d33cdaf1d715d4e83eedb))
27
+ * **tasks:** widen the fan-in and ext-code scans to their whole tiers ([43d2bad](https://github.com/elct9620/kobako/commit/43d2badfea3c13cb062e67d5ded8410a339862d3))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **codec:** reject ext 0x02 anywhere in the Panic frame, not only details ([062e29d](https://github.com/elct9620/kobako/commit/062e29d6ee15264e1bd942502b751cfe7610acad))
33
+ * **codec:** reject the Fault envelope in Rust host payload positions ([bdf2ed7](https://github.com/elct9620/kobako/commit/bdf2ed78fde2798bdc15f4e969bda228cf482f4b))
34
+ * **codec:** reject the reserved Handle id 0 on the Rust wire tier ([5f7e482](https://github.com/elct9620/kobako/commit/5f7e4821680e553da355d5257b0619e4a1cdce72))
35
+ * **tasks:** fail the anchors gate when no SPEC ceiling parses ([8d185f5](https://github.com/elct9620/kobako/commit/8d185f59afc28b5334d934f6916fd64e458e9359))
36
+ * **tasks:** inventory every codec-bearing class per transport file ([e553ae1](https://github.com/elct9620/kobako/commit/e553ae1578245d9bfca63cf4e8429666857dbb92))
37
+ * **tasks:** keep tooling-suite fixture tokens out of the anchor scans ([58a78b9](https://github.com/elct9620/kobako/commit/58a78b990684d4ad87d4db18b21eb8bd1c98713a))
38
+ * **tasks:** mark unmeasured fan-in as '-' in the hotspot report ([a4959fe](https://github.com/elct9620/kobako/commit/a4959fe0c93546711dd16002e38d993e350bcb8f))
39
+ * **tasks:** read pub fn qualifiers in the pub-surface scan ([ac0e7d3](https://github.com/elct9620/kobako/commit/ac0e7d3030729ad981b6a8de504c5837daf2038d))
40
+ * **tasks:** read the codec-bearing class in the wire-symmetry inventory ([85ce937](https://github.com/elct9620/kobako/commit/85ce937fdb35953b26fee5fa4ee55f53988147ea))
41
+ * **tasks:** scan the whole tier in every wire-symmetry inventory ([c2bba5c](https://github.com/elct9620/kobako/commit/c2bba5c02ca20dca14d061a03f8f4581d0995a66))
42
+ * **tasks:** truncate the pub-surface scan only at the test module ([9c6dc05](https://github.com/elct9620/kobako/commit/9c6dc054bfa1fe79c3410fa794290a1ce5b85f4d))
43
+ * **test:** flunk instead of skip when CI lacks a built guest prerequisite ([f7818f6](https://github.com/elct9620/kobako/commit/f7818f68c8114e5f9b0012a4dd4b069695bc3e32))
44
+ * **transport:** refuse the Fault envelope outside its legal position (E-50) ([58c5069](https://github.com/elct9620/kobako/commit/58c50691d32e245f41c2f8041dfb7e92b05b80e9))
45
+
46
+
47
+ ### Performance Improvements
48
+
49
+ * **bench:** re-bless the anchor onto the wasmtime 46 round ([9225702](https://github.com/elct9620/kobako/commit/9225702106c0c4caf90425ac08c11452b6388b55))
50
+ * **dispatch:** skip the Handle walk when the request carried none ([cd63514](https://github.com/elct9620/kobako/commit/cd6351459c492084a401fd1b6a8e4293761de93f))
51
+ * **sandbox:** skip the Handle walk when the invocation result carried none ([d2c4947](https://github.com/elct9620/kobako/commit/d2c494782d316df3bbf5fc223a8beaa1f04f5718))
52
+ * **transport:** skip the Handle walk when the yield result carried none ([bca463b](https://github.com/elct9620/kobako/commit/bca463bce0b8913941b3e3ba11c31cb41b843545))
53
+
54
+ ## [0.14.0](https://github.com/elct9620/kobako/compare/v0.13.0...v0.14.0) (2026-07-08)
55
+
56
+
57
+ ### Features
58
+
59
+ * **codec:** add the Run invocation envelope to the wire tier ([dbdd760](https://github.com/elct9620/kobako/commit/dbdd760ddc258681669f7f620f63b75f36322687))
60
+ * **crates:** add the kobako host SDK skeleton ([8a99d09](https://github.com/elct9620/kobako/commit/8a99d09ef7068a6738d44f1a735d39516b24156b))
61
+ * **crates:** add the parity runner to the kobako SDK ([998f059](https://github.com/elct9620/kobako/commit/998f059abd308ef921c295658aaf8377febb44e2))
62
+ * **crates:** grow the SDK capability-Handle table ([f93fe8f](https://github.com/elct9620/kobako/commit/f93fe8f3dce2509cfa527229f8f593f4d816b940))
63
+ * **crates:** grow the SDK Member block-yield seam ([4404713](https://github.com/elct9620/kobako/commit/44047130f309a2c935198077fb4f7f86839355e7))
64
+ * **crates:** grow the SDK preload and run invocation seams ([d8d5fe2](https://github.com/elct9620/kobako/commit/d8d5fe268a56d45dad4f8b35a25e942a559dcd5f))
65
+ * **crates:** honor the respond_to_guest narrowing on the SDK Member seam ([0f5eff1](https://github.com/elct9620/kobako/commit/0f5eff16a1e9f2229ad9d9c9316bf94e92035301))
66
+ * **crates:** let a resolved Handle recover its concrete member type ([abd5502](https://github.com/elct9620/kobako/commit/abd55029a44a7631d323c3aec3b625d9692f9c5b))
67
+ * **crates:** mark the SDK Error taxonomy non_exhaustive ([001fc69](https://github.com/elct9620/kobako/commit/001fc69e637d2c046f55cb517f9d9cf931793715))
68
+ * **examples:** add the guest→host dispatch half to the Rust host ([5cdde68](https://github.com/elct9620/kobako/commit/5cdde68824352c5685aaa94ae464e909705a4648))
69
+ * **examples:** assemble a minimal Rust host on the published crates ([6b98680](https://github.com/elct9620/kobako/commit/6b98680bcb625f9790f44df839035427a576e266))
70
+ * **tasks:** add a rails-stats-style rake stats size report ([c02d530](https://github.com/elct9620/kobako/commit/c02d530d43a85594323b7801fdbe75aa95ae7f8c))
71
+ * **tasks:** gate parity coverage over the CORE anchor manifest ([d26972c](https://github.com/elct9620/kobako/commit/d26972c1ad51e05df951643e17d66a6c811ba862))
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * **crates:** give SetupError a Display so Error::Setup reads cleanly ([bc8b128](https://github.com/elct9620/kobako/commit/bc8b128c9e296319c7fef47441b412d2ce345dff))
77
+ * **crates:** keep the no-timeout epoch deadline within range ([a3255df](https://github.com/elct9620/kobako/commit/a3255df98a77825bb39b571a60fe6ff83d269d19))
78
+ * **crates:** reject trailing bytes on Request and Run decode ([8e4929b](https://github.com/elct9620/kobako/commit/8e4929b64f3ea690f38211888070c2511da84754))
79
+ * **lib:** close the Data #with seam on Handle construction ([c0b50ae](https://github.com/elct9620/kobako/commit/c0b50aec659e32a72c905aaf94c939ac009ad621))
80
+ * **release:** resume the gem push loop past already-live versions ([170ee9b](https://github.com/elct9620/kobako/commit/170ee9bae6da3a65b4016040259e31e4721dfcfb))
81
+ * **release:** treat a yanked-only version as unpublished when publishing ([3111cc0](https://github.com/elct9620/kobako/commit/3111cc072a7c9d18b129fd2762f267d855b48d55))
82
+ * **transport:** fold fault messages to UTF-8 before they ride the wire ([0be8d40](https://github.com/elct9620/kobako/commit/0be8d4068dc5647f86746e80b356b0b9d52051f7))
83
+
3
84
  ## [0.13.0](https://github.com/elct9620/kobako/compare/v0.12.2...v0.13.0) (2026-07-03)
4
85
 
5
86
 
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/elct9620/kobako)
4
4
 
5
- Kobako is a Ruby gem that embeds a Wasm-isolated mruby interpreter inside your application, so you can execute untrusted Ruby scripts (LLM-generated code, user formulas, student submissions, third-party plugins) in-process without giving them access to host memory, files, network, or credentials.
5
+ Kobako is a Ruby gem that embeds a Wasm-isolated mruby interpreter inside your application, so you can execute untrusted Ruby scripts (LLM-generated code, user formulas, student submissions, third-party plugins) in-process without giving them access to host memory, files, network, or credentials. Its home is the Ruby ecosystem; a Rust SDK offers the same sandbox to hosts written in other languages.
6
6
 
7
- The host (`wasmtime`) runs a precompiled `kobako.wasm` guest containing mruby and a Transport proxy. The only way a guest script can reach the outside world is through Host App-declared **Services** — named Ruby objects you explicitly inject into the sandbox; the guest sees each one as a proxy that forwards calls back to the host over the Transport wire.
7
+ The host (`wasmtime`) runs a precompiled `kobako.wasm` guest containing mruby and a Transport proxy. The only way a guest script can reach the outside world is through Host App-declared **Services** — named host objects you explicitly inject into the sandbox; the guest sees each one as a proxy that forwards calls back to the host over the Transport wire.
8
8
 
9
9
  ```
10
10
  Host process Wasm guest
@@ -39,27 +39,102 @@ gem install kobako
39
39
 
40
40
  ## Quick Start
41
41
 
42
+ The same untrusted script runs identically from either host frontend. It executes inside the Wasm guest and cannot read your filesystem, open sockets, or touch your environment.
43
+
42
44
  ```ruby
43
45
  require "kobako"
44
46
 
45
47
  sandbox = Kobako::Sandbox.new
48
+ sandbox.eval("1 + 2") # => 3
49
+ ```
46
50
 
47
- result = sandbox.eval(<<~RUBY)
48
- 1 + 2
49
- RUBY
51
+ ```rust
52
+ use kobako::{Options, Sandbox};
53
+
54
+ // Options::default() is secure by default: no caps, hermetic isolation.
55
+ let mut sandbox = Sandbox::new("kobako.wasm", Options::default())?;
56
+ sandbox.eval("1 + 2")?; // => Value::Int(3)
57
+ ```
58
+
59
+ The gem bundles its Guest Binary; a Rust host loads one explicitly — see [Frontends & Guest Binaries](#frontends--guest-binaries) for the packages and the Guest Binary variants.
60
+
61
+ ## Frontends & Guest Binaries
62
+
63
+ Embedding kobako is two independent choices: the **host frontend** you build against, and the **Guest Binary** it runs. They compose freely — any frontend loads any Guest Binary, so a Ruby host can run a JSON-enabled guest and a Rust host can run the pure default.
64
+
65
+ ### Host frontends
66
+
67
+ The host embeds the sandbox and owns the SPEC wire codec. Choose by your host language and how much of the contract you want pre-assembled.
68
+
69
+ | Frontend | Package | Add it | Best for |
70
+ |----------|---------|--------|----------|
71
+ | Ruby gem | `kobako` (RubyGems) | `gem install kobako` | A Ruby host — Services, Handles, snippets, and pooling out of the box |
72
+ | Rust SDK | `kobako` (crates.io) | `kobako = "0.8"` | A Rust host — the same behavior contract behind an idiomatic Rust API |
73
+ | Low-level crates | `kobako-wasmtime` + `kobako-runtime` + `kobako-codec` | Cargo deps | A custom host, or driving the wire directly in another language |
74
+
75
+ The Rust crates are documented on [crates.io](https://crates.io/crates/kobako); the Ruby gem is this README. Two runnable Rust hosts show the choice: [`plugin-rs`](examples/plugin-rs) builds on the SDK, and [`wire-rs`](examples/wire-rs) assembles a host by hand on the low-level crates.
76
+
77
+ ### Pre-built Guest Binaries
78
+
79
+ The gem bundles the pure `kobako.wasm`. Regexp and JSON are opt-in capabilities compiled into separate variants, each attached to every [GitHub Release](https://github.com/elct9620/kobako/releases). Download a variant and point your host at it — `Sandbox.new(wasm_path:)` in Ruby, `Sandbox::new(path, ...)` in Rust.
80
+
81
+ | Variant | File | Adds | Distribution |
82
+ |---------|------|------|--------------|
83
+ | Pure (default) | `kobako.wasm` | mruby + IO | Bundled in the gem, and a Release asset |
84
+ | +regexp | `kobako+regexp.wasm` | Regexp / MatchData (ASCII) | Release asset |
85
+ | +regexp-unicode | `kobako+regexp-unicode.wasm` | Regexp / MatchData (Unicode) | Release asset |
86
+ | +json | `kobako+json.wasm` | JSON | Release asset |
87
+ | +full | `kobako+full.wasm` | JSON + Regexp (ASCII) | Release asset |
88
+
89
+ ```ruby
90
+ sandbox = Kobako::Sandbox.new(wasm_path: "kobako+full.wasm")
91
+ sandbox.eval('JSON.generate({ n: "42".to_i })') # => "{\"n\":42}"
92
+ ```
93
+
94
+ ### Custom Guest Binaries
95
+
96
+ When no pre-built variant matches your capability set, assemble a guest in Rust. `kobako-mruby` is the harness; its `init_gems` hook is where you install exactly the capability gems you want — the shipped `kobako-io` / `kobako-regexp` / `kobako-json`, or your own `beni::Gem`. `kobako-core`'s `export_guest!` emits the wasm ABI. `wasm/kobako-wasm/src/guest.rs` is the worked example.
97
+
98
+ | Guest crate | Role |
99
+ |-------------|------|
100
+ | `kobako-mruby` | mruby guest harness — the `MrbGuest` trait and provided flows |
101
+ | `kobako-core` | Guest ABI contract — the `Guest` trait and the `export_guest!` macro |
102
+ | `kobako-io` | IO / Kernel capability gem |
103
+ | `kobako-regexp` | Regexp / MatchData capability gem |
104
+ | `kobako-json` | JSON capability gem |
105
+
106
+ ```rust
107
+ use beni::{Error, Mrb};
108
+
109
+ struct MyGuest;
110
+
111
+ // Pick the capability gems the guest exposes.
112
+ impl kobako_mruby::MrbGuest for MyGuest {
113
+ fn init_gems(mrb: &Mrb) -> Result<(), Error> {
114
+ mrb.init_gem::<kobako_io::KobakoIo>()?;
115
+ mrb.init_gem::<kobako_json::KobakoJson>()?;
116
+ Ok(())
117
+ }
118
+ }
119
+
120
+ // Forward the ABI contract to the harness flows.
121
+ impl kobako_core::Guest for MyGuest {
122
+ fn eval() { <MyGuest as kobako_mruby::MrbGuest>::eval() }
123
+ fn run(env: &[u8]) { <MyGuest as kobako_mruby::MrbGuest>::run(env) }
124
+ fn yield_to_block(req: &[u8]) -> u64 { <MyGuest as kobako_mruby::MrbGuest>::yield_to_block(req) }
125
+ }
50
126
 
51
- result # => 3
127
+ kobako_core::export_guest!(MyGuest);
52
128
  ```
53
129
 
54
- The script executes inside the Wasm guest. It cannot read your filesystem, open sockets, or touch your `ENV`.
130
+ Build the crate as a `cdylib` for `wasm32-wasip1`, then bake the canonical boot state into the artifact (see [`CLAUDE.md`](CLAUDE.md) § Build Pipeline).
55
131
 
56
132
  ## Glossary
57
133
 
58
134
  | Term | Meaning |
59
135
  |------|---------|
60
136
  | Sandbox | The runtime unit (`Kobako::Sandbox`) that runs guest code and returns a result or raises a typed error. |
61
- | Service | A host Ruby object injected under `<Namespace>::<Member>` — the guest's only path to host resources. |
62
- | Namespace / Member | A guest-visible Ruby module, and a named binding (a module constant) within it. |
137
+ | Service | A host object bound at a constant-path name (`MyService::KV`) — the guest's only path to host resources. |
63
138
  | Invocation | One `#eval` or `#run`; capability state resets between invocations. |
64
139
  | Snippet | Named mruby code (source or bytecode) replayed into a fresh state before every invocation. |
65
140
  | Handle | An opaque token the guest holds for a host object the wire cannot transmit directly. |
@@ -69,7 +144,7 @@ The script executes inside the Wasm guest. It cannot read your filesystem, open
69
144
 
70
145
  ### Services
71
146
 
72
- Declare a Namespace, then `bind` any Ruby object as a Member; the guest reaches it as a `<Namespace>::<Member>` proxy and invokes its public methods through the Transport wire. See [`docs/behavior/registration.md`](docs/behavior/registration.md) B-07..B-12.
147
+ `bind` any Ruby object as a Service at a constant-path name; the guest reaches it as a `MyService::KV` (or top-level `File`) proxy and invokes its public methods through the Transport wire. See [`docs/behavior/registration.md`](docs/behavior/registration.md) B-08..B-12.
73
148
 
74
149
  ```ruby
75
150
  class User
@@ -80,8 +155,8 @@ class User
80
155
  end
81
156
  end
82
157
 
83
- sandbox.define(:Project).bind(:User, User.new(name: "alice"))
84
- sandbox.define(:KV) .bind(:Lookup, ->(key) { redis.get(key) })
158
+ sandbox.bind("Project::User", User.new(name: "alice"))
159
+ sandbox.bind("KV::Lookup", ->(key) { redis.get(key) })
85
160
 
86
161
  sandbox.eval(<<~RUBY)
87
162
  Project::User.name # => "alice"
@@ -89,7 +164,7 @@ sandbox.eval(<<~RUBY)
89
164
  RUBY
90
165
  ```
91
166
 
92
- Names must match `/\A[A-Z]\w*\z/`. Symbol kwargs travel transparently to the host method's keyword arguments. The registry seals at the first invocation (see [Invocation Lifecycle](#invocation-lifecycle)); later `#define` raises `ArgumentError`.
167
+ Each `::`-separated path segment must match `/\A[A-Z]\w*\z/`. Symbol kwargs travel transparently to the host method's keyword arguments. The registry seals at the first invocation (see [Invocation Lifecycle](#invocation-lifecycle)); later `#bind` raises `ArgumentError`.
93
168
 
94
169
  ### Output Capture
95
170
 
@@ -164,7 +239,7 @@ One Sandbox serves many invocations. Service bindings and preloaded snippets per
164
239
  ───────────── setup phase (mutable) ─────────────
165
240
 
166
241
  sandbox = Kobako::Sandbox.new
167
- sandbox.define(:KV).bind(:Lookup, ...)
242
+ sandbox.bind("KV::Lookup", ...)
168
243
  sandbox.preload(code: ..., name: :Adder)
169
244
  sandbox.preload(code: ..., name: :Greeter)
170
245
 
@@ -173,7 +248,7 @@ One Sandbox serves many invocations. Service bindings and preloaded snippets per
173
248
 
174
249
  ═════════════════ seal point ═════════════════
175
250
  First #eval or #run freezes the Service registry
176
- and snippet table. Further define / preload now
251
+ and snippet table. Further bind / preload now
177
252
  raise ArgumentError.
178
253
 
179
254
 
@@ -188,7 +263,7 @@ One Sandbox serves many invocations. Service bindings and preloaded snippets per
188
263
  :Adder → defines Adder
189
264
  :Greeter → defines Greeter
190
265
 
191
- 3. dispatch: eval(source) or run(:Target, *args)
266
+ 3. dispatch: eval(source) or run(:Target, *args, **kwargs)
192
267
 
193
268
  4. return value to host
194
269
 
@@ -206,11 +281,11 @@ For workloads that must be isolated from each other (one Sandbox per tenant, per
206
281
 
207
282
  For hosts that serve many short invocations, `Kobako::Pool` keeps a bounded set of warm, identically set-up Sandboxes and hands each one to a single exclusive holder at a time ([`docs/behavior/runtime.md`](docs/behavior/runtime.md) B-46..B-48). Construction forwards every `Sandbox.new` keyword verbatim; the optional block is the per-Sandbox setup window and runs exactly once per constructed Sandbox.
208
283
 
209
- `Kobako::Pool` is experimental today and is best treated as a convenience for warm, pre-configured reuse rather than a throughput optimisation. B-49 bakes the shared boot state into the artifact and every dynamic script still compiles and runs per invocation, so all a pool actually saves is the ~30 µs host-side `Sandbox.new`. For the workload kobako is built for — many small, short-lived Sandboxes running dynamic scripts — that is not a significant gain (~4-5% in the [serverless example](examples/serverless/README.md), and proportionally less once the script itself does real work).
284
+ `Kobako::Pool` is experimental today and is best treated as a convenience for warm, pre-configured reuse rather than a throughput optimisation. B-49 bakes the shared boot state into the artifact and every dynamic script still compiles and runs per invocation, so all a pool actually saves is the ~28 µs host-side `Sandbox.new`. For the workload kobako is built for — many small, short-lived Sandboxes running dynamic scripts — that is not a significant gain (~4-5% in the [serverless example](examples/serverless/README.md), and proportionally less once the script itself does real work).
210
285
 
211
286
  ```ruby
212
287
  pool = Kobako::Pool.new(slots: 4) do |sandbox|
213
- sandbox.define(:KV).bind(:Lookup, ->(key) { redis.get(key) })
288
+ sandbox.bind("KV::Lookup", ->(key) { redis.get(key) })
214
289
  end
215
290
 
216
291
  pool.with { |sandbox| sandbox.eval(%(KV::Lookup.call("user_42"))) }
@@ -228,7 +303,7 @@ Sandboxes construct lazily on first demand. `#with` yields a Sandbox with empty
228
303
  A Service method can accept a guest-supplied block via `&blk` and `yield` into it. The block body runs inside the Wasm guest; `break` / `next` / exceptions follow normal Ruby semantics, scoped to the single dispatch. See [`docs/behavior/yield.md`](docs/behavior/yield.md) B-23..B-30.
229
304
 
230
305
  ```ruby
231
- sandbox.define(:Seq).bind(:Map, ->(items, &blk) { items.map(&blk) })
306
+ sandbox.bind("Seq::Map", ->(items, &blk) { items.map(&blk) })
232
307
 
233
308
  sandbox.eval('Seq::Map.call([1, 2, 3]) { |x| x * 2 }')
234
309
  # => [2, 4, 6]
@@ -244,13 +319,13 @@ class Greeter
244
319
  def greet = "hi, #{@name}"
245
320
  end
246
321
 
247
- sandbox.define(:Factory).bind(:Make, ->(name) { Greeter.new(name) })
322
+ sandbox.bind("Factory::Make", ->(name) { Greeter.new(name) })
248
323
 
249
324
  sandbox.eval('Factory::Make.call("Bob").greet') # => "hi, Bob" (Handle round-trip inside guest)
250
325
  sandbox.eval('Factory::Make.call("Bob")') # => #<Greeter @name="Bob"> (B-37 restoration)
251
326
  ```
252
327
 
253
- A `break` value from a guest block is the one exception: it unwinds back to the guest Member call rather than to host code, so a Handle in it stays a Handle — restoring would just re-wrap the same object into a new id on the return trip.
328
+ A `break` value from a guest block is the one exception: it unwinds back to the guest Service call rather than to host code, so a Handle in it stays a Handle — restoring would just re-wrap the same object into a new id on the return trip.
254
329
 
255
330
  Each dispatch that hands back a non-wire-representable object allocates a *new* Handle — kobako never deduplicates by object identity (B-15, B-17). This is most visible with fluent / builder APIs. An `ActiveRecord::Relation` chain `spawn`s a fresh relation at each step, so every hop is an independent dispatch that binds its own Handle:
256
331
 
@@ -302,10 +377,10 @@ sandbox.run(:Greeter, name: "world") # => "hello, world"
302
377
 
303
378
  | Form | Signature | Snippet name source | Validation timing |
304
379
  |----------|--------------------------------------|---------------------------------------|----------------------------------------------------------------------------|
305
- | Source | `preload(code: "...", name: :Const)` | The `name:` keyword | Trial-compiled at preload; compile errors raise immediately |
306
- | Bytecode | `preload(binary: bytes)` | Read from the bytecode's `debug_info` | Deferred to first invocation; failure raises `Kobako::BytecodeError` |
380
+ | Source | `preload(code: "...", name: :Const)` | The `name:` keyword | First invocation's replay; compile errors raise `Kobako::SandboxError` |
381
+ | Bytecode | `preload(binary: bytes)` | Read from the bytecode's `debug_info` | First invocation's replay; structural failure raises `Kobako::BytecodeError` |
307
382
 
308
- Use the source form for snippets authored in your repo (compile errors fail fast at `#preload`); use the bytecode form when snippets ship as build artifacts from a separate `mrbc` pipeline. Both replay through the same per-invocation path.
383
+ Use the source form for snippets authored in your repo; use the bytecode form when snippets ship as build artifacts from a separate `mrbc` pipeline. Both replay through the same per-invocation path, so no snippet content failure surfaces at `#preload` — force the first replay with a no-op invocation (e.g. `sandbox.eval("nil")`) when you want validation before real traffic.
309
384
 
310
385
  ## Security
311
386
 
@@ -319,7 +394,7 @@ class ThemeReader # only #color is reachable; AppConfig.secret_key is n
319
394
  end
320
395
 
321
396
  sandbox = Kobako::Sandbox.new
322
- sandbox.define(:Cfg).bind(:Settings, ThemeReader.new) # not: bind(:Settings, AppConfig)
397
+ sandbox.bind("Cfg::Settings", ThemeReader.new) # not: bind("Cfg::Settings", AppConfig)
323
398
 
324
399
  sandbox.eval('Cfg::Settings.color') # => "#3366ff" — every other method raises NoMethodError
325
400
  ```
@@ -329,7 +404,7 @@ place: a private `respond_to_guest?(name)` answers, per method, whether the gues
329
404
  it. Returning `false` for every name makes the object opaque — a credential the guest
330
405
  forwards to another Service but never reads — while a named subset becomes an allow-list.
331
406
 
332
- Guest code can name any `<Namespace>::<Member>` path, but a forged name only resolves to
407
+ Guest code can name any `MyService::KV` path, but a forged name only resolves to
333
408
  something you bound — the real authorization gate is this host-side allowlist. Give each
334
409
  trust context its own Sandbox, and see [`docs/security-model.md`](docs/security-model.md) for the rest
335
410
  as security-design concerns: validating untrusted input, default-deny external effects,
@@ -342,15 +417,15 @@ Order-of-magnitude figures on macOS arm64, Ruby 3.4.7, YJIT off. Absolute values
342
417
  | Phase | Cost |
343
418
  |--------------------------------------------------------------|-----------------------|
344
419
  | First `Sandbox.new` ever for a Guest Binary (Module JIT, then disk-cached) | ~500 ms once per machine |
345
- | First `Sandbox.new` in a fresh process (`.cwasm` cache warm) | ~5 ms one-time |
346
- | Subsequent `Sandbox.new` (caches warm) | ~30 µs |
347
- | Warm `#eval("nil")` on a reused Sandbox | ~73 µs |
348
- | Warm `#run(:Entrypoint, ...)` dispatch | ~104 µs |
420
+ | First `Sandbox.new` in a fresh process (`.cwasm` cache warm) | ~3 ms one-time |
421
+ | Subsequent `Sandbox.new` (caches warm) | ~28 µs |
422
+ | Warm `#eval("nil")` on a reused Sandbox | ~71 µs |
423
+ | Warm `#run(:Entrypoint, ...)` dispatch | ~97 µs |
349
424
  | Service call amortized inside one invocation | ~6.8 µs |
350
- | Snippet replay per invocation | ~8 µs each |
425
+ | Snippet replay per invocation | ~7.6 µs each |
351
426
  | Per additional idle Sandbox (RSS) | ~1 KB |
352
427
 
353
- The Cranelift JIT runs once per machine and gem version — the compiled artifact persists in a `.cwasm` disk cache, so later processes deserialize in milliseconds. An idle Sandbox holds no wasm instance (the canonical boot state is baked into the artifact and instantiated per invocation), which is why a thousand idle tenants cost ~32 MB total. `ext/` does not release the GVL during wasmtime execution, so wasm work is GVL-serialized: aggregate throughput stays around 16k `#eval`/s regardless of Thread count, though Ruby-side `#eval` setup still overlaps. A +10% regression on any of the six SPEC-mandated benchmarks blocks release.
428
+ The Cranelift JIT runs once per machine and gem version — the compiled artifact persists in a `.cwasm` disk cache, so later processes deserialize in milliseconds. An idle Sandbox holds no wasm instance (the canonical boot state is baked into the artifact and instantiated per invocation), which is why a thousand idle tenants cost ~33 MB total. `ext/` does not release the GVL during wasmtime execution, so wasm work is GVL-serialized: aggregate throughput stays around 17k `#eval`/s regardless of Thread count, though Ruby-side `#eval` setup still overlaps. A +10% regression on any of the six SPEC-mandated benchmarks blocks release.
354
429
 
355
430
  Regexp is an opt-in capability gem, excluded from the default binary and the gated set; its throughput is tracked in a separate non-gated characterization (`#10` in [`benchmark/README.md`](benchmark/README.md)). There `=~` (~5 µs/match) costs about 4× `match?` (~1.2 µs), because `=~` eagerly builds the `MatchData` and match globals — prefer `match?` for boolean tests.
356
431
 
data/ROADMAP.md ADDED
@@ -0,0 +1,25 @@
1
+ # Roadmap
2
+
3
+ kobako is a Ruby gem providing an in-process Wasm sandbox for untrusted mruby
4
+ code: a wasmtime host runs a precompiled `kobako.wasm` guest, with host↔guest
5
+ Transport over a MessagePack wire. Features cover one-shot `#eval`, preload +
6
+ `#run` dispatch, Service injection at constant-path names, opaque
7
+ Capability Handles, block yield re-entry, three-class error attribution,
8
+ output capture, and a warm Sandbox pool.
9
+
10
+ | Feature | Entry Points | Notes |
11
+ |---------|-------------|-------|
12
+ | ✅ [F-01 Sandbox instantiation](docs/behavior/lifecycle.md) | [lib/kobako/sandbox.rb](lib/kobako/sandbox.rb) | B-22 (per-Thread isolation) is exercised only indirectly through the pool contention tests; no test cites it |
13
+ | ✅ [F-02 Service binding](docs/behavior/registration.md) | [lib/kobako/catalog/services.rb](lib/kobako/catalog/services.rb) | — |
14
+ | ✅ [F-04 Synchronous mruby source execution (`#eval`)](docs/behavior/lifecycle.md) | [lib/kobako/sandbox.rb](lib/kobako/sandbox.rb) | — |
15
+ | ✅ [F-05 Guest-initiated Transport dispatch](docs/behavior/dispatch.md) | [lib/kobako/transport/dispatcher.rb](lib/kobako/transport/dispatcher.rb) | — |
16
+ | ✅ [F-06 Capability Handle encoding and referencing](docs/behavior/dispatch.md) | [lib/kobako/catalog/handles.rb](lib/kobako/catalog/handles.rb) | — |
17
+ | ✅ [F-07 Three-class error attribution and raising](docs/behavior/errors.md) | [lib/kobako/outcome.rb](lib/kobako/outcome.rb) | E-26 (guest-entry envelope decode failure) has no exercising test — not reachable through the public API |
18
+ | ✅ [F-08 Guest output capture](docs/behavior/lifecycle.md) | [lib/kobako/capture.rb](lib/kobako/capture.rb) | — |
19
+ | ✅ [F-09 Host–guest message codec](docs/wire-codec.md) | [lib/kobako/codec/](lib/kobako/codec/) | — |
20
+ | ✅ [F-10 Reproducible build pipeline](SPEC.md#code-organization) | [tasks/wasm/build.rake](tasks/wasm/build.rake) | Verified by build-time gates (`rake anchors`, double-bake byte-identity, gemspec whitelist), not `test/` |
21
+ | ✅ [F-11 Multi-layer test and benchmark suite](SPEC.md#testing-style) | [test/](test/) | Benchmarks live in [benchmark/](benchmark/) with the gate in `tasks/bench/`; the anchor baseline advances only by deliberate re-bless |
22
+ | ✅ [F-12 Guest block reception and yield re-entry](docs/behavior/yield.md) | [lib/kobako/transport/yielder.rb](lib/kobako/transport/yielder.rb) | — |
23
+ | ✅ [F-13 Snippet preloading (`#preload`)](docs/behavior/invocation.md) | [lib/kobako/catalog/snippets.rb](lib/kobako/catalog/snippets.rb) | — |
24
+ | ✅ [F-14 Synchronous entrypoint dispatch (`#run`)](docs/behavior/invocation.md) | [lib/kobako/sandbox.rb](lib/kobako/sandbox.rb) | — |
25
+ | ✅ [F-15 Warm Sandbox pool checkout (`Kobako::Pool`)](docs/behavior/runtime.md) | [lib/kobako/pool.rb](lib/kobako/pool.rb) | — |
data/SECURITY.md CHANGED
@@ -25,7 +25,7 @@ ask to stay anonymous.
25
25
 
26
26
  In scope is anything that lets guest code cross the isolation boundary it should not:
27
27
  reaching host memory, the filesystem, the network, or `ENV`; obtaining ambient time or
28
- entropy the host froze; reaching a `Namespace::Member` you never bound; or a
28
+ entropy the host froze; reaching a Service you never bound; or a
29
29
  memory-safety fault in the host codec or wasmtime driver.
30
30
 
31
31
  Out of scope is what a bound Service is *designed* to expose: if guest code reaches a
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0](https://github.com/elct9620/kobako/compare/kobako-runtime-v0.8.0...kobako-runtime-v0.9.0) (2026-07-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **kobako-runtime:** Synchronize kobako crates versions
9
+
10
+ ## [0.8.0](https://github.com/elct9620/kobako/compare/kobako-runtime-v0.7.0...kobako-runtime-v0.8.0) (2026-07-08)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **crates:** give SetupError a Display so Error::Setup reads cleanly ([bc8b128](https://github.com/elct9620/kobako/commit/bc8b128c9e296319c7fef47441b412d2ce345dff))
16
+
3
17
  ## [0.7.0](https://github.com/elct9620/kobako/compare/kobako-runtime-v0.6.1...kobako-runtime-v0.7.0) (2026-07-03)
4
18
 
5
19
 
@@ -26,7 +26,7 @@ map the neutral types onto their own language surface.
26
26
 
27
27
  ```toml
28
28
  [dependencies]
29
- kobako-runtime = "0.7.0" # x-release-please-version
29
+ kobako-runtime = "0.9.0" # x-release-please-version
30
30
  ```
31
31
 
32
32
  ## License
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0](https://github.com/elct9620/kobako/compare/kobako-wasmtime-v0.8.0...kobako-wasmtime-v0.9.0) (2026-07-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **kobako-wasmtime:** Synchronize kobako crates versions
9
+
10
+ ## [0.8.0](https://github.com/elct9620/kobako/compare/kobako-wasmtime-v0.7.0...kobako-wasmtime-v0.8.0) (2026-07-08)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **crates:** keep the no-timeout epoch deadline within range ([a3255df](https://github.com/elct9620/kobako/commit/a3255df98a77825bb39b571a60fe6ff83d269d19))
16
+
3
17
  ## [0.7.0](https://github.com/elct9620/kobako/compare/kobako-wasmtime-v0.6.1...kobako-wasmtime-v0.7.0) (2026-07-03)
4
18
 
5
19
 
@@ -24,7 +24,7 @@ SDK consumes the same surface.
24
24
 
25
25
  ```toml
26
26
  [dependencies]
27
- kobako-wasmtime = "0.7.0" # x-release-please-version
27
+ kobako-wasmtime = "0.9.0" # x-release-please-version
28
28
  ```
29
29
 
30
30
  ## License
data/data/kobako.wasm CHANGED
Binary file
Binary file
Binary file
Binary file
@@ -6,7 +6,7 @@ module Kobako
6
6
  module Catalog
7
7
  # Host-side mapping from opaque integer Handle IDs to Ruby objects.
8
8
  # The table is owned by +Kobako::Sandbox+ and injected
9
- # into the per-Sandbox +Kobako::Catalog::Namespaces+ so guest→host dispatch
9
+ # into the per-Sandbox +Kobako::Catalog::Services+ so guest→host dispatch
10
10
  # resolves Handle targets and arguments against the same table that
11
11
  # host→guest wire encoding allocates into.
12
12
  #
@@ -95,7 +95,7 @@ module Kobako
95
95
  end
96
96
  end
97
97
 
98
- # Guard {#alloc} against issuing an ID past the cap. Returns +nil+
98
+ # Guard #alloc against issuing an ID past the cap. Returns +nil+
99
99
  # on success; raises +Kobako::HandleExhaustedError+ at exhaustion.
100
100
  def ensure_capacity!
101
101
  cap = Kobako::Handle::MAX_ID
@@ -107,7 +107,7 @@ module Kobako
107
107
  end
108
108
 
109
109
  # Single source of truth for the "unknown Handle id" raise used by
110
- # {#fetch}. Returns +nil+ on success; raises +Kobako::SandboxError+
110
+ # #fetch. Returns +nil+ on success; raises +Kobako::SandboxError+
111
111
  # when +id+ is not currently bound.
112
112
  def require_bound!(id)
113
113
  return if @entries.key?(id)