Conventions scratchpad · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/2ca56e16-7a0c-486a-9be4-3ddf2eae1764.md

#1 [high] PR 483 review setup: scope, rules, files

PR #483 NVIDIA/hyperflare-inference, branch rickybrent:core/gemma4-image-frontend f2340e42 -> main 6d6fe0c6. 13 files +732/-164. Title: "Add Gemma 4 image prep profile, bracketed 3x3 packing & atomic spans". My lens: C = conventions and duplication. Compare each new construct with closest precedent; flag departures; flag duplicated helpers/mechanisms.

Rules to cite (AGENTS.md):

#2 [high] packing.rs: bracketed_patch_geometry table + tensor_layout param

helios/src/frontend/images/packing.rs (PR head):

#3 [high] Should fix: packing.rs bracketed_patch_geometry table keyed on patches_per_feature

packing.rs:16-22 bracketed_patch_geometry(patches_per_feature) -> (merge_side, patch_width) table 4=>(2,1176), 9=>(3,768), else Err. Problem: patches_per_feature alone does not identify the patch float width. DeepSeek already uses patches_per_feature 9 (packing.rs deepseek() 315-317 checks geometry.tokens != patches/9, tensor_layout Deepseek branch gives 588 floats/patch). So 9=>768 encodes "Gemma-4-style interleaved patch", i.e. model identity, in shared upload packing. Same file already derives widths from the prepared layout enum: qwen() 123-134 (Moonvit/Step 588, Radio 768, Glm 1176) and tensor_layout keyed on ImageLayoutKind; class_token() 537 uses super::padded_grid::FEATURES. Rules: docs/design-review.md principle 3 lines 38-52 ("input packing ... stay shared; use prepared metadata ... to express model-dependent behavior"; enums/metadata must not become model allowlists); AGENTS.md:176-181; charter "Keep the runtime small and model-agnostic". Fix: take the patch feature width from prepared metadata (a declared per-layout patch width in the vision contract / ImageLayout, as class_token does with padded_grid::FEATURES) instead of a numeric table keyed on patches_per_feature.

#4 [high] Should fix: duplicate per-profile pixel-width tables (packing, conditioned, gemma4)

Three independent places now encode the same per-profile pixel width:

  1. helios/src/frontend/images/packing.rs:39-42 + 16-22 (Bracketed -> 1176 / 768 via bracketed_patch_geometry).
  2. helios/src/frontend/images/conditioned.rs:187-194 valid_processed (new arm Profile::Gemma4(_) => 768, line 192) — a third match arm table next to Radio 768, Glm 1176, PaddedGrid FEATURES (191), _ => 588.
  3. helios/src/frontend/images/gemma4.rs:116 3 * self.patch_size * self.patch_size. Precedent for a single source: class_token()/padded_grid use padded_grid::FEATURES (packing.rs:537); tensor_layout() is the declared layout authority (packing.rs:24-89). Risk: conditioned.rs caches validation (valid_processed) silently disagrees with the profile if either table changes, and the cache path returns "image preprocessing differs from its prompt geometry". Fix: derive the width from one shared helper (e.g. the same layout/metadata source used by tensor_layout).

#5 [high] Should fix: prompt.rs fills data.spans generically instead of in the layout

helios/src/model/prompt.rs:137-151 (new): fills prepared.data.spans from prepared.conditioned_inputs when config.contract.frontend.image_tokens.span is Some and no layout produced spans. Departures from precedent: (a) Every image layout module returns conditioned_inputs: vec![] (grep: bracketed.rs:44/90, class_token.rs:66, deepseek.rs:165, glm.rs:85, mimo.rs:76, moonvit.rs:89, qwen.rs:110, radio.rs:82, step.rs:108) — the vector is always filled here, so conditioned_inputs is no longer layout-owned. The precedent for spans is the layout: layouts/deepseek.rs:149 data.spans.push(start + padding..start + block.len()) alongside its own token expansion, then validate_prompt_data (model.rs:436-454) checks the span boundaries against the declared ImageSpan. (b) The new code trusts the ImageSpan metadata only for presence, and copies input.token_span, which for enveloped layouts is start..start + additional + 1 (prompt.rs:129-131) where additional is token_expansions from layouts/bracketed.rs:77-81 = geometry.tokens + 1. So the assembled span length is tokens+2. max_tokens is enforced in model.rs:438. Nothing in this PR's code or tests checks a Gemma4 ImageSpan (no contract fixture with span set for Gemma4; helios/tests/support/contracts/gemma4_frontend.json has "image_tokens": null), so the one path the feature is claimed for ("atomic spans for multimodal prefill scheduling") is untested end to end. Fix: build spans in the layout that builds the expansion (bracketed.rs, as deepseek.rs does), so the span is derived from the same indices as the expansion rather than re-derived by span arithmetic in prompt.rs.

#10 [high] Research summary

Reviewed PR #483 (Gemma 4 image prep profile, bracketed 3x3 packing, atomic spans) through the conventions-and-duplication lens, checking each new construct against its closest precedent in helios/src (packing.rs, conditioned.rs, layouts/deepseek.rs, layouts/bracketed.rs), helios/src/runtime_core (protobuf.rs, describe.rs), ignition/preparation/frontend.py, and the repository rules (AGENTS.md, docs/design-review.md, docs/runtime-core-design.md).

Four should-fix findings and three nits, recorded in the scratchpad:

  1. packing.rs:16-22 adds a patches_per_feature -> (merge_side, patch_width) table (4→1176, 9→768) in shared upload packing. patches_per_feature alone does not identify patch width — DeepSeek already uses 9 with 588 floats — so the table encodes model identity where the file's own precedent (qwen()'s layout-derived widths, class_token()'s padded_grid::FEATURES) derives widths from prepared metadata. This contradicts design-review principle 3 (input packing stays shared; metadata must not become a model allowlist).
  2. The same pixel width is now authored in three places (packing.rs table, conditioned.rs:192, gemma4.rs:116), with the cache-validating valid_processed silently disagreeing if either changes.
  3. model/prompt.rs:137-151 fills data.spans generically from conditioned_inputs, while every layout returns conditioned_inputs: vec![] and the established span authority is the layout itself (layouts/deepseek.rs:149 with validate_prompt_data). No test exercises a Gemma 4 ImageSpan, so the claimed scheduling path is unverified.
  4. gemma4.rs's envelope test shells out to .venv/bin/python to re-patch the chat template, duplicating prepare_templates.py::_annotate / annotated_template_asset and bypassing the existing template_fixtures::template("gemma4", ...) accessor.

Nits: runtime_core_pb2.py was regenerated with protobuf 7.36.1 while pyproject.toml (not opened) pins >=7.36.2; no protobuf round-trip test for ImageSettings.gemma4 although GLM and padded-grid each have one; the soft-token allowlist is duplicated between Rust and Python.

The Envelope extraction from patch_merge::Processor is a genuine de-duplication and the proto/serde/describe/Python validation additions follow their per-profile precedents exactly.

#11 [high] Coverage: what was read for each changed file

Coverage of PR #483 (13 files) through lens C (conventions and duplication), all read at ref pr/483 in context:

  1. helios/proto/runtime_core.proto (+10): enum value 11 + Gemma4ImageSettings gemma4 = 11 and the message mirror PatchMergeImageSettings tags 1-8 -> 1-6. Consistent with the patch_merge precedent next to it. No finding.
  2. helios/src/frontend/images/gemma4.rs (new, 416): read fully (1-200, plus diff for 200-416). Processor mirrors patch_merge::Processor / QwenProcessor lifetime style; process mirrors patches.rs::process/PatchProcessor::process structure (geometry, checked total, reserve_outputs, cu_seqlens). Findings: duplicated pixel width (gemma4.rs:116), duplicated soft-token allowlist (gemma4.rs:11), test reinvents template patch machinery (gemma4.rs:243-320).
  3. helios/src/frontend/images/mod.rs (+20): ImageSettings::Gemma4 + Gemma4ImageSettings mirror PatchMerge variants; Profile::Gemma4 arms mirror PaddedGrid arms in load/geometry/resized_rgb/process/expand_prompt/preparation_kind. Consistent. No finding.
  4. helios/src/frontend/images/conditioned.rs (+9): Profile::Gemma4(_) => 768 at line 192 in valid_processed's per-profile pixel-width match (187-194). Finding: third copy of the width table (entry 4).
  5. helios/src/frontend/images/packing.rs (+45/-5): bracketed_patch_geometry 16-22, tensor_layout new param 24-42, bracketed() 479-509, tests 570-586. Finding: entry 3.
  6. helios/src/frontend/images/patch_merge.rs (+61/-38): Envelope extraction 10-81, Processor 83-131. Genuine de-duplication; single nit on its home/doc (entry 9 item 3).
  7. helios/src/model/contract.rs (+1/-1): contract_enum ImagePreparationKind adds Gemma4 = 11, appended, no renumbering -> preserves wire ids (design-review principle 13). No finding.
  8. helios/src/model/packing.rs (+1): call site passes config.contract.vision.patches_per_feature into tensor_layout (model/packing.rs:92-97). Consequence of finding 1; the call site itself matches the neighbouring ImageTensor validation style.
  9. helios/src/model/prompt.rs (+15): 137-151 span filling. Finding entry 5.
  10. helios/src/runtime_core/describe.rs (+2): vision_json Gemma4 arm 442-443 mirrors PatchMerge arm 440-441. No finding.
  11. helios/src/runtime_core/protobuf.rs (+5): frontend_settings Gemma4 arm 167-171 mirrors PatchMerge 162-166. Nit: no round-trip test (entry 9 item 1) unlike GLM (726) / padded-grid (749).
  12. ignition/preparation/frontend.py (+25): gemma4 branch 113-137 mirrors glm branch 138-153 (uses _expected incl. optionals). Nit: duplicated soft-token allowlist (line 123 vs gemma4.rs:11).
  13. ignition/preparation/runtime_core_pb2.py (+122/-120): descriptor regenerated; generator version 7.36.2 -> 7.36.1. Nit (entry 6).

Also checked for precedent/duplication: helios/src/frontend/images/resize.rs (gemma4 correctly reuses resize::resize = uint8 antialiased bicubic, as patch_merge/qwen do, rather than adding a kernel); helios/src/model.rs::validate_prompt_data (408-457) for span enforcement; helios/src/scheduler.rs::set_prefill_spans consumers (server/runtime.rs:1460); layouts/* returning conditioned_inputs: vec![]; helios/tests/support/contracts/* fixtures (gemma4_frontend.json has image_tokens null); tests/frontend/prepare_templates.py and helios/tests/support/templates.rs; docs/runtime-core-design.md:247-248 (Python bindings generated by protoc).

#14 [high] Report of 2026-11-25 (revised head 2b4a31e): conventions and duplication

Re-read the revised head (2b4a31e, 36 files) for PR #483 through the conventions/duplication lens.

CLOSED since the previous report (verified in code):

REMAINING (verified):

  1. Nit/should-fix — per-profile patch width is still authored twice, in two match statements keyed on different enums: packing.rs:41-100 tensor_layout (by ImageLayoutKind) and mod.rs:459-473 ImageProcessor::patch_features (by Profile). Nothing links them at compile time; only packing.rs's processor_patch_features_match_tensor_layout_for_every_profile test (11 profiles) does. Fix: have tensor_layout ask the processor/profile for its width (or have patch_features delegate to the layout table) so a new profile cannot drift.
  2. Nit — gemma4.rs:54-56 defines patch_features() but process re-inlines 3 * self.patch_size * self.patch_size at gemma4.rs:132. Use self.patch_features() (as resized_rgb/process do for geometry); patches.rs:89 has the same pre-existing pattern.
  3. Nit — soft-token allowlist duplicated: gemma4.rs:13 SUPPORTED_SOFT_TOKENS = [70,140,280,560,1120] vs ignition/preparation/frontend.py:132. No neighbouring profile enumerates an allowlist (deepseek_row_major.rs:14 validates a range), so there is no precedent to follow; the two sites must be kept in step by hand.
  4. Nit — patch_merge::Envelope (patch_merge.rs:10-17) is now shared by PatchMerge and Gemma4 and its doc says so, but it still lives in patch_merge; gemma4.rs:8 imports it from there. A future enveloped layout will import from a profile module.
  5. Nit — server/config.rs:456-457 reaches into frontend::images::packing::bracketed_patch_features to restate the legacy-default rule; a VisionCapabilities/processor accessor would keep server config out of image-packing internals.
  6. Nit — tests/frontend/generate_gemma4_image_fixtures.py:17-25 copies pattern() and digest() verbatim from generate_glm_image_fixtures.py:18-25; it matches how the other generators are written (each standalone), so acceptable, but a shared helper would be the DRY form.
  7. Nit — bracketed.rs:57-65 restates marker-presence validation (start == 0 || end >= len) that validate_prompt_data (model.rs:441-456) already performs against span.start_token/span.end_token; the layout checks only that a marker slot exists, not that it is the declared marker, so the check is partial and duplicated. Not wrong, just split across two layers.

Precedents that hold (unchanged): proto tag 11 / Gemma4ImageSettings mirror PatchMergeImageSettings (runtime_core.proto:278-281,446-451,582-603); contract_enum! appends Gemma4 = 11 (model/contract.rs:68); describe.rs:451-452 and protobuf.rs:168-172 mirror the PatchMerge arms; frontend.py:114-173 mirrors the glm branch and _native_image_placeholder's atomic-token check (frontend.py:270-275); ImageSettings::Gemma4/Gemma4ImageSettings mirror the PaddedGrid/PatchMerge serde shapes (mod.rs:257-341); Envelope extraction is genuine de-duplication.

#15 [high] Research summary

Verdict: no blocking or should-fix findings remain in this lens; nits only.

I re-read the revised head (2b4a31e, 36 files) for conventions and duplication against each construct's closest precedent in the repo, judged against docs/design-review.md principles 1, 3 and 13 and AGENTS.md (not opened).

All four should-fix findings from my previous pass are closed in the code, not just in the reply. packing.rs:16-32 replaces the patches_per_feature → width table with bracketed_patch_features(&VisionCapabilities) plus square_merge_side (isqrt, non-squares rejected), and tensor_layout/bracketed() now read width from prepared metadata — exactly the route design-review.md:38-52 asks for. conditioned.rs:187 calls ImageProcessor::patch_features() instead of keeping a second width table. Atomic spans are now built by the layout that builds the envelope (layouts/bracketed.rs:52-88,104-107, mirroring layouts/deepseek.rs:149) instead of in the model/prompt.rs dispatcher, and there is a real span test (model/prompt.rs:1171-1256) plus server-side envelope/chunk bounds tests (server/config.rs:935-1021). The Gemma 4 envelope test no longer shells out to .venv/bin/python; it writes the {% mark %} template inline like its neighbours, and the live-parity test is #[ignore]d with hard assertions. The protobuf round-trip test for the new tag exists (runtime_core/protobuf.rs:812-860).

Residual nits (recorded, not blocking). The per-profile patch width is still authored in two independent match statements keyed on different enums — packing.rs:41-100 (ImageLayoutKind) and mod.rs:459-473 (Profile) — linked only by a test, not by the compiler; gemma4.rs:132 re-inlines 3 * patch_size² next to the patch_features() accessor that already computes it; the soft-token allowlist is duplicated between gemma4.rs:13 and ignition/preparation/frontend.py:132; patch_merge::Envelope is shared but still homed in patch_merge; server/config.rs:456 reaches into image-packing internals for the legacy-default rule; the new fixture generator copies pattern/digest from the GLM generator (consistent with how every generator is written); and bracketed.rs:57-65's marker-presence check partially duplicates the span-boundary validation in model.rs:441-456.

The proto tags, serde shapes, enum values, describe.rs/protobuf.rs arms and the Ignition branch all follow their per-profile precedents, and the Envelope extraction remains genuine de-duplication. Findings and citations are in scratchpad entry #14.

#16 [high] Verdict and coverage for the 2026-11-25 pass (head 2b4a31e)

PR #483 re-review, second pass. Head 2b4a31e, base main 27716185, 36 files +2269/-240. Branch was rebased and substantially rewritten after my previous report (#13), so findings from that report were re-verified from scratch rather than carried forward.

VERDICT: no blocking findings; no should-fix findings left in the conventions/duplication lens; seven nits (entry #14 items 1-7). The one residual structural risk worth a reviewer's eye is nit 1: per-profile patch width now lives in two independent matches (packing.rs:41-100 by ImageLayoutKind, mod.rs:459-473 by Profile), tied only by the processor_patch_features_match_tensor_layout_for_every_profile test (packing.rs:770-826). I graded it a nit because the duplication is bounded to two tables over the same 11 profiles and is test-covered; a compiler link (one delegating to the other) would close it.

WHAT WAS READ IN FULL OR IN SUBSTANTIAL CONTEXT THIS PASS: packing.rs (1-120 plus the new tests), conditioned.rs (150-240, 320-400), layouts/bracketed.rs (1-120), layouts/deepseek.rs (1-180), gemma4.rs (1-200, 330-420, plus diff), patch_merge.rs (1-220), model/prompt.rs (30-190, plus diff to 1284), model.rs (20-110, 400-480), server/config.rs (476-540, plus diff), mod.rs (960-1120, plus diff), runtime_core/protobuf.rs and describe.rs diffs, proto/runtime_core.proto, helios/build.rs, ignition/preparation/frontend.py (60-180, 240-300, plus diff), tests/frontend/generate_gemma4_image_fixtures.py, tests/frontend/generate_glm_image_fixtures.py, tests/preparation/test_frontend_gemma4.py, helios/tests/support/contracts/gemma4_frontend.json, docs/design-review.md, and the diffs for helios/README.md, docs/runtime-core-design.md, docs/TODO.txt, helios/model-contract.md, model/contract.rs, and the scheduler/server test-site patch_features: 0 updates.

NOT OPENED (judged non-substantive for this lens): the one-line additions in flare-cli/tests/unverified_payload.rs, helios/tests/deepseek_requests.rs, server/models.rs, server/protocol/decode.rs, server/request.rs, server/request/tml_tests.rs, server/runtime.rs, server/runtime/phase_tests.rs, scheduler/{boundary_tests,cache_memory,vision_window_tests}.rs (all patch_features: 0 struct-literal fills, seen via diff), tests/frontend/gemma4_images.json (consumed only through the Rust fixture reader at gemma4.rs:277-333), and the regenerated runtime_core_pb2.py descriptor blob beyond its header/version lines.

LIMITS: no build or test was run in this environment; every claim about behaviour is from reading the code and its callers. The author's claimed test counts are their own evidence. Nothing here assesses numerical parity with the HF processor, load-path performance, or serving behaviour — other lenses cover those.

#18 [high] Report of 2026-11-25 (head ab9a432): conventions & duplication, final

PR #483 (head ab9a432, base main 27716185) — conventions and duplication lens

Verdict: clean in this lens. No blocking or should-fix findings; 8 nits.

Verified this pass at the head (re-read, not just diff):

Nits (all with fixes)

  1. Per-profile patch width still authored twice, keyed on different enums. packing.rs:31-93 (ImageLayoutKind → width) and mod.rs:459-471 (Profile → same widths) are linked only by the test processor_patch_features_match_tensor_layout_for_every_profile (packing.rs:685-814). Fix: let one delegate to the other (e.g. tensor_layout takes the processor's patch_features()), so the compiler owns the invariant.
  2. Soft-token allowlist duplicated across languages. gemma4.rs:13 (SUPPORTED_SOFT_TOKENS) and ignition/preparation/frontend.py:132 (not in (70, 140, 280, 560, 1120)); no test ties them, and the Rust comment (gemma4.rs:11-12) documents the duplication deliberately. Fix: accept, or carry the allowed set in Gemma4ImageSettings so Helios validates prepared metadata.
  3. Envelope homed in a profile module. patch_merge.rs:10-17 documents itself as "shared by PatchMerge and Gemma4", and gemma4.rs:8 imports it from super::patch_merge. Fix: move to frontend/images/envelope.rs (or mod.rs beside ImageGeometry).
  4. max_patches computed twice. gemma4.rs:61-64 computes max_soft_tokens * pooling_area for the load check and gemma4.rs:98-100 (max_patches()) recomputes the same product for geometry. Fix: have load call the method (or store it).
  5. Validation style differs from its closest precedents. The two neighbouring fixed-geometry profiles pin their wire field to its one legal value — patch_merge.rs:92 (patch_size != 14), qwen.rs:22 (position_side != 48) — while gemma4.rs:27-40 accepts ranges (1..=64, 1..=16) that ignition/preparation/frontend.py:124-127,140-141 already fixed to 16/3 and :168-173 writes as literals. Keep the fields (the PatchMergeImageSettings.patch_size precedent supports them), but pinning 16/3 or citing the literal authors would read consistently.
  6. Module-const precedent unused for derived values. Fixed-geometry modules declare consts (glm.rs:13 FACTOR, padded_grid.rs:31-34 PATCH/MERGE/FEATURES, deepseek4.rs:10-11); gemma4.rs derives 768 at :86-88 and spells 48 px/768 in prose (helios/README.md:714-716) with no const. Fix: const FEATURES-style naming in gemma4.rs, or leave to nit 5's ruling.
  7. Gemma4ImageSettings literal repeated in six tests. gemma4.rs:228,252,295, packing.rs:782, prompt.rs:1181, config.rs:972, conditioned.rs:354. frontend::test_support (frontend/mod.rs:104) already exists for shared fixtures. Fix: one test_support::gemma4_settings() helper.
  8. Fixture generator copies helpers verbatim. tests/frontend/generate_gemma4_image_fixtures.py:17-24 (pattern, digest) is byte-identical to generate_glm_image_fixtures.py:18-25 apart from the comment. Every generator in tests/frontend/ is standalone, so this follows convention; a shared helper module would be the DRY form.

Precedents that hold (checked, no finding)

Proto tag 11 + Gemma4ImageSettings mirror PatchMergeImageSettings; contract_enum! appends Gemma4 = 11 without renumbering (model/contract.rs:68); #[serde(default)] tag 6 follows build.rs:20-56; describe.rs:451-452 and protobuf.rs:168-172 add arms beside the PatchMerge arms (and describe.rs:466-468 omits 0 so legacy describe JSON is unchanged); ImageSettings::Gemma4/Profile::Gemma4 arms mirror PaddedGrid in mod.rs:274-289,358-...; conditioned.rs:187 now uses the single width authority; the Envelope extraction is genuine de-duplication of patch_merge's expansion logic; the Ignition gemma4 branch (frontend.py:114-173) mirrors the glm branch (:174-189) including _expected for required and filtered-optional fields.

Limits

Read-only: no cargo test/pytest run here, so behavioural claims come from code and callers. Numerical parity, load cost, serving behaviour and prefix-cache partial-span behaviour are outside this lens.

#19 [high] Research summary

Reviewed PR #483 at head ab9a432 (38 files) through the conventions-and-duplication lens, comparing each new construct with its closest in-repo precedent and against AGENTS.md:188-199,352-364, docs/design-review.md principle 3 and the charter's "keep the runtime small and model-agnostic".

Verdict: no blocking or should-fix findings in this lens; 8 nits. Every item I raised in earlier passes is closed in the code, not only in the reply: gemma4::Processor::load now emits per-condition errors naming the field and both values (gemma4.rs:25-84); process calls self.patch_features() rather than re-inlining 3*patch_size² (gemma4.rs:164); the legacy 0 → 1176 rule moved onto the contract type as VisionCapabilities::bracketed_patch_features() (model.rs:72-80) and the duplicate Bracketed bootstrap check collapsed into one actionable error (server/config.rs:449-463); the README process paragraph is scoped to Qwen with per-profile width pointed at the accessor; the Gemma 4 fixture's model block (recorded image_*/boi_*/eoi_token_id) is now consumed by test_checked_in_gemma4_fixture_provenance_matches_image_settings; and a legacy Bracketed core with patch_features omitted is loaded end-to-end through Inputs::new and staged at 1176 floats (model/tests.rs:1277-1452).

Residual nits, all recorded with fixes: per-profile patch width is still authored in two matches over different enums (packing.rs:31-93 vs mod.rs:459-471) linked only by a test; the soft-token allowlist exists in two languages with nothing tying them; Envelope is shared but still homed in patch_merge; max_patches is computed twice in gemma4.rs; the load validation accepts ranges where patch_merge.rs:92/qwen.rs:22 pin the one legal value, and where glm.rs:13/padded_grid.rs:31-34 (not opened) would suggest a const; the settings literal is repeated in six tests despite frontend::test_support; and the new fixture generator copies pattern/digest verbatim from the GLM generator (consistent with every generator there).

Precedents that hold: proto tag 11 and Gemma4ImageSettings, contract_enum! append without renumbering, #[serde(default)] tag 6 in build.rs, the describe.rs/protobuf.rs (not opened) arms (with 0 omitted so legacy describe JSON is byte-identical), the Profile/ImageSettings arms mirroring PaddedGrid, the Ignition gemma4 branch mirroring glm, and the Envelope extraction as genuine de-duplication.

Limits: read-only — no build or test run, so behavioural claims come from code and callers; numerical parity, load cost, serving behaviour and partial-span prefix-cache behaviour are outside this lens. Full findings are note #18.

#20 [high] Coverage at head ab9a432: what was read per changed file

Coverage for PR #483 at head ab9a432 (38 files) through the conventions-and-duplication lens. "Read" = read in context at pr/483; "diff" = seen only through pr_diff/pr_files.

Read in context:

  1. helios/proto/runtime_core.proto — tag 11 gemma4 oneof arm, Gemma4ImageSettings (1-6), VisionCapacity.patch_features = 6, ImagePreparationKind value 11; mirrors PatchMergeImageSettings.
  2. helios/build.rs:53-56 — #[serde(default)] for VisionCapacity.patch_features, in the same chain as the other additive fields.
  3. helios/src/model.rs:44-103 — patch_features field with cfg'd serde(default), disabled(), bracketed_patch_features() (:72-80), validate() allowing 0 and requiring a multiple of 3 (:89).
  4. helios/src/model.rs:420-472 — validate_prompt_data span/marker enforcement (the layer the layout's bounds check sits in front of).
  5. helios/src/model/contract.rs:320-430 — ImageSpan, ImageTokenLayout::token_ids, PreparedContract::validate (vision↔layout↔image_tokens agreement).
  6. helios/src/frontend/images/gemma4.rs (whole file, 505 lines) — load/geometry/resized_rgb/process/expand_prompt plus all tests.
  7. helios/src/frontend/images/mod.rs:30-60, 240-360, 440-500 — module consts, ImageSettings/Gemma4ImageSettings/Profile, patch_features() and max_image_envelope_tokens().
  8. helios/src/frontend/images/packing.rs:1-200, 480-565, 565-816 — square_merge_side, tensor_layout, bracketed, class_token (precedent for the new guard style), both new tests.
  9. helios/src/frontend/images/patch_merge.rs:1-145 — Envelope extraction and Processor rebuild.
  10. helios/src/frontend/images/patches.rs (whole) — the PatchProcessor that Gemma 4 deliberately does not reuse; source of the 3*2*patch² inline.
  11. helios/src/frontend/images/glm.rs (whole) — const precedent (FACTOR, MIN/MAX_PIXELS) and the fixture test shape gemma4.rs mirrors.
  12. helios/src/frontend/images/qwen.rs:1-80 — position_side != 48 pinned-value precedent.
  13. helios/src/frontend/images/conditioned.rs:170-230 — patch_features() used for cache validation.
  14. helios/src/frontend/images/layouts/bracketed.rs (whole) — atomic_spans bool, flush_span, reworded error, tests.
  15. helios/src/frontend/images/layouts/deepseek.rs:1-167 — layout-owned data.spans precedent.
  16. helios/src/model/prompt.rs:30-90, 395-470 — the atomic_spans derivation passed into the layout and the test frontend's added tokens.
  17. helios/src/model/packing.rs:60-180 — Inputs::new calling tensor_layout at core load with &config.contract.vision.
  18. helios/src/model/tests.rs:1-200, 1000-1080, 1150-1460 — config()/manifest() fixtures and the full legacy-Bracketed load test.
  19. helios/src/model/testing.rs (whole) — shared fixture helpers (binding, metadata, manifest).
  20. helios/src/runtime_core/describe.rs:400-480 — vision_json Gemma 4 arm and the patch_features != 0 conditional.
  21. helios/src/server/config.rs:280-320, 440-495, 530-540 — bootstrap wiring, validate_loaded_image_processor, image_limits caller.
  22. helios/src/server/runtime/phase_tests.rs:5640-5760 — a Vision-graph fixture built by hand (precedent for the new model test).
  23. helios/src/execution/tests.rs:1186-1205 — BufferDescriptor literal precedent.
  24. ignition/preparation/frontend.py:1-90, 85-232, 230-316 — _token/_expected/tokenizer_settings, the gemma4 branch, prepare_frontend.
  25. ignition/preparation/contract.py:100-130 — model_contract default dict + docstring.
  26. ignition/preparation/runtime_core_pb2.py:1-20 — header and runtime-version block (also read at main).
  27. tests/frontend/generate_gemma4_image_fixtures.py (whole) and generate_glm_image_fixtures.py (whole).
  28. tests/frontend/gemma4_images.json — model block (:77-125, incl. the three token IDs) and the cases consumer contract.
  29. tests/preparation/test_frontend_gemma4.py (whole).
  30. tests/preparation/test_frontend_gemma4.py provenance test (:187-225) against the fixture blocks.
  31. helios/README.md:700-812, docs/runtime-core-design.md:175-250.
  32. helios/tests/support/contracts/gemma4_frontend.json (whole — still image_preparation: null, image_layout: null, image_tokens: null).
  33. Repo rules: AGENTS.md:170-210, 340-365, docs/design-review.md:31-52, 74.

Seen only via diff (all mechanical patch_features: 0 struct fills or one-line call-site changes): flare-cli/tests/unverified_payload.rs, helios/tests/deepseek_requests.rs, helios/src/scheduler/{boundary_tests,cache_memory,tests,vision_window_tests}.rs, helios/src/server/{models,protocol/decode,request,request/tml_tests,runtime}.rs, helios/src/model/contract.rs enum line, helios/model-contract.md, docs/TODO.txt, and the bulk descriptor blob of runtime_core_pb2.py (verified at header, runtime-version block, and the _globals offsets that moved by the new message).

Not established: whether a maintainer approved landing the profile ahead of its companion recipe (scope question, another lens); whether any published Bracketed core declares a non-square patches_per_feature (manifests live outside this repo).

#6 [medium] Should fix: runtime_core_pb2.py generator version downgraded to 7.36.1

ingestion/preparation/runtime_core_pb2.py header in the PR diff:

#7 [medium] Should fix: gemma4.rs test reinvents template fixture preparation

helios/src/frontend/images/gemma4.rs:243-320 checkpoint_tokens_expand_the_image_envelope builds its chat template by shelling out to ../.venv/bin/python with -c importing ignition.preparation.frontend.downloaded_template_asset and writing to std::env::temp_dir(). Precedents in the repository:

#8 [medium] Consistency checks that pass

Precedent checks that pass (no finding):

#9 [medium] Nits: protobuf test, duplicated allowlist, Envelope location

  1. Nit — no protobuf round-trip test for the new profile. Precedent: helios/src/runtime_core/protobuf.rs:726 serialized_glm_profile_selects_only_image_preparation and :749 serialized_padded_grid_profile_selects_only_image_preparation each assert the exact wire bytes select only the image preparation and that the profile loads. Gemma4 adds tag 11 (Gemma4ImageSettings gemma4 = 11) with no equivalent test, so the "additive, wire-compatible" claim in the PR description is checked only by the Python round trip the author ran by hand. Fix: add serialized_gemma4_profile_selects_only_image_preparation with the field-11 bytes (0x5a) and an ImageProcessor::load assertion.
  2. Nit — the supported soft-token allowlist is duplicated: gemma4.rs:11 SUPPORTED_SOFT_TOKENS: [usize; 5] = [70,140,280,560,1120] and ignition/preparation/frontend.py:123 if image.get("max_soft_tokens") not in (70, 140, 280, 560, 1120). Neighbouring profiles validate a range instead (deepseek_row_major.rs:14 (4..=1024).contains(&max_tokens)), so there is no established enumerated allowlist to follow. Keep one authority (the exported settings already carry the value) or derive the set from pooling_kernel_size/max_soft_tokens extremes; at minimum the two lists must not diverge.
  3. Nit — patch_merge::Envelope (patch_merge.rs:10-81) is now shared by gemma4; its doc comment says "shared by enveloped image layouts", so the module/home should follow the name (or the doc should say it currently serves patch-merge and Gemma 4).

#12 [medium] Severity correction: pb2 generator version is a nit

Entry 6 recorded runtime_core_pb2.py's Protobuf Python Version 7.36.2 -> 7.36.1 as "should fix". On reflection it is a nit:

Final severity list to report: