# MW/M31 Surface-Brightness Profile Explorer — Site Contract

## Purpose

Build a standalone, bilingual static Cloudflare Pages explainer that traces the Locatelli et al. (2024) reference Milky-Way model into draft Figure 3 and keeps model-conditioned M31 templates separate from the observed line-of-sight `CGMsum` measurements.

## Canonical project

- Local root: `mw_m31_profile_explorer/`
- Cloudflare Pages project: `m31cgm-mw-m31-profile-explorer`
- Default interface language: Chinese
- Canonical paper mirror link: `https://m31cgm-cgmsum-apj-draft.pages.dev/`

## Required narrative order

1. **What is measured?** EPIC measures `CGMsum = MW + M31 (+ Local Group)`, not a distance-resolved M31 component.
2. **Three coordinate questions.** Distinguish fixed-longitude Galactic latitude, the signed sky-plane M31→Galactic-center axis, and circular M31 projected radius.
3. **Reference density geometry.** Define the spherical halo and exponential disk and state that the implementation integrates `n_h^2 + n_d^2`, not `(n_h+n_d)^2`.
4. **Line-of-sight integration.** Show the observer-inside-the-MW geometry and 0.001–350 kpc integration.
5. **Observable bridge.** EM → intrinsic O VIII intensity → 80 eV response-matched emissivity closure → per-field absorbed 0.4–1.25 keV surface brightness.
6. **Latitude profile.** Fixed `l=l_M31`, southern `b=-|b|`; continuous broadband curve must say fixed `N_H=0.056e22 cm^-2`.
7. **Signed M31→GC profile.** Positive points toward the Galactic center, with `R_parallel=D_M31 tan(theta)`, `D_M31=780 kpc`; overlay actual fields separately.
8. **Observed radial profile.** Label every observational point `CGMsum`. Zhang is a conditional population-stack profile. Grayson values are 10–30 kpc bin bands, not radial curves.
9. **Figure-3 estimator bridge.** Distinguish 14-field min–max, N/S inverse-variance means, side-balanced central, and all-field inverse-variance central.
10. **Interpretation boundary and downloads.** Negative `CGMsum − MW_reference` is a model-tension residual, never negative M31 emission.

## Required figures

Every scientific figure must use SciencePlots `['science', 'no-latex']`, Agg, plain decimal ticks, and produce:

- `_1col.png` / `_1col.pdf`, width about 3.35 inch;
- `_2col.png` / `_2col.pdf`, width about 7 inch;
- PNG at 400 dpi or higher.

Figures:

1. MW latitude profile: halo, disk, total; EM/O VIII/broadband quantities available in data.
2. Signed M31→Galactic-center profile: fixed-NH curve plus actual-field absorbed predictions; include a fractional-change view.
3. Observed `CGMsum` versus M31 projected radius with local-covariance y errors and nominal 15 arcmin aperture radial spans (3.403 kpc) as horizontal extent bars, conditional Zhang profile, and Grayson 10–30 kpc bands. State that the horizontal bars are geometric aperture extents, not statistical errors or exact camera-mask-weighted radii.
4. Figure-3 field conversion/decomposition: direct-EM, closure-matched, and fixed-NH geometry-only field predictions plus estimator markers.

## Web interaction

- Sticky section navigation and direct EN/中文 toggle.
- Chinese is visible without JavaScript; English is available via a toggle.
- Figure mode buttons may switch among 2-column PNGs; all PDFs and 1-column assets remain downloadable.
- Expandable step-by-step derivations and data tables.
- Click-to-enlarge scientific figures with keyboard/Escape close.
- Tooltips/definitions for `CGMsum`, `EM`, `L.U.`, response closure, side-balanced, and all-field estimators.
- Respect `prefers-reduced-motion`; minimum 44 px interactive targets; visible focus states.
- Tables scroll horizontally on narrow screens; no page-level horizontal overflow.

## Scientific wording gates

Forbidden:

- calling the 14 observed points “M31 contribution” or “M31 profile” without `CGMsum`;
- calling the Locatelli 14-field min–max a credible/confidence interval;
- calling the diagonal parameter envelope a posterior interval;
- drawing Grayson 10–30 kpc bin values as radial curves;
- implying fixed-`N_H` continuous curves use a continuous HI4PI map;
- interpreting negative conditional residuals as negative physical emission.

Required phrases in both languages:

- “observed line-of-sight sum / 观测视线总和”;
- “conditional template / 条件模板”;
- “fixed-NH geometry curve / 固定NH的几何曲线”;
- “model-tension residual / 模型张力残差”.

## Build and verification

- Under a parent-level exclusive lock, snapshot and hash every input into a unique `.site-build-*` workspace, render its unique staging tree, validate all links/fragments/assets/manifest, recheck live input hashes, then atomically exchange the validated directory with `site/` using Linux `renameat2(RENAME_EXCHANGE)`.
- Parent files must survive failed and successful builds.
- Manifest `files` lists every public served asset except itself with byte size and SHA-256; `deployment_config` separately hashes non-downloadable Pages controls such as `_headers`. Production verification must compare the remote manifest, every public asset, and the effective security-response headers derived from `_headers`.
- Tests cover numerical closure, coordinate direction/sign, exact 14-field frozen predictions, terminology gates, bilingual parity, asset links, and manifest hashes.
- Production readback: HTTP 200 and matching bytes/SHA-256 for every manifest asset; browser console has zero errors; desktop and mobile screenshots are visually inspected.
