|
| 1 | +# Archive Analysis & Migration Plan |
| 2 | + |
| 3 | +**Goal:** Find useful logic in archive/ and migrate to trinity-nexus |
| 4 | +**Date:** 2026-02-18 |
| 5 | +**Priority:** HIGH |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 📊 Archive Structure Analysis |
| 10 | + |
| 11 | +### ✅ Useful Code (Should Migrate) |
| 12 | + |
| 13 | +#### 1. ML/AI Components |
| 14 | +**Location:** `archive/implementations/zig/src/ml/` |
| 15 | +**Files:** |
| 16 | +- `model.zig` - ML model architecture |
| 17 | +- `tensor.zig` - Tensor operations |
| 18 | +- `trainer.zig` - Training loop |
| 19 | +- `quantum.zig` - Quantum-inspired operations |
| 20 | + |
| 21 | +**Migration Target:** `trinity-nexus/core/ml/` |
| 22 | +**Status:** ⏳ Not migrated |
| 23 | +**Priority:** HIGH (for coder model) |
| 24 | + |
| 25 | +#### 2. Attention Mechanism |
| 26 | +**Location:** `archive/implementations/zig/src/attention.zig` |
| 27 | +**Useful for:** Transformer models |
| 28 | +**Migration Target:** `trinity-nexus/core/nn/` |
| 29 | +**Status:** ⏳ Not migrated |
| 30 | +**Priority:** HIGH |
| 31 | + |
| 32 | +#### 3. Optimizers |
| 33 | +**Location:** `archive/implementations/zig/src/optimizers.zig` |
| 34 | +**Useful for:** Training optimization |
| 35 | +**Migration Target:** `trinity-nexus/core/optimizers/` |
| 36 | +**Status:** ⏳ Not migrated |
| 37 | +**Priority:** MEDIUM |
| 38 | + |
| 39 | +#### 4. Quantization |
| 40 | +**Location:** `archive/implementations/zig/src/quantization.zig` |
| 41 | +**Useful for:** Model compression |
| 42 | +**Migration Target:** `trinity-nexus/core/quantization/` |
| 43 | +**Status:** ⏳ Not migrated |
| 44 | +**Priority:** HIGH (for ternary weights) |
| 45 | + |
| 46 | +#### 5. Benchmarks |
| 47 | +**Location:** `archive/old/benchmarks/` |
| 48 | +**Files:** |
| 49 | +- `bench_math.zig` - Math benchmarks |
| 50 | +- `bench_compression.zig` - Compression benchmarks |
| 51 | +- `ai_models_comparison.zig` - Model comparison |
| 52 | + |
| 53 | +**Migration Target:** `trinity-nexus/benchmarks/` |
| 54 | +**Status:** ✅ Already migrated |
| 55 | +**Priority:** LOW (already done) |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### 🗑️ Deprecated Code (Keep in Archive) |
| 60 | + |
| 61 | +#### 1. Old Frontend |
| 62 | +- `translator-app/` - Deprecated translation tool |
| 63 | +- `frontend/` - Old frontend experiments |
| 64 | + |
| 65 | +#### 2. Old Demos |
| 66 | +- `demos/` - Old demo code |
| 67 | +- `experiments/` - Old experiments |
| 68 | + |
| 69 | +#### 3. Marketing/Speculation |
| 70 | +- `museum/marketing/` - Marketing materials |
| 71 | +- `museum/speculation/` - Speculative code |
| 72 | + |
| 73 | +#### 4. Legacy Agents |
| 74 | +- `museum/legacy_agents/` - Old agent implementations |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## 🎯 Migration Plan |
| 79 | + |
| 80 | +### Phase 1: ML Components (HIGH PRIORITY) |
| 81 | + |
| 82 | +#### Task 1: Migrate tensor.zig |
| 83 | +**Source:** `archive/implementations/zig/src/ml/tensor.zig` |
| 84 | +**Target:** `trinity-nexus/core/ml/tensor.zig` |
| 85 | +**Changes:** |
| 86 | +- Update imports for trinity-nexus structure |
| 87 | +- Add tests |
| 88 | +- Integrate with VSA |
| 89 | + |
| 90 | +#### Task 2: Migrate model.zig |
| 91 | +**Source:** `archive/implementations/zig/src/ml/model.zig` |
| 92 | +**Target:** `trinity-nexus/core/ml/model.zig` |
| 93 | +**Changes:** |
| 94 | +- Update for ternary weights |
| 95 | +- Add VSA integration |
| 96 | +- Support .vibee spec generation |
| 97 | + |
| 98 | +#### Task 3: Migrate trainer.zig |
| 99 | +**Source:** `archive/implementations/zig/src/ml/trainer.zig` |
| 100 | +**Target:** `trinity-nexus/core/ml/trainer.zig` |
| 101 | +**Changes:** |
| 102 | +- Add distributed training support |
| 103 | +- Integrate with $TRI rewards |
| 104 | +- Add progress tracking |
| 105 | + |
| 106 | +#### Task 4: Migrate quantum.zig |
| 107 | +**Source:** `archive/implementations/zig/src/ml/quantum.zig` |
| 108 | +**Target:** `trinity-nexus/core/ml/quantum.zig` |
| 109 | +**Changes:** |
| 110 | +- Keep as quantum-inspired (not real quantum) |
| 111 | +- Add VSA quantum operations |
| 112 | +- Support symbolic reasoning |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +### Phase 2: Neural Network Components |
| 117 | + |
| 118 | +#### Task 5: Migrate attention.zig |
| 119 | +**Source:** `archive/implementations/zig/src/attention.zig` |
| 120 | +**Target:** `trinity-nexus/core/nn/attention.zig` |
| 121 | +**Changes:** |
| 122 | +- Ternary attention mechanism |
| 123 | +- VSA-based attention |
| 124 | +- SIMD optimization |
| 125 | + |
| 126 | +#### Task 6: Migrate optimizers.zig |
| 127 | +**Source:** `archive/implementations/zig/src/optimizers.zig` |
| 128 | +**Target:** `trinity-nexus/core/optimizers/` |
| 129 | +**Changes:** |
| 130 | +- Add ternary-aware optimizers |
| 131 | +- Φ-based learning rates |
| 132 | +- Integrate with VSA |
| 133 | + |
| 134 | +#### Task 7: Migrate quantization.zig |
| 135 | +**Source:** `archive/implementations/zig/src/quantization.zig` |
| 136 | +**Target:** `trinity-nexus/core/quantization/` |
| 137 | +**Changes:** |
| 138 | +- Ternary quantization (1.58 bits) |
| 139 | +- Φ-based quantization |
| 140 | +- Lossless compression |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +### Phase 3: Integration |
| 145 | + |
| 146 | +#### Task 8: Create ML spec |
| 147 | +**Target:** `specs/tri/ml_pipeline.vibee` |
| 148 | +**Content:** |
| 149 | +- Tensor operations spec |
| 150 | +- Model training spec |
| 151 | +- Optimizer spec |
| 152 | +- Quantization spec |
| 153 | + |
| 154 | +#### Task 9: Generate code from spec |
| 155 | +**Command:** `zig build vibee -- gen specs/tri/ml_pipeline.vibee` |
| 156 | +**Output:** `generated/ml_pipeline.zig` |
| 157 | + |
| 158 | +#### Task 10: Write tests |
| 159 | +**Target:** `trinity-nexus/core/ml/tests/` |
| 160 | +**Tests:** |
| 161 | +- Tensor operations |
| 162 | +- Model forward/backward |
| 163 | +- Optimizer convergence |
| 164 | +- Quantization accuracy |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +## 📊 Migration Status |
| 169 | + |
| 170 | +| Component | Source | Target | Status | Priority | |
| 171 | +|-----------|--------|--------|--------|----------| |
| 172 | +| Tensor | archive/.../ml/tensor.zig | nexus/core/ml/ | ⏳ | HIGH | |
| 173 | +| Model | archive/.../ml/model.zig | nexus/core/ml/ | ⏳ | HIGH | |
| 174 | +| Trainer | archive/.../ml/trainer.zig | nexus/core/ml/ | ⏳ | HIGH | |
| 175 | +| Quantum | archive/.../ml/quantum.zig | nexus/core/ml/ | ⏳ | HIGH | |
| 176 | +| Attention | archive/.../attention.zig | nexus/core/nn/ | ⏳ | HIGH | |
| 177 | +| Optimizers | archive/.../optimizers.zig | nexus/core/optimizers/ | ⏳ | MEDIUM | |
| 178 | +| Quantization | archive/.../quantization.zig | nexus/core/quantization/ | ⏳ | HIGH | |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## 🎯 Success Criteria |
| 183 | + |
| 184 | +1. ✅ All ML components migrated to trinity-nexus |
| 185 | +2. ✅ Tests passing for all migrated code |
| 186 | +3. ✅ .vibee specs created for ML pipeline |
| 187 | +4. ✅ Code generated from specs |
| 188 | +5. ✅ Integration with VSA working |
| 189 | +6. ✅ Coder model can train |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +## 📝 Estimated Time |
| 194 | + |
| 195 | +- **Phase 1 (ML):** 4-6 hours |
| 196 | +- **Phase 2 (NN):** 3-4 hours |
| 197 | +- **Phase 3 (Integration):** 2-3 hours |
| 198 | +- **Total:** 9-13 hours |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## 🚀 Next Steps |
| 203 | + |
| 204 | +1. Start with `tensor.zig` migration |
| 205 | +2. Create .vibee spec for tensors |
| 206 | +3. Generate code and test |
| 207 | +4. Continue with other components |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +**Status:** 📝 Plan Created |
| 212 | +**Next:** Execute Phase 1, Task 1 |
| 213 | +**Owner:** VIBEE |
0 commit comments