Subtraction and simplicity report · NVIDIA/hyperflare-inference #688

Raw Markdown for agents: https://autobot.eidonix.com/p/83d0c7a7-71c8-44ef-a714-107f2379d24e.md

Subtraction, Simplicity & Conventions review — PR #688 (fix(helios): align proposal_confidence manifest messages with submission-row layout)

Head reviewed: 879dc017 (branch fix/confidence-manifest-messages → main). Fixes #440. All 8 changed files were read at head; pr_diff / search_history fail on this head ("Could not read c513e46a…"), so per-file counts come from the dossier's pr_files and wording was verified by reading the head files directly.

Key findings

  1. (medium-high) The same layout clause is hand-typed twice and has already drifted. helios/src/execution/manifest.rs:830 says "submission row", :871 says "submission-row". The drift is load-bearing: the new test must assert two different spellings in its two loops (tests.rs:1367 vs :1393). One shared const (or, minimally, one identical spelling) removes the duplication and the drift class.
  2. (medium) docs/runtime-core-design.md:717-721 now restates in full the contract already fully stated 16 lines above at :697-701. On main:714-715 this sentence was a single deferring line; the fix expanded both sites. Collapse :717-721 to a reference — deletes 4 lines and one in-file copy of the contract.
  3. (small-medium) The new test re-types the speculative fixture and the assert block. Setup at tests.rs:1339-1351 duplicates :1319-1326 verbatim apart from max_active, and the same five assert!(error.contains(...)) lines are typed twice (:1366-1371, :1390-1396). One local helper plus one assert closure removes ~18 lines. The case list is genuinely new coverage and should not be trimmed.
  4. (small) docs/core-design.md:1228-1229 reads "completion frames indexed by completion frame". The grafted fix contradicts itself. Delete two words.
  5. (small) manifest.rs:830 is the only site writing bare max_active where all seven prose sites write Execution.max_active. Folds into finding 1.

Verdict on the subtraction axis proper: clean. No new flag, config knob, env var, wrapper, fallback branch, dependency, feature gate, or dead code; the two manifest.rs predicates are byte-for-byte the pre-PR ones (:826-832, :861-873) and only the two Err literals differ. request_capacity() is unchanged (:583-585). The PR does not violate AGENTS.md's "reject unsupported abstractions and churn" clause (AGENTS.md:188-193): 2 code lines, 0 configuration surface. Findings below are duplication/consistency, not excess machinery.

Finding 1 — one layout clause typed twice, already drifted (medium-high)

helios/src/execution/manifest.rs:830 (buffer arm):

                    || !(1..self.completion_token_capacity).contains(&buffer.shape[2]) {
                    return Err("proposal confidence requires [2, request_capacity, draft_capacity] float32 frames indexed by submission row (sized to max_active.next_power_of_two()) and draft depth 1..=completion_token_capacity - 1".into());
                }

helios/src/execution/manifest.rs:871 (graph arm):

                        || confidence.shape[2] > self.completion_token_capacity - 1 {
                        return Err("confidence output requires a speculative graph whose confidence_width equals draft_tokens and [2, request_capacity, draft_capacity] float32 submission-row frames covering confidence_width within draft depth 1..=completion_token_capacity - 1".into());
                    }

Both arms restate [2, request_capacity, draft_capacity], the max_active.next_power_of_two() derivation and the 1..=completion_token_capacity - 1 depth bound. Two spellings already exist, and the new test is forced to encode the drift — tests.rs:1367 asserts error.contains("submission row") in the buffer loop, tests.rs:1393 asserts error.contains("submission-row") in the graph loop. That is a test asserting an inconsistency rather than a contract.

Simplify to one const (this file has no consts today — grep for ^const returns nothing — so it is a small new convention, justified by the drift; format! is already house style at manifest.rs:762, 770, 782):

const CONFIDENCE_LAYOUT: &str = "[2, request_capacity, draft_capacity] float32 frames indexed by submission row (sized to Execution.max_active.next_power_of_two()) and draft depth 1..=completion_token_capacity - 1";

then

return Err(format!("proposal confidence requires {CONFIDENCE_LAYOUT}").into());

and

return Err(format!("confidence output requires a speculative graph whose confidence_width equals draft_tokens and {CONFIDENCE_LAYOUT} covering confidence_width").into());

Removes ~25 duplicated words, makes the two arms impossible to drift, and lets both test loops assert one string. Minimal alternative if a const is unwanted: change :871 "submission-row" → "submission row" and collapse the two assert blocks to one spelling; that alone removes findings 1 and 5's drift without any new type.

Finding 2 — one file states the full contract twice, 16 lines apart (medium)

docs/runtime-core-design.md:697-701:

Proposal-confidence buffers (`proposal_confidence`)
are contiguous FP32 storage with shape `[2, request_capacity, draft_capacity]`,
indexed by completion frame, submission row (sized to
`request_capacity = Execution.max_active.next_power_of_two()`), and draft depth
`1..=completion_token_capacity - 1`, covering every graph’s confidence width.

docs/runtime-core-design.md:717-721:

allocation requires adaptive selection. A confidence output declares
`confidence_width` and uses FP32 `[2, request_capacity, draft_capacity]`
submission-row frames (where
`request_capacity = Execution.max_active.next_power_of_two()` and
`draft_capacity` is in `1..=completion_token_capacity - 1`).

Before this PR, main:714-715 was a single line — A confidence output declares `confidence_width` and uses FP32 `[2, request_slots, draft_capacity]` frames. — that deferred to the storage paragraph. The fix made both sites independently complete, so the identical shape, the identical next_power_of_two() derivation and the identical depth bound now appear twice within one 40-line section. Replace :717-721 with:

allocation requires adaptive selection. A confidence output declares
`confidence_width` and uses the `proposal_confidence` storage described above.

Deletes 4 lines. Note: the cross-file repetition of this contract in docs/core-design.md:1227-1231, docs/scheduling-runtime-design.md:81-86, helios/README.md:301-304, helios/model-contract.md:227-233, helios/manifest.md:164-171 is required — the review bot's should-fix enforced the #542 precedent that all six specs state the layout — so that repetition is not a finding and must not be collapsed.

Finding 3 — the new test re-types its neighbour's fixture and asserts (small-medium)

helios/src/execution/tests.rs:1339-1351:

    value.graphs[0].kind = GraphKind::Speculative;
    value.graphs[0].token_capacity = 6;
    value.graphs[0].draft_tokens = 5;
    value.graphs[0].packed_token_capacity = 24;
    value.graphs[0].confidence_width = 5;
    value.buffers.push(BufferDescriptor {
        name: "proposal_confidence".into(),
        address: 0x20000,
        nbytes: 2 * 4 * 5 * 4,
        dtype: Dtype::Float32,
        shape: vec![2, 4, 5],
        strides: vec![20, 5, 1],
    });

is the same six field assignments and the same descriptor values as helios/src/execution/tests.rs:1319-1326 (eight_token_completions_accept_shorter_proposal_confidence), differing only by max_active and formatting. Separately, the five-line assert block at :1366-1371 is typed again at :1390-1396:

        let error = invalid.validate().unwrap_err().to_string();
        assert!(error.contains("submission row"), "{error}");
        assert!(error.contains("request_capacity"), "{error}");
        assert!(error.contains("draft depth 1..=completion_token_capacity - 1"), "{error}");
        assert!(!error.contains("request slot"), "{error}");
        assert!(!error.contains("request_slots"), "{error}");

Extract one test-module helper — e.g. fn speculative_with_confidence(value: &mut ExecutionManifest) — used by both tests, and one closure let assert_layout = |e: &str| { … }; used by both loops. Saves ~18 lines and leaves one place to change if the message text changes again.

Do not cut the cases. [2,3,5] trips shape[1] != request_capacity(), [1,4,5] trips shape[0] != 2, [2,4,16] trips the upper depth bound, Int32 trips dtype, width_exceeds trips shape[2] < confidence_width, width_mismatch trips confidence_width != draft_tokens, non_speculative trips the kind predicate — each is a distinct predicate not covered by the older tests at tests.rs:1137-1169 / :1310-1332 (those trip only confidence_width != draft_tokens and shape[2] < width). Fixture arithmetic is sound: manifest() sets max_active: 4 (tests.rs:202) and completion_token_capacity: 16 (tests.rs:194), so the test's value.max_active = 3 gives request_capacity() == 4 (asserted at :1338) and depth bound 1..=15.

Finding 4 — self-contradictory phrase left by the graft (small)

docs/core-design.md:1227-1231:

submitted lane limits. Confidence producers declare `confidence_width` and write
FP32 `[2, request_capacity, draft_capacity]` completion frames indexed by
completion frame, submission row (sized to
`request_capacity = Execution.max_active.next_power_of_two()`), and draft depth
`1..=completion_token_capacity - 1`.

"completion frames … indexed by completion frame" is a self-contradiction introduced by splicing the new list onto the old noun phrase. Minimal repair — delete the two words after the closing backtick:

submitted lane limits. Confidence producers declare `confidence_width` and write
FP32 `[2, request_capacity, draft_capacity]` frames indexed by
completion frame, submission row (sized to
`request_capacity = Execution.max_active.next_power_of_two()`), and draft depth
`1..=completion_token_capacity - 1`.

This is also the one site that reads machine-patched, against the repo-prose rule that documentation is a present-state specification rather than layered history (.agents/skills/repo-prose/SKILL.md:26-29 (not opened)).

Finding 5 — bare identifier in a user-facing error (small)

manifest.rs:830 writes "sized to max_active.next_power_of_two()". All seven prose sites write Execution.max_active: helios/README.md:303, helios/manifest.md:167, helios/model-contract.md:230, docs/core-design.md:1230, docs/runtime-core-design.md:700 and :720, docs/scheduling-runtime-design.md:84. A reader of a manifest validation error has no self in scope; the reviewer already raised this. One-word fix: Execution.max_active.next_power_of_two(). Folds into finding 1's const.

Already lean — reviewed and should not change

Process caveat (not a lens finding, carried forward)

The 1879 / 254 / 245 test totals are asserted identically for both heads with no CI check and no attached log; the review bot's own single pre-merge warning is the same gap, and no human reviewer has approved. That does not affect any finding above (a diagnostics-only diff cannot move those numbers), but nothing in this review independently confirms the new test compiles.

Open questions / could not verify