feat(tahuantinsuyu): fase 13 — Solar Return como sexto overlay

Sexto módulo siguiendo el patrón establecido. Cambio estructural:
3-way mutual exclusion para los módulos que comparten el outer ring
(transit + synastry + solar_return). Constante OUTER_RING_MODULES
abstrae el grupo para que fase 14+ pueda sumar lunar return / planet
returns sin tocar la lógica del shell.

- engine: PipelineRequest::SolarReturn { target_age_years } +
  build_solar_return_overlay. Llama eternal_astrology::next_return
  (Sun back to natal Sun, ventana ±1.5 años) desde un instante
  ~30 días antes del cumpleaños target. Computa la carta natal
  completa al return_instant (mismo observer + config natales —
  convención clásica) y la apila como Outer + Aspects cross natal ×
  return. z=12/13. Import: `next_return` añadido a la lista de
  re-exports del bridge.
- modules: solar_return::SolarReturnModule (id "solar_return", toggle
  + slider target_age_years 0..120 step 1.0). Registry pasa a 6
  módulos para Natal.
- shell: OUTER_RING_MODULES const con los tres ids; mutual exclusion
  generalizada de pair-wise a N-way (for-loop sobre el slice). Init
  de age en apply_selection ahora incluye solar_return. build_requests
  agrega la rama. Misma estructura que progression/solar_arc en la
  rama de age handling.
- canvas: aspect_endpoints("solar_return") = (bodies, transits). Tres
  loops del outer ring (paint dots, paint glyphs, anillos guía) ahora
  aceptan los tres module_ids.

Probarlo: en el panel, slider "Edad del retorno" en valor entero (ej.
36) + toggle "Activar" = ves la carta del año cuando volviste a tu
Sol natal a los 36, con todos sus planetas en el outer ring y cross
aspects con tu natal. Cambiando el slider podés explorar año por año.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-17 11:23:25 +00:00
parent d9e21fbedc
commit 8d95833c20
5 changed files with 203 additions and 26 deletions
+22 -15
View File
@@ -144,7 +144,7 @@ impl Shell {
// edad actual. Estos quedan en module_configs como // edad actual. Estos quedan en module_configs como
// valor base si el usuario nunca tocó el slider. // valor base si el usuario nunca tocó el slider.
self.module_configs.clear(); self.module_configs.clear();
for module_id in ["progression", "solar_arc"] { for module_id in ["progression", "solar_arc", "solar_return"] {
let entry = self let entry = self
.module_configs .module_configs
.entry(module_id.into()) .entry(module_id.into())
@@ -239,6 +239,12 @@ impl Shell {
}); });
} }
} }
if module_enabled(&self.module_configs, "solar_return") {
let age = self.module_age_or_current("solar_return");
requests.push(PipelineRequest::SolarReturn {
target_age_years: age,
});
}
requests requests
} }
@@ -475,17 +481,13 @@ impl Shell {
if let serde_json::Value::Object(map) = entry { if let serde_json::Value::Object(map) = entry {
map.insert(key.clone(), value.clone()); map.insert(key.clone(), value.clone());
} }
// Transit y Synastry comparten el outer ring del // Transit, Synastry y Solar Return comparten el
// canvas — son mutuamente excluyentes. Al prender // outer ring del canvas — son mutuamente excluyentes.
// uno, apagamos el otro y sincronizamos el panel. // Al prender uno, apagamos los otros + sync panel +
if key == "enabled" && bool_val { // persist.
let conflicting = match module_id.as_str() { if key == "enabled" && bool_val && OUTER_RING_MODULES.contains(&module_id.as_str()) {
"transit" => Some("synastry"), for &other in OUTER_RING_MODULES.iter() {
"synastry" => Some("transit"), if other != module_id && module_enabled(&self.module_configs, other) {
_ => None,
};
if let Some(other) = conflicting {
if module_enabled(&self.module_configs, other) {
set_module_enabled(&mut self.module_configs, other, false); set_module_enabled(&mut self.module_configs, other, false);
let other_str = other.to_string(); let other_str = other.to_string();
self.panel.update(cx, |p, cx| { self.panel.update(cx, |p, cx| {
@@ -496,9 +498,9 @@ impl Shell {
} }
} }
// Sincronizar visualmente el toggle [T] del canvas // Sincronizar visualmente el toggle [T] del canvas
// cuando el cambio afecta el outer ring (transit o // cuando el cambio afecta el outer ring (transit,
// synastry — ambos lo usan). // synastry o solar_return).
if (module_id == "transit" || module_id == "synastry") && key == "enabled" { if OUTER_RING_MODULES.contains(&module_id.as_str()) && key == "enabled" {
self.canvas.update(cx, |c, cx| { self.canvas.update(cx, |c, cx| {
c.set_layer_visible(LayerKind::Outer, bool_val, cx) c.set_layer_visible(LayerKind::Outer, bool_val, cx)
}); });
@@ -520,6 +522,11 @@ impl Shell {
// Helpers de module_configs // Helpers de module_configs
// ===================================================================== // =====================================================================
/// Módulos que pintan en el outer ring del canvas — mutuamente
/// excluyentes a nivel de UI. Al prender uno, los otros se apagan.
const OUTER_RING_MODULES: &[&str] = &["transit", "synastry", "solar_return"];
/// Etiqueta breve para mostrar al elegir una carta en el picker: /// Etiqueta breve para mostrar al elegir una carta en el picker:
/// `"YYYY-MM-DD · Lugar"` cuando hay lugar, sino solo la fecha. /// `"YYYY-MM-DD · Lugar"` cuando hay lugar, sino solo la fecha.
fn format_birth_brief(birth: &tahuantinsuyu_model::StoredBirthData) -> String { fn format_birth_brief(birth: &tahuantinsuyu_model::StoredBirthData) -> String {
@@ -572,7 +572,9 @@ fn render_wheel(
if visible.get(&LayerKind::Outer).copied().unwrap_or(true) { if visible.get(&LayerKind::Outer).copied().unwrap_or(true) {
for layer in &render.layers { for layer in &render.layers {
if matches!(layer.kind, LayerKind::Outer) if matches!(layer.kind, LayerKind::Outer)
&& (layer.module_id == "transit" || layer.module_id == "synastry") && (layer.module_id == "transit"
|| layer.module_id == "synastry"
|| layer.module_id == "solar_return")
{ {
for g in &layer.glyphs { for g in &layer.glyphs {
let (x, y) = polar_to_screen(g.deg, asc, rot_offset, radii.transits); let (x, y) = polar_to_screen(g.deg, asc, rot_offset, radii.transits);
@@ -727,12 +729,12 @@ impl Radii {
/// Resuelve qué radios corresponden a una capa de aspectos según el /// Resuelve qué radios corresponden a una capa de aspectos según el
/// `module_id`: natal-natal en `aspects`, cross con cada overlay /// `module_id`: natal-natal en `aspects`, cross con cada overlay
/// desde `bodies` (extremo natal) al ring del módulo. Synastry /// desde `bodies` (extremo natal) al ring del módulo. Synastry y
/// comparte el outer ring de tránsito (son mutuamente excluyentes /// Solar Return comparten el outer ring de tránsito (los tres son
/// a nivel de Shell). /// mutuamente excluyentes a nivel de Shell).
fn aspect_endpoints(&self, module_id: &str) -> (f32, f32) { fn aspect_endpoints(&self, module_id: &str) -> (f32, f32) {
match module_id { match module_id {
"transit" | "synastry" => (self.bodies, self.transits), "transit" | "synastry" | "solar_return" => (self.bodies, self.transits),
"progression" => (self.bodies, self.progression), "progression" => (self.bodies, self.progression),
"solar_arc" => (self.bodies, self.solar_arc), "solar_arc" => (self.bodies, self.solar_arc),
_ => (self.aspects, self.aspects), _ => (self.aspects, self.aspects),
@@ -945,7 +947,9 @@ fn paint_wheel(
// si alguno de los dos está prendido, pintamos el slot. // si alguno de los dos está prendido, pintamos el slot.
let outer_active = layers.iter().any(|l| { let outer_active = layers.iter().any(|l| {
matches!(l.kind, LayerKind::Outer) matches!(l.kind, LayerKind::Outer)
&& (l.module_id == "transit" || l.module_id == "synastry") && (l.module_id == "transit"
|| l.module_id == "synastry"
|| l.module_id == "solar_return")
}); });
if outer_active && show(LayerKind::Outer) { if outer_active && show(LayerKind::Outer) {
stroke_circle( stroke_circle(
@@ -968,7 +972,9 @@ fn paint_wheel(
let dot_r = (radii.sign_outer * 0.017).max(2.0); let dot_r = (radii.sign_outer * 0.017).max(2.0);
for layer in layers { for layer in layers {
if matches!(layer.kind, LayerKind::Outer) if matches!(layer.kind, LayerKind::Outer)
&& (layer.module_id == "transit" || layer.module_id == "synastry") && (layer.module_id == "transit"
|| layer.module_id == "synastry"
|| layer.module_id == "solar_return")
{ {
for g in &layer.glyphs { for g in &layer.glyphs {
let color = with_alpha(planet_color(palette, &g.symbol), 0.85); let color = with_alpha(planet_color(palette, &g.symbol), 0.85);
@@ -9,8 +9,8 @@ use std::sync::OnceLock;
use std::time::Instant; use std::time::Instant;
use eternal_astrology::{ use eternal_astrology::{
find_aspects, find_synastry_aspects, secondary_progression, solar_arc_true, Aspect, find_aspects, find_synastry_aspects, next_return, secondary_progression, solar_arc_true,
AspectKind as EAspectKind, BirthData, BodySet, ChartConfig, HouseSystem as EHouseSystem, Aspect, AspectKind as EAspectKind, BirthData, BodySet, ChartConfig, HouseSystem as EHouseSystem,
NatalChart, OrbTable, Zodiac as EZodiac, NatalChart, OrbTable, Zodiac as EZodiac,
}; };
use eternal_sky::{Ayanamsha, Body, EphemerisSession, Instant as ESInstant, Observer, SessionConfig}; use eternal_sky::{Ayanamsha, Body, EphemerisSession, Instant as ESInstant, Observer, SessionConfig};
@@ -264,6 +264,15 @@ pub fn compose(
crate::PipelineRequest::Synastry { partner_chart } => { crate::PipelineRequest::Synastry { partner_chart } => {
build_synastry_overlay(&natal, partner_chart, &mut render)?; build_synastry_overlay(&natal, partner_chart, &mut render)?;
} }
crate::PipelineRequest::SolarReturn { target_age_years } => {
build_solar_return_overlay(
&natal,
&config_e,
observer,
*target_age_years,
&mut render,
)?;
}
} }
} }
@@ -531,6 +540,100 @@ fn build_synastry_overlay(
Ok(()) Ok(())
} }
/// Helper: agrega al `RenderModel` las capas del overlay de Solar
/// Return — la carta natal completa computada al instante en que el
/// Sol vuelve a su posición natal en el año pedido. Esa nueva carta
/// va en el anillo externo (compartido con Transit/Synastry —
/// mutuamente excluyentes a nivel de Shell). Cross aspects natal ×
/// return.
fn build_solar_return_overlay(
natal: &NatalChart,
config_e: &ChartConfig,
observer: Observer,
target_age_years: f64,
render: &mut RenderModel,
) -> Result<(), EngineError> {
let session = session()?;
let natal_sun = natal.placement(Body::Sun).ok_or_else(|| {
EngineError::Eternal("natal chart sin Sol — Solar Return imposible".into())
})?;
let natal_sun_lon = natal_sun.longitude.longitude_rad();
// Buscar el próximo retorno desde un punto razonable antes del
// cumpleaños del año target. Restamos 30 días para garantizar que
// el retorno (que cae ~en la fecha de nacimiento) quede DENTRO de
// la ventana de búsqueda.
const TROPICAL_YEAR_SECS: f64 = 365.242190 * 86400.0;
let after_seconds = (target_age_years * 365.242190 - 30.0) * 86400.0;
let after_utc = natal
.birth
.instant
.utc()
.add_seconds(after_seconds.max(-TROPICAL_YEAR_SECS * 2.0));
let after = ESInstant::from_utc(after_utc);
let return_instant = next_return(session, Body::Sun, natal_sun_lon, after, None)
.map_err(|e| EngineError::Eternal(format!("next_return Sun: {:?}", e)))?;
// La carta del retorno se computa al return_instant con el mismo
// observer y config natales (convención clásica: solar return
// tropical en la ciudad de nacimiento).
let return_birth = BirthData::new(return_instant, observer);
let return_chart = NatalChart::compute(&return_birth, config_e, session).map_err(|e| {
EngineError::Eternal(format!("NatalChart::compute (solar return): {:?}", e))
})?;
let glyphs: Vec<Glyph> = return_chart
.placements
.iter()
.map(|p| Glyph {
deg: p.longitude.longitude_deg() as f32,
symbol: body_symbol(p.body).into(),
annotation: Some(format!("{:.1}°", p.longitude.degree_in_sign_decimal())),
retrograde: p.longitude_rate_rad_per_day < 0.0,
house: Some(p.house_number),
})
.collect();
render.layers.push(Layer {
module_id: "solar_return".into(),
kind: LayerKind::Outer,
ring: 0.82,
z: 12,
geometry: Geometry::GlyphsOnly,
glyphs,
});
let cross = find_synastry_aspects(
natal,
&return_chart,
&OrbTable::modern_western(),
EAspectKind::MAJORS,
);
let cross_lines: Vec<LineSeg> = cross
.iter()
.filter_map(|a| {
let n_p = natal.placement(a.person_a_body)?;
let r_p = return_chart.placement(a.person_b_body)?;
let opacity = orb_to_opacity(a.orb_abs_deg(), a.kind);
Some(LineSeg {
from_deg: n_p.longitude.longitude_deg() as f32,
to_deg: r_p.longitude.longitude_deg() as f32,
kind: aspect_kind_id(a.kind).into(),
opacity: opacity * 0.8,
})
})
.collect();
render.layers.push(Layer {
module_id: "solar_return".into(),
kind: LayerKind::Aspects,
ring: 0.0,
z: 13,
geometry: Geometry::Lines(cross_lines),
glyphs: Vec::new(),
});
Ok(())
}
// ===================================================================== // =====================================================================
// NatalChart → RenderModel // NatalChart → RenderModel
// ===================================================================== // =====================================================================
@@ -191,6 +191,13 @@ pub enum PipelineRequest {
Synastry { Synastry {
partner_chart: Box<Chart>, partner_chart: Box<Chart>,
}, },
/// `module_id = "solar_return"` — carta natal fresca al instante
/// del próximo retorno solar para la edad pedida (Sun back to
/// natal Sun). Anillo externo compartido con Transit/Synastry
/// — mutuamente excluyentes los tres a nivel de Shell.
SolarReturn {
target_age_years: f64,
},
} }
/// Composición canónica: carta natal + todos los overlays pedidos. /// Composición canónica: carta natal + todos los overlays pedidos.
@@ -136,6 +136,7 @@ impl Registry {
r.register(Box::new(progression::ProgressionModule)); r.register(Box::new(progression::ProgressionModule));
r.register(Box::new(solar_arc::SolarArcModule)); r.register(Box::new(solar_arc::SolarArcModule));
r.register(Box::new(synastry::SynastryModule)); r.register(Box::new(synastry::SynastryModule));
r.register(Box::new(solar_return::SolarReturnModule));
r r
} }
@@ -393,6 +394,58 @@ pub mod synastry {
} }
} }
// =====================================================================
// SolarReturnModule — carta del año en curso (Sun back to natal Sun)
// =====================================================================
pub mod solar_return {
use super::*;
/// Computa la carta natal completa al instante del próximo retorno
/// solar para la edad pedida. Comparte el outer ring con Transit y
/// Synastry — mutuamente excluyentes a nivel de Shell.
pub struct SolarReturnModule;
impl Module for SolarReturnModule {
fn id(&self) -> &'static str {
"solar_return"
}
fn label(&self) -> &'static str {
"Retorno solar"
}
fn description(&self) -> &'static str {
"Carta del año — Sol de vuelta a su posición natal."
}
fn applies_to(&self, kind: ChartKind) -> bool {
matches!(kind, ChartKind::Natal)
}
fn enabled_by_default(&self) -> bool {
false
}
fn controls(&self) -> Vec<Control> {
vec![
Control::Toggle {
key: "enabled".into(),
label: "Activar".into(),
default: false,
hotkey: None,
},
Control::Slider {
key: "target_age_years".into(),
label: "Edad del retorno".into(),
min: 0.0,
max: 120.0,
step: 1.0,
default: 30.0,
},
]
}
fn compute_layers(&self, _chart: &Chart, _cfg: &serde_json::Value) -> Vec<Layer> {
Vec::new()
}
}
}
// ===================================================================== // =====================================================================
// SolarArcModule — Solar Arc dirigido (true progressed Sun) // SolarArcModule — Solar Arc dirigido (true progressed Sun)
// ===================================================================== // =====================================================================
@@ -458,8 +511,9 @@ mod tests {
assert!(r.find("progression").is_some()); assert!(r.find("progression").is_some());
assert!(r.find("solar_arc").is_some()); assert!(r.find("solar_arc").is_some());
assert!(r.find("synastry").is_some()); assert!(r.find("synastry").is_some());
// Natal kind tiene 5 módulos aplicables. assert!(r.find("solar_return").is_some());
assert_eq!(r.for_kind(ChartKind::Natal).len(), 5); // Natal kind tiene 6 módulos aplicables.
assert_eq!(r.for_kind(ChartKind::Natal).len(), 6);
assert!(r.for_kind(ChartKind::Synastry).is_empty()); assert!(r.for_kind(ChartKind::Synastry).is_empty());
} }
} }