Skip to content

Package manifest

matrix.json is the single authoritative manifest for a Matrix package. The CLI validator at projects/matrix-3/packages/mx-cli/src/utils/manifestValidator.ts defines exactly what is required and what is optional. This page walks every field that validator inspects.

Validate any time

bash
mx validate                        # validates ./matrix.json (or package.json.matrix)
mx validate ./path/to/matrix.json
mx validate --json

Source: packages/mx-cli/src/commands/validate.ts:72-94.

Required fields

These are the fields without which the validator emits an error:

PathTypeValidator code
namenon-empty stringMXPKG_NAME_INVALID
versionnon-empty stringMXPKG_VERSION_INVALID
runtime.languagenon-empty stringMXPKG_RUNTIME_INVALID
runtime.entrynon-empty stringMXPKG_RUNTIME_INVALID
permissions.fsPolicyone of none, matrix-only, project-readonly, project-readwrite, global-readonlyMXPKG_PERMISSIONS_FSPOLICY_INVALID
componentsarray (may be empty)MXPKG_COMPONENTS_NOT_ARRAY

The minimum legal matrix.json:

json
{
  "name": "@my-org/my-package",
  "version": "0.1.0",
  "runtime": { "language": "typescript", "entry": "dist/index.js" },
  "components": [],
  "permissions": { "fsPolicy": "none" }
}

Optional top-level fields

FieldTypePurpose
descriptionstringHuman-readable description
classstringHigh-level shape tag, e.g. "hybrid" (chat uses this)
namespacestringLogical mount namespace, e.g. "system", "chat"
rootobjectSingle root actor declaration; alternative or supplement to components[]
webappobjectWeb app surface declaration — see App surfaces
httpobjectHTTP routes the gateway should attach to this runtime
consumesarrayService contracts the package depends on
exportsarrayLogical mounts this package promises to provide
configobjectConfig schema/defaults/providers — see Config contract
installobjectInstall lifecycle hooks (validate, migrate, seed, verify)

Component declarations (components[])

Each entry of components[] describes one actor class. Validator rules (manifestValidator.ts:158-244):

FieldRequiredTypeValidator code
typeyesnon-empty stringMXPKG_COMPONENT_TYPE_INVALID
exportnonon-empty string when presentMXPKG_COMPONENT_EXPORT_INVALID
mountnonon-empty string when presentMXPKG_COMPONENT_MOUNT_INVALID
autoStartnobooleanMXPKG_COMPONENT_AUTOSTART_INVALID
propsnoobjectMXPKG_COMPONENT_PROPS_INVALID
fsPolicynosame enum as top-level permissions.fsPolicyMXPKG_COMPONENT_FSPOLICY_INVALID

Real example, from packages/system/matrix.json:

json
{
  "type": "RuntimeManagerActor",
  "export": "RuntimeManagerActor",
  "mount": "system.runtimes",
  "autoStart": true,
  "surface": "headless",
  "description": "Physical runtime inventory and lifecycle control",
  "accepts": [
    "runtimes.ps", "runtimes.list", "runtimes.status",
    "runtimes.instances", "runtimes.reconcile",
    "runtimes.start", "runtimes.stop", "runtimes.reload"
  ]
}

surface, description, accepts, and emits on a component are not enforced by the CLI validator today but are read by introspection tools and by the discovery extractor (packages/mx-cli/src/utils/discovery-extractor.ts).

Install lifecycle hooks

matrix.json:install.<phase>.script declares scripts that mx install runs in order. Each phase entry must be an object with a script field:

json
{
  "install": {
    "validate": { "script": "scripts/validate-install.js", "description": "Check prerequisites" },
    "migrate":  { "script": "scripts/migrate.js" },
    "seed":     { "script": "scripts/seed.js" },
    "verify":   { "script": "scripts/verify.js" }
  }
}

Phases run in this order: validate, migrate, seed, verify. See Installing → Dependency resolution.

permissions object

json
{
  "permissions": {
    "fsPolicy": "global-readonly",
    "hostApi": "same-origin",
    "network": true,
    "subprocess": false,
    "env": true
  }
}
FieldValidator
fsPolicy (required)none, matrix-only, project-readonly, project-readwrite, global-readonly
hostApi (optional)none, same-origin
networkboolean
subprocessboolean
envboolean

The current validator only enforces shape. Runtime enforcement is target state — see Capability declarations.

Identity coupling: matrix.json vs package.json

packages/mx-cli/src/utils/package-store.ts enforces that the name in matrix.json agrees with package.json.name, modulo scope alias between @matrix/ and @open-matrix/. The version is read from package.json, not matrix.json, by mx publish and mx install (readVersionFromPackageDir).

Caution: Keep matrix.json:version and package.json:version in sync. Today only package.json drives publishing, but the manifest validator still requires a non-empty matrix.json:version. Mismatches mislead readers and confuse audit tools.

See also

Source: projects/matrix-3/packages/mx-cli/src/utils/manifestValidator.ts is the live validator. mx validate reports diagnostics from this module verbatim.