From 812b2d4f73db34c8a63d80d6253528e776b82e50 Mon Sep 17 00:00:00 2001 From: feco Date: Sun, 15 Nov 2026 12:18:40 +0000 Subject: [PATCH] Write text analyses with OpenRouter in the worker - analysis job: claims pending analyses (SKIP LOCKED, NOTIFY wake-up), builds a compact chart text without birth data, asks OpenRouter with a strict JSON schema, validates and stores the answer, model used, tokens and cost; retries transient errors, refunds credits on final failure, requeues interrupted jobs - prompt v1 for natal and synastry analyses, Hungarian style guide - compare-models subcommand for blind model comparison - migration 0003: attempts, next_attempt_at, model_used, cost_usd, notify trigger, one refund per analysis - db: rebuild when migrations change - compose: worker reads OPENROUTER_API_KEY from .env.secrets Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- Cargo.lock | 3 + crates/db/build.rs | 4 + crates/db/migrations/0003_analysis_jobs.sql | 28 ++ docker-compose.yml | 5 + services/backend/README.md | 6 +- services/worker/Cargo.toml | 3 + services/worker/README.md | 36 +- services/worker/src/analysis/compact.rs | 384 ++++++++++++++++++ services/worker/src/analysis/mod.rs | 272 +++++++++++++ services/worker/src/analysis/openrouter.rs | 155 +++++++ services/worker/src/analysis/prompt.rs | 224 ++++++++++ services/worker/src/compare.rs | 130 ++++++ services/worker/src/config.rs | 15 + services/worker/src/email.rs | 27 +- services/worker/src/main.rs | 54 ++- services/worker/src/tests.rs | 301 ++++++++++++++ .../testdata/natal-1988-11-02-notime.json | 1 + .../worker/testdata/natal-1990-03-15.json | 1 + .../worker/testdata/synastry-response.json | 1 + 19 files changed, 1615 insertions(+), 35 deletions(-) create mode 100644 crates/db/build.rs create mode 100644 crates/db/migrations/0003_analysis_jobs.sql create mode 100644 services/worker/src/analysis/compact.rs create mode 100644 services/worker/src/analysis/mod.rs create mode 100644 services/worker/src/analysis/openrouter.rs create mode 100644 services/worker/src/analysis/prompt.rs create mode 100644 services/worker/src/compare.rs create mode 100644 services/worker/testdata/natal-1988-11-02-notime.json create mode 100644 services/worker/testdata/natal-1990-03-15.json create mode 100644 services/worker/testdata/synastry-response.json diff --git a/Cargo.lock b/Cargo.lock index 9a38619..db51107 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2860,6 +2860,9 @@ dependencies = [ "axum", "db", "lettre", + "rand 0.9.5", + "reqwest", + "serde", "serde_json", "service-kit", "sqlx", diff --git a/crates/db/build.rs b/crates/db/build.rs new file mode 100644 index 0000000..ed70452 --- /dev/null +++ b/crates/db/build.rs @@ -0,0 +1,4 @@ +// Rebuild when a migration is added or changed (`sqlx::migrate!` embeds them). +fn main() { + println!("cargo:rerun-if-changed=migrations"); +} diff --git a/crates/db/migrations/0003_analysis_jobs.sql b/crates/db/migrations/0003_analysis_jobs.sql new file mode 100644 index 0000000..f28d6f9 --- /dev/null +++ b/crates/db/migrations/0003_analysis_jobs.sql @@ -0,0 +1,28 @@ +-- Text analyses written by the worker: retries with backoff, the model that +-- actually answered (e.g. behind 'openrouter/auto'), cost, a notification for +-- new requests, and at most one refund per analysis. + +ALTER TABLE analyses + ADD COLUMN attempts integer NOT NULL DEFAULT 0, + ADD COLUMN next_attempt_at timestamptz NOT NULL DEFAULT now(), + ADD COLUMN model_used text, + ADD COLUMN cost_usd double precision; + +COMMENT ON COLUMN analyses.content IS + 'Structured result: {title, summary, sections: {key: {title, body}}, strengths: [], challenges: [], advice}'; + +DROP INDEX analyses_pending_idx; +CREATE INDEX analyses_due_idx ON analyses (next_attempt_at) WHERE status = 'pending'; + +CREATE UNIQUE INDEX credit_ledger_refund_once ON credit_ledger (analysis_id) WHERE reason = 'refund'; + +CREATE FUNCTION notify_analyses() RETURNS trigger LANGUAGE plpgsql AS $$ +BEGIN + PERFORM pg_notify('analyses', ''); + RETURN NULL; +END; +$$; + +CREATE TRIGGER analyses_notify + AFTER INSERT ON analyses + FOR EACH STATEMENT EXECUTE FUNCTION notify_analyses(); diff --git a/docker-compose.yml b/docker-compose.yml index 28f77f0..e08e610 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,6 +67,11 @@ services: # points it at Mailpit. SMTP_URL: ${SMTP_URL:-} MAIL_FROM: ${MAIL_FROM:-Sorsfonalak } + PUBLIC_BASE_URL: ${PUBLIC_BASE_URL:-http://localhost:3000} + # OPENROUTER_API_KEY (not in git); without it analyses stay pending. + env_file: + - path: .env.secrets + required: false depends_on: postgres: condition: service_healthy diff --git a/services/backend/README.md b/services/backend/README.md index 0a41fa0..e7cf6e8 100644 --- a/services/backend/README.md +++ b/services/backend/README.md @@ -99,13 +99,11 @@ Hibák formátuma: `{"error": {"code", "message"}}`. A születési adatok hibái ## Elemzések és kreditek -- **Kérés:** a `POST .../analyses` létrehoz egy `pending` elemzést, és levonja az `ANALYSIS_COST` kreditet; a szöveget később a worker írja meg. Ha nincs elég kredit, 402 `insufficient_credits` a válasz. +- **Kérés:** a `POST .../analyses` létrehoz egy `pending` elemzést, és levonja az `ANALYSIS_COST` kreditet; a szöveget a worker írja meg, általában 1–2 perc alatt. A kliens a `GET /v1/analyses/{id}` végponton kérdezi le az állapotát. Ha nincs elég kredit, 402 `insufficient_credits` a válasz. - **Gyorsítótár:** a kulcs `sha256(típus | képlet- vagy szinasztria-hash | promptverzió | modell | nyelv)`. - Ha ugyanarra a képletre már kértek ilyet, ugyanazt adja vissza (200). - Ha bárhol van kész elemzés ugyanezzel a kulccsal (például ugyanaz a születési adat egy másik felhasználónál), ingyen átmásolja (201, `done`). ## Háttérmunkák -A [worker](../worker/README.md) már kiküldi az e-maileket az `email_outbox`-ból, és óránként takarít. Még hátravan: -- az elemzések megírása (OpenRouter, strukturált JSON, streaming); -- sikertelen elemzésnél a kredit visszatérítése (`refund`). +A [worker](../worker/README.md) kiküldi az e-maileket, megírja az elemzéseket (OpenRouter, strukturált JSON; hibánál visszaadja a kreditet), és óránként takarít. Még hátravan az elemzés streamelése a frontend felé. diff --git a/services/worker/Cargo.toml b/services/worker/Cargo.toml index 205e809..a434915 100644 --- a/services/worker/Cargo.toml +++ b/services/worker/Cargo.toml @@ -12,6 +12,9 @@ service-kit.workspace = true anyhow.workspace = true axum.workspace = true lettre.workspace = true +rand.workspace = true +reqwest.workspace = true +serde.workspace = true serde_json.workspace = true sqlx.workspace = true time.workspace = true diff --git a/services/worker/README.md b/services/worker/README.md index 6a0f40c..5812f22 100644 --- a/services/worker/README.md +++ b/services/worker/README.md @@ -1,6 +1,6 @@ # worker -Háttérmunkák a közös PostgreSQL-adatbázis fölött. Nincs nyilvános API-ja, csak egy `/healthz` végpontja (8082) a Docker healthcheckhez. Induláskor lefuttatja a migrációkat, ugyanúgy, mint a backend. +Háttérmunkák a közös PostgreSQL-adatbázis fölött: e-mail-küldés, szöveges elemzések (LLM), takarítás. Nincs nyilvános API-ja, csak egy `/healthz` végpontja (8082) a Docker healthcheckhez. Induláskor lefuttatja a migrációkat, ugyanúgy, mint a backend. ## Munkák @@ -17,7 +17,34 @@ Háttérmunkák a közös PostgreSQL-adatbázis fölött. Nincs nyilvános API-j - elküldött e-mailek 7 nap után (tokenes linkek vannak bennük), sikertelenek 30 nap után; - el nem fogadott meghívók 30 nappal a lejáratuk után. -**Később:** az elemzések megírása (OpenRouter), kredit-visszatérítés hibánál. +**Szöveges elemzések** (`analyses`, `pending` → `running` → `done`/`failed`) +- A backend létrehozza a `pending` sort, és levonja a kreditet. Egy trigger (`NOTIFY analyses`) felébreszti a workert; egyszerre `ANALYSIS_CONCURRENCY` elemzés készül. +- A prompt a tárolt képletből készül (`src/analysis/compact.rs`). Ez egy tömör szöveg, amely csak a pozíciókat tartalmazza: jegyek, fokok, házak, fényszögek, elemek. **Név, születési dátum, idő, hely és koordináta nem megy ki.** Ismeretlen születési időnél nincsenek házak, Aszcendens és MC. +- A modell OpenRouteren keresztül válaszol, azzal a modellel, amely a sor `model` mezőjében áll. A válasznak kötött JSON-sémát kell követnie (`src/analysis/prompt.rs`, `PROMPT_VERSION = v1`): + - `title`, `summary`; + - `sections`, radixnál: `personality`, `emotions`, `mind`, `love`, `work`, `growth`; szinasztriánál: `attraction`, `communication`, `emotional_bond`, `friction`, `long_term`; + - `strengths`, `challenges`, `advice`. + + A worker a választ maga is ellenőrzi a sémán. +- Eltárolja a ténylegesen válaszoló modellt (`model_used`; az `openrouter/auto` mögött ez más lehet), a tokenszámot és a költséget (`cost_usd`). +- **Átmeneti hiba** (hálózat, 429, 5xx, elfogyott OpenRouter-egyenleg, hibás vagy csonka válasz): újrapróbálja 30 mp, 2 perc, majd 8 perc múlva. +- **Végleges hiba** (például ismeretlen modell), vagy ha elfogyott a `MAX_ANALYSIS_ATTEMPTS` próbálkozás: az elemzés `failed` lesz, és a kredit visszajár (`refund`, elemzésenként legfeljebb egyszer). +- Ha a worker elemzés közben leáll, a félkész elemzést visszateszi a sorba. Ha összeomlik, az elemzés 15 perc múlva magától visszakerül. +- Szinasztriánál a modell a két félnek együtt szól; ha meg kell különböztetnie őket, „első fél” és „második fél” néven említi. + +**Később:** streaming a frontend felé. + +## Modellek összevetése + +```bash +OPENROUTER_API_KEY=... worker compare-models --chart natal.json \ + --models minimax/minimax-m3,anthropic/claude-sonnet-5.5 --language hu --out exports/model-compare +``` + +Ugyanazt a radix-elemzést több modellel is megírja, véletlenszerű betűkkel (`A.md`, `B.md`, …). +- A `key.json` mondja meg, melyik betű melyik modell, a tokenszámmal, a költséggel és az idővel együtt. +- A `prompt.md` a teljes promptot tartalmazza. +- A `--chart` a horoscope-api `/v1/natal` válasza. ## Konfiguráció @@ -28,6 +55,11 @@ Háttérmunkák a közös PostgreSQL-adatbázis fölött. Nincs nyilvános API-j | `MAIL_FROM` | `Sorsfonalak ` | feladó | | `POLL_INTERVAL_SECS` | `30` | tartalék lekérdezési időköz | | `MAX_EMAIL_ATTEMPTS` | `8` | ennyi próbálkozás után sikertelen a levél | +| `OPENROUTER_API_KEY` | – | OpenRouter-kulcs (compose-ban a `.env.secrets` fájlból); nélküle az elemzések várnak | +| `OPENROUTER_BASE_URL` | `https://openrouter.ai/api/v1` | | +| `PUBLIC_BASE_URL` | – | `HTTP-Referer` fejléc az OpenRouter felé | +| `ANALYSIS_CONCURRENCY` | `4` | egyszerre írt elemzések | +| `MAX_ANALYSIS_ATTEMPTS` | `3` | ennyi próbálkozás után sikertelen az elemzés (a kredit visszajár) | | `BIND_ADDR`, `LOG_FORMAT`, `RUST_LOG` | `0.0.0.0:8082`, `text`, `info` | | ## Fejlesztés: Mailpit diff --git a/services/worker/src/analysis/compact.rs b/services/worker/src/analysis/compact.rs new file mode 100644 index 0000000..b50a0bf --- /dev/null +++ b/services/worker/src/analysis/compact.rs @@ -0,0 +1,384 @@ +//! Compact text views of charts for the language model. +//! +//! Only astrological positions go in: no names, birth date, time, place or +//! coordinates. Plain text is shorter than the JSON and easier for models. + +use std::fmt::Write; + +use serde_json::Value; + +/// Points listed one per line; asteroids go on a shorter line. +const MAIN_POINTS: [&str; 14] = [ + "sun", + "moon", + "mercury", + "venus", + "mars", + "jupiter", + "saturn", + "uranus", + "neptune", + "pluto", + "chiron", + "north_node", + "south_node", + "lilith", +]; +const ASTEROIDS: [&str; 4] = ["ceres", "pallas", "juno", "vesta"]; +const ANGLES: [&str; 4] = ["ascendant", "midheaven", "descendant", "imum_coeli"]; +const MAX_SYNASTRY_ASPECTS: usize = 45; + +fn point_name(id: &str) -> String { + match id { + "north_node" => "North Node".into(), + "south_node" => "South Node".into(), + "lilith" => "Lilith (Black Moon)".into(), + "midheaven" => "Midheaven (MC)".into(), + "imum_coeli" => "Imum Coeli (IC)".into(), + "ascendant" => "Ascendant".into(), + "descendant" => "Descendant".into(), + other => capitalize(other), + } +} + +fn capitalize(s: &str) -> String { + let mut chars = s.chars(); + chars.next().map(|c| c.to_uppercase().chain(chars).collect()).unwrap_or_default() +} + +fn words(s: &str) -> String { + s.replace('_', " ") +} + +/// "Cancer 0°24'" from a position object (sign + degree_in_sign). +fn position(p: &Value) -> String { + let degree = p["degree_in_sign"].as_f64().unwrap_or(0.0); + // Rounded to the second first, as in the `degree_in_sign_dms` field; never 30°. + let secs = ((degree * 3600.0).round() as i64).clamp(0, 30 * 3600 - 1); + let (d, m) = (secs / 3600, secs % 3600 / 60); + format!("{} {d}°{m:02}'", capitalize(p["sign"].as_str().unwrap_or("?"))) +} + +fn time_known(chart: &Value) -> bool { + chart["time"]["time_known"].as_bool().unwrap_or(false) +} + +fn is_main(id: &str) -> bool { + MAIN_POINTS.contains(&id) || ANGLES.contains(&id) +} + +fn points(chart: &Value) -> impl Iterator { + chart["points"].as_array().into_iter().flatten() +} + +fn names(list: &Value) -> String { + list.as_array().into_iter().flatten().filter_map(Value::as_str).map(point_name).collect::>().join(", ") +} + +/// One line per point: "Sun: Cancer 0°24', house 3, retrograde, domicile". +fn point_lines(out: &mut String, chart: &Value, prefix: &str, houses: bool) { + for p in points(chart).filter(|p| MAIN_POINTS.contains(&p["id"].as_str().unwrap_or(""))) { + let mut line = format!("{prefix}- {}: {}", point_name(p["id"].as_str().unwrap_or("?")), position(p)); + if houses && let Some(h) = p["house"].as_i64() { + let _ = write!(line, ", house {h}"); + } + if p["retrograde"].as_bool() == Some(true) { + line.push_str(", retrograde"); + } + for dignity in p["dignities"].as_array().into_iter().flatten().filter_map(Value::as_str) { + let _ = write!(line, ", {}", words(dignity)); + } + if p["out_of_bounds"].as_bool() == Some(true) { + line.push_str(", out of bounds"); + } + let _ = writeln!(out, "{line}"); + } + let minor: Vec = points(chart) + .filter(|p| ASTEROIDS.contains(&p["id"].as_str().unwrap_or(""))) + .map(|p| { + let house = if houses { + p["house"].as_i64().map(|h| format!(" (house {h})")).unwrap_or_default() + } else { + String::new() + }; + format!("{} {}{house}", point_name(p["id"].as_str().unwrap_or("?")), position(p)) + }) + .collect(); + if !minor.is_empty() { + let _ = writeln!(out, "{prefix}- Asteroids: {}", minor.join("; ")); + } +} + +fn angle_lines(out: &mut String, chart: &Value, prefix: &str) { + let angles = &chart["angles"]; + for (id, label) in [("ascendant", "Ascendant"), ("midheaven", "Midheaven (MC)")] { + if angles[id].is_object() { + let _ = writeln!(out, "{prefix}- {label}: {}", position(&angles[id])); + } + } +} + +const BIRTH_TIME_UNKNOWN: &str = "Birth time: UNKNOWN. The chart is cast for noon, so there are no houses, \ + no Ascendant and no Midheaven, and the Moon may be up to about 7° off (its sign is uncertain near a sign boundary)."; + +/// A natal chart (the horoscope-api `/v1/natal` result). +pub fn natal(chart: &Value) -> String { + let mut out = String::new(); + let settings = &chart["settings"]; + let known = time_known(chart); + let _ = writeln!( + out, + "NATAL CHART ({} zodiac, {} houses)", + settings["zodiac"].as_str().unwrap_or("tropical"), + capitalize(&words( + chart["houses"]["system"].as_str().or(settings["house_system"].as_str()).unwrap_or("placidus") + )) + ); + let _ = writeln!(out, "{}", if known { "Birth time: known." } else { BIRTH_TIME_UNKNOWN }); + let summary = &chart["summary"]; + if let Some(sect) = summary["sect"].as_str() { + let _ = writeln!(out, "Sect: {sect} chart."); + } + let phase = &chart["moon_phase"]; + if let Some(name) = phase["phase"].as_str() { + let illumination = phase["illumination"].as_f64().map(|i| format!(" ({:.0}% illuminated)", i * 100.0)); + let _ = writeln!(out, "Moon phase: {}{}.", words(name), illumination.unwrap_or_default()); + } + + if known { + out.push_str("\nAngles:\n"); + angle_lines(&mut out, chart, ""); + let ruler = &summary["chart_ruler"]; + for kind in ["traditional", "modern"] { + let r = &ruler[kind]; + if let Some(planet) = r["planet"].as_str() { + if kind == "modern" && ruler["traditional"]["planet"] == r["planet"] { + continue; + } + let _ = writeln!( + out, + "- Chart ruler ({kind}): {} in {}, house {}", + point_name(planet), + capitalize(r["sign"].as_str().unwrap_or("?")), + r["house"] + ); + } + } + } + + out.push_str("\nPlanets and points:\n"); + point_lines(&mut out, chart, "", known); + + if known && let Some(cusps) = chart["houses"]["cusps"].as_array() { + let list: Vec = cusps.iter().map(|c| format!("{} {}", c["house"], position(c))).collect(); + let _ = writeln!(out, "\nHouse cusps: {}", list.join(" | ")); + } + + aspect_lines(&mut out, &chart["aspects"], "\nAspects (tightest first; orb in degrees):", usize::MAX); + + out.push_str("\nBalance (main planets):\n"); + for (title, key) in [("Elements", "elements"), ("Modalities", "modalities")] { + if let Some(groups) = summary[key].as_object() { + let list: Vec = groups + .iter() + .map(|(name, g)| { + let members = names(&g["points"]); + if members.is_empty() { format!("{name} 0") } else { format!("{name} {} ({members})", g["count"]) } + }) + .collect(); + let _ = writeln!(out, "- {title}: {}", list.join("; ")); + } + } + if known && let Some(h) = summary["hemispheres"].as_object() { + let list: Vec = h.iter().map(|(name, g)| format!("{} {}", words(name), g["count"])).collect(); + let _ = writeln!(out, "- Hemispheres: {}", list.join(", ")); + } + let retro = names(&summary["retrograde"]); + if !retro.is_empty() { + let _ = writeln!(out, "- Retrograde: {retro}"); + } + if known && let Some(fortune) = chart["lots"]["fortune"].as_object() { + let fortune = Value::Object(fortune.clone()); + let _ = writeln!(out, "- Part of Fortune: {}, house {}", position(&fortune), fortune["house"]); + } + out +} + +/// A synastry: both natal charts plus the synastry result (inter-aspects, +/// house overlays, composite) as stored by the backend. +pub fn synastry(chart1: &Value, chart2: &Value, result: &Value) -> String { + let mut out = String::from("SYNASTRY: two natal charts compared (Person 1 and Person 2), tropical zodiac.\n"); + for (label, chart) in [("Person 1", chart1), ("Person 2", chart2)] { + let _ = writeln!(out, "\n{label}:"); + if time_known(chart) { + let _ = writeln!(out, " Birth time: known."); + angle_lines(&mut out, chart, " "); + } else { + let _ = writeln!(out, " {BIRTH_TIME_UNKNOWN}"); + } + point_lines(&mut out, chart, " ", time_known(chart)); + } + + let mut aspects: Vec<&Value> = result["aspects"] + .as_array() + .into_iter() + .flatten() + .filter(|a| is_main(a["person1"].as_str().unwrap_or("")) && is_main(a["person2"].as_str().unwrap_or(""))) + .collect(); + aspects.sort_by(|a, b| a["orb"].as_f64().unwrap_or(99.0).total_cmp(&b["orb"].as_f64().unwrap_or(99.0))); + if !aspects.is_empty() { + let _ = writeln!( + out, + "\nInter-chart aspects (Person 1's point first; tightest {} of {}):", + aspects.len().min(MAX_SYNASTRY_ASPECTS), + aspects.len() + ); + for a in aspects.iter().take(MAX_SYNASTRY_ASPECTS) { + let _ = writeln!( + out, + "- {} {} {} (orb {:.1}°, {})", + point_name(a["person1"].as_str().unwrap_or("?")), + words(a["aspect"].as_str().unwrap_or("?")), + point_name(a["person2"].as_str().unwrap_or("?")), + a["orb"].as_f64().unwrap_or(0.0), + a["nature"].as_str().unwrap_or("neutral") + ); + } + } + if let Some(by_nature) = result["summary"]["by_nature"].as_object() { + let list: Vec = by_nature.iter().map(|(k, v)| format!("{k} {v}")).collect(); + let _ = writeln!(out, "All aspects by nature: {}", list.join(", ")); + } + + let overlays = &result["house_overlays"]; + for (key, label) in [ + ("person1_in_person2", "Person 1's planets in Person 2's houses"), + ("person2_in_person1", "Person 2's planets in Person 1's houses"), + ] { + let list: Vec = overlays[key] + .as_array() + .into_iter() + .flatten() + .filter(|o| MAIN_POINTS.contains(&o["point"].as_str().unwrap_or(""))) + .filter_map(|o| Some(format!("{} {}", point_name(o["point"].as_str()?), o["house"].as_i64()?))) + .collect(); + if !list.is_empty() { + let _ = writeln!(out, "\n{label}: {}", list.join(", ")); + } + } + + let composite = &result["composite"]; + if composite["points"].is_array() { + let both_known = time_known(chart1) && time_known(chart2); + let _ = writeln!(out, "\nComposite chart ({} method):", composite["method"].as_str().unwrap_or("midpoint")); + if both_known { + angle_lines(&mut out, composite, ""); + } + point_lines(&mut out, composite, "", both_known); + aspect_lines(&mut out, &composite["aspects"], "Composite aspects (tightest first):", 12); + } + out +} + +/// Aspects between main points and angles, tightest first. +fn aspect_lines(out: &mut String, aspects: &Value, heading: &str, limit: usize) { + let mut list: Vec<&Value> = aspects + .as_array() + .into_iter() + .flatten() + .filter(|a| is_main(a["point1"].as_str().unwrap_or("")) && is_main(a["point2"].as_str().unwrap_or(""))) + .collect(); + if list.is_empty() { + return; + } + list.sort_by(|a, b| a["orb"].as_f64().unwrap_or(99.0).total_cmp(&b["orb"].as_f64().unwrap_or(99.0))); + let _ = writeln!(out, "{heading}"); + for a in list.into_iter().take(limit) { + let motion = match a["applying"].as_bool() { + Some(true) => ", applying", + Some(false) => ", separating", + None => "", + }; + let _ = writeln!( + out, + "- {} {} {} (orb {:.1}°{motion})", + point_name(a["point1"].as_str().unwrap_or("?")), + words(a["aspect"].as_str().unwrap_or("?")), + point_name(a["point2"].as_str().unwrap_or("?")), + a["orb"].as_f64().unwrap_or(0.0) + ); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn fixture(name: &str) -> Value { + let path = format!("{}/testdata/{name}", env!("CARGO_MANIFEST_DIR")); + serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap() + } + + /// Birth data that must never reach the model. + fn assert_private(text: &str) { + for secret in ["1990", "1988", "14:30", "08:10", "Szeged", "Pécs", "Hungary", "HU", "46.", "20.1", "Budapest"] + { + assert!(!text.contains(secret), "'{secret}' leaked into:\n{text}"); + } + } + + #[test] + fn natal_with_birth_time() { + let text = natal(&fixture("natal-1990-03-15.json")); + assert_private(&text); + for expected in [ + "Birth time: known.", + "- Ascendant: Leo 19°23'", + "- Chart ruler (traditional): Sun in Pisces, house 8", + "- Sun: Pisces 24°42', house 8", + "- Pluto: Scorpio 17°36', house 4, retrograde, domicile", + "- Asteroids: Ceres Gemini 25°43' (house 11);", + "House cusps: 1 Leo 19°23' | 2 Virgo 9°35'", + "- Moon trine Chiron (orb 0.1°, applying)", + "- Elements: air 2 (Venus, Mars); earth 3 (Saturn, Uranus, Neptune); fire 0;", + "- Part of Fortune: Aries 5°10', house 8", + ] { + assert!(text.contains(expected), "missing '{expected}' in:\n{text}"); + } + // Tightest aspect first. + assert!(text.find("Moon trine Chiron").unwrap() < text.find("Moon square Ascendant").unwrap()); + } + + #[test] + fn natal_without_birth_time_has_no_houses() { + let text = natal(&fixture("natal-1988-11-02-notime.json")); + assert_private(&text); + assert!(text.contains("Birth time: UNKNOWN")); + for absent in + ["house ", "House cusps", "Ascendant:", "Midheaven (MC):", "Chart ruler", "Hemispheres", "Fortune"] + { + assert!(!text.contains(absent), "'{absent}' in:\n{text}"); + } + assert!(text.contains("- Venus: Libra 4°12', domicile")); + } + + #[test] + fn synastry_view() { + // The full horoscope-api response, with both persons' birth data in it. + let response = fixture("synastry-response.json"); + let text = synastry(&response["person1"], &response["person2"], &response); + assert_private(&text); + for expected in [ + "Person 1:\n Birth time: known.", + " - Sun: Pisces 24°42', house 8", + "Inter-chart aspects (Person 1's point first; tightest 45 of", + "(orb 0.0°, harmonious)", + "All aspects by nature: ", + "Person 1's planets in Person 2's houses: Sun 4, Moon 12", + "Composite chart (midpoint method):\n- Ascendant: Libra 8°39'", + "Composite aspects (tightest first):\n- Saturn conjunction Neptune (orb 0.1°)", + ] { + assert!(text.contains(expected), "missing '{expected}' in:\n{text}"); + } + } +} diff --git a/services/worker/src/analysis/mod.rs b/services/worker/src/analysis/mod.rs new file mode 100644 index 0000000..e600451 --- /dev/null +++ b/services/worker/src/analysis/mod.rs @@ -0,0 +1,272 @@ +//! Writes the requested text analyses (`analyses` rows in `pending` state). +//! +//! The backend inserts the row and charges the credits; this job claims it +//! (`running`), builds the prompt from the stored chart data, asks the model +//! through OpenRouter and stores the structured answer (`done`). Temporary +//! failures are retried with backoff; after the last attempt, or on a +//! permanent error, the analysis is `failed` and the credits are refunded. + +pub mod compact; +pub mod openrouter; +pub mod prompt; + +use std::collections::HashSet; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +use serde_json::Value; +use sqlx::PgPool; +use tokio::sync::{Semaphore, watch}; +use uuid::Uuid; + +use self::openrouter::{Completion, LlmError, OpenRouter}; +use self::prompt::{Kind, PROMPT_VERSION, Prompt}; + +/// A `running` analysis older than this was left behind by a stopped worker. +const STUCK_AFTER_MINUTES: i32 = 15; + +#[derive(Debug, sqlx::FromRow)] +pub struct Job { + pub id: Uuid, + pub kind: String, + pub chart_id: Option, + pub synastry_id: Option, + pub language: String, + pub model: String, + pub prompt_version: String, + pub attempts: i32, +} + +pub struct Analyzer { + pub db: PgPool, + pub llm: OpenRouter, + pub max_attempts: i32, + pub concurrency: usize, + /// Analyses being written right now (put back to `pending` on shutdown). + running: Mutex>, +} + +/// Wait before the next attempt: 30 s, 2 min, 8 min, ... at most 1 hour. +pub fn backoff(attempts: i32) -> Duration { + let exp = attempts.clamp(1, 6).saturating_sub(1) as u32; + Duration::from_secs((30 * 4u64.pow(exp)).min(3600)) +} + +impl Analyzer { + pub fn new(db: PgPool, llm: OpenRouter, max_attempts: i32, concurrency: usize) -> Self { + Self { db, llm, max_attempts, concurrency: concurrency.max(1), running: Mutex::default() } + } + + /// Takes the next due analysis, if any. + pub async fn claim(&self) -> Result, sqlx::Error> { + let job: Option = sqlx::query_as( + "UPDATE analyses SET status = 'running', started_at = now(), attempts = attempts + 1 \ + WHERE id = (SELECT id FROM analyses WHERE status = 'pending' AND next_attempt_at <= now() \ + ORDER BY next_attempt_at LIMIT 1 FOR UPDATE SKIP LOCKED) \ + RETURNING id, kind, chart_id, synastry_id, language, model, prompt_version, attempts", + ) + .fetch_optional(&self.db) + .await?; + if let Some(job) = &job { + self.running.lock().unwrap().insert(job.id); + } + Ok(job) + } + + /// Builds the prompt from the stored chart or synastry. + pub async fn prompt_for(&self, job: &Job) -> Result { + let kind = Kind::parse(&job.kind).ok_or_else(|| LlmError::Permanent(format!("unknown kind '{}'", job.kind)))?; + let db_err = |e: sqlx::Error| LlmError::Transient(format!("database: {e}")); + let gone = || LlmError::Permanent("the chart was deleted".into()); + let text = match kind { + Kind::Natal => { + let (chart,): (Value,) = sqlx::query_as("SELECT result FROM charts WHERE id = $1") + .bind(job.chart_id) + .fetch_optional(&self.db) + .await + .map_err(db_err)? + .ok_or_else(gone)?; + compact::natal(&chart) + } + Kind::Synastry => { + let (result, chart1, chart2): (Value, Value, Value) = sqlx::query_as( + "SELECT s.result, c1.result, c2.result FROM synastries s \ + JOIN charts c1 ON c1.id = s.chart1_id JOIN charts c2 ON c2.id = s.chart2_id WHERE s.id = $1", + ) + .bind(job.synastry_id) + .fetch_optional(&self.db) + .await + .map_err(db_err)? + .ok_or_else(gone)?; + compact::synastry(&chart1, &chart2, &result) + } + }; + if job.prompt_version != PROMPT_VERSION { + tracing::warn!(id = %job.id, requested = %job.prompt_version, current = PROMPT_VERSION, "prompt version differs"); + } + Ok(prompt::build(kind, &job.language, &text)) + } + + /// Writes one claimed analysis and records the outcome. + pub async fn handle(&self, job: Job) { + let started = Instant::now(); + let result = match self.prompt_for(&job).await { + Ok(prompt) => self.llm.complete(&job.model, &prompt).await, + Err(e) => Err(e), + }; + if let Err(e) = self.finish(&job, result, started.elapsed()).await { + tracing::error!(id = %job.id, error = %e, "saving the analysis result failed"); + } + self.running.lock().unwrap().remove(&job.id); + } + + async fn finish(&self, job: &Job, result: Result, took: Duration) -> Result<(), sqlx::Error> { + match result { + Ok(c) => { + sqlx::query( + "UPDATE analyses SET status = 'done', content = $2, model_used = $3, input_tokens = $4, \ + output_tokens = $5, cost_usd = $6, error = NULL, completed_at = now() \ + WHERE id = $1 AND status = 'running'", + ) + .bind(job.id) + .bind(&c.content) + .bind(&c.model) + .bind(c.input_tokens) + .bind(c.output_tokens) + .bind(c.cost_usd) + .execute(&self.db) + .await?; + tracing::info!( + id = %job.id, model = %c.model, input_tokens = c.input_tokens, output_tokens = c.output_tokens, + cost_usd = c.cost_usd, secs = took.as_secs(), "analysis done" + ); + } + Err(LlmError::Transient(message)) if job.attempts < self.max_attempts => { + let wait = backoff(job.attempts); + sqlx::query( + "UPDATE analyses SET status = 'pending', error = $2, \ + next_attempt_at = now() + make_interval(secs => $3) WHERE id = $1 AND status = 'running'", + ) + .bind(job.id) + .bind(&message) + .bind(wait.as_secs_f64()) + .execute(&self.db) + .await?; + tracing::warn!(id = %job.id, attempts = job.attempts, retry_in_secs = wait.as_secs(), error = %message, "analysis will be retried"); + } + Err(e) => { + self.fail(job.id, e.message()).await?; + tracing::error!(id = %job.id, attempts = job.attempts, error = %e.message(), "analysis failed"); + } + } + Ok(()) + } + + /// Marks the analysis failed and gives the credits back (once). + async fn fail(&self, id: Uuid, message: &str) -> Result<(), sqlx::Error> { + let mut tx = self.db.begin().await?; + let row: Option<(Option, i32)> = sqlx::query_as( + "UPDATE analyses SET status = 'failed', error = $2, completed_at = now() \ + WHERE id = $1 AND status = 'running' RETURNING requested_by, credits_charged", + ) + .bind(id) + .bind(message) + .fetch_optional(&mut *tx) + .await?; + if let Some((Some(user), credits)) = row + && credits > 0 + { + sqlx::query( + "INSERT INTO credit_ledger (id, user_id, delta, reason, analysis_id, note) \ + VALUES ($1, $2, $3, 'refund', $4, 'analysis failed') ON CONFLICT DO NOTHING", + ) + .bind(Uuid::now_v7()) + .bind(user) + .bind(credits) + .bind(id) + .execute(&mut *tx) + .await?; + } + tx.commit().await + } + + /// Puts analyses left `running` by a stopped worker back in the queue. + pub async fn requeue_stuck(&self) -> Result { + let result = sqlx::query( + "UPDATE analyses SET status = 'pending', error = 'interrupted', next_attempt_at = now() \ + WHERE status = 'running' AND started_at < now() - make_interval(mins => $1)", + ) + .bind(STUCK_AFTER_MINUTES) + .execute(&self.db) + .await?; + Ok(result.rows_affected()) + } + + /// On shutdown: analyses still being written go back to `pending` at once. + async fn release_running(&self) { + let ids: Vec = self.running.lock().unwrap().drain().collect(); + if ids.is_empty() { + return; + } + let result = sqlx::query( + "UPDATE analyses SET status = 'pending', error = 'interrupted', next_attempt_at = now(), \ + attempts = greatest(attempts - 1, 0) WHERE id = ANY($1) AND status = 'running'", + ) + .bind(&ids) + .execute(&self.db) + .await; + match result { + Ok(r) => tracing::info!(released = r.rows_affected(), "unfinished analyses put back in the queue"), + Err(e) => tracing::error!(error = %e, "releasing unfinished analyses"), + } + } +} + +pub async fn run(analyzer: Arc, poll: Duration, stop: watch::Receiver) { + let slots = Arc::new(Semaphore::new(analyzer.concurrency)); + let mut tasks = tokio::task::JoinSet::new(); + let mut listener = crate::listen(&analyzer.db, "analyses").await; + let mut last_requeue: Option = None; + loop { + if *stop.borrow() { + break; + } + if last_requeue.is_none_or(|t| t.elapsed() > Duration::from_secs(60)) { + last_requeue = Some(Instant::now()); + match analyzer.requeue_stuck().await { + Ok(0) => {} + Ok(n) => tracing::warn!(requeued = n, "interrupted analyses requeued"), + Err(e) => tracing::error!(error = %e, "requeueing analyses"), + } + } + // Fill the free slots. + while let Ok(permit) = slots.clone().try_acquire_owned() { + match analyzer.claim().await { + Ok(Some(job)) => { + let analyzer = analyzer.clone(); + tasks.spawn(async move { + analyzer.handle(job).await; + drop(permit); + }); + } + Ok(None) => break, + Err(e) => { + tracing::error!(error = %e, "claiming an analysis"); + break; + } + } + } + while tasks.try_join_next().is_some() {} + + tokio::select! { + () = crate::notified(listener.as_mut()) => {} + () = tokio::time::sleep(poll) => {} + Some(_) = tasks.join_next(), if !tasks.is_empty() => {} + () = crate::stopped(stop.clone()) => break, + } + } + // Give running analyses a moment, then hand the rest back to the queue. + let _ = tokio::time::timeout(Duration::from_secs(10), async { while tasks.join_next().await.is_some() {} }).await; + tasks.abort_all(); + analyzer.release_running().await; +} diff --git a/services/worker/src/analysis/openrouter.rs b/services/worker/src/analysis/openrouter.rs new file mode 100644 index 0000000..1f4701b --- /dev/null +++ b/services/worker/src/analysis/openrouter.rs @@ -0,0 +1,155 @@ +//! OpenRouter chat completions with structured (JSON schema) output. + +use std::time::Duration; + +use serde_json::{Value, json}; + +use super::prompt::{Prompt, validate}; + +pub const DEFAULT_BASE_URL: &str = "https://openrouter.ai/api/v1"; +/// Room for reasoning tokens as well as the answer. +const MAX_TOKENS: u32 = 16_000; + +pub struct OpenRouter { + http: reqwest::Client, + base_url: String, + api_key: String, + /// Sent as `HTTP-Referer` (app attribution on openrouter.ai). + referer: Option, +} + +#[derive(Debug, Clone)] +pub struct Completion { + pub content: Value, + /// The model that answered (differs from the requested one for routers like `openrouter/auto`). + pub model: String, + pub input_tokens: Option, + pub output_tokens: Option, + pub cost_usd: Option, +} + +#[derive(Debug, PartialEq)] +pub enum LlmError { + /// Worth retrying later (network, rate limit, provider outage, malformed answer). + Transient(String), + /// Retrying will not help (bad request, unknown model, rejected key). + Permanent(String), +} + +impl LlmError { + pub fn message(&self) -> &str { + match self { + LlmError::Transient(m) | LlmError::Permanent(m) => m, + } + } +} + +/// The JSON object in a reply, also when wrapped in a ``` fence or prose. +fn extract_json(text: &str) -> Option { + let trimmed = text.trim(); + if let Ok(v) = serde_json::from_str(trimmed) { + return Some(v); + } + let (start, end) = (trimmed.find('{')?, trimmed.rfind('}')?); + serde_json::from_str(trimmed.get(start..=end)?).ok() +} + +fn error_message(body: &Value, fallback: &str) -> String { + let e = &body["error"]; + let message = e["message"].as_str().unwrap_or(fallback); + match e["metadata"]["raw"].as_str() { + Some(raw) => format!("{message}: {}", raw.chars().take(300).collect::()), + None => message.to_owned(), + } +} + +impl OpenRouter { + pub fn new(base_url: &str, api_key: &str, referer: Option) -> Self { + let http = reqwest::Client::builder() + .timeout(Duration::from_secs(300)) + .connect_timeout(Duration::from_secs(10)) + .build() + .expect("HTTP client"); + Self { http, base_url: base_url.trim_end_matches('/').to_owned(), api_key: api_key.to_owned(), referer } + } + + pub async fn complete(&self, model: &str, prompt: &Prompt) -> Result { + let body = json!({ + "model": model, + "messages": [ + {"role": "system", "content": prompt.system}, + {"role": "user", "content": prompt.user}, + ], + "response_format": { + "type": "json_schema", + "json_schema": {"name": prompt.schema_name, "strict": true, "schema": prompt.schema}, + }, + // Only route to providers that honour the schema. + "provider": {"require_parameters": true}, + "max_tokens": MAX_TOKENS, + "usage": {"include": true}, + }); + let mut request = self + .http + .post(format!("{}/chat/completions", self.base_url)) + .bearer_auth(&self.api_key) + .header("X-Title", "Sorsfonalak") + .json(&body); + if let Some(referer) = &self.referer { + request = request.header("HTTP-Referer", referer); + } + let response = request.send().await.map_err(|e| LlmError::Transient(format!("request failed: {e}")))?; + let status = response.status(); + let text = response.text().await.map_err(|e| LlmError::Transient(format!("reading response: {e}")))?; + let reply: Value = serde_json::from_str(&text).unwrap_or(Value::Null); + + if !status.is_success() { + let message = format!( + "HTTP {}: {}", + status.as_u16(), + error_message(&reply, &text.chars().take(300).collect::()) + ); + // 402: our OpenRouter balance ran out; 408/429/5xx: try again later. + return Err(match status.as_u16() { + 402 | 408 | 429 | 500..=599 => LlmError::Transient(message), + _ => LlmError::Permanent(message), + }); + } + if reply["error"].is_object() { + return Err(LlmError::Transient(format!("provider error: {}", error_message(&reply, "unknown")))); + } + let choice = &reply["choices"][0]; + if choice["finish_reason"] == "length" { + return Err(LlmError::Transient("answer cut off at the token limit".into())); + } + let raw = choice["message"]["content"].as_str().unwrap_or_default(); + let content = extract_json(raw).ok_or_else(|| { + LlmError::Transient(format!("answer is not JSON: {}", raw.chars().take(200).collect::())) + })?; + validate(&prompt.schema, &content) + .map_err(|e| LlmError::Transient(format!("answer does not match the schema: {e}")))?; + + let usage = &reply["usage"]; + let tokens = |key: &str| usage[key].as_i64().and_then(|n| i32::try_from(n).ok()); + Ok(Completion { + content, + model: reply["model"].as_str().unwrap_or(model).to_owned(), + input_tokens: tokens("prompt_tokens"), + output_tokens: tokens("completion_tokens"), + cost_usd: usage["cost"].as_f64(), + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn extracts_json_from_fences_and_prose() { + assert_eq!(extract_json(r#"{"a":1}"#), Some(json!({"a": 1}))); + assert_eq!(extract_json("```json\n{\"a\": 1}\n```"), Some(json!({"a": 1}))); + assert_eq!(extract_json("Here you go: {\"a\": {\"b\": 2}} Enjoy!"), Some(json!({"a": {"b": 2}}))); + assert_eq!(extract_json("no json here"), None); + } +} diff --git a/services/worker/src/analysis/prompt.rs b/services/worker/src/analysis/prompt.rs new file mode 100644 index 0000000..b7c1409 --- /dev/null +++ b/services/worker/src/analysis/prompt.rs @@ -0,0 +1,224 @@ +//! Prompts and output schemas of the analyses (prompt version [`PROMPT_VERSION`]). +//! +//! The model answers with one JSON object (OpenRouter structured output); +//! [`validate`] checks it against the same schema before it is stored. + +use serde_json::{Value, json}; + +/// Matches the backend's `ANALYSIS_PROMPT_VERSION` (part of the cache key). +pub const PROMPT_VERSION: &str = "v1"; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Kind { + Natal, + Synastry, +} + +impl Kind { + pub fn parse(s: &str) -> Option { + match s { + "natal" => Some(Kind::Natal), + "synastry" => Some(Kind::Synastry), + _ => None, + } + } +} + +pub struct Prompt { + pub system: String, + pub user: String, + pub schema_name: &'static str, + pub schema: Value, +} + +/// (key, what the section covers) in reading order. +const NATAL_SECTIONS: [(&str, &str); 6] = [ + ("personality", "Core identity: the Sun, Moon, Ascendant and chart ruler read together"), + ("emotions", "Emotional needs, security and inner life (Moon, 4th house, water emphasis)"), + ("mind", "Thinking, communication and learning (Mercury, 3rd and 9th houses)"), + ("love", "Love, attraction and relationships (Venus, Mars, 5th and 7th houses, Descendant)"), + ("work", "Calling, career, money and daily work (MC, 10th, 2nd and 6th houses, Saturn, Jupiter)"), + ( + "growth", + "Main inner tensions, life lessons and the path of growth (tight squares and oppositions, Saturn, Chiron, Nodes)", + ), +]; + +const SYNASTRY_SECTIONS: [(&str, &str); 5] = [ + ("attraction", "What draws them together: Sun, Moon, Venus, Mars and Ascendant contacts"), + ("communication", "How they think and talk together (Mercury contacts, air emphasis, 3rd house overlays)"), + ("emotional_bond", "Emotional closeness, safety and care (Moon contacts, 4th and 8th house overlays)"), + ("friction", "Where they rub against each other and how to handle it (challenging aspects, Saturn, Pluto, Mars)"), + ("long_term", "Long-term potential and shared purpose, including the composite chart"), +]; + +fn sections(kind: Kind) -> &'static [(&'static str, &'static str)] { + match kind { + Kind::Natal => &NATAL_SECTIONS, + Kind::Synastry => &SYNASTRY_SECTIONS, + } +} + +/// The JSON schema of the answer (strict mode: every property required). +pub fn schema(kind: Kind) -> Value { + let mut props = serde_json::Map::new(); + for (key, about) in sections(kind) { + props.insert( + (*key).into(), + json!({ + "type": "object", + "description": about, + "additionalProperties": false, + "required": ["title", "body"], + "properties": { + "title": {"type": "string", "description": "Short, specific section title (not just the topic name)"}, + "body": {"type": "string", "description": "2-4 paragraphs separated by a blank line"} + } + }), + ); + } + let keys: Vec<&str> = sections(kind).iter().map(|(k, _)| *k).collect(); + json!({ + "type": "object", + "additionalProperties": false, + "required": ["title", "summary", "sections", "strengths", "challenges", "advice"], + "properties": { + "title": {"type": "string", "description": "Short, evocative title for this analysis (at most 8 words)"}, + "summary": {"type": "string", "description": "3-4 sentence overview"}, + "sections": {"type": "object", "additionalProperties": false, "required": keys, "properties": props}, + "strengths": {"type": "array", "items": {"type": "string"}, "description": "3-5 key strengths, one sentence each"}, + "challenges": {"type": "array", "items": {"type": "string"}, "description": "3-5 key challenges, one sentence each"}, + "advice": {"type": "string", "description": "A closing, encouraging paragraph with concrete guidance"} + } + }) +} + +const HUNGARIAN_STYLE: &str = "\ +Write natural, idiomatic Hungarian, as a native Hungarian author would; it must not read like a translation from English. \ +Use correct Hungarian suffixes and vowel harmony, Hungarian quotation marks („…”) and the en dash (–). \ +Use the usual Hungarian astrological terms: +- signs: Kos, Bika, Ikrek, Rák, Oroszlán, Szűz, Mérleg, Skorpió, Nyilas, Bak, Vízöntő, Halak (\"a Nap a Rák jegyében\", \"Kos Aszcendens\"); +- planets and points: Nap, Hold, Merkúr, Vénusz, Mars, Jupiter, Szaturnusz, Uránusz, Neptunusz, Plútó, Chiron (Kiron), \ +Észak-Holdcsomópont, Dél-Holdcsomópont, Lilith (Fekete Hold), Aszcendens, Descendens, Medium Coeli (MC), Imum Coeli (IC), Szerencsepont; +- aspects: együttállás (konjunkció), szextil, kvadrát (négyzet), trigon, szembenállás (oppozíció); +- other: \"a 3. házban\", \"a horoszkóp uralkodója\", retrográd, uralom (domicilium), száműzetés, exaltáció, esés, nappali/éjszakai horoszkóp."; + +fn language_name(language: &str) -> &'static str { + match language { + "hu" => "Hungarian", + _ => "English", + } +} + +fn rules(kind: Kind, language: &str) -> String { + let (role, reader) = match kind { + Kind::Natal => ( + "a personal natal chart interpretation", + "Speak to the owner of the chart directly, in the informal second person singular (in Hungarian: tegező forma, \"te\").", + ), + Kind::Synastry => ( + "a relationship (synastry) interpretation for two people", + "Write for both people at once, in the informal second person plural (in Hungarian: \"ti\", \"kettőtök\"). \ + When you must tell them apart, call them Person 1 and Person 2 (in Hungarian: \"az első fél\" and \"a második fél\"). \ + Do not assume their genders or the type of relationship.", + ), + }; + let mut text = format!( + "You are an experienced, warm and psychologically minded astrologer. You write {role} for the Sorsfonalak app. + +Write in {lang}. + +Rules: +- Base every statement on the chart data given. Never invent positions, aspects or houses that are not listed. +- When you interpret a placement, name its astrological basis in a short clause, but keep the focus on the person, not on jargon. +- Synthesize: weave signs, houses, aspects and rulers into one coherent portrait; show how tensions can be integrated. \ +Give the most weight to the Sun, Moon, Ascendant, chart ruler, tight aspects (orb under 3°) and strong emphases or gaps in elements and modalities. +- If a birth time is unknown, do not mention houses, the Ascendant or the Midheaven for that chart, and be careful with the Moon's sign. +- {reader} +- Tone: warm, honest, empowering and concrete. Not fatalistic: no predictions of illness, death, accidents or specific events, \ +and no medical, legal or financial advice. +- Avoid generic horoscope clichés and filler: every paragraph must say something specific to this chart. +- Texts are plain paragraphs separated by a blank line, without headings or lists inside; **bold** may be used sparingly. +- Length: each section 2-4 paragraphs (about 150-250 words); the whole analysis about 1300-1800 words. +- Answer with a single JSON object that matches the given schema, and nothing else.", + lang = language_name(language), + ); + if language == "hu" { + text.push_str("\n\n"); + text.push_str(HUNGARIAN_STYLE); + } + text +} + +pub fn build(kind: Kind, language: &str, chart_text: &str) -> Prompt { + let mut user = String::from("Chart data:\n\n"); + user.push_str(chart_text); + user.push_str("\nSections to write, in this order:\n"); + for (key, about) in sections(kind) { + user.push_str(&format!("- {key}: {about}\n")); + } + user.push_str("\nWrite the analysis now."); + Prompt { + system: rules(kind, language), + user, + schema_name: match kind { + Kind::Natal => "natal_analysis", + Kind::Synastry => "synastry_analysis", + }, + schema: schema(kind), + } +} + +/// Checks an answer against our schema subset (objects with required +/// properties, non-empty strings, string arrays with at least two items). +pub fn validate(schema: &Value, value: &Value) -> Result<(), String> { + fn walk(schema: &Value, value: &Value, path: &str) -> Result<(), String> { + match schema["type"].as_str() { + Some("object") => { + let obj = value.as_object().ok_or_else(|| format!("{path}: expected an object"))?; + for key in schema["required"].as_array().into_iter().flatten().filter_map(Value::as_str) { + let child = obj.get(key).ok_or_else(|| format!("{path}.{key}: missing"))?; + walk(&schema["properties"][key], child, &format!("{path}.{key}"))?; + } + Ok(()) + } + Some("array") => { + let items = value.as_array().ok_or_else(|| format!("{path}: expected an array"))?; + if items.len() < 2 { + return Err(format!("{path}: too few items")); + } + items.iter().enumerate().try_for_each(|(i, v)| walk(&schema["items"], v, &format!("{path}[{i}]"))) + } + Some("string") => match value.as_str() { + Some(s) if !s.trim().is_empty() => Ok(()), + _ => Err(format!("{path}: expected a non-empty string")), + }, + _ => Ok(()), + } + } + walk(schema, value, "$") +} + +/// The analysis as Markdown (for reading and comparing outputs). +pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String { + let (strengths, challenges, advice) = if language == "hu" { + ("Erősségek", "Kihívások", "Útravaló") + } else { + ("Strengths", "Challenges", "Advice") + }; + let mut md = + format!("# {}\n\n_{}_\n\n", content["title"].as_str().unwrap_or(""), content["summary"].as_str().unwrap_or("")); + for (key, _) in sections(kind) { + let s = &content["sections"][*key]; + md.push_str(&format!("## {}\n\n{}\n\n", s["title"].as_str().unwrap_or(key), s["body"].as_str().unwrap_or(""))); + } + for (title, key) in [(strengths, "strengths"), (challenges, "challenges")] { + md.push_str(&format!("## {title}\n\n")); + for item in content[key].as_array().into_iter().flatten().filter_map(Value::as_str) { + md.push_str(&format!("- {item}\n")); + } + md.push('\n'); + } + md.push_str(&format!("## {advice}\n\n{}\n", content["advice"].as_str().unwrap_or(""))); + md +} diff --git a/services/worker/src/compare.rs b/services/worker/src/compare.rs new file mode 100644 index 0000000..f455a01 --- /dev/null +++ b/services/worker/src/compare.rs @@ -0,0 +1,130 @@ +//! `worker compare-models`: writes the same natal analysis with several +//! models for a blind comparison. +//! +//! ```text +//! OPENROUTER_API_KEY=... worker compare-models --chart natal.json \ +//! --models minimax/minimax-m3,anthropic/claude-sonnet-5.5 [--language hu] [--out DIR] +//! ``` +//! +//! `--chart` is a horoscope-api `/v1/natal` response. The models get shuffled +//! letters: `A.md`, `B.md`, ... hold the analyses, `key.json` tells which +//! letter is which model (with tokens, cost and time). The output on the +//! console does not reveal the mapping. + +use std::path::PathBuf; +use std::time::Instant; + +use anyhow::{Context, bail}; +use rand::seq::SliceRandom; +use serde_json::{Value, json}; + +use crate::analysis::openrouter::{DEFAULT_BASE_URL, OpenRouter}; +use crate::analysis::{compact, prompt}; + +struct Args { + chart: PathBuf, + models: Vec, + language: String, + out: PathBuf, +} + +fn parse(args: Vec) -> anyhow::Result { + let (mut chart, mut models, mut language, mut out) = (None, Vec::new(), "hu".to_owned(), None); + let mut it = args.into_iter(); + while let Some(flag) = it.next() { + let mut value = || it.next().with_context(|| format!("{flag} needs a value")); + match flag.as_str() { + "--chart" => chart = Some(PathBuf::from(value()?)), + "--models" => models = value()?.split(',').map(|m| m.trim().to_owned()).filter(|m| !m.is_empty()).collect(), + "--language" => language = value()?, + "--out" => out = Some(PathBuf::from(value()?)), + other => bail!("unknown argument '{other}'"), + } + } + let chart = chart.context("--chart is required")?; + if models.is_empty() { + bail!("--models is required (comma separated OpenRouter model ids)"); + } + if models.len() > 26 { + bail!("at most 26 models"); + } + let out = out.unwrap_or_else(|| { + let stamp = time::OffsetDateTime::now_utc().unix_timestamp(); + PathBuf::from(format!("model-compare-{stamp}")) + }); + Ok(Args { chart, models, language, out }) +} + +pub async fn main(args: Vec) -> anyhow::Result<()> { + let args = parse(args)?; + let key = std::env::var("OPENROUTER_API_KEY") + .ok() + .filter(|k| !k.trim().is_empty()) + .context("OPENROUTER_API_KEY is not set")?; + let base_url = std::env::var("OPENROUTER_BASE_URL").unwrap_or_else(|_| DEFAULT_BASE_URL.into()); + + let raw = std::fs::read_to_string(&args.chart).with_context(|| format!("reading {}", args.chart.display()))?; + let mut chart: Value = serde_json::from_str(&raw).context("--chart is not JSON")?; + if chart["result"].is_object() { + chart = chart["result"].take(); + } + let built = prompt::build(prompt::Kind::Natal, &args.language, &compact::natal(&chart)); + + std::fs::create_dir_all(&args.out)?; + std::fs::write( + args.out.join("prompt.md"), + format!( + "# System\n\n{}\n\n# User\n\n{}\n\n# Schema\n\n```json\n{:#}\n```\n", + built.system, built.user, built.schema + ), + )?; + + let mut models = args.models.clone(); + models.shuffle(&mut rand::rng()); + let llm = std::sync::Arc::new(OpenRouter::new(&base_url, &key, None)); + let built = std::sync::Arc::new(built); + println!("Writing {} analyses in parallel (this takes a minute or two)...", models.len()); + + let mut tasks = tokio::task::JoinSet::new(); + for (i, model) in models.iter().enumerate() { + let (llm, built, model) = (llm.clone(), built.clone(), model.clone()); + let letter = char::from(b'A' + i as u8); + tasks.spawn(async move { + let started = Instant::now(); + let result = llm.complete(&model, &built).await; + (letter, model, result, started.elapsed().as_secs_f64()) + }); + } + + let mut key_entries = Vec::new(); + let mut total_cost = 0.0; + while let Some(joined) = tasks.join_next().await { + let (letter, model, result, secs) = joined?; + match result { + Ok(c) => { + let md = prompt::to_markdown(prompt::Kind::Natal, &args.language, &c.content); + let words = md.split_whitespace().count(); + std::fs::write(args.out.join(format!("{letter}.md")), &md)?; + std::fs::write(args.out.join(format!("{letter}.json")), serde_json::to_string_pretty(&c.content)?)?; + total_cost += c.cost_usd.unwrap_or(0.0); + println!("{letter}: ok, {words} words"); + key_entries.push(json!({ + "letter": letter.to_string(), "model": model, "model_used": c.model, "ok": true, "words": words, + "input_tokens": c.input_tokens, "output_tokens": c.output_tokens, "cost_usd": c.cost_usd, + "seconds": (secs * 10.0).round() / 10.0, + })); + } + Err(e) => { + println!("{letter}: failed (details in key.json)"); + key_entries.push(json!({ + "letter": letter.to_string(), "model": model, "ok": false, "error": e.message(), + "seconds": (secs * 10.0).round() / 10.0, + })); + } + } + } + key_entries.sort_by(|a, b| a["letter"].as_str().cmp(&b["letter"].as_str())); + std::fs::write(args.out.join("key.json"), serde_json::to_string_pretty(&key_entries)?)?; + println!("Total cost: ${total_cost:.4}. Output: {}", args.out.display()); + Ok(()) +} diff --git a/services/worker/src/config.rs b/services/worker/src/config.rs index cd7390a..fd69cf9 100644 --- a/services/worker/src/config.rs +++ b/services/worker/src/config.rs @@ -16,6 +16,15 @@ pub struct Config { pub poll_interval: Duration, /// After this many failed attempts an e-mail is marked as failed. pub max_email_attempts: i32, + /// Unset: analyses stay pending. + pub openrouter_api_key: Option, + pub openrouter_base_url: String, + /// Frontend address, sent to OpenRouter as `HTTP-Referer`. + pub public_base_url: Option, + /// Analyses written at the same time. + pub analysis_concurrency: usize, + /// After this many failed attempts an analysis fails and is refunded. + pub max_analysis_attempts: i32, } fn var(name: &str) -> Option { @@ -41,6 +50,12 @@ impl Config { mail_from: mail_from.parse().with_context(|| format!("invalid MAIL_FROM '{mail_from}'"))?, poll_interval: Duration::from_secs(parsed("POLL_INTERVAL_SECS", 30)?), max_email_attempts: parsed("MAX_EMAIL_ATTEMPTS", 8)?, + openrouter_api_key: var("OPENROUTER_API_KEY"), + openrouter_base_url: var("OPENROUTER_BASE_URL") + .unwrap_or_else(|| crate::analysis::openrouter::DEFAULT_BASE_URL.into()), + public_base_url: var("PUBLIC_BASE_URL"), + analysis_concurrency: parsed("ANALYSIS_CONCURRENCY", 4)?, + max_analysis_attempts: parsed("MAX_ANALYSIS_ATTEMPTS", 3)?, }) } } diff --git a/services/worker/src/email.rs b/services/worker/src/email.rs index 1c68a67..937984e 100644 --- a/services/worker/src/email.rs +++ b/services/worker/src/email.rs @@ -10,7 +10,6 @@ use lettre::message::{Mailbox, MultiPart}; use lettre::{AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor}; use serde_json::Value; use sqlx::PgPool; -use sqlx::postgres::PgListener; use tokio::sync::watch; use uuid::Uuid; @@ -174,18 +173,8 @@ impl Delivery { } } -async fn listen(db: &PgPool) -> Option { - let result = async { - let mut listener = PgListener::connect_with(db).await?; - listener.listen(CHANNEL).await?; - Ok::<_, sqlx::Error>(listener) - } - .await; - result.map_err(|e| tracing::warn!(error = %e, "LISTEN failed; polling only")).ok() -} - pub async fn run(delivery: Delivery, poll: Duration, stop: watch::Receiver) { - let mut listener = listen(&delivery.db).await; + let mut listener = crate::listen(&delivery.db, CHANNEL).await; loop { if *stop.borrow() { break; @@ -195,20 +184,8 @@ pub async fn run(delivery: Delivery, poll: Duration, stop: watch::Receiver Ok(_) => {} Err(e) => tracing::error!(error = %e, "e-mail delivery"), } - let notified = async { - match listener.as_mut() { - // Reconnects by itself; an error means the connection was lost for now. - Some(l) => { - if let Err(e) = l.recv().await { - tracing::warn!(error = %e, "LISTEN connection lost"); - tokio::time::sleep(Duration::from_secs(5)).await; - } - } - None => std::future::pending().await, - } - }; tokio::select! { - () = notified => {} + () = crate::notified(listener.as_mut()) => {} () = tokio::time::sleep(poll) => {} () = crate::stopped(stop.clone()) => break, } diff --git a/services/worker/src/main.rs b/services/worker/src/main.rs index 21dc453..ba40604 100644 --- a/services/worker/src/main.rs +++ b/services/worker/src/main.rs @@ -3,17 +3,21 @@ //! //! * e-mail delivery from `email_outbox` over SMTP (Mailpit in development) //! * hourly cleanup of expired sessions, tokens, invites and old e-mails -//! * later: writing the text analyses (LLM) +//! * writing the requested text analyses with an LLM (OpenRouter) //! //! Configuration: see [`config::Config`]; plus `BIND_ADDR` (default //! `0.0.0.0:8082`, only `/healthz`), `LOG_FORMAT` and `RUST_LOG`. -//! `worker healthcheck` performs a local health check (for Docker). +//! `worker healthcheck` performs a local health check (for Docker); +//! `worker compare-models ...` writes one analysis with several models (see [`compare`]). +mod analysis; mod cleanup; +mod compare; mod config; mod email; mod templates; +use std::sync::Arc; use std::time::Duration; use anyhow::Context; @@ -22,6 +26,7 @@ use axum::extract::State; use axum::http::StatusCode; use axum::routing::get; use sqlx::PgPool; +use sqlx::postgres::PgListener; use tokio::sync::watch; use crate::config::Config; @@ -33,6 +38,31 @@ pub async fn stopped(mut stop: watch::Receiver) { let _ = stop.wait_for(|s| *s).await; } +/// Subscribes to a NOTIFY channel; `None` (polling only) if that fails. +pub async fn listen(db: &PgPool, channel: &str) -> Option { + let result = async { + let mut listener = PgListener::connect_with(db).await?; + listener.listen(channel).await?; + Ok::<_, sqlx::Error>(listener) + } + .await; + result.map_err(|e| tracing::warn!(channel, error = %e, "LISTEN failed; polling only")).ok() +} + +/// Resolves on the next notification; never without a listener. +pub async fn notified(listener: Option<&mut PgListener>) { + match listener { + // Reconnects by itself; an error means the connection is down for now. + Some(l) => { + if let Err(e) = l.recv().await { + tracing::warn!(error = %e, "LISTEN connection lost"); + tokio::time::sleep(Duration::from_secs(5)).await; + } + } + None => std::future::pending().await, + } +} + async fn healthz(State(db): State) -> StatusCode { match sqlx::query("SELECT 1").execute(&db).await { Ok(_) => StatusCode::OK, @@ -43,8 +73,13 @@ async fn healthz(State(db): State) -> StatusCode { #[tokio::main] async fn main() -> anyhow::Result<()> { let addr = service_kit::bind_addr(DEFAULT_BIND_ADDR)?; - if std::env::args().nth(1).as_deref() == Some("healthcheck") { - return service_kit::healthcheck(addr); + match std::env::args().nth(1).as_deref() { + Some("healthcheck") => return service_kit::healthcheck(addr), + Some("compare-models") => { + service_kit::init_logging(); + return compare::main(std::env::args().skip(2).collect()).await; + } + _ => {} } service_kit::init_logging(); let config = Config::from_env()?; @@ -61,6 +96,17 @@ async fn main() -> anyhow::Result<()> { } None => tracing::warn!("SMTP_URL is not set: e-mails stay in the outbox"), } + match &config.openrouter_api_key { + Some(key) => { + let llm = + analysis::openrouter::OpenRouter::new(&config.openrouter_base_url, key, config.public_base_url.clone()); + let analyzer = + analysis::Analyzer::new(pool.clone(), llm, config.max_analysis_attempts, config.analysis_concurrency); + tracing::info!(concurrency = analyzer.concurrency, "analyses enabled"); + jobs.spawn(analysis::run(Arc::new(analyzer), config.poll_interval, stop.clone())); + } + None => tracing::warn!("OPENROUTER_API_KEY is not set: analyses stay pending"), + } jobs.spawn(cleanup::run(pool.clone(), stop.clone())); let app = Router::new().route("/healthz", get(healthz)).with_state(pool); diff --git a/services/worker/src/tests.rs b/services/worker/src/tests.rs index 2881673..392746b 100644 --- a/services/worker/src/tests.rs +++ b/services/worker/src/tests.rs @@ -180,3 +180,304 @@ async fn cleanup_removes_only_expired_data(db: PgPool) { sqlx::query_as("SELECT array_agg(id ORDER BY id) FROM email_outbox").fetch_one(&db).await.unwrap(); assert_eq!(left, vec![recent, unsent]); } + +// --- analyses ---------------------------------------------------------------------------- + +mod analyses { + use std::sync::{Arc, Mutex}; + + use axum::Json; + use axum::extract::State; + use axum::http::StatusCode; + use serde_json::{Value, json}; + use sqlx::PgPool; + use uuid::Uuid; + + use crate::analysis::openrouter::OpenRouter; + use crate::analysis::prompt::{Kind, schema, validate}; + use crate::analysis::{Analyzer, backoff}; + + /// Scripted replies (then the last one forever) and the requests received. + #[derive(Clone, Default)] + struct Fake { + replies: Arc>>, + requests: Arc>>, + } + + async fn completions(State(fake): State, Json(body): Json) -> (StatusCode, Json) { + fake.requests.lock().unwrap().push(body); + let mut replies = fake.replies.lock().unwrap(); + let (status, reply) = if replies.len() > 1 { replies.remove(0) } else { replies[0].clone() }; + (StatusCode::from_u16(status).unwrap(), Json(reply)) + } + + async fn fake_openrouter(replies: Vec<(u16, Value)>) -> (Fake, String) { + let fake = Fake { replies: Arc::new(Mutex::new(replies)), ..Default::default() }; + let app = + axum::Router::new().route("/chat/completions", axum::routing::post(completions)).with_state(fake.clone()); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let addr = listener.local_addr().unwrap(); + tokio::spawn(async move { axum::serve(listener, app).await.unwrap() }); + (fake, format!("http://{addr}")) + } + + fn content(kind: Kind) -> Value { + let schema = schema(kind); + let keys: Vec<&str> = schema["properties"]["sections"]["required"] + .as_array() + .unwrap() + .iter() + .map(|k| k.as_str().unwrap()) + .collect(); + let sections: serde_json::Map = keys + .iter() + .map(|k| ((*k).to_owned(), json!({"title": format!("Cím {k}"), "body": "Első bekezdés.\n\nMásodik."}))) + .collect(); + json!({ + "title": "Csendes erő", "summary": "Összefoglaló.", "sections": sections, + "strengths": ["Kitartás.", "Empátia."], "challenges": ["Túlgondolás.", "Visszahúzódás."], + "advice": "Bízz magadban." + }) + } + + fn reply(content: &Value) -> (u16, Value) { + ( + 200, + json!({ + "model": "test/model-2026", + "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": content.to_string()}}], + "usage": {"prompt_tokens": 2100, "completion_tokens": 4800, "cost": 0.0123} + }), + ) + } + + fn fixture(name: &str) -> Value { + let path = format!("{}/testdata/{name}", env!("CARGO_MANIFEST_DIR")); + serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap() + } + + struct Setup { + user: Uuid, + chart: Uuid, + } + + async fn setup(db: &PgPool) -> Setup { + let (user, chart) = (Uuid::now_v7(), Uuid::now_v7()); + sqlx::query("INSERT INTO users (id, email) VALUES ($1, 'anna@example.com')") + .bind(user) + .execute(db) + .await + .unwrap(); + sqlx::query( + "INSERT INTO charts (id, owner_id, label, is_primary, birth_data, result, chart_hash) \ + VALUES ($1, $2, 'Saját', true, '{}', $3, 'hash1')", + ) + .bind(chart) + .bind(user) + .bind(fixture("natal-1990-03-15.json")) + .execute(db) + .await + .unwrap(); + Setup { user, chart } + } + + async fn request_analysis(db: &PgPool, s: &Setup) -> Uuid { + let id = Uuid::now_v7(); + sqlx::query( + "INSERT INTO analyses (id, kind, chart_id, requested_by, language, model, prompt_version, cache_key, credits_charged) \ + VALUES ($1, 'natal', $2, $3, 'hu', 'test/model', 'v1', 'key', 1)", + ) + .bind(id) + .bind(s.chart) + .bind(s.user) + .execute(db) + .await + .unwrap(); + id + } + + fn analyzer(db: &PgPool, base_url: &str) -> Analyzer { + Analyzer::new(db.clone(), OpenRouter::new(base_url, "test-key", None), 3, 2) + } + + async fn run_once(a: &Analyzer) -> bool { + match a.claim().await.unwrap() { + Some(job) => { + a.handle(job).await; + true + } + None => false, + } + } + + type Row = (String, i32, Option, Option, Option, Option, bool); + + async fn row(db: &PgPool, id: Uuid) -> Row { + sqlx::query_as( + "SELECT status, attempts, error, model_used, output_tokens, cost_usd, next_attempt_at > now() \ + FROM analyses WHERE id = $1", + ) + .bind(id) + .fetch_one(db) + .await + .unwrap() + } + + async fn refunds(db: &PgPool, user: Uuid) -> Vec { + sqlx::query_scalar("SELECT delta FROM credit_ledger WHERE user_id = $1 AND reason = 'refund'") + .bind(user) + .fetch_all(db) + .await + .unwrap() + } + + async fn make_due(db: &PgPool, id: Uuid) { + sqlx::query("UPDATE analyses SET next_attempt_at = now() WHERE id = $1").bind(id).execute(db).await.unwrap(); + } + + #[sqlx::test(migrator = "db::MIGRATOR")] + async fn writes_the_analysis(db: PgPool) { + let s = setup(&db).await; + let id = request_analysis(&db, &s).await; + let (fake, url) = fake_openrouter(vec![reply(&content(Kind::Natal))]).await; + let a = analyzer(&db, &url); + + assert!(run_once(&a).await); + assert!(!run_once(&a).await, "nothing else is due"); + assert_eq!( + row(&db, id).await, + ("done".into(), 1, None, Some("test/model-2026".into()), Some(4800), Some(0.0123), false) + ); + let (stored,): (Value,) = + sqlx::query_as("SELECT content FROM analyses WHERE id = $1").bind(id).fetch_one(&db).await.unwrap(); + assert_eq!(stored["title"], "Csendes erő"); + + let requests = fake.requests.lock().unwrap(); + let body = &requests[0]; + assert_eq!(body["model"], "test/model"); + assert_eq!(body["response_format"]["json_schema"]["strict"], true); + assert_eq!(body["provider"]["require_parameters"], true); + let system = body["messages"][0]["content"].as_str().unwrap(); + let user = body["messages"][1]["content"].as_str().unwrap(); + assert!(system.contains("Write in Hungarian.") && system.contains("Szaturnusz")); + assert!(user.contains("- Sun: Pisces 24°42', house 8") && user.contains("- personality: ")); + // No birth data in the prompt. + for secret in ["1990", "14:30", "Szeged", "Hungary"] { + assert!(!user.contains(secret) && !system.contains(secret), "{secret} leaked"); + } + } + + #[sqlx::test(migrator = "db::MIGRATOR")] + async fn retries_bad_answers_then_fails_and_refunds(db: PgPool) { + let s = setup(&db).await; + let id = request_analysis(&db, &s).await; + let broken = json!({"title": "Csak cím"}); + let (_, url) = fake_openrouter(vec![reply(&broken)]).await; + let a = analyzer(&db, &url); + + assert!(run_once(&a).await); + let (status, attempts, error, _, _, _, later) = row(&db, id).await; + assert_eq!((status.as_str(), attempts, later), ("pending", 1, true)); + assert!(error.unwrap().contains("does not match the schema")); + assert!(!run_once(&a).await, "the retry waits"); + assert!(refunds(&db, s.user).await.is_empty()); + + for _ in 0..2 { + make_due(&db, id).await; + assert!(run_once(&a).await); + } + let (status, attempts, ..) = row(&db, id).await; + assert_eq!((status.as_str(), attempts), ("failed", 3)); + assert_eq!(refunds(&db, s.user).await, vec![1]); + } + + #[sqlx::test(migrator = "db::MIGRATOR")] + async fn permanent_errors_fail_at_once_and_retry_after_outage(db: PgPool) { + let s = setup(&db).await; + let bad_model = request_analysis(&db, &s).await; + let (_, url) = fake_openrouter(vec![(400, json!({"error": {"message": "unknown model"}}))]).await; + assert!(run_once(&analyzer(&db, &url)).await); + let (status, attempts, error, ..) = row(&db, bad_model).await; + assert_eq!((status.as_str(), attempts), ("failed", 1)); + assert_eq!(error.as_deref(), Some("HTTP 400: unknown model")); + assert_eq!(refunds(&db, s.user).await, vec![1]); + + // A provider outage (5xx) is retried and then succeeds. + let outage = request_analysis(&db, &s).await; + let (_, url) = + fake_openrouter(vec![(503, json!({"error": {"message": "overloaded"}})), reply(&content(Kind::Natal))]) + .await; + let a = analyzer(&db, &url); + assert!(run_once(&a).await); + assert_eq!(row(&db, outage).await.0, "pending"); + make_due(&db, outage).await; + assert!(run_once(&a).await); + assert_eq!(row(&db, outage).await.0, "done"); + assert_eq!(refunds(&db, s.user).await, vec![1], "no refund for the successful one"); + } + + #[sqlx::test(migrator = "db::MIGRATOR")] + async fn synastry_prompt_and_stuck_jobs(db: PgPool) { + let s = setup(&db).await; + let response = fixture("synastry-response.json"); + let (chart2, synastry) = (Uuid::now_v7(), Uuid::now_v7()); + sqlx::query( + "INSERT INTO charts (id, owner_id, label, is_primary, birth_data, result, chart_hash) \ + VALUES ($1, $2, 'Partner', false, '{}', $3, 'hash2')", + ) + .bind(chart2) + .bind(s.user) + .bind(&response["person2"]) + .execute(&db) + .await + .unwrap(); + sqlx::query( + "INSERT INTO synastries (id, owner_id, chart1_id, chart2_id, result, synastry_hash) VALUES ($1, $2, $3, $4, $5, 'sh')", + ) + .bind(synastry) + .bind(s.user) + .bind(s.chart) + .bind(chart2) + .bind(&response) + .execute(&db) + .await + .unwrap(); + let id = Uuid::now_v7(); + sqlx::query( + "INSERT INTO analyses (id, kind, synastry_id, requested_by, language, model, prompt_version, cache_key, \ + status, started_at) VALUES ($1, 'synastry', $2, $3, 'en', 'test/model', 'v1', 'k2', 'running', now() - interval '20 minutes')", + ) + .bind(id) + .bind(synastry) + .bind(s.user) + .execute(&db) + .await + .unwrap(); + + let (fake, url) = fake_openrouter(vec![reply(&content(Kind::Synastry))]).await; + let a = analyzer(&db, &url); + assert!(!run_once(&a).await, "running jobs are not claimed"); + assert_eq!(a.requeue_stuck().await.unwrap(), 1); + assert!(run_once(&a).await); + assert_eq!(row(&db, id).await.0, "done"); + + let requests = fake.requests.lock().unwrap(); + let user = requests[0]["messages"][1]["content"].as_str().unwrap(); + assert!(user.starts_with("Chart data:\n\nSYNASTRY") && user.contains("- attraction: ")); + assert!(requests[0]["messages"][0]["content"].as_str().unwrap().contains("Write in English.")); + assert!(!user.contains("Szeged") && !user.contains("Pécs")); + } + + #[test] + fn schema_validation_and_backoff() { + let schema = schema(Kind::Natal); + assert_eq!(validate(&schema, &content(Kind::Natal)), Ok(())); + let mut c = content(Kind::Natal); + c["sections"]["love"]["body"] = json!(" "); + assert_eq!(validate(&schema, &c), Err("$.sections.love.body: expected a non-empty string".into())); + c["sections"]["love"]["body"] = json!("Szöveg."); + c["sections"].as_object_mut().unwrap().remove("work"); + assert!(validate(&schema, &c).unwrap_err().contains("work: missing")); + assert_eq!([1, 2, 3, 9].map(|n| backoff(n).as_secs()), [30, 120, 480, 3600]); + } +} diff --git a/services/worker/testdata/natal-1988-11-02-notime.json b/services/worker/testdata/natal-1988-11-02-notime.json new file mode 100644 index 0000000..42f56d6 --- /dev/null +++ b/services/worker/testdata/natal-1988-11-02-notime.json @@ -0,0 +1 @@ +{"input":{"date":"1988-11-02","calendar":"gregorian","country":"HU","place":"Pécs","ambiguous_time":"reject","options":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true}},"location":{"country":{"iso2":"HU","iso3":"HUN","name":"Hungary"},"place":{"geonames_id":3046526,"name":"Pécs","country_code":"HU","region":"Baranya","latitude":46.07617,"longitude":18.22814,"elevation":155,"population":145347,"feature_code":"PPLA","timezone":"Europe/Budapest"},"latitude":46.07617,"longitude":18.22814,"elevation":155.0,"coordinates_source":"place"},"time":{"calendar":"gregorian","date_as_given":"1988-11-02","date":"1988-11-02","time_known":false,"zone":"Europe/Budapest","local":"1988-11-02T12:00:00","utc":"1988-11-02T11:00:00Z","utc_offset":"+01:00","utc_offset_seconds":3600,"dst":false,"abbreviation":"CET","zone_source":"place","local_mean_time":"12:12:55"},"settings":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true,"orbs":[{"aspect":"conjunction","angle":0.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0},{"aspect":"sextile","angle":60.0,"orb":5.0,"orb_with_luminary":7.0,"orb_with_minor_point":4.0},{"aspect":"square","angle":90.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"trine","angle":120.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"opposition","angle":180.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0}]},"astronomy":{"julian_day_ut":2447467.9583333335,"julian_day_tt":2447467.9589840383,"delta_t_seconds":56.22089645956596,"greenwich_sidereal_time":13.795757605012632,"greenwich_sidereal_time_hms":"13:47:45","local_sidereal_time":15.010966938345966,"local_sidereal_time_hms":"15:00:39","obliquity":{"true_obliquity":23.44316245092542,"mean_obliquity":23.440731685793907,"nutation_longitude":0.001209279324354778,"nutation_obliquity":0.00243076513151597}},"points":[{"id":"sun","kind":"luminary","longitude":220.24465918297574,"sign":"scorpio","degree_in_sign":10.244659182975738,"degree_in_sign_dms":"10°14'41\"","decan":2,"latitude":0.00006129337921598199,"distance_au":0.9920627304744153,"speed":1.001410686450585,"retrograde":false,"right_ascension":217.83065816525846,"declination":-14.893557312516599,"out_of_bounds":false,"house":null,"dignities":[]},{"id":"moon","kind":"luminary","longitude":141.59535398663743,"sign":"leo","degree_in_sign":21.595353986637434,"degree_in_sign_dms":"21°35'43\"","decan":3,"latitude":1.8239458197555352,"distance_au":0.002691676396389691,"speed":11.890352128408084,"retrograde":false,"right_ascension":144.58259463665843,"declination":16.034622640058284,"out_of_bounds":false,"house":null,"dignities":[]},{"id":"mercury","kind":"planet","longitude":203.67240488664407,"sign":"libra","degree_in_sign":23.672404886644074,"degree_in_sign_dms":"23°40'21\"","decan":3,"latitude":2.080066097793658,"distance_au":1.1494413552322,"speed":1.4592947124163995,"retrograde":false,"right_ascension":202.68418660310104,"declination":-7.257560067842413,"out_of_bounds":false,"house":null,"dignities":[]},{"id":"venus","kind":"planet","longitude":184.20729713561033,"sign":"libra","degree_in_sign":4.207297135610332,"degree_in_sign_dms":"4°12'26\"","decan":1,"latitude":1.600842978254867,"distance_au":1.2201839696119172,"speed":1.2093876520961369,"retrograde":false,"right_ascension":184.4964708225607,"declination":-0.2031607757044998,"out_of_bounds":false,"house":null,"dignities":["domicile"]},{"id":"mars","kind":"planet","longitude":0.056947166651394196,"sign":"aries","degree_in_sign":0.056947166651394196,"degree_in_sign_dms":"0°03'25\"","decan":1,"latitude":-1.9743781096407398,"distance_au":0.5170142444568075,"speed":0.06780587698246875,"retrograde":false,"right_ascension":0.8379830822626038,"declination":-1.7886931302680618,"out_of_bounds":false,"house":null,"dignities":["domicile"]},{"id":"jupiter","kind":"planet","longitude":63.72184270403584,"sign":"gemini","degree_in_sign":3.7218427040358435,"degree_in_sign_dms":"3°43'19\"","decan":1,"latitude":-1.0536922984438113,"distance_au":4.090779802244342,"speed":-0.11524433308295512,"retrograde":true,"right_ascension":61.92294589056518,"declination":19.864252778761966,"out_of_bounds":false,"house":null,"dignities":["detriment"]},{"id":"saturn","kind":"planet","longitude":269.0535396348011,"sign":"sagittarius","degree_in_sign":29.053539634801098,"degree_in_sign_dms":"29°03'13\"","decan":3,"latitude":0.8104158935021316,"distance_au":10.669710104353914,"speed":0.09053095202148352,"retrograde":false,"right_ascension":268.97469146751496,"declination":-22.62937753493649,"out_of_bounds":false,"house":null,"dignities":[]},{"id":"uranus","kind":"planet","longitude":268.42376943899455,"sign":"sagittarius","degree_in_sign":28.423769438994555,"degree_in_sign_dms":"28°25'26\"","decan":3,"latitude":-0.21410691414115288,"distance_au":19.951387341704123,"speed":0.04489473820063439,"retrograde":false,"right_ascension":268.27924733700814,"declination":-23.647853270474258,"out_of_bounds":true,"house":null,"dignities":[]},{"id":"neptune","kind":"planet","longitude":277.9585748028051,"sign":"capricorn","degree_in_sign":7.958574802805117,"degree_in_sign_dms":"7°57'31\"","decan":1,"latitude":0.9258947602306229,"distance_au":30.739334718048614,"speed":0.023413819711714592,"retrograde":false,"right_ascension":278.60422727228826,"declination":-22.279836570949808,"out_of_bounds":false,"house":null,"dignities":[]},{"id":"pluto","kind":"planet","longitude":222.41858415831175,"sign":"scorpio","degree_in_sign":12.418584158311745,"degree_in_sign_dms":"12°25'07\"","decan":2,"latitude":15.413563132224748,"distance_au":30.6143251924197,"speed":0.040481771060636246,"retrograde":false,"right_ascension":224.62148635749713,"declination":-0.851546692545945,"out_of_bounds":false,"house":null,"dignities":["domicile"]},{"id":"north_node","kind":"lunar_node","variant":"true","longitude":342.4090144421989,"sign":"pisces","degree_in_sign":12.409014442198895,"degree_in_sign_dms":"12°24'32\"","decan":2,"latitude":0.0,"distance_au":0.00237155474257769,"speed":0.014791162899341962,"retrograde":false,"right_ascension":343.7816037310667,"declination":-6.905660390176382,"out_of_bounds":false,"house":null},{"id":"south_node","kind":"lunar_node","variant":"true","longitude":162.4090144421989,"sign":"virgo","degree_in_sign":12.409014442198895,"degree_in_sign_dms":"12°24'32\"","decan":2,"latitude":-0.0,"distance_au":0.00237155474257769,"speed":0.014791162899341962,"retrograde":false,"right_ascension":163.78160373106675,"declination":6.905660390176382,"out_of_bounds":false,"house":null},{"id":"lilith","kind":"lunar_apogee","variant":"mean","longitude":169.12493923545063,"sign":"virgo","degree_in_sign":19.124939235450626,"degree_in_sign_dms":"19°07'30\"","decan":2,"latitude":-0.7344374352756126,"distance_au":0.002710625131722547,"speed":0.1107585238251603,"retrograde":false,"right_ascension":169.71540363178417,"declination":3.6288710075396606,"out_of_bounds":false,"house":null},{"id":"chiron","kind":"centaur","longitude":96.96501068744651,"sign":"cancer","degree_in_sign":6.965010687446508,"degree_in_sign_dms":"6°57'54\"","decan":1,"latitude":-6.530819936316607,"distance_au":11.556460828075,"speed":-0.023613073124870532,"retrograde":true,"right_ascension":97.22732296865279,"declination":16.737745502921598,"out_of_bounds":false,"house":null},{"id":"ceres","kind":"asteroid","longitude":347.48344661743056,"sign":"pisces","degree_in_sign":17.48344661743056,"degree_in_sign_dms":"17°29'00\"","decan":2,"latitude":-13.598931226763796,"distance_au":2.2531479565700847,"speed":-0.028375966226752845,"retrograde":true,"right_ascension":354.0007787320205,"declination":-17.428710958463025,"out_of_bounds":false,"house":null},{"id":"pallas","kind":"asteroid","longitude":304.67217557593284,"sign":"aquarius","degree_in_sign":4.67217557593284,"degree_in_sign_dms":"4°40'20\"","decan":1,"latitude":19.771832474706052,"distance_au":3.3304994842999402,"speed":0.16393022504430502,"retrograde":false,"right_ascension":302.36729233851065,"declination":0.14038932829978132,"out_of_bounds":false,"house":null},{"id":"juno","kind":"asteroid","longitude":147.84541205598444,"sign":"leo","degree_in_sign":27.84541205598444,"degree_in_sign_dms":"27°50'43\"","decan":3,"latitude":-9.350948402511358,"distance_au":2.328716731408671,"speed":0.36457053022899716,"retrograde":false,"right_ascension":146.8105638304701,"declination":3.4311614704822153,"out_of_bounds":false,"house":null},{"id":"vesta","kind":"asteroid","longitude":205.44105191487955,"sign":"libra","degree_in_sign":25.44105191487955,"degree_in_sign_dms":"25°26'28\"","decan":3,"latitude":4.995556789328873,"distance_au":3.166503453986765,"speed":0.5183281637590169,"retrograde":false,"right_ascension":205.4056277057048,"declination":-5.184596280547615,"out_of_bounds":false,"house":null}],"angles":null,"houses":null,"aspects":[{"point1":"pluto","point2":"north_node","aspect":"trine","major":true,"exact_angle":120.0,"separation":119.99043028388715,"orb":0.009569716112849846,"max_orb":4.0,"applying":false},{"point1":"venus","point2":"jupiter","aspect":"trine","major":true,"exact_angle":120.0,"separation":120.48545443157448,"orb":0.48545443157448176,"max_orb":7.0,"applying":false},{"point1":"saturn","point2":"uranus","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":0.6297701958065431,"orb":0.6297701958065431,"max_orb":8.0,"applying":false},{"point1":"neptune","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":179.0064358846414,"orb":0.9935641153585948,"max_orb":4.0,"applying":false},{"point1":"mars","point2":"saturn","aspect":"square","major":true,"exact_angle":90.0,"separation":91.00340753185031,"orb":1.0034075318503142,"max_orb":7.0,"applying":true},{"point1":"mars","point2":"uranus","aspect":"square","major":true,"exact_angle":90.0,"separation":91.63317772765686,"orb":1.6331777276568573,"max_orb":7.0,"applying":false},{"point1":"moon","point2":"mercury","aspect":"sextile","major":true,"exact_angle":60.0,"separation":62.07705090000661,"orb":2.0770509000066113,"max_orb":7.0,"applying":true},{"point1":"sun","point2":"north_node","aspect":"trine","major":true,"exact_angle":120.0,"separation":122.16435525922316,"orb":2.164355259223157,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"pluto","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.1739249753360355,"orb":2.1739249753360355,"max_orb":10.0,"applying":true},{"point1":"sun","point2":"neptune","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.71391561982938,"orb":2.286084380170621,"max_orb":7.0,"applying":false},{"point1":"venus","point2":"chiron","aspect":"square","major":true,"exact_angle":90.0,"separation":87.24228644816382,"orb":2.7577135518361757,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"chiron","aspect":"trine","major":true,"exact_angle":120.0,"separation":123.27964849552923,"orb":3.27964849552923,"max_orb":4.0,"applying":false},{"point1":"mars","point2":"jupiter","aspect":"sextile","major":true,"exact_angle":60.0,"separation":63.66489553738444,"orb":3.6648955373844387,"max_orb":5.0,"applying":true},{"point1":"venus","point2":"neptune","aspect":"square","major":true,"exact_angle":90.0,"separation":93.75127766719481,"orb":3.751277667194813,"max_orb":7.0,"applying":true},{"point1":"venus","point2":"mars","aspect":"opposition","major":true,"exact_angle":180.0,"separation":175.84965003104105,"orb":4.150349968958949,"max_orb":8.0,"applying":false},{"point1":"neptune","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":55.53999064449337,"orb":4.460009355506628,"max_orb":5.0,"applying":false},{"point1":"mercury","point2":"uranus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":64.75136455235048,"orb":4.751364552350481,"max_orb":5.0,"applying":true},{"point1":"venus","point2":"saturn","aspect":"square","major":true,"exact_angle":90.0,"separation":84.8462424991908,"orb":5.153757500809206,"max_orb":7.0,"applying":false},{"point1":"venus","point2":"uranus","aspect":"square","major":true,"exact_angle":90.0,"separation":84.2164723033842,"orb":5.783527696615806,"max_orb":7.0,"applying":false},{"point1":"moon","point2":"uranus","aspect":"trine","major":true,"exact_angle":120.0,"separation":126.82841545235712,"orb":6.82841545235712,"max_orb":9.0,"applying":true},{"point1":"moon","point2":"saturn","aspect":"trine","major":true,"exact_angle":120.0,"separation":127.45818564816366,"orb":7.4581856481636635,"max_orb":9.0,"applying":true}],"lots":null,"moon_phase":{"elongation":281.35069480366167,"phase":"last_quarter","illumination":0.4029484364043389,"waxing":false},"summary":{"elements":{"fire":{"count":4,"points":["moon","mars","saturn","uranus"]},"earth":{"count":1,"points":["neptune"]},"air":{"count":3,"points":["mercury","venus","jupiter"]},"water":{"count":2,"points":["sun","pluto"]}},"modalities":{"cardinal":{"count":4,"points":["mercury","venus","mars","neptune"]},"fixed":{"count":3,"points":["sun","moon","pluto"]},"mutable":{"count":3,"points":["jupiter","saturn","uranus"]}},"hemispheres":null,"sect":null,"chart_ruler":null,"retrograde":["jupiter","chiron","ceres"]},"warnings":["Birth time unknown: the chart is calculated for 12:00 local time; houses, angles and lots are omitted and the Moon may be off by up to ±7°."],"meta":{"service":"horoscope-api","version":"0.1.0","data_sources":{"ephemeris":{"name":"Swiss Ephemeris","version":"2.10.03","precise_years":[1800,2399],"license":"AGPL-3.0 (or Swiss Ephemeris Professional License)"},"tzdb_version":"2026f","geonames_downloaded":"2026-11-10","geonames_attribution":"Place data from GeoNames (https://www.geonames.org), CC BY 4.0"}}} \ No newline at end of file diff --git a/services/worker/testdata/natal-1990-03-15.json b/services/worker/testdata/natal-1990-03-15.json new file mode 100644 index 0000000..c7f1476 --- /dev/null +++ b/services/worker/testdata/natal-1990-03-15.json @@ -0,0 +1 @@ +{"input":{"date":"1990-03-15","time":"14:30","calendar":"gregorian","country":"HU","place":"Szeged","ambiguous_time":"reject","options":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true}},"location":{"country":{"iso2":"HU","iso3":"HUN","name":"Hungary"},"place":{"geonames_id":715429,"name":"Szeged","country_code":"HU","region":"Csongrád","latitude":46.253,"longitude":20.14824,"elevation":84,"population":160766,"feature_code":"PPLA","timezone":"Europe/Budapest"},"latitude":46.253,"longitude":20.14824,"elevation":84.0,"coordinates_source":"place"},"time":{"calendar":"gregorian","date_as_given":"1990-03-15","date":"1990-03-15","time_known":true,"zone":"Europe/Budapest","local":"1990-03-15T14:30:00","utc":"1990-03-15T13:30:00Z","utc_offset":"+01:00","utc_offset_seconds":3600,"dst":false,"abbreviation":"CET","zone_source":"place","local_mean_time":"14:50:36"},"settings":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true,"orbs":[{"aspect":"conjunction","angle":0.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0},{"aspect":"sextile","angle":60.0,"orb":5.0,"orb_with_luminary":7.0,"orb_with_minor_point":4.0},{"aspect":"square","angle":90.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"trine","angle":120.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"opposition","angle":180.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0}]},"astronomy":{"julian_day_ut":2447966.0625,"julian_day_tt":2447966.0631596106,"delta_t_seconds":56.99035186001821,"greenwich_sidereal_time":1.026228207907241,"greenwich_sidereal_time_hms":"01:01:34","local_sidereal_time":2.3694442079072413,"local_sidereal_time_hms":"02:22:10","obliquity":{"true_obliquity":23.442507593878688,"mean_obliquity":23.440554261349643,"nutation_longitude":0.00339087519886295,"nutation_obliquity":0.001953332529046976}},"points":[{"id":"sun","kind":"luminary","longitude":354.7020205265418,"sign":"pisces","degree_in_sign":24.702020526541787,"degree_in_sign_dms":"24°42'07\"","decan":3,"latitude":-0.0001600859660871015,"distance_au":0.9945454893765114,"speed":0.9960348950455624,"retrograde":false,"right_ascension":355.137190134683,"declination":-2.1053064360733478,"out_of_bounds":false,"house":8,"dignities":[]},{"id":"moon","kind":"luminary","longitude":220.49114909682726,"sign":"scorpio","degree_in_sign":10.491149096827257,"degree_in_sign_dms":"10°29'28\"","decan":2,"latitude":-5.137126936966204,"distance_au":0.002706438397934006,"speed":11.905109123602674,"retrograde":false,"right_ascension":216.36464391717846,"declination":-19.842379874956727,"out_of_bounds":false,"house":4,"dignities":["fall"]},{"id":"mercury","kind":"planet","longitude":351.33722192486994,"sign":"pisces","degree_in_sign":21.337221924869937,"degree_in_sign_dms":"21°20'14\"","decan":3,"latitude":-1.767054559244424,"distance_au":1.3641607046705002,"speed":1.9124975074781558,"retrograde":false,"right_ascension":352.74153385851827,"declination":-5.059069207497356,"out_of_bounds":false,"house":8,"dignities":["detriment","fall"]},{"id":"venus","kind":"planet","longitude":309.19074190449606,"sign":"aquarius","degree_in_sign":9.190741904496065,"degree_in_sign_dms":"9°11'27\"","decan":1,"latitude":3.210761745752445,"distance_au":0.566648807672413,"speed":0.8575864549206469,"retrograde":false,"right_ascension":310.74882933025754,"declination":-14.860452646903793,"out_of_bounds":false,"house":6,"dignities":[]},{"id":"mars","kind":"planet","longitude":302.88767438529624,"sign":"aquarius","degree_in_sign":2.8876743852962363,"degree_in_sign_dms":"2°53'16\"","decan":1,"latitude":-0.9562578276912909,"distance_au":1.840579086813708,"speed":0.7411797291001379,"retrograde":false,"right_ascension":305.4099961522405,"declination":-20.446728699281014,"out_of_bounds":false,"house":6,"dignities":[]},{"id":"jupiter","kind":"planet","longitude":91.38301888050613,"sign":"cancer","degree_in_sign":1.3830188805061283,"degree_in_sign_dms":"1°22'59\"","decan":1,"latitude":0.0472628738228669,"distance_au":4.966672089171061,"speed":0.06010771527683914,"retrograde":false,"right_ascension":91.50792792931192,"declination":23.482530527036243,"out_of_bounds":true,"house":11,"dignities":["exaltation"]},{"id":"saturn","kind":"planet","longitude":293.34036487171517,"sign":"capricorn","degree_in_sign":23.340364871715167,"degree_in_sign_dms":"23°20'25\"","decan":3,"latitude":0.21715021708535806,"distance_au":10.459974348007762,"speed":0.07569039671878404,"retrograde":false,"right_ascension":295.14929566490923,"declination":-21.210386164239075,"out_of_bounds":false,"house":6,"dignities":["domicile"]},{"id":"uranus","kind":"planet","longitude":279.22113659703035,"sign":"capricorn","degree_in_sign":9.221136597030352,"degree_in_sign_dms":"9°13'16\"","decan":1,"latitude":-0.29084136436712893,"distance_au":19.618515204325107,"speed":0.024841122434314383,"retrograde":false,"right_ascension":280.05651060627366,"declination":-23.411974152212395,"out_of_bounds":false,"house":5,"dignities":[]},{"id":"neptune","kind":"planet","longitude":284.2942723082604,"sign":"capricorn","degree_in_sign":14.294272308260418,"degree_in_sign_dms":"14°17'39\"","decan":2,"latitude":0.8540904011896173,"distance_au":30.5276024395645,"speed":0.01733583791374601,"retrograde":false,"right_ascension":285.422718578391,"declination":-21.826265954721933,"out_of_bounds":false,"house":5,"dignities":[]},{"id":"pluto","kind":"planet","longitude":227.6165096130519,"sign":"scorpio","degree_in_sign":17.616509613051903,"degree_in_sign_dms":"17°36'59\"","decan":2,"latitude":15.833495132174674,"distance_au":29.069070375131737,"speed":-0.013646284705936644,"retrograde":true,"right_ascension":229.5447426936776,"declination":-1.8558191266658761,"out_of_bounds":false,"house":4,"dignities":["domicile"]},{"id":"north_node","kind":"lunar_node","variant":"true","longitude":315.7509954251126,"sign":"aquarius","degree_in_sign":15.750995425112592,"degree_in_sign_dms":"15°45'04\"","decan":2,"latitude":0.0,"distance_au":0.0025645391588266656,"speed":-0.10836375714228033,"retrograde":true,"right_ascension":318.21224709267585,"declination":-16.11678431245977,"out_of_bounds":false,"house":6},{"id":"south_node","kind":"lunar_node","variant":"true","longitude":135.7509954251126,"sign":"leo","degree_in_sign":15.750995425112592,"degree_in_sign_dms":"15°45'04\"","decan":2,"latitude":-0.0,"distance_au":0.0025645391588266656,"speed":-0.10836375714228033,"retrograde":true,"right_ascension":138.21224709267585,"declination":16.11678431245977,"out_of_bounds":false,"house":12},{"id":"lilith","kind":"lunar_apogee","variant":"mean","longitude":224.6507126308452,"sign":"scorpio","degree_in_sign":14.650712630845192,"degree_in_sign_dms":"14°39'03\"","decan":2,"latitude":-5.145390826183486,"distance_au":0.0027106251317225477,"speed":0.1120539733751943,"retrograde":false,"right_ascension":220.56306354718154,"declination":-21.14573717539787,"out_of_bounds":false,"house":4},{"id":"chiron","kind":"centaur","longitude":100.56746556817768,"sign":"cancer","degree_in_sign":10.567465568177681,"degree_in_sign_dms":"10°34'03\"","decan":2,"latitude":-6.927085262419918,"distance_au":10.862653141984564,"speed":0.00042054492195409463,"retrograde":false,"right_ascension":100.92367335380553,"declination":16.1155476092339,"out_of_bounds":false,"house":11},{"id":"ceres","kind":"asteroid","longitude":85.72026820145419,"sign":"gemini","degree_in_sign":25.72026820145419,"degree_in_sign_dms":"25°43'13\"","decan":3,"latitude":5.420142084556969,"distance_au":2.389234768326728,"speed":0.2199963219509525,"retrograde":false,"right_ascension":85.13713762657613,"declination":28.790425435135266,"out_of_bounds":true,"house":11},{"id":"pallas","kind":"asteroid","longitude":27.633977112274877,"sign":"aries","degree_in_sign":27.633977112274877,"degree_in_sign_dms":"27°38'02\"","decan":3,"latitude":-21.159614577246938,"distance_au":3.17274610499082,"speed":0.4541011291828196,"retrograde":false,"right_ascension":33.19035846718262,"declination":-9.154209677772874,"out_of_bounds":false,"house":9},{"id":"juno","kind":"asteroid","longitude":235.08263282322608,"sign":"scorpio","degree_in_sign":25.082632823226078,"degree_in_sign_dms":"25°04'57\"","decan":3,"latitude":12.133791596449427,"distance_au":2.71048112832298,"speed":-0.013586841060013639,"retrograde":true,"right_ascension":235.65961410948307,"declination":-7.242987148218019,"out_of_bounds":false,"house":4},{"id":"vesta","kind":"asteroid","longitude":353.17798727870365,"sign":"pisces","degree_in_sign":23.177987278703654,"degree_in_sign_dms":"23°10'41\"","decan":3,"latitude":-4.6915766429060906,"distance_au":3.363529315579218,"speed":0.4846454186735754,"retrograde":false,"right_ascension":355.60394361110997,"declination":-7.015553510186796,"out_of_bounds":false,"house":8}],"angles":{"ascendant":{"longitude":139.38757367564722,"sign":"leo","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"speed":267.76529888295295},"midheaven":{"longitude":37.906526331496515,"sign":"taurus","degree_in_sign":7.906526331496515,"degree_in_sign_dms":"7°54'23\"","decan":1,"speed":369.95700921405324},"descendant":{"longitude":319.3875736756472,"sign":"aquarius","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"speed":267.76529888295295},"imum_coeli":{"longitude":217.9065263314965,"sign":"scorpio","degree_in_sign":7.906526331496508,"degree_in_sign_dms":"7°54'23\"","decan":1,"speed":369.95700921405324},"vertex":{"longitude":280.6161822700242,"sign":"capricorn","degree_in_sign":10.616182270024183,"degree_in_sign_dms":"10°36'58\"","decan":2,"speed":366.64575169412706},"antivertex":{"longitude":100.61618227002418,"sign":"cancer","degree_in_sign":10.616182270024183,"degree_in_sign_dms":"10°36'58\"","decan":2,"speed":366.64575169412706},"east_point":{"longitude":123.24182588104142,"sign":"leo","degree_in_sign":3.2418258810414216,"degree_in_sign_dms":"3°14'31\"","decan":1},"armc":35.54166311860861},"houses":{"system":"placidus","requested_system":"placidus","cusps":[{"house":1,"longitude":139.38757367564722,"sign":"leo","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"size":20.20346705534024},{"house":2,"longitude":159.59104073098746,"sign":"virgo","degree_in_sign":9.591040730987459,"degree_in_sign_dms":"9°35'28\"","decan":1,"size":25.655072496413652},{"house":3,"longitude":185.2461132274011,"sign":"libra","degree_in_sign":5.246113227401111,"degree_in_sign_dms":"5°14'46\"","decan":1,"size":32.6604131040954},{"house":4,"longitude":217.9065263314965,"sign":"scorpio","degree_in_sign":7.906526331496508,"degree_in_sign_dms":"7°54'23\"","decan":1,"size":37.49691202976581},{"house":5,"longitude":255.40343836126232,"sign":"sagittarius","degree_in_sign":15.403438361262317,"degree_in_sign_dms":"15°24'12\"","decan":2,"size":35.01789426529598},{"house":6,"longitude":290.4213326265583,"sign":"capricorn","degree_in_sign":20.421332626558296,"degree_in_sign_dms":"20°25'17\"","decan":3,"size":28.96624104908892},{"house":7,"longitude":319.3875736756472,"sign":"aquarius","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"size":20.20346705534024},{"house":8,"longitude":339.59104073098746,"sign":"pisces","degree_in_sign":9.591040730987459,"degree_in_sign_dms":"9°35'28\"","decan":1,"size":25.655072496413652},{"house":9,"longitude":5.246113227401111,"sign":"aries","degree_in_sign":5.246113227401111,"degree_in_sign_dms":"5°14'46\"","decan":1,"size":32.660413104095404},{"house":10,"longitude":37.906526331496515,"sign":"taurus","degree_in_sign":7.906526331496515,"degree_in_sign_dms":"7°54'23\"","decan":1,"size":37.49691202976579},{"house":11,"longitude":75.4034383612623,"sign":"gemini","degree_in_sign":15.403438361262303,"degree_in_sign_dms":"15°24'12\"","decan":2,"size":35.01789426529601},{"house":12,"longitude":110.42133262655831,"sign":"cancer","degree_in_sign":20.42133262655831,"degree_in_sign_dms":"20°25'17\"","decan":3,"size":28.966241049088907}]},"aspects":[{"point1":"moon","point2":"chiron","aspect":"trine","major":true,"exact_angle":120.0,"separation":119.92368352864958,"orb":0.07631647135042385,"max_orb":4.0,"applying":true},{"point1":"neptune","point2":"lilith","aspect":"sextile","major":true,"exact_angle":60.0,"separation":59.643559677415226,"orb":0.3564403225847741,"max_orb":4.0,"applying":false},{"point1":"north_node","point2":"lilith","aspect":"square","major":true,"exact_angle":90.0,"separation":91.1002827942674,"orb":1.1002827942674003,"max_orb":4.0,"applying":true},{"point1":"moon","point2":"uranus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":58.729987500203094,"orb":1.2700124997969056,"max_orb":7.0,"applying":false},{"point1":"venus","point2":"midheaven","aspect":"square","major":true,"exact_angle":90.0,"separation":88.71578442700047,"orb":1.2842155729995284,"max_orb":7.0,"applying":true},{"point1":"moon","point2":"venus","aspect":"square","major":true,"exact_angle":90.0,"separation":88.69959280766881,"orb":1.3004071923311926,"max_orb":9.0,"applying":false},{"point1":"uranus","point2":"midheaven","aspect":"trine","major":true,"exact_angle":120.0,"separation":118.68538973446616,"orb":1.3146102655338439,"max_orb":7.0,"applying":true},{"point1":"uranus","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":178.65367102885267,"orb":1.3463289711473294,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"saturn","aspect":"sextile","major":true,"exact_angle":60.0,"separation":61.36165565482662,"orb":1.3616556548266203,"max_orb":7.0,"applying":false},{"point1":"pluto","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":88.22893593740469,"orb":1.7710640625953147,"max_orb":7.0,"applying":false},{"point1":"pluto","point2":"north_node","aspect":"square","major":true,"exact_angle":90.0,"separation":88.13448581206069,"orb":1.8655141879393113,"max_orb":4.0,"applying":false},{"point1":"mercury","point2":"saturn","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.99685705315477,"orb":2.00314294684523,"max_orb":5.0,"applying":true},{"point1":"moon","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":177.41537723466925,"orb":2.5846227653307494,"max_orb":10.0,"applying":true},{"point1":"chiron","point2":"midheaven","aspect":"sextile","major":true,"exact_angle":60.0,"separation":62.660939236681166,"orb":2.660939236681166,"max_orb":4.0,"applying":true},{"point1":"pluto","point2":"lilith","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.9657969822067116,"orb":2.9657969822067116,"max_orb":4.0,"applying":true},{"point1":"neptune","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":56.677762695208514,"orb":3.3222373047914857,"max_orb":5.0,"applying":true},{"point1":"sun","point2":"mercury","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.3647986016718505,"orb":3.3647986016718505,"max_orb":10.0,"applying":true},{"point1":"north_node","point2":"ascendant","aspect":"opposition","major":true,"exact_angle":180.0,"separation":176.36342174946537,"orb":3.636578250534626,"max_orb":4.0,"applying":false},{"point1":"mercury","point2":"pluto","aspect":"trine","major":true,"exact_angle":120.0,"separation":123.72071231181803,"orb":3.7207123118180334,"max_orb":7.0,"applying":false},{"point1":"neptune","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":176.27319325991726,"orb":3.7268067400827363,"max_orb":4.0,"applying":false},{"point1":"moon","point2":"neptune","aspect":"sextile","major":true,"exact_angle":60.0,"separation":63.80312321143316,"orb":3.80312321143316,"max_orb":7.0,"applying":true},{"point1":"mars","point2":"midheaven","aspect":"square","major":true,"exact_angle":90.0,"separation":95.0188519462003,"orb":5.0188519462003,"max_orb":7.0,"applying":false},{"point1":"uranus","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":5.073135711230066,"orb":5.073135711230066,"max_orb":8.0,"applying":true},{"point1":"venus","point2":"mars","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":6.303067519199828,"orb":6.303067519199828,"max_orb":8.0,"applying":false},{"point1":"neptune","point2":"midheaven","aspect":"trine","major":true,"exact_angle":120.0,"separation":113.61225402323609,"orb":6.3877459767639095,"max_orb":7.0,"applying":true},{"point1":"sun","point2":"jupiter","aspect":"square","major":true,"exact_angle":90.0,"separation":96.68099835396436,"orb":6.680998353964355,"max_orb":9.0,"applying":true},{"point1":"sun","point2":"pluto","aspect":"trine","major":true,"exact_angle":120.0,"separation":127.08551091348988,"orb":7.085510913489884,"max_orb":9.0,"applying":false},{"point1":"moon","point2":"pluto","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":7.125360516224646,"orb":7.125360516224646,"max_orb":10.0,"applying":true},{"point1":"moon","point2":"mars","aspect":"square","major":true,"exact_angle":90.0,"separation":82.39652528846898,"orb":7.603474711531021,"max_orb":9.0,"applying":false},{"point1":"jupiter","point2":"uranus","aspect":"opposition","major":true,"exact_angle":180.0,"separation":172.1618822834758,"orb":7.838117716524209,"max_orb":8.0,"applying":true},{"point1":"moon","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":81.10357542118004,"orb":8.89642457881996,"max_orb":9.0,"applying":false}],"lots":{"fortune":{"longitude":5.176702245932688,"sign":"aries","degree_in_sign":5.176702245932688,"degree_in_sign_dms":"5°10'36\"","decan":1,"house":8},"spirit":{"longitude":273.59844510536175,"sign":"capricorn","degree_in_sign":3.5984451053617477,"degree_in_sign_dms":"3°35'54\"","decan":1,"house":5}},"moon_phase":{"elongation":225.78912857028547,"phase":"waning_gibbous","illumination":0.8479514390936294,"waxing":false},"summary":{"elements":{"fire":{"count":0,"points":[]},"earth":{"count":3,"points":["saturn","uranus","neptune"]},"air":{"count":2,"points":["venus","mars"]},"water":{"count":5,"points":["sun","moon","mercury","jupiter","pluto"]}},"modalities":{"cardinal":{"count":4,"points":["jupiter","saturn","uranus","neptune"]},"fixed":{"count":4,"points":["moon","venus","mars","pluto"]},"mutable":{"count":2,"points":["sun","mercury"]}},"hemispheres":{"above_horizon":{"count":3,"points":["sun","mercury","jupiter"]},"below_horizon":{"count":7,"points":["moon","venus","mars","saturn","uranus","neptune","pluto"]},"eastern":{"count":1,"points":["jupiter"]},"western":{"count":9,"points":["sun","moon","mercury","venus","mars","saturn","uranus","neptune","pluto"]}},"sect":"day","chart_ruler":{"ascendant_sign":"leo","traditional":{"planet":"sun","sign":"pisces","house":8},"modern":{"planet":"sun","sign":"pisces","house":8}},"retrograde":["pluto","juno"]},"warnings":[],"meta":{"service":"horoscope-api","version":"0.1.0","data_sources":{"ephemeris":{"name":"Swiss Ephemeris","version":"2.10.03","precise_years":[1800,2399],"license":"AGPL-3.0 (or Swiss Ephemeris Professional License)"},"tzdb_version":"2026f","geonames_downloaded":"2026-11-10","geonames_attribution":"Place data from GeoNames (https://www.geonames.org), CC BY 4.0"}}} \ No newline at end of file diff --git a/services/worker/testdata/synastry-response.json b/services/worker/testdata/synastry-response.json new file mode 100644 index 0000000..590dbcd --- /dev/null +++ b/services/worker/testdata/synastry-response.json @@ -0,0 +1 @@ +{"person1":{"input":{"date":"1990-03-15","time":"14:30","calendar":"gregorian","country":"HU","place":"Szeged","ambiguous_time":"reject","options":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true}},"location":{"country":{"iso2":"HU","iso3":"HUN","name":"Hungary"},"place":{"geonames_id":715429,"name":"Szeged","country_code":"HU","region":"Csongrád","latitude":46.253,"longitude":20.14824,"elevation":84,"population":160766,"feature_code":"PPLA","timezone":"Europe/Budapest"},"latitude":46.253,"longitude":20.14824,"elevation":84.0,"coordinates_source":"place"},"time":{"calendar":"gregorian","date_as_given":"1990-03-15","date":"1990-03-15","time_known":true,"zone":"Europe/Budapest","local":"1990-03-15T14:30:00","utc":"1990-03-15T13:30:00Z","utc_offset":"+01:00","utc_offset_seconds":3600,"dst":false,"abbreviation":"CET","zone_source":"place","local_mean_time":"14:50:36"},"settings":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true,"orbs":[{"aspect":"conjunction","angle":0.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0},{"aspect":"sextile","angle":60.0,"orb":5.0,"orb_with_luminary":7.0,"orb_with_minor_point":4.0},{"aspect":"square","angle":90.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"trine","angle":120.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"opposition","angle":180.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0}]},"astronomy":{"julian_day_ut":2447966.0625,"julian_day_tt":2447966.0631596106,"delta_t_seconds":56.99035186001821,"greenwich_sidereal_time":1.026228207907241,"greenwich_sidereal_time_hms":"01:01:34","local_sidereal_time":2.3694442079072413,"local_sidereal_time_hms":"02:22:10","obliquity":{"true_obliquity":23.442507593878688,"mean_obliquity":23.440554261349643,"nutation_longitude":0.00339087519886295,"nutation_obliquity":0.001953332529046976}},"points":[{"id":"sun","kind":"luminary","longitude":354.7020205265418,"sign":"pisces","degree_in_sign":24.702020526541787,"degree_in_sign_dms":"24°42'07\"","decan":3,"latitude":-0.0001600859660871015,"distance_au":0.9945454893765114,"speed":0.9960348950455624,"retrograde":false,"right_ascension":355.137190134683,"declination":-2.1053064360733478,"out_of_bounds":false,"house":8,"dignities":[]},{"id":"moon","kind":"luminary","longitude":220.49114909682726,"sign":"scorpio","degree_in_sign":10.491149096827257,"degree_in_sign_dms":"10°29'28\"","decan":2,"latitude":-5.137126936966204,"distance_au":0.002706438397934006,"speed":11.905109123602674,"retrograde":false,"right_ascension":216.36464391717846,"declination":-19.842379874956727,"out_of_bounds":false,"house":4,"dignities":["fall"]},{"id":"mercury","kind":"planet","longitude":351.33722192486994,"sign":"pisces","degree_in_sign":21.337221924869937,"degree_in_sign_dms":"21°20'14\"","decan":3,"latitude":-1.767054559244424,"distance_au":1.3641607046705002,"speed":1.9124975074781558,"retrograde":false,"right_ascension":352.74153385851827,"declination":-5.059069207497356,"out_of_bounds":false,"house":8,"dignities":["detriment","fall"]},{"id":"venus","kind":"planet","longitude":309.19074190449606,"sign":"aquarius","degree_in_sign":9.190741904496065,"degree_in_sign_dms":"9°11'27\"","decan":1,"latitude":3.210761745752445,"distance_au":0.566648807672413,"speed":0.8575864549206469,"retrograde":false,"right_ascension":310.74882933025754,"declination":-14.860452646903793,"out_of_bounds":false,"house":6,"dignities":[]},{"id":"mars","kind":"planet","longitude":302.88767438529624,"sign":"aquarius","degree_in_sign":2.8876743852962363,"degree_in_sign_dms":"2°53'16\"","decan":1,"latitude":-0.9562578276912909,"distance_au":1.840579086813708,"speed":0.7411797291001379,"retrograde":false,"right_ascension":305.4099961522405,"declination":-20.446728699281014,"out_of_bounds":false,"house":6,"dignities":[]},{"id":"jupiter","kind":"planet","longitude":91.38301888050613,"sign":"cancer","degree_in_sign":1.3830188805061283,"degree_in_sign_dms":"1°22'59\"","decan":1,"latitude":0.0472628738228669,"distance_au":4.966672089171061,"speed":0.06010771527683914,"retrograde":false,"right_ascension":91.50792792931192,"declination":23.482530527036243,"out_of_bounds":true,"house":11,"dignities":["exaltation"]},{"id":"saturn","kind":"planet","longitude":293.34036487171517,"sign":"capricorn","degree_in_sign":23.340364871715167,"degree_in_sign_dms":"23°20'25\"","decan":3,"latitude":0.21715021708535806,"distance_au":10.459974348007762,"speed":0.07569039671878404,"retrograde":false,"right_ascension":295.14929566490923,"declination":-21.210386164239075,"out_of_bounds":false,"house":6,"dignities":["domicile"]},{"id":"uranus","kind":"planet","longitude":279.22113659703035,"sign":"capricorn","degree_in_sign":9.221136597030352,"degree_in_sign_dms":"9°13'16\"","decan":1,"latitude":-0.29084136436712893,"distance_au":19.618515204325107,"speed":0.024841122434314383,"retrograde":false,"right_ascension":280.05651060627366,"declination":-23.411974152212395,"out_of_bounds":false,"house":5,"dignities":[]},{"id":"neptune","kind":"planet","longitude":284.2942723082604,"sign":"capricorn","degree_in_sign":14.294272308260418,"degree_in_sign_dms":"14°17'39\"","decan":2,"latitude":0.8540904011896173,"distance_au":30.5276024395645,"speed":0.01733583791374601,"retrograde":false,"right_ascension":285.422718578391,"declination":-21.826265954721933,"out_of_bounds":false,"house":5,"dignities":[]},{"id":"pluto","kind":"planet","longitude":227.6165096130519,"sign":"scorpio","degree_in_sign":17.616509613051903,"degree_in_sign_dms":"17°36'59\"","decan":2,"latitude":15.833495132174674,"distance_au":29.069070375131737,"speed":-0.013646284705936644,"retrograde":true,"right_ascension":229.5447426936776,"declination":-1.8558191266658761,"out_of_bounds":false,"house":4,"dignities":["domicile"]},{"id":"north_node","kind":"lunar_node","variant":"true","longitude":315.7509954251126,"sign":"aquarius","degree_in_sign":15.750995425112592,"degree_in_sign_dms":"15°45'04\"","decan":2,"latitude":0.0,"distance_au":0.0025645391588266656,"speed":-0.10836375714228033,"retrograde":true,"right_ascension":318.21224709267585,"declination":-16.11678431245977,"out_of_bounds":false,"house":6},{"id":"south_node","kind":"lunar_node","variant":"true","longitude":135.7509954251126,"sign":"leo","degree_in_sign":15.750995425112592,"degree_in_sign_dms":"15°45'04\"","decan":2,"latitude":-0.0,"distance_au":0.0025645391588266656,"speed":-0.10836375714228033,"retrograde":true,"right_ascension":138.21224709267585,"declination":16.11678431245977,"out_of_bounds":false,"house":12},{"id":"lilith","kind":"lunar_apogee","variant":"mean","longitude":224.6507126308452,"sign":"scorpio","degree_in_sign":14.650712630845192,"degree_in_sign_dms":"14°39'03\"","decan":2,"latitude":-5.145390826183486,"distance_au":0.0027106251317225477,"speed":0.1120539733751943,"retrograde":false,"right_ascension":220.56306354718154,"declination":-21.14573717539787,"out_of_bounds":false,"house":4},{"id":"chiron","kind":"centaur","longitude":100.56746556817768,"sign":"cancer","degree_in_sign":10.567465568177681,"degree_in_sign_dms":"10°34'03\"","decan":2,"latitude":-6.927085262419918,"distance_au":10.862653141984564,"speed":0.00042054492195409463,"retrograde":false,"right_ascension":100.92367335380553,"declination":16.1155476092339,"out_of_bounds":false,"house":11},{"id":"ceres","kind":"asteroid","longitude":85.72026820145419,"sign":"gemini","degree_in_sign":25.72026820145419,"degree_in_sign_dms":"25°43'13\"","decan":3,"latitude":5.420142084556969,"distance_au":2.389234768326728,"speed":0.2199963219509525,"retrograde":false,"right_ascension":85.13713762657613,"declination":28.790425435135266,"out_of_bounds":true,"house":11},{"id":"pallas","kind":"asteroid","longitude":27.633977112274877,"sign":"aries","degree_in_sign":27.633977112274877,"degree_in_sign_dms":"27°38'02\"","decan":3,"latitude":-21.159614577246938,"distance_au":3.17274610499082,"speed":0.4541011291828196,"retrograde":false,"right_ascension":33.19035846718262,"declination":-9.154209677772874,"out_of_bounds":false,"house":9},{"id":"juno","kind":"asteroid","longitude":235.08263282322608,"sign":"scorpio","degree_in_sign":25.082632823226078,"degree_in_sign_dms":"25°04'57\"","decan":3,"latitude":12.133791596449427,"distance_au":2.71048112832298,"speed":-0.013586841060013639,"retrograde":true,"right_ascension":235.65961410948307,"declination":-7.242987148218019,"out_of_bounds":false,"house":4},{"id":"vesta","kind":"asteroid","longitude":353.17798727870365,"sign":"pisces","degree_in_sign":23.177987278703654,"degree_in_sign_dms":"23°10'41\"","decan":3,"latitude":-4.6915766429060906,"distance_au":3.363529315579218,"speed":0.4846454186735754,"retrograde":false,"right_ascension":355.60394361110997,"declination":-7.015553510186796,"out_of_bounds":false,"house":8}],"angles":{"ascendant":{"longitude":139.38757367564722,"sign":"leo","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"speed":267.76529888295295},"midheaven":{"longitude":37.906526331496515,"sign":"taurus","degree_in_sign":7.906526331496515,"degree_in_sign_dms":"7°54'23\"","decan":1,"speed":369.95700921405324},"descendant":{"longitude":319.3875736756472,"sign":"aquarius","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"speed":267.76529888295295},"imum_coeli":{"longitude":217.9065263314965,"sign":"scorpio","degree_in_sign":7.906526331496508,"degree_in_sign_dms":"7°54'23\"","decan":1,"speed":369.95700921405324},"vertex":{"longitude":280.6161822700242,"sign":"capricorn","degree_in_sign":10.616182270024183,"degree_in_sign_dms":"10°36'58\"","decan":2,"speed":366.64575169412706},"antivertex":{"longitude":100.61618227002418,"sign":"cancer","degree_in_sign":10.616182270024183,"degree_in_sign_dms":"10°36'58\"","decan":2,"speed":366.64575169412706},"east_point":{"longitude":123.24182588104142,"sign":"leo","degree_in_sign":3.2418258810414216,"degree_in_sign_dms":"3°14'31\"","decan":1},"armc":35.54166311860861},"houses":{"system":"placidus","requested_system":"placidus","cusps":[{"house":1,"longitude":139.38757367564722,"sign":"leo","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"size":20.20346705534024},{"house":2,"longitude":159.59104073098746,"sign":"virgo","degree_in_sign":9.591040730987459,"degree_in_sign_dms":"9°35'28\"","decan":1,"size":25.655072496413652},{"house":3,"longitude":185.2461132274011,"sign":"libra","degree_in_sign":5.246113227401111,"degree_in_sign_dms":"5°14'46\"","decan":1,"size":32.6604131040954},{"house":4,"longitude":217.9065263314965,"sign":"scorpio","degree_in_sign":7.906526331496508,"degree_in_sign_dms":"7°54'23\"","decan":1,"size":37.49691202976581},{"house":5,"longitude":255.40343836126232,"sign":"sagittarius","degree_in_sign":15.403438361262317,"degree_in_sign_dms":"15°24'12\"","decan":2,"size":35.01789426529598},{"house":6,"longitude":290.4213326265583,"sign":"capricorn","degree_in_sign":20.421332626558296,"degree_in_sign_dms":"20°25'17\"","decan":3,"size":28.96624104908892},{"house":7,"longitude":319.3875736756472,"sign":"aquarius","degree_in_sign":19.387573675647218,"degree_in_sign_dms":"19°23'15\"","decan":2,"size":20.20346705534024},{"house":8,"longitude":339.59104073098746,"sign":"pisces","degree_in_sign":9.591040730987459,"degree_in_sign_dms":"9°35'28\"","decan":1,"size":25.655072496413652},{"house":9,"longitude":5.246113227401111,"sign":"aries","degree_in_sign":5.246113227401111,"degree_in_sign_dms":"5°14'46\"","decan":1,"size":32.660413104095404},{"house":10,"longitude":37.906526331496515,"sign":"taurus","degree_in_sign":7.906526331496515,"degree_in_sign_dms":"7°54'23\"","decan":1,"size":37.49691202976579},{"house":11,"longitude":75.4034383612623,"sign":"gemini","degree_in_sign":15.403438361262303,"degree_in_sign_dms":"15°24'12\"","decan":2,"size":35.01789426529601},{"house":12,"longitude":110.42133262655831,"sign":"cancer","degree_in_sign":20.42133262655831,"degree_in_sign_dms":"20°25'17\"","decan":3,"size":28.966241049088907}]},"aspects":[{"point1":"moon","point2":"chiron","aspect":"trine","major":true,"exact_angle":120.0,"separation":119.92368352864958,"orb":0.07631647135042385,"max_orb":4.0,"applying":true},{"point1":"neptune","point2":"lilith","aspect":"sextile","major":true,"exact_angle":60.0,"separation":59.643559677415226,"orb":0.3564403225847741,"max_orb":4.0,"applying":false},{"point1":"north_node","point2":"lilith","aspect":"square","major":true,"exact_angle":90.0,"separation":91.1002827942674,"orb":1.1002827942674003,"max_orb":4.0,"applying":true},{"point1":"moon","point2":"uranus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":58.729987500203094,"orb":1.2700124997969056,"max_orb":7.0,"applying":false},{"point1":"venus","point2":"midheaven","aspect":"square","major":true,"exact_angle":90.0,"separation":88.71578442700047,"orb":1.2842155729995284,"max_orb":7.0,"applying":true},{"point1":"moon","point2":"venus","aspect":"square","major":true,"exact_angle":90.0,"separation":88.69959280766881,"orb":1.3004071923311926,"max_orb":9.0,"applying":false},{"point1":"uranus","point2":"midheaven","aspect":"trine","major":true,"exact_angle":120.0,"separation":118.68538973446616,"orb":1.3146102655338439,"max_orb":7.0,"applying":true},{"point1":"uranus","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":178.65367102885267,"orb":1.3463289711473294,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"saturn","aspect":"sextile","major":true,"exact_angle":60.0,"separation":61.36165565482662,"orb":1.3616556548266203,"max_orb":7.0,"applying":false},{"point1":"pluto","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":88.22893593740469,"orb":1.7710640625953147,"max_orb":7.0,"applying":false},{"point1":"pluto","point2":"north_node","aspect":"square","major":true,"exact_angle":90.0,"separation":88.13448581206069,"orb":1.8655141879393113,"max_orb":4.0,"applying":false},{"point1":"mercury","point2":"saturn","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.99685705315477,"orb":2.00314294684523,"max_orb":5.0,"applying":true},{"point1":"moon","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":177.41537723466925,"orb":2.5846227653307494,"max_orb":10.0,"applying":true},{"point1":"chiron","point2":"midheaven","aspect":"sextile","major":true,"exact_angle":60.0,"separation":62.660939236681166,"orb":2.660939236681166,"max_orb":4.0,"applying":true},{"point1":"pluto","point2":"lilith","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.9657969822067116,"orb":2.9657969822067116,"max_orb":4.0,"applying":true},{"point1":"neptune","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":56.677762695208514,"orb":3.3222373047914857,"max_orb":5.0,"applying":true},{"point1":"sun","point2":"mercury","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.3647986016718505,"orb":3.3647986016718505,"max_orb":10.0,"applying":true},{"point1":"north_node","point2":"ascendant","aspect":"opposition","major":true,"exact_angle":180.0,"separation":176.36342174946537,"orb":3.636578250534626,"max_orb":4.0,"applying":false},{"point1":"mercury","point2":"pluto","aspect":"trine","major":true,"exact_angle":120.0,"separation":123.72071231181803,"orb":3.7207123118180334,"max_orb":7.0,"applying":false},{"point1":"neptune","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":176.27319325991726,"orb":3.7268067400827363,"max_orb":4.0,"applying":false},{"point1":"moon","point2":"neptune","aspect":"sextile","major":true,"exact_angle":60.0,"separation":63.80312321143316,"orb":3.80312321143316,"max_orb":7.0,"applying":true},{"point1":"mars","point2":"midheaven","aspect":"square","major":true,"exact_angle":90.0,"separation":95.0188519462003,"orb":5.0188519462003,"max_orb":7.0,"applying":false},{"point1":"uranus","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":5.073135711230066,"orb":5.073135711230066,"max_orb":8.0,"applying":true},{"point1":"venus","point2":"mars","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":6.303067519199828,"orb":6.303067519199828,"max_orb":8.0,"applying":false},{"point1":"neptune","point2":"midheaven","aspect":"trine","major":true,"exact_angle":120.0,"separation":113.61225402323609,"orb":6.3877459767639095,"max_orb":7.0,"applying":true},{"point1":"sun","point2":"jupiter","aspect":"square","major":true,"exact_angle":90.0,"separation":96.68099835396436,"orb":6.680998353964355,"max_orb":9.0,"applying":true},{"point1":"sun","point2":"pluto","aspect":"trine","major":true,"exact_angle":120.0,"separation":127.08551091348988,"orb":7.085510913489884,"max_orb":9.0,"applying":false},{"point1":"moon","point2":"pluto","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":7.125360516224646,"orb":7.125360516224646,"max_orb":10.0,"applying":true},{"point1":"moon","point2":"mars","aspect":"square","major":true,"exact_angle":90.0,"separation":82.39652528846898,"orb":7.603474711531021,"max_orb":9.0,"applying":false},{"point1":"jupiter","point2":"uranus","aspect":"opposition","major":true,"exact_angle":180.0,"separation":172.1618822834758,"orb":7.838117716524209,"max_orb":8.0,"applying":true},{"point1":"moon","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":81.10357542118004,"orb":8.89642457881996,"max_orb":9.0,"applying":false}],"lots":{"fortune":{"longitude":5.176702245932688,"sign":"aries","degree_in_sign":5.176702245932688,"degree_in_sign_dms":"5°10'36\"","decan":1,"house":8},"spirit":{"longitude":273.59844510536175,"sign":"capricorn","degree_in_sign":3.5984451053617477,"degree_in_sign_dms":"3°35'54\"","decan":1,"house":5}},"moon_phase":{"elongation":225.78912857028547,"phase":"waning_gibbous","illumination":0.8479514390936294,"waxing":false},"summary":{"elements":{"fire":{"count":0,"points":[]},"earth":{"count":3,"points":["saturn","uranus","neptune"]},"air":{"count":2,"points":["venus","mars"]},"water":{"count":5,"points":["sun","moon","mercury","jupiter","pluto"]}},"modalities":{"cardinal":{"count":4,"points":["jupiter","saturn","uranus","neptune"]},"fixed":{"count":4,"points":["moon","venus","mars","pluto"]},"mutable":{"count":2,"points":["sun","mercury"]}},"hemispheres":{"above_horizon":{"count":3,"points":["sun","mercury","jupiter"]},"below_horizon":{"count":7,"points":["moon","venus","mars","saturn","uranus","neptune","pluto"]},"eastern":{"count":1,"points":["jupiter"]},"western":{"count":9,"points":["sun","moon","mercury","venus","mars","saturn","uranus","neptune","pluto"]}},"sect":"day","chart_ruler":{"ascendant_sign":"leo","traditional":{"planet":"sun","sign":"pisces","house":8},"modern":{"planet":"sun","sign":"pisces","house":8}},"retrograde":["pluto","juno"]},"warnings":[]},"person2":{"input":{"date":"1988-11-02","time":"08:10","calendar":"gregorian","country":"HU","place":"Pécs","ambiguous_time":"reject","options":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true}},"location":{"country":{"iso2":"HU","iso3":"HUN","name":"Hungary"},"place":{"geonames_id":3046526,"name":"Pécs","country_code":"HU","region":"Baranya","latitude":46.07617,"longitude":18.22814,"elevation":155,"population":145347,"feature_code":"PPLA","timezone":"Europe/Budapest"},"latitude":46.07617,"longitude":18.22814,"elevation":155.0,"coordinates_source":"place"},"time":{"calendar":"gregorian","date_as_given":"1988-11-02","date":"1988-11-02","time_known":true,"zone":"Europe/Budapest","local":"1988-11-02T08:10:00","utc":"1988-11-02T07:10:00Z","utc_offset":"+01:00","utc_offset_seconds":3600,"dst":false,"abbreviation":"CET","zone_source":"place","local_mean_time":"08:22:55"},"settings":{"house_system":"placidus","zodiac":"tropical","ayanamsa":"lahiri","node_type":"true","lilith_type":"mean","aspect_set":"major","orb_multiplier":1.0,"topocentric":false,"include_asteroids":true,"orbs":[{"aspect":"conjunction","angle":0.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0},{"aspect":"sextile","angle":60.0,"orb":5.0,"orb_with_luminary":7.0,"orb_with_minor_point":4.0},{"aspect":"square","angle":90.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"trine","angle":120.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"opposition","angle":180.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0}]},"astronomy":{"julian_day_ut":2447467.798611111,"julian_day_tt":2447467.7992618135,"delta_t_seconds":56.220683521583425,"greenwich_sidereal_time":9.951929030758116,"greenwich_sidereal_time_hms":"09:57:07","local_sidereal_time":11.16713836409145,"local_sidereal_time_hms":"11:10:02","obliquity":{"true_obliquity":23.44316145730396,"mean_obliquity":23.44073174268686,"nutation_longitude":0.0012106597472633315,"nutation_obliquity":0.002429714617102156}},"points":[{"id":"sun","kind":"luminary","longitude":220.08471907868437,"sign":"scorpio","degree_in_sign":10.084719078684373,"degree_in_sign_dms":"10°05'05\"","decan":2,"latitude":0.00006626102495054454,"distance_au":0.992102537595831,"speed":1.0013184947397893,"retrograde":false,"right_ascension":217.67357931097249,"declination":-14.843241520608252,"out_of_bounds":false,"house":12,"dignities":[]},{"id":"moon","kind":"luminary","longitude":139.69428367097578,"sign":"leo","degree_in_sign":19.69428367097578,"degree_in_sign_dms":"19°41'39\"","decan":2,"latitude":1.9820019792845154,"distance_au":0.002688999501979699,"speed":11.914732756539912,"retrograde":false,"right_ascension":142.75926895323778,"declination":16.793626016182177,"out_of_bounds":false,"house":9,"dignities":[]},{"id":"mercury","kind":"planet","longitude":203.43980606355092,"sign":"libra","degree_in_sign":23.43980606355092,"degree_in_sign_dms":"23°26'23\"","decan":3,"latitude":2.086478538078108,"distance_au":1.145811679469352,"speed":1.4532194087724521,"retrograde":false,"right_ascension":202.46866816187594,"declination":-7.166150602192419,"out_of_bounds":false,"house":11,"dignities":[]},{"id":"venus","kind":"planet","longitude":184.01414981882007,"sign":"libra","degree_in_sign":4.014149818820073,"degree_in_sign_dms":"4°00'51\"","decan":1,"latitude":1.596705617189119,"distance_au":1.2192020983510008,"speed":1.2091545604850216,"retrograde":false,"right_ascension":184.3176078246865,"declination":-0.1303440382175825,"out_of_bounds":false,"house":10,"dignities":["domicile"]},{"id":"mars","kind":"planet","longitude":0.0462789357217458,"sign":"aries","degree_in_sign":0.0462789357217458,"degree_in_sign_dms":"0°02'47\"","decan":1,"latitude":-1.9854006769420527,"distance_au":0.5161176762728341,"speed":0.06577893333709059,"retrograde":false,"right_ascension":0.8325868851982424,"declination":-1.803048711117122,"out_of_bounds":false,"house":4,"dignities":["domicile"]},{"id":"jupiter","kind":"planet","longitude":63.74022389925326,"sign":"gemini","degree_in_sign":3.740223899253259,"degree_in_sign_dms":"3°44'25\"","decan":1,"latitude":-1.0537422449420097,"distance_au":4.09171123497238,"speed":-0.11491968724625304,"retrograde":true,"right_ascension":61.9421514465371,"declination":19.867643569829166,"out_of_bounds":false,"house":7,"dignities":["detriment"]},{"id":"saturn","kind":"planet","longitude":269.0390925617097,"sign":"sagittarius","degree_in_sign":29.039092561709708,"degree_in_sign_dms":"29°02'21\"","decan":3,"latitude":0.8107526152191606,"distance_au":10.667714177531998,"speed":0.09037142102275417,"retrograde":false,"right_ascension":268.9590440074642,"declination":-22.62893619564773,"out_of_bounds":false,"house":1,"dignities":[]},{"id":"uranus","kind":"planet","longitude":268.41660612891815,"sign":"sagittarius","degree_in_sign":28.416606128918147,"degree_in_sign_dms":"28°25'00\"","decan":3,"latitude":-0.21410518395336425,"distance_au":19.949342957646376,"speed":0.04480221839681019,"retrograde":false,"right_ascension":268.2714280224142,"declination":-23.647764776902598,"out_of_bounds":true,"house":1,"dignities":[]},{"id":"neptune","kind":"planet","longitude":277.9548407356426,"sign":"capricorn","degree_in_sign":7.95484073564262,"degree_in_sign_dms":"7°57'17\"","decan":1,"latitude":0.9259889294070069,"distance_au":30.737031186998223,"speed":0.02334302679929171,"retrograde":false,"right_ascension":278.6001934996054,"declination":-22.27996378634854,"out_of_bounds":false,"house":2,"dignities":[]},{"id":"pluto","kind":"planet","longitude":222.41211867520124,"sign":"scorpio","degree_in_sign":12.412118675201242,"degree_in_sign_dms":"12°24'44\"","decan":2,"latitude":15.413719701893417,"distance_au":30.614263343892894,"speed":0.04047950732578406,"retrograde":false,"right_ascension":224.61557375167868,"declination":-0.8495654273009196,"out_of_bounds":false,"house":12,"dignities":["domicile"]},{"id":"north_node","kind":"lunar_node","variant":"true","longitude":342.4067447265457,"sign":"pisces","degree_in_sign":12.406744726545696,"degree_in_sign_dms":"12°24'24\"","decan":2,"latitude":0.0,"distance_au":0.0023703311620956475,"speed":0.01356034913224367,"retrograde":false,"right_ascension":343.77949070412893,"declination":-6.906527154704448,"out_of_bounds":false,"house":3},{"id":"south_node","kind":"lunar_node","variant":"true","longitude":162.40674472654564,"sign":"virgo","degree_in_sign":12.40674472654564,"degree_in_sign_dms":"12°24'24\"","decan":2,"latitude":-0.0,"distance_au":0.0023703311620956475,"speed":0.01356034913224367,"retrograde":false,"right_ascension":163.77949070412888,"declination":6.906527154704448,"out_of_bounds":false,"house":9},{"id":"lilith","kind":"lunar_apogee","variant":"mean","longitude":169.10724849007508,"sign":"virgo","degree_in_sign":19.10724849007508,"degree_in_sign_dms":"19°06'26\"","decan":2,"latitude":-0.732107010876786,"distance_au":0.002710625131722546,"speed":0.11076024477644272,"retrograde":false,"right_ascension":169.70000738058022,"declination":3.6379400874894436,"out_of_bounds":false,"house":10},{"id":"chiron","kind":"centaur","longitude":96.96876515126625,"sign":"cancer","degree_in_sign":6.968765151266254,"degree_in_sign_dms":"6°58'08\"","decan":1,"latitude":-6.529342346014169,"distance_au":11.558991577109042,"speed":-0.023399399403010637,"retrograde":true,"right_ascension":97.23129087868793,"declination":16.73903226550937,"out_of_bounds":false,"house":8},{"id":"ceres","kind":"asteroid","longitude":347.4880592152269,"sign":"pisces","degree_in_sign":17.488059215226883,"degree_in_sign_dms":"17°29'17\"","decan":2,"latitude":-13.61124423958844,"distance_au":2.2514594899257023,"speed":-0.02937879550391531,"retrograde":true,"right_ascension":354.0103242438836,"declination":-17.438132394544294,"out_of_bounds":false,"house":4},{"id":"pallas","kind":"asteroid","longitude":304.6460390973059,"sign":"aquarius","degree_in_sign":4.646039097305902,"degree_in_sign_dms":"4°38'46\"","decan":1,"latitude":19.7968729155275,"distance_au":3.328351314826788,"speed":0.16334124889464707,"retrograde":false,"right_ascension":302.3376708656638,"declination":0.1592169927283783,"out_of_bounds":false,"house":2},{"id":"juno","kind":"asteroid","longitude":147.78713478108722,"sign":"leo","degree_in_sign":27.787134781087218,"degree_in_sign_dms":"27°47'14\"","decan":3,"latitude":-9.350552228681176,"distance_au":2.330160307832122,"speed":0.36516043129594944,"retrograde":false,"right_ascension":146.75646717002044,"declination":3.45093059133621,"out_of_bounds":false,"house":9},{"id":"vesta","kind":"asteroid","longitude":205.3582647370874,"sign":"libra","degree_in_sign":25.35826473708741,"degree_in_sign_dms":"25°21'30\"","decan":3,"latitude":4.995184454258002,"distance_au":3.1671618535920687,"speed":0.5183125054410217,"retrograde":false,"right_ascension":205.32826269760662,"declination":-5.155182727231384,"out_of_bounds":false,"house":11}],"angles":{"ascendant":{"longitude":237.93838260439563,"sign":"scorpio","degree_in_sign":27.938382604395628,"degree_in_sign_dms":"27°56'18\"","decan":3,"speed":273.84667036246424},"midheaven":{"longitude":166.42305048125678,"sign":"virgo","degree_in_sign":16.42305048125678,"degree_in_sign_dms":"16°25'23\"","decan":2,"speed":390.0321590005049},"descendant":{"longitude":57.938382604395656,"sign":"taurus","degree_in_sign":27.938382604395656,"degree_in_sign_dms":"27°56'18\"","decan":3,"speed":273.84667036246424},"imum_coeli":{"longitude":346.4230504812568,"sign":"pisces","degree_in_sign":16.42305048125678,"degree_in_sign_dms":"16°25'23\"","decan":2,"speed":390.0321590005049},"vertex":{"longitude":100.71285311744576,"sign":"cancer","degree_in_sign":10.71285311744576,"degree_in_sign_dms":"10°42'46\"","decan":2,"speed":305.13582391634833},"antivertex":{"longitude":280.7128531174458,"sign":"capricorn","degree_in_sign":10.712853117445775,"degree_in_sign_dms":"10°42'46\"","decan":2,"speed":305.13582391634833},"east_point":{"longitude":258.5096969063595,"sign":"sagittarius","degree_in_sign":18.509696906359522,"degree_in_sign_dms":"18°30'35\"","decan":2},"armc":167.50707546137173},"houses":{"system":"placidus","requested_system":"placidus","cusps":[{"house":1,"longitude":237.93838260439563,"sign":"scorpio","degree_in_sign":27.938382604395628,"degree_in_sign_dms":"27°56'18\"","decan":3,"size":31.757158721511672},{"house":2,"longitude":269.6955413259073,"sign":"sagittarius","degree_in_sign":29.6955413259073,"degree_in_sign_dms":"29°41'44\"","decan":3,"size":38.75211662210535},{"house":3,"longitude":308.44765794801265,"sign":"aquarius","degree_in_sign":8.447657948012647,"degree_in_sign_dms":"8°26'52\"","decan":1,"size":37.97539253324413},{"house":4,"longitude":346.4230504812568,"sign":"pisces","degree_in_sign":16.42305048125678,"degree_in_sign_dms":"16°25'23\"","decan":2,"size":30.117400322491733},{"house":5,"longitude":16.540450803748513,"sign":"aries","degree_in_sign":16.540450803748513,"degree_in_sign_dms":"16°32'26\"","decan":2,"size":22.878987749292378},{"house":6,"longitude":39.41943855304089,"sign":"taurus","degree_in_sign":9.41943855304089,"degree_in_sign_dms":"9°25'10\"","decan":1,"size":18.518944051354765},{"house":7,"longitude":57.938382604395656,"sign":"taurus","degree_in_sign":27.938382604395656,"degree_in_sign_dms":"27°56'18\"","decan":3,"size":31.757158721511644},{"house":8,"longitude":89.6955413259073,"sign":"gemini","degree_in_sign":29.6955413259073,"degree_in_sign_dms":"29°41'44\"","decan":3,"size":38.75211662210535},{"house":9,"longitude":128.44765794801265,"sign":"leo","degree_in_sign":8.447657948012647,"degree_in_sign_dms":"8°26'52\"","decan":1,"size":37.97539253324413},{"house":10,"longitude":166.42305048125678,"sign":"virgo","degree_in_sign":16.42305048125678,"degree_in_sign_dms":"16°25'23\"","decan":2,"size":30.117400322491704},{"house":11,"longitude":196.54045080374848,"sign":"libra","degree_in_sign":16.540450803748485,"degree_in_sign_dms":"16°32'26\"","decan":2,"size":22.878987749292406},{"house":12,"longitude":219.4194385530409,"sign":"scorpio","degree_in_sign":9.41943855304089,"degree_in_sign_dms":"9°25'10\"","decan":1,"size":18.518944051354737}]},"aspects":[{"point1":"pluto","point2":"north_node","aspect":"trine","major":true,"exact_angle":120.0,"separation":119.99462605134445,"orb":0.005373948655545746,"max_orb":4.0,"applying":false},{"point1":"venus","point2":"jupiter","aspect":"trine","major":true,"exact_angle":120.0,"separation":120.2739259195668,"orb":0.2739259195668069,"max_orb":7.0,"applying":false},{"point1":"saturn","point2":"uranus","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":0.6224864327915611,"orb":0.6224864327915611,"max_orb":8.0,"applying":false},{"point1":"neptune","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":179.01392441562365,"orb":0.9860755843763513,"max_orb":4.0,"applying":false},{"point1":"mars","point2":"saturn","aspect":"square","major":true,"exact_angle":90.0,"separation":91.00718637401206,"orb":1.0071863740120648,"max_orb":7.0,"applying":true},{"point1":"mars","point2":"uranus","aspect":"square","major":true,"exact_angle":90.0,"separation":91.62967280680363,"orb":1.629672806803626,"max_orb":7.0,"applying":false},{"point1":"mars","point2":"ascendant","aspect":"trine","major":true,"exact_angle":120.0,"separation":122.10789633132612,"orb":2.107896331326117,"max_orb":7.0,"applying":true},{"point1":"sun","point2":"neptune","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.87012165695825,"orb":2.129878343041753,"max_orb":7.0,"applying":false},{"point1":"sun","point2":"north_node","aspect":"trine","major":true,"exact_angle":120.0,"separation":122.32202564786132,"orb":2.3220256478613237,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"pluto","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.327399596516898,"orb":2.327399596516898,"max_orb":10.0,"applying":true},{"point1":"lilith","point2":"midheaven","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.6841980088182993,"orb":2.6841980088182993,"max_orb":4.0,"applying":true},{"point1":"venus","point2":"chiron","aspect":"square","major":true,"exact_angle":90.0,"separation":87.04538466755382,"orb":2.9546153324461812,"max_orb":4.0,"applying":true},{"point1":"sun","point2":"chiron","aspect":"trine","major":true,"exact_angle":120.0,"separation":123.11595392741812,"orb":3.1159539274181185,"max_orb":4.0,"applying":false},{"point1":"mars","point2":"jupiter","aspect":"sextile","major":true,"exact_angle":60.0,"separation":63.69394496353152,"orb":3.6939449635315214,"max_orb":5.0,"applying":true},{"point1":"moon","point2":"mercury","aspect":"sextile","major":true,"exact_angle":60.0,"separation":63.74552239257514,"orb":3.7455223925751397,"max_orb":7.0,"applying":true},{"point1":"venus","point2":"neptune","aspect":"square","major":true,"exact_angle":90.0,"separation":93.94069091682252,"orb":3.9406909168225184,"max_orb":7.0,"applying":true},{"point1":"venus","point2":"mars","aspect":"opposition","major":true,"exact_angle":180.0,"separation":176.03212911690167,"orb":3.9678708830983282,"max_orb":8.0,"applying":false},{"point1":"pluto","point2":"midheaven","aspect":"sextile","major":true,"exact_angle":60.0,"separation":55.98906819394446,"orb":4.010931806055538,"max_orb":5.0,"applying":false},{"point1":"neptune","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":55.54272206044138,"orb":4.457277939558622,"max_orb":5.0,"applying":false},{"point1":"venus","point2":"saturn","aspect":"square","major":true,"exact_angle":90.0,"separation":85.0249427428896,"orb":4.975057257110393,"max_orb":7.0,"applying":false},{"point1":"mercury","point2":"uranus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":64.97680006536723,"orb":4.976800065367229,"max_orb":5.0,"applying":true},{"point1":"venus","point2":"uranus","aspect":"square","major":true,"exact_angle":90.0,"separation":84.40245631009805,"orb":5.597543689901954,"max_orb":7.0,"applying":false},{"point1":"jupiter","point2":"ascendant","aspect":"opposition","major":true,"exact_angle":180.0,"separation":174.19815870514236,"orb":5.801841294857638,"max_orb":8.0,"applying":true},{"point1":"sun","point2":"midheaven","aspect":"sextile","major":true,"exact_angle":60.0,"separation":53.66166859742759,"orb":6.338331402572408,"max_orb":7.0,"applying":false},{"point1":"moon","point2":"pluto","aspect":"square","major":true,"exact_angle":90.0,"separation":82.71783500422544,"orb":7.282164995774565,"max_orb":9.0,"applying":false},{"point1":"moon","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":98.24409893341988,"orb":8.244098933419878,"max_orb":9.0,"applying":false},{"point1":"moon","point2":"uranus","aspect":"trine","major":true,"exact_angle":120.0,"separation":128.72232245794237,"orb":8.722322457942369,"max_orb":9.0,"applying":true}],"lots":{"fortune":{"longitude":157.54794719668706,"sign":"virgo","degree_in_sign":7.547947196687062,"degree_in_sign_dms":"7°32'53\"","decan":1,"house":9},"spirit":{"longitude":318.3288180121042,"sign":"aquarius","degree_in_sign":18.328818012104193,"degree_in_sign_dms":"18°19'44\"","decan":2,"house":3}},"moon_phase":{"elongation":279.6095645922914,"phase":"last_quarter","illumination":0.41790186237223387,"waxing":false},"summary":{"elements":{"fire":{"count":4,"points":["moon","mars","saturn","uranus"]},"earth":{"count":1,"points":["neptune"]},"air":{"count":3,"points":["mercury","venus","jupiter"]},"water":{"count":2,"points":["sun","pluto"]}},"modalities":{"cardinal":{"count":4,"points":["mercury","venus","mars","neptune"]},"fixed":{"count":3,"points":["sun","moon","pluto"]},"mutable":{"count":3,"points":["jupiter","saturn","uranus"]}},"hemispheres":{"above_horizon":{"count":6,"points":["sun","moon","mercury","venus","jupiter","pluto"]},"below_horizon":{"count":4,"points":["mars","saturn","uranus","neptune"]},"eastern":{"count":7,"points":["sun","mercury","venus","saturn","uranus","neptune","pluto"]},"western":{"count":3,"points":["moon","mars","jupiter"]}},"sect":"day","chart_ruler":{"ascendant_sign":"scorpio","traditional":{"planet":"mars","sign":"aries","house":4},"modern":{"planet":"pluto","sign":"scorpio","house":12}},"retrograde":["jupiter","chiron","ceres"]},"warnings":[]},"settings":{"aspect_set":"major","orb_multiplier":1.0,"orbs":[{"aspect":"conjunction","angle":0.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0},{"aspect":"sextile","angle":60.0,"orb":5.0,"orb_with_luminary":7.0,"orb_with_minor_point":4.0},{"aspect":"square","angle":90.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"trine","angle":120.0,"orb":7.0,"orb_with_luminary":9.0,"orb_with_minor_point":4.0},{"aspect":"opposition","angle":180.0,"orb":8.0,"orb_with_luminary":10.0,"orb_with_minor_point":4.0}]},"aspects":[{"person1":"midheaven","person2":"neptune","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":119.95168559585389,"orb":0.048314404146111656,"max_orb":7.0},{"person1":"saturn","person2":"mercury","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":89.90055880816425,"orb":0.0994411918357514,"max_orb":7.0},{"person1":"ascendant","person2":"moon","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":0.3067099953285606,"orb":0.3067099953285606,"max_orb":10.0},{"person1":"moon","person2":"sun","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":0.4064300181428848,"orb":0.4064300181428848,"max_orb":10.0},{"person1":"chiron","person2":"sun","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":119.51725351050669,"orb":0.4827464894933087,"max_orb":4.0},{"person1":"mars","person2":"jupiter","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":120.85254951395703,"orb":0.8525495139570296,"max_orb":7.0},{"person1":"uranus","person2":"sun","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":59.13641751834598,"orb":0.8635824816540207,"max_orb":7.0},{"person1":"venus","person2":"sun","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":89.10602282581169,"orb":0.8939771741883078,"max_orb":9.0},{"person1":"midheaven","person2":"chiron","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":59.06223881976973,"orb":0.9377611802302681,"max_orb":4.0},{"person1":"mars","person2":"venus","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":118.87352456647616,"orb":1.1264754335238365,"max_orb":7.0},{"person1":"pluto","person2":"midheaven","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":61.19345913179512,"orb":1.193459131795123,"max_orb":5.0},{"person1":"uranus","person2":"neptune","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":1.2662958613877322,"orb":1.2662958613877322,"max_orb":8.0},{"person1":"jupiter","person2":"mars","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":91.33673994478438,"orb":1.3367399447843837,"max_orb":7.0},{"person1":"pluto","person2":"lilith","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":58.509261122976824,"orb":1.4907388770231762,"max_orb":4.0},{"person1":"lilith","person2":"midheaven","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":58.22766214958841,"orb":1.7723378504115885,"max_orb":4.0},{"person1":"chiron","person2":"north_node","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":118.16072084163198,"orb":1.839279158368015,"max_orb":4.0},{"person1":"chiron","person2":"pluto","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":121.84465310702356,"orb":1.8446531070235608,"max_orb":4.0},{"person1":"neptune","person2":"pluto","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":61.882153633059175,"orb":1.8821536330591755,"max_orb":5.0},{"person1":"neptune","person2":"north_node","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":58.11247241828528,"orb":1.8875275817147212,"max_orb":4.0},{"person1":"moon","person2":"north_node","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":121.91559562971844,"orb":1.9155956297184389,"max_orb":4.0},{"person1":"moon","person2":"pluto","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":1.9209695783739562,"orb":1.9209695783739562,"max_orb":10.0},{"person1":"pluto","person2":"moon","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":87.92222594207612,"orb":2.0777740579238753,"max_orb":9.0},{"person1":"neptune","person2":"midheaven","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":117.87122182700364,"orb":2.1287781729963626,"max_orb":7.0},{"person1":"midheaven","person2":"sun","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.82180725281214,"orb":2.1781927471878646,"max_orb":10.0},{"person1":"mercury","person2":"lilith","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.77002656520514,"orb":2.229973434794857,"max_orb":4.0},{"person1":"lilith","person2":"pluto","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":2.2385939556439496,"orb":2.2385939556439496,"max_orb":4.0},{"person1":"lilith","person2":"north_node","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":117.7560320957005,"orb":2.2439679042994953,"max_orb":4.0},{"person1":"uranus","person2":"chiron","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.74762855423592,"orb":2.2523714457640835,"max_orb":4.0},{"person1":"jupiter","person2":"saturn","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.65607368120357,"orb":2.3439263187964343,"max_orb":8.0},{"person1":"moon","person2":"neptune","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":57.46369163881536,"orb":2.5363083611846378,"max_orb":7.0},{"person1":"chiron","person2":"neptune","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.38737516746494,"orb":2.6126248325350616,"max_orb":4.0},{"person1":"jupiter","person2":"venus","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":92.63113093831396,"orb":2.6311309383139587,"max_orb":7.0},{"person1":"mars","person2":"mars","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":57.15860455042554,"orb":2.8413954495744633,"max_orb":5.0},{"person1":"jupiter","person2":"uranus","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":177.033587248412,"orb":2.9664127515879954,"max_orb":8.0},{"person1":"uranus","person2":"north_node","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":63.185608129515344,"orb":3.1856081295153444,"max_orb":4.0},{"person1":"uranus","person2":"pluto","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":56.80901792182911,"orb":3.19098207817089,"max_orb":5.0},{"person1":"venus","person2":"pluto","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":86.77862322929482,"orb":3.2213767707051773,"max_orb":7.0},{"person1":"sun","person2":"ascendant","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":116.76363792214616,"orb":3.2363620778538404,"max_orb":9.0},{"person1":"north_node","person2":"pluto","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":93.33887674991135,"orb":3.33887674991135,"max_orb":4.0},{"person1":"moon","person2":"chiron","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":123.522383945561,"orb":3.5223839455610033,"max_orb":4.0},{"person1":"chiron","person2":"chiron","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":3.598700416911427,"orb":3.598700416911427,"max_orb":4.0},{"person1":"sun","person2":"uranus","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":86.28541439762364,"orb":3.71458560237636,"max_orb":9.0},{"person1":"north_node","person2":"moon","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":176.0567117541368,"orb":3.9432882458631866,"max_orb":4.0},{"person1":"ascendant","person2":"mercury","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":64.0522323879037,"orb":4.0522323879037,"max_orb":5.0},{"person1":"neptune","person2":"sun","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":64.20955322957604,"orb":4.209553229576045,"max_orb":7.0},{"person1":"sun","person2":"saturn","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":85.66292796483208,"orb":4.337072035167921,"max_orb":9.0},{"person1":"midheaven","person2":"pluto","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":175.49440765629527,"orb":4.505592343704734,"max_orb":8.0},{"person1":"saturn","person2":"ascendant","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":55.40198226731954,"orb":4.598017732680461,"max_orb":5.0},{"person1":"mercury","person2":"midheaven","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":175.08582855638684,"orb":4.9141714436131565,"max_orb":8.0},{"person1":"mars","person2":"ascendant","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":64.94929178090061,"orb":4.949291780900609,"max_orb":5.0},{"person1":"venus","person2":"venus","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":125.17659208567599,"orb":5.176592085675992,"max_orb":7.0},{"person1":"pluto","person2":"pluto","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":5.204390937850661,"orb":5.204390937850661,"max_orb":8.0},{"person1":"uranus","person2":"venus","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":95.20698677821028,"orb":5.206986778210279,"max_orb":7.0},{"person1":"sun","person2":"mars","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":5.344258409179986,"orb":5.344258409179986,"max_orb":10.0},{"person1":"venus","person2":"jupiter","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":114.5494819947572,"orb":5.450518005242799,"max_orb":7.0},{"person1":"moon","person2":"midheaven","aspect":"sextile","nature":"harmonious","major":true,"exact_angle":60.0,"separation":54.06809861557048,"orb":5.931901384429523,"max_orb":7.0},{"person1":"neptune","person2":"neptune","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":6.339431572617798,"orb":6.339431572617798,"max_orb":8.0},{"person1":"jupiter","person2":"neptune","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":173.42817814486352,"orb":6.571821855136477,"max_orb":8.0},{"person1":"mercury","person2":"ascendant","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":113.39883932047431,"orb":6.601160679525691,"max_orb":7.0},{"person1":"saturn","person2":"midheaven","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":126.91731439045839,"orb":6.917314390458387,"max_orb":7.0},{"person1":"ascendant","person2":"pluto","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":83.024544999554,"orb":6.975455000446004,"max_orb":7.0},{"person1":"mars","person2":"sun","aspect":"square","nature":"challenging","major":true,"exact_angle":90.0,"separation":82.80295530661186,"orb":7.197044693388136,"max_orb":9.0},{"person1":"pluto","person2":"sun","aspect":"conjunction","nature":"neutral","major":true,"exact_angle":0.0,"separation":7.531790534367531,"orb":7.531790534367531,"max_orb":10.0},{"person1":"sun","person2":"midheaven","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":171.721029954715,"orb":8.278970045285007,"max_orb":10.0},{"person1":"jupiter","person2":"sun","aspect":"trine","nature":"harmonious","major":true,"exact_angle":120.0,"separation":128.70170019817823,"orb":8.70170019817823,"max_orb":9.0},{"person1":"sun","person2":"venus","aspect":"opposition","nature":"challenging","major":true,"exact_angle":180.0,"separation":170.68787070772171,"orb":9.312129292278286,"max_orb":10.0}],"house_overlays":{"person1_in_person2":[{"point":"sun","sign":"pisces","house":4},{"point":"moon","sign":"scorpio","house":12},{"point":"mercury","sign":"pisces","house":4},{"point":"venus","sign":"aquarius","house":3},{"point":"mars","sign":"aquarius","house":2},{"point":"jupiter","sign":"cancer","house":8},{"point":"saturn","sign":"capricorn","house":2},{"point":"uranus","sign":"capricorn","house":2},{"point":"neptune","sign":"capricorn","house":2},{"point":"pluto","sign":"scorpio","house":12},{"point":"north_node","sign":"aquarius","house":3},{"point":"south_node","sign":"leo","house":9},{"point":"lilith","sign":"scorpio","house":12},{"point":"chiron","sign":"cancer","house":8},{"point":"ceres","sign":"gemini","house":7},{"point":"pallas","sign":"aries","house":5},{"point":"juno","sign":"scorpio","house":12},{"point":"vesta","sign":"pisces","house":4},{"point":"ascendant","sign":"leo","house":9},{"point":"midheaven","sign":"taurus","house":5}],"person2_in_person1":[{"point":"sun","sign":"scorpio","house":4},{"point":"moon","sign":"leo","house":1},{"point":"mercury","sign":"libra","house":3},{"point":"venus","sign":"libra","house":2},{"point":"mars","sign":"aries","house":8},{"point":"jupiter","sign":"gemini","house":10},{"point":"saturn","sign":"sagittarius","house":5},{"point":"uranus","sign":"sagittarius","house":5},{"point":"neptune","sign":"capricorn","house":5},{"point":"pluto","sign":"scorpio","house":4},{"point":"north_node","sign":"pisces","house":8},{"point":"south_node","sign":"virgo","house":2},{"point":"lilith","sign":"virgo","house":2},{"point":"chiron","sign":"cancer","house":11},{"point":"ceres","sign":"pisces","house":8},{"point":"pallas","sign":"aquarius","house":6},{"point":"juno","sign":"leo","house":1},{"point":"vesta","sign":"libra","house":3},{"point":"ascendant","sign":"scorpio","house":4},{"point":"midheaven","sign":"virgo","house":2}]},"summary":{"aspect_count":66,"by_nature":{"harmonious":32,"challenging":24,"neutral":10},"by_aspect":{"conjunction":10,"sextile":16,"square":12,"trine":16,"opposition":12}},"composite":{"method":"midpoint","points":[{"id":"sun","longitude":287.39336980261305,"sign":"capricorn","degree_in_sign":17.39336980261305,"degree_in_sign_dms":"17°23'36\"","decan":2,"house":4},{"id":"moon","longitude":180.09271638390152,"sign":"libra","degree_in_sign":0.09271638390151793,"degree_in_sign_dms":"0°05'34\"","decan":1,"house":12},{"id":"mercury","longitude":277.3885139942104,"sign":"capricorn","degree_in_sign":7.388513994210427,"degree_in_sign_dms":"7°23'19\"","decan":1,"house":3},{"id":"venus","longitude":246.60244586165805,"sign":"sagittarius","degree_in_sign":6.602445861658055,"degree_in_sign_dms":"6°36'09\"","decan":1,"house":2},{"id":"mars","longitude":331.466976660509,"sign":"pisces","degree_in_sign":1.4669766605089762,"degree_in_sign_dms":"1°28'01\"","decan":1,"house":5},{"id":"jupiter","longitude":77.5616213898797,"sign":"gemini","degree_in_sign":17.561621389879704,"degree_in_sign_dms":"17°33'42\"","decan":2,"house":9},{"id":"saturn","longitude":281.18972871671247,"sign":"capricorn","degree_in_sign":11.189728716712466,"degree_in_sign_dms":"11°11'23\"","decan":2,"house":3},{"id":"uranus","longitude":273.8188713629743,"sign":"capricorn","degree_in_sign":3.818871362974278,"degree_in_sign_dms":"3°49'08\"","decan":1,"house":3},{"id":"neptune","longitude":281.1245565219515,"sign":"capricorn","degree_in_sign":11.12455652195149,"degree_in_sign_dms":"11°07'28\"","decan":2,"house":3},{"id":"pluto","longitude":225.01431414412656,"sign":"scorpio","degree_in_sign":15.014314144126558,"degree_in_sign_dms":"15°00'52\"","decan":2,"house":2},{"id":"north_node","longitude":329.0788700758292,"sign":"aquarius","degree_in_sign":29.078870075829172,"degree_in_sign_dms":"29°04'44\"","decan":3,"house":5},{"id":"south_node","longitude":149.07887007582912,"sign":"leo","degree_in_sign":29.078870075829116,"degree_in_sign_dms":"29°04'44\"","decan":3,"house":11},{"id":"lilith","longitude":196.87898056046015,"sign":"libra","degree_in_sign":16.87898056046015,"degree_in_sign_dms":"16°52'44\"","decan":2,"house":1},{"id":"chiron","longitude":98.76811535972197,"sign":"cancer","degree_in_sign":8.768115359721975,"degree_in_sign_dms":"8°46'05\"","decan":1,"house":9},{"id":"ceres","longitude":36.604163708340536,"sign":"taurus","degree_in_sign":6.604163708340536,"degree_in_sign_dms":"6°36'15\"","decan":1,"house":8},{"id":"pallas","longitude":346.1400081047904,"sign":"pisces","degree_in_sign":16.14000810479041,"degree_in_sign_dms":"16°08'24\"","decan":2,"house":6},{"id":"juno","longitude":191.43488380215663,"sign":"libra","degree_in_sign":11.434883802156634,"degree_in_sign_dms":"11°26'06\"","decan":2,"house":1},{"id":"vesta","longitude":279.26812600789555,"sign":"capricorn","degree_in_sign":9.268126007895546,"degree_in_sign_dms":"9°16'05\"","decan":1,"house":3}],"angles":{"ascendant":{"longitude":188.66297814002144,"sign":"libra","degree_in_sign":8.662978140021437,"degree_in_sign_dms":"8°39'47\"","decan":1},"midheaven":{"longitude":102.16478840637666,"sign":"cancer","degree_in_sign":12.164788406376658,"degree_in_sign_dms":"12°09'53\"","decan":2},"descendant":{"longitude":8.662978140021437,"sign":"aries","degree_in_sign":8.662978140021437,"degree_in_sign_dms":"8°39'47\"","decan":1},"imum_coeli":{"longitude":282.16478840637666,"sign":"capricorn","degree_in_sign":12.164788406376658,"degree_in_sign_dms":"12°09'53\"","decan":2}},"houses":{"method":"midpoint_of_cusps","cusps":[{"house":1,"longitude":188.66297814002144,"sign":"libra","degree_in_sign":8.662978140021437,"degree_in_sign_dms":"8°39'47\"","decan":1,"size":25.980312888425942},{"house":2,"longitude":214.64329102844738,"sign":"scorpio","degree_in_sign":4.643291028447379,"degree_in_sign_dms":"4°38'36\"","decan":1,"size":32.2035945592595},{"house":3,"longitude":246.84688558770688,"sign":"sagittarius","degree_in_sign":6.846885587706879,"degree_in_sign_dms":"6°50'49\"","decan":1,"size":35.31790281866978},{"house":4,"longitude":282.16478840637666,"sign":"capricorn","degree_in_sign":12.164788406376658,"degree_in_sign_dms":"12°09'53\"","decan":2,"size":33.807156176128785},{"house":5,"longitude":315.97194458250544,"sign":"aquarius","degree_in_sign":15.971944582505444,"degree_in_sign_dms":"15°58'19\"","decan":2,"size":28.94844100729415},{"house":6,"longitude":344.9203855897996,"sign":"pisces","degree_in_sign":14.920385589799594,"degree_in_sign_dms":"14°55'13\"","decan":2,"size":23.742592550221843},{"house":7,"longitude":8.662978140021437,"sign":"aries","degree_in_sign":8.662978140021437,"degree_in_sign_dms":"8°39'47\"","decan":1,"size":25.980312888425942},{"house":8,"longitude":34.64329102844738,"sign":"taurus","degree_in_sign":4.643291028447379,"degree_in_sign_dms":"4°38'36\"","decan":1,"size":32.2035945592595},{"house":9,"longitude":66.84688558770688,"sign":"gemini","degree_in_sign":6.846885587706879,"degree_in_sign_dms":"6°50'49\"","decan":1,"size":35.31790281866978},{"house":10,"longitude":102.16478840637666,"sign":"cancer","degree_in_sign":12.164788406376658,"degree_in_sign_dms":"12°09'53\"","decan":2,"size":33.80715617612873},{"house":11,"longitude":135.9719445825054,"sign":"leo","degree_in_sign":15.971944582505387,"degree_in_sign_dms":"15°58'19\"","decan":2,"size":28.948441007294207},{"house":12,"longitude":164.9203855897996,"sign":"virgo","degree_in_sign":14.920385589799594,"degree_in_sign_dms":"14°55'13\"","decan":2,"size":23.742592550221843}]},"aspects":[{"point1":"saturn","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":0.0651721947609758,"orb":0.0651721947609758,"max_orb":8.0,"applying":null},{"point1":"chiron","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":89.89486278029949,"orb":0.10513721970050938,"max_orb":4.0,"applying":null},{"point1":"sun","point2":"lilith","aspect":"square","major":true,"exact_angle":90.0,"separation":90.5143892421529,"orb":0.5143892421529017,"max_orb":4.0,"applying":null},{"point1":"jupiter","point2":"lilith","aspect":"trine","major":true,"exact_angle":120.0,"separation":119.31735917058046,"orb":0.6826408294195403,"max_orb":4.0,"applying":null},{"point1":"saturn","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":179.0249403103358,"orb":0.9750596896641923,"max_orb":8.0,"applying":null},{"point1":"neptune","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":178.95976811557483,"orb":1.0402318844251681,"max_orb":8.0,"applying":null},{"point1":"mercury","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":88.72553585418899,"orb":1.2744641458110095,"max_orb":7.0,"applying":null},{"point1":"mercury","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":178.62039863448845,"orb":1.3796013655115473,"max_orb":4.0,"applying":null},{"point1":"venus","point2":"ascendant","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.93946772163662,"orb":2.0605322783633824,"max_orb":5.0,"applying":null},{"point1":"mars","point2":"uranus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":57.6481052975347,"orb":2.3518947024653016,"max_orb":5.0,"applying":null},{"point1":"neptune","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":177.64355883777048,"orb":2.3564411622295154,"max_orb":4.0,"applying":null},{"point1":"sun","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":62.37905565848649,"orb":2.379055658486493,"max_orb":7.0,"applying":null},{"point1":"mars","point2":"north_node","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":2.3881065846798037,"orb":2.3881065846798037,"max_orb":4.0,"applying":null},{"point1":"saturn","point2":"chiron","aspect":"opposition","major":true,"exact_angle":180.0,"separation":177.5783866430095,"orb":2.421613356990491,"max_orb":4.0,"applying":null},{"point1":"neptune","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":92.46157838193005,"orb":2.461578381930053,"max_orb":7.0,"applying":null},{"point1":"saturn","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":92.52675057669103,"orb":2.526750576691029,"max_orb":7.0,"applying":null},{"point1":"pluto","point2":"midheaven","aspect":"trine","major":true,"exact_angle":120.0,"separation":122.8495257377499,"orb":2.8495257377499,"max_orb":7.0,"applying":null},{"point1":"chiron","point2":"midheaven","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.396673046654655,"orb":3.396673046654655,"max_orb":4.0,"applying":null},{"point1":"ascendant","point2":"midheaven","aspect":"square","major":true,"exact_angle":90.0,"separation":86.49818973364478,"orb":3.5018102663552213,"max_orb":7.0,"applying":null},{"point1":"mercury","point2":"uranus","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.5696426312361496,"orb":3.5696426312361496,"max_orb":8.0,"applying":null},{"point1":"moon","point2":"uranus","aspect":"square","major":true,"exact_angle":90.0,"separation":93.72615497907276,"orb":3.72615497907276,"max_orb":9.0,"applying":null},{"point1":"mercury","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.7360425277410627,"orb":3.7360425277410627,"max_orb":8.0,"applying":null},{"point1":"mercury","point2":"saturn","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":3.8012147225020385,"orb":3.8012147225020385,"max_orb":8.0,"applying":null},{"point1":"saturn","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":56.17541457258591,"orb":3.8245854274140925,"max_orb":5.0,"applying":null},{"point1":"neptune","point2":"pluto","aspect":"sextile","major":true,"exact_angle":60.0,"separation":56.11024237782493,"orb":3.8897576221750683,"max_orb":5.0,"applying":null},{"point1":"mercury","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":175.22372558783377,"orb":4.776274412166231,"max_orb":8.0,"applying":null},{"point1":"uranus","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":85.15589322295284,"orb":4.844106777047159,"max_orb":7.0,"applying":null},{"point1":"venus","point2":"mars","aspect":"square","major":true,"exact_angle":90.0,"separation":84.86453079885092,"orb":5.135469201149078,"max_orb":7.0,"applying":null},{"point1":"sun","point2":"midheaven","aspect":"opposition","major":true,"exact_angle":180.0,"separation":174.7714186037636,"orb":5.228581396236393,"max_orb":10.0,"applying":null},{"point1":"sun","point2":"saturn","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":6.2036410859005855,"orb":6.2036410859005855,"max_orb":10.0,"applying":null},{"point1":"sun","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":6.268813280661561,"orb":6.268813280661561,"max_orb":10.0,"applying":null},{"point1":"moon","point2":"venus","aspect":"sextile","major":true,"exact_angle":60.0,"separation":66.50972947775654,"orb":6.509729477756537,"max_orb":7.0,"applying":null},{"point1":"moon","point2":"mercury","aspect":"square","major":true,"exact_angle":90.0,"separation":97.29579761030891,"orb":7.2957976103089095,"max_orb":9.0,"applying":null},{"point1":"uranus","point2":"neptune","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":7.305685158977212,"orb":7.305685158977212,"max_orb":8.0,"applying":null},{"point1":"saturn","point2":"uranus","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":7.370857353738188,"orb":7.370857353738188,"max_orb":8.0,"applying":null},{"point1":"moon","point2":"ascendant","aspect":"conjunction","major":true,"exact_angle":0.0,"separation":8.570261756119919,"orb":8.570261756119919,"max_orb":10.0,"applying":null},{"point1":"sun","point2":"ascendant","aspect":"square","major":true,"exact_angle":90.0,"separation":98.73039166259161,"orb":8.730391662591614,"max_orb":9.0,"applying":null}]},"meta":{"service":"horoscope-api","version":"0.1.0","data_sources":{"ephemeris":{"name":"Swiss Ephemeris","version":"2.10.03","precise_years":[1800,2399],"license":"AGPL-3.0 (or Swiss Ephemeris Professional License)"},"tzdb_version":"2026f","geonames_downloaded":"2026-11-10","geonames_attribution":"Place data from GeoNames (https://www.geonames.org), CC BY 4.0"}}} \ No newline at end of file