Skip to content

Fix Roc client wire semantics - #12475

Merged
developing-today-fleet[bot] merged 2 commits into
mainfrom
queue/21022-12466-roc-wire-r1
Nov 22, 2026
Merged

developing-today-fleet[bot] merged 2 commits into
mainfrom
queue/21022-12466-roc-wire-r1

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Preserve original JSON wire names and values, omit absent optional arguments, and send {} for tools with no arguments.
  • Include bearer authorization and MCPX_RUN; propagate daemon and tool-level errors.
  • Resolve the Roc compiler through a flake devshell when it is not on the host PATH.
  • Add compiler, runner, and fail-closed dry-run regression coverage.

The mock-daemon regression exposed the safety gap: without x-mcpx-run, the request cannot be intercepted as a dry-run call. Roc now sends that identity like the other generated clients.

Verification

  • cd pkgs/mcpx && go test -count=1 ./internal/api ./internal/codegen ./internal/runner
  • cd pkgs/mcpx && go test -race -shuffle=on -count=5 -run 'Roc' ./internal/codegen ./internal/runner
  • Roc compiler validation used nightly 2026-11-13-03dce41 and basic-cli 0.28.1.

Closes #12466

Roc now emits original JSON wire keys and values, omits absent optional arguments, encodes empty arguments as {}, and propagates daemon and tool errors. Include MCPX_RUN and bearer auth in requests. The dry-run regression caught that omitting x-mcpx-run lets a dispatched Roc call lack the run identity needed for safe interception.

Resolve Roc through a flake devshell when it is unavailable on the host PATH.

Closes #12466
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 08:08
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c50a6193-5a3e-4a48-9309-95cc60cf136a
Commits

Reviewing files that changed from the base of the PR and between 4cef8fe and 25c4342.

Files selected for processing: 5

  • pkgs/mcpx/internal/codegen/roc.go
  • pkgs/mcpx/internal/codegen/roc_test.go
  • pkgs/mcpx/internal/runner/dispatch.go
  • pkgs/mcpx/internal/runner/language.go
  • pkgs/mcpx/internal/runner/roc_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T08:36:50.773498Z 25c4342 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92c6b57394

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +22 to 25
for _, want := range []string{"import pf.Http", "import pf.Env", "import http.Request", "TransportError(Str)", "StatusError(U16)", "DaemonError(Str)", "ToolResultError(Str)", "Try(Response.Response, ToolError)", "name : Str", "count : I64", "Http.send!(authenticated_request, {})", "x-mcpx-session", "x-mcpx-run", "MCPX_RUN", "Authorization", "Bearer", "demo_say_hi! = |args|", `Json.to_str_try("say-hi")`, `Json.to_str_try("demo-server")`, "isError ?: Bool", "List.keep_oks(content, |block| block.?text)", "Response.body", "Json.parse", "MCPX_TRANSPORT_BEARER_TOKEN", `\"next-page\"`, `raw ?: a`, "a.Json.Encodable(_)"} {
if !strings.Contains(out, want) {
t.Errorf("Roc client missing %q:\n%s", want, out)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add property-based coverage for the wire serialization invariants

The new hand-built argument serializer has explicit invariants—preserve original property names and values, omit absent optional fields, and encode empty arguments as {}—but these checks only inspect generated source substrings. The compiler smoke test and single x: "world" mock-daemon case do not establish those invariants across inputs. This violates the testing doctrine in AGENTS.md, which requires property-based tests for invariant-bearing code, including serializers. Add generated schemas/arguments and use decoded requests observed by the mock daemon as the oracle, covering escaping, sanitization collisions, and optional-field presence.

AGENTS.md reference: AGENTS.md:L36-L39

Useful? React with 👍 / 👎.

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.

Added TestRocWireSerializationProperties in runner tests. It builds 16 seeded Roc tool schemas with collision-prone/reserved/quoted wire keys and generated requiredness/argument values, runs one Roc process against a mock daemon, and compares each decoded JSON request to the expected server/tool/args. The fixed cases guarantee all optional fields omitted once and all present once; remaining schemas vary requiredness/presence. Verified with the focused runner tests and go test -race -shuffle=on -count=5 -run Roc ./internal/runner (pass). Commit: 25c4342.

@developing-today-fleet
developing-today-fleet Bot merged commit 668d92d into main Nov 22, 2026
1 check passed
@developing-today-fleet
developing-today-fleet Bot deleted the queue/21022-12466-roc-wire-r1 branch November 22, 2026 08:35
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.

Fix Roc client wire semantics and execution safety

1 participant