Skip to content

Implement event tables#4217

Open
cloutiertyler wants to merge 3 commits intojsdt/ws-v2from
tyler/impl-event-tables
Open

Implement event tables#4217
cloutiertyler wants to merge 3 commits intojsdt/ws-v2from
tyler/impl-event-tables

Conversation

@cloutiertyler
Copy link
Contributor

@cloutiertyler cloutiertyler commented Feb 6, 2026

Description of Changes

Adds event tables support to SpacetimeDB (Rust server bindings only, V10 ABI).

Event tables are write-only tables whose rows persist to the commitlog but are NOT merged into committed state. Their rows are ephemeral in memory — only visible to V2 subscribers in the transaction that inserted them.

Schema & ABI:

  • Add is_event: bool to RawTableDefV10, TableDef, and TableSchema
  • New st_event_table system table (TableId 17) tracks which tables are event tables, avoiding migration of StTableRow
  • is_event is reconstructed from st_event_table in schema_for_table_raw()

Rust bindings macro:

  • Add event keyword: #[spacetimedb::table(name = my_events, public, event)]
  • Emits const IS_EVENT: bool = true; on TableInternal
  • Wired through register_table() to V10 builder's .with_event()

Core behavior:

  • merge_apply_inserts(): event table rows are recorded in TxData (for commitlog + subscriptions) but skip merging into committed state
  • replay_insert(): event table rows return early — no committed state rebuilt on restart

Compile-time semi-join validation:

  • CanBeLookupTable marker trait in query-builder — event tables don't implement it
  • Semi-join methods require R: CanBeLookupTable, giving a compile error if an event table is used as the lookup side

Cherry-picks joshua/shub/raw-module-def-v10 (#4153) as a prerequisite. V9 is completely untouched.

Deferred: V2 subscription evaluation, runtime SQL semi-join validation, view validation.

API and ABI breaking changes

New field is_event: bool added to RawTableDefV10 (appended at end for ABI compat). Defaults to false, so existing modules are unaffected.

CanBeLookupTable trait bound replaces HasIxCols on semi-join methods in the query builder. All non-event tables implement CanBeLookupTable, so existing code compiles unchanged.

Expected complexity level and risk

3 — The changes touch the schema pipeline end-to-end (raw def → validated def → runtime schema → system table → committed state merge/replay), but each individual change is straightforward. The main risk area is the merge skip logic in committed_state.rs, which is on the hot path and must correctly distinguish event tables from persistent ones. The system table approach avoids any migration risk for existing databases.

Testing

  • cargo check passes (verified locally)
  • Verify event table inserts are recorded in TxData for commitlog persistence
  • Verify committed state remains empty for event tables after merge
  • Verify replay skips event table rows (state stays empty after restart)
  • Verify compile error when using event table as right side of query builder semi-join
  • Verify non-event tables are completely unaffected

@cloutiertyler cloutiertyler force-pushed the tyler/impl-event-tables branch from c96550a to 57cc9a5 Compare February 6, 2026 01:21
@cloutiertyler cloutiertyler force-pushed the tyler/impl-event-tables branch from f9bb16a to c13a4b1 Compare February 6, 2026 01:46
Shubham8287 and others added 3 commits February 5, 2026 22:26
# Description of Changes

Switch Wasm module to `__describe_module_v10__` from
`__describe_module__` to expose `RawModuleDefV10`

# API and ABI breaking changes
2.0 breaking change.

# Expected complexity level and risk
1

# Testing
Exising smoketests should be enough.
Each validated schema type (TableDef, IndexDef, ReducerDef, etc.) now
has its own From impl for the corresponding V10 raw type, mirroring
the existing V9 conversions. The main From<ModuleDef> for RawModuleDefV10
is simplified to use .into() calls.
@cloutiertyler cloutiertyler force-pushed the tyler/impl-event-tables branch from c13a4b1 to 07d57a5 Compare February 6, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants