← Back to Pull requests

feat(harnessnode): configurable max receive message size #236

Merged
aramase merged 9 files (422 lines) on Nov 04, 2026 18:31 UTC
View on GitHub
aramase aramase commented on Nov 04, 2026 17:12 UTC
Author

Start carries the session's whole prior journal in one message, so a long session hits gRPC's 4 MiB receive limit and harnessnode refuses it with RESOURCE_EXHAUSTED before the harness runs.

  • HARNESS_MAX_RECV_MSG_SIZE (bytes) sets the harness server's receive limit. harnessnode reads all its config from env vars, so this is an env var rather than a CLI flag. Unset keeps 4 MiB; an invalid value stops startup before any listener opens.

  • placement.DefaultDialWith(opts ...grpc.DialOption) dials like DefaultDial plus the host's options, for example to raise the client-side receive limit. DefaultDial is unchanged, and the incarnation's call metadata still wins over a host interceptor.

  • Docs and changelog fragments included. No proto or spec change.
  • Tested with go test -race ./.... New tests cover a 5 MiB Start refused by default and accepted at a 16 MiB setting, and a 5 MiB harness-to-host message through DefaultDial and DefaultDialWith. Not tested through atenet-router.

    Diff: 422 lines (+412 / -10) across 9 files Reviewer: gambtho Review duration: 78m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.74) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.74 · 422 lines diff across 9 files
    0.74
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.82 · 2 substantive comment(s)
    0.82
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    86%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.362
    Sensitive Paths sensitive_paths
    0.074
    Real PR Conversation Timeline
    6 items
    Copilot Copilot commented on code on Nov 04, 2026 18:01 UTC
    Code Review
    placement/placement.go:1
    @@ -653,12 +654,34 @@ func describeError(ctx context.Context, err error, timedOut bool) error {
     // gRPC client with the incarnation's CallMetadata attached to every call; only the transport
     // differs. One dial path, two address forms.
     func DefaultDial(inc api.Incarnation) (api.Harness, func() error, error) {
    +	return dialHarness(inc, nil)
    +}
    +
    +// DefaultDialWith returns a Dialer that dials as DefaultDial does, plus opts. A host uses it to
    +// change the connection without reimplementing the dial, for example to accept harness frames
    +// larger than gRPC's 4 MiB default with
    +// grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(n)). opts apply after DefaultDial's own
    +// options, so they replace a conflicting one such as the insecure transport credentials. Two
    +// things they cannot change: the incarnation's CallMetadata is still attached last, replacing any
    +// value an interceptor in opts sets for the same keys, and a unix:// incarnation still dials its
    +// socket.
    +func DefaultDialWith(opts ...grpc.DialOption) Dialer {

    DefaultDialWith adds a public configuration contract, but spec.md is unchanged and WIRE-13 still states unconditionally that reference-host harness dials use no transport security. Update WIRE-13 to distinguish default dialing from explicitly configured credentials, and extend RT-4d to document option precedence and preservation of incarnation metadata and Unix-socket selection.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 04, 2026 18:01 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟡 Changes recommended

    The new public DefaultDialWith configuration contract is undocumented in spec.md, leaving WIRE-13 inaccurate and RT-4d missing option precedence and metadata and Unix-socket preservation guarantees.

    <details open>
    <summary><strong>1 open issue</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document DefaultDialWith security and option precedence · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    This PR makes harness message receive limits configurable so long session histories can exceed gRPC’s default 4 MiB limit without replacing the standard dialing logic.

    Changes:

  • Adds HARNESS_MAX_RECV_MSG_SIZE, validated before harnessnode opens listeners.

  • Adds placement.DefaultDialWith for host-supplied gRPC options while preserving incarnation routing metadata and Unix-socket selection.

  • Adds receive-limit and routing tests, documentation, and changelog fragments.
  • | File | Description |
    | ---- | ----------- |
    | placement/​placement.go | Adds configurable dialing through DefaultDialWith. |
    | placement/​dial_test.go | Tests client receive limits and routing guarantees. |
    | docs/​substrate-conformance.md | Documents host-interceptor routing coverage. |
    | docs/​harness-authoring.md | Explains server and client receive-limit configuration. |
    | cmd/​harnessnode/​tracing_test.go | Adapts tracing tests to the server constructor parameter. |
    | cmd/​harnessnode/​recv_limit_test.go | Tests configuration parsing and oversized session histories. |
    | cmd/​harnessnode/​main.go | Validates, applies, and logs the server receive limit. |
    | changelog/​unreleased/​placement-default-dial-with.md | Announces the configurable dialer API. |
    | changelog/​unreleased/​harnessnode-max-recv-msg-size.md | Announces the harnessnode receive-limit setting. |
    </details>

    <sub>Review effort: Balanced</sub>

    aramase aramase commented on code on Nov 04, 2026 18:06 UTC
    Code Review
    placement/placement.go:1
    @@ -653,12 +654,34 @@ func describeError(ctx context.Context, err error, timedOut bool) error {
     // gRPC client with the incarnation's CallMetadata attached to every call; only the transport
     // differs. One dial path, two address forms.
     func DefaultDial(inc api.Incarnation) (api.Harness, func() error, error) {
    +	return dialHarness(inc, nil)
    +}
    +
    +// DefaultDialWith returns a Dialer that dials as DefaultDial does, plus opts. A host uses it to
    +// change the connection without reimplementing the dial, for example to accept harness frames
    +// larger than gRPC's 4 MiB default with
    +// grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(n)). opts apply after DefaultDial's own
    +// options, so they replace a conflicting one such as the insecure transport credentials. Two
    +// things they cannot change: the incarnation's CallMetadata is still attached last, replacing any
    +// value an interceptor in opts sets for the same keys, and a unix:// incarnation still dials its
    +// socket.
    +func DefaultDialWith(opts ...grpc.DialOption) Dialer {

    WIRE-13 describes the reference host, which still dials with DefaultDial; DefaultDialWith is a library option for embedding hosts. RT-4d already says CallMetadata replaces any same-key value, TestDefaultDialWithCallMetadataOverridesHostInterceptors pins that for DefaultDialWith, and the option order and unix-socket handling are in the godoc and docs/harness-authoring.md. Leaving spec.md as is.

    gambtho gambtho commented on Nov 04, 2026 18:29 UTC
    Reviewer

    Clear change, and the tests cover both directions nicely. One small edge: an interceptor that passes PerRPCCredentials can still put a second ate-target-actor on the wire, since gRPC adds credential metadata after the context rewrite. Could the godoc and guide scope the replacement guarantee to outgoing-context metadata and note that credentials shouldn't set routing keys? Not blocking.

    gambtho gambtho approved these changes on Nov 04, 2026 18:29 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    aramase aramase
    Labels
    risk: low confidence: 86.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 74.1% (HIGH) · Higher = larger blast radius
    74.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 86.7% · Lower = rushed or shallow review
    86.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.9% · Safe to merge
    9.9%