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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.githooks/linux-tests.sh +29 -0
  3. data/.release-please-manifest.json +1 -1
  4. data/CHANGELOG.md +460 -0
  5. data/README.md +43 -4
  6. data/ROADMAP.md +1 -2
  7. data/crates/kobako-runtime/CHANGELOG.md +309 -0
  8. data/crates/kobako-runtime/README.md +7 -4
  9. data/crates/kobako-transport/CHANGELOG.md +38 -0
  10. data/crates/kobako-transport/README.md +3 -4
  11. data/crates/kobako-wasmtime/CHANGELOG.md +208 -0
  12. data/crates/kobako-wasmtime/README.md +4 -3
  13. data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
  14. data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
  15. data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
  16. data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
  17. data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
  18. data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
  19. data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
  20. data/crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx +13 -0
  21. data/data/kobako.wasm +0 -0
  22. data/lib/kobako/3.3/kobako.so +0 -0
  23. data/lib/kobako/3.4/kobako.so +0 -0
  24. data/lib/kobako/4.0/kobako.so +0 -0
  25. data/lib/kobako/catalog/extensions.rb +14 -2
  26. data/lib/kobako/catalog/flags.rb +3 -5
  27. data/lib/kobako/catalog/grants.rb +5 -4
  28. data/lib/kobako/catalog/handles.rb +14 -32
  29. data/lib/kobako/catalog/mount.rb +11 -3
  30. data/lib/kobako/catalog/network.rb +35 -0
  31. data/lib/kobako/catalog/replacements.rb +28 -0
  32. data/lib/kobako/catalog/services.rb +5 -19
  33. data/lib/kobako/catalog/snippets.rb +3 -18
  34. data/lib/kobako/catalog.rb +3 -0
  35. data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
  36. data/lib/kobako/codec/decoder.rb +5 -5
  37. data/lib/kobako/codec/ext_types.rb +3 -3
  38. data/lib/kobako/codec/handle_walk.rb +3 -43
  39. data/lib/kobako/codec/state.rb +2 -18
  40. data/lib/kobako/codec/value_budget.rb +133 -41
  41. data/lib/kobako/codec.rb +6 -7
  42. data/lib/kobako/context.rb +24 -11
  43. data/lib/kobako/errors.rb +18 -18
  44. data/lib/kobako/extension.rb +3 -2
  45. data/lib/kobako/filesystem.rb +10 -3
  46. data/lib/kobako/fork.rb +42 -0
  47. data/lib/kobako/handle.rb +2 -3
  48. data/lib/kobako/names.rb +28 -0
  49. data/lib/kobako/network.rb +210 -0
  50. data/lib/kobako/outcome.rb +7 -7
  51. data/lib/kobako/runtime.rb +3 -2
  52. data/lib/kobako/sandbox.rb +73 -35
  53. data/lib/kobako/sandbox_options.rb +42 -109
  54. data/lib/kobako/transport/argument_wrap.rb +64 -0
  55. data/lib/kobako/transport/block_failure.rb +1 -1
  56. data/lib/kobako/transport/dispatcher.rb +6 -6
  57. data/lib/kobako/transport/exposure.rb +26 -15
  58. data/lib/kobako/transport/reflection.rb +21 -4
  59. data/lib/kobako/transport/run.rb +8 -23
  60. data/lib/kobako/transport/yielder.rb +2 -9
  61. data/lib/kobako/transport.rb +1 -0
  62. data/lib/kobako/usage.rb +4 -2
  63. data/lib/kobako/version.rb +1 -1
  64. data/lib/kobako.rb +8 -4
  65. data/release-please-config.json +15 -0
  66. data/sig/kobako/catalog/extensions.rbs +2 -0
  67. data/sig/kobako/catalog/grants.rbs +7 -4
  68. data/sig/kobako/catalog/handles.rbs +2 -2
  69. data/sig/kobako/catalog/mount.rbs +3 -1
  70. data/sig/kobako/catalog/network.rbs +20 -0
  71. data/sig/kobako/catalog/replacements.rbs +14 -0
  72. data/sig/kobako/catalog/services.rbs +0 -4
  73. data/sig/kobako/catalog/snippets.rbs +0 -2
  74. data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
  75. data/sig/kobako/codec/handle_walk.rbs +0 -6
  76. data/sig/kobako/codec/state.rbs +0 -4
  77. data/sig/kobako/codec/value_budget.rbs +48 -5
  78. data/sig/kobako/codec.rbs +2 -2
  79. data/sig/kobako/context.rbs +3 -1
  80. data/sig/kobako/errors.rbs +4 -7
  81. data/sig/kobako/filesystem.rbs +21 -3
  82. data/sig/kobako/fork.rbs +17 -0
  83. data/sig/kobako/network.rbs +115 -0
  84. data/sig/kobako/outcome.rbs +1 -1
  85. data/sig/kobako/runtime.rbs +32 -3
  86. data/sig/kobako/sandbox.rbs +10 -2
  87. data/sig/kobako/sandbox_options.rbs +29 -40
  88. data/sig/kobako/transport/argument_wrap.rbs +15 -0
  89. data/sig/kobako/transport/error.rbs +1 -1
  90. data/sig/kobako/transport/exposure.rbs +2 -4
  91. data/sig/kobako/transport/reflection.rbs +10 -0
  92. data/sig/kobako/transport/run.rbs +0 -2
  93. data/sig/kobako/transport/yielder.rbs +0 -3
  94. data/sig/kobako/transport.rbs +1 -1
  95. data/sig/kobako.rbs +13 -0
  96. metadata +25 -11
  97. data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
  98. data/lib/kobako/constant_name.rb +0 -8
  99. data/lib/kobako/pool.rb +0 -140
  100. data/sig/kobako/constant_name.rbs +0 -3
  101. 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
@@ -28,7 +28,7 @@ module Kobako
28
28
  raised = @raised
29
29
  return if raised.nil? || !error.equal?(raised)
30
30
 
31
- "#{raised.klass}: #{raised.message}"
31
+ "#{raised.class_name}: #{raised.message}"
32
32
  end
33
33
  end
34
34
  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.public_send(name, *args, &block)
118
+ Reflection::PUBLIC_SEND.bind(target).call(name, *args, &block)
119
119
  else
120
- target.public_send(name, *args, **kwargs, &block)
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
- object.__send__(PREDICATE, name) ? true : false
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 target.respond_to?(name)
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.singleton_class if target.is_a?(Module) || target.singleton_methods.any?
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
- target.class
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
- (target.is_a?(Module) && owner.singleton_class?)
152
+ (module?(target) && owner.singleton_class?)
136
153
  end
137
154
  end
138
155
  end
@@ -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 = normalize_entrypoint(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: Codec::HandleWalk.deep_wrap(args, handles, 1),
27
- kwargs: Codec::HandleWalk.deep_wrap(kwargs, handles, 1)
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 ArgumentError, "arguments must be an Array" unless args.is_a?(Array)
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 ArgumentError, "keyword arguments must be a Hash" unless kwargs.is_a?(Hash)
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 ArgumentError,
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
- raise LocalJumpError, "guest block invoked after host dispatch frame returned" unless @active
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, klass: klass)) if arm == :error
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "transport/call"
4
+ require_relative "transport/argument_wrap"
4
5
  require_relative "transport/run"
5
6
  require_relative "transport/block_failure"
6
7
  require_relative "transport/yielder"
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+; it never exceeds the
12
- # cap, even when the cap was hit.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobako
4
- VERSION = "0.30.0"
4
+ VERSION = "0.32.0"
5
5
  end
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, Pool, Runtime (+ ext), Context
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-defined handle that needs nothing in +lib/+ sits at the root]
27
- # Kobako::Filesystem sits at the root, for the Catalog.
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"
@@ -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"
@@ -17,6 +17,8 @@ module Kobako
17
17
 
18
18
  def validate: (untyped extension) -> void
19
19
 
20
+ def validate_dependencies: (untyped dependencies) -> void
21
+
20
22
  def unmet_dependency: () -> [untyped, untyped]?
21
23
 
22
24
  def symbolize: (untyped name) -> untyped
@@ -1,13 +1,16 @@
1
1
  module Kobako
2
2
  module Catalog
3
3
  class Grants
4
- def initialize: () -> void
4
+ type key = [Symbol, String]
5
+
6
+ type grant = Mount | Network
5
7
 
6
- def register: (Mount grant) -> nil
8
+ def initialize: () -> void
7
9
 
8
- def include?: (Mount grant) -> bool
10
+ def register: (grant grant) -> nil
9
11
 
10
- def entries: (?Hash[String, Mount] overrides) -> Array[Mount::tuple]
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 key: () -> String
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
@@ -22,8 +22,6 @@ module Kobako
22
22
  def register_binary: (String bytes) -> nil
23
23
 
24
24
  def entry_tuple: (entry) -> tuple
25
-
26
- def normalize_name: (Symbol | String name) -> Symbol
27
25
  end
28
26
  end
29
27
  end
@@ -1,9 +1,9 @@
1
1
  module Kobako
2
2
  module Codec
3
- module Utils
3
+ module Boundary
4
4
  def self.assert_utf8: (String string, String label) -> void
5
5
 
6
- def self.with_boundary: [T] () { () -> T } -> T
6
+ def self.within: [T] () { () -> T } -> T
7
7
  end
8
8
  end
9
9
  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
@@ -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