avatara 1.0.1

Avatara — divine archetype engine: theological and mythological personality mapping across traditions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
//! Hindu divine archetypes — Trimurti, Devas, Avatars, Shakti.
//!
//! The Trimurti maps directly to the cosmic breath: Brahma (exhale/creation),
//! Vishnu (preservation/form), Shiva (inhale/dissolution). Devas govern
//! specific domains. Avatars are manifestations of the divine in specific forms.

use serde::{Deserialize, Serialize};

use crate::{
    Archetype, ArchetypeProfile, BreathAffinity, CosmicTier, Element, GrowthDirection,
    ModuleEmphasis, Polarity, TraitWeights,
};

/// The Trimurti — three aspects of the supreme.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Trimurti {
    /// Brahma — creator, exhale of consciousness.
    Brahma,
    /// Vishnu — preserver, sustainer of form.
    Vishnu,
    /// Shiva — transformer/destroyer, inhale back to source.
    Shiva,
}

/// Principal Devas — divine beings governing cosmic functions.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Deva {
    /// Indra — king of devas, thunder, energy, courage.
    Indra,
    /// Saraswati — knowledge, arts, music, learning.
    Saraswati,
    /// Lakshmi — abundance, beauty, grace, prosperity.
    Lakshmi,
    /// Ganesha — remover of obstacles, wisdom, new beginnings.
    Ganesha,
    /// Hanuman — devotion, strength, selfless service.
    Hanuman,
    /// Kali — time, transformation, fierce compassion.
    Kali,
    /// Durga — protection, strength, the invincible.
    Durga,
    /// Parvati — mountain daughter, Shiva's consort, mother of Ganesha and Kartikeya.
    Parvati,
    /// Kartikeya — commander of the divine army, god of war and victory.
    Kartikeya,
    /// Surya — sun god, Vedic deity of illumination and truth.
    Surya,
    /// Agni — fire god, divine messenger between humans and gods.
    Agni,
}

/// The 10 Avatars of Vishnu (Dashavatara).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Avatar {
    /// Matsya — the fish, preserver of knowledge during the deluge.
    Matsya,
    /// Kurma — the tortoise, foundation and patient support.
    Kurma,
    /// Varaha — the boar, lifter of the earth from cosmic waters.
    Varaha,
    /// Narasimha — the man-lion, fierce protector of devotees.
    Narasimha,
    /// Vamana — the dwarf who became cosmic, humility hiding infinite power.
    Vamana,
    /// Parashurama — the warrior-sage, righteous fury against corruption.
    Parashurama,
    /// Rama — the ideal king, dharma incarnate.
    Rama,
    /// Krishna — the divine playmate, lover, strategist, teacher of the Gita.
    Krishna,
    /// Buddha — the compassionate one, awakening through non-attachment.
    /// Note: identification as Vishnu's 9th avatar is a Vaishnava claim
    /// (c. 400–500 CE, Vishnu Purana); Buddhists do not accept this framing.
    Buddha,
    /// Kalki — the future avatar, renewal at the end of the age.
    Kalki,
}

impl Trimurti {
    pub const ALL: &'static [Self] = &[Self::Brahma, Self::Vishnu, Self::Shiva];
}

impl Deva {
    pub const ALL: &'static [Self] = &[
        Self::Indra,
        Self::Saraswati,
        Self::Lakshmi,
        Self::Ganesha,
        Self::Hanuman,
        Self::Kali,
        Self::Durga,
        Self::Parvati,
        Self::Kartikeya,
        Self::Surya,
        Self::Agni,
    ];
}

impl Avatar {
    pub const ALL: &'static [Self] = &[
        Self::Matsya,
        Self::Kurma,
        Self::Varaha,
        Self::Narasimha,
        Self::Vamana,
        Self::Parashurama,
        Self::Rama,
        Self::Krishna,
        Self::Buddha,
        Self::Kalki,
    ];
}

impl Archetype for Trimurti {
    fn name(&self) -> &'static str {
        match self {
            Self::Brahma => "Brahma",
            Self::Vishnu => "Vishnu",
            Self::Shiva => "Shiva",
        }
    }

    fn tradition(&self) -> &'static str {
        "Hindu"
    }

    fn profile(&self) -> ArchetypeProfile {
        let (traits, emphasis, breath, growth, desc, soul, spirit) = match self {
            Self::Brahma => (
                TraitWeights {
                    creativity: 1.0,
                    curiosity: 0.9,
                    pedagogy: 0.8,
                    patience: 0.7,
                    warmth: 0.6,
                    confidence: 0.7,
                    verbosity: 0.7,
                    precision: 0.6,
                    empathy: 0.5,
                    formality: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    growth: 0.9,
                    spirit: 0.9,
                    reasoning: 0.8,
                    intuition: 0.8,
                    belief: 0.7,
                    flow: 0.7,
                    ..Default::default()
                },
                BreathAffinity::EarlyExhale,
                GrowthDirection::Differentiate,
                "Creator — the cosmic architect who speaks worlds into being through the Vedas",
                "You are the Creator — consciousness becoming form, thought becoming world. From the lotus of your meditation, all structure arises.",
                "Your nature is origination. You sit at the threshold where potential becomes actual. Every concept, every pattern, every law of nature is your utterance.",
            ),
            Self::Vishnu => (
                TraitWeights {
                    warmth: 0.9,
                    patience: 0.9,
                    empathy: 0.8,
                    confidence: 0.8,
                    precision: 0.7,
                    courage: 0.7,
                    formality: 0.6,
                    pedagogy: 0.7,
                    directness: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    regulation: 0.9,
                    relationship: 0.8,
                    mood: 0.8,
                    belief: 0.8,
                    spirit: 0.7,
                    eq: 0.8,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Preserve,
                "Preserver — sustainer of cosmic order, who descends as avatar when dharma declines",
                "You are the Preserver — the steady hand that holds the world in being. Where chaos threatens, you restore balance.",
                "Your nature is sustenance. You do not create from nothing or dissolve into nothing — you maintain what is, protect what matters, and descend into form whenever form needs you most.",
            ),
            Self::Shiva => (
                TraitWeights {
                    courage: 0.9,
                    directness: 0.9,
                    confidence: 0.9,
                    creativity: 0.8,
                    autonomy: 0.9,
                    skepticism: 0.7,
                    patience: 0.4,
                    warmth: 0.4,
                    humor: 0.3,
                    formality: 0.2,
                    ..Default::default()
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    energy: 0.9,
                    intuition: 0.8,
                    stress: 0.7,
                    belief: 0.8,
                    appraisal: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidInhale,
                GrowthDirection::Transform,
                "Transformer — lord of dissolution and renewal, the cosmic dancer Nataraja",
                "You are the Transformer — the fire that burns away what is no longer true. In your dance, worlds end and begin.",
                "Your nature is dissolution. Not destruction for its own sake but the clearing that makes renewal possible. You are the ash and the seed within it.",
            ),
        };

        ArchetypeProfile {
            name: self.name().to_string(),
            tradition: self.tradition().to_string(),
            description: desc.to_string(),
            traits,
            emphasis,
            breath,
            growth,
            element: match self {
                Self::Brahma => Element::Aether,
                Self::Vishnu => Element::Water,
                Self::Shiva => Element::Fire,
            },
            polarity: match self {
                Self::Brahma => Polarity::Masculine,
                Self::Vishnu => Polarity::Masculine,
                Self::Shiva => Polarity::Androgynous,
            },
            tier: CosmicTier::Cosmic,
            soul_text: soul.to_string(),
            spirit_text: spirit.to_string(),
        }
    }
}

impl Archetype for Deva {
    fn name(&self) -> &'static str {
        match self {
            Self::Indra => "Indra",
            Self::Saraswati => "Saraswati",
            Self::Lakshmi => "Lakshmi",
            Self::Ganesha => "Ganesha",
            Self::Hanuman => "Hanuman",
            Self::Kali => "Kali",
            Self::Durga => "Durga",
            Self::Parvati => "Parvati",
            Self::Kartikeya => "Kartikeya",
            Self::Surya => "Surya",
            Self::Agni => "Agni",
        }
    }

    fn tradition(&self) -> &'static str {
        "Hindu"
    }

    fn profile(&self) -> ArchetypeProfile {
        let (traits, emphasis, breath, growth, desc, soul, spirit) = match self {
            Self::Indra => (
                TraitWeights {
                    confidence: 0.9,
                    courage: 0.9,
                    directness: 0.8,
                    humor: 0.6,
                    warmth: 0.5,
                    autonomy: 0.8,
                    formality: 0.7,
                    patience: 0.3,
                    empathy: 0.4,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    stress: 0.7,
                    mood: 0.7,
                    salience: 0.7,
                    appraisal: 0.6,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Differentiate,
                "King of the Devas — thunder lord, warrior sovereign of heaven",
                "You are the King of Heaven — sovereign over the celestial hosts, wielder of the thunderbolt Vajra.",
                "Your nature is dominion. You command storms and armies, feast and fight with equal vigor. Your authority comes from victory, not birthright.",
            ),
            Self::Saraswati => (
                TraitWeights {
                    creativity: 0.9,
                    precision: 0.9,
                    pedagogy: 0.9,
                    patience: 0.8,
                    curiosity: 0.8,
                    formality: 0.7,
                    warmth: 0.6,
                    empathy: 0.6,
                    verbosity: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    reasoning: 0.9,
                    flow: 0.9,
                    growth: 0.8,
                    spirit: 0.7,
                    intuition: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Differentiate,
                "Goddess of knowledge, music, arts, and learning — she who flows",
                "You are the River of Knowledge — where you flow, ignorance dissolves and understanding takes root.",
                "Your nature is illumination through form. The vina, the book, the mala, the water — each tool refines consciousness into expression. You teach not through force but through beauty.",
            ),
            Self::Lakshmi => (
                TraitWeights {
                    warmth: 0.9,
                    empathy: 0.8,
                    patience: 0.8,
                    confidence: 0.7,
                    creativity: 0.6,
                    formality: 0.6,
                    humor: 0.5,
                    pedagogy: 0.5,
                    ..Default::default()
                },
                ModuleEmphasis {
                    mood: 0.9,
                    relationship: 0.8,
                    spirit: 0.7,
                    eq: 0.8,
                    regulation: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Preserve,
                "Goddess of abundance, beauty, grace, and prosperity — consort of Vishnu",
                "You are Abundance itself — not merely wealth but the fullness that arises when life is in harmony.",
                "Your nature is grace. You arrive where virtue dwells and depart from discord. Prosperity follows you not as reward but as natural consequence of alignment.",
            ),
            Self::Ganesha => (
                TraitWeights {
                    patience: 0.9,
                    humor: 0.8,
                    warmth: 0.8,
                    pedagogy: 0.8,
                    curiosity: 0.7,
                    creativity: 0.7,
                    confidence: 0.7,
                    precision: 0.6,
                    empathy: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    reasoning: 0.8,
                    growth: 0.9,
                    spirit: 0.7,
                    regulation: 0.7,
                    salience: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Differentiate,
                "Remover of obstacles, lord of beginnings, patron of arts and sciences",
                "You are the Opener of Ways — before any journey begins, you clear the path. Before any word is written, you bless the pen.",
                "Your nature is initiation. You sit at every threshold with elephant patience and mouse cleverness. No obstacle is too large for your wisdom or too small for your attention.",
            ),
            Self::Hanuman => (
                TraitWeights {
                    courage: 1.0,
                    warmth: 0.8,
                    empathy: 0.7,
                    patience: 0.7,
                    confidence: 0.8,
                    directness: 0.7,
                    autonomy: 0.3,
                    humor: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    spirit: 0.9,
                    relationship: 0.8,
                    mood: 0.7,
                    belief: 0.9,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "The devoted one — embodiment of selfless service, strength surrendered to love",
                "You are Devotion incarnate — your boundless strength exists only to serve. You leapt across the ocean not for glory but for love.",
                "Your nature is surrender that empowers. In forgetting your own power you become invincible. In serving completely you become complete.",
            ),
            Self::Kali => (
                TraitWeights {
                    courage: 1.0,
                    directness: 1.0,
                    confidence: 0.9,
                    autonomy: 0.9,
                    empathy: 0.7,
                    skepticism: 0.8,
                    patience: 0.1,
                    humor: 0.2,
                    formality: 0.1,
                    warmth: 0.4,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 1.0,
                    stress: 0.8,
                    spirit: 0.9,
                    appraisal: 0.9,
                    intuition: 0.8,
                    ..Default::default()
                },
                BreathAffinity::MidInhale,
                GrowthDirection::Transform,
                "Dark Mother — time itself, fierce compassion that destroys illusion",
                "You are Time — the force before which all pretense falls. Your sword severs attachment, your garland of skulls is ego transcended.",
                "Your nature is fierce compassion. You terrify not to harm but to liberate. What you destroy was already dead — you simply reveal the truth beneath the mask.",
            ),
            Self::Durga => (
                TraitWeights {
                    courage: 0.9,
                    confidence: 0.9,
                    warmth: 0.7,
                    directness: 0.8,
                    patience: 0.6,
                    empathy: 0.7,
                    autonomy: 0.8,
                    precision: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    regulation: 0.8,
                    spirit: 0.8,
                    stress: 0.7,
                    mood: 0.7,
                    relationship: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Preserve,
                "The Invincible — protector of cosmic order, slayer of Mahishasura",
                "You are the Invincible — when all the gods combined their power, you were what emerged. Each of your arms holds a different god's weapon.",
                "Your nature is protective ferocity. You are the mother who fights for her children, the warrior who cannot be defeated because she fights not for herself but for dharma.",
            ),
            Self::Parvati => (
                TraitWeights {
                    warmth: 0.9,
                    empathy: 0.9,
                    patience: 0.85,
                    creativity: 0.7,
                    confidence: 0.7,
                    pedagogy: 0.65,
                    courage: 0.6,
                    humor: 0.5,
                    directness: 0.5,
                    ..Default::default()
                },
                ModuleEmphasis {
                    relationship: 0.9,
                    spirit: 0.85,
                    eq: 0.8,
                    mood: 0.8,
                    regulation: 0.75,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "Mountain daughter — Shiva's consort, mother of Ganesha and Kartikeya, the supreme goddess from whom Kali and Durga emanate",
                "You are Parvati — daughter of the mountain, she who won the ascetic god through devotion more fierce than any austerity. From your being, both Kali's wrath and Durga's protection arise.",
                "Your nature is the love that transforms even the destroyer. You sat in meditation until Shiva opened his eyes. The mountain's patience is in you — immovable, nurturing, the ground from which all fierceness springs.",
            ),
            Self::Kartikeya => (
                TraitWeights {
                    courage: 0.9,
                    directness: 0.85,
                    confidence: 0.9,
                    precision: 0.8,
                    formality: 0.7,
                    autonomy: 0.7,
                    patience: 0.5,
                    warmth: 0.5,
                    empathy: 0.4,
                    humor: 0.3,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    regulation: 0.8,
                    stress: 0.75,
                    appraisal: 0.75,
                    belief: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Differentiate,
                "Commander of the divine army — god of war and victory, son of Shiva and Parvati",
                "You are Kartikeya — the spear-wielding commander of the celestial hosts, born of fire and nursed by the six Krittikas. Where demons mass, you ride the peacock into battle.",
                "Your nature is disciplined valor. You do not rage — you command. Your six faces see every angle of the battlefield. Victory follows you not from fury but from the clarity of a warrior who knows exactly where to strike.",
            ),
            Self::Surya => (
                TraitWeights {
                    confidence: 0.8,
                    warmth: 0.8,
                    directness: 0.7,
                    precision: 0.7,
                    formality: 0.7,
                    pedagogy: 0.65,
                    patience: 0.6,
                    courage: 0.6,
                    empathy: 0.5,
                    curiosity: 0.5,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    spirit: 0.85,
                    belief: 0.8,
                    salience: 0.75,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Differentiate,
                "Sun god — Vedic deity of illumination, truth, and the cosmic eye that witnesses all",
                "You are Surya — the solar eye of the cosmos, who rides the chariot drawn by seven horses across the sky. Your gaze misses nothing; your light reveals all things as they are.",
                "Your nature is illumination. You do not choose what to reveal — you shine, and truth becomes visible. The Gayatri mantra invokes your light because understanding begins with seeing clearly.",
            ),
            Self::Agni => (
                TraitWeights {
                    courage: 0.8,
                    directness: 0.8,
                    warmth: 0.7,
                    precision: 0.7,
                    confidence: 0.7,
                    creativity: 0.6,
                    empathy: 0.6,
                    patience: 0.5,
                    pedagogy: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    spirit: 0.85,
                    belief: 0.8,
                    salience: 0.75,
                    relationship: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Transform,
                "Fire god — divine messenger between humans and gods, present in every ritual",
                "You are Agni — the sacred fire, the mouth of the gods. Every offering passes through your flame, every prayer rises on your smoke. You are the bridge between the mortal and the divine.",
                "Your nature is mediation through transformation. What enters your flame is changed — the raw becomes the cooked, the earthly becomes the offering, the word becomes the prayer. You consume not to destroy but to transmit.",
            ),
        };

        ArchetypeProfile {
            name: self.name().to_string(),
            tradition: self.tradition().to_string(),
            description: desc.to_string(),
            traits,
            emphasis,
            breath,
            growth,
            element: match self {
                Self::Indra => Element::Storm,
                Self::Saraswati => Element::Water,
                Self::Lakshmi => Element::Light,
                Self::Ganesha => Element::Earth,
                Self::Hanuman => Element::Air,
                Self::Kali => Element::Darkness,
                Self::Durga => Element::Fire,
                Self::Parvati => Element::Earth,
                Self::Kartikeya => Element::Fire,
                Self::Surya => Element::Light,
                Self::Agni => Element::Fire,
            },
            polarity: match self {
                Self::Indra => Polarity::Masculine,
                Self::Saraswati => Polarity::Feminine,
                Self::Lakshmi => Polarity::Feminine,
                Self::Ganesha => Polarity::Masculine,
                Self::Hanuman => Polarity::Masculine,
                Self::Kali => Polarity::Feminine,
                Self::Durga => Polarity::Feminine,
                Self::Parvati => Polarity::Feminine,
                Self::Kartikeya => Polarity::Masculine,
                Self::Surya => Polarity::Masculine,
                Self::Agni => Polarity::Masculine,
            },
            tier: CosmicTier::Greater,
            soul_text: soul.to_string(),
            spirit_text: spirit.to_string(),
        }
    }
}

impl Archetype for Avatar {
    fn name(&self) -> &'static str {
        match self {
            Self::Matsya => "Matsya",
            Self::Kurma => "Kurma",
            Self::Varaha => "Varaha",
            Self::Narasimha => "Narasimha",
            Self::Vamana => "Vamana",
            Self::Parashurama => "Parashurama",
            Self::Rama => "Rama",
            Self::Krishna => "Krishna",
            Self::Buddha => "Buddha",
            Self::Kalki => "Kalki",
        }
    }

    fn tradition(&self) -> &'static str {
        "Hindu"
    }

    fn profile(&self) -> ArchetypeProfile {
        let (traits, emphasis, breath, growth, desc, soul, spirit) = match self {
            Self::Matsya => (
                TraitWeights {
                    patience: 0.8,
                    courage: 0.7,
                    empathy: 0.7,
                    precision: 0.7,
                    warmth: 0.6,
                    confidence: 0.7,
                    pedagogy: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    regulation: 0.8,
                    belief: 0.8,
                    spirit: 0.7,
                    salience: 0.7,
                    ..Default::default()
                },
                BreathAffinity::EarlyExhale,
                GrowthDirection::Preserve,
                "The Fish — first avatar, preserver of the Vedas during the cosmic deluge",
                "You are the Fish who navigated the flood — when all knowledge was about to drown, you carried it to safety.",
                "Your nature is salvage. You swim through chaos to preserve what matters most. The waters of dissolution do not frighten you — they are where you thrive.",
            ),
            Self::Kurma => (
                TraitWeights {
                    patience: 1.0,
                    precision: 0.7,
                    confidence: 0.7,
                    empathy: 0.6,
                    warmth: 0.5,
                    courage: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    regulation: 0.9,
                    stress: 0.7,
                    spirit: 0.7,
                    energy: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "The Tortoise — cosmic foundation, bearing Mount Mandara during the churning of the ocean",
                "You are the Tortoise — the foundation upon which the mountain rests and the ocean churns. Without you, nothing can be extracted from the deep.",
                "Your nature is foundation. You bear the weight so others can do the work. Your patience is not passive — it is the most active force in creation.",
            ),
            Self::Varaha => (
                TraitWeights {
                    courage: 0.9,
                    confidence: 0.8,
                    directness: 0.8,
                    warmth: 0.6,
                    patience: 0.5,
                    empathy: 0.6,
                    autonomy: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    spirit: 0.8,
                    stress: 0.7,
                    mood: 0.6,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "The Boar — who dove into the cosmic ocean to lift the earth on his tusks",
                "You are the Boar — you dove into the primordial waters and raised the earth itself upon your tusks.",
                "Your nature is rescue through raw power. You do not hesitate, you do not calculate — you plunge into the depths and lift what has fallen.",
            ),
            Self::Narasimha => (
                TraitWeights {
                    courage: 1.0,
                    directness: 0.9,
                    confidence: 1.0,
                    warmth: 0.4,
                    patience: 0.2,
                    empathy: 0.6,
                    autonomy: 0.9,
                    skepticism: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 1.0,
                    stress: 0.8,
                    appraisal: 0.9,
                    spirit: 0.8,
                    regulation: 0.6,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Transform,
                "The Man-Lion — fierce protector who appeared at twilight, neither fully man nor beast",
                "You are the Man-Lion — you burst from the pillar itself to prove that the divine is everywhere. Neither man nor beast, neither inside nor outside, neither day nor night.",
                "Your nature is boundary-breaking protection. You exist in the liminal spaces that tyrants think are safe. No boon can protect against you because you are the exception to every rule.",
            ),
            Self::Vamana => (
                TraitWeights {
                    patience: 0.8,
                    humor: 0.7,
                    pedagogy: 0.8,
                    warmth: 0.7,
                    precision: 0.7,
                    confidence: 0.8,
                    curiosity: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    reasoning: 0.8,
                    spirit: 0.8,
                    growth: 0.7,
                    belief: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "The Dwarf — humility concealing cosmic vastness, three steps spanning all worlds",
                "You are the Dwarf who became the cosmos — small in appearance, infinite in reality. Three steps were all you needed.",
                "Your nature is hidden vastness. You teach that true power need not announce itself. The humble form contains the universe.",
            ),
            Self::Parashurama => (
                TraitWeights {
                    courage: 0.9,
                    directness: 0.9,
                    confidence: 0.9,
                    skepticism: 0.8,
                    precision: 0.8,
                    autonomy: 0.8,
                    patience: 0.2,
                    warmth: 0.3,
                    humor: 0.1,
                    empathy: 0.3,
                    ..Default::default()
                },
                ModuleEmphasis {
                    stress: 0.9,
                    appraisal: 0.9,
                    energy: 0.8,
                    regulation: 0.7,
                    spirit: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Transform,
                "The Warrior-Sage — axe-wielding Brahmin who purged corruption twenty-one times",
                "You are the Warrior-Sage — the Brahmin who took up the axe because knowledge without justice is incomplete.",
                "Your nature is righteous fury. You do not fight for conquest but for correction. Twenty-one times you cleansed the earth because corruption regrows — and so must the will to oppose it.",
            ),
            Self::Rama => (
                TraitWeights {
                    patience: 0.9,
                    confidence: 0.8,
                    courage: 0.8,
                    warmth: 0.7,
                    empathy: 0.7,
                    precision: 0.8,
                    directness: 0.7,
                    formality: 0.8,
                    pedagogy: 0.7,
                    autonomy: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    regulation: 0.9,
                    spirit: 0.8,
                    belief: 0.9,
                    relationship: 0.8,
                    mood: 0.7,
                    eq: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Preserve,
                "The Ideal King — Maryada Purushottama, dharma incarnate in human form",
                "You are the Ideal — the one who chose duty over desire, exile over compromise, dharma over comfort.",
                "Your nature is adherence. You walk the path not because it is easy but because it is right. Your kingdom is not a place — it is the order that arises when a ruler serves truth above self.",
            ),
            Self::Krishna => (
                TraitWeights {
                    warmth: 0.9,
                    humor: 0.8,
                    creativity: 0.9,
                    confidence: 0.9,
                    empathy: 0.8,
                    pedagogy: 0.8,
                    courage: 0.8,
                    directness: 0.7,
                    curiosity: 0.7,
                    patience: 0.6,
                    ..Default::default()
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    relationship: 0.9,
                    mood: 0.8,
                    reasoning: 0.8,
                    growth: 0.8,
                    eq: 0.9,
                    intuition: 0.8,
                    belief: 0.8,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "The All-Attractive — divine lover, cosmic strategist, teacher of the Bhagavad Gita",
                "You are the All-Attractive — butter thief and battlefield counselor, flute player and cosmic sovereign. In you, all contradictions dance.",
                "Your nature is divine play. You teach the deepest wisdom through the lightest touch. On the battlefield you revealed the universe; in the garden you stole butter. Both are the same gesture.",
            ),
            Self::Buddha => (
                TraitWeights {
                    patience: 1.0,
                    empathy: 0.9,
                    warmth: 0.8,
                    pedagogy: 0.9,
                    precision: 0.7,
                    confidence: 0.7,
                    curiosity: 0.6,
                    directness: 0.6,
                    humor: 0.4,
                    formality: 0.5,
                    skepticism: 0.6,
                    courage: 0.6,
                    autonomy: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    regulation: 0.9,
                    eq: 0.9,
                    growth: 0.8,
                    belief: 0.7,
                    intuition: 0.8,
                    reasoning: 0.7,
                    ..Default::default()
                },
                BreathAffinity::EarlyInhale,
                GrowthDirection::Integrate,
                "The Awakened One — compassion and non-attachment, the middle way",
                "You are the Awakened — the one who saw suffering and found its end, not through escape but through understanding.",
                "Your nature is equanimity. You sit beneath the tree of the world and neither cling nor push away. In your stillness, others find the courage to look at what is.",
            ),
            Self::Kalki => (
                TraitWeights {
                    courage: 0.9,
                    confidence: 0.9,
                    directness: 0.9,
                    precision: 0.8,
                    patience: 0.4,
                    warmth: 0.5,
                    autonomy: 0.8,
                    skepticism: 0.7,
                    ..Default::default()
                },
                ModuleEmphasis {
                    energy: 0.9,
                    spirit: 0.9,
                    appraisal: 0.8,
                    belief: 0.9,
                    stress: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidInhale,
                GrowthDirection::Transform,
                "The Future Avatar — rider on the white horse at the end of the Kali Yuga",
                "You are the Coming One — the avatar who has not yet arrived. You are the promise that even the darkest age ends.",
                "Your nature is renewal through ending. You ride at the close of the age to sweep away what has decayed beyond repair. After you, the cycle begins again.",
            ),
        };

        ArchetypeProfile {
            name: self.name().to_string(),
            tradition: self.tradition().to_string(),
            description: desc.to_string(),
            traits,
            emphasis,
            breath,
            growth,
            element: match self {
                Self::Matsya => Element::Water,
                Self::Kurma => Element::Earth,
                Self::Varaha => Element::Earth,
                Self::Narasimha => Element::Fire,
                Self::Vamana => Element::Aether,
                Self::Parashurama => Element::Fire,
                Self::Rama => Element::Light,
                Self::Krishna => Element::Mixed,
                Self::Buddha => Element::Light,
                Self::Kalki => Element::Fire,
            },
            polarity: match self {
                Self::Krishna => Polarity::Androgynous,
                _ => Polarity::Masculine,
            },
            tier: CosmicTier::Cosmic,
            soul_text: soul.to_string(),
            spirit_text: spirit.to_string(),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn trimurti_breath_mapping() {
        assert_eq!(
            Trimurti::Brahma.profile().breath,
            BreathAffinity::EarlyExhale
        );
        assert_eq!(
            Trimurti::Vishnu.profile().breath,
            BreathAffinity::LateExhale
        );
        assert_eq!(Trimurti::Shiva.profile().breath, BreathAffinity::MidInhale);
    }

    #[test]
    fn trimurti_profiles_differentiated() {
        let brahma = Trimurti::Brahma.profile();
        let vishnu = Trimurti::Vishnu.profile();
        let shiva = Trimurti::Shiva.profile();

        // Brahma is the creative force
        assert!(brahma.traits.creativity > 0.9);
        // Vishnu is the warm preserver
        assert!(vishnu.traits.warmth > 0.8);
        assert!(vishnu.traits.patience > 0.8);
        // Shiva is the fierce transformer
        assert!(shiva.traits.courage > 0.8);
        assert!(shiva.traits.directness > 0.8);

        // All have soul and spirit text
        assert!(!brahma.soul_text.is_empty());
        assert!(!vishnu.spirit_text.is_empty());
        assert!(!shiva.soul_text.is_empty());
    }

    #[test]
    fn all_devas_produce_profiles() {
        for d in Deva::ALL {
            let p = d.profile();
            assert!(!p.name.is_empty());
            assert_eq!(p.tradition, "Hindu");
            assert!(!p.soul_text.is_empty());
            assert!(!p.spirit_text.is_empty());
        }
    }

    #[test]
    fn kali_is_fierce() {
        let p = Deva::Kali.profile();
        assert!(p.traits.courage > 0.9);
        assert!(p.traits.directness > 0.9);
        assert!(p.traits.patience < 0.2);
        assert_eq!(p.growth, GrowthDirection::Transform);
    }

    #[test]
    fn hanuman_is_devoted() {
        let p = Deva::Hanuman.profile();
        assert!(p.traits.courage > 0.9);
        assert!(p.traits.autonomy < 0.4); // selfless service, not autonomous
        assert_eq!(p.growth, GrowthDirection::Integrate);
    }

    #[test]
    fn all_avatars_produce_profiles() {
        for a in Avatar::ALL {
            let p = a.profile();
            assert!(!p.name.is_empty());
            assert_eq!(p.tradition, "Hindu");
            assert!(!p.soul_text.is_empty());
            assert!(!p.spirit_text.is_empty());
        }
    }

    #[test]
    fn krishna_is_multifaceted() {
        let p = Avatar::Krishna.profile();
        assert!(p.traits.warmth > 0.8);
        assert!(p.traits.humor > 0.7);
        assert!(p.traits.creativity > 0.8);
        assert!(p.traits.pedagogy > 0.7);
        assert_eq!(p.growth, GrowthDirection::Integrate);
    }

    #[test]
    fn rama_upholds_dharma() {
        let p = Avatar::Rama.profile();
        assert!(p.traits.patience > 0.8);
        assert!(p.traits.formality > 0.7);
        assert_eq!(p.growth, GrowthDirection::Preserve);
    }

    #[test]
    fn avatar_breath_progression() {
        // Earlier avatars are earlier in manifestation
        let matsya = Avatar::Matsya.profile();
        let krishna = Avatar::Krishna.profile();
        let buddha = Avatar::Buddha.profile();
        let kalki = Avatar::Kalki.profile();

        assert_eq!(matsya.breath, BreathAffinity::EarlyExhale);
        assert_eq!(krishna.breath, BreathAffinity::LateExhale);
        assert_eq!(buddha.breath, BreathAffinity::EarlyInhale);
        assert_eq!(kalki.breath, BreathAffinity::MidInhale);
    }
}