Is this related to a problem?
The Stylus code validator applies 6 phases of fixes across 50+ regex patterns. This logic exists in both Python (_fix_code() in generate_stylus_code.py) and TypeScript (validateAndFixCode() in generateStylusCode.ts). New contributors find it overwhelming and don't know how to add new fixes without breaking existing ones.
Describe the feature
Create docs/STYLUS_CODE_VALIDATION.md documenting:
- Overview — why validation exists, the 6 phases, the cargo check backstop
- Phase descriptions — what each phase fixes, with before/after examples
- Python vs TypeScript differences — Python has cargo check (some fixes "moved to cargo check"); TS has all fixes active
- How to add a new fix — step-by-step guide with naming convention (Fix 40, 41, etc.)
- Error guidance mapping — table of Rust error codes → fix strategies
- Common pitfalls — e.g., Fix 41 (underscore functions), Fix 47 (getter chains)
Which module does this relate to?
Example usage
## Phase 3: Storage Accessors
Fixes incorrect storage read/write patterns in sol_storage! fields.
| Fix # | Pattern | Before | After |
|-------|---------|--------|-------|
| 34 | String mapping read | `.get(k)` on string field | `.getter(k).get_string()` |
| 43 | Double setter | `.setter(k).setter().set_str()` | `.setter(k).set_str()` |
| 45 | Nested struct write | `.get(k).field.setter()` | `.setter(k).field.setter()` |
Additional context
- Python:
src/mcp/tools/generate_stylus_code.py (search for _fix_phase_)
- TypeScript:
apps/web/src/lib/tools/generateStylusCode.ts (search for Phase)
src/utils/compiler_verifier.py has the ERROR_GUIDANCE dict
Is this related to a problem?
The Stylus code validator applies 6 phases of fixes across 50+ regex patterns. This logic exists in both Python (
_fix_code()ingenerate_stylus_code.py) and TypeScript (validateAndFixCode()ingenerateStylusCode.ts). New contributors find it overwhelming and don't know how to add new fixes without breaking existing ones.Describe the feature
Create
docs/STYLUS_CODE_VALIDATION.mddocumenting:Which module does this relate to?
Example usage
Additional context
src/mcp/tools/generate_stylus_code.py(search for_fix_phase_)apps/web/src/lib/tools/generateStylusCode.ts(search forPhase)src/utils/compiler_verifier.pyhas theERROR_GUIDANCEdict