fix(snapshot): decouple snapshot identity from storage keys#188
Conversation
yordis
commented
May 29, 2026
- Snapshot schema identity needs to remain independent from backend-specific key layouts so each store can use its own addressing model.
- Snapshot decoding needs to fail closed when persisted state belongs to a different schema identity.
PR SummaryMedium Risk Overview Runtime API: NATS adapter: JetStream KV keys move to Call sites: Execution and JetStream store pass Reviewed by Cursor Bugbot for commit ff2a4da. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughSnapshot type names are validated and returned via SnapshotType::snapshot_type(); EncodedSnapshot envelopes include a ChangesSnapshot Type System Refactoring
Sequence Diagram(s)sequenceDiagram
participant Client
participant SnapshotCodec
participant SnapshotStore
participant JetStreamKV
Client->>SnapshotStore: list/get snapshots for SnapshotType
SnapshotStore->>JetStreamKV: list/get keys with snapshots.data.<type>.*
JetStreamKV-->>SnapshotStore: key, value
SnapshotStore->>SnapshotCodec: decode value (read embedded "type")
SnapshotCodec-->>SnapshotStore: Snapshot<T> or UnexpectedType
SnapshotStore-->>Client: validated snapshots (skips colliding keys)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Code Coverage SummaryDetailsDiff against mainResults for commit: ff2a4da Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/encoded_snapshot.rs (1)
35-42:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winBack-compat: required
SnapshotEnvelope.typebreaks decoding of older envelopes
SnapshotEnvelopedeclaresr#type: Stringwith only#[serde(rename = "type")](no#[serde(default)]), andEncodedSnapshot::from_bytesdeserializes the envelope viaserde_json::from_sliceand maps any serde failure intoSnapshotEnvelopeDecodeError::envelope_source. Older persisted envelopes that lack thetypekey will therefore fail deserialization (“missing fieldtype”) rather than producing a clearer typed “unexpected type” error; add a migration/back-compat decode path if such data can exist.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a28f264d-45d7-4b71-8cbb-995336672962
📒 Files selected for processing (6)
rsworkspace/crates/trogon-decider-nats/src/snapshot_store.rsrsworkspace/crates/trogon-decider-runtime/src/execution.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/encoded_snapshot.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/snapshot_decode_error.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/snapshot_type.rsrsworkspace/crates/trogonai-proto/src/scheduler/schedules/codec.rs
a5e3787 to
220d826
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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-runtime/src/snapshot/snapshot_type.rs`:
- Around line 2-4: Replace the primitive snapshot identifier return type with a
dedicated value object: introduce a SnapshotTypeId type (with a fallible
constructor like SnapshotTypeId::new or TryFrom<&str> that enforces the
invariant and returns a specific error type) and change the trait method
signature fn snapshot_type() -> Result<SnapshotTypeId, Self::Error>; update any
implementations to construct/return SnapshotTypeId via its validated factory;
ensure SnapshotTypeId implements common traits needed by callers (Display, Eq,
Hash, Clone, Debug and serde traits if used) so callers stop depending on a raw
&'static str and invalid identifiers become unrepresentable.
🪄 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: e29d31ec-d1f5-4e72-9006-587504b50d1e
📒 Files selected for processing (9)
rsworkspace/crates/trogon-decider-nats/src/snapshot_store.rsrsworkspace/crates/trogon-decider-nats/src/store.rsrsworkspace/crates/trogon-decider-runtime/src/execution.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/encoded_snapshot.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/snapshot_decode_error.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/snapshot_encode_error.rsrsworkspace/crates/trogon-decider-runtime/src/snapshot/snapshot_type.rsrsworkspace/crates/trogonai-proto/src/codec.rsrsworkspace/crates/trogonai-proto/src/scheduler/schedules/codec.rs
🚧 Files skipped from review as they are similar to previous changes (7)
- rsworkspace/crates/trogonai-proto/src/scheduler/schedules/codec.rs
- rsworkspace/crates/trogonai-proto/src/codec.rs
- rsworkspace/crates/trogon-decider-nats/src/store.rs
- rsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/encoded_snapshot.rs
- rsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/snapshot_decode_error.rs
- rsworkspace/crates/trogon-decider-runtime/src/snapshot/codec/snapshot_encode_error.rs
- rsworkspace/crates/trogon-decider-nats/src/snapshot_store.rs
220d826 to
da1c745
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit da1c745. Configure here.
14d143c to
6909bf2
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
6909bf2 to
ff2a4da
Compare
