Skip to content

feat: add Drop D proto gap types (MCP, middleware, SigV4) - #55

Merged
rhuss merged 7 commits into
mainfrom
fix/proto-gap-drop-d
Aug 8, 2026
Merged

feat: add Drop D proto gap types (MCP, middleware, SigV4)#55
rhuss merged 7 commits into
mainfrom
fix/proto-gap-drop-d

Conversation

@rhuss

@rhuss rhuss commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

All changes follow the established 3-layer pattern: domain types, converters with deep-copy, coverage tests, and round-trip/deep-copy unit tests.

JIRA: RHAIENG-6595

Test plan

  • mise run test passes
  • mise run lint passes (0 issues)
  • mise run proto:check passes (generated files up to date)
  • All TestConverterCoversAllProtoFields_* coverage tests pass (13/13)
  • No skipped fields remain in SandboxPolicy coverage test
  • Manual review of converter round-trip correctness

Summary by CodeRabbit

  • New Features
    • Added support for credential signing, signing service and region settings, JSON-RPC body-size limits, and MCP options in network policies.
    • Added parameter matching for Layer 7 allow and deny rules.
    • Added configurable network middleware with endpoint selection, ordering, custom settings, and error handling.
  • Documentation
    • Added implementation and design documentation for the expanded network policy capabilities.
  • Bug Fixes
    • Improved policy conversion reliability and preserved configuration data during round trips.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rhuss, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d121505-0577-473c-a403-3c615a863b53

📥 Commits

Reviewing files that changed from the base of the PR and between cff9785 and d0be11f.

📒 Files selected for processing (2)
  • openshell/v1/internal/converter/network_policy.go
  • openshell/v1/internal/converter/policy.go
📝 Walkthrough

Walkthrough

The PR adds SDK types and protobuf conversions for SigV4, JSON-RPC, MCP, and network middleware policy fields. It also adds round-trip, deep-copy, and converter coverage tests, plus design and implementation documentation.

Changes

Network Policy Proto Gaps

Layer / File(s) Summary
Drop D design and implementation scope
docs/superpowers/...
The plan and specification define the endpoint, MCP, middleware, converter, test, and validation changes.
Endpoint and MCP policy mappings
openshell/v1/types/network_policy.go, openshell/v1/internal/converter/network_policy.go, openshell/v1/internal/converter/network_policy_test.go
Endpoint signing and JSON-RPC fields, MCP options, and L7 parameter matchers now map between SDK and protobuf representations. Tests cover conversion, round trips, and MCP pointer isolation.
Network middleware policy conversion
openshell/v1/types/policy.go, openshell/v1/internal/converter/policy.go, openshell/v1/internal/converter/policy_test.go, openshell/v1/internal/converter/coverage_test.go
Sandbox policies now carry network middleware configurations. Conversion copies middleware metadata, structured configuration, and endpoint selectors. Tests cover field mapping, round trips, deep-copy behavior, and protobuf field coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses #37 and #35, but #36 is incomplete because SupervisorMiddlewareService and its response conversion are not implemented. Add SupervisorMiddlewareService and GetSandboxConfigResponse.supervisor_middleware_services domain types, converters, coverage handling, and unit tests.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 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 Drop D proto gap additions for MCP, middleware, and SigV4.
Out of Scope Changes check ✅ Passed The implementation and supporting documentation remain focused on the linked Drop D network policy and middleware objectives.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/proto-gap-drop-d

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 Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.59%. Comparing base (e44c700) to head (d0be11f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
+ Coverage   89.57%   89.59%   +0.01%     
==========================================
  Files          78       78              
  Lines        4901     4967      +66     
==========================================
+ Hits         4390     4450      +60     
- Misses        345      350       +5     
- Partials      166      167       +1     

☔ 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)
openshell/v1/internal/converter/policy_test.go (1)

689-703: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover Config deep-copy isolation.

This test mutates only Endpoints.Include. Add a Config value, mutate the source proto configuration after conversion, and assert that policy.NetworkMiddlewares["test"].Config retains the original value.

Based on learnings, mutable proto-backed maps must be deep-copied across the proto/SDK boundary.

🤖 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 `@openshell/v1/internal/converter/policy_test.go` around lines 689 - 703,
Extend TestSandboxPolicyMiddlewareDeepCopy by adding a Config value to the test
middleware, mutate the corresponding source proto Config after
SandboxPolicyFromProto conversion, and assert
policy.NetworkMiddlewares["test"].Config still contains the original value. Keep
the existing Endpoints.Include isolation assertion.

Sources: Coding guidelines, Learnings

🤖 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 `@openshell/v1/internal/converter/policy.go`:
- Around line 185-190: Update the converter containing SandboxPolicyToProto so
structpb.NewStruct errors for m.Config are propagated to the caller instead of
silently omitting result.Config. Change the relevant converter signatures and
call sites to return and handle the error, or validate
NetworkMiddlewareConfig.Config before request construction, while preserving the
existing successful conversion behavior.

---

Nitpick comments:
In `@openshell/v1/internal/converter/policy_test.go`:
- Around line 689-703: Extend TestSandboxPolicyMiddlewareDeepCopy by adding a
Config value to the test middleware, mutate the corresponding source proto
Config after SandboxPolicyFromProto conversion, and assert
policy.NetworkMiddlewares["test"].Config still contains the original value. Keep
the existing Endpoints.Include isolation assertion.
🪄 Autofix

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: c0734b27-6ec7-4974-adfa-756f838e06c6

📥 Commits

Reviewing files that changed from the base of the PR and between e44c700 and cff9785.

📒 Files selected for processing (9)
  • docs/superpowers/plans/2026-08-08-proto-gap-drop-d.md
  • docs/superpowers/specs/2026-08-08-proto-gap-drop-d-design.md
  • openshell/v1/internal/converter/coverage_test.go
  • openshell/v1/internal/converter/network_policy.go
  • openshell/v1/internal/converter/network_policy_test.go
  • openshell/v1/internal/converter/policy.go
  • openshell/v1/internal/converter/policy_test.go
  • openshell/v1/types/network_policy.go
  • openshell/v1/types/policy.go

Comment on lines +185 to +190
if m.Config != nil {
s, err := structpb.NewStruct(m.Config)
if err == nil {
result.Config = s
}
}

@coderabbitai coderabbitai Bot Aug 8, 2026

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 | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate all conversion call sites that must propagate validation errors.
rg -n -C 3 --type go '\bSandboxPolicyToProto\s*\(' .
rg -n -C 3 --type go '\bmiddlewareConfigToProto\s*\(' .
rg -n -C 3 --type go '\bNewStruct\s*\(' openshell/v1/internal/converter

Repository: rhuss/openshell-sdk-go

Length of output: 8493


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the converter signatures, call sites, and concrete middleware config handling.
sed -n '1,220p' openshell/v1/internal/converter/policy.go
sed -n '140,210p' openshell/v1/internal/converter/sandbox.go
sed -n '170,200p' openshell/v1/internal/converter/setting.go

# Search for API/write/validate calls around Policy or middleware config to see whether errors are usable downstream.
rg -n -C 2 --type go '\b(Policy|MergeOperations|SandboxPolicy|NetworkMiddlewares|PolicyPolicies|Middleware|Config)\b' openshell/v1/internal openshell/v1 --glob '!**/*_test.go' | head -n 200

Repository: rhuss/openshell-sdk-go

Length of output: 22350


Return Config conversion errors.

structpb.NewStruct can reject values in NetworkMiddlewareConfig.Config. The current code drops the conversion and sends a middleware config without Config, changing the policy.

Make the conversion caller-propagated, either by changing these converters to return an error or by validating Config before SandboxPolicyToProto builds the request.

🤖 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 `@openshell/v1/internal/converter/policy.go` around lines 185 - 190, Update the
converter containing SandboxPolicyToProto so structpb.NewStruct errors for
m.Config are propagated to the caller instead of silently omitting
result.Config. Change the relevant converter signatures and call sites to return
and handle the error, or validate NetworkMiddlewareConfig.Config before request
construction, while preserving the existing successful conversion behavior.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Valid observation. The SDK converter pattern does not return errors (all ToProto functions have void returns), so propagating the structpb.NewStruct error would break the established API contract across all converters.

In practice, Config values always originate from structpb.AsMap() on the FromProto path, which produces only JSON-compatible types. A comment has been added (d0be11f) explaining this constraint: non-JSON-compatible values in user-constructed maps are silently dropped.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@rhuss, the added comment documents the behavior, but it does not resolve the data-loss case.

NetworkMiddlewareConfig.Config is public and user-constructible as map[string]any. If it contains a value that structpb.NewStruct rejects, the SDK sends a different policy without Config.

I understand that the current ToProto contract has no error return. That constraint means this change needs validation before conversion, or another explicit invalid-config behavior. The converter must not silently omit policy configuration.


✏️ Learnings added
Learnt from: rhuss
Repo: rhuss/openshell-sdk-go PR: 55
File: openshell/v1/internal/converter/policy.go:185-192
Timestamp: 2026-08-08T14:36:47.934Z
Learning: In the Go SDK, established `ToProto` converters use void return values and do not return conversion errors. In `openshell/v1/internal/converter/policy.go`, `middlewareConfigToProto` documents that it silently drops `types.NetworkMiddlewareConfig.Config` when `structpb.NewStruct` rejects user-constructed non-JSON-compatible map values.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

Copilot AI 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.

Pull request overview

Adds the remaining “Drop D” network-policy proto gap types/fields to the Go SDK’s domain layer and converters, with coverage + unit tests to ensure new proto fields are represented and round-trip correctly.

Changes:

  • Extend network endpoint policy types/converters to support SigV4 signing fields, JSON-RPC max body size, MCP options, and L7 allow/deny Params matching.
  • Add network middleware domain types plus SandboxPolicy.NetworkMiddlewares, with policy converters and unit tests.
  • Update converter field-coverage tests and add design/plan docs for the Drop D proto gap work.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
openshell/v1/types/policy.go Adds NetworkMiddlewares to SandboxPolicy and introduces middleware domain types.
openshell/v1/types/network_policy.go Adds SigV4/JSON-RPC/MCP fields to PolicyNetworkEndpoint and Params to L7 rule types.
openshell/v1/internal/converter/policy.go Implements middleware conversions and wires them into SandboxPolicy conversions.
openshell/v1/internal/converter/policy_test.go Adds middleware conversion, round-trip, and deep-copy tests.
openshell/v1/internal/converter/network_policy.go Maps new endpoint fields, MCP options, and L7 Params between proto and domain types.
openshell/v1/internal/converter/network_policy_test.go Adds unit tests for new endpoint fields, MCP, and Params.
openshell/v1/internal/converter/coverage_test.go Marks new proto fields/messages as handled via coverage tests.
docs/superpowers/specs/2026-08-08-proto-gap-drop-d-design.md Documents the design/mapping decisions for the proto-gap fixes.
docs/superpowers/plans/2026-08-08-proto-gap-drop-d.md Implementation plan/checklist for the Drop D proto-gap work.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread openshell/v1/internal/converter/policy.go
@rhuss
rhuss merged commit dafac7a into main Aug 8, 2026
7 checks passed
@rhuss
rhuss deleted the fix/proto-gap-drop-d branch August 8, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants