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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cthmodules

v4.0.0

Published

Causal-Temporal Historiometry kernel. Universal, policy-injected, deterministic analytical engine for historical event prediction.

Readme

The CTH Framework: A Functional Real-World Psychohistory

BANNER

License: CC BY-NC-SA 4.0 Academic Paper Field: Cliodynamics Node.js




✨🚀 UPDATE! v4.0

This major update completes the transition to a fully policy-driven, actor-aware kernel. Every numeric assumption is now externalized into auditable Policy objects, and individual historical actors are modeled as first-class causal agents through the new Token Dynamics Engine.

Key Features & Improvements

  • Token Dynamics Engine (Phase E.25): Each event now carries a token_instance describing the primary actor (power, network, charisma, momentum, ideological extremity, legitimacy, rationality). The engine computes a Token Impact Multiplier (TIM) applied per-engine — disruptors amplify systemic risk, architects and stabilizers dampen it.
  • Policy Injection System (Phase A.4): All analytic weights, thresholds, and constants are externalized into versioned, citable Policy objects. Two analysts using the same kernel but different Policies produce independently auditable, comparable results.
  • Specialized Policy Variants: Five domain-specific lenses ship out of the box — General, Geopolitical, Economic, Technological, and Revolutionary — each tuned to the causal dynamics of its domain.
  • Trajectory Bonus Mechanisms: Two complementary signals reward managed transformations: a structural delta inferred from Foundation's phase reconstruction (trajectory_bonus) and a reported delta read directly from macro_context.deltaCTH (reported_delta_bonus), positive-only so ruptures are not penalized twice.
  • Enhanced Calibration Suite: calibrate() now returns MAE, RMSE, Brier Score, Directional Accuracy, and per-category breakdowns. sensitivityAnalysis() identifies which synthesis weights drive error most. optimizePolicy() runs deterministic hill-climbing to minimize corpus MAE automatically.
  • IDataAdapter Interface (Phase B.6): Callers provide structured data through any adapter implementing adapt(rawInput). The kernel never touches raw text or external formats — full separation of ingestion and analysis.



The transition from descriptive history to predictive civilizational engineering.

  • 🏛️ Now the PAST into auditable data.
  • 🧬 Now the PRESENT into a technical diagnosis.
  • Now the FUTURE into a manageable probability.

The CTH Framework is an advanced computational system designed to quantify, simulate, and predict the stability and transitions of large-scale socio-historical systems. By integrating Shannon Entropy, Non-linear Dynamics, and High-Density Monte Carlo Simulations, CTH provides a functional realization of the goals proposed by Isaac Asimov’s Psychohistory, translated into a rigorous 21st-century mathematical architecture.


🚀 Key System Features

  • 📡 Master Predictor (cth-core.js): Central synthesis unit integrating six analytic engines into a single ultraCTH score (0–1). Outputs RMD/CMN verdict, certainty bracket, AlphaBreak status, Mule Clause flag, reflexivity penalty, and population modulation — all deterministically reproducible via SHA-256 hash.
  • 🎭 Token Dynamics Engine: Models individual actors as causal agents. Computes a Token Impact Score (TIS) from eight actor fields and applies a role-weighted Token Impact Multiplier (TIM) to Foundation, Dynamics, and Chaos risks before synthesis. Disruptors, architects, catalysts, stabilizers, and wildcards each produce distinct causal signatures.
  • 🦋 Butterfly Field Engine: High-density mapping of non-linear causal drift. Tracks initial condition sensitivity, divergence indices, and somatic resonance thresholds across the five temporal phases.
  • 🛡️ Chaos Resilience Engine: Internal resilience suite computing entropy, ERI (Event Resilience Index), blind spots, polarization, and fatigue. AlphaBreak and hedge thresholds are policy-configurable per domain.
  • 📜 Policy System: All analytic assumptions live in versioned, distributable Policy objects — not in the kernel. Inter-policy comparison (compare()), sensitivity analysis, and automated optimization (optimizePolicy()) allow rigorous, reproducible calibration across analytical schools.
  • 🔗 Causal Inheritance (Phase D.20): Events inherit systemic stress from parent events with configurable exponential decay (half_life). A child event registered with causal_parent_id automatically receives attenuated macro stress from its predecessor's ultraCTH.
  • 🤖 Bridge Layer (cth-bridge.js): Multi-context manager and adapter layer. Accepts any structured input via the IDataAdapter interface, manages causal chains across registered contexts, and exposes calibration, comparison, sensitivity, and optimization as first-class operations.
  • 📉 Deterministic Chaos: All simulation (Monte Carlo loops, deep zoom, butterfly perturbations) uses trigonometric deterministic noise tied to event parameters — zero Math.random(). Every prediction is fully reproducible and SHA-256 verifiable.

Evaluation v4.0 / Latest State

| Psychohistory Criterion (Asimov) | Level | Comment | |---------------------------------------------|------------|-------| | Quantifying macro-social trends | 8.8 / 10 | Very strong | | Predicting large-scale events | 8.7 / 10 | Solid differentiation and range | | Handling "historical forces" (EVEI) | 8.4 / 10 | Good | | Butterfly Effect + Chaos management | 8.8 / 10 | Excellent | | Invariance / Pantemporal patterns | 8.2 / 10 | Good | | Mathematical determinism | 9.0 / 10 | Excellent | | Empirical validation / Real calibration | 8.7 / 10 | Very strong (MAE 0.0356) | | Handling individual variables (Token) | 8.6 / 10 | Very effective | | Real future prediction capability | 8.4 / 10 | Increasingly credible |

Overall Verdict: 8.6 / 10


🏛 Core Methodology: The Architecture of Context

BANNER

The Tetrasociohistorical Context (CTH) is a quantitative index designed to evaluate the historical, social, economic, and demographic conditions surrounding an event at a specific moment. It operates on the premise that an event's relevance is inseparable from its environmental context.

The Four Dimensions of CTH

The index is constructed from four main dimensions, each normalized to ensure proportional contribution:

  • Historical Epoch (E): Captured through metrics like GDP per capita, Gini inequality, and political event density.
  • Social Range (S): Based on average income and literacy rates.
  • Age Range (A): Reflecting life expectancy and birth rates.
  • Population Range (P): Analyzing population density and urbanization rates.

Dynamic Weight Adjustment & Resilience

A critical feature of the CTH Framework is its ability to handle incomplete historical datasets. If data for a specific dimension is missing (e.g., political records for a remote era), the system dynamically redistributes the weights to prevent distortions, ensuring the integrity of the analysis.


⚙️ The Analytical Engines

The framework is architected into specialized engines that process complexity, noise, and causal drift in human systems.

1. Stochastic Projection Engine

  • Master Predictor Engine: The central arbiter that synthesizes data from all sub-modules to deliver a final trajectory with 99.7% statistical confidence.
  • Monte Carlo Core: Executes up to 50,000 iterations per phase to map the probability flow of civilizational outcomes.
  • CMN/RMD Analysis: Classifies transitions into Systemic Collapse (CMN) or Adaptive Transformation (RMD).

2. Chaos & Resilience Architecture

  • Chaos Detection Engine: Quantifies phase entropy using Shannon metrics to identify when a system enters a "non-deterministic" or chaotic regime.
  • ERI (Emergency Response Index): Measures the kinetic recovery speed and resilience of a society after a Black Swan event.
  • Bivariate Interaction Engine: Models non-linear couplings between dimensions (e.g., how economic decline triggers demographic shifts or political revolutions).

3. The Seldon Bridge (AI Integration)

  • CTH-bridge.JS: An autonomous layer that bridges the mathematical core with Large Language Models (LLMs).
  • Natural Language Processing: Translates raw historical narratives and real-time global news into structured CTH data points.
  • Dynamic Calibration: Allows the system to act as a "Psychohistorical Monitor," adjusting predictions in real-time as global data is ingested.

🚀 Getting Started

Installation

npm install cthmodules

Basic Implementation

const { MasterPredictor } = require('cthmodules');

// Initialize the engine with societal metrics
const analysis = MasterPredictor.analyzeTrajectory(inputData);

console.log(`Global Stability Index: ${analysis.cth_global}`);
console.log(`Structural Singularity Risk: ${analysis.singularity_risk}%`);

🔌 CTHmodules API (Public Access)

The CTH Psychohistorical Framework is now available for developers, analysts, and AI agents via our official API. Integrate high-certainty predictive logic into your own systems.

💳 Available Plans

  • The Explorer (Free): $0,00/mo | Ideal for individual testing.
  • The Strategist: $9.99/mo | Professional grade analysis.
  • The Institutional: $29.99/mo | High-volume data processing.
  • The Foundation: $99.99/mo | Full-scale framework integration.

🛠 Quick Integration

You can connect to the engine using any language (Python, JS, Go, etc.) through the RapidAPI Gateway.

Official Endpoint: https://cthmodules.p.rapidapi.com/v1/predict/

🧬 Commitment to Evolution

100% of the revenue generated through these plans is directly reinvested into the CTH Framework.


🤝 Research & Collaboration

The CTH Framework is currently seeking collaboration with elite research institutions (specifically the Santa Fe Institute) to scale its "Butterfly Field Engine" onto high-performance computing clusters and quantum architectures.

🧠 Lead Architect Alejo Malia 🌐 Website cthmodules.cc 📑 Paper The Tetrasociohistorical Context: A Quantitative Model for the Analysis of Historical Events 👁 Visión "You can't connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future." - Steve Jobs


License

This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0). © 2023-2026 Alejo Malia. All rights reserved. Intellectual Property Registered (No. 2505091695916).

License: CC BY-NC-SA 4.0 Terms of Use