db-mcp 1.1.1 → 2.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.
- package/.gitleaks.toml +9 -0
- package/.trivyignore +8 -0
- package/README.md +193 -120
- package/dist/{chunk-TVIZ3XJH.js → chunk-5Y42NPBP.js} +4168 -2411
- package/dist/{chunk-AOUL5SHS.js → chunk-645ZEFLA.js} +70 -20
- package/dist/chunk-OKOVZ5QE.js +28 -0
- package/dist/chunk-SFJQCNG7.js +131 -0
- package/dist/{chunk-FW7UCRLN.js → chunk-VIDSICEL.js} +3 -0
- package/dist/chunk-WBER5YY4.js +2053 -0
- package/dist/{chunk-4IA3DB5C.js → chunk-X3MUUOWM.js} +19 -2
- package/dist/{chunk-Z2GFQU3G.js → chunk-Z7C2TM4L.js} +114 -21
- package/dist/cli.js +79 -5
- package/dist/{http-VSB7DBJR.js → http-6KF4ULDI.js} +199 -77
- package/dist/index.d.ts +231 -8
- package/dist/index.js +6 -5
- package/dist/{sqlite-26V3Y4MK.js → sqlite-U5KSYQXK.js} +62 -138
- package/dist/{sqlite-native-5O7FZJGB.js → sqlite-native-JXMCFQBA.js} +575 -113
- package/dist/worker-script.js +34 -10
- package/logs/.gitkeep +1 -0
- package/mcp-config-example.json +83 -0
- package/package.json +9 -8
- package/playwright.config.ts +1 -1
- package/scripts/update-badges.ts +99 -0
- package/server.json +7 -5
- package/test-server/README.md +20 -23
- package/test-server/code-map.md +45 -33
- package/test-server/reset-database.ps1 +59 -17
- package/test-server/scripts/README.md +27 -0
- package/test-server/{test-help-resources.mjs → scripts/test-help-resources.mjs} +12 -5
- package/test-server/scripts/test-prompts.mjs +251 -0
- package/test-server/{test-tool-annotations.mjs → scripts/test-tool-annotations.mjs} +9 -4
- package/test-server/test-advanced/README.md +70 -0
- package/test-server/test-advanced/test-codemode-advanced-admin.md +174 -0
- package/test-server/test-advanced/test-codemode-advanced-core.md +193 -0
- package/test-server/test-advanced/test-codemode-advanced-geo.md +157 -0
- package/test-server/test-advanced/test-codemode-advanced-introspection.md +171 -0
- package/test-server/test-advanced/test-codemode-advanced-json.md +169 -0
- package/test-server/test-advanced/test-codemode-advanced-migration.md +160 -0
- package/test-server/test-advanced/test-codemode-advanced-stats.md +185 -0
- package/test-server/test-advanced/test-codemode-advanced-text.md +183 -0
- package/test-server/test-advanced/test-codemode-advanced-transactions.md +136 -0
- package/test-server/test-advanced/test-codemode-advanced-vector.md +141 -0
- package/test-server/test-codemode/README.md +121 -0
- package/test-server/test-codemode/test-codemode-admin.md +223 -0
- package/test-server/test-codemode/test-codemode-core.md +286 -0
- package/test-server/test-codemode/test-codemode-geo.md +177 -0
- package/test-server/test-codemode/test-codemode-introspection.md +190 -0
- package/test-server/test-codemode/test-codemode-json.md +237 -0
- package/test-server/test-codemode/test-codemode-migration.md +278 -0
- package/test-server/test-codemode/test-codemode-sandbox.md +413 -0
- package/test-server/test-codemode/test-codemode-stats.md +232 -0
- package/test-server/test-codemode/test-codemode-text.md +237 -0
- package/test-server/test-codemode/test-codemode-transactions.md +236 -0
- package/test-server/test-codemode/test-codemode-vector.md +244 -0
- package/test-server/test-codemode/test-codemode-wasm-degradation.md +394 -0
- package/test-server/test-database.sql +37 -1
- package/test-server/test-resources.md +43 -16
- package/test-server/test-tool-groups/README.md +100 -0
- package/test-server/test-tool-groups/test-admin-core.md +165 -0
- package/test-server/test-tool-groups/test-admin-extensions.md +133 -0
- package/test-server/{test-tools.md → test-tool-groups/test-core-data.md} +103 -17
- package/test-server/test-tool-groups/test-core-schema.md +240 -0
- package/test-server/test-tool-groups/test-geo-haversine.md +130 -0
- package/test-server/test-tool-groups/test-geo-spatialite.md +110 -0
- package/test-server/test-tool-groups/test-introspection-diagnostics.md +123 -0
- package/test-server/test-tool-groups/test-introspection-schema.md +133 -0
- package/test-server/test-tool-groups/test-json-read.md +219 -0
- package/test-server/test-tool-groups/test-json-write.md +157 -0
- package/test-server/test-tool-groups/test-migration.md +193 -0
- package/test-server/test-tool-groups/test-stats-advanced.md +118 -0
- package/test-server/test-tool-groups/test-stats-basic.md +156 -0
- package/test-server/test-tool-groups/test-text-advanced.md +169 -0
- package/test-server/test-tool-groups/test-text-basic.md +177 -0
- package/test-server/test-tool-groups/test-transactions.md +179 -0
- package/test-server/test-tool-groups/test-vector-read.md +130 -0
- package/test-server/test-tool-groups/test-vector-write.md +115 -0
- package/test-server/tool-reference.md +79 -58
- package/tsconfig.build.json +6 -0
- package/dist/chunk-RHVEZ42P.js +0 -873
- package/test-server/test-agent-experience.md +0 -243
- package/test-server/test-group-tools.md +0 -861
- package/test-server/test-tools-advanced-1.md +0 -517
- package/test-server/test-tools-advanced-2.md +0 -487
- package/test-server/test-tools-codemode.md +0 -629
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# db-mcp Code Mode Testing: [transactions]
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Do not track progress in this file.** Track your test progress, coverage matrix, and findings in your internal task tracking system (artifact). However, you SHOULD edit this file to fix any factual errors, broken code, or incorrect assertions in the test prompts.
|
|
5
|
+
> If there is nothing to fix, don't update UNRELEASED.md.
|
|
6
|
+
> We're currently testing Native mode.
|
|
7
|
+
|
|
8
|
+
**Step 1:** Read `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file`.
|
|
9
|
+
|
|
10
|
+
**Step 2:** Conduct an exhaustive test of the **transactions** tool group using ONLY `sqlite_execute_code`. Do not use direct tool calls or terminal.
|
|
11
|
+
|
|
12
|
+
**Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
|
|
13
|
+
|
|
14
|
+
> **Note:** All 8 transaction tools are **`[NATIVE ONLY]`** — they are not available in WASM mode.
|
|
15
|
+
|
|
16
|
+
## WASM Mode
|
|
17
|
+
|
|
18
|
+
> [!CAUTION]
|
|
19
|
+
> **Skip this entire prompt in WASM mode.** All 8 transaction tools are `[NATIVE ONLY]` — they are not registered in the WASM adapter. The `sqlite.transactions` namespace exists but contains 0 methods. Use `test-tool-group-codemode-wasm-degradation.md` to verify this behavior.
|
|
20
|
+
|
|
21
|
+
## Reporting Format
|
|
22
|
+
|
|
23
|
+
- ❌ Fail: Tool errors or produces incorrect results
|
|
24
|
+
- ⚠️ Issue: Unexpected behavior or improvement opportunity
|
|
25
|
+
- 📦 Payload: Unnecessarily large response — monitor `metrics.tokenEstimate`.
|
|
26
|
+
|
|
27
|
+
## Test Database Schema
|
|
28
|
+
|
|
29
|
+
| Table | Rows | Key Columns |
|
|
30
|
+
| ------------- | ---- | ---------------------------------------- |
|
|
31
|
+
| test_products | 16 | id, name, price, category |
|
|
32
|
+
| test_orders | 20 | id, product_id (FK), total_price, status |
|
|
33
|
+
|
|
34
|
+
## Testing Requirements
|
|
35
|
+
|
|
36
|
+
> [!CAUTION]
|
|
37
|
+
> **Zero tolerance for raw MCP errors.** Report as ❌.
|
|
38
|
+
|
|
39
|
+
1. **Batched scripting**: Bundle checks with `failures` array where possible.
|
|
40
|
+
2. **Error path testing**: Every tool with `{}` (Zod) and domain error.
|
|
41
|
+
3. **Token tracking**: Monitor `metrics.tokenEstimate`.
|
|
42
|
+
4. **Coverage Matrix**: `| Tool | Happy Path | Domain Error | Zod Error |`
|
|
43
|
+
5. **Deterministic checklist first**.
|
|
44
|
+
6. **Code Over Docs**: Fix the handler code if standards (Structured Errors/Zod) are violated. Do NOT change docs/prompts to accommodate broken code.
|
|
45
|
+
|
|
46
|
+
> **⚠️ Transaction ordering matters**: Transaction tests must be sequential — each test depends on the state left by the previous one. Do NOT batch transaction lifecycle tests (begin/commit/rollback) into a single failures-array script. Run them individually to verify state transitions.
|
|
47
|
+
|
|
48
|
+
## Structured Error Response Pattern
|
|
49
|
+
|
|
50
|
+
Handler error ✅ = JSON with `success` + `error`. MCP error ❌ = raw text, `isError: true`.
|
|
51
|
+
|
|
52
|
+
## Cleanup
|
|
53
|
+
|
|
54
|
+
- No permanent state — transactions rollback automatically on error.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Phase 1: Transaction Lifecycle — Happy Paths (sequential)
|
|
59
|
+
|
|
60
|
+
> Run each as an individual `sqlite_execute_code` call to verify state transitions.
|
|
61
|
+
|
|
62
|
+
### 1.1 — Check initial state
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
return await sqlite.transactions.status();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Expected: `{status: "none", active: false}`
|
|
69
|
+
|
|
70
|
+
### 1.2 — Begin transaction
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
return await sqlite.transactions.begin();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Expected: Success, transaction ID returned.
|
|
77
|
+
|
|
78
|
+
### 1.3 — Verify active state
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
return await sqlite.transactions.status();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Expected: `{status: "active", active: true}`
|
|
85
|
+
|
|
86
|
+
### 1.4 — Rollback
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
return await sqlite.transactions.rollback();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Expected: Success.
|
|
93
|
+
|
|
94
|
+
### 1.5 — Verify none state after rollback
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
return await sqlite.transactions.status();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Expected: `{status: "none", active: false}`
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Phase 2: Savepoints — Happy Paths (sequential)
|
|
105
|
+
|
|
106
|
+
### 2.1 — Begin + savepoint + release + commit
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
await sqlite.transactions.begin();
|
|
110
|
+
await sqlite.transactions.savepoint({ name: "sp1" });
|
|
111
|
+
await sqlite.transactions.rollbackTo({ name: "sp1" });
|
|
112
|
+
await sqlite.transactions.release({ name: "sp1" });
|
|
113
|
+
const result = await sqlite.transactions.commit();
|
|
114
|
+
return result;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2.2 — Transactional execute
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
return await sqlite.transactions.execute({
|
|
121
|
+
statements: ["SELECT 1 AS test", "SELECT 2 AS test2"],
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Expected: Success with 2 statements executed.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Phase 3: Transaction Domain Errors (batched where possible)
|
|
130
|
+
|
|
131
|
+
🔴 3.1 — Execute with invalid SQL:
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
return await sqlite.transactions.execute({
|
|
135
|
+
statements: ["INSERT INTO nonexistent_table VALUES (1)"],
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Expected: `{success: false}` with rollback info.
|
|
140
|
+
|
|
141
|
+
🔴 3.2 — Execute with empty array:
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
return await sqlite.transactions.execute({ statements: [] });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Report behavior.
|
|
148
|
+
|
|
149
|
+
🔴 3.3 — Rollback with no active transaction:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
return await sqlite.transactions.rollback();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Report behavior when no transaction is active.
|
|
156
|
+
|
|
157
|
+
🔴 3.4 — Release nonexistent savepoint:
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
await sqlite.transactions.begin();
|
|
161
|
+
const result = await sqlite.transactions.release({
|
|
162
|
+
name: "nonexistent_sp_xyz",
|
|
163
|
+
});
|
|
164
|
+
await sqlite.transactions.rollback(); // cleanup
|
|
165
|
+
return result;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Expected: `{success: false}` — structured error.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Phase 4: Transaction Zod Validation (batched)
|
|
173
|
+
|
|
174
|
+
🔴 4.1. `sqlite.transactions.begin({})` → success or handler error (no required params)
|
|
175
|
+
🔴 4.2. `sqlite.transactions.status({})` → success or handler error (no required params)
|
|
176
|
+
🔴 4.3. `sqlite.transactions.commit({})` → success or handler error (no required params)
|
|
177
|
+
🔴 4.4. `sqlite.transactions.rollback({})` → success or handler error (no required params)
|
|
178
|
+
🔴 4.5. `sqlite.transactions.execute({})` → `{success: false}` (missing `statements`)
|
|
179
|
+
🔴 4.6. `sqlite.transactions.savepoint({})` → `{success: false}` (missing `name`)
|
|
180
|
+
🔴 4.7. `sqlite.transactions.release({})` → `{success: false}` (missing `name`)
|
|
181
|
+
🔴 4.8. `sqlite.transactions.rollbackTo({})` → `{success: false}` (missing `name`)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Phase 5: Multi-Step Workflow
|
|
186
|
+
|
|
187
|
+
### 5.1 — Transactional write with verification
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
const failures = [];
|
|
191
|
+
|
|
192
|
+
// Execute a multi-statement transaction
|
|
193
|
+
const result = await sqlite.transactions.execute({
|
|
194
|
+
statements: [
|
|
195
|
+
"CREATE TABLE temp_cm_txn (id INTEGER PRIMARY KEY, val TEXT)",
|
|
196
|
+
"INSERT INTO temp_cm_txn VALUES (1, 'alpha')",
|
|
197
|
+
"INSERT INTO temp_cm_txn VALUES (2, 'beta')",
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
if (!result || result.success === false)
|
|
201
|
+
failures.push("transactionExecute failed");
|
|
202
|
+
|
|
203
|
+
// Verify data was committed
|
|
204
|
+
const count = await sqlite.core.count({ table: "temp_cm_txn" });
|
|
205
|
+
if (count.count !== 2) failures.push(`expected 2 rows, got ${count.count}`);
|
|
206
|
+
|
|
207
|
+
// Cleanup
|
|
208
|
+
await sqlite.core.writeQuery("DROP TABLE IF EXISTS temp_cm_txn");
|
|
209
|
+
|
|
210
|
+
return { failures, success: failures.length === 0 };
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### 5.2 — Status + execute cross-check
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
const before = await sqlite.transactions.status();
|
|
217
|
+
const exec = await sqlite.transactions.execute({
|
|
218
|
+
statements: ["SELECT COUNT(*) AS n FROM test_products"],
|
|
219
|
+
});
|
|
220
|
+
const after = await sqlite.transactions.status();
|
|
221
|
+
return { before, exec, after };
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Expected: `before.active === false`, `after.active === false` (execute is self-contained).
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Post-Test Procedures
|
|
229
|
+
|
|
230
|
+
1. **Cleanup**: Ensure no active transaction is left open
|
|
231
|
+
2. **Triage findings**: Create implementation plan if issues found
|
|
232
|
+
3. **Scope of fixes**: Handler code, server-instructions, this prompt
|
|
233
|
+
4. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
|
|
234
|
+
5. **Commit**: Stage and commit — do NOT push
|
|
235
|
+
6. **Token audit**: Report most expensive block
|
|
236
|
+
7. **Final summary**: After testing/re-testing
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# db-mcp Code Mode Testing: [vector]
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Do not track progress in this file.** Track your test progress, coverage matrix, and findings in your internal task tracking system (artifact). However, you SHOULD edit this file to fix any factual errors, broken code, or incorrect assertions in the test prompts.
|
|
5
|
+
> If there is nothing to fix, don't update UNRELEASED.md.
|
|
6
|
+
> We're currently testing Native mode.
|
|
7
|
+
|
|
8
|
+
**Step 1:** Read `C:\Users\chris\Desktop\db-mcp\src\constants\server-instructions\gotchas.md` using `view_file`.
|
|
9
|
+
|
|
10
|
+
**Step 2:** Conduct an exhaustive test of the **vector** tool group using ONLY `sqlite_execute_code`. Do not use direct tool calls or terminal.
|
|
11
|
+
|
|
12
|
+
**Step 3:** The agent should update C:\Users\chris\Desktop\db-mcp\UNRELEASED.md with any/all changes/fixes.
|
|
13
|
+
|
|
14
|
+
## WASM Mode
|
|
15
|
+
|
|
16
|
+
> When testing against a **WASM backend** (`--sqlite` / sql.js): All 11 vector tools are fully WASM-compatible. No phases to skip or adjust.
|
|
17
|
+
|
|
18
|
+
## Reporting Format
|
|
19
|
+
|
|
20
|
+
- ❌ Fail: Tool errors or produces incorrect results
|
|
21
|
+
- ⚠️ Issue: Unexpected behavior or improvement opportunity
|
|
22
|
+
- 📦 Payload: Unnecessarily large response — monitor `metrics.tokenEstimate`.
|
|
23
|
+
|
|
24
|
+
## Test Database Schema
|
|
25
|
+
|
|
26
|
+
| Table | Rows | Key Columns |
|
|
27
|
+
| --------------- | ---- | --------------------------------------------------------- |
|
|
28
|
+
| test_embeddings | 20 | id, content, category, embedding (8-dim JSON float array) |
|
|
29
|
+
|
|
30
|
+
**Categories**: database, fitness, food, tech, travel (each ~4 rows)
|
|
31
|
+
**Row 1**: content="Machine learning fundamentals", category="tech", embedding=[0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01]
|
|
32
|
+
|
|
33
|
+
> Vector tools use pure JS computations (cosine, euclidean, dot product) with JSON-stored vectors — no native extension required. All 11 tools work identically in both WASM and Native modes.
|
|
34
|
+
|
|
35
|
+
## Testing Requirements
|
|
36
|
+
|
|
37
|
+
> [!CAUTION]
|
|
38
|
+
> **Zero tolerance for raw MCP errors.** Report as ❌.
|
|
39
|
+
|
|
40
|
+
1. **Batched scripting**: Bundle checks with `failures` array.
|
|
41
|
+
2. **Error path testing**: Every tool with `{}` (Zod) and domain error.
|
|
42
|
+
3. **Token tracking**: Monitor `metrics.tokenEstimate`.
|
|
43
|
+
4. **Coverage Matrix**: `| Tool | Happy Path | Domain Error | Zod Error |`
|
|
44
|
+
5. **Deterministic checklist first**.
|
|
45
|
+
6. **Code Over Docs**: Fix the handler code if standards (Structured Errors/Zod) are violated. Do NOT change docs/prompts to accommodate broken code.
|
|
46
|
+
|
|
47
|
+
## Structured Error Response Pattern
|
|
48
|
+
|
|
49
|
+
Handler error ✅ = JSON with `success` + `error`. MCP error ❌ = raw text, `isError: true`.
|
|
50
|
+
|
|
51
|
+
## Cleanup
|
|
52
|
+
|
|
53
|
+
- Temporary tables: `temp_*` prefix. Drop at end of script.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Phase 1: Vector Read Tools — Happy Paths (batched)
|
|
58
|
+
|
|
59
|
+
1. `sqlite.vector.count({table: "test_embeddings"})` → `{count: 20}`
|
|
60
|
+
2. `sqlite.vector.dimensions({table: "test_embeddings", vectorColumn: "embedding"})` → `{dimensions: 8}`
|
|
61
|
+
3. `sqlite.vector.get({table: "test_embeddings", idColumn: "id", vectorColumn: "embedding", id: 1})` → content="Machine learning fundamentals", 8 dims
|
|
62
|
+
4. `sqlite.vector.search({table: "test_embeddings", vectorColumn: "embedding", queryVector: [0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01], metric: "cosine", limit: 3})` → row 1 first (exact match, similarity ≈ 1)
|
|
63
|
+
5. `sqlite.vector.search({table: "test_embeddings", vectorColumn: "embedding", queryVector: [0.12, 0.45, -0.23, 0.78, 0.34, -0.56, 0.89, 0.01], metric: "cosine", limit: 3, whereClause: "category = 'database'"})` → only database results
|
|
64
|
+
6. `sqlite.vector.distance({vector1: [1, 0, 0], vector2: [0, 1, 0], metric: "cosine"})` → ≈ 1.0 (orthogonal)
|
|
65
|
+
7. `sqlite.vector.distance({vector1: [3, 4], vector2: [0, 0], metric: "euclidean"})` → 5.0
|
|
66
|
+
8. `sqlite.vector.normalize({vector: [3, 4]})` → `{normalized: [0.6, 0.8], originalMagnitude: 5}`
|
|
67
|
+
9. `sqlite.vector.stats({table: "test_embeddings", vectorColumn: "embedding"})` → min/max/avg magnitude
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Phase 2: Vector Write Tools — Happy Paths (temp table)
|
|
72
|
+
|
|
73
|
+
10. `sqlite.vector.createTable({tableName: "temp_cm_vector", dimensions: 8, additionalColumns: [{name: "content", type: "TEXT"}, {name: "category", type: "TEXT"}]})` → success
|
|
74
|
+
11. `sqlite.vector.store({table: "temp_cm_vector", idColumn: "id", vectorColumn: "vector", id: 1, vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]})` → success
|
|
75
|
+
12. `sqlite.vector.batchStore({table: "temp_cm_vector", idColumn: "id", vectorColumn: "vector", items: [{id: 2, vector: [0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 0.77, 0.88]}, {id: 3, vector: [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]}]})` → `{stored: 2}`
|
|
76
|
+
13. `sqlite.vector.count({table: "temp_cm_vector"})` → `{count: 3}`
|
|
77
|
+
14. `sqlite.vector.search({table: "temp_cm_vector", vectorColumn: "vector", queryVector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8], metric: "cosine", limit: 2})` → row 1 first
|
|
78
|
+
15. `sqlite.vector.delete({table: "temp_cm_vector", idColumn: "id", ids: [1]})` → success
|
|
79
|
+
16. `sqlite.vector.count({table: "temp_cm_vector"})` → `{count: 2}`
|
|
80
|
+
17. Cleanup: `sqlite.core.dropTable({tableName: "temp_cm_vector"})`
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Phase 3: Vector Domain Errors (batched)
|
|
85
|
+
|
|
86
|
+
🔴 18. `sqlite.vector.search({table: "nonexistent_xyz", vectorColumn: "embedding", queryVector: [1,2,3], metric: "cosine"})` → `{success: false}`
|
|
87
|
+
🔴 19. `sqlite.vector.distance({vector1: [1, 2, 3], vector2: [1, 2], metric: "cosine"})` → error about dimension mismatch
|
|
88
|
+
🔴 20. `sqlite.vector.get({table: "test_embeddings", idColumn: "id", vectorColumn: "embedding", id: 9999})` → report behavior (nonexistent row)
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Phase 4: Vector Zod Validation (batched)
|
|
93
|
+
|
|
94
|
+
🔴 21. `sqlite.vector.createTable({})` → `{success: false}`
|
|
95
|
+
🔴 22. `sqlite.vector.store({})` → `{success: false}`
|
|
96
|
+
🔴 23. `sqlite.vector.batchStore({})` → `{success: false}`
|
|
97
|
+
🔴 24. `sqlite.vector.search({})` → `{success: false}`
|
|
98
|
+
🔴 25. `sqlite.vector.get({})` → `{success: false}`
|
|
99
|
+
🔴 26. `sqlite.vector.delete({})` → `{success: false}`
|
|
100
|
+
🔴 27. `sqlite.vector.count({})` → `{success: false}`
|
|
101
|
+
🔴 28. `sqlite.vector.stats({})` → `{success: false}`
|
|
102
|
+
🔴 29. `sqlite.vector.dimensions({})` → `{success: false}`
|
|
103
|
+
🔴 30. `sqlite.vector.normalize({})` → `{success: false}`
|
|
104
|
+
🔴 31. `sqlite.vector.distance({})` → `{success: false}`
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Phase 5: Multi-Step Workflow
|
|
109
|
+
|
|
110
|
+
### 5.1 — Similarity search pipeline
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
const failures = [];
|
|
114
|
+
// Get first embedding
|
|
115
|
+
const row1 = await sqlite.core.readQuery(
|
|
116
|
+
"SELECT embedding FROM test_embeddings WHERE id = 1",
|
|
117
|
+
);
|
|
118
|
+
const vec = JSON.parse(row1.rows[0].embedding);
|
|
119
|
+
|
|
120
|
+
// Search for similar
|
|
121
|
+
const similar = await sqlite.vector.search({
|
|
122
|
+
table: "test_embeddings",
|
|
123
|
+
vectorColumn: "embedding",
|
|
124
|
+
queryVector: vec,
|
|
125
|
+
metric: "cosine",
|
|
126
|
+
limit: 5,
|
|
127
|
+
});
|
|
128
|
+
if (!similar || !similar.rows || similar.rows.length < 1)
|
|
129
|
+
failures.push("search returned no results");
|
|
130
|
+
|
|
131
|
+
// Get stats
|
|
132
|
+
const vstats = await sqlite.vector.stats({
|
|
133
|
+
table: "test_embeddings",
|
|
134
|
+
vectorColumn: "embedding",
|
|
135
|
+
});
|
|
136
|
+
if (!vstats) failures.push("stats failed");
|
|
137
|
+
|
|
138
|
+
// Distance calc
|
|
139
|
+
const dist = await sqlite.vector.distance({
|
|
140
|
+
vector1: vec,
|
|
141
|
+
vector2: vec,
|
|
142
|
+
metric: "cosine",
|
|
143
|
+
});
|
|
144
|
+
// Self-distance should be 0 (or very close)
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
failures,
|
|
148
|
+
success: failures.length === 0,
|
|
149
|
+
resultCount: similar?.rows?.length,
|
|
150
|
+
selfDistance: dist.distance,
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 5.2 — Create → populate → search → teardown
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
const failures = [];
|
|
158
|
+
await sqlite.vector.createTable({
|
|
159
|
+
tableName: "temp_cm_vec_pipe",
|
|
160
|
+
dimensions: 3,
|
|
161
|
+
});
|
|
162
|
+
await sqlite.vector.batchStore({
|
|
163
|
+
table: "temp_cm_vec_pipe",
|
|
164
|
+
idColumn: "id",
|
|
165
|
+
vectorColumn: "vector",
|
|
166
|
+
items: [
|
|
167
|
+
{ id: 1, vector: [1, 0, 0] },
|
|
168
|
+
{ id: 2, vector: [0, 1, 0] },
|
|
169
|
+
{ id: 3, vector: [0, 0, 1] },
|
|
170
|
+
],
|
|
171
|
+
});
|
|
172
|
+
const results = await sqlite.vector.search({
|
|
173
|
+
table: "temp_cm_vec_pipe",
|
|
174
|
+
vectorColumn: "vector",
|
|
175
|
+
queryVector: [1, 0, 0],
|
|
176
|
+
metric: "cosine",
|
|
177
|
+
limit: 3,
|
|
178
|
+
});
|
|
179
|
+
if (results.rows[0].id !== 1) failures.push("expected row 1 as closest match");
|
|
180
|
+
await sqlite.core.dropTable({ tableName: "temp_cm_vec_pipe" });
|
|
181
|
+
return { failures, success: failures.length === 0 };
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### 5.3 — Vector + JSON cross-group
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
const failures = [];
|
|
190
|
+
// Create vector table with metadata column
|
|
191
|
+
await sqlite.vector.createTable({
|
|
192
|
+
tableName: "temp_cm_vec_json",
|
|
193
|
+
dimensions: 3,
|
|
194
|
+
additionalColumns: [{ name: "metadata", type: "TEXT" }],
|
|
195
|
+
});
|
|
196
|
+
// Store vector with JSON metadata
|
|
197
|
+
await sqlite.vector.store({
|
|
198
|
+
table: "temp_cm_vec_json",
|
|
199
|
+
idColumn: "id",
|
|
200
|
+
vectorColumn: "vector",
|
|
201
|
+
id: 1,
|
|
202
|
+
vector: [1, 0, 0],
|
|
203
|
+
});
|
|
204
|
+
await sqlite.core.writeQuery({
|
|
205
|
+
query: `UPDATE temp_cm_vec_json SET metadata = '{"category": "test", "score": 0.95}' WHERE id = 1`,
|
|
206
|
+
});
|
|
207
|
+
// Search and extract JSON from results
|
|
208
|
+
const results = await sqlite.vector.search({
|
|
209
|
+
table: "temp_cm_vec_json",
|
|
210
|
+
vectorColumn: "vector",
|
|
211
|
+
queryVector: [1, 0, 0],
|
|
212
|
+
metric: "cosine",
|
|
213
|
+
limit: 1,
|
|
214
|
+
});
|
|
215
|
+
if (!results.rows || results.rows.length === 0)
|
|
216
|
+
failures.push("vector search returned no results");
|
|
217
|
+
const meta = await sqlite.json.extract({
|
|
218
|
+
table: "temp_cm_vec_json",
|
|
219
|
+
column: "metadata",
|
|
220
|
+
path: "$.category",
|
|
221
|
+
whereClause: "id = 1",
|
|
222
|
+
});
|
|
223
|
+
if (!meta || meta.success === false)
|
|
224
|
+
failures.push("JSON extract from vector table failed");
|
|
225
|
+
await sqlite.core.dropTable({ tableName: "temp_cm_vec_json" });
|
|
226
|
+
return {
|
|
227
|
+
failures,
|
|
228
|
+
success: failures.length === 0,
|
|
229
|
+
searchResult: results,
|
|
230
|
+
jsonMeta: meta,
|
|
231
|
+
};
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Post-Test Procedures
|
|
237
|
+
|
|
238
|
+
1. **Cleanup**: Drop `temp_*` tables
|
|
239
|
+
2. **Triage findings**: Create implementation plan if issues found
|
|
240
|
+
3. **Scope of fixes**: Handler code, server-instructions, this prompt
|
|
241
|
+
4. **Validate**: Instruct the user to run the test suite (Vitest/Playwright), lint, and typecheck. Do NOT run them yourself.
|
|
242
|
+
5. **Commit**: Stage and commit — do NOT push
|
|
243
|
+
6. **Token audit**: Report most expensive block
|
|
244
|
+
7. **Final summary**: After testing/re-testing
|