JAIMINI_BACKEND_STANDARD - TheDaniel166/moira GitHub Wiki
Jaimini Backend Standard
Subsystem: moira/jaimini.py
Computational Domain: Jaimini Chara Karakas
Constitutional Phase: 11 โ Architecture Freeze and Validation Codex
Status: Constitutional
Part I โ Architecture Standard
ยง1. Computational Definitions
ยง1.1 Chara Karaka
A Chara Karaka (Sanskrit: variable significator) is a Jaimini technique in which the seven classical planets (and optionally Rahu) are ranked by the degree each planet occupies within its sidereal sign. The planet holding the highest degree is assigned the Atmakaraka role (soul significator). Successive planets take successive roles down to the Darakaraka (spouse significator).
The authoritative engine is jaimini_karakas(sidereal_longitudes, scheme). It accepts
a dict of planet name โ sidereal longitude and an optional JaiminiPolicy, and returns
a JaiminiKarakaResult containing the full ranked assignment.
The karaka pool:
| Scheme | Planets |
|---|---|
| 7-karaka | Sun, Moon, Mars, Mercury, Jupiter, Venus, Saturn |
| 8-karaka | Sun, Moon, Mars, Mercury, Jupiter, Venus, Saturn, Rahu |
Ketu is never included in either scheme.
Karaka roles โ 7-karaka scheme (KARAKA_NAMES_7):
| Rank | Role | Abbreviation | Signification |
|---|---|---|---|
| 1 | Atmakaraka | AK | Soul |
| 2 | Amatyakaraka | AmK | Career / minister |
| 3 | Bhratrikaraka | BK | Siblings |
| 4 | Matrikaraka | MaK | Mother |
| 5 | Pitrikaraka | PiK | Father |
| 6 | Gnatikaraka | GK | Community / disputes |
| 7 | Darakaraka | DK | Spouse |
Karaka roles โ 8-karaka scheme (KARAKA_NAMES_8):
Ranks 1โ5 are identical to the 7-karaka scheme. Then:
| Rank | Role | Abbreviation | Signification |
|---|---|---|---|
| 6 | Putrakaraka | PuK | Children |
| 7 | Gnatikaraka | GK | Community / disputes |
| 8 | Darakaraka | DK | Spouse |
Effective degree:
Each planet's sort key is its degree within its sidereal sign, computed as
sidereal_longitude % 30. Rahu is an exception: because Rahu moves retrograde, its
effective degree is inverted: 30 โ (sidereal_longitude % 30). This inversion is
stored in KarakaAssignment.is_rahu_inverted.
Tiebreaker:
When two planets occupy exactly the same effective degree, the tie is flagged in
JaiminiKarakaResult.tie_warnings as a (planet_A, planet_B) pair. A deterministic
tiebreaker is applied (pool-index ordering) so the output is always a complete ranked
sequence. The result is indeterminate in the astronomical sense; the tie_warnings
flag preserves that fact.
Planet types (KarakaPlanetType):
| Value | Planets |
|---|---|
LUMINARY |
Sun, Moon |
INNER |
Mercury, Venus, Mars |
OUTER |
Jupiter, Saturn |
NODE |
Rahu (8-scheme only) |
Planet type is a structural classification based on astronomical category. It is not a dignity or condition assessment.
ยง2. Layer Structure
The Jaimini subsystem is organized into ten layers, each building on the prior according to the constitutional dependency graph.
| Layer | Phase | Vessel / Function |
|---|---|---|
| 0 | Core | jaimini_karakas() |
| 1 | Truth Preservation | KarakaAssignment, JaiminiKarakaResult |
| 2 | Classification | KarakaRole, KarakaPlanetType |
| 3 | Inspectability | by_planet(), by_karaka(), darakaraka, has_ties |
| 4 | Policy | JaiminiPolicy, scheme parameter |
| 5โ6 | (Relational) | Not applicable at this domain scale |
| 7 | Integrated Local Condition | KarakaConditionProfile, karaka_condition_profile() |
| 8 | Aggregate Intelligence | JaiminiChartProfile, jaimini_chart_profile() |
| 9 | Network Intelligence | KarakaPair, karaka_pair() |
| 10 | Hardening | validate_jaimini_output() |
Note: Phases 5โ6 (Relational Formalization and Relational Hardening) do not apply to the Jaimini domain at its current scale. The subsystem has no temporal structure or containment relationship that requires relational vessels.
ยง3. Delegated Assumptions
The Jaimini subsystem does not compute the following. Callers are responsible for supplying correct values.
- Sidereal conversion: all input longitudes must already be sidereal. Ayanamsa
application is the caller's responsibility (see
moira.sidereal). - Nodal selection: the caller is responsible for providing Rahu's longitude (not Ketu's) for 8-scheme computation. Ketu is ignored even if supplied.
- Planet identification: planet names must match the canonical pool strings
exactly (
'Sun','Moon','Mars','Mercury','Jupiter','Venus','Saturn','Rahu').
ยง4. Doctrine Surface
The doctrinal choices made by the Jaimini subsystem are explicit and located.
| Choice | Location | Default |
|---|---|---|
| Karaka pool โ 7-scheme | _POOL_7 module constant |
Sun, Moon, Mars, Mercury, Jupiter, Venus, Saturn |
| Karaka pool โ 8-scheme | _POOL_8 module constant |
_POOL_7 + Rahu |
| Karaka role names | KARAKA_NAMES_7, KARAKA_NAMES_8 module constants |
Canonical per Jaimini Sutras |
| Rahu degree inversion | _effective_degree() internal function |
30 โ (lon % 30) |
| Tiebreaker | jaimini_karakas() sort key |
Pool-index ordering (deterministic) |
| Scheme selection | JaiminiPolicy.scheme or scheme arg |
7 |
| Ayanamsa acknowledgement | JaiminiPolicy.ayanamsa_system field |
'Lahiri' (informational only) |
ยง5. Public Vessels
The following are the constitutional public vessels of the Jaimini subsystem.
Classification constants:
KarakaRoleโ string constants for the eight karaka role namesKarakaPlanetTypeโ structural category constants: LUMINARY, INNER, OUTER, NODE
Policy:
JaiminiPolicyโ frozen dataclass encoding scheme and ayanamsa acknowledgement
Name tables:
KARAKA_NAMES_7โ ordered list of karaka role names for the 7-schemeKARAKA_NAMES_8โ ordered list of karaka role names for the 8-scheme
Truth-preservation vessels:
KarakaAssignmentโ immutable vessel for one planet's karaka role assignmentJaiminiKarakaResultโ immutable vessel for the complete ranked computation
Condition vessels:
KarakaConditionProfileโ integrated local condition for oneKarakaAssignment
Aggregate vessels:
JaiminiChartProfileโ chart-wide aggregate over a fullJaiminiKarakaResult
Network vessels:
KarakaPairโ structural edge connecting two karaka roles
Computational functions:
jaimini_karakas(sidereal_longitudes, scheme, policy)โ core Chara Karaka engineatmakaraka(sidereal_longitudes, scheme)โ convenience accessor for the AK planetkaraka_condition_profile(assignment, scheme)โ build a condition profilejaimini_chart_profile(result)โ build a chart-wide aggregate profilekaraka_pair(result, role_a, role_b)โ build a network pair from two named rolesvalidate_jaimini_output(result)โ invariant guard for aJaiminiKarakaResult
Part II โ Terminology Standard
ยง6. Required Terms
The following terms carry specific meanings within this subsystem and must not be used loosely.
| Term | Normative Meaning |
|---|---|
| Chara Karaka | One of the seven (or eight) variable significators computed by Jaimini's degree-rank method |
| Atmakaraka | The planet with the highest effective degree in its sign; the soul significator; karaka_rank == 1 |
| Darakaraka | The planet with the lowest effective degree; the spouse significator; karaka_rank == scheme |
| effective degree | The sort key for a planet: lon % 30 for most planets; 30 โ (lon % 30) for Rahu |
| scheme | The integer 7 or 8 selecting which planet pool and role table to use |
| degree inversion | Rahu's exclusive transformation โ its effective degree is 30 โ actual_degree because it moves retrograde |
| tie | A pair of planets with exactly equal effective degrees; flagged in tie_warnings |
| tiebreaker | The deterministic pool-index ordering applied when two planets share an effective degree |
| planet type | The KarakaPlanetType structural category of a planet (LUMINARY / INNER / OUTER / NODE) |
| karaka rank | The 1-based integer position in the ranked sequence (1 = AK, scheme value = DK) |
| karaka role | The string role name assigned to a rank (e.g. 'Atmakaraka', 'Darakaraka') |
| condition profile | A flat doctrinal summary of one KarakaAssignment, integrating rank and type |
| chart profile | A chart-wide aggregate across all karaka assignments in a JaiminiKarakaResult |
| karaka pair | A KarakaPair; a structural edge between any two named karaka roles |
ยง7. Forbidden Conflations
The following pairs must not be equated.
KarakaAssignment and KarakaConditionProfile
KarakaAssignment is the raw truth-preservation vessel from the engine. A
KarakaConditionProfile is a derived doctrinal summary augmenting it with typed
classification. One is the source; the other is a projection.
degree_in_sign and zodiacal longitude
degree_in_sign is the effective sort key (inverted for Rahu). The actual sidereal
longitude within the sign is sidereal_longitude % 30. These differ for Rahu.
karaka_rank and karaka_name
karaka_rank is an integer (1โ8). karaka_name is a string role label. They are
correlated but must not be treated as interchangeable. Use KarakaRole constants
to reference a role by name; use karaka_rank for numeric comparisons.
sidereal_longitude and degree_in_sign
sidereal_longitude is the full sidereal position in [0, 360). degree_in_sign is
the effective degree within the sign used for sorting, in [0, 30] (30.0 possible for
Rahu at exactly 0ยฐ in sign).
tie_warnings and indeterminism
A non-empty tie_warnings signals an astronomically improbable but technically valid
degenerate case. It does not mean the output is invalid โ a complete ranked sequence
is always returned.
scheme and pool size
scheme is the integer 7 or 8 and also the expected length of assignments. The
scheme value is the length of the pool and also controls which role names are used.
They are derived from the same integer but represent different things.
JaiminiChartProfile and JaiminiKarakaResult
JaiminiKarakaResult is the primary truth-preservation vessel from the engine.
JaiminiChartProfile is a derived aggregate summary. One is the source; the other
is a projection for downstream doctrinal use.
KarakaPair and JaiminiChartProfile
KarakaPair is a two-node network edge between two specific roles. JaiminiChartProfile
is a chart-wide summary across all seven or eight roles. One is local and relational;
the other is global.
Part III โ Invariant Register
ยง8.1 Vessel Invariants
KarakaAssignment:
karaka_rankโ [1, 8]planetis a non-empty stringdegree_in_signโ [0.0, 30.0] (closed interval โ 30.0 is permitted for Rahu at 0ยฐ in sign)sidereal_longitudeโ [0.0, 360.0) (half-open โ 360.0 is forbidden)
JaiminiKarakaResult:
schemeโ {7, 8}len(assignments) == schemeassignments[i].karaka_rank == i + 1for all i (consecutive from 1)- All planet names in
assignmentsare distinct atmakaraka == assignments[0].planet
KarakaConditionProfile:
karaka_rankโ [1, 8]planet_typeis a validKarakaPlanetTypevalueis_atmakarakaisTrueif and only ifkaraka_rank == 1is_darakarakaisTrueif and only ifkaraka_rank == scheme
JaiminiChartProfile:
schemeโ {7, 8}len(profiles) == schemehas_ties == Trueif and only iftie_count >= 1has_ties == Falseif and only iftie_count == 0
KarakaPair:
planet_a != planet_binvolves_nodeisTrueif and only if eithertype_aortype_bisNODEboth_are_nodesisTrueif and only if bothtype_aandtype_bareNODEboth_are_nodesimpliesinvolves_node
ยง8.2 Truth Invariants
KARAKA_NAMES_7andKARAKA_NAMES_8are immutable. No function modifies or overrides them at runtime._POOL_7and_POOL_8are immutable tuples. Pool membership defines which planets are valid in a given scheme.KarakaAssignment.sidereal_longitudealways stores the original pre-inversion longitude normalised to [0, 360), even for Rahu.KarakaAssignment.degree_in_signalways stores the effective sort key (inverted for Rahu, un-inverted for all others).- Ketu is never present in any assignment, even if supplied in the input dict.
ยง8.3 Aggregate Invariants
JaiminiChartProfile:
atmakaraka_planetequalsprofiles[0].planetdarakaraka_planetequalsprofiles[-1].planethas_node_atmakarakaisTrueif and only ifprofiles[0].planet_type == KarakaPlanetType.NODEhas_node_darakarakaisTrueif and only ifprofiles[-1].planet_type == KarakaPlanetType.NODE- All planet names across
profilesare distinct
ยง8.4 Network Invariants
KarakaPair:
both_are_nodesimpliesinvolves_node;involves_nodedoes not implyboth_are_nodeskaraka_pair()raisesValueErrorif either role name is absent from the result (e.g. requestingPutrakarakafrom a 7-scheme result)
Part IV โ Failure Doctrine
ยง9.1 Invalid Inputs
- Passing
schemeoutside {7, 8} tojaimini_karakas()raisesValueError. - Constructing
JaiminiPolicywithschemeoutside {7, 8} raisesValueError. - Requesting an 8-scheme computation without
'Rahu'insidereal_longitudesraisesKeyError. - Requesting any scheme without all required pool planets raises
KeyError. - Constructing
KarakaAssignmentwithkaraka_rankoutside [1, 8] raisesValueError. - Constructing
KarakaAssignmentwith an emptyplanetstring raisesValueError. - Constructing
KarakaAssignmentwithdegree_in_signoutside [0.0, 30.0] raisesValueError. - Constructing
KarakaAssignmentwithsidereal_longitudeoutside [0.0, 360.0) raisesValueError. - Constructing
KarakaPairwith the same planet in both roles raisesValueError. - Constructing
KarakaPairwithinvolves_nodeinconsistent with the supplied planet types raisesValueError. - Calling
karaka_pair()with a role name absent from the result raisesValueError.
ยง9.2 Search Exhaustion
This subsystem does not perform iterative search. All computation is a single sort over at most 8 values. There is no search exhaustion failure mode.
ยง9.3 Invariant Failure
validate_jaimini_output()raisesValueErrorwith a descriptive message if:schemeis not 7 or 8len(assignments)does not equalscheme- Any
karaka_rankis not in consecutive order beginning at 1 - Any
karaka_namedoes not match the canonical name list at its index - Any planet name is not in the pool for the scheme
- Any planet name appears more than once
atmakarakadoes not equalassignments[0].planet- Any
tie_warningsentry references a self-pair or a planet outside the pool
JaiminiKarakaResult.__post_init__raisesValueErroron construction if scheme, assignment count, rank sequence, planet uniqueness, or atmakaraka-field consistency are violated.JaiminiChartProfile.__post_init__raisesValueErroron construction if scheme, profile count, or has_ties/tie_count consistency are violated.
Part V โ Determinism Standard
ยง10. Determinism Guarantees
jaimini_karakas()is fully deterministic: given the samesidereal_longitudesdict andscheme, the output is identical in every call with no dependency on external state.- When two planets share exactly the same effective degree (a tie), the tiebreaker is pool-index ordering. This is stable: the same pair of tied planets will always resolve in the same order.
karaka_condition_profile(),jaimini_chart_profile(),karaka_pair(), andvalidate_jaimini_output()are pure functions with no side effects.- Import-time side effects: none. The module initialises only module-level constants.
- No ephemeris access, database access, or external state is required at any point. The computation is a single in-memory sort over at most 8 values.
Part VI โ Validation Codex
ยง11. Minimum Validation Commands
The following command must pass without error on any constitutionally correct installation of this subsystem:
python -m pytest tests/unit/test_jaimini.py -v
All tests in test_jaimini.py must pass. The test suite validates:
KARAKA_NAMES_7andKARAKA_NAMES_8structure and no-duplicate invariantsjaimini_karakas()7-scheme: rank order, atmakaraka, karaka name assignment, degree_in_sign computation, is_rahu_inverted, no spurious tie_warningsjaimini_karakas()8-scheme: Rahu inclusion, 8-karaka names, Ketu exclusion- Rahu degree inversion: effective degree and sidereal_longitude storage
atmakaraka()convenience function correctness- Tie detection: same-degree produces tie_warnings; distinct degrees do not
- Error handling: invalid scheme raises, missing planet raises, extra keys ignored
JaiminiKarakaResultandKarakaAssignmentfrozen/slot constraintsKarakaRoleandKarakaPlanetTypeclassification constantsJaiminiPolicyconstruction, scheme validation, policy override injaimini_karakas()JaiminiKarakaResultinspectability:by_planet(),by_karaka(),darakaraka,has_tiesKarakaAssignment.__post_init__guard behavior for all guard conditionsJaiminiKarakaResult.__post_init__guard behavior: bad scheme, wrong count, duplicate planet, atmakaraka mismatch, out-of-sequence rankkaraka_condition_profile(): is_atmakaraka, is_darakaraka, planet_type, is_rahu_inverted flagsjaimini_chart_profile(): scheme, atmakaraka_planet, darakaraka_planet, profile count, has_node_atmakaraka, has_ties, tie_countJaiminiChartProfile.__post_init__guard behavior: has_ties/tie_count consistencykaraka_pair(): role correctness, planet correctness, involves_node, both_are_nodesKarakaPair.__post_init__guard behavior: same-planet, inconsistent involves_nodevalidate_jaimini_output(): valid result accepted, wrong karaka_name detected, planet outside pool detected, self-pair tie_warning detected
ยง12. Required Validation Themes
Any validation suite for this subsystem must demonstrate the following:
- Rank monotonicity โ for a set of distinct planetary degrees, the ranked sequence is in strictly descending order of effective degree.
- Rahu inversion correctness โ Rahu at a known longitude produces the expected
inverted effective degree;
sidereal_longitudestores the pre-inversion value. - Rahu boundary case โ Rahu at exactly 0ยฐ in sign (degree_in_sign = 30.0) is accepted without error.
- Scheme isolation โ a 7-scheme computation never includes Rahu; an 8-scheme computation always includes Rahu; Ketu is never included in either.
- Tiebreaker determinism โ two calls with identical tied inputs produce identical ranked sequences.
- Policy override โ
JaiminiPolicy.schemeoverrides theschemepositional argument. - Guard completeness โ every field-level invariant on
KarakaAssignmentandJaiminiKarakaResultis covered by at least one rejection test. - Condition profile fidelity โ
karaka_condition_profile()setsis_atmakarakaonly for rank 1 andis_darakarakaonly for the last rank of the scheme. - Aggregate consistency โ
jaimini_chart_profile()has_ties and tie_count are consistent with the source result's tie_warnings. - Network integrity โ
karaka_pair()raises for an absent role;KarakaPairraiseswhenplanet_a == planet_bor wheninvolves_nodeis inconsistent with the supplied planet types.