feat(stdlib): AURA BCI builtins — gaussian_kernel_1d·separable_blur·nearest_template·r2 (handoff f125d45c)#2207
Merged
Merged
Conversation
…arest_template·r2 (handoff f125d45c) Pure-hexa port over the farr handle API (no new C builtin), mirroring stats/correlation.hexa + consciousness/phi_spatial.hexa. + 10-falsifier self-test vs hand-computed numpy references. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…mmetric) + CHANGELOG + verdict Row-normalized Gaussian K is intentionally asymmetric at the boundary (edge rows sum to less than center rows pre-normalization), so the original F3 symmetry assertion was a false invariant — the self-test caught it. F3 now asserts the correct row-stochastic + edge-asymmetric property. hexa run → 10/10 PASS · __HEXA_STDLIB_AURA_BCI_KERNELS__ PASS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
AURA BCI .hexa-native porting primitives (handoff f125d45c)
Implements the 4 numpy-equivalent kernels the anima
AURA-*app set needs to drop its// TODO(f125d45c)stubs and compile/run.Surface (
stdlib/aura/bci_kernels.hexa)gaussian_kernel_1d(n, sigma)K[i,j]=exp(-(i-j)²/2σ²), each row ÷ its sum (Σ_j K[i,j]=1)K=np.exp(-(i-j)**2/(2σ**2)); K/=K.sum(1,keepdims=True)separable_blur(x, k, g)Y = K·reshape(x,[g,g])·K^TK @ x.reshape(g,g) @ K.Tnearest_template(y, templates, n_t, d)argmin_i ‖y−templates[i]‖²(int index, ties→lowest)int(np.argmin(((T-y)**2).sum(1)))r2(y, ref, n)1 − SS_res/SS_tot1 - ((y-r)**2).sum()/((r-r.mean())**2).sum()No new C builtin required
Pure-hexa port over the existing farr handle API (
farr_zeros/get/set/free) +self/runtime/math_pure.exp_pure— mirrors the establishedstdlib/stats/correlation.hexaandstdlib/consciousness/phi_spatial.hexaprecedent (stdlib-as-builtin over farr).add_gaussian_noise(RFC 033) andphi_spatial(RFC 036) already existed as builtins; these four close the remaining gap the handoff named.Verification — 10/10 falsifiers PASS
hexa run stdlib/aura/bci_kernels_test.hexa→__HEXA_STDLIB_AURA_BCI_KERNELS__ PASS(verbatim stdout committed at.verdicts/aura-bci-kernels/bci_kernels_test_2026_05_30.txt).gaussian_kernel_1d(5,1.0)every row sums to 1 (max |Δ| = 2.22e-16)gaussian_kernel_1d(3,1.0)center K[1,1] = 0.451863 (numpy 0.45186276187760605, asserted to 1e-9)gaussian_kernel_1d(4,1.5)row-stochastic AND edge-asymmetric (K[0,1] > K[1,0] — design, see note below)separable_blur(const 7.0)== const 7.0 (partition-of-unity)separable_blur(center impulse)center stays max, all ≥ 0nearest_templateexact → idx 3 · nearest(y≈[1.1,1.1,1.1]) → idx 1r2(y==ref)== 1.0 · F9r2known == 0.8 (exact) · F10 mean-predictor == 0.0Note on row-normalized Gaussian asymmetry (honest finding)
The first draft of F3 asserted K symmetry — that FAILED, and the self-test caught it. Row-normalized Gaussian K is intentionally asymmetric at the boundary: edge rows sum to less than center rows pre-normalization, so dividing each row by its own sum makes
K[0,1] ≠ K[1,0]. This is the standard weighted-average smoothing operator (every output is a proper convex combination of inputs) and matches numpyK/=K.sum(1,keepdims=True). The implementation was correct; the test invariant was wrong and is now fixed to assert the true row-stochastic + edge-asymmetric property. Module doc-comment updated accordingly.🤖 Generated with Claude Code