Skip to content

Add executable fallback to brand detection - #1380

Merged
oferchen merged 1 commit into
masterfrom
prepare-for-production-release-and-documentation-validation
Oct 28, 2025
Merged

oferchen merged 1 commit into
masterfrom
prepare-for-production-release-and-documentation-validation

Conversation

@oferchen

@oferchen oferchen commented Oct 28, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • add reusable helpers to derive a brand from program paths and OsStr inputs
  • fall back to the current executable name when argv[0] is absent
  • extend branding tests to cover the new helpers and fallback behaviour

Testing

  • cargo test -p rsync-core branding::tests

@oferchen
oferchen merged commit d86ba15 into master Oct 28, 2025
@oferchen
oferchen deleted the prepare-for-production-release-and-documentation-validation branch October 28, 2025 15:00
oferchen added a commit that referenced this pull request Mar 30, 2026
Now that the lz4 per-token flush alignment (PR #3053) and zstd
per-token flush boundary (PR #3047) wire fixes are merged, enable
actual interop testing for both codecs instead of skipping them.

- Update capability_compression_negotiation_preference test to expect
  zstd/lz4 selection when their feature flags are enabled
- Replace informational-only zstd/lz4 interop test stubs with real
  run_compress_test calls including delta transfer variants
- Update auto-negotiation comments to reflect that zstd/lz4 are now
  fully validated and advertised

Closes #1380
oferchen added a commit that referenced this pull request Mar 30, 2026
…ts (#3055)

Now that the lz4 per-token flush alignment (PR #3053) and zstd
per-token flush boundary (PR #3047) wire fixes are merged, enable
actual interop testing for both codecs instead of skipping them.

- Update capability_compression_negotiation_preference test to expect
  zstd/lz4 selection when their feature flags are enabled
- Replace informational-only zstd/lz4 interop test stubs with real
  run_compress_test calls including delta transfer variants
- Update auto-negotiation comments to reflect that zstd/lz4 are now
  fully validated and advertised

Closes #1380
oferchen added a commit that referenced this pull request Mar 31, 2026
Root cause: supported_compressions() advertised zstd and lz4 in the
vstring negotiation list despite their wire format not being validated
against upstream rsync. When upstream client sent plain -z, both sides
negotiated zstd (highest priority), but our zstd decompressor produced
"Unknown frame descriptor" errors because the per-token wire framing
doesn't match upstream's token.c format.

This caused ALL 10 compression interop tests to fail - even zlibx tests -
because auto-negotiation overrode the user's -z to use zstd.

Fix: remove zstd/lz4 from supported_compressions() so auto-negotiation
falls back to zlibx (which works). The codecs remain compiled in for
future use; re-enable after wire format validation (tasks #1379, #1380).

Also: skip explicit --compress-choice=zstd/lz4 tests in compress interop
script until wire format is validated.
oferchen added a commit that referenced this pull request Mar 31, 2026
…n negotiation (#3076)

* fix: detect --new-compress, --compress-choice from client args for daemon compression

The daemon receiver's do_compression detection only checked for 'z' in
compact short flags (e.g. -avz). Upstream rsync only puts 'z' in the
argstr for CPRES_ZLIB; for zlibx it sends --new-compress, and for
zstd/lz4 it sends --compress-choice=ALGO as long options.

This caused the daemon to set do_compression=false when receiving
compressed transfers using zlibx/zstd/lz4, resulting in:
- zstd/lz4: "block reference N without basis file" (compressed bytes
  misread as plain 4-byte LE token indices)
- zlibx: "Unknown frame descriptor" (compression not activated)

Fix: parse --new-compress, --old-compress, and --compress-choice=ALGO
from client args. When an explicit compress_choice is set, skip the
compression vstring negotiation (matching upstream compat.c:543) and
use the specified algorithm directly.

upstream: options.c:2800-2805 server_options(), compat.c:543

* fix: remove up:compress-zstd and up:compress-lz4 from known interop failures

These daemon receiver compression failures are fixed by the
--compress-choice detection in the previous commit.

* fix: exclude unvalidated zstd/lz4 from compression auto-negotiation

Root cause: supported_compressions() advertised zstd and lz4 in the
vstring negotiation list despite their wire format not being validated
against upstream rsync. When upstream client sent plain -z, both sides
negotiated zstd (highest priority), but our zstd decompressor produced
"Unknown frame descriptor" errors because the per-token wire framing
doesn't match upstream's token.c format.

This caused ALL 10 compression interop tests to fail - even zlibx tests -
because auto-negotiation overrode the user's -z to use zstd.

Fix: remove zstd/lz4 from supported_compressions() so auto-negotiation
falls back to zlibx (which works). The codecs remain compiled in for
future use; re-enable after wire format validation (tasks #1379, #1380).

Also: skip explicit --compress-choice=zstd/lz4 tests in compress interop
script until wire format is validated.

* style: fix rustfmt formatting in compression negotiation tests

* fix: update negotiation tests to reflect zstd/lz4 exclusion from auto-negotiation
oferchen added a commit that referenced this pull request Apr 3, 2026
…-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.
oferchen added a commit that referenced this pull request Apr 3, 2026
…-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.
oferchen added a commit that referenced this pull request Apr 3, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request Apr 5, 2026
Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.
oferchen added a commit that referenced this pull request Apr 5, 2026
Advertise zstd and lz4 in the capability negotiation string when their
respective feature flags are enabled. Previously these algorithms were
only usable via explicit --compress-choice and were intentionally
excluded from auto-negotiation pending daemon receive codec validation.

With PR #3113 fixing the daemon receive codec, auto-negotiation can
safely select zstd/lz4 when both peers support them. The preference
order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none.

Closes #1379, closes #1380.
oferchen added a commit that referenced this pull request Apr 6, 2026
Advertise zstd and lz4 in the capability negotiation string when their
respective feature flags are enabled. Previously these algorithms were
only usable via explicit --compress-choice and were intentionally
excluded from auto-negotiation pending daemon receive codec validation.

With PR #3113 fixing the daemon receive codec, auto-negotiation can
safely select zstd/lz4 when both peers support them. The preference
order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none.

Closes #1379, closes #1380.
oferchen added a commit that referenced this pull request Apr 6, 2026
Advertise zstd and lz4 in the capability negotiation string when their
respective feature flags are enabled. Previously these algorithms were
only usable via explicit --compress-choice and were intentionally
excluded from auto-negotiation pending daemon receive codec validation.

With PR #3113 fixing the daemon receive codec, auto-negotiation can
safely select zstd/lz4 when both peers support them. The preference
order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none.

Closes #1379, closes #1380.
oferchen added a commit that referenced this pull request Apr 6, 2026
Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.
oferchen added a commit that referenced this pull request Apr 6, 2026
Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.
oferchen added a commit that referenced this pull request Apr 6, 2026
* feat: enable zstd compression auto-negotiation

Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.

* fix: reuse sender-side CompressedTokenEncoder across files for zstd

Create the CompressedTokenEncoder once at session level in
run_transfer_loop() and pass it to per-file functions, matching
upstream token.c's single compression context pattern. Previously
each file created a new encoder (new ZSTD_CCtx), breaking zstd's
continuous-stream contract where the receiver expects one DCtx
for the entire session.

upstream: token.c uses a single compression context across all files
oferchen added a commit that referenced this pull request May 1, 2026
…ts (#3055)

Now that the lz4 per-token flush alignment (PR #3053) and zstd
per-token flush boundary (PR #3047) wire fixes are merged, enable
actual interop testing for both codecs instead of skipping them.

- Update capability_compression_negotiation_preference test to expect
  zstd/lz4 selection when their feature flags are enabled
- Replace informational-only zstd/lz4 interop test stubs with real
  run_compress_test calls including delta transfer variants
- Update auto-negotiation comments to reflect that zstd/lz4 are now
  fully validated and advertised

Closes #1380
oferchen added a commit that referenced this pull request May 1, 2026
…n negotiation (#3076)

* fix: detect --new-compress, --compress-choice from client args for daemon compression

The daemon receiver's do_compression detection only checked for 'z' in
compact short flags (e.g. -avz). Upstream rsync only puts 'z' in the
argstr for CPRES_ZLIB; for zlibx it sends --new-compress, and for
zstd/lz4 it sends --compress-choice=ALGO as long options.

This caused the daemon to set do_compression=false when receiving
compressed transfers using zlibx/zstd/lz4, resulting in:
- zstd/lz4: "block reference N without basis file" (compressed bytes
  misread as plain 4-byte LE token indices)
- zlibx: "Unknown frame descriptor" (compression not activated)

Fix: parse --new-compress, --old-compress, and --compress-choice=ALGO
from client args. When an explicit compress_choice is set, skip the
compression vstring negotiation (matching upstream compat.c:543) and
use the specified algorithm directly.

upstream: options.c:2800-2805 server_options(), compat.c:543

* fix: remove up:compress-zstd and up:compress-lz4 from known interop failures

These daemon receiver compression failures are fixed by the
--compress-choice detection in the previous commit.

* fix: exclude unvalidated zstd/lz4 from compression auto-negotiation

Root cause: supported_compressions() advertised zstd and lz4 in the
vstring negotiation list despite their wire format not being validated
against upstream rsync. When upstream client sent plain -z, both sides
negotiated zstd (highest priority), but our zstd decompressor produced
"Unknown frame descriptor" errors because the per-token wire framing
doesn't match upstream's token.c format.

This caused ALL 10 compression interop tests to fail - even zlibx tests -
because auto-negotiation overrode the user's -z to use zstd.

Fix: remove zstd/lz4 from supported_compressions() so auto-negotiation
falls back to zlibx (which works). The codecs remain compiled in for
future use; re-enable after wire format validation (tasks #1379, #1380).

Also: skip explicit --compress-choice=zstd/lz4 tests in compress interop
script until wire format is validated.

* style: fix rustfmt formatting in compression negotiation tests

* fix: update negotiation tests to reflect zstd/lz4 exclusion from auto-negotiation
oferchen added a commit that referenced this pull request May 1, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request May 1, 2026
* feat: enable zstd compression auto-negotiation

Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.

* fix: reuse sender-side CompressedTokenEncoder across files for zstd

Create the CompressedTokenEncoder once at session level in
run_transfer_loop() and pass it to per-file functions, matching
upstream token.c's single compression context pattern. Previously
each file created a new encoder (new ZSTD_CCtx), breaking zstd's
continuous-stream contract where the receiver expects one DCtx
for the entire session.

upstream: token.c uses a single compression context across all files
oferchen added a commit that referenced this pull request May 5, 2026
…ts (#3055)

Now that the lz4 per-token flush alignment (PR #3053) and zstd
per-token flush boundary (PR #3047) wire fixes are merged, enable
actual interop testing for both codecs instead of skipping them.

- Update capability_compression_negotiation_preference test to expect
  zstd/lz4 selection when their feature flags are enabled
- Replace informational-only zstd/lz4 interop test stubs with real
  run_compress_test calls including delta transfer variants
- Update auto-negotiation comments to reflect that zstd/lz4 are now
  fully validated and advertised

Closes #1380
oferchen added a commit that referenced this pull request May 5, 2026
…n negotiation (#3076)

* fix: detect --new-compress, --compress-choice from client args for daemon compression

The daemon receiver's do_compression detection only checked for 'z' in
compact short flags (e.g. -avz). Upstream rsync only puts 'z' in the
argstr for CPRES_ZLIB; for zlibx it sends --new-compress, and for
zstd/lz4 it sends --compress-choice=ALGO as long options.

This caused the daemon to set do_compression=false when receiving
compressed transfers using zlibx/zstd/lz4, resulting in:
- zstd/lz4: "block reference N without basis file" (compressed bytes
  misread as plain 4-byte LE token indices)
- zlibx: "Unknown frame descriptor" (compression not activated)

Fix: parse --new-compress, --old-compress, and --compress-choice=ALGO
from client args. When an explicit compress_choice is set, skip the
compression vstring negotiation (matching upstream compat.c:543) and
use the specified algorithm directly.

upstream: options.c:2800-2805 server_options(), compat.c:543

* fix: remove up:compress-zstd and up:compress-lz4 from known interop failures

These daemon receiver compression failures are fixed by the
--compress-choice detection in the previous commit.

* fix: exclude unvalidated zstd/lz4 from compression auto-negotiation

Root cause: supported_compressions() advertised zstd and lz4 in the
vstring negotiation list despite their wire format not being validated
against upstream rsync. When upstream client sent plain -z, both sides
negotiated zstd (highest priority), but our zstd decompressor produced
"Unknown frame descriptor" errors because the per-token wire framing
doesn't match upstream's token.c format.

This caused ALL 10 compression interop tests to fail - even zlibx tests -
because auto-negotiation overrode the user's -z to use zstd.

Fix: remove zstd/lz4 from supported_compressions() so auto-negotiation
falls back to zlibx (which works). The codecs remain compiled in for
future use; re-enable after wire format validation (tasks #1379, #1380).

Also: skip explicit --compress-choice=zstd/lz4 tests in compress interop
script until wire format is validated.

* style: fix rustfmt formatting in compression negotiation tests

* fix: update negotiation tests to reflect zstd/lz4 exclusion from auto-negotiation
oferchen added a commit that referenced this pull request May 5, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request May 5, 2026
* feat: enable zstd compression auto-negotiation

Add zstd to the supported compression list advertised during vstring
negotiation, gated on the `zstd` feature flag. When both peers support
zstd, it is automatically selected as the preferred compression codec
instead of falling back to zlibx/zlib. This mirrors upstream rsync's
compat.c:100-112 where SUPPORT_ZSTD gates zstd in the preference list.

The zstd per-token wire framing was validated in PR #3081, making it
safe for auto-negotiation. Lz4 remains excluded until its wire format
is interop-validated (task #1380). Graceful fallback to zlibx/zlib
occurs when the remote peer does not advertise zstd support.

* fix: reuse sender-side CompressedTokenEncoder across files for zstd

Create the CompressedTokenEncoder once at session level in
run_transfer_loop() and pass it to per-file functions, matching
upstream token.c's single compression context pattern. Previously
each file created a new encoder (new ZSTD_CCtx), breaking zstd's
continuous-stream contract where the receiver expects one DCtx
for the entire session.

upstream: token.c uses a single compression context across all files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant