|
150 | 150 |
|
151 | 151 | Model pair: all-MiniLM-L6-v2 (384d) → all-mpnet-base-v2 (768d) |
152 | 152 | Corpus: 1000 synthetic texts across 10 topics |
| 153 | + |
| 154 | +## Stress Test Results |
| 155 | + |
| 156 | +All CLI commands tested with intentionally corrupted/edge-case inputs. **Zero raw tracebacks** after fixes. |
| 157 | + |
| 158 | +| Input | gate | calibrate | transform | inspect | |
| 159 | +|-------|------|-----------|-----------|---------| |
| 160 | +| Nonexistent file | ✅ Clean | ✅ Clean | ✅ Clean | ✅ Clean | |
| 161 | +| Bad magic bytes | ✅ Clean | — | — | ✅ Clean | |
| 162 | +| Truncated file | — | — | — | ✅ Clean | |
| 163 | +| Random garbage | — | — | — | ✅ Clean | |
| 164 | +| NaN in vectors | ✅ Clean | ✅ Clean | — | — | |
| 165 | +| Inf in vectors | ✅ Clean | — | — | — | |
| 166 | +| Empty vectors (K=0) | ✅ Clean | — | — | — | |
| 167 | +| Single vector (K=1) | ✅ Clean | ✅ Clean | — | — | |
| 168 | +| Wrong dimension | ✅ Clean | ✅ Success* | ✅ Clean | — | |
| 169 | +| Text file as .npy | ✅ Clean | — | — | — | |
| 170 | +| Empty source dir | — | — | ✅ Clean | — | |
| 171 | +| Dimension mismatch | ✅ Clean | — | ✅ Clean | — | |
| 172 | + |
| 173 | +*calibrate with wrong dims succeeds (200d→768d) — this is valid behavior, the mapping stores the dims and validates on transform. |
| 174 | + |
| 175 | +### Bugs found in stress test (Round 2) |
| 176 | + |
| 177 | +| Bug | Command | Fix | |
| 178 | +|-----|---------|-----| |
| 179 | +| Raw traceback on NaN/Inf vectors | gate, calibrate | Wrapped np.load and gate.evaluate in try/except | |
| 180 | +| Raw traceback on empty vectors | gate | Added early emptiness check with clean message | |
| 181 | +| Raw traceback on wrong dims | gate, transform | Added early dim check + wrapped transform | |
| 182 | +| Raw traceback on single vector | gate | Wrapped gate.evaluate in try/except | |
| 183 | +| Raw traceback on bad .npy file | gate | Wrapped np.load in try/except | |
| 184 | +| Raw traceback on dim mismatch in transform | transform | Wrapped mapping.transform in generator | |
| 185 | +| Raw traceback on NaN in calibrate | calibrate | Wrapped mapping.fit in try/except | |
| 186 | + |
| 187 | +## Cross-Domain Benchmark |
| 188 | + |
| 189 | +**Model pair:** all-MiniLM-L6-v2 (384d) → all-mpnet-base-v2 (768d) |
| 190 | +**Corpus:** 500 texts across 10 domains (medical, legal, code, finance, science, news, philosophy, cooking, math, travel) |
| 191 | + |
| 192 | +### Embedding Stability (Number Preservation) |
| 193 | + |
| 194 | +| Check | Result | |
| 195 | +|-------|--------| |
| 196 | +| Source self-retrieval R@1 | 100.0% | |
| 197 | +| Target self-retrieval R@1 | 100.0% | |
| 198 | +| Re-embed exact match (source) | True (max diff: 0.00e+00) | |
| 199 | +| Re-embed exact match (target) | True (max diff: 0.00e+00) | |
| 200 | + |
| 201 | +**Conclusion:** Embeddings are perfectly deterministic. Same input → same vector, zero drift. |
| 202 | + |
| 203 | +### Mapping Fidelity |
| 204 | + |
| 205 | +| Metric | Value | |
| 206 | +|--------|-------| |
| 207 | +| Mapped vs target cosine (mean) | 0.9985 | |
| 208 | +| Mapped vs target cosine (p5) | 0.9967 | |
| 209 | +| Mapped vs target cosine (min) | 0.9919 | |
| 210 | + |
| 211 | +Per-domain cosine (all > 0.997): |
| 212 | + |
| 213 | +| Domain | Cosine | |
| 214 | +|--------|--------| |
| 215 | +| medical_abstracts | 0.9987 | |
| 216 | +| legal_contracts | 0.9987 | |
| 217 | +| code_reviews | 0.9984 | |
| 218 | +| financial_reports | 0.9985 | |
| 219 | +| scientific_papers | 0.9986 | |
| 220 | +| news_articles | 0.9989 | |
| 221 | +| philosophy_texts | 0.9980 | |
| 222 | +| cooking_recipes | 0.9984 | |
| 223 | +| math_problems | 0.9979 | |
| 224 | +| travel_guides | 0.9987 | |
| 225 | + |
| 226 | +### Cross-Domain Query Retrieval (K=500) |
| 227 | + |
| 228 | +| Domain | Mapped R@1 | Mapped R@10 | Ceiling R@1 | Retention | |
| 229 | +|--------|-----------|-------------|-------------|-----------| |
| 230 | +| medical_abstracts | 1 | 1 | 1 | 100% | |
| 231 | +| legal_contracts | 1 | 1 | 1 | 100% | |
| 232 | +| code_reviews | 1 | 1 | 1 | 100% | |
| 233 | +| financial_reports | 1 | 1 | 1 | 100% | |
| 234 | +| scientific_papers | 1 | 1 | 1 | 100% | |
| 235 | +| news_articles | 1 | 1 | 1 | 100% | |
| 236 | +| philosophy_texts | 1 | 1 | 1 | 100% | |
| 237 | +| cooking_recipes | 1 | 1 | 1 | 100% | |
| 238 | +| math_problems | 1 | 1 | 1 | 100% | |
| 239 | +| travel_guides | 1 | 1 | 1 | 100% | |
| 240 | + |
| 241 | +### Gate Verdict |
| 242 | + |
| 243 | +Gate predicts WARN (0.838) because the synthetic corpus is cleaner than real-world data. Actual measured retention is 100% across all domains. The gate is conservative — correct behavior for production use. |
| 244 | + |
| 245 | +### Mapping Type Comparison |
| 246 | + |
| 247 | +| Type | Gate | R@1 | R@10 | |
| 248 | +|------|------|-----|------| |
| 249 | +| Ridge | WARN | 1.000 | 1.000 | |
| 250 | +| LowRankAffine | WARN | 1.000 | 1.000 | |
0 commit comments