Skip to content

7-Plugin Architecture & Host Contract ​

LatticeDX v0.4.2 delivers all platform capabilities through seven independent NocoBase plugins under plugins/nocobase/*. This architecture keeps the Apache-2.0 source tree isolated from the NocoBase host runtime: nocobase/nocobase:2.2.50 runs as an external OCI container and mounts the plugins under sdkProvidedByHost: true.

7 Apache-2.0 Plugins & NocoBase 2.2.50 Host Contract
BUILD STAGE · ESBUILD 0.28.2 & NOCOBASE-EXTERNALS.MJSRUNTIME STAGE · EXTERNAL OCI CONTAINER (:RO MOUNT)StripBundleMount :ro7 @latticedx/*SourcesApache-2.0 · v0.4.2sdkProvidedByHost: trueHost Externals(Stripped)7 @nocobase/* packagesReact 18.2 · AntD 5.24Bundled Pure-OSILibsopenid-client@6.8.9maplibre · @xyflow/reactCompiled dist/*server · client ·client-v2externalVersion.jsNocoBase 2.2.50 Hostnode_modules/@latticedx/*Resolves Host SDKPG16 & Valkey 8.1nocobase_app · 56+ RLSValkey DB 0 / 1 / 2
InspectorHost Externals (Stripped)Click any component to inspect bindings & boundaries
Role
Host Vendor & SDK Externals (Stripped at Build)
Package / Port
scripts/lib/nocobase-externals.mjs
Protocol
react@18.2.0 · antd@5.24.2 · 7 @nocobase/*
Payload / Schema
Stripped at build time (externalized)
Responsibilities
Marks React, AntD, and all 7 @nocobase/* SDK packages external so esbuild strips them and resolves symbols from the host container.
All seven @latticedx/* plugins compile under sdkProvidedByHost: true (stripping @nocobase/*, React 18.2, and AntD 5.24 while bundling Pure-OSI libs), mount read-only (:ro) into external nocobase/nocobase:2.2.50, and preserve Powered by NocoBase attribution under Clause 5.2.

Inventory of the 7 @latticedx/* Plugins (0.4.2) ​

Every package declares "version": "0.4.2", "private": true, "license": "Apache-2.0", "supportedVersions": ["2.2.x"], "testedRuntime": "2.2.50", and "sdkProvidedByHost": true, along with its own LICENSE and README.md.

#Directory (plugins/nocobase/)Package Name (package.json)Server & Client EntrypointsBuild Strategy & Host Externals
1action-bridge/@latticedx/plugin-action-bridgeserver.cjs, client.js, client-v2.jsbuild.mjs copies src/ to dist/ and writes dist/externalVersion.js for @nocobase/server, @nocobase/client, @nocobase/client-v2
2plugin-lattice-foundation/@latticedx/plugin-lattice-foundationdist/server/index.js (LatticeFoundationPlugin), client.js, client-v2.jsscripts/build.mjs syntax-checks JS via node --check, bundles relative client imports with a zero-dep loader, and externalizes NocoBase SDK packages, react, and antd
3plugin-enterprise-auth/@latticedx/plugin-enterprise-authdist/server/index.js (EnterpriseLoginPlugin), client.js, client-v2.jsBundles openid-client@6.8.9 via bundleDependencies; externalizes @nocobase/server, @nocobase/auth, @nocobase/plugin-auth, @nocobase/client, @nocobase/client-v2, react, and antd
4plugin-dxos-para/@latticedx/plugin-dxos-paradist/server/index.js (DxosParaPlugin), client.js, client-v2.jsbuild.mjs copies src/ to dist/; executes Office/PDF extraction and pgvector HNSW + tsvector RRF search via host @nocobase/database
5plugin-dxos-blocks/@latticedx/plugin-dxos-blocksdist/server/index.js (DxosBlocksServerPlugin), client.js, client-v2.jsUses esbuild@0.28.2 to bundle maplibre-gl@6.19.0 (including CSS and worker) into UMD client bundles; registers 12 Native v2 BlockModels and dxosBlocks / dxosBroker
6plugin-dxos-studio/@latticedx/plugin-dxos-studiodist/server/index.js (DxosStudioPlugin), client.js, client-v2.jsUses esbuild@0.28.2 to bundle @xyflow/react@12.12.1 and @dagrejs/dagre@3.1.3 into UMD client bundles for LatticeFlow v2, Visual DMN, WMS, Rich Schema, and n8n bridge
7plugin-dxos-ai/@latticedx/plugin-dxos-aidist/server/index.js (DxosAiPlugin), client.js, client-v2.jsbuild.mjs bundles relative client modules; registers 7 AI Profiles, 20 Unified Tools, Streamable HTTP MCP gateway, A2A gateway, and proactive triage scheduler

Resource Ownership & Gateway Routes per Plugin ​

All server APIs are registered via this.app.resourceManager.define(...) or Gateway.registerRequestHandler(...) along clean plugin boundaries:

Owning PluginresourceManager.define ResourcesGateway Handlers & Guard Middleware
plugin-action-bridgedxActions (13 actions)Server-side PKCE linking proxy for /lattice/* (fails closed with HTTP 503 when DX_BRIDGE_* env vars are unset)
plugin-lattice-foundationdxos, dxosApiKeys, dxosLedger, dxosDataGov, dxosVault, dxosEvents, dxosApprovals, dxosNotify, dxosForms, latticeNative, latticeApps, latticePortals, latticeChatter, latticeVoucher, latticeNotifications, latticeSla, latticeContextSync, latticeIntegrationsGateway.registerRequestHandler: /v/form/*, /v/track/*, /v/lattice-brand.svg, /v/mobile
plugin-enterprise-authenterpriseAuth (9 actions)lattice-keycloak authenticator + enterpriseAuthRevocationGuard middleware
plugin-dxos-paralatticePara (6 actions)P.A.R.A. organization scope middleware + runAfterCommit vector chunk retry handler
plugin-dxos-blocksdxosBlocks (17 actions), dxosBroker (10 actions)dxosTelemetryDirectGuard blocking raw CRUD on latticeTelemetryPoints, latticeTwinShadows, latticeIotDevices
plugin-dxos-studiodxosStudio, dxosWms, dxosDmn, dxosDelegations, dxosAutomations, dxosBuilder, dxosN8nFour guard middlewares (dxosServiceScope, dxosWmsDmnScope, dxosAutomationScope, dxosOrganizationScope)
plugin-dxos-aidxosAi (AI Assistant, App Builder 2.0, Eval Lab, surfaceEvents)POST /api/dxos-mcp, POST /api/dxos-mcp/it-ot, GET /.well-known/agent-card.json, POST /api/dxos-a2a

Host Contract (sdkProvidedByHost: true) & nocobase-externals.mjs ​

Rather than vendoring @nocobase/* packages into the workspace node_modules, every plugin declares host SDK packages and shared frontend libraries as externals. At container startup, nocobase/nocobase:2.2.50 resolves those imports directly from the host image runtime.

Host Externals & Version Contract (scripts/lib/nocobase-externals.mjs)
ParameterTypeDefaultDescription
DEFAULT_NOCOBASE_VERSIONrequired
string2.2.50Default NocoBase runtime version embedded in dist/externalVersion.js when NOCOBASE_VERSION is unset.
NOCOBASE_VERSION
env (SemVer)2.2.50Optional environment override validated against SEMVER_RE before generating external metadata.
NOCOBASE_EXTERNAL_NAMESrequired
string[7]2.2.50@nocobase/server, @nocobase/auth, @nocobase/plugin-auth, @nocobase/database, @nocobase/client, @nocobase/client-v2, @nocobase/plugin-workflow.
SHARED_VENDOR_VERSIONSrequired
object18.2.0 / 5.24.2Host-provided frontend vendor packages: react (18.2.0), react-dom (18.2.0), and antd (5.24.2).

externalVersionSource(names, options) in scripts/lib/nocobase-externals.mjs validates every requested package against the allowlist (Object.hasOwn(versions, name)), rejects any undeclared host dependency, and writes dist/externalVersion.js with an SPDX-License-Identifier: Apache-2.0 header.

json
{
  "name": "@latticedx/plugin-lattice-foundation",
  "version": "0.4.2",
  "private": true,
  "license": "Apache-2.0",
  "main": "dist/server/index.js",
  "nocobase": {
    "supportedVersions": ["2.2.x"],
    "testedRuntime": "2.2.50",
    "sdkProvidedByHost": true
  }
}

Server Plugin Lifecycle Hooks & Middleware Ordering ​

Each server plugin extends Plugin from @nocobase/server and implements deterministic lifecycle hooks covering registration, idempotent seeding, startup repair, and clean teardown.

Lifecycle HookExecution PhaseStandard Behavior Across @latticedx/*
load()Plugin loading into Koa & ResourceManagerRegisters collections, binds this.db.attachLatticeRlsPolicy, calls resourceManager.define, grants acl.allow / acl.registerSnippet, installs ordered middleware, registers Gateway.registerRequestHandler, attaches db.on hooks, and initializes schedulers (_delayTicker, _triageScheduler).
install()Initial plugin installationRuns idempotent database seeding under withSystemRlsBypass (seedFoundation, ensureDefaultAiWorkforce, runStartupRepairs).
afterEnable()Re-enabling an existing pluginReconciles role action grants (ensureIncidentManagerGrants), starter AI profiles (forceUpdate: false), and route/SLA repairs without overwriting admin edits.
start()Application boot completionRuns idempotent startup grants and repairs (ensureIncidentManagerGrants, runStartupRepairs, alongside this.app.once('afterStart', ...)).
unload() / remove() / destroy()Reload, disable, or shutdownStops eventBusDrainer, clears stopAutomationListener() timers, flushes _otelExporter.shutdown(), stops _triageScheduler, and calls Gateway.unregisterRequestHandler to prevent leaked listeners.

Middleware Execution Order & DB Event Hooks ​

Middleware registration uses explicit before and after anchors so authentication, direct-CRUD guards, and RLS transaction scoping execute in strict sequence:

Anchor / Hook StageRegistered Components & Enforcement
Before auth (before: 'auth')latticePaasApiKeyAuth parses X-Lattice-API-Key or Authorization: Bearer ldx_pat_* tokens and populates ctx.state.currentUser before session auth runs.
After auth (after: 'auth')enterpriseAuthRevocationGuard checks revoked: and revoked_sid: entries in Valkey DB 2.
After acl, before latticeNativeScope (after: 'acl', before: 'latticeNativeScope')Domain guard middlewares (dxosTelemetryDirectGuard, dxosServiceScope, dxosWmsDmnScope, dxosAutomationScope, dxosOrganizationScope, dxosAiProfileScope, dxosAiHitlScope, dxosAiMemoryAndA2aScope) reject unauthorized direct collection queries before latticeNativeScope opens the RLS transaction.
After dataWrapping, before dataSource (before: 'dataSource', after: 'dataWrapping')dxosMcpGateway, dxosA2aAgentCard, and dxosA2aGateway intercept Streamable HTTP MCP JSON-RPC and A2A discovery requests.
DB lifecycle hooks (this.db.on)latticeServiceTickets.beforeValidate, WMS_DMN_COLLECTIONS .beforeValidate, latticeAiProfiles.beforeValidate (preventing builder role escalation and SSRF in mcpServers), roles.afterCreate (stripping auto-granted roles from Builder AI profiles), and llmServices.afterSave (rebinding starter agents to updated LLM services).

Guard Middleware & DB Event Hook Reference ​

Guard / HookOwning PluginAnchor & Enforcement Behavior
latticePaasApiKeyAuthplugin-lattice-foundationbefore: 'auth' — verifies ldx_pat_* via SHA-256 and clamps effective role below key bounds
enterpriseAuthRevocationGuardplugin-enterprise-authafter: 'auth' — rejects revoked subjects and session IDs tracked in Valkey DB 2
dxosTelemetryDirectGuardplugin-dxos-blocksafter: 'acl', before: 'latticeNativeScope' — blocks raw CRUD on telemetry, twin shadow, and IoT device tables
dxosServiceScope / dxosWmsDmnScopeplugin-dxos-studioafter: 'acl', before: 'latticeNativeScope' — enforces scoped service tickets and requires dxosWms / dxosDmn endpoints
dxosAutomationScope / dxosOrganizationScopeplugin-dxos-studioafter: 'acl', before: 'latticeNativeScope' — blocks raw automation CRUD and restricts latticeOrganizations direct access to root
dxosAiProfileScope / dxosAiHitlScopeplugin-dxos-aiafter: 'acl', before: 'latticeNativeScope' — restricts latticeAiProfiles to admins and blocks direct HITL queue writes
dxosAiMemoryAndA2aScopeplugin-dxos-aiafter: 'acl', before: 'latticeNativeScope' — requires dedicated endpoints for AI memory, A2A tasks, and OTel traces
latticeAiProfiles.beforeValidate & roles.afterCreateplugin-dxos-aiLocks isAdminBuilder roles, validates mcpServers URLs against SSRF, and strips auto-grants on new roles
Gateway.registerRequestHandler (5 handlers)foundation & dxos-aiServes /v/form/*, /v/track/*, /v/lattice-brand.svg, /v/mobile, and /.well-known/agent-card.json; unregistered cleanly on unload()/destroy()
javascript
const { Plugin, Gateway } = require("@nocobase/server");

class CustomLatticePlugin extends Plugin {
  async load() {
    this.app.resourceManager.use(this.guardMiddleware(), {
      tag: "customDomainGuard",
      after: "acl",
      before: "latticeNativeScope",
    });
    this.app.resourceManager.define({ name: "customDomain", actions: this.buildActions() });
    this.app.once("afterStart", () => this.ensureSeeded().catch(() => {}));
  }

  async install() { await this.ensureSeeded(); }
  async afterEnable() { await this.ensureSeeded(); }

  async unload() {
    this.stopTimers();
    if (this._gatewayHandler) {
      Gateway?.unregisterRequestHandler?.(this._gatewayHandler);
      this._gatewayHandler = null;
    }
    if (typeof super.unload === "function") await super.unload();
  }
}

Operational Notes & Client Bundling Boundaries ​

Operational RuleImplementation Details
Immutable read-only mounts (:ro)All seven plugin directories mount read-only inside /app/nocobase/node_modules/@latticedx/*. Build scripts generate dist/externalVersion.js and client bundles ahead of container launch.
Retired module cleanupplugin-lattice-foundation/scripts/build.mjs explicitly unlinks retired files and legacy migrations after copying src/ to dist/, preventing NocoBase auto-discovery from loading stale artifacts during local rebuilds.
Zero-proprietary client bundlingPlugins with only internal relative imports (plugin-lattice-foundation, plugin-dxos-ai) use a small built-in JS module bundler checked by node --check, while plugin-dxos-blocks and plugin-dxos-studio invoke esbuild@0.28.2 (MIT) to bundle maplibre-gl, @xyflow/react, and @dagrejs/dagre into UMD client bundles with react, react-dom, antd, and @nocobase/client* kept external.
Clause 5.2 attribution preservedclient and client-v2 navigation surfaces keep Powered by NocoBase, version v2.2.50, https://www.nocobase.com, and License settings intact.

Shared Static Exports Between Plugins ​

To let downstream plugins (plugin-dxos-studio, plugin-dxos-ai) call shared domain primitives without duplicating logic across packages, the core plugin classes attach static helpers directly on their exported Plugin constructors:

  • LatticeFoundationPlugin: exposes appendLedgerEntrySafely, computeMeanKineticTemperature, recordLineageEdge, captureQuarantineRecord, publishDomainEvent, verifyStandardWebhookSignature, resolveConnectorSecrets, recordGenAiSpan, startGenAiSpan, persistGenAiTrace, dispatchOmnichannel, requestApproval, and decideUnifiedInboxItem.
  • DxosStudioPlugin: exposes parseFormulaAst, evaluateFormulaExpression, validateFormulaExpression, validateSafeRegexPattern, registerRichSchemaHooks, alignPortalOverviewRoutesSort, normalizeLegacySlaEscalateRoles, and createOrganizationDirectGuardMiddleware.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)