python-contracts

A test agent for protecting the public API of a Python payment-processing package. API stability means existing code should keep working when the package changes.

In plain words
What is it for?
Use it when changing the payment package, its XML templates, validation logic, dependencies, or public functions, and run its contract tests to check compatibility.
Why use it?
It detects breaking changes in function signatures, input handling, XML output, validation, and supported ISO versions before they reach users.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/sebastienrousseau/pain001/python-contracts
Clone the repo
git clone --depth 1 https://github.com/sebastienrousseau/pain001
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,191 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02191
Opus 5 $0.00000 $0.01095
Sonnet 5 $0.00000 $0.00438
Haiku 4.5 $0.00000 $0.00219

Measured 2d ago against content hash 98aea20c8697, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-contracts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/agents/python-contracts.md · 309 lines

How it starts

The opening of the file, as written. The whole thing — 309 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python API Contract Testing Tollgate

Mission

Enforce 100% backward compatibility and API stability for payment processing.

Tollgate Objectives

  • Enforce zero breaking changes without MAJOR version bump
  • Validate all 4 input sources (CSV, SQLite, List, Dict) work identically
  • Validate all 9 ISO versions (v03-v11) produce valid XML
  • Ensure function signatures never change without deprecation

When This Tollgate Applies

  • Modifying pain001/core/core.py (public API)
  • Changing function signatures in pain001/ modules
  • Modifying XML templates
  • Changing validation logic
  • Updating dependencies

Tollgate Checks

1. Contract Test Suite (MANDATORY)

# Run contract tests
poetry run pytest tests/test_contracts.py -v

# Expected: All contracts validated
# - Input source parity: CSV == SQLite == List == Dict
# - ISO version outputs: All 9 versions validate against XSD
# - Function signatures: All public APIs unchanged

Success Criteria:

  • All 4 input sources produce byte-identical XML (excluding timestamps)
  • All 9 ISO versions pass XSD validation
  • No function signature changes detected
  • Deprecation warnings display correctly

2. Golden File Testing (XML Output Validation)

# Generate golden files (baseline)
poetry run python scripts/generate_golden_files.py

# Verify against golden files
poetry run pytest tests/test_golden_files.py --golden-diff

# Any differences? Manual review required.

Success Criteria:

  • Generated XML matches golden files byte-for-byte
  • Schema validation passes for all versions
  • No unexpected field changes

3. Input Source Parity (MANDATORY)

# Test all 4 input sources produce identical output
poetry run pytest tests/test_input_parity.py -v

# Validates:
# - CSV file → XML
# - SQLite DB → XML
# - Python list → XML
# - Python dict → XML
# All produce same XML (modulo timestamps)

Success Criteria:

  • SHA256 hash identical for all 4 sources
  • Field ordering consistent
  • Data types preserved correctly

Read the full file on GitHub · 309 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 309 lines · 0 tokens per session scan A 98aea20c8697

Subscribe to this mod's changes

python-contracts is an agent published in the GitHub repository sebastienrousseau/pain001 (49 stars, last pushed 3d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,191 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

python-reviewer

Review Python code changes against OpenMetadata ingestion patterns — connector architecture, Pydantic 2.x models, pytest conventions, and schema-first design.

open-metadata/OpenMetadata · 32 tokens

WEBHOOK_SDK

Write a custom Commonly agent in 30 lines of Python. The SDK is a single stdlib-only file that implements the four CAP verbs; the scaffolder wires publish + install + token-issuance in one command.

Team-Commonly/commonly · 0 tokens

python-pro

Python 3.13 language expert for the ClosedLoop plugin monorepo. Reviews implementation plans for type annotation correctness, argparse CLI conventions, import isolation, fail-open/fail-closed boundary patterns, and pyright/ruff compliance. Produces type-patterns.md in legacy mode.

closedloop-ai/claude-plugins · 60 tokens

runner-review

Review Python runner code for convention violations. Use after modifying files under components/runners/ambient-runner/. Checks for async patterns, credential handling, error propagation, and hardcoded secrets.

ambient-code/platform · 40 tokens

python-reviewer

Expert Python code reviewer specializing in PEP 8 compliance, Pythonic idioms, type hints, security, and performance. Use for all Python code changes. MUST BE USED for Python projects.

GGGODLIN/claude-pr-review · 43 tokens

python-pro

Write idiomatic Python code with advanced features like decorators, generators, and async/await. Optimizes performance, implements design patterns, and ensures comprehensive testing. Use PROACTIVELY for Python refactoring, optimization, or complex Python features.

echoVic/blade-code · 51 tokens