Skip to content

Fix critical/high findings from whole-codebase audit - #32

Merged
hd152 merged 1 commit into
mainfrom
fix/audit-critical-high
Sep 24, 2026
Merged

hd152 merged 1 commit into
mainfrom
fix/audit-critical-high

Conversation

@hd152

@hd152 hd152 commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the 13 critical/high-severity bugs from a whole-codebase audit. Each fix has a regression test that fails on the old code. The one exception is #12's native path: that needs the old wheel to demonstrate, so only its numpy mirror was checked against the old code.

# Area Bug → fix
1 auto_settings Presets that don't list a setting were ignored when blending it, so one preset's value applied to every target (e.g. galaxy coarse chroma 0 → 50 on a 97% star-field blend). Unlisted presets now vote for the baseline value; booleans take the value with the largest total weight.
2 frame_processor Pool workers only got array masters. dark_exptime never arrived, so mismatched-exposure darks were subtracted unscaled on the default parallel path.
3 cli d = masters['dark'] overwrote the target-directory loop variable, so hierarchical sessions with darks lost their info.json (Bayer, WCS, GPS, name).
4 photometry_core, color_calibrate A 3-axis WCS from the (3,H,W) cube broke Gaia projection, so --photometry never produced results.
5 color_calibrate median(r / median(r)) is always 1, so --color-calibrate never changed the image. Now uses median(expected / measured).
6 stacking With --auto at 15+ frames, median/linear_fit/ivw/wavelet silently became an unrejected patch-weighted mean.
7 registration match_stars_affine subtracted the calculate_shift seed instead of adding it, so seeded affine failed for shifts over ~5 px.
8 pipeline Phase-1/2 checkpoint resume skipped target inference and the auto-advisor. A shared _infer_target_and_advise now runs on every path.
9 psf_deconvolution The blind-PSF "RL refinement" flattened the PSF (peak 0.068 → 0.011). Removed.
10 difference_imaging ZOGY kernel flux powers were swapped, so S_corr was not unit-variance when flux_new ≠ flux_ref.
11 time handling Origin DATE-OBS is local time with TIMEZONE stored separately. The new utils.obs_time_utc_iso applies it (dispersion zenith angle, photometry airmass, light-curve MJD), the stacked header now keeps TIMEZONE, and a below-horizon zenith angle returns None.
12 stacking + Rust fold_pixel Online sigma-clip (--stream) froze pixels seeded by one sample. They now accept samples until they have 3. astro_native 0.36.0 → 0.37.0.
13 frame_processor The GPU master cache was keyed on shape/dtype and only checked on a new shape, so the next target in the same process reused stale GPU masters. It is now keyed on host-array identity and checked per frame.

Behaviour changes to be aware of

Test plan

  • pytest -q -n auto: 1723 passed
  • ruff check . clean; tools/lint_conventions.py 0 errors (same 15 pre-existing warnings)
  • Each new test verified to fail against the pre-fix source (for Bump signpath/github-action-submit-signing-request from 1 to 3 #12, only the numpy path)
  • Re-run a real session with --auto and compare against the 2.3.0 output
  • CI native job builds 0.37.0 and passes parity tests

🤖 Generated with Claude Code

Thirteen correctness bugs, each with a regression test that fails on the
old code:

- auto_settings: settings only some presets define were blended over
  those presets alone, so one preset's value (galaxy coarse chroma,
  nebula aniso diffusion, pre_gradient_removal) applied to every
  target. Unlisted presets now vote for the baseline value.
- frame_processor: pool workers never received scalar masters
  (dark_exptime), so mismatched-exposure darks were subtracted unscaled
  on the default parallel path.
- cli: the calibration-analysis block reassigned the target-directory
  loop variable to the master dark, so hierarchical sessions with darks
  lost their info.json metadata.
- photometry_core/color_calibrate: 3-axis WCS from the stacked cube made
  --photometry and --color-calibrate fail silently; the colour
  correction ratio was also self-normalised to exactly 1.
- stacking: the patch-weighted path replaced median/linear_fit/ivw/
  wavelet with an unrejected weighted mean under --auto.
- registration: match_stars_affine subtracted the calculate_shift seed
  instead of adding it.
- pipeline: phase-1/2 checkpoint resume skipped target inference and
  the auto-advisor (shared helper now used on every path).
- psf_deconvolution: removed the broken blind-PSF "RL refinement" that
  flattened the PSF.
- difference_imaging: ZOGY matched-filter kernel flux powers swapped.
- utils/photometry*/pipeline: apply the FITS TIMEZONE to Origin's local
  DATE-OBS (obs_time_utc_iso), keep TIMEZONE in the stacked header, and
  decline a below-horizon zenith angle.
- stacking + native fold_pixel: online sigma-clip froze pixels seeded by
  one sample; accept until 3 samples. astro_native 0.37.0.
- frame_processor: GPU master cache keyed by host-array identity and
  checked per frame, so a later target can't reuse stale GPU masters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hd152
hd152 merged commit c23410a into main Sep 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant