Skip to content

[DEV-1658] Support projection v2 engine#229

Merged
w1am merged 1 commit into
masterfrom
w1am/dev-1658-rust-support-projection-v2-engine
May 6, 2026
Merged

[DEV-1658] Support projection v2 engine#229
w1am merged 1 commit into
masterfrom
w1am/dev-1658-rust-support-projection-v2-engine

Conversation

@w1am
Copy link
Copy Markdown

@w1am w1am commented May 6, 2026

Adds support for selecting the V2 projection engine when creating a projection via a new engine version option. V1 remains the default.

Closes DEV-1658.

@linear
Copy link
Copy Markdown

linear Bot commented May 6, 2026

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add projection engine version selection support

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds ProjectionEngineVersion enum supporting V1 and V2 engines
• Introduces engine_version field to projection creation options
• Implements builder method for setting engine version preference
• Updates protobuf schema to include engine version parameter
Diagram
flowchart LR
  A["ProjectionEngineVersion enum<br/>V1 default, V2 option"] --> B["CreateProjectionOptions<br/>engine_version field"]
  B --> C["ProjectionClient<br/>passes to protobuf"]
  C --> D["projections.proto<br/>engine_version parameter"]
Loading

Grey Divider

File Changes

1. kurrentdb/src/options/projections.rs ✨ Enhancement +27/-0

Add projection engine version enum and options

• Adds ProjectionEngineVersion enum with V1 (default) and V2 variants
• Implements as_i32() conversion method for protobuf serialization
• Adds engine_version field to CreateProjectionOptions struct
• Implements builder method engine_version() for fluent configuration

kurrentdb/src/options/projections.rs


2. kurrentdb/src/event_store/generated/projections.rs Dependencies +2/-0

Add engine version field to protobuf message

• Adds engine_version: i32 field to protobuf Options message
• Field uses tag 5 in protobuf schema

kurrentdb/src/event_store/generated/projections.rs


3. kurrentdb/src/projection_client.rs ✨ Enhancement +1/-0

Pass engine version to projection creation request

• Passes engine_version from options to protobuf request
• Converts enum value using as_i32() method

kurrentdb/src/projection_client.rs


View more (1)
4. kurrentdb/protos/projections.proto ⚙️ Configuration changes +1/-0

Add engine version field to protobuf schema

• Adds int32 engine_version = 5 field to Options message
• Positioned after query field in schema

kurrentdb/protos/projections.proto


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented May 6, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. V1 sent as non-zero 🐞 Bug ≡ Correctness
Description
ProjectionClient::create always sets engine_version from options, and the default V1 maps to 1, so
requests will always carry a non-zero engine_version even when the user didn’t opt into V2. This
removes the ability to send the protobuf-default value (0 / omitted-on-wire) for the default path,
which can break or change behavior on servers that treat 0/unspecified specially.
Code

kurrentdb/src/projection_client.rs[R75-80]

            projections::create_req::Options {
                query: query.clone(),
+                engine_version: options.engine_version.as_i32(),
                mode: Some(projections::create_req::options::Mode::Continuous(
                    projections::create_req::options::Continuous {
                        name: name.as_ref().to_string(),
Evidence
The protobuf schema introduces engine_version as a plain int32 (defaulting to 0 in proto3), but the
Rust API’s default (V1) is converted to 1 and is always assigned into the request, meaning the field
is never left at its default value for the default engine selection path.

kurrentdb/protos/projections.proto[28-32]
kurrentdb/src/options/projections.rs[6-19]
kurrentdb/src/projection_client.rs[74-84]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ProjectionClient::create` unconditionally sets `engine_version`, and the default `ProjectionEngineVersion::V1` is mapped to `1`. In proto3, an `int32` defaults to `0` (and is typically omitted on the wire when 0), so the client can no longer send the default/unspecified value for the default engine.

### Issue Context
This change alters on-wire behavior for the default code path (previously “no engine version field existed / was absent”, now “engine_version is explicitly set to 1”). If servers differentiate between 0/unspecified and explicit values, this can change behavior.

### Fix Focus Areas
- kurrentdb/src/options/projections.rs[13-19]
- kurrentdb/src/projection_client.rs[74-84]
- kurrentdb/protos/projections.proto[21-40]

### Suggested direction
- Map `V1` to `0` (so it stays protobuf-default) and `V2` to `1` (or whatever the server expects), OR
- Make `engine_version` `optional int32` (or better, a proto `enum`) and only populate it when the user selects `V2`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@w1am w1am changed the title feat: support projection v2 engine [DEV-1658] Support projection v2 engine May 6, 2026
@w1am w1am self-assigned this May 6, 2026
@w1am w1am merged commit 451c692 into master May 6, 2026
77 of 79 checks passed
@w1am w1am deleted the w1am/dev-1658-rust-support-projection-v2-engine branch May 6, 2026 08:15
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@w1am 👉 Created pull request targeting release/v1.2: #230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant