Commit Graph

384 Commits

Author SHA1 Message Date
clockwork-labs-bot fca10ae8bc docs: Add supported index key types to Index docs page (#4606)
Fixes #4592

Adds a "Supported Column Types" section to the Index documentation page
listing:

- **Supported types**: integers (all widths), bool, String, Identity,
ConnectionId, Uuid, Hash, and no-payload enums with
`#[derive(SpacetimeType)]`
- **Unsupported types**: floats (no total ordering),
ScheduleAt/TimeDuration/Timestamp (not yet supported, links #2650),
Vec/arrays, enums with payloads, nested structs
- **Workaround tip**: scaled integers for floating-point coordinates
- **Direct index restrictions**: only u8/u16/u32/u64 and no-payload
enums

The list is derived from the `FilterableValue` trait implementations in
`crates/lib/src/filterable_value.rs` and the direct index validation in
`crates/schema/src/def/validate/v9.rs`.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-30 21:02:57 +00:00
Ryan ad71f4ce96 [C#] Add support for IEnumerable<T> for Views' return types (#4486)
This is the implementation to resolve #4424 
# Description of Changes
* Add support for `IEnumerable<T>` as a valid C# View return type in
codegen, so view implementations can return query results without
forcing `ToList()`. The generator now detects `IEnumerable<T>`,
serializes it via the list serializer.
* Snapshots have been updated with a test to confirm that
`IEnumerable<T>` rather than checking it is unsupported (which we had
added when removing support during the transition away from `Query<T>`
usage.
* Refreshes docs/examples to reflect the new supported signature.

# API and ABI breaking changes
No breaking changes. This is additive support for an existing .NET
interface.

# Expected complexity level and risk
2 - Low

# Testing
- [X] Rebuilt CLI locally, ran regression tests, and `dotnet tests` in
C# module bindings.
- [X] Tested updated docs code snippets to ensure they resolve in an IDE
and publish.

---------

Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
2026-03-23 23:20:46 +00:00
clockwork-labs-bot 39abb1a43b docs: Fix incorrect Math.random() note in reducer context (#4667)
Per Joshua: the note about `Math.random()` in the reducer context docs
is out of date and incorrect. TypeScript modules should use `ctx.random`
instead.

**Changes:**
- Remove `Math.random()` from the warning about non-deterministic RNGs
(it was listed alongside C#'s `Random` as something to avoid)
- Replace the incorrect `:::note` block with a proper table row
documenting `ctx.random` in the TypeScript context properties reference
- Same fixes applied to versioned docs (v1.12.0)

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-21 13:08:41 +00:00
Ryan af29a78b5b Updated Query with Indexes to be code-accurate (#4165)
# Description of Changes

Implements the fix for #4130 by updating docs with accurate usage
instructions for Query with Indexes in C#.

# API and ABI breaking changes

Docs only, no API or ABI changes

# Expected complexity level and risk

1

# Testing

- [X] Tested code snippets through addition of regression tests in #4123

Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2026-03-20 21:45:25 +00:00
clockwork-tien a16c6fe7ea fix(docs): Fix back to top button display (#4670)
# Description of Changes
- Fix issue with back to top button displays incorrectly
- Move the button to bottom left not to overlap with Ask AI

# Demo and screenshots
- After

<img width="1459" height="894" alt="image"
src="https://github.com/user-attachments/assets/75b4edda-dc54-493f-9274-0ca78f10fac7"
/>


https://github.com/user-attachments/assets/4cf7c3f4-51cc-4987-87db-b065ce4f7746

- Before

<img width="173" height="78" alt="image"
src="https://github.com/user-attachments/assets/052be945-fd2b-4276-a129-89c34a6a818b"
/>



<!-- 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] Back to top button displays correctly and works
2026-03-19 11:07:56 +00:00
Jason Larabie f8d6d76ee4 Update Unreal SDK to websocket 2.0 (#4497)
# Description of Changes

- Updated the Unreal SDK and generated Unreal bindings for the websocket
2.0 protocol/model
  - Reworked DbConnectionBase to handle the updated message shapes
- Switched subscription handling over to new message types and
QuerySetId
- Updated reducer to ReducerResult, removal of callbacks, and set
reducer flags
  - Added event table support
- Baked in multi-module support replacing [the old
PR](<https://github.com/clockworklabs/SpacetimeDB/pull/3417>)
- Added functionality to generate module support for multiple folders in
the Unreal project (add <module>.Build.cs, <module>.h, <module>.cpp)
using the --module-name
- Add new configuration option for spacetime generate to handle module
prefix
 - Regenerated Unreal Blackholio/TestClient/QuickstartChat bindings
   - Rebuilt Unreal Blackholio's consume entity to use event tables 
 - Updated migration documentation
 - Updated the version bump tool to impact C++

# API and ABI breaking changes

- Unreal websocket/message handling updated to the new protocol
- Unreal generation now expects a real .uproject target and will stop
immediately if project
    metadata is invalid instead of continuing past setup issues.

# Expected complexity level and risk

3 - A large set of changes to update the websocket/message handling
along with heavy codegen changes to handle multi-module support

# Testing

Test coverage of the Unreal SDK will need expansion in a future ticket
once our issues with flakiness on CI is resolved.

- [x] Updated Unreal Blackholio 
- [x] Ran full Unreal SDK test suite
- [x] Built new test project using the new `--module-prefix` 
- [x] Run through Unreal Blackholio (C++ and Blueprint)
- [x] Rebuilt Unreal Blackholio with multi-module, and duplicate
generated module testing side-by-side modules that would overlap

# Review Question(s)
- [x] Updates to `spacetime init` have made the tutorial a little
confusing with pathing for the Unreal Blackholio tutorial. To fix though
we'd have to update all the commands to be more explicit, or update the
tutorial `spacetime init` to use `--project-path .` to keep pathing
simpler, thoughts?

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Ryan <r.ekhoff@clockworklabs.io>
2026-03-18 21:14:06 +00:00
joshua-spacetime 3fe50e72d0 [Rust] Extend view table accessors with count (#4638)
# Description of Changes

Adds `count` to rust's procedural view API.

This API already existed in C# and typescript. This patch just adds
tests for those module languages.

We were already tracking reads for `count`, and so all this patch does
is add the new rust module bindings.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Smoketests for rust, C#, and typescript.
2026-03-16 13:03:50 +00:00
Tyler Cloutier 53256446d4 spacetime.json updates (#4504)
# Description of Changes

Adds a new reference documentation page for `spacetime.json` and fixes
several bugs where the CLI behavior diverged from the proposal.

**Docs:**
- New page at `/cli-reference/spacetime-json` covering config structure,
field reference, generate configuration, children/inheritance,
`spacetime dev` config, database selection, flag overrides,
`--no-config`, `--env`/environments, config file discovery, and editor
support

**Bug fixes:**
- `generate` was incorrectly inherited by child databases. A child with
a different `module-path` would silently inherit the parent's generate
entries, causing bindings to be written to the wrong output directory.
Generate is now never inherited, matching the proposal.
- The source conflict rule for `module-path`/`bin-path`/`js-path` was
not implemented during inheritance. A child specifying `module-path`
could still inherit `bin-path` from the parent. Now, if a child
specifies any module source, the others are not inherited.
- `--num-replicas` was not marked as a per-database override, so it
could be used with multiple databases selected without error.

# API and ABI breaking changes

None. These are bug fixes aligning the implementation with the intended
behavior from the proposal:
- `generate` inheritance was never documented or intended
- The source conflict rule was specified in the proposal but not
implemented
- `--num-replicas` as per-database is consistent with the other
module-source flags

# Expected complexity level and risk

2 - The changes are small and well-scoped. The generate inheritance fix
simplifies the code (removes a parameter). The source conflict rule adds
a straightforward check during field inheritance. Tests have been
updated to match.

# Testing

- [x] All 136 existing CLI tests pass
- [x] Updated tests for generate non-inheritance behavior
- [x] Docs site builds successfully, page renders in sidebar
- [ ] Manual test: verify a child with a different `module-path` no
longer inherits parent's `generate`
- [ ] Manual test: verify `--num-replicas` errors when multiple
databases are selected

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2026-03-14 20:42:39 +00:00
joshua-spacetime 61be6e69f6 Update docs for primary key views (#4620)
# Description of Changes

Updates the reference docs with the implications of primary key
inference for query builder views, implemented in #4572, #4573, #4614.

# API and ABI breaking changes

None

# Expected complexity level and risk

1. Docs only change

# Testing

N/A
2026-03-13 13:01:39 +00:00
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
Frederik 534fd306cf Fix Rust Chat App Tutorial not showing messages of other users live (#4588)
# Description of Changes

This fixes an Issue in the Rust [Chat App
Tutorial](https://spacetimedb.com/docs/tutorials/chat-app#creating-the-client),
that is caused by the [Event Type
Changes](https://spacetimedb.com/docs/upgrade/?client-language=rust&server-language=rust#event-type-changes)
in 2.0

This resulted in other clients not receiving new messages, since they
are now Event::Transaction and no longer included within the
Event::Reducer

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->
I don't think any? I only changed a tutorial, the real change was in 2.0

# Expected complexity level and risk

1

# Testing

- [x] I ran the Tutorial app with these changes and messages started to
appear as expected on the second client when writing something on the
first.



There might be more places where this is an Issue, I just noticed this
one while following the Tutorial.

---------

Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2026-03-11 21:54:32 +00:00
clockwork-labs-bot 21b5af0610 docs: Clarify HTTP endpoint auth is optional, not required (#4562)
## Summary

All `/v1/database` routes go through `anon_auth_middleware`, which
allocates a new anonymous identity when no `Authorization` header is
provided. The docs previously marked many endpoints as requiring auth
(`Required Headers`) when they actually accept anonymous requests.

## Code audit

Traced through `anon_auth_middleware` in `crates/client-api/src/auth.rs`
and each route handler in `crates/client-api/src/routes/database.rs`:

| Route | Old docs | Actual behavior | New docs |
|---|---|---|---|
| `POST /v1/database` (publish) | Required | Optional (anon creates new
DB) | Optional + explanation |
| `PUT /v1/database/:id` (publish) | Required | Optional (ownership
checked) | Optional + explanation |
| `GET /v1/database/:id` (info) | No auth section | No auth used |
Unchanged |
| `DELETE /v1/database/:id` | Required | Optional (ownership checked) |
Optional + explanation |
| `GET .../names` | No auth section | No auth used | Unchanged |
| `POST .../names` | Required | Optional (TLD ownership checked) |
Optional + explanation |
| `PUT .../names` | Required | Optional (ownership checked) | Optional +
explanation |
| `GET .../identity` | No auth section | No auth used | Unchanged |
| `GET .../subscribe` (WS) | Optional | Optional | Unchanged (already
correct) |
| `POST .../call/:reducer` | Required | Optional (identity passed to
reducer) | Optional + explanation |
| `GET .../schema` | No auth section | No permission check | Added
Optional section |
| `GET .../logs` | Required | Optional (ownership checked) | Optional +
explanation |
| `POST .../sql` | Required | Optional (RLS enforces access) | Optional
+ explanation |

Routes that genuinely require auth (`POST /v1/identity/websocket-token`,
`GET /v1/identity/:id/verify`) use `SpacetimeAuthRequired` and are
unchanged.

## Changes

- `authorization.md`: Added paragraph explaining anonymous access for
all `/v1/database` endpoints
- `database.md`: Changed `Required Headers` to `Optional Headers` for 8
endpoints, with per-endpoint explanations of anonymous behavior
- `database.md`: Added new `Optional Headers` section to `/schema`
endpoint (previously undocumented)

---------

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>
2026-03-06 09:15:34 +00:00
clockwork-labs-bot 214932510c docs: Audit HTTP API docs against code (#4569)
Audited all registered routes in `database.rs` and `identity.rs` against
the HTTP API documentation.

## Fixes

**database.md:**
- `/v1/database/:name_or_identity` publish: `POST` → `PUT` (code has
`db_put: put(publish::<S>)`)
- `DELETE` row in summary table: anchor pointed to POST section instead
of DELETE section
- Typo: `Updgrade` → `Upgrade` in WebSocket subscribe headers

**identity.md:**
- Removed `POST /v1/identity/:identity/set-email` — documented but has
no handler registered in `IdentityRoutes` (dead documentation)

## Routes in code but intentionally not documented (internal/unstable)

- `POST /v1/database/:noi/pre_publish`
- `PUT /v1/database/:noi/reset`
- `GET /v1/database/:noi/unstable/timestamp`

These are used internally by the CLI and are not part of the public API.

---------

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>
2026-03-06 00:47:59 +00:00
Ben Snyder 292bda8eed docs: self-hosted prod/test/dev Azure VM guide with key rotation, Azure Key Vault workflows, and rsync data migration pattern (#4545)
## Summary

This PR creates a comprehensive self-hosted JWT key rotation how-to for
SpacetimeDB with reproducible defaults, identity-preserving rotation
guidance, and host-scoped data migration runbooks. It is written for
both operators and automation workflows, with explicit guardrails for
production-like VM environments.

## Key Changes

- Adds a top-level assumptions/risk section for a multi-host topology
(`prod`, `test`, `dev`, optional `local`) including backup prerequisites
before rotation or sync.
- Defines an opinionated, end-to-end path contract for keys:
  - host source: `./.generated/spacetimedb-keys`
  - runtime mount: `/etc/spacetimedb`
- startup args pinned to `/etc/spacetimedb/id_ecdsa` and
`/etc/spacetimedb/id_ecdsa.pub`
- Includes reproducible quickstart scaffolding:
  - OpenSSL commands for compatible ES256/P-256 key generation
  - non-container and Docker startup examples
  - rotation/verify command sequence and marker checks
- Documents one unified tooling surface around `spacetimedb-tooling.ts`
for:
  - rotate (`--dry-run`, `--yes`)
  - verify (`--verify-only`)
  - token continuity (`--resign-token-only`)
- explicit token/key path overrides (`--publisher-cli-toml-path`,
`--private-key-path`)
- Clarifies 401 vs 403 behavior and why identity drift causes publish
failures after rotation.
- Covers all rotation strategies in one place:
  - clean-slate rotation (stateless/dev)
  - identity-preserving rotation (stateful)
  - OIDC-backed identity model for production
- Adds host-scoped migration runbooks for staged sync (`prod -> test ->
dev`) with destination-side token re-signing semantics (run on
destination host context, including SSH examples).
- Explicitly separates conceptual topology guidance from currently
implemented sync primitives in reference tooling to avoid over-claiming.
- Adds operational guardrails for sync promotions:
  - `rsync --delete` is destructive
  - stop/start ordering around sync
- required acceptance gates: key parity, destination re-sign,
restart/redeploy, publish marker validation
- Expands verification and automation content:
  - PEM/parity/fingerprint/newline checks
- AI/automation contract with inputs, outputs, required command order,
and success/failure markers
- troubleshooting flow for `InvalidSignature` and ownership mismatch
errors

## Why This Matters

The most common failure mode in self-hosted fleets is identity drift:
signatures validate, but `spacetime publish` still fails with `403
Forbidden` because destination ownership no longer matches the
publishing identity after key rotation or data movement.

The updated how-to makes these operator requirements explicit:

1. preserve identity continuity across rotations and host promotions
2. re-sign destination tokens after `rsync` in destination host context
3. treat restart/redeploy and publish markers as promotion gates

Following this runbook prevents regressions where key material is
correct but publish still fails due to stale signatures or owner
mismatch state.

## Why JWT Key Rotation Is Essential for Self-Hosters

In self-hosted deployments, operators are the signing authority.
Rotation is both a security control and an operational correctness
requirement.

### Security value

- reduces exposure window for compromised private keys
- invalidates old/stolen tokens after rotation
- mitigates risk from snapshots, backups, clones, and long-lived VM
access

### Operational value

- keeps key material consistent across multi-VM environments
- reduces publish outages after promotion/sync operations
- prevents avoidable `401`/`403` failures in routine release workflows

## Scope

- docs-only change
- public-safe examples only (no internal org names, private vault IDs,
or private secret prefixes)
- includes non-container and Docker workflows, self-publish/versioning
guidance, and marker-based validation (`PUBLISH_SUCCESS`,
`PUBLISH_FAILED`)
- includes data migration workflow guidance (`rsync` + destination
re-sign + restart/redeploy + publish checks)

---------

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-03-05 02:55:57 +00:00
clockwork-labs-bot cacfd73865 docs: fix TS index definition nameaccessor (#4537)
The TypeScript table index definition uses `accessor` not `name` for the
index identifier. Fixes three instances:

- `docs/docs/.../indexes.md`: two occurrences (`idx_age`,
`by_player_and_level`)
- `docs/docs/.../constraints.md`: one occurrence (`by_user_item`)

```diff
-{ name: 'by_player_and_level', algorithm: 'btree', columns: ['player_id', 'level'] }
+{ accessor: 'by_player_and_level', algorithm: 'btree', columns: ['player_id', 'level'] }
```

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-04 11:06:17 +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
Zeke Foppa 923dfe28c6 Fix a misprint in the self-hosting docs (#4524)
# Description of Changes

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

The docs refer to a block mentioning `/v1/publish` but we don't have
such a block in our example config. What we actually have is:
```
    # Block all other routes explicitly. Only localhost can use these routes. If you want to open your
    # server up so that anyone can publish to it you should comment this section out.
    location / {
        allow 127.0.0.1;
        deny all;
    }
```

# API and ABI breaking changes

None.

# Expected complexity level and risk

1.

# Testing

None

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-03-02 21:23:04 +00:00
Ryan c323bdf0dc [docs] Corrected call case and updated out-dir to match part 3 (#4513)
# Description of Changes

Contains 2 changes to documentation:
* Updates Unity Client Blackholio tutorial, part 2, with a corrected
`call` command. `Debug` became `debug` to match the automatic case
conversion that now occurs. Originally found and reported by discord
user `chrispavs`
* Updates Unity Client Blackholio tutorial, part 2, with the `out-dir`
path to match the path given in the [Entering the
Game](https://spacetimedb.com/docs/tutorials/unity/part-3#entering-the-game)
of `step 3`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1 - Docs correction

# Testing

- [X] Tested all `blackholio` tutorial steps using C# server and Unity
client
2026-03-02 19:06:28 +00:00
clockwork-labs-bot b322348f41 docs: document how to access module owner via init reducer (#4315)
In the `init` reducer, `ctx.sender` is the **module owner** — the
identity of the user who published the database. This is the only
lifecycle reducer where the owner identity is automatically provided.

Added a tip to the lifecycle docs showing:
- That `ctx.sender` in `init` is the owner
- How to store it in a table for later authorization checks
- Examples in TypeScript, C#, and Rust

Closes #3229

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-01 20:45:54 +00:00
clockwork-labs-bot 5d9eb7c705 Add missing TypeScript example in migration guide (#4508)
The 'Option 2: overwrite the name of individual tables' section of the
2.0 migration guide had an empty TypeScript tab. Adds a complete example
using `table()` with an explicit `name` property to preserve the
pre-conversion table name.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-01 16:02:30 +00:00
bradleyshep efa6f382b1 LLM benchmark tool updates (#4413)
# Description of Changes

LLM benchmark updates for local development:

- **Local SDK paths**: Templates use relative paths to workspace crates
(`crates/bindings`, `crates/bindings-csharp`,
`crates/bindings-typescript`) instead of published packages, so the
bench runs against local SDK changes.
- **NODEJS_DIR support**: On Windows (e.g. nvm4w), if `pnpm` is not on
PATH, the bench uses `NODEJS_DIR` to locate `pnpm` and prepends it to
PATH for subprocesses.
- **Refactor**: Extracted `relative_to_workspace()` in `templates.rs`
and removed noisy `NODEJS_DIR` logging in `publishers.rs`.
- **Benchmark results**: Updated `docs/llms/llm-comparison-details.json`
and `docs/llms/llm-comparison-summary.json`.

# API and ABI breaking changes

None.

# Expected complexity level and risk

**2** — Local-only changes to the benchmark tool. Templates now require
local SDKs to be built (especially TypeScript: `pnpm build` in
`crates/bindings-typescript`). No impact on published SDKs or runtime.

# Testing

- [ ] Run `cargo llm run --lang rust --modes docs --providers openai`
from repo root
- [ ] Run TypeScript benchmarks with `pnpm build` in
`crates/bindings-typescript` first
- [ ] On Windows with nvm4w, set `NODEJS_DIR` if `pnpm` is not on PATH
and run TypeScript benchmarks

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-03-01 02:22:59 +00:00
clockwork-labs-bot 1aff83da93 Fix missing word 'time' in ScheduleAt tutorial docs (#4490)
Fixes a missing word in the Unity and Unreal tutorial part-3 docs.

**Before:** `specify a specific at which to call a reducer once`
**After:** `specify a specific **time** at which to call a reducer once`

Fixed in 4 files (current docs + v1.12.0 versioned docs), 6 occurrences
total.

Spotted by Tyler.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-02-27 18:22:46 +00:00
Tao Tien 824c993fae Remove security warning from 00500-schedule-tables.md (#4463)
Now that scheduled reducers are private, this warning is no longer
necessary.

# Description of Changes

- removed Security Considerations section from Schedule Tables
documentation

Signed-off-by: Tao Tien <29749622+taotien@users.noreply.github.com>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-02-26 21:57:22 +00:00
clockwork-tien 5764ade224 fix(docs): Rename spacerace to referrals for nav item (#4477)
# Description of Changes
- Rename `Spacerace` to `Referrals` for docs nav item to align with
updated naming

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

# Screenshots
- After:
<img width="1510" height="49" alt="image"
src="https://github.com/user-attachments/assets/3bdbe6ec-8a51-4686-9292-28c38b6d14d9"
/>

- Before:
<img width="1460" height="47" alt="image"
src="https://github.com/user-attachments/assets/5c70b0ef-d5fc-42fa-9dc9-5fd4f034d415"
/>


# 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] Docs displays correctly
2026-02-26 11:06:16 +00:00
Boegie19 42097c3ff4 Add schedule name correction for LLMs (#4370)
# Description of Changes
This change is needed since the AI halicunates that the name is schedule
for some dam reason every time in the llm tests. while it is scheduled

https://github.com/clockworklabs/SpacetimeDB/blob/e2f8a607593f8e2e446df06d84b21e26af2bfc68/docs/llms/docs-benchmark-details.json#L90
# 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! -->

- [ ] Run the LLM benchmark and see if this fixes it

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-02-26 00:25:53 +00:00
Phoebe Goldman 3a850743f5 Correct unique indexes in cheat sheet to use filter, not find (#4452)
# Description of Changes

Some examples in our cheat-sheet incorrectly used a `filter` method on a
unique index. Unique indexes expose `find`, and non-unique indexes
expose `find`. This commit updates the cheatsheet to use the appropriate
index seek methods.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

N/a

# Testing

N/a

# Reviewers

Does the C++ code work as written, or do you have to do something
horrible to do with ranges?
2026-02-26 00:14:37 +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
John Detter 611be36278 Fix spacerace button in docs (#4458)
# Description of Changes

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

- Right now if you go to the docs https://spacetimedb.com/docs/ and you
click on spacerace in the upper right it will 404. This PR fixes this
issue.

# 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 - just a docs update

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

```
cd docs
npm install
npm run dev
```

- [x] spacerace button works in docs
2026-02-25 21:49:06 +00:00
Knut Egil V. Nygård 5fcd934d34 Correct "table" to "view" in 00250-zen-of-spacetimedb.md (#4434)
# Description of Changes

Corrected the wording from `a table` to `a view` where the documentation
links to the "Views" feature page.

---------

Signed-off-by: Knut Egil V. Nygård <86576502+knut-egil@users.noreply.github.com>
Signed-off-by: joshua-spacetime <josh@clockworklabs.io>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-02-25 01:12:20 +00:00
Julien Lavocat bce97d45ac Fix AI assistant rules links in llms.txt (#4430)
# Description of Changes

Fix AI assistant rules links in llms.txt, they were missing a `/docs`

# API and ABI breaking changes

None.

# Expected complexity level and risk

0.0001

# Testing

Clicked the link
2026-02-24 22:42:59 +00:00
Tyler Cloutier a4d29daec8 Fix spacetime dev template issues and clean up CLI (#4396)
## Summary

Multiple fixes and improvements to `spacetime dev`, `spacetime publish`,
`spacetime init`, and templates:

### CLI fixes
- **Fix `spacetime dev` watch path and .env.local handling** for
templates with a `spacetimedb/` subdirectory
- **Validate package manager availability** before installing
dependencies — re-prompts if the selected PM isn't on PATH
- **Remove JS/TS beta warning** from `spacetime publish`
- **Remove unstable warning** from `spacetime init`
- **Remove unused `spacetime energy` command** (can be re-added later
when properly implemented)
- **Fix `tsc` detection on Windows** — `set_extension(".cmd")` produced
`tsc..cmd` (double dot); fixed to `set_extension("cmd")`
- **Add `typescript` as devDependency** to all server template
`spacetimedb/package.json` files so `tsc` is available during build
- **Strip `\?\` extended-length path prefix** from user-facing output in
both `dev` and `publish` commands (produced by `fs::canonicalize()` on
Windows)
- **Fix publish reporting success when user declines** non-local server
prompt — changed `return Ok(())` to `bail!()` consistent with other
abort cases
- **Forward stdin to client process** in `spacetime dev` so interactive
CLI templates work

### Template fixes
- **Fix Angular template environment variables** — Angular's esbuild
builder doesn't support `import.meta.env`, so we use a dev script to
generate `environment.local.ts` with Angular's native `fileReplacements`
pattern
- **Fix TanStack Start template** — rename `createRouter` to `getRouter`
(v1.121+ breaking change), upgrade to React 19, and add
`@vitejs/plugin-react` for automatic JSX runtime support
- **Fix `moduleResolution` in remix-ts and nextjs-ts** server tsconfigs
— change from `"node"` to `"bundler"` to support subpath exports like
`spacetimedb/server`
- **Fix browser-ts template** — convert from static HTML + IIFE bundle
to standard Vite dev server app so it works with `spacetime dev` and
reads env vars from `.env.local`
- **Add `deno` as devDependency** to deno-ts template (matches how
bun-ts includes bun)
- **Convert basic-ts from empty web app to CLI app** matching basic-rs —
connect, subscribe to person table, print on insert

## Test plan

- [x] `cargo test -p spacetimedb-cli` — all 133 tests pass
- [ ] `spacetime dev --template angular-ts` — verify Angular app
connects with correct database name
- [ ] `spacetime dev --template react-ts` — verify React template still
works
- [ ] `spacetime dev --template tanstack-ts` — verify TanStack Start
template loads without errors
- [ ] `spacetime dev --template remix-ts` — verify Remix template builds
and runs
- [ ] `spacetime dev --template nextjs-ts` — verify Next.js template
still works
- [ ] `spacetime dev --template browser-ts` — verify Vite dev server
starts and app connects
- [ ] `spacetime dev --template bun-ts` — verify Bun CLI template runs
interactively
- [ ] `spacetime dev --template basic-ts` — verify CLI connects and
prints on insert
- [ ] Verify no `\?\` prefix in any displayed paths on Windows
- [ ] Verify no `tsc not found` warning when building server modules
- [ ] Select unavailable package manager at init prompt — verify
re-prompt
- [ ] Decline non-local server prompt — verify clean error instead of
"Published successfully!"

---------

Co-authored-by: Piotr Sarnacki <drogus@gmail.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
2026-02-24 02:39:42 -05:00
bradleyshep c37b7912b3 LLM Benchmark docs updates from testings (#4416)
# Description of Changes

Documentation updates from llm-benchmark testing. Includes:

- **Core concepts**: Tables, column types, auto-increment, indexes,
access permissions, schedule tables, event tables, performance
- **Client references**: C# and TypeScript reference updates
- **Migration guide**: 2.0 migration docs
- **AI rules**: `spacetimedb-csharp.mdc`, `spacetimedb-typescript.mdc`,
new `spacetimedb-migration-2.0.mdc`
- **Cheat sheet**: Database cheat sheet updates
- **Reducers, procedures, reducer context**: Small fixes and
clarifications
- **llms.md**: LLM-related doc updates

# API and ABI breaking changes

None. Documentation only.

# Expected complexity level and risk

**Complexity: 2** — Broad docs changes but no code. Risk is limited to
incorrect or misleading docs.

# Testing

- [ ] Build docs site and confirm it renders
- [ ] Spot-check updated pages (tables, schedule tables, cheat sheet,
client references)
- [ ] Confirm C# tutorial examples use `nameof(...)` and snake_case

---------

Signed-off-by: bradleyshep <148254416+bradleyshep@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-02-23 21:09:14 -08:00
clockwork-labs-bot b002158db8 Enable confirmed reads by default (#4390)
## Summary

Enable confirmed reads by default for all WebSocket subscriptions and
SQL queries. This is a 2.0 breaking change that improves data integrity.

### What changed

Previously, subscription updates and SQL results were sent to clients
immediately, before the transaction was confirmed durable. A server
crash could cause clients to have observed data that was lost.

Now the server defaults to `confirmed=true`. Clients receive updates
only after durability is confirmed. This adds a small latency cost but
guarantees that any data a client receives will survive a server
restart.

### Changes

**Server (2 files, 2 lines each):**
- `subscribe.rs`: `SubscribeQueryParams.confirmed` defaults to `true`
- `database.rs`: `SqlQueryParams.confirmed` defaults to `true`

**Documentation:**
- Migration guide updated with "Confirmed Reads Enabled by Default"
section
- Added to overview list and quick migration checklist

### Opt-out

Clients can opt out by explicitly passing `?confirmed=false` in the
WebSocket URL or using `.withConfirmedReads(false)` /
`.WithConfirmedReads(false)` / `.with_confirmed_reads(false)` in SDKs.

### Smoketest impact

Smoketests that don't explicitly pass `--confirmed` will now get
confirmed reads via the server default. This should not cause failures
-- confirmed reads only add a small wait for durability confirmation
before sending results. The `confirmed_reads.py` smoketest explicitly
passes `--confirmed` and continues to work as before.

### SDK impact

No SDK changes needed. SDKs only send the `confirmed` query parameter
when explicitly set by the user. When not set, the server default
applies -- which is now `true`.

---------

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: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-02-24 02:27:42 +00:00
bradleyshep 55c1b815d4 LLM Benchmark Results - Feb 26 (#4388)
# Description of Changes

- Update llm benchmark results based on latest testing
- Clean up details file to remove old models
- Regenerated the summary file

# API and ABI breaking changes

- None

# Expected complexity level and risk

- 1

# Testing

- Verify the new summary file loads correctly on the website.
2026-02-23 23:15:39 +00:00
Ryan 92e9767a81 [Docs] Updates to 00600-c-sharp.md to work in 2.0 (#4415)
# Description of Changes

* Updates directory tree to reflect the actual results of running
`spacetime dev --template basic-cs my-spacetime-app` with no additional
arguments.
* Updates the `Add` -> `add` reducer call to use lower-case to match the
default when no override is specified.
* Updates the `SayHello` -> `say_hello` reducer call to use lower-case
to match the default when no override is specified.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [X] Walked through every step with a local server to test behavior.
This involved.
* Cleared all local cache and rebuilding the CLI.
* Rebuilding the DLLs
* From my test project directory, running:
`D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe
dev --template basic-cs my-spacetime-app` and selecting the default
values.
* This threw an error because, I believe, it was not using the local
DLLs.
* Going into each `.csproj` to ensure they are using the local versions
of the files.
* Running the remaining commands, while targeting the local CLI
executables:
  * Note: `local` server is mapped to `127.0.0.1:3000`
```
D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe publish -s local my-spacetime-app
D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe call -s local my-spacetime-app add Alice
D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe sql -s local my-spacetime-app "SELECT * FROM Person"
D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe call -s local my-spacetime-app say_hello
D:\Projects\ClockworkLabs\SpacetimeDB\target\debug\spacetimedb-cli.exe logs -s local my-spacetime-app
```
2026-02-23 23:11:39 +00:00
Jeffrey Dallatezza 7923d6f64b Update default doc version to 2.0.0 (#4411)
# Description of Changes

Docs will now go to version 2.0.0 by default, and there is a banner with
a link to the newer docs if someone is viewing the v1 docs.

# Expected complexity level and risk

1. Biggest risk here is breaking links.

# Testing

I tested this locally, and checked that links are working.

There is also a broken link checker in the CI.
2026-02-23 23:09:42 +00:00
joshua-spacetime 6298e0a4e0 Remove query builder's .build() from llm docs (#4398)
# Description of Changes

Removes left over references to the query builder's `.build()` method as
well as some stale C# references from `llms.md`.

Only rust and C# docs needed updating.

# API and ABI breaking changes

None

# Expected complexity level and risk

1. Small docs update

# Testing

N/A
2026-02-23 19:19:52 +00:00
Tyler Cloutier d3deaeec08 Docs: Add links to all quickstart guides on Getting Started page (#4395)
## Summary
- Update the `QuickstartLinks` component on the Getting Started
(`/docs`) page to show all 16 quickstart guides instead of just 4
(TypeScript, C#, Rust, React)
- The component now uses `useDocsVersion()` to filter items based on the
active doc version, so v1.12 only shows quickstarts that exist in that
version while v2.0 shows all 16
- Add new SVG logos for Vue, Nuxt, Svelte, Angular, TanStack Start,
Deno, and C++
- Replace existing logos (React, Next.js, Node.js, Bun, Remix, HTML5)
with consistent monochrome `currentColor` versions sourced from the
spacetime-web homepage
- Fix Rust logo visibility in dark mode by removing hardcoded
`style="color: black;"`

## Test plan
- [ ] Verify the Getting Started page on v2.0.0-rc1 shows all 16
quickstart cards
- [ ] Verify the Getting Started page on v1.12.0 shows only the
quickstarts that exist in that version (react, vue, svelte, typescript,
rust, c-sharp)
- [ ] Verify all card links navigate to the correct quickstart page
- [ ] Verify logos are visible in both light and dark mode
2026-02-23 18:49:34 +00:00
bradleyshep c14c8d15b0 TS quickstart template fixes (nextjs + nodejs) (#4380)
# Description of Changes

- Node.js: Use esbuild instead of tsx 
- Node.js: Remove interactive CLI since it doesn't work with `spacetime
dev`
- Next.js: Fix onError callback to use single argument (ctx) and use
ctx.event for the error.
- Next.js: Replace lint-disable comment with `_connection` for the
unused variable.
- Updated quickstart docs to use proper `withDatabaseName`

# API and ABI breaking changes

None.

# Expected complexity level and risk

**Complexity: 1–2.** Small tooling, type, and lint tweaks. Low risk.

# Testing

- [ ] Build affected templates (e.g. `pnpm build` in nextjs-ts).
- [ ] Lint passes.
2026-02-22 11:05:56 +00:00
Phoebe Goldman 2d4395c76d Docs: SpacetimeDB 2.0 migration guide (#4383)
# Description of Changes

Expanded and reorganized the 2.0 migration guide, and also deleted a
file that was in the wrong place. (The word "migration" is
overloaded...)

# API and ABI breaking changes

N/a

# Expected complexity level and risk

Like, 1 I guess, since this isn't code? But we should be careful to get
this right.

# Testing

- [x] Pasted all 2.0 Rust examples into a project based on the
`basic-rs` template and got 'em to build.
- This required filling in some code outside the examples (defining
`play_damage_animation`, binding `target` and `amount`), and changing
one table name that was used in two examples, but otherwise everything
is valid.
  - I didn't test the 1.0 examples.

---------

Co-authored-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: = <cloutiertyler@gmail.com>
2026-02-21 03:29:39 +00:00
Jeffrey Dallatezza bddfc19725 Add doc versioning (#4381)
# Description of Changes

This change cuts a version of the docs from 1.12.0
(e45cf891c2), and saves it under
`docs/versioned_docs/version-1.12.0`.

If you go to the docs page, it will redirect to the 1.12.0 docs, which
has a banner at the top for trying the prerelease docs:
<img width="1027" height="283" alt="Screenshot 2026-02-20 at 12 07
39 PM"
src="https://github.com/user-attachments/assets/8ff3d622-b693-469a-980a-01c34d0506b8"
/>

If you select the prelease docs, there is a warning banner at the top:
<img width="886" height="299" alt="Screenshot 2026-02-20 at 12 08 52 PM"
src="https://github.com/user-attachments/assets/5508a635-765e-40cc-ad2a-cbbed7f779dd"
/>


# Expected complexity level and risk

This only changes docs.

# Testing

I've testing by running this locally.
2026-02-20 22:41:39 +00:00
bradleyshep e256ceff33 Change deno quickstart to use package.json instead of deno.json (#4374)
# Description of Changes

Deno quickstart template now uses `package.json` instead of `deno.json`
so `spacetime dev` can run it. Added `templates/deno-ts/package.json`,
removed `deno.json`, and updated the Deno quickstart doc.

# API and ABI breaking changes

None.

# Expected complexity level and risk

**1** — Template and docs only.

# Testing

- [ ] `spacetime dev --template deno-ts` and confirm client runs.
- [ ] Spot-check updated Deno quickstart doc.
2026-02-20 19:05:59 +00:00
Piotr Sarnacki 19cc87ebfa Allow skipping DB if the config file is available (#4358)
# Description of Changes

This PR introduces a possibility to skip passing a DB name to various
commands if there is a config file with one database defined

# API and ABI breaking changes

This changes the behaviour of several CLI commands:

  1. call
  2. subscribe
  3. sql
  4. describe
  5. logs
  6. delete

# Expected complexity level and risk

4 - it's tricky to get all of the combinations of CLI arguments right

# Testing

I've tested the simplest cases manually.

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: = <cloutiertyler@gmail.com>
2026-02-20 17:48:54 +00:00
Shubham Mishra e2f8a60759 Case conversion (#4263)
# Description of Changes

Update the Default casing policy to `snake_case` for `RawModuleDefV10`.

Messy PR contains changes at different places, so that CI can pass:

Here are the main changes as follows:
- `bindings-macro` & `bindings` crate: `name` macro in Indexes for
canonical name and supply it to `RawModuleDefV10` via `ExplicitNames`.
- `bindings-typescript`: 
- Changes has been reviewed through this PR -
https://github.com/clockworklabs/SpacetimeDB/pull/4308.
   
- `binding-csharp`: a single line change to pass `sourceName` of index
instead of null.
- `codegen`:
  
- Changes has been merged from branch -
https://github.com/clockworklabs/SpacetimeDB/pull/4337.
  
- Except a fix in rust codegen to use canonical name in Query buillder
instead of accessor.
  
- `lib/db/raw_def`: Extends `RawDefModuleV10` structure to support case
conversion.
  
- `schema` crate:
- `validate/v9` - Nothing itself should change or changes in v9
validation logic but the file contains a `CoreValidator` which is shared
with `validate/v10`. No test have t be updated to `validate/v9` which
ensures we aren't regressing it.
- `validate/v10`: This is the main meat, look at the new tests added in
bottom to understand what it does.
     
   -  Rest of the files are either test updates or module bindings. 
     
    ## Testing:
1. Extensive unit tests have been added to verify generated `ModuleDef`
is correct.
2. I have done some e2e testing to verify rust codegen with rust and
typescript modules.
3. I would have like to do more testing for other codegens , I am
continue doing .

I have removed `sql.py` smoketest, as that seems to be already migated
in new framework and was headache to update.

## Expected complexity level and risk
4, It could have side-effect which aren't easily visible.


 
 
 
 
 
 -  -  -

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
Co-authored-by: Noa <coolreader18@gmail.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@clockworklabs.io>
Co-authored-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2026-02-20 10:44:29 +00:00
Tyler Cloutier b2bb2180c5 Fix spacetime dev watch filtering and improve quickstart copy-paste experience (#4317)
## Summary
- Fix `spacetime dev` failing on C# projects by watching the module
directory itself instead of hardcoded `spacetimedb_dir/src/` (which
doesn't exist for C# templates)
- Add layered file-watch filtering to avoid triggering rebuilds on build
artifacts:
1. Always-ignore dirs (`target/`, `bin/`, `obj/`, `node_modules/`, etc.)
  2. Always-watch exceptions (`.env.local`, `spacetime.*.local.json`)
  3. `.gitignore` rules from global, project, and module levels
- Suppress init's generic "Next steps" message when called from
`spacetime dev`, print a dev-appropriate `cd` hint instead when a new
project is created in a subdirectory
- Update 12 quickstart docs to tell users to open a new terminal and `cd
my-spacetime-app` before running CLI commands

## Test plan
- [x] `cargo build -p spacetimedb-cli` compiles successfully
- [ ] `spacetime dev --template basic-cs` no longer errors with "Input
watch path is neither a file nor a directory"
- [ ] Modifying a `.cs` file in `spacetimedb/` triggers a rebuild
- [ ] Build artifacts in `obj/`/`bin/` do not trigger rebuilds
- [ ] Rust projects (`spacetimedb/src/` exists) continue to work as
before
- [ ] `spacetime dev --template basic-cs` from a non-project directory
prints the "Tip: cd" hint, not the generic "Next steps"
- [ ] `spacetime init` standalone still prints "Next steps" as before

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-02-19 23:12:34 +00:00
John Detter 27bb9f8edf Remove database names in quickstarts (#4354)
# Description of Changes

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

- For the quickstarts we don't want to pass a database name during
`spacetime dev --template ...`

# API and ABI breaking changes

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

None - this is just docs

# Expected complexity level and risk

None - this is just docs

<!--
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] All quickstarts no longer pass a database name during `spacetime
dev --template ...`
2026-02-19 21:18:29 +00:00
doug ae8c9159b3 Add ConnectionManager for robust React lifecycle handling (#4028)
## Summary
- Add `ConnectionManager` singleton that uses reference counting and
deferred cleanup to handle React StrictMode's double-mount behavior
- Implement TanStack Query-style pattern: `retain()` / `release()`
instead of direct connect/disconnect
- Use `useSyncExternalStore` for tear-free state reads in React

## Changes
- **New:** `src/sdk/connection_manager.ts` - Core ConnectionManager
implementation
- **Modified:** `src/react/SpacetimeDBProvider.ts` - Now uses
ConnectionManager
- **Modified:** `src/react/connection_state.ts` - Simplified type,
imports from ConnectionManager
- **Modified:** `src/sdk/db_connection_builder.ts` - Added `getUri()`
and `getModuleName()` methods
- **Modified:** `src/sdk/db_connection_impl.ts` - Minor type updates for
ConnectionManager integration
- **New:** `tests/connection_manager.test.ts` - 33 unit tests
- **Docs:** Added React Integration section to TypeScript reference
- **Docs:** Added StrictMode compatibility note to README

## Test plan
- [x] `pnpm test` passes (104 tests)
- [x] `pnpm build` passes
- [x] Manual browser test with React StrictMode - single WebSocket
connection

---

## Motivation

### The Problem

React StrictMode double-mounts components in development to help catch
bugs:

1. Mount → creates WebSocket connection
2. Unmount → destroys WebSocket connection
3. Remount → creates **another** WebSocket connection

Without ConnectionManager, you get either:
- **Two connections** (if you don't clean up on unmount)
- **Broken connection** (if you clean up on unmount, the remount races
with cleanup)

### Why ConnectionManager? (vs alternatives)

| Alternative | Problem |
|-------------|---------|
| Don't clean up on unmount | Leaks connections, memory leaks, stale
subscriptions |
| Disable StrictMode | Hides real bugs, production still has edge cases
|
| Connection in module scope | React can't react to state changes, no
`useSyncExternalStore` |

**ConnectionManager approach** (TanStack Query pattern):
- Reference counting: multiple components share one connection
- Deferred cleanup: `setTimeout(0)` lets StrictMode remount cancel
cleanup
- External store: connection state lives outside React but syncs
properly

---

## Why Two `useSyncExternalStore` Usages?

The SDK now has two places using `useSyncExternalStore`. They solve
different problems:

| | `useTable` | `ConnectionManager` |
|---|---|---|
| **Subscribes to** | Table row changes | Connection state changes |
| **External store** | `DbConnection.db.tableName` callbacks |
`ConnectionManager` singleton |
| **Re-renders when** | Row inserted/deleted/updated | `isActive`,
`identity`, `error` change |
| **Manages lifecycle?** |  No - assumes connection exists |  Yes -
owns connect/disconnect |

### `useTable` assumes a connection exists

```tsx
// useTable.ts - subscribes to TABLE DATA
useEffect(() => {
  const connection = connectionState.getConnection()!;  // assumes this exists
  if (connectionState.isActive && connection) {
    const cancel = connection.subscriptionBuilder().subscribe(query);
    return () => cancel.unsubscribe();
  }
}, [...]);
```

### `ConnectionManager` manages WHEN the connection exists

```tsx
// OLD SpacetimeDBProvider - broken with StrictMode
useEffect(() => {
  const conn = builder.build();    // Creates WebSocket
  return () => conn.disconnect();  // Destroys WebSocket
}, [builder]);
// StrictMode: build → disconnect → build = TWO CONNECTIONS RACING

// NEW SpacetimeDBProvider - works with StrictMode  
useEffect(() => {
  ConnectionManager.retain(key, builder);   // refCount++, maybe create
  return () => ConnectionManager.release(key); // refCount--, deferred cleanup
}, [key, builder]);
// StrictMode: retain(1) → release(0, schedule) → retain(1, cancel) = ONE CONNECTION
```

### The Layered Architecture

```
ConnectionManager (lifecycle: retain/release, deferred cleanup)
    ↓
SpacetimeDBProvider (React context + useSyncExternalStore for connection state)
    ↓
useTable (useSyncExternalStore for table data)
```

- `useTable` syncs **data** from an existing connection
- `ConnectionManager` syncs **connection state** AND manages **when the
connection exists**

---------

Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2026-02-19 16:21:19 +00:00
joshua-spacetime 41cfbbc7e0 Update subscription and query builder docs (#4329)
# Description of Changes

This patch does the following:

- Adds api reference docs for the module-side query builder in the view
docs
- Merges the client sdk and subscription docs pages
- Keeps subscription and client overview docs high-level (moved all api
docs to the language reference docs)
- Replaces SQL examples in the docs with the query builder
- Replaces SQL subscriptions in the templates with the query builder

Note, the last commit in this patch set transitions the templates over
to use the query builder instead of SQL subscriptions. This will break
them temporarily until #4000 merges.

Also note, a lot of this was AI assisted. It can still be improved upon,
but it's in a better state than it was.

# API and ABI breaking changes

N/A

# Expected complexity level and risk

1

# Testing

N/A

---------

Signed-off-by: joshua-spacetime <josh@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2026-02-19 03:59:33 +00:00
Jason Larabie 34aa9654fd Docs - add shared C++ version notice inside first C++ tab across docs (#4348)
# Description of Changes
- Added a shared component with a message for C++ on the version pinning
- Updated every doc that has a C++ tab to include the new message

# API and ABI breaking changes

N/A

# Expected complexity level and risk

2 - Small document change but used a shared component

# Testing
- [x] Tested locally with pnpm dev
- [x] Hosted on my personal site to double check the shared component
2026-02-19 00:20:47 +00:00
Noa ea0e01edb7 Fixes for procedure example in docs (#4346)
# Description of Changes

The maximum http timeout (500ms) was too low for the OpenAI API to have
time to respond, so I raised it, and verified that the rust and
typescript examples work. Csharp wasn't building at all for some reason
(`Workload installation failed: Unable to load the service index for
source https://api.nuget.org/v3/index.json.`?)

# Expected complexity level and risk

1

# Testing

- [x] Manually tested these changes
2026-02-18 23:21:23 +00:00