Class: Kobako::Invocation

Inherits:
Object
  • Object
show all
Defined in:
lib/kobako/invocation.rb

Overview

Host-side value object for a single Sandbox#run invocation (docs/wire-codec.md Invocation channels; docs/behavior.md B-31).

An Invocation captures the host-layer concept of “a single #run call”: the entrypoint constant name plus its positional and keyword arguments. Host pre-flight (E-24 / E-25 / E-29 / E-30) is enforced at construction so the Value Object is the single source of truth —anything that passes Invocation.new is safe to encode and ship to the guest.

Invocation sits at top level, not under Kobako::RPC: RPC in SPEC is the guest→host capability channel (Server / Client / Request / Response / Handle); Invocation is the opposite direction (host→guest entrypoint dispatch) and structurally rejects Handles (E-29), so it has no relationship with the HandleTable. The #encode output is the “Invocation envelope” that ships through the __kobako_run command buffer.

Built on the class X < Data.define(…) subclass form (the Steep-friendly shape — see lib/kobako/outcome/panic.rb).

Constant Summary collapse

NAME_PATTERN =

Ruby constant-name pattern enforced on the entrypoint Symbol (docs/behavior.md E-25). Parallel to Kobako::Snippet::Table::NAME_PATTERN; the two constants name the same regex but cover distinct surfaces (snippet identity vs. entrypoint resolution) so a future divergence stays local.

/\A[A-Z]\w*\z/

Instance Method Summary collapse

Constructor Details

#initialize(entrypoint:, args: [], kwargs: {}) ⇒ Invocation

steep:ignore:start



37
38
39
40
41
42
43
# File 'lib/kobako/invocation.rb', line 37

def initialize(entrypoint:, args: [], kwargs: {})
  super(
    entrypoint: normalize_entrypoint(entrypoint),
    args: validate_args!(args),
    kwargs: validate_kwargs!(kwargs)
  )
end

Instance Method Details

#encodeObject

Encode this Invocation to the msgpack bytes the guest’s __kobako_run entry point consumes as its command-buffer payload (docs/wire-codec.md Invocation channels). The Value Object’s own invariants are the contract; this method does not re-check the shape. Layout: msgpack map with string keys “entrypoint” (Symbol via ext 0x00), “args” (Array), “kwargs” (Map with Symbol keys).



53
54
55
56
57
58
59
# File 'lib/kobako/invocation.rb', line 53

def encode
  Codec::Encoder.encode(
    "entrypoint" => entrypoint,
    "args" => args,
    "kwargs" => kwargs
  )
end