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.12.tar.gz (24.6 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.12-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_harness-0.0.12.tar.gz
  • Upload date:
  • Size: 24.6 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.12.tar.gz
Algorithm Hash digest
SHA256 86ae1dbd63f276f7ce001eeadecf1bf955ea9c2c9a4d0fc98d4ea2be25b78f35
MD5 58cd73a75ca51a9aad8faeba7ae37fe2
BLAKE2b-256 b959a3b0bd6a51e705f8a1809bfb6ab174b3c99ccc614f1ffdae277ad8749b43

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_harness-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 19.1 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d66c5f401780821f36243327f1e285d68df67b27066149923b1158afc55f08d7
MD5 cb79f63731e3b0fe95db5636f9f6ac6e
BLAKE2b-256 8be00c1fe6d0e2c27792007a7b036a5d958e626ca0095140cc09f381324fa568

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