Code Consistency Validator
Validates type consistency across Rust, TypeScript, and PostgreSQL boundaries.
When to Use
- Reviewing code for type mismatches
- Debugging precision loss issues
- Validating API contracts between languages
- Checking BigInt/Number conversions
- Auditing cross-language data flow
Workflow
Step 1: Run Quick Grep
Use provided grep commands to find potential issues.
Step 2: Check Critical Patterns
Look for Number() on wei/balance, parseInt without radix.
Step 3: Generate Report
Report findings using severity levels (CRITICAL/WARNING/INFO).
Critical Type Mappings
| Rust | TypeScript | PostgreSQL | |------|------------|------------| | i64/u64 | bigint (not number!) | BIGINT | | U256 | string | DECIMAL(36,18) | | f64 | number | DOUBLE PRECISION |
π΄ CRITICAL Patterns
Number(response.profit_wei) // β Precision loss!
parseInt(hexBalance) // β Missing radix!
JSON.stringify({ amount: BigInt(x) }) // β Fails!
Quick Grep
grep -rn "Number(" --include="*.ts" | grep -E "(wei|balance|amount)"
grep -rn "parseInt(" --include="*.ts" | grep -v ", 10)" | grep -v ", 16)"
Report Format
π΄ CRITICAL (funds at risk) π WARNING (potential bugs) π‘ INFO (style) β VALIDATED