Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion baml_language/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions baml_language/crates/baml_version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Stamped BAML language product version.

pub const CANONICAL_VERSION: &str = "0.22.1";
pub const PYPI_VERSION: &str = "0.22.1";
pub const CANONICAL_VERSION: &str = "0.22.2";
pub const PYPI_VERSION: &str = "0.22.2";
pub const CHANNEL: &str = "canary";
#[allow(dead_code)]
const STABLE_VERSION: &str = "0.22.1";
const STABLE_VERSION: &str = "0.22.2";
2 changes: 1 addition & 1 deletion baml_language/release.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[release]
canary_version = "0.22.1"
canary_version = "0.22.2"
1 change: 1 addition & 0 deletions baml_language/sdk_tests/crates/csharp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ prost = { workspace = true }


[dev-dependencies]
baml_version = { workspace = true }
sdk_test_harness_runner = { path = "../../harness_runner" }

[package.metadata.ci]
Expand Down
18 changes: 18 additions & 0 deletions baml_language/sdk_tests/crates/csharp/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ if (-not [System.IO.Path]::IsPathRooted($TargetDir)) {
$TargetDir = [System.IO.Path]::GetFullPath($TargetDir)
$NativeLibrary = Join-Path $TargetDir "debug/bridge_cffi.dll"

# Exercise the release ABI probe in source CI, before publishing any packages.
$AbiProbe = Join-Path $WorkspaceRoot "sdks/csharp/bridge_csharp/tests/Baml.Bridge.AbiLifetimeProbe/Baml.Bridge.AbiLifetimeProbe.csproj"
$AbiBytecode = Join-Path $TargetDir "csharp-abi-probe.bytecode"
Push-Location $WorkspaceRoot
try {
cargo run --quiet -p sdk_test_codegen -- emit-bytecode --fixture function_calls --out $AbiBytecode
if ($LASTEXITCODE -ne 0) {
throw "ABI probe bytecode generation failed with exit code $LASTEXITCODE"
}
dotnet build $AbiProbe --configuration Debug --nologo -p:BamlNativeProbeMode=Direct -p:NuGetAudit=false
if ($LASTEXITCODE -ne 0) {
throw "ABI probe build failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}

# Build every fixture consumer (and the union-generator tool) in ONE
# MSBuild invocation: the projects compile in parallel across cores and the
# shared Baml.Bridge project builds exactly once. The tests then run with
Expand Down Expand Up @@ -58,5 +75,6 @@ try {

if ($env:NEXTEST_ENV) {
Add-Content -Path $env:NEXTEST_ENV -Value "SDK_TEST_CSHARP_SETUP=1"
Add-Content -Path $env:NEXTEST_ENV -Value "BAML_CSHARP_ABI_PROBE_BYTECODE=$AbiBytecode"
Add-Content -Path $env:NEXTEST_ENV -Value "BAML_BRIDGE_PATH=$NativeLibrary"
}
9 changes: 9 additions & 0 deletions baml_language/sdk_tests/crates/csharp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ case "$(uname -s)" in
*) native_library="$target_dir/debug/libbridge_cffi.so" ;;
esac

# Exercise the release ABI probe in source CI, before publishing any packages.
abi_probe="$workspace_root/sdks/csharp/bridge_csharp/tests/Baml.Bridge.AbiLifetimeProbe/Baml.Bridge.AbiLifetimeProbe.csproj"
abi_bytecode="$target_dir/csharp-abi-probe.bytecode"
(cd "$workspace_root" && cargo run --quiet -p sdk_test_codegen -- \
emit-bytecode --fixture function_calls --out "$abi_bytecode")
dotnet build "$abi_probe" --configuration Debug --nologo \
-p:BamlNativeProbeMode=Direct -p:NuGetAudit=false

# Build every fixture consumer (and the union-generator tool) in ONE
# MSBuild invocation: the projects compile in parallel across cores and the
# shared Baml.Bridge project builds exactly once. The tests then run with
Expand All @@ -40,5 +48,6 @@ dotnet build \

if [[ -n "${NEXTEST_ENV:-}" ]]; then
echo "SDK_TEST_CSHARP_SETUP=1" >> "$NEXTEST_ENV"
echo "BAML_CSHARP_ABI_PROBE_BYTECODE=$abi_bytecode" >> "$NEXTEST_ENV"
echo "BAML_BRIDGE_PATH=$native_library" >> "$NEXTEST_ENV"
fi
22 changes: 22 additions & 0 deletions baml_language/sdk_tests/crates/csharp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ mod tests {
);
}

// SDK_PARITY_LINT(skip): exercises the C# release ABI probe before publication
#[test]
fn test_release_abi_lifetimes_match_current_native_library() {
let project = manifest_dir().join("../../../sdks/csharp/bridge_csharp/tests/Baml.Bridge.AbiLifetimeProbe/Baml.Bridge.AbiLifetimeProbe.csproj");
let native = env::var("BAML_BRIDGE_PATH").expect("native library from C# setup");
let bytecode =
env::var("BAML_CSHARP_ABI_PROBE_BYTECODE").expect("ABI fixture from C# setup");
let output = run_project(
&project,
&[
"-p:BamlNativeProbeMode=Direct",
"--",
&native,
baml_version::CANONICAL_VERSION,
&bytecode,
],
);
assert_stdout_contains(&output, "pre_and_inflight_cancellation=ok");
assert_stdout_contains(&output, "media_handle_clone_release=ok");
assert_stdout_contains(&output, "callback_boundary=contained");
}

// SDK_PARITY_LINT(skip): exercises C#-specific native SDK integration coverage
#[test]
fn test_basic_calls_executes_sync_and_async() {
Expand Down
4 changes: 2 additions & 2 deletions baml_language/sdks/cpp/bridge_cpp/include/baml/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace baml {

inline constexpr const char* kBridgeRuntimeName = "BAML C++ bridge";
inline constexpr const char* kToolchainVersion = "0.22.1";
inline constexpr const char* kBridgeRuntimeVersion = "0.22.1";
inline constexpr const char* kToolchainVersion = "0.22.2";
inline constexpr const char* kBridgeRuntimeVersion = "0.22.2";

inline constexpr const char* toolchain_version() { return kToolchainVersion; }
inline constexpr const char* bridge_runtime_version() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<AssemblyName>Baml.Bridge</AssemblyName>
<RootNamespace>Baml</RootNamespace>
<PackageId>baml-bridge</PackageId>
<Version>0.22.1</Version>
<Version>0.22.2</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>BoundaryML</Authors>
<Description>Managed runtime bridge for generated BAML C# clients.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ namespace Baml;
internal static class RuntimeIdentity
{
internal const string RuntimeName = "baml-bridge";
internal const string ToolchainVersion = "0.22.1";
internal const string BridgeRuntimeVersion = "0.22.1";
internal const string ToolchainVersion = "0.22.2";
internal const string BridgeRuntimeVersion = "0.22.2";
internal const string PackageVersion = BridgeRuntimeVersion;
internal const string RequiredBridgeVersion = ToolchainVersion;
internal const int GeneratedContractVersion = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
internal static unsafe partial class Program
{
private const string NativeLibraryName = "bridge_cffi";
private const uint BamlApiV1AbiVersion = 2;
private const uint BamlApiV1AbiVersion = 4;
private const uint BamlBridgeLanguageCSharp = 5;
private const uint BamlBridgeLanguageRust = 4;
private const uint StatusOk = 0;
Expand All @@ -21,7 +21,7 @@ internal static unsafe partial class Program
private const int HandleTypeMediaAudio = 7;

private static readonly nuint RequiredV1PrefixSize = ApiFieldEnd(
nameof(BamlApiV1.RegisterBridge));
nameof(BamlApiV1.MediaFromFileContent));

private static readonly ConcurrentDictionary<
uint,
Expand Down Expand Up @@ -152,8 +152,8 @@ public static int Main(string[] args)
"hello world"),
"hello_world returned an unexpected value");
Require(
api->CancelFunctionCall(helloCallId) == 0,
"completed call ID was not reserved against reuse");
api->CancelFunctionCall(helloCallId) == 1,
"completed call ID was accepted for cancellation");

const string utf8Boundary = "héllo\0雪\u0001";
ulong stringCallId = api->NewFunctionCall();
Expand Down Expand Up @@ -247,18 +247,16 @@ private static void VerifyCancellation(BamlApiV1* api)
"pre-registration cancellation was rejected");
byte[] preCancelled = CallFunction(
api,
"slow_cancel_probe",
EncodeCallArguments(preCancelledId, null, null));
RequireNonSuccess(
preCancelled,
"pre-cancelled call returned success");
"throws_test.SleepMs",
EncodeSleepArguments(preCancelledId));
RequireCancellation(preCancelled);

ulong inFlightId = api->NewFunctionCall();
Require(inFlightId != 0, "in-flight call ID allocation failed");
Task<byte[]> inFlight = DispatchFunction(
api,
"slow_cancel_probe",
EncodeCallArguments(inFlightId, null, null));
"throws_test.SleepMs",
EncodeSleepArguments(inFlightId));
Thread.Sleep(TimeSpan.FromMilliseconds(100));
var started = System.Diagnostics.Stopwatch.StartNew();
Require(
Expand All @@ -269,9 +267,7 @@ private static void VerifyCancellation(BamlApiV1* api)
.GetAwaiter()
.GetResult();
started.Stop();
RequireNonSuccess(
cancelled,
"in-flight cancelled call returned success");
RequireCancellation(cancelled);
Require(
started.Elapsed < TimeSpan.FromSeconds(2),
$"in-flight cancellation completed too slowly: {started.Elapsed}");
Expand Down Expand Up @@ -324,8 +320,8 @@ private static void VerifyCallIdentifiers(BamlApiV1* api)
api->CancelFunctionCall(0) == 1,
"zero call ID was accepted for cancellation");
Require(
api->CancelFunctionCall(ulong.MaxValue) == 0,
"nonzero pre-registration cancellation was rejected");
api->CancelFunctionCall(ulong.MaxValue) == 1,
"unknown call ID was accepted for cancellation");

var identifiers = new HashSet<ulong>();
for (int index = 0; index < 1_024; index++)
Expand All @@ -335,6 +331,12 @@ private static void VerifyCallIdentifiers(BamlApiV1* api)
Require(
identifiers.Add(identifier),
$"new_function_call repeated {identifier}");
Require(
api->ReleaseFunctionCall(identifier) == 0,
"unused call allocation was not released");
Require(
api->ReleaseFunctionCall(identifier) == 1,
"released call allocation was accepted twice");
}
}

Expand Down Expand Up @@ -377,6 +379,19 @@ private static Task<byte[]> DispatchFunction(
return completion.Task;
}

private static byte[] EncodeSleepArguments(ulong callId)
{
var value = new List<byte>();
WriteTag(value, 3, 0);
WriteVarint(value, 10_000); // InboundValue.int_value: milliseconds.
var argument = new List<byte>();
WriteLengthDelimited(argument, 1, Encoding.UTF8.GetBytes("ms"));
WriteLengthDelimited(argument, 6, value);
var call = new List<byte>(EncodeCallArguments(callId, null, null));
WriteLengthDelimited(call, 1, argument);
return [.. call];
}

private static byte[] EncodeCallArguments(
ulong callId,
string? argumentName,
Expand Down Expand Up @@ -405,6 +420,8 @@ private static byte[] EncodeCallArguments(

WriteTag(output, 2, 0);
WriteVarint(output, callId);
// An explicit default InvocationOptions is required; omission is a legacy call.
WriteLengthDelimited(output, 6, []);
return [.. output];
}

Expand Down Expand Up @@ -443,6 +460,17 @@ private static string DecodeSuccessfulString(byte[] encodedResult)
$"successful result is not a string or string literal: {Convert.ToHexString(encodedResult)}");
}

private static void RequireCancellation(byte[] encodedResult)
{
Require(
TryGetLengthDelimited(encodedResult, 3, out var error)
&& TryGetLengthDelimited(error, 1, out var value)
&& TryGetLengthDelimited(value, 7, out var errorClass)
&& TryGetLengthDelimited(errorClass, 1, out var name)
&& DecodeUtf8(name, "error class") == "baml.panics.Cancelled",
$"expected cancellation, received {Convert.ToHexString(encodedResult)}");
}

private static void RequireNonSuccess(
byte[] encodedResult,
string message)
Expand Down Expand Up @@ -888,6 +916,12 @@ private static void ValidateRequiredFunctions(BamlApiV1* api)
api->MediaMimeType is not null,
"media_mime_type is null");
Require(api->RegisterBridge is not null, "register_bridge is null");
Require(api->ReleaseFunctionCall is not null, "release_function_call is null");
Require(api->InvocationClockNs is not null, "invocation_clock_ns is null");
Require(api->InvocationProtocolVersion is not null, "invocation_protocol_version is null");
Require(api->InvocationProtocolVersion() == 1, "unexpected invocation protocol");
Require(api->MediaName is not null, "media_name is null");
Require(api->MediaFromFileContent is not null, "media_from_file_content is null");
}

private static nuint ApiFieldEnd(string field) =>
Expand Down Expand Up @@ -1108,6 +1142,18 @@ public readonly delegate* unmanaged[Cdecl]<
public readonly delegate* unmanaged[Cdecl]<
BamlBridgeInfoV1*,
BamlBuffer> RegisterBridge;
public readonly delegate* unmanaged[Cdecl]<delegate* unmanaged[Cdecl]<sbyte*, nuint, int, void>, void> RegisterUnhandledSpawnErrorCallback;
public readonly delegate* unmanaged[Cdecl]<BamlBuffer> ShutdownRuntime;
public readonly delegate* unmanaged[Cdecl]<byte*, nuint, byte*, BamlBuffer> InitializeRuntimeFromBlobWithMetadata;
public readonly delegate* unmanaged[Cdecl]<uint> InvocationProtocolVersion;
public readonly delegate* unmanaged[Cdecl]<ulong, ulong*, uint> InvocationClockNs;
public readonly delegate* unmanaged[Cdecl]<ulong, int> ReleaseFunctionCall;
public readonly delegate* unmanaged[Cdecl]<delegate* unmanaged[Cdecl]<byte*, nuint, void>, void> RegisterHostDispatchV2;
public readonly delegate* unmanaged[Cdecl]<delegate* unmanaged[Cdecl]<uint, void>, void> RegisterHostCancelCallback;
public readonly delegate* unmanaged[Cdecl]<ulong, ulong, BamlBuffer*, ulong*, uint> TraceSelection;
public readonly delegate* unmanaged[Cdecl]<ulong, BamlBuffer*, uint> InvocationContext;
public readonly delegate* unmanaged[Cdecl]<ulong, int, BamlBuffer*, uint> MediaName;
public readonly delegate* unmanaged[Cdecl]<int, byte*, byte*, byte*, ulong*, int*, uint> MediaFromFileContent;
}

private static partial class NativeMethods
Expand Down
4 changes: 2 additions & 2 deletions baml_language/sdks/go/baml_go/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package baml_go
// ToolchainVersion is the canonical BAML toolchain whose generated bytecode
// this module accepts. BridgeRuntimeVersion preserves Go's published v prefix.
const BridgeRuntimeName = "github.com/boundaryml/baml-go"
const ToolchainVersion = "0.22.1"
const BridgeRuntimeVersion = "v0.22.1"
const ToolchainVersion = "0.22.2"
const BridgeRuntimeVersion = "v0.22.2"
const DefaultRuntimeVersion = ToolchainVersion

func requiredRuntimeVersion() string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package baml_bridge;

final class BamlVersion {
static final String TOOLCHAIN_VERSION = "0.22.1";
static final String BRIDGE_RUNTIME_VERSION = "0.22.1";
static final String TOOLCHAIN_VERSION = "0.22.2";
static final String BRIDGE_RUNTIME_VERSION = "0.22.2";

private BamlVersion() {}
}
2 changes: 1 addition & 1 deletion baml_language/sdks/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "baml_bridge"
version = "0.22.1"
version = "0.22.2"
description = "BAML python bindings (new system, bex_engine)"
authors = [{ "name" = "Boundary", "email" = "[email protected]" }]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion baml_language/sdks/python/src/baml_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _handle_unhandled_spawn_error(error_bytes: bytes, cancelled: bool) -> None:

register_unhandled_spawn_error_callback(_handle_unhandled_spawn_error)

__version__ = "0.22.1"
__version__ = "0.22.2"


# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion baml_language/sdks/python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Baml
module Bridge
TOOLCHAIN_VERSION = "0.22.1"
BRIDGE_RUNTIME_VERSION = "0.22.1"
TOOLCHAIN_VERSION = "0.22.2"
BRIDGE_RUNTIME_VERSION = "0.22.2"
VERSION = TOOLCHAIN_VERSION
end
end
2 changes: 1 addition & 1 deletion baml_language/sdks/rust/bridge_rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rust-version.workspace = true
# crates.io, so its version must be the canonical BAML language version.
# `scripts/baml-language-version` keeps this equal to the canary version and
# stamps it to the release version at packaging time (`check` guards it).
version = "0.22.1"
version = "0.22.2"
authors.workspace = true
license.workspace = true
homepage.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions baml_language/sdks/rust/bridge_rust/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
//! development builds too.

pub(crate) const BRIDGE_RUNTIME_NAME: &str = "baml_bridge";
pub(crate) const TOOLCHAIN_VERSION: &str = "0.22.1";
pub(crate) const BRIDGE_RUNTIME_VERSION: &str = "0.22.1";
pub(crate) const TOOLCHAIN_VERSION: &str = "0.22.2";
pub(crate) const BRIDGE_RUNTIME_VERSION: &str = "0.22.2";
Loading
Loading