This project uses mise to manage development tools and run tasks. Mise ensures everyone uses the same tool versions and provides a consistent development experience.
- mise - Development tool manager (required)
- SpacetimeDB CLI - For running integration tests
# Install mise
curl https://mise.run | sh
# Add to your shell (choose one):
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc # Bash
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc # Zsh
echo '~/.local/bin/mise activate fish | source' >> ~/.config/fish/config.fish # Fish
# Restart your shell or run:
source ~/.bashrc # or ~/.zshrc# Clone the repository
git clone https://github.com/perplexes/spacetime-workflow-engine
cd spacetime-workflow-engine
# Trust the mise configuration (required once per project)
mise trust
# Install all development tools (Rust, Node.js)
mise install
# Run setup to install dependencies and verify environment
mise run setupThis will:
- Install Rust stable (for building the workflow engine)
- Install Node.js 22 (for TypeScript integration tests)
- Install npm dependencies for TypeScript tests
- Verify SpacetimeDB CLI is available
# Install SpacetimeDB CLI (if not already installed)
mise run setup-spacetime
# Start local SpacetimeDB server
spacetime start
# Deploy the example module
mise run publish
# Verify it's working
mise run logsThe mise.toml file defines:
- Tool versions: Rust 1.75, Node.js 22
- Environment variables: SpacetimeDB connection settings
- Tasks: Build, test, lint, deploy commands
When you enter the project directory, mise automatically:
- Activates the correct tool versions
- Sets up environment variables
- Makes all tasks available via
mise run <task>
mise run test # All unit tests
mise run test-core # Core library only
mise run test-specific -- test_name # Specific test
mise run tv # With verbose outputIntegration tests require a running SpacetimeDB server.
# Start SpacetimeDB if not running
spacetime start
# Full integration suite (deploys module + runs TypeScript tests)
mise run integration
# Or run TypeScript tests only (assumes module already deployed)
mise run test-tsmise run test # Rust unit tests
mise run test-core # Core library tests only
mise run test-ts # TypeScript integration tests
mise run integration # Full suite (deploy + TypeScript)
mise run tv # Verbose test output
mise run verify # fmt + clippy + testCode must pass formatting and linting checks:
mise run fmt # Format code
mise run clippy # Run lints
mise run verify # Run all checks (fmt + clippy + test)- Use
snake_casefor timer and signal wire names (the derive macros do this automatically) - Workflow handlers should be stateless structs - all state goes in
Statetype - Prefer the fluent API:
WorkflowResult::to("step").after_timer(T::X, 1.secs()) - Use
#[derive(Timer)]and#[derive(Signal)]for type safety - Keep workflow logic in handler methods; reducers should be thin wrappers
- Public items should have doc comments
- Examples in doc comments should use
ignoresince they require SpacetimeDB context - Update relevant docs in
docs/when changing public APIs
spacetime-workflow-engine/
├── core/ # workflow-core crate (pure Rust, no SpacetimeDB deps)
│ └── src/
│ ├── handler.rs # WorkflowHandler trait
│ ├── types.rs # WorkflowResult, TimerRequest, etc.
│ ├── registry.rs # Global workflow registry
│ └── traits.rs # Timer, Signal traits
├── macros/ # workflow-macros crate (proc macros)
│ └── src/
│ └── lib.rs # Timer, Signal derives + install! macro
├── example/ # Example SpacetimeDB module
│ └── src/
│ ├── lib.rs # Module entry point
│ └── workflows/ # Example workflow implementations
├── tests/
│ └── typescript/ # TypeScript integration tests
└── docs/ # Documentation
- Add implementation to appropriate file in
core/src/ - Export from
core/src/lib.rsif public - Add to
core/src/prelude.rsif commonly used - Write unit tests in the same file or
core/src/proptest_tests.rs - Update
docs/API.mdif it's a public API
- Add implementation in
macros/src/lib.rs - Add tests in
example/showing usage - Update
docs/API.mdwith examples
- Create new file in
example/src/workflows/ - Export from
example/src/workflows/mod.rs - Register in
install!{}block inexample/src/lib.rs - Add test reducers if needed
- Add TypeScript tests in
tests/typescript/integration.test.ts - Regenerate bindings:
spacetime generate --lang typescript --out-dir tests/typescript/bindings --project-path example
Follow conventional commit style:
Add feature X for Y
- Bullet points for details if needed
- Keep lines under 72 characters
Co-Authored-By: Your Name <email@example.com>
Good commit message examples from this repo:
Add TypeScript integration tests and fix module reloadRestructure as workspace for easy Cargo integrationAdd ergonomic API: derive macros, fluent builder, duration extensions
- Create a feature branch from
main - Make your changes with tests
- Run the full verification:
mise run verify # fmt + clippy + test mise run integration # if you changed runtime behavior
- Update documentation as needed
- Submit PR with clear description of changes
Before submitting:
-
mise run fmt-checkpasses -
mise run clippypasses -
mise run testpasses -
mise run integrationpasses (if runtime behavior changed) - New public APIs are documented
- Examples compile and work
- Check existing documentation
- Look at example workflows in
example/src/workflows/ - Open an issue for questions or bugs