Skip to content

fix(V2): cascade stage project/unit child deletes#1564

Merged
TheLastCicada merged 6 commits into
v2-rc2from
fix/cascade-delete-project-children
Apr 7, 2026
Merged

fix(V2): cascade stage project/unit child deletes#1564
TheLastCicada merged 6 commits into
v2-rc2from
fix/cascade-delete-project-children

Conversation

@TheLastCicada

@TheLastCicada TheLastCicada commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add src/utils/v2-cascade-delete.js to stage child DELETE rows for project and unit delete flows before parent delete staging
  • update project-v2 and unit-v2 destroy handlers to invoke cascade staging and return stagedChildDeletes
  • add integration and live API coverage for project/unit cascade delete behavior, and update stale orphan-record TODO comments in staging model

Test plan

  • fnm use && npm run test:v2
  • Run tests/v2/live-api/cascade-delete.live.spec.js against a live CADT+datalayer environment

Note

Medium Risk
Touches V2 deletion/staging logic and introduces transactional, mutex-guarded cascade delete staging, which could affect data-layer consistency if incorrect. CI workflow changes (dependency install, service readiness checks) may also impact test stability across jobs.

Overview
Adds cascade delete staging for V2 project and unit deletes by introducing src/utils/v2-cascade-delete.js to pre-stage DELETE rows for dependent child records (e.g., verificationissuanceunitunit_label, plus other project children).

Updates the V2 destroy handlers to run cascade staging inside a sequelizeV2 transaction guarded by processingSyncRegistriesTransactionMutexV2, and returns stagedChildDeletes in the API response; also reorders org resync reconciliation to occur before opening its transaction.

Expands coverage with new V2 integration tests and a new live API suite (tests/v2/live-api/cascade-delete.live.spec.js) and wires it into data-short.js; CI workflow is tightened by using npm ci, consolidating system/Chia installs, adding CADT health polling, and removing some verbose port diagnostics.

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

Prevent orphaned child records by staging DELETE rows for project/unit
children before parent deletion. This keeps staged changes aligned with
the datalayer commit pipeline and makes delete responses explicit via
stagedChildDeletes counts.
Comment thread src/controllers/v2/project-v2.controller.js Outdated
Wrap child and parent delete staging in one transaction so partial
staging cannot commit child deletes without the parent row.
@TheLastCicada TheLastCicada changed the base branch from develop to v2-rc2 April 6, 2026 16:00
Reduce fixed waits and redundant setup in the v2 live-api job, and
run cascade delete coverage from the existing data-short orchestration
instead of a separate test process.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bf336d4. Configure here.

Comment thread .github/workflows/tests.yaml
Install required system packages and Chia tools in one step per job so
apt metadata refresh runs once after repository sources are configured.
getDiffObject returned diff.change={} for DELETE actions, but the
staging findAll controller strips raw data from the response. The
cascade delete live test relied on row.data (which was removed) causing
JSON.parse(undefined). Include parsed staging data in diff.change for
DELETE (matching INSERT/UPDATE behavior) and update the test to read
from diff.change.
Move reconcileOrganization() before the transaction in the resync
controller so its non-transactional DB writes complete before the
registry_hash='0' reset, preventing a race where reconcile overwrites
the reset value.

Fix V1 unit integration tests that checked staging-empty immediately
after commit+sync. The sync task inserts data before its afterCommit
callback truncates staging, so merge the staging-empty check into the
poll condition. Also clear committed staging records before the split
call so assertNoPendingCommits passes, and increase maxAttempts for the
serial-number ordering test to handle sync backlog from prior tests.
@TheLastCicada TheLastCicada merged commit 0a18f1f into v2-rc2 Apr 7, 2026
35 of 36 checks passed
@TheLastCicada TheLastCicada deleted the fix/cascade-delete-project-children branch April 7, 2026 16:39
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