Skip to content

Fix verifier transition transaction invariants - #1588

Merged
1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
0x-fyve:fix-1526-verifier-quorum-transitions
Aug 30, 2026
Merged

1nonlypiece merged 1 commit into
Disciplr-Org:mainfrom
0x-fyve:fix-1526-verifier-quorum-transitions

Conversation

@0x-fyve

@0x-fyve 0x-fyve commented Aug 30, 2026

Copy link
Copy Markdown

Overview

Makes verifier decision recording and admin verifier approve/suspend transitions deterministic across retries and concurrent requests.

Related Issue

Closes #1526
Refs #1526

Changes

  • Persist verification records, audit logs, and evidence references in the same database transaction for single and bulk verification submissions.
  • Remove manual rollback deletes from verification routes so failed evidence validation rolls back the whole transaction instead of attempting partial cleanup after commit.
  • Add transaction support to audit log creation so verifier mutations and verification decisions do not split audit writes from their owning state change.
  • Add transaction-aware evidence reference persistence while preserving the existing Prisma path for standalone service calls.
  • Add createOrTransitionVerifier for atomic admin approve/suspend creation or transition, including duplicate-create recovery via onConflict('user_id').ignore().
  • Update route tests to assert that evidence references are written with the same transaction object as the verification record.

Verification Results

  • npm test -- src/tests/verifications.idempotency.test.ts src/tests/verifications.bulk.test.ts src/tests/adminVerifiers.test.ts tests/adminVerifiers.lifecycle.test.ts
    • Passed: 4 suites, 73 tests.
  • npx tsc --noEmit --skipLibCheck --module NodeNext --moduleResolution NodeNext --target ES2022 --types node,jest src/routes/verifications.ts src/routes/adminVerifiers.ts src/services/verifiers.ts src/services/evidence.ts src/lib/audit-logs.ts
    • Passed.
  • git diff --check
    • Passed.
  • npm run build
    • Failed due to pre-existing unrelated syntax errors in src/middleware/webhookVerify.ts at lines 380 and 517.

Acceptance Criteria

Criteria Status
Verification submissions are atomic across verification, audit, and evidence writes Done
Duplicate/retry behavior remains deterministic through existing idempotency checks Done
Admin verifier approve/suspend uses a single create-or-transition transaction Done
Concurrent admin creation recovers from stale reads without duplicate profiles Done
Focused automated tests cover transaction plumbing and route behavior Done

Notes

This change intentionally does not alter unrelated webhook verification syntax errors or dependency/lockfile state.

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@0x-fyve Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@1nonlypiece
1nonlypiece merged commit 32f2163 into Disciplr-Org:main Aug 30, 2026
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.

[Quality][High] Improve verifier quorum and administrator transitions: transactional invariants and recovery

2 participants