Skip to content

Implement persistent typed database environments - #5887

Merged
cloutiertyler merged 40 commits into
masterfrom
tyler/environment-variables
Sep 14, 2026
Merged

cloutiertyler merged 40 commits into
masterfrom
tyler/environment-variables

Conversation

@cloutiertyler

@cloutiertyler cloutiertyler commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Implements typed environment variables with typed module accessors, persistent values, and a usage guide. Supports undeclared values, --env-only, explicit deletion, and --replace-env. Updates use module-publishing permissions and validate atomically against module declarations.

Creation and reset persist initial values before starting the replica. Rejected publishes preserve the running host; unchanged publishes remain no-ops. Cloud companion: SpacetimeDBPrivate#3940.

API and ABI breaking changes

Not breaking. Requires a minor version bump.

Extends V10 metadata and host imports. Extends the HTTP API to allow publishing environment variables when publishing a module. ENV-enabled modules require an updated host.

Rollback safety impact

n/a (no prerequisite PRs). Older hosts cannot run ENV-enabled modules. Standalone control DB row encodings are unchanged; re-upgrading ignores obsolete initial values left by an older server's reset. --delete-data clears environment values.

Expected complexity level and risk

4/5. Publication, persistence, secret access controls, and all four module libraries.

Testing

CLI smoke tests and module tests cover typed access, authorization, atomic updates, rejected publication, unchanged-publication no-ops, view refresh, restart/recovery, and legacy control DB reset compatibility.

Comment thread crates/bindings-cpp/include/spacetimedb/bsatn/reader.h
Comment thread crates/bindings-csharp/Runtime/Internal/FFI.cs
@cloutiertyler cloutiertyler changed the title Add database environment storage, SQL, and module bindings Implement typed publish-only database environments Sep 8, 2026
Comment thread crates/bindings-sys/src/lib.rs
Comment thread crates/bindings/src/lib.rs
Comment thread crates/bindings-cpp/src/abi/wasi_shims.cpp Outdated
Comment thread crates/bindings-cpp/src/abi/wasi_shims.cpp Outdated
Comment thread crates/bindings-csharp/Runtime/build/SpacetimeDB.Runtime.targets Outdated
Comment thread crates/bindings-macro/src/environment.rs Outdated
Comment thread crates/bindings-typescript/src/server/environment.ts Outdated
Comment thread crates/cli/src/spacetime_config/environment.rs
Comment thread crates/cli/src/subcommands/env.rs
Comment thread crates/cli/src/subcommands/publish.rs Outdated
Comment thread crates/cli/src/subcommands/publish/environment.rs Outdated
Comment thread crates/cli/src/subcommands/publish/environment/tests.rs Outdated
Comment thread crates/client-api-messages/src/publish.rs
Comment thread crates/client-api/src/lib.rs Outdated
Comment thread crates/core/src/host/host_controller.rs
Comment thread crates/core/src/host/module_host.rs
Comment thread crates/core/src/host/v8/syscall/common.rs
Comment thread crates/core/src/host/v8/syscall/mod.rs Outdated
Comment thread crates/core/src/host/wasm_common.rs Outdated
Comment thread crates/core/src/host/wasm_common/module_host_actor.rs
Comment thread crates/core/src/host/wasm_common/module_host_actor.rs
Comment thread tools/ci/commands/workflow-coordinator/src/main.rs Outdated
Comment thread crates/cli/src/spacetime_config.rs
Comment thread crates/cli/src/subcommands/publish.rs Outdated
Comment thread crates/cli/src/schema_extract.rs
Comment thread crates/cli/src/subcommands/publish.rs
Comment thread crates/core/src/host/wasm_common/module_host_actor.rs

@cloutiertyler cloutiertyler left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've really spent quite a while reviewing and testing this PR. I believe it's good to go, but this is still quite high risk, especially with changes to the control db and the host/module lifecycle.

@cloutiertyler
cloutiertyler added this pull request to the merge queue Sep 14, 2026
Merged via the queue into master with commit 1fb994c Sep 14, 2026
60 of 63 checks passed
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.

4 participants