boxsafe 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.directory +2 -0
  2. package/.env.example +3 -0
  3. package/AUDIT_LANG.md +45 -0
  4. package/BOXSAFE_VERSION_NOTES.md +14 -0
  5. package/README.md +4 -0
  6. package/TODO.md +130 -0
  7. package/adapters/index.ts +27 -0
  8. package/adapters/primary/cli-adapter.ts +56 -0
  9. package/adapters/secondary/filesystem/node-filesystem.ts +307 -0
  10. package/adapters/secondary/system/configuration.ts +147 -0
  11. package/ai/caller.ts +42 -0
  12. package/ai/label.ts +33 -0
  13. package/ai/modelConfig.ts +236 -0
  14. package/ai/provider.ts +111 -0
  15. package/boxsafe.config.json +68 -0
  16. package/core/auth/dasktop/cred/CRED.md +112 -0
  17. package/core/auth/dasktop/cred/credLinux.ts +82 -0
  18. package/core/auth/dasktop/cred/credWin.ts +2 -0
  19. package/core/config/defaults/boxsafeDefaults.ts +67 -0
  20. package/core/config/defaults/index.ts +1 -0
  21. package/core/config/loadConfig.ts +133 -0
  22. package/core/loop/about.md +13 -0
  23. package/core/loop/boxConfig.ts +20 -0
  24. package/core/loop/buildExecCommand.ts +76 -0
  25. package/core/loop/cmd/execode.ts +121 -0
  26. package/core/loop/cmd/test.js +3 -0
  27. package/core/loop/execLoop.ts +341 -0
  28. package/core/loop/git/VERSIONING.md +17 -0
  29. package/core/loop/git/commands.ts +11 -0
  30. package/core/loop/git/gitClient.ts +78 -0
  31. package/core/loop/git/index.ts +99 -0
  32. package/core/loop/git/runVersionControlRunner.ts +33 -0
  33. package/core/loop/initNavigator.ts +44 -0
  34. package/core/loop/initTasksManager.ts +35 -0
  35. package/core/loop/runValidation.ts +25 -0
  36. package/core/loop/tasks/AGENT-TASKS.md +36 -0
  37. package/core/loop/tasks/index.ts +96 -0
  38. package/core/loop/toolCalls.ts +168 -0
  39. package/core/loop/toolDispatcher.ts +146 -0
  40. package/core/loop/traceLogger.ts +106 -0
  41. package/core/loop/types.ts +26 -0
  42. package/core/loop/versionControlAdapter.ts +36 -0
  43. package/core/loop/waterfall.ts +404 -0
  44. package/core/loop/writeArtifactAtomically.ts +13 -0
  45. package/core/navigate/NAVIGATE.md +186 -0
  46. package/core/navigate/about.md +128 -0
  47. package/core/navigate/examples.ts +367 -0
  48. package/core/navigate/handler.ts +148 -0
  49. package/core/navigate/index.ts +32 -0
  50. package/core/navigate/navigate.test.ts +372 -0
  51. package/core/navigate/navigator.ts +437 -0
  52. package/core/navigate/types.ts +132 -0
  53. package/core/navigate/utils.ts +146 -0
  54. package/core/paths/paths.ts +33 -0
  55. package/core/ports/index.ts +271 -0
  56. package/core/segments/CONVENTIONS.md +30 -0
  57. package/core/segments/loop/index.ts +18 -0
  58. package/core/segments/map.ts +56 -0
  59. package/core/segments/navigate/index.ts +20 -0
  60. package/core/segments/versionControl/index.ts +18 -0
  61. package/core/util/logger.ts +128 -0
  62. package/docs/AGENT-TASKS.md +36 -0
  63. package/docs/ARQUITETURA_CORRECAO.md +121 -0
  64. package/docs/CONVENTIONS.md +30 -0
  65. package/docs/CRED.md +112 -0
  66. package/docs/L_RAG.md +567 -0
  67. package/docs/NAVIGATE.md +186 -0
  68. package/docs/PRIMARY_ACTORS.md +78 -0
  69. package/docs/SECONDARY_ACTORS.md +174 -0
  70. package/docs/VERSIONING.md +17 -0
  71. package/docs/boxsafe.config.md +472 -0
  72. package/eslint.config.mts +15 -0
  73. package/main.ts +53 -0
  74. package/memo/generated/codelog.md +13 -0
  75. package/memo/state/tasks/state.json +6 -0
  76. package/memo/state/tasks/tasks/task_001.md +2 -0
  77. package/memo/states-logs/logs.txt +7 -0
  78. package/memo/states-logs/trace-mljvrxvi-9g0k4q.jsonl +11 -0
  79. package/memo/states-logs/trace-mljvvc9j-pe9ekj.jsonl +11 -0
  80. package/memo/states-logs/trace-mljvvm1c-wbnqzp.jsonl +11 -0
  81. package/memo/states-logs/trace-mljxecwn-9xh3nw.jsonl +11 -0
  82. package/memo/states-logs/trace-mljxqkfm-ipijik.jsonl +11 -0
  83. package/memo/states-logs/trace-mljxwtrw-3fanky.jsonl +11 -0
  84. package/memo/states-logs/trace-mljxzen3-m8iinh.jsonl +11 -0
  85. package/memo/states-logs/trace-mljyucef-td6odn.jsonl +11 -0
  86. package/memo/states-logs/trace-mljyuprw-b1a6f4.jsonl +11 -0
  87. package/memo/states-logs/trace-mljyvefl-b6yoce.jsonl +11 -0
  88. package/memo/states-logs/trace-mljyxjo4-n7ibj2.jsonl +13 -0
  89. package/memo/states-logs/trace-mljziez5-8drqtn.jsonl +13 -0
  90. package/memo/states-logs/trace-mljziulp-dtd03z.jsonl +13 -0
  91. package/memo/states-logs/trace-mljzjwrq-1p2krb.jsonl +13 -0
  92. package/memo/states-logs/trace-mljzl0i7-b1cqa6.jsonl +13 -0
  93. package/memo/states-logs/trace-mljzmlk6-7kdyls.jsonl +13 -0
  94. package/memo/states-logs/trace-mlk0oj25-xa3dcu.jsonl +13 -0
  95. package/memo/states-logs/trace-mlk1x59q-713huj.jsonl +14 -0
  96. package/memo/states-logs/trace-mlk22dz8-7fd6hq.jsonl +14 -0
  97. package/memo/states-logs/trace-mlk241uy-wmx907.jsonl +14 -0
  98. package/memo/states-logs/trace-mlk2bf5r-yoh1vg.jsonl +15 -0
  99. package/package.json +44 -0
  100. package/pnpm-workspace.yaml +4 -0
  101. package/prompt_improvement_example.md +55 -0
  102. package/remove.txt +1 -0
  103. package/tests/adapters.test.ts +128 -0
  104. package/tests/extractCode.test.ts +26 -0
  105. package/tests/integration.test.ts +83 -0
  106. package/tests/loadConfig.test.ts +25 -0
  107. package/tests/navigatorBoundary.test.ts +17 -0
  108. package/tests/ports.test.ts +84 -0
  109. package/tests/runAllTests.ts +49 -0
  110. package/tests/toolCalls.test.ts +149 -0
  111. package/tests/waterfall.test.ts +52 -0
  112. package/tsconfig.json +32 -0
  113. package/tsup.config.ts +17 -0
  114. package/types.d.ts +96 -0
  115. package/util/ANSI.ts +29 -0
  116. package/util/extractCode.ts +217 -0
  117. package/util/extractToolCalls.ts +80 -0
  118. package/util/logger.ts +125 -0
package/docs/L_RAG.md ADDED
@@ -0,0 +1,567 @@
1
+ # 📚 RAG – Roadmap Matemático Essencial
2
+ > Objetivo: Entender profundamente busca vetorial e embeddings
3
+ > Foco: Teoria + Prática + Validação
4
+ > Tempo estimado: 3-4 semanas (1-2h/dia)
5
+
6
+ ---
7
+
8
+ # 🚀 FASE 0 — Quick Win (COMEÇAR AQUI!)
9
+ **Objetivo:** Ver RAG funcionando ANTES de estudar teoria
10
+
11
+ ## 🎯 Projeto Prático Mínimo
12
+ - [ ] Instalar Qdrant local (Docker)
13
+ - [ ] Gerar embeddings de 3-5 frases
14
+ - [ ] Indexar no Qdrant
15
+ - [ ] Fazer busca vetorial simples
16
+ - [ ] Ver os scores de similaridade
17
+
18
+ ### 📖 Fontes
19
+ **Vídeo (PT-BR):**
20
+ - [RAG do Zero - Como Funciona na Prática](https://www.youtube.com/watch?v=T-D1OfcDW1M) - Universo Programado
21
+
22
+ **Código Prático:**
23
+ - [Qdrant Quickstart](https://qdrant.tech/documentation/quick-start/)
24
+ - [Mini RAG em 50 linhas](https://github.com/openai/openai-cookbook/blob/main/examples/Question_answering_using_embeddings.ipynb)
25
+
26
+ ### ✅ Checkpoint
27
+ - [ ] Consegui fazer uma busca e recuperar o texto mais similar
28
+ - [ ] Entendi (mesmo que superficialmente) que texto → vetor → busca
29
+
30
+ ---
31
+
32
+ # ✅ FASE 1 — Fundamentos Absolutos
33
+
34
+ ## 🔹 1. Vetores em ℝⁿ
35
+ **O que aprender:**
36
+ - [ ] O que é um vetor (lista de números)
37
+ - [ ] Representação geométrica (seta no espaço)
38
+ - [ ] Soma de vetores
39
+ - [ ] Multiplicação por escalar
40
+ - [ ] Vetores em 2D, 3D e alta dimensão
41
+
42
+ ### 📖 Fontes
43
+ **Vídeo (PT-BR):**
44
+ - [Vetores - Essência da Álgebra Linear](https://www.youtube.com/watch?v=fNk_zzaMoSs) - 3Blue1Brown (legendado PT)
45
+
46
+ **Texto/Paper:**
47
+ - [Introduction to Linear Algebra - MIT OpenCourseWare](https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/resources/lecture-1-the-geometry-of-linear-equations/) - Primeiras 10 páginas
48
+
49
+ **Código Prático:**
50
+ - [NumPy Vectors Tutorial](https://numpy.org/doc/stable/user/quickstart.html#the-basics)
51
+
52
+ ### 🏆 Challenge
53
+ **Implementar:**
54
+ ```javascript
55
+ // Criar funções sem libs externas:
56
+ function addVectors(v1, v2) { /* ... */ }
57
+ function scalarMultiply(scalar, vector) { /* ... */ }
58
+ function vectorMagnitude(v) { /* ... */ }
59
+ ```
60
+
61
+ ### ✅ Checkpoint
62
+ - [ ] Implementei soma e multiplicação de vetores
63
+ - [ ] Entendi que embedding é só um vetor grande
64
+
65
+ ---
66
+
67
+ ## 🔹 2. Produto Escalar (Dot Product)
68
+ **O que aprender:**
69
+ - [ ] Fórmula: v·w = v₁w₁ + v₂w₂ + ... + vₙwₙ
70
+ - [ ] Interpretação geométrica (projeção)
71
+ - [ ] Relação com ângulo entre vetores
72
+ - [ ] Quando resultado é positivo/negativo/zero
73
+
74
+ ### 📖 Fontes
75
+ **Vídeo (PT-BR):**
76
+ - [Produto Escalar e Vetorial](https://www.youtube.com/watch?v=LyGKycYT2v0) - Ferreto Matemática
77
+
78
+ **Texto/Paper:**
79
+ - [Dot Product - Better Explained](https://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/)
80
+
81
+ **Visualização Interativa:**
82
+ - [Dot Product Visualization](https://www.geogebra.org/m/cF7RwK3H)
83
+
84
+ ### 🏆 Challenge
85
+ **LeetCode Style:**
86
+ - Implementar dot product manualmente
87
+ - Calcular dot product de 2 embeddings reais do OpenAI
88
+ - Prever se textos são similares antes de calcular
89
+
90
+ ### ✅ Checkpoint
91
+ - [ ] Implementei dot product do zero
92
+ - [ ] Entendi que quanto maior o dot product, mais "alinhados" os vetores
93
+
94
+ ---
95
+
96
+ ## 🔹 3. Norma de um Vetor
97
+ **O que aprender:**
98
+ - [ ] O que é magnitude/tamanho do vetor
99
+ - [ ] Norma Euclidiana: ||v|| = √(v₁² + v₂² + ... + vₙ²)
100
+ - [ ] Normalização de vetores (unit vector)
101
+ - [ ] Por que normalizar importa para similaridade
102
+
103
+ ### 📖 Fontes
104
+ **Vídeo (PT-BR):**
105
+ - [Norma de Vetores](https://www.youtube.com/watch?v=8QiXsv7JlaA) - Matemática Rio
106
+
107
+ **Texto/Paper:**
108
+ - [Vector Norms](https://mathworld.wolfram.com/VectorNorm.html) - Wolfram MathWorld (seções 1-3)
109
+
110
+ ### 🏆 Challenge
111
+ ```javascript
112
+ // Implementar:
113
+ function euclideanNorm(vector) { /* ... */ }
114
+ function normalize(vector) { /* ... */ }
115
+
116
+ // Testar:
117
+ // Normalizar um embedding
118
+ // Verificar que norma = 1 após normalização
119
+ ```
120
+
121
+ ### ✅ Checkpoint
122
+ - [ ] Calculei norma de vetores manualmente
123
+ - [ ] Normalizei vetores e verifiquei ||v|| = 1
124
+
125
+ ---
126
+
127
+ # ✅ FASE 2 — Similaridade Vetorial (Coração do RAG)
128
+
129
+ ## 🔹 4. Similaridade de Cosseno
130
+ **O que aprender:**
131
+ - [ ] Fórmula: cos(θ) = (v·w) / (||v|| ||w||)
132
+ - [ ] Por que mede ângulo e não distância
133
+ - [ ] Por que ignora magnitude
134
+ - [ ] Range: -1 (opostos) a 1 (idênticos)
135
+ - [ ] Quando usar cosine vs euclidean
136
+
137
+ ### 📖 Fontes
138
+ **Vídeo (PT-BR):**
139
+ - [Similaridade de Cosseno Explicada](https://www.youtube.com/watch?v=e9U0QAFbfLI) - Programador Lhama
140
+
141
+ **Paper:**
142
+ - [Cosine Similarity and Cosine Distance](https://arxiv.org/abs/1909.09427) - Seções 1-2
143
+
144
+ **Código Didático:**
145
+ - [Cosine Similarity from Scratch](https://github.com/ashishpatel26/Amazing-Feature-Engineering/blob/master/src/similarity_measures.py)
146
+
147
+ ### 🏆 Challenge
148
+ **Kaggle-style:**
149
+ - [Text Similarity Challenge](https://www.kaggle.com/code/adamschroeder/cosine-similarity-from-scratch)
150
+ - Implementar cosine similarity do zero
151
+ - Comparar com sklearn.metrics.pairwise.cosine_similarity
152
+ - Calcular similaridade entre 3 textos diferentes
153
+
154
+ ### ✅ Checkpoint
155
+ - [ ] Implementei cosine similarity sem libs
156
+ - [ ] Testei com embeddings reais e faz sentido
157
+
158
+ ---
159
+
160
+ ## 🔹 5. Distância Euclidiana
161
+ **O que aprender:**
162
+ - [ ] Fórmula: d(v,w) = √Σ(vᵢ - wᵢ)²
163
+ - [ ] Diferença entre distância e ângulo
164
+ - [ ] Quando usar euclidean vs cosine
165
+ - [ ] Problema da "maldição da dimensionalidade"
166
+
167
+ ### 📖 Fontes
168
+ **Vídeo (PT-BR):**
169
+ - [Distância Euclidiana](https://www.youtube.com/watch?v=4FpSlaOU_ko) - Sandeco
170
+
171
+ **Texto Comparativo:**
172
+ - [Cosine vs Euclidean Distance](https://cmry.github.io/notes/euclidean-v-cosine) - Blog técnico
173
+
174
+ ### 🏆 Challenge
175
+ ```javascript
176
+ // Implementar ambas e comparar:
177
+ function euclideanDistance(v1, v2) { /* ... */ }
178
+ function cosineSimilarity(v1, v2) { /* ... */ }
179
+
180
+ // Dataset de teste:
181
+ // 3 frases sobre programação
182
+ // 3 frases sobre culinária
183
+ // Qual métrica separa melhor os grupos?
184
+ ```
185
+
186
+ ### ✅ Checkpoint
187
+ - [ ] Entendi quando usar cada métrica
188
+ - [ ] Testei ambas em dados reais
189
+
190
+ ---
191
+
192
+ # ✅ FASE 3 — Chunking (CRÍTICO PARA RAG)
193
+
194
+ ## 🔹 6. Text Chunking
195
+ **O que aprender:**
196
+ - [ ] Por que dividir texto em pedaços
197
+ - [ ] Fixed-size chunking
198
+ - [ ] Sentence-based chunking
199
+ - [ ] Semantic chunking
200
+ - [ ] Overlap entre chunks (por que e quanto)
201
+ - [ ] Tamanho ideal: 256-512 tokens
202
+
203
+ ### 📖 Fontes
204
+ **Vídeo (PT-BR):**
205
+ - [Chunking Strategies para RAG](https://www.youtube.com/watch?v=8OJC21T2SL4) - AI Brasil
206
+
207
+ **Paper Fundamental:**
208
+ - [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) - Seção 3.1
209
+
210
+ **Repo Didático:**
211
+ - [LangChain Text Splitters](https://github.com/langchain-ai/langchain/tree/master/libs/text-splitters) - Ver exemplos
212
+
213
+ **Artigo Prático:**
214
+ - [Chunking Strategies for LLM Applications](https://www.pinecone.io/learn/chunking-strategies/)
215
+
216
+ ### 🏆 Challenge
217
+ **Implementar:**
218
+ ```javascript
219
+ // 3 estratégias diferentes:
220
+ function fixedSizeChunk(text, size, overlap) { /* ... */ }
221
+ function sentenceChunk(text, maxSentences) { /* ... */ }
222
+ function semanticChunk(text, embedModel) { /* ... */ }
223
+
224
+ // Testar com documento de 5000 palavras
225
+ // Comparar quantidade e qualidade dos chunks
226
+ ```
227
+
228
+ **Teste Real:**
229
+ - Pegar um artigo técnico
230
+ - Fazer chunking com 3 estratégias
231
+ - Gerar embeddings
232
+ - Fazer perguntas e ver qual recupera melhor
233
+
234
+ ### ✅ Checkpoint
235
+ - [ ] Implementei 3 estratégias de chunking
236
+ - [ ] Testei qual funciona melhor para meu caso de uso
237
+
238
+ ---
239
+
240
+ # ✅ FASE 4 — Embeddings (Texto → Matemática)
241
+
242
+ ## 🔹 7. Embeddings Fundamentais
243
+ **O que aprender:**
244
+ - [ ] O que é um embedding
245
+ - [ ] Como modelos transformam texto em vetor
246
+ - [ ] Word2Vec (conceito histórico)
247
+ - [ ] Transformers e attention (conceito geral)
248
+ - [ ] Por que vetores próximos = significado similar
249
+ - [ ] Espaço semântico
250
+
251
+ ### 📖 Fontes
252
+ **Vídeo (PT-BR):**
253
+ - [O que são Embeddings](https://www.youtube.com/watch?v=wjZofJX0v4M) - Código Fonte TV
254
+
255
+ **Paper Clássico (ler introdução):**
256
+ - [Word2Vec - Efficient Estimation of Word Representations](https://arxiv.org/abs/1301.3781)
257
+
258
+ **Paper Moderno:**
259
+ - [Sentence-BERT: Sentence Embeddings using Siamese BERT](https://arxiv.org/abs/1908.10084) - Seções 1-3
260
+
261
+ **Visualização Interativa:**
262
+ - [Tensorflow Embedding Projector](https://projector.tensorflow.org/)
263
+ - [Word2Vec Visualizer](https://anvaka.github.io/pm/#/galaxy/word2vec-wiki)
264
+
265
+ **Repo Prático:**
266
+ - [OpenAI Embeddings Guide](https://github.com/openai/openai-cookbook/blob/main/examples/Embedding_long_inputs.ipynb)
267
+
268
+ ### 🏆 Challenge
269
+ **Projeto:**
270
+ 1. Gerar embeddings de 20 frases (10 sobre tech, 10 sobre esporte)
271
+ 2. Reduzir dimensionalidade para 2D (usar PCA ou t-SNE)
272
+ 3. Plotar no gráfico
273
+ 4. Verificar se formam clusters
274
+
275
+ **Ferramentas:**
276
+ - [Scikit-learn PCA](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html)
277
+ - [Plotly para visualização](https://plotly.com/javascript/)
278
+
279
+ ### ✅ Checkpoint
280
+ - [ ] Gerei embeddings e visualizei em 2D
281
+ - [ ] Entendi que textos similares ficam próximos no espaço
282
+
283
+ ---
284
+
285
+ # ✅ FASE 5 — Busca Eficiente (Implementação Real)
286
+
287
+ ## 🔹 8. Nearest Neighbor Search
288
+ **O que aprender:**
289
+ - [ ] O que é k-Nearest Neighbors (kNN)
290
+ - [ ] Busca exata (brute force)
291
+ - [ ] Por que busca linear não escala
292
+ - [ ] Approximate Nearest Neighbor (ANN)
293
+ - [ ] Trade-off: velocidade vs precisão
294
+
295
+ ### 📖 Fontes
296
+ **Vídeo (PT-BR):**
297
+ - [KNN - K-Nearest Neighbors](https://www.youtube.com/watch?v=HVXime0nQeI) - Programação Dinâmica
298
+
299
+ **Paper Survey:**
300
+ - [A Survey of Approximate Nearest Neighbor Search](https://arxiv.org/abs/1908.02143) - Seção 1-2
301
+
302
+ **Benchmark Interativo:**
303
+ - [ANN Benchmarks](http://ann-benchmarks.com/) - Comparar algoritmos
304
+
305
+ ### 🏆 Challenge
306
+ **Implementar:**
307
+ ```javascript
308
+ // Busca exata (brute force)
309
+ function exactKNN(query, vectors, k) {
310
+ // Calcular similaridade com TODOS
311
+ // Retornar top-k
312
+ }
313
+
314
+ // Medir tempo com:
315
+ // 100 vetores
316
+ // 1.000 vetores
317
+ // 10.000 vetores
318
+ // Ver explosão de tempo
319
+ ```
320
+
321
+ **Benchmark:**
322
+ - Comparar sua implementação com Qdrant
323
+ - Ver diferença de velocidade
324
+
325
+ ### ✅ Checkpoint
326
+ - [ ] Implementei busca exata
327
+ - [ ] Entendi por que preciso de ANN
328
+
329
+ ---
330
+
331
+ ## 🔹 9. HNSW (Hierarchical Navigable Small World)
332
+ **O que aprender:**
333
+ - [ ] Conceito de grafo de navegação
334
+ - [ ] Estrutura hierárquica
335
+ - [ ] Como insere novos vetores
336
+ - [ ] Como busca (skip list probabilístico)
337
+ - [ ] Parâmetros: M e ef
338
+
339
+ ### 📖 Fontes
340
+ **Vídeo (PT-BR):**
341
+ - [Vector Databases Explicado](https://www.youtube.com/watch?v=dN0lsF2cvm4) - Filipe Deschamps (parte sobre HNSW)
342
+
343
+ **Paper Original:**
344
+ - [Efficient and Robust Approximate Nearest Neighbor Search Using HNSW](https://arxiv.org/abs/1603.09320)
345
+
346
+ **Visualização:**
347
+ - [HNSW Interactive Demo](https://github.com/nmslib/hnswlib) - Ver README com GIFs
348
+
349
+ **Documentação Técnica:**
350
+ - [Qdrant HNSW Implementation](https://qdrant.tech/documentation/concepts/indexing/#hnsw)
351
+
352
+ ### 🏆 Challenge
353
+ **Projeto Comparativo:**
354
+ 1. Indexar 10.000 embeddings
355
+ 2. Testar busca com diferentes parâmetros HNSW
356
+ 3. Medir: tempo de busca, recall, memória
357
+ 4. Documentar trade-offs
358
+
359
+ **Ferramenta:**
360
+ - [Qdrant](https://qdrant.tech/)
361
+ - [Weaviate](https://weaviate.io/)
362
+
363
+ ### ✅ Checkpoint
364
+ - [ ] Configurei HNSW no Qdrant
365
+ - [ ] Entendi impacto dos parâmetros M e ef
366
+
367
+ ---
368
+
369
+ # ✅ FASE 6 — Espaço Vetorial (Teoria Avançada)
370
+
371
+ ## 🔹 10. Fundamentos de Espaço Vetorial
372
+ **O que aprender:**
373
+ - [ ] O que é dimensão
374
+ - [ ] Base de um espaço vetorial
375
+ - [ ] Combinação linear (intuição)
376
+ - [ ] Subespaços
377
+ - [ ] Por que embeddings têm 384/768/1536 dimensões
378
+
379
+ ### 📖 Fontes
380
+ **Vídeo (PT-BR):**
381
+ - [Espaços Vetoriais](https://www.youtube.com/watch?v=TgKwz5Ikpc8) - USP Online
382
+
383
+ **Texto Teórico:**
384
+ - [Linear Algebra - Chapter 2](https://www.math.ucdavis.edu/~linear/linear-guest.pdf) - UC Davis (páginas 50-80)
385
+
386
+ **Opcional (se quiser aprofundar):**
387
+ - [3Blue1Brown - Essence of Linear Algebra](https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab) - Playlist completa legendada
388
+
389
+ ### 🏆 Challenge
390
+ **Conceitual:**
391
+ - Explicar por que não podemos visualizar 768 dimensões
392
+ - Desenhar analogia de redução de dimensionalidade
393
+ - Entender por que PCA "achata" informação
394
+
395
+ ### ✅ Checkpoint
396
+ - [ ] Entendi conceito de dimensionalidade
397
+ - [ ] Sei por que embeddings são vetores densos em alta dimensão
398
+
399
+ ---
400
+
401
+ # ✅ FASE 7 — Avaliação de RAG (Qualidade)
402
+
403
+ ## 🔹 11. Métricas de Retrieval
404
+ **O que aprender:**
405
+ - [ ] Precision, Recall, F1
406
+ - [ ] Mean Reciprocal Rank (MRR)
407
+ - [ ] Normalized Discounted Cumulative Gain (NDCG)
408
+ - [ ] Hit Rate @ K
409
+ - [ ] Como criar dataset de teste
410
+
411
+ ### 📖 Fontes
412
+ **Vídeo (PT-BR):**
413
+ - [Métricas de Avaliação - ML](https://www.youtube.com/watch?v=Kdsp6soqA7o) - Mario Filho
414
+
415
+ **Paper Fundamental:**
416
+ - [Evaluating RAG Systems](https://arxiv.org/abs/2309.15217) - Seções 3-4
417
+
418
+ **Repo Prático:**
419
+ - [RAG Evaluation Framework](https://github.com/explodinggradients/ragas)
420
+
421
+ **Artigo Técnico:**
422
+ - [How to Evaluate RAG Applications](https://www.confident-ai.com/blog/how-to-evaluate-a-rag-system)
423
+
424
+ ### 🏆 Challenge
425
+ **Projeto Final:**
426
+ 1. Criar dataset de 50 perguntas + respostas corretas
427
+ 2. Implementar RAG completo
428
+ 3. Calcular métricas: Precision@5, Recall@5, MRR
429
+ 4. Testar 3 estratégias de chunking
430
+ 5. Documentar qual funcionou melhor
431
+
432
+ **Ferramenta:**
433
+ - [RAGAS Framework](https://github.com/explodinggradients/ragas)
434
+
435
+ ### ✅ Checkpoint
436
+ - [ ] Avaliei meu RAG com métricas objetivas
437
+ - [ ] Sei identificar quando retrieval falha
438
+
439
+ ---
440
+
441
+ ## 🔹 12. Debugging e Otimização
442
+ **O que aprender:**
443
+ - [ ] Inspecionar scores de similaridade
444
+ - [ ] Por que recuperou chunks errados
445
+ - [ ] Ajustar top-k (quantidade de chunks)
446
+ - [ ] Re-ranking de resultados
447
+ - [ ] Hybrid search (keyword + vector)
448
+
449
+ ### 📖 Fontes
450
+ **Vídeo (PT-BR):**
451
+ - [Otimizando RAG na Prática](https://www.youtube.com/watch?v=UVn2NroKQCw) - AI Pub
452
+
453
+ **Artigo Prático:**
454
+ - [Advanced RAG Techniques](https://blog.llamaindex.ai/a-cheat-sheet-and-some-recipes-for-building-advanced-rag-803a9d94c41b)
455
+
456
+ **Repo com Exemplos:**
457
+ - [LangChain RAG Cookbook](https://github.com/langchain-ai/rag-from-scratch)
458
+
459
+ ### 🏆 Challenge
460
+ **Debugging Real:**
461
+ 1. Implementar logging de scores
462
+ 2. Identificar falsos positivos
463
+ 3. Testar hybrid search
464
+ 4. Implementar re-ranking com cross-encoder
465
+
466
+ **Dataset de teste:**
467
+ - [MS MARCO](https://microsoft.github.io/msmarco/) - Dataset acadêmico
468
+
469
+ ### ✅ Checkpoint
470
+ - [ ] Consigo debugar por que RAG falhou
471
+ - [ ] Implementei estratégias de melhoria
472
+
473
+ ---
474
+
475
+ # 🎯 PROJETO FINAL INTEGRADOR
476
+
477
+ ## 🏆 Challenge Master
478
+ **Construir RAG Production-Ready:**
479
+
480
+ ### Requisitos:
481
+ 1. **Dataset:** 100+ documentos sobre tema técnico
482
+ 2. **Chunking:** Implementar 2 estratégias
483
+ 3. **Embeddings:** Usar modelo de sua escolha
484
+ 4. **Vector DB:** Qdrant com HNSW configurado
485
+ 5. **API:** Endpoint REST para queries
486
+ 6. **Avaliação:** 30 perguntas de teste + métricas
487
+ 7. **Logging:** Rastrear todas as queries e scores
488
+ 8. **Documentação:** README explicando decisões
489
+
490
+ ### Entregáveis:
491
+ - [ ] Código no GitHub
492
+ - [ ] Métricas documentadas
493
+ - [ ] Análise de casos de falha
494
+ - [ ] Proposta de melhorias futuras
495
+
496
+ ### Validação:
497
+ - Precision@5 > 0.7
498
+ - Tempo de resposta < 500ms
499
+ - Recall@10 > 0.8
500
+
501
+ ---
502
+
503
+ # 📊 Ordem de Prioridade Revisada
504
+
505
+ ## 🔥 Altíssima (NÃO PULAR):
506
+ - Fase 0 (Quick Win)
507
+ - Fase 1 (itens 1-3)
508
+ - Fase 2 (itens 4-5)
509
+ - Fase 3 (item 6 - Chunking)
510
+ - Fase 4 (item 7 - Embeddings)
511
+
512
+ ## ⚡ Importante:
513
+ - Fase 5 (itens 8-9)
514
+ - Fase 7 (itens 11-12)
515
+
516
+ ## 🎓 Avançado (pode deixar para depois):
517
+ - Fase 6 (item 10)
518
+
519
+ ---
520
+
521
+ # 🗓️ Cronograma Sugerido
522
+
523
+ **Semana 1:**
524
+ - Fase 0 + Fase 1 (1-3)
525
+
526
+ **Semana 2:**
527
+ - Fase 2 (4-5) + Fase 3 (6)
528
+
529
+ **Semana 3:**
530
+ - Fase 4 (7) + Fase 5 (8-9)
531
+
532
+ **Semana 4:**
533
+ - Fase 7 (11-12) + Projeto Final
534
+
535
+ ---
536
+
537
+ # 📚 Recursos Extras
538
+
539
+ ## Comunidades (tirar dúvidas):
540
+ - [Discord AI Brasil](https://discord.gg/aidevsbrasil)
541
+ - [Reddit r/MachineLearning](https://www.reddit.com/r/MachineLearning/)
542
+ - [Qdrant Discord](https://discord.gg/qdrant)
543
+
544
+ ## Ferramentas úteis:
545
+ - [Notebook LM](https://notebooklm.google.com/) - Para estudar papers
546
+ - [Obsidian](https://obsidian.md/) - Organizar estudos
547
+ - [Anki](https://apps.ankiweb.net/) - Flashcards de conceitos
548
+
549
+ ## Datasets para praticar:
550
+ - [HuggingFace Datasets](https://huggingface.co/datasets)
551
+ - [Kaggle Datasets](https://www.kaggle.com/datasets)
552
+
553
+ ---
554
+
555
+ # ✅ Checklist Final de Domínio
556
+
557
+ Você dominou RAG quando conseguir:
558
+
559
+ - [ ] Explicar como texto vira vetor (embedding)
560
+ - [ ] Implementar cosine similarity do zero
561
+ - [ ] Explicar por que HNSW é mais rápido que busca linear
562
+ - [ ] Escolher estratégia de chunking baseado no contexto
563
+ - [ ] Debugar por que seu RAG retornou resposta errada
564
+ - [ ] Avaliar qualidade do RAG com métricas objetivas
565
+ - [ ] Construir RAG do zero sem frameworks pesados
566
+
567
+ **Parabéns! 🎉 Você agora entende RAG profundamente.**