trigram.go raw
1 package oracle
2
3 import "git.mleku.dev/mleku/dendrite/pkg/state"
4
5 // DomainType classifies the information environment (outer trigram).
6 // This determines what kind of source the organism should emphasize.
7 type DomainType uint8
8
9 const (
10 DomainEmpirical DomainType = iota // Earth (000): data, measurements, benchmarks
11 DomainEmerging // Thunder (001): new discoveries, recent commits
12 DomainCritiques // Water (010): failure modes, edge cases, bugs
13 DomainApplications // Lake (011): examples, tests, working code
14 DomainVisualization // Fire (100): diagrams, architecture, intuition
15 DomainFoundations // Heaven (101): axioms, first principles, theory
16 DomainMethodology // Wind (110): techniques, algorithms, how-to
17 DomainCanon // Mountain (111): textbooks, proofs, standards
18 )
19
20 // IntentionType classifies the understanding gap (inner trigram).
21 // This determines what kind of understanding the organism needs.
22 type IntentionType uint8
23
24 const (
25 IntentEmpirical IntentionType = iota // Earth: need evidence/grounding
26 IntentEmerging // Thunder: need awareness of new work
27 IntentCritiques // Water: need to understand failures
28 IntentApplications // Lake: need practical experience
29 IntentVisualization // Fire: need intuitive grasp
30 IntentFoundations // Heaven: need axiomatic understanding
31 IntentMethodology // Wind: need technique/process
32 IntentCanon // Mountain: need established knowledge
33 )
34
35 // EngagementStyle is the ADSR-modulated depth of engagement with data.
36 type EngagementStyle uint8
37
38 const (
39 StyleBroad EngagementStyle = iota // Attack: many results, shallow, orientation
40 StyleTargeted // Decay: specific gap-filling, fewer, deeper
41 StyleReference // Sustain: occasional lookups, integration
42 StyleSynthesis // Release: cross-domain connections, meta-level
43 )
44
45 // TrigramToDomain maps an outer trigram to a domain type.
46 func TrigramToDomain(t state.Trigram) DomainType {
47 switch t {
48 case state.Earth:
49 return DomainEmpirical
50 case state.Thunder:
51 return DomainEmerging
52 case state.Water:
53 return DomainCritiques
54 case state.Lake:
55 return DomainApplications
56 case state.Fire:
57 return DomainVisualization
58 case state.Heaven:
59 return DomainFoundations
60 case state.Wind:
61 return DomainMethodology
62 case state.Mountain:
63 return DomainCanon
64 default:
65 return DomainEmpirical
66 }
67 }
68
69 // TrigramToIntention maps an inner trigram to an intention type.
70 func TrigramToIntention(t state.Trigram) IntentionType {
71 switch t {
72 case state.Earth:
73 return IntentEmpirical
74 case state.Thunder:
75 return IntentEmerging
76 case state.Water:
77 return IntentCritiques
78 case state.Lake:
79 return IntentApplications
80 case state.Fire:
81 return IntentVisualization
82 case state.Heaven:
83 return IntentFoundations
84 case state.Wind:
85 return IntentMethodology
86 case state.Mountain:
87 return IntentCanon
88 default:
89 return IntentEmpirical
90 }
91 }
92
93 // DomainKeywords returns search/focus keywords for a domain type.
94 func DomainKeywords(d DomainType) []string {
95 switch d {
96 case DomainEmpirical:
97 return []string{"data", "empirical", "measurements", "benchmarks", "results"}
98 case DomainEmerging:
99 return []string{"preprint", "new", "emerging", "recent", "2026"}
100 case DomainCritiques:
101 return []string{"critique", "failure", "edge case", "limitation", "bug"}
102 case DomainApplications:
103 return []string{"example", "application", "tutorial", "playground", "test"}
104 case DomainVisualization:
105 return []string{"diagram", "visualization", "intuition", "geometric", "visual"}
106 case DomainFoundations:
107 return []string{"axioms", "first principles", "foundations", "theory"}
108 case DomainMethodology:
109 return []string{"how to", "technique", "method", "algorithm", "implementation"}
110 case DomainCanon:
111 return []string{"textbook", "established", "canonical", "proof", "standard"}
112 default:
113 return nil
114 }
115 }
116
117 // IntentionPrefix returns the query prefix expressing what understanding is needed.
118 func IntentionPrefix(i IntentionType) string {
119 switch i {
120 case IntentEmpirical:
121 return "What empirical evidence exists for"
122 case IntentEmerging:
123 return "What recent developments exist in"
124 case IntentCritiques:
125 return "What are the failure modes and critiques of"
126 case IntentApplications:
127 return "What are practical examples and applications of"
128 case IntentVisualization:
129 return "How can one visualize or intuitively understand"
130 case IntentFoundations:
131 return "What are the foundational principles of"
132 case IntentMethodology:
133 return "How does one implement or apply"
134 case IntentCanon:
135 return "What is the established canonical knowledge about"
136 default:
137 return "What is"
138 }
139 }
140
141 // ADSRToStyle maps an ADSR phase (0-3) to an engagement style.
142 func ADSRToStyle(phase uint8) EngagementStyle {
143 if phase > 3 {
144 return StyleBroad
145 }
146 return EngagementStyle(phase)
147 }
148
149 // ChangingBitFocus returns the dimension-specific focus string for a
150 // changing line's bit position. isInner distinguishes inner (understanding)
151 // from outer (source) trigram lines.
152 func ChangingBitFocus(bit int, isInner bool) string {
153 context := "understanding of"
154 if !isInner {
155 context = "sources about"
156 }
157 switch bit {
158 case 0: // bonding
159 return "How the accretion/dissolution balance shifts in " + context
160 case 1: // constraint
161 return "What structural constraints are being revised in " + context
162 case 2: // energy
163 return "What is expanding or contracting in scope of " + context
164 default:
165 return "What is changing in " + context
166 }
167 }
168