Skip to content

Cascading deletes#1572

Merged
TheLastCicada merged 17 commits into
developfrom
v2-rc2
Apr 7, 2026
Merged

Cascading deletes#1572
TheLastCicada merged 17 commits into
developfrom
v2-rc2

Conversation

@TheLastCicada

@TheLastCicada TheLastCicada commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Plus important dependency updates


Note

Medium Risk
Moderate risk: changes V2 delete behavior by staging cascaded child deletions inside a mutexed DB transaction, which could affect data-layer sync integrity if the cascade list is incomplete or mis-scoped. CI/workflow and wallet-availability retry tweaks may change test timing and failure modes but are operationally contained.

Overview
V2 deletes now cascade via staging: destroy handlers for project, verification, issuance, and unit stage DELETE rows for dependent child records (e.g., unit_label, unit, issuance) using new helpers in src/utils/v2-cascade-delete.js, and run the cascade + parent staging inside a sequelizeV2 transaction guarded by processingSyncRegistriesTransactionMutexV2.

Operational hardening: the org resync flow reconciles before opening the transaction to ensure the registry_hash reset wins; staging diff generation treats missing data as {}; assertWalletIsAvailable now distinguishes connection failures from temporary sync lag and retries a few times.

Tooling/CI updates: GitHub Actions installs are consolidated (npm ci, combined apt installs incl. MySQL + Chia tools), faucet funding wait is extended, CADT readiness uses a /health poll instead of fixed sleep, and commit-and-tag-version/release wiring is removed from package.json/lockfile while adding a new test:v2:live:cascade-delete script.

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

TheLastCicada and others added 17 commits April 3, 2026 11:05
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.
Wrap child and parent delete staging in one transaction so partial
staging cannot commit child deletes without the parent row.
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.
Replace commit-and-tag-version/conventional-changelog-cli with
release-please for automated version bumps, changelog generation,
and GitHub Release creation via a Release PR workflow on main.

- Add release-please-config.json and .release-please-manifest.json
- Add .github/workflows/release-please.yml (triggers on push to main)
- Strip auto-release.yml to dev-dependency auto-update only
- Remove commit-and-tag-version devDep, release script, and config
- Keep auto-release-rc.yml unchanged for RC releases on develop
Install required system packages and Chia tools in one step per job so
apt metadata refresh runs once after repository sources are configured.
chore(CI): migrate from standard-version to release-please
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.
The auto-release workflow's primary purpose is to compare the version
in package.json to existing tags and create a tag + changelog when the
version is new. PR #1567 removed this core functionality in favor of
release-please-action, which adds an unnecessary external dependency.

The original approach using npx conventional-changelog-cli works fine
and doesn't require any project devDependencies (npx downloads it
on-the-fly in CI). The commit-and-tag-version devDep removal from
#1567 is intentionally kept since the auto-release workflow never
used it — it only resolves the handlebars vulnerability from #1562.

Reverts: auto-release.yml changes from #1567
Removes: release-please.yml, release-please-config.json,
         .release-please-manifest.json
Testnet transaction confirmation latency caused the v1-to-v2 upgrade
test to timeout waiting for wallet funding. All 8 jobs got identical
HTTP 202 faucet responses, but confirmation times ranged from ~3 to
5+ minutes. Bump MAX_ATTEMPTS from 30 to 60 (10 minutes) across all
8 wallet funding polling loops to absorb testnet variability.
…-children

fix(V2): cascade stage project/unit child deletes
…e-tag-creation

revert(CI): restore auto-release tag creation, remove release-please
…g-timeout

fix(CI): increase faucet funding timeout from 5 to 10 minutes
…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.
After org creation, the wallet temporarily desyncs while processing
on-chain confirmations. The middleware assertWalletIsAvailable check
and test commitStagedRecords both failed instantly with no retry,
causing spurious CI failures.

Server-side: assertWalletIsAvailable now retries up to 5 times (25s)
when the wallet is reachable but not synced, while still failing fast
on connection errors (checked on every retry iteration).

Test-side (V1): commitStagedRecords retries up to 5 times (50s) on
wallet availability/sync errors before giving up. V2 already has
createRetryableRequest at the transport layer handling this, so the
V2 commitStagedRecords is left unchanged.
fix(V2): add cascade deletes for mid-chain verification and issuance endpoints
…-desync

fix(CI): retry on transient wallet desync during commit
@TheLastCicada TheLastCicada merged commit 5be9063 into develop Apr 7, 2026
27 checks passed
@TheLastCicada TheLastCicada deleted the v2-rc2 branch April 7, 2026 19:33
@TheLastCicada TheLastCicada restored the v2-rc2 branch April 7, 2026 20:09
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