Skip to content

refactor(server): split responses.rs by role and unify reply framing - #4089

Open
hubcio wants to merge 1 commit into
masterfrom
server-ng-pr5-responses-recut
Open

hubcio wants to merge 1 commit into
masterfrom
server-ng-pr5-responses-recut

Conversation

@hubcio

@hubcio hubcio commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

responses.rs mixed three concerns in 2459 lines: identifier and
namespace resolution, reply frame building, and the process probe
behind GetStats. Around it the read side carried two more forks:
private server copies of the metadata crate's stream and topic
resolvers, and five hand-written ReplyHeader echo literals plus a
sixth writing the rejection result section against a private 12-byte
constant. Any change to an echo or a resolver had to be repeated at
every copy.

Split responses.rs into leaf modules by role: namespace.rs resolves
wire identifiers and partition namespaces and owns the
consumer-group offset fence, reply_frame.rs owns the seven frame
builders, and sysinfo_probe.rs owns that probe. The catalog keeps
NonReplicatedResponse and imports the three one way, keeping the
module graph a DAG.

Export StreamsInner::resolve_stream_id and resolve_topic_id beside
the sibling UsersInner::resolve_user_id, and delete the server
copies, so the in-apply, dispatch read and HTTP read gates end on
one resolution.

Give ReplyHeader two constructors: from_prepare reproduces the
committed-reply literal, echoing is the base the request-echo sites
consume with ... echoing leaves client zero on purpose: dispatch
stamps the transport id, the rest the VSR id, so no base can pick
one. The rejection section moves beside its decoder as
write_rejection_section. The NoAck fast path keeps its literal: it
stamps live consensus fields, not the echo. Frames match byte for
byte before and after.

The dispatch failure exits trade byte snapshots, which pinned the
previous refactor rather than the wire contract, for one shape test
per exit.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Sep 7, 2026
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38067% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.08%. Comparing base (c2bd0c0) to head (a9c2a53).

Files with missing lines Patch % Lines
core/server/src/namespace.rs 88.25% 22 Missing and 7 partials ⚠️
core/server/src/reply_frame.rs 96.37% 6 Missing and 14 partials ⚠️
core/server/src/sysinfo_probe.rs 92.30% 0 Missing and 4 partials ⚠️
core/server/src/http/reads.rs 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4089      +/-   ##
============================================
- Coverage     87.13%   87.08%   -0.05%     
  Complexity     1455     1455              
============================================
  Files          1273     1276       +3     
  Lines        215301   215145     -156     
  Branches     179909   179753     -156     
============================================
- Hits         187597   187358     -239     
- Misses        23178    23245      +67     
- Partials       4526     4542      +16     
Components Coverage Δ
Rust Core 88.10% <95.38%> (-0.06%) ⬇️
Java SDK 67.58% <ø> (ø)
C# SDK 77.16% <ø> (+0.04%) ⬆️
Python SDK 90.97% <ø> (ø)
PHP SDK 85.67% <ø> (ø)
Node SDK 96.24% <ø> (-0.03%) ⬇️
Go SDK 69.48% <ø> (+0.03%) ⬆️
Files with missing lines Coverage Δ
core/binary_protocol/src/consensus/header.rs 83.37% <100.00%> (+1.50%) ⬆️
core/binary_protocol/src/consensus/reply_result.rs 100.00% <100.00%> (ø)
core/consensus/src/plane_helpers.rs 95.16% <100.00%> (-0.15%) ⬇️
core/metadata/src/stm/result.rs 98.75% <100.00%> (-0.03%) ⬇️
core/metadata/src/stm/stream.rs 94.04% <100.00%> (-0.01%) ⬇️
core/metadata/src/stm/user.rs 93.16% <ø> (ø)
core/server/src/boot/mod.rs 87.19% <100.00%> (ø)
core/server/src/consumer_group.rs 97.74% <ø> (ø)
core/server/src/dispatch/authz.rs 98.40% <100.00%> (ø)
core/server/src/dispatch/failure.rs 97.56% <100.00%> (+0.19%) ⬆️
... and 14 more

... and 49 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

responses.rs mixed three concerns in 2459 lines: identifier and
namespace resolution, reply frame building, and the process probe
behind GetStats. Around it the read side carried two more forks:
private server copies of the metadata crate's stream and topic
resolvers, and five hand-written ReplyHeader echo literals plus a
sixth writing the rejection result section against a private 12-byte
constant. Any change to an echo or a resolver had to be repeated at
every copy.

Split responses.rs into leaf modules by role: namespace.rs resolves
wire identifiers and partition namespaces and owns the
consumer-group offset fence, reply_frame.rs owns the seven frame
builders, and sysinfo_probe.rs owns that probe. The catalog keeps
NonReplicatedResponse and imports the three one way, keeping the
module graph a DAG.

Export StreamsInner::resolve_stream_id and resolve_topic_id beside
the sibling UsersInner::resolve_user_id, and delete the server
copies, so the in-apply, dispatch read and HTTP read gates end on
one resolution.

Give ReplyHeader two constructors: from_prepare reproduces the
committed-reply literal, echoing is the base the request-echo sites
consume with `..`. echoing leaves client zero on purpose: dispatch
stamps the transport id, the rest the VSR id, so no base can pick
one. The rejection section moves beside its decoder as
write_rejection_section. The NoAck fast path keeps its literal: it
stamps live consensus fields, not the echo. Frames match byte for
byte before and after.

The dispatch failure exits trade byte snapshots, which pinned the
previous refactor rather than the wire contract, for one shape test
per exit.
@hubcio
hubcio force-pushed the server-ng-pr5-responses-recut branch from 051a527 to a9c2a53 Compare September 14, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant