kobako 0.12.2 → 0.14.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.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +41 -0
- data/Cargo.lock +126 -137
- data/README.md +5 -3
- data/ROADMAP.md +26 -0
- data/crates/kobako-runtime/CHANGELOG.md +15 -0
- data/crates/kobako-runtime/Cargo.toml +1 -1
- data/crates/kobako-runtime/README.md +1 -1
- data/crates/kobako-runtime/src/error.rs +8 -0
- data/crates/kobako-runtime/src/lib.rs +4 -2
- data/crates/kobako-runtime/src/profile.rs +35 -0
- data/crates/kobako-runtime/src/runtime.rs +7 -0
- data/crates/kobako-wasmtime/CHANGELOG.md +15 -0
- data/crates/kobako-wasmtime/Cargo.toml +4 -4
- data/crates/kobako-wasmtime/README.md +1 -1
- data/crates/kobako-wasmtime/src/ambient.rs +5 -2
- data/crates/kobako-wasmtime/src/config.rs +10 -2
- data/crates/kobako-wasmtime/src/driver.rs +13 -1
- data/crates/kobako-wasmtime/src/frames.rs +105 -5
- data/crates/kobako-wasmtime/src/instance_pre.rs +7 -6
- data/crates/kobako-wasmtime/src/invocation.rs +4 -5
- data/crates/kobako-wasmtime/src/trap.rs +42 -21
- data/data/kobako.wasm +0 -0
- data/ext/kobako/Cargo.toml +1 -1
- data/ext/kobako/src/lib.rs +0 -2
- data/ext/kobako/src/runtime.rs +114 -38
- data/lib/kobako/catalog/handles.rb +2 -2
- data/lib/kobako/catalog/namespaces.rb +2 -2
- data/lib/kobako/catalog/snippets.rb +1 -1
- data/lib/kobako/codec/decoder.rb +7 -7
- data/lib/kobako/codec/encoder.rb +2 -2
- data/lib/kobako/codec/error.rb +3 -3
- data/lib/kobako/codec/factory.rb +10 -10
- data/lib/kobako/codec/handle_walk.rb +17 -21
- data/lib/kobako/codec/utils.rb +9 -9
- data/lib/kobako/codec.rb +4 -4
- data/lib/kobako/errors.rb +14 -39
- data/lib/kobako/handle.rb +5 -2
- data/lib/kobako/namespace.rb +3 -3
- data/lib/kobako/outcome.rb +1 -0
- data/lib/kobako/sandbox.rb +61 -33
- data/lib/kobako/sandbox_options.rb +51 -9
- data/lib/kobako/transport/dispatcher.rb +17 -14
- data/lib/kobako/transport/request.rb +2 -2
- data/lib/kobako/transport/response.rb +2 -2
- data/lib/kobako/transport/run.rb +1 -1
- data/lib/kobako/transport/yield.rb +3 -3
- data/lib/kobako/transport/yielder.rb +6 -6
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +0 -1
- data/release-please-config.json +66 -6
- data/sig/kobako/codec/handle_walk.rbs +2 -2
- data/sig/kobako/codec.rbs +11 -0
- data/sig/kobako/handle.rbs +0 -2
- data/sig/kobako/runtime.rbs +8 -3
- data/sig/kobako/sandbox.rbs +9 -5
- data/sig/kobako/sandbox_options.rbs +11 -2
- data/sig/kobako/transport/dispatcher.rbs +8 -8
- data/sig/kobako/transport/run.rbs +1 -1
- data/sig/kobako/transport/yielder.rbs +2 -2
- data/sig/kobako/transport.rbs +8 -0
- metadata +3 -4
- data/ext/kobako/src/snapshot.rs +0 -75
- data/lib/kobako/snapshot.rb +0 -32
- data/sig/kobako/snapshot.rbs +0 -12
data/release-please-config.json
CHANGED
|
@@ -18,29 +18,39 @@
|
|
|
18
18
|
"path": "/wasm/Cargo.lock",
|
|
19
19
|
"jsonpath": "$.package[?(@.name=='kobako-core')].version"
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
"type": "toml",
|
|
23
|
+
"path": "/wasm/kobako-core/Cargo.toml",
|
|
24
|
+
"jsonpath": "$.dependencies['kobako-codec'].version"
|
|
25
|
+
},
|
|
21
26
|
{
|
|
22
27
|
"type": "generic",
|
|
23
28
|
"path": "/wasm/kobako-core/README.md"
|
|
24
29
|
}
|
|
25
30
|
]
|
|
26
31
|
},
|
|
27
|
-
"wasm/kobako": {
|
|
28
|
-
"component": "kobako-
|
|
32
|
+
"wasm/kobako-mruby": {
|
|
33
|
+
"component": "kobako-mruby",
|
|
29
34
|
"release-type": "rust",
|
|
30
35
|
"extra-files": [
|
|
31
36
|
{
|
|
32
37
|
"type": "toml",
|
|
33
38
|
"path": "/wasm/Cargo.lock",
|
|
34
|
-
"jsonpath": "$.package[?(@.name=='kobako')].version"
|
|
39
|
+
"jsonpath": "$.package[?(@.name=='kobako-mruby')].version"
|
|
35
40
|
},
|
|
36
41
|
{
|
|
37
42
|
"type": "toml",
|
|
38
|
-
"path": "/wasm/kobako/Cargo.toml",
|
|
43
|
+
"path": "/wasm/kobako-mruby/Cargo.toml",
|
|
39
44
|
"jsonpath": "$.dependencies['kobako-core'].version"
|
|
40
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"type": "toml",
|
|
48
|
+
"path": "/wasm/kobako-mruby/Cargo.toml",
|
|
49
|
+
"jsonpath": "$.dependencies['kobako-codec'].version"
|
|
50
|
+
},
|
|
41
51
|
{
|
|
42
52
|
"type": "generic",
|
|
43
|
-
"path": "/wasm/kobako/README.md"
|
|
53
|
+
"path": "/wasm/kobako-mruby/README.md"
|
|
44
54
|
}
|
|
45
55
|
]
|
|
46
56
|
},
|
|
@@ -104,6 +114,26 @@
|
|
|
104
114
|
}
|
|
105
115
|
]
|
|
106
116
|
},
|
|
117
|
+
"crates/kobako-codec": {
|
|
118
|
+
"component": "kobako-codec",
|
|
119
|
+
"release-type": "rust",
|
|
120
|
+
"extra-files": [
|
|
121
|
+
{
|
|
122
|
+
"type": "toml",
|
|
123
|
+
"path": "/crates/Cargo.lock",
|
|
124
|
+
"jsonpath": "$.package[?(@.name=='kobako-codec')].version"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "toml",
|
|
128
|
+
"path": "/wasm/Cargo.lock",
|
|
129
|
+
"jsonpath": "$.package[?(@.name=='kobako-codec')].version"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "generic",
|
|
133
|
+
"path": "/crates/kobako-codec/README.md"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
107
137
|
"crates/kobako-runtime": {
|
|
108
138
|
"component": "kobako-runtime",
|
|
109
139
|
"release-type": "rust",
|
|
@@ -148,13 +178,43 @@
|
|
|
148
178
|
"path": "/crates/kobako-wasmtime/README.md"
|
|
149
179
|
}
|
|
150
180
|
]
|
|
181
|
+
},
|
|
182
|
+
"crates/kobako": {
|
|
183
|
+
"component": "kobako-sdk",
|
|
184
|
+
"release-type": "rust",
|
|
185
|
+
"extra-files": [
|
|
186
|
+
{
|
|
187
|
+
"type": "toml",
|
|
188
|
+
"path": "/crates/Cargo.lock",
|
|
189
|
+
"jsonpath": "$.package[?(@.name=='kobako')].version"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "toml",
|
|
193
|
+
"path": "/crates/kobako/Cargo.toml",
|
|
194
|
+
"jsonpath": "$.dependencies['kobako-codec'].version"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"type": "toml",
|
|
198
|
+
"path": "/crates/kobako/Cargo.toml",
|
|
199
|
+
"jsonpath": "$.dependencies['kobako-runtime'].version"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"type": "toml",
|
|
203
|
+
"path": "/crates/kobako/Cargo.toml",
|
|
204
|
+
"jsonpath": "$.dependencies['kobako-wasmtime'].version"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"type": "generic",
|
|
208
|
+
"path": "/crates/kobako/README.md"
|
|
209
|
+
}
|
|
210
|
+
]
|
|
151
211
|
}
|
|
152
212
|
},
|
|
153
213
|
"plugins": [
|
|
154
214
|
{
|
|
155
215
|
"type": "linked-versions",
|
|
156
216
|
"groupName": "kobako crates",
|
|
157
|
-
"components": ["kobako-core", "kobako-
|
|
217
|
+
"components": ["kobako-codec", "kobako-core", "kobako-mruby", "kobako-io", "kobako-json", "kobako-regexp", "kobako-baker", "kobako-runtime", "kobako-wasmtime", "kobako-sdk"]
|
|
158
218
|
}
|
|
159
219
|
],
|
|
160
220
|
"extra-files": [
|
|
@@ -5,9 +5,9 @@ module Kobako
|
|
|
5
5
|
|
|
6
6
|
def self?.representable?: (untyped value) -> bool
|
|
7
7
|
|
|
8
|
-
def self?.deep_wrap: (untyped value, Kobako::
|
|
8
|
+
def self?.deep_wrap: (untyped value, Kobako::Codec::_HandleTable handler) -> untyped
|
|
9
9
|
|
|
10
|
-
def self?.deep_restore: (untyped value, Kobako::
|
|
10
|
+
def self?.deep_restore: (untyped value, Kobako::Codec::_HandleTable handler) -> untyped
|
|
11
11
|
|
|
12
12
|
def self?.primitive_type?: (untyped value) -> bool
|
|
13
13
|
|
data/sig/kobako/codec.rbs
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
module Kobako
|
|
2
2
|
module Codec
|
|
3
|
+
# The Handle allocator/resolver a wire walk works against: alloc
|
|
4
|
+
# registers a non-wire-representable object and returns its Handle,
|
|
5
|
+
# fetch resolves a wire Handle id back to the live object. The
|
|
6
|
+
# Sandbox's Kobako::Catalog::Handles is the production conformer;
|
|
7
|
+
# modelled structurally so the Codec and Transport tiers need no
|
|
8
|
+
# upward dependency on Catalog.
|
|
9
|
+
interface _HandleTable
|
|
10
|
+
def alloc: (untyped object) -> Kobako::Handle
|
|
11
|
+
|
|
12
|
+
def fetch: (Integer id) -> untyped
|
|
13
|
+
end
|
|
3
14
|
end
|
|
4
15
|
end
|
data/sig/kobako/handle.rbs
CHANGED
data/sig/kobako/runtime.rbs
CHANGED
|
@@ -7,17 +7,22 @@ module Kobako
|
|
|
7
7
|
(Float | Integer)? timeout_seconds,
|
|
8
8
|
Integer? memory_limit,
|
|
9
9
|
Integer? stdout_limit_bytes,
|
|
10
|
-
Integer? stderr_limit_bytes
|
|
10
|
+
Integer? stderr_limit_bytes,
|
|
11
|
+
Symbol profile
|
|
11
12
|
) -> Runtime
|
|
12
13
|
|
|
13
14
|
def on_dispatch=: (^(String, Kobako::Transport::_GuestYielder) -> String dispatch_proc) -> void
|
|
14
15
|
|
|
15
|
-
def eval: (String preamble, String source, String snippets) ->
|
|
16
|
+
def eval: (String preamble, String source, String snippets) -> String
|
|
16
17
|
|
|
17
|
-
def run: (String preamble, String snippets, String envelope) ->
|
|
18
|
+
def run: (String preamble, String snippets, String envelope) -> String
|
|
18
19
|
|
|
19
20
|
def usage: () -> [Float, Integer]
|
|
20
21
|
|
|
22
|
+
def captures: () -> [String, bool, String, bool]
|
|
23
|
+
|
|
24
|
+
def profile: () -> Symbol
|
|
25
|
+
|
|
21
26
|
# Frame-scoped guest re-entry handle the ext hands the dispatch Proc as
|
|
22
27
|
# its second argument; stands in as the +String -> String+ callable the
|
|
23
28
|
# host +Transport::Yielder+ invokes for a block yield.
|
data/sig/kobako/sandbox.rbs
CHANGED
|
@@ -10,13 +10,13 @@ module Kobako
|
|
|
10
10
|
def memory_limit: () -> Integer?
|
|
11
11
|
def stdout_limit: () -> Integer?
|
|
12
12
|
def stderr_limit: () -> Integer?
|
|
13
|
+
def profile: () -> Symbol
|
|
13
14
|
|
|
15
|
+
# Every keyword beyond wasm_path forwards verbatim to
|
|
16
|
+
# SandboxOptions.new (the four caps + the profile floor).
|
|
14
17
|
def initialize: (
|
|
15
18
|
?wasm_path: String?,
|
|
16
|
-
|
|
17
|
-
?stderr_limit: Integer?,
|
|
18
|
-
?timeout: (Float | Integer)?,
|
|
19
|
-
?memory_limit: Integer?
|
|
19
|
+
**untyped options
|
|
20
20
|
) -> void
|
|
21
21
|
|
|
22
22
|
def stdout: () -> String
|
|
@@ -42,14 +42,18 @@ module Kobako
|
|
|
42
42
|
|
|
43
43
|
private
|
|
44
44
|
|
|
45
|
+
def build_runtime!: () -> Kobako::Runtime
|
|
46
|
+
|
|
45
47
|
def install_dispatch_proc!: () -> void
|
|
46
48
|
|
|
47
49
|
def begin_invocation!: () -> void
|
|
48
50
|
|
|
49
51
|
def read_usage!: () -> void
|
|
50
52
|
|
|
53
|
+
def read_captures!: () -> void
|
|
54
|
+
|
|
51
55
|
def trap_class_for: (Kobako::TrapError err) -> singleton(Kobako::TrapError)
|
|
52
56
|
|
|
53
|
-
def invoke!: (Symbol verb) { () ->
|
|
57
|
+
def invoke!: (Symbol verb) { () -> String } -> untyped
|
|
54
58
|
end
|
|
55
59
|
end
|
|
@@ -3,26 +3,33 @@ module Kobako
|
|
|
3
3
|
DEFAULT_TIMEOUT_SECONDS: Float
|
|
4
4
|
DEFAULT_MEMORY_LIMIT: Integer
|
|
5
5
|
DEFAULT_OUTPUT_LIMIT: Integer
|
|
6
|
+
DEFAULT_PROFILE: Symbol
|
|
7
|
+
PROFILES: Array[Symbol]
|
|
6
8
|
|
|
7
9
|
attr_reader timeout: Float?
|
|
8
10
|
attr_reader memory_limit: Integer?
|
|
9
11
|
attr_reader stdout_limit: Integer?
|
|
10
12
|
attr_reader stderr_limit: Integer?
|
|
13
|
+
attr_reader profile: Symbol
|
|
11
14
|
|
|
12
15
|
def self.new: (
|
|
13
16
|
?timeout: (Float | Integer)?,
|
|
14
17
|
?memory_limit: Integer?,
|
|
15
18
|
?stdout_limit: Integer?,
|
|
16
|
-
?stderr_limit: Integer
|
|
19
|
+
?stderr_limit: Integer?,
|
|
20
|
+
?profile: Symbol
|
|
17
21
|
) -> SandboxOptions
|
|
18
22
|
|
|
19
23
|
def initialize: (
|
|
20
24
|
?timeout: (Float | Integer)?,
|
|
21
25
|
?memory_limit: Integer?,
|
|
22
26
|
?stdout_limit: Integer?,
|
|
23
|
-
?stderr_limit: Integer
|
|
27
|
+
?stderr_limit: Integer?,
|
|
28
|
+
?profile: Symbol
|
|
24
29
|
) -> void
|
|
25
30
|
|
|
31
|
+
def enforce_floor!: (Symbol declared) -> void
|
|
32
|
+
|
|
26
33
|
private
|
|
27
34
|
|
|
28
35
|
def normalize_timeout: ((Float | Integer)? timeout) -> Float?
|
|
@@ -30,5 +37,7 @@ module Kobako
|
|
|
30
37
|
def normalize_memory_limit: (Integer? memory_limit) -> Integer?
|
|
31
38
|
|
|
32
39
|
def normalize_output_limit: (Integer? limit, String name) -> Integer?
|
|
40
|
+
|
|
41
|
+
def normalize_profile: (untyped profile) -> Symbol
|
|
33
42
|
end
|
|
34
43
|
end
|
|
@@ -12,9 +12,9 @@ module Kobako
|
|
|
12
12
|
|
|
13
13
|
CALLABLE_ALLOW: Array[Symbol]
|
|
14
14
|
|
|
15
|
-
def self?.dispatch: (String request_bytes, Kobako::
|
|
15
|
+
def self?.dispatch: (String request_bytes, Kobako::Transport::_NamespaceRegistry namespaces, Kobako::Codec::_HandleTable handler, Kobako::Transport::_GuestYielder yield_to_guest) -> String
|
|
16
16
|
|
|
17
|
-
def self?.resolve_call_args: (Kobako::Transport::Request request, Kobako::
|
|
17
|
+
def self?.resolve_call_args: (Kobako::Transport::Request request, Kobako::Codec::_HandleTable handler) -> [Array[untyped], Hash[Symbol, untyped]]
|
|
18
18
|
|
|
19
19
|
def self?.encode_caught_error: (StandardError error) -> String
|
|
20
20
|
|
|
@@ -24,17 +24,17 @@ module Kobako
|
|
|
24
24
|
|
|
25
25
|
def self?.reject_unexposed!: (untyped target, Symbol name) -> void
|
|
26
26
|
|
|
27
|
-
def self?.resolve_arg: (untyped value, Kobako::
|
|
27
|
+
def self?.resolve_arg: (untyped value, Kobako::Codec::_HandleTable handler) -> untyped
|
|
28
28
|
|
|
29
|
-
def self?.resolve_target: (String | Kobako::Handle target, Kobako::
|
|
29
|
+
def self?.resolve_target: (String | Kobako::Handle target, Kobako::Transport::_NamespaceRegistry namespaces, Kobako::Codec::_HandleTable handler) -> untyped
|
|
30
30
|
|
|
31
|
-
def self?.resolve_path: (String path, Kobako::
|
|
31
|
+
def self?.resolve_path: (String path, Kobako::Transport::_NamespaceRegistry namespaces) -> untyped
|
|
32
32
|
|
|
33
|
-
def self?.require_live_object!: (Integer id, Kobako::
|
|
33
|
+
def self?.require_live_object!: (Integer id, Kobako::Codec::_HandleTable handler) -> untyped
|
|
34
34
|
|
|
35
|
-
def self?.encode_ok: (untyped value, Kobako::
|
|
35
|
+
def self?.encode_ok: (untyped value, Kobako::Codec::_HandleTable handler) -> String
|
|
36
36
|
|
|
37
|
-
def self?.wrap_as_handle: (untyped value, Kobako::
|
|
37
|
+
def self?.wrap_as_handle: (untyped value, Kobako::Codec::_HandleTable handler) -> Kobako::Handle
|
|
38
38
|
|
|
39
39
|
def self?.encode_error: (String type, String message) -> String
|
|
40
40
|
end
|
|
@@ -11,7 +11,7 @@ module Kobako
|
|
|
11
11
|
|
|
12
12
|
def initialize: (entrypoint: Symbol | String, ?args: Array[untyped], ?kwargs: Hash[untyped, untyped]) -> void
|
|
13
13
|
|
|
14
|
-
def encode: (Kobako::
|
|
14
|
+
def encode: (Kobako::Codec::_HandleTable handler) -> String
|
|
15
15
|
|
|
16
16
|
private
|
|
17
17
|
|
|
@@ -3,10 +3,10 @@ module Kobako
|
|
|
3
3
|
class Yielder
|
|
4
4
|
@yield_to_guest: Kobako::Transport::_GuestYielder
|
|
5
5
|
@break_tag: Symbol
|
|
6
|
-
@handler: Kobako::
|
|
6
|
+
@handler: Kobako::Codec::_HandleTable
|
|
7
7
|
@active: bool
|
|
8
8
|
|
|
9
|
-
def initialize: (Kobako::Transport::_GuestYielder yield_to_guest, Symbol break_tag, Kobako::
|
|
9
|
+
def initialize: (Kobako::Transport::_GuestYielder yield_to_guest, Symbol break_tag, Kobako::Codec::_HandleTable handler) -> void
|
|
10
10
|
|
|
11
11
|
def yield: (*untyped args) -> untyped
|
|
12
12
|
|
data/sig/kobako/transport.rbs
CHANGED
|
@@ -8,5 +8,13 @@ module Kobako
|
|
|
8
8
|
interface _GuestYielder
|
|
9
9
|
def call: (String) -> String
|
|
10
10
|
end
|
|
11
|
+
|
|
12
|
+
# The Service registry a dispatch resolves constant-path targets
|
|
13
|
+
# against. The Sandbox's Kobako::Catalog::Namespaces is the
|
|
14
|
+
# production conformer; modelled structurally so the Transport
|
|
15
|
+
# layer needs no upward dependency on Catalog.
|
|
16
|
+
interface _NamespaceRegistry
|
|
17
|
+
def lookup: (String target) -> untyped
|
|
18
|
+
end
|
|
11
19
|
end
|
|
12
20
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kobako
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aotokitsuruya
|
|
@@ -53,6 +53,7 @@ files:
|
|
|
53
53
|
- Cargo.toml
|
|
54
54
|
- LICENSE
|
|
55
55
|
- README.md
|
|
56
|
+
- ROADMAP.md
|
|
56
57
|
- SECURITY.md
|
|
57
58
|
- crates/kobako-runtime/CHANGELOG.md
|
|
58
59
|
- crates/kobako-runtime/Cargo.toml
|
|
@@ -60,6 +61,7 @@ files:
|
|
|
60
61
|
- crates/kobako-runtime/src/dispatch.rs
|
|
61
62
|
- crates/kobako-runtime/src/error.rs
|
|
62
63
|
- crates/kobako-runtime/src/lib.rs
|
|
64
|
+
- crates/kobako-runtime/src/profile.rs
|
|
63
65
|
- crates/kobako-runtime/src/runtime.rs
|
|
64
66
|
- crates/kobako-runtime/src/snapshot.rs
|
|
65
67
|
- crates/kobako-runtime/src/yielder.rs
|
|
@@ -86,7 +88,6 @@ files:
|
|
|
86
88
|
- ext/kobako/src/runtime.rs
|
|
87
89
|
- ext/kobako/src/runtime/bridge.rs
|
|
88
90
|
- ext/kobako/src/runtime/errors.rs
|
|
89
|
-
- ext/kobako/src/snapshot.rs
|
|
90
91
|
- lib/kobako.rb
|
|
91
92
|
- lib/kobako/capture.rb
|
|
92
93
|
- lib/kobako/catalog.rb
|
|
@@ -110,7 +111,6 @@ files:
|
|
|
110
111
|
- lib/kobako/runtime.rb
|
|
111
112
|
- lib/kobako/sandbox.rb
|
|
112
113
|
- lib/kobako/sandbox_options.rb
|
|
113
|
-
- lib/kobako/snapshot.rb
|
|
114
114
|
- lib/kobako/snippet.rb
|
|
115
115
|
- lib/kobako/snippet/binary.rb
|
|
116
116
|
- lib/kobako/snippet/source.rb
|
|
@@ -149,7 +149,6 @@ files:
|
|
|
149
149
|
- sig/kobako/runtime.rbs
|
|
150
150
|
- sig/kobako/sandbox.rbs
|
|
151
151
|
- sig/kobako/sandbox_options.rbs
|
|
152
|
-
- sig/kobako/snapshot.rbs
|
|
153
152
|
- sig/kobako/snippet.rbs
|
|
154
153
|
- sig/kobako/snippet/binary.rbs
|
|
155
154
|
- sig/kobako/snippet/source.rbs
|
data/ext/kobako/src/snapshot.rs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
//! `Kobako::Snapshot` — the Ruby-facing per-invocation observable bundle.
|
|
2
|
-
//!
|
|
3
|
-
//! The success-path view of the engine-neutral snapshot: the outcome bytes
|
|
4
|
-
//! and the two captured output channels, exposed through five raw readers.
|
|
5
|
-
//! The helper methods that pack them into `Kobako::Capture`
|
|
6
|
-
//! (`Kobako::Snapshot#stdout` / `#stderr`) live in
|
|
7
|
-
//! `lib/kobako/snapshot.rb`. The split keeps the ext side a pure value
|
|
8
|
-
//! carrier and lets Ruby own the convenience surface. Usage is not on the
|
|
9
|
-
//! Snapshot — `Sandbox#usage` reads it from `Kobako::Runtime#usage`, which
|
|
10
|
-
//! survives the trap path where no `Kobako::Snapshot` is produced.
|
|
11
|
-
|
|
12
|
-
use magnus::{method, prelude::*, Error as MagnusError, RModule, RString, Ruby};
|
|
13
|
-
|
|
14
|
-
use kobako_runtime::snapshot::Capture;
|
|
15
|
-
|
|
16
|
-
/// Per-invocation snapshot value. Magnus wraps it so a single ext call
|
|
17
|
-
/// from `Runtime::eval` / `Runtime::run` returns the whole bundle — the
|
|
18
|
-
/// Sandbox layer decomposes it without round-tripping into ext again. The
|
|
19
|
-
/// fields are set once at construction and never mutated; the five public
|
|
20
|
-
/// methods registered in `init` read them out one by one.
|
|
21
|
-
#[magnus::wrap(class = "Kobako::Snapshot", free_immediately, size)]
|
|
22
|
-
pub(crate) struct Snapshot {
|
|
23
|
-
return_bytes: Vec<u8>,
|
|
24
|
-
stdout: Capture,
|
|
25
|
-
stderr: Capture,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
impl Snapshot {
|
|
29
|
-
/// Bundle the success outputs the Runtime collected once the guest
|
|
30
|
-
/// export returned with an outcome: the drained OUTCOME_BUFFER bytes
|
|
31
|
-
/// and the capture pipes clipped to their caps.
|
|
32
|
-
pub(crate) fn new(return_bytes: Vec<u8>, stdout: Capture, stderr: Capture) -> Self {
|
|
33
|
-
Self {
|
|
34
|
-
return_bytes,
|
|
35
|
-
stdout,
|
|
36
|
-
stderr,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fn return_bytes(&self) -> RString {
|
|
41
|
-
let ruby = Ruby::get().expect("Ruby thread");
|
|
42
|
-
ruby.str_from_slice(&self.return_bytes)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
fn stdout_bytes(&self) -> RString {
|
|
46
|
-
let ruby = Ruby::get().expect("Ruby thread");
|
|
47
|
-
ruby.str_from_slice(&self.stdout.bytes)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
fn stdout_truncated(&self) -> bool {
|
|
51
|
-
self.stdout.truncated
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
fn stderr_bytes(&self) -> RString {
|
|
55
|
-
let ruby = Ruby::get().expect("Ruby thread");
|
|
56
|
-
ruby.str_from_slice(&self.stderr.bytes)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
fn stderr_truncated(&self) -> bool {
|
|
60
|
-
self.stderr.truncated
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Register `Kobako::Snapshot` plus its five raw readers under the
|
|
65
|
-
/// `Kobako` module. Called from `crate::init` after `Kobako::Runtime`
|
|
66
|
-
/// is registered so the magnus wrap macro can resolve the class name.
|
|
67
|
-
pub(crate) fn init(ruby: &Ruby, kobako: RModule) -> Result<(), MagnusError> {
|
|
68
|
-
let snapshot = kobako.define_class("Snapshot", ruby.class_object())?;
|
|
69
|
-
snapshot.define_method("return_bytes", method!(Snapshot::return_bytes, 0))?;
|
|
70
|
-
snapshot.define_method("stdout_bytes", method!(Snapshot::stdout_bytes, 0))?;
|
|
71
|
-
snapshot.define_method("stdout_truncated", method!(Snapshot::stdout_truncated, 0))?;
|
|
72
|
-
snapshot.define_method("stderr_bytes", method!(Snapshot::stderr_bytes, 0))?;
|
|
73
|
-
snapshot.define_method("stderr_truncated", method!(Snapshot::stderr_truncated, 0))?;
|
|
74
|
-
Ok(())
|
|
75
|
-
}
|
data/lib/kobako/snapshot.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "capture"
|
|
4
|
-
|
|
5
|
-
module Kobako
|
|
6
|
-
# Kobako::Snapshot — per-invocation observable bundle returned from
|
|
7
|
-
# +Kobako::Runtime#eval+ and +#run+.
|
|
8
|
-
#
|
|
9
|
-
# The magnus class (see ext/kobako/src/snapshot.rs) carries five raw
|
|
10
|
-
# readers: +return_bytes+, +stdout_bytes+, +stdout_truncated+,
|
|
11
|
-
# +stderr_bytes+, +stderr_truncated+. This file reopens the class to add
|
|
12
|
-
# the Ruby-side helpers that pack those raw fields into the user-facing
|
|
13
|
-
# value object +Kobako::Capture+ — the same shape +Kobako::Sandbox+
|
|
14
|
-
# exposes to the Host App. Usage is not on the Snapshot; +Sandbox#usage+
|
|
15
|
-
# reads it from +Kobako::Runtime#usage+, which also covers the trap path
|
|
16
|
-
# where no Snapshot is produced.
|
|
17
|
-
class Snapshot
|
|
18
|
-
# Wrap the stdout capture pair (+stdout_bytes+, +stdout_truncated+)
|
|
19
|
-
# as a +Kobako::Capture+ value object. The byte content never carries
|
|
20
|
-
# a truncation sentinel; +#truncated?+ is the only way to observe
|
|
21
|
-
# that the cap was hit.
|
|
22
|
-
def stdout
|
|
23
|
-
Capture.new(bytes: stdout_bytes, truncated: stdout_truncated)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Wrap the stderr capture pair as a +Kobako::Capture+ value object.
|
|
27
|
-
# Mirror of +#stdout+.
|
|
28
|
-
def stderr
|
|
29
|
-
Capture.new(bytes: stderr_bytes, truncated: stderr_truncated)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
data/sig/kobako/snapshot.rbs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
class Snapshot
|
|
3
|
-
def return_bytes: () -> String
|
|
4
|
-
def stdout_bytes: () -> String
|
|
5
|
-
def stdout_truncated: () -> bool
|
|
6
|
-
def stderr_bytes: () -> String
|
|
7
|
-
def stderr_truncated: () -> bool
|
|
8
|
-
|
|
9
|
-
def stdout: () -> Kobako::Capture
|
|
10
|
-
def stderr: () -> Kobako::Capture
|
|
11
|
-
end
|
|
12
|
-
end
|