|
| 1 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 2 | +# VIBEE Specification — MU Learning DB |
| 3 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 4 | +# φ² + 1/φ² = 3 = TRINITY |
| 5 | +# Issue #74: Accumulate error patterns → auto-fix rules |
| 6 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 7 | + |
| 8 | +name: mu_learning_db |
| 9 | +version: "1.0.0" |
| 10 | +language: zig |
| 11 | +module: mu_learning_db |
| 12 | + |
| 13 | +description: | |
| 14 | + MU Learning DB — scans .trinity/mu/errors/*.json, extracts recurring patterns, |
| 15 | + builds auto-fix rules. `tri mu learn` extracts patterns, `tri mu fix <spec>` |
| 16 | + applies known fixes to generated output. |
| 17 | + |
| 18 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 19 | +# TYPE SYSTEM |
| 20 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 21 | + |
| 22 | +types: |
| 23 | + AutoFixRule: |
| 24 | + fields: |
| 25 | + id: String |
| 26 | + pattern: String |
| 27 | + replacement: String |
| 28 | + category: String |
| 29 | + description: String |
| 30 | + apply_count: Int |
| 31 | + success_count: Int |
| 32 | + |
| 33 | + LearnResult: |
| 34 | + fields: |
| 35 | + rules_total: Int |
| 36 | + new_rules: Int |
| 37 | + updated_rules: Int |
| 38 | + errors_scanned: Int |
| 39 | + |
| 40 | + FixResult: |
| 41 | + fields: |
| 42 | + spec: String |
| 43 | + rules_applied: Int |
| 44 | + fixes_made: Int |
| 45 | + compile_before: Bool |
| 46 | + compile_after: Bool |
| 47 | + |
| 48 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 49 | +# BEHAVIORS |
| 50 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 51 | + |
| 52 | +behaviors: |
| 53 | + get_builtin_rules: |
| 54 | + description: "Return hardcoded auto-fix rules from known patterns" |
| 55 | + inputs: [] |
| 56 | + output: List(AutoFixRule) |
| 57 | + steps: |
| 58 | + - Return rules for Int64→i64, List→[]const, Float32→f64, etc. |
| 59 | + - Return rules for YAML comment stripping |
| 60 | + - Return rules for missing import detection |
| 61 | + |
| 62 | + learn_from_errors: |
| 63 | + description: "Scan .trinity/mu/errors/*.json, extract new patterns" |
| 64 | + inputs: [] |
| 65 | + output: LearnResult |
| 66 | + steps: |
| 67 | + - Read all JSON files in .trinity/mu/errors/ |
| 68 | + - Group by error_category |
| 69 | + - Count frequency of each error_message prefix |
| 70 | + - Merge with existing rules in .trinity/mu/learning_db.json |
| 71 | + - Save updated DB |
| 72 | + |
| 73 | + apply_fixes: |
| 74 | + description: "Apply known fixes to a spec's generated output" |
| 75 | + inputs: |
| 76 | + - spec_path: String |
| 77 | + output: FixResult |
| 78 | + steps: |
| 79 | + - Load learning DB |
| 80 | + - Run vibee gen on spec |
| 81 | + - Read generated .zig file |
| 82 | + - Apply matching auto-fix rules |
| 83 | + - Write fixed file |
| 84 | + - Run zig ast-check |
| 85 | + - Report result |
| 86 | + |
| 87 | + run_mu_learn_command: |
| 88 | + description: "CLI: tri mu learn" |
| 89 | + inputs: [] |
| 90 | + output: Void |
| 91 | + steps: |
| 92 | + - Call learn_from_errors |
| 93 | + - Print summary of new/updated rules |
| 94 | + |
| 95 | + run_mu_fix_command: |
| 96 | + description: "CLI: tri mu fix <spec>" |
| 97 | + inputs: |
| 98 | + - spec_path: String |
| 99 | + output: Void |
| 100 | + steps: |
| 101 | + - Call apply_fixes |
| 102 | + - Print before/after compile status |
| 103 | + |
| 104 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 105 | +# CONSTRAINTS |
| 106 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 107 | + |
| 108 | +constraints: |
| 109 | + - Learning DB at .trinity/mu/learning_db.json |
| 110 | + - At least 10 built-in auto-fix rules |
| 111 | + - Rules are additive — never remove a working rule |
| 112 | + - Fix attempts are logged with success/fail |
| 113 | + - Never modify .tri specs — only fix generated output |
| 114 | + |
| 115 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 116 | +# TESTS |
| 117 | +# ═══════════════════════════════════════════════════════════════════════════════ |
| 118 | + |
| 119 | +tests: |
| 120 | + - name: "builtin rules count" |
| 121 | + expected: {min_rules: 10} |
| 122 | + |
| 123 | + - name: "Int64 → i64 fix" |
| 124 | + input: {code: "const x: Int64 = 0;"} |
| 125 | + expected: {fixed: "const x: i64 = 0;"} |
| 126 | + |
| 127 | + - name: "List(T) → []const T fix" |
| 128 | + input: {code: "items: List(u8)"} |
| 129 | + expected: {fixed: "items: []const u8"} |
0 commit comments