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.5.tar.gz (15.9 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.5-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_harness-0.0.5.tar.gz
  • Upload date:
  • Size: 15.9 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.5.tar.gz
Algorithm Hash digest
SHA256 db5297df2f5ef60ac9f05ffba60cdd1273a78de5ac1a38e479666fee5b77b891
MD5 48c79f4b06752eb763cc41d276060016
BLAKE2b-256 40ae0a33ecc64352b59834888e66dd4c587943348cd0f5a53288b234d7bf92a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_harness-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 be9195699938ea551ffa546058596347b7c15ca734542ac8429df10986ddd3f2
MD5 ec7352753f726ab824d09c624e0f1945
BLAKE2b-256 04d5a064e5355017f9f540abbc0096165af3259f026e74915845f6ac0f8a088e

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