Skip to content

spacetime.json updates#4504

Open
cloutiertyler wants to merge 3 commits intomasterfrom
tyler/spacetime-json-docs
Open

spacetime.json updates#4504
cloutiertyler wants to merge 3 commits intomasterfrom
tyler/spacetime-json-docs

Conversation

@cloutiertyler
Copy link
Contributor

@cloutiertyler cloutiertyler commented Feb 28, 2026

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

  • All 136 existing CLI tests pass
  • Updated tests for generate non-inheritance behavior
  • 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

Reference docs for the spacetime.json config file (proposal 0032),
covering config structure, field reference, generate configuration,
children/inheritance, dev configuration, database selection, flag
overrides, environments, config discovery, and editor support.
Docs fixes:
- Use game-world region names instead of cloud regions (region-us etc.)
- Replace "testnet" server with "maincloud"
- Fix config precedence order to match Vite's convention
- Fix spacetime dev step ordering (build, generate, publish)
- Fix config auto-generation description (spacetime.json + spacetime.local.json)
- Fix safety prompt description (only spacetime.json triggers it)
- Move --build-options from global to per-database overrides

Code fixes:
- Stop inheriting generate from parent to children, preventing
  different modules from silently overwriting each other's bindings
- Implement source conflict rule: if a child specifies any of
  module-path/bin-path/js-path, the others are not inherited
- Mark --num-replicas as module_specific (per-database override)
- Update tests to match new generate inheritance behavior
@futile
Copy link

futile commented Mar 1, 2026

These new docs allowed me to quickly understand how the config files work, and the order/hierarchy in which everything is applied. I thought that might be helpful feedback :) Thanks a lot!

@gefjon gefjon added documentation Improvements or additions to documentation docs deploy ASAP Important docs changes that should be deployed immediately. bugfix Fixes something that was expected to work differently CLI only This change only affects the CLI behavior labels Mar 2, 2026
Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

I haven't tested the CLI changes, but they look reasonable to me and I'm convinced by the updated automated test. The new docs page looks good; I think we should deploy it as soon as we can (thus the label).

Comment on lines +3092 to +3095
fn test_generate_not_inherited_for_children_sharing_module() {
// Even when children share the parent's module-path, generate is not inherited.
// Deduplication in generate.rs handles the common case; inheritance would be
// dangerous when a child overrides module-path.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move test description to outer doc comment.

Suggested change
fn test_generate_not_inherited_for_children_sharing_module() {
// Even when children share the parent's module-path, generate is not inherited.
// Deduplication in generate.rs handles the common case; inheritance would be
// dangerous when a child overrides module-path.
/// Even when children share the parent's module-path, generate is not inherited.
///
/// Deduplication in generate.rs handles the common case; inheritance would be
/// dangerous when a child overrides module-path.
fn test_generate_not_inherited_for_children_sharing_module() {

| `build-options` | string | Yes | Options passed to the build command |
| `break-clients` | boolean | Yes | Allow breaking changes |
| `num-replicas` | number | Yes | Number of database replicas |
| `anonymous` | boolean | Yes | Use anonymous identity |
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this apply to all CLI operations, or only specific ones? Is this gonna try to anonymously publish my database?

@bfops bfops changed the title Add spacetime.json documentation page spacetime.json updates Mar 2, 2026
Copy link
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

my code-owned changes in crates/cli/src/subcommands LGTM. the spacetime_config changes are inscrutable to me since I haven't had a chance to understand the iceberg of code that is spacetime dev + spacetime.json, so I abdicate my code-ownership of that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that was expected to work differently CLI only This change only affects the CLI behavior docs deploy ASAP Important docs changes that should be deployed immediately. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants