Forms Builder

Forms Builder - Operational Workflows & State Machines

Form authoring lifecycle, multi-step draft progression, DAG evaluation cycle, and state transition tables for the Forms Builder domain.

Operational Workflows & State Machines

The Forms Builder domain operates through controlled state machines that govern how form schemas are authored, validated, published, and deprecated, as well as how respondents navigate multi-step drafts and finalize submissions.


1. Schema Authoring & Version Lifecycle

A form schema progresses through a unidirectional lifecycle ensuring that active forms remain stable while permitting continuous design iteration:

stateDiagram-v2
    [*] --> Draft: Administrator Creates / Clones Version
    Draft --> Validating: Publish Request Triggered
    Validating --> Draft: Cycle Detected / Validation Error
    Validating --> ActivePublished: DAG Validated & Zero Cycles Confirmed
    ActivePublished --> Deprecated: Superceded by Newer Version
    ActivePublished --> Archived: Blueprint Decommissioned
    Deprecated --> Archived: All Retention Windows Expired
    Archived --> [*]

Schema Version State Transitions

Current StateTarget StateTrigger / ActionGuard ConditionsPrimary ActorDomain Event Emitted
[*] DraftDesigner creates new blueprint or clones an existing frozen schemaBlueprint code is unique; authoring permissions verifiedForm DesignerFormSchemaDraftCreated
DraftValidatingDesigner clicks “Publish Version”At least one page and one valid input field existForm DesignerFormSchemaValidationInitiated
ValidatingActivePublishedSystem finishes cycle detection and structural verificationDependency graph is acyclic; all validation descriptors are soundSchema Validation EngineFormSchemaPublished
ValidatingDraftSystem discovers an invalid dependency or structural errorCycle detected or invalid regex descriptor foundSchema Validation EngineFormSchemaValidationFailed
ActivePublishedDeprecatedA newer schema version for the same blueprint is publishedNewer version achieves ActivePublished stateSystem OrchestratorFormSchemaDeprecated
ActivePublishedArchivedAdministrator shuts down the form permanentlyBlueprint decommission requested; in-flight drafts notifiedForm AdministratorFormSchemaArchived
DeprecatedArchivedFormal retention period passes with zero active draft sessionsNo open draft sessions remain bound to this versionLifecycle DaemonFormSchemaArchived

2. Submitter Response & Multi-Step Draft Progression

Respondents interact with multi-step forms through a persistent draft state machine:

flowchart TD
    Start["User Opens Form URL"] --> CheckPolicy{"Access & Quota Valid?"}
    CheckPolicy -->|No: Quota / Expired| Deny["Halt: Show Expiration / Quota Screen"]
    CheckPolicy -->|Yes: Access Granted| InitDraft["Initialize SubmissionDraftSession"]

    InitDraft --> StepView["Render Current Page / Step"]
    StepView --> UserInput["User Inputs Answers"]
    UserInput --> DagEval["Client-Side DAG Evaluation<br/>(Visibility & Formulas Updated)"]

    DagEval --> AutosaveTrigger{"Autosave Triggered?<br/>(Time / Step Navigation)"}
    AutosaveTrigger -->|Yes| SaveDraft["Persist Answers to Draft Session"]
    AutosaveTrigger -->|No| NextStep{"User Navigates Next?"}

    SaveDraft --> NextStep
    NextStep -->|Forward Page| StepGate{"Current Step Valid?"}
    StepGate -->|Fails| ShowErrors["Display Inline Errors"]
    ShowErrors --> UserInput
    StepGate -->|Passes| BranchLogic{"Skip Logic Present?"}
    BranchLogic -->|Jump Ahead| JumpPage["Navigate to Target Page"]
    BranchLogic -->|Sequential| NextPage["Navigate to Step (N+1)"]
    JumpPage --> StepView
    NextPage --> StepView

    NextStep -->|Final Submit Clicked| ServerValidation["Authoritative Server-Side Validation"]
    ServerValidation --> Result{"Exhaustive Validation Pass?"}
    Result -->|Fails| ReturnErrors["Return Field Error Map to User"]
    ReturnErrors --> UserInput

    Result -->|Passes| PurgeHidden["Purge Conditionally Concealed Answers"]
    PurgeHidden --> HashSealing["Generate SHA-256 Response Hash"]
    HashSealing --> CommitSubmission["Commit FormSubmission Aggregate"]
    CommitSubmission --> EmitEvent["Emit FormSubmissionValidated Event"]
    EmitEvent --> TerminateDraft["Purge Draft Session & Display Confirmation"]

3. Submission Draft Session State Transitions

Current StateTarget StateTrigger / ActionGuard ConditionsPrimary ActorDomain Event Emitted
[*] SessionInitiatedUser loads active form URL or opens invitation tokenForm is ActivePublished; quota not reached; not expiredSubmitterFormDraftSessionStarted
SessionInitiatedDraftProgressSubmitter enters values or triggers autosaveSession token valid; payload size within boundariesSubmitter ClientFormDraftStepSaved
DraftProgressDraftProgressSubmitter navigates between pages or periodically savesStep answers conform to minimum client requirementsSubmitter ClientFormDraftStepSaved
DraftProgressSubmittedSubmitter submits final step and server validation passesAll required active fields valid; response hash sealedServer Validation EngineFormSubmissionValidated
DraftProgressExpiredInactivity window exceeds session retention (e.g., 30 days)Current timestamp > session expiration timestampExpiration DaemonFormDraftSessionExpired
DraftProgressTerminatedBlueprint quota is filled by another concurrent userTarget blueprint transitions to QuotaExhaustedSystem Concurrency ManagerFormDraftSessionTerminated

4. Directed Acyclic Graph (DAG) Runtime Evaluation Workflow

At both runtime client display and authoritative server ingestion, conditional visibility and calculations are resolved through an exact topological evaluation workflow:

flowchart LR
    A["Field Input Change<br/>(e.g., has_dependents = True)"] --> B["Locate DAG Dependents<br/>in Dependency Adjacency Map"]
    B --> C["Topologically Order<br/>Affected Dependent Nodes"]
    C --> D["Evaluate Visibility Expressions<br/>Against Current Answers"]
    D --> E{"Visibility State Changed?"}

    E -->|Becomes Visible| F["Enable Controls & Apply Required Rules"]
    E -->|Becomes Concealed| G["Disable Controls & Mark for Data Purging"]

    F --> H["Evaluate Computed Formulas<br/>(e.g., total_score = sum(...))"]
    G --> H
    H --> I["Update Downstream Dependents<br/>Recursively Along DAG Edges"]
    I --> J["Render Final Visual State<br/>or Finalize Server Validation"]

Dynamic Evaluation Invariants

  • Topological Order Execution: If Field $C$ depends on Field $B$, and Field $B$ depends on Field $A$, changes to Field $A$ strictly trigger evaluation of $B$ first, followed by $C$.
  • Short-Circuit Protection: If a parent Layout Section evaluates to hidden, all contained child fields are automatically treated as concealed without evaluating their individual conditional logic expressions.

Our Premium Sponsors

Obelaw is proudly open-source. Continued development, bug fixes, and community support are made possible by the generosity of our sponsors.

Sponsor Obelaw