Persist onboarding progress - #120
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #84
Adds persisted onboarding progress and a consent history model.
OnboardingProgress, 1:1 withUser):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 viaSet, and the record refuses further writes oncecompleted(terminal state).ConsentRecord, many-to-one withUser): append-only — every grant/withdraw inserts a new row instead of mutating one, so the row history is the audit trail. Each row carriespurpose,required(computed at write time fromREQUIRED_CONSENT_PURPOSES, frozen onto the row),policyVersion,status,source,grantedAt/withdrawnAt.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.OnboardingService.complete()requires allREQUIRED_ONBOARDING_STEPSpresent and allREQUIRED_CONSENT_PURPOSEScurrently granted (viaConsentService.hasAllRequiredGranted) before allowing thein_progress → completedtransition.ConsentService.withdrawblocks required purposes outright (required-cannot-withdraw); optional purposes withdraw freely, carrying forward the last knownpolicyVersion.GET /onboarding,POST /onboarding/steps,POST /onboarding/complete,GET /consents,GET /consents/history,POST /consents/grant,POST /consents/withdraw.Verification evidence
prisma/migrations/20260730130000_add_onboarding_and_consent/migration.sql—onboarding_progressandconsent_recordstables, FKs tousers, indexes onstatusand(userId, purpose, createdAt).