Skip to content

chore: tunnel auth#4588

Open
NathanFlurry wants to merge 1 commit into04-07-chore_remove_udb_as_a_dependency_of_envoy-clientfrom
04-08-chore_tunnel_auth
Open

chore: tunnel auth#4588
NathanFlurry wants to merge 1 commit into04-07-chore_remove_udb_as_a_dependency_of_envoy-clientfrom
04-08-chore_tunnel_auth

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@claude
Copy link
Copy Markdown

claude bot commented Apr 8, 2026

PR Review: chore: tunnel auth (#4588)

Good security addition. The core mechanism — whitelist authorized (gateway_id, request_id) pairs when the engine pushes tunnel messages outbound, then validate those pairs when the envoy/runner sends tunnel messages back — is correct and well-scoped.

Security

The auth model is sound: an envoy/runner can only send a tunnel response for a request the engine explicitly initiated. Using scc::HashMap for concurrent access (per CLAUDE.md guidance) avoids mutex contention and is the right call here.

message_index is intentionally excluded from the auth key. Once a (gateway_id, request_id) pair is authorized, all message_index values for that pair are accepted. This is correct for streaming responses, but deserves an inline comment to make the intent explicit so a future reader doesn't question it.

Memory Growth

authorized_tunnel_routes grows indefinitely for the lifetime of a connection — entries are inserted but never removed. For long-lived connections handling many requests this accumulates without bound. If completed routes are never reused, consider removing entries when the response stream terminates, or at minimum document that per-connection accumulation is acceptable and the map is bounded by request volume.

pegboard-envoy Tests Entirely Commented Out

The test file engine/packages/pegboard-envoy/tests/support/ws_to_tunnel_task.rs is 100% commented out with a // TODO: Use TestCtx note. This leaves the envoy auth enforcement side completely untested at the unit level. The pegboard-runner tests (all four) work and compile, but the two implementations have different test coverage. Per CLAUDE.md's Engine Runner Parity requirement, this gap should be tracked and resolved. Either unblock the envoy tests or file a follow-up task with context on what TestCtx dependency is needed.

Minor: Error Context Dropped in pegboard-envoy

In pegboard-envoy/src/ws_to_tunnel_task.rs, the error context string was removed:

// Before
ctx.ups().context("failed to get UPS instance for tunnel message")?

// After
ctx.ups()?

In pegboard-runner, the equivalent context was preserved at the call site. The envoy change loses diagnostic information for a UPS initialization failure. Easy fix: keep the .context(...) call.

Import Cleanup (Positive)

The merge of the two universalpubsub imports in pegboard-runner's ws_to_tunnel_task.rs is a clean improvement.

Blank Lines

Two unrelated blank lines removed in both conn.rs files (before enum Init and #[tracing::instrument]). Harmless but unrelated to the auth change.

Tests

Coverage in pegboard-runner is thorough: rejection and acceptance paths tested for both mk2 and mk1. The #[path] trick to test private functions is effective. One gap: the tunnel_to_ws_task insert path (the authorization registration side) has no unit tests in either package — only the enforcement side is tested. A test confirming that receiving a ToEnvoyTunnelMessage/ToClientTunnelMessage actually populates authorized_tunnel_routes would close that loop.

Summary

The implementation is correct. Key items before merging:

  1. Unblock or track the envoy test gap (CLAUDE.md parity requirement)
  2. Address the memory growth question (cleanup or explicit note)
  3. Add a comment explaining message_index exclusion from the auth key
  4. Restore .context() on ctx.ups()? in pegboard-envoy

@NathanFlurry NathanFlurry force-pushed the 04-08-chore_tunnel_auth branch 2 times, most recently from 6de6776 to cfcac6f Compare April 8, 2026 09:39
@NathanFlurry NathanFlurry changed the base branch from 04-07-chore_remove_udb_as_a_dependency_of_envoy-client to graphite-base/4588 April 8, 2026 10:37
@NathanFlurry NathanFlurry mentioned this pull request Apr 8, 2026
11 tasks
@NathanFlurry NathanFlurry force-pushed the 04-08-chore_tunnel_auth branch from cfcac6f to 2f4d372 Compare April 8, 2026 11:07
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4588 to 04-07-chore_remove_udb_as_a_dependency_of_envoy-client April 8, 2026 11:07
@NathanFlurry NathanFlurry force-pushed the 04-08-chore_tunnel_auth branch from 2f4d372 to 85d514f Compare April 8, 2026 11:12
@MasterPtato MasterPtato changed the base branch from 04-07-chore_remove_udb_as_a_dependency_of_envoy-client to graphite-base/4588 April 8, 2026 20:11
@MasterPtato MasterPtato force-pushed the 04-08-chore_tunnel_auth branch from 85d514f to e629058 Compare April 8, 2026 20:11
@MasterPtato MasterPtato force-pushed the 04-08-chore_tunnel_auth branch from e629058 to ec89f2e Compare April 8, 2026 20:14
@MasterPtato MasterPtato changed the base branch from graphite-base/4588 to 04-07-chore_revert_actor_v2_hack April 8, 2026 20:14
@MasterPtato MasterPtato force-pushed the 04-07-chore_revert_actor_v2_hack branch from 8262c65 to d758690 Compare April 8, 2026 20:30
@MasterPtato MasterPtato force-pushed the 04-08-chore_tunnel_auth branch from ec89f2e to 4bea0d4 Compare April 8, 2026 20:30
@MasterPtato MasterPtato changed the base branch from 04-07-chore_revert_actor_v2_hack to graphite-base/4588 April 8, 2026 20:46
@MasterPtato MasterPtato force-pushed the 04-08-chore_tunnel_auth branch from 4bea0d4 to d7b0668 Compare April 8, 2026 20:46
@MasterPtato MasterPtato changed the base branch from graphite-base/4588 to 04-07-chore_remove_udb_as_a_dependency_of_envoy-client April 8, 2026 20:46
@MasterPtato MasterPtato marked this pull request as ready for review April 8, 2026 20:50
Copy link
Copy Markdown
Contributor

Merge activity

  • Apr 8, 8:52 PM UTC: A user started a stack merge that includes this pull request via Graphite.

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.

2 participants