Correctness scratchpad · NVIDIA/hyperflare-inference #79

Raw Markdown for agents: https://autobot.eidonix.com/p/a2418290-3e19-46e3-b386-091fca74002c.md

#1 [high] PR #79 overview and governing rules

PR #79 "fix(heliopause): fall back when no-replace rename is unsupported", head 06b9011, base main. 7 files, +468/-22: heliopause/src/export/{archive.rs,binding.rs,core.rs}, helios/src/core/{cache.rs,conversion.rs}, ignition/preparation/model_core.py, tests/preparation/test_directory_preflight.py (new). Label bug, area:caching, area:packaging. Review state: changes requested by yatesdr; earlier comment by original-el8 said the blob fallback alone does not fix #54 because the directory export reaches a second no-replace rename (helios/src/package/cache.rs:2377/3559/3145, package/export.rs:743, package/conversion.rs:312 — those paths do not exist at this head; the equivalent code now lives in helios/src/core/cache.rs and helios/src/core/conversion.rs). This head answers that with a directory preflight.

Charter/AGENTS rules that bear on it: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" (charter, How We Work, bring real evidence); AGENTS.md "Reject weakened guarantees … Do not remove validation, suppress errors, silently substitute execution paths"; AGENTS.md requires validation that exercises the affected behavior, not mocks; design-review principle 6 (explicit lifetimes) and 12 (validate the real path and report evidence honestly); docs/design-review.md principle 16 (PR description order).

Charter/AGENTS: no rule about fallback layers — "Reject unsupported abstractions and churn … Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement" (AGENTS.md contribution criteria). A fallback for a demonstrated defect (issue #54) has a concrete requirement, so the fallback itself is in scope.

#3 [high] Blocking?: preflight cannot run on the export path #54 hits; still-dead call sites

Head 41f1c76. ignition export always calls export_core(prepared, recorder, storage, None, ...) (ignition/cli/serve.py:330) and prepared.export(None, ...) for multi-host (serve.py:229) → path=None → cache_only=True. Consequences at head:

#4 [high] Should fix: edit.rs:250 still an uncovered no-replace rename

helios/src/core/conversion/edit.rs:195-252: edit builds staging, syncs it (249) then calls crate::core::cache::rename_noreplace(&staging, request.output) at :250-251 with no preflight_directory_publication and no hard-link fallback. Its only exists-check is the early if request.output.exists() at :27-32 (checked before the costly file copy). Reachable from ignition edit → heliopause/src/export/conversion.rs:191-217 → conversion::edit. On a mergerfs destination this still ends with publish edited core: Invalid argument (os error 22) after copying every companion, exactly the #54 symptom. This is the one remaining reachable instance the PR was meant to close.

#5 [high] Should fix: test_directory_preflight.py:43-52 cannot fail on its subject

tests/preparation/test_directory_preflight.py:43-52: test_cache_only_and_packed_exports_do_not_probe_directory_publication calls model_core.export_core(None, None, None, destination, options={}, publisher=object(), form=form) with no 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. The test's pytest.raises(RuntimeError, match="configured core cache") therefore matches that early error: the unexpected probe at :45-46 can never run, and the test passes whether or not model_core.py:41-42 guards. It cannot detect the regression it names. Fix: enter export_options(tmp_path/'cache') as the first test does (test at :11-40 does this and is the one that actually exercises line 41-42), and let only the guard decide. Also note the first test fakes flare_heliopause/torch (:28-31), so it asserts call order only.

#6 [high] Should fix: conversion.rs:316-317 preflight precedes verification and destination check

helios/src/core/conversion.rs:316-317 places preflight_directory_publication(output) in unpack_with right after the directory-form check (:313-315) and before payloads.verify() via verify_stored_data (called :323) and before the established check if output.exists() { "destination exists: {path}" } at :364-366. Two behaviour changes on error paths: (a) unpacking onto an existing output now fails with directory export preflight: destination exists (message from cache.rs:4196-4199) instead of destination exists: <path> at :365; helios/src/core/conversion.rs:4254/4263 tests assert only contains("destination exists"), so they still pass, but the message users see changed and is now produced twice for one condition. (b) preflight_directory_publication calls fs::create_dir_all(parent) (cache.rs:4205) although the doc comment at cache.rs:4174-4175 says "this probe reserves nothing"; so a corrupt or unreadable source core now creates the output parent directory before it is rejected, while the failure path at conversion.rs:447-449 only removes staging. Also note the check at :216-218 in pack has the same ordering: preflight-free, but output.exists() there precedes work. Fix: run the probe after verify_stored_data, and put the output.exists() check before the probe (or make the probe tolerate a missing parent with NotFound).

#9 [high] Research summary

Reviewed PR #79 at head 41f1c76 through the correctness lens: all 7 changed files read in surrounding code, every caller traced (ignition export → model_core/host_ranks/rank_group → heliopause capture/publish → helios cache/conversion/export), findings verified in the code and recorded in scratchpad entries #3-#8 (the full report is #2 plus these).

Verdict: the blob hard-link fallback is correct and complete; the new directory-publication preflight is not. Four should-fix findings:

  1. The preflight largely cannot run on the path issue #54 hits, while the one reachable publisher it left aside (core edit) is still unguarded: ignition export passes path=None, so model_core.py:41-42, binding.rs:34-36 and core.rs:640-642 never fire and cache.rs:3678 (commit_standalone) has no production caller; conversion/edit.rs:250 still fails bare with EINVAL on mergerfs after copying every companion.
  2. tests/preparation/test_directory_preflight.py:43-52 passes for the wrong reason: without export_options, model_core.py:31-33 raises first and the test matches that message.
  3. helios/src/core/conversion.rs:316-317 runs the probe before verify_stored_data and before the established destination exists: <path> check, so the user-visible error for an existing destination changed, and the probe's create_dir_all(parent) creates the output parent before a bad source is rejected.
  4. Two errno policies for one syscall (EINVAL|ENOTSUP in archive.rs vs +ENOSYS in cache.rs), against the repo precedent in selene/src/disk.rs.

Also verified correct: atomic hard-link semantics, EEXIST preservation, same-directory EXDEV safety, blob.rs caller cleanup, and the capture_with_owners/OwnerLease guarantee. No live mergerfs reproduction exists, so the EINVAL mapping rests on injected-errno tests.

#10 [high] Verdict for head 41f1c76 (current run): should-fix issues only

Review of PR #79 "fix(heliopause): fall back when no-replace rename is unsupported", head 41f1c76 (merge of main), base main, 7 files +468/−22. Lens: correctness (callers, platforms, error paths, state, resources). Governing rules cited: charter "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" and the four-part PR description rule; AGENTS.md "Reject weakened guarantees … validation must exercise the affected behavior, not mocks"; docs/design-review.md principle 12 (validate the real path, report evidence honestly) and 16 (description order). Issue #54 is the concrete requirement, so the fallback itself is in scope of the "no fallback layers" rule.

VERDICT: should-fix issues only. No blockers.

BLOCKING: none.

SHOULD FIX (each verified in code; details in notes #3-#6):

  1. helios/src/core/conversion/edit.rs:250 — edit publishes with a bare rename_noreplace, no preflight, no fallback; reachable from ignition edit (heliopause/src/export/conversion.rs:191-217). Still fails on mergerfs exactly as #54 after copying every companion; the message is publish edited core: Invalid argument (os error 22) at edit.rs:250-251.
  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 added probes are unreachable from ignition export, which passes path=None (ignition/cli/serve.py:330 and :229), and commit_standalone has no production caller (tests only: cache.rs:5011/5017/5132). Reached in production: cache.rs:2804 (Root::export_entry, from export/core.rs:921/934 and export/conversion.rs:351) and conversion.rs:316 (unpack_with). Uncovered: export.rs:742 publish_staged_directory — reached only from export/core.rs:1014 when path is non-empty and no cache is configured, which no Python caller produces.
  3. tests/preparation/test_directory_preflight.py:43-52 — test cannot fail on its subject (no export_options context → model_core.py:31-33 raises "configured core cache" first, which is what the test matches).
  4. helios/src/core/conversion.rs:316-317 — probe runs before verify_stored_data (:323) and before the destination exists: {output} check (:364-366), so an existing output now reports directory export preflight: destination exists (cache.rs:4196-4199) instead of destination exists: <path>, and fs::create_dir_all(parent) (cache.rs:4205) creates the output parent before a corrupt source is rejected, despite the "reserves nothing" doc comment (cache.rs:4174-4175).
  5. Two errno policies for one syscall: archive.rs:304-307 accepts EINVAL|ENOTSUP; cache.rs:4238-4249 also accepts ENOSYS; repo precedent selene/src/disk.rs:1308-1311 (EOPNOTSUPP|ENOSYS). One predicate beside rename_noreplace (cache.rs:4265) should serve both.

NITS (see note #7): ring SystemRandom + unbounded retry loop for the probe name (cache.rs:4206-4218) instead of token() (cache.rs:3537); probe tree can be orphaned on kill; preflight_directory_publication returning Ok on non-Linux (cache.rs:4179-4183) is indistinguishable from success at call sites; the pyfunction wraps failures as PyRuntimeError (binding.rs:121-124) where core_snapshot.py:61-62/74-75 uses FileExistsError; #[cfg(any(target_os="linux", test))] on the new helper (archive.rs:298); docs/multi-host.md:314-315 still documents only the same-filesystem requirement (no no-replace rename requirement, no docs/TODO entry for the unrun mergerfs reproduction); PR description omits tests/preparation + ignition/preparation and claims "Fixes #54".

VERIFIED CORRECT (note #7): the blob fallback (archive.rs:298-313) links only on the two unsupported errnos, preserves other errnos, is atomic and EEXIST-preserving, and same-directory (blob.rs:177-178) so no EXDEV; the caller (blob.rs:194-224) maps AlreadyExists to reuse, owns temporary cleanup and tolerates NotFound, so not unlinking is right; capture_with_owners (binding.rs:97-118) keeps OwnerLease until a confirmed drain and lifetime.rs:14-21 still forgets an unconfirmed lease.

SUPERSEDES entry #2 (report of 2026-11-25 at head 06b9011):

EVIDENCE STATUS: no live mergerfs reproduction; the EINVAL/ENOTSUP mapping rests on injected-errno tests (archive.rs tests at +437-458; cache.rs:4539-4567) and on the raw-errno comparison in code. The PR reports rustfmt --check and 3 focused helper tests; whether helios compiled is not stated.

#7 [medium] Verified-correct items and nits for PR #79

Verified correct in code (so the report can say so):

#8 [medium] Coverage: files read, callers traced, unsettled items

Files read in context at head 41f1c76 for this lens (correctness): heliopause/src/export/archive.rs (240-320 diff + whole install_blob), binding.rs (20-115, diff), core.rs (200-260, 597-665, 900-1030, 4160-4230, 4470-4520), helios/src/core/cache.rs (2770-2830, 2980-3010, 3110-3165, 3540-3730, 4165-4310, 4490-4600), conversion.rs (190-222, 300-451, 2600-2660, 2700-2770, 2887-2960, 3490-3570, 4230-4280, 2759-2890), conversion/edit.rs (1-70, 120-253), export.rs (700-775), selene/src/disk.rs (1290-1325), heliopause/src/lifetime.rs, ignition/preparation/{model_core.py, runtime_core.py, core_snapshot.py, core_file.py, host_ranks.py, rank_group.py}, ignition/cli/{serve.py, publishing.py}, tests/preparation/test_directory_preflight.py, plus the diff of all 7 files. Callers traced: ignition export → serve.py:330 export_core(..., None, ...) / serve.py:229 prepared.export(None,...); host_ranks.py:439-500; rank_group.py:97-140; core_file.combine → heliopause export_combine → core.rs publish_payload; core_snapshot payload_convert/combine/edit/promote → heliopause conversion.rs. Not settled by code (test/settling action): whether the mergerfs EINVAL mapping holds against the real FUSE filesystem — no live reproduction exists; the two injected-errno tests (archive.rs:437-458, cache.rs:4539-4567) are the only evidence. combine publishes with plain fs::rename (conversion.rs:3538), so it is not another uncovered no-replace rename — a grep for its publish call settled the open question from the previous run.