Skip to content

Commit c5aa65e

Browse files
Rust-first quality hardening: move Kerr horizon to core and enforce presentation gates.
Extend the golden oracle, add C7/W9/fmt CI checks, consolidate shared UI/shell modules, and split audio synthesis so physics stays in Rust and regressions are caught mechanically.
1 parent 257fdd9 commit c5aa65e

50 files changed

Lines changed: 1050 additions & 372 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030

3131
- **UI sound feedback.** Replaced sharp 880 Hz menu beeps with soft procedural clicks,
3232
warm confirm chimes, muted deny thuds, and gentler deposit clinks. Ops tab switches
33-
use a quieter tick.
33+
use a quieter tick. WAV synthesis lives in `scripts/audio/audio_synth.gd`; `AudioManager`
34+
handles buses and playback only.
35+
36+
- **Rust-first quality hardening.** Kerr outer horizon (`outer_horizon_radius_rg`) in
37+
`accretion-core` with gdext `horizon_in_rg`; extended astropy golden oracle (horizon,
38+
ISCO, efficiency, blackbody RGB). Mechanical gates C7 (presentation-boundary scan),
39+
W9 (wiki `implements` paths), and `cargo fmt --check` in `make check`. Shared UI
40+
modules (`UpgradeCatalog`, `MilestoneFormat`, `RunFlow`, `UpgradePanelLogic`),
41+
`GameShell` autoload, `GameState.UPGRADE`, throttled ops refresh and run stats emit.
3442

3543
- **Visual drama pass (F011).** Replaced flat ambient with intent-lit scene: hard warm
3644
BH-motivated key + cool rim, ambient dropped to 0.12 for contrast; ACES tonemap and

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Operational bootstrap: **[AGENTS.md](AGENTS.md)**.
77

88
## Quick checklist
99

10-
1. **Clone setup:** `./scripts/setup-hooks.sh` (once per clone).
10+
1. **Clone setup:** `./scripts/setup-hooks.sh` (once per clone) or `make setup`.
1111
2. **Dependencies:** `pip install -r scripts/requirements.txt`, Rust stable, Godot 4.7.
1212
3. **Before push:** `make check` must pass (includes wiki validation).
1313
4. **Wiki:** update for any scope/behavior change; cite feature `id:` if applicable.

‎Makefile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ godot-presentation: build
6161
fi; \
6262
"$$GODOT" --headless --path . res://scenes/PresentationTests.tscn
6363

64-
check: gen hooks
64+
check: gen
6565
git diff --exit-code crates/accretion-core/src/constants.rs
6666
git diff --exit-code crates/accretion-core/tests/fixtures/golden.json
6767
sh scripts/check_invariants.sh
6868
sh scripts/check_wiki.sh
6969
cargo test --workspace
7070
cargo clippy --workspace --all-targets -- -D warnings
71+
cargo fmt --check
7172
$(MAKE) godot-smoke
7273
$(MAKE) godot-presentation
74+
75+
setup: hooks

‎bin/libgodot_ext.dylib‎

1.78 KB
Binary file not shown.

‎crates/accretion-core/src/derived.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ mod tests {
5353

5454
const RTOL: f64 = 0.000000001;
5555

56+
#[test]
57+
fn h_bar_matches_reduced_planck() {
58+
let expected = H_PLANCK / (2.0 * std::f64::consts::PI);
59+
assert!((H_BAR - expected).abs() <= RTOL * expected.abs());
60+
}
61+
5662
#[test]
5763
fn sigma_sb_matches_closed_form() {
5864
let expected =

‎crates/accretion-core/src/kerr.rs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ pub fn isco_radius(spin: f64) -> f64 {
3636
3.0 + z2 - ((3.0 - z1) * (3.0 + z1 + 2.0 * z2)).sqrt()
3737
}
3838

39+
/// Outer (event) horizon radius in units of `R_g = GM/c^2` for prograde Kerr.
40+
///
41+
/// BPT (1972): `r_+ = R_g (1 + sqrt(1 - a^2))`. Schwarzschild limit: `2 R_g` at `a = 0`.
42+
pub fn outer_horizon_radius_rg(spin: f64) -> f64 {
43+
let a = spin;
44+
1.0 + (1.0 - a * a).max(0.0).sqrt()
45+
}
46+
3947
/// ISCO radius \[cm\] for mass `m_bh_msun` and spin `spin`.
4048
pub fn r_isco(m_bh_msun: f64, spin: f64) -> f64 {
4149
isco_radius(spin) * gravitational_radius_cm(m_bh_msun)
@@ -140,6 +148,23 @@ mod tests {
140148
assert!((isco_specific_angular_momentum(0.0) - expected).abs() < TOL);
141149
}
142150

151+
#[test]
152+
fn outer_horizon_schwarzschild_is_two_rg() {
153+
assert!((outer_horizon_radius_rg(0.0) - 2.0).abs() < TOL);
154+
}
155+
156+
#[test]
157+
fn outer_horizon_shrinks_with_prograde_spin() {
158+
assert!(outer_horizon_radius_rg(0.9) < outer_horizon_radius_rg(0.0));
159+
assert!(outer_horizon_radius_rg(0.998) < outer_horizon_radius_rg(0.9));
160+
}
161+
162+
#[test]
163+
fn specific_angular_momentum_at_isco_schwarzschild() {
164+
let expected = 6.0 * 2.0_f64.sqrt();
165+
assert!((specific_angular_momentum(6.0, 0.0) - expected).abs() < TOL);
166+
}
167+
143168
#[test]
144169
fn orbital_frequency_scales_inversely_with_mass() {
145170
const M: f64 = 10.0;

‎crates/accretion-core/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub use eddington::{
4242

4343
pub use kerr::{
4444
THORNE_SPIN_LIMIT, efficiency_from_spin, gravitational_radius_cm, isco_radius,
45-
isco_specific_angular_momentum, isco_specific_energy, orbital_frequency_hz, r_isco, r_s,
46-
specific_angular_momentum,
45+
isco_specific_angular_momentum, isco_specific_energy, orbital_frequency_hz,
46+
outer_horizon_radius_rg, r_isco, r_s, specific_angular_momentum,
4747
};
4848

4949
// --- Disk ------------------------------------------------------------------

‎crates/accretion-core/tests/fixtures/golden.json‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,88 @@
5151
},
5252
"radius": "20.0*R_S",
5353
"expected": 1918879.3025530614
54+
},
55+
{
56+
"fn": "outer_horizon_radius_rg",
57+
"args": {
58+
"spin": 0.0
59+
},
60+
"expected": 2.0
61+
},
62+
{
63+
"fn": "outer_horizon_radius_rg",
64+
"args": {
65+
"spin": 0.5
66+
},
67+
"expected": 1.8660254037844386
68+
},
69+
{
70+
"fn": "outer_horizon_radius_rg",
71+
"args": {
72+
"spin": 0.998
73+
},
74+
"expected": 1.0632139225171164
75+
},
76+
{
77+
"fn": "isco_radius",
78+
"args": {
79+
"spin": 0.0
80+
},
81+
"expected": 6.0
82+
},
83+
{
84+
"fn": "efficiency_from_spin",
85+
"args": {
86+
"spin": 0.0
87+
},
88+
"expected": 0.057190958417936755
89+
},
90+
{
91+
"fn": "isco_radius",
92+
"args": {
93+
"spin": 0.9
94+
},
95+
"expected": 2.320883041761887
96+
},
97+
{
98+
"fn": "efficiency_from_spin",
99+
"args": {
100+
"spin": 0.9
101+
},
102+
"expected": 0.15575299199446402
103+
},
104+
{
105+
"fn": "blackbody_rgb",
106+
"args": {
107+
"temp_k": 10000.0
108+
},
109+
"expected": {
110+
"r": 0.6107029755863023,
111+
"g": 0.6953388614148782,
112+
"b": 1.0
113+
}
114+
},
115+
{
116+
"fn": "blackbody_rgb",
117+
"args": {
118+
"temp_k": 1000000.0
119+
},
120+
"expected": {
121+
"r": 0.30118764851471985,
122+
"g": 0.43900865221295887,
123+
"b": 1.0
124+
}
125+
},
126+
{
127+
"fn": "blackbody_rgb",
128+
"args": {
129+
"temp_k": 10000000.0
130+
},
131+
"expected": {
132+
"r": 0.2998291305366286,
133+
"g": 0.4376873079904965,
134+
"b": 1.0
135+
}
54136
}
55137
]
56138
}

‎crates/accretion-core/tests/golden.rs‎

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,53 @@ fn golden_matches_astropy_oracle() {
1515
let doc: serde_json::Value = serde_json::from_str(&f).expect("invalid golden.json");
1616

1717
for case in doc["cases"].as_array().expect("cases array") {
18-
let exp = case["expected"].as_f64().expect("expected f64");
19-
let got = match case["fn"].as_str().expect("fn name") {
20-
"sigma_sb" => phys::SIGMA_SB,
21-
"sigma_t" => phys::SIGMA_T,
22-
"l_eddington" => phys::l_eddington(case["args"]["m_bh_msun"].as_f64().unwrap()),
23-
"disk_temperature" => phys::disk_temperature(
24-
case["args"]["r_cm"].as_f64().unwrap(),
25-
case["args"]["m_bh_msun"].as_f64().unwrap(),
26-
case["args"]["mdot_gs"].as_f64().unwrap(),
27-
),
18+
let fn_name = case["fn"].as_str().expect("fn name");
19+
match fn_name {
20+
"sigma_sb" => {
21+
let exp = case["expected"].as_f64().expect("expected f64");
22+
assert_relative_eq(phys::SIGMA_SB, exp, ORACLE_RTOL);
23+
}
24+
"sigma_t" => {
25+
let exp = case["expected"].as_f64().expect("expected f64");
26+
assert_relative_eq(phys::SIGMA_T, exp, ORACLE_RTOL);
27+
}
28+
"l_eddington" => {
29+
let exp = case["expected"].as_f64().expect("expected f64");
30+
let got = phys::l_eddington(case["args"]["m_bh_msun"].as_f64().unwrap());
31+
assert_relative_eq(got, exp, ORACLE_RTOL);
32+
}
33+
"disk_temperature" => {
34+
let exp = case["expected"].as_f64().expect("expected f64");
35+
let got = phys::disk_temperature(
36+
case["args"]["r_cm"].as_f64().unwrap(),
37+
case["args"]["m_bh_msun"].as_f64().unwrap(),
38+
case["args"]["mdot_gs"].as_f64().unwrap(),
39+
);
40+
assert_relative_eq(got, exp, ORACLE_RTOL);
41+
}
42+
"outer_horizon_radius_rg" => {
43+
let exp = case["expected"].as_f64().expect("expected f64");
44+
let got = phys::outer_horizon_radius_rg(case["args"]["spin"].as_f64().unwrap());
45+
assert_relative_eq(got, exp, ORACLE_RTOL);
46+
}
47+
"isco_radius" => {
48+
let exp = case["expected"].as_f64().expect("expected f64");
49+
let got = phys::isco_radius(case["args"]["spin"].as_f64().unwrap());
50+
assert_relative_eq(got, exp, ORACLE_RTOL);
51+
}
52+
"efficiency_from_spin" => {
53+
let exp = case["expected"].as_f64().expect("expected f64");
54+
let got = phys::efficiency_from_spin(case["args"]["spin"].as_f64().unwrap());
55+
assert_relative_eq(got, exp, ORACLE_RTOL);
56+
}
57+
"blackbody_rgb" => {
58+
let exp = &case["expected"];
59+
let got = phys::blackbody_rgb(case["args"]["temp_k"].as_f64().unwrap());
60+
assert_relative_eq(got.0, exp["r"].as_f64().unwrap(), ORACLE_RTOL);
61+
assert_relative_eq(got.1, exp["g"].as_f64().unwrap(), ORACLE_RTOL);
62+
assert_relative_eq(got.2, exp["b"].as_f64().unwrap(), ORACLE_RTOL);
63+
}
2864
other => panic!("unknown fn {other}"),
29-
};
30-
assert_relative_eq(got, exp, ORACLE_RTOL);
65+
}
3166
}
3267
}

‎crates/godot-ext/src/lib.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ impl BlackHole {
105105
phys::isco_radius(self.spin)
106106
}
107107

108+
#[func]
109+
fn horizon_in_rg(&self) -> f64 {
110+
phys::outer_horizon_radius_rg(self.spin)
111+
}
112+
108113
/// New mass \[M_sun\] after accreting at the current feed rate for `dt_s` \[s\].
109114
#[func]
110115
fn advance_mass(&self, dt_s: f64) -> f64 {

0 commit comments

Comments
 (0)