Use StorePath message type in proto for store-path fields#1636
Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom Mar 31, 2026
Merged
Use StorePath message type in proto for store-path fields#1636Ericson2314 merged 1 commit intoNixOS:masterfrom
StorePath message type in proto for store-path fields#1636Ericson2314 merged 1 commit intoNixOS:masterfrom
Conversation
The proto file already had `message StorePath { string path = 1; }`
but it was only used as a top-level RPC argument. Fields like
`BuildMessage.drv`, `LogChunk.drv`, and `FetchRequisitesRequest.path`
were plain `string` even though they always contain store paths.
This commit changes those fields to use the `StorePath` message type,
making the schema self-documenting and paving the way for type-safe
gRPC code on the Rust side.
On the Rust side, a `ProtoStorePath` newtype in the `shared` crate
wraps `harmonia_store_core::store_path::StorePath` and implements
`prost::Message` to match the proto wire format. prost-build's
`extern_path` maps the proto `StorePath` message to this newtype,
so generated code uses `ProtoStorePath` directly — eliminating the
manual `parse_store_path` calls that were scattered across the gRPC
handlers.
auto-merge was automatically disabled
March 31, 2026 19:05
Head branch was pushed to by a user without write access
11a2709 to
cd42188
Compare
artemist
reviewed
Mar 31, 2026
Member
artemist
left a comment
There was a problem hiding this comment.
I don't really like this, but it seems like most of that is prost's fault.
| /// | ||
| /// where `path` contains the store-path base name (`<hash>-<name>`). | ||
| #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
| pub struct ProtoStorePath(pub StorePath); |
Member
There was a problem hiding this comment.
Could this be better implemented as an extension trait?
Member
Author
There was a problem hiding this comment.
I had to make a new type because otherwise we run afowl of the orphan restriction. It could go in Harmonia itself underneath a feature, though.
| 1 => { | ||
| let mut s = String::new(); | ||
| encoding::string::merge(wire_type, &mut s, buf, ctx)?; | ||
| #[allow(deprecated)] |
Member
There was a problem hiding this comment.
I'd rather not use something deprecated, but it seems like prost very much does not want you to implement Decode yourself
Member
Author
Yeah I would like to open a "look at what you made me do!" issue after this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The proto file already had
message StorePath { string path = 1; }but it was only used as a top-level RPC argument. Fields likeBuildMessage.drv,LogChunk.drv, andFetchRequisitesRequest.pathwere plainstringeven though they always contain store paths.This commit changes those fields to use the
StorePathmessage type, making the schema self-documenting and paving the way for type-safe gRPC code on the Rust side.On the Rust side, a
ProtoStorePathnewtype in thesharedcrate wrapsharmonia_store_core::store_path::StorePathand implementsprost::Messageto match the proto wire format. prost-build'sextern_pathmaps the protoStorePathmessage to this newtype, so generated code usesProtoStorePathdirectly — eliminating the manualparse_store_pathcalls that were scattered across the gRPC handlers.