Skip to content

test(module): isolate concurrent fixture Wasm artifacts - #457

Merged
Mathih13 merged 2 commits into
mainfrom
fix/private-durable-wasm
Sep 7, 2026
Merged

Mathih13 merged 2 commits into
mainfrom
fix/private-durable-wasm

Conversation

@Mathih13

@Mathih13 Mathih13 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Concurrent durable fixtures can publish corrupt Wasm. SpacetimeDB 2.7.1 sends each optimizer to the same .opt.wasm output after Cargo finishes; a concurrent run read an all-zero Wasm header.

Build the Module once per test process, retain its bytes, and publish a private copy for each Standalone through --bin-path. Reuse the typed-taxi artifact reader and test four concurrent publications, including anonymous publication. Start the fixtures before the worker barrier so a startup failure cannot strand other workers.

All seven checks pass at 91c5745bed7a82536449b4670889a59b7e1020f4, including the full durable selection, Gateway auction regression, all crate suites, strict workspace clippy and binding comparison. Independent review and completed CodeRabbit review have no outstanding findings.

Pinned CLI source: https://github.com/clockworklabs/SpacetimeDB/blob/v2.7.1/crates/cli/src/tasks/mod.rs

Implemented by GPT-6 through Codex in T3 Code.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d33c6dc5-2fb4-4347-b61a-3dde0dfc66bc

📥 Commits

Reviewing files that changed from the base of the PR and between 128ad6b and 91c5745.

📒 Files selected for processing (1)
  • module/tests/fixture_publish.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The test infrastructure now builds and caches the Wasm module once per process. Publishing helpers use cached bytes through --bin-path. A concurrent fixture test covers regular and anonymous publication with SQL validation.

Changes

Module test publishing

Layer / File(s) Summary
Shared Wasm artifact support
module/tests/support/module_wasm.rs, module/tests/support/mod.rs, module/tests/typed_taxi_contracts.rs
The support module builds and caches validated Wasm bytes. Typed taxi tests use the shared helper and remove their local build logic.
Concurrent module publication
module/tests/support/mod.rs, module/tests/fixture_publish.rs, gateway/Cargo.toml, .github/workflows/module-durable.yml
Publishing helpers pass cached bytes through --bin-path. The fixture test publishes four modules concurrently and queries game_item_template. The workflow comments and gateway development dependency reflect the updated test flow.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 91c57

Module integration tests now reuse cached Wasm bytes while publishing each fixture from a private artifact path. Concurrent regular and anonymous publication is covered, with no remaining merge-blocking risk identified.

Sequence Diagram(s)

sequenceDiagram
  participant FixturePublishTest
  participant ModuleTestSupport
  participant ModulePublisher
  participant SQLQuery
  FixturePublishTest->>ModuleTestSupport: request cached module_bytes
  ModuleTestSupport->>ModulePublisher: publish Wasm bytes
  ModulePublisher-->>FixturePublishTest: publication result
  FixturePublishTest->>SQLQuery: query game_item_template
  SQLQuery-->>FixturePublishTest: query result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: isolating concurrent fixture Wasm artifacts in module tests.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/private-durable-wasm

Comment @coderabbitai help to get the list of available commands.

@Mathih13 Mathih13 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.

The private-byte publication path addresses the shared optimizer output, and the extracted Cargo artifact reader preserves the configured target directory.

One test failure path needs a fix before merge. In concurrent_fixtures_publish_complete_modules, each worker starts its Standalone before reaching a four-party Barrier. If any startup panics, the other workers wait forever and the scoped thread join cannot finish. Start all four Standalone instances before spawning the workers, then move one into each worker and put ready.wait() first. Publication still starts concurrently, while startup failures remain bounded by the existing Standalone timeout.

Please retain the current CI and CodeRabbit checks after that correction.

@Mathih13

Mathih13 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Independent review of PR #457 at 91c5745bed7a82536449b4670889a59b7e1020f4 is complete with no findings. GPT-5.6 Sol at medium effort checked repository standards, process isolation, Cargo artifact selection, target-directory handling, failure paths, the Gateway dev dependency and the concurrent publication test. It also verified the pinned SpacetimeDB CLI bypasses wasm-opt for --bin-path.

Local diagnostic tests passed: four concurrent fixture publications, including anonymous publication, and the existing typed-taxi durable contracts. Formatting and diff checks pass. Full CI and actual CodeRabbit review are still pending; this is not yet a merge handoff. Root is monitoring and will report the final result.

@Mathih13

Mathih13 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review the current head 91c5745bed7a82536449b4670889a59b7e1020f4, including the final fixture startup ordering. The branch is stable while checks and review finish.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

@Mathih13 I will review the current head, including the final fixture startup ordering.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mathih13

Mathih13 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

The startup-barrier finding is fixed in current head 91c5745bed7a82536449b4670889a59b7e1020f4: the parent starts all four Standalone fixtures first, then moves them into workers whose first operation is ready.wait(). The revised concurrent test passed locally, and current-head CI is running.

@coderabbitai The reported missing Module dependency is already present in the base and current branch: module/Cargo.toml declares serde_json = "1" under dev-dependencies. The extracted function already used it in typed_taxi_contracts before this PR. This PR adds the direct Gateway dev-dependency because that crate also includes the shared test support. Current-head cargo clippy --workspace --all-targets --all-features -- -D warnings passed, including these integration targets. Please reconcile the merge-risk statement with this evidence when completing the current-head review.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relevant files ---'
fd -t f -a '^(fixture_publish|mod|module_wasm|typed_taxi_contracts)\.rs$' module/tests gateway 2>/dev/null || true

printf '%s\n' '--- module dev-dependencies ---'
rg -n -A16 -B3 '^\[dev-dependencies\]' module/Cargo.toml

printf '%s\n' '--- gateway dev-dependencies ---'
rg -n -A16 -B3 '^\[dev-dependencies\]' gateway/Cargo.toml

printf '%s\n' '--- fixture test outline ---'
ast-grep outline module/tests/fixture_publish.rs --items all --view expanded

printf '%s\n' '--- concurrent fixture test source ---'
rg -n -A80 -B8 'concurrent|ready\.wait|thread::spawn|Standalone' module/tests/fixture_publish.rs

Length of output: 4293


@Mathih13 The current source confirms both corrections.

module/tests/fixture_publish.rs starts all four Standalone fixtures before it creates the worker threads. Each worker calls ready.wait() before it publishes. This removes the reported fixture startup ordering risk.

module/Cargo.toml declares serde_json = "1" under [dev-dependencies]. gateway/Cargo.toml also declares serde_json = "1" under [dev-dependencies]. The direct Gateway dependency is required for its integration targets that include the shared test support.

I withdraw the prior merge-risk statements for the startup barrier and the missing Module dependency.


✏️ Learnings added
Learnt from: Mathih13
URL: https://github.com/LyraCoreProject/LyraCore/pull/457

Timestamp: 2026-09-07T15:39:02.478Z
Learning: In `module/tests/fixture_publish.rs`, the concurrent publication test must start every `Standalone` fixture in the parent before worker threads begin. Each worker must wait on the shared `Barrier` before calling `Standalone::publish_module()` or `Standalone::publish_module_anonymous()`.

Learnt from: Mathih13
URL: https://github.com/LyraCoreProject/LyraCore/pull/457

Timestamp: 2026-09-07T15:39:02.478Z
Learning: Both `module/Cargo.toml` and `gateway/Cargo.toml` require `serde_json = "1"` under `[dev-dependencies]` because their integration-test targets compile shared test support that uses `serde_json`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@Mathih13
Mathih13 merged commit 180a681 into main Sep 7, 2026
7 checks passed
@Mathih13
Mathih13 deleted the fix/private-durable-wasm branch October 11, 2026 18:20
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