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.10.tar.gz (23.2 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.10-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_harness-0.0.10.tar.gz
  • Upload date:
  • Size: 23.2 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.10.tar.gz
Algorithm Hash digest
SHA256 034d3ab1b0b486a33ee3ac1539bad6c6ac4e44e13dbf0b36096c4f0a3c2cd222
MD5 6f6142e076951c204732f023f9589e60
BLAKE2b-256 0b4860627ceec4c79dd26133ffac3ee94b87b0b40287523c0b71a7579e5755ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_harness-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f881c8643a913ac5bfe6a6ccf3a258a92d44094c27c3e2453431e9f293b19d8a
MD5 088370c5629a2cb9e5b0600ebdc88451
BLAKE2b-256 7e824bca05904a74e6da8680944903ae60c1fb88951960fb0a31a6988f4c7b0b

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