Review: PR #79 — fix(heliopause): fall back when no-replace rename is unsupported
Head 41f1c76, base main, 7 files, +468/−22. Lens: correctness (callers, platforms, error paths, state, resources). All 7 changed files were read in surrounding code and every caller traced: ignition export → model_core.export_core → host_ranks/rank_group → heliopause capture/publish → helios cache/conversion/export.
Key findings
Verdict: should-fix issues only. No blockers.
The blob hard-link fallback itself (heliopause/src/export/archive.rs:298-313) is correct, atomic, EEXIST-preserving, and its caller is compatible. The problem is the second half of the PR — the directory-publication preflight. Three of its five added call sites are unreachable from ignition export, the one reachable publisher it left aside (conversion::edit) still fails bare with EINVAL on mergerfs, one of the new tests cannot fail on its subject, and in unpack_with the probe was placed before verification and before the established destination check, which changes user-visible errors and creates the output parent on a failure path.
Should-fix findings: 5 (edit.rs uncovered; unreachable preflight call sites; test passes for the wrong reason; unpack_with placement; two errno policies for one syscall). Nits: 6.
Should fix
1. helios/src/core/conversion/edit.rs:250 — core edit still fails on mergerfs with no preflight and no fallback
edit builds and syncs its staging tree, then publishes with a bare no-replace rename:
// edit.rs:249-251
crate::core::cache::synchronize(&staging)?;
crate::core::cache::rename_noreplace(&staging, request.output)
.map_err(|e| invalid(format!("publish edited core: {e}")))?;
There is no preflight_directory_publication call and no hard-link fallback. The only exists-check is the early if request.output.exists() at edit.rs:27-32, which runs before the costly companion copy, so it does not help on an unsupported filesystem. This is reachable in production from ignition edit → heliopause/src/export/conversion.rs:206 (export_payload_edit → helios_core::core::conversion::edit).
On a mergerfs destination the user still gets publish edited core: Invalid argument (os error 22) after every companion has been copied — the exact #54 symptom the PR exists to close. Fix: route edit publication through the same path as unpack_with — preflight after verification, or accept the hard-link fallback for the directory tree (with the same-directory guarantee checked).
2. ignition/preparation/model_core.py:41-42, heliopause/src/export/binding.rs:34-36, heliopause/src/export/core.rs:640-642, helios/src/core/cache.rs:3678 — the new preflight is unreachable on the path issue #54 hits
ignition export always passes path=None:
ignition/cli/serve.py:330:export_core(prepared, recorder, storage, None, ...)ignition/cli/serve.py:229:prepared.export(None, ...)for multi-host
so cache_only = path is None (model_core.py:27) is always true on that path, and every guard is conditioned on the negation:
model_core.py:41-42:if not cache_only and form == 'directory'— never fires.binding.rs:34-36:if !request.sources && !request.path.as_os_str().is_empty()— never fires, because every Python rank capture passessources=True(model_core.py:51-52).core.rs:640-642:if !cache_only && form == "directory"— never fires.cache.rs:3670Staging::commit_standalone, which contains the line-3678 probe, has no production caller — only tests (cache.rs:5011,5017,5132). Production cache-only publication isStaging::commit(cache.rs:3644), which uses plainfs::rename, not a no-replace rename.
What production actually reaches: cache.rs:2804 (Root::export_entry, from heliopause/src/export/core.rs:921/934 and heliopause/src/export/conversion.rs:351) and conversion.rs:316 (unpack_with). helios/src/core/export.rs:742 (publish_staged_directory) is reached only from core.rs:1014 when path is non-empty and no cache is configured — no Python caller produces that.
So the PR's claim that directory publication is preflighted does not hold for the paths production uses. Fix: either wire the probe into the cache-only publication in Staging::commit, or drop the unreachable sites and keep only the ones with a real caller — plus fix finding 1.
3. tests/preparation/test_directory_preflight.py:43-52 — the new test cannot fail on its subject
with pytest.raises(RuntimeError, match="configured core cache"):
model_core.export_core(None, None, None, destination, options={}, publisher=object(), form=form)
The test never enters an export_options(...) context, so core_snapshot._OPTIONS.get() is None and model_core.py:31-33 raises RuntimeError("export requires the configured core cache") before line 41 is reached. The assertion matches that earlier error, so the unexpected probe installed at :45-46 can never run and the test passes whether or not the guard at model_core.py:41-42 exists. It cannot detect the regression its name describes. Fix: wrap in with export_options(tmp_path / "cache"): as the first test does (:33), then assert only that the probe is not called. Note the first test (:11-40) does exercise line 41-42 but fakes flare_heliopause/torch (:28-31), so it asserts call order only, not filesystem behaviour.
4. helios/src/core/conversion.rs:316-317 — probe runs before verification and before the destination check
unpack_with now probes immediately after the directory-form check (:313-315) and before verify_stored_data (:323) and the established destination check at :364-366. Two behaviour changes on error paths:
(a) Changed error text for an existing destination. preflight_directory_publication returns AlreadyExists with the message destination exists (cache.rs:4196-4199), so the user now sees directory export preflight: destination exists from conversion.rs:316-317 instead of destination exists: <path> from :364-366. The tests at :4254/:4263 assert only contains("destination exists"), so they still pass while the message users see changed, and the condition is now reported twice.
(b) Parent directory created on a failure path. preflight_directory_publication calls fs::create_dir_all(parent) (cache.rs:4205) although its own doc comment says "this probe reserves nothing" (cache.rs:4174-4175). A corrupt or unreadable source core now creates the output parent before being rejected, while the failure path at conversion.rs:447-449 only removes staging.
Fix: move the probe after verify_stored_data, and put the output.exists() check before it — or make the probe tolerate a missing parent with NotFound.
5. heliopause/src/export/archive.rs:304-307 vs helios/src/core/cache.rs:4238-4249 vs selene/src/disk.rs:1308-1311 — two errno policies for one syscall
For renameat2(RENAME_NOREPLACE):
archive.rs:304-307treats onlyEINVAL | ENOTSUPas unsupported.cache.rs:4240treatsEINVAL | ENOTSUP | ENOSYSas unsupported.- The repo's own precedent for "filesystem does not support this syscall" is
selene/src/disk.rs:1308-1311:Some(libc::EOPNOTSUPP | libc::ENOSYS) => Ok(()).
A filesystem (or seccomp filter / older kernel) returning ENOSYS therefore gains the blob fallback but not the directory probe, so the two halves of this PR disagree on the same syscall. Fix: one predicate function next to rename_noreplace (cache.rs:4265) used by both sites, covering the union and matching the selene precedent.
Nits
cache.rs:4206-4218: the probe name usesSystemRandomin an unbounded retry loop, althoughtoken()already exists atcache.rs:3537.cache.rs:4179-4183: on non-Linuxpreflight_directory_publicationreturnsOk(())— indistinguishable from success atbinding.rs:121-124, where it is surfaced to Python asPyRuntimeErrorrather than theFileExistsErrorconvention used incore_snapshot.py:61-62/74-75.cache.rs:4218-4237: a probe tree (mode0o700) can be orphaned if the process is killed between creation and cleanup.archive.rs:298:#[cfg(any(target_os = "linux", test))]keeps the new helper's tests from sitting beside the Windows path.docs/multi-host.md:314-315still documents only the same-filesystem requirement — no no-replace rename requirement, and no docs/TODO entry for the unrun mergerfs reproduction.- PR description omits
tests/preparationandignition/preparationand claims "Fixes #54" although findings 1 and 2 leave reachable #54 paths unguarded (docs/design-review.md (not opened) principle 16; charter's four-part description rule).
Verified correct
- Blob fallback is sound.
archive.rs:298-313links only forEINVAL/ENOTSUP(:304-311), returns every other errno unchanged (:312), andhard_linkis atomic, refuses an existing destination withEEXIST, and works in the same directory —blob.rs:178buildstemporaryasself.root.join(...), so noEXDEV. - Caller compatible.
blob.rs:194-213mapsAlreadyExiststoverify_pinned(reuse) and propagates other errors;blob.rs:216-224removes the temporary and toleratesNotFound. The helper therefore correctly does not unlink (:309comment) — the earlier review nit is fixed. capture_with_owners(binding.rs:97-118) keepsOwnerLeaseacross capture and drain and releases only on a confirmed drain (:104-105);heliopause/src/lifetime.rs:14-21stillmem::forgets an unconfirmed lease. Drain still runs after a failed capture (testbinding.rs:1473-1521), matching pre-PR behaviour.- Probe semantics detect a "rename replaced target" surprise (
cache.rs:4227-4232), andrename_noreplaceitself is unchanged (cache.rs:4265-4285). combineis not another #54 path — it publishes with plainfs::rename(helios/src/core/conversion.rs:3538), not a no-replace rename.
Open questions / not settled by code
- No live mergerfs reproduction exists. The
EINVAL→ unsupported mapping rests entirely on injected-errno tests (archive.rstests at diff +437-458;cache.rs:4539-4567) and on reading the code. A run ofignition exportto a mergerfs destination with a directory-form core would settle both the mapping and findings 1-2. The PR states the Heliopause Cargo test could not compile on macOS (Linux-only Helios APIs), so the helios-side tests may not have been run at all — the description does not say. - Whether the author intends
commit_standalone/publish_staged_directoryto be future call sites (no production caller today) or believes they are live — either way the PR description's claim needs correcting.
Governing rules cited
- Charter, How We Work: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)"; PR descriptions must be complete and honest.
AGENTS.md(not opened): "Reject weakened guarantees … Do not remove validation, suppress errors, silently substitute execution paths"; validation must exercise the affected behaviour, not mocks.AGENTS.md(not opened) contribution criteria: "Do not add … fallback layers … without a concrete requirement" — issue #54 is the concrete requirement, so the fallback itself is in scope; the unreachable probes are not.docs/design-review.md(not opened) principle 12 (validate the real path and report evidence honestly) and principle 16 (PR description order/content).