Skip to content

Persist onboarding progress - #120

Merged
3m1n3nc3 merged 2 commits into
learnault:mainfrom
Ezeh20:persist-onboarding-progress
Jul 30, 2026
Merged

Persist onboarding progress#120
3m1n3nc3 merged 2 commits into
learnault:mainfrom
Ezeh20:persist-onboarding-progress

Conversation

@Ezeh20

@Ezeh20 Ezeh20 commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Closes #84

Adds persisted onboarding progress and a consent history model.

  • Onboarding (OnboardingProgress, 1:1 with User): version, currentStep, completedSteps[], status, timestamps. Resuming (GET /onboarding) upserts-on-read so it's deterministic on first and every subsequent call. Saving a step (POST /onboarding/steps) is idempotent — steps dedupe via Set, and the record refuses further writes once completed (terminal state).
  • Consent (ConsentRecord, many-to-one with User): append-only — every grant/withdraw inserts a new row instead of mutating one, so the row history is the audit trail. Each row carries purpose, required (computed at write time from REQUIRED_CONSENT_PURPOSES, frozen onto the row), policyVersion, status, source, grantedAt/withdrawnAt.
  • Transitions: a generic canTransition<S>(map, from, to) guard (src/utils/transitions.ts) — a minimal, scoped stand-in for the still-unbuilt "Introduce Typed Status Enums and Transition Guards" dependency, sized to what this feature needs rather than blocking on that work.
  • Completion gating: OnboardingService.complete() requires all REQUIRED_ONBOARDING_STEPS present and all REQUIRED_CONSENT_PURPOSES currently granted (via ConsentService.hasAllRequiredGranted) before allowing the in_progress → completed transition.
  • Required vs. optional kept distinct: ConsentService.withdraw blocks required purposes outright (required-cannot-withdraw); optional purposes withdraw freely, carrying forward the last known policyVersion.
  • Routes: GET /onboarding, POST /onboarding/steps, POST /onboarding/complete, GET /consents, GET /consents/history, POST /consents/grant, POST /consents/withdraw.

Verification evidence

  • Migration: prisma/migrations/20260730130000_add_onboarding_and_consent/migration.sqlonboarding_progress and consent_records tables, FKs to users, indexes on status and (userId, purpose, createdAt).
  • Transition matrix:

@3m1n3nc3
3m1n3nc3 merged commit 12928ee into learnault:main Jul 30, 2026
1 check passed
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.

Feature: Add Onboarding and Consent Persistence

3 participants