Restore the saturated intercept count by uncueing the embedded radar (#145)
build / mod (push) Failing after 31s
build / mod (push) Failing after 31s
The heavy WASM scenario (wasm_flat_budget, 64 integrated complexes vs two `airdef wave oreshnik 40 2600`) lost intercepts at the tick-2102 checkpoint: 522 (main) -> 302 (#133) -> 243 (#134). Decomposed by A/B on one fixture, one host (2bcce64), one SDK, each slice built from its own commit: - 522 -> 302 (#133): Track.vel became an estimate from noisy measured places (it was the target's true velocity); the forecast, the aim lead and the interceptor's launch Fix all read it. Forcing the class estimate to Unknown leaves the count unchanged (native 296 ~= 294), so class/roles is not the cause. The pre-#133 522 used the target's true velocity, which the #133 contract "class and speed only from measurements" forbids; this portion is the intentional cost of honest measurement-only tracks and is kept. - 302 -> 243 (#134): the network cue was extended from the separate engagement radar to every fire-quality radar, including each weapon's embedded radar. Cueing every relayed contact each tick flooded the embedded fire control with one-tick plots whose noisy velocity degraded guidance. Restricting the cue back to separate radars recovers the whole drop: 243 -> 325. - own_fire_within / FIRE_QUALITY / channels are NOT causes here: relaxing the own-fire gate or the channel limit each changed nothing (243 -> 243). Embedded radars always measure Fire plots of quality >= 64 and have no channel limit. - #140 does not affect this loadout, by fact: the fixture deploys no separate radar, so every profile is embedded with channels = 0; the channel-age bug binds only where a profile has channels, and the channels-off A/B was flat. Fix: the cue looks only through a separate fire-quality radar (sam.kind == SamKind::Radar); the embedded radar keeps its beam/revisit/lock acquisition as before #134. All radar profiles, channel limits, own-fire authority and the measurement-only class/speed contract are preserved; no target truth is injected. Measured after the fix (WASM, fuel budget 300M/tick): checkpoint 325 intercepts / 2011 hits, fuel max 118M; final (tick 3302, two late Smart raids) 385 / 2472, fuel max 176M; zero fuel failures. The first late raid reports the #135 recon flight ("Разведка противника: впереди налёта высланы разведчики"); the second is silent (recon budget spent) — the fixture now expects exactly that instead of the stale empty chat that stopped the scenario. Tests: - airdef-mod/tests/saturation.rs: deterministic native replica of the checkpoint (same sim, host block tracer) asserting the restored count and a regression threshold, plus the #140 loadout fact (no separate radar, channels = 0). - Sim::launch_audit (why.rs): on-demand tolerance diagnostic counting why each (system, drone) pair holds fire — no track / stale / no authority / role / doctrine / reach / claimed / not ready / not aimed / terrain / ready. - sensor_tests: a network plot cues a separate fire radar but not the embedded one. - wasm_flat_budget baselines re-measured with provenance comments; the asserted fixture SHA in tools/airdef.py updated. Verification: `python3 tools/airdef.py test-budgets` passes both stages and the two late raids (283 steps, fuel failures = 0). airdef-core 292 + 8, mod lib 104, mod scenarios 5, saturation 2 — all green. A/B record: docs/measurements/issue-145-intercept-regression.json. Co-Authored-By: Kimi Code <noreply@moonshot.ai> Integration note (shipped engine 8e711f969): the tick-2102 checkpoint baseline is unchanged and passes on the shipped engine (325 intercepts / 2011 hits). The final stats baseline was re-measured on the shipped engine with #146 integrated (one knowledge snapshot per Smart order changes the two late raids): 414 / 2463, world 8885 sections / 420671 rays / 3442845 cells. The asserted fixture SHA in tools/airdef.py was updated to match. python3 tools/airdef.py test-budgets passes all 283 steps with zero fuel failures (tick max 184608537 / 300000000).
This commit is contained in:
@@ -599,6 +599,41 @@ fn network_relay_keeps_source_age_and_quality_but_not_launch_authority() {
|
||||
assert!(!why::radar_cue(&sim.sams[receiver], &[&sim.sams[engagement]], id, sim.tick), "a broken link still cued a launch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_network_plot_cues_a_separate_fire_radar_but_not_the_embedded_one() {
|
||||
// #145: a fire-quality radar is cued to look at a network contact, but the weapon's own
|
||||
// embedded radar is not — cueing every relayed contact each tick flooded the embedded fire
|
||||
// control with one-tick plots and degraded the intercepts. The embedded radar keeps its
|
||||
// beam/revisit/lock acquisition; a separate engagement radar still takes the cue.
|
||||
let mut sim = Sim::new(145);
|
||||
let search = radar_with_role(&mut sim, RadarRole::Search, 0.0);
|
||||
let engagement = radar_with_role(&mut sim, RadarRole::Engagement, 10.0);
|
||||
let embedded = {
|
||||
let id = sim.id();
|
||||
sim.sams.push(Sam::new(id, SamKind::S400, DVec3::new(20.0, 70.0, 0.0), 0.0));
|
||||
sim.sams.len() - 1
|
||||
};
|
||||
sim.add_drone(DroneKind::Shahed, DVec3::new(150.0, 120.0, 0.0), DVec3::Z, DVec3::new(150.0, 120.0, 0.0));
|
||||
let id = sim.drones[0].id;
|
||||
let at = sim.drones[0].pos;
|
||||
let away = DVec3::new(-600.0, 120.0, 0.0);
|
||||
let mut ground = Ground::default();
|
||||
for tick in 1..=8 {
|
||||
sim.tick = tick;
|
||||
// The search radar measures the contact; the embedded and engagement radars look away,
|
||||
// so only a cue (not the beam, a revisit or a lock) could give them an own plot.
|
||||
sim.sams[search].beam = bearing(sim.sams[search].pos, at);
|
||||
sim.sams[embedded].beam = bearing(sim.sams[embedded].pos, away);
|
||||
sim.sams[engagement].beam = bearing(sim.sams[engagement].pos, away);
|
||||
sim.update_sight(&mut ground);
|
||||
}
|
||||
let emb = sim.sams[embedded].track(id).expect("the embedded radar holds the network track");
|
||||
assert_eq!(emb.own_tick, 0, "the embedded radar cue-measured a relayed contact (#145)");
|
||||
assert!(!emb.own_authorizes(sim.tick), "a relayed plot gave the embedded radar fire authority");
|
||||
let eng = sim.sams[engagement].track(id).expect("the engagement radar holds the track");
|
||||
assert!(eng.own_tick > 0, "a separate fire-quality radar was not cued by the network plot");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_air_picture_prefers_the_better_plot_at_one_tick() {
|
||||
let mut sim = Sim::new(1345);
|
||||
|
||||
@@ -511,9 +511,12 @@ impl Sim {
|
||||
// The beam passes its bearing this tick (the angle wraps at 2π: the difference is taken round).
|
||||
let in_beam = swept(rel.x.atan2(-rel.z), b0, w);
|
||||
let revisit = scan.agile && held.is_some_and(|t| t.own_tick > 0 && now - t.own_tick >= (period / 3.0) as u64);
|
||||
// A network plot cues a fire-quality radar to look, but is never itself a
|
||||
// measurement: reach, terrain, probability and noise still apply.
|
||||
let cue = profile.allows(battery::Measure::Fire)
|
||||
// A network plot cues a *separate* fire-quality radar to look, but is never itself
|
||||
// a measurement: reach, terrain, probability and noise still apply. The weapon's
|
||||
// own embedded radar is not cued: measuring every relayed contact each tick flooded
|
||||
// its fire control with one-tick plots whose noisy velocity degraded the intercepts
|
||||
// (#145); it keeps its beam/revisit/lock acquisition, as before the profiles (#134).
|
||||
let cue = sam.kind == SamKind::Radar && profile.allows(battery::Measure::Fire)
|
||||
&& held.is_some_and(|t| t.own_tick == 0 && t.age(now) <= MISSILE_AGE);
|
||||
if !(in_beam || locked || revisit || cue) {
|
||||
continue;
|
||||
|
||||
@@ -272,6 +272,153 @@ pub(super) fn gun_blocks(s: &Sam, aim_id: u32, gt: u32, aim_error: f64, dist: f6
|
||||
| (if s.bursts > 0 { 0 } else { NO_ROUNDS })
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the saturation audit (#145)
|
||||
|
||||
/// Why the armed systems hold their fire, counted over every (system, alive drone) pair at the
|
||||
/// moment of the call: the same predicates `step_sams` decides with, in the decision's order, so
|
||||
/// each pair lands on the first ground that stops it. On demand only — the diagnostic a
|
||||
/// regression scenario reads, never per-tick work. A pair the system would launch at now counts
|
||||
/// as `ready`; the interceptor outcomes (a launch that missed) are the session's [`Tally`].
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct LaunchAudit {
|
||||
/// The system's picture holds no track of the drone at all.
|
||||
pub no_track: u32,
|
||||
/// Its track is older than a launcher fires on (`MISSILE_AGE`).
|
||||
pub stale: u32,
|
||||
/// No own confirmed fire plot: a relayed or search plot, quality below `FIRE_QUALITY`, or own
|
||||
/// measurement too old — the track is there but does not authorize a launch.
|
||||
pub no_authority: u32,
|
||||
/// The estimated class is out of the system's roles, and no last chance applies.
|
||||
pub role: u32,
|
||||
/// The doctrine (sector, guarded objects, reserve) holds the shot.
|
||||
pub doctrine: u32,
|
||||
/// The forecast place is beyond the missile's reach, and no long shot is allowed.
|
||||
pub out_of_reach: u32,
|
||||
/// Enough interceptors are on it already (`doctrine.needed`).
|
||||
pub claimed: u32,
|
||||
/// The launcher is not ready: cooldown, reload, no rounds, failed.
|
||||
pub not_ready: u32,
|
||||
/// The mount is not laid on the target yet.
|
||||
pub not_aimed: u32,
|
||||
/// The land ruled the shot out (the cached verdict; an uncached one resolves within a tick).
|
||||
pub terrain: u32,
|
||||
/// Nothing stops the pair: the system would launch at it now.
|
||||
pub ready: u32,
|
||||
}
|
||||
|
||||
impl LaunchAudit {
|
||||
/// The non-zero counts as a line, for a scenario report.
|
||||
pub fn text(&self) -> String {
|
||||
let parts = [
|
||||
(self.no_track, "нет трассы"),
|
||||
(self.stale, "трасса протухла"),
|
||||
(self.no_authority, "нет права на пуск"),
|
||||
(self.role, "вне ролей"),
|
||||
(self.doctrine, "доктрина"),
|
||||
(self.out_of_reach, "вне дальности"),
|
||||
(self.claimed, "занята перехватчиками"),
|
||||
(self.not_ready, "пусковая не готова"),
|
||||
(self.not_aimed, "не наведена"),
|
||||
(self.terrain, "рельеф"),
|
||||
(self.ready, "готова стрелять"),
|
||||
];
|
||||
parts.iter().filter(|(n, _)| *n > 0).map(|(n, name)| format!("{name}: {n}")).collect::<Vec<_>>().join(", ")
|
||||
}
|
||||
}
|
||||
|
||||
impl Sim {
|
||||
/// The saturation audit: every armed system against every alive drone, attributed to the first
|
||||
/// ground that stops the shot. Reads the tracks' estimates and provenance, never the target's
|
||||
/// own class or velocity (#133).
|
||||
pub fn launch_audit(&self) -> LaunchAudit {
|
||||
let mut a = LaunchAudit::default();
|
||||
let now = self.tick;
|
||||
let (missile_on, _) = engagement_counts(&self.sams);
|
||||
let radars: Vec<&Sam> = self.sams.iter().filter(|s| s.kind == SamKind::Radar).collect();
|
||||
let opts = Opts { last_chance: self.last_chance, far_shots: self.far_shots };
|
||||
for sam in &self.sams {
|
||||
let Some(load) = sam.kind.spec().missile.as_ref() else { continue };
|
||||
if !sam.alive() || sam.moving() {
|
||||
continue;
|
||||
}
|
||||
let spec = sam.kind.spec();
|
||||
let mount = sam.mount().0;
|
||||
let lead_speed = spec.gun.as_ref().map_or(5.0, |g| g.shell);
|
||||
let cued = |id: u32| !radars.is_empty() && radar_cue(sam, &radars, id, now);
|
||||
// Long shots only while nothing of the system's roles is in its normal reach.
|
||||
let role_in_reach = !radars.is_empty()
|
||||
&& sam.tracks.iter().any(|tr| {
|
||||
self.drones.iter().find(|d| d.id == tr.id).is_some_and(|d| {
|
||||
claimed(d, &missile_on, sam.target) < sam.doctrine.needed(d, tr.class)
|
||||
&& basis(sam, load, tr, d, now, claimed(d, &missile_on, sam.target), 1.0, opts, cued(tr.id), true) == Some(Basis::Role)
|
||||
})
|
||||
});
|
||||
for d in self.drones.iter().filter(|d| d.alive()) {
|
||||
let Some(tr) = sam.track(d.id) else {
|
||||
a.no_track += 1;
|
||||
continue;
|
||||
};
|
||||
let blocks = target_blocks(sam.roles, Some(tr), now, d);
|
||||
if blocks & STALE != 0 {
|
||||
a.stale += 1;
|
||||
continue;
|
||||
}
|
||||
let own = tr.own_authorizes(now);
|
||||
let cue = cued(d.id);
|
||||
let authorized = if sam.mode == battery::SamMode::LauncherOnly { cue } else { own || cue };
|
||||
if !authorized {
|
||||
a.no_authority += 1;
|
||||
continue;
|
||||
}
|
||||
let est = tr.class;
|
||||
let free = claimed(d, &missile_on, sam.target);
|
||||
let chance = blocks & ROLE != 0 && last_chance(self.last_chance, sam.roles, est, d, free);
|
||||
if blocks & ROLE != 0 && !chance {
|
||||
a.role += 1;
|
||||
continue;
|
||||
}
|
||||
if blocks & ROLE == 0 && sam.doctrine.area_blocks(sam.pos, tr, now) | sam.doctrine.reserve_blocks(sam.missiles, d, est) != 0 {
|
||||
a.doctrine += 1;
|
||||
continue;
|
||||
}
|
||||
let est_at = tr.est(now);
|
||||
let reach = reach_blocks(load.min, load.max, 1.0, sam.pos, est_at);
|
||||
let far = reach == TOO_FAR
|
||||
&& reach_blocks(load.min, load.max, FAR_K, sam.pos, est_at) == 0
|
||||
&& far_blocks(opts.far_shots, sam, load, cue, role_in_reach) == 0;
|
||||
if reach != 0 && !(far && blocks & ROLE == 0) {
|
||||
a.out_of_reach += 1;
|
||||
continue;
|
||||
}
|
||||
if reach == 0 && !(own || sam.mode == battery::SamMode::LauncherOnly) {
|
||||
a.no_authority += 1;
|
||||
continue;
|
||||
}
|
||||
if free >= sam.doctrine.needed(d, est) {
|
||||
a.claimed += 1;
|
||||
continue;
|
||||
}
|
||||
if missile_blocks(sam) != 0 {
|
||||
a.not_ready += 1;
|
||||
continue;
|
||||
}
|
||||
let (_, want_yaw, want_pitch) = aim_wants(mount, est_at, tr.vel, lead_speed);
|
||||
let err = aim_error(spec.family, sam.yaw, sam.pitch, want_yaw, want_pitch);
|
||||
if !missile_aligned(spec.family, sam.yaw, mount, Some(est_at), d.id, d.id, err) {
|
||||
a.not_aimed += 1;
|
||||
continue;
|
||||
}
|
||||
if sam.terrain_verdict(d.id, now).unwrap_or(0) != 0 {
|
||||
a.terrain += 1;
|
||||
continue;
|
||||
}
|
||||
a.ready += 1;
|
||||
}
|
||||
}
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the diagnostic
|
||||
|
||||
/// A diagnostic condition and its structured or legacy reason.
|
||||
|
||||
Reference in New Issue
Block a user