Commit Graph

2536 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 133c6aa5f0 Merge branch 'master' into centril/authctx-docs 2025-10-28 16:38:06 +01:00
joshua-spacetime 39f91270e1 Auto-migration rules for views (#3484)
# Description of Changes

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

Defines auto-migration rules for views.

> What are they?

Answer: You can always auto-migrate a view. It's just a matter of
whether you have to disconnect clients. Removal of a view or changing
the return type in a breaking way requires that we disconnect clients.

TODO: Even if a view is updated in a completely compatible way, we still
have to wipe or dirty the read set in order to force a re-computation
because the behavior could have changed.

# 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

<!--
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. -->

2.5

Not just a mechanical change.

Most of the time you can think of views as though they were tables.
However for auto-migration there is a key distinction. Views don't have
observably persistent state. While we can persist state internally, we
can always derive a view's result set from the database state. Hence
auto-migration rules are not as strict.

# 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] Auto-migration planner tests
2025-10-28 14:30:38 +00:00
John Detter af69e5862e Improve spacetime-install.ps1 (#3505)
# Description of Changes

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

This is a follow-up to
https://github.com/clockworklabs/SpacetimeDB/pull/2356 . Essentially we
want to remove this `return` statement so that you can both install the
vcruntime and also continue installing SpacetimeDB without having to run
the installer twice on Windows.

# 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 affects windows installation.

<!--
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 tested this on a new Windows 11 install. You can test the script by
downloading it from this PR and then running the following:
```
iex (Get-Content .\spacetime-install.ps1 -Raw -Encoding UTF8)
```

- [x] I have tested this

This is from a brand-new Windows11 install with all updates installed:
<img width="971" height="328" alt="image"
src="https://github.com/user-attachments/assets/76e9b813-64f9-4a92-b961-c2136fa1372e"
/>

Then I opened a new terminal window:
<img width="815" height="162" alt="image"
src="https://github.com/user-attachments/assets/49e7cf95-fa37-4a5b-9fdd-7722e2055495"
/>

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-10-27 23:48:17 +00:00
Egor Vorontsov 20a12172ef Included dropped_table_id into the error message in replay (#3481)
# Description of Changes

Extra debug info for #3465.

# API and ABI breaking changes

None.

# Expected complexity level and risk

### 1.

# Testing

- [x] Manual testing on a borked database.
2025-10-27 22:04:50 +00:00
Zeke Foppa 423414973a Bump TypeScript versions to 1.6.2 (#3424)
# Description of Changes

Bump the TypeScript package version to 1.6.2 in preparation for a
release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Existing CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-27 20:54:28 +00:00
Zeke Foppa 9ad5e7038a CI - Cancel runs on new pushes (#3501)
# Description of Changes

Add `cancel-in-progress` to our GitHub workflows.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] Pushing new commits to this PR causes cancels of previous CI runs

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-27 19:15:21 +00:00
Mazdak Farrokhzad b150bf4b64 Merge branch 'master' into centril/authctx-docs 2025-10-27 19:10:48 +01:00
Phoebe Goldman a952ba5737 Include cargo-insta in devShell in nix flake (#3470)
# Description of Changes

For to run `cargo insta test`, `cargo insta review`, &c during local
development.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

1: just changes to the devShell in the flake, not even the actual
package build.

# Testing

- [x] Ran `cargo insta test` locally using the dev shell.
2025-10-24 21:07:30 +00:00
rekhoff 023a7d31e3 Add a SpacetimeDBException to C# SDK to aid in debugging (#3386)
# Description of Changes

This implements a fix to an issue with debugging using the C# SDK, by
adding new exception types:
* `SpacetimeDBException`, 
* `SpacetimeDBArgumentException`,
* `SpacetimeDBEmptyReducerNameException`

Additional, regenerating bindings will now allow clients to report an
`SpacetimeDBEmptyReducerNameException` rather than an
`ArgumentOutOfRangeException` when the client receives an empty reducer
name from the server.

An example of the generated code currently, that results in the
exception:
https://github.com/clockworklabs/SpacetimeDB/blob/544e2edc2d1f7d1dd118832a815b6dbd7a6c1d82/sdks/csharp/examples~/quickstart-chat/client/module_bindings/SpacetimeDBClient.g.cs#L475

Note: Normally this is not an issue for a client, because the
`SpacetimeDBEmptyReducerNameException` would be caught by the
[Try/Catch](https://github.com/clockworklabs/SpacetimeDB/blob/9f59118e24449cdd2d3e182bd44fdb26078e921b/sdks/csharp/src/SpacetimeDBClient.cs#L421C25-L421C42)
statement, but a debugger will still catch the exception and halt
operation. This can be annoying to a developer when debugging.

By separating out the exception into a custom `Exception` type, we allow
a developer to flag the new exception type as something it can ignore,
without ignoring other relevant exceptions.

# API and ABI breaking changes

Not a breaking change.
Clients will need to regenerate bindings to get the new exceptions

# Expected complexity level and risk

1

# Testing

- [X] Tested regenerating bindings and confirmed intended output.
- [X] Tested debugging and receiving
`SpacetimeDBEmptyReducerNameException` when expected.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-24 20:59:19 +00:00
Rémi THOMAS 230205d442 spacetime-install.ps1 installs Visual C++ Redistributable if needed (#2356)
Add VCRuntime detection and installation. This runtime is mandatory.

# Description of Changes
Update the Windows powershell script to install VCRuntime.

# Expected complexity level and risk
Not complex.
Download directly from Microsoft.

# Testing
Tested on a clean Windows 10 machine.

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-10-24 20:45:24 +00:00
joshua-spacetime 8f11ac81e3 Make name a required parameter of view macro (#3480)
# Description of Changes

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

Makes `name` a required parameter of the `#[view]` macro. This is to be
consistent with the `#[table]` macro since views should expose the same
interface as tables.

# 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

<!--
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. -->

1

# 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] Added new compile tests
- [x] Updated existing compile tests
2025-10-24 20:43:33 +00:00
Julien Lavocat 5aa80bfcc3 Add back llms.md (#3479)
# Description of Changes

LLMS.md was deleted and not added before merging the docusaurus
migration

# API and ABI breaking changes

None

# Expected complexity level and risk

0

# Testing

None
2025-10-24 18:24:56 +00:00
Mazdak Farrokhzad 50d58a2858 Add modules/benchmarks-ts (#3408)
# Description of Changes

Adds `modules/benchmarks-ts`.

# API and ABI breaking changes

None

# Expected complexity level and risk

2?

# Testing

This is a test.

---------

Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Noa <coolreader18@gmail.com>
2025-10-24 16:34:13 +00:00
Mazdak Farrokhzad ef51c40b4c improve JwtClaims & AuthCtx docs 2025-10-24 18:08:26 +02:00
Julien Lavocat afb8c08b98 Docusaurus migration (#3343)
## Description of Changes

- Migrate the documentation site to **Docusaurus**.
- Add a **GitHub Action workflow** that runs `pnpm build` on pull
requests targeting `master`.
This command checks for broken links and images and ensures the site
builds correctly.
- Add a **GitHub Action workflow** to publish the docs automatically
when a merge occurs on the `docs/release` branch.

**Important**: The workflows haven't been tested yet due to the fact
that they need to be merged first before being able to run. It's a
fairly basic workflow I don't expect this to block anyone but anyways I
will make another PR with the complete changes when I can actually run
it.

---

## API and ABI Breaking Changes

No breaking changes for **SpacetimeDB** users.  
Documentation contributors should experience minimal disruption —
content is still written in Markdown.

---

## Expected Complexity Level and Risk

**Complexity:** 3/5

**Reasons:**
1. Several adjustments were made to fit Docusaurus conventions:
- Replaced our custom `:::server-rust` blocks with [Docusaurus `<Tabs/>`
components](https://docusaurus.io/docs/markdown-features/tabs).
- Converted “Note” callouts using
[admonitions](https://docusaurus.io/docs/markdown-features/admonitions)
instead of Markdown blockquotes.
- Updated all images (including Unity tutorial ones, which were
previously commented out).
- Moved images from the DO bucket into the repository at
`docs/static/images`.

2. Customized Docusaurus CSS and one component to apply our theme and
color palette.

---

## Testing

Tested locally.

---

## Review Notes

This PR involves many file changes — a full code review is likely not
productive.
Instead, please focus on verifying that the **documentation content**
was migrated correctly:

- Review sections you’re familiar with to confirm accuracy.
- Ensure formatting, links, and images render as expected.

You can follow the updated **README** for instructions on running
Docusaurus locally.

---------

Signed-off-by: Julien Lavocat <JulienLavocat@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: = <cloutiertyler@gmail.com>
2025-10-24 14:36:38 +00:00
Phoebe Goldman dcd8640543 Rust module bindings and macros for defining procedures (#3444)
# Description of Changes

This commit adds a macro attribute `#[procedure]` which applies to
functions, and various in-WASM machinery for defining, calling and
running procedures.

A simple example of a procedure, included in `modules/module-test`:

```rust
fn sleep_one_second(ctx: &mut ProcedureContext) {
    let prev_time = ctx.timestamp;
    let target = prev_time + Duration::from_secs(1);
    ctx.sleep_until(target);
    let new_time = ctx.timestamp;
    let actual_delta = new_time.duration_since(prev_time).unwrap();
    log::info!("Slept from {prev_time} to {new_time}, a total of {actual_delta:?}");
}
```

We intend eventually to make procedures be `async` functions (with the
trivial `now_or_never` executor from `future-util`), but I found that
making the types work for this was giving me a lot of trouble, and
decided to put it off in the interest of unblocking more parallelizable
work.

Host-side infrastructure for executing procedures is not included in
this commit. I have a prototype working, but cleaning it up for review
and merge will come a bit later.

One item of complexity in this PR is enabling scheduled tables to
specify either reducers or procedures, while still providing
compile-time diagnostics for ill-typed scheduled functions (as opposed
to publish-time). I had to rewrite the previous
`schedule_reducer_typecheck` into a more complex `schedule_typecheck`
with a trait `ExportFunctionForScheduledTable`, which takes a "tacit
trait parameter" encoding reducer-ness or procedure-ness, as described
in https://willcrichton.net/notes/defeating-coherence-rust/ .

The trait name `ExportFunctionForScheduledTable` is user-facing in the
sense that it will appear in compiler diagnostics in ill-typed modules.
As such, I am open to bikeshedding.

# API and ABI breaking changes

Adds a new user-facing API, which we intend to change before releasing.

# Expected complexity level and risk

2? Mostly pretty mechanical changes to macros and bindings.

# Testing

- [x] Added a procedure definition to `module-test`, saw that it
typechecks.
- [x] Executed same procedure definition using #3390 , the prototype
implementation this PR draws from.
2025-10-24 14:35:32 +00:00
Kim Altintop 0b16f8a3c4 core: Add more context to errors returned from host controller (#3449)
Namely, add replica id and database identity to the error context.


# Expected complexity level and risk

1

# Testing
2025-10-24 12:15:24 +00:00
Zeke Foppa 76f3368795 Remove unused release-fast profile (#3473)
# Description of Changes

Remove this custom build profile that was the same as `release`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

None

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-23 21:08:15 +00:00
Zeke Foppa f726b02c74 CI - C# quickstart test properly uses nuget (#3466)
# Description of Changes

The quickstart smoketest was not correctly fudging our NuGet
dependencies to use the local versions of the packages, so it was
pulling them from NuGet. This ended up causing issues when we tried to
modify local packages and then use them in a way that affected the
quickstart (e.g.
https://github.com/clockworklabs/SpacetimeDB/pull/3386).

We had a few issues: we weren't ensuring that the local packages were
built, we weren't using the right directory for those packages, and we
weren't adding a "package source mapping" that forced those packages to
be used from the local directory.

# API and ABI breaking changes

None. CI-only.

# Expected complexity level and risk

2

# Testing

- [x] CI passes when
https://github.com/clockworklabs/SpacetimeDB/pull/3386 is merged
together with this PR (it wasn't before).

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-23 19:50:18 +00:00
joshua-spacetime f8631cc749 Remove connection_id from ViewContext (#3464)
# Description of Changes

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

Removing `connection_id` from `ViewContext` for performance reasons. We
intend to wait to hear from clients before assuming that it's necessary
to include.

# API and ABI breaking changes

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

None (unreleased feature)

# Expected complexity level and risk

<!--
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. -->

0

# 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! -->

n/a
2025-10-23 18:43:35 +00:00
Noa ddfdde2b0f Update to pgwire 0.34.2 (#3451)
# Description of Changes

This is primarily to get their fixes for the tls negotiation deadloop
that we were experiencing.

[This is the
diff](https://github.com/sunng87/pgwire/compare/v0.32.1...v0.34.1) of
changes between 0.32.1 and 0.34.1.

# API and ABI breaking changes

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

# Expected complexity level and risk

2? This was something we discussed wanting to do. It's a change to an
important dependency, but we know it comes with stuff we want.

# 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! -->
n/a - problem not in this repo.
- [ ] <!-- 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-10-23 18:30:45 +00:00
Mazdak Farrokhzad 457ae18ae2 util::jobs: add commentary + use .expect(..) (#3468)
# Description of Changes

1. Add more commentary to `jobs.rs`
2. Use `.expect(...)` more in `jobs.rs`

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Covered by existing tests.
2025-10-23 14:59:02 +00:00
Shubham Mishra 5ad2dcff21 fix migration which adds column and index together. (#3450)
# Description of Changes

`auto_migrate_database` should not take table schema as input because
each step is ordered and may depend on changes made by a prior step,
this approach can lead to incorrect assumptions (e.g., adding a column
changes its table id).

Migration steps now retrieve the current table schema when they run.
This adds a small performance cost, but it simplifies the logic and code
is not under hotpath.

fixes #3441 

# API and ABI breaking changes
NA

# Expected complexity level and risk
1

# Testing
Update smoketest to add failed case.

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
2025-10-23 07:04:00 +00:00
Mazdak Farrokhzad 0b07bffa8a V8: Let a worker thread own the isolate (#3401)
# Description of Changes

1. Moves work of `JsInstance` to a worker thread to avoid re-making the
isolate all the time.
2. Does some minor refactoring.
3. Deals with `JsInstanceEnv` being potentially unset.

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

# API and ABI breaking changes

None

# Expected complexity level and risk

3

# Testing

Should be covered by exiting tests.
2025-10-22 22:39:38 +00:00
Noa dd9499132b [TS] Fix ctx.timestamp serialization (#3461)
# Description of Changes

Resolves #3433. The issue was caused by the fact we were calling
`serialize_to_js` with a full `Timestamp` struct, not just an `i64`. In
the future I'd like to move away from the use of `serialize_to_js` to
avoid problems like this.

# API and ABI breaking changes

Technically a breaking change, but fixes a bug.

# Expected complexity level and risk

1

# 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] Checked to ensure `ctx.timestamp` is correct.
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
2025-10-22 21:36:22 +00:00
joshua-spacetime 0d325b2dcc Add macro bindings for views (#3429)
# Description of Changes

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

Adds the `#[view]` procedural macro and module describers for views.
```rust
#[view(public)]
fn player(ctx: &ViewContext) -> Vec<Player> {
    ctx.db.player().identity().find(ctx.sender).into_iter().collect()
}

#[view(public)]
fn player(ctx: &AnonymousViewContext, level: u32) -> Vec<Player> {
    ctx.db.player().level().filter(level).collect()
}
```

Note, this deviates from the proposal in that views may only return
`Vec<T>` or `Option<T>`. They can't return an arbitrary `SpacetimeType`.

# API and ABI breaking changes

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

This technically isn't a breaking change, but it's worth mentioning that
this patch refactors `ReducerInfo` so that we can use it for views as
well.

# Expected complexity level and risk

<!--
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. -->

2

# 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] Negative compile tests
- [x] Negative publish (module validation) tests
- [x] Test system tables are updated accurately
2025-10-22 20:23:48 +00:00
Zeke Foppa f8b66a913e Remove unused docker-compose files (#3455)
# Description of Changes

These files don't seem to be used anywhere.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Existing CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-22 16:57:38 +00:00
Jeffrey Dallatezza 39a03b4a67 Add typescript bindings for auth claims. (#3442)
# Description of Changes

This adds an `AuthCtx` for typescript modules.

# API and ABI breaking changes

This adds a function to the typescript ABI.

# Expected complexity level and risk

1.5.

# Testing

I tested with by linking with this for a local typescript module.
2025-10-22 15:42:39 +00:00
Ning Sun d205795553 feat: update pgwire to 0.34 and improve how we disable ssl (#3432)
# Description of Changes

Hello team, I'm the original author of pgwire library. In this patch, I
have some updates about spacetimedb's usage of pgwire library:

- Updated pgwire library to 0.34, which includes a critical fix for busy
loop on accepting new connection
- This version will return error on no-op handlers, as requested by
@mamcx
- Update `StartupHandler` for `SslRequest`. `SslRequest` is handled in
`process_socket` automatically before `StartupHandler` kicks in. So it's
safe to remove the match branch. The framework will reject TLS
negotiation automatically if no TLS support compiled
- Updated feature flags. Add `no-default-features` so we will not pull
TLS dependencies.

# API and ABI breaking changes

N/A

# Expected complexity level and risk

1

# Testing

Would be nice to verify if you have integration test on postgres
interface.

---------

Co-authored-by: Mario Montoya <mamcx@elmalabarista.com>
2025-10-21 23:06:52 +00:00
Zeke Foppa 0f0cb47d03 CI - Move Internal Tests to GitHub (#3436)
# Description of Changes

Move a version of the Jenkins logic into a GitHub workflow. See the
linked issue for more context.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

2

# Testing

- [x] Tests currently passing on this PR
- [x] Tests fail with appropriate error if made to fail, e.g. version
bump
(https://github.com/clockworklabs/SpacetimeDB/actions/runs/18666569784/job/53219039721)
- [x] If the timeout is sharply reduced, we get an appropriate timeout
message
(https://github.com/clockworklabs/SpacetimeDB/actions/runs/18693760959/job/53305759272?pr=3436)

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-21 19:33:17 +00:00
Zeke Foppa 9195d827b6 gitignore node_modules even when it's a symlink (#3446)
# Description of Changes

Just a gitignore tweak.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] `git` is no longer trying to commit my `node_modules` symlink

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-21 19:25:45 +00:00
Jeffrey Dallatezza bf37b2947b Add bindings for csharp modules to use JWT claims (#3414)
# Description of Changes

This exposes JWT claims for csharp modules, similar to how they are
exposed to rust modules in
https://github.com/clockworklabs/SpacetimeDB/pull/3288.

This adds the new types `AuthCtx` and `JwtClaims`, and adds an `AuthCtx`
to the `ReducerContext`.

`AuthCtx` represents the credentials associated with the request, and
`JwtClaims` represents a jwt token.

One difference from the rust version is that I didn't create helpers to
build an `AuthCtx` from a jwt payload. The reason is that we would need
to be able to compute the identity from the payload claims, which
requires a blake3 hash implementation. The first two c# libraries I
found had issues at runtime
([Blake3](https://www.nuget.org/packages/Blake3) is wrapping a rust
implementation, and
[HashifyNet](https://github.com/Deskasoft/HashifyNET/tree/main/HashifyNet/Algorithms/Blake3)
seems to be broken by our trimming because it uses reflection heavily).
I can look into taking the implementation from `HashifyNet`, since it is
MIT licensed, but I don't think we need to block merging on that.

# API and ABI breaking changes

This adds the new types `AuthCtx` and `JwtClaims`, and adds an `AuthCtx`
to the `ReducerContext`.

This also adds a csharp wrapper for the get_jwt ABI function added in
https://github.com/clockworklabs/SpacetimeDB/pull/3288.

# Expected complexity level and risk

2.

# Testing

This has a very minimal unit test of JwtClaims.

I manually tested using this locally with the csharp quickstart, and I
was able to print jwt tokens inside the module.
2025-10-21 19:17:33 +00:00
Zeke Foppa dac57e4a58 CI - Remove previews on discord posts for merged PRs (#3445)
# Description of Changes

The previews only work for public repos, meaning that the posts end up
looking inconsistent. I don't believe the previews add much information
anyway. _If_ there's information in there that we want, we should add it
to the post itself.

# API and ABI breaking changes

No.

# Expected complexity level and risk

1

# Testing

None. We'll see when it merges!

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-21 18:20:47 +00:00
joshua-spacetime c724a4e35d add rust-src to the toolchain and update trybuild test output (#3440)
# Description of Changes

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

Adds `rust-src` to the toolchain and updates the expected output of the
`trybuild` tests.

`rust-src` places the entire source code of the rust stdlib under the
local toolchain directory. `rust-analyzer` uses it for "go to
definition" (among other things) in the stdlib. When included in the
toolchain, rustc can provide code frames that it can't otherwise.

The reason for its addition is that if anyone includes it in their local
toolchain, the error messages produced by rustc when running the `ui`
tests will be slightly different (have some more information) than when
run in CI. Hence those tests will fail locally but not in CI. Rather
than removing `rust-src` locally so that the tests will pass, I've opted
to just add it to the toolchain so that everyone runs with it by
default, including in CI.

# 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

<!--
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. -->

0

# 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] Updated rustc tests
2025-10-21 02:03:07 +00:00
Mazdak Farrokhzad 5ec2cc38e5 V8: prepare for JS workers (#3395)
# Description of Changes

This PR refactors various things in preparation for adding JS workers.
The changes are useful on their own without said workers and they are
also their own PR for ease of review.

1. Move all budget/timeout/energy/log-long-running logic to its own
module.
2. Extract some functions.
3. `register_hooks` now validates early that `__call_reducer__` and
`__describe_module__` exist and are functions. Validation beyond this is
not possible with V8.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Mostly covered by existing tests...
Also, future work.
2025-10-21 00:54:50 +00:00
joshua-spacetime 8d1298b76d Add module def types for views (#3427)
# Description of Changes

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

Adds type definitions for `RawViewDefV9` and `ViewDef`. Also validates
these module defs and populates the system tables:
- `st_table`
- `st_column`
- `st_view`
- `st_view_param`
- `st_view_column`

# 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

<!--
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. -->

2

# 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! -->

Integration tests to follow when views are added to
`__describe_module__`

---------

Signed-off-by: joshua-spacetime <josh@clockworklabs.io>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-10-20 21:48:05 +00:00
Tyler Cloutier 3309404c1b Fixed the react router issue and added a new test app to test for it (#3428)
# Description of Changes

This PR fixes https://github.com/clockworklabs/SpacetimeDB/issues/3359.
Additionally I have add a new test app to test for this issue and I
changed a perl script to be portable on windows.

The issue was that `useTable` had it's own `isActive` state that it was
incorrectly maintaining, when it should just have been using the
connections `isActive` state directly.

This fixes a critical bug and should be pushed ASAP.

# API and ABI breaking changes

None, fixes a critical bug.

# Expected complexity level and risk

2, quite straightforward fix after figuring it out.

# Testing

- [x] I added a test app and tested the fix in my browser.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-20 21:23:53 +00:00
Phoebe Goldman ab3554576b Add a nix flake (#3422)
# Description of Changes

Recently, my hacked-together env stopped working, probably due to our
switching linkers. This pushed me to write a proper Nix packaging for
SpacetimeDB, complete with flake and development environment.

Some things I haven't been able to figure out (or in some cases, just
haven't bothered with):

- Unreal.
- C# WASI SDK.
- Exposing Git commit hash for `spacetime --version`.
- Making the Rust SDK's reauth test work. This test tries to write a
file in the home directory, which is inaccessible in the Nix sandbox.

# API and ABI breaking changes


It's a new thing we have to maintain if we're exposing it to users, but
I need to maintain it anyways to be able to develop Spacetime, so...

# Expected complexity level and risk

1

# Testing

- [x] Ran `nix flake check` locally.
- [x] Ran `nix build` locally and then did `spacetime start`, got an
apparently-responsive SpacetimeDB.
- [x] Ran `nix develop` locally, then `cargo build` and `cargo test` in
the dev shell.

---------

Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2025-10-20 17:44:50 +00:00
Zeke Foppa 1b3545361d Weaken minimum dotnet version (#3418)
# Description of Changes

Relax the patch version requirement in `global.json`, because `8.0.400`
isn't available on Linux.

# API and ABI breaking changes

No.

# Expected complexity level and risk

1

# Testing

I've been using this modification for a long time and we've never had
people complain about bad C# DLLs or anything.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-20 17:17:36 +00:00
Tyler Cloutier 6a94092032 Initial TypeScript reference docs (#3407)
# Description of Changes

This PR adds a new TypeScript reference doc at
`/docs/modules/typescript`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1, just docs

# Testing

- [ ] I have carefully reviewed the changes and believe that all code
represented here should compile.

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-10-20 16:41:59 +00:00
Jeffrey Dallatezza dbc49b1fd6 Add AuthCtx to ReducerContext for rust (#3288)
# Description of Changes

This exposes client credentials in reducer calls for rust.

# API and ABI breaking changes

API Changes:

The main API change is the addition of `AuthCtx` and the `sender_auth`
in `ReducerContext`. This also adds JwtClaims, which has some helpers
for getting commonly used claims.

ABI Changes:

This adds one new functions `get_jwt`. This uses
`st_connection_credentials` to look up the credentials associated with a
connection id.

This adds ABI version 10.2.

# Expected complexity level and risk

2. This adds new ABI functions

# Testing

I've done some manual testing with modified versions of the quickstart.
We should add some examples that use the new API.
2025-10-17 21:03:54 +00:00
joshua-spacetime 542d26d7ff add system tables for views (#3419)
# Description of Changes

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

This patch defines the system table schemas for views and allocates IDs
for them. It **does not** populate these tables.

# 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

<!--
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. -->

1

# 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! -->

Tests will be added in the patch that populates these tables
2025-10-17 19:01:22 +00:00
Zeke Foppa 0d2a0edd0c Fix CLI package._json version (#3423)
# Description of Changes

We didn't fix this after merging the 1.6.0 version bump into the
TypeScript PR.

I had originally fixed this in the release branch, but that patch got
lost once I recreated the branch, so we should release an updated CLI
(probably just update the existing GH release).

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Existing CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-10-17 17:27:46 +00:00
Phoebe Goldman 0a6aa7c5d9 ModuleDef and schema changes to support procedures (#3392)
# Description of Changes

This commit extends various schema and schema-adjacent structures to
describe procedures, a new kind of database function which are allowed
to perform side effects.

This includes extending `RawModuleDefV9` with a way to register
`RawProcedureDefV9`s in the `misc_exports`, preserving compatibility
with modules that predate procedures.

The module validation path is reorganized somewhat to validate various
properties related to procedures while preserving code clarity and
maintainability.

Additionally, the `ArgsTuple` machinery for ser/de-ing reducer arguments
using the argument type as a seed is extended to also support procedure
arguments.

All of this is currently unused.

# API and ABI breaking changes

Additive and backwards-compatible additions to `RawModuleDefV9` and
friends.

# Expected complexity level and risk

2 - some minor complexity in schema validation which may have gotten
borked in a merge at some point.

# Testing

Unsure what tests would be useful, open to suggestions from reviewers.

- [ ] <!-- 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-10-17 17:22:14 +00:00
Tyler Cloutier c2439ceb8a Fixed a circular import that was not detected in the TypeScript SDK (#3421)
# Description of Changes

Alessandro ran into a stack overflow trying to use the TypeScript SDK
from Remix (Node.js). We debugged it to be a circular import of
`BinaryWriter` due to a barrel import. This fixes that issue.

# API and ABI breaking changes

This is technically an API breaking change because anyone who was
importing `BinaryWriter` or `BinaryReader` from `spacetimedb/sdk` will
now have to import it from `spacetimedb` or `spacetimedb/lib`.

# Expected complexity level and risk

1

# 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] Alessandro and I have tested this change.
2025-10-17 16:49:54 +00:00
Noa bf177c534b Fix windows linker errors (#3416)
# Description of Changes

My guess as to the problem was that there were static libs in the
dependency graph that were wanting to statically link to libc functions,
but rustc didn't know we wanted to link libc statically - so adding
`+crt-static` fixes it.

# API and ABI breaking changes

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

# 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

<!-- 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] Builds successfully on windows now.
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
2025-10-16 22:47:46 +00:00
Mazdak Farrokhzad a02d8ba8f0 Notify user in CLI that js/ts is beta quality (#3415)
# Description of Changes

Notify user in CLI that js/ts is beta quality.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

N/A
2025-10-16 16:26:13 +00:00
Noa bb43213245 Typescript module API (#3327)
# Description of Changes

Currently based on #3361 

Implements most of the TS module API (not yet a function for type
aliases).

# Expected complexity level and risk

<!--
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] Extremely basic module stuff works
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->

---------

Signed-off-by: Noa <coolreader18@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-16 14:58:50 +00:00
Zeke Foppa d4837c37ab Bump versions to 1.6.0 (#3413)
# Description of Changes

Bumping versions to 1.6.0 in preparation for upcoming release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1
# Testing

- [x] Existing CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-16 01:26:35 +00:00
samuel.engstrom@arvikasoft.se 3075ca4fba Add forgotten variance to table_index::can_merge (#3391)
TableIndex merge logic to was missing  variants.

# Description of Changes

This pull request fixes an issue where the TableIndex::can_merge
function was missing match variants.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1 / 5 (Trivial)
This is a very low-risk change. It simply adds a few lines to a match
statement

# Testing

Manual testing confirm that creating two tables with indices with the
for the missing variants no longer causes a panic.
2025-10-15 17:05:54 +00:00