Skip to content

Commit 741dec0

Browse files
committed
fix(V2): strengthen cascade-delete staging assertions
- Add exact DELETE row count guards after each staging query (12 for Graph A, 21 for Graph A + Graph B combined) to catch mutations that stage spurious extra rows without changing the stagedChildDeletes counter - Expand Graph B survivor list to include val1Id/val2Id/val3Id — the parent validations whose child verifications were deleted; these must NOT be cascade-deleted upward
1 parent c1073d1 commit 741dec0

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/v2/live-api/cascade-delete.live.spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ describe('Cascade Delete Live API Tests', function () {
136136
expect(hasStagedDelete(stagedRowsA, table, key, value), `missing staged delete ${table}:${value}`).to.equal(true);
137137
}
138138

139+
// Exact row count guards against spurious over-staging (12 = 11 children + project itself)
140+
const deleteRowsA = stagedRowsA.filter((r) => r.action === 'DELETE');
141+
expect(deleteRowsA.length, 'unexpected extra staged deletes in Graph A').to.equal(12);
142+
139143
// --- Graph B deletes: unit3, issuance2, verification1 ---
140144
const unitDelResp = await request.delete(`/v2/unit/${unit3Id}`).expect(200);
141145
expect(unitDelResp.body.success).to.equal(true);
@@ -171,6 +175,10 @@ describe('Cascade Delete Live API Tests', function () {
171175
expect(hasStagedDelete(stagedRowsB, table, key, value), `missing staged delete ${table}:${value}`).to.equal(true);
172176
}
173177

178+
// Exact row count: 12 from Graph A + 9 from Graph B = 21 DELETE rows total
179+
const deleteRowsB = stagedRowsB.filter((r) => r.action === 'DELETE');
180+
expect(deleteRowsB.length, 'unexpected extra staged deletes after Graph B').to.equal(21);
181+
174182
// --- Commit cycle 2: commit all deletes (both graphs) in one pass ---
175183
await commitStagedRecords(request, [], true);
176184
await waitForPendingCommits(request);
@@ -216,10 +224,15 @@ describe('Cascade Delete Live API Tests', function () {
216224
}
217225

218226
// Verify non-deleted Graph B siblings are still present (guards against
219-
// overly-aggressive cascades that silently delete sibling entities)
227+
// overly-aggressive cascades that silently delete sibling entities).
228+
// val1/val2/val3 are parent validations whose child verifications were
229+
// deleted — they must NOT be cascade-deleted upward.
220230
const survivingGraphB = [
221231
['/v2/project', projectBId],
222232
['/v2/project-methodology', pm1Id],
233+
['/v2/validation', val1Id],
234+
['/v2/validation', val2Id],
235+
['/v2/validation', val3Id],
223236
['/v2/verification', ver2Id],
224237
['/v2/verification', ver3Id],
225238
['/v2/issuance', iss3Id],

0 commit comments

Comments
 (0)