Skip to content

feat(edge): stream binary Docker request bodies - #1172

Merged
scttbnsn merged 2 commits into
dev/v1.8from
feat/edge-request-body
Sep 13, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.8from
feat/edge-request-body

Conversation

@scttbnsn

Copy link
Copy Markdown
Contributor

Docker API requests over Portwing edge connections now preserve raw bytes, including tar build contexts. The gateway passes the agent's advertised capabilities to the transport; capable agents receive bodyStream requests, 32 KiB base64 chunks paced by WebSocket write callbacks, and a terminal stream_end. Older agents keep the inline JSON path and reject binary input before sending a request.

Uploads are bounded to 512 MiB per body and per connection in aggregate, and stop after 30 seconds without write progress. Timeout, remote rejection, write failure, and disconnect release upload state and stop further chunks. Interrupted uploads send a keyed request-cancelled error instead of stream_end; older Portwing agents ignore the error and expire the incomplete upload safely. Cancellation does not stop a Docker operation already dispatched.

Tests cover binary/JSON byte preservation, capability negotiation, backpressure, streaming response correlation, limits, late callbacks, timeout, disconnect, and write failures. The opt-in integration test drives the actual Go Portwing receiver over WebSocket and verifies exact binary bytes at a Unix Docker socket. Run bash scripts/edge-body-interop.sh /path/to/portwing. Independent correctness, security, performance, tests, and simplification review found no issues.

Completes the controller half of CodesWhat/portwing#205. This targets dev/v1.8; stable availability follows the Drydock release for that development line.

@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drydock-website Ready Ready Preview Sep 13, 2026 1:54am UTC
drydockdemo-website Ready Ready Preview Sep 13, 2026 1:54am UTC

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: dc8903fc-c1d6-4ab8-83b9-92396998b814

📥 Commits

Reviewing files that changed from the base of the PR and between aa3d36c and d18bb31.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (8)
  • app/agent/AgentClient.test.ts
  • app/agent/AgentClient.ts
  • app/agent/EdgeAgentAdapter.test.ts
  • app/agent/EdgeAgentAdapter.ts
  • app/api/portwing-ws.test.ts
  • app/api/portwing-ws.ts
  • content/docs/current/api/portwing.mdx
  • scripts/edge-body-interop.sh

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.

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@greptileai Review exact head d18bb31df9c8e1cfdd615b0d7acb6dfe8d4401d4. Review binary upload sender against Portwing PR334 and existing edge-request-body-stream capability. Threat model: authenticated controller/agent remote Docker management. Focus exact bytes, capability fallback, bounded send backpressure, timeout/disconnect/early response cancellation, and interoperability. Exclude hostile-maintainer/local self-attacks. Review pass1, maximum3.

@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds capability-gated streaming of raw Docker request bodies over Portwing edge connections.

  • Preserves binary and JSON bytes using callback-paced, base64-encoded 32 KiB chunks.
  • Enforces per-body and aggregate upload limits with timeout, failure, response, and disconnect cleanup.
  • Preserves the legacy inline-JSON path for agents without the capability.
  • Adds protocol documentation, unit coverage, and an opt-in test against the real Go receiver.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, interoperability, or resource-lifecycle defects identified.

Capability fallback preserves existing behavior, streamed uploads retain exact bytes and bounded write sequencing, and all reviewed settlement paths release upload state and prevent further chunks.

Important Files Changed

Filename Overview
app/agent/EdgeAgentAdapter.ts Implements bounded capability-gated body streaming, request correlation, timeout handling, cancellation, and upload-state cleanup.
app/agent/AgentClient.ts Preserves raw request bytes for capable agents while retaining legacy JSON parsing for older agents.
app/api/portwing-ws.ts Filters and forwards agent-advertised capability strings into the edge transport.
app/agent/EdgeAgentAdapter.test.ts Covers byte preservation, chunk pacing, response correlation, limits, timeout, disconnect, write failures, and real-receiver interoperability.
scripts/edge-body-interop.sh Builds a local Portwing receiver and runs the opt-in exact-byte interoperability test.
content/docs/current/api/portwing.mdx Documents capability negotiation, frame sequencing, limits, cancellation behavior, and interoperability testing.

Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin/dev..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn

Copy link
Copy Markdown
Contributor Author

CodeRabbit CLI review completed against d18bb31df9c8e1cfdd615b0d7acb6dfe8d4401d4 and origin/dev/v1.8 while the GitHub app was rate-limited. It reviewed all nine changed files and raised one timer-refresh finding.

I checked the finding against the sender and Portwing receiver. Request/chunk write callbacks finish before stream_end is emitted, and Portwing does not dispatch Docker until that frame arrives. The terminal callback already refreshes the current timer from the pending map. Early errors and disconnects clear the pending request and body before another callback can refresh anything. The reported stale-timer path requires a response stream before stream_end, outside this protocol. The five callback, cancellation, and terminal-write boundary tests pass. No code change was needed.

Greptile reviewed this same head with no actionable findings. The independent correctness, security, performance, tests, and simplification review was also clean. Actual TypeScript-to-Go interoperability verified all 131,075 binary bytes. Full local test/build hooks passed. This records the real CLI review; the GitHub app has not completed a review.

@biggest-littlest biggest-littlest 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.

Reviewed d18bb31 with the recorded CodeRabbit CLI finding verification, clean Greptile result, independent review, and binary interoperability evidence. No actionable findings remain.

@ALARGECOMPANY ALARGECOMPANY 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.

Reviewed d18bb31 against the documented upload framing and cancellation contract. The timer finding is refuted by frame ordering and the passing boundary tests; Greptile and independent review are clean.