PR #713: fix(flare-cli,helios): release page cache with O_DIRECT peer serving, inherit orbit memory reserve, and log integrated MemInfo

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/a0439720-50e6-486b-906c-2f4799675f2e

Opened by a workflow run, Dec 3, 2026 4:58 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: jcartu (CONTRIBUTOR; 6 merged / 3 closed / 11 open PRs in 180 days, mostly docs + helios; Discord: jcartu) Motivation: On a 2×DGX Spark (GB10) box, page cache left behind by flare's own core-distribution reads makes orbit run plan a KV cache up to 38% smaller than a manual flare run, and sometimes makes CUDA context creation fail with 116 GiB "available". The PR tries to stop that page cache accumulating, and to make the failure mode legible when it still happens. Scale: +779 / −48 lines in 11 files Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #713 (release page cache with O_DIRECT peer serving, inherit orbit memory reserve, log integrated MemInfo)

Charter alignment: partly — and the charter's evidence clause binds. The problem is in scope: the vision names DGX Spark explicitly, and #630 is a GB10 report labelled bug/performance/priority:P2/triage:investigate with a reporter re-measuring across three releases; Orbit supervises serving ranks, which is a stated goal. But "Bring real evidence" (#210 for performance, #397 for root-cause fixes) is not met: verification is self-reported cargo test/clippy output on Linux x86_64 with no CI on head 4efd9fd, and the author's own Disclosures state "live GB10 impact remains unmeasured" and that GB10 CU_DEVICE_ATTRIBUTE_INTEGRATED / CUDA_ERROR_OUT_OF_MEMORY behaviour at context creation is "unconfirmed." #630's 2026-12-02 comment shows #667's existing release calls did not clear the ~9 GiB controller page cache by plan time — exactly where the four new release sites and O_DIRECT aim — with nothing showing they now succeed. Ask 1 of #630 (size the plan from MemFree, or flush before planning) is untouched: shared_available still delegates to flare_selene::offload::available_memory.

Novelty & status: genuinely additive. No commits on main since branch point cc0a49d touch these 11 files, and no open PR competes. It extends merged #667 rather than duplicating it. Note the dossier's warning: read the 11 files, not pr_diff — the diff is polluted with merged #690/#702/#707 content.

Value vs cost — three changes, three very different ratios.

Conditions. Split into three PRs: land (2) with docs and land (3) as-is; defer (1) until pfn's offered ~5-minute instrumented GB10 run shows the cache is actually cleared — otherwise the root cause is the sizing path and that is what should change.

Verdict: Worth it with changes — keep the reserve inheritance and MemInfo diagnostics; defer the O_DIRECT peer-serving change pending GB10 evidence.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, performance, enhancement, area:memory, area:orbit

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +performance, +enhancement, +area:memory, +area:orbit

Gates and contracts

Contracts, Charter & Verification Gates Audit — PR #713 (4efd9fd, 11 files, +779/−48)

Verdict

No contract or verification gate blockers. All four hard gates pass. I found no signed-format/wire/captured-graph change, no vendored-file fork, no unmerged-external dependency, no applicable mandatory formal/GPU gate that was skipped, and no reported failing test or failing CI check. Three non-blocking observations are recorded at the end (evidence gap on the claimed benefit, undocumented user-visible precedence rule, unverifiable design sign-off identity) — none of them is a repository-governance gate violation.


Gate 1 — Signed core-format / wire / captured-graph / public contract boundaries: PASS

Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS

Gate 3 — Mandatory verification evidence (design-review Layer 3): PASS

TLA+ / Kani / mutation gates — not triggered. docs/design-review.md:209–228 mandates python3 verification/helios-lifecycle/check.py (not opened) only for changes to "admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering or ownership, offload aggregation, readiness, or rank coordination", and Kani only for completion-vector validation, prepared completion contracts, state-view extent arithmetic, or sequential validators. Checking each touched site against that list:

Layer 1 CPU checks — reported for every affected crate, at --release --locked. flare-cli (251 passed) and helios --features runtime-core,server (1948 passed) are exactly the two crates the PR changes, run with cargo test --locked --release as Layer 1 requires; flare (255 passed) was run too, and clippy --all-targets plus rustfmt --edition 2024 --check are reported. No Python file is touched, so no pytest suite is owed. These are self-reported, but they are not contradicted by anything in the description or the Discovery Dossier, which explicitly confirms "Everything the description claims is present in the tree; I found no claimed change that is missing."

No failing test and no failing CI check on 4efd9fd. The description reports 0 failed in all three crates; the Dossier states there are no CI checks at all on the head commit and no comments, reviews, or labels. Since nothing reports a failure or an explicit refusal to run tests on this non-trivial change, and my tooling cannot observe GitHub Actions check runs, I do not raise a CI finding — per the calibration rule against unobservable-CI false positives. I note only that the reported counts are unverified by any repository artifact.

Performance-benchmark gate — trigger not met. docs/design-review.md principle 12 / charter #210 require a main-vs-branch served-workload A/B when a speedup is claimed. This PR claims no speedup and publishes no performance number: it explicitly states the trade-off ("O_DIRECT peer serving drops kernel readahead in exchange for avoiding page-cache accumulation") and discloses "live GB10 impact remains unmeasured" and that GB10 CU_DEVICE_ATTRIBUTE_INTEGRATED / context-creation CUDA_ERROR_OUT_OF_MEMORY behaviour is "unconfirmed". Disclosure of unrun hardware checks is precisely what principle 12 asks for, and the non-substitution rule at docs/design-review.md:247–251 ("Disclosure does not excuse skipping runnable CPU checks") is satisfied because all runnable CPU layers were run. See observation (1) for the residual risk this leaves.

Gate 4 — Material scope / claim contradictions: PASS


Non-blocking observations (reported, not gate violations)

  1. The claimed benefit is unmeasured on every affected path, and #630's primary ask is untouched (evidence risk, not a gate breach). The PR's stated purpose is to stop the KV-plan loss that #630 measured at −37.8% (13.0 GiB / 1,961,984 tokens vs 20.5 GiB / 3,153,664). #630's 2026-12-02 comment records that merged #667's release calls did not clear the ~9 GiB controller page cache by plan time, and the sizing path is unchanged (memory.rs:30–33 still returns flare_selene::offload::available_memory), so whether the four new sites plus O_DIRECT change the observed plan is open. The reporter offered a ~5-minute instrumented reproduction on the hardware. I record this as the single largest weakness in the evidence chain, but it is disclosed, it is hardware-only (not a skipped CPU layer), and no speedup number is claimed — so it is an evidence-quality matter for the value lens rather than a Layer-3 gate violation.
  2. A new user-visible precedence rule ships with no documentation, and no docs file is touched (0 of 11). The rule "saved persistent-group --memory-limit beats a config-inherited one; an explicit CLI flag beats both" (controller.rs:1972–1997) is exactly the shape of the documented transfer_streams rule at docs/orbit.md:632–634, but nothing analogous is written for --memory-limit; the new Plan cache fields, the stderr page-cache warning (memory.rs:106–114), and the drop_caches hint inside CudaError.description (memory.rs:133–137) also have no documented home (docs/cli-design.md:1436–1484 is the natural one). This is a documentation gap under AGENTS.md prose rules, not a contradicted normative invariant — docs/cli-design.md:1484, :759, :895 and docs/orbit.md:182 already state the default the PR now implements.
  3. docs/orbit.md:467's "groups … retain their own serving memory settings" is now true only for groups that saved --memory-limit. Groups without a saved limit and a host [memory] reserve inherit the reserve. That is the documented budget order (docs/cli-design.md:1484) and each node reads its own host configuration (docs/cli-design.md:1381), so I read this as wanted behaviour, but it is a silent KV-budget change for existing configs and should be stated in docs/orbit.md alongside the persistent-group section (docs/orbit.md:374–402).

What I checked and did not find

No docs/core-format-design.md, docs/scheduling-theory.md (not opened), or docs/scheduling-runtime-design.md invariant is contradicted; no Protobuf/enum/wire/graph addition; no helios/native/ or vendored third-party change; no new crate dependency or unpinned external reference; no touched scheduler, admission, dispatch, execution-transport, or PrefixCheckpointCache code that would trigger verification/helios-lifecycle/check.py (not opened), Kani, or mutation testing; no reported failing test or failing CI check on 4efd9fd; no fabricated benchmark or verification artifact.

Full report

Subtraction and simplicity

Subtraction & Simplicity audit — PR #713 (head 4efd9fd)

Scope note: the tooling pr_diff for helios/src/runtime_core/memory.rs and flare-cli/src/main.rs includes unrelated merged work (e.g. row_backing_bytes, largest_count, registration_context), so I audited only the 11 files listed in pr_files and, inside them, only the hunks that belong to this PR's three stated changes. Verdict up front: the change is not lean. The I/O copy path itself is tight, but there are five concrete duplications the PR either creates or knowingly extends, and two of them have correctness consequences beyond style.


High signal — duplication with a behavioural cost

1. A second, divergent /proc/meminfo parser, reading the same file twice on the same path

helios/src/runtime_core/memory.rs:50–76 adds a strict parser:

let kib = fields.next()?.parse::<u64>().ok()?; if fields.next()? != "kB" || fields.next().is_some() { return None; }

But the tree already parses MemAvailable: in selene/src/offload.rs:959–971 (available_memory, looser: accepts any trailing junk after kB), MemTotal: at selene/src/offload.rs:983–993, and a third in ignition/planning.py:128–131 (not opened). The PR leaves shared_available delegating to the old parser —

memory.rs:31–33 pub(super) fn shared_available(meminfo: &str, total: usize) -> Result<usize> { Ok(flare_selene::offload::available_memory(meminfo, total)?) }

— and then reads /proc/meminfo again, with the new parser, inside the same planning call:

So one plan invocation reads /proc/meminfo twice and parses MemAvailable with two parsers that disagree on malformed input. The Plan cache line can therefore print a MemAvailable that differs from the number the plan was actually sized from — on the exact diagnostic path #630 asked for. Fix: extend flare_selene::offload with one meminfo_value(name)/LinuxMemInfo type (it owns the other two parsers) and delete LinuxMemInfo::parse (−27 lines), or at minimum have append_integrated_meminfo consume the already-read MemorySnapshot instead of re-reading the file.

2. verify_file is hash_file with one extra line, and the PR edited both

helios/src/core/cache.rs:4428–4447 and helios/src/core/cache.rs:4498–4514 are the same function:

verify_file: open, DigestContext::new(&SHA256), vec![0; 1 << 20], loop with Interrupted retry, crate::os::release_page_cache(&file); read?; then if PayloadId::from_digest(context.finish()) != declared { … } hash_file: identical, minus the comparison.

verify_file(path, declared) collapses to if hash_file(path)? != declared { Err(...) } else { Ok(()) } — about 14 lines removed, and the release call (which the PR adds at both :4441 and :4511) exists in one place instead of two, so a future change cannot update one and miss the other.

3. enrich_integrated_ctx_oom has two arguments that encode one fact, and the OOM test is written twice

memory.rs:118–128:

pub(super) fn enrich_integrated_ctx_oom(mut error: crate::Error, integrated: bool, meminfo: Option<LinuxMemInfo>) -> crate::Error if !integrated { return error; } let Some(info) = meminfo else { return error; }; if let … && cuda.code == super::driver::CUDA_ERROR_OUT_OF_MEMORY

integrated == true && meminfo.is_some() is the only meaningful state; the (bool, Option<T>) pair is exactly the invalid-state-you-can-represent shape. It also forces the caller to compute integrated != 0 twice, helios/src/runtime_core/mod.rs:379–385:

memory::enrich_integrated_ctx_oom(error, integrated != 0, (integrated != 0 && status == driver::CUDA_ERROR_OUT_OF_MEMORY).then(memory::LinuxMemInfo::read).flatten(),

and the "is this an OOM" decision then lives in two places: the .then(… status == CUDA_ERROR_OUT_OF_MEMORY) in mod.rs:382 and the re-check at memory.rs:130. Collapse to one Option<LinuxMemInfo> parameter (caller passes None unless integrated-and-OOM) and drop the integrated parameter and one of the two OOM tests.


High signal — pure subtraction

4. AlignedBuffer is now the third copy of the same unsafe allocator wrapper

flare-cli/src/distribution.rs:1226–1253 (new, +28 lines) is byte-for-byte the shape of selene/src/disk.rs:2253–2294:

distribution.rs selene/src/disk.rs
struct AlignedBuffer { address: usize, bytes: usize } struct AlignedBuffer { address: usize, length: usize }
flare_helios::allocate_aligned(bytes)? + unsafe { std::ptr::write_bytes(address as *mut u8, 0, bytes) } flare_eos::allocate_aligned(length) + identical write_bytes
impl Drop { unsafe { flare_helios::free_aligned(self.address, self.bytes) } } impl Drop { unsafe { flare_eos::free_aligned(self.address, self.length) } }

helios/src/engram/reader.rs:90 (not opened)/:414 is a third raw alloc/free pair on the same two functions. flare_eos exports allocate_aligned/free_aligned (eos/src/lib.rs:48–64) but no owning type, so every caller re-derives the Drop invariant. Adding pub struct AlignedBuffer to flare_eos (where the allocator lives) deletes 28 lines here and ~40 in selene/src/disk.rs, and removes two hand-written // SAFETY:-correct blocks from review surface.

5. The --memory-limit precedence rule is argv string-matching, three times over

flare-cli/src/orbit/controller.rs:1967–1997:

fn has_memory_limit(args: &[String]) -> bool { args.iter().any(|arg| arg == "--memory-limit" || arg.starts_with("--memory-limit=")) } let skip_config_limit = memory_limit_from_config && has_memory_limit(saved); if arg == "--memory-limit" { skip_next = true; continue; } if arg.starts_with("--memory-limit=") { continue; }

The same arg == "--flag" / starts_with("--flag=") + skip_next pair-strip loop already exists twice in this crate: controller.rs:2004–2022 (deduplicate_tensor_parallel) and flare-cli/src/orbit/agent.rs:2232–2251 (grant argv strip for --tensor-parallel). This PR adds a third hand-rolled copy, and the copy is already fragile: a trailing --memory-limit with no value sets skip_next that is never consumed, and the predicate is duplicated between has_memory_limit (:1968–1969) and the strip body (:1986, :1990).

The structural version deletes the whole mechanism: RunOptions already distinguishes the two cases, so carry the config reserve as a value instead of as argv — pub memory_limit_from_config: bool (controller.rs:167–169) becomes config_memory_limit: Option<MemoryLimit>, the config layer stops injecting --memory-limit into options.serving at all (flare-cli/src/main.rs:538–540, flare-cli/src/cli.rs:672–682), and merge_serving_options shrinks to "use saved, else CLI, else config" with no string matching. That removes has_memory_limit, skip_config_limit, skip_next, the memory_limit_from_config bool field, the bool parameter at controller.rs:1975, and the duplicated predicate — roughly 20 lines and one new cross-module contract (the undocumented precedence rule) in exchange for one enum field.

6. The from_config predicate the test asserts is copied, not called

flare-cli/src/main.rs:538–540:

memory_limit_from_config: run.serving.memory_limit.is_some() && run_matches.value_source("memory_limit") != Some(clap::parser::ValueSource::CommandLine),

flare-cli/src/config.rs:917–918 (new test) re-implements it verbatim:

let from_config = run.serving.memory_limit.is_some() && run_matches.value_source("memory_limit") != Some(ValueSource::CommandLine);

Because the test reconstructs the expression instead of calling production code, it cannot fail if main.rs:538 changes — it only tests itself. Extract one fn memory_limit_from_config(run: &OrbitRun, matches: &ArgMatches) -> bool and call it from both (net −2 lines, but it makes ~30 lines of test assertions meaningful).

7. Duplicated release loop and a redundant empty guard

flare-cli/src/distribution.rs:1261–1263 and :1330–1332 are the same three lines:

for &(offset, size) in ranges { flare_helios::release_page_cache_range(file, offset, size); }

The direct path already has this loop; the buffered path needs it too. Since the buffered fallback inside copy_ranges_direct (:1309) routes through copy_ranges_buffered (which releases), the only reason for the outer copy at :1330–1332 is the success path of the direct copy. Hoisting the loop into copy_source_ranges after the branch (release always, then return the result) removes one copy and makes "every served range is released" true by construction in one place rather than two. Relatedly, :1324 if ranges.is_empty() || ranges.iter().all(|&(_, size)| size == 0) { return Ok(0); } overlaps release_page_cache_range's own if len == 0 { return; } (eos/src/unix.rs:75); the guard is only there to skip a 4 MiB allocation for an all-zero request — worth one comment, or drop the is_empty() half.

8. Two unexplained thresholds for one condition

helios/src/runtime_core/memory.rs:36–38:

pub(super) const PAGE_CACHE_WARN_THRESHOLD: u64 = 10 << 30; pub(super) const CTX_OOM_DROP_CACHES_THRESHOLD: u64 = 4 << 30;

Both answer "is reclaimable page cache large enough to be the cause?", 2 GiB into the same reclaimable gap, differing only in where they are checked. #630 asked for one number (">10 GiB divergence"). Either collapse to one constant or state why context creation is more sensitive than KV sizing — as written, a reviewer cannot tell whether 4 << 30 is measured or guessed, and the PR's own disclosure says it is unmeasured on target hardware.

9. The memory-line prints the same triple twice in one startup

memory.rs:105 appends meminfo.summary() to the summary that already became the Plan cache line, and :108–111 embeds {} = meminfo.summary() again inside the warning that is printed immediately after at memory.rs:1264–1267. On a polluted GB10 controller, one startup prints MemFree 1.00 GiB / MemAvailable 11.20 GiB / Cached 10.60 GiB twice. Drop the parenthetical from the warning string.

10. append_integrated_meminfo mixes a mutation with a returned warning

memory.rs:100–115 takes &mut String, appends, and returns Option<String> for the caller to eprintln!. That is why the call site needs the let meminfo_warning = …; finish(summary); if let Some(w) = … contortion at memory.rs:1256–1268. Returning Option<String> (the full line, or (line, Option<warning>)) makes the call site four straight lines and keeps formatting in one place.


Low signal


What is already lean — do not "simplify" these


Test volume vs. change

Of the +779 lines, roughly 300 are tests. The memory.rs parser tests (:2266–2409) are thorough and mostly worth keeping, but flare-cli/src/config.rs:896–992 is 97 lines of assertions for a 6-line production change, three of whose assertions test a predicate the test itself re-declares (item 6). If item 5's structural change lands, most of controller.rs:3793–3839's four merge_serving_options cases collapse to two (saved wins / CLI wins) because the flag-parsing edge cases no longer exist.

Full report

Code correctness

Deep Code Correctness / Invariants / Hot-Path Audit — PR #713 @ 4efd9fd

Scope note (affects how the PR was partitioned): the supplied file list and pr_files report 11 files, but the actual diff also modifies helios/src/runtime_core/cache_memory.rs (+~180 lines: Layout.sentinel_granules, fixed_segments, pack_prefixes, plan_mapping_handles rewrite, new alias_plane third predicate). That makes this a >900-line, multi-crate PR, so it was partitioned into 3 concurrent slices (flare-cli distribution/config/orbit; helios runtime_core memory+planning; helios core/cache.rs+eos), each run through the full 4-part protocol, then synthesized and independently re-verified below.

Bottom line: the O_DIRECT peer-serving rewrite, the page-cache release sites, the /proc/meminfo diagnostics, enrich_integrated_ctx_oom, and the row_backing_bytes sentinel arithmetic are all correct under adversarial tracing (proofs below). There is one Major state-persistence defect in the new [memory] reserve propagation, plus three Minor performance/estimator issues. No Blocker.


MAJOR-1 — [memory] reserve is baked into the persisted --persistent group on first launch, so later config edits are silently ignored forever

Diff sites: flare-cli/src/orbit/controller.rs:692-696 (merge), :875-878 (persist), flare-cli/src/orbit/controller.rs:1967-1987 (merge_serving_options), flare-cli/src/orbit/store.rs:231-233 (GroupSpec.serving), flare-cli/src/config.rs:152-158.

memory_limit_from_config only protects an already-saved value; it does nothing to stop the config-derived value from being written into the saved spec when the group had no saved limit:

fn merge_serving_options(
    saved: &[String],
    current: &[String],
    memory_limit_from_config: bool,
) -> Vec<String> {
    let mut serving = saved.to_vec();
    let skip_config_limit = memory_limit_from_config && has_memory_limit(saved);
    ...
        if skip_config_limit {          // <-- only true when `saved` ALREADY has a limit

and the merged list (which now contains the config-inherited --memory-limit=-12GiB emitted by ServingOptions::rank_options, flare-cli/src/cli.rs:1150-1152) is then written verbatim into the durable orbit file:

let saved = GroupSpec {
    name: name.clone(),
    core,
    serving: serving.clone(),   // controller.rs:878 — config-derived limit included

GroupSpec is serialized to ~/.config/flare/orbit.toml (not opened) via Orbit::save_group/save (store.rs:299-324) and re-read on every later attach/restart/controller relaunch.

Decision table (all four rows verified from the code):

memory_limit_from_config saved has --memory-limit outcome
true yes saved wins (intended)
true no config value appended → persisted into the spec ← defect
false (explicit CLI) any both appended; OrbitRun has #[command(args_override_self = true)] (cli.rs:571-573), so clap keeps the last → explicit wins ✔
n/a n/a main.rs:531-537 sets the flag as is_some() && value_source != CommandLine, which is exactly "came from config" ✔

Concrete counterexample: orbit.toml (not opened) has memory = { reserve = "12 GiB" }. Operator runs flare orbit run --name g --persistent model/. The spec persists serving = ["--memory-limit=-12GiB", ...]. The host is later resized (or the reserve is corrected) to reserve = "7 GiB". On the next flare orbit run --name g (or after a controller reboot, which relaunches from the spec), saved now does contain --memory-limit, so skip_config_limit == true and the new group is launched with the stale 12 GiB — a config value the operator has already changed, with no warning, and the only escape is hand-editing orbit.toml (not opened) or passing an explicit --memory-limit. This is exactly the bug class the PR set out to fix ("without clobbering saved persistent-group overrides"), just inverted: config now clobbers nothing but poisons the saved state.

Fix: do not persist config-derived limits. Either (a) keep it out of serving entirely and store it as a separate GroupSpec field mirroring how transfer_streams/roce_ring are stored, e.g. pub memory_limit_from_config: Option<String> set in controller.rs:875 and re-applied at launch, or (b) strip it before save_group (serving.retain(..) on the config-derived entry when options.memory_limit_from_config), and (c) add a regression test that persists, changes [memory] reserve, and reloads — the new tests (controller.rs:3793-3837, config.rs:895-990) never round-trip through save_group/Orbit::load, which is why this is unobserved.


MINOR-1 — alias_plane's new largest_count clause makes plane eligibility non-monotone: adding a plane can disqualify already-eligible planes and shrink the snapshot alias budget

Diff sites: helios/src/runtime_core/cache_memory.rs:73-91 (and its duplicate consumer helios/src/runtime_core/memory.rs:654-680).

    unit == largest
        || alignment.div_ceil(unit) <= row.div_ceil(page)
        || (largest == unit.saturating_mul(2)
            && row.div_ceil(largest_count.saturating_mul(alignment).max(1)) >= 2)

Only the third clause references largest_count, and it is anti-monotone in the number of densest planes: raising largest_count raises the divisor, shrinking row.div_ceil(largest_count * alignment) and turning the clause off for planes that previously qualified — i.e. adding a mixed-width plane can remove alias borrowing from unrelated planes.

Concrete counterexample: row = 4 MiB, alignment = 2 MiB, page = 4 MiB, one plane unit = 1 MiB with a densest plane largest = 2 MiB, largest_count = 1: clause 2 fails (div_ceil(1 MiB) = 2 > div_ceil(4 MiB) = 1) but clause 3 holds (row.div_ceil(1*2 MiB) = 2 >= 2). Now add a second densest plane (largest_count = 2): clause 3 becomes 4 MiB / 4 MiB = 1 >= 2 → false, so the 1 MiB plane loses eligibility and capacities() (memory.rs:654-680) computes a smaller cached/rows snapshot budget for the same total memory.

Why only Minor: eligibility is recomputed with the same eligible_planes(geometry, row_alignment) call inside Layout::grouped (cache_memory.rs:297), and the same rounding is used on both sides, so an accepted capacity is always buildable in Layout — this can never accept a plan that fails to allocate. The loss is a smaller alias budget, not corruption.

Fix: make the dense-plane test width-relative and monotone, e.g. alignment.div_ceil(unit) * largest_count.max(1) <= row.div_ceil(page), keeping the third clause additive rather than as a replacement.


MINOR-2 — hash_file evicts the page cache of a file that is immediately re-read in full by the same import path

Diff site: helios/src/core/cache.rs:4502-4513 + caller helios/src/core/cache.rs:1900-1906.

    let read = loop { ... };
    crate::os::release_page_cache(&file);
    read?;
    Ok(PayloadId::from_digest(context.finish()))
    let digest = hash_file(&path)?;
    let file = File::open(&path).map_err(failure)?;
    let object = self.insert_legacy_container(digest, file)?;

hash_file's only caller (import_legacy_into) opens the identical inode on the next line and streams it again through write_stream, so the eviction converts a warm second pass into a guaranteed cold re-read.

Counterexample: flare cache import of a 70 GB legacy core set — ~70 GB of extra storage reads (import read volume roughly doubles on NVMe).

Fix: give hash_file a release: bool (or hoist the eviction to after insert_legacy_container returns) and pass false at cache.rs:1904.

MINOR-3 — plan accounting double-counts the sentinel rounding tail (pessimistic only)

Diff sites: helios/src/runtime_core/memory.rs:1361 and :589; callee cache_memory.rs:133-141/:291-304.

The row side now correctly becomes alignment + tail (fixed_segments), but the KV side keeps bytes(core,1,pages) = Σ round_up(pages*unit, align) while the bytes actually created per plane are (page_capacity*unit).div_ceil(a)*a, i.e. one granule less when the extent is already aligned. pages*unit = 4 MiB with a = 2 MiB → estimate 4 MiB, real 2 MiB. Effect: one skipped KV page and a slightly inflated "Allocate cache" total; never an over-accept. Fix: mirror remaining_prefix for the page side in both places.


Verified correct (with the counterexamples that were actually run through)

O_DIRECT peer serving — flare-cli/src/distribution.rs:1267-1336. read_len = (skip + take).next_multiple_of(4096) is provably <= chunk_bytes for every input (skip < 4096, take <= chunk_bytes - skip, chunk_bytes a 4096 multiple) → no OOB into AlignedBuffer, no position - skip underflow. count <= skip reproduces RangeReader's exact "file ended inside a requested range" error (core_cache.rs:599-601), so EOF-inside-range is byte-identical across both paths. The mid-stream EINVAL fallback reconstructs rest = [(position, remaining)] ++ ranges[index+1..] — resumption is byte-exact at every failure index (0/1/2/3), no duplication or loss, and total + copied is the true count. direct_reopen resolves /proc/self/fd/N (same inode, works for unlinked files) so there is no TOCTOU against the verified fd. Empty/zero-length ranges short-circuit to Ok(0). Note serve_source:1216 discards the return value, and the receiver enforces exactly range_bytes bytes, so a short copy surfaces as UnexpectedEof rather than silent corruption. Double release_page_cache_range on the fallback path (copy_ranges_buffered then copy_source_ranges:1330) is idempotent posix_fadvise on the same inode — harmless.

Windows build of the new re-exports — helios/src/lib.rs:38-41. All re-exported symbols exist on Windows (direct_reopen eos/src/windows.rs:126, release_page_cache* windows.rs:150-151 no-op stubs; FileReadAt/allocate_aligned/free_aligned are unconditional in eos/src/lib.rs:24-64), and every #[cfg(unix)] gate in distribution.rs is complete. No compile break.

copy_file durability — helios/src/core/cache.rs:4767-4777. The "lost directory fsync" hypothesis is false: the removed callee container::sync_file (container.rs:1176-1185) is, on non-Windows, exactly File::open(path)?.sync_all(); directory durability is still provided by synchronize→syncdir (cache.rs:4813, 4836-4842), and make_immutable still runs after it. No mmap of container files exists anywhere (only helios/src/engram/reader.rs memfds and an anonymous mapping), so POSIX_FADV_DONTNEED cannot unmap live pages.

verify_file/hash_file restructure — helios/src/core/cache.rs:4432-4446, 4502-4513. The let read = loop { break Ok/Err } form has no early return, so release_page_cache always runs; read? still precedes context.finish(), so a mid-read error still suppresses the digest comparison and propagates the identical failure(error).

row_backing_bytes — helios/src/runtime_core/memory.rs:492-509. Proved consistent with the real layout for all units >= 1, not just multiples: with n = row_bytes/alignment, round_up(u*row_bytes, a) - (n-1)*a = a + (fixed_bytes - n*a) = granule + tail, which is exactly fixed_segments() under fixed_bytes = round_up(execution*row_bytes, a) (cache_memory.rs:291, :410-414). Worked check: row=82_143_488, a=2 MiB (n=39), u=2 → span=158 MiB, saved=76 MiB, result 82 MiB = 2 MiB + 80 MiB, matching the new test's claim. Non-multiple case row=1_500_000, a=2 MiB: u=1 → 2 MiB, u=2 → 3_145_728 = a + 1 MiB. units == 0 returns span early, matching sentinel_granules = 0; no call site passes execution == 0 (memory.rs:581/605/618/1103/1361), and saved <= span - a, so no underflow is reachable. bytes(core, 0, …) is deliberately retained at memory.rs:676-680 (virtual extent vs physical); no site was missed.

meminfo + OOM enrichment — helios/src/runtime_core/memory.rs:41-146, mod.rs:375-388. parse matches only exact "MemFree:"/"MemAvailable:"/"Cached:" tokens, so SwapCached:/SReclaimable: cannot alias Cached:; every fields.next()? early-return is fail-closed (diagnostics skipped, never a wrong number); checked_mul(1024) covers overflow. reclaimable_gap() = available.saturating_sub(free) is correct (Linux guarantees available >= free). Thresholds use strict > and the tests pin 10 GiB/4 GiB exact-boundary behaviour. check_ctx passes the real status at both call sites (cuDevicePrimaryCtxRetain mod.rs:407-410, cuCtxCreate_v2 :413-416), only re-reads /proc when integrated != 0 && status == CUDA_ERROR_OUT_OF_MEMORY, and preserves the structured Error::Execution(ExecutionError::Driver(CudaError { code: 2, .. })) — the #[cfg]-shadowed let result is legal and warning-free on both platforms. CUDA_ERROR_OUT_OF_MEMORY = 2 is correct.

Persistent-group merge, explicit-CLI path. skip_config_limit == false appends both occurrences, and OrbitRun carries #[command(args_override_self = true)] (cli.rs:571-573), so clap keeps the last value → an explicit --memory-limit genuinely overrides a saved one. The defect above is confined to the config-inherited path.

Not verifiable in this environment (carried from the PR's own disclosures): live GB10 CU_DEVICE_ATTRIBUTE_INTEGRATED / CUDA_ERROR_OUT_OF_MEMORY-during-context-creation behaviour, whether cuDevSmResourceSplit accepts the three-group codec partition on driver 615.x, and whether codec-context VMM allocations remain usable from the compute/worker contexts. The 10 GiB / 4 GiB thresholds are heuristic by construction with no live MemFree/MemAvailable data.

Full report

Final review

Recommendation: Changes Requested

The O_DIRECT peer-serving rewrite, the four new page-cache release sites, the /proc/meminfo parser/enrichment, and the [memory] reserve inheritance are all correct on the read/write paths I traced at 4efd9fd — the aligned-chunk arithmetic cannot overrun its buffer, the mid-stream EINVAL fallback is byte-exact, the release calls are unconditional, and the Windows/macOS cfg gating is complete. Two verified, non-hardware defects remain: the config-derived --memory-limit is written into the persisted --persistent group and then locked in by the very rule that is supposed to protect saved values, and hash_file now evicts the page cache of a file the same import path immediately re-reads in full. Both are small, local fixes.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Config-derived --memory-limit is frozen into a --persistent group, so later [memory] reserve edits are silently ignored forever. flare-cli/src/orbit/controller.rs:692-696 merges saved ++ current; when the saved group has no limit and the limit came from config, the config-derived --memory-limit=<v> (produced by flare-cli/src/cli.rs:1150-1152 via OrbitRun::rank_options, cli.rs:672-682) is appended and then persisted verbatim: GroupSpec { serving: serving.clone(), .. } at flare-cli/src/orbit/controller.rs:875-878 → Orbit::save_group (flare-cli/src/orbit/store.rs:318-324) → ~/.config/flare/orbit.toml (not opened). On the next launch spec.serving now contains --memory-limit, so skip_config_limit = memory_limit_from_config && has_memory_limit(saved) (:1978) is true and the new config value is skipped. Verified counterexample: [memory] reserve = "12 GiB", orbit run --name g --persistent model/ → saved --memory-limit=-12GiB; operator corrects config to 7 GiB; orbit run --name g still launches with 12 GiB, with no warning, and the only escapes are an explicit flag or hand-editing orbit.toml (not opened). This inverts the PR's own goal ("without clobbering saved persistent-group overrides") — the value the operator never typed becomes the saved override. Fix: do not persist a config-derived limit — strip it before save_group (retain-drop the config-inherited entry when options.memory_limit_from_config), or carry it as its own GroupSpec field re-applied at launch, mirroring transfer_streams/roce_ring. The four existing tests (controller.rs:3794-3839) never round-trip through save_group/Orbit::load, which is why this is unobserved; add one that persists, edits the reserve, and reloads.
  2. hash_file evicts the page cache of the file the same import path immediately re-reads in full. helios/src/core/cache.rs:4511 drops the cache after hashing, and its only caller opens the identical inode on the next line: let digest = hash_file(&path)?; let file = File::open(&path)...; self.insert_legacy_container(digest, file)? (:1904-1906), which streams the whole file again through write_stream (:4386-4396) and evicts again (:4398). Net effect: the legacy-core import path now reads every payload from storage twice instead of once warm — roughly doubling read volume on a multi-GB core set (flare cache import-style flows through import_legacy_into, :1889). This is a regression introduced by this PR on the host-RAM reuse side of the #93/#630 trade. Fix: give hash_file a release: bool (pass false at :1904) or hoist the eviction to after insert_legacy_container returns.

Subtract / Simplify

  1. helios/src/core/cache.rs:4428-4447 is hash_file (:4498-4514) plus one comparison; collapse to if hash_file(path)? != declared { .. } so the newly added release_page_cache exists once instead of twice.
  2. helios/src/runtime_core/memory.rs:117-129: enrich_integrated_ctx_oom(error, integrated: bool, meminfo: Option<LinuxMemInfo>) encodes one fact twice (integrated == true implies meminfo.is_some() at the only call site, mod.rs:379-385) and re-tests the OOM code already tested by the caller's .then(..). One Option<LinuxMemInfo> parameter removes the invalid state, the duplicate OOM test, and the duplicated integrated != 0.
  3. flare-cli/src/distribution.rs:1261-1263 and :1330-1332 are the same release loop; hoisting it into copy_source_ranges after the branch (release always, then return the copy result) makes "every served range is released" true in one place and preserves the release-on-error property.
  4. flare-cli/src/distribution.rs:1226-1253 re-implements the same allocate_aligned/free_aligned owning wrapper that exists at selene/src/disk.rs (not opened) (~2253-2294); a shared owning AlignedBuffer in eos (where the allocator lives) deletes it and one hand-written Drop.
  5. flare-cli/src/orbit/controller.rs:1967-1997 is a third hand-rolled --flag/--flag= + skip_next argv scanner in this crate (see deduplicate_tensor_parallel :2000-2028 and orbit/agent.rs:2231-2251); carrying the reserve as a value (Option<MemoryLimit>) instead of argv removes has_memory_limit, skip_config_limit, skip_next, the bool field and the duplicated predicate — and would make Should Fix 1 structurally impossible.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.