Skip to content

fix(V2): add cascade deletes for mid-chain verification and issuance endpoints#1571

Merged
TheLastCicada merged 1 commit into
v2-rc2from
fix/mid-chain-cascade-deletes
Apr 7, 2026
Merged

fix(V2): add cascade deletes for mid-chain verification and issuance endpoints#1571
TheLastCicada merged 1 commit into
v2-rc2from
fix/mid-chain-cascade-deletes

Conversation

@TheLastCicada

@TheLastCicada TheLastCicada commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes orphaned children on verification/issuance delete: DELETE /v2/verification/:id now cascades to issuances → units → unit_labels, and DELETE /v2/issuance/:id now cascades to units → unit_labels. Previously only the parent row was staged, leaving downstream records orphaned in the datalayer.
  • Adds stageVerificationChildDeletes and stageIssuanceChildDeletes to v2-cascade-delete.js, mirroring the existing project and unit cascade patterns (transaction + mutex).
  • Documents the two-category deletion design in a JSDoc block: project-scoped records cascade on delete; shared/standalone records (methodology, stakeholder, program, label) intentionally do NOT cascade because they can be cross-referenced by other registries on the network.

Test plan

Integration tests (all new, run via npm run test:v2)

  • Verification cascade: delete verification → stages issuance + unit + unit_label deletes (3 child deletes)
  • Issuance cascade: delete issuance with 2 units + 2 unit_labels → stages all 4 child deletes (also covers multi-unit-per-issuance edge case)
  • Issuance no-children: delete issuance with no units → stagedChildDeletes === 0
  • Verification no-children: existing test updated to assert stagedChildDeletes === 0
  • Double delete: deleting a project twice before commit creates duplicate staging rows (documents current behavior)
  • Multi-unit cascade: project delete with 2 units under one issuance cascades all units + unit_labels

Live API tests (run via npm run test:v2:live:cascade-delete)

  • Batched test covering all three cascade levels in one commit cycle: unit → unit_label, issuance → unit + unit_label, verification → issuance + unit + unit_label. Replaces the previous single unit-cascade test to add coverage without adding extra commit cycles (~2 min each).

Note

Medium Risk
Modifies V2 deletion staging for verification and issuance to add transactional cascade behavior; mistakes could over/under-delete staged records or impact DataLayer sync ordering, but scope is limited to delete paths and is covered by new integration/live tests.

Overview
Fixes mid-chain delete staging for V2 verification and issuance. DELETE /v2/verification/:id now also stages deletes for downstream issuance → unit → unit_label, and DELETE /v2/issuance/:id now stages unit → unit_label deletes to prevent orphaned children.

Deletes are now staged under the existing V2 mutex + sequelizeV2.transaction, and responses include stagedChildDeletes for visibility. Adds new cascade helpers (stageVerificationChildDeletes, stageIssuanceChildDeletes) plus expanded integration and live API coverage for multi-child cascades, no-children cases, and documenting current double-delete-before-commit behavior.

Reviewed by Cursor Bugbot for commit dcdb60f. Bugbot is set up for automated code reviews on this repo. Configure here.

…endpoints

DELETE /v2/verification/:id and DELETE /v2/issuance/:id previously staged
only the parent row, orphaning downstream children (issuances, units,
unit_labels). This mirrors the cascade logic already present on project
and unit deletes.

Adds stageVerificationChildDeletes and stageIssuanceChildDeletes helpers,
wires them into their respective controllers with transaction + mutex,
and documents the two-category deletion design (project-scoped cascade
vs shared-record guard) in v2-cascade-delete.js.

Integration tests cover both mid-chain cascades, double-delete
idempotency, and multi-unit-per-issuance. Live API test batches all
three cascade levels (unit, issuance, verification) into one commit
cycle to avoid adding test runtime.
@TheLastCicada TheLastCicada merged commit bd3da80 into v2-rc2 Apr 7, 2026
25 checks passed
@TheLastCicada TheLastCicada deleted the fix/mid-chain-cascade-deletes branch April 7, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant