diff --git a/bindings/go/README.md b/bindings/go/README.md index 39ee6b6bdf..b3ed63ddd4 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -70,6 +70,7 @@ Import `encoding/json` and The backend is selected at build time: `cgo` with `switchyard_native` uses the native library; other builds use WASM. Both use `New(config)` and the same routing API. +Call `Backend()` to report `"native"` or `"wasm"` without creating a router. Supply the model groups needed by the configured algorithm. Composite needs `any` for eligible answer targets, plus `capable`, `efficient`, and `judge`. diff --git a/bindings/go/backend_native.go b/bindings/go/backend_native.go index 380d62ad9e..c8ad6c4936 100644 --- a/bindings/go/backend_native.go +++ b/bindings/go/backend_native.go @@ -26,6 +26,9 @@ import ( "unsafe" ) +// Backend returns the compiled routing backend: "native" or "wasm". +func Backend() string { return "native" } + type nativeBackend struct { mu sync.RWMutex ptr *C.SyRouter diff --git a/bindings/go/backend_native_test.go b/bindings/go/backend_native_test.go new file mode 100644 index 0000000000..18a7b39576 --- /dev/null +++ b/bindings/go/backend_native_test.go @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +//go:build cgo && switchyard_native + +package switchyard + +import "testing" + +func TestBackend(t *testing.T) { + if got := Backend(); got != "native" { + t.Fatalf("Backend() = %q, want native", got) + } +} diff --git a/bindings/go/backend_wazero.go b/bindings/go/backend_wazero.go index 30ffa6150c..10663254c0 100644 --- a/bindings/go/backend_wazero.go +++ b/bindings/go/backend_wazero.go @@ -18,6 +18,9 @@ import ( "time" ) +// Backend returns the compiled routing backend: "native" or "wasm". +func Backend() string { return "wasm" } + type wasmBackend struct { runtime *wasmRuntime slots []*wasmSlot diff --git a/bindings/go/wasm_test.go b/bindings/go/wasm_test.go index aad517456f..96dec387da 100644 --- a/bindings/go/wasm_test.go +++ b/bindings/go/wasm_test.go @@ -83,6 +83,12 @@ func TestWasmCancellationBeforeOutcome(t *testing.T) { } } +func TestBackend(t *testing.T) { + if got := Backend(); got != "wasm" { + t.Fatalf("Backend() = %q, want wasm", got) + } +} + // Parent and child identities must share the guest that owns their session state. func TestWasmSessionAffinity(t *testing.T) { backend := &wasmBackend{slots: []*wasmSlot{{}, {}}}