kobako 0.19.0-aarch64-linux → 0.21.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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/CHANGELOG.md +127 -0
  4. data/README.md +96 -44
  5. data/ROADMAP.md +1 -1
  6. data/crates/kobako-runtime/CHANGELOG.md +44 -0
  7. data/crates/kobako-runtime/README.md +1 -1
  8. data/crates/kobako-transport/CHANGELOG.md +31 -0
  9. data/crates/kobako-transport/README.md +43 -0
  10. data/crates/kobako-wasmtime/CHANGELOG.md +30 -0
  11. data/crates/kobako-wasmtime/README.md +1 -1
  12. data/data/kobako.wasm +0 -0
  13. data/lib/kobako/3.3/kobako.so +0 -0
  14. data/lib/kobako/3.4/kobako.so +0 -0
  15. data/lib/kobako/4.0/kobako.so +0 -0
  16. data/lib/kobako/catalog/extensions.rb +50 -43
  17. data/lib/kobako/catalog/handles.rb +7 -16
  18. data/lib/kobako/catalog/services.rb +24 -46
  19. data/lib/kobako/catalog/snippets.rb +16 -33
  20. data/lib/kobako/codec/decoder.rb +10 -13
  21. data/lib/kobako/codec/encoder.rb +7 -7
  22. data/lib/kobako/codec/error.rb +6 -6
  23. data/lib/kobako/codec/ext_types.rb +12 -72
  24. data/lib/kobako/codec/handle_walk.rb +6 -6
  25. data/lib/kobako/codec/state.rb +4 -56
  26. data/lib/kobako/codec/utils.rb +4 -4
  27. data/lib/kobako/codec.rb +11 -21
  28. data/lib/kobako/context.rb +208 -0
  29. data/lib/kobako/errors.rb +59 -16
  30. data/lib/kobako/execution.rb +52 -0
  31. data/lib/kobako/extension.rb +24 -10
  32. data/lib/kobako/outcome.rb +71 -128
  33. data/lib/kobako/payload/arguments.rb +59 -0
  34. data/lib/kobako/payload.rb +19 -0
  35. data/lib/kobako/pool.rb +1 -7
  36. data/lib/kobako/sandbox.rb +51 -191
  37. data/lib/kobako/sandbox_options.rb +24 -3
  38. data/lib/kobako/snippet/binary.rb +3 -4
  39. data/lib/kobako/snippet/source.rb +5 -6
  40. data/lib/kobako/snippet.rb +2 -2
  41. data/lib/kobako/transport/call.rb +21 -0
  42. data/lib/kobako/transport/dispatcher.rb +94 -142
  43. data/lib/kobako/transport/error.rb +21 -5
  44. data/lib/kobako/transport/reflection.rb +82 -0
  45. data/lib/kobako/transport/run.rb +25 -33
  46. data/lib/kobako/transport/yielder.rb +27 -36
  47. data/lib/kobako/transport.rb +11 -8
  48. data/lib/kobako/unresolved.rb +17 -0
  49. data/lib/kobako/usage.rb +7 -7
  50. data/lib/kobako/version.rb +1 -1
  51. data/lib/kobako.rb +1 -0
  52. data/release-please-config.json +47 -2
  53. data/sig/kobako/catalog/extensions.rbs +4 -6
  54. data/sig/kobako/catalog/handles.rbs +0 -2
  55. data/sig/kobako/catalog/services.rbs +4 -4
  56. data/sig/kobako/catalog/snippets.rbs +4 -2
  57. data/sig/kobako/codec/error.rbs +4 -4
  58. data/sig/kobako/codec/ext_types.rbs +0 -7
  59. data/sig/kobako/codec/state.rbs +0 -4
  60. data/sig/kobako/codec.rbs +4 -5
  61. data/sig/kobako/context.rbs +36 -0
  62. data/sig/kobako/errors.rbs +27 -6
  63. data/sig/kobako/execution.rbs +24 -0
  64. data/sig/kobako/extension.rbs +4 -2
  65. data/sig/kobako/outcome.rbs +12 -13
  66. data/sig/kobako/payload/arguments.rbs +26 -0
  67. data/sig/kobako/payload.rbs +4 -0
  68. data/sig/kobako/pool.rbs +0 -2
  69. data/sig/kobako/runtime.rbs +44 -14
  70. data/sig/kobako/sandbox.rbs +5 -24
  71. data/sig/kobako/sandbox_options.rbs +9 -2
  72. data/sig/kobako/snippet/binary.rbs +1 -1
  73. data/sig/kobako/snippet/source.rbs +1 -1
  74. data/sig/kobako/transport/call.rbs +21 -0
  75. data/sig/kobako/transport/dispatcher.rbs +9 -11
  76. data/sig/kobako/transport/error.rbs +11 -0
  77. data/sig/kobako/transport/reflection.rbs +15 -0
  78. data/sig/kobako/transport/run.rbs +1 -1
  79. data/sig/kobako/transport/yielder.rbs +2 -2
  80. data/sig/kobako/transport.rbs +8 -2
  81. data/sig/kobako/unresolved.rbs +4 -0
  82. metadata +18 -12
  83. data/lib/kobako/fault.rb +0 -38
  84. data/lib/kobako/outcome/panic.rb +0 -42
  85. data/lib/kobako/transport/request.rb +0 -76
  86. data/lib/kobako/transport/response.rb +0 -83
  87. data/lib/kobako/transport/yield.rb +0 -94
  88. data/sig/kobako/fault.rbs +0 -19
  89. data/sig/kobako/outcome/panic.rbs +0 -34
  90. data/sig/kobako/transport/request.rbs +0 -29
  91. data/sig/kobako/transport/response.rbs +0 -33
  92. data/sig/kobako/transport/yield.rbs +0 -34
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../codec"
4
- require_relative "yield"
5
4
 
6
5
  module Kobako
7
6
  # See lib/kobako/transport.rb for the umbrella module doc; this file
@@ -15,24 +14,25 @@ module Kobako
15
14
  # Service method observes it as an ordinary Ruby Proc through
16
15
  # #to_proc; +yield val+ / +block.call(val)+ invokes #yield, which
17
16
  # serialises the positional args, re-enters the guest via the injected
18
- # +yield_to_guest+ lambda, and reifies the +YieldResponse+ into Ruby
17
+ # +yield_to_guest+ lambda, and reifies the Yield Reply into Ruby
19
18
  # control flow:
20
19
  #
21
- # * +tag 0x01+ ok — return the decoded value to +yield+'s caller
22
- # * +tag 0x02+ break — +throw break_tag, value+ so the Dispatcher's
23
- # +catch+ frame unwinds the Service method
24
- # * +tag 0x04+ error — raise the +{class, message}+ payload at the
25
- # Service's yield site
20
+ # * ok — return the decoded value to +yield+'s caller
21
+ # * break — +throw break_tag, value+ so the Dispatcher's +catch+
22
+ # frame unwinds the Service method
23
+ # * error — raise the guest's class and message at the Service's
24
+ # yield site
26
25
  #
27
26
  # The Dispatcher calls #invalidate! from its +ensure+ block once
28
27
  # dispatch completes; any later call to a stashed Yielder then raises
29
28
  # +LocalJumpError+ — the observable shape of an escaped Yielder.
30
29
  class Yielder
31
- # +yield_to_guest+ is a +String → String+ callable (the ext's
32
- # per-dispatch +Kobako::Runtime::GuestYielder+) that
33
- # #yield invokes to re-enter the guest; +break_tag+ is the +catch+
34
- # throw tag the Dispatcher matches against to unwind the Service on
35
- # +tag 0x02+. +handler+ is the Sandbox's +Kobako::Catalog::Handles+,
30
+ # +yield_to_guest+ is the ext's per-dispatch
31
+ # +Kobako::Runtime::GuestYielder+, which #yield invokes to re-enter
32
+ # the guest: it takes the argument payload and answers the reply
33
+ # already split into +[arm, body, class]+. +break_tag+ is the
34
+ # +catch+ throw tag the Dispatcher matches against to unwind the
35
+ # Service on a break. +handler+ is the invocation's +Kobako::Catalog::Handles+,
36
36
  # used to restore a Capability Handle in the block's ok value back to
37
37
  # its host object before it reaches the Service +yield+ site.
38
38
  def initialize(yield_to_guest, break_tag, handler)
@@ -42,7 +42,7 @@ module Kobako
42
42
  @active = true
43
43
  end
44
44
 
45
- # Re-enter the guest with +args+ and reify the YieldResponse into
45
+ # Re-enter the guest with +args+ and reify the Yield Reply into
46
46
  # Ruby control flow. Raises +LocalJumpError+ if called after
47
47
  # #invalidate!. The ok value is consumed by the host Service
48
48
  # method, so a Capability Handle in it is restored to its host object.
@@ -52,18 +52,13 @@ module Kobako
52
52
  def yield(*args)
53
53
  raise LocalJumpError, "guest block invoked after host dispatch frame returned" unless @active
54
54
 
55
- # Yield arguments are a payload position: a +Kobako::Fault+ among
56
- # them has no wire representation, so the encode refuses it at
57
- # this call site. The tracking bracket below opens only around the
58
- # decode: the guest re-entry may run nested dispatches whose own
59
- # brackets would otherwise pollute the signal.
60
- bytes = @yield_to_guest.call(Kobako::Codec.forbid_faults { Kobako::Codec::Encoder.encode(args) })
61
- response, carried_handle = Kobako::Codec.track_handles { Kobako::Transport::Yield.decode(bytes) }
62
- return restore(response.value, carried_handle) if response.ok?
55
+ arm, body, klass = @yield_to_guest.call(Kobako::Codec::Encoder.encode(args))
56
+ raise "#{klass}: #{body}" if arm == :error
63
57
 
64
- throw @break_tag, response.value if response.break?
58
+ value, carried_handle = decode_body(body)
59
+ throw @break_tag, value if arm == :break
65
60
 
66
- raise yield_failure(response.value, default: "yield error")
61
+ restore(value, carried_handle)
67
62
  end
68
63
 
69
64
  # The Proc the Dispatcher passes as +&block+, binding #yield so a
@@ -81,6 +76,15 @@ module Kobako
81
76
 
82
77
  private
83
78
 
79
+ # Decode a value-carrying arm's payload, answering the value and
80
+ # whether the decode carried a Capability Handle. The tracking
81
+ # bracket opens only around this decode: the guest re-entry may run
82
+ # nested dispatches whose own brackets would otherwise pollute the
83
+ # signal.
84
+ def decode_body(body)
85
+ Kobako::Codec.track_handles { Kobako::Codec::Decoder.decode(body) }
86
+ end
87
+
84
88
  # Restore any Capability Handle in a block's ok value to its host
85
89
  # object via the injected +Catalog::Handles+. Only the
86
90
  # ok path calls this — host code consumes the ok value, whereas a
@@ -92,19 +96,6 @@ module Kobako
92
96
 
93
97
  Kobako::Codec::HandleWalk.deep_restore(value, @handler)
94
98
  end
95
-
96
- # Reify a +YieldResponse+ tag 0x04 payload into a +RuntimeError+ the
97
- # Service method observes at its +yield+ site. The +{class, message,
98
- # backtrace}+ shape mirrors the +Kobako::Transport::Yield+ tag 0x04
99
- # payload; +default+ provides a fallback when the payload is not a
100
- # Hash.
101
- def yield_failure(payload, default:)
102
- return RuntimeError.new(default) unless payload.is_a?(Hash)
103
-
104
- klass = payload["class"] || "RuntimeError"
105
- message = payload["message"] || default
106
- RuntimeError.new("#{klass}: #{message}")
107
- end
108
99
  end
109
100
  end
110
101
  end
@@ -1,19 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "transport/request"
4
- require_relative "transport/response"
3
+ require_relative "transport/call"
5
4
  require_relative "transport/run"
6
- require_relative "transport/yield"
7
5
  require_relative "transport/yielder"
8
6
  require_relative "transport/error"
7
+ require_relative "transport/reflection"
9
8
  require_relative "transport/dispatcher"
10
9
 
11
10
  module Kobako
12
- # Kobako::Transport — host↔guest message transport namespace.
13
- # Houses the envelope value objects (Request / Response / Run / Yield),
14
- # the guest→host +Dispatcher+, and the host→guest +Yielder+.
15
- # +Sandbox#initialize+ composes them onto the
16
- # +Runtime+ as a dispatch +Proc+ + +yield_to_guest+ lambda pair.
11
+ # Kobako::Transport — host↔guest message transport namespace. Houses the
12
+ # host side of one Call/Reply exchange: the call value objects +Call+
13
+ # (guest→host, as the native side decoded it) and +Run+ (host→guest), the
14
+ # +Dispatcher+ that answers a routed Call, the +Yielder+ that re-enters
15
+ # the guest for a block, the +Reflection+ floor a dispatch must clear, and
16
+ # +Error+ for a wire violation the host detects. Each invocation's
17
+ # +Context+ composes them into the dispatch +Proc+ it passes +Runtime+ for
18
+ # that run.
19
+ #
17
20
  # "RPC" was deliberately not chosen — it implies a cross-process boundary that
18
21
  # kobako does not have, since host and guest share one OS thread and
19
22
  # one wasm linear memory. See
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kobako
4
+ # Kobako::Unresolved — the sentinel backing a fillable Service path: one
5
+ # declared with +Sandbox#bind(path)+ carrying no object. It reserves the
6
+ # path's Frame 1 slot so the guest sees the bound constant while the host
7
+ # defers the object it stands for. A guest dispatch to an unfilled fillable
8
+ # is refused as an unresolved target and surfaces as +Kobako::ServiceError+
9
+ # when the guest leaves it unrescued — the same capability-failure channel
10
+ # as an idiom with no backend bound.
11
+ #
12
+ # A single shared value; only its identity distinguishes it, so the dispatch
13
+ # layer recognises it with +equal?+. A Host App may name it at a +bind+ site
14
+ # to declare a fillable explicitly.
15
+ module Unresolved
16
+ end
17
+ end
data/lib/kobako/usage.rb CHANGED
@@ -21,16 +21,16 @@ module Kobako
21
21
  # the high-water.
22
22
  #
23
23
  # Both readers are populated on every outcome, including +TrapError+
24
- # branches, so the Host App can read +Sandbox#usage+ after rescuing a
25
- # trap to diagnose how much of the budget the failing invocation
26
- # consumed. Before the first invocation +Sandbox#usage+ returns the
27
- # pre-invocation sentinel +Kobako::Usage::EMPTY+.
24
+ # branches, so the Host App can read +#usage+ off the run's
25
+ # +Kobako::Execution+ — the one a raised error carries on +#execution+ —
26
+ # after rescuing a trap to diagnose how much of the budget the failing
27
+ # invocation consumed.
28
28
  #
29
29
  # Built on the +class X < Data.define(...)+ subclass form (the
30
- # Steep-friendly shape — see +lib/kobako/outcome/panic.rb+).
30
+ # Steep-friendly shape — see +.rubocop.yml+ for the rationale).
31
31
  class Usage < Data.define(:wall_time, :memory_peak)
32
- # Pre-invocation sentinel. Reused by +Sandbox+ before any invocation
33
- # has run so callers do not need to handle a +nil+ +#usage+.
32
+ # Pre-run sentinel. A fresh +Kobako::Context+ holds it until its guest
33
+ # runs, so an Execution's +#usage+ is never +nil+.
34
34
  EMPTY = new(wall_time: 0.0, memory_peak: 0)
35
35
  end
36
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobako
4
- VERSION = "0.19.0"
4
+ VERSION = "0.21.0"
5
5
  end
data/lib/kobako.rb CHANGED
@@ -10,6 +10,7 @@ rescue LoadError
10
10
  end
11
11
 
12
12
  require_relative "kobako/errors"
13
+ require_relative "kobako/unresolved"
13
14
  require_relative "kobako/extension"
14
15
  require_relative "kobako/transport"
15
16
  require_relative "kobako/catalog"
@@ -22,7 +22,7 @@
22
22
  {
23
23
  "type": "toml",
24
24
  "path": "/wasm/kobako-core/Cargo.toml",
25
- "jsonpath": "$.dependencies['kobako-codec'].version"
25
+ "jsonpath": "$.dependencies['kobako-transport'].version"
26
26
  },
27
27
  {
28
28
  "type": "generic",
@@ -39,6 +39,11 @@
39
39
  "path": "/wasm/Cargo.lock",
40
40
  "jsonpath": "$.package[?(@.name=='kobako-mruby')].version"
41
41
  },
42
+ {
43
+ "type": "toml",
44
+ "path": "/wasm/kobako-mruby/Cargo.toml",
45
+ "jsonpath": "$.dependencies['kobako-transport'].version"
46
+ },
42
47
  {
43
48
  "type": "toml",
44
49
  "path": "/wasm/kobako-mruby/Cargo.toml",
@@ -115,6 +120,31 @@
115
120
  }
116
121
  ]
117
122
  },
123
+ "crates/kobako-transport": {
124
+ "component": "kobako-transport",
125
+ "release-type": "rust",
126
+ "extra-files": [
127
+ {
128
+ "type": "toml",
129
+ "path": "/Cargo.lock",
130
+ "jsonpath": "$.package[?(@.name=='kobako-transport')].version"
131
+ },
132
+ {
133
+ "type": "toml",
134
+ "path": "/crates/Cargo.lock",
135
+ "jsonpath": "$.package[?(@.name=='kobako-transport')].version"
136
+ },
137
+ {
138
+ "type": "toml",
139
+ "path": "/wasm/Cargo.lock",
140
+ "jsonpath": "$.package[?(@.name=='kobako-transport')].version"
141
+ },
142
+ {
143
+ "type": "generic",
144
+ "path": "/crates/kobako-transport/README.md"
145
+ }
146
+ ]
147
+ },
118
148
  "crates/kobako-codec": {
119
149
  "component": "kobako-codec",
120
150
  "release-type": "rust",
@@ -149,6 +179,11 @@
149
179
  "path": "/Cargo.lock",
150
180
  "jsonpath": "$.package[?(@.name=='kobako-runtime')].version"
151
181
  },
182
+ {
183
+ "type": "toml",
184
+ "path": "/crates/kobako-runtime/Cargo.toml",
185
+ "jsonpath": "$.dependencies['kobako-transport'].version"
186
+ },
152
187
  {
153
188
  "type": "generic",
154
189
  "path": "/crates/kobako-runtime/README.md"
@@ -174,6 +209,11 @@
174
209
  "path": "/crates/kobako-wasmtime/Cargo.toml",
175
210
  "jsonpath": "$.dependencies['kobako-runtime'].version"
176
211
  },
212
+ {
213
+ "type": "toml",
214
+ "path": "/crates/kobako-wasmtime/Cargo.toml",
215
+ "jsonpath": "$.dependencies['kobako-transport'].version"
216
+ },
177
217
  {
178
218
  "type": "generic",
179
219
  "path": "/crates/kobako-wasmtime/README.md"
@@ -189,6 +229,11 @@
189
229
  "path": "/crates/Cargo.lock",
190
230
  "jsonpath": "$.package[?(@.name=='kobako')].version"
191
231
  },
232
+ {
233
+ "type": "toml",
234
+ "path": "/crates/kobako/Cargo.toml",
235
+ "jsonpath": "$.dependencies['kobako-transport'].version"
236
+ },
192
237
  {
193
238
  "type": "toml",
194
239
  "path": "/crates/kobako/Cargo.toml",
@@ -215,7 +260,7 @@
215
260
  {
216
261
  "type": "linked-versions",
217
262
  "groupName": "kobako crates",
218
- "components": ["kobako-codec", "kobako-core", "kobako-mruby", "kobako-io", "kobako-json", "kobako-regexp", "kobako-baker", "kobako-runtime", "kobako-wasmtime", "kobako-sdk"]
263
+ "components": ["kobako-transport", "kobako-codec", "kobako-core", "kobako-mruby", "kobako-io", "kobako-json", "kobako-regexp", "kobako-baker", "kobako-runtime", "kobako-wasmtime", "kobako-sdk"]
219
264
  }
220
265
  ],
221
266
  "extra-files": [
@@ -7,21 +7,19 @@ module Kobako
7
7
 
8
8
  def seal!: () -> self
9
9
 
10
- def refresh_backends!: (Kobako::Catalog::Services services) -> self
10
+ def resolve: () -> Hash[String, untyped]
11
11
 
12
12
  private
13
13
 
14
- def refresh_backend: (untyped extension, Kobako::Catalog::Services services, Hash[untyped, untyped] resolved) -> void
14
+ def install_object: (untyped backend) -> untyped
15
+
16
+ def resolve_backend: (untyped extension, Hash[String, untyped] resolved, Hash[untyped, untyped] by_provider) -> void
15
17
 
16
18
  def validate!: (untyped extension) -> void
17
19
 
18
20
  def assert_dependencies!: () -> void
19
21
 
20
22
  def symbolize: (untyped name) -> untyped
21
-
22
- def callable?: (untyped provider) -> bool
23
-
24
- def initial_object: (untyped provider) -> untyped
25
23
  end
26
24
  end
27
25
  end
@@ -7,8 +7,6 @@ module Kobako
7
7
 
8
8
  def fetch: (Integer id) -> untyped
9
9
 
10
- def reset!: () -> self
11
-
12
10
  def size: () -> Integer
13
11
 
14
12
  private
@@ -3,15 +3,15 @@ module Kobako
3
3
  class Services
4
4
  NAME_PATTERN: Regexp
5
5
 
6
- def initialize: (?handler: Kobako::Catalog::Handles) -> void
6
+ def initialize: () -> void
7
7
 
8
8
  def bind: (Symbol | String path, untyped object) -> self
9
9
 
10
- def lookup: (Symbol | String target) -> untyped
10
+ def bound?: (Symbol | String path) -> bool
11
11
 
12
- def refresh: (Symbol | String path, untyped object) -> self
12
+ def lookup: (Symbol | String target) -> untyped
13
13
 
14
- def encode: () -> String
14
+ def paths: () -> Array[String]
15
15
 
16
16
  def seal!: () -> self
17
17
 
@@ -5,11 +5,13 @@ module Kobako
5
5
 
6
6
  type entry = Kobako::Snippet::Source | Kobako::Snippet::Binary
7
7
 
8
+ type tuple = [Symbol, String?, String]
9
+
8
10
  def initialize: () -> void
9
11
 
10
12
  def register: (?code: String?, ?name: (Symbol | String)?, ?binary: String?) -> (Symbol | nil)
11
13
 
12
- def encode: () -> String
14
+ def entries: () -> Array[tuple]
13
15
 
14
16
  private
15
17
 
@@ -19,7 +21,7 @@ module Kobako
19
21
 
20
22
  def register_binary!: (String bytes) -> nil
21
23
 
22
- def entry_payload: (entry) -> Hash[String, untyped]
24
+ def entry_tuple: (entry) -> tuple
23
25
 
24
26
  def normalize_name: (Symbol | String name) -> Symbol
25
27
  end
@@ -3,16 +3,16 @@ module Kobako
3
3
  class Error < StandardError
4
4
  end
5
5
 
6
- class Truncated < Error
6
+ class TruncatedInputError < Error
7
7
  end
8
8
 
9
- class InvalidType < Error
9
+ class InvalidTypeError < Error
10
10
  end
11
11
 
12
- class InvalidEncoding < Error
12
+ class InvalidEncodingError < Error
13
13
  end
14
14
 
15
- class UnsupportedType < Error
15
+ class UnsupportedTypeError < Error
16
16
  end
17
17
  end
18
18
  end
@@ -3,7 +3,6 @@ module Kobako
3
3
  module ExtTypes
4
4
  EXT_SYMBOL: Integer
5
5
  EXT_HANDLE: Integer
6
- EXT_ERRENV: Integer
7
6
  UNREPRESENTABLE_GUARD_ID: Integer
8
7
 
9
8
  def self?.build_factory: () -> MessagePack::Factory
@@ -16,16 +15,10 @@ module Kobako
16
15
 
17
16
  def self?.unpack_handle: (String payload, State state) -> Kobako::Handle
18
17
 
19
- def self?.pack_fault: (Kobako::Fault fault, State state) -> String
20
-
21
- def self?.unpack_fault: (String payload, State state) -> Kobako::Fault
22
-
23
18
  def self?.register_symbol: (MessagePack::Factory factory) -> void
24
19
 
25
20
  def self?.register_handle: (MessagePack::Factory factory) -> void
26
21
 
27
- def self?.register_fault: (MessagePack::Factory factory) -> void
28
-
29
22
  def self?.register_unrepresentable: (MessagePack::Factory factory) -> void
30
23
  end
31
24
 
@@ -1,16 +1,12 @@
1
1
  module Kobako
2
2
  module Codec
3
3
  class State
4
- MAX_EXT_DEPTH: Integer
5
4
  STATE_KEY: Symbol
6
5
 
7
6
  def self.current: () -> State
8
7
 
9
8
  def track_handles: [T] { () -> T } -> [T, bool]
10
9
  def record_handle!: () -> void
11
- def forbid_faults: [T] { () -> T } -> T
12
- def faults_forbidden?: () -> bool
13
- def within_ext_frame: [T] (singleton(Kobako::Codec::Error) over_limit) { () -> T } -> T
14
10
 
15
11
  private
16
12
 
data/sig/kobako/codec.rbs CHANGED
@@ -2,18 +2,17 @@ module Kobako
2
2
  module Codec
3
3
  MAX_NESTING_DEPTH: Integer
4
4
 
5
- # A value in the closed wire type set (docs/wire-codec.md § Type
6
- # Mapping): the scalar leaves, a Capability Handle, and Array / Hash
5
+ # A value in the closed wire type set (docs/wire/payload-msgpack.md
6
+ # § Type Mapping): the scalar leaves, a Capability Handle, and Array / Hash
7
7
  # containers of the same. The by-value payloads that cross the wire —
8
- # dispatch arguments and success values — inhabit this type; a Fault
9
- # (ext 0x02) is an envelope-position value, not a wire_value.
8
+ # dispatch arguments and success values — inhabit this type; a Fault is
9
+ # an envelope shape, not a wire_value.
10
10
  type wire_value = nil | bool | Integer | Float | String | Symbol
11
11
  | Kobako::Handle
12
12
  | Array[wire_value]
13
13
  | Hash[wire_value, wire_value]
14
14
 
15
15
  def self.track_handles: [T] { () -> T } -> [T, bool]
16
- def self.forbid_faults: [T] { () -> T } -> T
17
16
 
18
17
  # The Handle allocator/resolver a wire walk works against: alloc
19
18
  # registers a non-wire-representable object and returns its Handle,
@@ -0,0 +1,36 @@
1
+ module Kobako
2
+ class Context
3
+ def initialize: (
4
+ runtime: Kobako::Runtime,
5
+ services: Kobako::Catalog::Services,
6
+ snippets: Kobako::Catalog::Snippets,
7
+ extensions: Kobako::Catalog::Extensions
8
+ ) -> void
9
+
10
+ def bind: (Symbol | String path, untyped object) -> self
11
+
12
+ def lookup: (Symbol | String path) -> untyped
13
+
14
+ def eval: (String code) ?{ (Kobako::Context) -> void } -> Kobako::Execution
15
+
16
+ def run: (Kobako::Transport::Run request) ?{ (Kobako::Context) -> void } -> Kobako::Execution
17
+
18
+ private
19
+
20
+ def collect_overrides: () { (Kobako::Context) -> void } -> void
21
+
22
+ def dispatch_handler: () -> Kobako::Transport::dispatch_proc
23
+
24
+ def populate_observability!: (Kobako::Runtime::Snapshot snapshot) -> void
25
+
26
+ def trap_class_for: (Kobako::TrapError err) -> singleton(Kobako::TrapError)
27
+
28
+ def trap_error_for: (Kobako::Runtime::Snapshot snapshot, Symbol verb) -> Kobako::TrapError
29
+
30
+ def build_execution: (untyped value, failed: bool) -> Kobako::Execution
31
+
32
+ def settle_outcome: (Kobako::Runtime::Snapshot snapshot, Symbol verb, Symbol? entrypoint) -> Kobako::Execution
33
+
34
+ def invoke!: (Symbol verb, ?entrypoint: Symbol?) { () -> Kobako::Runtime::Snapshot } -> Kobako::Execution
35
+ end
36
+ end
@@ -2,7 +2,14 @@ module Kobako
2
2
  class Error < StandardError
3
3
  end
4
4
 
5
+ module CarriesExecution
6
+ attr_reader execution: Kobako::Execution?
7
+
8
+ def with_execution: (Kobako::Execution execution) -> self
9
+ end
10
+
5
11
  class TrapError < Error
12
+ include CarriesExecution
6
13
  end
7
14
 
8
15
  class TimeoutError < TrapError
@@ -17,27 +24,27 @@ module Kobako
17
24
  class ModuleNotBuiltError < SetupError
18
25
  end
19
26
 
20
- module StructuredError : Error
27
+ module Diagnosable : Error
21
28
  attr_reader origin: String?
22
29
  attr_reader klass: String?
23
30
  attr_reader backtrace_lines: Array[String]?
24
- attr_reader details: untyped
25
31
 
26
32
  def initialize: (
27
33
  String message,
28
34
  ?origin: String?,
29
35
  ?klass: String?,
30
- ?backtrace_lines: Array[String]?,
31
- ?details: untyped
36
+ ?backtrace_lines: Array[String]?
32
37
  ) -> void
33
38
  end
34
39
 
35
40
  class SandboxError < Error
36
- include StructuredError
41
+ include Diagnosable
42
+ include CarriesExecution
37
43
  end
38
44
 
39
45
  class ServiceError < Error
40
- include StructuredError
46
+ include Diagnosable
47
+ include CarriesExecution
41
48
  end
42
49
 
43
50
  class HandleExhaustedError < SandboxError
@@ -46,6 +53,20 @@ module Kobako
46
53
  class BytecodeError < SandboxError
47
54
  end
48
55
 
56
+ class UndefinedEntrypointError < SandboxError
57
+ attr_reader name: Symbol?
58
+ attr_reader available: Array[Symbol]
59
+
60
+ def initialize: (
61
+ String message,
62
+ ?name: Symbol?,
63
+ ?available: Array[Symbol],
64
+ ?origin: String?,
65
+ ?klass: String?,
66
+ ?backtrace_lines: Array[String]?
67
+ ) -> void
68
+ end
69
+
49
70
  class PoolTimeoutError < Error
50
71
  end
51
72
  end
@@ -0,0 +1,24 @@
1
+ module Kobako
2
+ class Execution
3
+ attr_reader value: untyped
4
+ attr_reader usage: Kobako::Usage
5
+
6
+ def initialize: (
7
+ value: untyped,
8
+ usage: Kobako::Usage,
9
+ stdout: Kobako::Capture,
10
+ stderr: Kobako::Capture,
11
+ failed: bool
12
+ ) -> void
13
+
14
+ def failed?: () -> bool
15
+
16
+ def stdout: () -> String
17
+
18
+ def stderr: () -> String
19
+
20
+ def stdout_truncated?: () -> bool
21
+
22
+ def stderr_truncated?: () -> bool
23
+ end
24
+ end
@@ -11,10 +11,12 @@ module Kobako
11
11
 
12
12
  class Backend < Data
13
13
  attr_reader path: String
14
+ attr_reader object: untyped
14
15
  attr_reader provider: untyped
15
16
 
16
- def self.new: (path: String, provider: untyped) -> Kobako::Extension::Backend
17
- | (String path, untyped provider) -> Kobako::Extension::Backend
17
+ def self.new: (path: String, ?object: untyped, ?provider: untyped) -> Kobako::Extension::Backend
18
+
19
+ def initialize: (path: String, ?object: untyped, ?provider: untyped) -> void
18
20
  end
19
21
  end
20
22
  end
@@ -1,24 +1,23 @@
1
1
  module Kobako
2
2
  module Outcome
3
- TYPE_VALUE: Integer
4
- TYPE_PANIC: Integer
3
+ ORIGIN_SANDBOX: String
4
+ ORIGIN_SERVICE: String
5
+ SUBCLASSES: Hash[String, singleton(SandboxError)]
5
6
 
6
- def self?.decode: (String bytes) -> untyped
7
+ type panic_fields = [String, String, String, Array[String], Array[String]]
7
8
 
8
- def self?.build_trap_error: (Integer? tag) -> TrapError
9
+ def self?.reify: (Symbol kind, String payload, panic_fields? panic, ?entrypoint: Symbol?) -> Kobako::Codec::wire_value
9
10
 
10
- def self?.split_tag: (String bytes) -> [Integer?, String]
11
+ # Everything below is private_class_method at runtime; RBS cannot mark a
12
+ # `self?` method private, so the declarations stay visible to the checker.
13
+ def self?.panic_error: (panic_fields panic, Symbol? entrypoint) -> (SandboxError | ServiceError)
11
14
 
12
- def self?.decode_value: (String body) -> Kobako::Codec::wire_value
15
+ def self?.error_class: (String origin, String klass) -> (singleton(SandboxError) | singleton(ServiceError))
13
16
 
14
- def self?.decode_panic: (String body) -> void
17
+ def self?.trap_error: (Symbol kind) -> TrapError
15
18
 
16
- def self?.build_panic_record: (String body) -> Panic
19
+ def self?.decode_value: (String payload) -> Kobako::Codec::wire_value
17
20
 
18
- def self?.build_panic_error: (Panic panic) -> (SandboxError | ServiceError)
19
-
20
- def self?.panic_target_class: (Panic panic) -> (singleton(SandboxError) | singleton(ServiceError))
21
-
22
- def self?.build_transport_error: (String message, ?detail: String?) -> Transport::Error
21
+ def self?.wire_error: (String message, ?diagnostic: String?) -> Transport::Error
23
22
  end
24
23
  end