You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor Capabilities structure and enforce read-only mode
- Removed write and DDL capability flags from Capabilities struct.
- Updated methods to create capabilities to focus solely on read-only operations.
- Adjusted tests and integration points to reflect the new capabilities structure.
- Modified error messages to clarify that Plenum is strictly read-only.
- Ensured all database engines reject write and DDL operations uniformly.
- Cleaned up main.rs and MCP tool documentation to remove references to write/DDL capabilities.
--sql "INSERT INTO logs (level, message) VALUES ('INFO', 'Application started')"
331
332
```
332
333
333
-
**Success Output:**
334
+
**Error Output:**
334
335
```json
335
336
{
336
-
"ok": true,
337
+
"ok": false,
337
338
"engine": "postgres",
338
339
"command": "query",
339
-
"data": {
340
-
"columns": [],
341
-
"rows": [],
342
-
"rows_affected": 1
343
-
},
344
-
"meta": {
345
-
"execution_ms": 45,
346
-
"rows_returned": 0
340
+
"error": {
341
+
"code": "CAPABILITY_VIOLATION",
342
+
"message": "Plenum is read-only and cannot execute this query. Please run this query manually:\n\nINSERT INTO logs (level, message) VALUES ('INFO', 'Application started')"
347
343
}
348
344
}
349
345
```
350
346
351
-
### Write Query (UPDATE)
347
+
**Agent Workflow:** When a write operation is needed:
348
+
1. Use Plenum to introspect schema and read current data
349
+
2. Construct the SQL statement
350
+
3. Present it to the user for manual execution
351
+
352
+
### Attempted DDL Query (REJECTED)
353
+
354
+
DDL operations are also rejected:
352
355
353
356
```bash
354
357
plenum query \
355
358
--name prod-db \
356
-
--sql "UPDATE users SET last_login = CURRENT_TIMESTAMP WHERE id = 42" \
357
-
--allow-write
359
+
--sql "CREATE TABLE temp_results (id SERIAL PRIMARY KEY, value TEXT)"
358
360
```
359
361
360
-
**Success Output:**
362
+
**Error Output:**
361
363
```json
362
364
{
363
-
"ok": true,
365
+
"ok": false,
364
366
"engine": "postgres",
365
367
"command": "query",
366
-
"data": {
367
-
"columns": [],
368
-
"rows": [],
369
-
"rows_affected": 1
370
-
},
371
-
"meta": {
372
-
"execution_ms": 52,
373
-
"rows_returned": 0
368
+
"error": {
369
+
"code": "CAPABILITY_VIOLATION",
370
+
"message": "Plenum is read-only and cannot execute this query. Please run this query manually:\n\nCREATE TABLE temp_results (id SERIAL PRIMARY KEY, value TEXT)"
374
371
}
375
372
}
376
373
```
377
374
378
-
### Write Query (DELETE)
379
-
380
-
```bash
381
-
plenum query \
382
-
--name prod-db \
383
-
--sql "DELETE FROM temp_cache WHERE created_at < NOW() - INTERVAL '1 hour'" \
384
-
--allow-write
385
-
```
386
-
387
-
### DDL Query (CREATE TABLE)
388
-
389
-
```bash
390
-
plenum query \
391
-
--name prod-db \
392
-
--sql "CREATE TABLE temp_results (id SERIAL PRIMARY KEY, value TEXT)" \
"message": "Plenum is read-only and cannot execute this query. Please run this query manually:\n\nUPDATE users SET email = 'test@example.com' WHERE id = 1"
0 commit comments