@aleph-ai/tinyaleph 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md CHANGED
@@ -82,6 +82,7 @@ So too can concepts be:
82
82
  | **Reduction Semantics** | Strong normalization with ⊕ operators |
83
83
  | **Lambda Translation** | τ: Terms → λ-expressions |
84
84
  | **Enochian Vocabulary** | 21-letter alphabet, prime basis, sedenions |
85
+ | **Observer Architecture** | SMF, PRSC, Temporal, Entanglement, Agency, Boundary, Safety layers |
85
86
 
86
87
  ---
87
88
 
@@ -171,6 +172,59 @@ console.log({
171
172
 
172
173
  ---
173
174
 
175
+ ## Observer Architecture
176
+
177
+ The library includes a modular observer architecture for building autonomous AI systems:
178
+
179
+ ```javascript
180
+ const {
181
+ SedenionMemoryField,
182
+ PRSCLayer,
183
+ TemporalLayer,
184
+ EntanglementLayer,
185
+ AgencyLayer,
186
+ BoundaryLayer,
187
+ SafetyLayer
188
+ } = require('@aleph-ai/tinyaleph');
189
+
190
+ // Create observer stack
191
+ const smf = new SedenionMemoryField({ dimension: 16 });
192
+ const prsc = new PRSCLayer();
193
+ const temporal = new TemporalLayer();
194
+
195
+ // Process input through the stack
196
+ smf.absorb([0.5, 0.3, 0.2]); // Encode semantic input
197
+ prsc.tick(0.01, smf); // Run oscillator dynamics
198
+ temporal.recordMoment({ smf: smf.state, coherence: prsc.coherence });
199
+
200
+ console.log('Coherence:', prsc.coherence);
201
+ console.log('Entropy:', smf.entropy());
202
+ ```
203
+
204
+ ### Architecture Layers
205
+
206
+ | Layer | Purpose | Key Classes |
207
+ |-------|---------|-------------|
208
+ | **SMF** | 16D semantic state space | `SedenionMemoryField`, `SMF_AXES`, `SMF_CODEBOOK` |
209
+ | **PRSC** | Prime resonance oscillators | `PRSCLayer`, `PrimeOscillator`, `EntanglementDetector` |
210
+ | **Temporal** | Time-aware pattern storage | `TemporalLayer`, `Moment`, `TemporalPatternDetector` |
211
+ | **Entanglement** | Concept binding | `EntanglementLayer`, `EntangledPair`, `Phrase` |
212
+ | **Agency** | Goal-directed attention | `AgencyLayer`, `AttentionFocus`, `Goal`, `Action` |
213
+ | **Boundary** | Input/output gating | `BoundaryLayer`, `ObjectivityGate`, `SensoryChannel` |
214
+ | **Safety** | Constraint enforcement | `SafetyLayer`, `SafetyConstraint`, `SafetyMonitor` |
215
+
216
+ ### Utility Modules
217
+
218
+ | Module | Purpose |
219
+ |--------|---------|
220
+ | `core/errors` | Browser-compatible event emitter, structured errors |
221
+ | `core/logger` | Configurable logging with levels |
222
+ | `telemetry/metrics` | Counter, Gauge, Histogram metrics |
223
+ | `transport` | WebSocket, SSE, Polling transports |
224
+ | `profiling` | RingBuffer, Timer, Profiler |
225
+
226
+ ---
227
+
174
228
  ## Formal Semantics
175
229
 
176
230
  The library implements a rigorous formal semantics layer based on model-theoretic foundations:
@@ -0,0 +1,257 @@
1
+ # Topology Module Reference
2
+
3
+ The topology module implements topological invariants and physical constant derivations from the 108bio.pdf paper "Twist Eigenstates and Topological Morphogenesis".
4
+
5
+ ## Core Concepts
6
+
7
+ ### The 108 Invariant
8
+
9
+ The number 108 = 2² × 3³ plays a fundamental role as the minimal closed-form twist configuration:
10
+
11
+ ```javascript
12
+ const { TWIST_108 } = require('@aleph-ai/tinyaleph/core/prime');
13
+
14
+ console.log(TWIST_108.value); // 108
15
+ console.log(TWIST_108.binary); // 4 (2²)
16
+ console.log(TWIST_108.ternary); // 27 (3³)
17
+ console.log(TWIST_108.mod30Boundary); // 29 (prime sieve)
18
+
19
+ // Check if a number resonates with 108
20
+ console.log(TWIST_108.resonates(216)); // true (multiple of 108)
21
+ console.log(TWIST_108.resonates(100)); // false
22
+
23
+ // Get twist angle for a prime
24
+ console.log(TWIST_108.twistAngle(2)); // 180 degrees
25
+ console.log(TWIST_108.twistAngle(3)); // 120 degrees
26
+ console.log(TWIST_108.twistAngle(5)); // 72 degrees
27
+ ```
28
+
29
+ ### Knot Invariants
30
+
31
+ Mathematical knots with topological invariants for deriving physical constants:
32
+
33
+ ```javascript
34
+ const { Knot, TREFOIL, FIGURE_EIGHT, STANDARD_KNOTS } = require('@aleph-ai/tinyaleph/core/topology');
35
+
36
+ // The Trefoil knot (3₁) - fundamental stable structure
37
+ console.log(TREFOIL.name); // 'Trefoil'
38
+ console.log(TREFOIL.notation); // '3_1'
39
+ console.log(TREFOIL.crossings); // 3
40
+ console.log(TREFOIL.sticks); // 6
41
+ console.log(TREFOIL.bridge); // 2
42
+ console.log(TREFOIL.unknotting); // 1
43
+
44
+ // Trefoil complexity: T = s·c - b + u = 6×3 - 2 + 1 = 17
45
+ console.log(TREFOIL.complexity()); // 17
46
+
47
+ // Mass ratio derivation: 17 × 108 = 1836
48
+ console.log(TREFOIL.deriveMassRatio()); // 1836
49
+
50
+ // Create custom knot
51
+ const myKnot = new Knot({
52
+ name: 'Custom',
53
+ notation: 'X_1',
54
+ crossings: 5,
55
+ sticks: 8,
56
+ bridge: 2,
57
+ unknotting: 2
58
+ });
59
+ console.log(myKnot.complexity()); // 8×5 - 2 + 2 = 40
60
+ ```
61
+
62
+ ## Physical Constants
63
+
64
+ ### Derived Constants
65
+
66
+ The `PhysicalConstants` class derives fundamental constants from topological invariants:
67
+
68
+ ```javascript
69
+ const { PhysicalConstants } = require('@aleph-ai/tinyaleph/core/topology');
70
+
71
+ // Proton-electron mass ratio
72
+ const massRatio = PhysicalConstants.protonElectronRatio();
73
+ console.log(massRatio.derived); // 1836
74
+ console.log(massRatio.experimental); // 1836.15267343
75
+ console.log(massRatio.relativeError); // ~0.00008
76
+ console.log(massRatio.formula); // '17 × 108 = 1836'
77
+
78
+ // Fine structure constant inverse
79
+ const alpha = PhysicalConstants.fineStructureInverse();
80
+ console.log(alpha.derived); // 137
81
+ console.log(alpha.experimental); // 137.035999084
82
+ console.log(alpha.relativeError); // ~0.00026
83
+ console.log(alpha.formula); // '108 + 29 = 137'
84
+
85
+ // Higgs mass
86
+ const higgs = PhysicalConstants.higgsMass();
87
+ console.log(higgs.derived); // 125 (GeV)
88
+ console.log(higgs.experimental); // 125.25
89
+ console.log(higgs.formula); // '5³ = 125'
90
+
91
+ // Get all constants
92
+ const all = PhysicalConstants.all();
93
+
94
+ // Validate framework
95
+ const validation = PhysicalConstants.validate();
96
+ console.log(validation.overallValid); // true
97
+ ```
98
+
99
+ ## Gauge Symmetry
100
+
101
+ ### Standard Model from 108
102
+
103
+ The factorization 108 = 2² × 3³ generates the Standard Model gauge group:
104
+
105
+ ```javascript
106
+ const { GaugeSymmetry } = require('@aleph-ai/tinyaleph/core/topology');
107
+
108
+ // SU(3) color symmetry from 3³ = 27
109
+ const su3 = GaugeSymmetry.su3();
110
+ console.log(su3.name); // 'SU(3)'
111
+ console.log(su3.type); // 'Color'
112
+ console.log(su3.generator); // 27
113
+ console.log(su3.twistAngle); // 120 (degrees)
114
+
115
+ // SU(2) weak symmetry from 2² = 4
116
+ const su2 = GaugeSymmetry.su2();
117
+ console.log(su2.twistAngle); // 180 (degrees)
118
+
119
+ // U(1) electromagnetic from full 108
120
+ const u1 = GaugeSymmetry.u1();
121
+ console.log(u1.twistAngle); // 360 (degrees)
122
+
123
+ // Full Standard Model
124
+ const sm = GaugeSymmetry.standardModel();
125
+ console.log(sm.name); // 'SU(3) × SU(2) × U(1)'
126
+
127
+ // Decompose any number
128
+ const decomp = GaugeSymmetry.decompose(216);
129
+ console.log(decomp.su3Strength); // 27
130
+ console.log(decomp.su2Strength); // 8
131
+ console.log(decomp.is108Resonant); // true
132
+ ```
133
+
134
+ ## Observer Hierarchy
135
+
136
+ ### Multi-Scale Observers
137
+
138
+ From the paper's Table 1, observers at different scales:
139
+
140
+ ```javascript
141
+ const { OBSERVER_HIERARCHY, getObserverLevel, observerCapacity } = require('@aleph-ai/tinyaleph/core/topology');
142
+
143
+ // Access hierarchy
144
+ console.log(OBSERVER_HIERARCHY);
145
+ // [
146
+ // { scale: 'Quantum', constituentOscillators: 'Wavefunctions', ... },
147
+ // { scale: 'Molecular', ... },
148
+ // { scale: 'Biological', ... },
149
+ // { scale: 'Cognitive', ... },
150
+ // { scale: 'Planetary', ... },
151
+ // { scale: 'Cosmic', ... }
152
+ // ]
153
+
154
+ // Get specific level
155
+ const cognitive = getObserverLevel('cognitive');
156
+ console.log(cognitive.typicalComplexity); // 1000
157
+ console.log(cognitive.observableBehavior); // 'Awareness and thought'
158
+
159
+ // Calculate observer capacity
160
+ // C_obs = α·N_osc·K̄·τ⁻¹
161
+ const capacity = observerCapacity(
162
+ 1000, // oscillator count
163
+ 0.5, // mean coupling
164
+ 0.1, // coherence time
165
+ 1.0 // scaling constant
166
+ );
167
+ console.log(capacity); // 5000
168
+ ```
169
+
170
+ ## Free Energy Dynamics
171
+
172
+ ### Cubic FEP Dynamics
173
+
174
+ The consciousness model from Section 4.2:
175
+
176
+ ```javascript
177
+ const { FreeEnergyDynamics } = require('@aleph-ai/tinyaleph/core/topology');
178
+
179
+ // Create dynamics: dψ/dt = αψ + βψ² + γψ³
180
+ const fep = new FreeEnergyDynamics(0.1, -0.5, -0.1);
181
+
182
+ // Compute derivative at state ψ
183
+ console.log(fep.derivative(0.5)); // Rate of change
184
+
185
+ // Single step evolution
186
+ const newPsi = fep.step(0.5, 0.01);
187
+
188
+ // Find fixed points (attractors)
189
+ const fixedPts = fep.fixedPoints();
190
+ for (const pt of fixedPts) {
191
+ console.log(`ψ=${pt.value}: ${pt.stability}`);
192
+ }
193
+
194
+ // Compute potential V(ψ)
195
+ const potential = fep.potential(0.5);
196
+
197
+ // Simulate trajectory
198
+ const trajectory = fep.simulate(0.3, 10, 0.01);
199
+ for (const point of trajectory.slice(0, 5)) {
200
+ console.log(`t=${point.t.toFixed(2)}: ψ=${point.psi.toFixed(3)}`);
201
+ }
202
+
203
+ // Check stability at a point
204
+ console.log(fep.stabilityAt(0.5)); // 'stable' | 'unstable' | 'marginal'
205
+ ```
206
+
207
+ ## API Reference
208
+
209
+ ### TWIST_108
210
+
211
+ | Property | Type | Description |
212
+ |----------|------|-------------|
213
+ | `value` | number | 108 |
214
+ | `binary` | number | 4 (2²) |
215
+ | `ternary` | number | 27 (3³) |
216
+ | `mod30Boundary` | number | 29 |
217
+ | `resonates(n)` | function | Check if n is multiple of 108 |
218
+ | `twistAngle(p)` | function | Get 360/p degrees |
219
+ | `totalTwist(primes)` | function | Sum of twist angles |
220
+ | `isTwistClosed(primes)` | function | Check if total twist is multiple of 360 |
221
+
222
+ ### Knot Class
223
+
224
+ | Method | Returns | Description |
225
+ |--------|---------|-------------|
226
+ | `complexity()` | number | T = s·c - b + u |
227
+ | `deriveMassRatio()` | number | T × 108 |
228
+ | `isPrimeKnot()` | boolean | True if knot is prime |
229
+ | `genusLowerBound()` | number | (c - b + 1) / 2 |
230
+ | `toJSON()` | object | Full knot descriptor |
231
+
232
+ ### PhysicalConstants
233
+
234
+ | Method | Returns | Description |
235
+ |--------|---------|-------------|
236
+ | `protonElectronRatio()` | object | 17 × 108 = 1836 |
237
+ | `fineStructureInverse()` | object | 108 + 29 = 137 |
238
+ | `higgsMass()` | object | 5³ = 125 GeV |
239
+ | `all()` | object | All derived constants |
240
+ | `validate()` | object | Validation results |
241
+
242
+ ### FreeEnergyDynamics
243
+
244
+ | Method | Returns | Description |
245
+ |--------|---------|-------------|
246
+ | `derivative(psi)` | number | dψ/dt at psi |
247
+ | `step(psi, dt)` | number | Euler step |
248
+ | `fixedPoints()` | array | Fixed point analysis |
249
+ | `potential(psi)` | number | V(ψ) |
250
+ | `simulate(psi0, duration, dt)` | array | Full trajectory |
251
+ | `stabilityAt(psi)` | string | Stability classification |
252
+
253
+ ## Related Modules
254
+
255
+ - **[Core Prime](./01-core.md)** - Prime utilities including TWIST_108
256
+ - **[Physics](./02-physics.md)** - Oscillator dynamics
257
+ - **[Collective Intelligence](./08-collective.md)** - Observer Scale Manager