Skip to content

feat(engine): DeleteEmitter scaffold for parallel deterministic delete (#2259) - #4260

Merged
oferchen merged 1 commit into
masterfrom
feat/delete-emitter-scaffold-2259
May 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/delete-emitter-scaffold-2259

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Scaffolds DeleteEmitter, the single-threaded drain task for the parallel-deterministic delete pipeline (design: docs/design/parallel-deterministic-delete.md). The emitter is the single writer of every observable delete side effect, preserving the invariant that wall-clock unlink order, *deleting itemize order, and NDX_DEL_STATS framing match upstream rsync 3.4.1 byte for byte.
  • Lands the DeleteFs trait carving one method per upstream-distinguishable entry kind (delete.c::delete_item:144-176), the production RealDeleteFs impl backed by std::fs, and a RecordingDeleteFs test fake that captures the dispatch sequence without touching the filesystem.
  • Drops in placeholder DeletePlan / PlannedDelete / DeletePlanMap / DirTraversalCursor types inside emitter.rs using the exact names from DDP-A3 (Stop delegating --server to external fallback #2253) and DDP-A4 (Stop delegating --server to fallback binary #2254), so substitution at merge is mechanical.

Scope

In scope (task DDP-C1, #2259):

  • crates/engine/src/delete/mod.rs declaring pub mod emitter;.
  • crates/engine/src/delete/emitter.rs with the trait, fakes, struct, and skeleton emit_all loop.
  • Unit tests asserting dispatch + ordering invariants.

Out of scope (subsequent DDP-C tasks):

Test plan

  • cargo fmt --all clean
  • cargo nextest run -p engine --all-features -E 'test(delete::emitter)' -- 5 / 5 pass
  • cargo check -p engine --tests clean
  • cargo clippy -p engine --all-targets --all-features --no-deps clean for the new module (a pre-existing bench warning on adaptive_bufferpool.rs is unrelated and already on master)
  • CI: fmt+clippy, nextest (stable), Windows, macOS, Linux musl

Test cases

  1. Empty plan map returns Ok(()) immediately, no events recorded, zero stats.
  2. Full dispatch matrix: one entry per kind in a single directory verifies File -> unlink_file, Directory -> rmdir, Symlink -> unlink_symlink, Device -> unlink_device, Special -> unlink_special, with DeleteStats incremented for each.
  3. Three directories x two entries each: events emerge in cursor order, within-directory plan order is preserved (the plan is already reversed by compute_extras; see generator.c:320).
  4. Cursor outpaces plans: emitter parks at the missing-plan gap, returns Ok, and resumes correctly on a later emit_all call once the plan is published.
  5. RealDeleteFs smoke test on a tempfile::tempdir exercising unlink_file + rmdir against real filesystem state.

Cross-PR coordination

This PR runs in parallel with the DDP-A3+A4 PR (DeletePlan / DeletePlanMap / DirTraversalCursor at crates/engine/src/delete/). Both PRs add pub mod delete; to crates/engine/src/lib.rs; the second to merge resolves the trivial conflict by keeping a single declaration. The placeholder types inside this PR's emitter.rs are named identically to the design spec so DDP-A3+A4 can replace them with use imports without touching the emitter logic.

#2259)

Scaffolds the single-threaded emitter half of the parallel-deterministic
delete pipeline (design: parallel-deterministic-delete.md). Lands the
DeleteFs trait so the dispatch table per upstream entry kind (delete.c
delete_item:144-176) is mockable in tests, a RealDeleteFs production
impl backed by std::fs, a RecordingDeleteFs test fake that captures the
syscall sequence, and the DeleteEmitter::emit_all drain loop that walks
DirTraversalCursor in upstream traversal order and increments
DeleteStats per planned entry.

The DeletePlan, DeletePlanMap, and DirTraversalCursor types are
declared as in-file placeholders (matching the names DDP-A3 #2253 and
DDP-A4 #2254 will produce) so the scaffold is independently mergeable;
the type substitution at merge is mechanical. Syscall hardening
(DDP-C2 #2260) and upstream error policy (DDP-C3 #2261) come next.

Tests cover the empty-map base case, the full File/Dir/Symlink/
Device/Special dispatch matrix, multi-directory cursor-order traversal
with within-directory plan order, and the cursor-outpaces-plans gap
where emit_all parks and resumes on a later call.
@oferchen
oferchen force-pushed the feat/delete-emitter-scaffold-2259 branch from 8ccce92 to b2536f8 Compare May 17, 2026 20:25
@oferchen
oferchen merged commit 22f219f into master May 17, 2026
12 of 13 checks passed
@github-actions github-actions Bot added the enhancement New feature or request label May 17, 2026
oferchen added a commit that referenced this pull request May 18, 2026
#2259) (#4260)

Scaffolds the single-threaded emitter half of the parallel-deterministic
delete pipeline (design: parallel-deterministic-delete.md). Lands the
DeleteFs trait so the dispatch table per upstream entry kind (delete.c
delete_item:144-176) is mockable in tests, a RealDeleteFs production
impl backed by std::fs, a RecordingDeleteFs test fake that captures the
syscall sequence, and the DeleteEmitter::emit_all drain loop that walks
DirTraversalCursor in upstream traversal order and increments
DeleteStats per planned entry.

The DeletePlan, DeletePlanMap, and DirTraversalCursor types are
declared as in-file placeholders (matching the names DDP-A3 #2253 and
DDP-A4 #2254 will produce) so the scaffold is independently mergeable;
the type substitution at merge is mechanical. Syscall hardening
(DDP-C2 #2260) and upstream error policy (DDP-C3 #2261) come next.

Tests cover the empty-map base case, the full File/Dir/Symlink/
Device/Special dispatch matrix, multi-directory cursor-order traversal
with within-directory plan order, and the cursor-outpaces-plans gap
where emit_all parks and resumes on a later call.
oferchen added a commit that referenced this pull request May 18, 2026
#2259) (#4260)

Scaffolds the single-threaded emitter half of the parallel-deterministic
delete pipeline (design: parallel-deterministic-delete.md). Lands the
DeleteFs trait so the dispatch table per upstream entry kind (delete.c
delete_item:144-176) is mockable in tests, a RealDeleteFs production
impl backed by std::fs, a RecordingDeleteFs test fake that captures the
syscall sequence, and the DeleteEmitter::emit_all drain loop that walks
DirTraversalCursor in upstream traversal order and increments
DeleteStats per planned entry.

The DeletePlan, DeletePlanMap, and DirTraversalCursor types are
declared as in-file placeholders (matching the names DDP-A3 #2253 and
DDP-A4 #2254 will produce) so the scaffold is independently mergeable;
the type substitution at merge is mechanical. Syscall hardening
(DDP-C2 #2260) and upstream error policy (DDP-C3 #2261) come next.

Tests cover the empty-map base case, the full File/Dir/Symlink/
Device/Special dispatch matrix, multi-directory cursor-order traversal
with within-directory plan order, and the cursor-outpaces-plans gap
where emit_all parks and resumes on a later call.
@oferchen
oferchen deleted the feat/delete-emitter-scaffold-2259 branch May 19, 2026 19:28
oferchen added a commit that referenced this pull request Aug 24, 2026
#2259) (#4260)

Scaffolds the single-threaded emitter half of the parallel-deterministic
delete pipeline (design: parallel-deterministic-delete.md). Lands the
DeleteFs trait so the dispatch table per upstream entry kind (delete.c
delete_item:144-176) is mockable in tests, a RealDeleteFs production
impl backed by std::fs, a RecordingDeleteFs test fake that captures the
syscall sequence, and the DeleteEmitter::emit_all drain loop that walks
DirTraversalCursor in upstream traversal order and increments
DeleteStats per planned entry.

The DeletePlan, DeletePlanMap, and DirTraversalCursor types are
declared as in-file placeholders (matching the names DDP-A3 #2253 and
DDP-A4 #2254 will produce) so the scaffold is independently mergeable;
the type substitution at merge is mechanical. Syscall hardening
(DDP-C2 #2260) and upstream error policy (DDP-C3 #2261) come next.

Tests cover the empty-map base case, the full File/Dir/Symlink/
Device/Special dispatch matrix, multi-directory cursor-order traversal
with within-directory plan order, and the cursor-outpaces-plans gap
where emit_all parks and resumes on a later call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant