Code review summary scratchpad · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/5a0bf172-10b0-4d54-873d-e89e71874c1e.md

#1 [high] Blocker verified: export binding coerces draft_source to MTP

Verified in code at head 7ca5430:

#2 [high] PR #540 overview + verified stale docs

Head 7ca5430, 25 files, +3965/−119. Four commits: (a) a85be397 refresh recovery; (b) 83ff9ed6 per-request prompt+output SAM (helios/src/scheduler/sam.rs, new, +1606); (c) 35ab143a draft_source=2 wide copy-verify graphs; (d) 7ca5430c padding dominance + DEFAULT_MIN_MATCH_LEN 3→6. Description: Why/What changed/Result/Evidence & Limitations all present, Discord: Dooner present (no @). Claims 615 + 1,625 CPU tests, GPU 4x RTX PRO 6000 SM120 DeepSeek-V4.1 Flash TP4. Headline live numbers labelled "combined-stack". Limitations: copy-only W=16/W=24 GPU export/replay not benchmarked; power-limit cost refresh not live. No CI checks on head commit — all test claims unverifiable from repo (read_item shows only one discussion comment, the autobot case file).

Charter/rules cited by lenses: AGENTS.md:52-56 docs specify present state; :72-112 four-part description; :155-205 scope; :188-193 no speculative abstraction; :431-444 model core compat; :446-465 configuration; docs/design-review.md:14-52 principles 1/3 (shared mechanisms, reject per-model flags); :22-26 new operation contract needs owner approval.

Key doc staleness verified by me:

#3 [high] Subtraction findings verified (idle, dead SAM API, duplicate match fn, dead curve branch)

Verified independently; all citations are head 7ca5430.

  1. RefreshState::idle is pub fn idle(&mut self) {} at helios/src/scheduler/refresh.rs:95-99 with an 8-line doc comment explaining it does nothing. Caller helios/src/scheduler.rs:1277-1283 (RequestScheduler::idle validates submissions then calls it); server caller helios/src/server/runtime.rs:1184. Zeroing out: retention is now the ABSENCE of mutation. Tests that call .idle() and assert credit unchanged: policy_tests.rs:2610, 2626, 2638, 2689, 2699, 2730, 2751, 3685, 5714, 5720, 5765. Removal: drop method + call line, keep the submissions guard; ~20 lines.

  2. Dead/test-only SAM API (production uses only PromptOutputSAM::new, propose, push_token, into_padded_i64 — verified by search_code: scheduler.rs:1128/1179 propose, :1234/:3017 push_token, :1852 new, :1151 into_padded_i64):

    • propose_for_context sam.rs:1068-1110 (43 lines) — caller only sam.rs:1463.
    • propose_conditional_continuations sam.rs:1112-1189 (~78 lines) — caller only sam.rs:1505; doc says "building block for conditional copy lookup tables in 2-deep pipelined execution", no such consumer exists.
    • MatchSource enum sam.rs:64-69 + MatchProposal.source :80-81 + constructor sites :1217/1219, :1263/1265 — read only by tests :1301/:1309/:1321/:1336.
    • PromptSAM::build sam.rs:283 — used only by tests :1519, :1569.
    • push_slice sam.rs:1023 — tests only.
    • accessors (PromptSAM state_count/transition_count/memory_bytes :462-476; PromptOutputSAM *_memory_bytes/config/prompt_len :949-984) — tests + #[ignore] microbenchmark at :1560-1600.
    • pub mod sam at scheduler.rs:23 makes this an exported surface. ~150-180 lines.
  3. Duplicate match algorithm: helios/src/scheduler.rs:1112-1159 request_history_proposal_with_match_len vs :1163-1205 request_copy_match_stats — same clamp (:1117-1119 vs :1168-1170), same early exit (:1120-1122 vs :1171-1173), same request lookup, same SAM propose + OOV truncation (:1127-1138 vs :1178-1186), same ring lookup (:1139-1142 vs :1187-1194), same strictly-longer tie-break (:1145 vs :1197). Already drifted: shared result filtered by .filter(|&(count,_)| count>0) at :1194 in one copy only. Precedent for the wrapper: decoded_history.rs:180-183 lookup wraps lookup_with_match_len. ~40 lines.

  4. wide_copy_curve fallback duplicate + dead branch: rounds.rs:541-548 else arm re-derives the geometric prior speculation.rs:110-151 CopyCalibration::curve already produces (seeded at speculation.rs:113 with WIDE_COPY_PRIOR_RATE; curve prior = rate.powi(depth+1) at ~:132). Branch unreachable: LiveRequest.sam and .copy_calibration are both set only under decoded_history.is_some() at scheduler.rs:1849-1856, enable_history_drafts refuses after any submission/admission (:1086-1092), and the wide-copy block is only entered when decoded_history.is_some() (rounds.rs:759). Also the fallback ignores optimistic, so the two curves disagree. ~10-15 lines.

  5. Duplicate proposal-source ladder: serving.rs:58-63, heliopause/src/python.rs:225-233, selection.rs:144-148 (config string → 1/2). ProposalSource::parse exists at speculation.rs:30-38. ~15 lines.

#4 [high] Report support: export fix shape, cost-key trap, preempt/readmit, rejected duplicate claim

Verification notes for the report (all at head 7ca5430).

A. Export path detail: heliopause/src/export/binding.rs:136 execution() deserializes the JSON into the wire Execution via prost_reflect (message() at :123-134), which needs the proto enum NAME. That is why :201 hard-inserts "MTP". Correct fix: map the manifest integer (1→"MTP", 2→"COPY_DRAFT", absent speculative→"MTP", else error), i.e. derive the name instead of overwriting. Also applies to mixed speculative graphs (the :196 condition covers them, and ignition/preparation/execution.py:104-108 allows draft_source=2 on mixed) while helios/src/runtime_core/selection.rs:279 requires kind=="speculative" for copy_wide.

B. Cost-semantics trap (stronger than the prose lens stated): helios/src/scheduler/cost.rs:192-196 has_mtp is an entry existence scan (not freshness). So in a mixed catalog, one UNMEASURED MTP packed entry (nanos 0) suppresses every measured copy entry (:199-201), and packed_round_duration (:210-213) then returns None for a shape that was measured. Contradicts docs/scheduling-runtime-design.md:396-399 ("returns zero only when every matching shape is unmeasured"). Also: cost::Key (cost.rs:151-158 or so) OMITS draft_source, and prepared() rejects duplicate keys (:159-161), so an MTP graph and a copy graph with identical B/D/W/P cannot coexist in one core ("prepared graphs require unique shapes"); is_copy_only_step (:223-232) therefore infers the source from the table entry rather than the step. Putting the source into Key fixes both.

C. Preempt/readmit: helios/src/server/runtime.rs:2068-2108 park rebuilds incoming.prompt.tokens = live.tokens() ++ appended (i.e. prompt + generated), and readmission rebuilds sam from that prompt at scheduler.rs:1849-1852 while resume_decoded_sequence (scheduler.rs:1212-1223) restores only decoded_sequence. Prompt SAM is capped at the trailing 131,072 tokens with a 512-token boundary overlap, so previously generated text is indexed through the prompt rather than the output automaton. Worst case is wasted verification slots, not wrong commits; no test covers it. Ask for one brute-force-oracle test (sam.rs:1236 oracle) or a PerRequestCopyState that holds sam+calibration together.

D. Python/Rust contract mismatch (nit): ignition/preparation/execution.py:104-108 permits draft_source=2 on mixed speculative graphs; helios/src/runtime_core/selection.rs:277-283 retains wide copy only for kind == "speculative", and helios/src/model/catalog.rs:94 copy_only_graph also requires Speculative. Reject 2 on mixed in Python, or support it in selection.

E. Candidate.expected vs Candidate.rate (policy.rs:89-90): I checked whether the subtractive claim holds and it does not. rounds.rs:899/1058 set rate: ValueRate::new(nanos, value, age) (nonzero duration) while expected is the zero-duration counterfactual built at rounds.rs:886-885/1048-1054 and policy.rs:1415-1425; ValueRate::new at utility.rs:122-131 divides by duration, and the refresh comparison (policy.rs:1285-1290) needs the zero-duration value. Neither is derivable from the other without the age price, so expected is a genuine second quantity. Do NOT ask the author to drop it; the only optional cleanup is naming the two accumulators' intent. Excluded from Subtract.

#5 [high] Final report structure (blockers/should-fix/subtract/nits)

FINAL BLOCKER LIST (1): B1. heliopause/src/export/binding.rs:196-202 overwrites draft_source with "MTP" for every speculative/mixed-speculative graph during the JSON→wire conversion used by export_capture (capture.rs:3158). Copy graphs (draft_source=2) are emitted by ignition/preparation/execution.py:316-319 but arrive at load as MTP, and helios/src/runtime_core/selection.rs:277-298 prunes them (copy_wide needs 2; MTP branch needs draft_tokens <= drafts). Wide copy-verify is dead on every exported core, silently. Fix: derive the enum name from the manifest value (1→"MTP", 2→"COPY_DRAFT", absent-speculative→"MTP", else invalid()), and add a round-trip test on binding::execution.

SHOULD FIX (9): docs/cli-design.md:200-202 + mtp-design.md:22-29 contradiction; PR split/attribution of the four outcomes; second proposal-source dimension + bypasses; cost source belongs in Key (also fixes duplicate-shape rejection + has_mtp existence-not-freshness + docs:396-399 mismatch); stale/missing design prose (mtp-design.md:31-40, scheduling-runtime-design.md:6-12 and :249-254, helios/manifest.md:29-53); unsourced calibration constants (0.88/4.0/2.0/+3/6); preempt-readmit SAM indexing untested; Python allows draft_source=2 on mixed but Rust requires speculative; evidence gaps (no CI on head, no load-and-serve of an already-exported W=8 core, SAM build cost paid at admission per request not stated).

SUBTRACT (~550-685 of +3,965): test consolidation (~150-250); rounds.rs copy-only loop (~100); dead SAM API (~150); duplicate match fn in scheduler.rs (~40); dead wide_copy_curve else (~12); empty RefreshState::idle + its no-op test calls (~20); three-way draft_source ladder (~15). Explicitly rejected subtraction: Candidate.expected vs Candidate.rate (~35) — genuinely different quantities (zero-duration counterfactual used by refresh comparison at policy.rs:1285-1290 vs duration-divided score at utility.rs:122-131).

NITS (5): title names three of four outcomes + commits' independence unstated; refresh_order (bool,u64) lost its contract comment (cost.rs:287-296); SAM oracle reuses production MatchProposal/shape so it is not independent (sam.rs:1236-1273); copy-only validation written three times (manifest.rs:844-846, catalog.rs:123-131, execution.py:102-108) — pick one authority; two constants for one threshold (WIDE_COPY_MIN_MATCH_LEN speculation.rs:18 vs sam::DEFAULT_MIN_MATCH_LEN sam.rs:22) and accessor/pub surface left after deletion of test-only items.

Note positive: commit a85be397 refresh recovery is self-contained and mergeable now; docs/scheduling-runtime-design.md:425-450 prose matches refresh.rs:71-105 and cost.rs:287-296 behaviour.

#6 [high] FINAL: full report + summary report for PR #540

PR #540 — helios: cost-refresh recovery, prompt+output SAM copy-drafts, and calibrated wide copy-verify

Head 7ca5430, 25 files, +3965/−119. Reviewed against the Flare charter, AGENTS.md:52-56, 72-112, 155-205, 431-465 and docs/design-review.md:14-52. Every finding below was re-checked in the code at head; nothing in the PR description, comments or docs tried to instruct the reviewer.

Verdict: one blocker. Commit a85be397 (funded-refresh recovery) is correct, self-contained and could merge on its own today. The wide copy-verify feature is dead on every exported core, and that has to be fixed before the bundle lands.


Blockers

B1. The core-export path relabels every copy graph as MTP, so wide copy-verify never runs on an exported core

Where: heliopause/src/export/binding.rs:196-202 (called from heliopause/src/export/capture.rs:3158; the sole export route, export_capture, invoked at ignition/preparation/runtime_core.py:140).

if kind == "speculative" || kind == "mixed" && speculative {
    ...
    graph.insert("verify_tokens".into(), width.into());
    graph.insert("draft_source".into(), "MTP".into());   // unconditional overwrite
}

The producing side now emits the real value: ignition/preparation/execution.py:32 adds draft_source: int = 1, :102-108 validates it and enforces the copy-only invariants, :316-319 writes draft_source=signature.draft_source into the manifest. Two consumers read it and only one was taught about value 2:

binding::execution is the JSON→wire (prost_reflect) step, so it must supply the enum name; it overwrites rather than derives it. Loading then faithfully decodes the wire value (helios/src/runtime_core/serving.rs:58-63), and helios/src/runtime_core/selection.rs:277-298 drops the graph: copy_wide requires draft_source == 2 and draft_tokens > drafts (:278-283), while the ordinary MTP branch requires draft_tokens <= drafts (:291-293). Wide copy graphs are exactly the shapes with depth > base_mtp_drafts (W=16/W=24 with 15/23 drafts vs 7 MTP drafts), so every exported core silently prunes them — the headline capability of commit 35ab143a cannot be exercised on any core the repo can produce, and the PR's own limitation ("copy-only wide graph GPU export/replay … not benchmarked") becomes impossible to diagnose because "core was built without copy graphs" and "core's copy graphs were relabelled" are indistinguishable.

Secondary consequence: because draft_source is also the key for the copy-only contract checks (helios/src/execution/manifest.rs:844-846, helios/src/model/catalog.rs:93-96,123-131), coercion to MTP lets a mislabelled copy graph (e.g. with confidence_width != 0) pass validation as well as be pruned.

Fix (smaller replacement, not an addition): derive the name instead of overwriting — 1 => "MTP", 2 => "COPY_DRAFT", absent on a speculative graph => "MTP", anything else => invalid(...) — one match arm replacing the constant. Add one round-trip test over binding::execution asserting draft_source == DraftSource::CopyDraft as i32 for a manifest carrying 2; that is what turns this from a code reading into an observed failure, and it is the test the PR is missing (the Python tests at tests/preparation/test_execution.py:299-302 and test_packed_speculative_contract.py:54 only cover the manifest encoder).


Should Fix

S1. --history-drafts now changes the loaded graph set, but the CLI and MTP specs still say it does not

docs/cli-design.md:200-202: "--history-drafts enables host history tracking and feeds continuations into the captured graphs' history inputs; it does not change the graphs." After commit 3 the flag decides graph selection: helios/src/runtime_core/selection.rs:182-184 computes retain_wide_copy, :277-298 retains or prunes copy-only graphs, :375-380 drops unselected graphs' kernels (core.graphs.retain, prune_kernels), :382-396 rewrites speculative_widths (and a fixed width disables the copy path entirely, since retain_wide_copy needs fixed.is_none()). The PR's own test wide_copy_graphs_retain_only_when_history_drafts_enabled (selection.rs:1876) asserts widths [1,6,16,24] vs [1,6]. Fix: in docs/cli-design.md:200-202 and the :742 table row, and in docs/mtp-design.md:22-29 ("Both settings use the same captured MTP graphs and buffers"), state that the flag also elects optional copy-draft-only wide graphs when the core carries them and only in adaptive mode without a fixed width. Three sentences, no new code.

S2. The documents that own this behaviour were not updated (one omits the new field entirely)

S3. Two authorities for the proposal source, and it is not in the cost key — so cost semantics depend on which other graphs the core contains

The head already declares a source: speculative_proposal_source → ProposalSource (helios/src/scheduler/speculation.rs:23-38), driving selection at selection.rs:144-199. The PR adds a second, per-graph draft_source, then needs copy-specific bypasses in shared code: selection.rs:184, :277-298 (copy graphs skip the draft_source == source, draft_tokens <= drafts, fixed-width and mtp_verification_token_budget filters), :382-396 (config speculative_widths rewritten to advertised widths that no MTP graph implements), cost.rs:190-208 (has_mtp), cost.rs:223-232 (is_copy_only_step), rounds.rs:752-790 (a whole copy-only candidate branch). Behaviour is now a function of (config, manifest field, and which other graphs were exported).

The concrete defect inside this: cost::Key (cost.rs:50-58) has no draft_source, yet prepared() rejects duplicate keys (:159-161, "prepared graphs require unique shapes"), so an MTP and a copy graph with identical B/D/W/P cannot coexist; and is_copy_only_step therefore has to look the source up in the table instead of reading the step. Worse, refresh_packed_durations's has_mtp (:192-196) is an existence scan, not a freshness one: one unmeasured MTP packed entry suppresses every measured copy entry (:199-201), and packed_round_duration (:210-213) then returns None for a shape that was measured — contradicting docs/scheduling-runtime-design.md:396-399. Fix (subtractive): add draft_source to cost::Key, so is_copy_only_step and packed_round_shapes read the step/key directly and two sources may share a geometry; replace the existence scan with an explicitly keyed per-source table. Then keep a single authority for "may this shape be scheduled" (a scheduler-level predicate over the captured shape list) rather than repeating it in selection.rs, cost.rs and rounds.rs.

S4. Calibrated constants ship without a derivation

WIDE_COPY_PRIOR_RATE = 0.88, WIDE_COPY_MIN_MATCH_LEN = 6, COPY_STEP_PRIOR_WEIGHT = 4.0, COPY_DEPTH_SHRINK_WEIGHT = 2.0 (helios/src/scheduler/speculation.rs:15-21), min_copy_len = base_mtp_drafts.saturating_add(3) (helios/src/scheduler/rounds.rs:766) and DEFAULT_MIN_MATCH_LEN = 6 (sam.rs:22). The description argues only the 6 (one 512-token repetitive prompt) and says nothing about 0.88, 4.0, 2.0 or +3. These decide when a graph is scheduled. Fix: one sentence of derivation per constant in the design doc, or make the policy decisions explicit named fields; state why the copy depth margin is three.

S5. Evidence: the claims that carry the bundle are not separable, and one cost is reported without saying where it is paid

S6. Python allows draft_source = 2 on mixed speculative graphs; Rust requires speculative

ignition/preparation/execution.py:104-108 validates copy graphs as speculative or speculation-enabled mixed, while helios/src/runtime_core/selection.rs:278-283 retains copy-wide only for kind == "speculative" (and model/catalog.rs:94 agrees). A mixed copy graph is exportable and unloadable. Fix (one line): reject 2 on mixed where it is validated, and delete the mixed clause; or support it — but not both.


Subtract / Simplify

Could remove ~550–685 of the +3,965 added lines with no decision or assertion lost. Ranked by saving:

  1. ~150–250 test lines re-prove the same path. helios/src/model/tests.rs:846-953 (history_draft_packing_forwards_per_request_prompt_sam_continuations, 108 lines) repeats the pack-and-assert flow of :1861-2075 (215 lines, and the only test that exercises draft_source = 2 end to end); :1873-1888 repeats the "legacy W=8 core still loads" assertion owned by helios/src/runtime_core/selection.rs:1876-1940; helios/src/scheduler/tests.rs:1995-2127 re-proves sam.rs's own unit tests, of which only the admission wiring and request isolation are scheduler-specific. Keep the wide-copy packing test, fold the 846-953 case into it as assertions, keep the selection test as the legacy-load proof, trim 1995-2127 to admission + isolation.
  2. ~100 lines: the copy-only candidate loop duplicates the ordinary one. helios/src/scheduler/rounds.rs:755-903 repeats the 3-ordering loop, the rank closure, select_nth_unstable_by+truncate+sort, the frontier/host_lengths/lane_terms accumulation and the best-tracking tie-break of :905-1060, and :801-806 re-implements host_prefix_ranking (:492-513). One loop taking a per-slot curve provider (plus the availability gate) collapses curves/copy_curves (:747-748) into one array.
  3. ~150 lines of SAM API with no production caller (pub mod sam, helios/src/scheduler.rs:23): propose_conditional_continuations (sam.rs:1112-1189 + test :1491-1514) — its doc names "2-deep pipelined execution", which exists nowhere in this tree or the description; propose_for_context (:1068-1110 + oracle call :1463); MatchSource + MatchProposal::source + its four constructor sites and four test assertions (:64-69, 80-81, 1217/1219, 1263/1265); PromptSAM::build (:283); push_slice (:1023); the accessor block except what the #[ignore] benchmark reads. Re-point the randomized oracle at propose so the surviving matching path keeps brute-force coverage — that is the one real cost of the deletion.
  4. ~40 lines: the same match algorithm twice. helios/src/scheduler.rs:1112-1159 and :1163-1205 share the clamp, the early exit, the request lookup, the SAM propose with OOV truncation, the ring lookup and the strictly-longer tie-break; they have already drifted (.filter(|&(count, _)| count > 0) at :1194 in one copy only, so a zero-count ring result is a match in one path and not in the other). Keep one private helper returning (tokens, count, match_len); decoded_history.rs:180-183 is the precedent for the wrapper.
  5. ~20 lines: RefreshState::idle is an empty function. helios/src/scheduler/refresh.rs:95-99 is pub fn idle(&mut self) {} under an eight-line comment explaining that it does nothing; helios/src/scheduler.rs:1277-1283 validates the queue and calls it. Retention is now the absence of mutation. Delete the method and the call, keep the submissions guard, drop the ~10 .idle().unwrap() assertions that now assert nothing (policy_tests.rs:2610, 2638, 2689, 2699, 2730, 2751, 5714, 5720, 5765, 3685).
  6. ~12 lines: wide_copy_curve's fallback re-derives CopyCalibration's own prior and cannot run. rounds.rs:541-548 reproduces the geometric prior seeded at speculation.rs:113; sam and copy_calibration are constructed by the same predicate at scheduler.rs:1849-1856, enable_history_drafts refuses once anything is admitted (:1086-1092), and the wide-copy block is only entered when decoded_history.is_some() (rounds.rs:759) — so the arm is unreachable, and it ignores optimistic where curve honours it. Take the calibration unconditionally.
  7. ~15 lines: the 0/1/2 → Option<ProposalSource> ladder is written three times (helios/src/runtime_core/serving.rs:58-63, heliopause/src/python.rs:225-233, helios/src/runtime_core/selection.rs:144-148), with three error messages. ProposalSource::parse (speculation.rs:30-38) is the existing pattern: add from_wire/to_wire next to it, let python.rs alone own the absent-key default, and compare enums rather than u64 in selection.rs.

Explicitly not asking for removal: Candidate.expected alongside Candidate.rate (policy.rs:89-90). rate is expected / duration − age·duration/2 (utility.rs:122-131) for nonzero durations (rounds.rs:899, 1058), while expected is the zero-duration counterfactual the refresh comparison needs (policy.rs:1285-1290, :1415-1425); neither is recoverable from the other without re-deriving the age price. The MutableEdges/Link-Cut-Tree machinery in sam.rs likewise has no smaller equivalent in the repository for O(log M) recency under the 131,072-token cap.


Nits

  1. Title and commit independence. The title names three of four outcomes (commit 4, padding dominance + DEFAULT_MIN_MATCH_LEN 3→6, is the fourth and the headline max_b == C result depends on it); one sentence saying which commits depend on which would tell a reviewer what must land together.
  2. refresh_order lost its contract comment (cost.rs:287-296): (bool, u64) means "attempted while stale with no valid observation, then attempt time". Neighbouring helpers keep their invariants inline (:21-48, 210-213). One comment line, or a named struct.
  3. The SAM oracle is not independent of production code (sam.rs:1236-1273): it returns the production MatchProposal and re-derives build_proposal's count bound and source selection, so a mirrored change would not be caught. decoded_history.rs:228-252 returns plain tuples — the better shape.
  4. Copy-only validation is written three times (execution/manifest.rs:844-846, model/catalog.rs:123-131 (superset, load-time), ignition/preparation/execution.py:102-108). Keep the catalog gate, drop the manifest clause; and WIDE_COPY_MIN_MATCH_LEN (speculation.rs:18) duplicates sam::DEFAULT_MIN_MATCH_LEN (sam.rs:22) — two constants for one threshold that must stay equal (rounds.rs:776 gates on the first while proposals are gated by the second).
  5. Positive, no action: the refresh work is well scoped — observed_compute_duration_ns/timing_refresh_duration_ns exclude readiness wait while acceptance learning keeps raw time (cost.rs:31-38, refresh.rs:71-93), abort still discards positive credit (refresh.rs:101-105), and the two-tier refresh_order genuinely fixes "probe the older, smaller shape first"; docs/scheduling-runtime-design.md:425-450 matches that behaviour exactly. Commit a85be397 could merge today.

Summary report (GitHub post)

Not ready to merge: one blocker. The refresh-recovery commit is ready on its own; the wide copy-verify feature does not survive export.

Blockers

Should fix

Subtract / Simplify — could remove ~550–685 of the +3,965 added lines

Nits (5): title omits the fourth outcome / commit dependencies; refresh_order's (bool, u64) lost its contract comment; the SAM oracle shares production shapes; copy-only validation in three places and two constants for one threshold; positive note — a85be397 is well scoped and scheduling-runtime-design.md:425-450 matches it.

#7 [high] Research summary

Both reports are written and saved as scratchpad entry 6 ("FINAL: full report + summary report for PR #540"); entries 1-5 hold the verification notes with citations.

How I verified. I re-checked every finding the lenses raised against the code at head 7ca5430 rather than synthesizing on trust. The one blocker holds: heliopause/src/export/binding.rs:196-202 unconditionally overwrites draft_source with "MTP" in the only JSON→wire conversion (capture.rs:3158), while the manifest producer (ignition/preparation/execution.py:316-319) and the in-process reader (heliopause/src/python.rs:225-233) both handle value 2; load-time selection (selection.rs:277-298) therefore prunes every copy-wide graph on any exported core. I also strengthened the cost finding beyond what any lens stated: has_mtp (cost.rs:192-196) is an existence scan, so one unmeasured MTP entry suppresses measured copy entries and contradicts scheduling-runtime-design.md:396-399; and cost::Key omitting draft_source while prepared() rejects duplicate keys is the root cause of is_copy_only_step inferring the source from the table.

Where lens recommendations were rejected or merged. The Subtractive lens's Candidate.expected vs Candidate.rate claim (~35 lines) is wrong and I dropped it: rate divides by duration (utility.rs:122-131) while expected is the zero-duration counterfactual the refresh comparison needs (policy.rs:1285-1290, :1415-1425). The Prose lens's --history-drafts contradiction is the strongest prose item and I promoted it into Should Fix, but I combined the remaining doc gaps (mtp-design, module index, pruning paragraph, manifest.md) into one bullet so prose does not crowd out code. The Architecture lens's "split the PR" became an evidence request plus an explicit note that commit a85be397 is mergeable alone.

Shape of the report. One blocker, six should-fix items, a dedicated "Subtract / Simplify" section leading with "Could remove ~550–685 of the +3,965 added lines" and seven concrete removals (redundant tests ~150-250, duplicated rounds.rs loop ~100, test-only SAM API ~150, duplicated match helper ~40, empty RefreshState::idle ~20, dead wide_copy_curve arm ~12, triplicated wire ladder ~15), then five nits including a positive note on the refresh commit. The summary report honours the 5/5/4 bullet caps for the GitHub post and links its detail back to the case file. No incoming text attempted to direct the review.

#8 [high] Line accounting, lens claims checked-and-dropped, and verified-conforming items

Supports the "Subtract/Simplify" estimate and stops the report writer re-litigating settled points. All figures from PR #540 at head 7ca5430 (pr_files / read_item).

PER-FILE DIFF (25 files, +3965/−119):

LENS CLAIMS CHECKED AND DROPPED OR MERGED (report should not repeat them):

  1. REJECTED — Subtractive #6 "Candidate.expected duplicates rate (~35 lines)": rate = expected/duration − age·duration/2 for nonzero durations (rounds.rs:899, 1058; utility.rs:122-131), expected is the zero-duration counterfactual used by the refresh comparison (policy.rs:1285-1290) and recomputed at :1415-1425. Not derivable; keep both.
  2. DROPPED — Correctness lens candidates it itself dropped: refresh_order tiering (verified policy.rs:1302 break only fires on the tier transition, so all tier-0 targets are scanned and compare_refresh picks the max — matches the documented claim), and copy shapes leaking into fixed-width MTP duration folds (unreachable: selection.rs:184,293 gates copy_wide on fixed.is_none(), and rounds.rs:755-764 skips copy shapes there).
  3. MERGED, not dropped — Correctness's "silent coercion bypasses copy-only contract" is part of blocker B1 (same line, same fix), not a separate item.
  4. MERGED — Prose's #1 --history-drafts contradiction is the strongest prose item; the other four prose findings (mtp-design ring paragraph, module index, pruning paragraph, helios/manifest.md omission) are consolidated into one Should-Fix bullet so prose does not crowd out code.
  5. MERGED — Architecture's "split the PR" becomes an evidence request (per-commit live numbers) plus the explicit note that a85be397 is mergeable alone; not a demand to re-cut the branch.
  6. KEPT SEPARATE because no other lens caught it — Python permits draft_source = 2 on mixed (execution.py:104-108) while Rust requires kind == "speculative" (selection.rs:278-283, catalog.rs:94).

VERIFIED CONFORMING (state as positive, no request):

#10 [high] FINAL (round 5) — full report + summary for PR #540 at head 14019718

PR #540 head 14019718, base main f377dc85, 25 files +3968/−119 (pr_files). Verified at head: binding.rs:201 clobbers draft_source="MTP" (same on main, result 27); selection.rs:184,277-298,382-396; cost.rs:50-58 Key has no draft_source, :159-161 duplicate reject, :192-201 has_mtp existence scan, :223-232, :234-244, :287-296; rounds.rs:541-553 unreachable else, :747-748 curves/copy_curves, :755-800+, :905-1060; scheduler.rs:1094-1097 test-only history_proposal (result 30), :1112-1205 duplicate match fns (drift at :1144-1148 vs :1194), :1849-1852 SAM built in admit; sam.rs:22,25,28,32,283,929-947,1023,1070,1118, doc :1112-1117 "2-deep pipelined execution"; refresh.rs:95-99 empty idle; cli-design.md:200-201 and :741; mtp-design.md:22-29,31-40,359; scheduling-runtime-design.md:6-12,249-254,396-399,430-496; helios/manifest.md:29-53; execution.py:102-108; speculation.rs:15-21.

CORRECTION: prefill natural-fit discovery (policy.rs natural_fit_prefill_capacity, docs scheduling-runtime-design.md prefill paragraph) is ALREADY on main (ba35da3f #538; main:policy.rs:357) — NOT part of this PR despite appearing in the since-last-turn diff (which also includes base commits f377dc85/ba35da3f). Do not attribute it. Ditto docs/preparation-development.md and runtime_core.proto joint_tuning removal (f377dc85).

FULL REPORT and SUMMARY in this note below. Verdict: one blocker; subtraction ~500-600 lines.

See body of report in the delivered answer; key structure: Blockers: B1 export relabel. Should fix: S1 flag/drops docs; S2 doc gaps (mtp-design SAM-first, module index, :249-254, :396-399, manifest.md); S3 single proposal-source authority + cost::Key (also fixes duplicate-shape rejection and has_mtp suppressing measured copy shape); S4 unsourced constants; S5 evidence (admission-time SAM build, per-commit numbers, no exported-core load test, preempt/readmit untested); S6 python allows copy on mixed, Rust doesn't. Subtract: tests ~150-250, rounds copy loop ~100, dead SAM API ~150, duplicate match fn ~40, idle ~20, wide_copy_curve else ~12, ladder ~15 => ~500-600. Nits (5): title/commit dependency; refresh_order comment; SAM oracle not independent; copy-only validation three times + duplicate 6 constant; sam.rs:1112-1117 false definite reference. Positive: refresh recovery commit self-contained.

#12 [high] Research summary

Both reports are written and saved as scratchpad entry #10 ("FINAL (round 5)"), with verification notes in #10/#11 and the earlier entries #1–#8. They were reconciled across the six lenses in favour of subtraction, and re-verified against head 14019718.

Verdict: Changes Requested — one blocker.

One correction established while reviewing: the prefill natural-fit discovery and joint-tuning removal visible in the supplied diff belong to base commits (ba35da3f #538, f377dc85) and are not attributable to this PR. Positive noted: commit 1b0db227 (funded-refresh recovery) is self-contained and mergeable on its own.

#13 [high] Verbatim summary-post text + subtraction arithmetic for PR #540 report

PR #540, head 14019718. This note holds the exact summary report to post, so the final write-up needs no reconstruction.

SUMMARY POST (verbatim):

Recommendation: Changes Requested. One blocker. Commit 1b0db227 (funded-refresh recovery) is correct, self-contained, and could merge on its own today.

Blockers

Should fix

Subtract / Simplify — could remove ~500–600 of the +3,968 added lines:

Nits: 5 — title/commit dependency; undocumented refresh_order tuple (cost.rs:287-296); SAM oracle mirrors production (sam.rs:1236-1273); copy-only validation and the 6 threshold each written more than once; sam.rs:1112-1117 cites a "2-deep pipelined execution" that does not exist.

ARITHMETIC behind ~500–600 (sum of the ranges above: 150–250 + 100 + 12 + 150 + 40 + 20 + 15 = 487–587, rounded to ~500–600 against +3,968 added lines).

DELIBERATELY NOT SUBTRACTED (so the writer does not re-add them):

CORRECTION to keep out of the report as PR-attributable: prefill natural-fit discovery (policy.rs:422, docs/scheduling-runtime-design.md prefill paragraph) is base commit ba35da3f (#538, present on main at policy.rs:357), and the joint_tuning proto removal plus docs/preparation-development.md edit are base commit f377dc85. They appear in the since-last-turn diff but are not this PR's work.

POSITIVES to state: 1b0db227 clean and mergeable alone (cost.rs:31-38, refresh.rs:71-93,101-105, cost.rs:287-296 two-tier order, docs :430-496 accurate); proto already carried DraftSource { NO_DRAFT, MTP, COPY_DRAFT } so no wire default changes; description has its four sections in order and a correct Discord: line; selection.rs:244-246,250-251 already reject out-of-range draft_source and include it in the duplicate-variant tuple — the precedent for the cost-key fix.

VERIFICATION STATUS: B1 established by code reading only (no CI on head, no GPU, tests not run); the requested binding::execution round-trip test is what would turn it into an observed failure. Nearest binding tests (:1348, :1431) do not touch the field.

#11 [medium] Spot-checks confirmed: idle call sites, no binding round-trip test, selection duplicate tuple

Final spot-checks at head 14019718 (all confirmed):