feat(native): PR1B — byte-bounded outbound queue, typed send result#4
Open
mrmidi wants to merge 1 commit into
Open
feat(native): PR1B — byte-bounded outbound queue, typed send result#4mrmidi wants to merge 1 commit into
mrmidi wants to merge 1 commit into
Conversation
mrmidi
force-pushed
the
pr1b/queue-bounds
branch
from
July 20, 2026 14:25
43dddd5 to
63f8ff9
Compare
Pin fptn submodule to 7443f40 (pr1b/queue-bounds). C++ bridge: - sendPacket() returns uint8_t (0=accepted, 1=queue_full, 2=transport_stopped, 3=invalid_packet) - Status struct: +4 queue fields (queued_packets, queued_bytes, queued_bytes_peak, queue_full_count) Swift: - WebsocketSendResult enum in SharedTunnelRuntime (shared by app + tunnel). Mapped from C++ uint8_t via init(bridgeValue:). - TunnelWebSocketTransport protocol updated: sendPacket returns WebsocketSendResult. - Both wrappers (app + tunnel) return typed result. - Status struct: +4 queue diagnostic fields. Provider: - startReadLoop uses switch by result: .queueFull → feeds backpressure .transportStopped → breaks batch early (labeled loop) .invalidPacket/.unknown → counted, does not slow valid traffic Tests: 22/22 passed. Debug build succeeded.
mrmidi
force-pushed
the
pr1b/queue-bounds
branch
from
July 20, 2026 14:55
63f8ff9 to
58cca42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR1B — Queue and Batch Bounds
Base:
pr1a/native-baseline(stacked PR chain)fptn submodule:
13acece(pr1b/queue-bounds)Send() — typed result + byte accounting
SendResultenum:accepted,queue_full,transport_stopped,invalid_packettry_send. Both bytes and packet count reserved before the channel operation.queue_full_count_.RunSender() — strict batch limit + accounting release
releaseDequeuedPacketAccounting()called immediately on every dequeue, before IP-version validationpending_packet) prevents batch overshoot: bounds raw IP payload bytes to 64 KiB except one individually oversized packetQueue counters (unsigned, never reset in Stop)
queued_packetsqueued_bytesqueued_bytes_peakqueue_full_countC++ → Swift boundary
sendPacket()returnsuint8_t; null/zero-length rejected asinvalid_packetWebsocketSendResultenum in SharedTunnelRuntime;init(bridgeValue:)maps raw value;.unknown = 255Provider behavior
Native cleanups
#include <TargetConditionals.h>moved outside namespacesendPacketbefore vector constructionVerification
Native test debt
C++ accounting tests (concurrent CAS, rollback, gauge lifecycle, batch bounds) need fptn gtest infrastructure. Tracked for PR1B/PR1C fptn branch.
Stack