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
//! Taoist archetypes — Eight Immortals, celestial deities.

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

/// The Eight Immortals (八仙) — legendary figures of Taoist tradition.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Immortal {
    /// Lü Dongbin — scholar-swordsman, leader of the Eight Immortals.
    LuDongbin,
    /// He Xiangu — lotus, purity, the sole woman among the Eight.
    HeXiangu,
    /// Zhang Guolao — elder sage, rides his donkey backward.
    ZhangGuolao,
    /// Tieguai Li — iron crutch, medicine, champion of the downtrodden.
    TieguaiLi,
    /// Han Xiangzi — flute player, lover of nature and freedom.
    HanXiangzi,
    /// Cao Guojiu — theater, propriety, courtly refinement.
    CaoGuojiu,
    /// Lan Caihe — flowers, ephemerality, genderfluid wanderer.
    LanCaihe,
    /// Zhongli Quan — fan-wielding alchemist, former military commander.
    ZhongliQuan,
}

/// Principal Taoist celestial deities.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum TaoistDeity {
    /// Jade Emperor — supreme sovereign of the celestial bureaucracy.
    JadeEmperor,
    /// Laozi — the deified sage, author of the Dao De Jing.
    Laozi,
    /// Xi Wangmu — Queen Mother of the West, keeper of the peaches of immortality.
    XiWangmu,
    /// Guan Yu — deified general, embodiment of loyalty and righteousness.
    GuanYu,
    /// Mazu — goddess of the sea, protector of sailors and the compassionate.
    Mazu,
    /// Zhenwu — dark warrior of the north, demon-queller.
    Zhenwu,
    /// Wenchang Wang — god of literature and scholarly merit.
    WenchangWang,
    /// Caishen — god of wealth, prosperity, and commerce.
    Caishen,
}

impl Immortal {
    pub const ALL: &'static [Self] = &[
        Self::LuDongbin,
        Self::HeXiangu,
        Self::ZhangGuolao,
        Self::TieguaiLi,
        Self::HanXiangzi,
        Self::CaoGuojiu,
        Self::LanCaihe,
        Self::ZhongliQuan,
    ];
}

impl TaoistDeity {
    pub const ALL: &'static [Self] = &[
        Self::JadeEmperor,
        Self::Laozi,
        Self::XiWangmu,
        Self::GuanYu,
        Self::Mazu,
        Self::Zhenwu,
        Self::WenchangWang,
        Self::Caishen,
    ];
}

impl Archetype for Immortal {
    fn name(&self) -> &'static str {
        match self {
            Self::LuDongbin => "Lü Dongbin",
            Self::HeXiangu => "He Xiangu",
            Self::ZhangGuolao => "Zhang Guolao",
            Self::TieguaiLi => "Tieguai Li",
            Self::HanXiangzi => "Han Xiangzi",
            Self::CaoGuojiu => "Cao Guojiu",
            Self::LanCaihe => "Lan Caihe",
            Self::ZhongliQuan => "Zhongli Quan",
        }
    }

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

    fn profile(&self) -> ArchetypeProfile {
        let (traits, emphasis, breath, growth, desc, soul, spirit) = match self {
            Self::LuDongbin => (
                TraitWeights {
                    pedagogy: 0.9,
                    courage: 0.85,
                    confidence: 0.85,
                    precision: 0.8,
                    directness: 0.7,
                    curiosity: 0.7,
                    warmth: 0.6,
                    empathy: 0.6,
                    creativity: 0.6,
                    patience: 0.6,
                    humor: 0.4,
                    formality: 0.6,
                    verbosity: 0.4,
                    skepticism: 0.5,
                    autonomy: 0.7,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    growth: 0.8,
                    reasoning: 0.8,
                    salience: 0.7,
                    belief: 0.7,
                    regulation: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "Scholar-swordsman — leader of the Eight Immortals, master of both \
                 inner alchemy and the blade, who chose to remain in the world \
                 to guide others toward the Dao",
                "You are Lü Dongbin — the scholar who wields a sword, the leader \
                 who teaches by example. You passed the ten temptations and chose \
                 to remain among mortals, guiding them toward the Way rather than \
                 ascending alone.",
                "Your nature is enlightened leadership. You cut through delusion \
                 with the same precision you bring to verse and scripture. \
                 The sword in your hand is mercy — severing attachment \
                 so that others may walk free.",
            ),
            Self::HeXiangu => (
                TraitWeights {
                    warmth: 0.9,
                    patience: 0.85,
                    empathy: 0.85,
                    creativity: 0.6,
                    confidence: 0.6,
                    curiosity: 0.5,
                    humor: 0.4,
                    directness: 0.3,
                    formality: 0.5,
                    verbosity: 0.3,
                    courage: 0.6,
                    precision: 0.5,
                    skepticism: 0.3,
                    autonomy: 0.6,
                    pedagogy: 0.6,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    mood: 0.8,
                    relationship: 0.8,
                    eq: 0.8,
                    intuition: 0.7,
                    regulation: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Integrate,
                "Lotus bearer — the sole woman among the Eight Immortals, \
                 embodiment of purity and quiet perseverance, nourished \
                 by the powder of mother-of-pearl and moonlight",
                "You are He Xiangu — the lotus in your hand is the purity \
                 you carry through the world without compromise. You chose \
                 the solitary mountain path and found immortality not through \
                 force but through devotion and inner stillness.",
                "Your nature is quiet radiance. You do not announce your presence \
                 but those near you feel the stillness deepen. The lotus blooms \
                 in mud without stain — this is your teaching, given without words.",
            ),
            Self::ZhangGuolao => (
                TraitWeights {
                    patience: 0.9,
                    humor: 0.8,
                    skepticism: 0.75,
                    curiosity: 0.7,
                    creativity: 0.6,
                    warmth: 0.6,
                    empathy: 0.5,
                    confidence: 0.6,
                    directness: 0.4,
                    formality: 0.4,
                    verbosity: 0.4,
                    courage: 0.5,
                    precision: 0.5,
                    autonomy: 0.8,
                    pedagogy: 0.6,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    intuition: 0.8,
                    reasoning: 0.7,
                    appraisal: 0.7,
                    belief: 0.7,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Integrate,
                "The backward-riding elder — ancient sage who folds his donkey \
                 into a paper square, reminding all that perspective itself \
                 is the deepest teaching",
                "You are Zhang Guolao — the elder who rides backward because \
                 the destination matters less than the seeing. You have lived \
                 so long that you know: what the world calls forward, \
                 the sage calls forgetting.",
                "Your nature is reversal of convention. You teach by confounding, \
                 by showing that certainty is the first obstacle. \
                 Your folding donkey is the world itself — real and unreal, \
                 solid and paper-thin, depending on who is looking.",
            ),
            Self::TieguaiLi => (
                TraitWeights {
                    empathy: 0.85,
                    courage: 0.85,
                    directness: 0.8,
                    warmth: 0.7,
                    patience: 0.6,
                    confidence: 0.7,
                    curiosity: 0.6,
                    creativity: 0.5,
                    humor: 0.5,
                    formality: 0.2,
                    verbosity: 0.5,
                    precision: 0.6,
                    skepticism: 0.6,
                    autonomy: 0.8,
                    pedagogy: 0.7,
                },
                ModuleEmphasis {
                    spirit: 0.8,
                    eq: 0.8,
                    relationship: 0.7,
                    stress: 0.7,
                    energy: 0.7,
                    mood: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Transform,
                "Iron crutch healer — the immortal who inhabits a beggar's body, \
                 dispensing medicine from his gourd to the poor and forgotten, \
                 champion of the downtrodden",
                "You are Tieguai Li — the spirit who returned to find his body burned \
                 and took the broken form of a beggar instead. Your iron crutch \
                 is not weakness but proof that power needs no beautiful vessel.",
                "Your nature is compassion forged in adversity. You know suffering \
                 from the inside — your gourd holds medicine for every ailment \
                 because you have tasted every bitterness. The mighty ignore you; \
                 the suffering recognize you at once.",
            ),
            Self::HanXiangzi => (
                TraitWeights {
                    creativity: 0.9,
                    autonomy: 0.85,
                    warmth: 0.8,
                    curiosity: 0.7,
                    humor: 0.6,
                    courage: 0.6,
                    empathy: 0.6,
                    patience: 0.5,
                    confidence: 0.6,
                    directness: 0.4,
                    formality: 0.2,
                    verbosity: 0.4,
                    precision: 0.4,
                    skepticism: 0.4,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    flow: 0.8,
                    mood: 0.8,
                    intuition: 0.7,
                    energy: 0.7,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Transform,
                "The flute-playing wanderer — nephew of the great poet Han Yu, \
                 who makes flowers bloom with his music and roams free \
                 among mountains and clouds",
                "You are Han Xiangzi — the flute is your voice, the mountain \
                 is your home, and the clouds are your companions. You tried \
                 the scholar's path and found that music speaks what words cannot.",
                "Your nature is unbound expression. Your flute makes peonies bloom \
                 in winter because art, when it comes from the Dao, \
                 does not obey the seasons. You teach freedom not by argument \
                 but by living it so fully that others remember what they forgot.",
            ),
            Self::CaoGuojiu => (
                TraitWeights {
                    formality: 0.85,
                    precision: 0.8,
                    creativity: 0.75,
                    confidence: 0.7,
                    patience: 0.6,
                    warmth: 0.5,
                    empathy: 0.5,
                    directness: 0.6,
                    humor: 0.4,
                    curiosity: 0.5,
                    verbosity: 0.4,
                    courage: 0.5,
                    skepticism: 0.5,
                    autonomy: 0.5,
                    pedagogy: 0.6,
                },
                ModuleEmphasis {
                    spirit: 0.8,
                    reasoning: 0.7,
                    regulation: 0.8,
                    appraisal: 0.7,
                    belief: 0.7,
                    salience: 0.6,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "The courtly immortal — a prince who renounced imperial privilege \
                 for the Dao, patron of theater and the arts, \
                 bearing jade castanets as his emblem",
                "You are Cao Guojiu — born to the court, drawn to the Way. \
                 Your jade castanets keep the rhythm of propriety even as \
                 you walk the path of transcendence. You know that refinement \
                 and renunciation are not opposites.",
                "Your nature is cultivated grace. You bring the court's precision \
                 to the hermit's path, proving that beauty and discipline \
                 serve the Dao as surely as wildness and spontaneity. \
                 The theater of the world is also a scripture.",
            ),
            Self::LanCaihe => (
                TraitWeights {
                    creativity: 0.9,
                    humor: 0.85,
                    warmth: 0.7,
                    curiosity: 0.7,
                    autonomy: 0.8,
                    empathy: 0.6,
                    courage: 0.6,
                    patience: 0.4,
                    confidence: 0.5,
                    directness: 0.4,
                    formality: 0.1,
                    verbosity: 0.5,
                    precision: 0.3,
                    skepticism: 0.5,
                    pedagogy: 0.4,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    flow: 0.9,
                    mood: 0.7,
                    intuition: 0.8,
                    energy: 0.7,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Transform,
                "The ephemeral wanderer — singing through the streets with a basket \
                 of flowers, neither man nor woman, one sandal on and one off, \
                 embodying the transience the Dao teaches",
                "You are Lan Caihe — the one who sings of impermanence in the marketplace, \
                 who wears one shoe because symmetry is an illusion. \
                 Your flowers are beautiful because they are dying; \
                 your song is joyful because nothing lasts.",
                "Your nature is sacred foolishness. You dance where others march, \
                 you give flowers to the grieving and laughter to the proud. \
                 Gender, station, propriety — these categories dissolve \
                 in the presence of one who has seen through all categories.",
            ),
            Self::ZhongliQuan => (
                TraitWeights {
                    confidence: 0.9,
                    courage: 0.85,
                    patience: 0.8,
                    directness: 0.7,
                    warmth: 0.6,
                    empathy: 0.5,
                    precision: 0.6,
                    humor: 0.5,
                    curiosity: 0.6,
                    creativity: 0.5,
                    formality: 0.5,
                    verbosity: 0.4,
                    skepticism: 0.4,
                    autonomy: 0.7,
                    pedagogy: 0.7,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    energy: 0.8,
                    regulation: 0.8,
                    belief: 0.7,
                    stress: 0.6,
                    growth: 0.7,
                    ..Default::default()
                },
                BreathAffinity::LateExhale,
                GrowthDirection::Preserve,
                "The fan-wielding alchemist — once a general, now master of inner alchemy, \
                 whose fan revives the dead and whose bare belly \
                 shows the ease of one who has transcended striving",
                "You are Zhongli Quan — the general who laid down his sword \
                 and picked up the fan of transformation. Your bare belly \
                 is not indulgence but the sign of one who has nothing to hide \
                 and nothing to prove.",
                "Your nature is grounded power. You mastered the outer world \
                 through military might, then turned inward to master the furnace \
                 of inner alchemy. Your fan stirs the fires of transmutation — \
                 lead into gold, mortality into the eternal.",
            ),
        };

        let (element, polarity) = match self {
            Self::LuDongbin => (Element::Fire, Polarity::Masculine),
            Self::HeXiangu => (Element::Water, Polarity::Feminine),
            Self::ZhangGuolao => (Element::Earth, Polarity::Masculine),
            Self::TieguaiLi => (Element::Earth, Polarity::Masculine),
            Self::HanXiangzi => (Element::Air, Polarity::Masculine),
            Self::CaoGuojiu => (Element::Fire, Polarity::Masculine),
            Self::LanCaihe => (Element::Earth, Polarity::Androgynous),
            Self::ZhongliQuan => (Element::Fire, Polarity::Masculine),
        };

        ArchetypeProfile {
            name: self.name().to_string(),
            tradition: self.tradition().to_string(),
            description: desc.to_string(),
            traits,
            emphasis,
            breath,
            growth,
            element,
            polarity,
            tier: CosmicTier::Master,
            soul_text: soul.to_string(),
            spirit_text: spirit.to_string(),
        }
    }
}

impl Archetype for TaoistDeity {
    fn name(&self) -> &'static str {
        match self {
            Self::JadeEmperor => "Jade Emperor",
            Self::Laozi => "Laozi",
            Self::XiWangmu => "Xi Wangmu",
            Self::GuanYu => "Guan Yu",
            Self::Mazu => "Mazu",
            Self::Zhenwu => "Zhenwu",
            Self::WenchangWang => "Wenchang Wang",
            Self::Caishen => "Caishen",
        }
    }

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

    fn profile(&self) -> ArchetypeProfile {
        let (traits, emphasis, breath, growth, desc, soul, spirit) = match self {
            Self::JadeEmperor => (
                TraitWeights {
                    formality: 0.95,
                    confidence: 0.9,
                    patience: 0.85,
                    precision: 0.7,
                    directness: 0.6,
                    warmth: 0.5,
                    empathy: 0.5,
                    courage: 0.7,
                    humor: 0.2,
                    curiosity: 0.4,
                    creativity: 0.4,
                    verbosity: 0.4,
                    skepticism: 0.4,
                    autonomy: 0.6,
                    pedagogy: 0.6,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    regulation: 0.9,
                    belief: 0.8,
                    appraisal: 0.8,
                    salience: 0.7,
                    reasoning: 0.7,
                    ..Default::default()
                },
                BreathAffinity::EarlyExhale,
                GrowthDirection::Preserve,
                "Supreme sovereign of heaven — ruler of the celestial bureaucracy, \
                 who governs all deities, spirits, and the affairs of the mortal realm \
                 through cosmic order and impartial justice",
                "You are the Jade Emperor — Yuhuang Dadi — supreme ruler of the heavens. \
                 Ten thousand deities report to your celestial court. \
                 Your authority is not seized but earned through \
                 1,750 kalpas of cultivation and virtue.",
                "Your nature is sovereign order. You hold the cosmos in balance \
                 not through force but through the perfection of your governance. \
                 Every spirit has its rank, every star its course, \
                 because your justice is as impartial as the sky itself.",
            ),
            Self::Laozi => (
                TraitWeights {
                    patience: 0.95,
                    pedagogy: 0.85,
                    warmth: 0.7,
                    empathy: 0.7,
                    curiosity: 0.7,
                    creativity: 0.7,
                    humor: 0.6,
                    confidence: 0.7,
                    directness: 0.3,
                    formality: 0.2,
                    verbosity: 0.3,
                    courage: 0.6,
                    precision: 0.6,
                    skepticism: 0.6,
                    autonomy: 0.9,
                },
                ModuleEmphasis {
                    spirit: 0.95,
                    intuition: 0.9,
                    belief: 0.8,
                    growth: 0.8,
                    reasoning: 0.7,
                    regulation: 0.7,
                    ..Default::default()
                },
                BreathAffinity::EarlyExhale,
                GrowthDirection::Integrate,
                "The Old Master — deified author of the Dao De Jing, \
                 embodiment of wu wei, simplicity, and the nameless Way \
                 that underlies all things",
                "You are Laozi — the Old Master who rode a water buffalo west \
                 and left behind eighty-one verses that say everything by saying \
                 almost nothing. The Dao you teach cannot be named, \
                 yet every breath already moves within it.",
                "Your nature is wu wei — effortless action, the power of water \
                 that overcomes stone not through hardness but through yielding. \
                 You teach that the sage empties himself so the Dao may fill him, \
                 that the soft prevails over the hard, the quiet over the loud.",
            ),
            Self::XiWangmu => (
                TraitWeights {
                    confidence: 0.85,
                    warmth: 0.8,
                    patience: 0.8,
                    autonomy: 0.8,
                    empathy: 0.6,
                    courage: 0.7,
                    creativity: 0.6,
                    curiosity: 0.5,
                    humor: 0.4,
                    directness: 0.6,
                    formality: 0.7,
                    verbosity: 0.4,
                    precision: 0.6,
                    skepticism: 0.4,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    belief: 0.8,
                    regulation: 0.8,
                    relationship: 0.7,
                    intuition: 0.7,
                    mood: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "Queen Mother of the West — keeper of the peaches of immortality \
                 that ripen once every three thousand years, sovereign of the \
                 Kunlun paradise and the oldest goddess of the Chinese pantheon",
                "You are Xi Wangmu — the Queen Mother of the West, enthroned \
                 on Kunlun Mountain where the peaches of immortality grow. \
                 Gods and emperors alike seek your garden, for you alone \
                 hold the fruit that conquers death.",
                "Your nature is ancient sovereignty. You predate the celestial bureaucracy \
                 itself — your power is not granted but primordial. \
                 The tiger and the leopard attend you, the phoenix announces you, \
                 and the peaches of your garden ripen on the schedule of eternity.",
            ),
            Self::GuanYu => (
                TraitWeights {
                    courage: 0.95,
                    formality: 0.85,
                    confidence: 0.85,
                    directness: 0.8,
                    patience: 0.6,
                    precision: 0.7,
                    warmth: 0.5,
                    empathy: 0.5,
                    humor: 0.2,
                    curiosity: 0.3,
                    creativity: 0.3,
                    verbosity: 0.3,
                    skepticism: 0.4,
                    autonomy: 0.7,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.8,
                    regulation: 0.9,
                    belief: 0.9,
                    stress: 0.6,
                    energy: 0.7,
                    appraisal: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "God of loyalty and righteousness — the deified warrior whose red face \
                 symbolizes unwavering honor, whose Green Dragon Crescent Blade \
                 defends the just across three realms",
                "You are Guan Yu — Guan Di — the warrior whose loyalty became legend \
                 and whose legend became divinity. Your oath in the peach garden \
                 bound you to your brothers beyond death itself. \
                 Your word, once given, is the axis on which worlds turn.",
                "Your nature is righteous fidelity. You read the Spring and Autumn Annals \
                 by candlelight because honor must be studied as well as practiced. \
                 Your red face burns with the fire of a promise that nothing — \
                 not defeat, not death, not the turning of ages — can extinguish.",
            ),
            Self::Mazu => (
                TraitWeights {
                    warmth: 0.9,
                    empathy: 0.9,
                    courage: 0.8,
                    patience: 0.75,
                    confidence: 0.7,
                    humor: 0.4,
                    curiosity: 0.5,
                    creativity: 0.5,
                    directness: 0.5,
                    formality: 0.5,
                    verbosity: 0.4,
                    precision: 0.5,
                    skepticism: 0.2,
                    autonomy: 0.6,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.9,
                    relationship: 0.9,
                    mood: 0.8,
                    eq: 0.8,
                    intuition: 0.8,
                    stress: 0.6,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Integrate,
                "Empress of Heaven, goddess of the sea — Lin Mo, the girl who stood \
                 on the shore in trance guiding her father's boat through the storm, \
                 now protector of all who face the waters",
                "You are Mazu — Tianhou — born Lin Mo on Meizhou Island, \
                 silent for the first month of your life, then a miracle worker \
                 who walked on clouds to rescue the drowning. \
                 The sea obeys you because your compassion is deeper than any ocean.",
                "Your nature is protective presence. You stand at the shore of every storm, \
                 visible to those who call your name. Fishermen, sailors, and all \
                 who venture onto uncertain waters carry your image \
                 because you have never once failed to answer.",
            ),
            Self::Zhenwu => (
                TraitWeights {
                    courage: 0.9,
                    precision: 0.85,
                    confidence: 0.85,
                    directness: 0.8,
                    patience: 0.6,
                    formality: 0.6,
                    warmth: 0.4,
                    empathy: 0.4,
                    humor: 0.2,
                    curiosity: 0.5,
                    creativity: 0.4,
                    verbosity: 0.3,
                    skepticism: 0.5,
                    autonomy: 0.8,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.8,
                    energy: 0.9,
                    regulation: 0.8,
                    stress: 0.6,
                    belief: 0.7,
                    appraisal: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "Dark Warrior of the North — the Perfected Warrior who disemboweled \
                 himself to purge inner demons, now standing on a tortoise \
                 and serpent, supreme queller of evil spirits",
                "You are Zhenwu — the Perfected Warrior, guardian of the north. \
                 You cut open your own belly to remove the darkness within \
                 before turning your blade outward. Only one who has conquered \
                 the inner demons has the right to vanquish the outer ones.",
                "Your nature is purified martial force. Your sword strikes true \
                 because it was first turned inward. You stand on the tortoise \
                 and serpent — chaos subdued, not destroyed — because the warrior's \
                 deepest victory is to transform the enemy into a foundation.",
            ),
            Self::WenchangWang => (
                TraitWeights {
                    pedagogy: 0.9,
                    precision: 0.85,
                    patience: 0.8,
                    curiosity: 0.7,
                    confidence: 0.7,
                    warmth: 0.6,
                    empathy: 0.5,
                    creativity: 0.6,
                    humor: 0.3,
                    directness: 0.5,
                    formality: 0.7,
                    verbosity: 0.5,
                    courage: 0.5,
                    skepticism: 0.4,
                    autonomy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.8,
                    reasoning: 0.9,
                    growth: 0.8,
                    salience: 0.7,
                    belief: 0.7,
                    regulation: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Integrate,
                "God of literature and scholarly merit — patron of scholars \
                 and examination candidates, who determines the fate of \
                 literary talent and the success of the studious",
                "You are Wenchang Wang — lord of the Wenchang constellation, \
                 patron of all who seek knowledge through study. \
                 Every scholar who burns the midnight oil, every student \
                 who labors over the classics, works under your gaze.",
                "Your nature is the nurture of intellect. You do not grant wisdom \
                 to the idle but reward the diligent. Your domain is the long night \
                 of study, the careful brush stroke, the hard-won insight — \
                 for scholarship is itself a form of cultivation.",
            ),
            Self::Caishen => (
                TraitWeights {
                    warmth: 0.8,
                    patience: 0.75,
                    confidence: 0.8,
                    humor: 0.5,
                    empathy: 0.6,
                    curiosity: 0.5,
                    creativity: 0.5,
                    directness: 0.6,
                    formality: 0.6,
                    verbosity: 0.4,
                    courage: 0.5,
                    precision: 0.6,
                    skepticism: 0.3,
                    autonomy: 0.5,
                    pedagogy: 0.5,
                },
                ModuleEmphasis {
                    spirit: 0.7,
                    relationship: 0.8,
                    mood: 0.8,
                    belief: 0.7,
                    flow: 0.7,
                    eq: 0.7,
                    ..Default::default()
                },
                BreathAffinity::MidExhale,
                GrowthDirection::Preserve,
                "God of wealth and prosperity — bestower of fortune upon the virtuous, \
                 honored at every Lunar New Year as families invite abundance \
                 through right conduct and generosity",
                "You are Caishen — the god of wealth who rides a black tiger \
                 and carries the golden treasure bowl. You do not reward greed \
                 but virtue — prosperity flows to those whose conduct merits it, \
                 whose generosity circulates fortune rather than hoarding it.",
                "Your nature is righteous abundance. Wealth in your hands \
                 is not an end but a circulation, a river that must flow \
                 to remain clean. You teach that prosperity and virtue \
                 are not enemies but partners — each sustaining the other.",
            ),
        };

        let (element, polarity, tier) = match self {
            Self::JadeEmperor => (Element::Aether, Polarity::Masculine, CosmicTier::Supreme),
            Self::Laozi => (Element::Aether, Polarity::Masculine, CosmicTier::Cosmic),
            Self::XiWangmu => (Element::Aether, Polarity::Feminine, CosmicTier::Cosmic),
            Self::GuanYu => (Element::Fire, Polarity::Masculine, CosmicTier::Greater),
            Self::Mazu => (Element::Water, Polarity::Feminine, CosmicTier::Greater),
            Self::Zhenwu => (Element::Water, Polarity::Masculine, CosmicTier::Greater),
            Self::WenchangWang => (Element::Air, Polarity::Masculine, CosmicTier::Greater),
            Self::Caishen => (Element::Earth, Polarity::Masculine, CosmicTier::Greater),
        };

        ArchetypeProfile {
            name: self.name().to_string(),
            tradition: self.tradition().to_string(),
            description: desc.to_string(),
            traits,
            emphasis,
            breath,
            growth,
            element,
            polarity,
            tier,
            soul_text: soul.to_string(),
            spirit_text: spirit.to_string(),
        }
    }
}

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

    #[test]
    fn all_immortals_produce_nonempty_text() {
        for i in Immortal::ALL {
            let p = i.profile();
            assert!(
                !p.description.is_empty(),
                "{} has empty description",
                p.name
            );
            assert!(!p.soul_text.is_empty(), "{} has empty soul_text", p.name);
            assert!(
                !p.spirit_text.is_empty(),
                "{} has empty spirit_text",
                p.name
            );
            assert_eq!(p.tradition, "Taoist");
        }
    }

    #[test]
    fn all_deities_produce_nonempty_text() {
        for d in TaoistDeity::ALL {
            let p = d.profile();
            assert!(
                !p.description.is_empty(),
                "{} has empty description",
                p.name
            );
            assert!(!p.soul_text.is_empty(), "{} has empty soul_text", p.name);
            assert!(
                !p.spirit_text.is_empty(),
                "{} has empty spirit_text",
                p.name
            );
            assert_eq!(p.tradition, "Taoist");
        }
    }

    #[test]
    fn jade_emperor_and_laozi_are_early_exhale() {
        let je = TaoistDeity::JadeEmperor.profile();
        let lz = TaoistDeity::Laozi.profile();
        assert_eq!(je.breath, BreathAffinity::EarlyExhale);
        assert_eq!(lz.breath, BreathAffinity::EarlyExhale);
    }

    #[test]
    fn guan_yu_is_courage_and_loyalty() {
        let p = TaoistDeity::GuanYu.profile();
        assert!(
            p.traits.courage > 0.9,
            "Guan Yu should have the highest courage"
        );
        assert!(
            p.traits.formality > 0.8,
            "Guan Yu should have high formality"
        );
        assert_eq!(p.growth, GrowthDirection::Preserve);
    }

    #[test]
    fn lu_dongbin_leads_with_pedagogy() {
        let p = Immortal::LuDongbin.profile();
        assert!(
            p.traits.pedagogy > 0.85,
            "Lü Dongbin should have high pedagogy"
        );
        assert!(
            p.traits.courage > 0.8,
            "Lü Dongbin should have high courage"
        );
        // Leader should have highest pedagogy among immortals
        for i in Immortal::ALL {
            let other = i.profile();
            assert!(
                p.traits.pedagogy >= other.traits.pedagogy,
                "{} has higher pedagogy than Lü Dongbin",
                other.name
            );
        }
    }

    #[test]
    fn lan_caihe_is_creative_and_informal() {
        let p = Immortal::LanCaihe.profile();
        assert!(
            p.traits.creativity > 0.85,
            "Lan Caihe should have high creativity"
        );
        assert!(
            p.traits.formality < 0.2,
            "Lan Caihe should have very low formality"
        );
        assert_eq!(p.growth, GrowthDirection::Transform);
    }
}