Skip to content

crates/remote-{client,proto}: implement check RPC definitions - #161

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/check
Apr 25, 2026
Merged

twitchyliquid64 merged 1 commit into
mainfrom
tom/check

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Remote check now supports sending a directory and streaming back per-object check results (packages, profiles, harnesses) with verdicts and error details.
    • Client/API adds configurable filters and checker selection for targeted validations; new arguments surface these options.
    • Protocol and service now expose a bidirectional streaming RPC for the check workflow.
  • Tests

    • Added tests that validate tarball transfer and result/verdict mapping.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Refactors CheckResult.check from &'static str to Cow<'static, str>, updates callers to use .into(), and adds a streaming remote Check RPC with protobufs plus a client-side Client::check implementation that streams a compressed archive and consumes server check responses.

Changes

Cohort / File(s) Summary
Check library type refactor
crates/check/src/lib.rs, crates/check/src/harness.rs, crates/check/src/naming.rs, crates/check/src/outputs.rs, crates/check/src/profile.rs
Changed CheckResult.check from &'static str → Cow<'static, str> and updated all constructor sites to set check via .into(); no other logic changes.
Remote client check API & tests
crates/remote-client/src/lib.rs, crates/remote-client/Cargo.toml
Added Client::check method and CheckArgs struct, streams a tar.zst archive as CheckMessage::Chunk, spawns a background task consuming CheckResponse stream, maps remote verdicts to local enums, and includes tests (CheckMockServer); added check workspace dependency.
Protobufs & build
crates/remote-proto/protos/res/check.proto, crates/remote-proto/protos/res/remote_execution_service.proto, crates/remote-proto/build.rs
Added res/check.proto (messages: CheckMessage, CheckRequest, CheckObject, CheckResult, CheckResponse, CheckVerdict) and new rpc Check(stream CheckMessage) returns (stream CheckResponse); included res/check.proto in protobuf compilation.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Client as Remote Client
    participant Compressor as TarZst Compressor
    participant Server as Remote Server

    User->>Client: call check(dir, args)
    Client->>Compressor: compress directory -> tar.zst (streamable)
    Client->>Server: send initial CheckRequest (client_id, filters, flags)
    loop upload chunks
        Client->>Server: send CheckMessage::Chunk(bytes)
    end
    Server->>Server: assemble archive & run checkers
    alt success
        Server->>Client: CheckResponse::Check(CheckObject + results)
        Client->>User: emit mapped (CheckObj, Vec<CheckResult>)
    else error
        Server->>Client: CheckResponse::Error(message)
        Client->>User: emit Error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • gominimal/build-servers#52: Changes the check crate's public API and invokes check::run_checks, closely related to the CheckResult type change and remote check integration.

Poem

🐰 I packed a dir in whisper-thin tar,

I hopped it off to servers afar,
Cowed my strings, streamed bytes in flight,
Verdicts came back in morning light—
A rabbit's cheer: the checks took flight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: implementing check RPC definitions in remote-client and remote-proto crates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/check

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
crates/remote-client/src/lib.rs (1)

1030-1060: Add one explicit test for server-side CheckResponse::Error handling.

The success path is covered well, but the error branch in Client::check (Line 497) is currently unexercised.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/remote-client/src/lib.rs` around lines 1030 - 1060, Add a test that
exercises the error branch of Client::check by having the mock
RemoteExecutionServiceServer send a CheckResponse::Error and asserting that
client.check returns an Err; specifically, create a new #[tokio::test] that sets
up a temp dir and a RemoteExecutionServiceServer which responds with
CheckResponse::Error (matching the enum used in the CheckResponse handling
inside Client::check) and then call Client::check (the method around Line 497)
and assert the returned result is an error and contains the expected error
message/variant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 446-455: The code panics because the result of the
tokio::task::spawn_blocking + and_then is unwrapped; change Client::check's
stream setup to propagate errors instead of calling unwrap by replacing the
final .unwrap() with proper error propagation (e.g., use ? or .map_err(...) and
return Err(Error::Other(...)) from Client::check). Specifically locate the
spawn_blocking block that produces `let file = tokio::task::spawn_blocking(move
|| -> Result<std::fs::File, Error> { ... }) .await .map_err(|e|
Error::Other(e.into())) .and_then(|r| r) .unwrap();` and modify it to return a
Result (remove unwrap), for example chain .await.map_err(...).and_then(|r| r)
and then use `?` to assign `file` or explicitly handle the Err to return from
Client::check so archive/build failures surface as an Error return instead of
panicking.
- Around line 501-519: The code silently "fails open" by treating unknown object
variants (c.obj.and_then(... ) => None => continue) and unrecognized verdicts (_
=> check::CheckVerdict::Skip) as benign; change this to surface protocol/parsing
errors instead: in the object match around c.obj and check_object::Msg, return
or propagate a descriptive error (not continue) when None is encountered so
malformed messages are rejected, and in the verdict mapping around
check_result::CheckVerdict::try_from(r.verdict) replace the wildcard arm with an
Err return (or map to a Result and propagate the error) so unknown/invalid
verdict values are reported rather than coerced to Skip; update the surrounding
function signatures (e.g., the iterator/map closure and its caller) to return
Result where needed so these errors can bubble up.

---

Nitpick comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 1030-1060: Add a test that exercises the error branch of
Client::check by having the mock RemoteExecutionServiceServer send a
CheckResponse::Error and asserting that client.check returns an Err;
specifically, create a new #[tokio::test] that sets up a temp dir and a
RemoteExecutionServiceServer which responds with CheckResponse::Error (matching
the enum used in the CheckResponse handling inside Client::check) and then call
Client::check (the method around Line 497) and assert the returned result is an
error and contains the expected error message/variant.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b68f545-716c-4cbb-9c45-f9a222674b55

📥 Commits

Reviewing files that changed from the base of the PR and between 66075a4 and 1838f87.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • crates/check/src/harness.rs
  • crates/check/src/lib.rs
  • crates/check/src/naming.rs
  • crates/check/src/outputs.rs
  • crates/check/src/profile.rs
  • crates/remote-client/Cargo.toml
  • crates/remote-client/src/lib.rs
  • crates/remote-proto/build.rs
  • crates/remote-proto/protos/res/check.proto
  • crates/remote-proto/protos/res/remote_execution_service.proto

Comment thread crates/remote-client/src/lib.rs Resolved
Comment thread crates/remote-client/src/lib.rs Resolved
@coderabbitai

coderabbitai Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 2 unresolved review comments.

Files modified:

  • crates/remote-client/src/lib.rs

Commit: d37dff19b470dd1fba0845f7a9a77865767c0483

The changes have been pushed to the tom/check branch.

Time taken: 5m 30s

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 492-536: The code currently swallows frames when msg.msg is None
in the stream loop (while let Some(msg) = rpc.next().await), which can hide
malformed responses; change the None => {} branch to return an error so the
caller fails fast (e.g., return Error::Other(anyhow!("missing/invalid
CheckResponse.msg").into())); update the match handling around
check_response::Msg and msg.msg to treat a missing top-level message as a
protocol error rather than silently continuing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d2261a82-8ed9-4ebd-87b7-076797d6f384

📥 Commits

Reviewing files that changed from the base of the PR and between 1838f87 and d37dff1.

📒 Files selected for processing (1)
  • crates/remote-client/src/lib.rs

Comment thread crates/remote-client/src/lib.rs Resolved

@bryan-minimal bryan-minimal left a comment

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.

LGTM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
crates/remote-client/src/lib.rs (1)

505-565: ⚠️ Potential issue | 🟠 Major

Fail fast on missing top-level CheckResponse.msg.

Line 564 still treats a malformed response frame as benign. That can drop protocol errors on the floor and let the caller observe partial success. Return an Err through the channel here instead of continuing.

Proposed fix
                 match msg.msg {
                     Some(check_response::Msg::Error(e)) => {
                         let _ = tx.unbounded_send((
                             check::CheckObj::Package(String::new()),
                             Err(Error::Other(anyhow!("check failed: {}", e.msg).into())),
                         ));
                         break;
                     }
                     Some(check_response::Msg::Check(c)) => {
                         let obj = match c.obj.and_then(|o| o.msg) {
                             Some(check_object::Msg::Package(n)) => check::CheckObj::Package(n),
                             Some(check_object::Msg::Profile(n)) => check::CheckObj::Profile(n),
                             Some(check_object::Msg::Harness(n)) => check::CheckObj::Harness(n),
                             None => {
                                 let _ = tx.unbounded_send((
                                     check::CheckObj::Package(String::new()),
                                     Err(Error::Other(
                                         anyhow!("check response missing object").into(),
                                     )),
                                 ));
                                 break;
                             }
                         };
                         let check_results: Result<Vec<_>, Error> = c
                             .results
                             .into_iter()
                             .map(|r| -> Result<check::CheckResult, Error> {
                                 let verdict = match check_result::CheckVerdict::try_from(r.verdict)
                                 {
                                     Ok(check_result::CheckVerdict::CvFail) => {
                                         check::CheckVerdict::Fail
                                     }
                                     Ok(check_result::CheckVerdict::CvFixed) => {
                                         check::CheckVerdict::Fixed
                                     }
                                     Ok(check_result::CheckVerdict::CvSkip) => {
                                         check::CheckVerdict::Skip
                                     }
                                     Ok(check_result::CheckVerdict::CvPass) => {
                                         check::CheckVerdict::Pass
                                     }
                                     Ok(check_result::CheckVerdict::CvUnspecified) | Err(_) => {
                                         return Err(Error::Other(
                                             anyhow!("invalid check verdict value {}", r.verdict)
                                                 .into(),
                                         ));
                                     }
                                 };
                                 Ok(check::CheckResult {
                                     check: r.check.into(),
                                     verdict,
                                     err: r.errors,
                                 })
                             })
                             .collect();
                         if tx.unbounded_send((obj, check_results)).is_err() {
                             break;
                         }
                     }
-                    None => {}
+                    None => {
+                        let _ = tx.unbounded_send((
+                            check::CheckObj::Package(String::new()),
+                            Err(Error::Other(
+                                anyhow!("malformed check response: missing message").into(),
+                            )),
+                        ));
+                        break;
+                    }
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/remote-client/src/lib.rs` around lines 505 - 565, The match arm
handling msg.msg == None should not ignore a malformed top-level CheckResponse;
in the match on msg.msg inside the message-processing loop (the branch after
Some(check_response::Msg::Error) and Some(check_response::Msg::Check)), replace
the current None => {} with logic that sends an Err down tx (e.g.,
tx.unbounded_send((check::CheckObj::Package(String::new()),
Err(Error::Other(anyhow!("missing check response message").into())))) and then
break so the caller receives the protocol error instead of continuing.
🧹 Nitpick comments (1)
crates/remote-client/src/lib.rs (1)

1010-1017: Broaden the request assertions in the new check test.

This only checks client_id and packages, so regressions in files_stream, filter_names, skip_checkers, profiles/harnesses, or remote_cache_gcs_bucket serialization would still pass.

Suggested test expansion
             let Msg::Request(req) = first.msg.unwrap() else {
                 panic!("expected CheckRequest as first message");
             };
             assert!(!req.client_id.is_empty());
             assert!(req.packages);
+            assert!(!req.profiles);
+            assert!(!req.harnesses);
+            assert_eq!(req.filter_names, Vec::<String>::new());
+            assert_eq!(req.skip_checkers, Vec::<String>::new());
+            assert_eq!(req.remote_cache_gcs_bucket, None);
+            let files_stream = req.files_stream.expect("expected files_stream");
+            assert_eq!(
+                files_stream.kind,
+                i32::from(stream_config::StreamKind::SkWorktree)
+            );
+            let format = files_stream.format.expect("expected files format");
+            let stream_config::Format::Files(files) = format else {
+                panic!("expected files stream format");
+            };
+            let tarball = files.tarball.expect("expected tarball config");
+            assert_eq!(
+                tarball.compression,
+                i32::from(TarballCompression::TarZst)
+            );

Also applies to: 1076-1083

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/remote-client/src/lib.rs` around lines 1010 - 1017, The test only
asserts req.client_id and req.packages; expand the assertions in the block that
reads the first message (pattern matching Msg::Request(req)) to validate all
important fields were serialized correctly: add explicit assertions checking
req.files_stream (or its enum/option contents) matches the expected files
stream, req.filter_names equals the expected filter_names vec, req.skip_checkers
equals expected skip_checkers, req.profiles or req.harnesses matches the
expected profiles/harnesses structure, and req.remote_cache_gcs_bucket equals
the expected bucket string (and any nested fields); update any expected values
used by the test setup and mirror this same expansion for the other occurrence
around the second test block (the one similar at the later lines) to prevent
regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 505-565: The match arm handling msg.msg == None should not ignore
a malformed top-level CheckResponse; in the match on msg.msg inside the
message-processing loop (the branch after Some(check_response::Msg::Error) and
Some(check_response::Msg::Check)), replace the current None => {} with logic
that sends an Err down tx (e.g.,
tx.unbounded_send((check::CheckObj::Package(String::new()),
Err(Error::Other(anyhow!("missing check response message").into())))) and then
break so the caller receives the protocol error instead of continuing.

---

Nitpick comments:
In `@crates/remote-client/src/lib.rs`:
- Around line 1010-1017: The test only asserts req.client_id and req.packages;
expand the assertions in the block that reads the first message (pattern
matching Msg::Request(req)) to validate all important fields were serialized
correctly: add explicit assertions checking req.files_stream (or its enum/option
contents) matches the expected files stream, req.filter_names equals the
expected filter_names vec, req.skip_checkers equals expected skip_checkers,
req.profiles or req.harnesses matches the expected profiles/harnesses structure,
and req.remote_cache_gcs_bucket equals the expected bucket string (and any
nested fields); update any expected values used by the test setup and mirror
this same expansion for the other occurrence around the second test block (the
one similar at the later lines) to prevent regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 874a83fe-6c75-4da4-8344-a3acf44d98c3

📥 Commits

Reviewing files that changed from the base of the PR and between d37dff1 and 8fd0d18.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • crates/check/src/harness.rs
  • crates/check/src/lib.rs
  • crates/check/src/naming.rs
  • crates/check/src/outputs.rs
  • crates/check/src/profile.rs
  • crates/remote-client/Cargo.toml
  • crates/remote-client/src/lib.rs
  • crates/remote-proto/build.rs
  • crates/remote-proto/protos/res/check.proto
  • crates/remote-proto/protos/res/remote_execution_service.proto
✅ Files skipped from review due to trivial changes (6)
  • crates/remote-proto/build.rs
  • crates/check/src/profile.rs
  • crates/check/src/outputs.rs
  • crates/check/src/harness.rs
  • crates/remote-client/Cargo.toml
  • crates/remote-proto/protos/res/check.proto
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/remote-proto/protos/res/remote_execution_service.proto
  • crates/check/src/naming.rs

@twitchyliquid64
twitchyliquid64 merged commit c70fbce into main Apr 25, 2026
8 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/check branch April 25, 2026 00:05
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