Skip to main content

Complexity Fitness Analyzer for Codebases - Measures whether your codebase is more complex than it needs to be

Project description

๐Ÿ”ฅ Prometheus

Complexity Fitness Analyzer for Codebases

Named after the Titan who gave fire to humanity

License: MIT

Copyright ยฉ 2025 Andrew H. Bond andrew.bond@sjsu.edu


The Thesis

Simpler systems are more reliable. This isn't opinionโ€”it's physics:

  • Shannon's Information Theory: More bits = more error probability
  • Thermodynamics (Landauer): Complex systems require more energy to maintain
  • Reliability Engineering: R = rโ‚ ร— rโ‚‚ ร— ... ร— rโ‚™ (more components = exponentially lower reliability)

Prometheus measures whether your codebase is more complex than it needs to be.


Quick Start

pip install radon lizard

# Analyze a GitHub repo
python prometheus.py pallets/flask

# Compare multiple repos with one command
python olympus.py -f repos.txt -o comparison.html

repos.txt:

pallets/flask
psf/requests
django/django

That's it. Olympus clones, analyzes, and generates an interactive comparison dashboard.


The Tools

Tool Named After Purpose
olympus.py Home of the gods ๐Ÿ†• Orchestrator โ€” one command to analyze everything
prometheus.py Titan of forethought Core analyzer โ€” 2D fitness quadrant
hubris.py Greek concept of fatal pride Resilience theater detector
prometheus_ui.py โ€” Shared UI components & bivariate color palette
shield_analyzer.py Aegis (Shield of Zeus) Resilience pattern detector
entropy_analyzer.py Shannon Complexity metrics
scent_analyzer.py Code smells NIH patterns, staleness, freshness
sentinel.py Security guard Security vulnerability scanner
oracle.py Delphi LLM-assisted analysis

๐Ÿ†• Olympus: One Command to Rule Them All

New in v2.0: Olympus is now the orchestrator. One command analyzes multiple repos:

python olympus.py -f repos.txt -o comparison.html

What it does:

  1. Reads repos.txt (one owner/repo per line)
  2. Clones each repo (shallow, cached in .olympus_cache/)
  3. Runs prometheus.py (complexity + resilience)
  4. Runs hubris.py (theater detection)
  5. Generates interactive HTML comparison dashboard

Output:

======================================================================
OLYMPUS - Multi-Repository Comparison
======================================================================
  [clone] pallets/flask... OK
  [prometheus] pallets/flask... OK
  [hubris] pallets/flask... OK
  [clone] psf/requests... OK
  [prometheus] psf/requests... OK
  [hubris] psf/requests... OK

  HTML: comparison.html

Features

  • Bivariate color gradient: 16ร—16 dithered quadrant chart with distinct colors per quadrant
  • GitHub avatars: Visual identification of each repo
  • Interactive tooltips: Hover for details
  • Glossary: Built-in definitions for all terms (FORTRESS, GLASS HOUSE, Theater Ratio, etc.)
  • Ranked table: Sortable by health score, complexity, resilience, theater ratio
  • Caching: Re-runs skip already-analyzed repos

Flexible Input

# From file
python olympus.py -f repos.txt -o comparison.html

# Direct arguments
python olympus.py pallets/flask psf/requests -o comparison.html

# Mix remote and local
python olympus.py pallets/flask ./my-local-project -o comparison.html

# Existing JSON reports
python olympus.py prometheus_flask.json prometheus_django.json -o comparison.html

The Prometheus Quadrant

                    HIGH RESILIENCE
                          โ”‚
       ๐Ÿ’€ DEATHTRAP       โ”‚       ๐Ÿฐ FORTRESS
    (Complex AND          โ”‚    (Over-engineered
     undefended)          โ”‚     but defended)
                          โ”‚
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
                          โ”‚
       ๐Ÿ  GLASS HOUSE     โ”‚       ๐Ÿš๏ธ BUNKER
    (Simple but           โ”‚    (Ideal: Simple
     fragile)             โ”‚     and defended)
                          โ”‚
                    LOW RESILIENCE

    โ† HIGH COMPLEXITY          LOW COMPLEXITY โ†’

Goal: Move toward the BUNKER quadrant (bottom-right).

Quadrant Definitions

Quadrant Description Action
๐Ÿš๏ธ BUNKER Low complexity, high resilience. The ideal. Maintain
๐Ÿฐ FORTRESS Low complexity, low resilience. Hidden technical debt. Add error handling
๐Ÿ  GLASS HOUSE High complexity, low resilience. Visibly fragile. Simplify OR add resilience
๐Ÿ’€ DEATHTRAP High complexity, high resilience. Over-engineered. Simplify

Hubris: Resilience Theater Detector

Core thesis: "The complexity added by reliability patterns can introduce more failure modes than it prevents."

Hubris detects cargo cult resilienceโ€”patterns that look defensive but are implemented incorrectly:

Anti-Pattern Problem
Retry without backoff Thundering herd
Retry without max attempts Infinite loops
Uncoordinated timeouts Cascading failures
Invisible circuit breakers Silent failures
except Exception: pass Swallowed errors
Untested fallbacks False confidence
Multiple resilience libraries Complexity explosion

Theater Ratio

Theater Ratio = patterns_detected / patterns_correct
Ratio Meaning
1.0 Perfect โ€” all patterns correctly implemented
1.5 50% cargo cult
โˆž All theater, no substance

Usage

# Standalone
python hubris.py pallets/flask --html hubris_report.html

# Integrated (via Olympus)
python olympus.py -f repos.txt  # Hubris runs automatically

Installation

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

Optional (Go analysis)

go install github.com/securego/gosec/v2/cmd/gosec@latest

Metrics

Complexity (Entropy Analyzer)

Metric Good Bad
Cyclomatic Complexity < 5 > 10
Cognitive Complexity < 10 > 20
Maintainability Index > 65 < 40
Token Entropy 4-6 > 8

Resilience (Shield Analyzer)

Pattern Quality Checks
Retry Backoff? Jitter? Max attempts?
Timeout Coordinated? Reasonable values?
Circuit Breaker Metrics? Fallback? Thresholds?
Rate Limiting Per-client? Graceful degradation?

Freshness (Scent Analyzer)

Rating Criteria
๐ŸŸข FRESH Active development, modern patterns
๐ŸŸก STALE < 6 months since last commit
๐ŸŸ  MOLDY 6-12 months, outdated deps
๐Ÿ”ด ROTTEN > 1 year, deprecated patterns

Output Files

File Contents
comparison.html Olympus multi-repo dashboard
prometheus_<repo>.html Single-repo quadrant report
prometheus_<repo>.json Machine-readable metrics
hubris_<repo>.html Resilience theater report

Example: Compare Famous Repos

repos.txt:

# Well-maintained
pallets/flask
psf/requests
encode/httpx

# Satirical (for fun)
kelseyhightower/nocode
EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
auchenberg/volkswagen
python olympus.py -f repos.txt -o hall_of_fame.html

See where FizzBuzzEnterpriseEdition (the world's most over-engineered FizzBuzz) lands on the quadrant! ๐Ÿ˜„


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.


The Hubris Insight

Most "reliability engineering" is theater. Teams add:

  • Retries (without backoff โ†’ thundering herd)
  • Circuit breakers (without metrics โ†’ invisible failures)
  • Timeouts (uncoordinated โ†’ cascading failures)
  • Multiple resilience libraries (โ†’ complexity explosion)

The patterns look defensive. The implementation adds failure modes.

Hubris detects this. A high theater ratio means your resilience is performance, not protection.


Contributing

Contributions welcome. The thesis:

It doesn't work until you test it. Ground state or it doesn't exist.


License

MIT


Related Work

  • radon โ€” Python complexity metrics
  • lizard โ€” Multi-language cyclomatic complexity
  • SonarQube โ€” Enterprise code quality

Built to answer: "Is this codebase more complex than it needs to be?"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prometheus_analyzer-0.1.0.tar.gz (109.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prometheus_analyzer-0.1.0-py3-none-any.whl (110.1 kB view details)

Uploaded Python 3

File details

Details for the file prometheus_analyzer-0.1.0.tar.gz.

File metadata

  • Download URL: prometheus_analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 109.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for prometheus_analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd16ec2731f03fe61bfa27a7a6f7c07e713aa3f7b31a4d6128d0e5162d3447b6
MD5 7a7aad3078145f76aaf43c9a68ebf0b6
BLAKE2b-256 8bfb540711f99cb8c33898d004e2ce1a0e4b58e315c8a2756e942a373e907493

See more details on using hashes here.

File details

Details for the file prometheus_analyzer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prometheus_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44ed5a606d593cfcf497d141e8f6b8b192e6f1a862171f179177ac19d954491f
MD5 76d5c0aaa6a07beffbc6a570a0181ca9
BLAKE2b-256 29ac69a90f00002f78618aad9988f4b2865180890160bb8331a0d3b38bb6bcc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page