Skip to content

Commit e45d36e

Browse files
Ungate procedures from the unstable feature (#5164)
# Description of Changes Graduate **procedures** (and the outgoing HTTP client used from procedures) out of the `unstable` feature gate / `SPACETIMEDB_UNSTABLE_FEATURES` across all module libraries. The `procedure` macro, `ProcedureContext`, `with_tx`/`try_with_tx`, scheduled procedures, and `ctx.http` are now available without opting into `unstable`. **Still gated** (unchanged): HTTP handlers/webhooks, views, RLS / `client_visibility_filter`, and immediate-scheduling (`volatile_nonatomic_schedule_immediate`). Per library: - **`bindings-sys`**: ungate the `procedure` host-call module + raw ABI imports (`procedure_start/commit/abort_mut_tx`, `procedure_http_request`) and `call_no_ret`. Scheduling ABI stays gated. - **`bindings` (Rust)**: ungate the `procedure` macro, `ProcedureContext`, `TxContext`/`with_tx`/`try_with_tx`, `db_read_only`/`get_read_only`, the procedure traits, `register_procedure`, `__call_procedure__`, and procedure RNG. The `http` module (previously gated as a unit) now has fine-grained gating so the outgoing `HttpClient` is exposed while `HandlerContext`/`Router`/handler macros stay gated. - **`bindings-csharp`**: drop `[Experimental("STDB_UNSTABLE")]` from `ProcedureContext.WithTx/TryWithTx` (runtime + codegen) and the generated `ProcedureTxContext`; FFI snapshots regenerated. Handler context members + RLS attribute stay gated. - **`bindings-cpp`**: ungate the procedure ABI (`abi.h`/`FFI.h`), `tx_execution.h`, the outgoing HTTP client (`http.h`/`http_convert.h`), and `procedure_context.h`. `handler_context.h`/`router.h`/`http_handler_macros.h` still `#error` without `SPACETIMEDB_UNSTABLE_FEATURES`. - **docs**: remove the procedures beta notices (HTTP handlers stay marked beta for a later release); regenerate `static/llms.md`. - **`sdk-test-procedure`**: no longer needs `features = ["unstable"]`. # API and ABI breaking changes Not breaking. This is purely additive to the stable surface: procedures become available **without** the `unstable` feature, while modules that already opt into `unstable` are unaffected. The wasm host-ABI imports were already implemented host-side and merely gated module-side, so there is no ABI version change. (No breaking-change label needed.) # Expected complexity level and risk **3/5.** The diff itself is mostly removing `#[cfg]`/`#ifdef`/`[Experimental]` guards, but the gate bundled procedures + outgoing HTTP + handlers + the ABI crate together, so the work was in *separating* procedures from the features that stay gated. Areas reviewers may want to scrutinize: - The Rust `http` module went from "gated as a whole" to fine-grained per-item gating; the outgoing `HttpClient` is exposed while handler types/macros stay behind `unstable`. - The `unstable` cut reaches the ABI crate (`bindings-sys`), which is the only way procedures can compile without the feature. - C++ separation of the outgoing HTTP client from HTTP handlers across several headers. # Testing - [x] Rust: `cargo check -p spacetimedb` passes in default, `--features unstable`, and `--no-default-features --features unstable`. - [x] Rust end-to-end: `sdk-test-procedure` (uses procedures, `with_tx`/`try_with_tx`, `ctx.http.get`, `new_uuid_v7`, scheduled procedures) builds **without** `unstable`. - [x] C#: Codegen + Runtime build; `Codegen.Tests` pass (6/6) after FFI snapshot regen. - [x] C++: host syntax-check confirms procedures + `ctx.http.send()` compile **without** the flag, full headers compile **with** it, and `handler_context.h` still `#error`s without it. (Not built for the real wasm/emscripten target locally — relying on CI.) - [x] `cargo ci lint` components reproduced locally: rustfmt, clippy (`-D warnings`, default + `unstable`), csharpier, and `cargo doc --deny warnings`. - [ ] Reviewer: confirm the wasm bindings + C#/C++ test suites pass in CI (especially the C++ wasm build, which couldn't run locally).
1 parent cb92b6f commit e45d36e

24 files changed

Lines changed: 74 additions & 138 deletions

File tree

crates/bindings-cpp/include/spacetimedb/abi/FFI.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ using ::identity;
7575
using ::get_jwt;
7676

7777
// ===== Procedure Transactions =====
78-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
7978
using ::procedure_start_mut_tx;
8079
using ::procedure_commit_mut_tx;
8180
using ::procedure_abort_mut_tx;
82-
#endif
8381

8482
// ===== Module Export Helpers =====
8583

crates/bindings-cpp/include/spacetimedb/abi/abi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ STDB_IMPORT_10_2(get_jwt)
174174
Status get_jwt(const uint8_t* connection_id_ptr, BytesSource* out);
175175

176176
// ===== Procedure Transactions (spacetime_10.3) =====
177-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
178177
STDB_IMPORT_10_3(procedure_start_mut_tx)
179178
Status procedure_start_mut_tx(int64_t* out);
180179

@@ -190,7 +189,6 @@ Status procedure_http_request(
190189
const uint8_t* request_ptr, size_t request_len,
191190
const uint8_t* body_ptr, size_t body_len,
192191
BytesSource out[2]);
193-
#endif
194192

195193
} // extern "C"
196194

crates/bindings-cpp/include/spacetimedb/http.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
#pragma once
55

6-
#ifndef SPACETIMEDB_UNSTABLE_FEATURES
7-
#error "spacetimedb/http.h requires SPACETIMEDB_UNSTABLE_FEATURES to be enabled"
8-
#endif
9-
106
#include <string>
117
#include <vector>
128
#include <optional>
@@ -302,12 +298,8 @@ class HttpClient {
302298
* @endcode
303299
*/
304300
Outcome<HttpResponse> send(const HttpRequest& request) {
305-
#ifndef SPACETIMEDB_UNSTABLE_FEATURES
306-
return Err<HttpResponse>("HTTP requests require SPACETIMEDB_UNSTABLE_FEATURES to be enabled");
307-
#else
308301
// Implemented in http_client_impl.h to avoid circular dependencies
309302
return SendImpl(request);
310-
#endif
311303
}
312304

313305
private:
@@ -317,7 +309,7 @@ class HttpClient {
317309
} // namespace SpacetimeDB
318310

319311
// Include implementation dependencies after class definition to avoid circular dependencies
320-
#if defined(SPACETIMEDB_UNSTABLE_FEATURES) && !defined(SPACETIMEDB_HTTP_CONVERT_H)
312+
#ifndef SPACETIMEDB_HTTP_CONVERT_H
321313
#include "spacetimedb/logger.h"
322314
#include "spacetimedb/http_convert.h"
323315
#include "spacetimedb/http_client_impl.h"

crates/bindings-cpp/include/spacetimedb/http_convert.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ inline std::pair<wire::HttpResponse, std::vector<uint8_t>> to_wire_split(const H
281281
} // namespace convert
282282
} // namespace SpacetimeDB
283283

284-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
285284
#include "spacetimedb/logger.h"
286285
#include "spacetimedb/http_client_impl.h"
287-
#endif
288286

289287
#endif // SPACETIMEDB_HTTP_CONVERT_H

crates/bindings-cpp/include/spacetimedb/internal/tx_execution.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace SpacetimeDB::Internal {
1111

12-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
13-
1412
template<typename T>
1513
struct is_outcome : std::false_type {};
1614

@@ -143,8 +141,6 @@ auto try_with_tx(MakeReducerContext&& make_reducer_ctx, Func& body) -> decltype(
143141
return result;
144142
}
145143

146-
#endif
147-
148144
} // namespace SpacetimeDB::Internal
149145

150146
#endif // SPACETIMEDB_INTERNAL_TX_EXECUTION_H

crates/bindings-cpp/include/spacetimedb/procedure_context.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include <spacetimedb/abi/FFI.h> // For transaction syscalls
99
#include <spacetimedb/internal/tx_execution.h>
1010
#include <spacetimedb/random.h> // For StdbRng
11-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
1211
#include <spacetimedb/http.h> // For HttpClient
13-
#endif
1412
#include <cstdint>
1513
#include <functional>
1614
#include <stdexcept>
@@ -66,12 +64,10 @@ struct ProcedureContext {
6664
// Used to track which client connection initiated this procedure
6765
ConnectionId connection_id;
6866

69-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
7067
// HTTP client for making external requests
7168
// IMPORTANT: HTTP calls are NOT allowed inside transactions!
7269
// Always call HTTP before with_tx() or try_with_tx()
7370
HttpClient http;
74-
#endif
7571

7672
private:
7773
// Lazily initialized RNG for UUID generation
@@ -173,10 +169,9 @@ struct ProcedureContext {
173169
return Uuid::from_counter_v7(counter_uuid_, timestamp, random_bytes);
174170
}
175171

176-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
177172
/**
178173
* @brief Execute a callback within a database transaction
179-
*
174+
*
180175
* Starts a mutable transaction, executes the callback, and commits on success.
181176
* If the callback panics (via LOG_PANIC), the transaction is automatically rolled back.
182177
*
@@ -238,7 +233,6 @@ struct ProcedureContext {
238233
};
239234
return Internal::try_with_tx(make_reducer_ctx, body);
240235
}
241-
#endif
242236
};
243237

244238
} // namespace SpacetimeDB

crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#FFI.verified.cs

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-csharp/Codegen.Tests/fixtures/explicitnames/snapshots/Module#FFI.verified.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,11 @@ Internal.TxContext inner
151151

152152
private ProcedureTxContext? _cached;
153153

154-
[Experimental("STDB_UNSTABLE")]
155154
public Local Db => _db;
156155

157-
[Experimental("STDB_UNSTABLE")]
158156
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
159157
base.WithTx(tx => body((ProcedureTxContext)tx));
160158

161-
[Experimental("STDB_UNSTABLE")]
162159
public TxOutcome<TResult> TryWithTx<TResult, TError>(
163160
Func<ProcedureTxContext, Result<TResult, TError>> body
164161
)
@@ -252,7 +249,6 @@ public Uuid NewUuidV7()
252249
}
253250
}
254251

255-
[Experimental("STDB_UNSTABLE")]
256252
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase
257253
{
258254
internal ProcedureTxContext(Internal.TxContext inner)

crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,11 @@ Internal.TxContext inner
593593

594594
private ProcedureTxContext? _cached;
595595

596-
[Experimental("STDB_UNSTABLE")]
597596
public Local Db => _db;
598597

599-
[Experimental("STDB_UNSTABLE")]
600598
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
601599
base.WithTx(tx => body((ProcedureTxContext)tx));
602600

603-
[Experimental("STDB_UNSTABLE")]
604601
public TxOutcome<TResult> TryWithTx<TResult, TError>(
605602
Func<ProcedureTxContext, Result<TResult, TError>> body
606603
)
@@ -694,7 +691,6 @@ public Uuid NewUuidV7()
694691
}
695692
}
696693

697-
[Experimental("STDB_UNSTABLE")]
698694
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase
699695
{
700696
internal ProcedureTxContext(Internal.TxContext inner)

crates/bindings-csharp/Codegen/Module.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,14 +2545,11 @@ internal ProcedureContext(Identity identity, ConnectionId? connectionId, Random
25452545
25462546
private ProcedureTxContext? _cached;
25472547
2548-
[Experimental("STDB_UNSTABLE")]
25492548
public Local Db => _db;
2550-
2551-
[Experimental("STDB_UNSTABLE")]
2549+
25522550
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
25532551
base.WithTx(tx => body((ProcedureTxContext)tx));
2554-
2555-
[Experimental("STDB_UNSTABLE")]
2552+
25562553
public TxOutcome<TResult> TryWithTx<TResult, TError>(
25572554
Func<ProcedureTxContext, Result<TResult, TError>> body)
25582555
where TError : Exception =>
@@ -2643,7 +2640,6 @@ public Uuid NewUuidV7()
26432640
}
26442641
}
26452642
2646-
[Experimental("STDB_UNSTABLE")]
26472643
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase {
26482644
internal ProcedureTxContext(Internal.TxContext inner) : base(inner) {}
26492645

0 commit comments

Comments
 (0)