Skip to main content

Prometheus - Complexity Fitness Analyzer

CI PyPI version Python 3.10+ License: MIT

A pragmatic tool for measuring whether a codebase is too complex for its task.

Quick Start

pip install prometheus-analyzer

# Analyze a GitHub repo directly
prometheus https://github.com/pallets/flask

# Or use short form
prometheus pallets/flask

# Analyze local codebase
prometheus /path/to/your/code

# Outputs: prometheus_pallets_flask.html, prometheus_pallets_flask.json

The Tools

Tool Named After Purpose
prometheus.py Titan who gave fire to humanity Combined orchestrator — 2D fitness quadrant
shield_analyzer.py (Aegis) Shield of Zeus/Athena Resilience pattern detector
entropy_analyzer.py Shannon Complexity metrics
hubris.py Greek for "excessive pride" Resilience theater detector — finds cargo-cult patterns
olympus.py Home of the gods Multi-repository comparison tool

Theoretical Basis

This tool implements a pragmatic proof that simpler systems are more reliable:

Shannon's Information Theory

  • Channel capacity limits how much information can be transmitted error-free
  • Code is an information channel between intent and execution
  • Higher complexity → more bits → higher error probability

Thermodynamics (Landauer's Principle)

  • Maintaining information requires energy: E = kT ln(2) per bit
  • Complex systems require more energy to maintain
  • Complex systems have more failure modes and decay faster

Reliability Engineering

  • System reliability: R = r₁ × r₂ × ... × rₙ
  • Each component with reliability r < 1 reduces total reliability
  • More components = exponentially lower reliability

Kolmogorov Complexity

  • The complexity of an object is the length of its shortest description
  • Simpler descriptions are more compressible
  • High compression ratio → redundancy → potential simplification

Metrics Collected

Per-File Metrics

  • Cyclomatic Complexity: Number of independent paths through code
  • Cognitive Complexity: Weighted by nesting depth (SonarQube-style)
  • Halstead Metrics: Volume, difficulty, effort, estimated bugs
  • Maintainability Index: Composite score (0-100)
  • Token Entropy: Shannon entropy of token distribution
  • Compression Ratio: original_size / gzip_size
  • Nesting Depth: Maximum control flow nesting
  • Coupling: Import count and dependencies

Task Metrics (Estimated)

  • Test file count and test case count
  • Assertion density
  • API endpoint count
  • Function point estimate

Fitness Ratios (The Key Outputs)

  • Complexity per Feature: Is the code over-engineered?
  • LOC per Function Point: Industry standard ~50
  • Bits per Feature: Information-theoretic complexity density
  • Redundancy Ratio: How much could be DRY'd out?

Installation

pip install radon lizard

Usage

Analyze GitHub Repos

# Full URL
python prometheus.py https://github.com/django/django

# Short form (owner/repo)
python prometheus.py fastapi/fastapi

# Keep the cloned repo after analysis
python prometheus.py pallets/flask --keep

Analyze Local Code

# Full analysis with HTML quadrant chart
python prometheus.py /your/codebase

# Just resilience (Aegis)
python shield_analyzer.py /your/codebase

# Just complexity (Shannon metrics)
python entropy_analyzer.py /your/codebase

Output Files

Files are automatically named after the repo:

  • prometheus_<owner>_<repo>.html — Visual quadrant report
  • prometheus_<owner>_<repo>.json — Machine-readable data

Override with:

python prometheus.py owner/repo --html custom.html -o custom.json

Thresholds

Metric Good Medium Poor
Cyclomatic Complexity (avg) < 5 5-10 > 10
Maintainability Index > 65 40-65 < 40
LOC per Function Point < 50 50-150 > 150
Token Entropy 4-6 6-8 < 4 or > 8

Interpreting Results

Risk Levels

  • LOW: Complexity well-matched to task. Reliable.
  • MEDIUM: Trending toward excess. Monitor.
  • HIGH: Over-complex. Elevated error rates expected.
  • CRITICAL: Significantly over-engineered. Refactor before adding features.

The Pragmatic Verdict

From PyPI (Recommended)

# Basic installation
pip install prometheus-analyzer

# With security scanning (bandit)
pip install prometheus-analyzer[security]

# Full suite with all optional dependencies
pip install prometheus-analyzer[full]

After installation, use the commands:

prometheus pallets/flask
olympus -f repos.txt -o comparison.html
hubris pallets/flask --html hubris_report.html

From Source

git clone https://github.com/yourusername/prometheus.git
cd prometheus
pip install -e .

Manual Installation (Legacy)

If installing manually without the package:

# Minimal (Prometheus only)
pip install radon lizard

# Full Suite
pip install radon lizard bandit

This tool doesn't claim to measure "truth" — it measures fitness.

Per the pragmatist framework:

  • We don't ask "is this codebase correct?"
  • We ask "will this codebase reliably do its job?"

Physics and information theory tell us: simpler systems win.

Limitations

  • Task complexity estimation is heuristic (based on tests, endpoints, imports)
  • Some metrics only available for Python (uses radon)
  • Doesn't measure semantic complexity (bad names, confusing logic)
  • Can't detect "essential" vs "accidental" complexity

Extending

To add new languages or metrics:

  1. Add extension mapping in Extractor.LANGUAGE_EXTENSIONS
  2. Implement _analyze_<language>() method
  3. Integrate additional static analysis tools

Hubris: Resilience Theater Detector

Hubris analyzes codebases for cargo-cult resilience patterns — code that looks like it handles failures but doesn't actually work.

Quadrant Classification

Quadrant Description
SIMPLE Few patterns, low complexity — appropriate for simple tasks
BATTLE_HARDENED Many patterns, correctly implemented — production-ready
OVERENGINEERED Too many patterns for the task — unnecessary complexity
CARGO_CULT Many patterns, poorly implemented — false sense of security

What It Detects

  • Retry without backoff: Retries that hammer services without delay
  • Missing timeouts: Network calls without timeout configuration
  • Empty exception handlers: except: pass and similar anti-patterns
  • Circuit breakers without metrics: Breakers that can't report state
  • Library soup: Too many resilience libraries without coherent strategy

Architecture

hubris.py        # Main orchestrator
├── models.py    # Data classes (HubrisReport, etc.)
├── patterns.py  # Regex patterns for detection
├── detectors.py # Detection logic (RetryDetector, TimeoutDetector, etc.)
├── fp_filter.py # False positive filtering
├── design_patterns.py  # Design pattern anti-pattern detection
└── report.py    # HTML report generation

Usage

# Analyze a codebase
python hubris.py /path/to/code

# Generate HTML report
python hubris.py /path/to/code --html report.html

# Export JSON
python hubris.py /path/to/code -o report.json

Philosophy

"Complexity is the enemy of reliability."

This tool exists because:

  1. Simpler systems have fewer failure modes (physics)
  2. Simpler systems are easier to understand (cognition)
  3. Simpler systems are cheaper to maintain (economics)
  4. We can measure simplicity (information theory)

Therefore: we can measure expected reliability.

That's the pragmatic proof.


Built to answer: "Can you provide something I can measure?"

Metadata

Release files for prometheus-analyzer 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prometheus-analyzer 0.2.2
File Size Uploaded Provenance
prometheus_analyzer-0.2.2.tar.gz 170.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for prometheus-analyzer 0.2.2
File Interpreter ABI Platform
prometheus_analyzer-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 320.5 kB

Release files / prometheus_analyzer-0.2.2.tar.gz

Download URL prometheus_analyzer-0.2.2.tar.gz
Size 170.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0bba50b6f14dac558481c76ba721ee33bf806ce1946752aaaf5b0eb727587634
BLAKE2b-256 checksum
How to use checksums
1e61c3dba7d967ed37b61b7e2c735d1d9e1f82695034be392b99723d0b48a7dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / prometheus_analyzer-0.2.2-py3-none-any.whl

Download URL prometheus_analyzer-0.2.2-py3-none-any.whl
Size 149.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
377f6c3889469d889b6026e2ae11378fd6a24265771c5179ca56c8fa1fbdcd13
BLAKE2b-256 checksum
How to use checksums
9e2b6ce0099264880fea454a0d757ec13682c875a9fd907c23dcf6b2b43e52d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Security for prometheus-analyzer 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page