Yearly forecast: solar return, transits, progressions, profection, eclipses
CI / test (push) Successful in 56s
CI / build (push) Successful in 4m41s
CI / deploy (push) Skipped

- astro-engine: forecast module (solar return moment, slow-planet transits
  with exact dates and periods, natal house ingresses, secondary
  progressions, annual profection, eclipses via Swiss Ephemeris)
- horoscope-api: POST /v1/forecast, solar return chart cast for the place
  of the birthday
- backend: forecasts table, /v1/charts/{id}/forecasts, /v1/forecasts/{id}
  and its analyses using a new 'forecast' unit; current year of life open,
  the next one 30 days before the birthday
- packages: Páros and Család include forecasts (6 000 / 11 000 Ft),
  +1 éves előrejelzés add-on 2 500 Ft; Egy elemzés unchanged
- worker and prompt: forecast kind with five sections and forecast rules
  (trends, no event predictions); no birth data, place or exact age sent
- frontend: /kepletek/{id}/elorejelzes with the solar return wheel, the
  keys of the year, a monthly timeline, transit list and detailed forecast
- data export: forecasts added, model name removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-18 08:19:13 +00:00
co-authored by Claude Opus 5.5
parent 829c33e52f
commit f1bd34c394
42 changed files with 4764 additions and 85 deletions
+96 -7
View File
@@ -17,16 +17,19 @@ pub enum Kind {
Synastry,
/// A free teaser of a natal chart: a title and a few sentences.
Summary,
/// One year of a natal chart: solar return, transits, progressions, profection, eclipses.
Forecast,
}
impl Kind {
pub const ALL: [Kind; 3] = [Kind::Summary, Kind::Natal, Kind::Synastry];
pub const ALL: [Kind; 4] = [Kind::Summary, Kind::Natal, Kind::Synastry, Kind::Forecast];
pub fn as_str(self) -> &'static str {
match self {
Kind::Natal => "natal",
Kind::Synastry => "synastry",
Kind::Summary => "summary",
Kind::Forecast => "forecast",
}
}
@@ -35,6 +38,7 @@ impl Kind {
"natal" => Some(Kind::Natal),
"synastry" => Some(Kind::Synastry),
"summary" => Some(Kind::Summary),
"forecast" => Some(Kind::Forecast),
_ => None,
}
}
@@ -68,10 +72,39 @@ const SYNASTRY_SECTIONS: [(&str, &str); 5] = [
("long_term", "Long-term potential and shared purpose, including the composite chart"),
];
const FORECAST_SECTIONS: [(&str, &str); 5] = [
(
"theme",
"The main theme of the year: the solar return chart (its Ascendant, the houses of the Sun and the Moon, \
angular planets, tight aspects), the profected house and the lord of the year",
),
(
"love",
"Love, relationships, family and friendships during the year (Venus, the Moon, the 4th, 5th, 7th and 11th \
houses, and the transits and eclipses touching them)",
),
(
"work",
"Work, calling, money and daily life during the year (Midheaven, the 2nd, 6th and 10th houses, Jupiter and \
Saturn transits)",
),
(
"growth",
"Inner development: the progressed Moon's sign, house and lunation phase, the other progressions, and the \
transits of Uranus, Neptune and Pluto",
),
(
"timeline",
"The year in time order from birthday to birthday, in exactly 4 paragraphs, one for each quarter: the main \
periods and dates (transits, eclipses, progressed Moon ingresses) of that quarter",
),
];
fn sections(kind: Kind) -> &'static [(&'static str, &'static str)] {
match kind {
Kind::Natal => &NATAL_SECTIONS,
Kind::Synastry => &SYNASTRY_SECTIONS,
Kind::Forecast => &FORECAST_SECTIONS,
Kind::Summary => &[],
}
}
@@ -106,6 +139,13 @@ pub fn schema(kind: Kind) -> Value {
);
}
let keys: Vec<&str> = sections(kind).iter().map(|(k, _)| *k).collect();
let (strengths, challenges) = match kind {
Kind::Forecast => (
"3-5 main opportunities of the year, one sentence each",
"3-5 main challenges of the year, one sentence each",
),
_ => ("3-5 key strengths, one sentence each", "3-5 key challenges, one sentence each"),
};
json!({
"type": "object",
"additionalProperties": false,
@@ -114,8 +154,8 @@ pub fn schema(kind: Kind) -> Value {
"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"},
"strengths": {"type": "array", "items": {"type": "string"}, "description": strengths},
"challenges": {"type": "array", "items": {"type": "string"}, "description": challenges},
"advice": {"type": "string", "description": "A closing, encouraging paragraph with concrete guidance"}
}
})
@@ -133,6 +173,11 @@ Use the usual Hungarian astrological terms:
Never leave English words (e.g. fire, earth, air, water) in the Hungarian text.
- 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.";
const HUNGARIAN_FORECAST_TERMS: &str = "\
Forecast terms in Hungarian: szolár (szoláris visszatérés, a szolár képlet), tranzit (\"a Szaturnusz tranzitja a Napod \
felett\"), progresszió (a progresszív Hold), profekció, az év ura, napfogyatkozás, holdfogyatkozás, retrográd, \
Szaturnusz-visszatérés. Write dates the Hungarian way: \"március 12.\", \"március 12-től április 30-ig\", \"2027 januárja\".";
fn language_name(language: &str) -> &'static str {
match language {
"hu" => "Hungarian",
@@ -151,6 +196,10 @@ pub fn default_system(kind: Kind, language: &str) -> String {
"a short free summary of a natal chart (a teaser shown before the detailed, paid analysis)",
"Speak to the owner of the chart directly, in the informal second person singular (in Hungarian: tegező forma, \"te\").",
),
Kind::Forecast => (
"a personal forecast for one year of life, from one birthday to the next",
"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\"). \
@@ -178,6 +227,8 @@ and no medical, legal or financial advice.
- Answer with a single JSON object that matches the given schema, and nothing else.",
lang = language_name(language),
length = match kind {
Kind::Forecast => "Length: each section 2-4 paragraphs (about 150-250 words), the timeline exactly 4 \
paragraphs; the whole forecast about 1500-2000 words.",
Kind::Summary => "Length: one paragraph of 3-4 sentences (60-100 words). Pick the Sun, Moon and Ascendant \
(if the birth time is known) and the single most striking feature of the chart (a very tight aspect, \
a stellium, a strong element emphasis or gap). It must be complete in itself and specific to this chart: \
@@ -185,13 +236,38 @@ and no medical, legal or financial advice.
_ => "Length: each section 2-4 paragraphs (about 150-250 words); the whole analysis about 1300-1800 words.",
},
);
if kind == Kind::Forecast {
text.push_str(FORECAST_RULES);
}
if language == "hu" {
text.push_str("\n\n");
text.push_str(HUNGARIAN_STYLE);
if kind == Kind::Forecast {
text.push('\n');
text.push_str(HUNGARIAN_FORECAST_TERMS);
}
}
text
}
const FORECAST_RULES: &str = "
Forecast rules:
- Describe themes, tendencies, opportunities and the timing of periods, never certain events: \"a good time for\", \
\"may bring\", \"asks for\", not \"will happen\". Nothing about illness, death, accidents, pregnancy, lawsuits or \
gains and losses of money.
- Use only the dates in the data and do not invent any; a transit is felt during its whole period, most strongly \
around the exact dates. Retrograde planets make a contact two or three times: describe it as one process.
- Weigh the techniques as an astrologer does: the solar return Ascendant and the houses of the solar return Sun and \
Moon set the scene; the lord of the year and the profected house say which area of life is activated; exact \
transits of Saturn, Uranus, Neptune and Pluto to the Sun, Moon, Ascendant, Midheaven and personal planets are the \
main turning points; Jupiter transits are openings; eclipses matter only where they touch the natal chart; the \
progressed Moon shows the emotional season.
- A planet meeting its own natal place (marked \"cycle\") is a life milestone, e.g. the Saturn return or the \
Uranus opposition: name it as such.
- If there is no solar return chart (unknown birth time), build the year on the transits and progressions, and do \
not mention houses, the Ascendant or the Midheaven.";
/// Splits a stored prompt version (`v2` or `v2-r<id>`, the id of an admin-edited
/// system prompt in `prompt_revisions`) into the code version and the revision id.
pub fn split_version(version: &str) -> (&str, Option<i64>) {
@@ -230,6 +306,7 @@ pub fn build(kind: Kind, language: &str, chart_text: &str, system: Option<&str>)
Kind::Natal => "natal_analysis",
Kind::Synastry => "synastry_analysis",
Kind::Summary => "chart_summary",
Kind::Forecast => "forecast_analysis",
},
schema: schema(kind),
}
@@ -301,10 +378,11 @@ pub fn polish(language: &str, content: &mut 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 (strengths, challenges, advice) = match (language, kind) {
("hu", Kind::Forecast) => ("Lehetőségek", "Kihívások", "Útravaló"),
("hu", _) => ("Erősségek", "Kihívások", "Útravaló"),
(_, Kind::Forecast) => ("Opportunities", "Challenges", "Advice"),
_ => ("Strengths", "Challenges", "Advice"),
};
let mut md =
format!("# {}\n\n_{}_\n\n", content["title"].as_str().unwrap_or(""), content["summary"].as_str().unwrap_or(""));
@@ -354,6 +432,17 @@ mod tests {
assert!(Kind::ALL.iter().all(|k| Kind::parse(k.as_str()) == Some(*k)));
}
#[test]
fn forecast_prompt() {
let p = build(Kind::Forecast, "hu", "SOLAR RETURN", None);
assert_eq!(p.schema_name, "forecast_analysis");
assert!(p.system.contains("Forecast rules") && p.system.contains("szolár") && p.system.contains("tegező"));
assert!(p.user.contains("- timeline:") && p.user.contains("- theme:"));
let keys = p.schema["properties"]["sections"]["required"].as_array().unwrap().len();
assert_eq!(keys, 5);
assert!(!default_system(Kind::Natal, "hu").contains("Forecast rules"));
}
#[test]
fn validate_rejects_placeholder_titles() {
let schema = schema(Kind::Synastry);