Skip to main content

An agentic codebase evaluation and evolution tool for Python projects.

Project description

Python Harness

An agentic codebase evaluation and evolution tool for Python projects.

python-harness is designed to be a universal standard tool—just like pytest or ruff—but instead of just checking syntax or running tests, it evaluates the architecture, readability, and governance of your codebase using both static analysis and LLMs (DeepSeek/OpenAI).

Features

  1. Hard Evaluation (First Fence): Enforces strict rules using ruff, mypy, and ty. Evaluates Cyclomatic Complexity (CC) and Maintainability Index (MI) via radon.
  2. Governance QC (Second Fence): Checks if the changes violate core project governance or attempt to bypass the evaluation rules themselves.
  3. Soft Evaluation (Third Fence):
    • Calculates architecture metrics like Fan-out (coupling).
    • Generates a holistic package understanding using LLMs.
    • Performs "Blind QA": Randomly samples functions/classes and tests the LLM's ability to understand them without context.
  4. Actionable Output: Synthesizes the evaluation into a final Pass/Fail verdict with exactly 3 concrete, actionable refactoring suggestions.

Installation

You can install python-harness using uv or pip:

uv pip install python-harness

Configuration

python-harness requires an LLM to perform its soft evaluation. Create a .env file in the root of your project:

LLM_API_KEY=your_api_key_here
LLM_BASE_URL=https://api.deepseek.com/v1
LLM_MODEL_NAME=deepseek-reasoner
LLM_MINI_MODEL_NAME=deepseek-chat

(Note: If you don't provide an API key, the harness will safely run in Mock mode).

Usage

1. Measure

To evaluate your codebase, run the measure command in your project directory:

harness measure .

This will run the full 3-fence evaluation and output a report with a final verdict and top 3 improvement suggestions.

2. Refine (Evolution Loop - WIP)

The refine command is an Agentic Edit-Test-Improve loop. It takes the suggestions generated by measure, automatically creates branches (variants), applies the changes, runs the tests (pytest), and picks the best variant.

harness refine . --steps 1 --max-retries 3

License

MIT License. See LICENSE for more details.

A harness toolkit for Python projects

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

python_harness-0.0.3.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

python_harness-0.0.3-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file python_harness-0.0.3.tar.gz.

File metadata

  • Download URL: python_harness-0.0.3.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_harness-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e2e30f6c291f37ac701e5f3137be2e0d87a67cdf2beb1e861e5293f63332a123
MD5 1ff0e4d91b157bbed44ea2aee1acbf9a
BLAKE2b-256 6d1d0b1c2672e55bfa4a49713d3f07e406dbdb26303c45507f1cdd15aa8255b1

See more details on using hashes here.

File details

Details for the file python_harness-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: python_harness-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for python_harness-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e808d4923e9bbca433b14981702c689a4b2f5f716261c5c60f3da7e8034479f5
MD5 ec0fd274fb5b05cbecfd683f6995d2d1
BLAKE2b-256 b8d52c687b616b3d2a4290717678dc205bba55e904c2cb3640d5fd17825b1506

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