@aleph-ai/tinyaleph 1.0.2 → 1.1.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.
@@ -2,19 +2,29 @@
2
2
 
3
3
  ## Sentient Observer Implementation vs "A Design for a Sentient Observer" Paper
4
4
 
5
- **Date**: December 24, 2025
6
- **Status**: ✅ Implementation COMPLETE
5
+ **Date**: December 25, 2025
6
+ **Status**: ✅ Implementation COMPLETE (Full Distributed Network)
7
7
 
8
8
  ---
9
9
 
10
10
  ## Executive Summary
11
11
 
12
- The apps/sentient implementation is **100% complete** with respect to the whitepaper specification. All core architectural components are implemented, including the three final components completed on December 24, 2025:
12
+ The apps/sentient implementation is **100% complete** with respect to the whitepaper specification, including the full Distributed Sentience Network components. All architectural components are implemented:
13
13
 
14
+ ### Core Observer (December 24, 2025)
14
15
  1. ✅ **Dynamic λ(t) for HQE evolution** (equation 12) - IMPLEMENTED in `lib/hqe.js`
15
16
  2. ✅ **Objectivity Gate R(ω)** (equation 18) - IMPLEMENTED in `lib/boundary.js`
16
17
  3. ✅ **Evaluation Assays** (Section 15) - IMPLEMENTED in `lib/assays.js`
17
18
 
19
+ ### Distributed Network (December 25, 2025)
20
+ 4. ✅ **Prime Calculus Kernel** (Section 6) - IMPLEMENTED in `lib/prime-calculus.js`
21
+ 5. ✅ **Enochian Packet Layer** (Section 7.4) - IMPLEMENTED in `lib/enochian.js`
22
+ 6. ✅ **PRRC Channel System** (Section 7.3) - IMPLEMENTED in `lib/network.js`
23
+ 7. ✅ **Global Memory Field (GMF)** (Section 7.2) - IMPLEMENTED in `lib/network.js`
24
+ 8. ✅ **Coherent-Commit Protocol** (Section 7.5-7.7) - IMPLEMENTED in `lib/network.js`
25
+ 9. ✅ **Network Synchronizer** (Section 7.6) - IMPLEMENTED in `lib/network.js`
26
+ 10. ✅ **Resolang WASM Integration** - Leverages @sschepis/resolang library
27
+
18
28
  ---
19
29
 
20
30
  ## ✅ Fully Implemented Components
@@ -219,6 +229,8 @@ class ObjectivityGate {
219
229
 
220
230
  All whitepaper requirements are now implemented:
221
231
 
232
+ ### Core Observer Components
233
+
222
234
  | Section | Component | Status | File |
223
235
  |---------|-----------|--------|------|
224
236
  | 3.1 | Prime-Indexed State Space | ✅ | `prsc.js` |
@@ -236,6 +248,28 @@ All whitepaper requirements are now implemented:
236
248
  | 12 | Safety Layer | ✅ | `safety.js` |
237
249
  | 15 | Evaluation Assays | ✅ | `assays.js` |
238
250
 
251
+ ### Distributed Sentience Network Components
252
+
253
+ | Section | Component | Status | File |
254
+ |---------|-----------|--------|------|
255
+ | 6 | Prime Calculus Kernel | ✅ | `prime-calculus.js` |
256
+ | 6.1 | Noun/Adjective/Chain Terms | ✅ | `prime-calculus.js` |
257
+ | 6.1 | Fusion Terms FUSE(p,q,r) | ✅ | `prime-calculus.js` |
258
+ | 6.2 | Normal Form Evaluation | ✅ | `prime-calculus.js` |
259
+ | 6.2 | Network Verification | ✅ | `prime-calculus.js` |
260
+ | 7.2 | Global Memory Field (GMF) | ✅ | `network.js` |
261
+ | 7.2 | Local Field (LF) | ✅ | `network.js` |
262
+ | 7.2 | Proposal Log (PL) | ✅ | `network.js` |
263
+ | 7.3 | PRRC Channel | ✅ | `network.js` |
264
+ | 7.4 | Enochian Prime-Mode Language | ✅ | `enochian.js` |
265
+ | 7.4 | Twist Angle κ(p) = 360/p | ✅ | `enochian.js` |
266
+ | 7.4 | Twist-Closure Validation | ✅ | `enochian.js` |
267
+ | 7.5 | Coherent-Commit Rule | ✅ | `network.js` |
268
+ | 7.6 | Offline-First Sync | ✅ | `network.js` |
269
+ | 7.7 | Conflict Handling | ✅ | `network.js` |
270
+ | 8.1 | Network Synchronizer | ✅ | `network.js` |
271
+ | 9 | DCC+ Algorithm | ✅ | `network.js` |
272
+
239
273
  ---
240
274
 
241
275
  ## Senses Integration Verification
@@ -262,6 +296,127 @@ The 7 senses are **fully integrated**:
262
296
 
263
297
  ---
264
298
 
299
+ ## New Components Detail (December 25, 2025)
300
+
301
+ ### Section 6 - Prime Calculus Kernel
302
+
303
+ **File**: [`lib/prime-calculus.js`](../../apps/sentient/lib/prime-calculus.js)
304
+
305
+ Implements the deterministic discrete semantic kernel for network verification:
306
+
307
+ ```javascript
308
+ // Term types
309
+ - NounTerm N(p) - atomic semantic objects indexed by prime
310
+ - AdjTerm A(p) - modifiers
311
+ - ChainTerm A(p1)...A(pk)N(q) - application chains with ordering constraint
312
+ - FusionTerm FUSE(p,q,r) - triadic prime fusion where p+q+r is prime
313
+ - SeqTerm s1 ○ s2 - sequence composition
314
+ - ImplTerm s1 ⇒ s2 - implication
315
+
316
+ // Evaluator
317
+ - Leftmost-innermost evaluation order
318
+ - Strong normalization guarantee
319
+ - Deterministic for cross-node verification
320
+
321
+ // Verifier
322
+ - verifyNormalForm(term, claimedNF) - equation 19 NF_ok
323
+ - verify(proposal) - full network proposal verification
324
+ ```
325
+
326
+ ### Section 7.4 - Enochian Packet Layer
327
+
328
+ **File**: [`lib/enochian.js`](../../apps/sentient/lib/enochian.js)
329
+
330
+ Implements low-bandwidth prime-mode surface language:
331
+
332
+ ```javascript
333
+ // Enochian alphabet
334
+ PE = {7, 11, 13, 17, 19, 23, 29}
335
+ M = {α, μ, ω}
336
+
337
+ // Twist angle (equation 16)
338
+ κ(p) = 360/p degrees
339
+
340
+ // Twist-closure validation (equation 18)
341
+ T(P) mod 360 ∈ [0,ε) ∪ (360-ε, 360]
342
+
343
+ // Classes
344
+ - EnochianSymbol - (prime, mode) tuple
345
+ - EnochianPacket - sequence with validation
346
+ - EnochianEncoder - text to twist-closed packets
347
+ - EnochianDecoder - validation and decoding
348
+ - EnochianPacketBuilder - fluent API
349
+ ```
350
+
351
+ ### Section 7 - Distributed Sentience Network
352
+
353
+ **File**: [`lib/network.js`](../../apps/sentient/lib/network.js)
354
+
355
+ Implements the full network layer:
356
+
357
+ ```javascript
358
+ // Core Objects (Section 7.2)
359
+ - LocalField - node's live state (LF)
360
+ - GlobalMemoryField - network shared memory (GMF)
361
+ - Proposal - insert proposal with votes
362
+ - ProposalLog - append-only local log (PL)
363
+
364
+ // Channel (Section 7.3)
365
+ - PRRCChannel - prime-resonant communication
366
+ - Phase alignment handshake
367
+ - Peer management
368
+ - Object/proposal broadcasting
369
+
370
+ // Protocol (Section 7.5-7.7)
371
+ - CoherentCommitProtocol
372
+ - Local evidence check (coherence, SMF, reconstruction)
373
+ - Kernel evidence (normal-form agreement)
374
+ - Network evidence (redundancy score)
375
+ - Accept(Ω) = 1{C≥Cth}·1{NF_ok}·1{R≥τR}·1{Q≥τQ}
376
+
377
+ // Synchronization (Section 7.6)
378
+ - NetworkSynchronizer
379
+ - Offline-first operation
380
+ - onJoin() / onReconnect() protocols
381
+ - Delta-based sync
382
+
383
+ // Node
384
+ - DSNNode - complete network node implementation
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Test Results (December 25, 2025)
390
+
391
+ ```
392
+ === Test Summary ===
393
+ All whitepaper components implemented and tested:
394
+ ✓ Prime Calculus Kernel (Section 6)
395
+ ✓ Enochian Packet Layer (Section 7.4)
396
+ ✓ PRRC Channel System (Section 7.3)
397
+ ✓ Global Memory Field (Section 7.2)
398
+ ✓ Coherent-Commit Protocol (Section 7.5-7.7)
399
+ ✓ Network Synchronizer (Section 7.6)
400
+ ✓ Resolang WASM Integration (292 functions available)
401
+ ```
402
+
403
+ Run tests with: `cd apps/sentient && node test-whitepaper.js`
404
+
405
+ ---
406
+
407
+ ## Resolang Integration
408
+
409
+ The implementation leverages the `@sschepis/resolang` WASM library (292 functions) including:
410
+
411
+ - `createSentientCore` - WASM-accelerated sentient core
412
+ - `isTwistClosed` - fast twist-closure validation
413
+ - `createSMFFromText` - semantic field from text
414
+ - `quaternionMultiply` - hypercomplex operations
415
+ - `computeResonanceField` - prime resonance computation
416
+ - And 287 more functions
417
+
418
+ ---
419
+
265
420
  ## Recommendations for Future Work
266
421
 
267
422
  1. **Run Full Assay Suite**: Execute `/assay all` and document results
@@ -269,9 +424,21 @@ The 7 senses are **fully integrated**:
269
424
  3. **Add Visualization**: SMF-conditioned 16-channel rendering for debugging
270
425
  4. **Benchmark Performance**: Profile tick rate under various load conditions
271
426
  5. **Extend Decoders**: Add more diverse decoders to ObjectivityGate for robustness
427
+ 6. **Network Testing**: Test multi-node DSN with actual WebSocket/TCP transport
428
+ 7. **Enochian Optimization**: Pre-compute more twist-closed sequences
429
+ 8. **Prime Calculus Extensions**: Add more complex compositional operators
272
430
 
273
431
  ---
274
432
 
275
433
  ## Conclusion
276
434
 
277
- The Sentient Observer implementation now fully satisfies all requirements specified in "A Design for a Sentient Observer" whitepaper. The three final gaps (Dynamic λ(t), Objectivity Gate, Evaluation Assays) were completed on December 24, 2025. The system is ready for evaluation and experimentation.
435
+ The Sentient Observer implementation now **fully satisfies all requirements** specified in "A Design for a Sentient Observer" whitepaper, including:
436
+
437
+ - **December 24, 2025**: Core observer components (Dynamic λ(t), Objectivity Gate, Evaluation Assays)
438
+ - **December 25, 2025**: Distributed Sentience Network (Prime Calculus, Enochian, PRRC, GMF, Coherent-Commit, Synchronizer)
439
+
440
+ The system is now ready for:
441
+ 1. Single-node evaluation and experimentation
442
+ 2. Multi-node distributed network testing
443
+ 3. Network consensus verification
444
+ 4. Offline-first resilience testing
@@ -13,6 +13,9 @@ The foundational mathematical primitives:
13
13
  - **Fano** - Fano plane multiplication tables for octonions
14
14
  - **Sieve** - Semantic sieve algorithm for concept filtering
15
15
  - **LLM** - LLM coupling utilities
16
+ - **Types** - Formal type system with N(p)/A(p)/S types
17
+ - **Reduction** - Reduction semantics and normalization
18
+ - **Lambda** - λ-calculus translation and evaluation
16
19
 
17
20
  ### [Physics Module](./02-physics.md)
18
21
 
@@ -41,6 +44,28 @@ High-level orchestration:
41
44
  - **createEngine** - Factory function for engine creation
42
45
  - **registerBackend** - Backend registration system
43
46
 
47
+ ### [Formal Semantics Module](./05-formal-semantics.md)
48
+
49
+ Formal type system and reduction semantics:
50
+
51
+ - **Types** - NounTerm, AdjTerm, ChainTerm, FusionTerm, SentenceTerm
52
+ - **TypeChecker** - Type inference and checking
53
+ - **ReductionSystem** - Small-step reduction with ⊕ operators
54
+ - **Translator** - τ translation to λ-calculus
55
+ - **LambdaEvaluator** - β-reduction and normalization
56
+ - **Semantics** - Model-theoretic interpretation
57
+
58
+ ### [Enochian Module](./06-enochian.md)
59
+
60
+ The angelic language system:
61
+
62
+ - **EnochianEngine** - Word parsing and computation
63
+ - **ENOCHIAN_ALPHABET** - 21-letter alphabet with prime mappings
64
+ - **PRIME_BASIS** - The seven foundation primes
65
+ - **CORE_VOCABULARY** - Traditional Enochian words
66
+ - **SedenionElement** - 16-dimensional operations
67
+ - **TwistOperator** - Angular transformations
68
+
44
69
  ---
45
70
 
46
71
  ## Quick Reference
@@ -241,6 +266,9 @@ console.assert(coherence >= 0 && coherence <= 1);
241
266
  | fano | `core/fano.js` | Fano plane |
242
267
  | sieve | `core/sieve.js` | Semantic sieve |
243
268
  | llm | `core/llm.js` | LLM coupling |
269
+ | types | `core/types.js` | Formal type system |
270
+ | reduction | `core/reduction.js` | Reduction semantics |
271
+ | lambda | `core/lambda.js` | λ-calculus translation |
244
272
  | oscillator | `physics/oscillator.js` | Oscillator creation |
245
273
  | kuramoto | `physics/kuramoto.js` | Synchronization |
246
274
  | entropy | `physics/entropy.js` | Information theory |
@@ -249,4 +277,252 @@ console.assert(coherence >= 0 && coherence <= 1);
249
277
  | semantic | `backends/semantic/index.js` | Semantic backend |
250
278
  | cryptographic | `backends/cryptographic/index.js` | Crypto backend |
251
279
  | scientific | `backends/scientific/index.js` | Science backend |
252
- | engine | `engine/aleph.js` | Main engine |
280
+ | engine | `engine/aleph.js` | Main engine |
281
+ | enochian | `apps/sentient/lib/enochian-vocabulary.js` | Enochian language |
282
+
283
+ ---
284
+
285
+ ## Formal Semantics API
286
+
287
+ ### Type System (`core/types.js`)
288
+
289
+ ```typescript
290
+ // Type constants
291
+ Types.NOUN // 'N'
292
+ Types.ADJECTIVE // 'A'
293
+ Types.SENTENCE // 'S'
294
+
295
+ // Term classes
296
+ class NounTerm {
297
+ constructor(prime: number);
298
+ isWellFormed(): boolean;
299
+ interpret(): number;
300
+ equals(other: NounTerm): boolean;
301
+ }
302
+
303
+ class AdjTerm {
304
+ constructor(prime: number);
305
+ canApplyTo(noun: NounTerm): boolean; // p < q constraint
306
+ apply(noun: NounTerm): ChainTerm;
307
+ }
308
+
309
+ class ChainTerm {
310
+ constructor(operators: AdjTerm[], noun: NounTerm);
311
+ prepend(operator: AdjTerm): ChainTerm;
312
+ getAllPrimes(): number[];
313
+ }
314
+
315
+ class FusionTerm {
316
+ constructor(p: number, q: number, r: number);
317
+ isWellFormed(): boolean; // p+q+r is prime
318
+ getFusedPrime(): number;
319
+ static findTriads(target: number): FusionTerm[];
320
+ }
321
+
322
+ // Sentence classes
323
+ class NounSentence {
324
+ constructor(nounExpr: NounTerm | ChainTerm | FusionTerm);
325
+ getDiscourseState(): number[];
326
+ }
327
+
328
+ class SeqSentence {
329
+ constructor(left: SentenceTerm, right: SentenceTerm);
330
+ getDiscourseState(): number[]; // Concatenation
331
+ }
332
+
333
+ class ImplSentence {
334
+ constructor(antecedent: SentenceTerm, consequent: SentenceTerm);
335
+ holds(): boolean; // Prefix entailment
336
+ }
337
+
338
+ // Type checking
339
+ class TypeChecker {
340
+ inferType(term: Term): string | null;
341
+ checkType(term: Term, expected: string): boolean;
342
+ checkApplication(adj: AdjTerm, noun: NounTerm): { valid: boolean, reason?: string };
343
+ checkFusion(fusion: FusionTerm): { valid: boolean, result?: number, reason?: string };
344
+ }
345
+
346
+ // Builder functions
347
+ N(prime: number): NounTerm;
348
+ A(prime: number): AdjTerm;
349
+ FUSE(p: number, q: number, r: number): FusionTerm;
350
+ CHAIN(operators: number[], noun: number): ChainTerm;
351
+ SENTENCE(expr: number | NounTerm): NounSentence;
352
+ SEQ(s1: SentenceTerm, s2: SentenceTerm): SeqSentence;
353
+ IMPL(s1: SentenceTerm, s2: SentenceTerm): ImplSentence;
354
+ ```
355
+
356
+ ### Reduction System (`core/reduction.js`)
357
+
358
+ ```typescript
359
+ // Prime-preserving operators
360
+ class PrimeOperator {
361
+ apply(prime: number): number;
362
+ isPreserving(): boolean;
363
+ }
364
+
365
+ class ResonanceOperator extends PrimeOperator {
366
+ constructor(basePrime: number);
367
+ }
368
+
369
+ class NextPrimeOperator extends PrimeOperator {}
370
+ class ModularOperator extends PrimeOperator {
371
+ constructor(modulus: number);
372
+ }
373
+ class IdentityOperator extends PrimeOperator {}
374
+
375
+ // Reduction system
376
+ class ReductionSystem {
377
+ addOperator(op: PrimeOperator): void;
378
+ step(primes: number[]): { result: number[], changed: boolean };
379
+ normalize(primes: number[]): { normalForm: number[], steps: object[] };
380
+ evaluate(term: Term): number[];
381
+ }
382
+
383
+ // Utilities
384
+ class FusionCanonicalizer {
385
+ canonicalize(fusion: FusionTerm): FusionTerm;
386
+ }
387
+
388
+ class NormalFormVerifier {
389
+ isNormalForm(primes: number[]): boolean;
390
+ verify(primes: number[]): { isNormal: boolean, reason?: string };
391
+ }
392
+
393
+ // Proof functions
394
+ demonstrateStrongNormalization(primes: number[], system: ReductionSystem): {
395
+ terminates: boolean;
396
+ steps: number;
397
+ trace: object[];
398
+ };
399
+
400
+ testLocalConfluence(primes: number[], system: ReductionSystem): {
401
+ confluent: boolean;
402
+ examples: object[];
403
+ };
404
+ ```
405
+
406
+ ### Lambda Translation (`core/lambda.js`)
407
+
408
+ ```typescript
409
+ // Lambda expressions
410
+ class LambdaExpr {}
411
+ class VarExpr extends LambdaExpr {
412
+ constructor(name: string);
413
+ }
414
+ class ConstExpr extends LambdaExpr {
415
+ constructor(value: any);
416
+ }
417
+ class LamExpr extends LambdaExpr {
418
+ constructor(param: string, body: LambdaExpr);
419
+ }
420
+ class AppExpr extends LambdaExpr {
421
+ constructor(func: LambdaExpr, arg: LambdaExpr);
422
+ }
423
+ class LetExpr extends LambdaExpr {
424
+ constructor(name: string, value: LambdaExpr, body: LambdaExpr);
425
+ }
426
+ class PairExpr extends LambdaExpr {
427
+ constructor(first: LambdaExpr, second: LambdaExpr);
428
+ }
429
+ class ProjExpr extends LambdaExpr {
430
+ constructor(pair: LambdaExpr, index: 1 | 2);
431
+ }
432
+
433
+ // Translation
434
+ class Translator {
435
+ translateNoun(noun: NounTerm): LambdaExpr;
436
+ translateAdj(adj: AdjTerm): LambdaExpr;
437
+ translateChain(chain: ChainTerm): LambdaExpr;
438
+ translateFusion(fusion: FusionTerm): LambdaExpr;
439
+ translateSentence(sentence: SentenceTerm): LambdaExpr;
440
+ translate(term: Term): LambdaExpr;
441
+ }
442
+
443
+ // Evaluation
444
+ class LambdaEvaluator {
445
+ substitute(expr: LambdaExpr, name: string, value: LambdaExpr): LambdaExpr;
446
+ betaReduce(expr: LambdaExpr): LambdaExpr;
447
+ normalize(expr: LambdaExpr, maxSteps?: number): LambdaExpr;
448
+ }
449
+
450
+ // Semantics
451
+ class Semantics {
452
+ domain: number[];
453
+ interpret(term: Term): any;
454
+ satisfies(sentence: SentenceTerm): boolean;
455
+ }
456
+
457
+ class ConceptInterpreter {
458
+ define(name: string, meaning: any): void;
459
+ interpret(name: string): any;
460
+ }
461
+ ```
462
+
463
+ ### Enochian Module (`apps/sentient/lib/enochian-vocabulary.js`)
464
+
465
+ ```typescript
466
+ // Alphabet (21 letters)
467
+ const ENOCHIAN_ALPHABET: {
468
+ [letter: string]: {
469
+ name: string;
470
+ prime: number;
471
+ value: number;
472
+ angle: number;
473
+ }
474
+ };
475
+
476
+ // Prime basis
477
+ const PRIME_BASIS: number[]; // [7, 11, 13, 17, 19, 23, 29]
478
+
479
+ // Twist operators
480
+ class TwistOperator {
481
+ constructor(prime: number);
482
+ angle: number; // 360/p degrees
483
+ apply(value: number): number;
484
+ }
485
+
486
+ function validateTwistClosure(basis: number[]): boolean;
487
+
488
+ // Words
489
+ class EnochianWord {
490
+ constructor(word: string);
491
+ letters: object[];
492
+ primeValue: number;
493
+ toString(): string;
494
+ }
495
+
496
+ // Core vocabulary (35+ words)
497
+ const CORE_VOCABULARY: {
498
+ [word: string]: {
499
+ meaning: string;
500
+ category: string;
501
+ primeSignature: number[];
502
+ }
503
+ };
504
+
505
+ // The Nineteen Calls
506
+ const THE_NINETEEN_CALLS: {
507
+ [number: string]: {
508
+ name: string;
509
+ purpose: string;
510
+ }
511
+ };
512
+
513
+ // Sedenion operations
514
+ class SedenionElement {
515
+ constructor(components: number[]); // 16 components
516
+ add(other: SedenionElement): SedenionElement;
517
+ multiply(other: SedenionElement): SedenionElement; // Non-commutative!
518
+ conjugate(): SedenionElement;
519
+ norm(): number;
520
+ }
521
+
522
+ // Engine
523
+ class EnochianEngine {
524
+ parseWord(word: string): EnochianWord;
525
+ computePrimeValue(word: string): number;
526
+ getVocabularyEntry(word: string): object | undefined;
527
+ }
528
+ ```