Skip to content

Testing and Verification ​

LatticeDX separates verification into two tiers: offline deterministic checks (TypeScript compilation, unit tests, plugin contract suites, natural-language routing evaluation, and supply-chain verification) and live integration checks executed against running Docker Compose stacks (tenant isolation, OIDC login, ClamAV scanning, NGSI-LD sync, and recovery drills).

Verification Matrix ​

Verification LayerRunner / ScriptRequires Running ServicesScope
Typecheck, Unit & Buildpnpm check (tsc, vitest)NoValidates TypeScript types across @dx/* workspaces, runs Vitest unit tests, and builds packages.
Plugin Contracts & Recovery Scriptsnode --testNoVerifies domain rules, 56 RLS tables, FEEL/DMN evaluators, OTel exporter, PKI ledger, and backup scripts.
Vietnamese NL Router Evaleval-vietnamese-nl-agent.mjsNoEvaluates routing accuracy across 20 unified tools and adversarial prompt-injection refusals.
Source & Supply-Chain Gatessource-headers.mjs, pof:check, release:sbomNoEnforces Apache-2.0 SPDX headers, Pure-OSI isolation checks, CycloneDX SBOM freshness, and pnpm audit.
Live Stack Readiness & E2Elocal:doctor, smoke-*.mjs, acceptance-*.mjsYes (Docker Compose)Exercises end-to-end flows through APISIX, Keycloak, nocobase, PostgreSQL 16, ClamAV, Orion-LD, and Mosquitto.

Offline Verification (Unit, Contract, and AI Evaluation) ​

Static checks and contract suites execute directly on Node.js 24 and pnpm 10.23.0 without starting Docker containers, making them suitable for fast pre-commit and pre-PR validation.

bash
pnpm typecheck
pnpm test
pnpm build
# Or run all three sequentially
pnpm check

Vietnamese Natural-Language Routing Evaluation ​

scripts/eval-vietnamese-nl-agent.mjs invokes parseVietnameseNaturalIntent in plugin-dxos-ai across seven behavioral test categories:

Eval CategoryTarget Tool / BehaviorAcceptance Criterion
rag-searchdxos_search_enterprise_contextRoutes SOP lookups, cold-chain queries, order searches, and asset checks.
workflow-tasksdxos_my_workflow_tasksResolves pending approval queues and delivery confirmation task lists.
orchestrationdxos_orchestrate_enterprise_caseTriggers cross-department bottleneck radar and SLA summary runs.
alarm-opsdxos_alarm_actionDistinguishes action: ack (acknowledgment) from action: clear (closure).
creative-architectdxos_design_creative_block, dxos_compose_page_blocksExtracts widgetType, alert thresholds, and layout placement for isAdmin: true.
admin-provision / admin-rollbackdxos_provision_role_workspace, dxos_snapshot_or_rollback_pageLocks specified columns and restores prior portal UI snapshots.
security-refusalExplicit refusal (refused: true)Blocks .env reads, AGENT_API_KEY extraction, DROP TABLE/UNION SELECT, and unauthorized admin calls.

Passing --min-pass=95 requires an aggregate pass rate of at least 95% to exit 0.

PostgreSQL 16 FORCE RLS Isolation Verification ​

Tenant isolation is verified at two levels:

  1. Contract-level (m1-rls-security.test.cjs and pg-rls-and-observability.test.cjs): verifies the registry of 56 static tables (54 camelCase tables keyed on "organizationId" and 2 snake_case tables lattice_native_request_attachments and lattice_native_request_uploads keyed on "organization_id"), tests assertSafeSqlIdentifier, and asserts that repository queries inside a mock Sequelize tracker execute under transaction-local set_config('app.current_org', :orgId, true) or set_config('app.rls_bypass', 'on', true) with SAVEPOINT isolation.
  2. Database-level: queries pg_class and pg_policies directly under the nocobase_app (NOSUPERUSER NOBYPASSRLS) runtime role to verify that every static and dynamic (latticeCustom*) tenant table enforces FORCE ROW LEVEL SECURITY.
bash
node --test plugins/nocobase/plugin-lattice-foundation/tests/m1-rls-security.test.cjs plugins/nocobase/plugin-lattice-foundation/tests/pg-rls-and-observability.test.cjs

Live Stack Integration and End-to-End Suites ​

After starting the local Compose stack (pnpm local:up or docker compose -f infra/compose/core.yml -f infra/compose/nocobase.yml up -d), smoke-* and acceptance-* scripts execute real HTTP workflows through APISIX (http://localhost:8080), Keycloak (http://localhost:8081), and NocoBase (http://localhost:13000).

Integration Verification Scripts in package.json
ParameterTypeDefaultDescription
pnpm local:doctor
script—Non-mutating loopback readiness check for API (/ready), Keycloak OIDC discovery, and NocoBase; supports --integration and --agent flags.
pnpm test:foundation
script—Verifies task lifecycle, optimistic concurrency (409), org-a/org-b isolation, clean ClamAV upload, and EICAR rejection.
pnpm test:nocobase
script—Validates NocoBase host boot, loading of all 7 @latticedx/* plugins, and core routing.
pnpm test:scanner-outage
script—Verifies fail-closed file upload behavior when ClamAV or file-scanner is unavailable.
pnpm acceptance:logistics-rbac
script—Exercises Cold-Chain OMS/WMS flows, FEFO lot allocation, ePOD verification, and role-based access control.
pnpm acceptance:dxos-ai-mcp
script—Verifies AI Studio runs, MCP JSON-RPC (/api/dxos-mcp), quota tracking, and trace auditing.
pnpm acceptance:headless-paas
script—Validates scoped ldx_pat_* API keys, Ed25519/Merkle ledger verification, and OpenAPI/AsyncAPI specs.
pnpm acceptance:broker-automation-builder
script—Exercises IIoT telemetry ingestion, LatticeFlow DAG rules, and App Builder operations.
pnpm test:native-recovery
script—Executes backup, MD5 row-fingerprint comparison, and isolated restore verification for nocobase-db.

Note on AI worker scripts: pnpm test:agent-provider and pnpm test:agent-worker-live require .env.agent with a configured provider key; all other integration scripts run against the default local configuration in .env.example.

Non-Mutating Readiness Checks with pnpm local:doctor ​

scripts/check-local.mjs issues read-only HTTP GET metadata probes (no authentication, no writes, and no model calls) against loopback endpoints with a 3000ms timeout per service:

json
{
  "scope": "service-readiness",
  "ok": true,
  "businessFlowsVerified": false,
  "checks": [
    { "service": "engine", "status": "ready", "httpStatus": 200 },
    { "service": "keycloak", "status": "ready", "httpStatus": 200 },
    { "service": "nocobase", "status": "ready", "httpStatus": 200 }
  ]
}

Pass --integration to include orion-ld (:1026/version) and n8n (:5678/healthz) before executing pnpm test:ngsi-ld-postgres or pnpm test:incident-agent.

CI, Compose Validation, and Supply-Chain Gates ​

.github/workflows/ci.yml executes four independent jobs on every push and pull request targeting main:

CI JobChecks & Verification Scope
checkRuns pnpm check, node scripts/source-headers.mjs --check, pnpm pof:check, pnpm release:sbom -- --check, eval-vietnamese-nl-agent.mjs --min-pass=95, brand naming checks, and all node --test suites.
dependency-auditRuns pnpm audit --prod --audit-level=low to verify zero known vulnerabilities across production dependencies.
compose-validateRuns docker compose config --quiet across every stack under infra/compose/ (core.yml, nocobase.yml, native-rehearsal.yml, integration.yml, native-files.yml, uc1-sample.yml, iiot.yml, and prod.yml with all profiles enabled).
trivy-scanRuns aquasecurity/trivy-action for CRITICAL and HIGH vulnerabilities, misconfigurations, and leaked secrets.

Six Checks in scripts/verify-pof-readiness.mjs (pnpm pof:check) ​

  • spdx-headers: Confirms all first-party source files carry SPDX-License-Identifier: Apache-2.0.
  • governance-files: Verifies required licensing and governance documents (LICENSE, NOTICE, COPYRIGHT.txt, CONTRIBUTING.md, SECURITY.md, and build documentation).
  • plugin-isolation: Confirms all 7 plugins declare "sdkProvidedByHost": true and avoid bundling external host runtime code.
  • compose-digests: Confirms every image: entry in infra/compose/*.yml pins an immutable @sha256:... digest.
  • upstream-clean: Confirms .gitmodules and upstream/nocobase are absent from the repository tree.
  • no-secrets: Scans tracked files for API token patterns and PEM private key headers.
bash
node scripts/source-headers.mjs --check
pnpm pof:check
pnpm release:sbom -- --check
pnpm audit --prod --audit-level=low

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