Principle:ALwrity ALwrity Onboarding Session Management
| Knowledge Sources | |
|---|---|
| Domains | Software_Architecture, Onboarding, Multi_Tenancy |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Mechanism that tracks a user's progress through a multi-step initialisation flow, reconciling persisted state against actual artefacts so a session can resume from the correct step without losing prior work.
Description
Onboarding session management is the pattern of storing a user's progress through a sequential setup flow — API keys, website analysis, research preferences, persona generation, business info — and exposing that state to the frontend so the user can resume where they left off. It solves the problem of a user abandoning a multi-step flow partway through and returning later: rather than forcing them to restart, the system loads the persisted step index, inspects which artefacts actually exist in the database, and presents the first incomplete step.
A critical refinement is reconciliation: if all required artefacts exist but the completion flag was never set (e.g. a backend error prevented the final mark), the system detects this and marks the flow complete in a one-time pass. This makes the flow idempotent — re-initialising a fully-onboarded user is a no-op.
Usage
Use this principle when:
- A product has a multi-step setup flow that users may interrupt and resume.
- The flow's steps produce persistent artefacts (DB rows, files) that can be inspected independently of the step counter.
- The frontend needs a single "where am I" endpoint to decide which step to render.
- A hard reset (delete all artefacts) and a soft reset (reset step counter only) are both needed.
Theoretical Basis
The session is modelled as a state machine with one state per step plus a terminal completed state. The transition function is:
# Abstract state machine (NOT a real implementation)
def next_step(session):
for step in STEPS: # 1..N
if not artefact_exists(session.user, step):
return step # first incomplete step
return COMPLETED # all artefacts present
def reconcile(session):
if not session.completed and all(artefact_exists(session.user, s) for s in STEPS):
session.completed = True # one-time fix-up
The key insight is that the authoritative state is the set of artefacts, not the step counter: the counter is a derived view that is recomputed on each initialisation.
Practical Guide
- Artefact-first state. Compute the current step from the presence of artefacts, not from a stored counter, so corruption of the counter self-heals.
- Reconciliation pass. Run a reconciliation check on every initialisation; it is cheap and idempotent.
- Hard vs. soft reset. A soft reset resets the counter; a hard reset deletes artefacts and cascades to dependent scheduled tasks.
- Per-tenant isolation. Store session state in the per-user database so one user's reset never touches another's.