Skip to main content

Module init

Module init 

Source
Expand description

Engine boot sequence (v0.1.2 — schema/ATTACH layout).

Implements the 8-step boot sequence from plan 14:

  1. Open engine storage (PG: connect; SQLite: create data_dir + open a router connection that ATTACHes one file per module)
  2. Apply engine schema migrations (creates engine.modules, engine.audit, engine.instances, engine.migrations)
  3. Read engine.modules — on first boot seed it from the running build’s compile-time modules; on subsequent boots just SELECT enabled modules
  4. For each enabled module: PG CREATE SCHEMA IF NOT EXISTS <m> or SQLite ensure-attached, then run module migrations
  5. Wire trait routing — handled by callers (engine binary builds the WorkflowStore against the prepared pool)
  6. Engine-level multi-node coordination:
    • PG: pg_try_advisory_lock(1) for leader election (existing path)
    • SQLite: engine.lock single-row exclusive (existing path)
    • Insert into engine.instances on startup, refresh on timer, DELETE on graceful shutdown
  7. Mount HTTP routers from each enabled module (caller wires them)
  8. Start scheduler, workers, etc. (caller wires them)

EngineBoot returns the prepared pool(s), the engine-events bus, the instance id, and the list of enabled modules — everything callers need to compose WorkflowStore, WorkflowCtx, and the HTTP router.

Structs§

BuiltinModule
One row to seed into engine.modules on first boot. default_enabled = false means operators must flip it to TRUE before its migrations run — used for opt-in modules like auth so existing v0.1.2 deployments don’t get unexpected schema changes.
PgBoot
SqliteBoot

Enums§

EngineBoot
Result of the engine boot sequence — the parts each backend wired up. The engine binary uses these to compose its WorkflowStore / WorkflowCtx / HTTP router.

Functions§

builtin_modules
Built-in modules implied by the running build’s compile-time features.