#1 [high] should fix: EINVAL/ENOTSUP vs ENOSYS: two definitions of "no-replace unsupported"
archive.rs:477-480 (blob fallback) treats only EINVAL and ENOTSUP as "renameat2 unsupported":
error.raw_os_error().is_some_and(|code| code == libc::EINVAL || code == libc::ENOTSUP).
cache.rs:3685-3696 (new directory preflight) treats EINVAL, ENOTSUP and ENOSYS as unsupported (matches!(error.raw_os_error(), Some(libc::EINVAL | libc::ENOTSUP | libc::ENOSYS))).
Why it matters: the same filesystem property now has two independent definitions in the tree, and they disagree. On a host where renameat2 itself is unavailable (old kernel, or a seccomp profile that filters it, which is the very class of restriction issue #54 comes from — mergerfs returns EINVAL) the preflight reports "filesystem does not support atomic no-replace directory publication" while the blob install in the same export still returns a bare ENOSYS and aborts. Fix: one shared predicate, e.g. fn noreplace_unsupported(error: &io::Error) -> bool in helios core (next to rename_noreplace) used by both, and include ENOSYS in both. Smaller version of the diff: delete the duplicated == EINVAL || == ENOTSUP literal at archive.rs:479 and call the shared helper.
#3 [high] should fix: same preflight runs up to three times per export; python bootstrap + pyfunction deletable
Simplification: the preflight is now called from four places, three of them immediately after an existence check of the same destination, and one of those is inside a Python-level path that also probes.
Call sites added by the PR:
- helios/src/core/cache.rs:2358
export_entry— right after cache.rs:2351if fs::symlink_metadata(destination).is_ok() { return Err("already exists") }. - helios/src/core/cache.rs:3125
commit_standalone— right after cache.rs:3118 the same symlink_metadata check. - helios/src/core/conversion.rs:245
unpack_selected— right after conversion.rs:289… actually before theif output.exists()check at conversion.rs:289-291; the preflight duplicates that check (cache.rs:3641-3650 does symlink_metadata again and returns its own "destination exists" error). - heliopause/src/export/core.rs:708
publish_payload— after the two existingpath.exists()checks at core.rs:686-700 (payload export destination already exists, checked twice already in that function). - heliopause/src/export/binding.rs:34
export_capture— before capture, for the!request.sourcespath;publish_payloadat binding.rs:64 does it again in the same call for the samerequest.path. - ignition/preparation/model_core.py:41-42
export_preflight_directory— before capture; the export then reaches (5) and then (4).
So a single ignition export of a directory core runs the probe up to three times in sequence (Python preflight → export_capture → publish_payload), each one creating and removing a probe directory in the destination parent. That is the "parallel paths / redundant checks" pattern the contribution rules call out (AGENTS.md:170-175 "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement"; and charter "Look for the smallest footprint in shared code, or a way to solve it without new code at all.").
Smaller version: keep the probe in exactly one place — the earliest point that the export reaches before capture. export_capture (binding.rs:34) already covers every non-sources capture, including the ignition path, because model_core.py always goes through export_model/RuntimeCore.write → export_capture. The Python bootstrap in model_core.py:41-42 and its 68-line test file (tests/preparation/test_directory_preflight.py) can then be deleted, as can the export_preflight_directory pyfunction and its registration (binding.rs:120-124, 128). For unpack_selected, the preflight also duplicates the output.exists() check at conversion.rs:289 and can be dropped, since rename_noreplace at conversion.rs:324 already returns AlreadyExists, mapped to destination exists at :325-327.
#8 [high] Research summary
Reviewed PR #79 through the simplicity lens (what can be deleted) against the charter, AGENTS.md and docs/design-review.md. Six findings recorded in the scratchpad; none are blocking, four should fix.
-
should fix —
heliopause/src/export/archive.rs:477-480vshelios/src/core/cache.rs:3685-3696: the PR writes the "no-replace rename is unsupported" predicate twice and the two copies disagree — the blob fallback accepts onlyEINVAL/ENOTSUP, the new preflight also acceptsENOSYS. One shared predicate (next torename_noreplace) deletes the duplicate and makes the blob path honour the same set. -
should fix — one
ignition exportof a directory core runs the probe three times:ignition/preparation/model_core.py:41-42→heliopause/src/export/binding.rs:34→heliopause/src/export/core.rs:708. Smallest footprint is one probe atexport_capture; the Python bootstrap, theexport_preflight_directorypyfunction and its registration, and the whole 68-linetests/preparation/test_directory_preflight.pythen go away. The check added athelios/src/core/conversion.rs:245also duplicatesunpack_selected's ownoutput.exists()guard at :289 and theAlreadyExistsmapping at :324-327. -
should fix —
helios/src/core/cache.rs:3653-3665: the probe reinvents unique naming withring::SystemRandomand a retry loop, althoughtoken()(cache.rs:2991) is used by both neighbouring publication paths. ~12 lines and an untestable error arm deletable; the name needs no unpredictability. -
should fix —
archive.rs:616-661: the 0o555 staging test does not prove its stated premise (as root, which the container builds use, the chmod is unenforced), and two other 20-line tests both only pass a singleErrthrough an 8-line helper. One error test plus the existing destination/temporary assertions suffice. -
should fix —
binding.rs:97-118:capture_with_ownersis a 22-line generic helper extracted only to be testable, and its sole test (binding.rs:1046-1091) passesCell/AtomicBoolstubs, so helper and test only prove each other's control flow. The old inlineOwnerLeaseshape would be ~4 lines. -
nit — inside the preflight: the destination existence check duplicates every caller's identical check with a different message, the
Ok(())-replaced-target branch and itsUnsupportedarm are unreachable on any conforming filesystem, and the three-arm(result, cleanup)match reduces toresult.and(cleanup). Alsocommit_standalone(cache.rs:3117-3126) movessynchronize(&self.directory)after the new checks with no test or stated reason.
I did not review rename-fallback atomicity/concurrency guarantees (that is the filesystem-correctness lens, where original-el8 has already commented), and I could not run the Rust tests.
#9 [high] Review scope, rule citations and caveats for the D-lens report
Scope of this review (lens D, simplicity): read all 7 changed files in context — heliopause/src/export/{archive,binding,core}.rs, helios/src/core/{cache,conversion}.rs, ignition/preparation/model_core.py, tests/preparation/test_directory_preflight.py — plus callers: heliopause/src/export/{blob,conversion,transfer}.rs, helios/src/core/export.rs:735-760, ignition/preparation/{core_file,core_snapshot,runtime_core,host_ranks}.py. Findings are in scratchpad entries 1-7.
Rule citations to use in the report:
- Charter, "How We Work": "Look for the smallest footprint in shared code, or a way to solve it without new code at all." → finding 3 (triple probe).
- AGENTS.md:170-175 "Reject unsupported abstractions and churn … Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement" → findings 2 (third probe path + pyfunction) and 5 (generic helper).
- AGENTS.md:176-181 "Require focused, meaningful validation. Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness." → findings 4 and 5.
- docs/design-review.md principle 15 (Reject scope expansion and weakened constraints) points back at the same AGENTS.md rejection criteria.
- docs/design-review.md principle 16 and AGENTS.md:67-135 (four-part PR description) — the description discloses only the heliopause blob fix + "focused helper harness passed 3 tests", but the diff also adds a Helios preflight, a Python pyfunction, an ignition bootstrap step and a new Python test file ("Not mentioned in the description: tests/preparation, ignition/preparation" per the orientation packet). That is an evidence/description gap worth one sentence in the report, though it belongs mainly to the prose lens; the simplicity consequence is that the PR is now two mechanisms (link fallback + directory preflight) where one was scoped.
Caveat to state honestly in the report:
- Finding 4's premise that chmod 0o555 is unenforced depends on the test running as root (true in the documented container build, docs/container.md, but not verified here). If the test suite runs as an unprivileged user, the 0o555 does exercise "publication must not unlink" — the finding then degrades to "two overlapping error tests should be merged". Stated either way, the test is redundant with the first test's assertion that the temporary still exists.
- No tests were run (no tool for it in this review); every claim above is from reading the code at head 06b9011. The renamed-error-type question in note 5 (
PyRuntimeErrornow raised for all export_capture errors, previously only for the drain path) is unverified against Python callers and would be settled by running tests/preparation/test_runtime_core.py. - I deliberately did not assess the fallback's atomicity, EEXIST semantics or concurrency (original-el8's review comment on the PR already covers those); that is another lens.
#2 [medium] should fix: preflight probe uses ring RNG where token() already exists (12 lines deletable)
cache.rs:3638/3653-3665 (new preflight probe) draws a probe name from ring's SystemRandom with a random retry loop, while the same module already has a cheap unique-name helper used by both directory publications that sit right next to the probe:
- cache.rs:2991
fn token() -> String { format!("{}-{:x}", std::process::id(), TRANSACTION.fetch_add(1, Ordering::Relaxed)) } - cache.rs:2366
. {name}.flare-{token()}(export_entry), cache.rs:3133 (commit_standalone)
Why it matters (simplicity lens): the probe name does not need to be unguessable — nothing security-relevant depends on it, it is created with create_new semantics (DirBuilder::create fails with EEXIST) and it lives in the same parent directory as the caller-named staging directory. Randomising it buys nothing over the existing pid+counter token, costs a ring::rand dependency edge and 12 lines of hex formatting, and adds an error path (could not generate publication probe name) that has no test and cannot practically occur. Fix: let probe = parent.join(format!(".flare-rename-probe-{}", token())); fs::DirBuilder::new().mode(0o700).create(&probe) and drop the loop/SystemRandom block. If the EEXIST retry matters for the token form, the surrounding TRANSACTION counter plus pid already makes collisions exclusive to a single process, so the retry can go too.
#4 [medium] should fix: archive.rs temporary-cleanup test relies on unenforced 0o555; two error tests overlap
archive.rs:616-661 test unsupported_noreplace_rename_leaves_temporary_cleanup_to_the_caller — this is the heaviest test in the PR (chmod 0o555 on the staging directory, restore, then assert the temporary still exists, then call remove_temporary). What it actually proves beyond unsupported_noreplace_rename_installs_blob_with_a_hard_link (archive.rs:612-633, which already asserts destination and temporary both exist and both read payload) is only that install_blob_after_rename_error does not call unlink — which is visible in the 4-line body, and which the 0o555 chmod does not test reliably: the test runs as root in most CI containers (the repository builds via containers, docs/container.md), where write permission on a directory is not enforced, so the chmod is a no-op and the test's stated premise ("unlinking also needs write permission... Publication must not unlink") is not exercised. That makes it a test that does not prove its behaviour, which AGENTS.md:176-181 rejects ("Tests must exercise the affected behavior or contract").
Also perf/lens: other_rename_errors_are_preserved_without_installing_the_blob (archive.rs:682-702) and unsupported_noreplace_rename_preserves_hard_link_errors (archive.rs:708-…) are both pure pass-through of a single Err, 20 lines each, for a 8-line function; one error-preservation test would carry both.
Fix: delete the 0o555 test (the caller's cleanup is already covered end-to-end by blob.rs:216-224 and by the first test's temporary-still-present assertion), and merge the two error-preservation tests into one.
#5 [medium] should fix: binding.rs capture_with_owners helper + its stub test test only themselves
binding.rs:97-118 — capture_with_owners is a new generic helper extracted from the old inline code, and capture at binding.rs:33-86 was converted from a closure passed to py.detach into a let capture = || { ... } closure ending in a bare result (note the leftover let result = ...; result at binding.rs:37/84-85 — the final result binding is now redundant; result was already the tail expression of the and_then chain, so lines 46-84 could end ... }) and drop the let result = name).
The helper exists only to be testable, and the only test (binding.rs:1046-1091, preflight_failure_drains_without_capturing_and_retains_owners_on_failed_drain) passes closures that are Cell/AtomicBool stubs — it does not exercise OwnerLease, capture_rank, drain_context, or any preflight. What the test proves is the control flow of capture_with_owners itself, i.e. the helper tests the helper. That is the "mocks that bypass the behavior cannot establish runtime correctness" case in AGENTS.md:176-181.
Also the preflight is placed inside capture, so its failure path runs the drain — meaning a preflight rejection still drains the CUDA context even though nothing was captured. That is a behaviour question for another lens, but from the simplicity lens it is worth noting that the old code shape (preflight in the closure) would have been 4 lines rather than a 22-line generic helper plus a 34-line test.
Smaller version: inline the preflight at binding.rs:33-36, keep the original let mut lease = OwnerLease(Some(owners)); / drop(lease.take_after_drain()) shape, and delete capture_with_owners plus its stub test (binding.rs:1046-1091). If the owner-retention-on-failed-drain invariant genuinely needs a test, it belongs against a real drain, not against closures.
Additionally: the extraction changes the error type for the drain failure from PyRuntimeError (raised at binding.rs:93 for every error now) — verify the Python callers that distinguished RuntimeError from ValueError still behave; test_runtime_core.py:76 tests export_capture errors.
#6 [low] nit: preflight duplicates callers' existence check and has two near-duplicate error arms
Nit-level redundancies inside the new preflight function (helios/src/core/cache.rs:3623-3708):
- cache.rs:3641-3650 re-checks
symlink_metadata(destination)and returnsAlreadyExists "destination exists"— but every one of its callers already performed the identical check immediately before the call: cache.rs:2351, cache.rs:3118, conversion.rs:289, heliopause/src/export/core.rs:686-700 (twice). The check is needed for thepublish_payloadreachability and for zero-cost safety, but note that callers' messages differ ("export destination {} already exists" vs "destination exists"), so two different errors now describe the same condition for the same caller — see the test at tests/preparation/test_directory_preflight.py:65 matching "destination exists" while cache.rs:2352 says "export destination ... already exists". Pick one message and delete it from the callers rather than duplicating it. - cache.rs:3686-3688:
error.kind() == io::ErrorKind::Unsupported || matches!(raw_os_error …). TheUnsupportedarm exists only for theOk(())branch at cache.rs:3674-3679 (rename silently replaced the target). If that self-check is kept it needs its own branch; otherwise the wholeUnsupportedarm and theOk(())-replaced branch (5 lines, unreachable on any filesystem that honours RENAME_NOREPLACE) can go: a rename that succeeds is simply the success of the second probe at cache.rs:3682. - cache.rs:3697-3707 the
(result, cleanup)match:(Ok(()), cleanup) => cleanupis justresult.and(cleanup); the three-arm match can be two lines. Similarlypreflight_directory_publication(cache.rs:3623-3631) needs the#[cfg(not(target_os = "linux"))] { let _ = destination; Ok(()) }shape only because the body isreturn-based;#[cfg]on a statement expression would be shorter. - Docs comment at cache.rs:3621-3622 is fine and short. archive.rs:482
// BlobStore::commit owns temporary cleanup after publication.is a useful cross-reference — keep.
#7 [low] nit: commit_standalone moves synchronize after the check for no stated reason
Nit: helios/src/core/cache.rs:3117-3126 commit_standalone — the PR moved synchronize(&self.directory) (previously the first statement, cache.rs old line 3117) to after the new existence check and preflight (new cache.rs:3126). Behaviour that changed: a destination that already exists no longer synchronises the staged tree first — harmless, arguably better. But the preflight is now performed on destination before synchronize(&self.directory), so the reordering's stated purpose is unclear from the diff and there is no test distinguishing the orders. If the reorder is not needed for the fallback, restoring the original first-line synchronize(&self.directory)?; keeps the diff at one added line. (cache.rs:3117-3151 in the head file.)
Also: commit_standalone and export_entry are near-duplicates (both: existence check, preflight, parent/name derivation, staging path from parent, rename_noreplace, cleanup, syncdir). Now that both carry the same 4-line preflight block, the pair is a natural single helper — but that is pre-existing duplication, not introduced here; mention as optional.