mcp-quickbase 2.0.5 → 2.2.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/.crewchief/runs/state.json +3 -0
- package/.mcp.json +6 -32
- package/.sdd/tickets/RELS_relationship-management/README.md +98 -0
- package/.sdd/tickets/RELS_relationship-management/planning/analysis.md +190 -0
- package/.sdd/tickets/RELS_relationship-management/planning/architecture.md +413 -0
- package/.sdd/tickets/RELS_relationship-management/planning/plan.md +177 -0
- package/.sdd/tickets/RELS_relationship-management/planning/quality-strategy.md +335 -0
- package/.sdd/tickets/RELS_relationship-management/planning/review-updates.md +95 -0
- package/.sdd/tickets/RELS_relationship-management/planning/security-review.md +213 -0
- package/.sdd/tickets/RELS_relationship-management/planning/ticket-review.md +885 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1001_domain-setup.md +96 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1002_get-relationships-tool.md +142 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1003_register-phase1-tools.md +105 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2001_create-relationship-tool.md +151 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2002_update-relationship-tool.md +145 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.3001_delete-relationship-tool.md +154 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4001_integration-testing.md +159 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4002_final-verification.md +182 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS_TASK_INDEX.md +179 -0
- package/crewchief.config.js +31 -0
- package/dist/client/quickbase.d.ts +7 -2
- package/dist/client/quickbase.js +64 -51
- package/dist/client/quickbase.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/server.d.ts +3 -3
- package/dist/mcp/server.js +21 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-stdio-server.js +64 -49
- package/dist/mcp-stdio-server.js.map +1 -1
- package/dist/server.js +84 -83
- package/dist/server.js.map +1 -1
- package/dist/tools/apps/create_app.d.ts +2 -2
- package/dist/tools/apps/create_app.js +23 -23
- package/dist/tools/apps/create_app.js.map +1 -1
- package/dist/tools/apps/index.d.ts +4 -4
- package/dist/tools/apps/index.js +3 -3
- package/dist/tools/apps/list_tables.d.ts +7 -7
- package/dist/tools/apps/list_tables.js +28 -27
- package/dist/tools/apps/list_tables.js.map +1 -1
- package/dist/tools/apps/update_app.d.ts +2 -2
- package/dist/tools/apps/update_app.js +28 -26
- package/dist/tools/apps/update_app.js.map +1 -1
- package/dist/tools/base.d.ts +3 -3
- package/dist/tools/base.js +7 -7
- package/dist/tools/base.js.map +1 -1
- package/dist/tools/configure_cache.d.ts +3 -3
- package/dist/tools/configure_cache.js +16 -16
- package/dist/tools/configure_cache.js.map +1 -1
- package/dist/tools/fields/create_field.d.ts +8 -7
- package/dist/tools/fields/create_field.js +39 -29
- package/dist/tools/fields/create_field.js.map +1 -1
- package/dist/tools/fields/delete_field.d.ts +79 -0
- package/dist/tools/fields/delete_field.js +105 -0
- package/dist/tools/fields/delete_field.js.map +1 -0
- package/dist/tools/fields/get_field.d.ts +91 -0
- package/dist/tools/fields/get_field.js +82 -0
- package/dist/tools/fields/get_field.js.map +1 -0
- package/dist/tools/fields/index.d.ts +5 -3
- package/dist/tools/fields/index.js +11 -5
- package/dist/tools/fields/index.js.map +1 -1
- package/dist/tools/fields/update_field.d.ts +7 -15
- package/dist/tools/fields/update_field.js +39 -38
- package/dist/tools/fields/update_field.js.map +1 -1
- package/dist/tools/files/download_file.d.ts +2 -2
- package/dist/tools/files/download_file.js +35 -35
- package/dist/tools/files/download_file.js.map +1 -1
- package/dist/tools/files/index.d.ts +3 -3
- package/dist/tools/files/index.js +3 -3
- package/dist/tools/files/upload_file.d.ts +2 -2
- package/dist/tools/files/upload_file.js +52 -44
- package/dist/tools/files/upload_file.js.map +1 -1
- package/dist/tools/index.d.ts +13 -12
- package/dist/tools/index.js +6 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/records/bulk_create_records.d.ts +2 -2
- package/dist/tools/records/bulk_create_records.js +28 -28
- package/dist/tools/records/bulk_create_records.js.map +1 -1
- package/dist/tools/records/bulk_update_records.d.ts +2 -2
- package/dist/tools/records/bulk_update_records.js +27 -27
- package/dist/tools/records/bulk_update_records.js.map +1 -1
- package/dist/tools/records/create_record.d.ts +2 -2
- package/dist/tools/records/create_record.js +40 -40
- package/dist/tools/records/create_record.js.map +1 -1
- package/dist/tools/records/index.d.ts +6 -6
- package/dist/tools/records/index.js +3 -3
- package/dist/tools/records/query_records.d.ts +3 -3
- package/dist/tools/records/query_records.js +82 -78
- package/dist/tools/records/query_records.js.map +1 -1
- package/dist/tools/records/update_record.d.ts +2 -2
- package/dist/tools/records/update_record.js +31 -29
- package/dist/tools/records/update_record.js.map +1 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +1 -1
- package/dist/tools/relationships/create_relationship.d.ts +150 -0
- package/dist/tools/relationships/create_relationship.js +181 -0
- package/dist/tools/relationships/create_relationship.js.map +1 -0
- package/dist/tools/relationships/delete_relationship.d.ts +66 -0
- package/dist/tools/relationships/delete_relationship.js +85 -0
- package/dist/tools/relationships/delete_relationship.js.map +1 -0
- package/dist/tools/relationships/get_relationships.d.ts +126 -0
- package/dist/tools/relationships/get_relationships.js +126 -0
- package/dist/tools/relationships/get_relationships.js.map +1 -0
- package/dist/tools/relationships/index.d.ts +14 -0
- package/dist/tools/relationships/index.js +37 -0
- package/dist/tools/relationships/index.js.map +1 -0
- package/dist/tools/relationships/update_relationship.d.ts +139 -0
- package/dist/tools/relationships/update_relationship.js +168 -0
- package/dist/tools/relationships/update_relationship.js.map +1 -0
- package/dist/tools/reports/index.d.ts +2 -2
- package/dist/tools/reports/index.js +3 -3
- package/dist/tools/reports/run_report.d.ts +3 -3
- package/dist/tools/reports/run_report.js +29 -29
- package/dist/tools/reports/run_report.js.map +1 -1
- package/dist/tools/tables/create_table.d.ts +2 -49
- package/dist/tools/tables/create_table.js +26 -49
- package/dist/tools/tables/create_table.js.map +1 -1
- package/dist/tools/tables/get_table_fields.d.ts +2 -2
- package/dist/tools/tables/get_table_fields.js +25 -25
- package/dist/tools/tables/get_table_fields.js.map +1 -1
- package/dist/tools/tables/index.d.ts +4 -4
- package/dist/tools/tables/index.js +3 -3
- package/dist/tools/tables/update_table.d.ts +2 -2
- package/dist/tools/tables/update_table.js +28 -26
- package/dist/tools/tables/update_table.js.map +1 -1
- package/dist/tools/test_connection.d.ts +2 -2
- package/dist/tools/test_connection.js +28 -28
- package/dist/tools/test_connection.js.map +1 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/types/mcp.d.ts +1 -1
- package/dist/utils/cache.js +16 -16
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/file.js +44 -40
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/logger.js +30 -28
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/retry.js +10 -10
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +39 -36
- package/dist/utils/validation.js.map +1 -1
- package/docs/README.md +6 -0
- package/docs/future-improvements.md +33 -0
- package/docs/migration-guide.md +160 -0
- package/docs/release-notes.md +89 -0
- package/package.json +5 -4
- /package/{HARDENING_SUMMARY.md → docs/hardening-summary.md} +0 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# Quality Strategy: Relationship Management
|
|
2
|
+
|
|
3
|
+
## Testing Philosophy
|
|
4
|
+
|
|
5
|
+
This feature follows enterprise-grade testing principles with comprehensive coverage of both happy paths and error scenarios. Given the destructive nature of the delete operation, testing must verify that tool descriptions accurately communicate risks and that error handling prevents unintended data loss.
|
|
6
|
+
|
|
7
|
+
Testing priorities:
|
|
8
|
+
1. **Critical paths** - All CRUD operations must work correctly
|
|
9
|
+
2. **Error handling** - API errors, validation errors, and edge cases
|
|
10
|
+
3. **Safety verification** - Delete tool description contains required warnings
|
|
11
|
+
4. **Integration** - Tools register correctly and are callable through MCP
|
|
12
|
+
|
|
13
|
+
## Coverage Requirements
|
|
14
|
+
|
|
15
|
+
**Minimum Thresholds (from jest.config.js):**
|
|
16
|
+
- Line coverage: 40%
|
|
17
|
+
- Function coverage: 40%
|
|
18
|
+
- Statement coverage: 40%
|
|
19
|
+
- Branch coverage: 20%
|
|
20
|
+
|
|
21
|
+
**Target Thresholds:**
|
|
22
|
+
- Line coverage: 80% for new relationship tools
|
|
23
|
+
- Branch coverage: 70% for new relationship tools
|
|
24
|
+
|
|
25
|
+
**Note:** The minimum thresholds are enforced by jest.config.js and represent hard requirements. The target thresholds are aspirational goals for new relationship tool code quality.
|
|
26
|
+
|
|
27
|
+
**Coverage Focus Areas:**
|
|
28
|
+
- All tool `run()` methods
|
|
29
|
+
- Parameter validation paths
|
|
30
|
+
- Error handling branches
|
|
31
|
+
- Response transformation logic
|
|
32
|
+
|
|
33
|
+
## Test Types
|
|
34
|
+
|
|
35
|
+
### Unit Tests
|
|
36
|
+
|
|
37
|
+
**Scope:** Individual tool classes with mocked QuickbaseClient
|
|
38
|
+
|
|
39
|
+
**Tools:** Jest with ts-jest
|
|
40
|
+
|
|
41
|
+
**Coverage Target:** >= 80% for new code
|
|
42
|
+
|
|
43
|
+
**What to Test:**
|
|
44
|
+
|
|
45
|
+
1. **Tool Properties**
|
|
46
|
+
- Correct `name` value
|
|
47
|
+
- Description is non-empty string
|
|
48
|
+
- `paramSchema` is valid JSON Schema object
|
|
49
|
+
|
|
50
|
+
2. **Happy Path Execution**
|
|
51
|
+
- Successful API responses transformed correctly
|
|
52
|
+
- All response fields mapped properly
|
|
53
|
+
- Metadata included in results
|
|
54
|
+
|
|
55
|
+
3. **Parameter Validation**
|
|
56
|
+
- Required parameters validated
|
|
57
|
+
- Invalid parameter types rejected
|
|
58
|
+
- Optional parameters handled correctly
|
|
59
|
+
|
|
60
|
+
4. **Error Handling**
|
|
61
|
+
- API errors (4xx, 5xx) handled gracefully
|
|
62
|
+
- Network errors caught and reported
|
|
63
|
+
- Validation errors include helpful messages
|
|
64
|
+
|
|
65
|
+
5. **Edge Cases**
|
|
66
|
+
- Empty relationship lists
|
|
67
|
+
- Relationships with no lookup/summary fields
|
|
68
|
+
- Large relationship counts (pagination)
|
|
69
|
+
|
|
70
|
+
### Integration Tests
|
|
71
|
+
|
|
72
|
+
**Scope:** Tool registration and end-to-end execution flow
|
|
73
|
+
|
|
74
|
+
**Approach:** Test that tools are registered and callable through the registry
|
|
75
|
+
|
|
76
|
+
**What to Test:**
|
|
77
|
+
- All four tools appear in `toolRegistry.getAllTools()`
|
|
78
|
+
- Tools can be retrieved by name via `toolRegistry.getTool()`
|
|
79
|
+
- Execute returns proper `ApiResponse` structure
|
|
80
|
+
|
|
81
|
+
### End-to-End Tests
|
|
82
|
+
|
|
83
|
+
**Scope:** Not required for initial release
|
|
84
|
+
|
|
85
|
+
**Note:** E2E tests against real Quickbase API would require test credentials and are deferred to future work.
|
|
86
|
+
|
|
87
|
+
## Critical Paths
|
|
88
|
+
|
|
89
|
+
The following paths MUST have comprehensive test coverage:
|
|
90
|
+
|
|
91
|
+
### 1. Get Relationships
|
|
92
|
+
|
|
93
|
+
**Happy Path:**
|
|
94
|
+
- Returns array of relationships with complete structure
|
|
95
|
+
- Pagination works (skip parameter honored)
|
|
96
|
+
- Empty array returned for tables with no relationships
|
|
97
|
+
|
|
98
|
+
**Error Cases:**
|
|
99
|
+
- Table not found (404)
|
|
100
|
+
- Unauthorized (401)
|
|
101
|
+
- Forbidden (403)
|
|
102
|
+
- Network error
|
|
103
|
+
|
|
104
|
+
**Edge Cases:**
|
|
105
|
+
- Table with many relationships (pagination needed)
|
|
106
|
+
- Cross-app relationships have limited details
|
|
107
|
+
|
|
108
|
+
### 2. Create Relationship
|
|
109
|
+
|
|
110
|
+
**Happy Path:**
|
|
111
|
+
- Basic relationship creation (parent + child only)
|
|
112
|
+
- With lookup field IDs
|
|
113
|
+
- With summary field (all accumulation types)
|
|
114
|
+
- With both lookup and summary fields
|
|
115
|
+
|
|
116
|
+
**Error Cases:**
|
|
117
|
+
- Parent table not found
|
|
118
|
+
- Invalid field IDs for lookups
|
|
119
|
+
- Missing accumulation type when summary_field_id provided (must be validated via JSON Schema)
|
|
120
|
+
- Tables in different apps
|
|
121
|
+
|
|
122
|
+
**Edge Cases:**
|
|
123
|
+
- Creating relationship that already exists
|
|
124
|
+
- Summary field with WHERE filter
|
|
125
|
+
|
|
126
|
+
### 3. Update Relationship
|
|
127
|
+
|
|
128
|
+
**Happy Path:**
|
|
129
|
+
- Add lookup fields to existing relationship
|
|
130
|
+
- Add summary field to existing relationship
|
|
131
|
+
- Add both lookup and summary fields
|
|
132
|
+
|
|
133
|
+
**Error Cases:**
|
|
134
|
+
- Relationship not found
|
|
135
|
+
- Invalid lookup field IDs
|
|
136
|
+
- Missing accumulation type when summary_field_id provided (must be validated via JSON Schema)
|
|
137
|
+
|
|
138
|
+
**Edge Cases:**
|
|
139
|
+
- Adding fields that already exist (additive behavior)
|
|
140
|
+
- Empty update (no fields to add)
|
|
141
|
+
|
|
142
|
+
### 4. Delete Relationship (CRITICAL - Extra Coverage Required)
|
|
143
|
+
|
|
144
|
+
**Happy Path:**
|
|
145
|
+
- Successful deletion returns relationship ID
|
|
146
|
+
- All lookup/summary fields deleted
|
|
147
|
+
|
|
148
|
+
**Error Cases:**
|
|
149
|
+
- Relationship not found (404)
|
|
150
|
+
- Unauthorized (401)
|
|
151
|
+
- Forbidden (403)
|
|
152
|
+
|
|
153
|
+
**Safety Verification:**
|
|
154
|
+
- Tool description contains "WARNING"
|
|
155
|
+
- Tool description contains "DESTRUCTIVE"
|
|
156
|
+
- Tool description mentions lookup fields deletion
|
|
157
|
+
- Tool description mentions summary fields deletion
|
|
158
|
+
- Tool description mentions data loss is permanent
|
|
159
|
+
- Tool description recommends `get_relationships` first
|
|
160
|
+
- Tool description recommends user confirmation
|
|
161
|
+
|
|
162
|
+
## Negative Testing Requirements
|
|
163
|
+
|
|
164
|
+
### Invalid Inputs
|
|
165
|
+
|
|
166
|
+
| Test Case | Input | Expected |
|
|
167
|
+
|-----------|-------|----------|
|
|
168
|
+
| Empty table_id | `""` | Validation error |
|
|
169
|
+
| Missing table_id | `undefined` | Validation error |
|
|
170
|
+
| Invalid table_id type | `123` (number) | Validation error |
|
|
171
|
+
| Empty relationship_id (for update/delete) | `undefined` | Validation error |
|
|
172
|
+
| Invalid accumulation_type | `"INVALID"` | API error or validation error |
|
|
173
|
+
| Non-numeric field IDs | `["abc"]` | Validation error |
|
|
174
|
+
|
|
175
|
+
### API Error Handling
|
|
176
|
+
|
|
177
|
+
| Status Code | Scenario | Expected Behavior |
|
|
178
|
+
|-------------|----------|-------------------|
|
|
179
|
+
| 400 | Bad request | Return error with message |
|
|
180
|
+
| 401 | Invalid token | Return auth error |
|
|
181
|
+
| 403 | No permission | Return forbidden error |
|
|
182
|
+
| 404 | Not found | Return not found error |
|
|
183
|
+
| 429 | Rate limited | Retry (handled by client) |
|
|
184
|
+
| 500 | Server error | Return server error |
|
|
185
|
+
|
|
186
|
+
### Authorization Failures
|
|
187
|
+
|
|
188
|
+
- Test with invalid/expired token (mocked)
|
|
189
|
+
- Test access to table without permissions (mocked)
|
|
190
|
+
|
|
191
|
+
### Resource Not Found
|
|
192
|
+
|
|
193
|
+
- Non-existent table ID
|
|
194
|
+
- Non-existent relationship ID
|
|
195
|
+
- Non-existent parent table ID
|
|
196
|
+
|
|
197
|
+
## Test Data Strategy
|
|
198
|
+
|
|
199
|
+
### Mocking Approach
|
|
200
|
+
|
|
201
|
+
All tests use mocked `QuickbaseClient`:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
jest.mock('../../client/quickbase');
|
|
205
|
+
|
|
206
|
+
const mockClient = new QuickbaseClient(config) as jest.Mocked<QuickbaseClient>;
|
|
207
|
+
mockClient.request = jest.fn().mockResolvedValue(mockResponse);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Mock Response Templates
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Relationship structure
|
|
214
|
+
const mockRelationship = {
|
|
215
|
+
id: 123,
|
|
216
|
+
parentTableId: 'parent-table-id',
|
|
217
|
+
childTableId: 'child-table-id',
|
|
218
|
+
foreignKeyField: {
|
|
219
|
+
id: 123,
|
|
220
|
+
label: 'Related Parent',
|
|
221
|
+
type: 'numeric'
|
|
222
|
+
},
|
|
223
|
+
isCrossApp: false,
|
|
224
|
+
lookupFields: [
|
|
225
|
+
{ id: 456, label: 'Parent Name', type: 'text' }
|
|
226
|
+
],
|
|
227
|
+
summaryFields: [
|
|
228
|
+
{ id: 789, label: 'Child Count', type: 'numeric' }
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Get relationships response
|
|
233
|
+
const mockGetResponse = {
|
|
234
|
+
success: true,
|
|
235
|
+
data: {
|
|
236
|
+
relationships: [mockRelationship],
|
|
237
|
+
metadata: {
|
|
238
|
+
totalRelationships: 1,
|
|
239
|
+
numRelationships: 1,
|
|
240
|
+
skip: 0
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// Create/Update response
|
|
246
|
+
const mockCreateResponse = {
|
|
247
|
+
success: true,
|
|
248
|
+
data: mockRelationship
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// Delete response
|
|
252
|
+
const mockDeleteResponse = {
|
|
253
|
+
success: true,
|
|
254
|
+
data: {
|
|
255
|
+
relationshipId: 123
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Error response
|
|
260
|
+
const mockErrorResponse = {
|
|
261
|
+
success: false,
|
|
262
|
+
error: {
|
|
263
|
+
message: 'Table not found',
|
|
264
|
+
code: 404,
|
|
265
|
+
type: 'NotFoundError'
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Quality Gates
|
|
271
|
+
|
|
272
|
+
Before verification, all items must be checked:
|
|
273
|
+
|
|
274
|
+
### Code Quality
|
|
275
|
+
|
|
276
|
+
- [ ] All unit tests pass (`npm test`)
|
|
277
|
+
- [ ] Coverage thresholds met (40% lines/functions/statements, 20% branches per jest.config.js)
|
|
278
|
+
- [ ] No linting errors (`npm run lint`)
|
|
279
|
+
- [ ] No TypeScript errors (`npm run build`)
|
|
280
|
+
|
|
281
|
+
### Functional Completeness
|
|
282
|
+
|
|
283
|
+
- [ ] All four tools implemented
|
|
284
|
+
- [ ] All tools registered in toolRegistry
|
|
285
|
+
- [ ] Parameter schemas match implementation
|
|
286
|
+
- [ ] Response types match API responses
|
|
287
|
+
|
|
288
|
+
### Critical Path Coverage
|
|
289
|
+
|
|
290
|
+
- [ ] Get relationships: happy path + errors
|
|
291
|
+
- [ ] Create relationship: all parameter combinations
|
|
292
|
+
- [ ] Update relationship: additive behavior verified
|
|
293
|
+
- [ ] Delete relationship: all error cases
|
|
294
|
+
|
|
295
|
+
### Safety Verification
|
|
296
|
+
|
|
297
|
+
- [ ] Delete tool description starts with WARNING
|
|
298
|
+
- [ ] Delete tool description mentions DESTRUCTIVE
|
|
299
|
+
- [ ] Delete tool description lists what is deleted
|
|
300
|
+
- [ ] Delete tool description states data is permanent
|
|
301
|
+
- [ ] Delete tool description recommends confirmation
|
|
302
|
+
|
|
303
|
+
### Edge Cases
|
|
304
|
+
|
|
305
|
+
- [ ] Empty results handled
|
|
306
|
+
- [ ] Pagination works
|
|
307
|
+
- [ ] Missing optional fields handled
|
|
308
|
+
- [ ] API error messages preserved
|
|
309
|
+
|
|
310
|
+
## Test File Organization
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
src/__tests__/tools/
|
|
314
|
+
relationships.test.ts # All relationship tool tests
|
|
315
|
+
- describe('GetRelationshipsTool')
|
|
316
|
+
- describe('tool properties')
|
|
317
|
+
- describe('execute - success')
|
|
318
|
+
- describe('execute - errors')
|
|
319
|
+
- describe('execute - edge cases')
|
|
320
|
+
- describe('CreateRelationshipTool')
|
|
321
|
+
- describe('tool properties')
|
|
322
|
+
- describe('execute - success')
|
|
323
|
+
- describe('execute - errors')
|
|
324
|
+
- describe('validation')
|
|
325
|
+
- describe('UpdateRelationshipTool')
|
|
326
|
+
- describe('tool properties')
|
|
327
|
+
- describe('execute - success')
|
|
328
|
+
- describe('execute - errors')
|
|
329
|
+
- describe('additive behavior')
|
|
330
|
+
- describe('DeleteRelationshipTool')
|
|
331
|
+
- describe('tool properties')
|
|
332
|
+
- describe('tool description safety') # CRITICAL
|
|
333
|
+
- describe('execute - success')
|
|
334
|
+
- describe('execute - errors')
|
|
335
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Ticket Review Updates
|
|
2
|
+
|
|
3
|
+
**Original Review Date:** 2025-12-28
|
|
4
|
+
**Updates Completed:** 2025-12-28
|
|
5
|
+
**Update Status:** Complete
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
| Category | Issues Found | Issues Fixed |
|
|
10
|
+
|----------|--------------|--------------|
|
|
11
|
+
| Critical Issues | 0 | 0 |
|
|
12
|
+
| Boundary Violations | 0 | 0 |
|
|
13
|
+
| High-Risk Areas | 3 | 3 |
|
|
14
|
+
| Gaps & Ambiguities | 5 | 3 |
|
|
15
|
+
| Ticket Issues | 0 | 0 |
|
|
16
|
+
|
|
17
|
+
## High-Risk Areas Addressed
|
|
18
|
+
|
|
19
|
+
### Risk 1: API Response Structure Assumption (Low-Medium Risk)
|
|
20
|
+
**Original Problem:** TypeScript interfaces based on documentation rather than live API testing. If actual API responses differ, tools may fail or return incorrect data.
|
|
21
|
+
|
|
22
|
+
**Changes Made:**
|
|
23
|
+
- **plan.md Phase 1**: Added explicit acceptance criterion requiring API response structure validation against TypeScript interfaces before proceeding to Phase 2
|
|
24
|
+
- **plan.md Phase 1 deliverables**: Added task to validate actual API responses match documented interfaces
|
|
25
|
+
|
|
26
|
+
**Result:** Phase 1 now includes explicit validation step to catch any documentation discrepancies early.
|
|
27
|
+
|
|
28
|
+
### Risk 2: Test Coverage Threshold Discrepancy (Low Risk)
|
|
29
|
+
**Original Problem:** Discrepancy between documented thresholds:
|
|
30
|
+
- jest.config.js: 40% lines/functions/statements, 20% branches
|
|
31
|
+
- quality-strategy.md: 35% minimum
|
|
32
|
+
- plan.md: >= 35%
|
|
33
|
+
|
|
34
|
+
**Changes Made:**
|
|
35
|
+
- **quality-strategy.md**: Updated minimum thresholds to match jest.config.js exactly (40% lines/functions/statements, 20% branches)
|
|
36
|
+
- **quality-strategy.md**: Clarified that 40% is the hard requirement from jest.config.js, with 80% as aspirational target for new relationship tools
|
|
37
|
+
- **plan.md Phase 3**: Updated acceptance criteria from >= 35% to >= 40% for consistency
|
|
38
|
+
- **plan.md Phase 4**: Updated acceptance criteria to reference jest.config.js thresholds (40% lines/functions/statements, 20% branches)
|
|
39
|
+
|
|
40
|
+
**Result:** All documents now consistently reference jest.config.js as the authoritative source for coverage thresholds.
|
|
41
|
+
|
|
42
|
+
### Risk 3: Conditional JSON Schema Validation for Summary Fields
|
|
43
|
+
**Original Problem:** `summary_accumulation_type` documented as "Required if summary_field_id" but JSON Schema validation rules not explicitly defined.
|
|
44
|
+
|
|
45
|
+
**Changes Made:**
|
|
46
|
+
- **architecture.md CreateRelationshipParams**: Added explicit note about conditional validation requirement
|
|
47
|
+
- **architecture.md UpdateRelationshipParams**: Added explicit note about conditional validation requirement
|
|
48
|
+
- **plan.md Phase 2**: Added acceptance criterion to validate that summary field parameters enforce accumulation type requirement
|
|
49
|
+
- **quality-strategy.md**: Added test case for missing accumulation type when summary_field_id is provided
|
|
50
|
+
|
|
51
|
+
**Result:** Implementation requirements now explicitly state that JSON Schema must enforce conditional validation.
|
|
52
|
+
|
|
53
|
+
## Gaps Filled
|
|
54
|
+
|
|
55
|
+
### Gap 1: Cross-App Relationship Handling
|
|
56
|
+
**Status:** Acknowledged as implementation-phase concern
|
|
57
|
+
**Action:** No planning document changes needed; implementation will handle error messages as recommended in review
|
|
58
|
+
|
|
59
|
+
### Gap 2: Relationship Field Type Validation
|
|
60
|
+
**Status:** Acknowledged as implementation-phase concern
|
|
61
|
+
**Action:** quality-strategy.md already includes tests for invalid field IDs
|
|
62
|
+
|
|
63
|
+
### Gap 3: Summary Field Accumulation Type Validation
|
|
64
|
+
**Status:** Fixed (see Risk 3 above)
|
|
65
|
+
|
|
66
|
+
### Ambiguity 1: Reference Field Deletion Behavior
|
|
67
|
+
**Changes Made:**
|
|
68
|
+
- **architecture.md DeleteRelationshipTool description**: Enhanced to explicitly note that reference field remains and may need manual deletion
|
|
69
|
+
|
|
70
|
+
**Result:** Tool description now clarifies cleanup steps after relationship deletion.
|
|
71
|
+
|
|
72
|
+
### Ambiguity 2: Pagination Implementation
|
|
73
|
+
**Changes Made:**
|
|
74
|
+
- **plan.md Phase 1**: Added acceptance criterion to verify actual pagination behavior during implementation
|
|
75
|
+
|
|
76
|
+
**Result:** Phase 1 will validate whether API supports limit parameter and adjust if needed.
|
|
77
|
+
|
|
78
|
+
## Document Change Summary
|
|
79
|
+
|
|
80
|
+
| Document | Lines Modified | Key Changes |
|
|
81
|
+
|----------|----------------|-------------|
|
|
82
|
+
| quality-strategy.md | ~8 | Updated coverage thresholds to match jest.config.js (40/40/40/20); added conditional validation test case |
|
|
83
|
+
| architecture.md | ~6 | Added conditional validation notes to CreateRelationshipParams and UpdateRelationshipParams; enhanced DeleteRelationshipTool description |
|
|
84
|
+
| plan.md | ~8 | Added API response validation to Phase 1; added conditional validation to Phase 2; updated Phase 3 and Phase 4 coverage thresholds; added pagination verification to Phase 1 |
|
|
85
|
+
| analysis.md | 0 | No changes needed |
|
|
86
|
+
| security-review.md | 0 | No changes needed |
|
|
87
|
+
|
|
88
|
+
## Verification
|
|
89
|
+
|
|
90
|
+
**Re-review Recommended:** Yes
|
|
91
|
+
**Expected Result:** All low and low-medium risks should now be resolved
|
|
92
|
+
|
|
93
|
+
## Next Steps
|
|
94
|
+
1. Run `/sdd:review RELS_relationship-management` to verify all issues addressed
|
|
95
|
+
2. If passes, proceed to `/sdd:create-tasks RELS_relationship-management`
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Security Review: Relationship Management
|
|
2
|
+
|
|
3
|
+
## Security Assessment
|
|
4
|
+
|
|
5
|
+
### Authentication & Authorization
|
|
6
|
+
|
|
7
|
+
**How Auth is Handled:**
|
|
8
|
+
|
|
9
|
+
Authentication for all relationship operations flows through the existing `QuickbaseClient` which:
|
|
10
|
+
|
|
11
|
+
1. Uses `QB-USER-TOKEN` header for authentication
|
|
12
|
+
2. Uses `QB-Realm-Hostname` header to identify the target realm
|
|
13
|
+
3. Token is provided via environment variable (`QUICKBASE_USER_TOKEN`)
|
|
14
|
+
4. Token is never logged (redacted in all logging)
|
|
15
|
+
|
|
16
|
+
**Authorization Model:**
|
|
17
|
+
|
|
18
|
+
- Quickbase API enforces role-based permissions at the API level
|
|
19
|
+
- Users can only access/modify relationships in tables they have permission to
|
|
20
|
+
- The MCP server does not add additional authorization layers
|
|
21
|
+
- Permission errors (403) are passed through to the agent
|
|
22
|
+
|
|
23
|
+
**Security Considerations:**
|
|
24
|
+
|
|
25
|
+
- Token stored in environment variables (standard practice)
|
|
26
|
+
- No token validation performed client-side (delegated to Quickbase API)
|
|
27
|
+
- All authorization errors from API are surfaced clearly
|
|
28
|
+
|
|
29
|
+
### Data Protection
|
|
30
|
+
|
|
31
|
+
**Sensitive Data Handling:**
|
|
32
|
+
|
|
33
|
+
| Data Type | Protection Method |
|
|
34
|
+
|-----------|-------------------|
|
|
35
|
+
| User Token | Redacted in logs, stored in env var |
|
|
36
|
+
| Realm Hostname | Partially redacted in logs |
|
|
37
|
+
| Table IDs | Not considered sensitive, logged for debugging |
|
|
38
|
+
| Relationship IDs | Not considered sensitive, logged for debugging |
|
|
39
|
+
| Field Labels | Not considered sensitive |
|
|
40
|
+
|
|
41
|
+
**Data in Transit:**
|
|
42
|
+
|
|
43
|
+
- All API calls use HTTPS (enforced by QuickbaseClient base URL)
|
|
44
|
+
- TLS/SSL certificate validation handled by Node.js fetch
|
|
45
|
+
|
|
46
|
+
**Data at Rest:**
|
|
47
|
+
|
|
48
|
+
- Response caching in memory only (CacheService)
|
|
49
|
+
- No persistent storage of relationship data
|
|
50
|
+
- Cache has configurable TTL (default 3600s)
|
|
51
|
+
|
|
52
|
+
### Input Validation
|
|
53
|
+
|
|
54
|
+
**Validation Approach:**
|
|
55
|
+
|
|
56
|
+
All tools use the existing `BaseTool.validateParams()` method which:
|
|
57
|
+
|
|
58
|
+
1. Validates against JSON Schema (`paramSchema`)
|
|
59
|
+
2. Uses Zod for runtime type checking
|
|
60
|
+
3. Provides descriptive error messages
|
|
61
|
+
|
|
62
|
+
**Parameter Validation Rules:**
|
|
63
|
+
|
|
64
|
+
| Parameter | Validation | Risk if Bypassed |
|
|
65
|
+
|-----------|------------|------------------|
|
|
66
|
+
| `table_id` | Required string | API error (400) |
|
|
67
|
+
| `relationship_id` | Required number for update/delete | API error (400) |
|
|
68
|
+
| `parent_table_id` | Required string for create | API error (400) |
|
|
69
|
+
| `lookup_field_ids` | Optional array of numbers | API error if invalid |
|
|
70
|
+
| `summary_accumulation_type` | Optional string | API error if invalid |
|
|
71
|
+
|
|
72
|
+
**Injection Prevention:**
|
|
73
|
+
|
|
74
|
+
- Parameters are passed as JSON body/query params
|
|
75
|
+
- No string interpolation in SQL/query contexts
|
|
76
|
+
- Quickbase API handles all query parsing
|
|
77
|
+
|
|
78
|
+
### Known Gaps
|
|
79
|
+
|
|
80
|
+
| Gap | Risk Level | Mitigation | Status |
|
|
81
|
+
|-----|------------|------------|--------|
|
|
82
|
+
| No rate limiting beyond API defaults | Low | Quickbase API has its own rate limiting; client has 10 req/sec default | Accepted |
|
|
83
|
+
| Delete operation is irreversible | High | Tool description strongly warns agent; recommends user confirmation | Mitigated |
|
|
84
|
+
| No role-based access control in MCP server | Medium | Relies on Quickbase API permissions; MCP server is trusted middleware | Accepted |
|
|
85
|
+
| Cached relationship data may become stale | Low | Cache TTL limits staleness; operations can use `skipCache` | Accepted |
|
|
86
|
+
| No audit logging of destructive operations | Medium | Quickbase API maintains audit trail; consider future enhancement | Deferred |
|
|
87
|
+
|
|
88
|
+
## Initial Release Security Scope
|
|
89
|
+
|
|
90
|
+
### In Scope
|
|
91
|
+
|
|
92
|
+
- **Input Validation**: All parameters validated before API calls
|
|
93
|
+
- **Error Handling**: API errors returned without sensitive data leakage
|
|
94
|
+
- **Token Protection**: User token never exposed in logs or error messages
|
|
95
|
+
- **HTTPS Enforcement**: All API calls over TLS
|
|
96
|
+
- **Agent Safety**: Delete operation clearly marked as destructive
|
|
97
|
+
|
|
98
|
+
### Out of Scope (Future Phases)
|
|
99
|
+
|
|
100
|
+
- **Audit Logging**: Detailed logging of who requested what operations
|
|
101
|
+
- **Additional Authorization**: Role-based restrictions beyond Quickbase API
|
|
102
|
+
- **Dry-Run Mode**: Preview what would be deleted before actual deletion
|
|
103
|
+
- **Undo/Recovery**: Ability to recover deleted relationships
|
|
104
|
+
- **Rate Limiting UI**: Visibility into remaining API quota
|
|
105
|
+
|
|
106
|
+
## Destructive Operation Security
|
|
107
|
+
|
|
108
|
+
### Delete Relationship Risk Assessment
|
|
109
|
+
|
|
110
|
+
**Risk:** Agents may delete relationships without understanding consequences, causing permanent data loss.
|
|
111
|
+
|
|
112
|
+
**Impact:**
|
|
113
|
+
- All lookup fields associated with relationship are deleted
|
|
114
|
+
- All summary fields associated with relationship are deleted
|
|
115
|
+
- Data in deleted fields is permanently lost
|
|
116
|
+
- Cannot be recovered without Quickbase backup restore
|
|
117
|
+
|
|
118
|
+
**Mitigations Implemented:**
|
|
119
|
+
|
|
120
|
+
1. **Tool Description Warning**
|
|
121
|
+
```
|
|
122
|
+
WARNING: DESTRUCTIVE OPERATION - Permanently deletes an entire
|
|
123
|
+
table-to-table relationship INCLUDING ALL LOOKUP AND SUMMARY FIELDS
|
|
124
|
+
associated with it. All data in those fields will be permanently
|
|
125
|
+
lost and CANNOT be recovered.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
2. **Guidance for Safe Usage**
|
|
129
|
+
- Recommends using `get_relationships` first to review impact
|
|
130
|
+
- Recommends confirming with user before proceeding
|
|
131
|
+
- Suggests deleting individual fields instead if relationship should remain
|
|
132
|
+
|
|
133
|
+
3. **No Automatic Execution**
|
|
134
|
+
- Agent must explicitly call the delete tool
|
|
135
|
+
- Human-in-the-loop confirmation recommended in description
|
|
136
|
+
|
|
137
|
+
### Comparison with Other Delete Operations
|
|
138
|
+
|
|
139
|
+
| Operation | Destructiveness | Current Mitigation | Recommendation |
|
|
140
|
+
|-----------|-----------------|--------------------|--------------------|
|
|
141
|
+
| Delete Record | Medium | Standard tool description | None needed |
|
|
142
|
+
| Delete Field | High | Standard tool description | Consider adding warning |
|
|
143
|
+
| Delete Table | Very High | Standard tool description | Consider adding warning |
|
|
144
|
+
| Delete Relationship | High | WARNING in description | Implemented |
|
|
145
|
+
| Delete App | Critical | Standard tool description | Strongly recommend warning |
|
|
146
|
+
|
|
147
|
+
## Security Checklist
|
|
148
|
+
|
|
149
|
+
### Code Security
|
|
150
|
+
|
|
151
|
+
- [x] No hardcoded secrets (tokens from env vars)
|
|
152
|
+
- [x] Input validation on all external inputs (BaseTool handles)
|
|
153
|
+
- [x] Proper error handling without info leakage (existing pattern)
|
|
154
|
+
- [x] Dependencies reviewed (existing deps, no new ones)
|
|
155
|
+
- [x] No SQL injection vulnerabilities (N/A - JSON API)
|
|
156
|
+
- [x] No XSS vulnerabilities (N/A - not a web UI)
|
|
157
|
+
|
|
158
|
+
### API Security
|
|
159
|
+
|
|
160
|
+
- [x] HTTPS enforced for all API calls
|
|
161
|
+
- [x] Auth token properly passed in headers
|
|
162
|
+
- [x] Auth token never logged
|
|
163
|
+
- [x] API errors handled without token exposure
|
|
164
|
+
- [x] Rate limiting in place (client default)
|
|
165
|
+
|
|
166
|
+
### Agent Safety
|
|
167
|
+
|
|
168
|
+
- [x] Destructive operations clearly labeled
|
|
169
|
+
- [x] Delete tool warns about permanent data loss
|
|
170
|
+
- [x] Delete tool lists what will be deleted
|
|
171
|
+
- [x] Delete tool recommends confirmation workflow
|
|
172
|
+
- [x] Non-destructive tools indicate they are safe
|
|
173
|
+
|
|
174
|
+
## Security Testing Requirements
|
|
175
|
+
|
|
176
|
+
### Authentication Tests
|
|
177
|
+
|
|
178
|
+
- [ ] Verify token is not present in any log output
|
|
179
|
+
- [ ] Verify 401 errors are handled gracefully
|
|
180
|
+
- [ ] Verify 403 errors return permission-denied message
|
|
181
|
+
|
|
182
|
+
### Input Validation Tests
|
|
183
|
+
|
|
184
|
+
- [ ] Test with malformed table IDs
|
|
185
|
+
- [ ] Test with injection attempts in string parameters
|
|
186
|
+
- [ ] Test with oversized payloads
|
|
187
|
+
|
|
188
|
+
### Error Handling Tests
|
|
189
|
+
|
|
190
|
+
- [ ] Verify error messages don't contain token
|
|
191
|
+
- [ ] Verify error messages don't contain realm details beyond necessary
|
|
192
|
+
- [ ] Verify network errors don't leak internal details
|
|
193
|
+
|
|
194
|
+
### Destructive Operation Tests
|
|
195
|
+
|
|
196
|
+
- [ ] Verify delete tool description contains required warnings
|
|
197
|
+
- [ ] Test delete returns clear confirmation of what was deleted
|
|
198
|
+
- [ ] Test delete errors don't suggest partial completion without clarity
|
|
199
|
+
|
|
200
|
+
## Recommendations
|
|
201
|
+
|
|
202
|
+
### Immediate (This Release)
|
|
203
|
+
|
|
204
|
+
1. **Implement comprehensive tool descriptions** - Done in design
|
|
205
|
+
2. **Follow existing security patterns** - Using BaseTool, QuickbaseClient
|
|
206
|
+
3. **Test error handling** - Ensure no sensitive data in errors
|
|
207
|
+
|
|
208
|
+
### Future Enhancements
|
|
209
|
+
|
|
210
|
+
1. **Audit Logging**: Add structured logging for relationship operations with timestamp, user (if available), and action
|
|
211
|
+
2. **Dry-Run Mode**: Consider `--dry-run` or preview parameter for delete
|
|
212
|
+
3. **Confirmation Token**: For extra safety, require a confirmation parameter for delete operations
|
|
213
|
+
4. **Rate Limit Visibility**: Expose remaining API quota in responses
|