Skip to content

Use StorePath message type in proto for store-path fields#1636

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:harmonia-for-grpc
Mar 31, 2026
Merged

Use StorePath message type in proto for store-path fields#1636
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:harmonia-for-grpc

Conversation

@Ericson2314
Copy link
Copy Markdown
Member

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.

@Ericson2314 Ericson2314 enabled auto-merge March 31, 2026 18:52
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

@artemist artemist force-pushed the harmonia-for-grpc branch from 11a2709 to cd42188 Compare March 31, 2026 19:05
@Ericson2314 Ericson2314 enabled auto-merge March 31, 2026 19:10
Copy link
Copy Markdown
Member

@artemist artemist left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this be better implemented as an extension trait?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather not use something deprecated, but it seems like prost very much does not want you to implement Decode yourself

@Ericson2314
Copy link
Copy Markdown
Member Author

but it seems like most of that is prost's fault.

Yeah I would like to open a "look at what you made me do!" issue after this.

@Ericson2314 Ericson2314 added this pull request to the merge queue Mar 31, 2026
Merged via the queue into NixOS:master with commit c8b96da Mar 31, 2026
3 of 4 checks passed
@Ericson2314 Ericson2314 deleted the harmonia-for-grpc branch March 31, 2026 20:30
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