Skip to content

fix(guard): serialize gateway actor keys correctly#4655

Draft
NathanFlurry wants to merge 1 commit intobreak-up/subscribe-before-namespace-dispatchfrom
break-up/serialize-gateway-actor-keys
Draft

fix(guard): serialize gateway actor keys correctly#4655
NathanFlurry wants to merge 1 commit intobreak-up/subscribe-before-namespace-dispatchfrom
break-up/serialize-gateway-actor-keys

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

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 14, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 14, 2026

Code Review: fix(guard): serialize gateway actor keys correctly

Overview

This PR fixes a semantic bug in serialize_actor_key in the guard routing layer. The original code called escaped_parts.join(EMPTY_KEY) using the empty-key sentinel constant as the join separator. Both EMPTY_KEY and KEY_SEPARATOR happened to equal "/", so the output was identical before and after, but the code used the wrong constant for the wrong purpose.


Correctness

No functional change in this PR. Both constants equal "/", so the serialized output is bit-for-bit identical before and after. The fix is a semantic/clarity correction: the join separator should reference the separator constant, not the empty-key sentinel.

This is still the right fix. Had either constant ever drifted (e.g. EMPTY_KEY becoming "" or the separator becoming ":"), the old code would have silently produced wrong keys.


Minor Suggestion: Eliminate KEY_SEPARATOR_CHAR

The PR adds two constants to work around a type mismatch (char for replace(), &str for join()):

const KEY_SEPARATOR: &str = "/";
const KEY_SEPARATOR_CHAR: char = /;

str::replace accepts any Pattern, and &str implements Pattern, so KEY_SEPARATOR_CHAR is unnecessary. KEY_SEPARATOR (&str) works in both the replace and join calls, removing the extra constant.


Test Coverage

No unit tests exist for serialize_actor_key. For escape logic, a small test table is worth adding to cover: empty slice, single part, multiple parts joined with /, part containing / escaped to "\/", and empty string part encoded as "\0".


Summary

Area Assessment
Correctness No functional regression; semantic fix is valid
Code style Consistent with surrounding code
Suggestion KEY_SEPARATOR_CHAR can be removed; use &str for both replace and join
Tests Missing -- worth adding for the escape logic

Small, low-risk fix. Removing KEY_SEPARATOR_CHAR is a nice-to-have, not a blocker.

@NathanFlurry NathanFlurry marked this pull request as ready for review April 15, 2026 01:09
@NathanFlurry NathanFlurry force-pushed the break-up/subscribe-before-namespace-dispatch branch from a05b2e5 to a91a7cb Compare April 15, 2026 02:40
@NathanFlurry NathanFlurry force-pushed the break-up/serialize-gateway-actor-keys branch from 9550912 to 3948546 Compare April 15, 2026 02:40
@NathanFlurry NathanFlurry force-pushed the break-up/serialize-gateway-actor-keys branch from 3948546 to eb94473 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry force-pushed the break-up/subscribe-before-namespace-dispatch branch from a91a7cb to a752140 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry marked this pull request as draft April 15, 2026 02:59
@NathanFlurry NathanFlurry force-pushed the break-up/serialize-gateway-actor-keys branch from eb94473 to 55e0885 Compare April 15, 2026 06:55
@NathanFlurry NathanFlurry force-pushed the break-up/subscribe-before-namespace-dispatch branch from a752140 to 2aca1af Compare April 15, 2026 06:55
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.

1 participant