Repository navigation
defk-o08.6: rolling_stats mean_std raises on a bad window, so its loop keeps no bounds check - #72
Merged
Merged
Conversation
…p keeps no bounds check A raising guard 'if w < 1 or w > n' before the loop gives 1 <= w <= n, which proves x[i - w] and both out writes: the module's report lists no kept bounds check (was 3), the flagged strip carries float checks only, and clang's remark no longer cites the array bounds (the sliding sums still keep the loop scalar). A window outside 1..length(x) now raises ArgumentError at the call. non_finite_test's mixed-error strip case moves to an unguarded copy of the kernel; the catalog kernel gets a test of its guard (docs/performance.md 6.42). Closes the last gap of epic defk-o08.
DanielLuning
pushed a commit
that referenced
this pull request
Oct 20, 2026
…port 3 -> 0 kept bounds checks; non_finite_test's mixed-error case on an unguarded copy; mix ci green."
DanielLuning
pushed a commit
that referenced
this pull request
Oct 20, 2026
…026-10-20) closed the last gap; the closing check's catalog kernels list none of the children's bounds checks (cosine_topk, pcm_mix sum loop, rolling_stats mean_std). Compile time: +3.5% of the work before step 1 after defk-o08.2-o08.5."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The last gap of epic
defk-o08, found in its closing check.defk-9zawas opened forexamples/rolling_stats.exsmean_std, whereold = if i >= w, do: x[i - w], else: 0.0keeps a bounds check.defk-b38made the compiler drop that check once a raising guard establishesw >= 1, and9zaclosed on a test kernel that has the guard. The catalog kernel never got the guard.examples/rolling_stats.exs:mean_stdnow starts withif w < 1 or w > n, do: raise(ArgumentError, "the window must be in 1..length(x)"). Past the guard,1 <= w <= nholds: anorthat is false narrows both sides. That provesx[i - w], and bothoutwrites, becausem = n - w + 1 >= 1andlength(out) == 2 * m. The kernel's comment and the example's header say so.test/non_finite_test.exs: a test used the catalogmean_stdwith invalid windows (-1,0) to put a bad value and an out-of-range read or a zero divisor in one flagged strip. The guard now raises first, which is correct in Elixir order, and both modes agree.Defk.NonFiniteTest.Rolling, an unguarded copy of the old kernel. Its assertions and C checks are unchanged.w = -1,0andn + 1raise the guard'sArgumentErrorbefore any read; a NaN with a valid window still raises;w = nsucceeds; and the C still checks the window-sum reads once per strip, with no checked read left.docs/performance.md: a new entry 6.42.Results
From the fast-path report under
report: :full, before → after:x[i - w],out[i - w + 1],out[m + i - w + 1]).docs/agents/runs.md).How it was checked
mix cion the laptop (macOS) passed: 2305 tests, Credo found no issues, Dialyzer reported 0 errors.mix defk.examples --only rolling_stats: the example's check passed, without timing.mix dump_c examples/rolling_stats.exs:Rolling.Kernels.reportlists all four accesses as dropped.Touches a promised surface? No: an example script and a test. No
CHANGELOG.mdentry.Touches
test/stability/? No.