kobako 0.29.0-aarch64-linux → 0.31.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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/CHANGELOG.md +552 -10
  4. data/README.md +126 -564
  5. data/ROADMAP.md +3 -2
  6. data/crates/kobako-runtime/CHANGELOG.md +488 -1
  7. data/crates/kobako-runtime/README.md +11 -4
  8. data/crates/kobako-transport/CHANGELOG.md +39 -2
  9. data/crates/kobako-transport/README.md +8 -8
  10. data/crates/kobako-wasmtime/CHANGELOG.md +315 -8
  11. data/crates/kobako-wasmtime/README.md +11 -6
  12. data/crates/kobako-wasmtime/src/preview1/testsuite-expected.txt +6 -0
  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/typenames.witx +750 -0
  21. data/crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx +441 -0
  22. data/data/kobako.wasm +0 -0
  23. data/lib/kobako/3.3/kobako.so +0 -0
  24. data/lib/kobako/3.4/kobako.so +0 -0
  25. data/lib/kobako/4.0/kobako.so +0 -0
  26. data/lib/kobako/catalog/extensions.rb +19 -7
  27. data/lib/kobako/catalog/flags.rb +4 -6
  28. data/lib/kobako/catalog/grants.rb +5 -4
  29. data/lib/kobako/catalog/handles.rb +9 -31
  30. data/lib/kobako/catalog/mount.rb +12 -12
  31. data/lib/kobako/catalog/network.rb +35 -0
  32. data/lib/kobako/catalog/replacements.rb +28 -0
  33. data/lib/kobako/catalog/services.rb +7 -21
  34. data/lib/kobako/catalog/snippets.rb +10 -25
  35. data/lib/kobako/catalog.rb +4 -1
  36. data/lib/kobako/codec/{utils.rb → boundary.rb} +5 -3
  37. data/lib/kobako/codec/decoder.rb +12 -12
  38. data/lib/kobako/codec/ext_types.rb +5 -7
  39. data/lib/kobako/codec/handle_walk.rb +5 -47
  40. data/lib/kobako/codec/nesting.rb +7 -7
  41. data/lib/kobako/codec/value_budget.rb +134 -42
  42. data/lib/kobako/codec.rb +1 -1
  43. data/lib/kobako/context.rb +28 -15
  44. data/lib/kobako/errors.rb +15 -12
  45. data/lib/kobako/extension.rb +3 -2
  46. data/lib/kobako/filesystem.rb +53 -15
  47. data/lib/kobako/handle.rb +2 -2
  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/payload/arguments.rb +2 -2
  52. data/lib/kobako/pool.rb +47 -25
  53. data/lib/kobako/runtime.rb +3 -2
  54. data/lib/kobako/sandbox.rb +113 -56
  55. data/lib/kobako/sandbox_options.rb +41 -107
  56. data/lib/kobako/snippet/bytecode.rb +1 -1
  57. data/lib/kobako/snippet/source.rb +1 -1
  58. data/lib/kobako/transport/argument_wrap.rb +64 -0
  59. data/lib/kobako/transport/block_failure.rb +1 -1
  60. data/lib/kobako/transport/dispatcher.rb +10 -10
  61. data/lib/kobako/transport/exposure.rb +28 -17
  62. data/lib/kobako/transport/reflection.rb +28 -11
  63. data/lib/kobako/transport/run.rb +13 -28
  64. data/lib/kobako/transport/yielder.rb +3 -10
  65. data/lib/kobako/transport.rb +1 -0
  66. data/lib/kobako/version.rb +1 -1
  67. data/lib/kobako.rb +38 -0
  68. data/release-please-config.json +16 -0
  69. data/sig/core/thread.rbs +6 -0
  70. data/sig/kobako/catalog/extensions.rbs +5 -3
  71. data/sig/kobako/catalog/grants.rbs +7 -4
  72. data/sig/kobako/catalog/handles.rbs +2 -4
  73. data/sig/kobako/catalog/mount.rbs +3 -5
  74. data/sig/kobako/catalog/network.rbs +20 -0
  75. data/sig/kobako/catalog/replacements.rbs +14 -0
  76. data/sig/kobako/catalog/services.rbs +1 -5
  77. data/sig/kobako/catalog/snippets.rbs +3 -5
  78. data/sig/kobako/catalog.rbs +1 -1
  79. data/sig/kobako/codec/boundary.rbs +9 -0
  80. data/sig/kobako/codec/decoder.rbs +1 -1
  81. data/sig/kobako/codec/handle_walk.rbs +0 -6
  82. data/sig/kobako/codec/nesting.rbs +2 -2
  83. data/sig/kobako/codec/value_budget.rbs +48 -5
  84. data/sig/kobako/codec.rbs +1 -2
  85. data/sig/kobako/context.rbs +4 -2
  86. data/sig/kobako/errors.rbs +4 -4
  87. data/sig/kobako/filesystem.rbs +38 -15
  88. data/sig/kobako/guest_yielder.rbs +1 -1
  89. data/sig/kobako/network.rbs +115 -0
  90. data/sig/kobako/outcome.rbs +1 -1
  91. data/sig/kobako/payload/arguments.rbs +1 -1
  92. data/sig/kobako/pool.rbs +8 -4
  93. data/sig/kobako/runtime.rbs +32 -3
  94. data/sig/kobako/sandbox.rbs +22 -7
  95. data/sig/kobako/sandbox_options.rbs +29 -38
  96. data/sig/kobako/transport/argument_wrap.rbs +15 -0
  97. data/sig/kobako/transport/dispatcher.rbs +2 -2
  98. data/sig/kobako/transport/error.rbs +1 -1
  99. data/sig/kobako/transport/exposure.rbs +3 -5
  100. data/sig/kobako/transport/reflection.rbs +12 -2
  101. data/sig/kobako/transport/run.rbs +3 -5
  102. data/sig/kobako/transport/yielder.rbs +0 -3
  103. data/sig/kobako/transport.rbs +2 -2
  104. data/sig/kobako.rbs +13 -0
  105. metadata +26 -8
  106. data/lib/kobako/constant_name.rb +0 -8
  107. data/sig/kobako/codec/utils.rbs +0 -9
  108. data/sig/kobako/constant_name.rbs +0 -3
@@ -9,15 +9,58 @@ module Kobako
9
9
 
10
10
  UINT: Hash[Integer, String]
11
11
 
12
- def self.assert_within!: (String bytes, Integer? budget) -> void
12
+ FLOAT_FORMATS: Hash[Integer, String]
13
13
 
14
- private
14
+ FLOATS: Regexp
15
+
16
+ NAN_ENTRY: Integer
17
+
18
+ def self.assert_within: (String bytes, Integer? budget) -> void
19
+
20
+ class Count
21
+ class OpenContainer < Struct[untyped]
22
+ attr_accessor held: Integer
23
+ attr_accessor keyed: bool
24
+ attr_accessor read: Integer
25
+ attr_accessor nan_keys: Integer
26
+ attr_accessor holds_nan: bool
27
+
28
+ def self.new: (Integer held, bool keyed, Integer read, Integer nan_keys, bool holds_nan) -> OpenContainer
29
+ end
30
+
31
+ @bytes: String
32
+ @budget: Integer
33
+ @remaining: Integer
34
+ @open: Array[OpenContainer]
35
+
36
+ @ended: bool
37
+
38
+ def initialize: (String bytes, Integer budget) -> void
39
+
40
+ def run: () -> void
15
41
 
16
- def self.step: (String bytes, Integer pos) -> [Integer?, Integer]
42
+ private
17
43
 
18
- def self.step_framed:(String bytes, Integer pos, Integer marker) -> [Integer?, Integer]
44
+ def count_value: (Integer pos, Integer children, bool keyed) -> void
45
+
46
+ def close_value: (bool holds_nan) -> void
47
+
48
+ def charge_key: (OpenContainer map) -> void
49
+
50
+ def spend: (Integer values) -> void
51
+
52
+ def nan?: (Integer pos) -> bool
53
+
54
+ def step: (Integer pos) -> [Integer?, Integer, bool]
55
+
56
+ def step_framed: (Integer pos, Integer marker) -> [Integer?, Integer, bool]
57
+
58
+ def uint: (Integer pos, Integer width) -> Integer
59
+ end
60
+
61
+ private
19
62
 
20
- def self.uint: (String bytes, Integer pos, Integer width) -> Integer
63
+ def self.within_by_size?: (String bytes, Integer budget) -> bool
21
64
  end
22
65
  end
23
66
  end
data/sig/kobako/codec.rbs CHANGED
@@ -2,8 +2,7 @@ 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/payload-msgpack.md
6
- # § Type Mapping): the scalar leaves, a Capability Handle, and Array / Hash
5
+ # A value in the closed wire type set: the scalar leaves, a Capability Handle, and Array / Hash
7
6
  # containers of the same. The by-value payloads that cross the wire —
8
7
  # dispatch arguments and success values — inhabit this type; a Fault is
9
8
  # an envelope shape, not a wire_value.
@@ -2,7 +2,7 @@ module Kobako
2
2
  class Context
3
3
  type preamble = [Array[String], Array[Kobako::Catalog::Snippets::tuple], Array[Kobako::Catalog::Flags::tuple]]
4
4
 
5
- @mounts: Hash[String, Kobako::Catalog::Mount]?
5
+ @replacements: Kobako::Catalog::Replacements
6
6
 
7
7
  def initialize: (
8
8
  runtime: Kobako::Runtime,
@@ -16,6 +16,8 @@ module Kobako
16
16
 
17
17
  def mount: (String at, Kobako::Filesystem::mountable filesystem, ?access: Kobako::Filesystem::access) ?{ (String path, Kobako::Filesystem::access access) -> boolish } -> self
18
18
 
19
+ def network: (Symbol | String name, ?untyped entry) ?{ (Kobako::Network::Builder) -> void } -> self
20
+
19
21
  def lookup: (Symbol | String path) -> Kobako::Transport::Exposure
20
22
 
21
23
  def eval: (String code) ?{ (Kobako::Context) -> void } -> Kobako::Execution
@@ -38,6 +40,6 @@ module Kobako
38
40
 
39
41
  def settle_outcome: (Kobako::Snapshot snapshot, Symbol verb, Symbol? entrypoint) -> Kobako::Execution
40
42
 
41
- def invoke!: (Symbol verb, ?entrypoint: Symbol?) { () -> Kobako::Snapshot } -> Kobako::Execution
43
+ def invoke: (Symbol verb, ?entrypoint: Symbol?) { () -> Kobako::Snapshot } -> Kobako::Execution
42
44
  end
43
45
  end
@@ -21,18 +21,18 @@ module Kobako
21
21
  class SetupError < Error
22
22
  end
23
23
 
24
- class ModuleNotBuiltError < SetupError
24
+ class GuestBinaryNotFoundError < SetupError
25
25
  end
26
26
 
27
27
  module Diagnosable : Error
28
28
  attr_reader origin: String?
29
- attr_reader klass: String?
29
+ attr_reader class_name: String?
30
30
  attr_reader backtrace_lines: Array[String]?
31
31
 
32
32
  def initialize: (
33
33
  String message,
34
34
  ?origin: String?,
35
- ?klass: String?,
35
+ ?class_name: String?,
36
36
  ?backtrace_lines: Array[String]?
37
37
  ) -> void
38
38
  end
@@ -81,7 +81,7 @@ module Kobako
81
81
  ?name: Symbol?,
82
82
  ?available: Array[Symbol],
83
83
  ?origin: String?,
84
- ?klass: String?,
84
+ ?class_name: String?,
85
85
  ?backtrace_lines: Array[String]?
86
86
  ) -> void
87
87
  end
@@ -1,17 +1,24 @@
1
1
  module Kobako
2
2
  module Filesystem
3
- type mountable = Memory | Temporary | Directory | Overlay | _Readable
3
+ type mountable = Tmpfs | Bind | Overlay | _Readable
4
4
 
5
5
  type access = :read | :read_write
6
6
 
7
+ def self.validate_mount: (untyped at, untyped access, untyped filesystem) -> nil
8
+
7
9
  # What a Filesystem written in Ruby answers to be mounted. One that
8
10
  # also answers _Listable lists its directories, and one answering
9
11
  # _Writable takes changes too; each method it lacks is refused alone.
12
+ # One answering _Exclusive vouches only the guest changes it.
10
13
  interface _Readable
11
14
  def open: (String path, Integer flags) -> _File
12
15
  def stat: (String path) -> _Stat
13
16
  end
14
17
 
18
+ interface _Exclusive
19
+ def exclusive?: () -> boolish
20
+ end
21
+
15
22
  interface _Listable
16
23
  def children: (String path) -> Array[String]
17
24
  end
@@ -20,13 +27,14 @@ module Kobako
20
27
  def mkdir: (String path) -> void
21
28
  def rmdir: (String path) -> void
22
29
  def unlink: (String path) -> void
23
- def rename: (String from, String to, directory: bool?) -> void
30
+ def rename: (String from, String to) -> void
24
31
  end
25
32
 
26
33
  # A file a Filesystem written in Ruby opened; +::File+ answers it. One
27
34
  # that also answers _WritableFile takes writes too, one answering
28
35
  # _AppendableFile takes appends, and any file may answer _SyncableFile
29
- # to flush or _ClosableFile to close.
36
+ # to flush, _ClosableFile to close, or _StatableFile to report its times
37
+ # and count of names.
30
38
  interface _File
31
39
  def pread: (Integer length, Integer offset) -> String?
32
40
  def size: () -> Integer
@@ -51,9 +59,15 @@ module Kobako
51
59
  def close: () -> void
52
60
  end
53
61
 
62
+ interface _StatableFile
63
+ def stat: () -> _Stat
64
+ end
65
+
54
66
  # What a Filesystem written in Ruby's +stat+ answers, as +File::Stat+
55
67
  # does; an +ino+ of zero names no identity. One that also answers
56
- # _StatDevice names the device its +ino+ belongs to.
68
+ # _StatDevice names the device its +ino+ belongs to, _StatKind says a
69
+ # special file is one, _StatTimes gives its times, and _StatLinks its
70
+ # count of names.
57
71
  interface _Stat
58
72
  def directory?: () -> boolish
59
73
  def size: () -> Integer
@@ -64,24 +78,33 @@ module Kobako
64
78
  def dev: () -> Integer
65
79
  end
66
80
 
67
- class Memory
68
- # A bare <tt>"path" => contents</tt> arrives as keywords, which RBS
69
- # cannot key by String; a Symbol keyword past +limit+ and +inodes+
70
- # raises ArgumentError.
71
- def initialize: (?Hash[String, String] files, ?limit: Integer?, ?inodes: Integer?, **String) -> void
81
+ interface _StatKind
82
+ def ftype: () -> String
72
83
  end
73
84
 
74
- class Temporary
75
- def initialize: (?limit: Integer?, ?inodes: Integer?) -> void
85
+ interface _StatTimes
86
+ def atime: () -> Time
87
+ def mtime: () -> Time
88
+ def ctime: () -> Time
89
+ end
90
+
91
+ interface _StatLinks
92
+ def nlink: () -> Integer
93
+ end
94
+
95
+ class Tmpfs
96
+ # A bare <tt>"path" => contents</tt> arrives as keywords, which RBS
97
+ # cannot key by String; a Symbol keyword past +size+ and +nr_inodes+
98
+ # raises ArgumentError.
99
+ def initialize: (?Hash[String, String] files, ?size: Integer?, ?nr_inodes: Integer?, **String) -> void
76
100
  end
77
101
 
78
- class Directory
79
- def initialize: (String path) -> void
102
+ class Bind
103
+ def initialize: (String path, ?exclusive: bool) -> void
80
104
  end
81
105
 
82
106
  class Overlay
83
- def initialize: () -> void
84
- def layer: (mountable filesystem, ?access: access) -> Overlay
107
+ def initialize: (lower: Array[mountable], ?upper: Tmpfs?) -> void
85
108
  end
86
109
 
87
110
  end
@@ -2,7 +2,7 @@ module Kobako
2
2
  # Frame-scoped guest re-entry handle the ext hands the dispatch Proc as
3
3
  # its last argument — the production conformer of
4
4
  # +Kobako::Transport::_GuestYielder+, answering the Yield Reply already
5
- # split off the core envelope.
5
+ # split off the Envelope.
6
6
  class GuestYielder
7
7
  def call: (String args_bytes) -> [Symbol, String, String?]
8
8
  end
@@ -0,0 +1,115 @@
1
+ module Kobako
2
+ module Network
3
+ type protocol = :http | :tcp | :udp
4
+
5
+ UNWRITTEN: Object
6
+
7
+ def self.normalize_endpoint: (untyped host, untyped port, Hash[Symbol, untyped] written) ->
8
+ [String, Integer, protocol, Array[Symbol | String | IPAddr], Array[HttpRule]]
9
+
10
+ def self.normalize_rule: (bool allow, untyped method, untyped path) -> [bool, String?, String]
11
+
12
+ def self.normalize_credential: (Symbol | String placement, untyped placeholder) -> String
13
+
14
+ def self.validate_name: (String name) -> nil
15
+
16
+ class Mock
17
+ def initialize: (?local_addresses: Array[String]?) -> void
18
+
19
+ def resolve: (String name, to: String | Array[String]) -> nil
20
+
21
+ def route: (String address, Integer port, to: [String, Integer], ?protocol: :tcp | :udp) -> nil
22
+
23
+ def refuse: (String address, Integer port, singleton(SystemCallError) errno, ?protocol: :tcp | :udp) -> nil
24
+
25
+ def hold: [T] (String name) { () -> T } -> T
26
+
27
+ def lookups: () -> Array[String]
28
+
29
+ def dialed_addresses: () -> Array[[String, Integer]]
30
+ end
31
+
32
+ class Endpoint < Data
33
+ attr_reader host: String
34
+ attr_reader port: Integer
35
+ attr_reader protocol: protocol
36
+ attr_reader addresses: Array[Symbol | String | IPAddr]
37
+ attr_reader rules: Array[HttpRule]
38
+
39
+ def self.new: (host: untyped, port: untyped, ?protocol: untyped, ?addresses: untyped, ?rules: untyped) -> Endpoint
40
+
41
+ def initialize: (host: untyped, port: untyped, ?protocol: untyped, ?addresses: untyped, ?rules: untyped) -> void
42
+ end
43
+
44
+ class Connection < Data
45
+ attr_reader host: String
46
+ attr_reader port: Integer
47
+ attr_reader protocol: protocol
48
+
49
+ def self.new: (host: String, port: Integer, protocol: protocol) -> Connection
50
+ end
51
+
52
+ class HttpRule
53
+ @allow: bool
54
+
55
+ def allow?: () -> bool
56
+ attr_reader method: String?
57
+ attr_reader path: String
58
+
59
+ def initialize: (allow: boolish, method: untyped, path: untyped) -> void
60
+ end
61
+
62
+ class Rules
63
+ @rules: Array[HttpRule]
64
+
65
+ def initialize: () -> void
66
+
67
+ def allow: (untyped method, untyped path) -> self
68
+
69
+ def deny: (untyped method, untyped path) -> self
70
+
71
+ def to_a: () -> Array[HttpRule]
72
+ end
73
+
74
+ class Credential
75
+ @source: ^(Request) -> String?
76
+
77
+ attr_reader placement: Symbol | String
78
+ attr_reader placeholder: String
79
+
80
+ def initialize: (Symbol | String placement, placeholder: untyped) ?{ (Request) -> String? } -> void
81
+
82
+ def value: (Request request) -> String?
83
+ end
84
+
85
+ class Request
86
+ attr_reader host: String
87
+ attr_reader port: Integer
88
+ attr_reader method: String
89
+ attr_reader scheme: String
90
+ attr_reader path: String
91
+ attr_reader header_names: Array[String]
92
+
93
+ def initialize: ([String, Integer] authority, String method, String scheme, String path, Array[String] header_names) -> void
94
+ end
95
+
96
+ class Builder
97
+ HOOKS: Array[Symbol]
98
+
99
+ @entry: untyped
100
+ @endpoints: Array[Endpoint]
101
+ @policies: Hash[Symbol, Array[^(untyped) -> boolish]]
102
+ @credentials: Array[Credential]
103
+
104
+ def initialize: (?untyped entry) -> void
105
+
106
+ def credential: (Symbol | String placement, placeholder: untyped) ?{ (Request) -> String? } -> self
107
+
108
+ def endpoint: (untyped host, port: untyped, ?protocol: untyped, ?addresses: untyped) ?{ (Rules) -> void } -> self
109
+
110
+ def policy: (Symbol hook) ?{ (untyped) -> boolish } -> self
111
+
112
+ def to_native: () -> [untyped, Array[Endpoint], Array[Credential], Hash[Symbol, Array[^(untyped) -> boolish]]]
113
+ end
114
+ end
115
+ end
@@ -12,7 +12,7 @@ module Kobako
12
12
 
13
13
  def self.panic_error: (panic_fields panic, Symbol? entrypoint) -> (SandboxError | ServiceError)
14
14
 
15
- def self.error_class: (String origin, String klass) -> (singleton(SandboxError) | singleton(ServiceError))
15
+ def self.error_class: (String origin, String class_name) -> (singleton(SandboxError) | singleton(ServiceError))
16
16
 
17
17
  def self.decode_value: (String payload) -> Kobako::Codec::wire_value
18
18
 
@@ -20,7 +20,7 @@ module Kobako
20
20
 
21
21
  private
22
22
 
23
- def validate_kwargs!: (Hash[untyped, untyped] kwargs) -> void
23
+ def validate_kwargs: (Hash[untyped, untyped] kwargs) -> void
24
24
  end
25
25
  end
26
26
  end
data/sig/kobako/pool.rbs CHANGED
@@ -2,7 +2,9 @@ module Kobako
2
2
  class Pool
3
3
  DEFAULT_CHECKOUT_TIMEOUT_SECONDS: Float
4
4
 
5
- @slots: Integer
5
+ DEPRECATION: String
6
+
7
+ @size: Integer
6
8
  @checkout_timeout: Float?
7
9
  @sandbox_options: Hash[Symbol, untyped]
8
10
  @setup: ^(Kobako::Sandbox) -> void | nil
@@ -12,7 +14,7 @@ module Kobako
12
14
  @slot_freed: Thread::ConditionVariable
13
15
 
14
16
  def initialize: (
15
- slots: Integer,
17
+ size: Integer,
16
18
  ?checkout_timeout: (Float | Integer)?,
17
19
  **untyped sandbox_options
18
20
  ) ?{ (Kobako::Sandbox) -> void } -> void
@@ -25,17 +27,19 @@ module Kobako
25
27
 
26
28
  def claim_or_wait: (Float? deadline) -> [Symbol, Kobako::Sandbox?]
27
29
 
28
- def await_slot!: (Float? deadline) -> void
30
+ def await_slot: (Float? deadline) -> void
29
31
 
30
32
  def construct_slot: () -> Kobako::Sandbox
31
33
 
34
+ def build_slot: () -> Kobako::Sandbox
35
+
32
36
  def checkin: (Kobako::Sandbox sandbox) -> void
33
37
 
34
38
  def release_capacity: () -> void
35
39
 
36
40
  def monotonic_now: () -> Float
37
41
 
38
- def validate_slots!: (untyped slots) -> void
42
+ def validate_size: (untyped size) -> void
39
43
 
40
44
  def normalize_checkout_timeout: ((Float | Integer)? checkout_timeout) -> Float?
41
45
  end
@@ -2,7 +2,32 @@ module Kobako
2
2
  class Runtime
3
3
  def self.default_path: () -> String
4
4
 
5
- def self.validate_mount!: (untyped at, untyped access, untyped filesystem) -> nil
5
+ def self.default_options: () -> {
6
+ timeout: Float?,
7
+ setup_timeout: Float?,
8
+ memory_limit: Integer?,
9
+ stdout_limit: Integer?,
10
+ stderr_limit: Integer?,
11
+ open_file_limit: Integer?,
12
+ open_connection_limit: Integer?,
13
+ connection_limit: Integer?,
14
+ profile: Symbol,
15
+ gvl: Symbol,
16
+ network: nil
17
+ }
18
+
19
+ def self.normalize_caps: (Hash[Symbol, untyped] caps) -> {
20
+ timeout: Float?,
21
+ setup_timeout: Float?,
22
+ memory_limit: Integer?,
23
+ stdout_limit: Integer?,
24
+ stderr_limit: Integer?,
25
+ open_file_limit: Integer?,
26
+ open_connection_limit: Integer?,
27
+ connection_limit: Integer?
28
+ }
29
+
30
+ def self.value_budget_of: (Integer? memory_limit) -> Integer?
6
31
 
7
32
  def self.from_path: (
8
33
  String path,
@@ -12,15 +37,19 @@ module Kobako
12
37
  stdout_limit: Integer?,
13
38
  stderr_limit: Integer?,
14
39
  open_file_limit: Integer?,
40
+ open_connection_limit: Integer?,
41
+ connection_limit: Integer?,
15
42
  profile: Symbol,
16
- gvl: Symbol
43
+ gvl: Symbol,
44
+ network: Network::Mock?
17
45
  ) -> Runtime
18
46
 
19
47
  type setup = [
20
48
  Array[String],
21
49
  Array[Kobako::Catalog::Snippets::tuple],
22
50
  Array[Kobako::Catalog::Flags::tuple],
23
- Array[Kobako::Catalog::Mount::tuple]
51
+ Array[Kobako::Catalog::Mount::tuple],
52
+ Array[Kobako::Catalog::Network::tuple]
24
53
  ]
25
54
 
26
55
  def eval: (Kobako::Transport::dispatch_proc dispatch, setup setup, String source) -> Kobako::Snapshot
@@ -12,11 +12,14 @@ module Kobako
12
12
  def stdout_limit: () -> Integer?
13
13
  def stderr_limit: () -> Integer?
14
14
  def open_file_limit: () -> Integer?
15
+ def open_connection_limit: () -> Integer?
16
+ def connection_limit: () -> Integer?
15
17
  def profile: () -> Symbol
16
18
  def gvl: () -> Symbol
17
19
 
18
- # Every keyword beyond wasm_path forwards verbatim to
19
- # SandboxOptions.new (the caps + the profile floor).
20
+ # Every keyword beyond wasm_path lands on the runtime's defaults for
21
+ # SandboxOptions.new; the runtime judges the profile, the mode, and the
22
+ # floor.
20
23
  def initialize: (
21
24
  ?wasm_path: String?,
22
25
  **untyped options
@@ -28,6 +31,8 @@ module Kobako
28
31
 
29
32
  def mount: (String at, Kobako::Filesystem::mountable filesystem, ?access: Kobako::Filesystem::access) ?{ (String path, Kobako::Filesystem::access access) -> boolish } -> Kobako::Sandbox
30
33
 
34
+ def network: (Symbol | String name, ?untyped entry) ?{ (Kobako::Network::Builder) -> void } -> Kobako::Sandbox
35
+
31
36
  def preload: (code: String, name: Symbol | String) -> Kobako::Sandbox
32
37
  | (binary: String) -> Kobako::Sandbox
33
38
 
@@ -39,14 +44,24 @@ module Kobako
39
44
 
40
45
  private
41
46
 
42
- def build_runtime!: () -> Kobako::Runtime
43
-
44
- def new_invocation: () -> Kobako::Context
47
+ def build_runtime: () -> Kobako::Runtime
45
48
 
46
49
  def preamble: (Array[Kobako::Catalog::Snippets::tuple] snippets) -> Kobako::Context::preamble
47
50
 
48
- def refuse_once_invoked!: (String verb) -> void
51
+ def refuse_once_invoked: (String verb) -> void
52
+
53
+ def seal: (String reason) -> String
54
+
55
+ def begin_invocation: () -> Kobako::Context
56
+
57
+ def warn_release_on_main_thread: () -> void
58
+
59
+ module MainThreadRelease
60
+ MESSAGE: String
61
+
62
+ self.@warned: bool
49
63
 
50
- def begin_invocation!: () -> void
64
+ def self.warn_once: () -> void
65
+ end
51
66
  end
52
67
  end
@@ -1,45 +1,43 @@
1
1
  module Kobako
2
2
  class SandboxOptions < Data
3
- DEFAULT_TIMEOUT_SECONDS: Float
4
- DEFAULT_SETUP_TIMEOUT_SECONDS: Float
5
- DEFAULT_MEMORY_LIMIT: Integer
6
- DEFAULT_OUTPUT_LIMIT: Integer
7
- DEFAULT_OPEN_FILE_LIMIT: Integer
8
- DEFAULT_PROFILE: Symbol
9
- PROFILES: Array[Symbol]
10
- GVL_MODES: Array[Symbol]
11
- DEFAULT_GVL: Symbol
12
- VALUE_BYTES: Integer
13
-
14
3
  attr_reader timeout: Float?
15
4
  attr_reader setup_timeout: Float?
16
5
  attr_reader memory_limit: Integer?
17
6
  attr_reader stdout_limit: Integer?
18
7
  attr_reader stderr_limit: Integer?
19
8
  attr_reader open_file_limit: Integer?
9
+ attr_reader open_connection_limit: Integer?
10
+ attr_reader connection_limit: Integer?
20
11
  attr_reader profile: Symbol
21
12
  attr_reader gvl: Symbol
13
+ attr_reader network: Network::Mock?
22
14
 
23
15
  def self.new: (
24
- ?timeout: (Float | Integer)?,
25
- ?setup_timeout: (Float | Integer)?,
26
- ?memory_limit: Integer?,
27
- ?stdout_limit: Integer?,
28
- ?stderr_limit: Integer?,
29
- ?open_file_limit: Integer?,
30
- ?profile: Symbol,
31
- ?gvl: Symbol
16
+ timeout: (Float | Integer)?,
17
+ setup_timeout: (Float | Integer)?,
18
+ memory_limit: Integer?,
19
+ stdout_limit: Integer?,
20
+ stderr_limit: Integer?,
21
+ open_file_limit: Integer?,
22
+ open_connection_limit: Integer?,
23
+ connection_limit: Integer?,
24
+ profile: Symbol,
25
+ gvl: Symbol,
26
+ network: Network::Mock?
32
27
  ) -> SandboxOptions
33
28
 
34
29
  def initialize: (
35
- ?timeout: (Float | Integer)?,
36
- ?setup_timeout: (Float | Integer)?,
37
- ?memory_limit: Integer?,
38
- ?stdout_limit: Integer?,
39
- ?stderr_limit: Integer?,
40
- ?open_file_limit: Integer?,
41
- ?profile: Symbol,
42
- ?gvl: Symbol
30
+ timeout: (Float | Integer)?,
31
+ setup_timeout: (Float | Integer)?,
32
+ memory_limit: Integer?,
33
+ stdout_limit: Integer?,
34
+ stderr_limit: Integer?,
35
+ open_file_limit: Integer?,
36
+ open_connection_limit: Integer?,
37
+ connection_limit: Integer?,
38
+ profile: Symbol,
39
+ gvl: Symbol,
40
+ network: Network::Mock?
43
41
  ) -> void
44
42
 
45
43
  def to_h: () -> {
@@ -49,20 +47,13 @@ module Kobako
49
47
  stdout_limit: Integer?,
50
48
  stderr_limit: Integer?,
51
49
  open_file_limit: Integer?,
50
+ open_connection_limit: Integer?,
51
+ connection_limit: Integer?,
52
52
  profile: Symbol,
53
- gvl: Symbol
53
+ gvl: Symbol,
54
+ network: Network::Mock?
54
55
  }
55
56
 
56
57
  def value_budget: () -> Integer?
57
-
58
- def enforce_floor!: (Symbol declared) -> void
59
-
60
- private
61
-
62
- def normalize_timeout: ((Float | Integer)? timeout, String name) -> Float?
63
-
64
- def normalize_limit: (Integer? limit, String name) -> Integer?
65
-
66
- def normalize_choice: (untyped value, Array[Symbol] choices, String name) -> Symbol
67
58
  end
68
59
  end
@@ -0,0 +1,15 @@
1
+ module Kobako
2
+ module Transport
3
+ module ArgumentWrap
4
+ def self.wrap: (untyped value, Kobako::Codec::_HandleTable handles, ?Integer depth) -> untyped
5
+
6
+ private
7
+
8
+ def self.refuse_past_nesting: (Integer depth) -> void
9
+
10
+ def self.wrap_leaf: (untyped value, Kobako::Codec::_HandleTable handles) -> untyped
11
+
12
+ def self.wrap_hash: (Hash[untyped, untyped] hash, Kobako::Codec::_HandleTable handles, Integer depth) -> Hash[untyped, untyped]
13
+ end
14
+ end
15
+ end
@@ -21,11 +21,11 @@ module Kobako
21
21
 
22
22
  def self.resolve_call_args: (Kobako::Payload::Arguments arguments, Kobako::Codec::_HandleTable handles, bool carried_handle) -> [Array[untyped], Hash[Symbol, untyped]]
23
23
 
24
- def self.caught_fault: (StandardError error, Kobako::Transport::BlockFailure failure) -> [String, String]
24
+ def self.fault_of: (StandardError error, Kobako::Transport::BlockFailure failure) -> [String, String]
25
25
 
26
26
  def self.invoke: (Kobako::Transport::Exposure exposure, String method, Array[untyped] args, Hash[Symbol, untyped] kwargs, Kobako::Transport::Yielder? yielder) -> untyped
27
27
 
28
- def self.reject_unreachable!: (Kobako::Transport::Exposure exposure, Symbol name) -> void
28
+ def self.reject_unreachable: (Kobako::Transport::Exposure exposure, Symbol name) -> void
29
29
 
30
30
  def self.resolve_arg: (untyped value, Kobako::Codec::_HandleTable handles) -> untyped
31
31
 
@@ -7,7 +7,7 @@ module Kobako
7
7
  String message,
8
8
  ?diagnostic: String?,
9
9
  ?origin: String?,
10
- ?klass: String?,
10
+ ?class_name: String?,
11
11
  ?backtrace_lines: Array[String]?
12
12
  ) -> void
13
13