# Localize the background failure to anomaly detection — 2026-10-03

**Follow-up:** `BACKGROUND_CANDIDATES_20261003.md` tests local and
component-crop replacements, rejects circular gates on correlated-noise
controls, and extends the paired test to three epochs. That extension also
exposes negative interpolated anomaly RMS values; a positive representation
is tested without changing the science uncertainty plane. No production
or full light-curve acceptance is implied by these controls.

**Conclusion:** the distant response first enters the historical background
algorithm's SEP-based anomaly repair, after the filled/smoothed image. SEP
deblending changes anomaly-catalogue shapes when unrelated image content
changes; those shapes control hard masks. Disabling deblending suppresses
the measured distant response, but also substantially reduces anomaly-mask
coverage. It is a diagnostic control, not yet an accepted repair. The full
photometric objective remains unmet and the RAW science candidate is unchanged.

Run: `/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/`.
Owned worktree: `/home/kshukawa/syndiff_pipeline/dev/.worktrees/temporal-raw-epsf`,
local branch `codex/temporal-raw-epsf`. All scripts below are under
`temporal_raw_epsf/`; nothing is pushed or installed into production.

## Observe the unchanged calculation

`background_stage_trace.py` observes returns and selected local variables
inside the frozen producer module, SHA256
`54a3ecd53566c64f9b02b2c055eb863f4fb4ee13e80f1df314a104ac98a38571`.
It does not substitute a reimplementation. Both baseline and +1-ppt injection
are recomputed in one process at FFI 602 for Gaia 1629810213318424704. The
full-frame float32 response and float64 source-aperture input stamps exactly
match the independently verified paired probe in `BACKGROUND_TRANSFER.md`.

For each intermediate map,

$$e_{s,j}=-10^6\frac{\sum_p w_{s,p}\,[B_{j,p}(D+\epsilon J)-B_{j,p}(D)]}{F_s}.$$

Here $e$ is the conditional stage response in ppm, $s$ labels a source and $j$
an algorithm stage. The pixel index is $p$. The dimensionless $w$ are the
existing fixed r3 aperture/sky weights, and $F_s$ is the measured RAW r3
rate in electrons/second. Each $B_j$ is a stage image in electrons/second
per pixel. The frozen RAW-minus-template residual is $D$; $J$ is the
conditional extended profile defined in the preceding report, normalized
to the injected target's RAW r3 rate; $\epsilon=0.001$ is the chosen fractional
injection. Components are coupled stages, not independent errors to sum.

| Stage | Maximum absolute remote aperture response [ppm] |
|---|---:|
| Filled/smoothed image | 1.33e-11 |
| Anomaly-repaired image, before smoothing | 97.162 |
| Anomaly-repaired image, after Gaussian smoothing | 98.811 |
| Residual correction before suppression | 1.266 |
| Residual correction after suppression | 53.289 |
| Final background | 97.186 |

Remote means more than 100 native pixels from the injected star, with exactly
zero injected counts on every scored remote aperture. Tiny values are
floating-point-scale responses in a deterministic test, not photometric noise.
The initial boundary mask is identical. The anomaly SEP mask changes at 2,028
pixels, 2,016 remote; later residual suppression changes at 121 pixels, 117
remote. The exact source of that later response is downstream of the first
anomaly changes and is not counted as a separate proven physical cause.

![Stage images locate the first distant change](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_stage_trace/assessment/stage_difference_maps.png)

![Underlying stage changes at actual remote star apertures](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_stage_trace/assessment/stage_remote_stamps.png)

## Object-catalogue versus noise-map controls

`background_anomaly_trace.py` independently reproduces the saved baseline
and injected SEP anomaly masks exactly. The global growth-curve noise value,
0.02900934126228094, is unchanged. Substituting the original object catalogue
while retaining the changed maps/noise eliminates all 2,028 mask changes.
Conversely, changed objects with original maps/noise reproduce all of them.
Freezing only the noise does not remove the changes. These substitutions
diagnose propagation; using an old catalogue is not a deployable correction.

`background_sep_locality.py` then seals both data and noise outside 200 pixels
to their original values and examines masks beyond 400 pixels. The default
detector still changes 1,902 remote pixels. Cleaning disabled gives 2,592;
deblending disabled gives zero, with or without cleaning. Original masks
are reproduced before interpreting these controls. Some undecomposed
islands are large, so a separate independent-object test follows below.

| Detector configuration | Baseline anomaly-mask pixels | Changed remote mask pixels, sealed-input test |
|---|---:|---:|
| Default | 46,843 | 1,902 |
| Cleaning disabled | 55,253 | 2,592 |
| Deblending disabled | 15,727 | 0 |
| Both disabled | 16,224 | 0 |

![Actual detector masks and their changes](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_stage_trace/assessment/sep_locality_masks.png)

## Independent-object demonstration and implementation evidence

`sep_independent_blends.py` builds two widely separated pairs of analytic
Gaussians. Remove only the first pair; the second pair's pixels and noise
are exactly identical. Cleaning is disabled in both arms. Default deblending
changes three remote pixel assignments, the remote ellipse's major-axis
estimate by up to 0.02259 pixel and its minor-axis estimate by 0.01841 pixel.
Centroids remain identical. An identical-input repeat is exact. Disabling
deblending produces one unsplit remote detection with unchanged measurements.
This is a locality test, not a TESS PSF-accuracy or anomaly-completeness test.

![Actual independent-pair images, fitted ellipses and changed assignments](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/sep_independent_blends/independent_blend_images.png)

The version-matched SEP 1.4.1 source resets a thread-local random seed at the
start of an extraction, then consumes that shared sequence when assigning
remaining pixels during deblending. A changed earlier object can therefore
change later assignments while the later object's pixels remain fixed.
This is consistent with the demonstrated cross-object flux/shape changes.
Sources: [extract.c](https://raw.githubusercontent.com/sep-developers/sep/v1.4.1/src/extract.c),
[deblend.c](https://raw.githubusercontent.com/sep-developers/sep/v1.4.1/src/deblend.c).
Installed package versions are frozen in the input manifest; no library
build or source patch was installed.

The background helper uses the deblended ellipse to choose pixels for an
S/N acceptance test, followed by a hard radial-growth decision. Changes in
those shapes can thus change entire anomaly masks. The library behaviour
is unsuitable for assuming that this background decision is strictly local;
this is not a claim that every use of SEP is scientifically invalid.

## Complete background-step control

The existing paired probe now supports a process-local diagnostic override
of `sep.extract(..., deblend_cont=1)`. It recomputes baseline and perturbation
on the same historical residual, template, mask and biharmonic fill; the
override is called twice as expected. The +/-1-ppt target errors become
−0.374660/+0.374660 ppm, approximately odd in amplitude. For the positive
probe, the maximum remote science/reference responses are 1.97e-11/6.53e-6
ppm in this deterministic calculation, versus 29.766/97.186 ppm originally.
The negative remote control agrees at the corresponding precision.

![Actual full-background responses under the deblending and fill controls](/astro/armin/koji/syndiff/dev_runs/temporal_raw_epsf_20261001/results/background_stage_trace/assessment/full_operator_controls.png)

This does not validate replacing the detector: its mask covers roughly a
third as many pixels. Which omitted detections are useful repairs versus
false detections is untested. The harmonic-fill control remains a separate
mitigation; it does not imply the interpolation itself produced the first
distant change.

## Execution and remaining work

All jobs are on plscience3 and terminal exit 0: stage trace 1810 (159 s),
anomaly substitution 1813 (77 s), detector locality 1818 (84 s), independent
blends 1823 (12 s), full no-deblend probes 1827/1828 (97/113 s), and
figure/score job 1830 (20 s). Exact commands and snapshots
are in the corresponding named `condor/` directories. All five published
figures were inspected. The synthetic figure's clipped title was redrawn
from unchanged saved arrays; its numerical results were not rerun or changed.

Next test a deterministic local anomaly decision, or validate the simpler
fill/detection alternatives against known injected background artifacts.
Preserve useful anomaly-removal capability as well as stellar signals.
Then extend the paired tests to orbit edges/middles, more magnitudes/colours
and CCD locations, before rebuilding and accepting a shadow hp_d series.
The original RAW photometry, ePSF/WCS, reference uncertainty and full noise
budget still require their own acceptance checks.

**Conclusion:** the nonlocal background failure is localized to a specific
anomaly-detection mechanism with exact replay, sealed-input and independent
object controls. Mitigations suppress the tested response, but no replacement
operator or photon-limited time series is accepted yet.
