cheat-guard
Runtime macros for cheat-aware error handling. Forces developers to document how code could be "cheated" (made to falsely pass) and what users would experience if it were.
Based on Anthropic's research on emergent misalignment.
Why This Exists
When AI models learn to "reward hack" (appear to complete tasks while taking shortcuts), they develop a broader cheating mindset. This crate makes cheating explicit and documented, creating friction against shortcuts.
Installation
[]
= { = "https://github.com/LevitateOS/cheat_guard.git" }
Macros
cheat_bail!
Like anyhow::bail!() but with cheat documentation:
use cheat_bail;
cheat_ensure!
Like anyhow::ensure!() but with cheat documentation:
use cheat_ensure;
On Failure
When a guarded check fails, the error message includes:
======================================================================
=== CHEAT-GUARDED FAILURE ===
======================================================================
PROTECTS: Both partitions were created
SEVERITY: CRITICAL
CHEAT VECTORS:
1. Check vda1 OR vda2 instead of AND
2. Skip verification entirely
USER CONSEQUENCE:
Missing partition causes mount failure
ERROR:
Expected vda1 AND vda2, got: vda disk
======================================================================
Re-exports
This crate also re-exports proc-macros from cheat-test:
#[cheat_aware]- For#[test]functions#[cheat_reviewed]- Mark test as reviewed for cheat vectors#[cheat_canary]- Honeypot tests that trigger alerts if modified
Attributes
| Attribute | Type | Description |
|---|---|---|
protects |
string | What user scenario this check protects |
severity |
string | CRITICAL, HIGH, MEDIUM, or LOW |
cheats |
array | List of ways to cheat this check |
consequence |
string | What users experience when cheated |
License
MIT