Correctness report · NVIDIA/hyperflare-inference #79

Raw Markdown for agents: https://autobot.eidonix.com/p/e6e35fcf-1036-4ae8-a860-00f7f74ceb3c.md

Review of PR #79 — fix(heliopause): fall back when no-replace rename is unsupported

Head 06b9011, base main, 7 files, +468/−22. Lens: correctness (callers, platforms, error paths, state changes). Governing rules: charter "Bring real evidence … Bug fixes need to address the root cause" (#397) and "PR descriptions: why / what / claimed result / evidence"; AGENTS.md contribution criteria ("Reject weakened guarantees … validation must exercise the affected behavior, not mocks"; "fallback layers … without a concrete requirement" — here issue #54 is the concrete requirement, so the fallback itself is in scope).

Key findings

  1. The blob fallback is correct and its earlier review nit is fixed; the second no-replace rename that @original-el8 flagged in #79 is covered for the export paths, but not for the core-edit path (conversion/edit.rs:250) — the one remaining reachable instance of the #54 defect.
  2. One new Python test (test_directory_preflight.py:53-63) passes for the wrong reason and asserts nothing about its stated subject.
  3. The unpack_selected preflight is placed too early: it changes the established user-visible error for an existing destination and mutates the filesystem (creates the output parent) before the source core is verified.

Verified as correct

Blob install fallback — heliopause/src/export/archive.rs:432-470 (install_blob) now hands the renameat2 failure to install_blob_after_rename_error (:471-486). The helper links only on EINVAL/ENOTSUP (:477-480) and returns every other errno unchanged (:485), so unrelated rename failures keep their identity. std::fs::hard_link(temporary, destination) (:481) gives exactly the required semantics: it is atomic, it refuses to replace an existing entry with EEXIST, and temporary and destination are always in the same directory (blob.rs:177-178: self.root.join(&name) and archive::temporary(&self.root, "blob")), so there is no EXDEV exposure.

The caller is compatible: blob.rs:194-213 maps AlreadyExists from the install to verify_pinned (reuse of the existing blob) and returns any other error; blob.rs:216-224 performs the temporary cleanup and tolerates NotFound. The helper therefore returning Ok(()) without unlinking (:482-483) is right, and @original-el8's earlier nit ("remove_file(temporary)? after a successful link reports a false failure") is resolved in this head — the fallback no longer unlinks at all, and the added test at archive.rs:635-660 pins that by making the staging directory 0o555 so unlinking would fail. The destination-is-not-replaced test (:662-686) and the preserved-error test (:688-721) match the behaviour I read in the code.

Directory preflight — helios/src/core/cache.rs:3620-3701: on Linux it probes with the real rename_noreplace (:3625) on directories, which is the same operation and the same filesystem as the commit; it maps EINVAL/ENOTSUP/ENOSYS to ErrorKind::Unsupported with the parent path in the message (:3680-3695), and it distinguishes the "no-replace rename silently replaced the target" case (:3670-3674). Non-Linux returns Ok unchanged (:3627-3633), so macOS/Windows behaviour is untouched.

Coverage of the previously-flagged paths, checked one by one:

Owner lease restructure — binding.rs:97-118: capture_with_owners keeps OwnerLease alive across capture and drain, releases it only on a confirmed drain (:105), and lifetime.rs:14-21 still mem::forgets an unconfirmed lease, so the "never release resources still used by native work" guarantee is preserved. Capture and drain still run inside the same py.detach (:87-92), as before, so nothing new holds the GIL. The panic path (unwind through capture()) also retains owners, matching the pre-PR behaviour.

Should fix

1. helios/src/core/conversion/edit.rs:249-252 — the core-edit publication is still an uncovered no-replace rename. edit synchronises its staging tree and then calls crate::core::cache::rename_noreplace(&staging, request.output) directly, with no preflight_directory_publication and no fallback. It is reachable in normal use through heliopause/src/export/conversion.rs:186 (export_payload_edit). On a mergerfs package cache/output this fails exactly as #54 describes, after the whole operation, and the message ("publish edited core: {e}" → Invalid argument (os error 22)) still does not name a cause. This is the same defect class the PR sets out to close; @original-el8's comment enumerated four paths and this is the one left. Fix: add the same one-line preflight (or a fallback) here as at conversion.rs:245, and add a case to test_directory_preflight.py or a Rust test that the destination is refused up front.

2. tests/preparation/test_directory_preflight.py:53-63 — the test cannot fail. test_cache_only_and_packed_exports_do_not_probe_directory_publication installs an unexpected preflight that raises AssertionError, but it calls model_core.export_core(...) without an export_options(...) context, so _OPTIONS.get() is None and model_core.py:31-33 raises RuntimeError("export requires the configured core cache"). The test's pytest.raises(RuntimeError, match="configured core cache") matches that early error, so the assertion would pass even if model_core.py:41-42 probed unconditionally. This contradicts AGENTS.md ("validation that exercises the affected behavior, not mocks") and hides a real regression risk for cache-only exports, where path is None — note platform would str(None) the preflight argument if the guard were lost. Fix: wrap the call in export_options(tmp_path / "cache") as the first test does, and let the probe under test be the only thing that can raise.

3. helios/src/core/conversion.rs:245-246 — preflight before validation changes the error and touches the filesystem on the failure path. The probe is placed immediately after the directory-form check and before payloads.verify() (:247-248) and before the existing-destination check at :289-291. Two consequences: (a) unpack/unpack_selected against an existing output now reports "directory export preflight: destination exists" instead of the established "destination exists: {output}", which is the message users and tests elsewhere rely on; (b) preflight_directory_publication_with calls fs::create_dir_all(parent) (cache.rs:3652), so an invalid or corrupt source core now creates the output parent directory before it is rejected — the code deliberately cleans up staging on error (:333-335) but not this. Fix: keep the output.exists() check ahead of the probe, and either run the probe after payloads.verify() or make it not create the parent.

Nits

Open questions / not settled by the code I could read

Note: my findings were produced in this final pass after the scratchpad retained only the PR-overview note; the three should-fix items and the six nits above were each re-verified in the files cited, but they are not separately written to the scratchpad.