Subtraction review of PR #79 (+468 / −22, 7 files)
Key findings
The stated fix — fall back to a hard link when renameat2(RENAME_NOREPLACE) returns EINVAL/ENOTSUP — is a six-line branch in heliopause/src/export/archive.rs plus one test. It is buried under a second mechanism, a "directory publication preflight", that adds ~244 lines, runs two to three times per export, duplicates a destination check that every call site already performs, and cannot change any outcome. On top of that the diff carries a generic helper with one caller, five tests for a three-line branch of which two pairs assert the same thing, and one unsolicited reorder.
- Blocking: the whole directory-publication preflight (preflight fn, 3 Rust tests, 1 new Python test file, a pyfunction and 5 call sites) is redundant — ~244 of 468 added lines. Every call site already checks the destination, and
rename_noreplacealready returns the same verdict where the tree is actually published. - Should fix:
capture_with_owners(binding.rs:97-118) exists only so a test can inject the preflight failure; main's inline body is equivalent (~71 lines). - Should fix: archive.rs has five tests for one branch; two pairs are duplicates and the injected-error seam helper can be inlined (~63 lines).
- Should fix (claim, 0 lines): even the retained fallback does not fix #54 — the directory publishers at cache.rs:2817/:3696, export.rs:742, conversion.rs:436 and edit.rs:250 (not opened) are still bare
rename_noreplace. - Nit: the
synchronizereorder incommit_standaloneis churn with no purpose (~2 lines).
Total removable: about 380 of 468 added lines. What is left is roughly +80/−1 in archive.rs alone: the branch, the EEXIST test and one errno test. Judged against AGENTS.md:188-193 ("Reject unsupported abstractions and churn": no fallback layers, extension points or switches without a concrete requirement) and AGENTS.md:194-199 ("Require focused, meaningful validation": tests must exercise the affected behaviour, mocks cannot establish runtime correctness).
1. Blocking — delete the entire directory-publication preflight (~244 lines)
What goes
| Location | Lines |
|---|---|
helios/src/core/cache.rs:4174-4261 preflight_directory_publication + preflight_directory_publication_with |
88 |
| helios/src/core/cache.rs:4518-4587 three tests | ~70 |
| tests/preparation/test_directory_preflight.py (new file) | 68 |
heliopause/src/export/binding.rs:33-36 call, :120-124 export_preflight_directory, :128 registration |
~9 |
| heliopause/src/export/core.rs:640-642 call | 3 |
helios/src/core/cache.rs:2804 call in export_entry |
1 |
helios/src/core/cache.rs:3678 call in commit_standalone |
1 |
helios/src/core/conversion.rs:316-317 call in unpack_with |
2 |
| ignition/preparation/model_core.py:41-42 call | 2 |
Replacement: nothing.
Why nothing is lost (verified in the code)
- Every call site already checks the destination immediately before calling the probe:
export_entryat cache.rs:2797-2803 (export destination {} already exists),commit_standaloneat cache.rs:3671-3677 (same message),publish_payloadat core.rs:618-620 and again at :627-632,unpack_withat conversion.rs:364-366 (destination exists: {output}). The probe's ownAlreadyExistsarm (cache.rs:4194-4200) is therefore a third or fourth check, with a different message than the established one. - The verdict the probe produces is already produced where it matters: the publication path calls
rename_noreplaceat cache.rs:2817 and :3696, with no wrapper, so on mergerfs the sameEINVALsurfaces there anyway. The probe only moves the failure earlier — after the expensive rank capture it is supposed to protect (model_core.py:41-42 runs beforeexport_modelat :51). - It reimplements helpers the repository already has:
token()(cache.rs:3537-3543) for unique staging names,unique_staging/staging_token(conversion.rs:2603-2623) for the ring-random hex name, andTempDirectory(conversion.rs:2595-2601) for cleanup. The probe hand-rolls all three (cache.rs:4206-4218, :4237, :4250-4260). - It is not free, contrary to its own doc comment ("this probe reserves nothing", cache.rs:4175): cache.rs:4204-4205 runs
fs::create_dir_all(parent)and creates the user's output parent, then :4213-4218 creates a.flare-rename-probe-<32 hex>directory and :4237 removes the tree — three filesystem mutations outside the destination on every probed export. - One export probes the same destination 2-3 times: model_core.py:42 →
publish_payload(core.rs:640-642) →root.export_entry(cache.rs:2804). - Its tests cannot fail on their subject. tests/preparation/test_directory_preflight.py:11-40 fakes
flare_heliopause(:28-31) with a stub namedrejectand asserts call order (calls == [str(destination)], :37) — it proves only thatmodel_core.export_corecalls a stub first. :43-52 is parametrized and passes because_OPTIONSis unset (model_core.py:31-33 aborts before the probe), so itsunexpectedstub is dead code. :55-68 needs a built native module, skips off Linux, and re-asserts exactly what cache.rs:4518-4587 already asserts. The destination-not-replaced guarantee is already covered by cache.rs:5497-5530exported_entries_never_replace_existing_outputand export.rs:1917/1946.
Smaller version: remove all of the above; keep no preflight.
2. Should fix — capture_with_owners and its test exist only for the preflight test (~71 lines)
heliopause/src/export/binding.rs:97-118 defines a generic capture_with_owners<O, T>(owners, capture, drain). It has exactly one production caller (binding.rs:89) and one test (binding.rs:1474-1520, 47 lines) whose only reason to exist is to inject the preflight failure from finding 1. Main's export_capture (main binding.rs:14-100) has the same capture → drain → release ordering inline, with OwnerLease created before py.detach and take_after_drain after; the PR version at binding.rs:33-95 is that same body wrapped in two closures plus the generic.
The one behavioural difference the PR introduces — the preflight at binding.rs:34-36, guarded by !request.sources && !request.path.as_os_str().is_empty() — goes with finding 1.
Smaller version: restore main's inline body; the file returns to its main size (the PR's +91/−20 nets to 0 added lines beyond the preflight guard).
3. Should fix — archive.rs tests prove the same two things twice, and the seam helper can be inlined (~63 lines)
heliopause/src/export/archive.rs:436-555 holds five tests (~118 lines) for a 15-line branch (:298-313).
unsupported_noreplace_rename_installs_blob_with_a_hard_link(:439-456) andunsupported_noreplace_rename_leaves_temporary_cleanup_to_the_caller(:457-488) both loopEINVAL/ENOTSUPand assert destination bytes == payload and temporary still present (:453-454 vs :481-483). The second's only extra content is the 0o555 staging chmod (:469-472, :480), which tests the unchangedremove_temporary(:314-317), not the new branch. Drop it: −32 lines.other_rename_errors_are_preserved_without_installing_the_blob(:513-533) andunsupported_noreplace_rename_preserves_hard_link_errors(:535-555) both assert "error kind preserved + destination not created" (:526-531 vs :548-553). One is enough: −21 lines.- Keep
unsupported_noreplace_rename_does_not_replace_an_existing_blob(:490-511): it is the EEXIST guaranteeBlobStore::commitrelies on (blob.rs:204-211 treatsAlreadyExistsas reuse). install_blob_after_rename_error(:298-313) is called from production at :275 only; it exists as a test seam so tests can inject an errno. Inlining it intoinstall_blob(:259-297) keeps identical behaviour and saves ~10 lines:
if unsafe { libc::renameat2(..., libc::RENAME_NOREPLACE) } != 0 {
let error = std::io::Error::last_os_error();
if !matches!(error.raw_os_error(), Some(libc::EINVAL | libc::ENOTSUP)) {
return Err(error.into());
}
// A no-replace rename the filesystem cannot do; link is atomic and never replaces.
std::fs::hard_link(temporary, destination)?;
}
Total: ~63 lines.
4. Should fix — the retained fallback does not fix #54 (claim, 0 lines)
The PR says "Fixes #54". The fallback only covers blob installation (archive.rs:275-279). The directory publishers that #54's export actually hits are all still bare rename_noreplace:
- helios/src/core/cache.rs:2817
export_entry— reached from heliopause/src/export/core.rs:934 on the default directory export; - helios/src/core/cache.rs:3696
commit_standalone; - helios/src/core/export.rs:742
publish_staged_directory— reached from heliopause/src/export/core.rs:1014 when no cache is configured; - helios/src/core/conversion.rs:436
unpack_with(theflare convertpath); - helios/src/core/conversion/edit.rs:250 (not opened).
search_code rename_noreplace shows no wrapper at any of them. Also independently reported by original-el8 in the PR thread. So on mergerfs the export still fails with the same EINVAL, only later ("Commit core" / "Publish core directory") and after capture — which is precisely why the preflight in finding 1 was added in front of three of these sites instead of fixing them.
Smaller version: the PR shrinks whichever way it goes — either add the same six-line fallback to publish_staged_directory and say nothing about preflight, or change "Fixes" to "Partially fixes" and keep the PR to archive.rs. Issue #54's own "Possible changes" lists the fallback or a preflight as alternatives; the PR ships both.
5. Nit — commit_standalone reorders synchronize for no reason (~2 lines)
helios/src/core/cache.rs:3678-3679 now checks the destination, probes, and then synchronizes; main (main cache.rs:3669-3677) synchronizes first and then checks. Nothing in the change explains the swap, and with the preflight gone it is pure churn under AGENTS.md:188-193. Revert to main's order: −1/+1.
Line accounting
| File (added/removed) | Removable | What |
|---|---|---|
| helios/src/core/cache.rs (+163/−1) | 159 | preflight fn 88 + 3 tests 70 + 2 call lines + reorder |
| tests/preparation/test_directory_preflight.py (+68) | 68 | whole new file |
| heliopause/src/export/binding.rs (+91/−20) | 71 | capture_with_owners + its test + preflight call, net of restoring the 20 removed lines |
| heliopause/src/export/archive.rs (+139/−1) | 63 | 2 duplicate tests 53 + inlined helper 10 |
| heliopause/src/export/core.rs (+3) | 3 | preflight call |
| helios/src/core/conversion.rs (+2) | 2 | preflight call |
| ignition/preparation/model_core.py (+2) | 2 | preflight call |
| Total | ~380 of 468 |
After the cuts the change is ~+80/−1 in heliopause/src/export/archive.rs: the six-line fallback, the unchanged-destination test and one preserved-errno test. That is the honest size of the stated fix.
Open questions and what could not be found
- Not run: no
cargo build/cargo testand nopytest. The review host is macOS and the PR itself reports that the Heliopause crate does not compile there because unchanged Helios code uses Linux-only APIs, so every claim above rests on reading the code at head 41f1c76, not on execution. - mergerfs unavailable, so the
EINVALbehaviour rests on issue #54's strace and the PR's own unit tests; there was no filesystem-level reproduction of the probe's side effects (parent creation,.flare-rename-probe-*churn). helios/src/core/conversion/edit.rs:250(not opened) was located by search but not read in full; its barerename_noreplacecall is visible in the hit but its surrounding existence check was not inspected.- AGENTS.md and the charter were read;
design-review.mdand other contributor docs were not opened, so if they impose a test-per-branch rule it was not weighed.