chain-client-sdk-ts/proto/chain/v1/module.proto
Dr. Stefan Flemming b6c6cc8295 feat: TypeScript client for Node, with a scriptable fake hub
A service in front of a hub needs four things: start a flow, follow
it, read what a detached run produced, and decide approvals. This is
that surface, plus the part a gateway cannot test without: a fake hub
that speaks the same service from the same .proto files and can be
scripted into every failure a real hub produces.

Errors carry the hub's own class (chain-error-kind), a coarse family,
and reachedHub, which separates a refused connection from a hub that
reports a dependency as down. Both arrive as gRPC UNAVAILABLE, and a
gateway that shows 'service not reachable' for the second one lies to
its users.

The .proto files are carried verbatim and loaded at runtime, so no
generated code can drift from the contract; two guards hold the
copies in place, and a skew suite runs the same client against a real
hub binary.

32 hermetic tests plus 4 against a real hub.

Signed-off-by: Dr. Stefan Flemming <sf@flemming.it>
2026-10-27 00:59:57 +01:00

45 lines
1.1 KiB
Protocol Buffer

syntax = "proto3";
package chain.v1;
import "google/protobuf/empty.proto";
import "chain/v1/common.proto";
// The Module service is what the hub calls to invoke a module.
//
// In Phase 0, modules run in-process as WASM components and this
// service is not over the wire. The proto definition exists so that
// external module processes (OCI, remote) can implement the same
// contract in Phase 1+.
service Module {
// Invoke the module once with typed inputs, receive typed outputs.
rpc Invoke(InvokeRequest) returns (InvokeResponse);
// Return the module's self-description.
rpc Describe(google.protobuf.Empty) returns (ModuleDescriptor);
}
message InvokeRequest {
InvocationId invocation_id = 1;
CapabilityRef capability = 2;
map<string, Payload> inputs = 3;
uint64 deadline_ms = 4;
}
message InvokeResponse {
oneof result {
Success success = 1;
ChainError error = 2;
}
}
message Success {
map<string, Payload> outputs = 1;
}
message ModuleDescriptor {
string name = 1;
string version = 2;
repeated CapabilityRef provides = 3;
repeated string permissions = 4;
}