Commit Graph

1992 Commits

Author SHA1 Message Date
clockwork-labs-bot cd88bebaf0 Bump HTTP procedure timeouts (500ms/10s → 30s/180s) and fix docs (#4630)
Relates to #4608

## Timeout bump

The previous defaults for HTTP requests in procedures were far too
restrictive:

| | Before | After |
|---|---|---|
| Default (no timeout set) | 500ms | **30s** |
| Maximum (clamp ceiling) | 10s | **180s** |

Users are hitting the 10s ceiling when calling LLM APIs (OpenAI, Gemini,
etc.) from procedures. These APIs routinely take 30-120 seconds,
especially for image/vision models. The 500ms default also caused silent
failures for users who did not explicitly set a timeout.

### Comparable platforms
- **Supabase Edge Functions**: 150s (free) / 400s (pro) total execution
- **Vercel Functions**: 10s (hobby) / 60s (pro) / 300s (enterprise)
total
- **Convex actions**: 120s limit
- **AWS Lambda**: up to 15 min total
- **Firebase/GCF**: 60s default, configurable up to 540s

Most platforms do not separately clamp outbound HTTP timeouts at all.

## Docs fix

The procedures docs page had a note inside the C++ tab only that said
`All timeouts are clamped to a maximum of 500ms by the host`. This was
wrong (the max was 10s, not 500ms) and buried in the wrong place
(applies to all languages, not just C++).

Moved the note outside the language tabs and updated the values to match
the new code.

### Changes
- `crates/core/src/host/instance_env.rs`: `HTTP_DEFAULT_TIMEOUT` 500ms →
30s, `HTTP_MAX_TIMEOUT` 10s → 180s
- `docs/.../procedures.md`: Fix and relocate timeout note

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-13 07:05:42 +00:00
joshua-spacetime a39b81b087 [C#] Primary keys for query builder views (#4626)
# Description of Changes

Same change set as
https://github.com/clockworklabs/SpacetimeDB/pull/4614, just targeting
master.

The return type of a query builder view is now a special SATS product
type `{ __query__: T }`. A view with this return type now has a primary
key if `T` has a primary key. This means that client codegen will
generate an `OnUpdate` callback for such views. It will also generate
query builder index bindings for the primary key column.

# API and ABI breaking changes

None. Old modules with query builder views still work, they just don't
have primary keys.

# Expected complexity level and risk

2

# Testing

Added equivalent tests to the ones that were added in #4573 and #4572.
2026-03-13 00:57:50 +00:00
John Detter cf06f8ad3c Version bump to 2.0.5 (#4623)
# Description of Changes

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

- Bumps version to 2.0.5

# API and ABI breaking changes

None - this is just a version bump

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

# Expected complexity level and risk

1 - just a version bump

<!--
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] License file has been properly updated, including the date change
- [x] CI is passing other than the internal check
2026-03-12 21:03:37 +00:00
Kim Altintop 24a66587d8 core: Attempt to repair databases with wrong host type (#4619)
Prior to #4549 the host type in `st_module` was always set to wasm. We
now correctly use the host type from the database, but the module may in
fact be a JS module. So if launching it as a wasm module fails, try JS
instead. If this succeeds, the module is definitely a JS module, so
attempt to repair `st_module` in this case.

# Expected complexity level and risk

2

# Testing

- [x] Added smoketest
2026-03-12 10:25:26 +00:00
Simon Gellis 18d4fbc320 Upgrade prometheus to 0.14.0 (#4598)
# Description of Changes

Upgrades the rust SDK's prometheus dependency from 0.13 to 0.14.

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

# API and ABI breaking changes

[The prometheus
changelog](https://github.com/tikv/rust-prometheus/blob/master/CHANGELOG.md#0140)
claims that the MSRV for the new version is 1.82, but this project
doesn't seem to have an official MSRV, so I don't think that's an ABI
change.

I don't think depending on a different prometheus version is itself a
breaking change. Prometheus is exposed through the rust SDK, but in an
explicitly [unstable
module](https://github.com/clockworklabs/SpacetimeDB/blob/3f58b5951bf3c49971c51aecb526439597b9c044/sdks/rust/src/lib.rs#L69-L76)
which "may change incompatibly without a major version bump". Prometheus
structs are also exposed from several crates, but with the same
disclaimers about unstable interfaces.

# Expected complexity level and risk

1. This is a module bump with simple-looking changes.

# Testing

- [x] Just confirmed everything still compiles and the tests still pass

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-11 21:58:35 +00:00
Allen Ray 7a7860dcdf Export Range/Bound from the spacetimedb/server in the Typescript sdk (#4567)
# Description of Changes

This change exports the Range (and Bound) types so that ranged filtering
can be done from Typescript modules. I chose to do export * so that both
Range and Bounds are included and I chose to not export as types since
the user will need to instantiate a Range for use in a query

# API and ABI breaking changes

None

# Expected complexity level and risk

1
It seems like this export was just missed as the [documentation for
range
queries](https://spacetimedb.com/docs/tables/indexes/#range-queries)
makes reference to them, but I was unable to import them as it
recommends (or at all)

# Testing

At the time of writing, I haven't tested the fix yet, I'll see if I can
get a local copy of spacetime built and validate I can now imports
Ranges.

---------

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-11 21:54:11 +00:00
Phoebe Goldman 6882232108 Add a mode to the Rust SDK with additional logging to a file (#4566)
# Description of Changes

In the Rust client SDK, with this PR, doing
`.with_debug_to_file("path.txt")` on the connection builder will result
in the SDK logging additional verbose info to `path.txt`.

# API and ABI breaking changes

Adds a new user-facing-ish API to the Rust client SDK.

# Expected complexity level and risk

2? Some possibility of deadlock due to adding a new mutex, but this is
explicitly not for production use.

# Testing

- [x] Ran `chat-console-rs` locally with this enabled and got some debug
logs out of it.
2026-03-11 20:28:08 +00:00
joshua-spacetime 408e54fd3b Fix disconnects breaking view updates for other connections (#4607)
# Description of Changes

Fixes a bug in client disconnect logic that would mark a client's views
as dropped(unsubscribed). However it was marking the identity's views as
dropped, not the connection. So if an identity had multiple connections
open, each subscribing to different views, and one of them disconnected,
the subscriptions for the other connections would break. The observed
behavior would be that they would stop receiving subscription updates.
This could potentially lead to their client cache getting into a
corrupted state.

Now, instead of dropping all of the views for a particular identity on
disconnect, we drop only the views for that particular connection. And
when I say drop, what I really mean is decrement. A view is not dropped
completely unless it no longer had any subscribers.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Regression smoketest was added
2026-03-11 15:17:31 +00:00
joshua-spacetime 6eaf06b6b5 [Rust] Primary keys for query builder views (#4572)
# Description of Changes

Query builder views return a subset of rows from a physical table. If
that table has a primary key, then so should the view. What this means
concretely is that the view should expose the same api as the table,
specifically as it relates to the primary key column.

With that in mind, this patch commits the following changes:
1. Annotates `ViewDef` with a `primary_key`
2. Updates the return type of query builder views in the raw module def
to a special product type
3. Adds an index for the primary key on the view's backing table
4. Updates the query planner to use this index
5. Updates rust client codegen to generate `on_update` for such views

# API and ABI breaking changes

None

Old `impl Query` views compiled with an older version of SpacetimeDB
will continue to work as they did before - without a primary key.

# Expected complexity level and risk

3

# Testing

- [x] New rust sdk integration suite exercising `on_update` for PK views
and semijoin scenarios
- [x] Smoketests for PK views and semijoin scenarios
2026-03-11 13:00:43 +00:00
joshua-spacetime f160d30601 Better error message for semijoin predicates (#4605)
# Description of Changes

`and` and `or` are scoped to only a single table. So using them in a
semijoin with two tables will fail to compile. Previously this resulted
in a gnarly error message (see #4586). This patch improves the error
message.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Adds error message assertion tests.
2026-03-11 01:00:56 +00:00
clockwork-labs-bot c7ef2346a2 Fix Bool deserialized as number in TS SDK fast path (#4596)
Fixes #4591

## Root Cause

The `isFixedSizeProduct` fast-path deserializer in `algebraic_type.ts`
maps `Bool` to `view.getUint8()`, which returns a **number** (0 or 1)
instead of a JavaScript **boolean**. The slow path (`reader.readBool()`)
correctly converts via `!== 0`.

This means any product type containing only fixed-size primitives
(bools, ints, floats) hits the fast path and returns numbers for boolean
fields. Products containing strings, arrays, or nested objects go
through the slow path and work correctly.

This explains the inconsistency in the issue: a flat `{ foo: bool }`
returns `{ foo: 1 }`, but adding a nested object pushes it to the slow
path where `foo` becomes `true` (though the nested bool still hits the
fast path within its own product).

## Fix

Special-case `Bool` in the fast-path code generation to emit:
```js
result.foo = view.getUint8(reader.offset) !== 0;
```
instead of:
```js
result.foo = view.getUint8(reader.offset);
```

One-line change in the ternary within `makeDeserializer`.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-10 20:51:25 +00:00
John Detter 354dd45499 Version bump 2.0.4 (#4600)
# Description of Changes

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

- Bumps version to 2.0.4

# API and ABI breaking changes

None - this is just a version bump

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

# Expected complexity level and risk

1 - this is just a version bump

<!--
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] License file has been updated with correct version + time

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-10 18:37:47 +00:00
Zeke Foppa 6d9cf691f2 CI - rustfmt instead of cargo fmt (#4595)
# Description of Changes

`cargo ci lint` was running `cargo fmt`, but that didn't pick up all
files. As a result, our pre-commit hook (which just runs `rustfmt` on
any changed `.rs` files) would change otherwise-untouched files in merge
commits.

This PR addresses that discrepancy by having `cargo ci lint` run
`rustfmt` on all tracked `.rs` files.

The entire diff is just `rustfmt` changes except for the changes in
`tools/ci/src/main.rs`.

# 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

# Testing

- [x] `cargo ci lint` fails
- [x] `cargo ci lint` passes after running `rustfmt` on everything
- [x] `cargo fmt --all` doesn't cause any diff after doing the above

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-03-10 05:58:54 +00:00
Kim Altintop b391d7333d Persist host type update and honor stored value after restart (#4549)
Fixes two issues that would prevent updating a database while also
changing the host type:

- We never actually updated the `ModuleKind` in `st_module` (hardcoded
to wasm)
- We never actually honored the value from `st_module` when
instantiating a module

To do so, the `Program` type from the datastore crate now carries the
`ModuleKind`, forcing call sites to make a decision.

Small adjustments to the smoketests / guard crate where made when
writing the test for this.

# Expected complexity level and risk

1

# Testing

- [x] Added smoketest
2026-03-07 22:00:59 +00:00
clockwork-labs-bot c5fa5d6fe7 Fix spacetime login --token falling through to web login (#4579)
## Bug

PR #4367 (login/logout UX overhaul) accidentally removed the early
`return Ok(())` after saving a token via `spacetime login --token`. This
caused the command to fall through into the web login flow
(`spacetimedb_login_and_save`), which fails when no browser or server is
available.

## Impact

All tests that use `spacetime login --token` are broken:
- 4 replication tests (`test_enable_disable_replication`,
`test_enable_replication_on_suspended_database`,
`test_enable_replication_fails_if_not_suspended`, `test_prefer_leader`)
- 5 teams tests (`test_permissions_clear_org`,
`test_permissions_delete_org`,
`test_org_permissions_mut_sql_org_members`,
`test_org_permissions_private_tables`,
`test_permissions_publish_org_members`)

## Fix

One line: restore `return Ok(())` after the `--token` branch.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-07 06:06:38 +00:00
clockwork-labs-bot 78c8acd0c9 Improve login/logout CLI UX (#4367)
## Summary

Improves the `spacetime login` and `spacetime logout` UX to behave more
like standard CLI tools.

### `spacetime login`

**Before:** If already logged in, prints "You are already logged in" and
exits. User must manually run `logout` first.

**After:** If already logged in, automatically logs out the previous
session and proceeds with a fresh login. Prints the old identity being
logged out and the new identity on success.

```
$ spacetime login
Logged out of previous session (identity 0xabc...).
Opening https://spacetimedb.com/login/cli?token=... in your browser.
Waiting to hear response from the server...
Logged in with identity 0xdef...
```

### `spacetime logout`

**Before:** No output on success. Hard failure if offline.

**After:**
- Prints confirmation: `Logged out (identity 0xabc...).`
- Prints `You are not logged in.` if already logged out
- Best-effort server-side session invalidation with 5s timeout (prints
warning if offline instead of failing)

### Changes

- `login.rs`: Remove `spacetimedb_token_cached` early-return; instead
log out previous session and proceed. Show identity on login success.
- `logout.rs`: Add identity display, not-logged-in check, 5s timeout for
server call with warning on failure.

Note: This subsumes the offline fix from #4361.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-06 00:23:09 +00:00
clockwork-labs-bot 5404126aba CLI - Notify users if there's an update available (#4363)
## Summary

Adds a version update check to the `spacetimedb-update` proxy, so users
are notified when a newer version of SpacetimeDB is available.

## Changes

Adds `crates/update/src/update_notice.rs` — a lightweight update check
that runs in the proxy path before exec'ing the CLI:

- **Cache-based**: Stores the last check result in
`~/.spacetime/.update_check_cache`. Only hits the network once every 24
hours.
- **Non-blocking on cache hit**: If the cache is fresh, it's a single
file read — no network, no delay.
- **Short timeout**: When the cache is stale, makes a single HTTP
request to GitHub releases API with a 5-second timeout. Uses the same
`SPACETIME_UPDATE_RELEASES_URL` env var as `spacetime version upgrade`.
- **Best-effort**: Any failure (network, parse, file I/O) is silently
ignored. The update check never interferes with the user's command.
- **Uses semver**: Proper version comparison via the `semver` crate
(already a dependency).

## Output

When a newer version is available:
```
A new version of SpacetimeDB is available: v2.1.0 (current: v2.0.0)
Run `spacetime version upgrade` to update.
```

# Testing
- [x] I get a warning if my local version is less than 2.0.2
- [x] If I have a cached update check, I get the same error even if I
have no network connection
- [x] if the cache is old, the next command checks again
- [x] if I'm not connected and the cache is stale, I'm still able to use
the CLI

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-05 22:20:57 +00:00
Shiven Garia af6d0df06c Fix typos in comments and doc comments across crates (#4560)
## Summary
- Fix `Deerialize` → `Deserialize` in doc comments for `ser.rs` and
`typespace.rs` (these are in developer-facing trait documentation)
- Fix `thier` → `their`, `reinintializes` → `reinitializes`, `occurence`
→ `occurrence`, `secion` → `section` across 4 other crates

## Details
Six typo fixes across 6 files, no logic changes:

| File | Typo | Fix |
|------|------|-----|
| `crates/sats/src/ser.rs:280` | `Deerialize` | `Deserialize` |
| `crates/sats/src/typespace.rs:303` | `Deerialize` | `Deserialize` |
| `crates/table/src/table.rs:460` | `thier` | `their` |
| `crates/schema/tests/ensure_same_schema.rs:21` | `reinintializes` |
`reinitializes` |
| `crates/lib/src/http.rs:131` | `occurence` | `occurrence` |
| `crates/bindings/src/lib.rs:763` | `secion` | `section` |

## Test plan
- [ ] No logic changes — comments and doc comments only
- [ ] CI should pass without issues

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:12:38 +00:00
joshua-spacetime c5743cfc8d Add implicit query builder conversions from bool to BoolExpr (#4547)
# Description of Changes

Adds implicit query builder conversions from `bool` to `BoolExpr` so
that you can write:
```rust
ctx.from.user().r#where(|u| u.online)
```

instead of
```rust
ctx.from.user().r#where(|u| u.online.eq(true))
```

Also removes `NullableCol` and `NullableIxCol` types from C# query
builder.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Unit and smoketests
2026-03-05 07:14:08 +00:00
clockwork-labs-bot 476d15755e spacetime dev - Replace template selection with fuzzy-filterable menu (#4470)
This pull request updates the template system to support richer metadata
and improves the interactive CLI experience for selecting templates. The
main changes are the addition of a `client_framework` field to template
metadata, a refactor of the templates JSON generation and parsing, and a
redesign of the interactive template selection flow to group templates
by language/framework and use fuzzy search for easier navigation.

<img width="407" height="409" alt="image"
src="https://github.com/user-attachments/assets/d3548505-80e8-4778-8bfb-71d5e3fe31e9"
/>

**Template Metadata and Serialization Improvements:**

* Added a new `client_framework` field to all template metadata files
(e.g., `.template.json`) and updated the Rust structs (`TemplateInfo`,
`TemplateDefinition`, etc.) to support this field, enabling more
descriptive and flexible template selection.
[[1]](diffhunk://#diff-5438edbe7b41e3e0a1a62ce0ebde2a833a0441d76c6ffdf16093a3cff258f462R3)
[[2]](diffhunk://#diff-34a44755a07373e9c2872db87a64c3fd752cfee7d8d536045909daf861ea4728R3)
[[3]](diffhunk://#diff-a826c5a2eac977cff44022d72856ec4b1af176ffbb50697f22857e1e3d478aa1R3)
[[4]](diffhunk://#diff-7a21474fbc5bbbd989e89f32aa8dcc25fcc6fe4ac43d418c42b2b38603d21714R3)
[[5]](diffhunk://#diff-d8ee9fd0ef15ed23f0f7f38e556d789bdefc6c37dab67fbfccebc513b9da871cR3)
[[6]](diffhunk://#diff-7224fd4300f9c5af7834ff5989a76a399ce9117c28f5d7e2c1fbd6bdaf45be1bR3)
[[7]](diffhunk://#diff-8b015b0ce6339c444ef5ef4dc5e862275d98967e5c189da37b51bdaa58443606R3)
[[8]](diffhunk://#diff-89e32f7fc9fc42863998d7651bc7fa1fdfb352e8ac3ef45792e3f1374052c9ddR3)
[[9]](diffhunk://#diff-8259d300fda149c968a68989aec2bc2afa479aded649ac6b8d3c4b277f610542R3)
[[10]](diffhunk://#diff-bb8b9202e51fb7038efa2f2bb23872afa02caf71ab3a0fb7f513ca7822c1b8faR3)
[[11]](diffhunk://#diff-18497b72a2306fc2560475e2548cfe1b96b6206c395380437ba1fafefd66e126L199-R221)
[[12]](diffhunk://#diff-18497b72a2306fc2560475e2548cfe1b96b6206c395380437ba1fafefd66e126R279)
* Refactored the templates JSON generation to use `serde` for
serialization, replacing manual string building, and ensured that
optional string fields serialize as empty strings when not present.

**CLI Interactive Template Selection Redesign:**

* Removed the previous "highlights" concept and reworked the interactive
selection to group templates by language/framework combinations, showing
counts and using fuzzy search for easier filtering.
[[1]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL38-L48)
[[2]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL772-R833)
[[3]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL813-L850)
* Updated the selection menus to allow users to pick a
language/framework group, then choose from multiple templates if
available, or opt to clone from GitHub or select "None."
[[1]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL772-R833)
[[2]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL813-L850)
* Improved language label formatting for better user experience in the
CLI prompt.

**Codebase Cleanup and API Changes:**

* Removed unused highlight-related structs and logic from the CLI,
simplifying the template fetching API to return only templates.
[[1]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL38-L48)
[[2]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL198-R198)
* Updated all template selection logic to use the new API and data
structures.
[[1]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL683-R679)
[[2]](diffhunk://#diff-7fcfe09d0f54dde6b2fc0cb2b9ff02ab064add692f5602d6f627fe3840e282caL748-R744)

These changes make template selection more intuitive and scalable as
more templates and frameworks are added.

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-03-04 23:44:36 +00:00
clockwork-labs-bot e991421009 Wait for database to load before returning schema (#4551)
## Summary

When hitting `/v1/schema` while a database is still loading (replaying
the log, running init reducers, etc.), the endpoint returned a 500 error
because the module host was not yet available.

## Changes

- Add `Host::wait_for_module(timeout)` in `crates/client-api/src/lib.rs`
-- polls `get_module_host` with exponential backoff (100ms, 200ms,
400ms, 800ms, 1s, 1s, ...) up to the given timeout
- Update the `/v1/schema` route to use `wait_for_module(10s)` instead of
the immediate `module()` call

If the database finishes loading within 10 seconds, the schema is
returned normally. If it does not load in time, the existing 500 error
is returned (same behavior as before, just delayed).

No other routes are changed -- this is scoped to the schema endpoint per
the issue description. Other routes (SQL, call, etc.) could adopt the
same pattern if needed.

Fixes clockworklabs/SpacetimeDBPrivate#2748

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-04 16:55:48 +00:00
Phoebe Goldman 018575d1f9 Expose RawModuleDefV10 via the HTTP schema route (#4540)
# Description of Changes

Add `?version=10` as an option to
`/v1/database/:name-or-identity/schema`, where previously only
`?version=9` was supported. This seems to have been forgotten when we
introduced `RawModuleDefV10`.

Also, in an unrelated minor fixup, fix a copy-paste error in a doc
comment in the V2 WebSocket format definition.

# API and ABI breaking changes

Additive extension to HTTP API.

# Expected complexity level and risk

1

# Testing

- [x] Did a local get against this route and got a JSON-ified
`RawModuleDefV10`:

```bash
$ curl http://localhost:3000/v1/database/chat-console-rs/schema?version=10
{"sections":[{"Typespace":{"types":[{"Product":{"elements":[{"name":{"some":"sender"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__identity__"},"algebraic_type":{"U256":[]}}]}}},{"name":{"some":"sent"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__timestamp_micros_since_unix_epoch__"},"algebraic_type":{"I64":[]}}]}}},{"name":{"some":"text"},"algebraic_type":{"String":[]}}]}},{"Product":{"elements":[{"name":{"some":"identity"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__identity__"},"algebraic_type":{"U256":[]}}]}}},{"name":{"some":"name"},"algebraic_type":{"Sum":{"variants":[{"name":{"some":"some"},"algebraic_type":{"String":[]}},{"name":{"some":"none"},"algebraic_type":{"Product":{"elements":[]}}}]}}},{"name":{"some":"online"},"algebraic_type":{"Bool":[]}}]}}]}},{"Types":[{"source_name":{"scope":[],"source_name":"Message"},"ty":0,"custom_ordering":true},{"source_name":{"scope":[],"source_name":"User"},"ty":1,"custom_ordering":true}]},{"Tables":[{"source_name":"message","product_type_ref":0,"primary_key":[],"indexes":[],"constraints":[],"sequences":[],"table_type":{"User":[]},"table_access":{"Public":[]},"default_values":[],"is_event":false},{"source_name":"user","product_type_ref":1,"primary_key":[0],"indexes":[{"source_name":{"some":"user_identity_idx_btree"},"accessor_name":{"some":"identity"},"algorithm":{"BTree":[0]}}],"constraints":[{"source_name":{"some":"user_identity_key"},"data":{"Unique":{"columns":[0]}}}],"sequences":[],"table_type":{"User":[]},"table_access":{"Public":[]},"default_values":[],"is_event":false}]},{"Reducers":[{"source_name":"identity_connected","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"identity_disconnected","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"init","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"send_message","params":{"elements":[{"name":{"some":"text"},"algebraic_type":{"String":[]}}]},"visibility":{"ClientCallable":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"set_name","params":{"elements":[{"name":{"some":"name"},"algebraic_type":{"String":[]}}]},"visibility":{"ClientCallable":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}}]},{"LifeCycleReducers":[{"lifecycle_spec":{"Init":[]},"function_name":"init"},{"lifecycle_spec":{"OnConnect":[]},"function_name":"identity_connected"},{"lifecycle_spec":{"OnDisconnect":[]},"function_name":"identity_disconnected"}]},{"ExplicitNames":{"entries":[{"Table":{"source_name":"message","canonical_name":"message"}},{"Table":{"source_name":"user","canonical_name":"user"}},{"Function":{"source_name":"identity_connected","canonical_name":"identity_connected"}},{"Function":{"source_name":"identity_disconnected","canonical_name":"identity_disconnected"}},{"Function":{"source_name":"init","canonical_name":"init"}},{"Function":{"source_name":"send_message","canonical_name":"send_message"}},{"Function":{"source_name":"set_name","canonical_name":"set_name"}}]}}]}
```
2026-03-04 05:21:38 +00:00
Noa 0b30b16c2d Bring typescript benchmark client to parity with rust (#4494)
# Description of Changes

* Enable pipelining by default
  * Set defaults for `MAX_INFLIGHT_PER_WORKER` for spacetime and convex
* Add a warmup period
* Reduce allocations in sdk (not that much of an effect but still
improved things)

This gives improved parity with the rust client on my machine.

# Expected complexity level and risk

1

# Testing

- [x] Yup:
```
══════════════════════════════════════════════════════════════════════
      RESULTS
══════════════════════════════════════════════════════════════════════

spacetimedb ████████████████████████████████████████ 80,617 TPS
convex █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 235 TPS

      ╔════════════════════════════════════════════════════════════╗
      ║                                                            ║
      ║       🚀 spacetimedb is 343x FASTER than convex! 🚀        ║
      ║                                                            ║
      ╚════════════════════════════════════════════════════════════╝
    ```
2026-03-03 23:10:52 +00:00
joshua-spacetime 89fba42165 Make accessor required for table-level index defs in C# (#4541)
# Description of Changes

Make `Accessor` a required argument for table-level index defs in C# to
align with rust and typescript. The same change was done for typescript
in https://github.com/clockworklabs/SpacetimeDB/pull/4525.

# API and ABI breaking changes

Technically breaks the module api, although I believe this is the
behavior that is outlined in the spec, and so the current behavior
should really be considered a bug.

# Expected complexity level and risk

1

# Testing

Added negative compile tests
2026-03-03 23:06:19 +00:00
Noa 8cb2038f85 Fix 'unsafe attr without unsafe' error (#4534)
# Description of Changes

Followup to #3802; was causing issues in modules in private. Rust 2024
now requires `unsafe()` around certain attributes, but the `settings`
macro was added after I first opened that PR, so I didn't wrap it.
Additionally, `settings` wasn't tested in this repo, so it wasn't
caught.

# Expected complexity level and risk

1

# Testing

- [x] Added use of `#[spacetimedb::settings]` in `module-test`
2026-03-03 19:58:44 +00:00
clockwork-tien af732f5ede feat(tanstack): add SSR prefetching for Tanstack Start (#4519)
# Description of Changes
- Add SSR prefetching for Tanstack Start

Closes https://github.com/clockworklabs/SpacetimeDB/issues/4438

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

# 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] SSR prefetch works from testing
2026-03-03 15:09:07 +00:00
joshua-spacetime 33f3ea18e2 Make accessor required for table-level index defs in typescript (#4525)
# Description of Changes

This patch contains two main changes:

1. It makes `accessor` a required argument for table-level index defs in
typescript to align with rust.

2. It removes unsound index typing in the TypeScript bindings by
splitting index data into two explicit representations:

- `indexes`: declarative user config (`IndexOpts`) used for type
inference
- `resolvedIndexes`: normalized runtime metadata (`UntypedIndex`)
derived from `RawTableDefV10`

`TableCacheImpl` now builds index accessors from `resolvedIndexes`
instead of re-casting `indexes` at runtime.

    This addressed the following comment:
    ```
// TODO: horrible horrible horrible. we smuggle this
`Array<UntypedIndex>`
// by casting it to an `Array<IndexOpts>` as `TableToSchema` expects.
// This is then used in `TableCacheImpl.constructor` and who knows where
else.
    // We should stop lying about our types.
    ```

    > Why?

    We were conflating two different concepts under `tableDef.indexes`:

      1. declared table-level index options authored by users
2. resolved runtime index definitions (including field-level inferred
indexes)

This required unsafe casts (`T['idxs']` / `UntypedIndex`) and made the
type model unsound.

Note, (2) was largely ai assisted.

# API and ABI breaking changes

Technically breaks the module api, although I believe this is the
behavior that is outlined in the spec, and so the current behavior
should really be considered a bug.

# Expected complexity level and risk

2

# Testing

Added unit tests covering the following:
1. Table-level explicit index without accessor throws.
2. Table-level duplicate accessor throws.
3. Table-level explicit accessor is accepted and used.
4. Field-level `.index(...)` derives accessor from the field name
(`displayName`).
2026-03-03 15:09:05 +00:00
Kim Altintop 17cc15ef4c Append commit instead of individual transactions to commitlog (#4404)
Re-open #4140 (reverted in #4292).


The original patch was merged a bit too eagerly.
It should go in _after_ 2.0 is released with some confidence.
2026-03-03 15:08:05 +00:00
Noa e3582131fe Migrate to Rust 2024 (#3802)
# Description of Changes

It'd be best to review this commit-by-commit, and using
[difftastic](https://difftastic.wilfred.me.uk) to easily tell when
changes are minor in terms of syntax but a line based diff doesn't show
that.

# Expected complexity level and risk

3 - edition2024 does bring changes to drop order, which could cause
issues with locks, but I looked through [all of the warnings that
weren't fixed
automatically](https://gistcdn.githack.com/coolreader18/80485ae5c5f82de1784229cce2febb26/raw/ba80f3fecda66ceb34f4f7ad73b98ea02d4893a2/warnings.html)
and couldn't find any issues.

# Testing

n/a; internal code change
2026-03-03 11:06:52 +00:00
clockwork-tien 5836c268a7 fix: fix useSpacetimeDBQuery returns untyped rows for TanStack Start (#4488)
# Description of Changes
- Fix useSpacetimeDBQuery returns untyped rows for TanStack Start

Closes https://github.com/clockworklabs/SpacetimeDB/issues/4441

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

# 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

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

- [ ] <!-- 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. -->
2026-03-03 10:55:46 +00:00
clockwork-labs-bot 7470eb23d3 Add --level flag to spacetime logs for filtering by log level (#4362)
Fixes #1972

Adds client-side log level filtering to `spacetime logs`:

- `--level <LEVEL>` / `-l <LEVEL>`: Show only logs at the specified
severity or higher. Valid values: `trace`, `debug`, `info`, `warn`,
`error`, `panic`. Default: show all logs (no filtering).
- `--level-exact`: When combined with `--level`, show only logs at
exactly the specified level.

Severity order (most to least): panic > error > warn > info > debug >
trace.

Examples:
```
spacetime logs mydb --level warn                # Show only warn, error, and panic
spacetime logs mydb --level info                 # Show info and above
spacetime logs mydb --level error --level-exact  # Show only errors
```

Filtering is done client-side.

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-03-03 07:02:46 +00:00
Noa 9eb0506056 [TS] Fix toCamelCase (#4523)
# Description of Changes

Previously, it didn't uncapitalize the first character. This makes the
runtime behavior match with the typed behavior.

# Expected complexity level and risk

1

# Testing

- [x] Added a test for `toCamelCase`
2026-03-02 20:31:59 +00:00
John Detter 033c181337 Upgrade prompt is skipped when -y is passed (#4511)
# Description of Changes

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

This prompt is now skipped when `-y` is passed:

<img width="1053" height="530" alt="image"
src="https://github.com/user-attachments/assets/7237df85-4a12-4ab7-b377-95abbd0084c2"
/>

# API and ABI breaking changes

None

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

# Expected complexity level and risk

1 - this just skips a prompt in the CLI

<!--
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] publish a 1.0 database to maincloud, then upgrade it to 2.0 and
pass `-y`. You should no longer get the upgrade prompt.
- [x] publish a 1.0 database to maincloud, then upgrade it to 2.0
without passing `-y`. You should still get the upgrade prompt.
2026-03-02 18:28:29 +00:00
Shubham Mishra ab65b60fe4 fix index truncate edge cases (#4501)
# Description of Changes
Index offset `truncate` methods returns `IndexError::KeyNotFound` when
asked to truncate on empty index offset file or the key in input is
smaller than the first entry.

This was causing `commitlog::reset_to` method to return error, and stuck
replicas in re-spawn loop.

# API and ABI breaking changes
NA

# Expected complexity level and risk
1

# Testing
Added new tests to cover edge scenerios.
2026-03-02 07:31:14 +00:00
clockwork-labs-bot 0e0834a236 Fix useTable isReady stuck on false due to stale snapshot cache (#4499)
## Problem

`useTable` returns `[rows, isReady]` where `isReady` is always `false`,
even when data is present in `rows`.

## Root Cause

When subscription data arrives, `onInsert` events fire and call
`computeSnapshot()` while `subscribeApplied` is still `false`. This
caches `[rows, false]` in `lastSnapshotRef.current`.

When `onApplied` later fires and sets `subscribeApplied = true`,
`computeSnapshot` is recreated (it has `subscribeApplied` in its
dependency array), which recreates `getSnapshot`. However,
`getSnapshot()` checks `lastSnapshotRef.current` first -- since it is
non-null (cached from the earlier insert events), it returns the stale
`[rows, false]` tuple without recomputing.

If no further row changes happen after `onApplied` fires, `isReady`
stays `false` forever.

## Fix

Clear `lastSnapshotRef.current` whenever `computeSnapshot` changes, so
the next `getSnapshot()` call recomputes and returns `[rows, true]`.

Reported by a user in Discord.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-02 03:06:07 +00:00
Jason Larabie 14f79910ee Update C++ module bindings to RawModuleDefV10 (#4461)
# Description of Changes
- Migrated the C++ module-definition assembly path to V10-first
internals:
      - Added v10_builder and module_type_registration systems.
- Switched Module::__describe_module__ to serialize RawModuleDef with
V10 payload.
      - Updated macro registration pipeline to register through V10
- Added explicit naming support across macro surface (*_NAMED variants
for reducer/procedure/
        view and field/index macros).
- Reworked multi-column index macros (FIELD_MultiColumnIndex,
FIELD_MultiColumnIndex_NAMED) with
        migration alias.
- Added SPACETIMEDB_SETTING_CASE_CONVERSION(...) to support case
conversion policy
- Error-path hardening by adding explicit constraint-registration error
tracking and preinit validation
  - Codegen updates:
      - Updated C++ moduledef regen to V10 builder types.
- Adjusted C++ codegen duplicate-variant wrapper generation to emit
proper product-type
        wrappers.
  - Test/harness updates:
- type-isolation-test runner now defaults to focused V10 regression
checks; --v9 runs broader
        legacy/full suite.
      - Added focused modules for positive/negative V10 checks:
          - test_multicolumn_index_valid
          - error_multicolumn_missing_field
          - error_default_missing_field
- Re-enabled C++ paths in sdks/rust/tests/test.rs procedure/view/test
suites.

# API and ABI breaking changes

- Refactor of the underlying module definition
- New *_NAMED variant macros for explicit canonical naming
- FIELD_NamedMultiColumnIndex renamed to FIELD_MultiColumnIndex

# Expected complexity level and risk

3 - Large set of changes moving over to V10 with underlying changes to
make future updates a little easier

# Testing
- [x] Ran the type isolation test and expanded it
- [x] Ran the spacetimedb-sdk test framework to confirm no more drift
between C++ and other module languages
- [x] Ran Unreal test suite though not really applicable
- [x] New app creation with `spacetime init --template basic-cpp`
- [x] Ran describe module tests against Rust + C# matching with C++ on
the /modules/sdk-test* modules to find any possible mis-alignment

# Review
- [x] Another look at the new features with C++
- [x] Thoughts on *_NAMED macros, I couldn't come up with a better
solution with C++20
2026-02-28 07:05:50 +00:00
John Detter c29a44c50b Version upgrade 2.0.3 (#4489)
# Description of Changes

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

- Version upgrade 2.0.3

# API and ABI breaking changes

- None, this is a version bump

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

# Expected complexity level and risk

- 1 - this is a version bump

<!--
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] License has been updated
- [x] Version number is correct (2.0.3)
2026-02-27 20:24:22 +00:00
Ryan d87e49487b [C#] Improve error messages for Views (#4435)
This is the implementation of a fix for #4425

# Description of Changes

* Clarified C# generator diagnostics for view return types:
1. Updated the comments around `IQuery<T>` handling to describe the
return value as `T?`, matching C# semantics.
2. Adjusted the validation comment to say views must return `List<T>` or
nullable `T` instead of “Vec/Option”.
* Synced the diagnostics fixture comments with the new terminology so
STDB0024 examples talk about `List<T>`/`T?`.
* Checked current documentation for anything C# related to “Vec/Option”
and confirmed everything now references `List<T>`/`T?`.
* Regenerated/verified tests and snapshots.

# API and ABI breaking changes

None

# Expected complexity level and risk

1 - Changes are documentation and diagnostic-comment only.

# Testing

- [X] CLI rebuilt, local `dotnet test` pass and error output tests
validated.

---------

Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-02-27 01:46:39 +00:00
joshua-spacetime e8a2d33155 C# smoketest for IQuery views (#4391)
# Description of Changes

~~Updates Roslyn codegen to handle `IQuery` return type for views.~~

~~`IQuery` wasn't recognized before this change, which meant `.Build()`
was still required for query builder views.~~

~~Note, we currently support the old `Query` return type which means we
still support `.Build()`. I'm not sure if this was intended when
`IQuery` was originally introduced, so I'm maintaining support for it
until I can determine otherwise. cc @cloutiertyler.~~

This is now a test only change.

This patch introduces scaffolding for defining and running C# module
smoketests. It also adds a new C# smoketest for an`IQuery` view.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

A testing only change.
2026-02-26 23:06:33 +00:00
clockwork-labs-bot 9fbb322b0b CLI - preserve leading .. in --out-dir paths (#4431)
## Problem

`spacetime generate --out-dir ../frontend-ts-src/module-bindings` was
resolving the path incorrectly, stripping the leading `..` component.
Reported in #4429 via a [user report on
Discord](https://discord.com/channels/1037340874172014652/1475935288919462072/1475935288919462072).

## Root Cause

`normalize_path_lexical()` in `spacetime_config.rs` used
`PathBuf::pop()` to handle `..` components, but `pop()` is a no-op on an
empty `PathBuf`. This silently dropped leading `..` segments:

- Input: `../frontend-ts-src/module-bindings`
- Output: `frontend-ts-src/module-bindings` (wrong — `..` was eaten)

## Fix

Replace the `PathBuf`-based normalization with a `Vec<Component>` stack
approach. `..` only cancels a preceding `Normal` component; otherwise it
is preserved. This correctly handles:

- `../foo` → `../foo` (leading `..` preserved)
- `../../a/b` → `../../a/b` (multiple leading `..` preserved)
- `a/b/../c` → `a/c` (inner `..` still resolves)
- `/home/user/project/../foo` → `/home/user/foo` (absolute paths work)

## Testing

Added `test_normalize_path_preserves_leading_dotdot` covering all edge
cases.

Closes #4429

---------

Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-02-26 19:54:20 +00:00
Piotr Sarnacki ad26525880 Fix publishing in directories with spaces (#4453)
# Description of Changes

The publish subcommand calls the build subcommand internally. The
build's implementation used to split the arguments by space, which
breaks when a directory contains a space.

# API and ABI breaking changes

-

# 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] Tested locally
- [x] Added a test
2026-02-26 19:29:40 +00:00
clockwork-labs-bot 4375cb81a8 spacetime dev - Print feedback when client process exits (#4469)
The main event loop in `spacetime dev` blocked on file change events
with no periodic check on the client process. If the client exited
(e.g., user pressed Enter in the basic-rs template), `spacetime dev`
gave no feedback at all.

**Fix**: Switch from blocking `recv()` to `recv_timeout(1s)` and check
client process status every second. On exit, prints:

- `Client process exited. File watcher is still active.` (exit code 0)
- `Warning: Client process exited with code N. File watcher is still
active.` (non-zero)

The file watcher continues running so module changes are still detected
and published.

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-02-26 18:31:01 +00:00
clockwork-labs-bot 350066ab4c spacetime dev - Fix file watcher ignoring --module-path / spacetime.json module_path (#4464)
## Summary

Fixes #4443 — `spacetime dev` ignores both `--module-path` CLI flag and
`module-path` in `spacetime.json` for the file watcher, always watching
`<project-path>/spacetimedb/` instead.

## Root Cause

Two bugs:

1. **Config's `module-path` never applied to `spacetimedb_dir`**: When
`spacetime.json` contains `module-path`, the recovery prompt is
correctly skipped (the code checks for its existence), but the value is
never used to update `spacetimedb_dir`. It stays as
`project_dir/spacetimedb`.

2. **Hardcoded fallback in `determine_publish_configs()`**: When there
are no publish targets in config (no `database` key or `children`), the
fallback creates a publish config entry with `module-path:
"spacetimedb"` hardcoded. This propagates to `extract_watch_dirs()`
(file watcher) and the publish loop, overriding any CLI or config value.

## Fix

1. After loading config, resolve `spacetimedb_dir` from config's
`module-path` in `additional_fields` when CLI did not provide
`--module-path`.

2. Pass the resolved `spacetimedb_dir` to `determine_publish_configs()`
as `default_module_path` so the fallback uses the correct path instead
of hardcoding `"spacetimedb"`.

## Testing

- All 5 existing `determine_publish_configs` tests pass
- Added new test
`test_determine_publish_configs_fallback_uses_provided_module_path` that
verifies the fallback uses the provided path

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-02-26 11:06:21 +00:00
joshua-spacetime 9f47647d0f Reduce fsync interval to 10ms (#4466)
# Description of Changes

Reduce fsync interval from 50ms -> 10ms

# API and ABI breaking changes

None

# Expected complexity level and risk

1

Should be fine based on p99 latencies

# Testing

N/A
2026-02-26 11:06:19 +00:00
clockwork-labs-bot ebea9a4b5c spacetime dev - Improve error when module directory does not exist (#4467)
When `spacetime dev` (or `publish`) cannot find the module directory,
the error was:

```
Error: Failed to build project
Could not detect the language of the module. Are you in a SpacetimeDB project directory?
```

This is confusing because the real problem is the directory does not
exist, not that the language cannot be detected.

Now shows:

```
Module directory does not exist: '/path/to/missing/dir'.
Check your --module-path flag or the module-path setting in spacetime.json.
```

Related to #4443.

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-02-26 08:37:07 +00:00
Zeke Foppa 1e6aa3226c Bump versions to 2.0.2 (#4455)
# Description of Changes

Bumping all versions to 2.0.2 for the release.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

CI

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-02-26 01:54:35 +00:00
Ryan f8ee1194fd [Docs] [C#] Update docs with List<T> returns and IEnumerable<T> tests (#4392)
# Description of Changes

* Updates `00500-views.md` with:
* Changes returned value to a nullable value, to match the return type
defintion.
* Wraps sample code in `public partial class Module` so pasting it in to
IDE will not return errors.
* Updates `00500-cheat-sheet.md` with:
* Changes reducer names to not start with `On` to avoid error `STDB0010:
Reducer method OnConnect starts with 'On', which is a reserved prefix.`
  * Adds `Accessor` values to views.
* Updates `Filter()` returned value to use `.ToList()` and the return
type to use `List<Player>` rather than `IEnumerable<Player>` to avoid
error, due to needing a return type to be `Vec<T>` or `Option<T>`.
* Updated `Coddgen.Test` to include tests verifying current behavior of
`IEnumerable<T>`, to aid in future update to allow a return type of
`IEnumerable<T>` to be allowed and converted internally to the required
type.

# API and ABI breaking changes

None

# Expected complexity level and risk

1 – documentation-only edits with no behavioral impact.

# Testing

- [X] Changed code blocks tested locally to ensure formatting resolved
in IDE.
2026-02-25 22:50:48 +00:00
Zeke Foppa 95c8c062fd Smoketest subscribe properly respects new confirmed behavior (#4454)
# Description of Changes

This doesn't actually change any used behavior, but fixes the
(apparently unused) `subscribe_confirmed` function, and makes it
possible to request unconfirmed reads as well.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

CI still passes? 🤷

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-02-25 20:37:58 +00:00
Shubham Mishra a327f91d30 TS: fix sourceName in table schema (#4449)
# Description of Changes
fixes: https://github.com/clockworklabs/SpacetimeDB/issues/4433.
Test will be added in:
https://github.com/clockworklabs/SpacetimeDB/pull/4450/changes

# API and ABI breaking changes
NA

# Expected complexity level and risk
2
2026-02-25 15:37:38 +00:00
Ryan 6fea15f745 [C#] Update RawTableIterBase.Enumerator to use ArrayPool for buffer (#4385)
This is the implementation of a fix for #4093 

# Description of Changes

* Updated `RawTableIterBase.Enumerator` to rent its scratch buffer from
`ArrayPool<byte>.Shared` (with dynamic re-rent on `BUFFER_TOO_SMALL`)
and return it on dispose, so iterating rows no longer allocates a fresh
`byte[]` per step.
* The enumerator still exposes the row bytes via `ArraySegment<byte>
Current`, but now the underlying storage is reused across iterations
rather than recreated each time.

Testing results from `master`:
```
allocated_bytes=14000
elapsed_ticks=1521829
sum=1249975000
row_count=50000
Find() TinyRecord (8 bytes payload) -> 132208 bytes allocated
Find() MediumRecord (~50 bytes payload) -> 132440 bytes allocated
Find() LargeRecord (1 KB payload) -> 134528 bytes allocated
Find() LargeRecord (10 KB payload) -> 152408 bytes allocated
Find() LargeRecord (100 KB payload) -> 336728 bytes allocated
Iter() 10 rows -> 131896 bytes allocated
Filter() iterate 20 rows -> 133288 bytes allocated
Filter() iterate 100 rows -> 135976 bytes allocated
10x consecutive Find() (TinyRecord) -> 1319120 bytes allocated
```

Testing results with this fix:
```
allocated_bytes=14000
elapsed_ticks=1504949
sum=1249975000
row_count=50000
Find() TinyRecord (8 bytes payload) -> 1096 bytes allocated
Find() MediumRecord (~50 bytes payload) -> 1280 bytes allocated
Find() LargeRecord (1 KB payload) -> 4464 bytes allocated
Find() LargeRecord (10 KB payload) -> 27464 bytes allocated
Find() LargeRecord (100 KB payload) -> 234312 bytes allocated
Iter() 10 rows -> 680 bytes allocated
Filter() iterate 20 rows -> 1872 bytes allocated
Filter() iterate 100 rows -> 3280 bytes allocated
10x consecutive Find() (TinyRecord) -> 8000 bytes allocated
```
# API and ABI breaking changes

No API or ABI changes

# Expected complexity level and risk

2 - low/moderate:
Touches the hot-path iterator that every `Iter`/`Find`/`Filter` call
uses

# Testing

- [X] Compiled CLI and ran regression tests locally
- [X] Verified iterator-based harness runs (client + module reducers) on
both `master` and this branch, confirming allocations drop from ~131 KB
per read to payload-scaled values.
- [X] Ensured no regressions in standard harness sanity checks
(`row_count=50000`, `sum=1249975000`).
2026-02-25 03:05:52 +00:00