kobako 0.19.0-aarch64-linux → 0.21.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +127 -0
- data/README.md +96 -44
- data/ROADMAP.md +1 -1
- data/crates/kobako-runtime/CHANGELOG.md +44 -0
- data/crates/kobako-runtime/README.md +1 -1
- data/crates/kobako-transport/CHANGELOG.md +31 -0
- data/crates/kobako-transport/README.md +43 -0
- data/crates/kobako-wasmtime/CHANGELOG.md +30 -0
- data/crates/kobako-wasmtime/README.md +1 -1
- 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 +50 -43
- data/lib/kobako/catalog/handles.rb +7 -16
- data/lib/kobako/catalog/services.rb +24 -46
- data/lib/kobako/catalog/snippets.rb +16 -33
- data/lib/kobako/codec/decoder.rb +10 -13
- data/lib/kobako/codec/encoder.rb +7 -7
- data/lib/kobako/codec/error.rb +6 -6
- data/lib/kobako/codec/ext_types.rb +12 -72
- data/lib/kobako/codec/handle_walk.rb +6 -6
- data/lib/kobako/codec/state.rb +4 -56
- data/lib/kobako/codec/utils.rb +4 -4
- data/lib/kobako/codec.rb +11 -21
- data/lib/kobako/context.rb +208 -0
- data/lib/kobako/errors.rb +59 -16
- data/lib/kobako/execution.rb +52 -0
- data/lib/kobako/extension.rb +24 -10
- data/lib/kobako/outcome.rb +71 -128
- data/lib/kobako/payload/arguments.rb +59 -0
- data/lib/kobako/payload.rb +19 -0
- data/lib/kobako/pool.rb +1 -7
- data/lib/kobako/sandbox.rb +51 -191
- data/lib/kobako/sandbox_options.rb +24 -3
- data/lib/kobako/snippet/binary.rb +3 -4
- data/lib/kobako/snippet/source.rb +5 -6
- data/lib/kobako/snippet.rb +2 -2
- data/lib/kobako/transport/call.rb +21 -0
- data/lib/kobako/transport/dispatcher.rb +94 -142
- data/lib/kobako/transport/error.rb +21 -5
- data/lib/kobako/transport/reflection.rb +82 -0
- data/lib/kobako/transport/run.rb +25 -33
- data/lib/kobako/transport/yielder.rb +27 -36
- data/lib/kobako/transport.rb +11 -8
- data/lib/kobako/unresolved.rb +17 -0
- data/lib/kobako/usage.rb +7 -7
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +1 -0
- data/release-please-config.json +47 -2
- data/sig/kobako/catalog/extensions.rbs +4 -6
- data/sig/kobako/catalog/handles.rbs +0 -2
- data/sig/kobako/catalog/services.rbs +4 -4
- data/sig/kobako/catalog/snippets.rbs +4 -2
- data/sig/kobako/codec/error.rbs +4 -4
- data/sig/kobako/codec/ext_types.rbs +0 -7
- data/sig/kobako/codec/state.rbs +0 -4
- data/sig/kobako/codec.rbs +4 -5
- data/sig/kobako/context.rbs +36 -0
- data/sig/kobako/errors.rbs +27 -6
- data/sig/kobako/execution.rbs +24 -0
- data/sig/kobako/extension.rbs +4 -2
- data/sig/kobako/outcome.rbs +12 -13
- data/sig/kobako/payload/arguments.rbs +26 -0
- data/sig/kobako/payload.rbs +4 -0
- data/sig/kobako/pool.rbs +0 -2
- data/sig/kobako/runtime.rbs +44 -14
- data/sig/kobako/sandbox.rbs +5 -24
- data/sig/kobako/sandbox_options.rbs +9 -2
- data/sig/kobako/snippet/binary.rbs +1 -1
- data/sig/kobako/snippet/source.rbs +1 -1
- data/sig/kobako/transport/call.rbs +21 -0
- data/sig/kobako/transport/dispatcher.rbs +9 -11
- data/sig/kobako/transport/error.rbs +11 -0
- data/sig/kobako/transport/reflection.rbs +15 -0
- data/sig/kobako/transport/run.rbs +1 -1
- data/sig/kobako/transport/yielder.rbs +2 -2
- data/sig/kobako/transport.rbs +8 -2
- data/sig/kobako/unresolved.rbs +4 -0
- metadata +18 -12
- data/lib/kobako/fault.rb +0 -38
- data/lib/kobako/outcome/panic.rb +0 -42
- data/lib/kobako/transport/request.rb +0 -76
- data/lib/kobako/transport/response.rb +0 -83
- data/lib/kobako/transport/yield.rb +0 -94
- data/sig/kobako/fault.rbs +0 -19
- data/sig/kobako/outcome/panic.rbs +0 -34
- data/sig/kobako/transport/request.rbs +0 -29
- data/sig/kobako/transport/response.rbs +0 -33
- data/sig/kobako/transport/yield.rbs +0 -34
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "../codec"
|
|
4
|
-
require_relative "../fault"
|
|
5
|
-
|
|
6
|
-
module Kobako
|
|
7
|
-
# See lib/kobako/transport.rb for the umbrella module doc; this file
|
|
8
|
-
# owns the Response value object and its +#encode+ / +.decode+ codec,
|
|
9
|
-
# plus the +STATUS_OK+ / +STATUS_ERROR+ status bytes.
|
|
10
|
-
module Transport
|
|
11
|
-
# ---------------- Response status bytes (docs/wire-contract.md § Response Shape) ---
|
|
12
|
-
|
|
13
|
-
# Response variant marker for the success branch.
|
|
14
|
-
STATUS_OK = 0
|
|
15
|
-
# Response variant marker for the fault branch.
|
|
16
|
-
STATUS_ERROR = 1
|
|
17
|
-
|
|
18
|
-
# Value object for a single host-side Transport Response
|
|
19
|
-
# ({docs/wire-codec.md Envelope Encoding → Response}[link:../../../docs/wire-codec.md]).
|
|
20
|
-
#
|
|
21
|
-
# 2-element msgpack array: +[status, value-or-fault]+. +status+ is 0
|
|
22
|
-
# (success) or 1 (fault). For success the second element is the return
|
|
23
|
-
# value; for fault it is a Fault (ext 0x02 envelope).
|
|
24
|
-
#
|
|
25
|
-
# Built on the +class X < Data.define(...)+ subclass form so the
|
|
26
|
-
# class body is fully Steep-visible; see +lib/kobako/outcome/panic.rb+
|
|
27
|
-
# for the rationale.
|
|
28
|
-
class Response < Data.define(:status, :payload)
|
|
29
|
-
def self.ok(value)
|
|
30
|
-
new(status: STATUS_OK, payload: value)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.error(fault)
|
|
34
|
-
unless fault.is_a?(Kobako::Fault)
|
|
35
|
-
raise ArgumentError, "Response.error requires Kobako::Fault, got #{fault.class}"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
new(status: STATUS_ERROR, payload: fault)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def initialize(status:, payload:)
|
|
42
|
-
unless [STATUS_OK, STATUS_ERROR].include?(status)
|
|
43
|
-
raise ArgumentError, "Response status must be 0 (ok) or 1 (error), got #{status.inspect}"
|
|
44
|
-
end
|
|
45
|
-
if status == STATUS_ERROR && !payload.is_a?(Kobako::Fault)
|
|
46
|
-
raise ArgumentError, "Response with error status must carry a Kobako::Fault payload"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
super
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def ok? = status == STATUS_OK
|
|
53
|
-
def error? = status == STATUS_ERROR
|
|
54
|
-
|
|
55
|
-
# Encode this Response to msgpack bytes as the 2-element
|
|
56
|
-
# +[status, payload]+ array. The ok variant's value is a payload
|
|
57
|
-
# position, so a +Kobako::Fault+ inside it has no wire
|
|
58
|
-
# representation and surfaces as +UnsupportedType+ — the
|
|
59
|
-
# Dispatcher's auto-wrap rescue turns it into a Capability Handle.
|
|
60
|
-
# The error variant carries the Fault envelope in its one legal
|
|
61
|
-
# position and encodes it plainly.
|
|
62
|
-
def encode
|
|
63
|
-
return Codec::Encoder.encode([status, payload]) if error?
|
|
64
|
-
|
|
65
|
-
Codec.forbid_faults { Codec::Encoder.encode([status, payload]) }
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Decode +bytes+ into a Response. Raises +Codec::InvalidType+ when the
|
|
69
|
-
# envelope is not the expected 2-element msgpack array, or when the
|
|
70
|
-
# Value Object's construction invariants reject the decoded fields.
|
|
71
|
-
def self.decode(bytes)
|
|
72
|
-
Codec::Decoder.decode(bytes) do |arr|
|
|
73
|
-
unless arr.is_a?(Array) && arr.length == 2
|
|
74
|
-
raise Codec::InvalidType, "Response envelope is malformed (expected a 2-element array)"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
status, payload = arr
|
|
78
|
-
new(status: status, payload: payload)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "../codec"
|
|
4
|
-
|
|
5
|
-
module Kobako
|
|
6
|
-
# See lib/kobako/transport.rb for the umbrella module doc; this file
|
|
7
|
-
# owns the +Yield+ envelope value object plus its +#encode+ / +.decode+
|
|
8
|
-
# codec for the +__kobako_yield_to_block+ wire form.
|
|
9
|
-
module Transport
|
|
10
|
-
# First byte of the YieldResponse for the success branch — body is
|
|
11
|
-
# the block's return value encoded as a single msgpack value.
|
|
12
|
-
TAG_OK = 0x01
|
|
13
|
-
# First byte for +break val+ — body is the break value.
|
|
14
|
-
TAG_BREAK = 0x02
|
|
15
|
-
# Reserved for future +return val+ support; both sides reject this
|
|
16
|
-
# tag as a wire violation (YieldResponse envelope contract).
|
|
17
|
-
TAG_RESERVED = 0x03
|
|
18
|
-
# First byte for an error / fault outcome — body is a
|
|
19
|
-
# +{"class", "message", "backtrace"}+ Hash.
|
|
20
|
-
TAG_ERROR = 0x04
|
|
21
|
-
|
|
22
|
-
# Tags both sides currently accept on the wire.
|
|
23
|
-
LIVE_TAGS = [TAG_OK, TAG_BREAK, TAG_ERROR].freeze
|
|
24
|
-
|
|
25
|
-
# Value object for a single YieldResponse envelope
|
|
26
|
-
# ({docs/wire-codec.md YieldResponse Envelope}[link:../../../docs/wire-codec.md]).
|
|
27
|
-
#
|
|
28
|
-
# The wire form is a one-byte tag followed by an msgpack payload.
|
|
29
|
-
# The three live tags are +0x01+ (ok), +0x02+ (break), and +0x04+
|
|
30
|
-
# (error); +0x03+ is reserved and rejected by both sides.
|
|
31
|
-
#
|
|
32
|
-
# +value+ carries whatever the wire payload decoded to — a plain
|
|
33
|
-
# Ruby value for the +ok+ / +break+ tags, and a +{"class",
|
|
34
|
-
# "message", "backtrace"}+ Hash for the +error+ tag. No further
|
|
35
|
-
# shape constraint is enforced here; the host-side dispatcher
|
|
36
|
-
# decides how to translate each variant into Ruby control flow.
|
|
37
|
-
#
|
|
38
|
-
# Lives alongside the other envelope value objects (+Request+,
|
|
39
|
-
# +Response+) since it is the guest-to-host shape used
|
|
40
|
-
# mid-dispatch-frame to answer a +__kobako_yield_to_block+ re-entry.
|
|
41
|
-
class Yield < Data.define(:tag, :value)
|
|
42
|
-
def initialize(tag:, value:)
|
|
43
|
-
unless Kobako::Transport::LIVE_TAGS.include?(tag)
|
|
44
|
-
raise ArgumentError,
|
|
45
|
-
"Yield tag must be one of #{Kobako::Transport::LIVE_TAGS.inspect}, got #{tag.inspect}"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
super
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def ok? = tag == Kobako::Transport::TAG_OK
|
|
52
|
-
def break? = tag == Kobako::Transport::TAG_BREAK
|
|
53
|
-
def error? = tag == Kobako::Transport::TAG_ERROR
|
|
54
|
-
|
|
55
|
-
# Encode this Yield to YieldResponse bytes: one tag byte followed
|
|
56
|
-
# by an msgpack-encoded +value+.
|
|
57
|
-
def encode
|
|
58
|
-
[tag].pack("C") + Codec::Encoder.encode(value)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Decode +bytes+ into a Yield. Rejects empty input, the reserved
|
|
62
|
-
# tag 0x03, and any tag outside +LIVE_TAGS+ by raising
|
|
63
|
-
# +Kobako::Codec::InvalidType+ — these are wire violations per the
|
|
64
|
-
# SPEC's YieldResponse envelope contract.
|
|
65
|
-
def self.decode(bytes)
|
|
66
|
-
bytes = bytes.b
|
|
67
|
-
raise Codec::InvalidType, "YieldResponse must carry at least one byte" if bytes.empty?
|
|
68
|
-
|
|
69
|
-
tag = bytes.getbyte(0) # : Integer
|
|
70
|
-
body = bytes.byteslice(1, bytes.bytesize - 1) # : String
|
|
71
|
-
|
|
72
|
-
reject_dead_tag!(tag)
|
|
73
|
-
# A YieldResponse is a payload position: an ext 0x02 Fault in its
|
|
74
|
-
# value is a wire violation (the Response fault field is the
|
|
75
|
-
# envelope's only home).
|
|
76
|
-
new(tag: tag, value: Codec.forbid_faults { Codec::Decoder.decode(body) })
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def self.reject_dead_tag!(tag)
|
|
80
|
-
return if LIVE_TAGS.include?(tag)
|
|
81
|
-
|
|
82
|
-
msg = if tag == TAG_RESERVED
|
|
83
|
-
"YieldResponse tag 0x03 is reserved"
|
|
84
|
-
else
|
|
85
|
-
format(
|
|
86
|
-
"YieldResponse tag 0x%02x is not recognised", tag
|
|
87
|
-
)
|
|
88
|
-
end
|
|
89
|
-
raise Codec::InvalidType, msg
|
|
90
|
-
end
|
|
91
|
-
private_class_method :reject_dead_tag!
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
data/sig/kobako/fault.rbs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
class Fault < Data
|
|
3
|
-
VALID_TYPES: Array[String]
|
|
4
|
-
|
|
5
|
-
attr_reader type: String
|
|
6
|
-
attr_reader message: String
|
|
7
|
-
attr_reader details: untyped
|
|
8
|
-
|
|
9
|
-
def self.new: (type: String, message: String, ?details: untyped) -> Fault
|
|
10
|
-
|
|
11
|
-
def initialize: (type: String, message: String, ?details: untyped) -> void
|
|
12
|
-
|
|
13
|
-
def with: (?type: String, ?message: String, ?details: untyped) -> Fault
|
|
14
|
-
|
|
15
|
-
def ==: (untyped other) -> bool
|
|
16
|
-
|
|
17
|
-
def hash: () -> Integer
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
module Outcome
|
|
3
|
-
class Panic
|
|
4
|
-
ORIGIN_SANDBOX: String
|
|
5
|
-
ORIGIN_SERVICE: String
|
|
6
|
-
|
|
7
|
-
attr_reader origin: String
|
|
8
|
-
attr_reader klass: String
|
|
9
|
-
attr_reader message: String
|
|
10
|
-
attr_reader backtrace: Array[String]
|
|
11
|
-
attr_reader details: untyped
|
|
12
|
-
|
|
13
|
-
def initialize: (
|
|
14
|
-
origin: String,
|
|
15
|
-
klass: String,
|
|
16
|
-
message: String,
|
|
17
|
-
?backtrace: Array[String],
|
|
18
|
-
?details: untyped
|
|
19
|
-
) -> void
|
|
20
|
-
|
|
21
|
-
def with: (
|
|
22
|
-
?origin: String,
|
|
23
|
-
?klass: String,
|
|
24
|
-
?message: String,
|
|
25
|
-
?backtrace: Array[String],
|
|
26
|
-
?details: untyped
|
|
27
|
-
) -> Panic
|
|
28
|
-
|
|
29
|
-
def ==: (untyped other) -> bool
|
|
30
|
-
|
|
31
|
-
def hash: () -> Integer
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
module Transport
|
|
3
|
-
class Request < Data
|
|
4
|
-
attr_reader target: String | Kobako::Handle
|
|
5
|
-
attr_reader method_name: String
|
|
6
|
-
attr_reader args: Array[Kobako::Codec::wire_value]
|
|
7
|
-
attr_reader kwargs: Hash[Symbol, Kobako::Codec::wire_value]
|
|
8
|
-
attr_reader block_given: bool
|
|
9
|
-
|
|
10
|
-
def self.new: (target: String | Kobako::Handle, method_name: String, ?args: Array[Kobako::Codec::wire_value], ?kwargs: Hash[Symbol, Kobako::Codec::wire_value], ?block_given: bool) -> Request
|
|
11
|
-
|
|
12
|
-
def self.decode: (String bytes) -> Request
|
|
13
|
-
|
|
14
|
-
def initialize: (target: String | Kobako::Handle, method_name: String, ?args: Array[Kobako::Codec::wire_value], ?kwargs: Hash[Symbol, Kobako::Codec::wire_value], ?block_given: bool) -> void
|
|
15
|
-
|
|
16
|
-
def encode: () -> String
|
|
17
|
-
|
|
18
|
-
def with: (?target: String | Kobako::Handle, ?method_name: String, ?args: Array[Kobako::Codec::wire_value], ?kwargs: Hash[Symbol, Kobako::Codec::wire_value], ?block_given: bool) -> Request
|
|
19
|
-
|
|
20
|
-
def ==: (untyped other) -> bool
|
|
21
|
-
|
|
22
|
-
def hash: () -> Integer
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def validate_kwargs!: (Hash[untyped, untyped] kwargs) -> void
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
module Transport
|
|
3
|
-
STATUS_OK: Integer
|
|
4
|
-
STATUS_ERROR: Integer
|
|
5
|
-
|
|
6
|
-
class Response < Data
|
|
7
|
-
attr_reader status: Integer
|
|
8
|
-
attr_reader payload: Kobako::Codec::wire_value | Kobako::Fault
|
|
9
|
-
|
|
10
|
-
def self.ok: (untyped value) -> Response
|
|
11
|
-
|
|
12
|
-
def self.error: (Kobako::Fault fault) -> Response
|
|
13
|
-
|
|
14
|
-
def self.decode: (String bytes) -> Response
|
|
15
|
-
|
|
16
|
-
def self.new: (status: Integer, payload: untyped) -> Response
|
|
17
|
-
|
|
18
|
-
def initialize: (status: Integer, payload: untyped) -> void
|
|
19
|
-
|
|
20
|
-
def with: (?status: Integer, ?payload: untyped) -> Response
|
|
21
|
-
|
|
22
|
-
def ok?: () -> bool
|
|
23
|
-
|
|
24
|
-
def error?: () -> bool
|
|
25
|
-
|
|
26
|
-
def encode: () -> String
|
|
27
|
-
|
|
28
|
-
def ==: (untyped other) -> bool
|
|
29
|
-
|
|
30
|
-
def hash: () -> Integer
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Kobako
|
|
2
|
-
module Transport
|
|
3
|
-
TAG_OK: Integer
|
|
4
|
-
TAG_BREAK: Integer
|
|
5
|
-
TAG_RESERVED: Integer
|
|
6
|
-
TAG_ERROR: Integer
|
|
7
|
-
LIVE_TAGS: Array[Integer]
|
|
8
|
-
|
|
9
|
-
class Yield
|
|
10
|
-
attr_reader tag: Integer
|
|
11
|
-
attr_reader value: Kobako::Codec::wire_value | Kobako::Fault
|
|
12
|
-
|
|
13
|
-
def self.decode: (String bytes) -> Yield
|
|
14
|
-
|
|
15
|
-
def self.reject_dead_tag!: (Integer tag) -> void
|
|
16
|
-
|
|
17
|
-
def initialize: (tag: Integer, value: untyped) -> void
|
|
18
|
-
|
|
19
|
-
def with: (?tag: Integer, ?value: untyped) -> Yield
|
|
20
|
-
|
|
21
|
-
def ok?: () -> bool
|
|
22
|
-
|
|
23
|
-
def break?: () -> bool
|
|
24
|
-
|
|
25
|
-
def error?: () -> bool
|
|
26
|
-
|
|
27
|
-
def encode: () -> String
|
|
28
|
-
|
|
29
|
-
def ==: (untyped other) -> bool
|
|
30
|
-
|
|
31
|
-
def hash: () -> Integer
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|