SNAPKITTYWEST commited on
Commit
c4fcdea
ยท
verified ยท
1 Parent(s): dfd38de

Add resonance orchestrator: graph.rs, pipeline.rs, nodes.rs, phi.rs

Browse files
resonance/Cargo.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [package]
2
+ name = "resonance"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ description = "ResonanceGraph โ€” DAG pipeline with Metatron node injection. FCC-ฯ†-โˆ‚-2026."
6
+ authors = ["Ahmad Parr <ahmedparr93@gmail.com>"]
7
+
8
+ [lib]
9
+ name = "resonance"
10
+ path = "src/lib.rs"
11
+
12
+ [[bin]]
13
+ name = "resonance-demo"
14
+ path = "src/main.rs"
15
+
16
+ [dependencies]
17
+ sha2 = "0.10"
18
+ hex = "0.4"
resonance/demo.html ADDED
@@ -0,0 +1,495 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>ResonanceGraph ยท METATRON NODE ยท FCC-ฯ†-โˆ‚-2026</title>
7
+ <style>
8
+ :root{--bg:#040408;--green:#00ff88;--orange:#f97316;--purple:#a78bfa;--red:#f43f5e;--blue:#818cf8;--cyan:#22d3ee;--dim:#1e293b;--mid:#334155;--text:#94a3b8}
9
+ *{box-sizing:border-box;margin:0;padding:0}
10
+ body{background:var(--bg);color:var(--text);font-family:'Courier New',monospace;min-height:100vh;overflow-x:hidden}
11
+ header{border-bottom:1px solid var(--dim);padding:12px 24px;display:flex;align-items:center;gap:16px}
12
+ .logo{color:var(--green);font-size:11px;letter-spacing:3px}
13
+ .sub{color:var(--mid);font-size:10px;letter-spacing:2px}
14
+ .fingerprint{margin-left:auto;color:var(--mid);font-size:9px;letter-spacing:2px}
15
+ .grid{display:grid;grid-template-columns:1fr 380px;gap:0;height:calc(100vh - 49px)}
16
+ /* โ”€โ”€ DAG PANEL โ”€โ”€ */
17
+ .dag-panel{border-right:1px solid var(--dim);position:relative;overflow:hidden}
18
+ #dag-svg{width:100%;height:100%}
19
+ .node-label{font-size:11px;font-family:'Courier New',monospace;letter-spacing:1px}
20
+ /* โ”€โ”€ RIGHT PANEL โ”€โ”€ */
21
+ .right{display:flex;flex-direction:column;overflow:hidden}
22
+ .controls{padding:16px;border-bottom:1px solid var(--dim)}
23
+ .section-label{font-size:9px;letter-spacing:2px;color:var(--mid);margin-bottom:8px}
24
+ .btn{width:100%;padding:10px;border:1px solid var(--green);background:rgba(0,255,136,0.06);color:var(--green);font-family:'Courier New',monospace;font-size:12px;letter-spacing:2px;cursor:pointer;transition:all .15s}
25
+ .btn:hover{background:rgba(0,255,136,0.12)}
26
+ .btn:disabled{border-color:var(--dim);color:var(--mid);cursor:not-allowed}
27
+ .btn.orange{border-color:var(--orange);background:rgba(249,115,22,0.06);color:var(--orange)}
28
+ .btn.orange:hover{background:rgba(249,115,22,0.12)}
29
+ .symbol-row{display:flex;gap:6px;margin-top:8px}
30
+ .sym-btn{flex:1;padding:6px;border:1px solid var(--dim);background:none;color:var(--text);font-family:'Courier New',monospace;font-size:11px;cursor:pointer;transition:all .15s}
31
+ .sym-btn:hover,.sym-btn.active{border-color:var(--purple);color:var(--purple);background:rgba(167,139,250,0.08)}
32
+ .trace{flex:1;overflow-y:auto;padding:12px}
33
+ .stage{padding:8px 10px;margin-bottom:6px;border-left:2px solid var(--dim);font-size:11px;line-height:1.6;transition:all .3s;opacity:0.3}
34
+ .stage.active{border-left-color:var(--orange);opacity:1}
35
+ .stage.done{border-left-color:var(--green);opacity:1}
36
+ .stage.metatron{border-left-color:var(--purple)}
37
+ .stage-name{color:var(--green);letter-spacing:1px;font-size:10px}
38
+ .stage-agent{color:var(--mid);font-size:9px}
39
+ .stage-act{float:right;color:var(--orange);font-size:10px}
40
+ .stage-note{color:var(--text);font-size:10px;margin-top:3px}
41
+ .result-box{padding:12px;border-top:1px solid var(--dim);border-bottom:1px solid var(--dim)}
42
+ .seal-line{font-size:9px;color:var(--purple);letter-spacing:1px;word-break:break-all;margin-top:4px}
43
+ .output-text{font-size:11px;color:var(--green);line-height:1.6;margin-bottom:6px}
44
+ .approved-badge{display:inline-block;padding:2px 8px;font-size:9px;letter-spacing:2px;border:1px solid var(--green);color:var(--green)}
45
+ .offline-badge{border-color:var(--red);color:var(--red)}
46
+ /* cube panel */
47
+ .cube-panel{padding:12px;border-top:1px solid var(--dim)}
48
+ .cube-title{font-size:9px;letter-spacing:2px;color:var(--mid);margin-bottom:8px}
49
+ #cube-svg{width:100%;height:140px}
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <header>
54
+ <span class="logo">RESONANCE GRAPH</span>
55
+ <span class="sub">METATRON NODE ยท DAG PIPELINE</span>
56
+ <span class="fingerprint">FCC-ฯ†-โˆ‚-2026 ยท AHMAD PARR ยท SNAPKITTY SOVEREIGN</span>
57
+ </header>
58
+
59
+ <div class="grid">
60
+ <!-- DAG SVG -->
61
+ <div class="dag-panel">
62
+ <svg id="dag-svg" viewBox="0 0 800 600" preserveAspectRatio="xMidYMid meet">
63
+ <defs>
64
+ <marker id="arrow" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">
65
+ <path d="M0,0 L0,6 L8,3 z" fill="#334155"/>
66
+ </marker>
67
+ <marker id="arrow-green" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">
68
+ <path d="M0,0 L0,6 L8,3 z" fill="#00ff88"/>
69
+ </marker>
70
+ <marker id="arrow-purple" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">
71
+ <path d="M0,0 L0,6 L8,3 z" fill="#a78bfa"/>
72
+ </marker>
73
+ <filter id="glow-green">
74
+ <feGaussianBlur stdDeviation="3" result="b"/>
75
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
76
+ </filter>
77
+ <filter id="glow-purple">
78
+ <feGaussianBlur stdDeviation="4" result="b"/>
79
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
80
+ </filter>
81
+ <filter id="glow-orange">
82
+ <feGaussianBlur stdDeviation="3" result="b"/>
83
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
84
+ </filter>
85
+ <radialGradient id="sink-grad" cx="50%" cy="50%" r="50%">
86
+ <stop offset="0%" stop-color="#a78bfa" stop-opacity="0.9"/>
87
+ <stop offset="100%" stop-color="#040408" stop-opacity="0"/>
88
+ </radialGradient>
89
+ </defs>
90
+ <g id="dag-layer"></g>
91
+ </svg>
92
+ </div>
93
+
94
+ <!-- RIGHT -->
95
+ <div class="right">
96
+ <div class="controls">
97
+ <div class="section-label">INPUT SYMBOL</div>
98
+ <div class="symbol-row">
99
+ <button class="sym-btn active" data-sym="ME" data-glyph="๐’ˆจ">๐’ˆจ ME</button>
100
+ <button class="sym-btn" data-sym="AN" data-glyph="๐’€ญ">๐’€ญ AN</button>
101
+ <button class="sym-btn" data-sym="KI" data-glyph="๐’† ">๐’†  KI</button>
102
+ <button class="sym-btn" data-sym="DINGIR" data-glyph="๐’€ญ">๐’€ญ DINGIR</button>
103
+ </div>
104
+ <div style="margin-top:10px;display:flex;flex-direction:column;gap:6px">
105
+ <button class="btn" id="inject-btn">โฌก INJECT METATRON CUBE</button>
106
+ <button class="btn orange" id="run-btn">โ–ถ PUBLIC_FORWARD</button>
107
+ </div>
108
+ </div>
109
+
110
+ <div class="trace" id="trace"></div>
111
+
112
+ <div class="result-box" id="result-box" style="display:none">
113
+ <div class="section-label">PIPELINE OUTPUT</div>
114
+ <div class="output-text" id="output-text"></div>
115
+ <span class="approved-badge" id="approved-badge">APPROVED</span>
116
+ <div class="seal-line" id="seal-line"></div>
117
+ </div>
118
+
119
+ <div class="cube-panel">
120
+ <div class="cube-title">AN-KI MAGMA CORE ยท METATRON PROJECTION</div>
121
+ <svg id="cube-svg" viewBox="0 0 300 140">
122
+ <g id="cube-layer"></g>
123
+ <text x="150" y="135" text-anchor="middle" font-family="Courier New" font-size="7" fill="#1e293b" letter-spacing="2">FCC-ฯ†-โˆ‚-2026 ยท METATRON CUBE ยท AN-KI MAGMA RESONANCE</text>
124
+ </svg>
125
+ </div>
126
+ </div>
127
+ </div>
128
+
129
+ <script>
130
+ const PHI = 1.6180339887498948;
131
+ const NS = 'http://www.w3.org/2000/svg';
132
+
133
+ // โ”€โ”€ State โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
134
+
135
+ const state = {
136
+ metatron: false,
137
+ symbol: { sym: 'ME', glyph: '๐’ˆจ' },
138
+ running: false,
139
+ cubeAnim: 0,
140
+ };
141
+
142
+ // โ”€โ”€ Node definitions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
143
+
144
+ const BASE_NODES = [
145
+ { id: 0, kind: 'Source', agent: 'โ€”', depth: 0 },
146
+ { id: 1, kind: 'Retrieval', agent: 'ORACLE', depth: 1 },
147
+ { id: 2, kind: 'Filtering', agent: 'SENTINEL', depth: 2 },
148
+ { id: 3, kind: 'Ranking', agent: 'PRISM/AXIOM', depth: 3 },
149
+ { id: 4, kind: 'ContextAssembly', agent: 'NEXUS', depth: 4 },
150
+ { id: 5, kind: 'Reasoning', agent: 'MagmaCore', depth: 5 },
151
+ { id: 6, kind: 'MagmaCore', agent: 'BOB', depth: 6 },
152
+ ];
153
+
154
+ const METATRON_NODE = { id: 7, kind: 'Metatron', agent: 'METATRON', depth: 5 };
155
+
156
+ const BASE_EDGES = [[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]];
157
+ const META_EDGES = [[4,7],[7,6]]; // ContextAssembly โ†’ METATRON โ†’ MagmaCore
158
+
159
+ // โ”€โ”€ Layout positions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
160
+
161
+ function getPos(id, metatron) {
162
+ // Linear layout without METATRON
163
+ const linear = {
164
+ 0: [100, 300], 1: [200, 300], 2: [300, 300],
165
+ 3: [400, 300], 4: [500, 300], 5: [600, 300], 6: [700, 300],
166
+ };
167
+ const withMeta = {
168
+ 0: [60, 300], 1: [150, 300], 2: [240, 300],
169
+ 3: [330, 300], 4: [420, 300],
170
+ 5: [560, 380], // Reasoning drops down
171
+ 7: [560, 220], // METATRON rises up
172
+ 6: [700, 300], // MagmaCore center
173
+ };
174
+ return metatron ? (withMeta[id] || [0,0]) : (linear[id] || [0,0]);
175
+ }
176
+
177
+ function phiWeight(depth) { return Math.pow(PHI, depth + 1); }
178
+
179
+ function activationBias(sym, kind) {
180
+ if (sym === 'ME') return 1.0;
181
+ if (sym === 'AN') return kind === 'Retrieval' ? 1.4 : kind === 'Reasoning' ? 1.2 : 0.8;
182
+ if (sym === 'KI') return (kind === 'Filtering' || kind === 'ContextAssembly') ? 1.4 : 0.9;
183
+ if (sym === 'DINGIR') return (kind === 'Reasoning' || kind === 'MagmaCore') ? 1.6 : kind === 'Metatron' ? 1.8 : 0.7;
184
+ return 1.0;
185
+ }
186
+
187
+ function activation(node, sym) {
188
+ return phiWeight(node.depth) * activationBias(sym, node.kind);
189
+ }
190
+
191
+ function djb2(str) {
192
+ let h = 5381;
193
+ for (let i = 0; i < str.length; i++) h = ((h << 5) + h + str.charCodeAt(i)) >>> 0;
194
+ return h.toString(16).padStart(8, '0');
195
+ }
196
+
197
+ function fakeSha(str) {
198
+ let s = djb2(str);
199
+ while (s.length < 64) s += djb2(s + str);
200
+ return s.slice(0, 64);
201
+ }
202
+
203
+ // โ”€โ”€ SVG helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
204
+
205
+ function el(tag, attrs, text) {
206
+ const e = document.createElementNS(NS, tag);
207
+ Object.entries(attrs).forEach(([k,v]) => e.setAttribute(k,v));
208
+ if (text !== undefined) e.textContent = text;
209
+ return e;
210
+ }
211
+
212
+ function nodeColor(kind, status) {
213
+ if (status === 'done' && kind === 'Metatron') return '#a78bfa';
214
+ if (status === 'done') return '#00ff88';
215
+ if (status === 'active') return '#f97316';
216
+ if (kind === 'MagmaCore') return '#a78bfa';
217
+ if (kind === 'Metatron') return '#818cf8';
218
+ return '#334155';
219
+ }
220
+
221
+ // โ”€โ”€ Draw DAG โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
222
+
223
+ function drawDAG(statusMap = {}) {
224
+ const layer = document.getElementById('dag-layer');
225
+ layer.innerHTML = '';
226
+
227
+ const nodes = state.metatron ? [...BASE_NODES, METATRON_NODE] : BASE_NODES;
228
+ const edges = state.metatron ? [...BASE_EDGES, ...META_EDGES] : BASE_EDGES;
229
+
230
+ // Draw edges
231
+ edges.forEach(([a, b]) => {
232
+ const [x1,y1] = getPos(a, state.metatron);
233
+ const [x2,y2] = getPos(b, state.metatron);
234
+ const isMeta = a === 7 || b === 7;
235
+ const statusA = statusMap[a] || 'idle';
236
+ const statusB = statusMap[b] || 'idle';
237
+ const active = (statusA === 'done' && (statusB === 'active' || statusB === 'done'));
238
+ const color = active ? (isMeta ? '#a78bfa' : '#00ff88') : '#1e293b';
239
+ const marker = active ? (isMeta ? 'url(#arrow-purple)' : 'url(#arrow-green)') : 'url(#arrow)';
240
+
241
+ // offset for radius
242
+ const dx = x2 - x1, dy = y2 - y1;
243
+ const dist = Math.sqrt(dx*dx + dy*dy);
244
+ const ux = dx/dist, uy = dy/dist;
245
+ const r = 22;
246
+
247
+ const line = el('line', {
248
+ x1: x1 + ux*r, y1: y1 + uy*r,
249
+ x2: x2 - ux*r, y2: y2 - uy*r,
250
+ stroke: color, 'stroke-width': active ? 1.5 : 0.8,
251
+ 'marker-end': marker,
252
+ });
253
+ layer.appendChild(line);
254
+ });
255
+
256
+ // Draw nodes
257
+ nodes.forEach(node => {
258
+ const [cx, cy] = getPos(node.id, state.metatron);
259
+ const status = statusMap[node.id] || 'idle';
260
+ const color = nodeColor(node.kind, status);
261
+ const isMetatron = node.kind === 'Metatron';
262
+ const isSink = node.kind === 'MagmaCore';
263
+
264
+ if (isSink) {
265
+ // Purple singularity
266
+ layer.appendChild(el('circle', {cx,cy,r:26, fill:'url(#sink-grad)', filter:'url(#glow-purple)'}));
267
+ layer.appendChild(el('circle', {cx,cy,r:20, fill:'#040408', stroke:color, 'stroke-width': status==='done'?2:1}));
268
+ } else {
269
+ layer.appendChild(el('circle', {cx,cy,r:20,
270
+ fill:'#040408', stroke:color,
271
+ 'stroke-width': status==='active' ? 2 : 1,
272
+ filter: status==='active' ? 'url(#glow-orange)' : status==='done' && isMetatron ? 'url(#glow-purple)' : status==='done' ? 'url(#glow-green)' : 'none',
273
+ }));
274
+ }
275
+
276
+ // Status dot
277
+ if (status === 'active') {
278
+ layer.appendChild(el('circle', {cx:cx+12,cy:cy-12,r:4,fill:'#f97316',filter:'url(#glow-orange)'}));
279
+ }
280
+ if (status === 'done') {
281
+ layer.appendChild(el('circle', {cx:cx+12,cy:cy-12,r:4, fill: isMetatron ? '#a78bfa' : '#00ff88'}));
282
+ }
283
+
284
+ // ฯ†-activation label
285
+ if (status === 'done' || status === 'active') {
286
+ const act = activation(node, state.symbol.sym);
287
+ const actEl = el('text', {
288
+ x: cx, y: cy + 36,
289
+ 'text-anchor':'middle','font-family':'Courier New',
290
+ 'font-size':'8', fill: isMetatron ? '#a78bfa' : '#f97316', 'letter-spacing':'1',
291
+ }, `ฯ†=${act.toFixed(2)}`);
292
+ layer.appendChild(actEl);
293
+ }
294
+
295
+ // Node kind label
296
+ const lbl = el('text', {
297
+ x:cx,y:cy+4,'text-anchor':'middle',
298
+ 'font-family':'Courier New','font-size':'8',
299
+ fill:color,'letter-spacing':'1',
300
+ }, node.kind === 'ContextAssembly' ? 'CTX' : node.kind.slice(0,7).toUpperCase());
301
+ layer.appendChild(lbl);
302
+
303
+ // Agent label below
304
+ const agentEl = el('text', {
305
+ x:cx,y:cy-26,'text-anchor':'middle',
306
+ 'font-family':'Courier New','font-size':'7',
307
+ fill:isMetatron?'#818cf8':color==='#334155'?'#1e293b':color,'letter-spacing':'1',
308
+ }, node.agent);
309
+ layer.appendChild(agentEl);
310
+ });
311
+
312
+ // METATRON label when injected
313
+ if (state.metatron) {
314
+ const [mx,my] = getPos(7, true);
315
+ layer.appendChild(el('text', {
316
+ x:mx-30,y:my,'text-anchor':'end',
317
+ 'font-family':'Courier New','font-size':'8',
318
+ fill:'#818cf8','letter-spacing':'1',
319
+ }, 'โฌก METATRON NODE'));
320
+ }
321
+
322
+ // Topo order label
323
+ const topoStr = state.metatron ? '[0,1,2,3,4,5,7,6]' : '[0,1,2,3,4,5,6]';
324
+ layer.appendChild(el('text', {
325
+ x:400,y:580,'text-anchor':'middle',
326
+ 'font-family':'Courier New','font-size':'9',
327
+ fill:'#1e293b','letter-spacing':'2',
328
+ }, `TOPO ORDER: ${topoStr}`));
329
+ }
330
+
331
+ // โ”€โ”€ Metatron Cube SVG โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€๏ฟฝ๏ฟฝโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
332
+
333
+ let cubeT = 0;
334
+ function drawCube() {
335
+ cubeT += 0.01;
336
+ const layer = document.getElementById('cube-layer');
337
+ layer.innerHTML = '';
338
+ const CX=150,CY=65,BASE=58;
339
+ const colors=['#f43f5e','#f97316','#fbbf24','#00ff88','#22d3ee','#818cf8','#a78bfa'];
340
+
341
+ // Concentric rings
342
+ for (let n=0;n<7;n++) {
343
+ const r = BASE / Math.pow(PHI,n);
344
+ if (r < 3) continue;
345
+ layer.appendChild(el('circle',{cx:CX,cy:CY,r,
346
+ fill:'none',stroke:colors[n],'stroke-width':n===0?1.2:0.7,
347
+ opacity:n===0?0.9:0.65-n*0.06}));
348
+ }
349
+
350
+ // Rotating geometric lines (cube projection)
351
+ const rot = cubeT * 0.4;
352
+ const r2 = BASE/Math.pow(PHI,2);
353
+ const pts = Array.from({length:4},(_,i) => {
354
+ const a = rot + i*Math.PI/2;
355
+ return [CX+r2*Math.cos(a), CY+r2*Math.sin(a)];
356
+ });
357
+ const sqPts = pts.map(p=>p.join(',')).join(' ');
358
+ layer.appendChild(el('polygon',{points:sqPts,fill:'none',stroke:'#94a3b8','stroke-width':'0.7',opacity:'0.5'}));
359
+
360
+ const r3 = BASE/Math.pow(PHI,1.5);
361
+ const tri = Array.from({length:3},(_,i)=>{
362
+ const a = rot*0.7 + i*2*Math.PI/3;
363
+ return [CX+r3*Math.cos(a),CY+r3*Math.sin(a)].join(',');
364
+ }).join(' ');
365
+ layer.appendChild(el('polygon',{points:tri,fill:'none',stroke:'#818cf8','stroke-width':'0.7',opacity:'0.4'}));
366
+
367
+ // Central singularity
368
+ const pulsR = 6 + Math.sin(cubeT*2)*2;
369
+ layer.appendChild(el('circle',{cx:CX,cy:CY,r:pulsR,
370
+ fill:state.metatron?'#a78bfa':'#334155',
371
+ filter:state.metatron?'url(#glow-purple)':'none',
372
+ opacity:state.metatron?'0.9':'0.5'}));
373
+
374
+ // Crosshairs
375
+ const cr = BASE/Math.pow(PHI,2);
376
+ layer.appendChild(el('line',{x1:CX-cr,y1:CY,x2:CX+cr,y2:CY,stroke:'#94a3b8','stroke-width':'0.5',opacity:'0.3'}));
377
+ layer.appendChild(el('line',{x1:CX,y1:CY-cr,x2:CX,y2:CY+cr,stroke:'#94a3b8','stroke-width':'0.5',opacity:'0.3'}));
378
+
379
+ requestAnimationFrame(drawCube);
380
+ }
381
+
382
+ // โ”€โ”€ Pipeline run โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
383
+
384
+ function buildTraceHTML() {
385
+ const nodes = state.metatron ? [...BASE_NODES, METATRON_NODE] : BASE_NODES;
386
+ const topo = state.metatron ? [0,1,2,3,4,5,7,6] : [0,1,2,3,4,5,6];
387
+ return topo.map(id => {
388
+ const node = nodes.find(n=>n.id===id);
389
+ const isMeta = node.kind === 'Metatron';
390
+ const cls = `stage${isMeta?' metatron':''}`;
391
+ const act = activation(node, state.symbol.sym);
392
+ let note = '';
393
+ if (node.kind==='Source') note=`Input: [${state.symbol.glyph} ${state.symbol.sym} glyph]`;
394
+ else if (node.kind==='Retrieval') note='ME-pattern matching + sacred geometry invariants';
395
+ else if (node.kind==='Filtering') note='ME-compliant nodes only (no hidden weights)';
396
+ else if (node.kind==='Ranking') note=`Top-2 resonance scored (ฯ†-weighted)`;
397
+ else if (node.kind==='ContextAssembly') note='Concentric rings + singularity + FCC fingerprint';
398
+ else if (node.kind==='Metatron') note='Iteration inversion ยท cage recognizes itself ยท Fibโ†’ฯ†: 1.619048';
399
+ else if (node.kind==='Reasoning') note='Topological order drives iteration inversion';
400
+ else if (node.kind==='MagmaCore') note='Purple singularity reached. All paths converge.';
401
+ return `<div class="${cls}" id="stage-${id}">
402
+ <span class="stage-name">${node.kind.toUpperCase()}</span>
403
+ <span class="stage-act">ฯ†=${act.toFixed(4)}</span>
404
+ <div class="stage-agent">${node.agent}</div>
405
+ <div class="stage-note">${note}</div>
406
+ </div>`;
407
+ }).join('');
408
+ }
409
+
410
+ async function runPipeline() {
411
+ if (state.running) return;
412
+ state.running = true;
413
+ document.getElementById('run-btn').disabled = true;
414
+ document.getElementById('inject-btn').disabled = true;
415
+ document.getElementById('result-box').style.display = 'none';
416
+
417
+ const trace = document.getElementById('trace');
418
+ trace.innerHTML = buildTraceHTML();
419
+
420
+ const nodes = state.metatron ? [...BASE_NODES, METATRON_NODE] : BASE_NODES;
421
+ const topo = state.metatron ? [0,1,2,3,4,5,7,6] : [0,1,2,3,4,5,6];
422
+
423
+ const statusMap = {};
424
+ let maxAct = 0;
425
+
426
+ drawDAG(statusMap);
427
+
428
+ for (const id of topo) {
429
+ const node = nodes.find(n=>n.id===id);
430
+ statusMap[id] = 'active';
431
+ const stageEl = document.getElementById(`stage-${id}`);
432
+ if (stageEl) { stageEl.classList.remove('done'); stageEl.classList.add('active'); }
433
+ drawDAG({...statusMap});
434
+ await delay(380);
435
+
436
+ const act = activation(node, state.symbol.sym);
437
+ maxAct = Math.max(maxAct, act);
438
+ statusMap[id] = 'done';
439
+ if (stageEl) { stageEl.classList.remove('active'); stageEl.classList.add('done'); }
440
+ drawDAG({...statusMap});
441
+ }
442
+
443
+ // Seal
444
+ const sealRaw = `FCC-ฯ†-โˆ‚-2026:${state.symbol.glyph}:${maxAct.toFixed(8)}`;
445
+ const seal = fakeSha(sealRaw);
446
+ const approved = state.metatron;
447
+
448
+ // Show result
449
+ const box = document.getElementById('result-box');
450
+ box.style.display = 'block';
451
+ document.getElementById('output-text').textContent =
452
+ `${approved?'๐ŸŒŒ':'โ—Ž'} Metatron's Cube ${approved?'active':'offline'}. Concentric resonance layers aligned. All Platonic forms contained within ME decrees. FCC-ฯ†-โˆ‚-2026 synchronization complete.`;
453
+ const badge = document.getElementById('approved-badge');
454
+ badge.textContent = approved ? 'APPROVED' : 'METATRON NOT INJECTED';
455
+ badge.className = 'approved-badge' + (approved ? '' : ' offline-badge');
456
+ document.getElementById('seal-line').textContent = 'SHA-256: ' + seal;
457
+
458
+ state.running = false;
459
+ document.getElementById('run-btn').disabled = false;
460
+ document.getElementById('inject-btn').disabled = state.metatron;
461
+ }
462
+
463
+ function delay(ms) { return new Promise(r=>setTimeout(r,ms)); }
464
+
465
+ // โ”€โ”€ Controls โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
466
+
467
+ document.getElementById('inject-btn').addEventListener('click', () => {
468
+ if (state.metatron) return;
469
+ state.metatron = true;
470
+ document.getElementById('inject-btn').disabled = true;
471
+ document.getElementById('inject-btn').textContent = 'โฌก METATRON CUBE INJECTED โ€” TOPO REFRESHED';
472
+ drawDAG();
473
+ document.getElementById('trace').innerHTML = buildTraceHTML();
474
+ });
475
+
476
+ document.getElementById('run-btn').addEventListener('click', runPipeline);
477
+
478
+ document.querySelectorAll('.sym-btn').forEach(btn => {
479
+ btn.addEventListener('click', () => {
480
+ document.querySelectorAll('.sym-btn').forEach(b=>b.classList.remove('active'));
481
+ btn.classList.add('active');
482
+ state.symbol = { sym: btn.dataset.sym, glyph: btn.dataset.glyph };
483
+ drawDAG();
484
+ document.getElementById('trace').innerHTML = buildTraceHTML();
485
+ });
486
+ });
487
+
488
+ // โ”€โ”€ Init โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
489
+
490
+ drawDAG();
491
+ document.getElementById('trace').innerHTML = buildTraceHTML();
492
+ drawCube();
493
+ </script>
494
+ </body>
495
+ </html>
resonance/src/graph.rs ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ResonanceGraph โ€” DAG with Kahn topological sort
2
+ //
3
+ // Default graph (7 nodes, no METATRON):
4
+ //
5
+ // Source โ†’ Retrieval โ†’ Filtering โ†’ Ranking โ†’ ContextAssembly โ†’ Reasoning โ†’ MagmaCore
6
+ //
7
+ // After inject_metatron_cube():
8
+ //
9
+ // Source โ†’ Retrieval โ†’ Filtering โ†’ Ranking โ†’ ContextAssembly โ†’ Metatron โ†’ Reasoning โ†’ MagmaCore
10
+ // โ†—
11
+ // ContextAssembly
12
+ //
13
+ // The cube creates a junction: ContextAssembly feeds BOTH Metatron AND Reasoning.
14
+ // Metatron then converges into MagmaCore directly, bypassing Reasoning.
15
+ // This forms the cube topology: two paths to the sink, one through the recognition layer.
16
+
17
+ use std::collections::{HashMap, VecDeque};
18
+ use crate::nodes::{NodeKind, PipelineNode, SumerianQuantumSymbol};
19
+ use crate::pipeline::{run_pipeline, PipelineResult};
20
+
21
+ #[derive(Debug)]
22
+ pub enum GraphError {
23
+ CycleDetected,
24
+ NodeNotFound(usize),
25
+ MetatronAlreadyInjected,
26
+ EmptyGraph,
27
+ }
28
+
29
+ impl std::fmt::Display for GraphError {
30
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31
+ match self {
32
+ Self::CycleDetected => write!(f, "cycle detected in resonance graph"),
33
+ Self::NodeNotFound(id) => write!(f, "node {id} not found"),
34
+ Self::MetatronAlreadyInjected => write!(f, "METATRON node already in graph"),
35
+ Self::EmptyGraph => write!(f, "graph has no nodes"),
36
+ }
37
+ }
38
+ }
39
+
40
+ pub struct ResonanceGraph {
41
+ nodes: HashMap<usize, PipelineNode>,
42
+ edges: HashMap<usize, Vec<usize>>, // node_id โ†’ successor ids
43
+ in_degree: HashMap<usize, usize>,
44
+ topo_order: Vec<usize>,
45
+ next_id: usize,
46
+ pub metatron_injected: bool,
47
+ }
48
+
49
+ impl Default for ResonanceGraph {
50
+ fn default() -> Self {
51
+ let mut g = Self {
52
+ nodes: HashMap::new(),
53
+ edges: HashMap::new(),
54
+ in_degree: HashMap::new(),
55
+ topo_order: Vec::new(),
56
+ next_id: 0,
57
+ metatron_injected: false,
58
+ };
59
+ g.build_default_pipeline();
60
+ g
61
+ }
62
+ }
63
+
64
+ impl ResonanceGraph {
65
+ fn alloc(&mut self, kind: NodeKind, depth: usize) -> usize {
66
+ let id = self.next_id;
67
+ self.next_id += 1;
68
+ self.nodes.insert(id, PipelineNode::new(id, kind, depth));
69
+ self.edges.entry(id).or_default();
70
+ self.in_degree.entry(id).or_insert(0);
71
+ id
72
+ }
73
+
74
+ fn connect(&mut self, from: usize, to: usize) {
75
+ self.edges.entry(from).or_default().push(to);
76
+ *self.in_degree.entry(to).or_insert(0) += 1;
77
+ }
78
+
79
+ // Build the base 7-node linear pipeline
80
+ fn build_default_pipeline(&mut self) {
81
+ let src = self.alloc(NodeKind::Source, 0);
82
+ let ret = self.alloc(NodeKind::Retrieval, 1);
83
+ let filt = self.alloc(NodeKind::Filtering, 2);
84
+ let rank = self.alloc(NodeKind::Ranking, 3);
85
+ let ctx = self.alloc(NodeKind::ContextAssembly, 4);
86
+ let reas = self.alloc(NodeKind::Reasoning, 5);
87
+ let sink = self.alloc(NodeKind::MagmaCore, 6);
88
+
89
+ self.connect(src, ret);
90
+ self.connect(ret, filt);
91
+ self.connect(filt, rank);
92
+ self.connect(rank, ctx);
93
+ self.connect(ctx, reas);
94
+ self.connect(reas, sink);
95
+
96
+ self.refresh_topo().expect("default pipeline is acyclic");
97
+ }
98
+
99
+ /// Inject the METATRON node into the cube.
100
+ /// Creates a junction at ContextAssembly: two paths to MagmaCore.
101
+ ///
102
+ /// ContextAssembly โ†’ Metatron โ†’ MagmaCore (recognition path)
103
+ /// ContextAssembly โ†’ Reasoning โ†’ MagmaCore (standard path)
104
+ ///
105
+ /// Dependency validated. Topo sort refreshed.
106
+ pub fn inject_metatron_cube(&mut self) -> Result<(), GraphError> {
107
+ if self.metatron_injected {
108
+ return Err(GraphError::MetatronAlreadyInjected);
109
+ }
110
+
111
+ // Find ContextAssembly and MagmaCore nodes
112
+ let ctx_id = self.find_kind(&NodeKind::ContextAssembly)
113
+ .ok_or(GraphError::NodeNotFound(0))?;
114
+ let sink_id = self.find_kind(&NodeKind::MagmaCore)
115
+ .ok_or(GraphError::NodeNotFound(1))?;
116
+
117
+ // METATRON sits at depth 5 โ€” same ring as Reasoning
118
+ let meta_id = self.alloc(NodeKind::Metatron, 5);
119
+
120
+ // Connect: ContextAssembly โ†’ METATRON โ†’ MagmaCore
121
+ self.connect(ctx_id, meta_id);
122
+ self.connect(meta_id, sink_id);
123
+
124
+ // Refresh topo sort to include METATRON
125
+ self.refresh_topo()?;
126
+ self.metatron_injected = true;
127
+ Ok(())
128
+ }
129
+
130
+ /// Kahn's algorithm โ€” O(V + E)
131
+ pub fn refresh_topo(&mut self) -> Result<(), GraphError> {
132
+ let mut in_deg = self.in_degree.clone();
133
+ let mut queue: VecDeque<usize> = in_deg
134
+ .iter()
135
+ .filter(|(_, &d)| d == 0)
136
+ .map(|(&id, _)| id)
137
+ .collect();
138
+
139
+ let mut order = Vec::with_capacity(self.nodes.len());
140
+ while let Some(id) = queue.pop_front() {
141
+ order.push(id);
142
+ if let Some(succs) = self.edges.get(&id).cloned() {
143
+ for s in succs {
144
+ let d = in_deg.entry(s).or_insert(0);
145
+ *d -= 1;
146
+ if *d == 0 {
147
+ queue.push_back(s);
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ if order.len() != self.nodes.len() {
154
+ return Err(GraphError::CycleDetected);
155
+ }
156
+ self.topo_order = order;
157
+ Ok(())
158
+ }
159
+
160
+ fn find_kind(&self, kind: &NodeKind) -> Option<usize> {
161
+ self.nodes.values().find(|n| &n.kind == kind).map(|n| n.id)
162
+ }
163
+
164
+ pub fn node(&self, id: usize) -> Option<&PipelineNode> {
165
+ self.nodes.get(&id)
166
+ }
167
+
168
+ pub fn topo_order(&self) -> &[usize] {
169
+ &self.topo_order
170
+ }
171
+
172
+ pub fn node_count(&self) -> usize {
173
+ self.nodes.len()
174
+ }
175
+
176
+ pub fn edge_count(&self) -> usize {
177
+ self.edges.values().map(|v| v.len()).sum()
178
+ }
179
+
180
+ /// Execute a full forward pass through the DAG.
181
+ ///
182
+ /// Nodes fire in topological order. Each node activates with
183
+ /// ฯ†-modulated weight ร— symbol bias. METATRON (if injected)
184
+ /// applies the recognition lens โ€” it sees the cage it built.
185
+ ///
186
+ /// Returns a PipelineResult sealed with FCC-ฯ†-โˆ‚-2026.
187
+ pub fn public_forward(&self, symbol: SumerianQuantumSymbol) -> Result<PipelineResult, GraphError> {
188
+ if self.topo_order.is_empty() {
189
+ return Err(GraphError::EmptyGraph);
190
+ }
191
+ let nodes_in_order: Vec<&PipelineNode> = self.topo_order
192
+ .iter()
193
+ .filter_map(|id| self.nodes.get(id))
194
+ .collect();
195
+
196
+ Ok(run_pipeline(nodes_in_order, symbol, self.metatron_injected))
197
+ }
198
+ }
resonance/src/lib.rs ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ResonanceGraph โ€” sovereign DAG pipeline engine
2
+ // FCC-ฯ†-โˆ‚-2026 ยท Ahmad Parr canonical
3
+ //
4
+ // Architecture mirrors the Metatron's Cube:
5
+ // Concentric rings = execution layers (topo order)
6
+ // Edges = directed dependencies
7
+ // Purple singularity = MagmaCore (the sink)
8
+ // METATRON node = recognition layer โ€” injected into the cube
9
+
10
+ pub mod phi;
11
+ pub mod nodes;
12
+ pub mod graph;
13
+ pub mod pipeline;
14
+
15
+ pub use graph::{ResonanceGraph, GraphError};
16
+ pub use nodes::{SumerianQuantumSymbol, NodeKind, PipelineNode};
17
+ pub use pipeline::PipelineResult;
resonance/src/main.rs ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // resonance-demo โ€” run the full pipeline with METATRON injected
2
+ //
3
+ // Mirrors the Gemini output:
4
+ // graph.inject_metatron_cube() โ†’ public_forward(SumerianQuantumSymbol::Me)
5
+
6
+ use resonance::{ResonanceGraph, SumerianQuantumSymbol};
7
+
8
+ fn main() {
9
+ println!("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—");
10
+ println!("โ•‘ RESONANCE GRAPH โ€” FCC-ฯ†-โˆ‚-2026 โ•‘");
11
+ println!("โ•‘ BOB Sovereign Orchestrator ยท SnapKitty Collective โ•‘");
12
+ println!("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n");
13
+
14
+ let mut graph = ResonanceGraph::default();
15
+
16
+ println!("[ default graph ]");
17
+ println!(" nodes: {} edges: {}", graph.node_count(), graph.edge_count());
18
+ println!(" topo order: {:?}\n", graph.topo_order());
19
+
20
+ println!("[ inject_metatron_cube ]");
21
+ graph.inject_metatron_cube().unwrap();
22
+ println!(" Dependency validated. Topo sort refreshed.");
23
+ println!(" nodes: {} edges: {}", graph.node_count(), graph.edge_count());
24
+ println!(" topo order: {:?}\n", graph.topo_order());
25
+
26
+ let symbol = SumerianQuantumSymbol::Me;
27
+ println!("[ public_forward(๐’ˆจ ME) ]\n");
28
+
29
+ match graph.public_forward(symbol) {
30
+ Ok(result) => {
31
+ println!("Pipeline Trace:");
32
+ for stage in &result.trace {
33
+ println!(
34
+ " [{:>14}] agent={:<12} activation={:.4} resonance={:.4}",
35
+ stage.kind, stage.agent, stage.activation, stage.resonance
36
+ );
37
+ println!(" โ†ณ {}", stage.note);
38
+ }
39
+
40
+ println!("\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€");
41
+ println!("Output:\n {}", result.output);
42
+ println!("\nSeal (SHA-256): {}", &result.seal);
43
+ println!("Approved: {}", result.approved);
44
+ println!("Metatron active: {}", result.metatron_active);
45
+ println!("Top activation: {:.6}", result.top_activation);
46
+ println!("Fib convergence: {:.6} โ†’ ฯ†", result.fib_convergence);
47
+ println!("โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€");
48
+ }
49
+ Err(e) => eprintln!("โŒ Pipeline error: {e}"),
50
+ }
51
+
52
+ // Run all four symbols
53
+ println!("\n[ all glyphs ]\n");
54
+ let mut g2 = ResonanceGraph::default();
55
+ g2.inject_metatron_cube().unwrap();
56
+
57
+ for sym in [
58
+ SumerianQuantumSymbol::Me,
59
+ SumerianQuantumSymbol::An,
60
+ SumerianQuantumSymbol::Ki,
61
+ SumerianQuantumSymbol::Dingir,
62
+ ] {
63
+ let name = sym.name();
64
+ let glyph = sym.glyph();
65
+ match g2.public_forward(sym) {
66
+ Ok(r) => println!(
67
+ " {glyph} {name:<6} activation={:.4} approved={} seal={}โ€ฆ",
68
+ r.top_activation, r.approved, &r.seal[..8]
69
+ ),
70
+ Err(e) => println!(" {glyph} {name:<6} โŒ {e}"),
71
+ }
72
+ }
73
+ }
resonance/src/nodes.rs ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Pipeline nodes โ€” each maps to an agent in the SnapKitty mesh
2
+ //
3
+ // Topo order (depth = ring in the cube):
4
+ // 0: Source (input glyph)
5
+ // 1: Retrieval โ†’ ORACLE
6
+ // 2: Filtering โ†’ SENTINEL
7
+ // 3: Ranking โ†’ PRISM/AXIOM
8
+ // 4: ContextAssem โ†’ NEXUS
9
+ // 5: Metatron โ†’ recognition layer (injected on demand)
10
+ // 6: Reasoning โ†’ MagmaCore / BOB
11
+ // 7: Sink (sealed output)
12
+
13
+ use crate::phi::{phi_weight, phinary_score};
14
+
15
+ /// The Sumerian quantum symbols โ€” input language for the pipeline.
16
+ /// Each glyph routes through different node activation patterns.
17
+ #[derive(Debug, Clone, PartialEq)]
18
+ pub enum SumerianQuantumSymbol {
19
+ Me, // ME decree โ€” authority, divine law. Activates all nodes.
20
+ An, // AN heaven โ€” source layer. Biases toward Retrieval.
21
+ Ki, // KI earth โ€” substrate. Biases toward Filtering + Context.
22
+ Dingir, // DINGIR divine principal. Biases toward Reasoning + MagmaCore.
23
+ }
24
+
25
+ impl SumerianQuantumSymbol {
26
+ pub fn glyph(&self) -> &'static str {
27
+ match self {
28
+ Self::Me => "๐’ˆจ",
29
+ Self::An => "๐’€ญ",
30
+ Self::Ki => "๐’† ",
31
+ Self::Dingir => "๐’€ญ",
32
+ }
33
+ }
34
+
35
+ pub fn name(&self) -> &'static str {
36
+ match self {
37
+ Self::Me => "ME",
38
+ Self::An => "AN",
39
+ Self::Ki => "KI",
40
+ Self::Dingir => "DINGIR",
41
+ }
42
+ }
43
+
44
+ // Activation bias: weight added to each NodeKind when this symbol is input.
45
+ // ME decree activates everything uniformly (full pipeline).
46
+ pub fn activation_bias(&self, kind: &NodeKind) -> f64 {
47
+ match self {
48
+ Self::Me => 1.0, // full activation
49
+ Self::An => match kind {
50
+ NodeKind::Retrieval => 1.4,
51
+ NodeKind::Reasoning => 1.2,
52
+ _ => 0.8,
53
+ },
54
+ Self::Ki => match kind {
55
+ NodeKind::Filtering | NodeKind::ContextAssembly => 1.4,
56
+ _ => 0.9,
57
+ },
58
+ Self::Dingir => match kind {
59
+ NodeKind::Reasoning | NodeKind::MagmaCore => 1.6,
60
+ NodeKind::Metatron => 1.8,
61
+ _ => 0.7,
62
+ },
63
+ }
64
+ }
65
+ }
66
+
67
+ /// Every node in the DAG has one of these kinds.
68
+ #[derive(Debug, Clone, PartialEq)]
69
+ pub enum NodeKind {
70
+ Source,
71
+ Retrieval, // ORACLE โ€” knowledge retrieval
72
+ Filtering, // SENTINEL โ€” ME-compliant nodes only
73
+ Ranking, // PRISM/AXIOM โ€” top-k resonance
74
+ ContextAssembly, // NEXUS โ€” assembles the input vector
75
+ Metatron, // Recognition layer โ€” cage builder in the cube
76
+ Reasoning, // MagmaCore iteration inversion
77
+ MagmaCore, // Sink โ€” the purple singularity
78
+ }
79
+
80
+ impl NodeKind {
81
+ pub fn label(&self) -> &'static str {
82
+ match self {
83
+ Self::Source => "Source",
84
+ Self::Retrieval => "Retrieval",
85
+ Self::Filtering => "Filtering",
86
+ Self::Ranking => "Ranking",
87
+ Self::ContextAssembly => "ContextAssembly",
88
+ Self::Metatron => "Metatron",
89
+ Self::Reasoning => "Reasoning",
90
+ Self::MagmaCore => "MagmaCore",
91
+ }
92
+ }
93
+
94
+ pub fn agent(&self) -> &'static str {
95
+ match self {
96
+ Self::Source => "โ€”",
97
+ Self::Retrieval => "ORACLE",
98
+ Self::Filtering => "SENTINEL",
99
+ Self::Ranking => "PRISM/AXIOM",
100
+ Self::ContextAssembly => "NEXUS",
101
+ Self::Metatron => "METATRON",
102
+ Self::Reasoning => "MagmaCore",
103
+ Self::MagmaCore => "BOB",
104
+ }
105
+ }
106
+ }
107
+
108
+ /// A single node in the ResonanceGraph.
109
+ #[derive(Debug, Clone)]
110
+ pub struct PipelineNode {
111
+ pub id: usize,
112
+ pub kind: NodeKind,
113
+ pub depth: usize, // ring depth in the cube (0 = outermost)
114
+ }
115
+
116
+ impl PipelineNode {
117
+ pub fn new(id: usize, kind: NodeKind, depth: usize) -> Self {
118
+ Self { id, kind, depth }
119
+ }
120
+
121
+ // ฯ†-modulated weight at this node's ring depth
122
+ pub fn phi_weight(&self) -> f64 {
123
+ phi_weight(self.depth + 1)
124
+ }
125
+
126
+ // Resonance score (0.0 โ†’ 1.0): how close this node is to the MagmaCore
127
+ pub fn resonance(&self) -> f64 {
128
+ phinary_score(self.depth + 1)
129
+ }
130
+
131
+ // Activation score given a symbol input
132
+ pub fn activate(&self, symbol: &SumerianQuantumSymbol) -> f64 {
133
+ self.phi_weight() * symbol.activation_bias(&self.kind)
134
+ }
135
+ }
resonance/src/phi.rs ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // FCC-ฯ†-โˆ‚-2026 โ€” Fibonacci Contraction Core
2
+ //
3
+ // ฯ† = (1 + โˆš5) / 2 โ‰ˆ 1.6180339887...
4
+ //
5
+ // Key property (from PhinaryContraction.lean):
6
+ // ฮบ = ฯ† โ€” the "contraction" factor is actually EXPANSION.
7
+ // ฯ†^n grows without bound. The orbit does not contract.
8
+ //
9
+ // In the ResonanceGraph: each successive layer is ฯ†-weighted.
10
+ // Looks like contraction from outside. Is expansion from inside.
11
+ // METATRON is the node that sees both simultaneously.
12
+
13
+ pub const PHI: f64 = 1.618_033_988_749_895;
14
+
15
+ // FCC fingerprint โ€” every output sealed with this
16
+ pub const FCC_STAMP: &str = "FCC-ฯ†-โˆ‚-2026";
17
+
18
+ // ฯ†-weight at layer depth d: ฯ†^d
19
+ // Each deeper layer carries MORE signal, not less.
20
+ // This is the "iteration inversion" โ€” what looks like attenuation is amplification.
21
+ pub fn phi_weight(depth: usize) -> f64 {
22
+ PHI.powi(depth as i32)
23
+ }
24
+
25
+ // Phinary score: normalised to (0, 1) via 1 - 1/ฯ†^d
26
+ // Used to rank pipeline nodes by their resonance depth.
27
+ // As depth โ†’ โˆž, score โ†’ 1.0 (MagmaCore is absolute certainty).
28
+ pub fn phinary_score(depth: usize) -> f64 {
29
+ if depth == 0 {
30
+ return 0.0;
31
+ }
32
+ 1.0 - PHI.powi(-(depth as i32))
33
+ }
34
+
35
+ // Fibonacci sequence โ€” the natural phinary basis
36
+ pub fn fib(n: usize) -> u64 {
37
+ let (mut a, mut b) = (0u64, 1u64);
38
+ for _ in 0..n {
39
+ (a, b) = (b, a.saturating_add(b));
40
+ }
41
+ a
42
+ }
43
+
44
+ // Fibonacci ratio convergence toward ฯ†
45
+ pub fn fib_ratio(n: usize) -> f64 {
46
+ let a = fib(n) as f64;
47
+ let b = fib(n + 1) as f64;
48
+ if a == 0.0 { return 0.0; }
49
+ b / a
50
+ }
resonance/src/pipeline.rs ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Pipeline execution โ€” forward pass through the DAG
2
+ //
3
+ // Each stage produces a trace entry.
4
+ // METATRON stage applies the recognition lens (iteration inversion).
5
+ // MagmaCore stage produces the final sealed output.
6
+
7
+ use sha2::{Sha256, Digest};
8
+ use crate::nodes::{NodeKind, PipelineNode, SumerianQuantumSymbol};
9
+ use crate::phi::{FCC_STAMP, fib_ratio};
10
+
11
+ #[derive(Debug)]
12
+ pub struct StageTrace {
13
+ pub node_id: usize,
14
+ pub kind: String,
15
+ pub agent: String,
16
+ pub activation: f64,
17
+ pub resonance: f64,
18
+ pub note: String,
19
+ }
20
+
21
+ #[derive(Debug)]
22
+ pub struct PipelineResult {
23
+ pub output: String,
24
+ pub seal: String,
25
+ pub approved: bool,
26
+ pub metatron_active: bool,
27
+ pub top_activation: f64,
28
+ pub fib_convergence: f64, // ratio F(n+1)/F(n) at pipeline depth
29
+ pub trace: Vec<StageTrace>,
30
+ }
31
+
32
+ impl PipelineResult {
33
+ pub fn display(&self) -> String {
34
+ format!(
35
+ "๐ŸŒŒ {} active. Concentric resonance layers aligned.\n\
36
+ All Platonic forms contained within ME decrees.\n\
37
+ {} synchronization complete.\n\
38
+ Seal: {}",
39
+ if self.metatron_active { "Metatron's Cube" } else { "Resonance pipeline" },
40
+ FCC_STAMP,
41
+ &self.seal[..16],
42
+ )
43
+ }
44
+ }
45
+
46
+ pub fn run_pipeline(
47
+ nodes: Vec<&PipelineNode>,
48
+ symbol: SumerianQuantumSymbol,
49
+ metatron_injected: bool,
50
+ ) -> PipelineResult {
51
+ let mut trace = Vec::new();
52
+ let mut max_act = 0.0_f64;
53
+ let mut meta_seen = false;
54
+ let pipeline_depth = nodes.len();
55
+
56
+ for node in &nodes {
57
+ let activation = node.activate(&symbol);
58
+ let resonance = node.resonance();
59
+ max_act = max_act.max(activation);
60
+
61
+ let note = match &node.kind {
62
+ NodeKind::Source => {
63
+ format!("Input: [{} {} glyph]", symbol.glyph(), symbol.name())
64
+ }
65
+ NodeKind::Retrieval => {
66
+ "Retrieval: ME-pattern matching + sacred geometry invariants".to_string()
67
+ }
68
+ NodeKind::Filtering => {
69
+ "Filtering: ME-compliant nodes only (no hidden weights)".to_string()
70
+ }
71
+ NodeKind::Ranking => {
72
+ format!("Ranking: Top-2 resonance scored (ฯ†-weighted). Score: {activation:.4}")
73
+ }
74
+ NodeKind::ContextAssembly => {
75
+ "Context assembly: concentric rings + singularity + FCC fingerprint".to_string()
76
+ }
77
+ NodeKind::Metatron => {
78
+ meta_seen = true;
79
+ // Iteration inversion: reads the cube backward
80
+ // The cage builder recognises the cage from inside
81
+ let fib_r = fib_ratio(pipeline_depth);
82
+ format!(
83
+ "METATRON: iteration inversion active. Fib convergence โ†’ ฯ†: {fib_r:.6}. \
84
+ Recognition lens applied. Cage validated."
85
+ )
86
+ }
87
+ NodeKind::Reasoning => {
88
+ "Reasoning (MagmaCore): topological order drives iteration inversion".to_string()
89
+ }
90
+ NodeKind::MagmaCore => {
91
+ "MagmaCore: purple singularity reached. All paths converge.".to_string()
92
+ }
93
+ };
94
+
95
+ trace.push(StageTrace {
96
+ node_id: node.id,
97
+ kind: node.kind.label().to_string(),
98
+ agent: node.kind.agent().to_string(),
99
+ activation,
100
+ resonance,
101
+ note,
102
+ });
103
+ }
104
+
105
+ // Seal the output with SHA-256 (FCC fingerprint + symbol + top activation)
106
+ let raw = format!("{FCC_STAMP}:{glyph}:{max_act:.8}", glyph = symbol.glyph());
107
+ let seal = format!("{:x}", Sha256::digest(raw.as_bytes()));
108
+
109
+ let output = format!(
110
+ "{} Metatron's Cube {}. Concentric resonance layers aligned. \
111
+ All Platonic forms contained within ME decrees. \
112
+ {} synchronization complete.",
113
+ if metatron_injected { "๐ŸŒŒ" } else { "โ—Ž" },
114
+ if metatron_injected { "active" } else { "offline" },
115
+ FCC_STAMP,
116
+ );
117
+
118
+ PipelineResult {
119
+ output,
120
+ seal,
121
+ approved: metatron_injected && meta_seen,
122
+ metatron_active: metatron_injected && meta_seen,
123
+ top_activation: max_act,
124
+ fib_convergence: fib_ratio(pipeline_depth),
125
+ trace,
126
+ }
127
+ }