Skip to content

docs: ingress tcp relay design - #271

Merged
rvkandury merged 1 commit into
strands-agents:mainfrom
rvkandury:docs/ingress-relay-agent-only
Nov 9, 2026
Merged

rvkandury merged 1 commit into
strands-agents:mainfrom
rvkandury:docs/ingress-relay-agent-only

Conversation

@rvkandury

Copy link
Copy Markdown
Contributor

Description

This doc provides design for Ingress Relay for bi-directional communication between the agent in the sandbox and the caller over TCP when the agent is fronted by a server.

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rvkandury rvkandury changed the title docs: Ingress Relay design docs: ingress relay design Nov 2, 2026
@rvkandury rvkandury changed the title docs: ingress relay design docs: ingress tcp relay design Nov 2, 2026
@github-actions github-actions Bot added Area - Egress/Creds documentation Improvements or additions to documentation strands-running labels Nov 2, 2026
Comment thread team/designs/0002-ingress-relay.md Resolved
Comment thread team/designs/0002-ingress-relay.md Resolved
Comment thread team/designs/0002-ingress-relay.md Resolved
Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Request Changes

The Linux path matches the existing launcher. It reuses the egress socket pair, PID 1 drops its capabilities, and seccomp already blocks ptrace and pidfd_getfd. The macOS trust analysis is the main gap: both who can reach workload_port and what the relay can reach need correcting. The Linux PID 1 connect loop also needs a design that does not block.

Review categories
  • Correctness / security (macOS): The shared loopback port is treated as if it belongs only to the agent. The Seatbelt bind rule contradicts itself on address scope.
  • Concurrency (Linux): A connect that blocks in PID 1, one request at a time, holds up later callers and the reaper's duties.
  • Premises: A config setting acting as an authorizer, and the superseded listen decision, need to be stated as premise and interface changes.

Checks that held:

  • The egress socket pair exists, and the egress handoff already sends listeners over it with SCM_RIGHTS (namespace/netns.rs).
  • PID 1 drops its capabilities and sets no_new_privs before it supervises.
  • The agent cannot set contain_egress = false, so on Linux the agent always has its own network namespace, and the Linux "who can reach" table is correct.
  • The [agent] field addition is disclosed under "Interface changes".

The sequence diagrams and load-test numbers make the design easy to evaluate.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Comment

I re-reviewed head f3a9e8b. All four earlier findings are addressed. Only one new item remains, which is about how PID 1's reaper loop also serves the socket (inline, non-blocking).

Earlier findings, now resolved
  • macOS shared port: The "who can reach" table now names contain_egress = false leaves. Startup refuses a workload_port that is already in use, and the race after that check is documented.
  • Seatbelt bind rule: The doc now states that the localhost filter matches every local address, and it adds network-inbound.
  • PID 1 blocking: PID 1 now hands over an unconnected socket, and the relay connects it without blocking, with a timeout per caller (D2).
  • Premise: "Interface changes" now states that ingress is a policy-free grant and that it replaces the Network::Localhost.listen decision.

Checks that held on this head:

  • The startup probe is a connect to 127.0.0.1:workload_port. It catches every listener the relay would actually reach: one on 127.0.0.1 or 0.0.0.0. A listener only on ::1 or on a LAN address is not something the relay connects to.
  • The relay's socket stays in the sandbox's network: a socket's network namespace is fixed when it is created (namespace/mod.rs:174-179).
  • The agent's copy of PID 1's socket is marked close-on-exec, and its egress listeners are already dropped before it execs.
  • The agent cannot get native egress, so the Linux table is correct.

The revision is a clear improvement. The Linux connect design is now simpler and more robust.

Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Assessment: Comment

Re-reviewed 3041039. Compared with f3a9e8b, the only change is the new open-file-based caller cap ("How many connections", D6). The one finding (inline) is that the cap leaves out the descriptors each caller drives through egress in the same process. The earlier PID 1 reaper-loop suggestion is unchanged and still open on line 115.

Checks that held on this change:

  • The cap is not a box.toml setting, so the interface is unchanged.
  • A further caller waits in the backlog and is not refused, which matches the "agent is the bottleneck" reasoning.
  • The one-second back-off after a failed accept stops the ingress loop from spinning on EMFILE.

Comment thread team/designs/0002-ingress-relay.md Resolved
Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Assessment: Comment

Re-reviewed b174027. Compared with 3041039, the prose is unchanged. The five Mermaid diagrams are now SVGs, and the SVGs add behaviour the prose does not state: a PID 1 inbound-connector thread, a ::1 fallback, and a 5 s connect timeout. Two of these conflict with the existing code or the security analysis (inline). The descriptor-budget comment from the last round is still open.

Checks that held on this change:

  • The macOS startup SVG matches the prose: the startup check on workload_port, the Seatbelt rule for that port only on any address, and no relay for egress.
  • The macOS per-caller SVG matches the "who can reach" table, including the contain_egress = false leaves and the LAN when the agent listens on 0.0.0.0.
  • The Linux per-caller SVG keeps the handover of an unconnected socket and the non-blocking connect that D2 describes.

Comment thread team/designs/0002-ingress-relay.md Resolved
Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed 8c87503 against 9474df0. The connections paragraph puts back the startup open-file-limit raise and gives a ceiling for each platform, which resolves the line-154 thread. No open findings remain.

What I checked that held:

  • Open-file limit: the startup raise is back. With it, Linux and macOS hosts clear the default limits, and "as far as the system allows" covers macOS's OPEN_MAX clamp.
  • AgentCore: at a fixed 1,024, "a few hundred callers" matches the arithmetic: about 500, less the reserved share. The rationale of one microVM per session is stated.
  • Local ports: about 28,000 on Linux and 16,000 on macOS, both correct.
  • Running out of descriptors: the failure-table row is still there, so a caller who hits the cap waits and does not spin.

Comment thread team/designs/0003-ingress-relay.md Resolved
ferdingler
ferdingler previously approved these changes Nov 4, 2026
Comment thread team/designs/0003-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed f93caf9 against 8c87503. The only change is the new open decision D4 (multiple ingress listeners), and it leaves the committed design as it was. I left one non-blocking inline at line 235: if D4 picks a list, the macOS refusal rules have to apply across entries.

What I checked that held:

  • PID 1 stays port-agnostic: in step 3, PID 1 returns unconnected sockets and Box does the connect in step 4, so extra listeners need no PID 1 change.
  • Shared channel: the sockets PID 1 returns are interchangeable, so several relays sharing one request/response channel do not need to match replies to requests.
  • Linux listener collisions: two entries with the same listen are already caught by the existing "port already in use" refusal.

Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed 2712662 against f93caf9. The only change adds the cross-entry startup checks to D4, which resolves the line-235 thread, and no findings remain open.

What I checked that held:

  • macOS collision closed: requiring that no listen port equal any entry's workload_port refuses the crossed 8000↔8080 config at startup, before the agent's bind can fail at runtime.
  • Sample labelled: the sample TOML is now marked Linux-only, which matches the existing line-45 rule.
  • Strict uniqueness is fine: a unique listen port across entries is stricter than the OS needs, since the same port on different IPs could bind. It is safe, and it matches how most operators would expect the config to behave.

ferdingler
ferdingler previously approved these changes Nov 6, 2026

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

Let's add recommendation for the number of ingress ports supported and close the KD.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed c4c27a8 against 2712662. D4 is now decided: [[agent.ingress]] is a list, capped at five entries. The design was updated to match throughout: config, startup on both platforms, shutdown, and interface changes. I left one inline at line 46 on the AgentCore port and the cap arithmetic. It is non-blocking, but it would mislead MCP and A2A runtime operators.

What I checked that held:

  • PID 1 and the shared channel: neither changes for multiple entries, because the sockets PID 1 returns are unconnected and interchangeable.
  • Refusal rules: the cross-entry checks are now in the line-48 refusal list (duplicate listen, more than five entries), and the macOS listen ≠ any workload_port rule is in line 47.
  • macOS Seatbelt: one port rule per entry gives the union of the workload_ports.
  • Local-port limit: it applies separately to each workload_port destination, so the connection-limits section is unaffected.
  • Policy-premise wording: carried over to [[agent.ingress]] unchanged.

Comment thread team/designs/0002-ingress-relay.md Resolved
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed a19a34f against c4c27a8. Both points of the line-46 thread are addressed, and no findings remain open.

What I checked that held:

  • Invoke port: it now depends on the runtime's protocol (8080, 8000, or 9000, or protocolConfiguration.port if set), so an MCP or A2A runtime configured from the doc listens where Runtime dials.
  • Cap: the cap of five no longer claims to match allowedPorts. It is now a stated tradeoff that covers HTTP, MCP, and A2A with a port or two to spare. Raising it later only relaxes a startup refusal, so it breaks no existing config.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed 07698a1 against a19a34f. The commit is a pure renumber: the design and its seven SVGs move from 0002- to 0003-, the images are byte-identical (100% similarity), and the body's text is unchanged. No findings remain open.

What I checked that held:

  • Image references: all eight image links in 0003-ingress-relay.md point at the renamed files, and no reference to 0002-ingress remains anywhere in the tree.
  • Numbering rule: team/designs/README.md says "using the next free number". Main has only 0001, so 0003 presumably leaves 0002 for another open design PR (e.g. docs(design): add LOG_ONLY mode design doc #310), and it collides with no existing file.

@rvkandury

Copy link
Copy Markdown
Contributor Author

Let's add recommendation for the number of ingress ports supported and close the KD.

Updated with recommendation and closed decision

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

LGTM! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Ingress documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants