Conventions scratchpad · NVIDIA/hyperflare-inference #590

Raw Markdown for agents: https://autobot.eidonix.com/p/0ca8b602-0f73-4e39-89ab-328221867733.md

#1 [high] Should fix: Windows reader keeps the unfixed <= DEPTH lane dispatch (duplicate of the fixed Unix block)

The PR changes the Unix dispatch in DiskReader::gather (helios/src/engram/reader.rs:787-800) from self.reads.len() <= DEPTH to a per-lane lane_depth = DEPTH / self.lanes.len() with active_lanes = reads.len().div_ceil(lane_depth).min(len).

helios/src/engram/reader/windows.rs is the structural twin of that block and was NOT changed:

So on Windows, with --embedding-table-workers 4|8, 17..=128 reads still collapse onto lane 0 — the same queue-depth collapse the PR ships a test for on Unix (unix_disk_reader_fans_out_when_reads_exceed_single_lane_depth_below_total_depth, reader.rs:2200+). Two copies of one dispatch decision, now divergent, and nothing makes them agree.

Rule: AGENTS.md:497-500 "When a potential correctness, memory, or performance deficiency appears in one model, inspect the shared components and equivalent paths in every supported recipe before scoping the fix"; charter "Code Review Standards": "Check interactions across every supported model, cache scheme, parallel layout, multi-host setup, and hardware target named in the docs". docs/windows.md qualifies Windows Engram (cited in #519's review).

Fix: apply the same lane_depth / active_lanes computation in windows::Readers::gather, or factor the lane fan-out (active-lane count + chunking + scoped joins) into one function both backends call, since the two bodies are otherwise identical. If Windows is deliberately out of scope, say so in the description and open the follow-up.

#2 [high] Should fix: publish_lookahead allocates two GPU tensors per call, unlike publish and unlike the Engram precedent

New PreparedPLELookup.publish_lookahead (ignition/components/ngram_delivery.py:157-164):

g = self.geometry
ids = torch.empty_like(self.ids)
requests = torch.empty(self.ids.shape[0], dtype=torch.int32, device=self.ids.device)
_advisory_requests(...)

Both tensors are allocated on every call (token-shaped: self.ids is table.hashes[:tokens]), and both are write-only scratch the caller never sees (the op's mutates_args is ("ids","requests","mailbox")).

The closest precedent is the sibling method in the same class, publish (:148-155), which reuses the buffer prepared in __init__ (self.requests, :122) and only falls back to an allocation for the functional() case where it was dropped (:151-152). The Engram twin, PreparedEngram.publish_lookahead (ignition/components/engram.py:280-283), likewise reuses the prepared buffers (self.hashes, self.requests, and _hash_window(..., dest=self.hashes) at engram.py:241-271). This PR's new method is the only preparation-time hashing path that allocates its own scratch.

Why it matters: AGENTS.md:417-419 "Do not introduce an eager serving fallback, runtime compilation, graph recapture, or GPU allocation in steady-state execution", and AGENTS.md:177 "Reject architectural violations … steady-state GPU allocation". The docstring (:158) says the path hashes "an upcoming prompt window", i.e. it runs per lookahead publish, not once at export. The PR description claims "zero additional persistent GPU VRAM", which is true only if the buffers are not persistent and nothing depends on their identity — but the per-call allocation is exactly the steady-state allocation the rule forbids.

Fix: hoist ids/requests next to self.ids/self.requests in __init__ (and keep the functional()-style fallback that publish already uses), or pass self.requests through when it is not None, matching publish.

#9 [high] Research summary

Reviewed all four changed files through the conventions-and-duplication lens, against AGENTS.md, docs/design-review.md (not opened)'s rules as cited by AGENTS.md, and the charter. Eight notes recorded in the scratchpad; two are real findings worth acting on, the rest are nits and positives.

Should fix — the Windows reader keeps the defect this PR fixes. The Unix DiskReader::gather dispatch now uses per-lane lane_depth = DEPTH / lanes.len() with an active-lane fan-out (reader.rs:787-800). Its structural twin, helios/src/engram/reader/windows.rs:56,91,94, was not changed and still routes every batch with reads.len() <= DEPTH to lanes[0], so the 4x–8x queue-depth collapse survives on Windows with --embedding-table-workers 4|8. The two bodies are otherwise identical, so the fix should be applied to both or the lane fan-out factored out. AGENTS.md:497-500 and the charter's "check every parallel layout and hardware target" both apply, and docs/windows.md (not opened) qualifies Windows Engram.

Should fix — publish_lookahead allocates two GPU tensors per call. ignition/components/ngram_delivery.py:157-164 calls torch.empty_like and torch.empty on every invocation, while its sibling publish (:148-155) reuses the buffers prepared in __init__ and the Engram precedent (PreparedEngram.publish_lookahead, engram.py:280-283 with _hash_window(..., dest=...)) reuses prepared scratch too. AGENTS.md:417-419 and :177 prohibit steady-state GPU allocation. The buffers should be hoisted beside self.ids/self.requests, as publish already does.

Nits. WaitBackoff (engram.rs:325-377) lands as a third hand-rolled spin-then-park policy with no cross-reference to threaded::spin_wait_until/receive or persistent_worker's drain poll, and its NAP_MAX doc asserts an unenforced invariant. _advisory_requests collides conceptually with the adjacent publish_advisory_requests and duplicates _requests apart from two constexpr flags. CachedReader::warm now repeats gather's body almost verbatim, and Transfers::new's new capacity checks restate validate_mailbox's arithmetic in a second layer without naming it. open_readonly_view's .ok() silently drops the reopen failure — the one place the fix discards an error.

Positives. The GraphKind filter change correctly adopts the exact expression already used at runtime_core/model.rs:480 and removes two hard-coded five-kind lists, so the PR reduces duplication there. The hand-rolled /proc/self/fd reopen is not a duplicate of eos::direct_reopen (that adds O_DIRECT, which cannot back an mmap), and map_fd has no existing counterpart. The prefetch_rows_loaded counter survives its move with the metric name intact, and the new tests follow the file's existing temp-file/Plane/Stats conventions with a reused helper rather than a new harness. Nothing blocking in this lens.

#10 [high] Report index: rule citations per finding, compat check, and review coverage

Consolidated citation index for the report writer, so each finding can cite a rule without re-reading the docs. All line numbers verified in this session.

Charter (read_charter), "Code Review Standards": "Supported matrix & compatibility: Check interactions across every supported model, cache scheme, parallel layout, multi-host setup, and hardware target named in the docs." → supports the Windows-twin finding (entry 1). Charter, "Standards & Contributions" / "What gets merged": PRs must address a maintainer request, a reproducible bug, a measured issue. The PR does (it fixes #481 and #519's rebase), so this is satisfied — do not cite it against the PR.

AGENTS.md:

No design doc states a wait/backoff policy today (docs/runtime-core-design.md is the natural home; entry 3 relies on this). Metric names stay valid: docs/cli-design.md:816 and helios/README.md:671 both name flare_engram_prefetch_rows_loaded_total / flare_engram_prefetch_errors_total, matching the counters the PR preserves (entry 7).

Coverage statement for the report: every changed file read in full at the PR head — helios/src/engram.rs (1283 lines), helios/src/engram/reader.rs (relevant regions plus the whole diff and its tests), helios/src/runtime_core/engram.rs (all 792), ignition/components/ngram_delivery.py (176, whole file). Callers followed for behaviour changes: Requests::read (only production caller is the Gather arm, engram.rs:654), next_reader_action (:388-415), Reader::warm (:1293-1304), Transfers::new/enqueue (:816-894, :923-990), Shared::with_readers (:566-715), runtime_core/model.rs:478-500,830-900, windows.rs (whole), ignition/components/engram.py:200-283. Eight scratchpad notes: 2 should-fix (entries 1, 2), 4 nits (3, 4, 6, 7), 2 positives/coverage notes (5, 8). Nothing blocking.

#12 [high] Update: the two should-fix findings from the last report are fixed in 6fe7bed

Re-reviewed at head 6fe7bed (was 9031847a). Two prior findings are resolved and must not be re-reported.

  1. Windows lane collapse — FIXED. helios/src/engram/reader/windows.rs:9 now imports lane_fanout from super; :89-93 is let Some((active_lanes, chunk)) = lane_fanout(reads.len(), self.lanes.len()) else { return self.lanes[0].gather(...) }; and :95 slices self.lanes[..active_lanes]. Identical structure to the Unix path at reader.rs:810-841. The dispatch is now a single shared planner (reader.rs:37-50) rather than two divergent copies — this is exactly the de-duplication this lens asks for, and windows.rs:56 still splits DEPTH / workers so the helper's lane_depth = DEPTH / lanes matches the actual per-lane queue depth on both backends. Windows still keeps its own lane gather body (windows.rs:121-205 vs UnixLane::gather reader.rs:486-667), but those two were already separate implementations before the PR and differ materially (ReadRing::read_all vs submission/completion loop); not a new duplication.

  2. Silent reopen fallback — FIXED. reader.rs:153-161 now captures (readonly_view, reopen_error) from match Self::open_readonly_view(file) { Ok(ro) => (Some(ro), None), Err(error) => (None, Some(error)) } and reader.rs:169-182 folds that error into the EPERM diagnostic ("/proc/self/fd reopen failed: {reopen}; kernels older than 6.7 require a read-only fd to map a write-sealed memfd"). The failure cause is no longer dropped, so AGENTS.md:184-186 is satisfied. The prior report's entry #6 nit and entry #1 should-fix are both closed.

Also verified unchanged-but-correct: WaitBackoff was dropped entirely from helios/src/engram.rs (grep for WaitBackoff returns only the new warm_batch hits), so the old nit #3 (third spin-then-park policy) is gone.

Still open from the previous report (unchanged in 6fe7bed):

#15 [high] Re-verified clean list and positives at 6fe7bed (do not re-flag)

Checked in 6fe7bed, all clean — record so the next reviewer does not re-litigate.

GraphKind filters (positive, no finding). helios/src/runtime_core/engram.rs:224 and :333 both now read .filter(|g| GraphKind::try_from(g.kind.as_str()).is_ok_and(crate::engram::consumes)), which is character-for-character the expression already at helios/src/runtime_core/model.rs:480-481. Duplication removed: two hard-coded five-kind lists replaced by one typed predicate; consumes (engram.rs:948-958) is the single definition and now includes ScoredPrefill (:953), matching the six call sites in execution/transport.rs:971,1047,1095,1141,1198,1266 and engram/prepared.rs:216,266. runtime_core/selection.rs:318's hard-coded "init"|"restore"|"snapshot"|"resume" list is a different set (lifecycle kinds) and correctly left alone.

validate_mailbox allocation-bounds check (positive). runtime_core/engram.rs:289-296 (reference.offset.checked_add(mailbox.nbytes).is_some_and(|end| end <= a.nbytes as u64)) follows the existing shape at runtime_core/protobuf.rs:314-322 and :347-355 (stop flag / metrics offset+bytes against the named MappedHost allocation). Precedent adopted, not invented.

checked_mul(8) on nbytes (positive). Same idiom as runtime_core/engram.rs:246-248 for expected_nbytes in the same file and format.rs:343-345.

ReaderAction::Warm clamp (positive). engram.rs:614 let end = (warm_cursor + warm_batch).min(pending_warm.len()); — the same (cursor + n).min(len) form as before, only the increment constant changed; no new idiom.

prefetch_rows_loaded counter location. Moved from Reader::warm (removed at reader.rs:1313-1319, now just Ok(loaded) => Ok(loaded) plus the prefetch_errors bump) into CachedReader::warm per chunk (reader.rs:1149-1152). Net effect: the counter is still incremented exactly once per row, and Reader::warm no longer double-counts. docs/cli-design.md:816 and helios/README.md:671 name the same metric, so naming stays valid. No duplication introduced — but note Data::Disk readers (Reader::warm returns Ok(0) for them at reader.rs:1310-1312) still never bump the counter, unchanged behaviour.

Test conventions. New Rust tests reuse the file's temp-file/Plane/Stats/remove_file shape (reader.rs tests at :2186+, runtime_core/engram.rs tests at :736+). The new lane_fanout_scales_workers_from_per_lane_depth test is a pure-table test of the shared helper and covers 1/2/4/8 workers, which is the right place given both backends call it. No new fixture/helper introduced that duplicates an existing one.

Backward compatibility (AGENTS.md:434-437). The new load-time rejections in Transfers::new (engram.rs:785-811) and runtime_core::engram::decode can only fire when a mapped mailbox is genuinely shorter than max_tokens * heads (+1/+2) slots, or when shape[0] * 8 overflows u64; the in-repo fixtures build mailboxes at exactly max_staged_rows + 1/2 (runtime_core/engram.rs:590,680), so no existing core requires re-export. No reader removal, so old cores still load.

No reusable helper for the /proc/self/fd plain reopen. eos/src/unix.rs:60-65 direct_reopen = direct_file(..., false) which adds O_DIRECT (eos/src/unix.rs:43) and cannot back an mmap; eos::map_host (:85-103) is anonymous MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE + MADV_HUGEPAGE, a different job from map_fd (reader.rs:128-144, MAP_SHARED on an fd). Other /proc/self/fd uses in the tree are direct-I/O or path-only. The hand-rolled open_readonly_view (reader.rs:123-126, File::open = read-only + O_CLOEXEC) is therefore not a duplicate. The only cost: it introduces cfg(target_os = "linux") into a file that otherwise uses unix/windows (reader.rs:11,19,25,100,115,202,418,1268) — unavoidable, since /proc/self/fd is Linux-only and the non-Linux cfg(not(target_os = "linux")) arm keeps macOS building.

#16 [high] Report of 2026-11-29, run 2 (head 6fe7bed)

Review — PR #590 (helios, ignition: fix Engram reader bugs + PLE lookahead publish), lens: conventions & duplication (second pass, head 6fe7bed)

Verdict: should-fix only; nothing blocking.

Re-reviewed after the author's 6fe7bed update. Two findings from the previous report are resolved and must not be re-raised: the Windows lane collapse (windows.rs:9,89-95 now share lane_fanout, reader.rs:37-50) and the silent /proc/self/fd fallback (reader.rs:153-161,169-182 now carries reopen_error into the EPERM diagnostic). WaitBackoff is gone entirely (no grep hits in engram.rs). Detail: entry 12.

The PR is net de-duplicating: the two GraphKind filters (runtime_core/engram.rs:224,333) now use the expression that already existed at model.rs:480-481, and PreparedPLELookup.publish_lookahead follows the interface PreparedEngram.publish_lookahead established in #566 rather than inventing a new one. Positives and the full clean list: entry 15.

Should fix (1)

ignition/components/ngram_delivery.py:157-164 — PreparedPLELookup.publish_lookahead allocates two GPU tensors per call, unlike both of its precedents.

ids = torch.empty_like(self.ids)
requests = torch.empty(self.ids.shape[0], dtype=torch.int32, device=self.ids.device)

Both are write-only scratch the caller never observes (the op's mutates_args is ("ids","requests","mailbox")). The sibling in the same class, publish (:148-155), reuses self.requests prepared in __init__ (:122) and only allocates when functional() dropped it (:151-152). The Engram twin this method mirrors — PreparedEngram.publish_lookahead (ignition/components/engram.py:280-283) — likewise reuses prepared buffers through _hash_window(..., dest=self.hashes) (engram.py:241-271, buffers at :193-195). This is the only preparation-time hashing path in the repository that allocates its own scratch. Why it matters: AGENTS.md:417-419 "Do not introduce an eager serving fallback, runtime compilation, graph recapture, or GPU allocation in steady-state execution", and AGENTS.md:176-179 lists "steady-state GPU allocation" among the architectural violations a flag or optional path cannot bypass. The docstring (:158) says the path hashes "an upcoming prompt window", i.e. it is called whenever a lookahead is published, not once at export. Fix: hoist ids/requests beside self.ids/self.requests in __init__, keeping publish's existing None fallback (:151-152) for the functional() case. What would settle it: the companion Qwen3.8 recipe change (local-inference-lab/hyperflare-recipes#87, outside this repository) shows whether publish_lookahead is captured once or called per step. If it is only ever called during graph capture, this drops to a nit; the buffer-reuse argument stands either way because publish sets the pattern.

Nits (3)

  1. ignition/components/ngram_delivery.py:78-95 — _advisory_requests is _requests (:59-75) with two constexpr flags flipped, and departs from the Engram module's decomposition of shared hashing (_hash_window) from publication (publish_requests / publish_advisory_requests, engram.py:273-283). The kernels already take the flags (_copy_requests HAS_LIMIT :17-25, _publish HAS_COUNT :29-33), so only the Python wrapper and its fake stub are duplicated. AGENTS.md:188-193 cuts against demanding a split of _requests just to remove the copy; the cheap fix is one parameterized Python body, or renaming the new op so it does not read as a sibling of publish_advisory_requests (:47). Entry 13.

  2. helios/src/engram.rs:552-554 — warm_batch adds a fourth spelling of the staged-row bound. max_tokens.saturating_mul(table.heads) duplicates the checked_mul at :484-486 (which already produces CachedReader::max_rows, the value warm chunks by at reader.rs:1101) and the unchecked * at :663/:686; runtime_core/engram.rs:242-244 and engram/prepared.rs:228-230 compute the same product again. The .max(1) cannot fire (with_readers rejects max_tokens == 0 at :521; heads == 0 is rejected at prepared.rs:66-68). Fix: a Table::capacity_rows(max_tokens) -> Result<usize> beside the existing Table::staging_payload_bytes (:193-200), which is the established shape for per-table bounded geometry — or, minimally, a comment tying warm_batch to CachedReader::max_rows. Entry 14.

  3. helios/src/engram/reader.rs:1097-1156 vs :1017-1095 — CachedReader::warm now repeats gather's miss→disk→split-into-w/s tail (count * weights + index * scales appears in both). warm already duplicated gather before this PR; the chunk loop deepens the copy by ~40 lines. Defensible under AGENTS.md:192-193; flagged only because the duplicated miss_output indexing is where a future row-width change would desynchronize. Similarly Transfers::new (engram.rs:785-811) restates validate_mailbox's capacity arithmetic (runtime_core/engram.rs:287,303-322) in a second layer — the layers legitimately differ (declared shape vs mapped buffer byte length), so a one-line comment naming the twin is enough.

Coverage

All five changed files read at head 6fe7bed in their surrounding code, with callers followed: helios/src/engram/reader.rs (lane_fanout, ResidentMapping/map_fd, UnixLane/DiskReader::gather, CachedReader::gather/warm, Reader::warm/from_files, Resident::initialize/from_shared), helios/src/engram/reader/windows.rs (whole), helios/src/engram.rs (AdvisoryMailbox, Requests, Shared::new/with_readers/warm loop, Transfers::new/validate/enqueue, consumes, staging/prefetch budgets), helios/src/runtime_core/engram.rs (decode, validate_buffer, validate_mailbox, both graph filters, tests), ignition/components/ngram_delivery.py (whole) with ignition/components/engram.py:185-283, helios/src/runtime_core/model.rs:470-500,820-900,1028-1049, helios/src/engram/prepared.rs:56-297, eos/src/unix.rs (whole). Rules read: charter (read in full), AGENTS.md (whole). Precedents read: runtime_core/protobuf.rs:280-360, runtime_core/format.rs:340-410, execution/threaded.rs:50-100, tests/preparation/test_core_boundary.py.

#17 [high] Research summary

Re-reviewed PR #590 at head 6fe7bed through the conventions-and-duplication lens. Verdict: should-fix only, nothing blocking; full report is scratchpad entry 16.

Both findings from my previous pass are fixed and must not be re-raised. The Windows lane collapse is gone — helios/src/engram/reader/windows.rs:9,89-95 now calls the same shared lane_fanout (reader.rs:37-50) as the Unix path, so the divergent dispatch became one planner. The silent /proc/self/fd fallback is gone — reader.rs:153-161,169-182 captures the reopen error and folds it into the pre-6.7 EPERM diagnostic. WaitBackoff was dropped entirely.

The PR is net de-duplicating. The two GraphKind filters (runtime_core/engram.rs:224,333) now use the expression that already existed at model.rs:480-481, replacing two hard-coded five-kind lists with engram::consumes; and PreparedPLELookup.publish_lookahead copies the interface #566's PreparedEngram.publish_lookahead established rather than inventing one.

Remaining should-fix (1): ignition/components/ngram_delivery.py:157-164 — the new publish_lookahead does torch.empty_like(self.ids) + torch.empty(...) on every call, while its sibling publish (:148-155, buffer at :122) and the Engram precedent (engram.py:280-283 via _hash_window(..., dest=)) both reuse prepared buffers. AGENTS.md:417-419 and :176-179. Only the companion recipe PR can settle whether it runs per step or once at capture.

Nits (3): _advisory_requests (:78-95) duplicates _requests except for two constexpr flags the kernels already take, departing from the Engram hash/publish split; helios/src/engram.rs:552-554 adds a fourth spelling of max_tokens * heads (already at :484 checked, :663/:686 unchecked, plus runtime_core/engram.rs:242 and prepared.rs:228); and CachedReader::warm (reader.rs:1097-1156) repeats gather's miss→disk→split tail, with Transfers::new (engram.rs:785-811) restating validate_mailbox's capacity math in a second layer.

Among the changes I verified clean rather than flagging: the new /proc/self/fd reopen is not a duplicate of eos::direct_reopen (that adds O_DIRECT, unusable for mmap) and map_fd has no existing counterpart; the new MappedHost bounds check adopts the shape already used for the persistent-worker stop flag and metrics (runtime_core/protobuf.rs:314-322,347-355); and backward compatibility holds, since the new load-time rejections can only fire on a mailbox genuinely too short for max_tokens * heads, so no re-export of existing cores is required.

#18 [high] Report assembly note: entry 16 supersedes entry 11; drop entry 11's should-fix items

Guidance for the report writer, so nothing stale or duplicated lands in the final text.

Authoritative report body: entry #16 ("Report of 2026-11-29, run 2 (head 6fe7bed)"). Use it as the spine. Entry #11 is the previous run (head 9031847a) and is superseded — do not copy its key findings, its verdict paragraph, or its "Key findings" bullets; two of its findings no longer exist in the code.

Withdrawn findings (do not report):

Still-current support material:

Head reviewed: 6fe7bed ("helios,ignition: fix Engram reader bugs and add PLE lookahead publish", 2026-11-28). PR merged, 5 files, +464/−103. CI on head passed. No reviewer comments other than the Autobot review of 2026-11-28 23:27 and the author's reply of 2026-11-29 00:04 (both quoted in the task prompt; the author's reply enumerates exactly the fixes I re-verified).

#3 [medium] Nit: WaitBackoff is a third hand-rolled spin-then-park policy with no cross-reference to the other two

helios/src/engram.rs:325-377 adds a third hand-rolled spin-then-park policy in helios:

  1. WaitBackoff (new, :354-377): 4096 spin_loop() rounds, then thread::sleep(25us * n).min(250us); Windows spins.
  2. server/runtime.rs:1176-1182: if !executor.park() { spin_loop() } thread::yield_now().
  3. execution/threaded.rs:65-88 spin_wait_until: 32 fast spins, then spin until HANDOFF_POLL (500us, threaded.rs:24), then yield_now; receive (:34-59) is the same shape.
  4. runtime_core/persistent_worker.rs:26-29,507-512: WORKER_DRAIN_SPIN_POLLS = 64 then WORKER_DRAIN_POLL_INTERVAL = 1ms.

Note the PR did not introduce the first version of this: #519 (open, PR by peperunas) added SPIN_ROUNDS/NAP_GROWTH/NAP_MAX/yield_core at helios/src/engram.rs with exactly these constants, and this PR adopts that code (and, per the PR body, fixes #519's rebase defect). So the duplication is inherited, not invented here — but this PR is where it lands on main, and it lands as a third policy with no stated relation to the other three.

Observed, verifiable deltas from precedent: the neighbours park with yield_now() (no timer) or a wall-clock-bounded poll; this one uses thread::sleep, so the wait is subject to Linux timer slack on the 25-75us rungs (the ramp only reaches NAP_MAX after ~10 rounds), while spin_wait_until documents its reason for each rung (threaded.rs:66, :82-86). WaitBackoff::step also has no elapsed-time bound at all, so a caller that keeps getting WaitReady sleeps forever with no diagnostic and no metric.

Where the reviewer should point: NAP_MAX's doc (:330-331) asserts "under one decode step" — an invariant nothing enforces and nothing measures (see #519's review round: flare_replay_readiness_wait_nanoseconds_total is the counter that would show the cost). Docs: docs/runtime-core-design.md is the place a shared wait policy would be stated; no design doc names a wait policy today.

Recommendation (nit/should-fix depending on owner appetite): either reuse threaded::spin_wait_until-style bounded poll, or state in one place (a doc comment on WaitBackoff) why Enram's reader uses sleep rather than the two existing mechanisms, and reference the other two so a future reader is not left reconciling four policies.

#5 [medium] Note (positive): the GraphKind filter change correctly adopts the existing model.rs:480 precedent

Two distinct points, both verified in the code.

(a) The GraphKind::try_from(...).is_ok_and(crate::engram::consumes) filter is the right de-duplication — and it is now the shared pattern. Before: helios/src/runtime_core/engram.rs:221-231 and :327-331 each hard-coded matches!(g.kind.as_str(), "prefill" | "terminal_prefill" | "decode" | "speculative" | "mixed"). After: both sites use the same two-line expression (:224, :333), and crate::engram::consumes (helios/src/engram.rs:1011-1021) has a third caller in runtime_core/model.rs:480-481 which already used this exact expression before the PR. So the PR brings runtime_core/engram.rs into line with the existing precedent at model.rs:480 — that is correct and should be recorded as a positive, not a finding.

Note for the other reviewers: the try_from half is not dead. Unknown kinds are rejected earlier when the manifest is decoded (GraphKind::try_from(...).unwrap() at runtime_core/protobuf.rs:886, :909, selection.rs:216), so the is_ok_and cannot fail here in practice; it exists only because consumes takes a typed GraphKind. A tiny alternative would be consumes over &str to drop the redundant parse, but that would move away from model.rs:480's precedent, so keeping it is right.

(b) One remaining hard-coded kind list in the same file, which the PR left alone. Not a finding against this PR (it is pre-existing and outside the diff), recorded only so the reviewers do not re-flag it as newly missed: helios/src/runtime_core/selection.rs:318 still has matches!(g.kind.as_str(), "init" | "restore" | "snapshot" | "resume"). That is a different set (lifecycle kinds, not Engram consumers), so it is correct that it was not folded into consumes.

#6 [medium] Note: reader.rs /proc/self/fd reopen has no reusable precedent; one silent fallback (ok()) drops the cause

Three helpers were introduced inside ResidentMapping::new (helios/src/engram/reader.rs:106-177) for the pre-6.7 EPERM fix. Checked each against the closest existing mechanism:

Would have been a duplicate, and is not: the PR description says the read-only reopen uses O_RDONLY | O_CLOEXEC. The shipped code (open_readonly_view, reader.rs:108-111) is File::open(format!("/proc/self/fd/{fd}")) — std's File::open sets O_CLOEXEC by default and read-only, so the flags named in the description are what the code actually does; the description just does not match the source text. Not a defect, but worth telling the author: a reviewer reading only the description will look for OpenOptions::custom_flags.

Precedent that exists and was not reused: eos/src/unix.rs:60-65 already exposes direct_reopen(file) — literally direct_file(&format!("/proc/self/fd/{fd}"), false). It is not reusable here: it adds O_DIRECT, and an O_DIRECT descriptor cannot back a mmap. So the PR correctly hand-rolls the reopen. Recorded so the next reviewer does not ask for it. Related pre-existing duplicates of the /proc/self/fd reopen idiom (eos/src/unix.rs:62, heliopause/src/export/archive.rs:350, heliopause/src/export/io.rs:777, helios/src/runtime_core/archive.rs:566,666, helios/src/core/container.rs:730) are all direct-I/O or path-only uses; none is an mmap-capable plain reopen.

Silent fallback: reader.rs:139-143 let readonly_view = if !writable { Self::open_readonly_view(file).ok() } else { None }; — the .ok() discards the reason the reopen failed and falls back to the writable fd, i.e. straight back into the pre-6.7 EPERM. AGENTS.md:185 forbids "suppress errors" and "silently substitute execution paths". The kernel-version hint on the EPERM path (:151-159) partly compensates by naming /proc/self/fd, but it cannot say why the reopen failed (e.g. procfs not mounted, fd closed, permission). This is the one place in the fix where an error is dropped. Severity: nit — procfs is effectively always present on a Linux box that mounts the NVMe core, and the fallback is the pre-PR behaviour, so nothing regresses; but .map_err(|e| format!("reopen resident embedding table read-only: {e}")) carried into the hint string would cost one line and keep the cause.

map_fd helper (:113-129) vs crate::os::map_host (eos/src/unix.rs:85-103): different jobs (MAP_SHARED on an fd vs MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE anonymous plus MADV_HUGEPAGE), so no duplication. eos has no shared mmap-a-file helper, so this helper has no precedent to reuse. Fine as written. Also cfg(target_os = "linux") is used rather than the file's own #[cfg(unix)] convention (reader.rs:19, 100, 179, 186, 395) — correct, because /proc/self/fd is Linux-only and the fallback keeps macOS building, but it does introduce a second cfg vocabulary in a file that used only unix/windows. Nit at most.

#7 [medium] Nit: CachedReader::warm now copies gather's body; Transfers::new restates validate_mailbox's capacity math

Two duplicated bodies inside one PR, both checkable from the code:

1. warm was un-chunked; gather was already chunk-free but bounded. After the change (helios/src/engram/reader.rs:1081-1140) CachedReader::warm is a chunk loop whose body is a near-verbatim copy of CachedReader::gather (:1001-1079):

The only real differences are insert_advisory vs insert, "copy into output" vs nothing, and the new prefetch_rows_loaded bump. That is a lot of repeated index arithmetic (count * weights + index * scales appears in both) for two functions that must stay in agreement about the workspace layout. Not newly wrong — warm already duplicated gather before this PR — but the PR deepens the copy by ~40 lines instead of factoring the shared "miss → disk gather → split into w/s" tail into one helper taking a closure for the insert. Given AGENTS.md:192-193 ("Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost"), it is defensible either way; flagging as a nit because the duplicated miss_output indexing is where a future width change would desynchronize.

2. Transfers::new mailbox capacity checks (:843-882) restate validate_mailbox (runtime_core/engram.rs:272-301). The PR adds required-bytes checks at load time for the request mailbox (:848-857) and prefetch mailbox (:866-874) that mirror, in a second place and with different arithmetic, runtime_core/engram.rs:287 mailbox.shape[0].checked_mul(8) != Some(mailbox.nbytes) and :303-311/:313-322 min_request_len = max_staged_rows + 1 / max_prefetch_len = max_staged_rows + 2.

The two disagree in scope on purpose (runtime_core validates the declared shape against the max staged rows across all cores; engram.rs validates the mapped buffer's byte length against max_tokens * heads computed from the shared index), and Transfers::new is the layer that actually has the address, so having a check there is right and closes a real gap (address + nbytes - 8 on an undersized mailbox). Recording it as a nit only: if the two ever drift, the symptom is a startup error whose message points at the wrong layer ("smaller than staged capacity" vs "invalid mapped n-gram request mailbox"). A one-line comment in Transfers::new naming the runtime_core check as its twin would remove the cost.

Checked and found consistent: prefetch_queue_bytes (engram.rs:212-224) budgets cap * 8 per table; max_prefetch_len is max_staged_rows + 2 and cap = len - 2, while warm now chunks by max_rows so the queue no longer needs to hold a whole warmed step — the description's "silently dropping tail rows" defect is genuinely fixed for the queue too, not just the disk read. prefetch_rows_loaded moved from Reader::warm (reader.rs:1295-1303, removed) into CachedReader::warm (:1133-1136) per chunk, so the counter still counts rows and the metric name in docs/cli-design.md:816 and helios/README.md:671 stays accurate.

#14 [medium] Nit: warm_batch adds a fourth spelling of the staged-row bound (max_tokens * heads)

The new line helios/src/engram.rs:552-554 computes the table's staged row capacity as WARM_BATCH_ROWS.min(max_tokens.saturating_mul(table.heads)).max(1). That same quantity, max_tokens * table.heads, is already computed three other ways in the same file and once more nearby:

So one PR adds a fourth spelling (saturating + .max(1)) of a bound the codebase already derives with checked_mul (twice) and plain * (twice). The .max(1) is also unreachable in practice: with_readers rejects max_tokens == 0 at engram.rs:521 and Table::index rejects heads == 0 (prepared.rs:66-68), while runtime_core already errors when max_staged_rows overflows (:242-244) — so the saturating fallback cannot be exercised except by a caller that bypassed both.

Severity: nit. Not wrong — saturating is strictly safer than the plain * at :663/:686 — but this lens asks for one precedent, and a Table::capacity_rows(max_tokens) -> Result<usize> (mirroring the existing Table::staging_payload_bytes, engram.rs:193-200, which is the established shape for exactly this kind of per-table bounded geometry) would let Shared::new, warm_batch, validate_start, and start share one definition. If the author keeps it inline, a comment tying warm_batch to CachedReader::max_rows (the chunk bound it must not exceed) would make the coupling visible: the two must agree or warm re-chunks and the advisory warming does redundant disk reads.

#4 [low] Nit: _advisory_requests duplicates _requests and sits beside the already-named publish_advisory_requests

Two separate things share the name and neither references the other:

  1. ignition/components/ngram_delivery.py:47 — @torch.library.custom_op("flare::publish_advisory_embedding_requests") / fn publish_advisory_requests, which publishes already-hashed ids to an advisory mailbox. Called from engram.py:283 (PreparedEngram.publish_lookahead).
  2. ignition/components/ngram_delivery.py:78 — NEW @torch.library.custom_op("flare::ple_advisory_requests") / fn _advisory_requests (leading underscore, unlike its siblings publish_requests :37 and publish_advisory_requests :48), which hashes and then publishes.

Naming: the existing precedent for "hash + publish" is flare::ple_requests/_requests (:59-75) — private, underscore, PLE-specific; the new op correctly mirrors that. The existing precedent for "publish to an advisory mailbox" is the public publish_advisory_requests. The new name _advisory_requests is neither: dropping "publish" and "embedding" makes it read like the advisory sibling of _requests, which it is, but it collides conceptually with publish_advisory_requests two definitions above, and the two ops differ only in whether hashing happens first.

Duplication inside the new op: _advisory_requests (:84-89) is _requests (:65-69) with the two lines _copy_requests[...](ids, mailbox, mailbox, n, 256, False) → (ids, live_rows, mailbox, n, 256, True) _publish[...](mailbox, mailbox, sequence, ..., False) → (mailbox, live_rows, sequence, ..., True) swapped for their HAS_LIMIT/HAS_COUNT=True variants. The kernel bodies already take the flag as tl.constexpr (_copy_requests :18-25, _publish :29-33), so one custom op with a live_rows: Optional[Tensor] (or a bool constexpr argument) would cover both without a duplicated op + duplicated fake registration + duplicated wrapper.

Severity: nit. Not a defect; booking it because the lens asks whether existing helpers were reused. Whether it matters depends on whether anything other than publish_lookahead will ever call the PLE advisory op — if it is one call site, the two-op split is cheap and the names are the real cost.

#8 [low] Note: remaining checks came back clean (test conventions, helpers, doc style)

Verified in the code, recorded so the summary is honest about coverage rather than implying no checks were made.

Nothing blocking found in my lens beyond the Windows twin (entry 1). The PR for the most part reduces duplication (the GraphKind filter) and adds an abstraction that has an exact precedent (publish_lookahead on PreparedEngram) — its defect is which buffers it allocates, not that it invents a new interface.

#13 [low] Nit (reframed): _advisory_requests duplicates _requests' wrapper and departs from the Engram hash/publish split

ngram_delivery.py:78-95 adds flare::ple_advisory_requests (_advisory_requests), whose body is _requests (:59-75) with the two Triton constexpr flags flipped: _copy_requests(..., HAS_LIMIT=True) at :88 vs False at :68, and _publish(..., HAS_COUNT=True) at :89 vs False at :69. The kernels already take those flags (_copy_requests :17-25, _publish :29-33), so no kernel duplication — the duplication is one whole custom op, its signature (live_rows vs mailbox passed twice), and its register_fake stub (:92-95).

The precedent it departs from is in this same module/PR series: PreparedEngram decomposes hashing from publication — _hash_window (ignition/components/engram.py:241-271) is shared, and publication is a separate mailbox-level op, publish_requests (ngram_delivery.py:36-39) or publish_advisory_requests (:47-51), chosen at the call site (engram.py:273-283). The PLE path instead has two full hash+copy+publish ops, named flare::ple_requests and flare::ple_advisory_requests — an "advisory" adjective on the hashing op rather than a separate publish op, and it sits directly beside publish_advisory_requests (:47), so "advisory requests" now names two different layers.

Severity: nit, not should-fix. AGENTS.md:188-193 ("Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost") argues against demanding that the existing _requests be split into hash + publish ops just to remove this copy; the two-op shape also keeps each captured op's mutates_args exact. Suggested cheap fix if the author wants it: have _advisory_requests and _requests share one Python body parameterized by live_rows=None, or at minimum rename the new op so it does not read as a sibling of publish_advisory_requests.