Commit Graph

2758 Commits

Author SHA1 Message Date
Mario Alejandro Montoya Cortes 4289cd8517 Making tx mut so we can auto-create params on compilation 2025-12-27 14:57:14 -05:00
Mario Alejandro Montoya Cortes d2dde1fb5b Call parameterized views from sql #3489, plan and execution 2025-12-25 16:40:53 -05:00
Mario Alejandro Montoya Cortes 13110e88b7 Call parameterized views from sql #3489, parsing 2025-12-24 13:56:34 -05:00
Jason Larabie 48b8a31fe0 Refactor /docs to close in on the final form (#3917)
# Description of Changes

Closes: #3895 
- Added third tier expanding folder
- Merged most into intro + core concepts 
- Collapsed modules + database into one
- Moved several documents to how-to to streamline the core concepts
- Added warning to RLS to use views
- refactored all links 
- Moved How To and References into Developer Resources
- Fixed TypeScript View code

Sample: (Getting Started will start expanded due to being the initial
page)
<img width="293" height="746" alt="image"
src="https://github.com/user-attachments/assets/6abc3a0d-1ae2-4886-bda7-11f5565afecf"
/>


# API and ABI breaking changes

N/A

# Expected complexity level and risk

1

# Testing

- [X] Updated the quickstarts.py and generate-cli tooling

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-12-23 15:06:57 +00:00
Noa 0a192082a8 Add missing Nameable implementations (#3920)
# Description of Changes

Fixes #3919.

# Expected complexity level and risk

1

# Testing

- [x] Erroring code now works

Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-12-21 20:18:12 +00:00
Ryan 8a0cd87c4f Adds datastore_index_scan_point_bsatn to C# Runtime (#3909)
# Description of Changes

To resolve #3875, we added exact-match unique index point lookup support
to the C# bindings by introducing and using
`datastore_index_scan_point_bsatn`.

Previously, generated unique index `Find()` was (in at least one
codepath) implemented as:

* A range scan (`datastore_index_scan_range_bsatn`) over a BTree bound,
then
* `SingleOrDefault()` to collapse the results into a single row.
When the scan is empty, `SingleOrDefault()` returns `default(T)`. For
value-type rows this can manifest as a default-initialized row instead
of “missing”, which is what surfaced as “default-ish row” behavior in
views.

Using `datastore_index_scan_point_bsatn` makes the C# implementation
match Rust semantics more closely by performing an exact point lookup
and returning:

* `null` when no rows are found
* the row when exactly one row is found
* (defensively) an error if >1 row is returned (unique index invariant
violation)
Similarly, `datastore_delete_by_index_scan_point_bsatn` was added and
used so deletes-by-unique-key are also exact-match point operations
rather than range deletes.

Runtime updates were made to utilize point scan in `FindSingle(key)` and
in both mutable/read-only unique-index paths.

To keep this non-breaking for existing modules, codegen now detects
whether the table row is a struct or a class and chooses the appropriate
base type:
* Struct rows: `Find()` returns `Row?` (`Nullable<Row>`).
* Class rows: `Find()` returns `Row?` (nullable reference, `null` on
miss).

# API and ABI breaking changes

This change is non-breaking with respect to row type kinds, because
class/record table rows continue to work via
RefUniqueIndex/ReadOnlyRefUniqueIndex while struct rows use
UniqueIndex/ReadOnlyUniqueIndex.

API surface changes:
* Generated `Find()` return type is now nullable (`Row?`) to correctly
represent “missing”.

ABI/runtime:
* Requires the point-scan hostcall import
(`datastore_index_scan_point_bsatn`) to be available; the runtime uses
point-scan for unique lookup (and point delete for unique delete).

# Expected complexity level and risk

Low 2

# Testing

- [X] Local testing: repro module + client validate view and direct
Find() behavior

---------

Signed-off-by: rekhoff <r.ekhoff@clockworklabs.io>
2025-12-20 00:32:37 +00:00
Ryan f309ea93f9 Removes C# regression test of TimestampCapabilities (#3908)
# Description of Changes

Removes the `TimestampCapabilities` test from the C# SDK's regression
test suite, due to creating inconsistent failures in automated CI
testing.

# API and ABI breaking changes

Not API/ABI breaking

# Expected complexity level and risk

1

# Testing

- [X] Ran locally, no failures in building or running C# regression
tests
2025-12-19 22:15:13 +00:00
Zeke Foppa 264e45eafc CI - Hackily fix V8 linker errors (#3921)
# Description of Changes

Introduce a hacky workaround to our `csharp-testsuite` to address
missing `librusty_v8.a`: manually check for that file and manually build
the package if it's missing.

# API and ABI breaking changes

CI-only change

# Expected complexity level and risk

1

# Testing

- [x] Locally tested removing the `librusty_v8.a` and then running
`cargo clean -p v8 && cargo build -p v8`, and this does seem to repair
it.
- [x] The CI has run with a cache that is "broken", but successfully
passes `csharp-testsuite`

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-19 21:22:18 +00:00
KirstenWF df035c48ff do not warn, if valid [UnrealSDK] (#3898)
# Description of Changes
Avoid warning if table is valid.

# API and ABI breaking changes
-

# Expected complexity level and risk
1

# Testing
Accessing tables via Blueprint and no warning in output log, if table is
valid.
2025-12-19 00:59:45 +00:00
John Detter 69edb3ebe2 Bump typescript package sizes again (#3906)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

- Just bumping typescript size limits again

# API and ABI breaking changes

No

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

0 - this is just a release change.

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

I have not tested this but I've verified the new limit is greater than
the package size.

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->
2025-12-19 00:42:35 +00:00
Jason Larabie 9daf51ea26 Remove old documentation that was mistakenly left (#3902)
# Description of Changes

With the refactor docs I had left the original module folder and
mistakenly didn't remove it as requested as per Tyler's comment:
https://github.com/clockworklabs/SpacetimeDB/pull/3877#pullrequestreview-3585291570:
> Also please remove the "old files" before merging.

# API and ABI breaking changes

N/A

# Expected complexity level and risk

1

# Testing

Removal of documents there is no test to run

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-12-19 00:36:48 +00:00
Mazdak Farrokhzad 8e3af49f64 Reuse buffers in ServerMessage<BsatnFormat> (#2911)
# Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/2824.

Defines a global pool `BsatnRowListBuilderPool` which reclaims the
buffers of a `ServerMessage<BsatnFormat>` and which is then used when
building new `ServerMessage<BsatnFormat>`s.

Notes:
1. The new pool `BsatnRowListBuilderPool` reports the same kind of
metrics to prometheus as `PagePool` does.
2. `BsatnRowListBuilder` now works in terms of `BytesMut`.
3. The trait method `fn to_bsatn_extend` is redefined to be capable of
dealing with `BytesMut` as well as `Vec<u8>`.
4. A trait `ConsumeEachBuffer` is defined from
`ServerMessage<BsatnFormat>` and down to extract buffers.
`<ServerMessage<_> as ConsumeEachBuffer>::consume_each_buffer(...)` is
then called in `messages::serialize(...)` just after bsatn-encoding the
entire message and before any compression is done. This is the place
where the pool reclaims buffers.

# Benchmarks

Benchmark numbers vs. master using `cargo bench --bench subscription --
--baseline subs` on i7-7700K, 64GB RAM:

```
footprint-scan          time:   [21.607 ms 21.873 ms 22.187 ms]
                        change: [-62.090% -61.438% -60.787%] (p = 0.00 < 0.05)
                        Performance has improved.

full-scan               time:   [22.185 ms 22.245 ms 22.324 ms]
                        change: [-36.884% -36.497% -36.166%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The improvements in `footprint-scan` are mostly thanks to
https://github.com/clockworklabs/SpacetimeDB/pull/2918, but 7 ms of the
improvements here are thanks to the pool. The improvements to
`full-scan` should be only thanks to the pool.

# API and ABI breaking changes

None

# Expected complexity level and risk

2?

# Testing

- Tests for `Pool<T>` also apply to `BsatnRowListBuilderPool`.
2025-12-18 23:02:36 +00:00
Noa 66f55471da Refactor typescript table iterators (#3782)
# Description of Changes

A few main goals here:
* have our iterator functions return an [`Iterator`
object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator)
so that users can use its combinators like `filter()` and `find()` and
`reduce()`. It's a very new JS api but we happen to know that the module
code will always be run in an environment that has it* :)

* improve lifecycle handling for iterator handles - mainly, if an
iterator is not run to completion, it will now eventually get garbage
collected, whereas before we would have a resource leak.

It turns out that the easiest way to do both of those things was to turn
TableIterator into a generator function, which also happens to make the
code much easier to read. Hooray :)

\* I did mention it in `table_cache` (which isn't run in our module
host) but it's fine, since that's only in the type system and
`IteratorObject` is defined in typescript's `lib.es2015.iterable.d.ts`
but is only given fancy methods in `lib.esnext.iterator.d.ts` - so if
the user uses esnext, they'll have access to them, but otherwise not.

# Expected complexity level and risk

1: this better separates concerns and makes the code clearer in its
purpose.

# Testing

- [x] Refactor, so automated testing is sufficient.
2025-12-18 20:55:10 +00:00
rekhoff 39f01289e5 C# implementation of Transactions for Procedures (#3809)
# Description of Changes

Implements the C# equivalent of #3638

This implement uses inheritance, where abstract base classes (like
`ProcedureContextBase` in `ProcedureContext.cs`) store the core of the
implementation, and then generated wrappers (like `ProcedureContext` in
the generated FFI.cs file) inherit from them.

For error handling, we work like Rust's implementation of `Result<T,E>`
but we require `where E : Exception` because of how exceptions work in
C#. Transaction-level failures come back as a `TxOutcome` and user
errors should follow the `Result<T,E>` pattern. In this implementation,
we have `UnwrapOrThrow()` throws exceptions directly because of C#'s
error handling pattern.

Unlike the Rust implementation's direct `Result` propagation, we are
using an `AbortGuard` pattern (in `ProcedureContext.cs`) for exception
handling, which uses `IDisposable` for automatic cleanup.

Most changes should have fairly similar Rust-equivalents beyond that.
For module authors, the changes here allow for the transation logic to
work like:
```csharp
ctx.TryWithTx<ResultType, Exception>(tx => {
    // transaction logic
    return Result<ResultType, Exception>.Ok(result);
});
```
This change includes a number of tests added to the
`sdks/csharp/examples~/regression-tests/`'s `server` and `client` to
validate the behavior of the changes. `server` changes provide further
usage examples for module authors.

# API and ABI breaking changes

Should not be a breaking change

# Expected complexity level and risk

2

# Testing

- [x] Created Regression Tests that show transitions in procedures
working in various ways, all of which pass.
2025-12-18 18:41:47 +00:00
Zeke Foppa c38b135038 CI - No cache-on-failure (#3903)
# Description of Changes

Disable `cache-on-failure` as we think that it's contributing to
mysterious `rusty_v8` linker issues.

I bumped the prefix key so that PRs with this change don't share caches
with PRs missing this change.

# API and ABI breaking changes

CI only.

# Expected complexity level and risk

1

# Testing

None. We'll have to see if we stop having issues once this is merged.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-18 18:20:02 +00:00
KirstenWF a914094b10 add missing Category = "SpacetimeDB" [UnrealSDK] (#3897)
# Description of Changes
added missing category specifier

# API and ABI breaking changes
-

# Expected complexity level and risk
1

# Testing
-
2025-12-18 17:44:59 +00:00
John Detter eb5000895d Bump versions to 1.11.1 (#3901)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

- Bump version numbers to `1.11.1`

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

1

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

- [x] Verified that the license has been updated
- [x] `spacetime --version` on this commit is correct

There is also a corresponding private PR.
2025-12-18 16:35:50 +00:00
Kim Altintop a2c434141d client-api: Pause time in websocket timeout tests (#3896)
Using `#[tokio::test(start_paused = true)]` pauses time, yet tokio will
still advance it when encountering `sleep`s while it has no other work
to do.

This makes the tests that rely on timeouts deterministic and should
prevent those tests from becoming flaky on busy machines.

# Expected complexity level and risk

2

# Testing

This modifies tests.
It does appear to work as described, but it can't hurt if the reviewers
convince themselves that it does indeed.
2025-12-18 10:17:41 +00:00
joshua-spacetime cb5e7117a7 Make subscribe durable (#3894)
# Description of Changes

With the addition of module-defined views, subscriptions are no longer
read-only as they may invoke view materialization.

The way this works is that a subscription starts off as a mutable
transaction, materializes views if necessary, and then downgrades to a
read-only transaction to evaluate the subscription.

Before this patch, we were calling `commit_downgrade` directly on the
`MutTxId` in order to downgrade the transaction. This would update the
in-memory `CommittedState`, but it wouldn't make the transaction
durable.

This would result in us incrementing the transaction offset of the
in-memory `CommittedState` without writing anything to the commitlog.
This in turn would invalidate snapshots as they would be pointing
further ahead into the commitlog than they should, and so when replaying
from a snapshot we would potentially skip over commits that were not
included in the snapshot.

This patch changes those call sites to use
`RelationalDB::commit_tx_downgrade` which both updates the in-memory
state **and** makes the transaction durable.

**NOTE:** The fact that views are materialized is purely an
implementation detail at this point in time. And technically view tables
are ephemeral meaning they are not persisted to the commitlog. So the
real bug here was that we were updating the tx offset of the in-memory
committed state at all. This is technically fixed by
https://github.com/clockworklabs/SpacetimeDB/pull/3884 and so after
https://github.com/clockworklabs/SpacetimeDB/pull/3884 lands this change
becomes a no-op. However, we still shouldn't be calling `commit` and
`commit_downgrade` directly on a `MutTxId` since in most cases it is
wrong to bypass the durability layer. And without this change, the bug
would still be present were view tables not ephemeral, which they may
not be at some point in the future.

# API and ABI breaking changes

None

# Expected complexity level and risk

1. The change itself is trivial, the bug is not.

# Testing

Adding an automated test for this is not so straightforward. First it's
view related which means we don't have many options apart from a smoke
test, but I don't believe the smoke tests have a mechanism for replaying
the commitlog.

If transaction offsets are supposed to be linear, without any gaps, then
it would be useful to assert that on each append, in which case we could
write a smoke test that would fail as soon as the offsets diverged.
2025-12-18 02:42:11 +00:00
joshua-spacetime a7c605caa9 Resolve algebraic type refs recursively for view type check (#3876)
# Description of Changes

Resolves algebraic type refs recursively in order to check the product
type of a query builder view.

This should fix the issue reported
[here](https://discord.com/channels/1037340874172014652/1448796556366057513).
However I've so far been unsuccessful in trying repro it.

Also adds further commentary to `Typespace::resolve` to make it clear
that it is not recursive.

# API and ABI breaking changes

None

# Expected complexity level and risk

0

# Testing

TODO. So far I haven't been able to repro with a smoketest
2025-12-18 01:24:32 +00:00
Jason Larabie e9d2b117cc Refactor /docs into Concepts (#3877)
# Description of Changes

Refactoring all sections to match a concept based approach to the docs.

Closes: #3840 

Currently:
- Modules - Closes: #3841 
- Databases - Closes: #3842 
- Tables - Closes: #3843 
- Reducers - Closes: #3844 
- Procedures - Closes: #3845
- Views - Closes: #3846 

# API and ABI breaking changes

N/A

# Expected complexity level and risk

1

# Testing

- [x] Walking through all code references before pushing

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-12-17 23:13:56 +00:00
Phoebe Goldman 4829616ec5 Ignore system meta-descriptor rows during replay (#3891)
# Description of Changes

Based on #3887 . Review starting from commit 233b48cc4.

We've encountered a commitlog which includes inserts into `st_table`,
`st_column`, &c of the rows which describe `st_view`, `st_view_param`,
&c. This caused replay to fail, as those rows were already inserted
during bootstrapping,
so we got set-semantic duplicate errors. With this commit, we ignore
set-semantic duplicate errors when replaying a commitlog specifically
for rows in system tables which describe system tables.

We also have to do an additional fixup for sequences. This is described
in-depth in comments added at the relevant locations.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

1 - I was careful not to swallow any errors which aren't obviously safe.

# Testing

- [x] Manually replayed commitlog which includes the above mentioned
inserts, got error prior to this commit, no error with this commit.
2025-12-17 21:39:34 +00:00
Kim Altintop e2b4113ffb Async shutdown for database / durability (#3880)
Controlled shutdown of a database should drain the outstanding
transactions
queue(s) and flush them to the durability layer.

With the introduction of another queueing layer in #3868, it became
harder to
observe when or if this process is completed.

This patch thus introduces an explicit (async) shutdown method for
`RelationalDB` and below, which will wait until all submitted
transactions are
either reported durable, or an error occurs in the durability layer.

`RelationalDB` is made `!Clone`, such that shutdown can be initiated in
the
`Drop` impl. Note that this requires access to a tokio runtime, which we
thread
through via the `Persistence` services in order to allow control over
which of
the various runtimes is being used for durability-related tasks.

Also moves `RelationalDB::open` to a blocking thread when a
persistence-enabled
database is constructed by the `HostController` -- this process performs
heavy
I/O and can take a substantial amount of time, during which we don't
want to
block a worker thread.

# API and ABI breaking changes

None

# Expected complexity level and risk

3

# Testing

- [ ] some testing added
- [ ] existing tests still pass
- [ ] `impl Drop for RelationalDB` difficult to test, extra eyeballs
needed

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-12-17 18:28:42 +00:00
Zeke Foppa 70628fb51e cargo ci on windows (#3859)
# Description of Changes

Make `cargo ci` work properly on Windows, in preparation for
https://github.com/clockworklabs/SpacetimeDB/pull/3702.

# API and ABI breaking changes

No. CI-only.

# Expected complexity level and risk

2. Not trivial, but not complicated.

# Testing

- [x] CI output seems to be genuinely running the tests, and it's
passing on Windows
- [x] Make a change to `crates/bindings-csharp` and see that `cargo ci
test` fails
- [x] I can manually run a minimal `cargo ci smoketests` invocation on a
Windows machine

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Kasama <robertoaall@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-17 17:34:49 +00:00
Phoebe Goldman 13614d7515 Add a fault-tolerant commitlog replay mode for use in debugging (#3887)
# Description of Changes

When debugging broken commitlogs, we want to inspect the whole
commitlog, including the part after the first error.
This is in contrast with the way we want to replay in prod, where we'd
rather get a hard error than an incorrect state.

This commit adds a new flag to commitlog replay, `ErrorBehavior`. The
`core` crate passes `ErrorBehavior::FailFast`
when replaying commitlogs to reconstruct databases. Internal tooling
(not in this repository) uses `ErrorBehavior::Warn` to print the
entirety of a broken commitlog.

# API and ABI breaking changes

Changes internal APIs only.

# Expected complexity level and risk

1 - no change to behavior of SpacetimeDB.

# Testing

None.
2025-12-17 14:15:24 +00:00
Jeffrey Dallatezza a1607ce523 Add Reducer to the end of reducer arg types to avoid collisions (#3889)
# Description of Changes

This helps with the issue reported in
https://github.com/clockworklabs/SpacetimeDB/issues/3811.

Right now we have a type representing the reducer, and a type for the
reducer args, and both have the same name. This adds `Reducer` to the
end of the args type, which is similar to what we are doing for
procedure arguments or the `Row` suffix for tables.

This will still cause some potential problems, since someone could have
a type that ends in `Reducer` (or `Row`), but this will fix the majority
of issues that are currently breaking people.

This also has some changes to get the basic react example to build.

# API and ABI breaking changes

This is technically a breaking change if people are using this for type
annotations (which doesn't seem too likely), but it should be an easy
one for people to fix.

# Expected complexity level and risk

1.

# Testing

I tested the quickstart.
2025-12-17 05:43:33 +00:00
Kim Altintop a388c48458 Ensure all-ephemeral transactions don't consume a tx offset (#3884)
Views are materialized in mutable transactions, but should not increment
the transaction offset maintained in the committed state.

This fixes storing completely empty transactions in the commitlog, and
maintains that the committed state tx offset is in-sync with the
commitlog's tx offset.

# Expected complexity level and risk

2

# Testing

Added a test.

---------

Signed-off-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-12-16 23:14:21 +00:00
Kim Altintop b1676abb82 cli: Flush stdout after printing the database tree (#3888)
`spacetime delete` may print the database tree and ask for confirmation.
We did not flush stdout, causing the tree to be interleaved with the
yes/no prompt.


# Expected complexity level and risk

1
2025-12-16 22:46:03 +00:00
Phoebe Goldman cc2ac5424c Strip sensitive info from HTTP errors (#3878)
# Description of Changes 

`reqwest` includes the full URL in its errors, including query params.
This is unfortunate, as query params can contain sensitive info like API
tokens. It's difficult for modules to clean these themselves, as they
see errors as strings, losing the structure of `reqwest::Error`.
In this commit, we strip query parts out of URLs in errors before
returning them to modules. I've also audited all of the error return
paths in the `http_request` method and left comments justifying why the
unchanged ones are safe.

# API and ABI breaking changes

Only if you consider the format of error messages part of our API, which
I don't. Procedure APIs aren't stable yet anyways.

# Expected complexity level and risk

1

# Testing

None yet - accepting input from reviewers about desired tests if we feel
that's necessary.

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->

---------

Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Julien Lavocat <JulienLavocat@users.noreply.github.com>
2025-12-16 22:32:17 +00:00
Noa 4d23fe3e8d [TS] Fix useTable casing issues (#3853)
# Description of Changes

Fixes #3807. Not sure what the best way to model this in the API is
(another argument to `t.row()`?), but it does work.

# Expected complexity level and risk

1

# Testing

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
2025-12-16 21:57:55 +00:00
Zeke Foppa f49945cc6a Fix CLI reference generation (#3403)
# Description of Changes

Add back the instructions for regenerating CLI docs, which were removed
in https://github.com/clockworklabs/SpacetimeDB/pull/3343. I also made a
script for it.

This also fixes the CI checking this file, which was silently broken in
the same PR.

I have **not** verified that this works in Git Bash in Windows.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing
- [x] CI passes
- [x] CI fails if I change the CLI reference
- [x] CLI reference looks visually reasonable on a local `pnpm dev`

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-16 20:17:51 +00:00
Jeffrey Dallatezza 4ebb31c573 Fix useReducer params (#3873)
# Description of Changes

`ParamsType` is a tuple, so we need to spread when we actually call
reducer functions.

Currently reducer arguments aren't being sent with the `useReducer`
hook.

# Expected complexity level and risk

1

# Testing

I tested this manually with the quickstart chat app.

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-12-16 20:17:27 +00:00
Julien Lavocat 178bb9d523 Fix broken SpacetimeDB logo in docs (#3886)
# Description of Changes

The `.png` logo image has been replaced by a `.svg` and needed to be
updated.

# API and ABI breaking changes

Not applicable

# Expected complexity level and risk

0.000001

# Testing

Run `pnpm dev` and check that the logo is correctly displayed in the top
left corner
2025-12-16 20:17:27 +00:00
Jeffrey Dallatezza 12fe0217b1 Tighten query types (#3866)
# Description of Changes

This improves the type safety a bit from
https://github.com/clockworklabs/SpacetimeDB/pull/3812.

The core change is that the previous version typed queries based on the
typescript type, not the spacetime type. This meant that we allowed
queries for incorrect tables, like a table that had the same column
names and types, but had a u32 instead of a u64 somewhere.

This still has an issue with allowing results from tables where the rows
are reordered, which would actually be a problem, but hopefully that is
not too common.

# API and ABI breaking changes

This is technically a breaking change, because it changes some type
parameters. I don't think people should be relying on these though, so I
don't think we should be worried about breaking them.

This would only cause new type errors for apps that are likely to error
at runtime anyway.

# Expected complexity level and risk

1.5. This should be low risk, since it is just a typing change.

# Testing

This has some type checks in `view.test-d.ts`, and I've done some manual
e2e testing.
2025-12-16 19:07:52 +00:00
Mazdak Farrokhzad 492e591845 Add WASM point scan ABIs & use them in Rust bindings (#3863)
# Description of Changes

Provides new WASM ABIs:

- `datastore_index_scan_point_bsatn`
- `datastore_delete_by_index_scan_point_bsatn`

These are then used where applicable to speed up `.find(_)` and friends.

Point scans are also used more internally where applicable.

What remains after this is use in C# module bindings and to expose this
in TS as well.

The PR makes TPS go from roughly 36k to 38k TPS on my machine and also
makes a difference in flamegraphs where the time spent in some index
scans are substantially decreased.

# API and ABI breaking changes

None

# Expected complexity level and risk

3? This touches the datastore an how we expose it to modules.

# Testing

Some existing tests now exercise the new ABIs by changing what
`.find(_)` and friends do.

---------

Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-12-12 22:07:54 +00:00
Zeke Foppa 8967ea7b59 CI - Use rust-toolchain-file everywhere (#3872)
# Description of Changes

We were using `rust-toolchain` in some places, and `rust-toolchain-file`
in others. I think Rust released a new version, which made the
`rust-toolchain` parts break with:

```
info: downloading component 'rustfmt'
info: removing previous version of component 'rust-src'
info: rolling back changes
error: could not rename component file from '/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/term/terminfo/searcher' to '/root/.rustup/tmp/a4eo07uz83vsyfhk_dir/bk': Invalid cross-device link (os error 18)
Error: Process completed with exit code 1.
```

(Separately, this breakage is confusing.. we'll probably run into this
again when we roll forward our rust version..)

# API and ABI breaking changes

None. CI-only change.

# Expected complexity level and risk

1

# Testing

- [x] CI passes
- [x] There are no more instances of `rust-toolchain`:
```
$ grep -rIP 'rust-toolchain(?!-file)' .github/workflows
.github/CODEOWNERS:/rust-toolchain.toml @cloutiertyler
```
(on `master`, this finds the instances we changed)

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-11 18:51:48 +00:00
Mazdak Farrokhzad 907d67ec1f wasmtime: pool async stack allocations on unix (#3830)
# Description of Changes

Uses `with_host_stack` to provide a `StackCreator` that pools
`FiberStack`s.
This does not use the pooling instance allocator and is limited to just
stacks.

# API and ABI breaking changes

None

# Expected complexity level and risk

3? Some unsafe and wasmtime internals relied upon.

# Testing

Covered by existing tests.
2025-12-11 07:46:47 +00:00
Roberto Pommella Alegro 5ac65739e5 add initial cargo ci (#3409)
# Description of Changes

This changes the ci runs to execute `cargo ci` instead of running
commands directly from the github workflow.

The goal here is to unify the commands under `cargo ci` so that it's
easier and more intuitive to run locally

# API and ABI breaking changes

There are no API/ABI changes.

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

Complexity: 1

It is not a complex change as it is mostly localized to the ci runs and
is easily reversible if something goes wrong. The biggest risk here is
to have future CI runs break, which can be remediated by reverting these
changes.

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] run `cargo ci` and its subcommands locally
- [x] run the github workflow against this branch to check if the CI
jobs are working properly.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Signed-off-by: Roberto Pommella Alegro <robertoaall@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-12-10 19:18:43 +00:00
Mario Montoya cdf8391ff3 Add rng support to ProcedureContext on Rust (#3865)
# Description of Changes

As the title says, required for
https://github.com/clockworklabs/SpacetimeDB/pull/3538.

# Expected complexity level and risk

1

# Testing

Will be done on the `uuid` pr.

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-12-10 19:05:21 +00:00
Mazdak Farrokhzad e5f1558ec7 Don't panic in datastore_index_scan_range_bsatn on invalid ranges (#3746)
# Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/3617.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

A proptest `empty_range_scans_dont_panic` is added.
2025-12-10 13:45:36 +00:00
Shubham Mishra 6c0b66ad6e filter alias for rust query builder's where method (#3856)
# Description of Changes
As title.


# API and ABI breaking changes
incremental binding.

# Expected complexity level and risk

# Testing
Unit and smoketest
2025-12-10 13:19:32 +00:00
Shubham Mishra 17b6ee1847 fix automigration bug with auto_inc (#3862)
# Description of Changes
fixes #3861.

While running prechecks for automigration, the `range` passed to
`iter_by_col_range_mut` was of type `AlgebraicValue::I128`, even though
it should have matched the column’s type.

Fix is straightforward by introducing `AlgebraicValue::from_i128`
helper.

# API and ABI breaking changes
NA

# Expected complexity level and risk
1

# Testing

- Modified smoketest to repro reported bug.

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-12-10 13:18:38 +00:00
Shubham Mishra d6eff1befe lte and gte operators to rust query builder (#3855)
# Description of Changes
Fixes #3827 

Adding lte and gte support for query_builder in rust.


# API and ABI breaking changes
Incremental change to bindings.

# Expected complexity level and risk
1


# Testing
unit test and smoketest
2025-12-10 12:24:34 +00:00
Jeffrey Dallatezza 0866367b07 Handle unknown transactions without erroring. (#3858)
# Description of Changes

Don't throw an error if there is no `reducerInfo`. The code was
previously trying to handle the case of an unknown reducer, but was
effectively asserting that the reducerInfo existed too soon.

Now we should be fine handling a transaction, even if we can't determine
reducer information for it.

# Expected complexity level and risk

1.

# Testing

I tested this by running the quickstart chat app, and using the CLI to
delete rows (via `spacetime sql`). Before this change, the client
errors, but now it handles it correctly.

I also tested with the repro in
https://github.com/clockworklabs/SpacetimeDB/issues/3817
2025-12-09 22:37:49 +00:00
Noa bea7a7dc68 [TS] Use 'override' when overriding class items (#3852)
# Description of Changes

This should fix part of #3503. Adds an override modifier to generated
code and fixes a warning from the angular compiler.

# Expected complexity level and risk

1

# Testing

- [x] Code works fine with the added `override` modifier.
- [ ] Perhaps we should have an angular test project?
2025-12-09 20:08:40 +00:00
Phoebe Goldman 111bc1a1f9 Rename docs dirs and files to have more digits (#3851)
# Description of Changes

This makes it possible to insert new pages between existing pages
without renaming the existing pages.

I also added a section to docs/README.md with procedure for how to name
new pages, which I'll paste here:

### Adding new pages

All of our directory and file names are prefixed with a five-digit
number which determines how they're sorted.
We started with the hundreds place as the smallest significant digit, to
allow using the tens and ones places to add new pages between.
When adding a new page in between two existing pages, choose a number
which:

- Doesn't use any more significant figures than it needs to.
- Is approximately halfway between the previous and next page.

For example, if you want to add a new page between `00300-foo` and
`00400-bar`, name it `00350-baz`. To add a new page between `00350-baz`
and `00400-bar`, prefer `00370-quux` or `00380-quux`, rather than
`00375-quux`, to avoid populating the ones place.

To add a new page after all previous pages, use the smallest multiple of
100 larger than all other pages. For example, if the highest-numbered
existing page is `01350-abc`, create `01400-def`.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

1 - @JulienLavocat said this wouldn't break anything.

# Testing

None.

---------

Co-authored-by: Jason Larabie <jason@clockworklabs.io>
2025-12-09 19:11:48 +00:00
Kim Altintop 16f1b2c1fe client-api: Deny changing the parent of an existing database (#3837)
Mainly a smoketest to exercise the intended behaviour. Also return an
error if we end up delegating to the reset database endpoint, which
itself doesn't accept a `parent` parameter.
2025-12-09 18:35:48 +00:00
John Detter 7e367b38a6 Update typescript package size limits (#3854)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

Updated package sizes from a failed release dry-run:
https://github.com/clockworklabs/SpacetimeDBPrivate/actions/runs/20045893743/job/57491806595

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

1 - this is just a release fix

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

I have not tested this, it is a trivial change.
2025-12-09 11:02:33 +00:00
Kim Altintop 062649c92e client-api: Send WebSocket messages fragmented (#2931)
RFC 6455, Section 5.4 describes message fragmentation, and we can do
that with tungstenite.

It does seem to help getting control messages (ping, pong, close)
through without head-of-line blocking.

# Expected complexity level and risk

2 - Need to test with clients

# Testing

TBD - some more abstraction is needed due to the difficulty of
synthetically producing a large outgoing message.
2025-12-09 09:21:11 +00:00
Noa af5b04e949 Implement sourcemap handling (#3828)
# Description of Changes

Uses the `sourcemap` crate to map text locations in the bundle to text
locations in the original source code.

# Expected complexity level and risk

1 - essentially only related to diagnostics

# Testing

- [x] Manually tested
- [ ] Add an automated test for backtrace output
2025-12-08 22:29:54 +00:00