Define and use HLKPlatform sorbet type #972
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the platform configuration logic by replacing hash-based data access with Sorbet-typed models, specifically introducing HLKPlatform, HLKClient, and HLKPlatformClientsOptions. The changes span several modules, including hckinstall, hcktest, and the qemuhck setup manager, updating them to use method calls and adding type signatures. Feedback from the review identifies several high-severity issues in the new models: the merge! method in HLKPlatformClientsOptions uses incorrect logic for booleans and default values while violating Sorbet's immutability for const fields. Furthermore, the use of the unsupported factory: keyword in T::Struct was flagged as a likely cause for runtime errors.
There was a problem hiding this comment.
Pull request overview
This PR introduces a Sorbet-typed Models::HLKPlatform (and related structs) and migrates platform access from hash-style (['key']/dig) to typed attribute access across engines/setup managers, aiming to make platform configuration safer and more consistent.
Changes:
- Add
Models::HLKPlatform,Models::HLKClient, andModels::HLKPlatformClientsOptionsas SorbetT::Structs. - Update
hcktest,hckinstall,qemuhck, and ancillary code to use typed accessors instead of JSON hashes. - Extend the JSON-load spec to validate platform JSON files against the new type.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/srb_json_load_spec.rb | Adds HLK platform JSON glob to Sorbet JSON-load coverage. |
| lib/models/hlk_platform.rb | Introduces new Sorbet structs for platform/client/options plus validation. |
| lib/models.rb | Registers new model autoloads for HLK platform types. |
| lib/models/svvp_config.rb | Switches SVVP clients_options type to the shared HLK platform clients options struct. |
| lib/engines/hcktest/hcktest.rb | Loads platform as Models::HLKPlatform and updates platform/client option access. |
| lib/engines/hcktest/tools.rb | Updates client address extraction to use typed client attributes. |
| lib/engines/hckinstall/hckinstall.rb | Updates install flow to use typed platform attributes (kit/clients/iso selection). |
| lib/setupmanagers/qemuhck/qemuhck.rb | Migrates QemuHCK to typed platform access and adds Sorbet signatures. |
| lib/project.rb | Types @engine_platform as T.nilable(Models::HLKPlatform) and updates usage. |
| lib/junit.rb | Updates platform name extraction to typed access (.name). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0e41534 to
bc0dcc1
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request transitions the configuration handling from generic hashes to formal Sorbet models (HLKPlatform, HLKClient, and HLKPlatformClientsOptions), updating the install and test engines to utilize these typed structures. While this improves type safety, the review identifies critical bugs in the HLKPlatformClientsOptions#merge! implementation, specifically regarding the mutation of immutable const fields, the use of non-standard methods like .present?, and logic errors that prevent the correct merging of boolean values. A minor refactoring to remove a redundant variable in hckinstall.rb was also suggested.
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the platform and client configuration parsing to use strongly-typed Sorbet models (HLKPlatform, HLKClient, and HLKPlatformClientsOptions) instead of raw JSON hashes. Hash accessors have been replaced with typed method calls across the codebase, and validation logic has been added for QEMU HCK platforms. The review feedback correctly identifies a potential runtime NoMethodError due to a missing nil check on @engine_platform in lib/project.rb, as well as Sorbet type-checking issues regarding nilable firmware binaries in lib/setupmanagers/qemuhck/qemuhck.rb.
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
No description provided.