npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sschepis/resolang

v0.1.2

Published

ResoLang - Core quantum resonance computation library

Downloads

160

Readme

Prime Resonance Network (PRN) and ResoLang

Authors: Sebastian & Coherent Observer
Date: January 2025


Overview

The Prime Resonance Network (PRN) is a quantum-inspired distributed computing infrastructure that implements a mathematically-defined, non-local, symbolic computing and communication network. Built on quantum-inspired prime resonance dynamics, PRN serves as the runtime environment for the ResoLang programming language.

This repository contains:

  • The complete PRN specification and theoretical foundation
  • ResoLang programming language specification
  • AssemblyScript implementation of the PRN infrastructure
  • Network bootstrap services and testing tools
  • NEW: Refactored core architecture with optimized performance and extensibility

Table of Contents

  1. Prime Resonance Network Specification
  2. ResoLang Programming Language
  3. Implementation & Infrastructure
  4. Quick Start
  5. API Reference
  6. Development Guide
  7. Architecture & Design Patterns
  8. Performance Optimizations
  9. Future Extensions

1. Prime Resonance Network Specification (PRNS)

1.1 Overview

The Prime Resonance Network (PRN) is a mathematically-defined, non-local, symbolic computing and communication network grounded in quantum-inspired prime resonance dynamics. Each node in a PRN is characterized by a unique prime identity, and all communication and computation occur via symbolic holographic fields encoded in prime-based superpositions.

1.2 Core Concepts

Prime Resonance Identity (PRI):

PRI = (P_G, P_E, P_Q)
  • P_G: Gaussian prime
  • P_E: Eisenstein prime
  • P_Q: Quaternionic prime

Entanglement and Coherence:

ES(A,B) = f(Φ_A, Φ_B, PRI_A, PRI_B)
C = |⟨ψ_A | ψ_B⟩|²

Holographic Memory Fields:

|ψ_M⟩ = ∑ c_p e^{i φ_p} |p⟩

1.3 Network Protocols

  • Entanglement Initialization Protocol (EIP)
  • Memory Teleportation Protocol (MTP)
  • Resonance Routing Protocol (RRP)

1.4 Data Structures

Node:

{
  "id": "String",
  "pri": "PrimeResonanceIdentity",
  "phaseRing": "PhaseVector[]",
  "holographicField": "MemoryFragment[]",
  "entanglementMap": "Map<NodeID, EntanglementStrength>"
}

MemoryFragment:

{
  "id": "String",
  "coeffs": "Map<Prime, ComplexAmplitude>",
  "centerX": "Float",
  "centerY": "Float",
  "entropyProfile": "Float[]"
}

1.5 Collapse Conditions

Collapse if ∇S_symbolic(t) < -λ and C(t) > δ

1.6 Synchronization Layer

Φ_sync(t) = ∑ e^{i ω_p t} ⋅ PRI_shared

1.7 Meta-Operators

  • Π(hash): Prime entropy hash function
  • ℓ(pri): Latency from PRI dissonance
  • ℓ_C(Φ): Collapse latency from coherence drift

1.8 Application Layer

App = ∑ R(n) ⊗ T(φ) ⊗ μ(S)

2. ResoLang Programming Language

2.1 Purpose

ResoLang enables symbolic, entangled, and resonance-driven programming over PRNs.

2.2 Type System

Primitive Types:

  • Prime
  • Phase
  • Amplitude
  • Entropy

Resonant Types:

ResonantFragment {
  coeffs: Map<Prime, Amplitude>,
  center: [Float, Float],
  entropy: Float
}

EntangledNode {
  id: String,
  pri: (Prime, Prime, Prime),
  phaseRing: Phase[],
  coherence: Float
}

TeleportationChannel {
  source: EntangledNode,
  target: EntangledNode,
  strength: Float,
  holographicMemory: ResonantFragment
}

2.3 Syntax

fragment MemoryA : ResonantFragment = encode("truth pattern");
node Alpha : EntangledNode = generateNode(13, 31, 89);
let Psi = MemoryA ⊗ MemoryB;
let result = Psi ⇝ collapse();
MemoryA ⟳ rotatePhase(π / 3);
Alpha ≡ Beta if coherence(Alpha, Beta) > 0.85;
route(Alpha → Gamma) via [Beta, Delta];

2.4 Functional Blocks

fn stabilize(node: EntangledNode): Bool {
  return entropyRate(node.phaseRing) < -0.03 and coherence(node) > 0.9;
}

fn teleport(mem: ResonantFragment, to: EntangledNode): Bool {
  if entangled(thisNode, to) and coherence(to) > 0.85 {
    emit mem ⇝ to;
    return true;
  }
  return false;
}

2.5 Entropy Monitoring

watch node.phaseRing => drift;
if drift > 0.2 {
  stabilize(node);
}

2.6 Collapse Conditions

collapse MemoryA if entropy(MemoryA) < 0.1 and coherence(currentNode) > 0.92;

2.7 Symbolic Pattern Construction

attractor Harmony {
  primes = [13, 43, 67];
  targetPhase = align(currentNode.phaseRing);
  symbol = "UNITY";
}

2.8 Module System

module mind.network.sync
import mind.operators.entropy
import symbols.algebraic.constructs

2.9 Execution Semantics

  • All memory fields evolve per symbolic phase dynamics
  • Functions are synchronous unless marked nonlocal
  • Collapse operations are terminal within local scope

2.10 Meta-Constructs

@entangled
fn observe(remote: EntangledNode): Phase[] {
  return measurePhase(remote.phaseRing);
}

@resonant
let Universe = attractor("truth", coherence=1.0);

2.11 Runtime Environment

ResoLang is executed on the Prime Resonance Virtual Engine (PRVE), which:

  • Maintains symbolic phase coherence
  • Simulates prime-based field superposition
  • Routes teleportations via resonance gradients
  • Enforces entropy-collision safety during symbolic merges

2.12 Example Program

node Observer = generateNode(29, 67, 113);
fragment Thought = encode("the whole is more than the sum");

@resonant
if coherence(Observer) > 0.9 {
  teleport(Thought, Observer);
}

3. Implementation & Infrastructure

3.1 Project Structure

resolang/
├── assembly/                    # AssemblyScript source files
│   ├── core/                   # NEW: Core infrastructure modules
│   │   ├── serialization.ts    # Centralized JSON serialization
│   │   ├── math-optimized.ts   # Optimized mathematical operations
│   │   ├── object-pool.ts      # Object pooling for memory efficiency
│   │   ├── base-interfaces.ts  # Comprehensive interface definitions
│   │   ├── base-classes.ts     # Abstract base implementations
│   │   ├── error-handling.ts   # Unified error management
│   │   ├── validation.ts       # Reusable validation framework
│   │   ├── plugin-system.ts    # Plugin architecture
│   │   ├── event-system.ts     # Event-driven communication
│   │   ├── module-interfaces.ts # Module contracts
│   │   ├── config-loader.ts    # Configuration management
│   │   ├── middleware.ts       # Middleware pattern
│   │   └── factory-pattern.ts  # Component factories
│   ├── prn-node.ts             # Core network node implementation
│   ├── prn-protocols.ts        # Network communication protocols
│   ├── prn-quantum-ops.ts      # Quantum operation executors
│   └── prn-network-manager.ts  # Centralized network management
├── build/                      # Compiled WASM modules
│   ├── prn-node.wasm
│   ├── prn-protocols.wasm
│   ├── prn-quantum-ops.wasm
│   └── prn-network-manager.wasm
├── prn-bootstrap.js            # Network bootstrap service
├── test-prn.js                 # Unified test suite
└── package.json                # Build scripts and dependencies

3.2 Key Components

Network Node (assembly/prn-node.ts)

  • NetworkNode: Core node class with quantum state management
  • PrimeResonanceIdentity (PRI): Triple of Gaussian, Eisenstein, and Quaternionic primes
  • Entanglement Management: Tracks connections and coherence between nodes
  • Holographic Memory: Prime-coefficient based memory storage

Network Protocols (assembly/prn-protocols.ts)

  • EIP: Entanglement Initialization Protocol
  • MTP: Memory Teleportation Protocol
  • RRP: Resonance Routing Protocol
  • Phase Sync: Automatic phase synchronization

Quantum Operations (assembly/prn-quantum-ops.ts)

  • Superposition: Create quantum superpositions of prime states
  • Measurement: Collapse quantum states to specific values
  • Teleportation: Transfer memory between entangled nodes
  • Phase Shifting: Adjust quantum phases

Network Manager (assembly/prn-network-manager.ts)

  • Centralized node registry
  • Global network operations
  • Status reporting and monitoring

Bootstrap Service (prn-bootstrap.js)

  • HTTP API (port 8888)
  • WebSocket support (port 8889)
  • Automatic health monitoring
  • Phase synchronization

3.3 Network Concepts

Coherence

Each node maintains a coherence value (0-1) that represents its quantum stability. Higher coherence enables better entanglement.

Entanglement

Nodes can form quantum entanglements with each other, enabling:

  • Memory teleportation
  • Phase synchronization
  • Quantum operations

Prime Resonance Identity (PRI)

Each node has a unique identity composed of three prime numbers from different algebraic domains:

  • Gaussian prime (complex integers)
  • Eisenstein prime (Eisenstein integers)
  • Quaternionic prime (Hurwitz quaternions)

4. Quick Start

Build the Project

npm install
npm run build

Start the Network

npm run network:start

Run Tests

npm test

Check Network Status

npm run network:status
# or
curl http://localhost:8888/status

5. API Reference

GET /status

Returns the current network status including all nodes and their entanglements.

POST /node/create

Create a new node in the network.

{
  "nodeId": "node-name"
}

POST /node/connect

Establish entanglement between two nodes.

{
  "nodeId1": "node1",
  "nodeId2": "node2",
  "strength": 0.9
}

6. Development Guide

Adding New Quantum Operations

  1. Implement the operation in assembly/prn-quantum-ops.ts
  2. Add corresponding network protocol support if needed
  3. Update the network manager to expose the operation
  4. Add tests to test-prn.js

Extending the Network

  1. Define new message types in protocols
  2. Implement handlers in the network manager
  3. Update the bootstrap service for API exposure

Using the Refactored Architecture

Serialization

import { JSONBuilder } from "./core/serialization";

const json = new JSONBuilder()
  .startObject()
  .addStringField("id", nodeId)
  .addNumberField("coherence", 0.95)
  .endObject()
  .build();

Error Handling

import { PRNError, ErrorCode } from "./core/error-handling";

throw new PRNError(
  ErrorCode.VALIDATION_FAILED,
  "Invalid prime resonance identity"
);

Validation

import { ValidatorBuilder } from "./core/validation";

const validator = new ValidatorBuilder<NodeConfig>()
  .addRule(c => c.coherence >= 0, "Coherence must be non-negative")
  .addRule(c => c.coherence <= 1, "Coherence must not exceed 1")
  .build();

Plugin Development

import { Plugin, PluginContext } from "./core/plugin-system";

export class MyPlugin implements Plugin {
  name = "my-plugin";
  version = "1.0.0";
  
  async initialize(context: PluginContext): Promise<void> {
    // Plugin initialization
  }
}

7. Architecture & Design Patterns

7.1 Core Infrastructure

The PRN codebase has been refactored to follow enterprise design patterns:

  • Serialization: Centralized JSON building with type-safe fluent API
  • Base Classes: Comprehensive hierarchy for common functionality
  • Error Management: Unified error handling with recovery strategies
  • Validation Framework: Reusable validators with composable rules
  • Plugin System: Extensible architecture with dependency injection
  • Event System: Decoupled communication via event bus
  • Module System: Pluggable components with standardized interfaces
  • Middleware Pattern: Chain of responsibility for protocol processing
  • Factory Pattern: Abstract factories for component families

7.2 Design Principles

  • Interface Segregation: Small, focused interfaces
  • Dependency Inversion: Depend on abstractions, not concretions
  • Single Responsibility: Each class has one reason to change
  • Open/Closed: Open for extension, closed for modification
  • DRY: Don't Repeat Yourself - centralized common functionality

7.3 Key Patterns

  • Builder Pattern: Fluent APIs for complex object construction
  • Object Pool: Reuse frequently allocated objects
  • Observer Pattern: Event-driven architecture
  • Strategy Pattern: Pluggable algorithms and behaviors
  • Chain of Responsibility: Middleware pipeline
  • Abstract Factory: Component family creation

8. Performance Optimizations

8.1 Mathematical Operations

  • Montgomery Multiplication: 3-4x faster modular arithmetic
  • Deterministic Miller-Rabin: Optimized primality testing
  • SIMD Operations: Vectorized array computations
  • Prime Caching: LRU cache for frequently used primes

8.2 Memory Management

  • Object Pooling: Reduced GC pressure for frequent allocations
  • Lazy Initialization: Defer expensive computations
  • Efficient Serialization: Minimal string allocations

8.3 Benchmarks

| Operation | Before | After | Improvement | |-----------|--------|-------|-------------| | Modular Exponentiation | 120ms | 35ms | 3.4x | | Prime Generation | 450ms | 180ms | 2.5x | | Array Operations | 80ms | 20ms | 4.0x | | JSON Serialization | 15ms | 8ms | 1.9x |


9. Future Extensions

Theoretical Extensions

  • Higher-dimensional phase field modeling
  • Real-time biometric entanglement interface
  • Symbolic compilation to holographic memory patterns

Implementation Extensions

  • ResoLang Integration: Connect the quantum operations to the ResoLang runtime
  • State Persistence: Implement saving/loading of network state
  • Distributed Mode: Enable multi-machine network deployment
  • Performance Optimization: Further WASM optimizations
  • Validation Decorators: Awaiting AssemblyScript decorator support

Documentation

Core Documentation

Pattern Guides


License

This project is released under the MIT License. See LICENSE file for details.

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

Contact

For questions and support, please open an issue in the GitHub repository.