kobako 0.30.0-aarch64-linux → 0.32.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.
- checksums.yaml +4 -4
- data/.githooks/linux-tests.sh +29 -0
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +460 -0
- data/README.md +43 -4
- data/ROADMAP.md +1 -2
- data/crates/kobako-runtime/CHANGELOG.md +309 -0
- data/crates/kobako-runtime/README.md +7 -4
- data/crates/kobako-transport/CHANGELOG.md +38 -0
- data/crates/kobako-transport/README.md +3 -4
- data/crates/kobako-wasmtime/CHANGELOG.md +208 -0
- data/crates/kobako-wasmtime/README.md +4 -3
- data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
- data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
- data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
- data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
- data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
- data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
- data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
- data/crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx +13 -0
- data/data/kobako.wasm +0 -0
- data/lib/kobako/3.3/kobako.so +0 -0
- data/lib/kobako/3.4/kobako.so +0 -0
- data/lib/kobako/4.0/kobako.so +0 -0
- data/lib/kobako/catalog/extensions.rb +14 -2
- data/lib/kobako/catalog/flags.rb +3 -5
- data/lib/kobako/catalog/grants.rb +5 -4
- data/lib/kobako/catalog/handles.rb +14 -32
- data/lib/kobako/catalog/mount.rb +11 -3
- data/lib/kobako/catalog/network.rb +35 -0
- data/lib/kobako/catalog/replacements.rb +28 -0
- data/lib/kobako/catalog/services.rb +5 -19
- data/lib/kobako/catalog/snippets.rb +3 -18
- data/lib/kobako/catalog.rb +3 -0
- data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
- data/lib/kobako/codec/decoder.rb +5 -5
- data/lib/kobako/codec/ext_types.rb +3 -3
- data/lib/kobako/codec/handle_walk.rb +3 -43
- data/lib/kobako/codec/state.rb +2 -18
- data/lib/kobako/codec/value_budget.rb +133 -41
- data/lib/kobako/codec.rb +6 -7
- data/lib/kobako/context.rb +24 -11
- data/lib/kobako/errors.rb +18 -18
- data/lib/kobako/extension.rb +3 -2
- data/lib/kobako/filesystem.rb +10 -3
- data/lib/kobako/fork.rb +42 -0
- data/lib/kobako/handle.rb +2 -3
- data/lib/kobako/names.rb +28 -0
- data/lib/kobako/network.rb +210 -0
- data/lib/kobako/outcome.rb +7 -7
- data/lib/kobako/runtime.rb +3 -2
- data/lib/kobako/sandbox.rb +73 -35
- data/lib/kobako/sandbox_options.rb +42 -109
- data/lib/kobako/transport/argument_wrap.rb +64 -0
- data/lib/kobako/transport/block_failure.rb +1 -1
- data/lib/kobako/transport/dispatcher.rb +6 -6
- data/lib/kobako/transport/exposure.rb +26 -15
- data/lib/kobako/transport/reflection.rb +21 -4
- data/lib/kobako/transport/run.rb +8 -23
- data/lib/kobako/transport/yielder.rb +2 -9
- data/lib/kobako/transport.rb +1 -0
- data/lib/kobako/usage.rb +4 -2
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +8 -4
- data/release-please-config.json +15 -0
- data/sig/kobako/catalog/extensions.rbs +2 -0
- data/sig/kobako/catalog/grants.rbs +7 -4
- data/sig/kobako/catalog/handles.rbs +2 -2
- data/sig/kobako/catalog/mount.rbs +3 -1
- data/sig/kobako/catalog/network.rbs +20 -0
- data/sig/kobako/catalog/replacements.rbs +14 -0
- data/sig/kobako/catalog/services.rbs +0 -4
- data/sig/kobako/catalog/snippets.rbs +0 -2
- data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
- data/sig/kobako/codec/handle_walk.rbs +0 -6
- data/sig/kobako/codec/state.rbs +0 -4
- data/sig/kobako/codec/value_budget.rbs +48 -5
- data/sig/kobako/codec.rbs +2 -2
- data/sig/kobako/context.rbs +3 -1
- data/sig/kobako/errors.rbs +4 -7
- data/sig/kobako/filesystem.rbs +21 -3
- data/sig/kobako/fork.rbs +17 -0
- data/sig/kobako/network.rbs +115 -0
- data/sig/kobako/outcome.rbs +1 -1
- data/sig/kobako/runtime.rbs +32 -3
- data/sig/kobako/sandbox.rbs +10 -2
- data/sig/kobako/sandbox_options.rbs +29 -40
- data/sig/kobako/transport/argument_wrap.rbs +15 -0
- data/sig/kobako/transport/error.rbs +1 -1
- data/sig/kobako/transport/exposure.rbs +2 -4
- data/sig/kobako/transport/reflection.rbs +10 -0
- data/sig/kobako/transport/run.rbs +0 -2
- data/sig/kobako/transport/yielder.rbs +0 -3
- data/sig/kobako/transport.rbs +1 -1
- data/sig/kobako.rbs +13 -0
- metadata +25 -11
- data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
- data/lib/kobako/constant_name.rb +0 -8
- data/lib/kobako/pool.rb +0 -140
- data/sig/kobako/constant_name.rbs +0 -3
- data/sig/kobako/pool.rbs +0 -42
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../codec"
|
|
4
|
+
require_relative "exposure"
|
|
5
|
+
|
|
6
|
+
module Kobako
|
|
7
|
+
module Transport
|
|
8
|
+
# The walk a #run argument takes on its way to the guest: a leaf with no
|
|
9
|
+
# wire form becomes a Capability Handle in the invocation's table, and
|
|
10
|
+
# the rest crosses as it stands. An argument the walk refuses is the
|
|
11
|
+
# Host App's mistake, raised as +Marshal.dump+ raises it: +TypeError+
|
|
12
|
+
# for what has no form to cross as, +ArgumentError+ past the depth.
|
|
13
|
+
module ArgumentWrap # :nodoc:
|
|
14
|
+
# Only Hash values are wrapped: a non-representable key raises rather
|
|
15
|
+
# than crossing as a token the guest→host restore walk could not
|
|
16
|
+
# round-trip.
|
|
17
|
+
def self.wrap(value, handles, depth = 0)
|
|
18
|
+
refuse_past_nesting(depth)
|
|
19
|
+
case value
|
|
20
|
+
when ::Array then value.map { |element| wrap(element, handles, depth + 1) }
|
|
21
|
+
when ::Hash then wrap_hash(value, handles, depth)
|
|
22
|
+
else
|
|
23
|
+
Codec::HandleWalk.representable?(value) ? value : wrap_leaf(value, handles)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class << self
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# A reference cycle necessarily trips the nesting bound, so an
|
|
31
|
+
# argument fails as a clean +ArgumentError+ rather than an unbounded
|
|
32
|
+
# host recursion.
|
|
33
|
+
def refuse_past_nesting(depth)
|
|
34
|
+
return unless depth > Codec::MAX_NESTING_DEPTH
|
|
35
|
+
|
|
36
|
+
raise ArgumentError,
|
|
37
|
+
"a #run argument nests deeper than #{Codec::MAX_NESTING_DEPTH} levels within the Run payload " \
|
|
38
|
+
"and cannot cross the sandbox boundary (possible reference cycle)"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def wrap_leaf(value, handles)
|
|
42
|
+
refused = Exposure.refused_class_of(value)
|
|
43
|
+
raise TypeError, "a #{refused} cannot cross as a Capability Handle" if refused
|
|
44
|
+
|
|
45
|
+
handles.alloc(value)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# A stateful object may cross the boundary as a Hash value but not as
|
|
49
|
+
# a key — the one deliberate asymmetry with the guest→host restore
|
|
50
|
+
# walk, which resolves Handle keys the guest built.
|
|
51
|
+
def wrap_hash(hash, handles, depth)
|
|
52
|
+
hash.to_h do |key, val|
|
|
53
|
+
unless Codec::HandleWalk.representable?(key, depth + 1)
|
|
54
|
+
raise TypeError,
|
|
55
|
+
"a Hash passed to #run has a key that cannot cross the sandbox boundary " \
|
|
56
|
+
"(#{key.class}); only wire-representable values may be Hash keys"
|
|
57
|
+
end
|
|
58
|
+
[key, wrap(val, handles, depth + 1)]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -61,16 +61,17 @@ module Kobako
|
|
|
61
61
|
# rescuable fault.
|
|
62
62
|
rescue StandardError => e
|
|
63
63
|
[:fault, *fault_of(e, failure)] # : [Symbol, String, String?]
|
|
64
|
-
ensure
|
|
65
|
-
yielder&.invalidate
|
|
66
64
|
end
|
|
67
65
|
|
|
68
66
|
class << self
|
|
69
67
|
private
|
|
70
68
|
|
|
69
|
+
# Routing reads only the target and the method, so a dispatch that
|
|
70
|
+
# cannot route answers before its arguments are read.
|
|
71
71
|
def run(call, resolver, handles, yielder)
|
|
72
|
-
arguments, carried_handle = decode_arguments(call.payload)
|
|
73
72
|
exposure = resolve_target(call.target, resolver, handles)
|
|
73
|
+
reject_unreachable(exposure, call.method_name.to_sym)
|
|
74
|
+
arguments, carried_handle = decode_arguments(call.payload)
|
|
74
75
|
args, kwargs = resolve_call_args(arguments, handles, carried_handle)
|
|
75
76
|
invoke(exposure, call.method_name, args, kwargs, yielder)
|
|
76
77
|
end
|
|
@@ -111,13 +112,12 @@ module Kobako
|
|
|
111
112
|
# unsplatted for methods that take no keywords.
|
|
112
113
|
def invoke(exposure, method, args, kwargs, yielder)
|
|
113
114
|
name = method.to_sym
|
|
114
|
-
reject_unreachable(exposure, name)
|
|
115
115
|
target = exposure.object
|
|
116
116
|
block = yielder&.to_proc
|
|
117
117
|
if kwargs.empty?
|
|
118
|
-
target.
|
|
118
|
+
Reflection::PUBLIC_SEND.bind(target).call(name, *args, &block)
|
|
119
119
|
else
|
|
120
|
-
target.
|
|
120
|
+
Reflection::PUBLIC_SEND.bind(target).call(name, *args, **kwargs, &block)
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
@@ -14,15 +14,6 @@ module Kobako
|
|
|
14
14
|
PREDICATE = :respond_to_guest?
|
|
15
15
|
private_constant :PREDICATE
|
|
16
16
|
|
|
17
|
-
# Kernel's own reflection, bound onto each object so a forwarder or a
|
|
18
|
-
# BasicObject answers from its own method table rather than through
|
|
19
|
-
# +method_missing+ / +respond_to_missing?+.
|
|
20
|
-
CLASS_OF = Kernel.instance_method(:class)
|
|
21
|
-
SINGLETON_CLASS_OF = Kernel.instance_method(:singleton_class)
|
|
22
|
-
SINGLETON_METHODS = Kernel.instance_method(:singleton_methods)
|
|
23
|
-
PRIVATE_METHODS = Kernel.instance_method(:private_methods)
|
|
24
|
-
private_constant :CLASS_OF, :SINGLETON_CLASS_OF, :SINGLETON_METHODS, :PRIVATE_METHODS
|
|
25
|
-
|
|
26
17
|
CALLABLE = Set.new(Reflection::CALLABLE_ALLOW).freeze
|
|
27
18
|
NOTHING = Set.new.freeze
|
|
28
19
|
private_constant :CALLABLE, :NOTHING
|
|
@@ -31,18 +22,38 @@ module Kobako
|
|
|
31
22
|
# each class's own surface for a caller that makes many references at
|
|
32
23
|
# once (a Handle table), so two objects of one class enumerate it once.
|
|
33
24
|
def self.of(object, surfaces = {})
|
|
34
|
-
klass = CLASS_OF.bind_call(object)
|
|
25
|
+
klass = Reflection::CLASS_OF.bind_call(object)
|
|
35
26
|
names = narrows_itself?(object, klass) ? nil : resolve_default_names(object, klass, surfaces)
|
|
36
27
|
new(object: object, names: names)
|
|
37
28
|
end
|
|
38
29
|
|
|
30
|
+
# The class of +object+ when no reference may stand for it, as its
|
|
31
|
+
# reachable surface is not Service behaviour; +nil+ otherwise. A
|
|
32
|
+
# +Binding+ / +Method+ / +UnboundMethod+ hands the guest a callable
|
|
33
|
+
# proxy onto host reflection (a returned +Binding+ reaches
|
|
34
|
+
# +Binding#eval+); a +Class+ or +Module+ hands over its class-level API
|
|
35
|
+
# (+File.popen+ / +read+, +Kernel.system+), which the owner-based
|
|
36
|
+
# dispatch floor cannot see because a singleton-class owner matches no
|
|
37
|
+
# core-module list; a +Delegator+ (+SimpleDelegator+, +DelegateClass+,
|
|
38
|
+
# +WeakRef+, +Tempfile+) is a transparent forwarder whose public
|
|
39
|
+
# +method_missing+ binds and calls the private method the guest names
|
|
40
|
+
# (+Kernel#system+), a surface the floor reads as ordinary Service
|
|
41
|
+
# behaviour.
|
|
42
|
+
def self.refused_class_of(object)
|
|
43
|
+
case object
|
|
44
|
+
when Binding, Method, UnboundMethod, Module, Delegator
|
|
45
|
+
# Delegator < BasicObject exposes no static +#class+.
|
|
46
|
+
Reflection::CLASS_OF.bind_call(object)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
39
50
|
# Whether the guest may call +name+ through this reference. The
|
|
40
51
|
# object's own predicate is consulted with the private surface
|
|
41
52
|
# included, so the guest's +public_send+ can never reach it.
|
|
42
53
|
def exposes?(name)
|
|
43
54
|
return names.include?(name) if names
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
Reflection::SEND.bind_call(object, PREDICATE, name) ? true : false
|
|
46
57
|
end
|
|
47
58
|
|
|
48
59
|
class << self
|
|
@@ -53,8 +64,8 @@ module Kobako
|
|
|
53
64
|
# +respond_to_missing?+ cannot answer for it.
|
|
54
65
|
def narrows_itself?(object, klass)
|
|
55
66
|
klass.method_defined?(PREDICATE) || klass.private_method_defined?(PREDICATE) ||
|
|
56
|
-
PRIVATE_METHODS.bind_call(object, false).include?(PREDICATE) ||
|
|
57
|
-
SINGLETON_METHODS.bind_call(object, false).include?(PREDICATE)
|
|
67
|
+
Reflection::PRIVATE_METHODS.bind_call(object, false).include?(PREDICATE) ||
|
|
68
|
+
Reflection::SINGLETON_METHODS.bind_call(object, false).include?(PREDICATE)
|
|
58
69
|
end
|
|
59
70
|
|
|
60
71
|
# A callable keeps its callable names; a class-level surface or a
|
|
@@ -76,9 +87,9 @@ module Kobako
|
|
|
76
87
|
end
|
|
77
88
|
|
|
78
89
|
def with_singleton(object, names)
|
|
79
|
-
return names if SINGLETON_METHODS.bind_call(object, false).empty?
|
|
90
|
+
return names if Reflection::SINGLETON_METHODS.bind_call(object, false).empty?
|
|
80
91
|
|
|
81
|
-
names.union(authored_names(SINGLETON_CLASS_OF.bind_call(object))).freeze
|
|
92
|
+
names.union(authored_names(Reflection::SINGLETON_CLASS_OF.bind_call(object))).freeze
|
|
82
93
|
end
|
|
83
94
|
|
|
84
95
|
# The public methods +owner+ itself defines in Ruby source.
|
|
@@ -17,6 +17,19 @@ module Kobako
|
|
|
17
17
|
# callable exposes by default, so the floor and the Exposure agree.
|
|
18
18
|
CALLABLE_ALLOW = %i[call [] yield arity lambda?].freeze
|
|
19
19
|
|
|
20
|
+
# Kernel's own reflection and dispatch, bound onto each object so a
|
|
21
|
+
# forwarder or a BasicObject answers from its own method table rather
|
|
22
|
+
# than through +method_missing+ / +respond_to_missing?+, for the floor,
|
|
23
|
+
# the Exposure, and the call alike.
|
|
24
|
+
CLASS_OF = Kernel.instance_method(:class)
|
|
25
|
+
IS_A = Kernel.instance_method(:is_a?)
|
|
26
|
+
SINGLETON_CLASS_OF = Kernel.instance_method(:singleton_class)
|
|
27
|
+
SINGLETON_METHODS = Kernel.instance_method(:singleton_methods)
|
|
28
|
+
PRIVATE_METHODS = Kernel.instance_method(:private_methods)
|
|
29
|
+
RESPOND_TO = Kernel.instance_method(:respond_to?)
|
|
30
|
+
PUBLIC_SEND = Kernel.instance_method(:public_send)
|
|
31
|
+
SEND = BasicObject.instance_method(:__send__)
|
|
32
|
+
|
|
20
33
|
# The reason +name+ is unreachable through +exposure+, or +nil+ when
|
|
21
34
|
# the dispatch may proceed. Composes the ambient-surface floor with the
|
|
22
35
|
# reference's Exposure, in that order: the Exposure only narrows and
|
|
@@ -81,7 +94,7 @@ module Kobako
|
|
|
81
94
|
|
|
82
95
|
klass = lookup_class(target)
|
|
83
96
|
return public_method_refusal(target, name, klass) if klass.public_method_defined?(name)
|
|
84
|
-
return "no public method #{name.inspect} on target" unless
|
|
97
|
+
return "no public method #{name.inspect} on target" unless RESPOND_TO.bind_call(target, name)
|
|
85
98
|
return service_refusal(name) if klass.method_defined?(name) || klass.private_method_defined?(name)
|
|
86
99
|
|
|
87
100
|
owner_refusal(target, name, klass)
|
|
@@ -117,9 +130,13 @@ module Kobako
|
|
|
117
130
|
# singleton class is taken only when it already holds a public
|
|
118
131
|
# method, since asking for it otherwise would create one.
|
|
119
132
|
def lookup_class(target)
|
|
120
|
-
return target
|
|
133
|
+
return SINGLETON_CLASS_OF.bind_call(target) if module?(target) || SINGLETON_METHODS.bind_call(target).any?
|
|
134
|
+
|
|
135
|
+
CLASS_OF.bind_call(target)
|
|
136
|
+
end
|
|
121
137
|
|
|
122
|
-
|
|
138
|
+
def module?(target)
|
|
139
|
+
IS_A.bind_call(target, Module)
|
|
123
140
|
end
|
|
124
141
|
|
|
125
142
|
# Whatever +Class+ inherits is surface every object shares rather
|
|
@@ -132,7 +149,7 @@ module Kobako
|
|
|
132
149
|
def ambient_owner?(owner, target)
|
|
133
150
|
owner >= Class ||
|
|
134
151
|
GADGET_OWNERS.include?(owner) ||
|
|
135
|
-
(
|
|
152
|
+
(module?(target) && owner.singleton_class?)
|
|
136
153
|
end
|
|
137
154
|
end
|
|
138
155
|
end
|
data/lib/kobako/transport/run.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../constant_name"
|
|
4
3
|
require_relative "../handle"
|
|
4
|
+
require_relative "../names"
|
|
5
5
|
require_relative "../codec"
|
|
6
6
|
require_relative "../payload"
|
|
7
|
+
require_relative "argument_wrap"
|
|
7
8
|
|
|
8
9
|
module Kobako
|
|
9
10
|
module Transport
|
|
@@ -11,7 +12,7 @@ module Kobako
|
|
|
11
12
|
# legitimately holds one.
|
|
12
13
|
class Run < Data.define(:entrypoint, :args, :kwargs) # :nodoc:
|
|
13
14
|
def initialize(entrypoint:, args: [], kwargs: {})
|
|
14
|
-
entrypoint =
|
|
15
|
+
entrypoint = Kobako.to_constant_name(entrypoint, "entrypoint")
|
|
15
16
|
validate_args(args)
|
|
16
17
|
validate_kwargs(kwargs)
|
|
17
18
|
super
|
|
@@ -23,42 +24,26 @@ module Kobako
|
|
|
23
24
|
# is counted from.
|
|
24
25
|
def encode_payload(handles)
|
|
25
26
|
Payload::Arguments.new(
|
|
26
|
-
args:
|
|
27
|
-
kwargs:
|
|
27
|
+
args: ArgumentWrap.wrap(args, handles, 1),
|
|
28
|
+
kwargs: ArgumentWrap.wrap(kwargs, handles, 1)
|
|
28
29
|
).encode
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
private
|
|
32
33
|
|
|
33
|
-
# A target of the wrong type raises TypeError, a Host App programming
|
|
34
|
-
# error caught before the run reaches the guest.
|
|
35
|
-
def normalize_entrypoint(target)
|
|
36
|
-
unless target.is_a?(Symbol) || target.is_a?(String)
|
|
37
|
-
raise TypeError, "entrypoint must be a Symbol or String, got #{target.class}"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
target_str = target.to_s
|
|
41
|
-
unless CONSTANT_NAME.match?(target_str)
|
|
42
|
-
raise ArgumentError,
|
|
43
|
-
"entrypoint must match #{CONSTANT_NAME.inspect} (got #{target.inspect})"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
target_str.to_sym
|
|
47
|
-
end
|
|
48
|
-
|
|
49
34
|
def validate_args(args)
|
|
50
|
-
raise
|
|
35
|
+
raise TypeError, "arguments must be an Array" unless args.is_a?(Array)
|
|
51
36
|
raise ArgumentError, forged_handle_message("arguments") if args.any?(Kobako::Handle)
|
|
52
37
|
end
|
|
53
38
|
|
|
54
39
|
# Checked here so the Host App sees the host-side message before any
|
|
55
40
|
# encode boundary.
|
|
56
41
|
def validate_kwargs(kwargs)
|
|
57
|
-
raise
|
|
42
|
+
raise TypeError, "keyword arguments must be a Hash" unless kwargs.is_a?(Hash)
|
|
58
43
|
|
|
59
44
|
bad_keys = kwargs.each_key.grep_v(Symbol)
|
|
60
45
|
unless bad_keys.empty?
|
|
61
|
-
raise
|
|
46
|
+
raise TypeError,
|
|
62
47
|
"keyword argument keys must be Symbols (got #{bad_keys.inspect})"
|
|
63
48
|
end
|
|
64
49
|
raise ArgumentError, forged_handle_message("keyword argument values") if kwargs.each_value.any?(Kobako::Handle)
|
|
@@ -11,18 +11,15 @@ module Kobako
|
|
|
11
11
|
@break_tag = break_tag
|
|
12
12
|
@handles = handles
|
|
13
13
|
@failure = failure
|
|
14
|
-
@active = true
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
# The ok value is consumed by the host Service, so a Capability Handle
|
|
18
17
|
# in it is restored. A block exit stays in the guest, so the Service
|
|
19
18
|
# is only unwound.
|
|
20
19
|
def yield(*args)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
arm, body, klass = @guest_yielder.call(encode_args(args))
|
|
20
|
+
arm, body, class_name = @guest_yielder.call(encode_args(args))
|
|
24
21
|
raise UnsupportedError, "the Sandbox runtime does not support yielding to a block" if arm == :unsupported
|
|
25
|
-
raise @failure.remember(BlockError.new(body,
|
|
22
|
+
raise @failure.remember(BlockError.new(body, class_name: class_name)) if arm == :error
|
|
26
23
|
|
|
27
24
|
throw @break_tag if arm == :break
|
|
28
25
|
|
|
@@ -33,10 +30,6 @@ module Kobako
|
|
|
33
30
|
method(:yield).to_proc
|
|
34
31
|
end
|
|
35
32
|
|
|
36
|
-
def invalidate
|
|
37
|
-
@active = false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
33
|
private
|
|
41
34
|
|
|
42
35
|
# Restated so the Service reads a refusal of its own argument rather
|
data/lib/kobako/transport.rb
CHANGED
data/lib/kobako/usage.rb
CHANGED
|
@@ -8,8 +8,10 @@ module Kobako
|
|
|
8
8
|
# +timeout+ deadline governs; Service callbacks count, reading the
|
|
9
9
|
# result and the captures afterwards does not.
|
|
10
10
|
# * +memory_peak+ — Integer bytes of memory the invocation grew,
|
|
11
|
-
# against the same baseline as +memory_limit
|
|
12
|
-
#
|
|
11
|
+
# against the same baseline as +memory_limit+. It can pass the cap by
|
|
12
|
+
# what a network queue had to take to move on or to keep a write's
|
|
13
|
+
# promised room, at most one read and one write per open connection,
|
|
14
|
+
# as Linux's +memory.peak+ records a forced charge.
|
|
13
15
|
#
|
|
14
16
|
# Filled on every outcome, traps included, so a Host App that rescues a
|
|
15
17
|
# trap reads from the error's +execution+ how much of the budget the
|
data/lib/kobako/version.rb
CHANGED
data/lib/kobako.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Inside +lib/+, the code sits in tiers: a tier may use the tiers below it
|
|
4
4
|
# and never one above.
|
|
5
5
|
#
|
|
6
|
-
# Orchestration Sandbox,
|
|
6
|
+
# Orchestration Sandbox, Runtime (+ ext), Context
|
|
7
7
|
# |
|
|
8
8
|
# Catalog setup-time registries + the per-invocation Handle table
|
|
9
9
|
# |
|
|
@@ -23,8 +23,10 @@
|
|
|
23
23
|
#
|
|
24
24
|
# [A type sits at the lowest tier that needs it]
|
|
25
25
|
# Kobako::Handle sits at the root, for Codec.
|
|
26
|
-
# [A native
|
|
27
|
-
# Kobako::Filesystem
|
|
26
|
+
# [A native piece sits at the tier of the constant it registers on]
|
|
27
|
+
# Kobako::Filesystem and Kobako::Network sit at the root, for the
|
|
28
|
+
# Catalog, and so do the name rules on Kobako itself, for the Catalog and
|
|
29
|
+
# Transport; Kobako::Runtime sits with the Sandbox that drives it.
|
|
28
30
|
# [Outcome may require <tt>transport/error.rb</tt>]
|
|
29
31
|
# The gem contract fixes the class name.
|
|
30
32
|
# [<tt>Codec.track_handles</tt> wraps only the decode call]
|
|
@@ -44,11 +46,13 @@ rescue LoadError
|
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
require_relative "kobako/filesystem"
|
|
49
|
+
require_relative "kobako/network"
|
|
47
50
|
require_relative "kobako/errors"
|
|
51
|
+
require_relative "kobako/names"
|
|
48
52
|
require_relative "kobako/unresolved"
|
|
49
53
|
require_relative "kobako/extension"
|
|
50
54
|
require_relative "kobako/transport"
|
|
51
55
|
require_relative "kobako/catalog"
|
|
52
56
|
require_relative "kobako/runtime"
|
|
57
|
+
require_relative "kobako/fork"
|
|
53
58
|
require_relative "kobako/sandbox"
|
|
54
|
-
require_relative "kobako/pool"
|
data/release-please-config.json
CHANGED
|
@@ -115,6 +115,11 @@
|
|
|
115
115
|
"path": "/wasm/kobako-baker/Cargo.lock",
|
|
116
116
|
"jsonpath": "$.package[?(@.name=='kobako-baker')].version"
|
|
117
117
|
},
|
|
118
|
+
{
|
|
119
|
+
"type": "toml",
|
|
120
|
+
"path": "/wasm/kobako-baker/Cargo.toml",
|
|
121
|
+
"jsonpath": "$.dependencies['kobako-transport'].version"
|
|
122
|
+
},
|
|
118
123
|
{
|
|
119
124
|
"type": "generic",
|
|
120
125
|
"path": "/wasm/kobako-baker/README.md"
|
|
@@ -140,6 +145,11 @@
|
|
|
140
145
|
"path": "/wasm/Cargo.lock",
|
|
141
146
|
"jsonpath": "$.package[?(@.name=='kobako-transport')].version"
|
|
142
147
|
},
|
|
148
|
+
{
|
|
149
|
+
"type": "toml",
|
|
150
|
+
"path": "/wasm/kobako-baker/Cargo.lock",
|
|
151
|
+
"jsonpath": "$.package[?(@.name=='kobako-transport')].version"
|
|
152
|
+
},
|
|
143
153
|
{
|
|
144
154
|
"type": "generic",
|
|
145
155
|
"path": "/crates/kobako-transport/README.md"
|
|
@@ -160,6 +170,11 @@
|
|
|
160
170
|
"path": "/wasm/Cargo.lock",
|
|
161
171
|
"jsonpath": "$.package[?(@.name=='kobako-codec')].version"
|
|
162
172
|
},
|
|
173
|
+
{
|
|
174
|
+
"type": "toml",
|
|
175
|
+
"path": "/crates/kobako-codec/Cargo.toml",
|
|
176
|
+
"jsonpath": "$.dependencies['kobako-transport'].version"
|
|
177
|
+
},
|
|
163
178
|
{
|
|
164
179
|
"type": "generic",
|
|
165
180
|
"path": "/crates/kobako-codec/README.md"
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
module Kobako
|
|
2
2
|
module Catalog
|
|
3
3
|
class Grants
|
|
4
|
-
|
|
4
|
+
type key = [Symbol, String]
|
|
5
|
+
|
|
6
|
+
type grant = Mount | Network
|
|
5
7
|
|
|
6
|
-
def
|
|
8
|
+
def initialize: () -> void
|
|
7
9
|
|
|
8
|
-
def
|
|
10
|
+
def register: (grant grant) -> nil
|
|
9
11
|
|
|
10
|
-
def
|
|
12
|
+
def include?: (grant grant) -> bool
|
|
13
|
+
def entries: (?Hash[key, grant] overrides) -> [Array[Mount::tuple], Array[Network::tuple]]
|
|
11
14
|
end
|
|
12
15
|
end
|
|
13
16
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Kobako
|
|
2
2
|
module Catalog
|
|
3
3
|
class Handles
|
|
4
|
+
MAX_HANDLES: Integer
|
|
5
|
+
|
|
4
6
|
def initialize: (?next_id: Integer) -> void
|
|
5
7
|
|
|
6
8
|
def alloc: (untyped object) -> Kobako::Handle
|
|
@@ -13,8 +15,6 @@ module Kobako
|
|
|
13
15
|
|
|
14
16
|
private
|
|
15
17
|
|
|
16
|
-
def reject_unwrappable: (untyped object) -> void
|
|
17
|
-
|
|
18
18
|
def ensure_capacity: () -> void
|
|
19
19
|
|
|
20
20
|
def require_bound: (Integer id) -> void
|
|
@@ -14,7 +14,9 @@ module Kobako
|
|
|
14
14
|
|
|
15
15
|
def self.new: (at: untyped, access: untyped, filesystem: untyped, policy: policy?) -> Mount
|
|
16
16
|
|
|
17
|
-
def
|
|
17
|
+
def initialize: (at: untyped, access: untyped, filesystem: untyped, policy: policy?) -> void
|
|
18
|
+
|
|
19
|
+
def key: () -> Grants::key
|
|
18
20
|
|
|
19
21
|
def conflict: (Mount other) -> String?
|
|
20
22
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Kobako
|
|
2
|
+
module Catalog
|
|
3
|
+
class Network < Data
|
|
4
|
+
type tuple = [String, untyped]
|
|
5
|
+
|
|
6
|
+
attr_reader name: String
|
|
7
|
+
attr_reader entry: untyped
|
|
8
|
+
|
|
9
|
+
def self.new: (name: untyped, entry: untyped) ?{ (Kobako::Network::Builder) -> void } -> Network
|
|
10
|
+
|
|
11
|
+
def initialize: (name: untyped, entry: untyped) ?{ (Kobako::Network::Builder) -> void } -> void
|
|
12
|
+
|
|
13
|
+
def key: () -> Grants::key
|
|
14
|
+
|
|
15
|
+
def conflict: (Mount | Network other) -> String?
|
|
16
|
+
|
|
17
|
+
def to_native: () -> tuple
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Kobako
|
|
2
|
+
module Catalog
|
|
3
|
+
class Replacements
|
|
4
|
+
@grants: Grants
|
|
5
|
+
@replaced: Hash[Grants::key, Grants::grant]
|
|
6
|
+
|
|
7
|
+
def initialize: (Grants grants) -> void
|
|
8
|
+
|
|
9
|
+
def replace: (Grants::grant grant, String refusal) -> nil
|
|
10
|
+
|
|
11
|
+
def entries: () -> [Array[Mount::tuple], Array[Network::tuple]]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
module Kobako
|
|
2
2
|
module Catalog
|
|
3
3
|
class Services
|
|
4
|
-
RESERVED_NAMESPACE: String
|
|
5
|
-
|
|
6
4
|
def initialize: () -> void
|
|
7
5
|
|
|
8
6
|
def bind: (Symbol | String path, untyped object) -> self
|
|
@@ -17,8 +15,6 @@ module Kobako
|
|
|
17
15
|
|
|
18
16
|
def validate_path: (Symbol | String path) -> String
|
|
19
17
|
|
|
20
|
-
def reserved?: (String path) -> bool
|
|
21
|
-
|
|
22
18
|
def collision?: (String path) -> bool
|
|
23
19
|
end
|
|
24
20
|
end
|
|
@@ -5,16 +5,10 @@ module Kobako
|
|
|
5
5
|
|
|
6
6
|
def self.representable?: (untyped value, ?Integer depth) -> bool
|
|
7
7
|
|
|
8
|
-
def self.deep_wrap: (untyped value, Kobako::Codec::_HandleTable handles, ?Integer depth) -> untyped
|
|
9
|
-
|
|
10
8
|
def self.deep_restore: (untyped value, Kobako::Codec::_HandleTable handles) -> untyped
|
|
11
9
|
|
|
12
10
|
private
|
|
13
11
|
|
|
14
|
-
def self.guard_nesting: (Integer depth) -> void
|
|
15
|
-
|
|
16
|
-
def self.deep_wrap_hash: (Hash[untyped, untyped] hash, Kobako::Codec::_HandleTable handles, Integer depth) -> Hash[untyped, untyped]
|
|
17
|
-
|
|
18
12
|
def self.primitive_type?: (untyped value) -> bool
|
|
19
13
|
|
|
20
14
|
def self.container_representable?: (untyped value, Integer depth) -> bool
|
data/sig/kobako/codec/state.rbs
CHANGED
|
@@ -6,13 +6,9 @@ module Kobako
|
|
|
6
6
|
def self.current: () -> State
|
|
7
7
|
|
|
8
8
|
@carried_handle: bool
|
|
9
|
-
@value_budget: Integer?
|
|
10
|
-
|
|
11
|
-
attr_reader value_budget: Integer?
|
|
12
9
|
|
|
13
10
|
def track_handles: [T] { () -> T } -> [T, bool]
|
|
14
11
|
def record_handle: () -> void
|
|
15
|
-
def within_value_budget: [T] (Integer? budget) { () -> T } -> T
|
|
16
12
|
|
|
17
13
|
private
|
|
18
14
|
|