Skip to content

chore: update s2 sdk#6

Merged
sgbalogh merged 3 commits intomainfrom
update
Jan 21, 2026
Merged

chore: update s2 sdk#6
sgbalogh merged 3 commits intomainfrom
update

Conversation

@sgbalogh
Copy link
Member

Also adds example on running against s2-lite

@sgbalogh sgbalogh changed the title update s2 sdk chore: update s2 sdk Jan 21, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This PR migrates from the legacy streamstore SDK to the newer s2-sdk (v0.23.0+) and adds documentation for running against s2-lite.

Key changes:

  • Replaced streamstore::Client with s2_sdk::S2 for client initialization
  • Updated type imports: BasinName, StreamName, ReadInput, ReadBatch, etc.
  • Migrated error handling from tonic::Code to S2Error variants with proper classification of definite vs indefinite failures
  • Adapted read API: ReadOutput::BatchReadBatch, handling tail position through batch.tail field
  • Improved hash computation flow by introducing GeneratedBatch struct to pass last_xxh3 explicitly
  • Added comprehensive example in README for running against local s2-lite instance

Issues found:

  • Typo in README heading: "aginst" instead of "against"
  • Minor formatting issue: extra space before else in history.rs:542

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The SDK migration is comprehensive and well-executed with proper error handling updates, type migrations, and API adaptations. Only minor cosmetic issues (typo and formatting) were found that don't affect functionality
  • No files require special attention - the migration is straightforward and properly handles all API changes

Important Files Changed

Filename Overview
README.md Added documentation for running against s2-lite with a typo in the heading ("aginst" should be "against")
rust/s2-verification/Cargo.toml Updated dependencies: replaced streamstore with s2-sdk >=0.23.0, removed tonic, bumped version to 0.2.0
rust/s2-verification/src/bin/collect-history.rs Migrated from streamstore SDK to s2-sdk: updated types, error handling, and client initialization patterns
rust/s2-verification/src/history.rs Updated SDK types and error handling: adapted read stream handling for new ReadBatch API, improved error classification logic with minor formatting issue

Sequence Diagram

sequenceDiagram
    participant App as collect-history
    participant SDK as s2-sdk (new)
    participant S2 as S2 Service
    
    Note over App,S2: SDK Migration Flow
    
    App->>SDK: S2::new(config)
    SDK-->>App: S2 client instance
    
    App->>SDK: s2.basin(basin_name)
    SDK-->>App: Basin client
    
    App->>SDK: basin.stream(stream_name)
    SDK-->>App: S2Stream
    
    App->>S2: create_stream(CreateStreamInput)
    alt Stream already exists
        S2-->>App: S2Error::Server(resource_already_exists)
    else Stream created
        S2-->>App: Success
    end
    
    App->>S2: check_tail()
    S2-->>App: Position
    
    App->>S2: read(ReadInput)
    alt Stream has data
        S2-->>App: ReadBatch with records
        Note over App: Compute xxh3 hash, rectify tail
    else Stream empty
        S2-->>App: S2Error::ReadUnwritten
    end
    
    loop For each concurrent client
        App->>SDK: S2::new(config)
        SDK-->>App: New client instance
        App->>SDK: basin.stream(stream_name)
        SDK-->>App: S2Stream
        
        loop num_ops_per_client
            alt Append operation
                App->>S2: append(AppendInput)
                alt Success
                    S2-->>App: AppendAck
                else Validation/Condition error
                    S2-->>App: S2Error (definite failure)
                else Side-effect error
                    S2-->>App: S2Error (indefinite failure)
                end
            else Read operation
                App->>S2: read_session(ReadInput)
                S2-->>App: Streaming<ReadBatch>
            else CheckTail operation
                App->>S2: check_tail()
                S2-->>App: Position
            end
        end
    end
    
    Note over App: Write history to JSONL file
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

README.md Outdated
``` No newline at end of file
```

## Running aginst `s2-lite`
Copy link

Choose a reason for hiding this comment

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

syntax: typo: "aginst" should be "against"

Suggested change
## Running aginst `s2-lite`
## Running against `s2-lite`
Prompt To Fix With AI
This is a comment left during a code review.
Path: README.md
Line: 132:132

Comment:
**syntax:** typo: "aginst" should be "against"

```suggestion
## Running against `s2-lite`
```

How can I resolve this? If you propose a fix, please make it concise.

} else {
CallFinish::AppendDefiniteFailure
}
}
Copy link

Choose a reason for hiding this comment

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

style: formatting: extra space before else

Suggested change
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: rust/s2-verification/src/history.rs
Line: 542:542

Comment:
**style:** formatting: extra space before `else` 

```suggestion
                }
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@sgbalogh sgbalogh merged commit e149253 into main Jan 21, 2026
2 checks passed
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.

2 participants