Skip to content

refactor: switch proto generation from protoc to buf - #31

Merged
rhuss merged 7 commits into
mainfrom
buf-migration
Jul 29, 2026
Merged

rhuss merged 7 commits into
mainfrom
buf-migration

Conversation

@rhuss

@rhuss rhuss commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Switch from raw protoc to buf for proto code generation, aligning with the monorepo SDK approach (NVIDIA/OpenShell#2271)
  • Sync proto files from upstream (includes options.proto that was previously stripped)
  • Remove UPSTREAM_VERSION, proto:sync, and proto:clean tasks

Changes

  • Add buf.yaml and buf.gen.yaml for declarative proto generation
  • Replace protoc-based mise tasks (proto:gen, proto:check) with buf equivalents
  • Remove proto:sync, proto:clean tasks (no longer needed)
  • Add buf 1.72.0 to mise.toml, remove standalone protoc dependency
  • Add proto target to Makefile
  • Regenerate all .pb.go files via buf pipeline

Testing

  • All 1035 tests pass
  • mise run proto:check confirms generated files are up to date
  • go build ./... compiles cleanly

Summary by CodeRabbit

  • New Features
    • Added workspace management, membership, and workspace-scoped API operations.
    • Added gateway capability information, provider profile metadata, credential refresh outputs, and additional credential strategies.
    • Added middleware configuration, MCP policy controls, AWS credential signing, and JSON-RPC limits for sandbox networking.
    • Added expanded annotations, provenance, and lifecycle status information across resources.
  • Security
    • Sensitive credentials and tokens are now explicitly protected in API schemas.
  • Developer Experience
    • Added standardized Protocol Buffer generation and consistency checks using Buf.

rhuss added 7 commits July 11, 2026 07:50
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Replace raw protoc invocations with buf, aligning with the monorepo
SDK approach (PR NVIDIA/OpenShell#2271).

- Add buf.yaml and buf.gen.yaml for declarative proto generation
- Replace protoc-based mise tasks (proto:gen, proto:check) with buf
- Remove proto:sync, proto:clean tasks (no longer needed)
- Remove UPSTREAM_VERSION (proto sources are now the source of truth)
- Sync proto files from upstream (includes options.proto)
- Add buf 1.72.0 to mise.toml, remove standalone protoc dependency
- Add proto target to Makefile
- Regenerate all .pb.go files via buf pipeline

All 1035 tests pass.

Signed-off-by: Roland Huß <rhuss@redhat.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR switches protobuf generation to Buf, adds generation and validation configuration, expands OpenShell workspace, provider, policy, gateway, sandbox, middleware, and secret-field schemas, and adds brainstorming documents for SDK documentation, authentication, and upstream migration planning.

Changes

Proto generation workflow

Layer / File(s) Summary
Buf generation workflow
Makefile, buf.yaml, buf.gen.yaml, mise.toml
Adds the proto Make target, Buf configuration, Buf-based generation and freshness checking, and removes obsolete proto clean/sync tasks.

Metadata and API contracts

Layer / File(s) Summary
Metadata and secret field contracts
proto/options.proto, proto/datamodel.proto
Adds the custom secret field option, workspace lifecycle messages, metadata fields, and provider credential annotations.
Gateway and workspace API surface
proto/openshell.proto
Adds gateway information, workspace and membership RPCs, workspace-scoped requests, secret markings, and supporting message types.
Provider and policy schema extensions
proto/openshell.proto
Adds provider refresh strategies and outputs, profile metadata, workspace fields, annotations, and policy provenance fields.
Sandbox middleware and MCP contracts
proto/sandbox.proto
Adds network middleware, AWS signing, MCP matching, JSON-RPC limits, and supervisor middleware service definitions.

SDK planning records

Layer / File(s) Summary
SDK planning records
brainstorm/00-overview.md, brainstorm/022-auth-guide.md, brainstorm/023-schema-docs.md, brainstorm/024-upstream-pr.md
Updates brainstorm tracking and adds plans for authentication documentation, schema documentation, and an upstream SDK pull request.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating proto generation from protoc to buf.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch buf-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.56%. Comparing base (580d763) to head (8137148).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #31      +/-   ##
==========================================
+ Coverage   88.51%   88.56%   +0.04%     
==========================================
  Files          70       70              
  Lines        4163     4163              
==========================================
+ Hits         3685     3687       +2     
+ Misses        330      328       -2     
  Partials      148      148              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
proto/openshell.proto (1)

2099-2105: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add annotations to CreateWorkspaceRequest for consistency.

To align with the Workspace model (where ObjectMeta supports both labels and annotations) and other create requests like CreateSandboxRequest, consider adding an annotations field here.

♻️ Proposed refactor
 message CreateWorkspaceRequest {
   // Workspace name. Must be a valid DNS-1123 label.
   string name = 1;
   // Optional labels for the workspace (key-value metadata).
   map<string, string> labels = 2;
+  // Optional annotations for the workspace (non-selector metadata).
+  map<string, string> annotations = 3;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@proto/openshell.proto` around lines 2099 - 2105, Add an annotations map field
to the CreateWorkspaceRequest message alongside the existing labels field,
matching the Workspace ObjectMeta and CreateSandboxRequest conventions; assign
it a new, unused protobuf field number.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@proto/sandbox.proto`:
- Around line 163-209: Update the canonical protocol field documentation to
include "mcp" and "json-rpc" among the supported values, matching the McpOptions
usage and JSON-RPC method references. Keep the existing protocol values and
descriptions intact while making the enumeration the complete source of truth.

---

Nitpick comments:
In `@proto/openshell.proto`:
- Around line 2099-2105: Add an annotations map field to the
CreateWorkspaceRequest message alongside the existing labels field, matching the
Workspace ObjectMeta and CreateSandboxRequest conventions; assign it a new,
unused protobuf field number.
🪄 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

Run ID: 2a334fbf-77d8-4d4f-924c-08f9d3741da2

📥 Commits

Reviewing files that changed from the base of the PR and between 580d763 and 8137148.

⛔ Files ignored due to path filters (5)
  • proto/datamodelv1/datamodel.pb.go is excluded by !**/*.pb.go
  • proto/openshellv1/openshell.pb.go is excluded by !**/*.pb.go
  • proto/openshellv1/openshell_grpc.pb.go is excluded by !**/*.pb.go
  • proto/optionsv1/options.pb.go is excluded by !**/*.pb.go
  • proto/sandboxv1/sandbox.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (13)
  • Makefile
  • brainstorm/00-overview.md
  • brainstorm/022-auth-guide.md
  • brainstorm/023-schema-docs.md
  • brainstorm/024-upstream-pr.md
  • buf.gen.yaml
  • buf.yaml
  • mise.toml
  • proto/UPSTREAM_VERSION
  • proto/datamodel.proto
  • proto/openshell.proto
  • proto/options.proto
  • proto/sandbox.proto
💤 Files with no reviewable changes (1)
  • proto/UPSTREAM_VERSION

Comment thread proto/sandbox.proto
Comment on lines +163 to +209
// Proxy-side credential signing mode: "sigv4" for AWS SigV4 re-signing.
// When set, the proxy strips the client's Authorization header and computes
// a fresh SigV4 signature using real credentials from the provider.
string credential_signing = 19;
// AWS signing service name override. Required when credential_signing is
// "sigv4" — e.g. "bedrock" for bedrock-runtime endpoints.
string signing_service = 20;
// AWS region override for SigV4 signing. When set, takes precedence over
// hostname-based region extraction. Required for non-standard endpoints.
string signing_region = 21;
// Maximum JSON-RPC-over-HTTP request body bytes to buffer for inspection.
// Defaults to 65536 when unset.
uint32 json_rpc_max_body_bytes = 22;
// MCP-only policy and inspection options. Only used when protocol is "mcp".
McpOptions mcp = 23;
}

// MCP options are grouped so MCP-specific policy can grow without adding more
// top-level NetworkEndpoint fields. Current enforcement targets the active
// 2025-11-25 Streamable HTTP/tools behavior, while preserving space for
// version-profile policy if OpenShell adopts 2026-07-28 draft behavior later.
//
// Planned policy extensions should use OpenShell-owned static definitions for
// MCP method/version profiles rather than treating dependency enums as the
// policy contract. Candidate profile checks include request metadata/header
// validation, response/SSE introspection, trusted annotation handling,
// resultType/cache metadata validation, x-mcp-header tool-definition checks,
// and subscriptions/listen handling.
//
// Sources:
// - https://modelcontextprotocol.io/specification/2025-11-25/server/tools
// - https://modelcontextprotocol.io/specification/draft/changelog
// - https://modelcontextprotocol.io/specification/draft/basic/transports/streamable-http
// - https://modelcontextprotocol.io/specification/draft/server/tools
message McpOptions {
// Hardening boundary for tools/call params.name. When unset or true, the
// supervisor enforces the MCP recommended tool-name syntax
// ^[A-Za-z0-9_.-]{1,128}$ before policy evaluation. Set false only for
// compatibility with servers that intentionally use non-recommended names.
//
// Source:
// - https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names
optional bool strict_tool_names = 1;
// Method-layer default for MCP endpoints. When true, OpenShell allows parsed
// MCP-family methods at the method layer unless a tool-name policy narrows
// tools/call. When unset or false, explicit method rules are required.
optional bool allow_all_known_mcp_methods = 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

protocol field enum doc doesn't list "mcp" (or "json-rpc"), but the new mcp field depends on it.

McpOptions mcp (line 177) states it's "Only used when protocol is "mcp"," yet the canonical protocol field enumeration ("rest", "websocket", "graphql", "sql", or "" — line 105-106) doesn't include "mcp". The changed method comments on L7DenyRule/L7Allow (lines 226-227, 256-257) similarly reference "JSON-RPC method name" as a supported form, which is also absent from that enumeration. Readers relying on the protocol field doc as the source of truth for valid values will miss these.

📝 Suggested doc update (outside this range, at line 105-106)
-  // Application protocol for L7 inspection: "rest", "websocket", "graphql", "sql", or "" (L4-only).
+  // Application protocol for L7 inspection: "rest", "websocket", "graphql", "sql", "json-rpc", "mcp", or "" (L4-only).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@proto/sandbox.proto` around lines 163 - 209, Update the canonical protocol
field documentation to include "mcp" and "json-rpc" among the supported values,
matching the McpOptions usage and JSON-RPC method references. Keep the existing
protocol values and descriptions intact while making the enumeration the
complete source of truth.

@rhuss
rhuss merged commit e40bf44 into main Jul 29, 2026
7 checks passed
@rhuss
rhuss deleted the buf-migration branch July 29, 2026 11:00
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.

1 participant