Blueprint & Codeblocks

Minerva isolates custom business logic within Codeblocks. A codeblock is a secure snippet of TypeScript authored by you or AI Commander, stored directly in the Blueprint, and executed dynamically.

The Execution Pipeline

When a codeblock needs to run, Minerva:

  1. Resolves the codeblock location in the Blueprint
  2. Generates typed virtual data.d.ts and external.d.ts files
  3. Compiles and lints the code
  4. Executes the result in a fresh QuickJS sandbox
  5. Validates the return value against strategy rules

Host Functions

The sandbox injects asynchronous host functions via the global query object:

  • query.listRecords(...)
  • query.getRecord(...)

By default, these run within the requestor scope so RBAC and field redaction are enforced.

Common Codeblock Types

  • CUSTOM / FORM
  • DOMAIN_VALIDATOR
  • IMPORT_TRANSFORM / EXPORT_TRANSFORM
  • AUDIENCE_MATRIX
  • MESSAGE_TEMPLATE
  • WEB_AUTOMATION

CEL Expressions

For simpler logic, Minerva uses CEL rather than full TypeScript. CEL is a good fit for permission conditions, record labels, notification subjects, and lightweight Dynamic UI expressions.

Choosing Between CEL and TypeScript

Use CEL when you need a single expression. Use TypeScript when you need async work, branching, iteration, or a full UI or HTML output.