fix(decider): preserve event-sourcing correctness - #491
Conversation
yordis
commented
Jul 19, 2026
- Creation correctness depends on the append guard remaining authoritative under stale state and concurrent first writers.
- Projection progress must not depend on unrelated subjects owning the physical stream tail.
- Durable WASM recovery requires snapshot identities that remain valid at the storage boundary.
PR SummaryMedium Risk Overview Subject-filtered WASM snapshot IDs move to a JetStream integration tests are centralized on Reviewed by Cursor Bugbot for commit 68bcbd5. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (23)
WalkthroughThe changes update effective ChangesFiltered projector catch-up
Effective NoStream execution
Versioned WASM snapshot identifiers
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant CommandEnvelope
participant WasmCommandExecution
participant EventStore
participant SnapshotStore
participant Append
CommandEnvelope->>WasmCommandExecution: provide command and write override
WasmCommandExecution->>WasmCommandExecution: resolve effective precondition
WasmCommandExecution->>EventStore: read replay when not NoStream
WasmCommandExecution->>SnapshotStore: read snapshot when not NoStream
WasmCommandExecution->>Append: append decided events
Append-->>WasmCommandExecution: return success or write conflict
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
rsworkspace/crates/trogon-decider-wasm-runtime/src/snapshot_id.rs (1)
38-39: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueAvoid an intermediate string allocation when encoding.
URL_SAFE_NO_PAD.encode(...)allocates a newStringwhich is then immediately copied into another newStringbyformat!. You can useencode_stringto append the base64 output directly to the"v1_"prefix, saving an allocation.💡 Proposed refactor
- let logical_identity = format!("{module_name}@{module_version}/{stream_id}"); - Self(format!("v1_{}", URL_SAFE_NO_PAD.encode(logical_identity))) + let logical_identity = format!("{module_name}@{module_version}/{stream_id}"); + let mut id = String::from("v1_"); + URL_SAFE_NO_PAD.encode_string(logical_identity, &mut id); + Self(id)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rsworkspace/crates/trogon-decider-wasm-runtime/src/snapshot_id.rs` around lines 38 - 39, Update the snapshot ID construction in the Self formatter to avoid creating an intermediate encoded String: initialize the output with the "v1_" prefix, use URL_SAFE_NO_PAD.encode_string to append the encoded logical identity directly, and return it while preserving the existing format.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rsworkspace/crates/trogon-decider-nats/src/projector/tests.rs`:
- Around line 235-236: Replace the local NatsServer startup and connect flow in
the projector tests with the existing trogon-nats test helpers, removing
reliance on testcontainers-modules. Apply this consistently at
rsworkspace/crates/trogon-decider-nats/src/projector/tests.rs:235-236, 266-267,
and 298-299, while preserving each test’s existing connection usage.
In
`@rsworkspace/crates/trogon-decider-nats/src/store/tests/command_execution_tests.rs`:
- Around line 151-175: The NatsServer and TestSubjectResolver test bootstrap is
duplicated across both NATS test files. Create a shared test-support helper
containing the JetStream-enabled NATS container setup and resolver, then update
NatsServer usage in
rsworkspace/crates/trogon-decider-nats/src/store/tests/command_execution_tests.rs:151-175
and rsworkspace/crates/trogon-decider-wasm-runtime/tests/nats_execution.rs:32-55
to import and reuse it, removing the duplicated local definitions.
---
Nitpick comments:
In `@rsworkspace/crates/trogon-decider-wasm-runtime/src/snapshot_id.rs`:
- Around line 38-39: Update the snapshot ID construction in the Self formatter
to avoid creating an intermediate encoded String: initialize the output with the
"v1_" prefix, use URL_SAFE_NO_PAD.encode_string to append the encoded logical
identity directly, and return it while preserving the existing format.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef39122c-eaba-4271-a3f9-d38b3864fde8
⛔ Files ignored due to path filters (1)
rsworkspace/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
docs/architecture/decider.mdrsworkspace/crates/trogon-decider-nats/src/projector.rsrsworkspace/crates/trogon-decider-nats/src/projector/tests.rsrsworkspace/crates/trogon-decider-nats/src/store/tests.rsrsworkspace/crates/trogon-decider-nats/src/store/tests/command_execution_tests.rsrsworkspace/crates/trogon-decider-runtime/src/execution.rsrsworkspace/crates/trogon-decider-runtime/src/execution/tests.rsrsworkspace/crates/trogon-decider-wasm-runtime/Cargo.tomlrsworkspace/crates/trogon-decider-wasm-runtime/src/execution.rsrsworkspace/crates/trogon-decider-wasm-runtime/src/execution/tests.rsrsworkspace/crates/trogon-decider-wasm-runtime/src/registry.rsrsworkspace/crates/trogon-decider-wasm-runtime/src/snapshot_id.rsrsworkspace/crates/trogon-decider-wasm-runtime/src/snapshot_id/tests.rsrsworkspace/crates/trogon-decider-wasm-runtime/tests/nats_execution.rsrsworkspace/crates/trogon-decider-wasm-runtime/tests/schedules_execution.rsrsworkspace/crates/trogon-decider-wasm-runtime/tests/support/mod.rs
Code Coverage SummaryDetailsDiff against mainResults for commit: 68bcbd5 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
097c41e to
5e5aea4
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>