Deterministic linter for AI-generated Python code
Project description
wraith
Catches what your AI forgot to check.
Deterministic linter for AI-generated Python code. Detects hallucinated APIs, phantom packages, hardcoded secrets, AI artifacts, and supply chain risks.
Install
pip install wraith
Usage
wraith check . # scan current directory
wraith check . --fix --diff # preview fixes
wraith check . --fix # apply fixes
wraith check . --select AG,VC001 # specific rules only
wraith check . --min-confidence 0.8 # high-confidence only
wraith check . --format sarif # CI/CD output
wraith rules # list all 20 rules
What it catches
API Guard — hallucinated API detection
| Rule | What | Example |
|---|---|---|
| AG001 | Non-existent attribute | os.path.joinn() → did you mean join? |
| AG002 | Non-existent kwarg | makedirs(exst_ok=True) → exist_ok |
| AG003 | Deprecated API | PEP 702 + source analysis, zero false positives |
| AG004 | Bare call without module | read_csv() → pd.read_csv() |
| AG005 | Missing import | np.array() without import numpy |
| AG006 | Contextual mismatch | pd.read_excel("data.csv") → wrong extension |
Phantom — package validation
| Rule | What |
|---|---|
| PH001 | Package not found on PyPI (slopsquatting risk) |
| PH002 | Package not installed in current environment |
| PH003 | Suspicious package (typosquat, new, low downloads) |
Vibe Check — AI artifact hygiene
| Rule | What |
|---|---|
| VC001 | Hardcoded secrets (entropy + prefix + bigram analysis) |
| VC002 | AI comments (# Generated by Claude, # Copilot) |
| VC003 | Debug code — print/breakpoint (pedantic, off by default) |
| VC004 | Debug imports (pdb, ipdb) |
| VC005 | Source map exposure |
| VC006 | Unauthed debug/admin endpoints |
| VC007 | Dangerous files in project (.env, .pem, credentials) |
| VC008 | Unpinned dependencies |
| VC009 | Missing lockfile |
| VC010 | Source map with full source disclosure |
| VC011 | Secret leaked to print/logging (taint analysis) |
Inline suppression
print("debug") # noqa: VC003
API_KEY = "sk-secret" # noqa: VC001
import pdb # noqa
Python API
import wraith
results = wraith.check_source('API_KEY = "sk-secret"')
fixed = wraith.fix('import pdb\nbreakpoint()')
How it works
- Tree-sitter AST parsing — no regex on source, proper syntax analysis
- Symbol table with scope tracking (PEP 227 LEGB) — distinguishes imports from local variables
- Python introspection — validates API calls against real installed modules
- Layered secret detection — known prefixes, Shannon entropy, bigram name classification, character class analysis
- Taint analysis — tracks data flow from secret sources to unsafe sinks
- TYPE_CHECKING awareness (PEP 484) — skips type-only imports
Research
Based on:
- AST Hallucination Guard (FORGE '26) — API validation via introspection
- Package Hallucinations in LLMs — phantom package detection
- Slopsquatting — supply chain attack via hallucinated names
- VibeGuard — AI code artifact hygiene
- Secrets in Source Code (Saha et al. 2020) — character class analysis
- Argus — hierarchical secret detection
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wraith-0.1.0.tar.gz
(64.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wraith-0.1.0.tar.gz.
File metadata
- Download URL: wraith-0.1.0.tar.gz
- Upload date:
- Size: 64.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1812c7f002e8490a52f9584790d041ebe526e582356cdc70dc90cf42a4ee378
|
|
| MD5 |
09c5557e3a18355a8fb7346fd1c71edb
|
|
| BLAKE2b-256 |
1b387f204030f045592b65d6812c23d809c52ef043b561b946af058152a5eda0
|
File details
Details for the file wraith-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: wraith-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 923.2 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
065253429b0c04ef820b779a5b5a0c464a987d58a6b9e2d17803e6643e7cea30
|
|
| MD5 |
7c49b0e180ba5d80b976879c1eac2a2a
|
|
| BLAKE2b-256 |
26bce331b2921fc5a9eca85c561033111d69787c6131f3adf89c0b8bdf9026b7
|