Skip to content

System setup flows

Setup flows provide a structured entry point for initial configuration and later administration. Brezel ships with an AI foundation flow for semantics, organization structure, signal sources, and agents. A system can replace that flow or add its own flows with resource_setup_flow Bakery resources.

Setup flows do not introduce a second data model for configuration. Steps point to ordinary Brezel modules and entities, so permissions, validation, history, and module layouts continue to apply.

Create a grouped Bakery file such as setup.bake.json:

[
{
"resource_setup_flow": "project_setup",
"resource": {
"title": "Project setup",
"description": "Configure the records required before work starts.",
"auto_start": true,
"roles": ["admin"],
"steps": [
{
"identifier": "projects",
"title": "Projects",
"scope": "client",
"required": true,
"targets": [
{
"identifier": "projects",
"type": "entities",
"module": "projects",
"mode": "collection",
"minimum": 1
}
]
}
]
}
}
]

When layout is omitted, Brezel generates a setup layout from the declared targets. The generated setup_resource widget links to the normal module list and create views.

Progress is stored independently for the scope selected by a step:

ScopeProgress belongs to
systemThe complete Brezel system.
clientThe active client.
userThe current user.
{"type":"entity","module":"projects"}A selected entity in the named module.

Entity-scoped steps show an authorized entity selector before opening the step. Targets can use scope_field to count or provision records related to the selected entity.

A target describes the records a step manages:

{
"identifier": "settings",
"type": "entities",
"module": "project_settings",
"mode": "singleton",
"scope_field": "project",
"minimum": 1,
"maximum": 1,
"defaults": {
"enabled": true
}
}

module can be a module identifier or a capability selector:

{
"capability": "SignalSources",
"strategy": "single"
}

Use strategy: "all" when a step intentionally covers every module carrying the capability. A single selector fails when more than one module matches instead of selecting one arbitrarily.

Supported target modes are create, singleton, collection, and scope_entity. Completion can require minimum and maximum record counts. A step is complete only after its checks pass and a user explicitly confirms it.

Steps can ensure that required entities exist when the step opens or is confirmed:

{
"identifier": "settings",
"title": "Project settings",
"scope": {"type": "entity", "module": "projects"},
"targets": [
{
"identifier": "settings",
"type": "entities",
"module": "project_settings",
"mode": "singleton",
"scope_field": "project",
"minimum": 1
}
],
"provision": [
{
"identifier": "project-settings",
"type": "entity.ensure",
"trigger": "on_enter",
"target": "settings",
"match": {"project": "$scope.entity_id"},
"values": {
"project": "$scope.entity_id",
"enabled": true
}
}
]
}

entity.ensure requires a non-empty match object. It updates the single matching entity or creates one when no match exists; multiple matches abort the operation. It runs through normal module policies and entity validation. Password fields are rejected.

Exact value placeholders supported in match, values, and nested arrays are $scope.id, $scope.entity_id, $scope.module, $client.id, and $user.id.

A step layout can be supplied in three ways:

  1. Omit layout to generate one from targets.
  2. Set layout to a global layout identifier.
  3. Put a complete layout JSON object directly in the step.

Inline example:

{
"identifier": "sources",
"title": "Signal sources",
"scope": "client",
"layout": {
"tabs": [
{
"rows": [
{
"cols": [
{
"components": [
{
"type": "widget",
"options": {
"widget": "setup_resource",
"target": "sources",
"dynamic_height": true
}
}
]
}
]
}
]
}
]
},
"targets": [
{
"identifier": "sources",
"type": "entities",
"module": {"capability": "SignalSources", "strategy": "single"},
"mode": "collection",
"minimum": 1
}
]
}

Inline layouts pass through the regular layout structure validator. They can use all normal layout components and widgets. The setup runtime is available to widgets as context.setup.

Use when.capability to hide a step when its supporting capability is absent:

{"when": {"capability": "OrganizationAssignments"}}

Packaged flows and layouts are fallbacks. A Bakery flow with the same identifier replaces the packaged flow. A stored global layout with the same identifier takes precedence over a packaged setup layout. This allows systems to keep the standard AI setup sequence while replacing individual presentations.

auto_start only opens an incomplete, non-dismissed flow from the authenticated start page. Dismissing it does not delete progress; the flow remains available under /setup.