Skip to content

docs: document reducer context random APIs#5306

Closed
clockwork-labs-bot wants to merge 2 commits into
masterfrom
docs/reducer-context-random-api
Closed

docs: document reducer context random APIs#5306
clockwork-labs-bot wants to merge 2 commits into
masterfrom
docs/reducer-context-random-api

Conversation

@clockwork-labs-bot

@clockwork-labs-bot clockwork-labs-bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add reducer context examples for deterministic random values across TypeScript, C#, Rust, and C++
  • clarify the context-provided random API usage that the agent skills already reference
  • correct the C++ example to match the SDK's inclusive gen_range(min, max) behavior

Validation

  • pnpm --dir docs build passed.
    • Docusaurus emitted the existing llms-txt warning for /docs/ask-ai/ask-ai, then completed successfully.
  • TypeScript snippet calls typechecked with tsc against sdks/typescript/src/server/rng.ts and sdks/typescript/src/server/sys.d.ts:
    • ctx.random()
    • ctx.random.integerInRange(1, 6)
    • ctx.random.fill(new Uint8Array(16))
  • Rust RNG context examples passed existing doctests:
    • cargo test -p spacetimedb --doc rng --features rand
  • C++ snippet syntax checked against the SDK headers:
    • clang++ -std=c++20 -Icrates/bindings-cpp/include -x c++ -fsyntax-only -
    • The compile emitted existing warning noise for WASM import/export attributes, but exited successfully.
  • C# was not compiled locally because dotnet is not installed on this host. The documented ctx.Rng.NextDouble() and ctx.Rng.Next(1, 7) calls were checked against the generated/runtime context source where ReducerContext.Rng is a System.Random.

Notes

  • A package-wide TypeScript declarations build was not used as validation here because this checkout currently fails before the snippet on missing optional Solid typings (solid-js / solid-js/store).

@clockwork-labs-bot

Copy link
Copy Markdown
Contributor Author

Closed in favor of the consolidated daily docs audit PR #5410 on branch bot/docs-audit.

pull Bot pushed a commit to age-rs/SpacetimeDB that referenced this pull request Jun 22, 2026
# Description of Changes

- Fix TypeScript connection examples to call `DbConnection.builder()`
without `new` and include `.build()`.
- Document reducer context random APIs across TypeScript, C#, Rust, and
C++.
- Align reducer skill determinism guidance with the documented
context-provided RNG API.
- Consolidates the work from clockworklabs#5403 and clockworklabs#5306 into the single daily docs
audit branch `bot/docs-audit`.

# API and ABI breaking changes

None. Documentation and agent skill guidance only.

# Expected complexity level and risk

1. This is a low-risk docs-only change plus one agent skill wording
update.

# Testing

- [x] `pnpm --dir docs build` passed. Docusaurus emitted the existing
`docusaurus-plugin-llms-txt` warning for `/docs/ask-ai/ask-ai`, then
generated static files successfully.
- [ ] Reviewer can check that the TypeScript connection snippets match
the SDK builder API.
- [ ] Reviewer can check that the reducer context RNG examples match the
supported APIs for each SDK.

---------

Co-authored-by: rain <rain@rain.local>
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.

1 participant