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