Skip to content

Add streaming negotiation prologue detector - #18

Merged
oferchen merged 1 commit into
masterfrom
codex/implement-rsync-3.4.1-functionality-in-rust
Oct 15, 2025
Merged

oferchen merged 1 commit into
masterfrom
codex/implement-rsync-3.4.1-functionality-in-rust

Conversation

@oferchen

@oferchen oferchen commented Oct 15, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • add a stateful negotiation prologue detector to mirror upstream chunked handshake behaviour
  • add unit tests covering binary detection, cached results, and split legacy prefixes

Testing

  • cargo test

@oferchen
oferchen merged commit f8a629b into master Oct 15, 2025
@oferchen
oferchen deleted the codex/implement-rsync-3.4.1-functionality-in-rust branch October 15, 2025 12:17
oferchen added a commit that referenced this pull request Sep 24, 2026
* test: register cross-impl hardlink batch replay divergence

Add oracle-gated cross-implementation --read-batch -aH parity cases for a
2- and 3-member hardlink cluster, both directions (upstream-writes/oc-reads
and oc-writes/upstream-reads). They assert the correct upstream-matching end
state: every cluster member present, all sharing one inode with the right
nlink, and the unlinked control independent.

Both are #[ignore]'d as a registered, owned known divergence (task #18):
oc's --write-batch ships the cluster's single payload under the sorted-first
member's NDX (the oc-self convention from #7928), while upstream ships it
under the sorted-last member - the FLAG_HLINK_LAST data-holder its generator
transfers (hlink.c:113-194 match_gnums(), hlink.c:490-565 finish_hard_link()),
and oc's batch replay decodes the follower's first_hlink_ndx with a different
base. So oc reading an upstream batch silently drops the leader (exit 0) and
upstream reading an oc batch exits 23.

A plain network -H transfer is unaffected - oc's live wire receiver follows
the sender's chosen data-holder correctly - so the divergence is specific to
the batch write and batch-replay paths, not the shared receiver.

These tests un-ignore when the batch-path fix lands (task #18); until then
they keep the verified divergence visible without a silent waiver. The
oc-self replay_hardlink_pair_parity case stays non-ignored and green.

* fix(batch): replay hardlinks under the sorted-last data-holder

Cross-implementation hardlink batch replay was broken both directions - a
fidelity obligation, since a batch is a tee of the protocol-32 wire stream
and the rsync man page requires any reader at protocol >= writer to replay
it. Upstream reading an oc batch failed with exit 23; oc reading an upstream
batch silently dropped the cluster leader at exit 0 (data loss). A plain
network -H transfer was unaffected in both directions.

Root cause: for a hardlink cluster upstream transfers the sorted-LAST member
- the one match_gnums() flags FLAG_HLINK_LAST and finish_hard_link()
completes - and links every other member (including the sorted-first) to it
(hlink.c:113-194, hlink.c:496-565). oc's --write-batch shipped the cluster's
single payload under the sorted-FIRST member's NDX, and the batch-replay
receiver treated the sorted-first hlink_first member as the materialized
data-holder. oc-self replay agreed with itself, so the divergence surfaced
only across implementations. The live wire path is unaffected because oc's
generator makes hlink_first the transferred member; only a recorded batch
stream can place the data-holder on a different member.

Three aligned changes:

- Writer (engine local_copy batch): ship the cluster payload under the
  sorted-LAST member's NDX, matching upstream's FLAG_HLINK_LAST data-holder,
  so upstream can replay an oc batch.

- Receiver replay commit (transfer receiver/transfer/replay.rs): record the
  just-committed hardlink member as its group's data-holder in the
  HardlinkApplyTracker. Which member the batch transferred is stream-dictated
  (now the sorted-last member), so the source cannot be inferred from disk
  presence - a stale pre-existing sorted-first member would otherwise win and
  the fresh payload be discarded.

- Receiver create_hardlinks(): during batch replay only (self.local_replay),
  let every hlink member - including the sorted-first leader - resolve its
  group source through promote_hardlink_leader() (which returns the recorded
  data-holder) and the self-link guard, so an absent or stale sorted-first
  member is re-linked to the fresh data-holder. The live path is unchanged:
  there an absent hlink_first member means its own transfer was
  skipped/errored (FLAG_SKIP_HLINK) and must not be resurrected, so that path
  keeps skipping every hlink_first member. This keeps the network -H receiver
  and its skip/virtual-first semantics untouched.

Un-ignores cross_impl_hardlink_batch_{pair,triple}_parity (added earlier as a
registered known divergence); they now pass both directions for 2- and
3-member clusters. Fixes the UTS batch-only-remove-source-regression cell
(replay into a pre-existing destination whose stale cluster members must be
re-linked to the freshly transferred payload). oc-self #7956/#7928 stay green
(they assert end state, which survives the data-holder change).

upstream: hlink.c:113-194 match_gnums(), hlink.c:496-565 finish_hard_link().
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