Varga Engine — High-Level Design
Status: Draft for review · Part of: Astro Composer · Updated: 2026-10-24
The varga engine maps one sidereal D1 (natal chart) longitude into each of the sixteen Shodasavarga signs, then builds the varga frame from the same mapping. It is pure arithmetic over a rulebook table: no binder call, no second position, and no varga computed from another varga.
1. Purpose
Divisional charts (vargas) are the most convention-sensitive layer in the composer.
The variants are real: D10 has at least three starting rules in use, D30 is not divided equally, and D16, D20, D40 and D45 differ between editions. If each screen encodes its own table, one birth yields two D9 charts — both “correct” under some convention — and the difference stays invisible.
The varga engine exists so that:
- every varga is one total, deterministic mapping from a D1 longitude to a sign;
- the variant scheme is a named rulebook entry, not a code branch;
- the varga lagna (rising sign) and the varga bodies come from the same mapping function;
- a response states which rulebook produced it, so two charts compare honestly.
2. Where it sits
chart core · D1 frame (lagna, longitudes, sign ids) ──┐
├──▶ varga engine ──▶ varga charts
rulebook · varga tables (parts, start rules) ─────────┘
- Upstream: chart core supplies the D1 lagna, each body’s full longitude and its binder sign id. The facade supplies the requested varga ids and one rulebook handle.
- Downstream: the facade assembles the varga layer into
POST /v1/charts; later varga-based strength readers consume the same signs. - Never: no binder call, no D1 sign recomputation, no chaining one varga into another, no dasha, panchang or interpretation from a varga.
Input contract
| Input | Source | Used for |
|---|---|---|
| D1 body longitudes | Chart core, from binder positions | Part index inside the 30° sign |
| D1 sign ids | Chart core, from binder positions | Table base and vargottama comparison |
| D1 lagna longitude and sign | Chart core frame | Varga lagna through the same mapping |
| Requested varga ids | Request and profile | Which charts to produce, in what order |
| Varga tables | Rulebook handle | Parts, starting rule, D30 spans, variant scheme |
| Zodiac | Profile | Sidereal guard for the classical tables |
Output contract
| Output | Shape | Read by |
|---|---|---|
vargas[id].lagna |
Varga lagna sign | Response, house placement inside the varga |
vargas[id].bodies[] |
Body, varga sign, part index | Response, varga strength later |
vargas[id].houses[] |
Whole-sign house rosters in the varga | Response, later varga readers |
vargottama |
D9 sign equals D1 sign, per body | Response, strength and interpretation inputs |
unsupported |
Requested varga ids the profile cannot serve | Facade error or degraded layer |
3. Responsibilities
| Area | Owns | Deterministic rule |
|---|---|---|
| Varga selection | D1 plus the requested divisional charts | D1 is read from chart core, never rebuilt |
| Part index | Position inside the 30° sign | Equal parts except D30; half-open intervals |
| Sign mapping | Part index to a varga sign | Rulebook start rule and direction; one lookup |
| Varga frame | The lagna’s varga sign and its houses | The same mapping function used for bodies |
| Vargottama | D1 sign equals D9 sign | Derived from the two mapped signs; never overridden |
| Table integrity | Parts and signs cover the sign exactly | Checked when the rulebook loads, not per request |
| Output | Requested charts only, canonical order | Sign ids and part index; no fabricated degree |
4. Architecture
Diagram: reference design, not deployed behaviour.
The engine has no orchestration of its own. It is a mapping service with one rule: the same function turns a planet’s longitude and the lagna’s longitude into a varga sign. Otherwise one frame could mix two conventions.
5. Rules
- From D1 only. A varga is never computed from another varga. Chaining divisions compounds rounding and yields charts no published table matches.
- One mapping function. Bodies, the lagna and later points all use the same
longitude → varga signfunction. Varga houses then apply chart core’s whole-sign sign-distance rule to the resulting ids, never a second house rule. - The mapping is total. For every varga, each of the 30° of a sign maps to exactly one part and one sign. A gap, overlap or uncovered degree is a rulebook defect, caught at load.
- Half-open parts. A longitude exactly on a part boundary belongs to the next part; exactly 30° is the next sign. No epsilon fudge hides a boundary.
- No varga degree. A varga response carries a sign id and a part index, never a degree inside the varga sign; that would imply precision the division lacks.
- Starting rules are data. Movable/fixed/dual, odd/even, elemental starts, reversed D2 halves and D30’s unequal spans live in the rulebook. A new scheme is a table row, not a branch.
- D30 is asserted, not assumed. Its spans must sum to 30° and reverse in even signs; the rulebook load fails otherwise.
- Vargottama is derived. “D1 sign equals D9 sign” falls out of the mapping and is reported as a flag. It is never stored as separate data or special-cased.
- Sidereal only. The classical tables are defined on the sidereal zodiac. A tropical profile reports the varga layer unsupported rather than mapping tropical degrees.
- D1 is passed through. The response’s D1 chart is the chart core chart, not a re-mapped copy, so a varga can never contradict the natal chart.
- Unknown ids fail. An unserved varga id is a validation error, never skipped silently.
- Deterministic order. Varga ids follow natural order (D1, D2 … D60) and bodies follow the chart’s canonical order, so two responses diff byte for byte.
6. Edge cases
| Case | Behaviour |
|---|---|
| Longitude exactly on a part boundary | Next part, per the half-open rule |
| Longitude 29.9999° versus 30.0° | Sign boundary follows chart core’s D1 sign; no local wrap |
| D2 halves | Only Cancer or Leo, reversed in even signs |
| D9 movable, fixed and dual starts | Three rulebook rows; no movable-only shortcut |
| D30 unequal spans | 5/5/8/7/5°, reversed in even signs, asserted at load |
| D10, D16, D20, D40, D45 variants | Named rulebook row; response names the rulebook hash |
| Retrograde body | Varga sign unchanged; motion does not enter the mapping |
| Rahu or Ketu | Mapped like any other point when the profile includes it |
| Varga lagna on a part boundary | Same half-open rule as a body |
| Vargottama in a fixed or dual sign | Derived from the D9 mapping; never forced |
| All sixteen vargas requested | Sixteen bounded passes over the same D1 values |
| No varga layer requested | Engine is not invoked; D1 is chart core’s output alone |
| Rulebook missing a varga row | UNKNOWN_RULEBOOK at load, not an implicit default |
7. Out of scope
- D1 frame, house placement, dignity and combustion (chart core).
- Vimshottari periods and the proportional division used by dashas (dasha engine).
- Varga strength, varga dignity and ashtakavarga scoring (later layers).
- Panchang, transits, matching and muhurta rules.
- Interpretation, remedies and chart drawing.
- Binder access, caching and provenance (facade and binder).
8. Planned code
| Piece | Responsibility |
|---|---|
varga/VargaCatalog |
Canonical ids, names, part counts and order |
varga/VargaTable |
Rulebook rows, start rules and load-time integrity checks |
varga/PartIndexer |
Equal and unequal subdivision of a sign |
varga/VargaSignMapper |
Part index and rulebook row to a varga sign |
varga/VargaChartBuilder |
Varga lagna, bodies and whole-sign houses |
varga/VargottamaResolver |
D1/D9 sign comparison per body |
varga/VargaSelection |
Requested set, validation and deterministic order |