amalfa 0.0.0-reserved → 1.0.1
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.
- package/.biomeignore +19 -0
- package/:memory: +0 -0
- package/:memory:-shm +0 -0
- package/:memory:-wal +0 -0
- package/CHANGELOG.md.old +43 -0
- package/LICENSE +21 -0
- package/README.md +359 -13
- package/README.old.md +112 -0
- package/ROADMAP.md +316 -0
- package/TEST_PLAN.md +561 -0
- package/agents.config.json +11 -0
- package/amalfa.config.example.ts +102 -0
- package/biome.json +49 -0
- package/bun.lock +371 -0
- package/docs/AGENT_PROTOCOLS.md +28 -0
- package/docs/ARCHITECTURAL_OVERVIEW.md +123 -0
- package/docs/BENTO_BOXING_DEPRECATION.md +281 -0
- package/docs/Bun-SQLite.html +464 -0
- package/docs/COMMIT_GUIDELINES.md +367 -0
- package/docs/DEVELOPER_ONBOARDING.md +36 -0
- package/docs/Graph and Vector Database Best Practices.md +214 -0
- package/docs/PERFORMANCE_BASELINES.md +88 -0
- package/docs/REPOSITORY_CLEANUP_SUMMARY.md +261 -0
- package/docs/edge-generation-methods.md +57 -0
- package/docs/elevator-pitch.md +118 -0
- package/docs/graph-and-vector-database-playbook.html +480 -0
- package/docs/hardened-sqlite.md +85 -0
- package/docs/headless-knowledge-management.md +79 -0
- package/docs/john-kaye-flux-prompt.md +46 -0
- package/docs/keyboard-shortcuts.md +80 -0
- package/docs/opinion-proceed-pattern.md +29 -0
- package/docs/polyvis-nodes-edges-schema.md +77 -0
- package/docs/protocols/lab-protocol.md +30 -0
- package/docs/reaction-iquest-loop-coder.md +46 -0
- package/docs/services.md +60 -0
- package/docs/sqlite-wal-readonly-trap.md +228 -0
- package/docs/strategy/css-architecture.md +40 -0
- package/docs/test-document-cycle.md +83 -0
- package/docs/test_lifecycle_E2E.md +4 -0
- package/docs/the-bicameral-graph.md +83 -0
- package/docs/user-guide.md +70 -0
- package/docs/vision-helper.md +53 -0
- package/drizzle/0000_minor_iron_fist.sql +19 -0
- package/drizzle/meta/0000_snapshot.json +139 -0
- package/drizzle/meta/_journal.json +13 -0
- package/example_usage.ts +39 -0
- package/experiment.sh +35 -0
- package/hello +2 -0
- package/index.html +52 -0
- package/knowledge/excalibur.md +12 -0
- package/package.json +60 -15
- package/plans/experience-graph-integration.md +60 -0
- package/prompts/gemini-king-mode-prompt.md +46 -0
- package/public/docs/MCP_TOOLS.md +372 -0
- package/schemas/README.md +20 -0
- package/schemas/cda.schema.json +84 -0
- package/schemas/conceptual-lexicon.schema.json +75 -0
- package/scratchpads/dummy-debrief-boxed.md +39 -0
- package/scratchpads/dummy-debrief.md +27 -0
- package/scratchpads/scratchpad-design.md +50 -0
- package/scratchpads/scratchpad-scrolling.md +20 -0
- package/scratchpads/scratchpad-toc-disappearance.md +23 -0
- package/scratchpads/scratchpad-toc.md +28 -0
- package/scratchpads/test_gardener.md +7 -0
- package/src/EnlightenedTriad.ts +146 -0
- package/src/JIT_Triad.ts +137 -0
- package/src/cli.ts +364 -0
- package/src/config/constants.ts +7 -0
- package/src/config/defaults.ts +99 -0
- package/src/core/BentoNormalizer.ts +113 -0
- package/src/core/EdgeWeaver.ts +145 -0
- package/src/core/FractureLogic.ts +22 -0
- package/src/core/Harvester.ts +73 -0
- package/src/core/LLMClient.ts +93 -0
- package/src/core/LouvainGate.ts +67 -0
- package/src/core/MarkdownMasker.ts +49 -0
- package/src/core/README.md +11 -0
- package/src/core/SemanticMatcher.ts +89 -0
- package/src/core/SemanticWeaver.ts +96 -0
- package/src/core/TagEngine.ts +56 -0
- package/src/core/TimelineWeaver.ts +61 -0
- package/src/core/VectorEngine.ts +232 -0
- package/src/daemon/index.ts +225 -0
- package/src/data/experience/test_doc_1.md +2 -0
- package/src/data/experience/test_doc_2.md +2 -0
- package/src/db/schema.ts +46 -0
- package/src/demo-triad.ts +45 -0
- package/src/gardeners/AutoTagger.ts +116 -0
- package/src/gardeners/BaseGardener.ts +55 -0
- package/src/llm/EnlightenedProvider.ts +95 -0
- package/src/mcp/README.md +6 -0
- package/src/mcp/index.ts +341 -0
- package/src/pipeline/AmalfaIngestor.ts +272 -0
- package/src/pipeline/HarvesterPipeline.ts +101 -0
- package/src/pipeline/Ingestor.ts +555 -0
- package/src/pipeline/PreFlightAnalyzer.ts +434 -0
- package/src/pipeline/README.md +7 -0
- package/src/pipeline/SemanticHarvester.ts +222 -0
- package/src/resonance/DatabaseFactory.ts +100 -0
- package/src/resonance/README.md +148 -0
- package/src/resonance/cli/README.md +7 -0
- package/src/resonance/cli/ingest.ts +41 -0
- package/src/resonance/cli/migrate.ts +54 -0
- package/src/resonance/config.ts +40 -0
- package/src/resonance/daemon.ts +236 -0
- package/src/resonance/db.ts +424 -0
- package/src/resonance/pipeline/README.md +7 -0
- package/src/resonance/pipeline/extract.ts +89 -0
- package/src/resonance/pipeline/transform_docs.ts +60 -0
- package/src/resonance/schema.ts +156 -0
- package/src/resonance/services/embedder.ts +131 -0
- package/src/resonance/services/simpleTokenizer.ts +119 -0
- package/src/resonance/services/stats.ts +327 -0
- package/src/resonance/services/tokenizer.ts +159 -0
- package/src/resonance/transform/cda.ts +393 -0
- package/src/resonance/types/enriched-cda.ts +112 -0
- package/src/services/README.md +56 -0
- package/src/services/llama.ts +59 -0
- package/src/services/llamauv.ts +56 -0
- package/src/services/olmo3.ts +58 -0
- package/src/services/phi.ts +52 -0
- package/src/types/artifact.ts +12 -0
- package/src/utils/EnvironmentVerifier.ts +67 -0
- package/src/utils/Logger.ts +21 -0
- package/src/utils/ServiceLifecycle.ts +207 -0
- package/src/utils/ZombieDefense.ts +244 -0
- package/src/utils/validator.ts +264 -0
- package/substack/substack-playbook-1.md +95 -0
- package/substack/substack-playbook-2.md +78 -0
- package/tasks/ui-investigation.md +26 -0
- package/test-db +0 -0
- package/test-db-shm +0 -0
- package/test-db-wal +0 -0
- package/tests/canary/verify_pinch_check.ts +44 -0
- package/tests/fixtures/ingest_test.md +12 -0
- package/tests/fixtures/ingest_test_boxed.md +13 -0
- package/tests/fixtures/safety_test.md +45 -0
- package/tests/fixtures/safety_test_boxed.md +49 -0
- package/tests/fixtures/tagged_output.md +49 -0
- package/tests/fixtures/tagged_test.md +49 -0
- package/tests/mcp-server-settings.json +8 -0
- package/tsconfig.json +46 -0
- package/verify-embedder.ts +54 -0
package/TEST_PLAN.md
ADDED
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
# AMALFA End-to-End Test Plan
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0.0
|
|
4
|
+
**Last Updated:** 2026-01-06
|
|
5
|
+
**Status:** Draft
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This document outlines comprehensive testing procedures for AMALFA (A Memory Layer For Agents), covering installation, configuration, ingestion, daemon operations, MCP integration, and edge cases.
|
|
10
|
+
|
|
11
|
+
## Test Environment
|
|
12
|
+
|
|
13
|
+
- **Runtime:** Bun v1.0+
|
|
14
|
+
- **OS:** macOS (primary), Linux (supported)
|
|
15
|
+
- **Test Data:** Sample markdown files, PolyVis documentation (~95 files)
|
|
16
|
+
- **MCP Client:** Claude Desktop
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Phase 1: Fresh Installation Test
|
|
21
|
+
|
|
22
|
+
**Objective:** Verify clean install from NPM works globally
|
|
23
|
+
|
|
24
|
+
### Steps
|
|
25
|
+
|
|
26
|
+
1. **Clean environment**
|
|
27
|
+
```bash
|
|
28
|
+
bun remove -g amalfa # Remove if exists
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. **Install from NPM**
|
|
32
|
+
```bash
|
|
33
|
+
bun add -g amalfa
|
|
34
|
+
amalfa --version
|
|
35
|
+
```
|
|
36
|
+
- Expected: Version 1.0.0 displayed
|
|
37
|
+
|
|
38
|
+
3. **Verify commands available**
|
|
39
|
+
```bash
|
|
40
|
+
amalfa help
|
|
41
|
+
amalfa doctor # Should show no database
|
|
42
|
+
```
|
|
43
|
+
- Expected: Help text displays all commands
|
|
44
|
+
- Expected: Doctor shows "Database not found" (clean state)
|
|
45
|
+
|
|
46
|
+
### Success Criteria
|
|
47
|
+
- [ ] Global installation completes without errors
|
|
48
|
+
- [ ] `amalfa` command available in PATH
|
|
49
|
+
- [ ] `--version` shows correct version
|
|
50
|
+
- [ ] `help` displays all commands
|
|
51
|
+
- [ ] `doctor` runs without crashing
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Phase 2: Single-Source Initialization
|
|
56
|
+
|
|
57
|
+
**Objective:** Test basic workflow with one source directory
|
|
58
|
+
|
|
59
|
+
### Steps
|
|
60
|
+
|
|
61
|
+
1. **Create test project**
|
|
62
|
+
```bash
|
|
63
|
+
mkdir -p /tmp/amalfa-test-single
|
|
64
|
+
cd /tmp/amalfa-test-single
|
|
65
|
+
mkdir docs
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Add sample markdown files**
|
|
69
|
+
```bash
|
|
70
|
+
echo "# Test Doc 1\nSome content about testing." > docs/test1.md
|
|
71
|
+
echo "# Test Doc 2\nMore content about features." > docs/test2.md
|
|
72
|
+
echo "# Test Doc 3\nFinal test document." > docs/test3.md
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. **Initialize (default config)**
|
|
76
|
+
```bash
|
|
77
|
+
amalfa init
|
|
78
|
+
```
|
|
79
|
+
- Expected: Progress indicators show 3/3 files
|
|
80
|
+
- Expected: Success message with stats (3 files, 3 nodes)
|
|
81
|
+
|
|
82
|
+
4. **Verify database**
|
|
83
|
+
```bash
|
|
84
|
+
amalfa stats
|
|
85
|
+
amalfa doctor
|
|
86
|
+
```
|
|
87
|
+
- Expected: Stats show 3 nodes, 3 embeddings
|
|
88
|
+
- Expected: Doctor shows all checks pass
|
|
89
|
+
|
|
90
|
+
5. **Test MCP server**
|
|
91
|
+
```bash
|
|
92
|
+
amalfa serve # Press Ctrl+C to stop after startup
|
|
93
|
+
```
|
|
94
|
+
- Expected: Server starts without errors
|
|
95
|
+
- Expected: Shows database path
|
|
96
|
+
|
|
97
|
+
### Success Criteria
|
|
98
|
+
- [ ] Default `./docs` directory discovered
|
|
99
|
+
- [ ] 3 markdown files ingested
|
|
100
|
+
- [ ] Database created in `.amalfa/resonance.db`
|
|
101
|
+
- [ ] Stats command shows accurate counts
|
|
102
|
+
- [ ] Doctor reports healthy state
|
|
103
|
+
- [ ] MCP server starts successfully
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Phase 3: Multi-Source Configuration
|
|
108
|
+
|
|
109
|
+
**Objective:** Test multiple source directories
|
|
110
|
+
|
|
111
|
+
### Steps
|
|
112
|
+
|
|
113
|
+
1. **Create multi-source project**
|
|
114
|
+
```bash
|
|
115
|
+
mkdir -p /tmp/amalfa-test-multi/{docs,notes,wiki}
|
|
116
|
+
cd /tmp/amalfa-test-multi
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
2. **Create config file**
|
|
120
|
+
```bash
|
|
121
|
+
cat > amalfa.config.json << 'EOF'
|
|
122
|
+
{
|
|
123
|
+
"sources": ["./docs", "./notes", "./wiki"],
|
|
124
|
+
"database": ".amalfa/multi.db"
|
|
125
|
+
}
|
|
126
|
+
EOF
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. **Add files to each source**
|
|
130
|
+
```bash
|
|
131
|
+
echo "# Documentation\nProject docs." > docs/doc1.md
|
|
132
|
+
echo "# Personal Notes\nMy notes." > notes/note1.md
|
|
133
|
+
echo "# Wiki Page\nWiki content." > wiki/wiki1.md
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
4. **Initialize**
|
|
137
|
+
```bash
|
|
138
|
+
amalfa init
|
|
139
|
+
```
|
|
140
|
+
- Expected: Shows "Sources: ./docs, ./notes, ./wiki"
|
|
141
|
+
- Expected: Processes 3 files from different directories
|
|
142
|
+
|
|
143
|
+
5. **Verify all sources ingested**
|
|
144
|
+
```bash
|
|
145
|
+
amalfa stats
|
|
146
|
+
ls -la .amalfa/
|
|
147
|
+
```
|
|
148
|
+
- Expected: 3 nodes from 3 different directories
|
|
149
|
+
- Expected: Database file is `multi.db` (not default)
|
|
150
|
+
|
|
151
|
+
### Success Criteria
|
|
152
|
+
- [ ] Config file loaded correctly
|
|
153
|
+
- [ ] All 3 source directories scanned
|
|
154
|
+
- [ ] Files from each source ingested
|
|
155
|
+
- [ ] Custom database path honored
|
|
156
|
+
- [ ] Stats show correct counts
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Phase 4: Daemon & File Watching
|
|
161
|
+
|
|
162
|
+
**Objective:** Test real-time file watching
|
|
163
|
+
|
|
164
|
+
### Steps
|
|
165
|
+
|
|
166
|
+
1. **Start daemon**
|
|
167
|
+
```bash
|
|
168
|
+
cd /tmp/amalfa-test-multi
|
|
169
|
+
amalfa daemon start
|
|
170
|
+
sleep 2
|
|
171
|
+
amalfa daemon status
|
|
172
|
+
```
|
|
173
|
+
- Expected: Daemon starts in background
|
|
174
|
+
- Expected: PID file created (`.amalfa-daemon.pid`)
|
|
175
|
+
- Expected: Status shows "running"
|
|
176
|
+
|
|
177
|
+
2. **Add new file**
|
|
178
|
+
```bash
|
|
179
|
+
echo "# New Document" > docs/new.md
|
|
180
|
+
sleep 5 # Wait for debounce + ingestion
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
3. **Verify update**
|
|
184
|
+
```bash
|
|
185
|
+
amalfa stats # Should show 4 nodes
|
|
186
|
+
tail -20 .amalfa-daemon.log # Check for update logs
|
|
187
|
+
```
|
|
188
|
+
- Expected: Stats show 4 nodes
|
|
189
|
+
- Expected: Log shows file change detected and processed
|
|
190
|
+
|
|
191
|
+
4. **Modify existing file**
|
|
192
|
+
```bash
|
|
193
|
+
echo "\n## Updated Section" >> docs/doc1.md
|
|
194
|
+
sleep 5
|
|
195
|
+
tail -20 .amalfa-daemon.log
|
|
196
|
+
```
|
|
197
|
+
- Expected: Log shows change detected
|
|
198
|
+
- Expected: Database updated (hash changed)
|
|
199
|
+
|
|
200
|
+
5. **Delete file**
|
|
201
|
+
```bash
|
|
202
|
+
rm docs/new.md
|
|
203
|
+
sleep 5
|
|
204
|
+
```
|
|
205
|
+
- Expected: Daemon handles deletion gracefully
|
|
206
|
+
|
|
207
|
+
6. **Stop daemon**
|
|
208
|
+
```bash
|
|
209
|
+
amalfa daemon stop
|
|
210
|
+
amalfa daemon status
|
|
211
|
+
```
|
|
212
|
+
- Expected: Daemon stops cleanly
|
|
213
|
+
- Expected: Status shows "stopped"
|
|
214
|
+
- Expected: PID file removed
|
|
215
|
+
|
|
216
|
+
### Success Criteria
|
|
217
|
+
- [ ] Daemon starts and runs in background
|
|
218
|
+
- [ ] PID file created correctly
|
|
219
|
+
- [ ] File additions detected within 5 seconds
|
|
220
|
+
- [ ] File modifications detected
|
|
221
|
+
- [ ] File deletions don't crash daemon
|
|
222
|
+
- [ ] Daemon stops cleanly with no orphaned processes
|
|
223
|
+
- [ ] Log file contains expected events
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Phase 5: MCP Integration Test
|
|
228
|
+
|
|
229
|
+
**Objective:** Test MCP server with Claude Desktop
|
|
230
|
+
|
|
231
|
+
### Steps
|
|
232
|
+
|
|
233
|
+
1. **Configure Claude Desktop**
|
|
234
|
+
- Edit: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"mcpServers": {
|
|
238
|
+
"amalfa-test": {
|
|
239
|
+
"command": "amalfa",
|
|
240
|
+
"args": ["serve"],
|
|
241
|
+
"cwd": "/tmp/amalfa-test-multi"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
2. **Restart Claude Desktop**
|
|
248
|
+
- Quit and reopen Claude Desktop
|
|
249
|
+
- Check MCP server status in settings
|
|
250
|
+
|
|
251
|
+
3. **Test each MCP tool**
|
|
252
|
+
|
|
253
|
+
**Tool 1: search_knowledge**
|
|
254
|
+
```
|
|
255
|
+
Prompt: "Search AMALFA for documents about 'wiki'"
|
|
256
|
+
Expected: Returns wiki1.md with relevant score
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Tool 2: get_node_content**
|
|
260
|
+
```
|
|
261
|
+
Prompt: "Get the content of [node_id from previous search]"
|
|
262
|
+
Expected: Returns full markdown content
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Tool 3: find_related**
|
|
266
|
+
```
|
|
267
|
+
Prompt: "Find documents related to [node_id]"
|
|
268
|
+
Expected: Returns semantically similar nodes
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Tool 4: get_graph_stats**
|
|
272
|
+
```
|
|
273
|
+
Prompt: "What are the AMALFA database statistics?"
|
|
274
|
+
Expected: Returns node/edge/embedding counts
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Tool 5: discover_topics**
|
|
278
|
+
```
|
|
279
|
+
Prompt: "What topics are in the AMALFA knowledge graph?"
|
|
280
|
+
Expected: Returns clusters or topic keywords
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
4. **Verify responses match database content**
|
|
284
|
+
- Cross-reference with `amalfa stats`
|
|
285
|
+
- Verify search results are relevant
|
|
286
|
+
|
|
287
|
+
### Success Criteria
|
|
288
|
+
- [ ] Claude Desktop recognizes AMALFA server
|
|
289
|
+
- [ ] All 5 MCP tools respond without errors
|
|
290
|
+
- [ ] Search results are semantically relevant
|
|
291
|
+
- [ ] Node content retrieval works
|
|
292
|
+
- [ ] Related nodes make semantic sense
|
|
293
|
+
- [ ] Stats match CLI stats output
|
|
294
|
+
- [ ] No crashes or timeouts
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Phase 6: Real-World Project Test
|
|
299
|
+
|
|
300
|
+
**Objective:** Test with actual project documentation
|
|
301
|
+
|
|
302
|
+
### Steps
|
|
303
|
+
|
|
304
|
+
1. **Use PolyVis as test case**
|
|
305
|
+
```bash
|
|
306
|
+
cd /tmp
|
|
307
|
+
# Use existing PolyVis repo or create test copy
|
|
308
|
+
mkdir polyvis-test && cd polyvis-test
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
2. **Create config**
|
|
312
|
+
```bash
|
|
313
|
+
cat > amalfa.config.json << 'EOF'
|
|
314
|
+
{
|
|
315
|
+
"sources": ["../polyvis/docs", "../polyvis/playbooks"],
|
|
316
|
+
"database": ".amalfa/polyvis.db"
|
|
317
|
+
}
|
|
318
|
+
EOF
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
3. **Initialize**
|
|
322
|
+
```bash
|
|
323
|
+
time amalfa init
|
|
324
|
+
```
|
|
325
|
+
- Expected: ~95 files processed
|
|
326
|
+
- Expected: Completes in ~7 seconds
|
|
327
|
+
- Expected: No errors or warnings
|
|
328
|
+
|
|
329
|
+
4. **Verify performance**
|
|
330
|
+
```bash
|
|
331
|
+
amalfa stats
|
|
332
|
+
ls -lh .amalfa/polyvis.db
|
|
333
|
+
```
|
|
334
|
+
- Expected metrics:
|
|
335
|
+
- Ingestion time: ~6-8 seconds (~13 files/sec)
|
|
336
|
+
- Database size: ~800KB
|
|
337
|
+
- Nodes: ~94
|
|
338
|
+
- Embeddings: ~94
|
|
339
|
+
|
|
340
|
+
5. **Test search quality**
|
|
341
|
+
- Use MCP to search for "CSS architecture"
|
|
342
|
+
- Use MCP to search for "database schema"
|
|
343
|
+
- Verify results are from correct playbooks/docs
|
|
344
|
+
|
|
345
|
+
### Success Criteria
|
|
346
|
+
- [ ] Large document set ingests successfully
|
|
347
|
+
- [ ] Performance meets expectations (>10 files/sec)
|
|
348
|
+
- [ ] Database size reasonable (~10KB per document)
|
|
349
|
+
- [ ] No memory issues or crashes
|
|
350
|
+
- [ ] Search results are high quality and relevant
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Phase 7: Edge Cases & Error Handling
|
|
355
|
+
|
|
356
|
+
**Objective:** Test error scenarios and boundary conditions
|
|
357
|
+
|
|
358
|
+
### Test Cases
|
|
359
|
+
|
|
360
|
+
#### 7.1: Missing Source Directory
|
|
361
|
+
```bash
|
|
362
|
+
cat > amalfa.config.json << 'EOF'
|
|
363
|
+
{"sources": ["./nonexistent"]}
|
|
364
|
+
EOF
|
|
365
|
+
amalfa init
|
|
366
|
+
```
|
|
367
|
+
- Expected: Warning message but doesn't crash
|
|
368
|
+
- Expected: "No valid source directories found" error
|
|
369
|
+
|
|
370
|
+
#### 7.2: Empty Source Directory
|
|
371
|
+
```bash
|
|
372
|
+
mkdir empty-dir
|
|
373
|
+
cat > amalfa.config.json << 'EOF'
|
|
374
|
+
{"sources": ["./empty-dir"]}
|
|
375
|
+
EOF
|
|
376
|
+
amalfa init
|
|
377
|
+
```
|
|
378
|
+
- Expected: Completes successfully with 0 nodes
|
|
379
|
+
- Expected: Database created but empty
|
|
380
|
+
|
|
381
|
+
#### 7.3: Invalid Markdown Files
|
|
382
|
+
```bash
|
|
383
|
+
echo "Not valid markdown {{{{ ]]]] ###" > broken.md
|
|
384
|
+
amalfa init
|
|
385
|
+
```
|
|
386
|
+
- Expected: Skips or handles gracefully
|
|
387
|
+
- Expected: Logs warning but continues
|
|
388
|
+
|
|
389
|
+
#### 7.4: Large File Test
|
|
390
|
+
```bash
|
|
391
|
+
# Create a 10MB markdown file
|
|
392
|
+
yes "# Test Section\nSome content here.\n" | head -n 100000 > large.md
|
|
393
|
+
amalfa init
|
|
394
|
+
```
|
|
395
|
+
- Expected: Processes without crashing
|
|
396
|
+
- Expected: May take longer but completes
|
|
397
|
+
- **TODO:** Implement file size limit (see below)
|
|
398
|
+
|
|
399
|
+
#### 7.5: Concurrent Access
|
|
400
|
+
```bash
|
|
401
|
+
amalfa daemon start
|
|
402
|
+
sleep 2
|
|
403
|
+
# While daemon is running
|
|
404
|
+
amalfa stats &
|
|
405
|
+
amalfa stats &
|
|
406
|
+
amalfa stats &
|
|
407
|
+
wait
|
|
408
|
+
```
|
|
409
|
+
- Expected: No database locking errors
|
|
410
|
+
- Expected: All commands complete successfully
|
|
411
|
+
|
|
412
|
+
#### 7.6: Rapid File Changes
|
|
413
|
+
```bash
|
|
414
|
+
amalfa daemon start
|
|
415
|
+
sleep 2
|
|
416
|
+
# Create 10 files rapidly
|
|
417
|
+
for i in {1..10}; do echo "# Doc $i" > "doc$i.md"; done
|
|
418
|
+
sleep 10
|
|
419
|
+
amalfa stats
|
|
420
|
+
```
|
|
421
|
+
- Expected: Debouncing batches changes
|
|
422
|
+
- Expected: All 10 files eventually ingested
|
|
423
|
+
|
|
424
|
+
#### 7.7: Special Characters in Filenames
|
|
425
|
+
```bash
|
|
426
|
+
touch "file with spaces.md"
|
|
427
|
+
touch "file-with-émoji-🎉.md"
|
|
428
|
+
amalfa init
|
|
429
|
+
```
|
|
430
|
+
- Expected: Handles gracefully
|
|
431
|
+
- Expected: Files ingested or skipped with warning
|
|
432
|
+
|
|
433
|
+
### Success Criteria
|
|
434
|
+
- [ ] Missing directories don't crash (warn only)
|
|
435
|
+
- [ ] Empty directories handled correctly
|
|
436
|
+
- [ ] Invalid markdown skipped gracefully
|
|
437
|
+
- [ ] Large files don't cause OOM
|
|
438
|
+
- [ ] No database locking under concurrent access
|
|
439
|
+
- [ ] Debouncing prevents rapid-fire updates
|
|
440
|
+
- [ ] Special characters in filenames handled
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Phase 8: Cleanup & Documentation
|
|
445
|
+
|
|
446
|
+
**Objective:** Verify cleanup and docs are correct
|
|
447
|
+
|
|
448
|
+
### Steps
|
|
449
|
+
|
|
450
|
+
1. **Check generated files**
|
|
451
|
+
```bash
|
|
452
|
+
cd /tmp/amalfa-test-multi
|
|
453
|
+
ls -la .amalfa/
|
|
454
|
+
find . -name ".amalfa*"
|
|
455
|
+
```
|
|
456
|
+
- Expected files:
|
|
457
|
+
- `.amalfa/multi.db` (database)
|
|
458
|
+
- `.amalfa/multi.db-shm` (shared memory)
|
|
459
|
+
- `.amalfa/multi.db-wal` (write-ahead log)
|
|
460
|
+
- `.amalfa-daemon.pid` (if daemon running)
|
|
461
|
+
- `.amalfa-daemon.log` (daemon logs)
|
|
462
|
+
|
|
463
|
+
2. **Test cleanup**
|
|
464
|
+
```bash
|
|
465
|
+
amalfa daemon stop # Ensure stopped
|
|
466
|
+
rm -rf .amalfa/
|
|
467
|
+
rm .amalfa-daemon.*
|
|
468
|
+
amalfa doctor
|
|
469
|
+
```
|
|
470
|
+
- Expected: Doctor shows clean state
|
|
471
|
+
|
|
472
|
+
3. **Verify documentation accuracy**
|
|
473
|
+
- [ ] README.md examples all work
|
|
474
|
+
- [ ] `amalfa.config.example.ts` valid
|
|
475
|
+
- [ ] MCP_TOOLS.md schemas match implementation
|
|
476
|
+
- [ ] Installation instructions correct
|
|
477
|
+
|
|
478
|
+
### Success Criteria
|
|
479
|
+
- [ ] All generated files documented
|
|
480
|
+
- [ ] Cleanup removes all artifacts
|
|
481
|
+
- [ ] No orphaned processes after cleanup
|
|
482
|
+
- [ ] Documentation matches actual behavior
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Test Execution Checklist
|
|
487
|
+
|
|
488
|
+
### Pre-Release Checklist
|
|
489
|
+
- [ ] All Phase 1-8 tests pass
|
|
490
|
+
- [ ] No console errors during normal operation
|
|
491
|
+
- [ ] Performance benchmarks met
|
|
492
|
+
- [ ] Documentation complete and accurate
|
|
493
|
+
- [ ] Example configs work as written
|
|
494
|
+
|
|
495
|
+
### Known Issues
|
|
496
|
+
- TypeScript config warnings (legacy code, not blocking)
|
|
497
|
+
- Biome lint warnings in `scripts/lab/` (not critical)
|
|
498
|
+
|
|
499
|
+
### Test Results Template
|
|
500
|
+
```
|
|
501
|
+
Test Date: YYYY-MM-DD
|
|
502
|
+
Tester: [Name]
|
|
503
|
+
Version: 1.0.0
|
|
504
|
+
|
|
505
|
+
Phase 1: [PASS/FAIL] - Notes:
|
|
506
|
+
Phase 2: [PASS/FAIL] - Notes:
|
|
507
|
+
Phase 3: [PASS/FAIL] - Notes:
|
|
508
|
+
Phase 4: [PASS/FAIL] - Notes:
|
|
509
|
+
Phase 5: [PASS/FAIL] - Notes:
|
|
510
|
+
Phase 6: [PASS/FAIL] - Notes:
|
|
511
|
+
Phase 7: [PASS/FAIL] - Notes:
|
|
512
|
+
Phase 8: [PASS/FAIL] - Notes:
|
|
513
|
+
|
|
514
|
+
Overall: [PASS/FAIL]
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## Edge Case Deep Dive: Large File Handling
|
|
520
|
+
|
|
521
|
+
### Problem
|
|
522
|
+
What happens if a user drops a huge markdown file (e.g., 100MB API documentation) into a watched folder? Current behavior is undefined and may cause:
|
|
523
|
+
- Excessive memory usage during embedding
|
|
524
|
+
- Long processing times blocking other updates
|
|
525
|
+
- Poor search quality (entire file as one chunk)
|
|
526
|
+
|
|
527
|
+
### Proposed Solution
|
|
528
|
+
Implement automatic file splitting for large documents:
|
|
529
|
+
|
|
530
|
+
1. **Detection:** Check file size before processing
|
|
531
|
+
2. **Threshold:** Files > 1MB trigger splitting
|
|
532
|
+
3. **Strategy:** Split by headers (H1/H2) or by token count
|
|
533
|
+
4. **Naming:** Create virtual nodes (e.g., `api-docs.md#section-1`)
|
|
534
|
+
5. **Graph:** Link split chunks with `part_of` edges
|
|
535
|
+
|
|
536
|
+
### Implementation Status
|
|
537
|
+
- [ ] TODO: Add file size check in AmalfaIngestor
|
|
538
|
+
- [ ] TODO: Implement markdown splitter utility
|
|
539
|
+
- [ ] TODO: Add configuration option for max file size
|
|
540
|
+
- [ ] TODO: Test with large real-world files
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## Future Test Scenarios
|
|
545
|
+
|
|
546
|
+
### V1.1+ Features
|
|
547
|
+
- [ ] Multi-language support (non-English embeddings)
|
|
548
|
+
- [ ] Custom embedding models
|
|
549
|
+
- [ ] Graph visualization export
|
|
550
|
+
- [ ] Backup/restore database
|
|
551
|
+
- [ ] Incremental edge reweaving
|
|
552
|
+
|
|
553
|
+
### Performance Tests
|
|
554
|
+
- [ ] 1000+ file corpus
|
|
555
|
+
- [ ] Embedding generation benchmark
|
|
556
|
+
- [ ] Search latency under load
|
|
557
|
+
- [ ] Memory profiling during ingestion
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
**End of Test Plan**
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AMALFA Configuration Example
|
|
3
|
+
*
|
|
4
|
+
* Copy this file to your project root as:
|
|
5
|
+
* - amalfa.config.ts (TypeScript)
|
|
6
|
+
* - amalfa.config.js (JavaScript)
|
|
7
|
+
* - amalfa.config.json (JSON)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
/**
|
|
12
|
+
* Source directories containing markdown files
|
|
13
|
+
* Relative to project root
|
|
14
|
+
*
|
|
15
|
+
* Examples:
|
|
16
|
+
* - ["./docs"] - Single directory
|
|
17
|
+
* - ["./docs", "./notes"] - Multiple directories
|
|
18
|
+
* - ["./docs", "../shared/notes"] - Across repositories
|
|
19
|
+
* - ["."] - Current directory (scans all .md files)
|
|
20
|
+
*
|
|
21
|
+
* Legacy: Single 'source' string still supported for backward compatibility
|
|
22
|
+
*/
|
|
23
|
+
sources: ["./docs"],
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Database file location
|
|
27
|
+
* Relative to project root
|
|
28
|
+
*
|
|
29
|
+
* The .amalfa directory is gitignored by default.
|
|
30
|
+
* The database can be regenerated from markdown at any time.
|
|
31
|
+
*/
|
|
32
|
+
database: ".amalfa/resonance.db",
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Embedding configuration
|
|
36
|
+
*/
|
|
37
|
+
embeddings: {
|
|
38
|
+
/**
|
|
39
|
+
* Embedding model to use
|
|
40
|
+
*
|
|
41
|
+
* Options:
|
|
42
|
+
* - "BAAI/bge-small-en-v1.5" (default) - Best balance (384 dims)
|
|
43
|
+
* - "sentence-transformers/all-MiniLM-L6-v2" - Faster (384 dims)
|
|
44
|
+
* - "BAAI/bge-base-en-v1.5" - More accurate (768 dims, slower)
|
|
45
|
+
*
|
|
46
|
+
* Models are downloaded on first use to .resonance/cache/
|
|
47
|
+
*/
|
|
48
|
+
model: "BAAI/bge-small-en-v1.5",
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Vector dimensions
|
|
52
|
+
* Must match the model's output size
|
|
53
|
+
*
|
|
54
|
+
* Common dimensions:
|
|
55
|
+
* - 384: Most small models
|
|
56
|
+
* - 768: Most base models
|
|
57
|
+
* - 1024: Large models
|
|
58
|
+
*/
|
|
59
|
+
dimensions: 384,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* File watcher configuration
|
|
64
|
+
*/
|
|
65
|
+
watch: {
|
|
66
|
+
/**
|
|
67
|
+
* Enable file watching
|
|
68
|
+
* Used by 'amalfa daemon' command
|
|
69
|
+
*/
|
|
70
|
+
enabled: true,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Debounce delay in milliseconds
|
|
74
|
+
*
|
|
75
|
+
* How long to wait after the last file change before
|
|
76
|
+
* triggering re-ingestion. This prevents excessive
|
|
77
|
+
* processing during rapid file edits.
|
|
78
|
+
*
|
|
79
|
+
* Recommended:
|
|
80
|
+
* - 1000ms (1 second) - Default, good for most cases
|
|
81
|
+
* - 500ms - More responsive, slightly higher CPU
|
|
82
|
+
* - 2000ms - Less responsive, lower CPU
|
|
83
|
+
*/
|
|
84
|
+
debounce: 1000,
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Patterns to exclude from ingestion
|
|
89
|
+
*
|
|
90
|
+
* Files/directories matching these patterns are ignored.
|
|
91
|
+
* Patterns are checked with String.includes(), not glob.
|
|
92
|
+
*
|
|
93
|
+
* Common exclusions:
|
|
94
|
+
* - "node_modules" - JavaScript dependencies
|
|
95
|
+
* - ".git" - Git internals
|
|
96
|
+
* - ".amalfa" - AMALFA data directory
|
|
97
|
+
* - "vendor" - PHP dependencies
|
|
98
|
+
* - "target" - Rust build artifacts
|
|
99
|
+
* - "dist" - Build output
|
|
100
|
+
*/
|
|
101
|
+
excludePatterns: ["node_modules", ".git", ".amalfa"],
|
|
102
|
+
};
|
package/biome.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false,
|
|
10
|
+
"includes": [
|
|
11
|
+
"src/**",
|
|
12
|
+
"scripts/**",
|
|
13
|
+
"tests/**",
|
|
14
|
+
"*.ts",
|
|
15
|
+
"*.js",
|
|
16
|
+
"*.json",
|
|
17
|
+
"*.css"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"formatter": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"indentStyle": "tab"
|
|
23
|
+
},
|
|
24
|
+
"linter": {
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"rules": {
|
|
27
|
+
"recommended": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"javascript": {
|
|
31
|
+
"formatter": {
|
|
32
|
+
"quoteStyle": "double"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"css": {
|
|
36
|
+
"parser": {
|
|
37
|
+
"cssModules": true,
|
|
38
|
+
"tailwindDirectives": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"assist": {
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"actions": {
|
|
44
|
+
"source": {
|
|
45
|
+
"organizeImports": "on"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|