4.0 KiB
4.0 KiB
Setup State Machine
D.7.1 does not implement persistence. This document proposes the model and transitions for D.7.8.
States
not_started
readiness_checked
foundation_installed
organization_created
administrator_created
scope_configured
sequences_configured
approval_configured
csv_validated
csv_imported
verified
completed
failed
cancelled
Events
CHECK_READINESS
INSTALL_FOUNDATION
CREATE_ORGANIZATION
CREATE_ADMIN
CONFIGURE_SCOPE
CONFIGURE_SEQUENCES
CONFIGURE_APPROVAL
VALIDATE_CSV
IMPORT_CSV
RUN_VERIFICATION
COMPLETE_SETUP
FAIL_STEP
CANCEL_SETUP
RESUME_SETUP
RESET_STEP
Transition Rules
| From | Event | To | Guard |
|---|---|---|---|
not_started |
CHECK_READINESS |
readiness_checked |
Required readiness checks pass or warnings are acknowledged. |
readiness_checked |
INSTALL_FOUNDATION |
foundation_installed |
Migrations valid and seed transaction succeeds. |
foundation_installed |
CREATE_ORGANIZATION |
organization_created |
Organization is created or resolved. |
organization_created |
CREATE_ADMIN |
administrator_created |
User, membership, and CRM role assignment resolve. |
administrator_created |
CONFIGURE_SCOPE |
scope_configured |
At least one branch and product type exists. |
scope_configured |
CONFIGURE_SEQUENCES |
sequences_configured |
Required sequence previews succeed. |
sequences_configured |
CONFIGURE_APPROVAL |
approval_configured |
Quotation workflow, steps, and matrix resolve. |
approval_configured |
VALIDATE_CSV |
csv_validated |
Preview has no blocking errors, or no CSV files were selected. |
csv_validated |
IMPORT_CSV |
csv_imported |
Commit succeeds or CSV import skipped. |
csv_imported |
RUN_VERIFICATION |
verified |
Required verification checks pass. |
verified |
COMPLETE_SETUP |
completed |
No blocking failures remain. |
| any non-completed state | FAIL_STEP |
failed |
Step returns blocking error. |
| any non-completed state | CANCEL_SETUP |
cancelled |
User confirms cancellation. |
failed |
RESUME_SETUP |
prior recoverable state | Failure source still recoverable. |
| completed step state | RESET_STEP |
earliest affected state | Explicit confirmation and reset scope guard pass. |
Proposed Persistence
setup_runs
Purpose: one row per setup attempt.
Fields:
idstatusmode:production | demo_uat | dry_runtarget_organization_idstarted_bycompleted_bystarted_atcompleted_atlast_errormetadata- timestamps
setup_run_steps
Purpose: step-level status, resume, and report storage.
Fields:
idsetup_run_idstep_keystatusinput_hashoutput_jsonerrors_jsonwarnings_jsonstarted_atcompleted_at- timestamps
seed_manifests
Purpose: seed package lifecycle tracking.
Fields:
idsetup_run_idorganization_idnameversiontypechecksumstatusapplied_byapplied_atreport_json- timestamps
seed_manifest_items
Purpose: item-level seed/import report and checksum tracking.
Fields:
idseed_manifest_iditem_keysource_filechecksumstatusimported_countupdated_countskipped_counterror_countwarning_countreport_json- timestamps
Staleness Rules
- Changing organization setup makes administrator, scope, sequence, approval, CSV, and verification stale.
- Changing administrator makes verification stale.
- Changing scope makes sequences, approval, CSV, and verification stale.
- Changing sequences makes verification stale.
- Changing approval makes CSV quotations and verification stale.
- Changing CSV preview invalidates committed import unless the source file checksum is unchanged.
- Any committed import makes verification stale.
Cancellation Rules
cancelledkeeps report history.- Cancellation does not rollback already committed successful steps.
- A cancelled setup can resume only through
RESUME_SETUPwith explicit acknowledgement of committed state.