Metadata-Version: 2.4
Name: cordis-verify
Version: 0.4.0
Summary: Cordis: Independent Adversarial AI-PR & AST Invariant Prosecutor
Author-email: Janmejai <janmejai2002@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/janmejai2002/cordis
Project-URL: Documentation, https://github.com/janmejai2002/cordis#readme
Project-URL: Repository, https://github.com/janmejai2002/cordis.git
Project-URL: Issues, https://github.com/janmejai2002/cordis/issues
Project-URL: Changelog, https://github.com/janmejai2002/cordis/releases
Keywords: ai-agent,adversarial-testing,ast-mutation,mutation-testing,property-based-testing,fuzzing,code-review,pull-request,claude-code,devin,antigravity,counterfeit-red,forge-guard
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: hypothesis>=6.80.0; extra == "dev"
Dynamic: license-file

# Cordis (`cordis-verify`)

**Adversarial AI-PR verification engine:** catches hollow assertions, test tampering, mock abuse, and surviving AST mutants before code reaches human review.

Zero external runtime dependencies on Python 3.11+ (`pyproject.toml` declares `dependencies = []`; Python 3.10 has an optional `tomli` fallback with a built-in minimal TOML parser if `tomli` is absent). Runs offline with zero LLM tokens.

## The Problem

AI coding agents optimize for one signal: making the test command exit `0`. Standard CI (`pytest`, `unittest`, line coverage) and `Fail-to-Pass` checks still report green when an agent:
- Weakens an equality check into a hollow assertion (`assert result is not None` or `assert True`)
- Tampers with tests (`@pytest.mark.skip`, deleted assertions, `assert x == x`)
- Abuses mocks (`@patch` on the function under test so real logic never executes)
- Overfits a single input or drops boundary guards while leaving AST mutants alive

Cordis runs deterministic AST anti-tampering checks, diff-scoped AST mutation testing, and differential edge-case fuzzing against your base commit.

## Try It in One Command

```bash
uvx cordis-verify demo
```

Or from a local checkout:

```bash
python -m cordis.cli demo
```

This runs a self-contained comparison between a counterfeit AI patch (single-input overfit + weakened assertion) and a verified fix across Gates 1–3, then prints a terminal scorecard and writes `cordis_report.html`.

## Honest Proof

Every metric below is tracked with its exact reproduction command in [docs/CLAIMS.md](docs/CLAIMS.md):

- **5-archetype synthetic benchmark** (`python -m cordis.cli benchmark`, fixtures in [experiments/benchmark_suite.py](experiments/benchmark_suite.py)):
  - Standard `pytest` / coverage: **`0/5`** caught
  - SWE-bench `Fail-to-Pass` (`git revert`): **`1/5`** caught
  - Cordis 4-Gate AST Prosecutor: **`5/5`** caught (`128.34 ms` on the recorded run; `LLM Diff Reviewers: 0/5` in the report is a methodological characterization, not an executed tool run)
- **Engine test suite** (`python -m unittest discover -s tests -q`): **`Ran 432 tests ... OK`** on this checkout with Python 3.13.4 (baseline `373 tests` recorded in [docs/CLAIMS.md](docs/CLAIMS.md))
- **Upstream catches** (verified via GitHub API on `2026-11-30` in [docs/audits/UPSTREAM_PR_STATUS.md](docs/audits/UPSTREAM_PR_STATUS.md)):
  - `anthropics/anthropic-sdk-python#2053` — submitted PR, **open / unmerged** (`state=open`, `merged=false`)
  - `567-labs/instructor#2878` — closed without merge on `2026-11-05`, with its test-gap content **consolidated into merged `567-labs/instructor#2912`** (`merged=true`, `2026-11-05`)

See [docs/BENCHMARKS.md](docs/BENCHMARKS.md) for the full breakdown and scope caveats.

## Install & Verify Your Repo

```bash
# Install the CLI (`cordis` and `cordis-verify`)
uv tool install cordis-verify
# or:
pip install cordis-verify
```

```bash
# Initialize optional cordis.toml + git pre-commit / Claude Code hooks
cordis init --dry-run
cordis init

# Prosecute local working-tree or branch changes against HEAD~1
python -m cordis.cli verify-git --base-ref HEAD~1

# Probe a single Python function and suggest mutant-killing assertions
python -m cordis.cli probe --source path/to/module.py --test tests/test_module.py --func target_fn --suggest-test
```

## Pipeline & Current Scope (`v0.4.0`)

| Gate / Module | Scope & Status | What It Verifies |
| :--- | :--- | :--- |
| **Gate 0: ForgeGuard & Hooks** (`cordis/forge_guard.py`, `cordis/policy_guard.py`, `cordis/hooks.py`) | Production | CI actor provenance, repo contributor policy checks, and local `pre-commit` / `PreToolUse` / `Stop` anti-bypass guards. |
| **Gate 1: AST Anti-Tamper & MAR** (`cordis/ast_gate.py`) | Production (Python) | 64-bit BLAKE2b structural anchors, deleted/weakened assertions, target mocking, `@skip`, and Weighted Mock-to-Assertion Ratio. |
| **Gate 2: Diff-Scoped AST Mutation** (`cordis/mutator.py`, `cordis/repair.py`) | Production (Python) | Mutates modified functions, runs repo tests (or in-memory fallback), and flags surviving mutants as hollow tests. |
| **Gate 3A: Differential Fuzzing** (`cordis/fuzzer.py`) | Production (Python) | 200-input edge-case matrix (`NaN`, `-0.0`, boundaries, empty collections) comparing `base_ref` vs. candidate; reports `SKIPPED` if non-importable in-process. |
| **Gate 3B: Mann-Whitney U Latency** (`cordis/fuzzer.py`) | Demo / Library | Available in `demo` and library API; intentionally marked `SKIPPED` in `verify-git` to avoid shared-CI timing noise. |
| **TS / JS / Go / Rust Gate 1** (`cordis/ts_gate.py`, `cordis/polyglot_gate.py`) | Experimental (Lexical) | Regex/lexical tampering scanners only — **not** full AST parsers. Gate 2 mutation in `verify-git` is Python-only. |

## Project Configuration (`cordis.toml`) & CI

Optional `cordis.toml` at your repository root (generated by `cordis init`):

```toml
exclude_paths = ["migrations/", "generated/", "docs/"]
mar_threshold = 0.25
enabled_gates = ["gate0", "gate1", "gate2", "gate3a"]
# test_command = ["pytest", "-q"]
```

For GitHub Actions, see [action.yml](action.yml), [.github/workflows/cordis.yml](.github/workflows/cordis.yml), and [docs/CI_CD_INTEGRATION.md](docs/CI_CD_INTEGRATION.md).

## Documentation

- [docs/INDEX.md](docs/INDEX.md) — Complete index of repository documentation
- [docs/QUICKSTART.md](docs/QUICKSTART.md) — 60-second setup and walkthrough
- [docs/CLI_REFERENCE.md](docs/CLI_REFERENCE.md) — Subcommands and flags reference
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — Gate pipeline and module internals
- [docs/CLAIMS.md](docs/CLAIMS.md) — Authoritative verification claims ledger
- [CONTRIBUTING.md](CONTRIBUTING.md) — Contribution workflow and required self-checks
- [SECURITY.md](SECURITY.md) — Security policy, runtime guarantees, and vulnerability reporting

## License

[MIT](LICENSE)
