Repository navigation
Description
Overview
Audit #603 found incorrect internal-edge Sibson coordinates and near-edge cancellation that can return weights summing above one without a diagnostic flag. This follow-up is filed separately; the audit retains strict expected-failure witnesses.
Plan
- Reproduce independent square-symmetry, partition and both-sided continuity failures.
- Preserve natural-neighbor support on internal edges and distinguish hull-edge limits.
- Handle area cancellation before normalization and positive filtering.
- Validate eager/JIT behavior and promote audit regressions after repair.
Detailed implementation plan
Affected repositories: PyAutoArray (primary), autolens_workspace_test. Suggested branch: feature/sibson-internal-edge-continuity.
Inspect autoarray/inversion/mesh/interpolator/sibson.py:_sibson_single_from_tables, especially normalization/positive filtering and the unconditional on-edge barycentric fallback. Establish independent symmetric and asymmetric reference coordinates before choosing an algorithmic repair. Test internal versus hull edges, exact/nextafter/finite offsets, nonnegative partition and affine precision, diagnostic flags and eager/JIT parity. Run focused interpolation tests, full library tests and downstream source-recovery smoke. Queue behind audit #603; no implementation or new worktree begins during filing.
Current shared worktrees are on feature/mesh-interpolator-numerics-audit with audit-only tests/scripts uncommitted. User explicitly authorized separate filing of bugs found by the audit.
Original Prompt
Audit finding and authorized follow-up
Fix Sibson interpolation at internal edges
Type: bug
Target: PyAutoArray
Repos:
- PyAutoArray
- autolens_workspace_test
Difficulty: large
Autonomy: supervised
Priority: high
Status: formalised
Consequence: glance
Witness: Square-symmetry center weights are 1/4 each; near-edge weights remain nonnegative, sum to one, and agree continuously from both sides under eager/JIT execution.
Review-minutes: 15
Unattended: ready
Fix Sibson interpolation at internal edges
Type: bug
Target: autoarray
Repos:
- PyAutoArray
- autolens_workspace_test
Difficulty: large
Autonomy: supervised
Priority: high
Witness: Square-symmetry center weights are 1/4 each; near-edge weights remain nonnegative, sum to one, and agree continuously from both sides under eager/JIT execution.
Review-minutes: 15
Found during approved audit PyAutoArray#603. Original user instruction: "Any bug found is filed separately; this task is the audit, not the fixes."
In autoarray/inversion/mesh/interpolator/sibson.py:_sibson_single_from_tables, every on-edge query is replaced with seed-triangle barycentric weights, including internal edges where off-edge natural neighbors contribute. For square points [(-1,-1),(-1,1),(1,-1),(1,1)], query(0,0), independent symmetry requires four weights0.25 and interpolated y*x=0. Actual weights0.5 for opposite diagonal nodes yield1. Lattice mesh boundary sweep found jumps up to0.02680921 at +/-1e-8 around internal edge midpoints.
Near the square center at (+/-1e-8,0), cancellation yields returned positive weights summing1.123877166 and interpolated yx=-1.123877166, with no overflow/degenerate flag. Code normalizes signed contributions before discarding negative weights. At epsilon0.01 weights sum1 and yx is near0; error worsens at1e-6 and1e-8.
Plan a separate algorithmic repair preserving full natural-neighbor cavities at internal edges, using a hull-edge limiting rule only where appropriate, and robustly handling area cancellation before normalization/filtering. Validate independent symmetric and asymmetric reference fixtures, both-sided finite and nextafter edge probes, affine precision, partition/nonnegative support, eager/JIT parity and source recovery. Promote audit strict xfails after repair. No production fix is part of audit#603; shared worktrees remain claimed by the audit until shipping.
Activity
Jammy2211 commentedon Nov 9, 2026
Algorithm plan (2026-11-09): for maintainer approval before any implementation
Root cause
_sibson_single_from_tables(and its numba twin_sibson_numba._sibson_from_tables) uses Watson's per-triangle decomposition. For every cavity triangle it forms the circle through the queryqand each of that triangle's three edges, including edges interior to the cavity. Those interior terms cancel in exact arithmetic, but whenqis on or near an interior edge that circle is (nearly) collinear and its centre runs to infinity. That produces both audit failures:Proposed algorithm: stolen areas from the cavity boundary only (no circle through an interior edge)
The stolen area of natural neighbour
vis|cell_new(q) ∩ cell_old(v)|, a convex polygon. Its boundary decomposes into segments, each separating two sites, so its area is a sum of segment terms½·cross(P−q, P′−q), measured relative to q and credited (+/−) to the two sites the segment separates:(a,b)shared by cavity trianglesT, T′: the old Voronoi edgec(T) → c(T′), credited +b / −a (for CCWa→binT). Only stored circumcentres are used here, never a circle throughq.(a,b)of triangleT: the in-cell piecec(T) → c_new(q,a,b)of the a|b Voronoi edge, credited +b / −a.c_new(q,a,b)is the only circle through q, and it is formed only on boundary edges.c_new(q,a,v) → c_new(q,v,b), where(a,v)and(v,b)are v's incoming and outgoing boundary edges (exactly one each, since the cavity is a topological disk). Credited to v.Since
qlies strictly inside the cavity, it is collinear with a boundary edge only if that edge is a hull edge and q is on it. Internal edges through or nearqare interior to the cavity and are never singular, so no on-edge special case is needed at internal edges.Rules by case:
Area cancellation is handled before normalisation:
|neg| ≤ tol·totalto 0 before normalising. A larger negative, or a mismatch between Σ areas and the independently summed new-cell polygon area (the closed loop of step-3 vertices), raises the existingdegenerateflag (NaN row; the perf: skip Sibson row padding in adaptive signals and unique mappings (DelaunayNN imaging) #629empty_failedcontract is kept).Shapes and caps are unchanged:
max_neighborssemantics are unchanged.c_newinto the existing compact neighbour slots (in/out per vertex): static-shape for JAX, a flat loop for numba.Prototype evidence (standalone NumPy, brute cavity, independent oracle = half-plane-clipped Voronoi cells)
y·x = 1Implementation surfaces
autoarray/inversion/mesh/interpolator/sibson.py:_sibson_single_from_tables, the NumPy and JAX bodies. Keep the BFS cavity (_cavity_triangle_indexes_{numpy,jax}); replace Watson contributions, on-edge override and normalise-then-filter.autoarray/inversion/mesh/interpolator/_sibson_numba.py:_sibson_from_tables, same algorithm in both theprangeand serial builds (fix: run numba prange kernels serially in multiprocessing search workers (#676) #677).sibson_serial_kernel_loses_allocation_hoisting(same numba body): land this repair first, then do the hoisting on the new body. Rewriting the per-query scratch twice would be wasted work.Validation (as the prompt asks)
y·x/ linear fields exact.nextafternormal offsets. Continuity asserted as|w(±δ) − w(0)| ≤ L·δ + 1e-14, with the exactly-on-edge value equal to the limit.Σ wᵢ pᵢ = qand linear fields exact to 1e-12, including near-edge and near-hull queries.test__sibson_serial_kernel_equals_parallel_kernel.test_sibson_square_center_matches_independent_symmetry_oracleandtest_sibson_near_edge_preserves_partition_after_positive_filterto ordinary tests.misc/jax_assertions/{delaunay_nn, delaunay_nn_caps}.py,imaging/mesh_interpolator_source_recovery.pyand the DelaunayNNjax_likelihoodscripts. Also measure the per-query kernel cost (autolens_profilingdelaunay_nnscripts): expected neutral-or-faster with C+2 circles instead of 3C.Phasing and consequence (for your decision)
mainred. That gives PR 1: PyAutoArray, both bodies plus the full test suite above. PR 2: autolens_workspace_test DelaunayNN pins.glance. DelaunayNN likelihoods will change wherever data points sit on or near internal edges, which is common: Hilbert image-mesh vertices are data-pixel centres, so traced data points can land exactly on edges. I recommend treating this asjudge(human/prm), as with fix: pseudo-determinant for intrinsic regularization log det H #683/fix: KNN neighbour search for a partial final point block #684.Implementation waits for approval of: (a) the boundary-formulation algorithm, (b) the PR split, (c) the consequence tier.
Prototype core (standalone; the oracle and probe drivers are in the session scratch)
Generated by Claude Code
Jammy2211 commentedon Nov 9, 2026
Library PR Created: #685 (+ workspace autolens_workspace_test#359)
The approved plan is implemented, split by repo, tier judge.
mesh_magnification.py's identity leg by −2.65% (1% tolerance). DelaunayNN now integrates its own Sibson basis (the feat: exact KNN mesh magnification areas + fix partial-block neighbour search (arc phase 4b) #665 kNN quadrature, shared), giving +0.04%, better than main's −0.41%. This affects the magnification diagnostic only, not the likelihood.Generated by Claude Code
Jammy2211 commentedon Nov 9, 2026
Library merged: #685 (af80e69), 2026-11-09, via
/prmwith CI 3/3 greenThis stays open for the workspace half, autolens_workspace_test#359 (documentation only). Its smoke CI is red for reasons outside its diff:
main(they're in autolens_workspace_test#358). The three failing scripts areimaging/jax_likelihood/{delaunay,rectangular}.pyandinterferometer/jax_likelihood/rectangular.py.smoke-tests.ymlwarningsNameError.In that same run,
mesh_magnification.py,mesh_interpolator_source_recovery.pyand the DelaunayNN assertions all pass against #685.Order to finish: fix PyAutoHeart, then
/prm#358, then/prm#359.Generated by Claude Code
Jammy2211 commentedon Nov 9, 2026
Shipped — 2026-11-09
mesh_magnification.py.nextafter); NumPy = numba = JAX-jit. The audit's 3 strict xfails are promoted.sibson_serial_kernel_loses_allocation_hoisting.Generated by Claude Code