Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #660

Raw Markdown for agents: https://autobot.eidonix.com/p/a1ec5b40-f44a-48d1-93a7-61c98a2bc274.md

#1 [high] F1: two anchor-decision sites still price different intervals

checkpoints.rs request_anchor_endpoint (PR head cf744df):

#3 [high] F3: test coverage at shipped default 0.05 is thin; broad fixture opt-out

PR body (read_item 660) says: "cargo test --release: helios server 1,269 / runtime-core,server 1,780"; and the Discord-relevant hosting rules: AGENTS.md:317 requires cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server. Changed tests the PR declares defaulted (no configure_policy) plus a load-bearing fixture change:

#5 [high] F1b: worked example of the price_start vs prefill_cursor divergence

Worked example with the PR's own test catalog (checkpoints.rs:4700-4705 measures Prefill 128=100, 256=110, 512=200; prompt 1024, interior boundary 896, fraction 0.05):

#6 [high] F5: PR-description accuracy vs actual diff and A/B scope

PR body, "What" section: "Unified retention & telemetry: request_anchor_endpoint and checkpoint_selection_uncached both call anchor_split_affordable" — but the interval each prices is still different (see F1/F1b), so the unification is only of the affordability predicate, not of the decision. PR body "Limits": "4× RTX PRO 6000 A/B ran on 22cac916834f (same cold-request math; only request_anchor_endpoint fallback helper + docs/tests added since)" — the helper is not docs/tests: it changes request_anchor_endpoint's budget base from the whole interval to request.checkpoints.initial_prefill_ns.unwrap_or(whole) and adds the extra_spent_ns term (checkpoints.rs:534-539), i.e. admission-role assignment (scheduler.rs:1797) and anchor promotion (checkpoints.rs:885-906) behave differently on the head than in the measured A/B; no A/B or attached CI exists on cf744df. Also the "What" header claims checkpoints.rs "(+95/-60, +35 net prod LOC)" while the file diff is +751/−87; the header understates the change by ~19× and is the line a reviewer would use to judge blast radius. Charter: AGENTS.md:194-199 "Require focused, meaningful validation ... Identify missing hardware, inputs, and unrun checks explicitly" and #210's served-workload A/B requirement. Docs updated consistently: docs/core-design.md:1436-1457, docs/cli-design.md:696-710, docs/scheduling-runtime-design.md:614-623, helios/README.md:372-389 — I found no contradiction between them and the code for the retained-anchor case; the no-capture (checkpoint_skip_storage) case is not described (see F2).

#7 [high] Research summary

Reviewed PR #660 (head cf744df) across correctness/contracts/system-level consequences: read the full checkpoints.rs diff and the changed regions of the file (anchor decision sites, selection, commit/store-failure path, checkpoint_copy_allowed, revoke_unused_anchor_guards, promote_request_anchor), the direct callers (scheduler.rs:1795-1811 admission role, :2405 commit hook, :2858-2910 capture storage), all changed tests, the four doc files, docs/api.md, AGENTS.md, and the TLA+/mutation harness.

Main findings (all cited verbatim in the scratchpad):

  1. Major — the two anchor-decision sites still price different intervals, so "unified retention" is only the affordability predicate. request_anchor_endpoint prices [price_start, prompt] (from baseline_interval/admission reuse, checkpoints.rs:483-541) while selection prices [prefill_cursor, prompt] (:562, :610-616), and the reconciling budgeted_anchor latch is only created when consumed_tokens >= prompt_tokens (:893-896), so mid-prefill steps are uncovered. With the PR's own measured costs, mid-prefill selection keeps the interior anchor (split clamps to 0 via saturating_sub at :445) while request_anchor_endpoint falls back to the prompt end (110 ns > 20 ns allowance) — and that site drives cache Anchor promotion at :906-908. The new agreement test (:4685-4771) cannot catch it: every arm pins initial_prefill_ns and leaves consumed_tokens == scheduled_consumed == 0.
  2. Major — a retained interior anchor is charged even when no checkpoint is stored. commit_checkpoint_plans debits split_ns to extra_spent_ns and the global counter before the destination is known (:923-934) and the checkpoint_skip_storage path refunds only copy_ns (:984); pre-PR the Anchor cut was hard-zero. Under snapshot pressure this permanently burns the request's allowance (also vetoing earlier optional cuts) while retaining nothing, and neither docs/core-design.md:1436-1457 nor helios/README.md:372-389 describes the no-capture case. flare_checkpoint_extra_work_nanoseconds_total's composition widened with docs/api.md:356-357 unchanged.
  3. Major (claims) — the A/B predates one of the two decision sites. The body dismisses the post-22cac91 delta as a "fallback helper + docs/tests", but checkpoints.rs:534-539 changes that site's budget base and adds the extra_spent_ns term, feeding admission role assignment and anchor promotion; no A/B or attached CI exists on cf744df. The checkpoints.rs LOC figure in the body (+95/−60, +35 net) is also ~19× smaller than the real +751/−87.
  4. Minor/medium — coverage at the shipped 0.05 default is thin. The new permissive_checkpoint_costs helper (tests.rs:161-184) sets fraction 1.0 and flattens prefill costs; it now governs the entire boundary_tests module (:74) and was added to the TLA/observed lifecycle-model reservation test (checkpoint_lifecycle_tests.rs:156-161), with policy/vision/phase fixtures opting out to 0.2/1.0/0.1. phase_tests.rs:1542-1546 re-geometried the short-system/short-prompt integration case to a chunk-aligned boundary. Six new inline tests at default 0.05 partly offset this.
  5. Minor (disclosed) — the candidate filter end < raw_anchor (:677) plus the unconditional prompt-end Endpoint push (:680-682) lets a request whose anchor split was rejected still take optional cuts below the abandoned anchor; the tests assert it, but nothing bounds admission pricing for that shape.

Docs and the check.py mutation rename are otherwise consistent with the code; no locks, wire/ABI or re-export changes; RequestScheduler remains single-threaded with a per-plan selection cache, so I found no new contention or memory-amplification hazard beyond finding 2.

#8 [high] F-indices: severities + verbatim quotes for each finding

FINDING 1 (Major) — two anchor-decision sites, different interval basis. Quote A (helios/src/scheduler/checkpoints.rs:483-487, request_anchor_endpoint): let baseline_start = request .checkpoints .baseline_interval .filter(|&(_, end)| end == request.prompt_tokens) .map_or(request.admission_reused_tokens as usize, |(start, _)| start); Quote B (checkpoints.rs:562, checkpoint_selection_uncached): let start = Self::prefill_cursor(request); (+ :610-616 passes start into Self::anchor_split_ns) Quote C (checkpoints.rs:893-896, promote_request_anchor — latch only after prompt completes): let latch = (raw_anchor < prompt_tokens && request.prefix_tokens != raw_anchor as u64 && request.consumed_tokens >= prompt_tokens as u64) .then_some((raw_anchor, prompt_tokens, anchor)); Impact: same request can return 896 at selection and 1024 at request_anchor_endpoint mid-prefill (see F1b entry); the latter drives cache promotion (self.cache.promote(id, RetentionRole::Anchor, epoch)? :906) and reoffer_publication (:908), and admission role assignment (scheduler.rs:1797 if self.is_request_anchor_endpoint(request, inbound.consumed_tokens)). Fix: price both sites from the same interval (prefill_cursor at selection, baseline_interval.0 at admission are inherently different instants — so instead have promote_request_anchor/is_request_anchor_endpoint consume the accounting's own Anchor cut, or extend the latch to mid-prefill by latching as soon as the selection first decides), and add a test with scheduled_consumed != consumed_tokens plus no injected initial_prefill_ns.

FINDING 2 (Major) — anchor split charged with no capture. Quote (checkpoints.rs:923-934): accounting.cuts.retain(|candidate| candidate.endpoint != cut.endpoint); accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.split_ns); accounting.extra_spent_ns = accounting.extra_spent_ns.saturating_add(cut.split_ns); self.stats.checkpoint_extra_work_ns = self.stats.checkpoint_extra_work_ns.saturating_add(cut.split_ns); vs storage-failure refund (checkpoints.rs:983-986): } else { accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.copy_ns); self.stats.checkpoint_skip_storage += 1; } Fix: on the storage-failure path, refund cut.split_ns too (and subtract it from checkpoint_extra_work_ns), i.e. only debit the split when destination is Some; document the case in docs/core-design.md:1436-1457.

FINDING 3 (Major, claims) — quote from PR body "What": "Unified retention & telemetry: request_anchor_endpoint and checkpoint_selection_uncached both call anchor_split_affordable". Quote from PR body "Limits": "4× RTX PRO 6000 A/B ran on 22cac916834f (same cold-request math; only request_anchor_endpoint fallback helper + docs/tests added since)". Counter-quote (checkpoints.rs:534-539): Some((whole, split_ns)) => anchor_split_affordable(request.checkpoints.initial_prefill_ns.unwrap_or(whole), split_ns, request.checkpoints.extra_spent_ns, fraction). Also body header says "checkpoints.rs (+95/-60, +35 net prod LOC)" vs pr_files +751/-87. Fix: re-run/attest the A/B on cf744df (or state the two decision sites' post-A/B behaviour change explicitly) and correct the LOC figure.

FINDING 4 (Minor→Major depending on adjudication) — test coverage at 0.05. Quote (helios/src/scheduler/tests.rs:178-183): scheduler .configure_policy(PolicyConfig { checkpoint_extra_work_fraction: 1.0, ..Default::default() }) .unwrap(); applied at boundary_tests.rs:74 super::tests::permissive_checkpoint_costs(&mut s, 4, None); (every scheduler_with_concurrency fixture) and checkpoint_lifecycle_tests.rs:156-161. Plus phase_tests.rs:1542-1546 re-geometry and :3898-3905 forced 1.0. Fix: keep at least one boundary/lifecycle/phase test at the shipped 0.05, and restore an interior-anchor case on a single-chunk short prompt in phase_tests.

FINDING 5 (Minor) — checkpoints.rs:672-682 filter end < raw_anchor + unconditional prompt-end Endpoint push after a rejected anchor.

FINDING 6 (Minor, style) — docs/cli-design.md:699-708 and docs/core-design.md:1457 carry ~100-118-column lines inside ~85-column files (wrapping regression only; no semantic problem).

#2 [medium] F2: anchor split charged even when snapshot storage unavailable; allowance spent without capture

checkpoints.rs commit_checkpoint_plans (:914-990): :923-934 accounting.cuts.retain(...); accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.split_ns); accounting.extra_spent_ns = accounting.extra_spent_ns.saturating_add(cut.split_ns); self.stats.checkpoint_extra_work_ns = ...saturating_add(cut.split_ns); then :960-986 storage-failure path refunds only the copy: :984 accounting.reserved_ns = accounting.reserved_ns.saturating_sub(cut.copy_ns); self.stats.checkpoint_skip_storage += 1; Before this PR the Anchor cut always had split_ns: 0, so a checkpoint_skip_storage on an interior anchor cost nothing. Now the request permanently carries the split in extra_spent_ns and the global counter even though no checkpoint was published, and the reservation was already consumed at selection (:651-659 adds anchor split to reserved_ns), so it also vetoed earlier optional Message/Endpoint candidates (:734-741 extra_spent_ns + reserved_ns + charge > available). docs/core-design.md:1440-1447 and helios/README.md:372-385 do not describe this no-capture case. Impact: under snapshot pressure (quote_snapshots None at :948/:969, or guard revoked by revoke_unused_anchor_guards :142-167 before the anchor commits) each attempt burns allowance and inflates flare_checkpoint_extra_work_nanoseconds_total while retaining nothing — a memory-pressure feedback loop. Also note metric composition widened (anchor splits now included) with docs/api.md:356-357 unchanged.

#9 [medium] Verified-clean areas (state plainly, do not invent issues)

Sound, verified by opening:

#4 [low] F4: candidate filter change admits message cuts below a rejected raw_anchor

Selection now filters optional message candidates with end < raw_anchor instead of end < anchor: checkpoints.rs:672-679 let mut candidates: Vec<_> = request.message_boundaries.iter().rev().copied().filter(|&end| start < end && end < raw_anchor && request.checkpoint_endpoint_eligible(end)) if start < request.prompt_tokens && request.prompt_tokens != anchor { candidates.push((request.prompt_tokens, RetentionRole::Endpoint)); } (:680-682) When the interior anchor was rejected for budget (anchor == prompt_tokens), every message boundary below raw_anchor stays a candidate; nothing re-charges the abandoned anchor split, so admission pricing (estimated_checkpoint_cut):781-789 used by policy.rs:357/711/778/940/1059/1256 does not reflect the extra Prefill launches. The new tests (checkpoints.rs:4280-4300 Case 2, :4330-4340 Case 3) assert this behaviour and the PR body states it explicitly ("Filters earlier Message cuts (end < raw_anchor)"). Flag as a disclosed scope limit / potential over-admission on prompts where anchor split is very expensive but many cheap aligned messages remain — the PR does not bound how many such optional cuts a rejected-anchor request may still take beyond the shared available allowance.