Skip to content

Sync Pipeline ​

The sync pipeline projects Core's reflection-based metadata into the SDK's sdk_* database tables. It is the write half of the platform invariant: the registry projects metadata at sync time; the database serves authorization at request time.ui5:sync is the act that moves data from the first to the second.

ui5:sync is mandatory. Runtime authorization reads the database, not the registry. An un-synced install has no grants. Run ui5:sync on every deploy.

What gets synchronized ​

Eight workers run in FK-dependency order:

OrderWorkerSourceTarget table
1ArtifactsWorkerUi5Registry artifactssdk_artifacts
2SlotsWorker#[Slot] declarationssdk_slots
3SettingsWorker#[Setting] declarationssdk_settings
4AbilitiesWorker#[Access], #[Act], See and #[Read] abilitiessdk_abilities
5RolesWorker#[Role] attributessdk_roles
6CustomizingWorker#[CustomizingEntry] catalogseach declared catalog table
7InstallationWorkerApp\Installation, the SDK's platform ownersdk_partners, sdk_partner_relationships
8ScopeConformanceWorker#[ContributesScope] contributionsnone (validation only)

Artifacts come first because later workers reference them; roles depend on abilities. CustomizingWorker reconciles each code-owned catalog table to its declared set. InstallationWorker checks that the operator App\Installation names exists on OperatorAdmin — otherwise it stops the sync, naming ui5:intake — and writes Pragmatiqu IT and its support department as the SDK declares them, the department owned by the organisation; it runs after the catalogues because that owns needs its type. ScopeConformanceWorker persists nothing: it checks that every contributed value-help scope projects the value help's declared entity type, and reports every mismatch as a blocker. SyncService runs the workers in the order of SyncWorkerCollectorInterface, each through the unit-of-work runner.

Invocation ​

bash
php artisan ui5:sync

Check without writing — every blocker, with the object that blocks and the app to clear it in:

bash
php artisan ui5:ready

ui5:sync runs the same check first and does not start while a blocker stands. Since SDK 2.0 there is no --dry.

A deploy runs the steps in this order:

bash
php artisan migrate --force
php artisan ui5:intake   # first deploy: the operator and app/Installation.php; idempotent
php artisan ui5:sync
php artisan ui5:cache    # production only, see below
php artisan ui5:tenant   # once per database, after the first sync

The command contract ​

ui5:sync is the one public surface of this domain, and it is Stable (soft-freeze): changes are additive and announced. Its contract:

  • The readiness check first. Before it writes anything, ui5:sync runs every worker in one transaction, rolls it back and collects every blocker — a row the code no longer declares that data people entered still uses. While one stands, it lists them and writes nothing. ui5:ready runs the check alone.
  • One transaction per worker. After a clean check, each worker commits on its own; a failure stops the sync, the workers before it stay applied, and the next run picks up from there.
  • Idempotent + ordered. Each worker reconciles its slice insert → update → delete, keyed on its natural identity. Re-running converges; it never duplicates.
  • The check does not branch every write — workers write through the wrapping transaction (so a later worker's FK lookups resolve against rows an earlier worker just staged), and the check rolls it back at the end.
  • Fails loud. On a worker failure the command reports a concise error (which worker, what message — no stack trace) and exits non-zero. A broken sync never passes silently.
  • Builds from the live SdkRegistry. If config('ui5.registry') is the cached registry, the command reaches past the binding to the live one.

Prerequisite — run ui5:intake first ​

ui5:sync runs as the automation actor — by default Pragmatiqu IT's support department — and checks the operator. ui5:intake writes both, so it must run before the first ui5:sync. It is idempotent and keyed on the operator's e-mail; a host has exactly one operator. A default setting carries no set_by: it is the declaration's value, not a person's write. See Installation and Tenant.

After sync — ui5:cache ​

In production, ui5:cache bakes the sync-assigned sdk_abilities ids into bootstrap/cache/ui5.php, so it must run after ui5:sync. Run before sync, it fails loud. Like ui5:sync, it builds from the live SdkRegistry whatever is bound (it owns exportToCache()).

Prerequisite — register the morph map ​

RolesWorker dissolves a scoped role declaration into a stable morph key at sync time. When a role is declared with a model context —

php
#[Role(role: 'key_account', note: 'Key account manager for one customer', scope: Customer::class)]

— the worker resolves Customer::class through Laravel's Relation::morphMap() to the registered alias (e.g. customer) and stores that key, not the FQCN.

This means the host must register its morph map before running ui5:sync. If a scoped model is not in the morph map, the worker falls back to storing the raw FQCN — which works, but silently couples your stored role scopes to a class path that breaks if the class ever moves. Register the morph map in a service provider:

php
// AppServiceProvider::boot()
use Illuminate\Database\Eloquent\Relations\Relation;

Relation::morphMap([
    'customer' => \App\Models\Customer::class,
    // …every model used as a #[Role] / #[Scoped*] context
]);

See Scoped Entity Sets and Role Scope for the read side of the same morph keys.

A module adds its own workers ​

Since SDK 2.0 the pipeline is open. A worker implements Sync\Contracts\SyncWorkerInterface — a unit of work: it takes the registry it mirrors as a constructor parameter named $registry, seals its transaction with a report, and leaves the readiness check to the command. It is declared in its module like any unit of work, and placed in the order through the collector in the module's service provider:

php
$this->app->afterResolving(SyncWorkerCollectorInterface::class, function (SyncWorkerCollectorInterface $workers) {
    $workers->after(RolesWorker::class, DunningLevelsWorker::class);
});

A row the code no longer declares but people's data still uses is a blocker: the worker keeps the row, reports it with the object as its target, and finishes the rest. SyncService itself stays internal. Each worker is a unit of work; the code-owned ones are catalogue units and write no positions to the audit.